From 2712b8a77b7adcb30f5430448b76d8c49cd7ef12 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 21:04:58 +0100 Subject: [PATCH 01/66] UnitsNet: 5.0.0-alpha001 --- CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.AmountOfSubstance.nuspec | 2 +- .../UnitsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- .../UnitsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- .../ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../BitRate/UnitsNet.NanoFramework.BitRate.nuspec | 2 +- ...UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- ...nitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec | 2 +- .../Density/UnitsNet.NanoFramework.Density.nuspec | 2 +- .../Duration/UnitsNet.NanoFramework.Duration.nuspec | 2 +- .../UnitsNet.NanoFramework.DynamicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricAdmittance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCharge.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec | 2 +- .../ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricInductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotential.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialAc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialDc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistivity.nuspec | 2 +- ...UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../Entropy/UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- .../UnitsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../Frequency/UnitsNet.NanoFramework.Frequency.nuspec | 2 +- .../UnitsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec | 2 +- .../Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../Information/UnitsNet.NanoFramework.Information.nuspec | 2 +- .../Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- .../UnitsNet.NanoFramework.KinematicViscosity.nuspec | 2 +- .../LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec | 2 +- .../GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- .../LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- .../LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.LuminousIntensity.nuspec | 2 +- .../MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec | 2 +- .../MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- .../Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- .../UnitsNet.NanoFramework.MassConcentration.nuspec | 2 +- .../MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- .../MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- .../UnitsNet.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- .../MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../Molarity/UnitsNet.NanoFramework.Molarity.nuspec | 2 +- .../Permeability/UnitsNet.NanoFramework.Permeability.nuspec | 2 +- .../Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- .../PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../Pressure/UnitsNet.NanoFramework.Pressure.nuspec | 2 +- .../UnitsNet.NanoFramework.PressureChangeRate.nuspec | 2 +- .../GeneratedCode/Properties/AssemblyInfo.cs | 4 ++-- .../GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- .../UnitsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- .../ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalLength.nuspec | 2 +- .../UnitsNet.NanoFramework.RelativeHumidity.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalAcceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffness.nuspec | 2 +- ...UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec | 2 +- .../GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificVolume.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- .../UnitsNet.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../Temperature/UnitsNet.NanoFramework.Temperature.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureDelta.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalResistance.nuspec | 2 +- .../GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec | 2 +- .../UnitsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeConcentration.nuspec | 2 +- .../VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec | 2 +- .../UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 4 ++-- UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs | 4 ++-- .../UnitsNet.WindowsRuntimeComponent.nuspec | 2 +- UnitsNet/UnitsNet.csproj | 4 ++-- 116 files changed, 120 insertions(+), 120 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index bc1c5f961f..fee32eba54 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public override string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 4.102.0 + 5.0.0-alpha001 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index cff0be451c..97c0f95bb2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Acceleration - 4.102.0 + 5.0.0-alpha001 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index 88346cd3b7..f017350ee2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmountOfSubstance - 4.102.0 + 5.0.0-alpha001 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index 3a883f419c..ca740d81ba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmplitudeRatio - 4.102.0 + 5.0.0-alpha001 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index 1f863071e0..bf4f770f2d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Angle - 4.102.0 + 5.0.0-alpha001 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index e6dbba448b..41508535d7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentEnergy - 4.102.0 + 5.0.0-alpha001 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index d759c6b4ec..a4a62cae22 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentPower - 4.102.0 + 5.0.0-alpha001 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index a680f144f6..68d33161ca 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Area - 4.102.0 + 5.0.0-alpha001 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index 792f2db3ba..f74cf189de 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaDensity - 4.102.0 + 5.0.0-alpha001 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index ebbe6222da..8f4b9d1d02 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 4.102.0 + 5.0.0-alpha001 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index 069ad496b0..8feef21d00 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BitRate - 4.102.0 + 5.0.0-alpha001 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 641860f8fa..418c2c70cf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 4.102.0 + 5.0.0-alpha001 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index a4dde2e769..66484b78b3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Capacitance - 4.102.0 + 5.0.0-alpha001 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index 0810911901..e07c29312c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 4.102.0 + 5.0.0-alpha001 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 18efe2e586..09c2a3a30a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Density - 4.102.0 + 5.0.0-alpha001 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index 62312f32e6..ca2ab9a564 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Duration - 4.102.0 + 5.0.0-alpha001 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index ad9cf873eb..04f0e76b59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.DynamicViscosity - 4.102.0 + 5.0.0-alpha001 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index 70d6c5b1d3..c76b4bd344 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricAdmittance - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index ddae8d5912..29dbee7844 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCharge - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index ee1a724637..0842dafc6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 7b543b4b4e..0464fa752a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductance - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index 10e68c5d40..762a37ad07 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductivity - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 3dba253ec3..65c451ac1a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrent - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index 0e2224aa8b..6e3319bf2c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index 5db8d83e9d..f1c2ed2e8e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index 9487bf2830..61898dbad9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricField - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index 99b14a06eb..a1b67c8b3d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricInductance - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index 0e8489497b..0e7a7faa39 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotential - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index 4078f0b5ac..877cafbbd6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 70692eb5b4..5aca5eb6c2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index cc59ca31d3..cdda59a65d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 71dc171dcd..88ab790236 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistance - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index 7b48616728..da26ea304d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistivity - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index f5d882e2d9..8708ae473d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 4.102.0 + 5.0.0-alpha001 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index 7acac4a94c..b2543fcb59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Energy - 4.102.0 + 5.0.0-alpha001 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 6ff59b3c5b..5424a6ea6a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Entropy - 4.102.0 + 5.0.0-alpha001 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index c7fef9bb9b..39a55078a2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Force - 4.102.0 + 5.0.0-alpha001 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index a30d3dcc1b..edc355e757 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForceChangeRate - 4.102.0 + 5.0.0-alpha001 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index eead6be232..f0faeb3fa3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForcePerLength - 4.102.0 + 5.0.0-alpha001 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index b5b8c68c00..797d74f79c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Frequency - 4.102.0 + 5.0.0-alpha001 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index fdeb68e009..728f25e9af 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.FuelEfficiency - 4.102.0 + 5.0.0-alpha001 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index 75292f0c41..c64d071448 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatFlux - 4.102.0 + 5.0.0-alpha001 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index 058bd1c86a..e1d1e8f648 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 4.102.0 + 5.0.0-alpha001 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index ccf3004c1a..0b35d21996 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Illuminance - 4.102.0 + 5.0.0-alpha001 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index 9857f5a3cc..8019c23240 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Information - 4.102.0 + 5.0.0-alpha001 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index 9834a0afbb..c92cd46708 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiance - 4.102.0 + 5.0.0-alpha001 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index 36d1bdd181..fa3ab150ec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiation - 4.102.0 + 5.0.0-alpha001 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index 4fb899795c..5ef0324a26 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.KinematicViscosity - 4.102.0 + 5.0.0-alpha001 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index 01dd168f00..35421f8938 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LapseRate - 4.102.0 + 5.0.0-alpha001 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index 0399936717..b581c84dd4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Length - 4.102.0 + 5.0.0-alpha001 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index a80ac51c6c..8eadc5ab6c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Level - 4.102.0 + 5.0.0-alpha001 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index 3117304400..badfee98d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearDensity - 4.102.0 + 5.0.0-alpha001 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index a287f4d78d..d842f11bfc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearPowerDensity - 4.102.0 + 5.0.0-alpha001 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index d2c47f0f30..549e27defa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Luminosity - 4.102.0 + 5.0.0-alpha001 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 408ba0e8c1..3568f63909 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousFlux - 4.102.0 + 5.0.0-alpha001 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index eb3840c162..5cabd560c8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousIntensity - 4.102.0 + 5.0.0-alpha001 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index 983d6643a5..a872e64472 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticField - 4.102.0 + 5.0.0-alpha001 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 1b96ff337a..4150b36414 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticFlux - 4.102.0 + 5.0.0-alpha001 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index 27b1dca208..9b1893cf68 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Magnetization - 4.102.0 + 5.0.0-alpha001 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index 0b8d882efd..7befed538b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Mass - 4.102.0 + 5.0.0-alpha001 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index 15078471d7..9264204d33 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassConcentration - 4.102.0 + 5.0.0-alpha001 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index fd633bf044..7a26f7f99f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlow - 4.102.0 + 5.0.0-alpha001 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index f9f5027ef3..151a7c2636 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlux - 4.102.0 + 5.0.0-alpha001 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 8d55d69e9a..4fd33472a5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFraction - 4.102.0 + 5.0.0-alpha001 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index f1f53989c7..22742c3af8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 4.102.0 + 5.0.0-alpha001 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index 6a12f4e59e..c04da57229 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEnergy - 4.102.0 + 5.0.0-alpha001 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index c5c119ef09..c4b4772fd4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEntropy - 4.102.0 + 5.0.0-alpha001 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index 51b79e687b..604843a75b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarMass - 4.102.0 + 5.0.0-alpha001 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index a3fc744103..55386675e2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Molarity - 4.102.0 + 5.0.0-alpha001 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 802f12fa08..1e4afdeff7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permeability - 4.102.0 + 5.0.0-alpha001 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index 2bda4ef981..005e87dba3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permittivity - 4.102.0 + 5.0.0-alpha001 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index bb0e0c3721..0373133d25 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Power - 4.102.0 + 5.0.0-alpha001 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 85c1c8405c..dd6f4de43e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerDensity - 4.102.0 + 5.0.0-alpha001 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index 5b5c4531c7..b77b67c0a6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerRatio - 4.102.0 + 5.0.0-alpha001 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 2f24e51daf..60feb536e0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Pressure - 4.102.0 + 5.0.0-alpha001 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index 4d52568885..66848cc0c7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PressureChangeRate - 4.102.0 + 5.0.0-alpha001 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Properties/AssemblyInfo.cs b/UnitsNet.NanoFramework/GeneratedCode/Properties/AssemblyInfo.cs index 014812729d..6f38f65936 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Properties/AssemblyInfo.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Properties/AssemblyInfo.cs @@ -47,8 +47,8 @@ // // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("4.102.0")] -[assembly: AssemblyFileVersion("4.102.0")] +[assembly: AssemblyVersion("5.0.0")] +[assembly: AssemblyFileVersion("5.0.0")] ////////////////////////////////////////////////// // This assembly doens't require native support // diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index 78b288806c..92a093584a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Ratio - 4.102.0 + 5.0.0-alpha001 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index 8e3e37b078..c27dcc9ad6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RatioChangeRate - 4.102.0 + 5.0.0-alpha001 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index 08894bb3cb..34c675c995 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactiveEnergy - 4.102.0 + 5.0.0-alpha001 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 7ba1d3e92f..92207483f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactivePower - 4.102.0 + 5.0.0-alpha001 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index 51664f0b46..948cdf7478 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalArea - 4.102.0 + 5.0.0-alpha001 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 3553af334d..96a41e4585 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalLength - 4.102.0 + 5.0.0-alpha001 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index a71dafd50c..3d81a09d51 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RelativeHumidity - 4.102.0 + 5.0.0-alpha001 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index 4e1253753d..eca4e2c58c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalAcceleration - 4.102.0 + 5.0.0-alpha001 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index 5013368ef1..4c44f24a46 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalSpeed - 4.102.0 + 5.0.0-alpha001 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 432c25e5b0..065f9aab09 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffness - 4.102.0 + 5.0.0-alpha001 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index 0a76197d2f..a968761cea 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 4.102.0 + 5.0.0-alpha001 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index f9e5951f98..ab6c8c6772 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Scalar - 4.102.0 + 5.0.0-alpha001 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 1eb779f5a6..19ac11230e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SolidAngle - 4.102.0 + 5.0.0-alpha001 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index ac11453f41..8aa3457c93 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEnergy - 4.102.0 + 5.0.0-alpha001 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index 97b6995766..6261451101 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEntropy - 4.102.0 + 5.0.0-alpha001 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 0b4d4308cd..721e6e9e38 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 4.102.0 + 5.0.0-alpha001 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index 55ff75c84c..273648ebb3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificVolume - 4.102.0 + 5.0.0-alpha001 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 01ffaf247f..7401e8c85e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificWeight - 4.102.0 + 5.0.0-alpha001 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index 7ff9db34a0..edbf0e44df 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Speed - 4.102.0 + 5.0.0-alpha001 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 9b1acbfc67..255279cf7a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 4.102.0 + 5.0.0-alpha001 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index d4d1c65017..dcc1d731bf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Temperature - 4.102.0 + 5.0.0-alpha001 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 66abf3192d..4fc0a4459b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 4.102.0 + 5.0.0-alpha001 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 52e1441723..11239065e7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureDelta - 4.102.0 + 5.0.0-alpha001 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index b09937024f..19e0399a3a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalConductivity - 4.102.0 + 5.0.0-alpha001 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index 072c5e5782..e3bc85d7cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalResistance - 4.102.0 + 5.0.0-alpha001 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 792e7e17d1..3c6c4eea25 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Torque - 4.102.0 + 5.0.0-alpha001 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index 284a9f14bf..70c6df9db8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TorquePerLength - 4.102.0 + 5.0.0-alpha001 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 314fbfbd27..8986b343cf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Turbidity - 4.102.0 + 5.0.0-alpha001 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index b246929560..669d871275 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VitaminA - 4.102.0 + 5.0.0-alpha001 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index 33b91f0062..7ef24bfddb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Volume - 4.102.0 + 5.0.0-alpha001 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index 2991a64739..2b54b23d67 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeConcentration - 4.102.0 + 5.0.0-alpha001 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index cd5e036fd8..fe5daa4fcd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlow - 4.102.0 + 5.0.0-alpha001 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index adfeff172d..231f74d839 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumePerLength - 4.102.0 + 5.0.0-alpha001 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 75d85eddb6..d1dcef7e23 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 4.102.0 + 5.0.0-alpha001 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 13f0f2e54a..0d34c252d8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 4.102.0 + 5.0.0-alpha001 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index 1f52482594..76ac93cf1c 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -2,7 +2,7 @@ UnitsNet.NumberExtensions - 4.102.0 + 5.0.0-alpha001 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). @@ -18,7 +18,7 @@ - 4.0.0.0 + 5.0.0.0 latest enable UnitsNet diff --git a/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs b/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs index 1f54a6b14c..86bf33263c 100644 --- a/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs +++ b/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs @@ -17,6 +17,6 @@ [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] [assembly: NeutralResourcesLanguage("")] -[assembly: AssemblyVersion("4.102.0")] -[assembly: AssemblyFileVersion("4.102.0")] +[assembly: AssemblyVersion("5.0.0")] +[assembly: AssemblyFileVersion("5.0.0")] [assembly: InternalsVisibleTo("UnitsNet.WindowsRuntimeComponent.Tests")] diff --git a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec b/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec index ef8fca7428..7ec22d2949 100644 --- a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec +++ b/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec @@ -2,7 +2,7 @@ UnitsNet.WindowsRuntimeComponent - 4.102.0 + 5.0.0-alpha001 Units.NET - Windows Runtime Component Andreas Gullberg Larsen Andreas Gullberg Larsen diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 0dce98bfd5..a1e5e0f1a1 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -2,7 +2,7 @@ UnitsNet - 4.102.0 + 5.0.0-alpha001 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. @@ -19,7 +19,7 @@ - 4.0.0.0 + 5.0.0.0 latest enable UnitsNet From 618a1d4e3645b0fabb5bdb8437b325c77e23adcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89tienne=20Fortin?= Date: Mon, 1 Nov 2021 16:10:26 -0400 Subject: [PATCH 02/66] CHG: Removed explicit support for net40 and net47. (#981) --- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 4 ++-- .../UnitsNet.Serialization.JsonNet.csproj | 4 ++-- UnitsNet/UnitsNet.csproj | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index 76ac93cf1c..f7700dbc74 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -1,4 +1,4 @@ - + UnitsNet.NumberExtensions @@ -22,7 +22,7 @@ latest enable UnitsNet - netstandard2.0;net40 + netstandard2.0 diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 9e9c8ac759..907ea8d71d 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -1,4 +1,4 @@ - + UnitsNet.Serialization.JsonNet @@ -23,7 +23,7 @@ 4.0.0.0 latest UnitsNet.Serialization.JsonNet - netstandard2.0;net40 + netstandard2.0 diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index a1e5e0f1a1..aaabf86f20 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -1,4 +1,4 @@ - + UnitsNet @@ -23,7 +23,7 @@ latest enable UnitsNet - netstandard2.0;net40;net47 + netstandard2.0 @@ -64,7 +64,7 @@ - + From 93d3b9b209af72d973109b0dcf199632d9713449 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 21:24:59 +0100 Subject: [PATCH 03/66] Fix warning about invalid powershell function name Only a single hyphen per function name allowed. --- Build/build-functions.psm1 | 2 +- Build/build-pack-nano-nugets.psm1 | 4 ++-- build-with-wrc.bat | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Build/build-functions.psm1 b/Build/build-functions.psm1 index a343bfed0e..b810b8ce13 100644 --- a/Build/build-functions.psm1 +++ b/Build/build-functions.psm1 @@ -139,7 +139,7 @@ function Start-PackNugets { write-host -foreground yellow "Skipping nanoFramework nuget pack." } else { write-host -foreground yellow "nanoFramework project not yet supported by dotnet CLI, using nuget.exe instead" - Invoke-Build-NanoNugets + Invoke-BuildNanoNugets } diff --git a/Build/build-pack-nano-nugets.psm1 b/Build/build-pack-nano-nugets.psm1 index 0f4c6f31c8..ef836ae544 100644 --- a/Build/build-pack-nano-nugets.psm1 +++ b/Build/build-pack-nano-nugets.psm1 @@ -2,7 +2,7 @@ $nugetOutDir = "$root\Artifacts\NuGet" $nuget = "$root\Tools\NuGet.exe" -function Invoke-Build-NanoNugets { +function Invoke-BuildNanoNugets { & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\Duration\UnitsNet.NanoFramework.Duration.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" & $nuget pack "$root\UnitsNet.NanoFramework\GeneratedCode\ElectricCurrent\UnitsNet.NanoFramework.ElectricCurrent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" @@ -22,4 +22,4 @@ function Invoke-Build-NanoNugets { } -export-modulemember -function Invoke-Build-NanoNugets +export-modulemember -function Invoke-BuildNanoNugets diff --git a/build-with-wrc.bat b/build-with-wrc.bat index 4e448be121..f1ba255c18 100644 --- a/build-with-wrc.bat +++ b/build-with-wrc.bat @@ -1,2 +1,2 @@ @echo off -powershell -ExecutionPolicy Bypass -NoProfile -File %~dp0\Build\build.ps1 -IncludeWindowsRuntimeComponent -IncludeNanoFramework +powershell -ExecutionPolicy Bypass -NoProfile -File "%~dp0\Build\build.ps1" -IncludeWindowsRuntimeComponent -IncludeNanoFramework From e950084ebd47f5fc6499739f2711eded922a2f52 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 21:25:25 +0100 Subject: [PATCH 04/66] codegen: Fix parsing semver version with suffix in codegen --- CodeGen/Generators/NanoFrameworkGenerator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CodeGen/Generators/NanoFrameworkGenerator.cs b/CodeGen/Generators/NanoFrameworkGenerator.cs index ea21d44749..a61492d970 100644 --- a/CodeGen/Generators/NanoFrameworkGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGenerator.cs @@ -62,7 +62,7 @@ public static void Generate(string rootDir, Quantity[] quantities) var lengthNuspecFile = Path.Combine(outputDir, "Length", "UnitsNet.NanoFramework.Length.nuspec"); var projectVersion = ParseVersion(File.ReadAllText(lengthNuspecFile), - new Regex(@"(?[\d\.]+)", RegexOptions.IgnoreCase), + new Regex(@"(?[\d.]+)(?-[a-z\d]+)?<\/version>", RegexOptions.IgnoreCase), "projectVersion"); foreach (var quantity in quantities) From 496ed5d2ba3af86f57b51403a31e9281efd108e7 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 21:47:03 +0100 Subject: [PATCH 05/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20Windows=20Runtime?= =?UTF-8?q?=20Component=20(WRC)=20target?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #815 --- Build/build-functions.psm1 | 28 +- Build/build.ps1 | 8 +- Build/set-version-UnitsNet.ps1 | 8 - .../NanoFrameworkGen/NuspecGenerator.cs | 2 +- CodeGen/Generators/QuantityJsonFilesParser.cs | 2 +- .../UnitsNetWrcGen/QuantityGenerator.cs | 750 - .../UnitsNetWrcGen/QuantityTypeGenerator.cs | 39 - .../UnitsNetWrcGen/StaticQuantityGenerator.cs | 122 - .../UnitAbbreviationsCacheGenerator.cs | 58 - .../UnitsNetWrcGen/UnitTypeGenerator.cs | 61 - CodeGen/Generators/UnitsNetWrcGenerator.cs | 97 - CodeGen/Program.cs | 8 +- Docs/UnitsNet.NuGet-README.md | 36 - README.md | 27 +- .../.gitignore | 1 - .../SimpleConversionDemo.UWP.CSharp/App.xaml | 8 - .../App.xaml.cs | 105 - .../Assets/LockScreenLogo.scale-200.png | Bin 1430 -> 0 bytes .../Assets/SplashScreen.scale-200.png | Bin 7700 -> 0 bytes .../Assets/Square150x150Logo.scale-200.png | Bin 2937 -> 0 bytes .../Assets/Square44x44Logo.scale-200.png | Bin 1647 -> 0 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 1255 -> 0 bytes .../Assets/StoreLogo.png | Bin 1451 -> 0 bytes .../Assets/Wide310x150Logo.scale-200.png | Bin 3204 -> 0 bytes .../MainPage.xaml | 13 - .../MainPage.xaml.cs | 32 - .../Package.appxmanifest | 28 - .../Properties/AssemblyInfo.cs | 29 - .../Properties/Default.rd.xml | 31 - .../SimpleConversionDemo.UWP.CSharp/README.md | 9 - .../SimpleConversionDemo.UWP.CSharp.csproj | 141 - ...ConversionDemo.UWP.CSharp_TemporaryKey.pfx | Bin 2528 -> 0 bytes .../SimpleConversionDemo.UWP.CSharp/build.bat | 12 - .../project.json | 17 - .../SimpleConversionDemo.UWP.WinJS/README.md | 13 - .../SimpleConversionDemo.UWP.WinJS.jsproj | 92 - ...eConversionDemo.UWP.WinJS_TemporaryKey.pfx | Bin 2528 -> 0 bytes .../SimpleConversionDemo.UWP.WinJS/build.bat | 12 - .../css/default.css | 2 - .../images/LockScreenLogo.scale-200.png | Bin 1430 -> 0 bytes .../images/SplashScreen.scale-200.png | Bin 7700 -> 0 bytes .../images/Square150x150Logo.scale-200.png | Bin 2937 -> 0 bytes .../images/Square44x44Logo.scale-200.png | Bin 1647 -> 0 bytes ...x44Logo.targetsize-24_altform-unplated.png | Bin 1255 -> 0 bytes .../images/StoreLogo.png | Bin 1451 -> 0 bytes .../images/Wide310x150Logo.scale-200.png | Bin 3204 -> 0 bytes .../SimpleConversionDemo.UWP.WinJS/index.html | 36 - .../SimpleConversionDemo.UWP.WinJS/js/main.js | 66 - .../lib/winjs-4.0.1/css/ui-dark.css | 7304 -- .../lib/winjs-4.0.1/css/ui-light.css | 7304 -- .../lib/winjs-4.0.1/fonts/Symbols.ttf | Bin 47488 -> 0 bytes .../lib/winjs-4.0.1/js/base.js | 26523 -------- .../lib/winjs-4.0.1/js/ui.js | 54913 ---------------- .../package.appxmanifest | 28 - .../project.json | 18 - ...UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- ...Net.NanoFramework.AmountOfSubstance.nuspec | 2 +- ...itsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- ...itsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- ...nitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- ...t.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../UnitsNet.NanoFramework.BitRate.nuspec | 2 +- ...mework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- ...ework.CoefficientOfThermalExpansion.nuspec | 2 +- .../UnitsNet.NanoFramework.Density.nuspec | 2 +- .../UnitsNet.NanoFramework.Duration.nuspec | 2 +- ...sNet.NanoFramework.DynamicViscosity.nuspec | 2 +- ...et.NanoFramework.ElectricAdmittance.nuspec | 2 +- ...itsNet.NanoFramework.ElectricCharge.nuspec | 2 +- ...NanoFramework.ElectricChargeDensity.nuspec | 2 +- ...t.NanoFramework.ElectricConductance.nuspec | 2 +- ....NanoFramework.ElectricConductivity.nuspec | 2 +- ...tsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- ...anoFramework.ElectricCurrentDensity.nuspec | 2 +- ...noFramework.ElectricCurrentGradient.nuspec | 2 +- ...nitsNet.NanoFramework.ElectricField.nuspec | 2 +- ...et.NanoFramework.ElectricInductance.nuspec | 2 +- ...Net.NanoFramework.ElectricPotential.nuspec | 2 +- ...t.NanoFramework.ElectricPotentialAc.nuspec | 2 +- ...amework.ElectricPotentialChangeRate.nuspec | 2 +- ...t.NanoFramework.ElectricPotentialDc.nuspec | 2 +- ...et.NanoFramework.ElectricResistance.nuspec | 2 +- ...t.NanoFramework.ElectricResistivity.nuspec | 2 +- ...mework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- ...tsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- ...itsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.Frequency.nuspec | 2 +- ...itsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- ...noFramework.HeatTransferCoefficient.nuspec | 2 +- .../UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../UnitsNet.NanoFramework.Information.nuspec | 2 +- .../UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- ...et.NanoFramework.KinematicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../UnitsNet.NanoFramework.Length.nuspec | 2 +- .../Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- ...nitsNet.NanoFramework.LinearDensity.nuspec | 2 +- ...et.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- ...UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- ...Net.NanoFramework.LuminousIntensity.nuspec | 2 +- ...nitsNet.NanoFramework.MagneticField.nuspec | 2 +- ...UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- ...nitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- ...Net.NanoFramework.MassConcentration.nuspec | 2 +- .../UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- ...UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- ...t.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- ...UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../UnitsNet.NanoFramework.Molarity.nuspec | 2 +- ...UnitsNet.NanoFramework.Permeability.nuspec | 2 +- ...UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- ...UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../UnitsNet.NanoFramework.Pressure.nuspec | 2 +- ...et.NanoFramework.PressureChangeRate.nuspec | 2 +- .../Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- ...tsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- ...itsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- ...nitsNet.NanoFramework.ReactivePower.nuspec | 2 +- ...itsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- ...sNet.NanoFramework.ReciprocalLength.nuspec | 2 +- ...sNet.NanoFramework.RelativeHumidity.nuspec | 2 +- ...anoFramework.RotationalAcceleration.nuspec | 2 +- ...tsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- ...t.NanoFramework.RotationalStiffness.nuspec | 2 +- ...mework.RotationalStiffnessPerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- ...itsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- ...tsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- ...noFramework.SpecificFuelConsumption.nuspec | 2 +- ...itsNet.NanoFramework.SpecificVolume.nuspec | 2 +- ...itsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- ...et.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.Temperature.nuspec | 2 +- ...NanoFramework.TemperatureChangeRate.nuspec | 2 +- ...sNet.NanoFramework.TemperatureDelta.nuspec | 2 +- ...t.NanoFramework.ThermalConductivity.nuspec | 2 +- ...Net.NanoFramework.ThermalResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.Torque.nuspec | 2 +- ...tsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../UnitsNet.NanoFramework.Volume.nuspec | 2 +- ...t.NanoFramework.VolumeConcentration.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- ...tsNet.NanoFramework.VolumePerLength.nuspec | 2 +- ...anoFramework.VolumetricHeatCapacity.nuspec | 2 +- ...anoFramework.WarpingMomentOfInertia.nuspec | 2 +- .../AmbiguousUnitParseException.cs | 29 - .../AssemblyInfo.cs | 5 - .../BaseDimensions.cs | 188 - UnitsNet.WindowsRuntimeComponent/BaseUnits.cs | 124 - .../Comparison.cs | 125 - .../ComparisonType.cs | 21 - .../CustomCode/GlobalConfiguration.cs | 19 - .../Quantities/AmplitudeRatio.extra.cs | 77 - .../CustomCode/Quantities/Area.extra.cs | 25 - .../CustomCode/Quantities/Density.extra.cs | 36 - .../CustomCode/Quantities/Duration.extra.cs | 27 - .../Quantities/ElectricPotential.extra.cs | 28 - .../CustomCode/Quantities/Force.extra.cs | 25 - .../CustomCode/Quantities/Length.extra.cs | 69 - .../CustomCode/Quantities/Mass.extra.cs | 82 - .../CustomCode/Quantities/Molarity.extra.cs | 35 - .../CustomCode/Quantities/Power.extra.cs | 26 - .../CustomCode/Quantities/PowerRatio.extra.cs | 71 - .../Quantities/Temperature.extra.cs | 49 - .../CustomCode/Quantity.cs | 41 - .../CustomCode/QuantityParser.cs | 217 - .../CustomCode/UnitAbbreviationsCache.cs | 221 - .../CustomCode/UnitParser.cs | 161 - .../CustomCode/UnitValueAbbreviationLookup.cs | 80 - .../Quantities/Acceleration.g.cs | 801 - .../Quantities/AmountOfSubstance.g.cs | 818 - .../Quantities/AmplitudeRatio.g.cs | 631 - .../GeneratedCode/Quantities/Angle.g.cs | 835 - .../Quantities/ApparentEnergy.g.cs | 614 - .../Quantities/ApparentPower.g.cs | 631 - .../GeneratedCode/Quantities/Area.g.cs | 801 - .../GeneratedCode/Quantities/AreaDensity.g.cs | 580 - .../Quantities/AreaMomentOfInertia.g.cs | 665 - .../GeneratedCode/Quantities/BitRate.g.cs | 1008 - .../BrakeSpecificFuelConsumption.g.cs | 614 - .../GeneratedCode/Quantities/Capacitance.g.cs | 685 - .../CoefficientOfThermalExpansion.g.cs | 614 - .../GeneratedCode/Quantities/Density.g.cs | 1246 - .../GeneratedCode/Quantities/Duration.g.cs | 733 - .../Quantities/DynamicViscosity.g.cs | 736 - .../Quantities/ElectricAdmittance.g.cs | 631 - .../Quantities/ElectricCharge.g.cs | 651 - .../Quantities/ElectricChargeDensity.g.cs | 583 - .../Quantities/ElectricConductance.g.cs | 617 - .../Quantities/ElectricConductivity.g.cs | 617 - .../Quantities/ElectricCurrent.g.cs | 699 - .../Quantities/ElectricCurrentDensity.g.cs | 617 - .../Quantities/ElectricCurrentGradient.g.cs | 631 - .../Quantities/ElectricField.g.cs | 583 - .../Quantities/ElectricInductance.g.cs | 634 - .../Quantities/ElectricPotential.g.cs | 648 - .../Quantities/ElectricPotentialAc.g.cs | 648 - .../ElectricPotentialChangeRate.g.cs | 903 - .../Quantities/ElectricPotentialDc.g.cs | 648 - .../Quantities/ElectricResistance.g.cs | 665 - .../Quantities/ElectricResistivity.g.cs | 804 - .../ElectricSurfaceChargeDensity.g.cs | 617 - .../GeneratedCode/Quantities/Energy.g.cs | 1175 - .../GeneratedCode/Quantities/Entropy.g.cs | 682 - .../GeneratedCode/Quantities/Force.g.cs | 818 - .../Quantities/ForceChangeRate.g.cs | 818 - .../Quantities/ForcePerLength.g.cs | 1209 - .../GeneratedCode/Quantities/Frequency.g.cs | 750 - .../Quantities/FuelEfficiency.g.cs | 634 - .../GeneratedCode/Quantities/HeatFlux.g.cs | 869 - .../Quantities/HeatTransferCoefficient.g.cs | 614 - .../GeneratedCode/Quantities/Illuminance.g.cs | 634 - .../GeneratedCode/Quantities/Information.g.cs | 1005 - .../GeneratedCode/Quantities/Irradiance.g.cs | 801 - .../GeneratedCode/Quantities/Irradiation.g.cs | 685 - .../Quantities/KinematicViscosity.g.cs | 719 - .../GeneratedCode/Quantities/LapseRate.g.cs | 580 - .../GeneratedCode/Quantities/Length.g.cs | 1124 - .../GeneratedCode/Quantities/Level.g.cs | 597 - .../Quantities/LinearDensity.g.cs | 804 - .../Quantities/LinearPowerDensity.g.cs | 991 - .../GeneratedCode/Quantities/Luminosity.g.cs | 804 - .../Quantities/LuminousFlux.g.cs | 583 - .../Quantities/LuminousIntensity.g.cs | 583 - .../Quantities/MagneticField.g.cs | 668 - .../Quantities/MagneticFlux.g.cs | 583 - .../Quantities/Magnetization.g.cs | 583 - .../GeneratedCode/Quantities/Mass.g.cs | 988 - .../Quantities/MassConcentration.g.cs | 1399 - .../GeneratedCode/Quantities/MassFlow.g.cs | 1124 - .../GeneratedCode/Quantities/MassFlux.g.cs | 767 - .../Quantities/MassFraction.g.cs | 974 - .../Quantities/MassMomentOfInertia.g.cs | 1039 - .../GeneratedCode/Quantities/MolarEnergy.g.cs | 614 - .../Quantities/MolarEntropy.g.cs | 614 - .../GeneratedCode/Quantities/MolarMass.g.cs | 767 - .../GeneratedCode/Quantities/Molarity.g.cs | 702 - .../Quantities/Permeability.g.cs | 583 - .../Quantities/Permittivity.g.cs | 583 - .../GeneratedCode/Quantities/Power.g.cs | 988 - .../Quantities/PowerDensity.g.cs | 1311 - .../GeneratedCode/Quantities/PowerRatio.g.cs | 597 - .../GeneratedCode/Quantities/Pressure.g.cs | 1311 - .../Quantities/PressureChangeRate.g.cs | 784 - .../GeneratedCode/Quantities/Ratio.g.cs | 665 - .../Quantities/RatioChangeRate.g.cs | 597 - .../Quantities/ReactiveEnergy.g.cs | 614 - .../Quantities/ReactivePower.g.cs | 631 - .../Quantities/ReciprocalArea.g.cs | 753 - .../Quantities/ReciprocalLength.g.cs | 736 - .../Quantities/RelativeHumidity.g.cs | 580 - .../Quantities/RotationalAcceleration.g.cs | 631 - .../Quantities/RotationalSpeed.g.cs | 784 - .../Quantities/RotationalStiffness.g.cs | 1124 - .../RotationalStiffnessPerLength.g.cs | 648 - .../GeneratedCode/Quantities/Scalar.g.cs | 580 - .../GeneratedCode/Quantities/SolidAngle.g.cs | 583 - .../Quantities/SpecificEnergy.g.cs | 991 - .../Quantities/SpecificEntropy.g.cs | 716 - .../Quantities/SpecificFuelConsumption.g.cs | 634 - .../Quantities/SpecificVolume.g.cs | 614 - .../Quantities/SpecificWeight.g.cs | 855 - .../GeneratedCode/Quantities/Speed.g.cs | 1107 - .../Quantities/StandardVolumeFlow.g.cs | 716 - .../GeneratedCode/Quantities/Temperature.g.cs | 733 - .../Quantities/TemperatureChangeRate.g.cs | 733 - .../Quantities/TemperatureDelta.g.cs | 716 - .../Quantities/ThermalConductivity.g.cs | 600 - .../Quantities/ThermalResistance.g.cs | 648 - .../GeneratedCode/Quantities/Torque.g.cs | 937 - .../Quantities/TorquePerLength.g.cs | 920 - .../GeneratedCode/Quantities/Turbidity.g.cs | 583 - .../GeneratedCode/Quantities/VitaminA.g.cs | 580 - .../GeneratedCode/Quantities/Volume.g.cs | 1430 - .../Quantities/VolumeConcentration.g.cs | 906 - .../GeneratedCode/Quantities/VolumeFlow.g.cs | 1515 - .../Quantities/VolumePerLength.g.cs | 682 - .../Quantities/VolumetricHeatCapacity.g.cs | 719 - .../Quantities/WarpingMomentOfInertia.g.cs | 665 - .../GeneratedCode/Quantity.g.cs | 758 - .../GeneratedCode/QuantityType.g.cs | 143 - .../GeneratedCode/UnitAbbreviationsCache.g.cs | 1722 - .../GeneratedCode/Units/AccelerationUnit.g.cs | 46 - .../Units/AmountOfSubstanceUnit.g.cs | 47 - .../Units/AmplitudeRatioUnit.g.cs | 36 - .../GeneratedCode/Units/AngleUnit.g.cs | 48 - .../Units/ApparentEnergyUnit.g.cs | 35 - .../Units/ApparentPowerUnit.g.cs | 36 - .../GeneratedCode/Units/AreaDensityUnit.g.cs | 33 - .../Units/AreaMomentOfInertiaUnit.g.cs | 38 - .../GeneratedCode/Units/AreaUnit.g.cs | 46 - .../GeneratedCode/Units/BitRateUnit.g.cs | 58 - .../BrakeSpecificFuelConsumptionUnit.g.cs | 39 - .../GeneratedCode/Units/CapacitanceUnit.g.cs | 39 - .../CoefficientOfThermalExpansionUnit.g.cs | 35 - .../GeneratedCode/Units/DensityUnit.g.cs | 72 - .../GeneratedCode/Units/DurationUnit.g.cs | 42 - .../Units/DynamicViscosityUnit.g.cs | 42 - .../Units/ElectricAdmittanceUnit.g.cs | 36 - .../Units/ElectricChargeDensityUnit.g.cs | 33 - .../Units/ElectricChargeUnit.g.cs | 37 - .../Units/ElectricConductanceUnit.g.cs | 35 - .../Units/ElectricConductivityUnit.g.cs | 35 - .../Units/ElectricCurrentDensityUnit.g.cs | 35 - .../Units/ElectricCurrentGradientUnit.g.cs | 36 - .../Units/ElectricCurrentUnit.g.cs | 40 - .../Units/ElectricFieldUnit.g.cs | 33 - .../Units/ElectricInductanceUnit.g.cs | 36 - .../Units/ElectricPotentialAcUnit.g.cs | 37 - .../ElectricPotentialChangeRateUnit.g.cs | 52 - .../Units/ElectricPotentialDcUnit.g.cs | 37 - .../Units/ElectricPotentialUnit.g.cs | 37 - .../Units/ElectricResistanceUnit.g.cs | 38 - .../Units/ElectricResistivityUnit.g.cs | 46 - .../ElectricSurfaceChargeDensityUnit.g.cs | 35 - .../GeneratedCode/Units/EnergyUnit.g.cs | 68 - .../GeneratedCode/Units/EntropyUnit.g.cs | 39 - .../Units/ForceChangeRateUnit.g.cs | 47 - .../Units/ForcePerLengthUnit.g.cs | 70 - .../GeneratedCode/Units/ForceUnit.g.cs | 52 - .../GeneratedCode/Units/FrequencyUnit.g.cs | 43 - .../Units/FuelEfficiencyUnit.g.cs | 36 - .../GeneratedCode/Units/HeatFluxUnit.g.cs | 50 - .../Units/HeatTransferCoefficientUnit.g.cs | 35 - .../GeneratedCode/Units/IlluminanceUnit.g.cs | 36 - .../GeneratedCode/Units/InformationUnit.g.cs | 58 - .../GeneratedCode/Units/IrradianceUnit.g.cs | 46 - .../GeneratedCode/Units/IrradiationUnit.g.cs | 39 - .../Units/KinematicViscosityUnit.g.cs | 41 - .../GeneratedCode/Units/LapseRateUnit.g.cs | 33 - .../GeneratedCode/Units/LengthUnit.g.cs | 85 - .../GeneratedCode/Units/LevelUnit.g.cs | 34 - .../Units/LinearDensityUnit.g.cs | 46 - .../Units/LinearPowerDensityUnit.g.cs | 57 - .../GeneratedCode/Units/LuminosityUnit.g.cs | 47 - .../GeneratedCode/Units/LuminousFluxUnit.g.cs | 33 - .../Units/LuminousIntensityUnit.g.cs | 33 - .../Units/MagneticFieldUnit.g.cs | 38 - .../GeneratedCode/Units/MagneticFluxUnit.g.cs | 33 - .../Units/MagnetizationUnit.g.cs | 33 - .../Units/MassConcentrationUnit.g.cs | 81 - .../GeneratedCode/Units/MassFlowUnit.g.cs | 65 - .../GeneratedCode/Units/MassFluxUnit.g.cs | 44 - .../GeneratedCode/Units/MassFractionUnit.g.cs | 56 - .../Units/MassMomentOfInertiaUnit.g.cs | 60 - .../GeneratedCode/Units/MassUnit.g.cs | 111 - .../GeneratedCode/Units/MolarEnergyUnit.g.cs | 35 - .../GeneratedCode/Units/MolarEntropyUnit.g.cs | 35 - .../GeneratedCode/Units/MolarMassUnit.g.cs | 44 - .../GeneratedCode/Units/MolarityUnit.g.cs | 40 - .../GeneratedCode/Units/PermeabilityUnit.g.cs | 33 - .../GeneratedCode/Units/PermittivityUnit.g.cs | 33 - .../GeneratedCode/Units/PowerDensityUnit.g.cs | 76 - .../GeneratedCode/Units/PowerRatioUnit.g.cs | 34 - .../GeneratedCode/Units/PowerUnit.g.cs | 57 - .../Units/PressureChangeRateUnit.g.cs | 45 - .../GeneratedCode/Units/PressureUnit.g.cs | 76 - .../Units/RatioChangeRateUnit.g.cs | 34 - .../GeneratedCode/Units/RatioUnit.g.cs | 38 - .../Units/ReactiveEnergyUnit.g.cs | 35 - .../Units/ReactivePowerUnit.g.cs | 36 - .../Units/ReciprocalAreaUnit.g.cs | 43 - .../Units/ReciprocalLengthUnit.g.cs | 42 - .../Units/RelativeHumidityUnit.g.cs | 33 - .../Units/RotationalAccelerationUnit.g.cs | 36 - .../Units/RotationalSpeedUnit.g.cs | 45 - .../RotationalStiffnessPerLengthUnit.g.cs | 37 - .../Units/RotationalStiffnessUnit.g.cs | 65 - .../GeneratedCode/Units/ScalarUnit.g.cs | 33 - .../GeneratedCode/Units/SolidAngleUnit.g.cs | 33 - .../Units/SpecificEnergyUnit.g.cs | 57 - .../Units/SpecificEntropyUnit.g.cs | 41 - .../Units/SpecificFuelConsumptionUnit.g.cs | 36 - .../Units/SpecificVolumeUnit.g.cs | 35 - .../Units/SpecificWeightUnit.g.cs | 49 - .../GeneratedCode/Units/SpeedUnit.g.cs | 64 - .../Units/StandardVolumeFlowUnit.g.cs | 41 - .../Units/TemperatureChangeRateUnit.g.cs | 42 - .../Units/TemperatureDeltaUnit.g.cs | 41 - .../GeneratedCode/Units/TemperatureUnit.g.cs | 42 - .../Units/ThermalConductivityUnit.g.cs | 34 - .../Units/ThermalResistanceUnit.g.cs | 37 - .../Units/TorquePerLengthUnit.g.cs | 53 - .../GeneratedCode/Units/TorqueUnit.g.cs | 54 - .../GeneratedCode/Units/TurbidityUnit.g.cs | 33 - .../GeneratedCode/Units/VitaminAUnit.g.cs | 33 - .../Units/VolumeConcentrationUnit.g.cs | 52 - .../GeneratedCode/Units/VolumeFlowUnit.g.cs | 88 - .../Units/VolumePerLengthUnit.g.cs | 39 - .../GeneratedCode/Units/VolumeUnit.g.cs | 83 - .../Units/VolumetricHeatCapacityUnit.g.cs | 41 - .../Units/WarpingMomentOfInertiaUnit.g.cs | 38 - UnitsNet.WindowsRuntimeComponent/IQuantity.cs | 62 - .../InternalHelpers/Guard.cs | 29 - .../ReflectionBridgeExtensions.cs | 89 - .../Properties/AssemblyInfo.cs | 22 - .../QuantityInfo.cs | 107 - .../QuantityNotFoundException.cs | 26 - .../UnitConverter.cs | 422 - .../UnitFormatter.cs | 81 - UnitsNet.WindowsRuntimeComponent/UnitInfo.cs | 37 - .../UnitNotFoundException.cs | 26 - .../UnitSystem.cs | 72 - .../UnitsNet.WindowsRuntimeComponent.csproj | 141 - ...WindowsRuntimeComponent.csproj.DotSettings | 2 - .../UnitsNet.WindowsRuntimeComponent.nuspec | 25 - .../UnitsNetException.cs | 25 - UnitsNet.sln | 2 +- appveyor.yml | 2 +- build-with-wrc.bat => build-all-targets.bat | 2 +- build.bat | 2 +- 431 files changed, 133 insertions(+), 193170 deletions(-) delete mode 100644 CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs delete mode 100644 CodeGen/Generators/UnitsNetWrcGen/QuantityTypeGenerator.cs delete mode 100644 CodeGen/Generators/UnitsNetWrcGen/StaticQuantityGenerator.cs delete mode 100644 CodeGen/Generators/UnitsNetWrcGen/UnitAbbreviationsCacheGenerator.cs delete mode 100644 CodeGen/Generators/UnitsNetWrcGen/UnitTypeGenerator.cs delete mode 100644 CodeGen/Generators/UnitsNetWrcGenerator.cs delete mode 100644 Docs/UnitsNet.NuGet-README.md delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/.gitignore delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/App.xaml delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/App.xaml.cs delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/LockScreenLogo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/SplashScreen.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square150x150Logo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/StoreLogo.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Assets/Wide310x150Logo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Properties/AssemblyInfo.cs delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/Properties/Default.rd.xml delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/README.md delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/build.bat delete mode 100644 Samples/SimpleConversionDemo.UWP.CSharp/project.json delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/README.md delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS.jsproj delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS_TemporaryKey.pfx delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/build.bat delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/css/default.css delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/LockScreenLogo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/SplashScreen.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/Square150x150Logo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/Square44x44Logo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/Square44x44Logo.targetsize-24_altform-unplated.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/StoreLogo.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/images/Wide310x150Logo.scale-200.png delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/index.html delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/js/main.js delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/css/ui-dark.css delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/css/ui-light.css delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/fonts/Symbols.ttf delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/js/base.js delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/js/ui.js delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/package.appxmanifest delete mode 100644 Samples/SimpleConversionDemo.UWP.WinJS/project.json delete mode 100644 UnitsNet.WindowsRuntimeComponent/AmbiguousUnitParseException.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/AssemblyInfo.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/BaseDimensions.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/BaseUnits.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/Comparison.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/ComparisonType.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/GlobalConfiguration.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/AmplitudeRatio.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Area.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Density.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Duration.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/ElectricPotential.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Force.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Length.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Mass.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Molarity.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Power.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/PowerRatio.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Temperature.extra.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/Quantity.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/QuantityParser.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/UnitAbbreviationsCache.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/UnitParser.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/CustomCode/UnitValueAbbreviationLookup.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/FuelEfficiency.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearPowerDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Luminosity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassConcentration.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFraction.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RatioChangeRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalArea.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalLength.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RelativeHumidity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Scalar.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/StandardVolumeFlow.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TorquePerLength.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Turbidity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeConcentration.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumePerLength.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantity.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/QuantityType.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AccelerationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmplitudeRatioUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AngleUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentEnergyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentPowerUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BitRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CapacitanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DurationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DynamicViscosityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductivityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricFieldUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricInductanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistivityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EnergyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EntropyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceChangeRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForcePerLengthUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FrequencyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FuelEfficiencyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatFluxUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IlluminanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/InformationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradianceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradiationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/KinematicViscosityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LapseRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LengthUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LevelUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearPowerDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminosityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousFluxUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousIntensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFieldUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFluxUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagnetizationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassConcentrationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFlowUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFluxUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFractionUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEnergyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEntropyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarMassUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermeabilityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermittivityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerDensityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerRatioUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureChangeRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioChangeRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactiveEnergyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactivePowerUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalAreaUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalLengthUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RelativeHumidityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalAccelerationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalSpeedUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ScalarUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SolidAngleUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEnergyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEntropyUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificVolumeUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificWeightUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpeedUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureDeltaUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalConductivityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalResistanceUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorquePerLengthUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorqueUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TurbidityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VitaminAUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeConcentrationUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeFlowUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumePerLengthUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/IQuantity.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/InternalHelpers/Guard.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/InternalHelpers/ReflectionBridgeExtensions.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/QuantityInfo.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/QuantityNotFoundException.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitConverter.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitFormatter.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitInfo.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitNotFoundException.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitSystem.cs delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj.DotSettings delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec delete mode 100644 UnitsNet.WindowsRuntimeComponent/UnitsNetException.cs rename build-with-wrc.bat => build-all-targets.bat (52%) diff --git a/Build/build-functions.psm1 b/Build/build-functions.psm1 index b810b8ce13..052d631f1c 100644 --- a/Build/build-functions.psm1 +++ b/Build/build-functions.psm1 @@ -27,7 +27,7 @@ function Update-GeneratedCode { write-host -foreground blue "Generate code...END`n" } -function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false, [boolean] $IncludeNanoFramework = $false) { +function Start-Build([boolean] $IncludeNanoFramework = $false) { write-host -foreground blue "Start-Build...`n---" $fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.msbuild.log" @@ -39,24 +39,6 @@ function Start-Build([boolean] $IncludeWindowsRuntimeComponent = $false, [boolea dotnet build --configuration Release "$root\UnitsNet.sln" $fileLoggerArg $appVeyorLoggerArg if ($lastexitcode -ne 0) { exit 1 } - if (-not $IncludeWindowsRuntimeComponent) - { - write-host -foreground yellow "Skipping WindowsRuntimeComponent build." - } - else - { - write-host -foreground green "Build WindowsRuntimeComponent." - $fileLoggerArg = "/logger:FileLogger,Microsoft.Build;logfile=$testReportDir\UnitsNet.WindowsRuntimeComponent.msbuild.log" - $appVeyorLoggerArg = if (Test-Path "$appVeyorLoggerDll") { "/logger:$appVeyorLoggerDll" } else { "" } - - # dontnet CLI does not support WindowsRuntimeComponent project type yet - # msbuild does not auto-restore nugets for this project type - write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using MSBuild15 instead" - & "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release /t:restore - & "$msbuild" "$root\UnitsNet.WindowsRuntimeComponent.sln" /verbosity:minimal /p:Configuration=Release $fileLoggerArg $appVeyorLoggerArg - if ($lastexitcode -ne 0) { exit 1 } - } - if (-not $IncludeNanoFramework) { write-host -foreground yellow "Skipping .NET nanoFramework build." @@ -128,13 +110,6 @@ function Start-PackNugets { if ($lastexitcode -ne 0) { exit 1 } } - if (-not $IncludeWindowsRuntimeComponent) { - write-host -foreground yellow "Skipping WindowsRuntimeComponent nuget pack." - } else { - write-host -foreground yellow "WindowsRuntimeComponent project not yet supported by dotnet CLI, using nuget.exe instead" - & $nuget pack "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" -Verbosity detailed -OutputDirectory "$nugetOutDir" - } - if (-not $IncludeNanoFramework) { write-host -foreground yellow "Skipping nanoFramework nuget pack." } else { @@ -142,7 +117,6 @@ function Start-PackNugets { Invoke-BuildNanoNugets } - write-host -foreground blue "Pack nugets...END`n" } diff --git a/Build/build.ps1 b/Build/build.ps1 index 0c5e087474..36b6169636 100644 --- a/Build/build.ps1 +++ b/Build/build.ps1 @@ -7,12 +7,9 @@ Publishing nugets is handled by nuget-publish.bat and run by the build server on the master branch. -.PARAMETER skipUWP - If flag is set, will skip the UWP (Windows Runtime Component) build step as this requires - some large, extra Visual Studio features to be installed. .EXAMPLE powershell ./build.ps1 - powershell ./build.ps1 -IncludeWindowsRuntimeComponent -IncludeNanoFramework + powershell ./build.ps1 -IncludeNanoFramework .NOTES Author: Andreas Gullberg Larsen @@ -20,7 +17,6 @@ #> [CmdletBinding()] Param( - [switch] $IncludeWindowsRuntimeComponent, [switch] $IncludeNanoFramework ) @@ -32,7 +28,7 @@ try { Remove-ArtifactsDir Update-GeneratedCode - Start-Build -IncludeWindowsRuntimeComponent $IncludeWindowsRuntimeComponent -IncludeNanoFramework $IncludeNanoFramework + Start-Build -IncludeNanoFramework $IncludeNanoFramework Start-Tests Start-PackNugets Compress-ArtifactsAsZip diff --git a/Build/set-version-UnitsNet.ps1 b/Build/set-version-UnitsNet.ps1 index d2908b1221..b4c0e10f65 100644 --- a/Build/set-version-UnitsNet.ps1 +++ b/Build/set-version-UnitsNet.ps1 @@ -55,8 +55,6 @@ $projFile = "$root\UnitsNet\UnitsNet.csproj" $numberExtensionsProjFile = "$root\UnitsNet.NumberExtensions\UnitsNet.NumberExtensions.csproj" $nanoFrameworkNuspecGeneratorFile = "$root\CodeGen\Generators\NanoFrameworkGen\NuspecGenerator.cs" $nanoFrameworkAssemblyInfoFile = "$root\UnitsNet.NanoFramework\GeneratedCode\Properties\AssemblyInfo.cs" -$winrtAssemblyInfoFile = "$root\UnitsNet.WindowsRuntimeComponent\Properties\AssemblyInfo.cs" -$winrtNuspecFile = "$root\UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.nuspec" # Use UnitsNet.Common.props version as base if bumping major/minor/patch $newVersion = Get-NewProjectVersion $projFile $paramSet $setVersion $bumpVersion @@ -68,15 +66,9 @@ $didStash = Invoke-StashPush Set-ProjectVersion $projFile $newVersion Set-ProjectVersion $numberExtensionsProjFile $newVersion -# Update AssemblyInfo.cs files -Set-AssemblyInfoVersion $winrtAssemblyInfoFile $newVersion - # Update AssemblyInfo.cs file for .NET nanoFramework Set-AssemblyInfoVersion $nanoFrameworkAssemblyInfoFile $newVersion -# Update .nuspec files -Set-NuspecVersion $winrtNuspecFile $newVersion - # Update codegen and .nuspec files for nanoFramework Set-NuspecVersion $nanoFrameworkNuspecGeneratorFile $newVersion Get-ChildItem -Path "$root\UnitsNet.NanoFramework\GeneratedCode" -Include '*.nuspec' -Recurse | diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index fee32eba54..b691996b2a 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -38,7 +38,7 @@ public override string Generate() Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component {_quantity.Name.ToLower()} + nanoframework {_quantity.Name.ToLower()} unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable "); diff --git a/CodeGen/Generators/QuantityJsonFilesParser.cs b/CodeGen/Generators/QuantityJsonFilesParser.cs index bf0578c593..aa57cef1d2 100644 --- a/CodeGen/Generators/QuantityJsonFilesParser.cs +++ b/CodeGen/Generators/QuantityJsonFilesParser.cs @@ -15,7 +15,7 @@ namespace CodeGen.Generators /// /// Parses JSON files that define quantities and their units. /// This will later be used to generate source code and can be reused for different targets such as .NET framework, - /// WindowsRuntimeComponent and even other programming languages. + /// .NET Core, .NET nanoFramework and even other programming languages. /// internal static class QuantityJsonFilesParser { diff --git a/CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs deleted file mode 100644 index 24c3d5eb34..0000000000 --- a/CodeGen/Generators/UnitsNetWrcGen/QuantityGenerator.cs +++ /dev/null @@ -1,750 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Linq; -using CodeGen.Helpers; -using CodeGen.JsonTypes; - -namespace CodeGen.Generators.UnitsNetWrcGen -{ - internal class QuantityGenerator : GeneratorBase - { - private readonly Quantity _quantity; - - private readonly bool _isDimensionless; - private readonly string _unitEnumName; - private readonly string _valueType; - private readonly Unit _baseUnit; - - public QuantityGenerator(Quantity quantity) - { - _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); - - _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.BaseUnit) ?? - throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", - nameof(quantity)); - - _valueType = quantity.BaseType; - _unitEnumName = $"{quantity.Name}Unit"; - - BaseDimensions baseDimensions = quantity.BaseDimensions; - _isDimensionless = baseDimensions == null || - baseDimensions.L == 0 && - baseDimensions.M == 0 && - baseDimensions.T == 0 && - baseDimensions.I == 0 && - baseDimensions.Θ == 0 && - baseDimensions.N == 0 && - baseDimensions.J == 0; - - } - - public override string Generate() - { - Writer.WL(GeneratedFileHeader); - Writer.WL(@" -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{"); - Writer.WLIfText(1, GetObsoleteAttributeOrNull(_quantity)); - Writer.WL($@" - /// - /// {_quantity.XmlDoc} - /// "); - - Writer.WLCondition(_quantity.XmlDocRemarks.HasText(), $@" - /// - /// {_quantity.XmlDocRemarks} - /// "); - - Writer.WL($@" - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class {_quantity.Name} : IQuantity - {{ - /// - /// The numeric value this quantity was constructed with. - /// - private readonly {_quantity.BaseType} _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly {_unitEnumName}? _unit; -"); - GenerateStaticConstructor(); - GenerateInstanceConstructors(); - GenerateStaticProperties(); - GenerateProperties(); - GenerateConversionProperties(); - GenerateStaticMethods(); - GenerateStaticFactoryMethods(); - GenerateStaticParseMethods(); - GenerateEqualityAndComparison(); - GenerateConversionMethods(); - GenerateToString(); - - Writer.WL($@" - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - {{ - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - }} - }} -}}"); - return Writer.ToString(); - } - - private void GenerateStaticConstructor() - { - var baseDimensions = _quantity.BaseDimensions; - Writer.WL($@" - static {_quantity.Name}() - {{"); - Writer.WL(_isDimensionless - ? @" - BaseDimensions = BaseDimensions.Dimensionless;" - : $@" - BaseDimensions = new BaseDimensions({baseDimensions.L}, {baseDimensions.M}, {baseDimensions.T}, {baseDimensions.I}, {baseDimensions.Θ}, {baseDimensions.N}, {baseDimensions.J});"); - - Writer.WL($@" - Info = new QuantityInfo(QuantityType.{_quantity.Name}, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - }} -"); - } - - private void GenerateInstanceConstructors() - { - Writer.WL($@" - /// - /// Creates the quantity with a value of 0 in the base unit {_baseUnit.SingularName}. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public {_quantity.Name}() - {{ - _value = 0; - _unit = BaseUnit; - }} - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private {_quantity.Name}({_quantity.BaseType} value, {_unitEnumName} unit) - {{ - if(unit == {_unitEnumName}.Undefined) - throw new ArgumentException(""The quantity can not be created with an undefined unit."", nameof(unit)); -"); - - Writer.WL(_quantity.BaseType == "double" - ? @" - _value = Guard.EnsureValidNumber(value, nameof(value));" - : @" - _value = value;"); - Writer.WL($@" - _unit = unit; - }} -"); - } - - private void GenerateStaticProperties() - { - Writer.WL($@" - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info {{ get; }} - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions {{ get; }} - - /// - /// The base unit of {_quantity.Name}, which is {_quantity.BaseUnit}. All conversions go via this value. - /// - public static {_unitEnumName} BaseUnit {{ get; }} = {_unitEnumName}.{_quantity.BaseUnit}; - - /// - /// Represents the largest possible value of {_quantity.Name} - /// - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_valueType}.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of {_quantity.Name} - /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_valueType}.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name}; - - /// - /// All units of measurement for the {_quantity.Name} quantity. - /// - public static {_unitEnumName}[] Units {{ get; }} = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().Except(new {_unitEnumName}[]{{ {_unitEnumName}.Undefined }}).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.BaseUnit}. - /// - public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, BaseUnit); - - #endregion -"); - } - - private void GenerateProperties() - { - Writer.WL($@" - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); -"); - - Writer.WL($@" - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public {_unitEnumName} Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => {_quantity.Name}.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => {_quantity.Name}.BaseDimensions; - - #endregion -"); - } - - private void GenerateConversionProperties() - { - Writer.WL(@" - #region Conversion Properties -"); - foreach (var unit in _quantity.Units) - { - Writer.WL($@" - /// - /// Get {_quantity.Name} in {unit.PluralName}. - /// "); - Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); - Writer.WL($@" - public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); -"); - } - - Writer.WL(@" - - #endregion -"); - } - - private void GenerateStaticMethods() - { - Writer.WL($@" - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation({_unitEnumName} unit) - {{ - return GetAbbreviation(unit, null); - }} - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: ""en-US"") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation({_quantity.Name}Unit unit, [CanBeNull] string cultureName) - {{ - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - }} - - #endregion -"); - } - - private void GenerateStaticFactoryMethods() - { - Writer.WL(@" - #region Static Factory Methods -"); - foreach (var unit in _quantity.Units) - { - var valueParamName = unit.PluralName.ToLowerInvariant(); - Writer.WL($@" - /// - /// Get {_quantity.Name} from {unit.PluralName}. - /// - /// If value is NaN or Infinity."); - Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); - Writer.WL($@" - [Windows.Foundation.Metadata.DefaultOverload] - public static {_quantity.Name} From{unit.PluralName}(double {valueParamName}) - {{ - {_valueType} value = ({_valueType}) {valueParamName}; - return new {_quantity.Name}(value, {_unitEnumName}.{unit.SingularName}); - }}"); - } - - Writer.WL(); - Writer.WL($@" - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// {_quantity.Name} unit value. - // Fix name conflict with parameter ""value"" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName(""returnValue"")] - public static {_quantity.Name} From(double value, {_unitEnumName} fromUnit) - {{ - return new {_quantity.Name}(({_valueType})value, fromUnit); - }} - - #endregion -"); - } - - private void GenerateStaticParseMethods() - { - Writer.WL($@" - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format ""<quantity> <unit>"". - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// - /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// ""<quantity> <unit>"". Eg. ""5.5 m"" or ""1ft 2in"" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse(""1 cup"") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static {_quantity.Name} Parse(string str) - {{ - return Parse(str, null); - }} - - /// - /// Parse a string with one or two quantities of the format ""<quantity> <unit>"". - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// - /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// ""<quantity> <unit>"". Eg. ""5.5 m"" or ""1ft 2in"" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse(""1 cup"") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: ""en-US"") to use when parsing number and unit. Defaults to if null. - public static {_quantity.Name} Parse(string str, [CanBeNull] string cultureName) - {{ - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse<{_quantity.Name}, {_unitEnumName}>( - str, - provider, - From); - }} - - /// - /// Try to parse a string with one or two quantities of the format ""<quantity> <unit>"". - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// Resulting unit quantity if successful. - /// - /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); - /// - public static bool TryParse([CanBeNull] string str, out {_quantity.Name} result) - {{ - return TryParse(str, null, out result); - }} - - /// - /// Try to parse a string with one or two quantities of the format ""<quantity> <unit>"". - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); - /// - /// Name of culture (ex: ""en-US"") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out {_quantity.Name} result) - {{ - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse<{_quantity.Name}, {_unitEnumName}>( - str, - provider, - From, - out result); - }} - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// - /// Length.ParseUnit(""m"", new CultureInfo(""en-US"")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static {_unitEnumName} ParseUnit(string str) - {{ - return ParseUnit(str, null); - }} - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// - /// Length.ParseUnit(""m"", new CultureInfo(""en-US"")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: ""en-US"") to use when parsing number and unit. Defaults to if null. - public static {_unitEnumName} ParseUnit(string str, [CanBeNull] string cultureName) - {{ - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse<{_unitEnumName}>(str, provider); - }} - - public static bool TryParseUnit(string str, out {_unitEnumName} unit) - {{ - return TryParseUnit(str, null, out unit); - }} - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {{number}} {{unit}} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit(""m"", new CultureInfo(""en-US"")); - /// - /// Name of culture (ex: ""en-US"") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out {_unitEnumName} unit) - {{ - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse<{_unitEnumName}>(str, provider, out unit); - }} - - #endregion -"); - } - - private void GenerateEqualityAndComparison() - { - Writer.WL($@" - #region Equality / IComparable - - public int CompareTo(object obj) - {{ - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is {_quantity.Name} obj{_quantity.Name})) throw new ArgumentException(""Expected type {_quantity.Name}."", nameof(obj)); - - return CompareTo(obj{_quantity.Name}); - }} - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo({_quantity.Name} other) - {{ - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - }} - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - {{ - if(obj is null || !(obj is {_quantity.Name} obj{_quantity.Name})) - return false; - - return Equals(obj{_quantity.Name}); - }} - - public bool Equals({_quantity.Name} other) - {{ - return _value.Equals(other.AsBaseNumericType(this.Unit)); - }} - - /// - /// - /// Compare equality to another {_quantity.Name} within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) - {{ - if(tolerance < 0) - throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - }} - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current {_quantity.Name}. - public override int GetHashCode() - {{ - return new {{ QuantityType, Value, Unit }}.GetHashCode(); - }} - - #endregion -"); - } - - private void GenerateConversionMethods() - { - Writer.WL($@" - #region Conversion Methods - - double IQuantity.As(object unit) => As(({_quantity.Name}Unit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As({_unitEnumName} unit) - {{ - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - }} - - /// - /// Converts this {_quantity.Name} to another {_quantity.Name} with the unit representation . - /// - /// A {_quantity.Name} with the specified unit. - public {_quantity.Name} ToUnit({_unitEnumName} unit) - {{ - var convertedValue = AsBaseNumericType(unit); - return new {_quantity.Name}(convertedValue, unit); - }} - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private {_valueType} AsBaseUnit() - {{ - switch(Unit) - {{"); - foreach (var unit in _quantity.Units) - { - var func = unit.FromUnitToBaseFunc.Replace("x", "_value"); - Writer.WL($@" - case {_unitEnumName}.{unit.SingularName}: return {func};"); - } - - Writer.WL($@" - default: - throw new NotImplementedException($""Can not convert {{Unit}} to base units.""); - }} - }} - - private {_valueType} AsBaseNumericType({_unitEnumName} unit) - {{ - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - {{"); - foreach (var unit in _quantity.Units) - { - var func = unit.FromBaseToUnitFunc.Replace("x", "baseUnitValue"); - Writer.WL($@" - case {_unitEnumName}.{unit.SingularName}: return {func};"); - } - - Writer.WL(@" - default: - throw new NotImplementedException($""Can not convert {Unit} to {unit}.""); - } - } - - #endregion -"); - } - - private void GenerateToString() - { - Writer.WL($@" - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - {{ - return ToString(null); - }} - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: ""en-US"") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - {{ - var provider = cultureName; - return ToString(provider, 2); - }} - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: ""en-US"") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - {{ - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - }} - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: ""{{0:0.##}} {{1}} for value and unit abbreviation respectively."" - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: ""en-US"") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - {{ - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - }} - - #endregion -"); - } - - /// - internal static string? GetObsoleteAttributeOrNull(Quantity quantity) => GetObsoleteAttributeOrNull(quantity.ObsoleteText); - - /// - internal static string? GetObsoleteAttributeOrNull(Unit unit) => GetObsoleteAttributeOrNull(unit.ObsoleteText); - - /// - /// Returns the Obsolete attribute if ObsoleteText has been defined on the JSON input - otherwise returns empty string - /// It is up to the consumer to wrap any padding/new lines in order to keep to correct indentation formats - /// - private static string? GetObsoleteAttributeOrNull(string obsoleteText) => string.IsNullOrWhiteSpace(obsoleteText) - ? null - : $"[System.Obsolete(\"{obsoleteText}\")]"; - } -} diff --git a/CodeGen/Generators/UnitsNetWrcGen/QuantityTypeGenerator.cs b/CodeGen/Generators/UnitsNetWrcGen/QuantityTypeGenerator.cs deleted file mode 100644 index 582b299d6a..0000000000 --- a/CodeGen/Generators/UnitsNetWrcGen/QuantityTypeGenerator.cs +++ /dev/null @@ -1,39 +0,0 @@ -using CodeGen.JsonTypes; - -namespace CodeGen.Generators.UnitsNetWrcGen -{ - internal class QuantityTypeGenerator : GeneratorBase - { - private readonly Quantity[] _quantities; - - public QuantityTypeGenerator(Quantity[] quantities) - { - _quantities = quantities; - } - - public override string Generate() - { - Writer.WL(GeneratedFileHeader); - Writer.WL(@" -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - /// - /// Lists all generated quantities with the same name as the quantity struct type, - /// such as Length, Mass, Force etc. - /// This is useful for populating options in the UI, such as creating a generic conversion - /// tool with inputValue, quantityName, fromUnit and toUnit selectors. - /// - public enum QuantityType - { - Undefined = 0,"); - foreach (var quantity in _quantities) - Writer.WL($@" - {quantity.Name},"); - Writer.WL(@" - } -}"); - return Writer.ToString(); - } - } -} diff --git a/CodeGen/Generators/UnitsNetWrcGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetWrcGen/StaticQuantityGenerator.cs deleted file mode 100644 index e32928a152..0000000000 --- a/CodeGen/Generators/UnitsNetWrcGen/StaticQuantityGenerator.cs +++ /dev/null @@ -1,122 +0,0 @@ -using CodeGen.Helpers; -using CodeGen.JsonTypes; - -namespace CodeGen.Generators.UnitsNetWrcGen -{ - internal class StaticQuantityGenerator : GeneratorBase - { - private readonly Quantity[] _quantities; - - public StaticQuantityGenerator(Quantity[] quantities) - { - _quantities = quantities; - } - - public override string Generate() - { - Writer.WL(GeneratedFileHeader); - Writer.WL(@" -using System; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.InternalHelpers; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Dynamically parse or construct quantities when types are only known at runtime. - /// - internal static partial class Quantity - { - /// - /// Try to dynamically construct a quantity. - /// - /// Numeric value. - /// Unit enum value. - /// The resulting quantity if successful, otherwise default. - /// True if successful with assigned the value, otherwise false. - internal static bool TryFrom(double value, Enum unit, out IQuantity quantity) - { - switch (unit) - {"); - foreach (var quantity in _quantities) - { - var quantityName = quantity.Name; - var unitTypeName = $"{quantityName}Unit"; - var unitValue = unitTypeName.ToCamelCase(); - Writer.WL($@" - case {unitTypeName} {unitValue}: - quantity = {quantityName}.From(value, {unitValue}); - return true;"); - } - - Writer.WL($@" - default: - {{ - quantity = default(IQuantity); - return false; - }} - }} - }} - - /// - internal static IQuantity Parse(Type quantityType, string quantityString) => Parse(null, quantityType, quantityString); - - /// - /// Dynamically parse a quantity string representation. - /// - /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . - /// Quantity string representation, such as ""1.5 kg"". Must be compatible with given quantity type. - /// The parsed quantity. - /// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type. - internal static IQuantity Parse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString) - {{ - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) - throw new ArgumentException($""Type {{quantityType}} must be of type UnitsNet.IQuantity.""); - - if (TryParse(formatProvider, quantityType, quantityString, out IQuantity quantity)) return quantity; - - throw new ArgumentException($""Quantity string could not be parsed to quantity {{quantityType}}.""); - }} - - /// - internal static bool TryParse(Type quantityType, string quantityString, out IQuantity quantity) => - TryParse(null, quantityType, quantityString, out quantity); - - /// - /// Try to dynamically parse a quantity string representation. - /// - /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . - /// Quantity string representation, such as ""1.5 kg"". Must be compatible with given quantity type. - /// The resulting quantity if successful, otherwise default. - /// The parsed quantity. - internal static bool TryParse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString, out IQuantity quantity) - {{ - quantity = default(IQuantity); - - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) - return false; - - var parser = QuantityParser.Default; -"); - foreach (var quantity in _quantities) - { - Writer.WL($@" - if (quantityType == typeof({quantity.Name})) - return parser.TryParse<{quantity.Name}, {quantity.Name}Unit>(quantityString, formatProvider, {quantity.Name}.From, out quantity); -"); - } - - Writer.WL($@" - throw new ArgumentException( - $""Type {{quantityType}} is not a known quantity type. Did you pass in a third-party quantity type defined outside UnitsNet library?""); - }} - }} -}}"); - return Writer.ToString(); - } - } -} diff --git a/CodeGen/Generators/UnitsNetWrcGen/UnitAbbreviationsCacheGenerator.cs b/CodeGen/Generators/UnitsNetWrcGen/UnitAbbreviationsCacheGenerator.cs deleted file mode 100644 index 5695ad777a..0000000000 --- a/CodeGen/Generators/UnitsNetWrcGen/UnitAbbreviationsCacheGenerator.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Linq; -using CodeGen.JsonTypes; - -namespace CodeGen.Generators.UnitsNetWrcGen -{ - internal class UnitAbbreviationsCacheGenerator : GeneratorBase - { - private readonly Quantity[] _quantities; - - public UnitAbbreviationsCacheGenerator(Quantity[] quantities) - { - _quantities = quantities; - } - - public override string Generate() - { - Writer.WL(GeneratedFileHeader); - Writer.WL(@" -using System; -using UnitsNet.Units; - -// ReSharper disable RedundantCommaInArrayInitializer -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - public sealed partial class UnitAbbreviationsCache - { - private static readonly (string CultureName, Type UnitType, int UnitValue, string[] UnitAbbreviations)[] GeneratedLocalizations - = new [] - {"); - foreach (var quantity in _quantities) - { - var unitEnumName = $"{quantity.Name}Unit"; - - foreach (var unit in quantity.Units) - { - foreach (var localization in unit.Localization) - { - var cultureName = localization.Culture; - - // All units must have a unit abbreviation, so fallback to "" for units with no abbreviations defined in JSON - var abbreviationParams = localization.Abbreviations.Any() - ? string.Join(", ", localization.Abbreviations.Select(abbr => $"\"{abbr}\"")) - : "\"\""; - Writer.WL($@" - (""{cultureName}"", typeof({unitEnumName}), (int){unitEnumName}.{unit.SingularName}, new string[]{{{abbreviationParams}}}),"); - } - } - } - - Writer.WL(@" - }; - } -}"); - return Writer.ToString(); - } - } -} diff --git a/CodeGen/Generators/UnitsNetWrcGen/UnitTypeGenerator.cs b/CodeGen/Generators/UnitsNetWrcGen/UnitTypeGenerator.cs deleted file mode 100644 index 939d947a17..0000000000 --- a/CodeGen/Generators/UnitsNetWrcGen/UnitTypeGenerator.cs +++ /dev/null @@ -1,61 +0,0 @@ -using CodeGen.Helpers; -using CodeGen.JsonTypes; - -namespace CodeGen.Generators.UnitsNetWrcGen -{ - internal class UnitTypeGenerator : GeneratorBase - { - private readonly Quantity _quantity; - private readonly string _unitEnumName; - - public UnitTypeGenerator(Quantity quantity) - { - _quantity = quantity; - _unitEnumName = $"{quantity.Name}Unit"; - } - - public override string Generate() - { - Writer.WL(GeneratedFileHeader); - Writer.WL($@" -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum {_unitEnumName} - {{ - Undefined = 0,"); - - foreach (var unit in _quantity.Units) - { - if (unit.XmlDocSummary.HasText()) - { - Writer.WL(); - Writer.WL($@" - /// - /// {unit.XmlDocSummary} - /// "); - } - - if (unit.XmlDocRemarks.HasText()) - { - Writer.WL($@" - /// {unit.XmlDocRemarks}"); - } - - Writer.WLIfText(2, UnitsNetGen.QuantityGenerator.GetObsoleteAttributeOrNull(unit)); - Writer.WL($@" - {unit.SingularName},"); - } - - Writer.WL($@" - }} - - #pragma warning restore 1591 -}}"); - return Writer.ToString(); - } - } -} diff --git a/CodeGen/Generators/UnitsNetWrcGenerator.cs b/CodeGen/Generators/UnitsNetWrcGenerator.cs deleted file mode 100644 index 332aa599bd..0000000000 --- a/CodeGen/Generators/UnitsNetWrcGenerator.cs +++ /dev/null @@ -1,97 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System.IO; -using System.Linq; -using CodeGen.Generators.UnitsNetWrcGen; -using CodeGen.JsonTypes; -using Serilog; - -namespace CodeGen.Generators -{ - /// - /// Code generator for UnitsNet.WindowsRuntimeComponent project. - /// - internal static class UnitsNetWrcGenerator - { - private const int AlignPad = 35; - - /// - /// Generate source code for UnitsNet project for the given parsed quantities. - /// Outputs files relative to the given root dir to these locations: - /// - /// - /// - /// UnitsNet.WindowsRuntimeComponent/GeneratedCode (quantity and unit types, Quantity, - /// UnitAbbreviationCache) - /// - /// - /// - /// - /// Path to repository root directory. - /// The parsed quantities. - /// - /// NOTE! WRC target is deprecated and no longer actively maintained and will receive no new features. - /// No tests are generated or run for WRC and the code generator scripts are only updated to work when JSON schema - /// changes. - /// - public static void Generate(string rootDir, Quantity[] quantities) - { - var outputDir = $"{rootDir}/UnitsNet.WindowsRuntimeComponent/GeneratedCode"; - - // Ensure output directories exist - Directory.CreateDirectory($"{outputDir}/Quantities"); - Directory.CreateDirectory($"{outputDir}/Units"); - - foreach (var quantity in quantities) - { - GenerateQuantity(quantity, $"{outputDir}/Quantities/{quantity.Name}.g.cs"); - GenerateUnitType(quantity, $"{outputDir}/Units/{quantity.Name}Unit.g.cs"); - Log.Information("✅ {Quantity} (WRC)", quantity.Name); - } - - Log.Information(""); - GenerateUnitAbbreviationsCache(quantities, $"{outputDir}/UnitAbbreviationsCache.g.cs"); - GenerateQuantityType(quantities, $"{outputDir}/QuantityType.g.cs"); - GenerateStaticQuantity(quantities, $"{outputDir}/Quantity.g.cs"); - - var unitCount = quantities.SelectMany(q => q.Units).Count(); - Log.Information(""); - Log.Information("Total of {UnitCount} units and {QuantityCount} quantities (Windows Runtime Component)", unitCount, quantities.Length); - Log.Information(""); - } - - private static void GenerateQuantity(Quantity quantity, string filePath) - { - var content = new QuantityGenerator(quantity).Generate(); - File.WriteAllText(filePath, content); - } - - private static void GenerateUnitType(Quantity quantity, string filePath) - { - var content = new UnitTypeGenerator(quantity).Generate(); - File.WriteAllText(filePath, content); - } - - private static void GenerateUnitAbbreviationsCache(Quantity[] quantities, string filePath) - { - var content = new UnitAbbreviationsCacheGenerator(quantities).Generate(); - File.WriteAllText(filePath, content); - Log.Information("✅ UnitAbbreviationsCache.g.cs (WRC)"); - } - - private static void GenerateQuantityType(Quantity[] quantities, string filePath) - { - var content = new QuantityTypeGenerator(quantities).Generate(); - File.WriteAllText(filePath, content); - Log.Information("✅ QuantityType.g.cs (WRC)"); - } - - private static void GenerateStaticQuantity(Quantity[] quantities, string filePath) - { - var content = new StaticQuantityGenerator(quantities).Generate(); - File.WriteAllText(filePath, content); - Log.Information("✅ Quantity.g.cs (WRC)"); - } - } -} diff --git a/CodeGen/Program.cs b/CodeGen/Program.cs index 53624d025f..c51a9d7cf7 100644 --- a/CodeGen/Program.cs +++ b/CodeGen/Program.cs @@ -42,10 +42,9 @@ internal class Program /// /// Verbose output? Defaults to false. /// The repository root directory, defaults to searching parent directories for UnitsNet.sln. - /// Skip generate UnitsNet.WindowsRuntimeComponent? Defaults to false. /// Skip generate nanoFramework Units? Defaults to false /// Update nanoFramework nuget dependencies? Defaults to false. - public static int Main(bool verbose = false, DirectoryInfo? repositoryRoot = null, bool skipWrc = false, bool skipNanoFramework = false, bool updateNanoFrameworkDependencies = false) + public static int Main(bool verbose = false, DirectoryInfo? repositoryRoot = null, bool skipNanoFramework = false, bool updateNanoFrameworkDependencies = false) { Log.Logger = new LoggerConfiguration() .WriteTo @@ -69,11 +68,6 @@ public static int Main(bool verbose = false, DirectoryInfo? repositoryRoot = nul UnitsNetGenerator.Generate(rootDir, quantities); - if (!skipWrc) - { - UnitsNetWrcGenerator.Generate(rootDir, quantities); - } - if(updateNanoFrameworkDependencies) { NanoFrameworkGenerator.UpdateNanoFrameworkDependencies( diff --git a/Docs/UnitsNet.NuGet-README.md b/Docs/UnitsNet.NuGet-README.md deleted file mode 100644 index d135ea46e9..0000000000 --- a/Docs/UnitsNet.NuGet-README.md +++ /dev/null @@ -1,36 +0,0 @@ -## Units.NET - -Everyone have written their share of trivial conversions - or less obvious ones where you need to Google that magic constant. - -Stop littering your code with unnecessary calculations, Units.NET gives you all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. - -### Build Targets - -* .NET Standard 1.0 -* .NET 3.5 Client -* [Windows Runtime Component](https://docs.microsoft.com/en-us/windows/uwp/winrt-components/) for UWP apps (JavaScript, C++ or C#) - -### Overview - -* [50+ quantities with a total of 500+ units](UnitsNet/GeneratedCode/Enums) generated from [JSON](UnitsNet/UnitDefinitions/) by [Powershell scripts](UnitsNet/Scripts/GenerateUnits.ps1) -* [1000+ unit tests](https://ci.appveyor.com/project/angularsen/unitsnet) on conversions and localizations -* Quantities as immutable structs that implement `IEquatable`, `IComparable` -* [Static typing](#static-typing) to avoid ambiguous quantities or units -* [Operator overloads](#operator-overloads) for arithmetic on quantities -* [Extension methods](#extension-methods) for short-hand creation and conversions -* [Parse and ToString()](#culture) supports cultures and localization -* [Example: Creating a unit converter app](#example-app) -* [Precision and accuracy](#precision) -* [Serializable with JSON.NET](#serialization) -* Extensible with [custom units](https://github.com/angularsen/UnitsNet/wiki/Extending-with-Custom-Units) -* [Contribute](#contribute) if you are missing some units -* [Continuous integration](#ci) posts status reports to pull requests and commits -* [Who are using this?](#who-are-using) - -### Installing - -Run the following command in the [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console) or go to the [NuGet site](https://www.nuget.org/packages/UnitsNet/) for the complete relase history. - -``` -Install-Package UnitsNet -``` diff --git a/README.md b/README.md index 4a7ec8335e..d044960b2a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ ## Units.NET -Add strongly typed quantities to your code and get merrily on with your life. +Add strongly typed quantities to your code and get merrily on with your life. No more magic constants found on Stack Overflow, no more second-guessing the unit of parameters and variables. @@ -42,15 +42,14 @@ Run the following command in the [Package Manager Console](http://docs.nuget.org * .NET Standard 2.0 * .NET 4.0 * [.NET nanoFramework](https://www.nanoframework.net/) -* [Windows Runtime Component](https://docs.microsoft.com/en-us/windows/uwp/winrt-components/) for UWP apps (WinJS or C++) ### Static Typing ```C# -// Construct +// Construct Length meter = Length.FromMeters(1); Length twoMeters = new Length(2, LengthUnit.Meter); - + // Convert double cm = meter.Centimeters; // 100 double yards = meter.Yards; // 1.09361 @@ -61,8 +60,8 @@ double inches = meter.Inches; // 39.3701 string PrintPersonWeight(Mass weight) { // Compile error! Newtons belong to Force, not Mass. A common source of confusion. - double weightNewtons = weight.Newtons; - + double weightNewtons = weight.Newtons; + // Convert to the unit of choice - when you need it return $"You weigh {weight.Kilograms:F1} kg."; } @@ -166,7 +165,7 @@ All you need is the value and the unit enum value. IQuantity quantity = Quantity.From(3, LengthUnit.Centimeter); // Length if (Quantity.TryFrom(3, LengthUnit.Centimeter, out IQuantity quantity2)) -{ +{ } ``` #### Parse quantity @@ -336,12 +335,12 @@ JSON output: } ``` -If you need to support deserializing into properties/fields of type `IComparable` instead of type `IQuantity`, then you can add +If you need to support deserializing into properties/fields of type `IComparable` instead of type `IQuantity`, then you can add ```c# jsonSerializerSettings.Converters.Add(new UnitsNetIComparableJsonConverter()); ``` -**Important!** +**Important!** We cannot guarantee backwards compatibility, although we will strive to do that on a "best effort" basis and bumping the major nuget version when a change is necessary. The base unit of any unit should be treated as volatile as we have changed this several times in the history of this library already. Either to reduce precision errors of common units or to simplify code generation. An example is Mass, where the base unit was first Kilogram as this is the SI unit of mass, but in order to use powershell scripts to generate milligrams, nanograms etc. it was easier to choose Gram as the base unit of Mass. @@ -374,7 +373,7 @@ It would be awesome to know who are using this library. If you would like your p #### Swing Catalyst and Motion Catalyst, Norway > Sports performance applications for Windows and iOS, that combine high-speed video with sensor data to bring facts into your training and visualize the invisible forces at work -> +> > Units.NET started here in 2007 when reading strain gauge measurements from force plates and has been very useful in integrating a number of different sensor types into our software and presenting the data in the user's preferred culture and units. https://www.swingcatalyst.com (for golf)
@@ -419,7 +418,7 @@ https://www.ansys.com/products/3d-design/ansys-discovery-live *- Tristan Milnthorp, Principal Software Architect (tristan.milnthorp@ansys.com)* #### Primoris Sigma Stargen -Stargen is a decades old software to create realistic planets and satellites from a given Star. It's based on work from various scientists and been used for years. Primoris Sigma Stargen is a C# port of the utility that makes it a Framework to extend it with new algorithms for planetary formation and physics equations. +Stargen is a decades old software to create realistic planets and satellites from a given Star. It's based on work from various scientists and been used for years. Primoris Sigma Stargen is a C# port of the utility that makes it a Framework to extend it with new algorithms for planetary formation and physics equations. https://github.com/ebfortin/primoris.universe.stargen @@ -438,11 +437,11 @@ https://kito.com #### Structural Analysis Format - SDK project -> The Structural Analysis Format (SAF) has been created to allow structural engineering applications to exchange data using a straight forward and simple to understand format. -> While inspired by IFC, SAF has its benefits that it's **easily modifyable** by the end-user _(it's an xlsx file)_, **well documented** and **easy to understand**. +> The Structural Analysis Format (SAF) has been created to allow structural engineering applications to exchange data using a straight forward and simple to understand format. +> While inspired by IFC, SAF has its benefits that it's **easily modifyable** by the end-user _(it's an xlsx file)_, **well documented** and **easy to understand**. > UnitsNet is used by the SDK provided by SCIA to facilitate import / export between metric & imperial systems -https://www.saf.guide +https://www.saf.guide https://github.com/StructuralAnalysisFormat/StructuralAnalysisFormat-SDK *- Dirk Schuermans, Software Engineer for [SCIA nv](https://www.scia.net)* diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/.gitignore b/Samples/SimpleConversionDemo.UWP.CSharp/.gitignore deleted file mode 100644 index 96382d195c..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/project.lock.json diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml b/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml deleted file mode 100644 index b1c066daf0..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml +++ /dev/null @@ -1,8 +0,0 @@ - - - diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml.cs b/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml.cs deleted file mode 100644 index 1fba308c44..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/App.xaml.cs +++ /dev/null @@ -1,105 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Runtime.InteropServices.WindowsRuntime; -using Windows.ApplicationModel; -using Windows.ApplicationModel.Activation; -using Windows.Foundation; -using Windows.Foundation.Collections; -using Windows.UI.Xaml; -using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; - -namespace UWP -{ - /// - /// Provides application-specific behavior to supplement the default Application class. - /// - sealed partial class App : Application - { - /// - /// Initializes the singleton application object. This is the first line of authored code - /// executed, and as such is the logical equivalent of main() or WinMain(). - /// - public App() - { - this.InitializeComponent(); - this.Suspending += OnSuspending; - } - - /// - /// Invoked when the application is launched normally by the end user. Other entry points - /// will be used such as when the application is launched to open a specific file. - /// - /// Details about the launch request and process. - protected override void OnLaunched(LaunchActivatedEventArgs e) - { - -#if DEBUG - if (System.Diagnostics.Debugger.IsAttached) - { - this.DebugSettings.EnableFrameRateCounter = true; - } -#endif - - Frame rootFrame = Window.Current.Content as Frame; - - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (rootFrame == null) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - rootFrame.NavigationFailed += OnNavigationFailed; - - if (e.PreviousExecutionState == ApplicationExecutionState.Terminated) - { - //TODO: Load state from previously suspended application - } - - // Place the frame in the current Window - Window.Current.Content = rootFrame; - } - - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), e.Arguments); - } - // Ensure the current window is active - Window.Current.Activate(); - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new Exception("Failed to load Page " + e.SourcePageType.FullName); - } - - /// - /// Invoked when application execution is being suspended. Application state is saved - /// without knowing whether the application will be terminated or resumed with the contents - /// of memory still intact. - /// - /// The source of the suspend request. - /// Details about the suspend request. - private void OnSuspending(object sender, SuspendingEventArgs e) - { - var deferral = e.SuspendingOperation.GetDeferral(); - //TODO: Save application state and stop any background activity - deferral.Complete(); - } - } -} diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/LockScreenLogo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/LockScreenLogo.scale-200.png deleted file mode 100644 index 735f57adb5dfc01886d137b4e493d7e97cf13af3..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1430 zcmaJ>TTC2P7~aKltDttVHYH6u8Io4i*}3fO&d$gd*bA_<3j~&e7%8(eXJLfhS!M@! zKrliY>>6yT4+Kr95$!DoD(Qn-5TP|{V_KS`k~E6(LGS@#`v$hQo&^^BKsw3HIsZBT z_y6C2n`lK@apunKojRQ^(_P}Mgewt$(^BBKCTZ;*xa?J3wQ7~@S0lUvbcLeq1Bg4o zH-bvQi|wt~L7q$~a-gDFP!{&TQfc3fX*6=uHv* zT&1&U(-)L%Xp^djI2?~eBF2cxC@YOP$+9d?P&h?lPy-9M2UT9fg5jKm1t$m#iWE{M zIf%q9@;fyT?0UP>tcw-bLkz;s2LlKl2qeP0w zECS7Ate+Awk|KQ+DOk;fl}Xsy4o^CY=pwq%QAAKKl628_yNPsK>?A>%D8fQG6IgdJ ztnxttBz#NI_a@fk7SU`WtrpsfZsNs9^0(2a z@C3#YO3>k~w7?2hipBf{#b6`}Xw1hlG$yi?;1dDs7k~xDAw@jiI*+tc;t2Lflg&bM)0!Y;0_@=w%`LW^8DsYpS#-bLOklX9r?Ei}TScw|4DbpW%+7 zFgAI)f51s}{y-eWb|vrU-Ya!GuYKP)J7z#*V_k^Xo>4!1Yqj*m)x&0L^tg3GJbVAJ zJ-Pl$R=NAabouV=^z_t;^K*0AvFs!vYU>_<|I^#c?>>CR<(T?=%{;U=aI*SbZADLH z&(f2wz_Y0??Tf|g;?|1Znw6}6U43Q#qNRwv1vp9uFn1)V#*4p&%$mP9x&15^OaBiDS(XppT|z^>;B{PLVEbS3IFYV yGvCsSX*m diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/SplashScreen.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1feda78d5100569825acedfd213a0d84e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7700 zcmeHLYj~4Yw%(;oxoEH#Kxq-eR|+VkP17b#Vk;?4QwkI+A{L04G+#<<(x#Un1#+h5>eArRq zTw$)ZvTWW_Y?bDho0nPVTh08+s`sp!j74rJTTtXIDww0SILedFv?sZ?yb@@}GN;#8 znk_b~Q(A0YR#uV4ef!osoV1M3;vQ8N$O|fStfgf$S5;ddUNv`tWtGjM;koG#N;7M< zP*84lnx(bn_KF&9Z5Ai$)#Cs3a|$OFw>WKCT$of*L7_CqQEinflT|W{JT+aKp-E0v zsxmYg)1(T>DROm+LN1eQw8}KCTp=C!$H7`PU!t9_Hw@TsTI2`udRZv*!a5`#A9hK6Y95L(CDUX&_@QxKV z_feX{UhA#ZWlvgpL$#w^D#lq`_A4AzDqd|Zv6y9PX&DNcN|l}_D^{q@GG&H^Pg583 z8FI6N8^H7b5WjGp;urW)d7F+_lcp%KsLX0viCmE(OHH+=%ZfD_=`voUuoUxFO^L;- z;!;2{g-YiiO6m4bs89OuF9!p{FGtH-f%8<2gY!h9s)4ciN%{Kh1+`}{^}M~+TDH9N z^Z5PlgVXMC&2&k*Hw^Lb9gny#ro$MOIxIt{+r)EA10$VR3 zanN8D{TUkl+v0CQ_>ZoHP<M-x#8@8ZiT#$Kh`(uRaX1g$Bg|qy$<#7 zSSAi{Nb8Y=lvNVeio+UGLCAtoLBfL`iOv`)yoJMDJBN>4IH@(l7YRF;61@>qq1iM9 zr@b#OC~SAxSle?5Pp8Z78{VO0YFr1x7kZU64Z23eLf2T2#6J_t;-E}DkB?NufZ0Ug zi?J&byXeaB-uTNVhuiM!UVQw}bZrJ3GtAETYp->!{q#zfN7D3AS9@Q7*V^85jGx#R z(QxYV(wW#F0XF9^^s>>H8pPlVJ>)3Oz z&_X8Sf@~?cH_O*cgi$U#`v`RRfv#y3m(ZpKk^5uLup+lVs$~}FZU$r_+}#hl%?g5m z-u-}-666ssp-xWQak~>PPy$mRc|~?pVSs1_@mBEXpPVfLF6(Ktf1S* zPPh@QZ=tFMs?LM2(5P3L2;l_6XX6s&cYsP1ip#eg0`ZEP0HGYh{UmS@o`MihLLvkU zgyAG0G`b1|qjxxh1(ODKFE%AP}Dq=3vK$P7TXP4GrM1kQ72!GUVMDl`rDC&2;TA}*nF z8$nQD&6ys_nc1*E7$*1S@R8$ymy(sQV}imGSedB@{!QR5P&N_H=-^o!?LsWs+2|mH z-e=)T^SvI)=_JIm7}j4;@*Z17=(#}m=~YF~z~CLI+vdAGlJDcdF$TM?CVI1%LhUrN zaa6DJ=Yh$)$k&Oz{-~8yw^GM^8prYxSxo zvI4k#ibryMa%%*8oI-5m61Koa_A_xg=(fwp0aBX{;X4Q;NXUhtaoJDo1>TqhWtn=_ zd5~chq#&6~c%8JZK#t_&J(9EVUU&upYeIovLt1>vaHe}UUq>#RGQj!EN#5+0@T`(@ z^g~>*c`VGRiSt;!$_4+0hk^I!@O3``5=sZ8IwlxWW7km1B&_t&E*u0_9UBa#VqwY* zz>nxv?FAsVnRaD(Bui=6i==BFUw0k4n$>`umU`F2l?7CYTD^)c2X+d9X&ddS9|gj? zM?knGkGCX&W8offw8aLC2$D{PjC3nVZwd4k?eZH8*mZ)U@3Qk8RDFOz_#WUA#vnzy zyP>KrCfKwSXea7}jgJjBc}PGY+4#6%lbZyjhy`5sZd_Vy6Wz;ixa?czkN}J9It1K6 zY!eu>|AwF^fwZlLAYyQI*lM@^>O>Iu6Vf6i>Q$?v!SeUS<{>UYMwz$*%Aq?w^`j{h z!$GZbhu=^D{&ET8;))LL%ZBDZkQqRd2;u~!d9bHGmLRhLDctNgYyjsuvoSZ#iVdoB z2!f--UUA#U;<{je#?cYt^{PIyKa%hW>}uepWMyAI{{Zo7?2>?$c9;whJae%oN|I-kpTQSx_C$Z&;f zi2i)qmEn=y4U0uvk)$m;zKfjPK@oc?I`}1Jzl$Q~aoKBd3kt7L#7gyt|A_qgz6ai< z=X%D1i!d2h?rHR^R8SUj&G||dkC?DT>{o#Yau<@uqVT{Xef&XG}5*E4aPk{}~ zplx&XhaV)&1EfI3Em;Bw#O5SV^c;{twb-1Rw)+=0!e_BLbd7tYmXCH0wrlOSS+~`7He8Iqx0{CN+DVit9;*6L~JAN zD&cyT)2?h}xnYmL?^)<7YyzZ3$FHU^Eg;DLqAV{#wv#Wj7S`Jdl1pX&{3(uZ?!uh} zDc$ZTNV*7le_W6}Hju~GMTxZQ1aWCeUc%!jv3MHAzt>Y-nQK%zfT*3ebDQA5b?iGn; zBjv3B+GhLTexd_(CzZDP4|#n5^~scvB6#Pk%Ho!kQ>yYw((Dv{6=$g3jT1!u6gORW zx5#`7Wy-ZHRa~IxGHdrp(bm%lf>2%J660nj$fCqN(epv@y!l9s7@k6EvxS{AMP>WY zX4$@F8^kayphIx-RGO$+LYl9YdoI5d|4#q9##`_F5Xnx`&GPzp2fB{-{P@ATw=X@~ z_|&^UMWAKD;jjBKTK(~o?cUFRK8EX=6>cXpfzg4ZpMB>*w_^8GSiT-Jp|xBOnzM+j z*09-@-~qJ(eqWq5@R4i^u4^{McCP(!3}C|v_WsTR*bIUxN(Nx`u##3B4{sE`Z`v8w zAwIG`?1~PkID~W{uDzmqH98Pew_1(;x2%8r^vY{)_&J2K)cN{W+h5+g)ZcjP&Ci#O zgy|8K@4kyMfwilHd&6TDlhb%++Pk!>9HRld6HT7gwyZGrxS$}CsD6`>6!!2K1@Mjf z(P0WYB7V_OFZyeWrbOFb>O54BNXf~K&?}3=^v;v_wT{DKr?jN^DtN&DXwX%u?s*c6`%8>WFz z7}YW^tp0bp^NriE)AB6M2l<7rn7fzePtR*omOevpfm9n?}2V*+0iW;S)C zhg`NAjL?D=W#k*$aR{>pGf~lD-rVtD;5jW1_*Jn1j1=es@Kcx4ySM_bwcQCT=d+DV z>Sz~L=Hj@(X%31nK$mWI@7d>}ORB`K(p=+`UD)+99YUGQc7y^bHZ1F(8|tL0 zdK*DT0kSXG_{BKTpP2*2PecdKV9;dq$^ZZDP;Nyq1kp-&GI5eAyZsK!e3V zK@rPy*{(`KIfo+lc878mDKk^V#`VT05}64kBtk%DgwLrOvLMj5-;*GNKv6c6pzMuL z6EP%ob|_0IW}lLRXCP2!9wWhEw3LA7iF#1O1mIZ@Z=6&bz41F;@S_GvYAG-#CW3z{ zP3+6vHhvP&A3$##Vo9$dT^#MoGg^|MDm=Bt1d2RRwSZ<;ZHICpLBv5Xs!D?BH^(9_ z7`H=N&^v|Z-%mP}wNzG{aiFCsRgwzwq!N6obW9+7(R; z(SZ=23`|`>qil!LMGG{_Heq!BD>(Y-zV9wD)}hz25JA37YR%39;kI4y9pgtcUass6 zP24}ZY$vvYeI`zy&)A_X#nY3017ap*0&jx|mVwyGhg3;!keU53a}Uhm3BZI$N$6Se zLWlAmy1S0xKJm4G_U@sN_Tm=`$xWJSEwKU98rZ&)1R^*$$1vA3oG#&*%SMxY_~oGP zP&PFJatFLM-Ps%84IV-+Ow)T{C7cqUAvauy4C z(FRz&?6$Rypj{xO!`y=*J5o4@U8Q-(y5(*=YoKeZ+-1YdljXxkA#B)zo=FeQH#?Le zycNUmEEHWO9a=X^pb#&cOq7-`7UA87#|S22)<7RUtZo|(zibX=w;K3qur9vy#`MNV z6UUcf9ZwEnKCCp+OoBnF@OdbvH)ANXO0o~Pi9l8=x3))}L<#vO0-~O4!~--Ket?d} zJaqsj<@CD1%S2cTW%rOP{Vto%0sGW~1RMa_j^)5nil0Yw- z0EE#bP+l4#P^%PQ+N*oxu1Zq05xZ!bXfYTg>9c{(Iw*lnjR^>kz%lAN^zFce7rppy zY8zA~3GD=A6d*hze&l4D_wA~+O!56)BZTe_rEu}Ezi<4!kG|W#amBZ5{&XS2@6R~H z{9o^y*BkH4$~yX9U&@CgbOzX1bn9xqF|zh$Dh0Y5y*E0e90*$!ObrHY3Ok0`2=O~r zCuke6KrP9KOf?V(YDsM<6pX2nVoN%M$LT^q#FmtaF?1^27F*IcNX~XRB(|hCFvdcc zc)$=S-)acdk$g4?_>jRqxpI6M3vHZk?0c^3=byamYDNf;uB{3NlKW5IhnOS3DNkMV z?tK8?kJ}pmvp%&&eTVOVjHP`q34hN1@!aK}H(K!vI`~gf|Gv+FNEQD5Yd<~yX7k_l h&G-K)@HZb3BABY{)U1?^%I#E6`MGoTtustd{~yM6srvu` diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square150x150Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec1a5484db1d52a7f9b5ec90a27c7030186..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2937 zcma)84OCO-8BSud5)jwMLRVKgX(S?$n?Ld|vrsm<$CF7)&zTbyy1FE5bU`Q17MRv`9ue$;R(@8kR;#vJ*IM0>cJIAOte!d7oRgdH zd%ySjdB6L9=gX^A6)VzH7p2l@v~3zJAMw|DFy#^)F@@F*`mqUn=Il>l)8_+ab;nOW{%+iPx z+s{Eu|&pIs)Z7{La9~?xKfyl z#43?gjEL15d4WbOZo#SiP%>DB^+BcnJ=7dHEe;r#G=tuw|ka z%q@}##Uh7;tc%L_64m(kHtw74ty%BJMb)_1)#S0j`)F8_1jF7vScpsnH=0V19bO8y zR`0SjIdCUo&=>JwMQF8KHA<{ODHTiQh}0^@5QRmCA?gOH6_H3K^-_sNB^RrdNuK-R zOO*vOrKCVvDwgUck`kF(E7j{I#iiN;b*ZdCt4m@HPA`EuEqGGf4%!K<;(=I=&Vyrw z%TwcWtxa}8mCZ%Cyf&ActJ6_$ox5z6-D!0-dvnRx6t7y3d+h6QYpKWO;8OdnvERo7 zuEf>ih5`wqY)~o@OeVt-wM?Q!>QzdGRj!bz6fzYrfw$hZfAKzr2-M+D+R>}~oT574c;_3zquHcElqKIsryILt3g8n3jcMb+j?i?-L3FpZJ z2WRVBRdDPc+G5aaYg#5hpE+6nQ|(VSoxT3|biF;BUq#==-27Xi=gihDPYP$7?=9cP zYKE$jeQ|3~_L0VG-(F~2ZPyD0=k{J4Q~h(t__{-mz_w8{JDY9{`1ouzz!Vr5!ECdE z6U~O1k8c}24V7~zzXWTV-Pe4)y}wQJS&q%H5`Fo_f_JvIU489aCX$;P`u#!I-=^4ijC2{&9!O&h>mi?9oYD=GC#%)6{GzN6nQYw+Fal50!#x^asjBBR50i`+mho*ttoqV)ubM2KD9S~k7+FR4>{29?6 z{!l6kDdyTN0YJ9LgkPWeXm|gyi@zM3?0@{&pXT12w|78&W-q!RRF)&iLCEZVH<|fR zN0fr2^t8H(>L?>K#>^+jWROLral(Qy-xoBq1U7A&DV||wClb)Otd9?(gZ|8znMF}D zf<1haWz^s0qgecz;RFGt0C-B4g`jNGHsFU+;{<%t65v^sjk^h$lmWn#B0#_)9ij&d z-~lc`A)YYExi^7sBuPM^Y|wA2g*5?`K?#7tzELQYNxGo$UB$4J8RJp1k(8Jj+~hMT zlN~>M@KTTh^--8y3PK_NZ@AC!{PT=CziBzGd+wTJ^@icH!Bd}%)g8V)%K?|c&WTUk zy}qv1C%(fjRoZ4ozC3{O%@5?)XzH35zHns$pgU*Q?fj4v?fp1Qbm+j;3l;9jam9Da zXVcKjPlQ73x78QPu|Ffm6x?`~e3oD=gl=4kYK?={kD5j~QCXU)`HSdduNNENzA*2$ zOm3PzF!lN5e*06-f1Uot67wY#{o-S1!KZ7E=!~7ynnk9_iJR#kFoNbAOT#^2Gd17F zMmvU6>lndZQGd|ax9kUoXXO+$N?|j@6qpsF&_j7YXvwo_C{JpmLw5&#e6k>atv%es z5)7r*Wvv_JkUpT}M!_o!nVlEk1Zbl=a*2hQ*<|%*K1Glj^FcF`6kTzGQ3lz~2tCc@ z&x|tj;aH&1&9HwcJBcT`;{?a+pnej;M1HO(6Z{#J!cZA04hnFl;NXA+&`=7bjW_^o zfC40u3LMG?NdPtwGl>Tq6u}*QG)}-y;)lu-_>ee3kibW(69n0$0Zy!}9rQz%*v1iO zT9_H>99yIrSPYVy6^);rR}7Yo=J_T@hi+qhTZXnVWyf;JDYm5#eYLTxr*?kiNn!+Y zQ+LUkBafNJ#rH#C(?d5^;gw9o#%daEI{mA*LHPIHPU`#|H$hD zwm>0&+kahQ)E#%~k>&5@&#Vg82H?s%71=)(soi@174pi9--2{w{1$}Sz4zGn3Du&x bht0Iza^2ykEt4(epJ78uh5nDlX8(TxzDYwP diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2ec8a61291ba76c54604aea7e9d20af11b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1647 zcmaJ?eM}Q)7(e+G1Q(|`V9JhTI2>MkceK4;p;PR&$Pi?ejk3YQ_3o`S&|W_dsOZ8# zWPTt69g`t$ab`0cj-Y0yiBSOqmd)tG7G(}M5aP0_%&9TijB#&)I{zSE^4@#z^FF`l z`8{8`o%wlL(UI|y2!cdsuVamHH~H86F!*-15em4)NqUpCQM5?aoC_eCf@lV4wvF2a zjDQn1JBL69f&@2M3rvzJcfE!eZ8FZUBlFlC5RD)it33{mF9#B82AiyQE%w)`vlwa> zv{<1sm&kSKK$&%2jSFn7$t&P%%6Ue>R=EAnG8N7fqynWG8L3p!4801a;8{+nliO(qd(jNJ_?+9W3#hLIDLoT6~3fx9=`CC-D}-AMrpEO7HK zt3$GicGPc?GmDjy7K2P@La;eu4!$zWCZ`ym{Z$b zu-O6RM&K4JT|BIZB`E-gxqG%FzanI#+2FFmqHqXG7yxWB=w55RGOM)$xMb(>kSNR z2w=1AZi%z=AmG~yea~XaXJR!v7vLn(RUnELfiB1|6D84ICOS}^Zo2AdN}<&*h}G_u z{xZ!(%>tLT3J3<5XhWy-tg+6)0nmUUENLW8TWA{R6bgVd3X;anYFZ^IRis*_P-C-r z;i>%1^eL3UI2-{w8nuFFcs0e~7J{O2k^~Ce%+Ly4U?|=!0LH=t6()xi<^I-rs+9sF z*q{E-CxZbGPeu#a;XJwE;9S1?#R&uns>^0G3p`hEUF*v`M?@h%T%J%RChmD|EVydq zmHWh*_=S%emRC*mhxaVLzT@>Z2SX0u9v*DIJ@WC^kLVdlGV6LpK$KIrlJqc zpJ921)+3JJdTx|<`G&kXpKkjGJv=76R`yYIQ{#c-`%+`#V(7}Q;&@6U8!Td1`d;?N z_9mnI#?AA}4J!r)LN4!E-@H5eXauuB7TOawS>Y|{-P?NNx-lq+z1W-+y(;39P&&LP zL{N80?&=C*qKmdA^moMZRuPcD!B<*mq$ch=0Cnlitw#txRWhb3%TQvPqjkC`F69G4b! ze7z9MZ#+;_#l?H37UqUhDFb^l&s2{oM$3I0o^Q!yx;;V)QmCMo)Tb_ui|mit8MS?U zm##6$sZZ1$@|s%?l@>4Z<*Q}sRBSKMhb4I{e5LdEhsHIHTe8Bod5c>6QtT>$XgUBz z6MK`kO$=jmt@FqggOhJ5j~e@ygRbG;<{Vu)*+nn9aQeo0;$#j;|MS=S$&L?BeV25z xs3B`@=#`5TF{^6(A1rvdY@|-RtQ|iS5{tyX+wH?;n8E)G$kykv-D^wh{{!TZT%7;_ diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce97e0a802b85f6021e822c89f8bf57d5cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1255 zcmaJ>TWs4@7*5+{G#S+&C!qC#> zf>5N3P6jO*Cz>ug*(_DmW=)kea&m$gZ^+nyiF`;j%w@}y8)>p*SH}C`m?DXeieF2U zyQHecc_L%Gh!7GMt+hG06y;+|p4>m~}PjA}rKViGiEnn7G0ZO<>G|7q;2?NwGCM3s?eued6%hd$B+ z*kQJ{#~$S=DFE(%=E+UkmlEI*%3llUf~8Ja9YU1Vui0IbGBkW_gHB%Rd&!!ioX zs40O?i9I{};kle7GMvE7(rk`la=gTI)47=>%?q@^iL-nUo3}h4S}N-KHn8t5mVP8w z&bSErwp+37 zNJJ8?a|{r5Q3R0Z5s-LB1WHOwYC@7pCHWND#cL1cZ?{kJ368_*(UDWUDyb<}0y@o# zfMF016iMWPCb6obAxT$JlB6(2DrlXDTB&!0`!m??4F(qWMhjVZo?JXQmz`1*58Z=& zcDmB|S-E@j?BoFGix0flckqdS4jsPNzhfWyWIM98GxcLs89C(~dw%$_t;JjX-SD}E zfiGV;{8Q%8r}w9x>EEigW81>`kvnU@pK)4+xk9@+bNj9L!AAZ@SZ@q|)&BmY3+HZx zul~BeG4|}-;L%cHViQGQX?^zFfO0&#cHwel=d`lH9sJ-@Sl@n*(8J2>%Ac`IxyY?Q z{=GhWvC#gu-~Ia7*n{=+;qM?Ul_wy1+u7ho;=`>EwP^g~R@{unBds`!#@}tluZQpS zm)M~nYEifJWJGx?_6DcTy>#uh%>!H9=hb^(v`=m3F1{L>db=<5_tm+_&knAQ2EU$s Mu9UqpbNZeC0BbUo^Z)<= diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/StoreLogo.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/StoreLogo.png deleted file mode 100644 index 7385b56c0e4d3c6b0efe3324aa1194157d837826..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1451 zcmaJ>eN5D57_Z|bH;{0+1#mbl)eTU3{h)Wf7EZV?;HD@XL@{B`Ui%(2aMxQ~xdXSv z5nzWi(LW)U2=Vc-cY@s7nPt{i0hc6!7xN4NNHI#EQl>YNBy8l4%x9gr_W-j zEZMQmmTIy(>;lblRfh`dIyTgc9W5d!VP$L4(kKrN1c5G~(O_#xG zAJCNTstD^5SeXFB+&$h=ToJP2H>xr$iqPs-#O*;4(!Fjw25-!gEb*)mU}=)J;Iu>w zxK(5XoD0wrPSKQ~rbL^Cw6O_03*l*}i=ydbu7adJ6y;%@tjFeXIXT+ms30pmbOP%Q zX}S;+LBh8Tea~TSkHzvX6$rYb)+n&{kSbIqh|c7hmlxmwSiq5iVhU#iEQ<>a18|O^Sln-8t&+t`*{qBWo5M?wFM(JuimAOb5!K#D}XbslM@#1ZVz_;!9U zpfEpLAOz=0g@bd6Xj_ILi-x^!M}73h^o@}hM$1jflTs|Yuj9AL@A3<-?MV4!^4q`e z)fO@A;{9K^?W?DbnesnPr6kK>$zaKo&;FhFd(GYFCIU^T+OIMb%Tqo+P%oq(IdX7S zf6+HLO?7o0m+p>~Tp5UrXWh!UH!wZ5kv!E`_w)PTpI(#Iw{AS`gH4^b(bm^ZCq^FZ zY9DD7bH}rq9mg88+KgA$Zp!iWncuU2n1AuIa@=sWvUR-s`Qb{R*kk(SPU^`$6BXz8 zn#7yaFOIK%qGxyi`dYtm#&qqox0$h=pNi#u=M8zUG@bpiZ=3sT=1}Trr}39cC)H|v zbL?W)=&s4zrh)7>L(|cc%$1#!zfL?HjpeP%T+x_a+jZ16b^iKOHxFEX$7d|8${H-* zIrOJ5w&i$>*D>AKaIoYg`;{L@jM((Kt?$N$5OnuPqVvq**Nm}(f0wwOF%iX_Pba;V z;m@wxX&NcV3?<1+u?A{y_DIj7#m3Af1rCE)o`D&Y3}0%7E;iX1yMDiS)sh0wKi!36 zL!Wmq?P^Ku&rK~HJd97KkLTRl>ScGFYZNlYytWnhmuu|)L&ND8_PmkayQb{HOY640 bno1(wj@u8DCVuFR|31B*4ek@pZJqxCDDe1x diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Wide310x150Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.CSharp/Assets/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b397fdbef1fb7e85afd71445d5de1952c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3204 zcmbVPeQXow8NYmBd90>}0NP?GhXW~VaeThm=a0tV#EwJMI!)6M3}|c4_Bl3=Kd>G0 z(GHx1wl<7(tP?FsOQkTilSo*iIvF%uArExJ73~P zSv1xEy!U(Wd4A9D`FQV@W3@F^qJ@PEF$@z`Z!*BbFsS(^?B zyiAzJ+q})bkgiQHWqEb*jJD-coHYr1^iocg)l!Qa{Xqs-l~6J}p-|##ZHYofskQ3$ zI0;xzXyhazBeXhIsg5A=%ufo@f)1yy&ScKS0;HF^!r_2UE^lpZEom(+@duma3awTv zCrCL-%D_SvYWIcdHkmI}#50(fkUi)Qgx!80ju>g1za^}ff>JI8Z@^-iCiaCgg@TgF z+vtE?Q9{VQUX&MW9SYYmGcxA14%N2@7FwBTD4N<(2{nWgV8$e3?-F=L^&FrtWn~(U_Q~~^uYiyeY6-KoTnfh9AWz@ zIKje0)u!_Lw)E}G!#kEfwKVdNt(UAf9*f>tEL_(=xco-T%jTi@7YlC3hs2ik%Le0H ztj}RTeCF(5mwvi3_56>-yB?l;J>-1%!9~=fs|QcNG3J~a@JCu`4SB460s0ZO+##4fFUSGLcj_ja^fL4&BKALfb#$6$O?>P@qx2Agl^x0i&ugt zsy5Pyu=()`7HRMG3IB7F1@`_ z+-!J%#i6e^U$e#+C%Q>_qVRzWRsG^W_n+@OcX@vzI&z;mzHNb!GQ?LWA(wtpqHqTM z1OFw_{Zn?fD)p)`c`kOgv{de=v@suGRqY{N^U7gI1VF3*F=obwaXI6ob5__Yn zVTguS!%(NI09J8x#AO_aW!9W7k*UvB;IWDFC3srwftr{kHj%g)fvnAm;&h_dnl~

MY- zf+K}sCe8qU6Ujs`3ua{U0Of$R_gVQBuUA za0v=mu#vIOqiiAZOr&h*$WyOw&k-xr$;G4Ixa!#TJNr>95(h>l%)PUy4p+^SgR(uR zta%k*?ny-+nAr8spEk1fo{J4i!b^Fia`N{_F6@zidA2ZTTrjl#^5Z-2KfB@Cu}l9s z(*|Z2jc?p~vn2f)3y9i*7zJV1L{$?|&q)4oaT;uXi6>1GkRXVTOzAz(RHEmr=eFIi z`}<>-Q?K0GN8!IYxeP1XKXO+jsJbp~o^);Bc;%b7Flpe7;1`Ny@3r7ZR;?R)aJt8C ziNlEC<@3f_lIV4TwV}&e;D!Ee5_|e#g0LUh=5vmYWYm7&2h*M>QPKvGh9-)wfMMW3 z8J9b%1k7dzPzO0_NGQy92BZ^FR6R~6;^6?lqO;-QUP4BY%cG%3vEhbm#>4vIhPBh3 z-+pZGjh$x%Hp{?=FHsMp0&wNPlj00us{&`1ZOZTqs8%4X&xH=UDr*xyBW(Zp&Em94 zf)ZSfn#yg0N)>!1kWdkqJ^S*z0FF5|fj&qcE#Na|%OY0$uO>!&hP+1ywfD_WXk@4J(?MBftK7>$Nvqh@tDuarN%PrTLQ2Uzysx>UV=V zk^RrDSvdQ?0;=hY67EgII-f4`t=+i*yS=Y~!XlqIy_4x&%+OdfbKOFPXS2X5%4R{N z$SQMX^AK6(fA - - - - - diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs b/Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs deleted file mode 100644 index d2e8c25c54..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/MainPage.xaml.cs +++ /dev/null @@ -1,32 +0,0 @@ -using Windows.UI.Xaml.Controls; -using UnitsNet; -using UnitsNet.Units; - -namespace UWP -{ - ///

- /// An empty page that can be used on its own or navigated to within a Frame. - /// - public sealed partial class MainPage : Page - { - /// - /// Example of public property returning WinRT component compatible type. - /// - public Temperature MyTemperature { get; set; } - - public MainPage() - { - InitializeComponent(); - - // Test some variations, From() constructors, Parse(), As() - string celsius = Temperature.FromDegreesCelsius(100).ToUnit(TemperatureUnit.DegreeCelsius).ToString(); - string fahrenheit = Temperature.Parse("100 °C").ToUnit(TemperatureUnit.DegreeFahrenheit).ToString(); - string kelvin = Temperature.FromDegreesCelsius(Temperature.Parse(fahrenheit).As(TemperatureUnit.DegreeCelsius)).ToUnit(TemperatureUnit.Kelvin).ToString(); - - // Arithmetic operators not allowed in WinRT Components, but SHOULD be allowed in UWP C# apps - // new Temperature(5) + new Temperature(6) - - MyTextBlock.Text = $"{celsius} = {fahrenheit} = {kelvin}"; - } - } -} diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest b/Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest deleted file mode 100644 index 4aa128459b..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/Package.appxmanifest +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - UWP - Andreas - Assets\StoreLogo.png - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Properties/AssemblyInfo.cs b/Samples/SimpleConversionDemo.UWP.CSharp/Properties/AssemblyInfo.cs deleted file mode 100644 index eaf72df06f..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("UWP")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("UWP")] -[assembly: AssemblyCopyright("Copyright © 2016")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Build and Revision Numbers -// by using the '*' as shown below: -// [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ComVisible(false)] \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/Properties/Default.rd.xml b/Samples/SimpleConversionDemo.UWP.CSharp/Properties/Default.rd.xml deleted file mode 100644 index 80a960ce32..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/Properties/Default.rd.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/README.md b/Samples/SimpleConversionDemo.UWP.CSharp/README.md deleted file mode 100644 index e922422524..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/README.md +++ /dev/null @@ -1,9 +0,0 @@ -## Test app: UWP C# and .NET 4.6.1 - -Illustrates using `UnitsNet.WindowsRuntimeComponent` from an UWP C# app. -The Windows Runtime Component nuget can be consumed from C#, JavaScript and C++ UWP apps. - -NOTE: Normally for C# UWP apps you would use the more feature-rich `UnitsNet` nuget, since Windows Runtime Component -only supports some of the .NET BCL types and has many constraints on how the public API of the library can be declared. - -![image](https://user-images.githubusercontent.com/787816/35769617-e0bf05b4-090d-11e8-85e4-efdd7b90a6be.png) \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj b/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj deleted file mode 100644 index 19f9c3b450..0000000000 --- a/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp.csproj +++ /dev/null @@ -1,141 +0,0 @@ - - - - - Debug - x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E} - AppContainerExe - Properties - UWP - UWP - en-US - UAP - 10.0.16299.0 - 10.0.16299.0 - 14 - 512 - {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx - E98156EA0B8126C89A2653E1CBF645701A704E52 - - - true - bin\x86\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x86 - false - prompt - true - - - bin\x86\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x86 - false - prompt - true - true - - - true - bin\ARM\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - ARM - false - prompt - true - - - bin\ARM\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - ARM - false - prompt - true - true - - - true - bin\x64\Debug\ - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - ;2008 - full - x64 - false - prompt - true - - - bin\x64\Release\ - TRACE;NETFX_CORE;WINDOWS_UWP - true - ;2008 - pdbonly - x64 - false - prompt - true - true - - - - - - - - - App.xaml - - - MainPage.xaml - - - - - - Designer - - - - - - - - - - - - - - - MSBuild:Compile - Designer - - - MSBuild:Compile - Designer - - - - 14.0 - - - - \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx b/Samples/SimpleConversionDemo.UWP.CSharp/SimpleConversionDemo.UWP.CSharp_TemporaryKey.pfx deleted file mode 100644 index 61cfb8eca28916b939aaf5fbd9591d72c51956d4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2528 zcmZXVcU05a632gmKnR8^plE=gpcI7!5(x4r3qhosMUjZo1f)u@flz`XD^jE@WkFi# ztW+t|K@m2rKnyj&(tA^y!i#&}+dc2RbI;tF?`P)TGymMVNHTPs1;mOZL(|xyGLbhT z_qae1P&OI*3z!Uj!o=Z7GTY(*q}W!#WVQt+{*!48_EY~k1>*#8sBGlT(2)KT*{p&<4T2?zin{Q{=_e}CfqpqN-^Hth0zsT+*58prEkfaE6JzM z_`?z*Q=@O`fl%yBOzto0z2LF_uMZD3Qe9h)AQ(;VVzlzQh{xHbdLDlB9W}ba*YcCufZn zLz0c3vQ;9(Q`2A?3}O5T1*Ei(burd6BD8g9 zE*4Vhjd8Epxue>{&>^`~{kPNGeY7W^E{W?%wRw9D?*(O>E-^T73UitGi#%9F_m;MF zb@xpU&|%d5x0npv0qVM{bH`p??}+=l^x{xJT~krGp_H%(>!YII`s_28e_y#RJ>I{67#3CDia%@iV!Fk46yK`DNzo(aG>e4(($~iVp<4*lXkoL5Ow#MD!Eqze> z-Q(_Zod`85WwhF(mVHMi^wD!(sei%Bh0Z>8aaVq)4E!M+5D}9EwELb@dMNyD+nX0? z{Z~%u!K#;fNe7>q=lpX52kupM1!qfhOz!|~O3X5ldp0a+X7jnht_LOK#gNix)i8Vk zvDkSkwZ?XaBr;lPZF@K>jZ$CAi;hwG%97_8?7Ws2)Bg~8D!EWo17y$D>z7Tu5n5wW zLu*T{6AC;RG3#0MRJIT^(j9tD%-bh_i_xyl>NiB&m6-Y<%ryPfUM(I`M3rP>>7S-PS*5;d!lo8F{iSCuO+!EkQ^=wdDTJ zqm?r*UiYs*i+-dD-}z}#W<+zyFB_9D{k<#0LSl-eeibIU7S#BZtfs1+gfzoL6&|*0a<2s4109Hp&EFd zx*Jq3gLhLC7{e^SZ^pF>qy`?n9#J7JeN=BTtZx1z?C&HjM`D1FfzfDNDkJOI#uJ=0LYL*Oc) z2q2jZ#f;E^3ZTqXSD7Bo%%PbPidp?b{qQIN3)nK35`aQlutR0pL0}MBnGb}*iy8w) zfD<$21-Jv=OnV6U00`g~bN@ly00*YhX2yYl2a~xowHLD$55V!SQwRY6SDhbI*)d!5 zLXufS|Lz>Zo=s-;U?Nu*5WsZy|71Y_Kl1Ns2MN>Fij#kg{4g>rHY14?lsIeaFdoXo zTOnb5(fDBS(aZjppkapo2c)G03FY>pUNsLVqfcFtfl6{HDC}ifID{lv&R}G)kPk(D zi+3b0xOqITA-#W=5q9Umuy0<0f$q;6+}`A1zh^*6b>cXjmqEd2KsQ>7Ob$G?)=Uo??M z+nf(;sKZNa~^}C4?U211MI#te8Dd5n8bL*RVr1=ey!bAY}{Bf*u zRjzDsRy|>#cKhR;xvLm#uLPnXl=LxLB(Nht?z#ki>1(vxC)cDgmBohY(sI$Mq_2MP zZV|7iRY%7lnF7aU`AMBs&PLP?STH9D0bN_ZmSlEvI1&UMaOxWK=`H| zE@`#OF8&!Jm#WY89pro^@m6uv$Qwa5_*`pAW?l*pXfeYE0+p;=@R4K5$ri;ZoE$jp z#&-ExY|fD?cD(FzM1X^`O&H9YS||7fi@vhZ;ybs98`ncui%h?Ldu!oON~vE_yPLRL zyv&)8Ss;$I0(r+vPkSf&bvB1M`ydFVb(pUNjwN1O+L1HLz>U5*cU7eKLBt_kP$MOI zG8(%@I2NNcn9ms5GfFSfVokWAavaB@LHLU3SG-2FTN9p=s`Nc_){`%KbVL>{o!%y) zc}uOOXGn1LP4&()FLd+C$m57)%;Yi_!;fyYE}$b-kzz;)JDV&wE6X{sK$Xgz)d1CX qgtr<4?Z%nD{WYa88!Rv-nI+P&ZgaWhlT9LIt?6pvF~ - - - - Debug - AnyCPU - - - Debug - ARM - - - Debug - x64 - - - Debug - x86 - - - Release - AnyCPU - - - Release - ARM - true - - - Release - x64 - true - - - Release - x86 - true - - - - f5b26152-a64b-42a8-8f19-d2eafb94cbd1 - - - - 15.0 - - - - - UAP - 10.0.16299.0 - 10.0.16299.0 - $(VersionNumberMajor).$(VersionNumberMinor) - en-US - SimpleConversionDemo.UWP.WinJS_TemporaryKey.pfx - 233FD264CDB1D145E2BAA90728A41382699F2046 - - - - Designer - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS_TemporaryKey.pfx b/Samples/SimpleConversionDemo.UWP.WinJS/SimpleConversionDemo.UWP.WinJS_TemporaryKey.pfx deleted file mode 100644 index 8cdfed649f7b9f3c9744553f78212ff43447dfda..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2528 zcmZXUcT|(v62QMe2ni)pVkn_129{<*S2{?Ml7t$hNef6v6p$t)2uo4wBF$YXqI4+> zC?FtJhzN=_1;L;cL1{sxZ`||V?s?~(Idf;`H|5@c?qDdeX(kXeh62llz@!t56LvU3 zte`>)ED213#WOG&Lt)wbpA^dqn8LEi!1D~9g|Pppi-QfsR7e3IVJP4|j1YwFznC!` z4u%R#JZ8Rr)bNRkiFE`_0Z&@e>W-`ec#k_e!a_3K1wP$#j&H4brG^)RS6|J&n^?CR ziW=qSRvJc2^s*T}lzx{W3+QtyhMn2fPCRvzS|t!Rlxw15g^WKzq}n4{-Hr@@k$s&N z*K}cnYeo5^yZ#7LV&-D?hQZxkF2fNU`qs_cEW%@#e(&F|m}YyQ4vxWlJME?}1j}k? zD~1TMP)pfQOIbT{)8X%^9!t}58a`q9kuwf4OqX+bZDcN>>)SQLfhg z9c1Z!Ar39>zS>F$nIHL(h_MtW6SMg!`LGX*&H{x)Z$y=Gh%a{j;-7O1%*r+W+*1y~ zflPjnSML4bH-Fd8`g@rHR~OjU+ah~LIgsUIn3rV{@q%|7yZW74ykRGAd#Z?ElN4LT z<*@EEg1*L27EzH4vFE{v4-}y!`-Lo;W2gKe4;;H z=Mi}sYQ21FCFyM;>GG54DUkZj_cP5B^Ebg z!5LqT880nGHn{TXfz1fxml`x0Er*0O%BZKNRR-?btPkXNn#9&v0DJYuC3|WOA9kPx&eF4!JUu7K7c@8k?oZBvwrKOE*{a+7-W;MIBMm%a;(GpEM{aiV<5%FpG*%BEM-^P|n^d-fY^|$nx zI5N>O{Gs z(%_fuAnYw;GJF?A(26lbngJTAwj9JyEm1 zr!#tCw@y-lwumJUVR-*pm#~vq2p9|k002Y$7b37GBF2Cxpu!L=Lp%TlKoO7wFn}7M z%wTeW5+m!$IOPC0K$T&CGB-xn_3wHtaE{@V7_~}(2gV5klYxN1Ac`tC2ul#b0p@@= z;0^=>fxtC}dIHx0F~Ev({v-i_7bDVV_~Aehg9S3;V8+-W;L6`!VgTXqx==>s!MGwA zLt&2j=jE)BLJD&b1Nkw50EQv`n*sg*%8!Ekjc92}-}$-nV=2sPXBEMwo|#kpD<9x( z(cM!+nJtcfZjk2Buv+y}^cr_7=XRM+(1Pv}=PSY&{9%PMe_S5$phnfs@^sQ@f0Z`U zT}KeTPD^;baLhS{&8S+wDEgIVDnQbmLX-#z=Es>)RHmXPkfVvumeXUGKokYP^LhR| zJvjI9`5%|Rhb4RrskM-ho{NuAdDBM@WxZY6WOLHyRZLSy3lG7qkh+}Tz9G9-79{R~ z+uIoS9dPLr(vPXzz$C_LC6Ma0!%$noh+I|D#_VmHu5*pZ6qySo=&4r#W?B29Q9?d; zJ(O{Kn%Y}jQ=RA|p60W@8q8T4y}?xTIb^e~i|y!bZ2Y&IJmm1_OmF0;m$d56R+hE3 zphU*lxxdk*A7d_%5F8DJY93w96QuwjkdvYqvQDaz9XNB zm=ue~`f8U4qUpba!qjdZA;gt`k0;P?tUXS&uSV1y}OQ-iQM%f6k|t(n;U=2*08+>09Z9n8GV zrPpw>l5BMe7@Tol^(@jo-+Y6!G|+bt1I+wfF_V~BYC!RX8PtsUT24GwLQ(e^ zu6*B~ipjZ@J>R6VSNW7xps%%KHCU%eqn~i6WxpW>KIlqi(Uv^C)|KUz5cwLL6ub=E))NO>NhJ73*flLX5d5StzeMoLh95)uXgy}qwhZ$u>rbKC4uUsCo z5kTd4oHr*wnKRqvT%V~U^R1Vj>LHxH$Oqbb(JUY5>xpq44{Upx*1+UdO`e~VH{1!Q zHgoovbq;+}_HTbPJc|^6Df)}80kl0Z5p!xI8&#-*QOAg4SRpJjaAqb!Fv3LcV{PRy q5*1o_)N^28)Gw4-K?EbF4+eSnPvjAc{MvSf2bVL5>YL=BAMY>MTTC2P7~aKltDttVHYH6u8Io4i*}3fO&d$gd*bA_<3j~&e7%8(eXJLfhS!M@! zKrliY>>6yT4+Kr95$!DoD(Qn-5TP|{V_KS`k~E6(LGS@#`v$hQo&^^BKsw3HIsZBT z_y6C2n`lK@apunKojRQ^(_P}Mgewt$(^BBKCTZ;*xa?J3wQ7~@S0lUvbcLeq1Bg4o zH-bvQi|wt~L7q$~a-gDFP!{&TQfc3fX*6=uHv* zT&1&U(-)L%Xp^djI2?~eBF2cxC@YOP$+9d?P&h?lPy-9M2UT9fg5jKm1t$m#iWE{M zIf%q9@;fyT?0UP>tcw-bLkz;s2LlKl2qeP0w zECS7Ate+Awk|KQ+DOk;fl}Xsy4o^CY=pwq%QAAKKl628_yNPsK>?A>%D8fQG6IgdJ ztnxttBz#NI_a@fk7SU`WtrpsfZsNs9^0(2a z@C3#YO3>k~w7?2hipBf{#b6`}Xw1hlG$yi?;1dDs7k~xDAw@jiI*+tc;t2Lflg&bM)0!Y;0_@=w%`LW^8DsYpS#-bLOklX9r?Ei}TScw|4DbpW%+7 zFgAI)f51s}{y-eWb|vrU-Ya!GuYKP)J7z#*V_k^Xo>4!1Yqj*m)x&0L^tg3GJbVAJ zJ-Pl$R=NAabouV=^z_t;^K*0AvFs!vYU>_<|I^#c?>>CR<(T?=%{;U=aI*SbZADLH z&(f2wz_Y0??Tf|g;?|1Znw6}6U43Q#qNRwv1vp9uFn1)V#*4p&%$mP9x&15^OaBiDS(XppT|z^>;B{PLVEbS3IFYV yGvCsSX*m diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/images/SplashScreen.scale-200.png b/Samples/SimpleConversionDemo.UWP.WinJS/images/SplashScreen.scale-200.png deleted file mode 100644 index 023e7f1feda78d5100569825acedfd213a0d84e9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7700 zcmeHLYj~4Yw%(;oxoEH#Kxq-eR|+VkP17b#Vk;?4QwkI+A{L04G+#<<(x#Un1#+h5>eArRq zTw$)ZvTWW_Y?bDho0nPVTh08+s`sp!j74rJTTtXIDww0SILedFv?sZ?yb@@}GN;#8 znk_b~Q(A0YR#uV4ef!osoV1M3;vQ8N$O|fStfgf$S5;ddUNv`tWtGjM;koG#N;7M< zP*84lnx(bn_KF&9Z5Ai$)#Cs3a|$OFw>WKCT$of*L7_CqQEinflT|W{JT+aKp-E0v zsxmYg)1(T>DROm+LN1eQw8}KCTp=C!$H7`PU!t9_Hw@TsTI2`udRZv*!a5`#A9hK6Y95L(CDUX&_@QxKV z_feX{UhA#ZWlvgpL$#w^D#lq`_A4AzDqd|Zv6y9PX&DNcN|l}_D^{q@GG&H^Pg583 z8FI6N8^H7b5WjGp;urW)d7F+_lcp%KsLX0viCmE(OHH+=%ZfD_=`voUuoUxFO^L;- z;!;2{g-YiiO6m4bs89OuF9!p{FGtH-f%8<2gY!h9s)4ciN%{Kh1+`}{^}M~+TDH9N z^Z5PlgVXMC&2&k*Hw^Lb9gny#ro$MOIxIt{+r)EA10$VR3 zanN8D{TUkl+v0CQ_>ZoHP<M-x#8@8ZiT#$Kh`(uRaX1g$Bg|qy$<#7 zSSAi{Nb8Y=lvNVeio+UGLCAtoLBfL`iOv`)yoJMDJBN>4IH@(l7YRF;61@>qq1iM9 zr@b#OC~SAxSle?5Pp8Z78{VO0YFr1x7kZU64Z23eLf2T2#6J_t;-E}DkB?NufZ0Ug zi?J&byXeaB-uTNVhuiM!UVQw}bZrJ3GtAETYp->!{q#zfN7D3AS9@Q7*V^85jGx#R z(QxYV(wW#F0XF9^^s>>H8pPlVJ>)3Oz z&_X8Sf@~?cH_O*cgi$U#`v`RRfv#y3m(ZpKk^5uLup+lVs$~}FZU$r_+}#hl%?g5m z-u-}-666ssp-xWQak~>PPy$mRc|~?pVSs1_@mBEXpPVfLF6(Ktf1S* zPPh@QZ=tFMs?LM2(5P3L2;l_6XX6s&cYsP1ip#eg0`ZEP0HGYh{UmS@o`MihLLvkU zgyAG0G`b1|qjxxh1(ODKFE%AP}Dq=3vK$P7TXP4GrM1kQ72!GUVMDl`rDC&2;TA}*nF z8$nQD&6ys_nc1*E7$*1S@R8$ymy(sQV}imGSedB@{!QR5P&N_H=-^o!?LsWs+2|mH z-e=)T^SvI)=_JIm7}j4;@*Z17=(#}m=~YF~z~CLI+vdAGlJDcdF$TM?CVI1%LhUrN zaa6DJ=Yh$)$k&Oz{-~8yw^GM^8prYxSxo zvI4k#ibryMa%%*8oI-5m61Koa_A_xg=(fwp0aBX{;X4Q;NXUhtaoJDo1>TqhWtn=_ zd5~chq#&6~c%8JZK#t_&J(9EVUU&upYeIovLt1>vaHe}UUq>#RGQj!EN#5+0@T`(@ z^g~>*c`VGRiSt;!$_4+0hk^I!@O3``5=sZ8IwlxWW7km1B&_t&E*u0_9UBa#VqwY* zz>nxv?FAsVnRaD(Bui=6i==BFUw0k4n$>`umU`F2l?7CYTD^)c2X+d9X&ddS9|gj? zM?knGkGCX&W8offw8aLC2$D{PjC3nVZwd4k?eZH8*mZ)U@3Qk8RDFOz_#WUA#vnzy zyP>KrCfKwSXea7}jgJjBc}PGY+4#6%lbZyjhy`5sZd_Vy6Wz;ixa?czkN}J9It1K6 zY!eu>|AwF^fwZlLAYyQI*lM@^>O>Iu6Vf6i>Q$?v!SeUS<{>UYMwz$*%Aq?w^`j{h z!$GZbhu=^D{&ET8;))LL%ZBDZkQqRd2;u~!d9bHGmLRhLDctNgYyjsuvoSZ#iVdoB z2!f--UUA#U;<{je#?cYt^{PIyKa%hW>}uepWMyAI{{Zo7?2>?$c9;whJae%oN|I-kpTQSx_C$Z&;f zi2i)qmEn=y4U0uvk)$m;zKfjPK@oc?I`}1Jzl$Q~aoKBd3kt7L#7gyt|A_qgz6ai< z=X%D1i!d2h?rHR^R8SUj&G||dkC?DT>{o#Yau<@uqVT{Xef&XG}5*E4aPk{}~ zplx&XhaV)&1EfI3Em;Bw#O5SV^c;{twb-1Rw)+=0!e_BLbd7tYmXCH0wrlOSS+~`7He8Iqx0{CN+DVit9;*6L~JAN zD&cyT)2?h}xnYmL?^)<7YyzZ3$FHU^Eg;DLqAV{#wv#Wj7S`Jdl1pX&{3(uZ?!uh} zDc$ZTNV*7le_W6}Hju~GMTxZQ1aWCeUc%!jv3MHAzt>Y-nQK%zfT*3ebDQA5b?iGn; zBjv3B+GhLTexd_(CzZDP4|#n5^~scvB6#Pk%Ho!kQ>yYw((Dv{6=$g3jT1!u6gORW zx5#`7Wy-ZHRa~IxGHdrp(bm%lf>2%J660nj$fCqN(epv@y!l9s7@k6EvxS{AMP>WY zX4$@F8^kayphIx-RGO$+LYl9YdoI5d|4#q9##`_F5Xnx`&GPzp2fB{-{P@ATw=X@~ z_|&^UMWAKD;jjBKTK(~o?cUFRK8EX=6>cXpfzg4ZpMB>*w_^8GSiT-Jp|xBOnzM+j z*09-@-~qJ(eqWq5@R4i^u4^{McCP(!3}C|v_WsTR*bIUxN(Nx`u##3B4{sE`Z`v8w zAwIG`?1~PkID~W{uDzmqH98Pew_1(;x2%8r^vY{)_&J2K)cN{W+h5+g)ZcjP&Ci#O zgy|8K@4kyMfwilHd&6TDlhb%++Pk!>9HRld6HT7gwyZGrxS$}CsD6`>6!!2K1@Mjf z(P0WYB7V_OFZyeWrbOFb>O54BNXf~K&?}3=^v;v_wT{DKr?jN^DtN&DXwX%u?s*c6`%8>WFz z7}YW^tp0bp^NriE)AB6M2l<7rn7fzePtR*omOevpfm9n?}2V*+0iW;S)C zhg`NAjL?D=W#k*$aR{>pGf~lD-rVtD;5jW1_*Jn1j1=es@Kcx4ySM_bwcQCT=d+DV z>Sz~L=Hj@(X%31nK$mWI@7d>}ORB`K(p=+`UD)+99YUGQc7y^bHZ1F(8|tL0 zdK*DT0kSXG_{BKTpP2*2PecdKV9;dq$^ZZDP;Nyq1kp-&GI5eAyZsK!e3V zK@rPy*{(`KIfo+lc878mDKk^V#`VT05}64kBtk%DgwLrOvLMj5-;*GNKv6c6pzMuL z6EP%ob|_0IW}lLRXCP2!9wWhEw3LA7iF#1O1mIZ@Z=6&bz41F;@S_GvYAG-#CW3z{ zP3+6vHhvP&A3$##Vo9$dT^#MoGg^|MDm=Bt1d2RRwSZ<;ZHICpLBv5Xs!D?BH^(9_ z7`H=N&^v|Z-%mP}wNzG{aiFCsRgwzwq!N6obW9+7(R; z(SZ=23`|`>qil!LMGG{_Heq!BD>(Y-zV9wD)}hz25JA37YR%39;kI4y9pgtcUass6 zP24}ZY$vvYeI`zy&)A_X#nY3017ap*0&jx|mVwyGhg3;!keU53a}Uhm3BZI$N$6Se zLWlAmy1S0xKJm4G_U@sN_Tm=`$xWJSEwKU98rZ&)1R^*$$1vA3oG#&*%SMxY_~oGP zP&PFJatFLM-Ps%84IV-+Ow)T{C7cqUAvauy4C z(FRz&?6$Rypj{xO!`y=*J5o4@U8Q-(y5(*=YoKeZ+-1YdljXxkA#B)zo=FeQH#?Le zycNUmEEHWO9a=X^pb#&cOq7-`7UA87#|S22)<7RUtZo|(zibX=w;K3qur9vy#`MNV z6UUcf9ZwEnKCCp+OoBnF@OdbvH)ANXO0o~Pi9l8=x3))}L<#vO0-~O4!~--Ket?d} zJaqsj<@CD1%S2cTW%rOP{Vto%0sGW~1RMa_j^)5nil0Yw- z0EE#bP+l4#P^%PQ+N*oxu1Zq05xZ!bXfYTg>9c{(Iw*lnjR^>kz%lAN^zFce7rppy zY8zA~3GD=A6d*hze&l4D_wA~+O!56)BZTe_rEu}Ezi<4!kG|W#amBZ5{&XS2@6R~H z{9o^y*BkH4$~yX9U&@CgbOzX1bn9xqF|zh$Dh0Y5y*E0e90*$!ObrHY3Ok0`2=O~r zCuke6KrP9KOf?V(YDsM<6pX2nVoN%M$LT^q#FmtaF?1^27F*IcNX~XRB(|hCFvdcc zc)$=S-)acdk$g4?_>jRqxpI6M3vHZk?0c^3=byamYDNf;uB{3NlKW5IhnOS3DNkMV z?tK8?kJ}pmvp%&&eTVOVjHP`q34hN1@!aK}H(K!vI`~gf|Gv+FNEQD5Yd<~yX7k_l h&G-K)@HZb3BABY{)U1?^%I#E6`MGoTtustd{~yM6srvu` diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/images/Square150x150Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.WinJS/images/Square150x150Logo.scale-200.png deleted file mode 100644 index af49fec1a5484db1d52a7f9b5ec90a27c7030186..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2937 zcma)84OCO-8BSud5)jwMLRVKgX(S?$n?Ld|vrsm<$CF7)&zTbyy1FE5bU`Q17MRv`9ue$;R(@8kR;#vJ*IM0>cJIAOte!d7oRgdH zd%ySjdB6L9=gX^A6)VzH7p2l@v~3zJAMw|DFy#^)F@@F*`mqUn=Il>l)8_+ab;nOW{%+iPx z+s{Eu|&pIs)Z7{La9~?xKfyl z#43?gjEL15d4WbOZo#SiP%>DB^+BcnJ=7dHEe;r#G=tuw|ka z%q@}##Uh7;tc%L_64m(kHtw74ty%BJMb)_1)#S0j`)F8_1jF7vScpsnH=0V19bO8y zR`0SjIdCUo&=>JwMQF8KHA<{ODHTiQh}0^@5QRmCA?gOH6_H3K^-_sNB^RrdNuK-R zOO*vOrKCVvDwgUck`kF(E7j{I#iiN;b*ZdCt4m@HPA`EuEqGGf4%!K<;(=I=&Vyrw z%TwcWtxa}8mCZ%Cyf&ActJ6_$ox5z6-D!0-dvnRx6t7y3d+h6QYpKWO;8OdnvERo7 zuEf>ih5`wqY)~o@OeVt-wM?Q!>QzdGRj!bz6fzYrfw$hZfAKzr2-M+D+R>}~oT574c;_3zquHcElqKIsryILt3g8n3jcMb+j?i?-L3FpZJ z2WRVBRdDPc+G5aaYg#5hpE+6nQ|(VSoxT3|biF;BUq#==-27Xi=gihDPYP$7?=9cP zYKE$jeQ|3~_L0VG-(F~2ZPyD0=k{J4Q~h(t__{-mz_w8{JDY9{`1ouzz!Vr5!ECdE z6U~O1k8c}24V7~zzXWTV-Pe4)y}wQJS&q%H5`Fo_f_JvIU489aCX$;P`u#!I-=^4ijC2{&9!O&h>mi?9oYD=GC#%)6{GzN6nQYw+Fal50!#x^asjBBR50i`+mho*ttoqV)ubM2KD9S~k7+FR4>{29?6 z{!l6kDdyTN0YJ9LgkPWeXm|gyi@zM3?0@{&pXT12w|78&W-q!RRF)&iLCEZVH<|fR zN0fr2^t8H(>L?>K#>^+jWROLral(Qy-xoBq1U7A&DV||wClb)Otd9?(gZ|8znMF}D zf<1haWz^s0qgecz;RFGt0C-B4g`jNGHsFU+;{<%t65v^sjk^h$lmWn#B0#_)9ij&d z-~lc`A)YYExi^7sBuPM^Y|wA2g*5?`K?#7tzELQYNxGo$UB$4J8RJp1k(8Jj+~hMT zlN~>M@KTTh^--8y3PK_NZ@AC!{PT=CziBzGd+wTJ^@icH!Bd}%)g8V)%K?|c&WTUk zy}qv1C%(fjRoZ4ozC3{O%@5?)XzH35zHns$pgU*Q?fj4v?fp1Qbm+j;3l;9jam9Da zXVcKjPlQ73x78QPu|Ffm6x?`~e3oD=gl=4kYK?={kD5j~QCXU)`HSdduNNENzA*2$ zOm3PzF!lN5e*06-f1Uot67wY#{o-S1!KZ7E=!~7ynnk9_iJR#kFoNbAOT#^2Gd17F zMmvU6>lndZQGd|ax9kUoXXO+$N?|j@6qpsF&_j7YXvwo_C{JpmLw5&#e6k>atv%es z5)7r*Wvv_JkUpT}M!_o!nVlEk1Zbl=a*2hQ*<|%*K1Glj^FcF`6kTzGQ3lz~2tCc@ z&x|tj;aH&1&9HwcJBcT`;{?a+pnej;M1HO(6Z{#J!cZA04hnFl;NXA+&`=7bjW_^o zfC40u3LMG?NdPtwGl>Tq6u}*QG)}-y;)lu-_>ee3kibW(69n0$0Zy!}9rQz%*v1iO zT9_H>99yIrSPYVy6^);rR}7Yo=J_T@hi+qhTZXnVWyf;JDYm5#eYLTxr*?kiNn!+Y zQ+LUkBafNJ#rH#C(?d5^;gw9o#%daEI{mA*LHPIHPU`#|H$hD zwm>0&+kahQ)E#%~k>&5@&#Vg82H?s%71=)(soi@174pi9--2{w{1$}Sz4zGn3Du&x bht0Iza^2ykEt4(epJ78uh5nDlX8(TxzDYwP diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/images/Square44x44Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.WinJS/images/Square44x44Logo.scale-200.png deleted file mode 100644 index ce342a2ec8a61291ba76c54604aea7e9d20af11b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1647 zcmaJ?eM}Q)7(e+G1Q(|`V9JhTI2>MkceK4;p;PR&$Pi?ejk3YQ_3o`S&|W_dsOZ8# zWPTt69g`t$ab`0cj-Y0yiBSOqmd)tG7G(}M5aP0_%&9TijB#&)I{zSE^4@#z^FF`l z`8{8`o%wlL(UI|y2!cdsuVamHH~H86F!*-15em4)NqUpCQM5?aoC_eCf@lV4wvF2a zjDQn1JBL69f&@2M3rvzJcfE!eZ8FZUBlFlC5RD)it33{mF9#B82AiyQE%w)`vlwa> zv{<1sm&kSKK$&%2jSFn7$t&P%%6Ue>R=EAnG8N7fqynWG8L3p!4801a;8{+nliO(qd(jNJ_?+9W3#hLIDLoT6~3fx9=`CC-D}-AMrpEO7HK zt3$GicGPc?GmDjy7K2P@La;eu4!$zWCZ`ym{Z$b zu-O6RM&K4JT|BIZB`E-gxqG%FzanI#+2FFmqHqXG7yxWB=w55RGOM)$xMb(>kSNR z2w=1AZi%z=AmG~yea~XaXJR!v7vLn(RUnELfiB1|6D84ICOS}^Zo2AdN}<&*h}G_u z{xZ!(%>tLT3J3<5XhWy-tg+6)0nmUUENLW8TWA{R6bgVd3X;anYFZ^IRis*_P-C-r z;i>%1^eL3UI2-{w8nuFFcs0e~7J{O2k^~Ce%+Ly4U?|=!0LH=t6()xi<^I-rs+9sF z*q{E-CxZbGPeu#a;XJwE;9S1?#R&uns>^0G3p`hEUF*v`M?@h%T%J%RChmD|EVydq zmHWh*_=S%emRC*mhxaVLzT@>Z2SX0u9v*DIJ@WC^kLVdlGV6LpK$KIrlJqc zpJ921)+3JJdTx|<`G&kXpKkjGJv=76R`yYIQ{#c-`%+`#V(7}Q;&@6U8!Td1`d;?N z_9mnI#?AA}4J!r)LN4!E-@H5eXauuB7TOawS>Y|{-P?NNx-lq+z1W-+y(;39P&&LP zL{N80?&=C*qKmdA^moMZRuPcD!B<*mq$ch=0Cnlitw#txRWhb3%TQvPqjkC`F69G4b! ze7z9MZ#+;_#l?H37UqUhDFb^l&s2{oM$3I0o^Q!yx;;V)QmCMo)Tb_ui|mit8MS?U zm##6$sZZ1$@|s%?l@>4Z<*Q}sRBSKMhb4I{e5LdEhsHIHTe8Bod5c>6QtT>$XgUBz z6MK`kO$=jmt@FqggOhJ5j~e@ygRbG;<{Vu)*+nn9aQeo0;$#j;|MS=S$&L?BeV25z xs3B`@=#`5TF{^6(A1rvdY@|-RtQ|iS5{tyX+wH?;n8E)G$kykv-D^wh{{!TZT%7;_ diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/images/Square44x44Logo.targetsize-24_altform-unplated.png b/Samples/SimpleConversionDemo.UWP.WinJS/images/Square44x44Logo.targetsize-24_altform-unplated.png deleted file mode 100644 index f6c02ce97e0a802b85f6021e822c89f8bf57d5cd..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1255 zcmaJ>TWs4@7*5+{G#S+&C!qC#> zf>5N3P6jO*Cz>ug*(_DmW=)kea&m$gZ^+nyiF`;j%w@}y8)>p*SH}C`m?DXeieF2U zyQHecc_L%Gh!7GMt+hG06y;+|p4>m~}PjA}rKViGiEnn7G0ZO<>G|7q;2?NwGCM3s?eued6%hd$B+ z*kQJ{#~$S=DFE(%=E+UkmlEI*%3llUf~8Ja9YU1Vui0IbGBkW_gHB%Rd&!!ioX zs40O?i9I{};kle7GMvE7(rk`la=gTI)47=>%?q@^iL-nUo3}h4S}N-KHn8t5mVP8w z&bSErwp+37 zNJJ8?a|{r5Q3R0Z5s-LB1WHOwYC@7pCHWND#cL1cZ?{kJ368_*(UDWUDyb<}0y@o# zfMF016iMWPCb6obAxT$JlB6(2DrlXDTB&!0`!m??4F(qWMhjVZo?JXQmz`1*58Z=& zcDmB|S-E@j?BoFGix0flckqdS4jsPNzhfWyWIM98GxcLs89C(~dw%$_t;JjX-SD}E zfiGV;{8Q%8r}w9x>EEigW81>`kvnU@pK)4+xk9@+bNj9L!AAZ@SZ@q|)&BmY3+HZx zul~BeG4|}-;L%cHViQGQX?^zFfO0&#cHwel=d`lH9sJ-@Sl@n*(8J2>%Ac`IxyY?Q z{=GhWvC#gu-~Ia7*n{=+;qM?Ul_wy1+u7ho;=`>EwP^g~R@{unBds`!#@}tluZQpS zm)M~nYEifJWJGx?_6DcTy>#uh%>!H9=hb^(v`=m3F1{L>db=<5_tm+_&knAQ2EU$s Mu9UqpbNZeC0BbUo^Z)<= diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/images/StoreLogo.png b/Samples/SimpleConversionDemo.UWP.WinJS/images/StoreLogo.png deleted file mode 100644 index 7385b56c0e4d3c6b0efe3324aa1194157d837826..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1451 zcmaJ>eN5D57_Z|bH;{0+1#mbl)eTU3{h)Wf7EZV?;HD@XL@{B`Ui%(2aMxQ~xdXSv z5nzWi(LW)U2=Vc-cY@s7nPt{i0hc6!7xN4NNHI#EQl>YNBy8l4%x9gr_W-j zEZMQmmTIy(>;lblRfh`dIyTgc9W5d!VP$L4(kKrN1c5G~(O_#xG zAJCNTstD^5SeXFB+&$h=ToJP2H>xr$iqPs-#O*;4(!Fjw25-!gEb*)mU}=)J;Iu>w zxK(5XoD0wrPSKQ~rbL^Cw6O_03*l*}i=ydbu7adJ6y;%@tjFeXIXT+ms30pmbOP%Q zX}S;+LBh8Tea~TSkHzvX6$rYb)+n&{kSbIqh|c7hmlxmwSiq5iVhU#iEQ<>a18|O^Sln-8t&+t`*{qBWo5M?wFM(JuimAOb5!K#D}XbslM@#1ZVz_;!9U zpfEpLAOz=0g@bd6Xj_ILi-x^!M}73h^o@}hM$1jflTs|Yuj9AL@A3<-?MV4!^4q`e z)fO@A;{9K^?W?DbnesnPr6kK>$zaKo&;FhFd(GYFCIU^T+OIMb%Tqo+P%oq(IdX7S zf6+HLO?7o0m+p>~Tp5UrXWh!UH!wZ5kv!E`_w)PTpI(#Iw{AS`gH4^b(bm^ZCq^FZ zY9DD7bH}rq9mg88+KgA$Zp!iWncuU2n1AuIa@=sWvUR-s`Qb{R*kk(SPU^`$6BXz8 zn#7yaFOIK%qGxyi`dYtm#&qqox0$h=pNi#u=M8zUG@bpiZ=3sT=1}Trr}39cC)H|v zbL?W)=&s4zrh)7>L(|cc%$1#!zfL?HjpeP%T+x_a+jZ16b^iKOHxFEX$7d|8${H-* zIrOJ5w&i$>*D>AKaIoYg`;{L@jM((Kt?$N$5OnuPqVvq**Nm}(f0wwOF%iX_Pba;V z;m@wxX&NcV3?<1+u?A{y_DIj7#m3Af1rCE)o`D&Y3}0%7E;iX1yMDiS)sh0wKi!36 zL!Wmq?P^Ku&rK~HJd97KkLTRl>ScGFYZNlYytWnhmuu|)L&ND8_PmkayQb{HOY640 bno1(wj@u8DCVuFR|31B*4ek@pZJqxCDDe1x diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/images/Wide310x150Logo.scale-200.png b/Samples/SimpleConversionDemo.UWP.WinJS/images/Wide310x150Logo.scale-200.png deleted file mode 100644 index 288995b397fdbef1fb7e85afd71445d5de1952c5..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3204 zcmbVPeQXow8NYmBd90>}0NP?GhXW~VaeThm=a0tV#EwJMI!)6M3}|c4_Bl3=Kd>G0 z(GHx1wl<7(tP?FsOQkTilSo*iIvF%uArExJ73~P zSv1xEy!U(Wd4A9D`FQV@W3@F^qJ@PEF$@z`Z!*BbFsS(^?B zyiAzJ+q})bkgiQHWqEb*jJD-coHYr1^iocg)l!Qa{Xqs-l~6J}p-|##ZHYofskQ3$ zI0;xzXyhazBeXhIsg5A=%ufo@f)1yy&ScKS0;HF^!r_2UE^lpZEom(+@duma3awTv zCrCL-%D_SvYWIcdHkmI}#50(fkUi)Qgx!80ju>g1za^}ff>JI8Z@^-iCiaCgg@TgF z+vtE?Q9{VQUX&MW9SYYmGcxA14%N2@7FwBTD4N<(2{nWgV8$e3?-F=L^&FrtWn~(U_Q~~^uYiyeY6-KoTnfh9AWz@ zIKje0)u!_Lw)E}G!#kEfwKVdNt(UAf9*f>tEL_(=xco-T%jTi@7YlC3hs2ik%Le0H ztj}RTeCF(5mwvi3_56>-yB?l;J>-1%!9~=fs|QcNG3J~a@JCu`4SB460s0ZO+##4fFUSGLcj_ja^fL4&BKALfb#$6$O?>P@qx2Agl^x0i&ugt zsy5Pyu=()`7HRMG3IB7F1@`_ z+-!J%#i6e^U$e#+C%Q>_qVRzWRsG^W_n+@OcX@vzI&z;mzHNb!GQ?LWA(wtpqHqTM z1OFw_{Zn?fD)p)`c`kOgv{de=v@suGRqY{N^U7gI1VF3*F=obwaXI6ob5__Yn zVTguS!%(NI09J8x#AO_aW!9W7k*UvB;IWDFC3srwftr{kHj%g)fvnAm;&h_dnl~

MY- zf+K}sCe8qU6Ujs`3ua{U0Of$R_gVQBuUA za0v=mu#vIOqiiAZOr&h*$WyOw&k-xr$;G4Ixa!#TJNr>95(h>l%)PUy4p+^SgR(uR zta%k*?ny-+nAr8spEk1fo{J4i!b^Fia`N{_F6@zidA2ZTTrjl#^5Z-2KfB@Cu}l9s z(*|Z2jc?p~vn2f)3y9i*7zJV1L{$?|&q)4oaT;uXi6>1GkRXVTOzAz(RHEmr=eFIi z`}<>-Q?K0GN8!IYxeP1XKXO+jsJbp~o^);Bc;%b7Flpe7;1`Ny@3r7ZR;?R)aJt8C ziNlEC<@3f_lIV4TwV}&e;D!Ee5_|e#g0LUh=5vmYWYm7&2h*M>QPKvGh9-)wfMMW3 z8J9b%1k7dzPzO0_NGQy92BZ^FR6R~6;^6?lqO;-QUP4BY%cG%3vEhbm#>4vIhPBh3 z-+pZGjh$x%Hp{?=FHsMp0&wNPlj00us{&`1ZOZTqs8%4X&xH=UDr*xyBW(Zp&Em94 zf)ZSfn#yg0N)>!1kWdkqJ^S*z0FF5|fj&qcE#Na|%OY0$uO>!&hP+1ywfD_WXk@4J(?MBftK7>$Nvqh@tDuarN%PrTLQ2Uzysx>UV=V zk^RrDSvdQ?0;=hY67EgII-f4`t=+i*yS=Y~!XlqIy_4x&%+OdfbKOFPXS2X5%4R{N z$SQMX^AK6(fA - - - - WinJS_471 - - - - - - - - - - -

-

Content goes here

-
- - diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/js/main.js b/Samples/SimpleConversionDemo.UWP.WinJS/js/main.js deleted file mode 100644 index c85ea57d1b..0000000000 --- a/Samples/SimpleConversionDemo.UWP.WinJS/js/main.js +++ /dev/null @@ -1,66 +0,0 @@ -// For an introduction to the Blank template, see the following documentation: -// https://go.microsoft.com/fwlink/?LinkId=232509 - -(function () { - "use strict"; - - var app = WinJS.Application; - var activation = Windows.ApplicationModel.Activation; - var isFirstActivation = true; - - app.onactivated = function (args) { - if (args.detail.kind === activation.ActivationKind.voiceCommand) { - // TODO: Handle relevant ActivationKinds. For example, if your app can be started by voice commands, - // this is a good place to decide whether to populate an input field or choose a different initial view. - } - else if (args.detail.kind === activation.ActivationKind.launch) { - // A Launch activation happens when the user launches your app via the tile - // or invokes a toast notification by clicking or tapping on the body. - if (args.detail.arguments) { - // TODO: If the app supports toasts, use this value from the toast payload to determine where in the app - // to take the user in response to them invoking a toast notification. - } - else if (args.detail.previousExecutionState === activation.ApplicationExecutionState.terminated) { - // TODO: This application had been suspended and was then terminated to reclaim memory. - // To create a smooth user experience, restore application state here so that it looks like the app never stopped running. - // Note: You may want to record the time when the app was last suspended and only restore state if they've returned after a short period. - } - } - - if (!args.detail.prelaunchActivated) { - // TODO: If prelaunchActivated were true, it would mean the app was prelaunched in the background as an optimization. - // In that case it would be suspended shortly thereafter. - // Any long-running operations (like expensive network or disk I/O) or changes to user state which occur at launch - // should be done here (to avoid doing them in the prelaunch case). - // Alternatively, this work can be done in a resume or visibilitychanged handler. - } - - if (isFirstActivation) { - // TODO: The app was activated and had not been running. Do general startup initialization here. - document.addEventListener("visibilitychange", onVisibilityChanged); - args.setPromise(WinJS.UI.processAll()); - } - - var t = UnitsNet.Temperature.fromDegreesCelsius(100); - var unit = UnitsNet.Units.TemperatureUnit; - document.getElementById('label').innerHTML = t.toUnit(unit.degreeCelsius).toString() + ' = ' + t.toUnit(unit.degreeFahrenheit).toString() + ' = ' + t.toUnit(unit.kelvin).toString(); - - - isFirstActivation = false; - }; - - function onVisibilityChanged(args) { - if (!document.hidden) { - // TODO: The app just became visible. This may be a good time to refresh the view. - } - } - - app.oncheckpoint = function (args) { - // TODO: This application is about to be suspended. Save any state that needs to persist across suspensions here. - // You might use the WinJS.Application.sessionState object, which is automatically saved and restored across suspension. - // If you need to complete an asynchronous operation before your application is suspended, call args.setPromise(). - }; - - app.start(); - -})(); diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/css/ui-dark.css b/Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/css/ui-dark.css deleted file mode 100644 index 991c9316d3..0000000000 --- a/Samples/SimpleConversionDemo.UWP.WinJS/lib/winjs-4.0.1/css/ui-dark.css +++ /dev/null @@ -1,7304 +0,0 @@ -/* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. */ -@keyframes WinJS-node-inserted { - from { - outline-color: #000; - } - to { - outline-color: #001; - } -} -@keyframes WinJS-opacity-in { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -@keyframes WinJS-opacity-out { - from { - opacity: 1; - } - to { - opacity: 0; - } -} -@keyframes WinJS-scale-up { - from { - transform: scale(0.85); - } - to { - transform: scale(1); - } -} -@keyframes WinJS-scale-down { - from { - transform: scale(1); - } - to { - transform: scale(0.85); - } -} -@keyframes WinJS-default-remove { - from { - transform: translateX(11px); - } - to { - transform: none; - } -} -@keyframes WinJS-default-remove-rtl { - from { - transform: translateX(-11px); - } - to { - transform: none; - } -} -@keyframes WinJS-default-apply { - from { - transform: none; - } - to { - transform: translateX(11px); - } -} -@keyframes WinJS-default-apply-rtl { - from { - transform: none; - } - to { - transform: translateX(-11px); - } -} -@keyframes WinJS-showEdgeUI { - from { - transform: translateY(-70px); - } - to { - transform: none; - } -} -@keyframes WinJS-showPanel { - from { - transform: translateX(364px); - } - to { - transform: none; - } -} -@keyframes WinJS-showPanel-rtl { - from { - transform: translateX(-364px); - } - to { - transform: none; - } -} -@keyframes WinJS-hideEdgeUI { - from { - transform: none; - } - to { - transform: translateY(-70px); - } -} -@keyframes WinJS-hidePanel { - from { - transform: none; - } - to { - transform: translateX(364px); - } -} -@keyframes WinJS-hidePanel-rtl { - from { - transform: none; - } - to { - transform: translateX(-364px); - } -} -@keyframes WinJS-showPopup { - from { - transform: translateY(50px); - } - to { - transform: none; - } -} -@keyframes WinJS-dragSourceEnd { - from { - transform: translateX(11px) scale(1.05); - } - to { - transform: none; - } -} -@keyframes WinJS-dragSourceEnd-rtl { - from { - transform: translateX(-11px) scale(1.05); - } - to { - transform: none; - } -} -@keyframes WinJS-enterContent { - from { - transform: translateY(28px); - } - to { - transform: none; - } -} -@keyframes WinJS-exit { - from { - transform: none; - } - to { - transform: none; - } -} -@keyframes WinJS-enterPage { - from { - transform: translateY(28px); - } - to { - transform: none; - } -} -@keyframes WinJS-updateBadge { - from { - transform: translateY(24px); - } - to { - transform: none; - } -} -@-webkit-keyframes WinJS-node-inserted { - from { - outline-color: #000; - } - to { - outline-color: #001; - } -} -@-webkit-keyframes -webkit-WinJS-opacity-in { - from { - opacity: 0; - } - to { - opacity: 1; - } -} -@-webkit-keyframes -webkit-WinJS-opacity-out { - from { - opacity: 1; - } - to { - opacity: 0; - } -} -@-webkit-keyframes -webkit-WinJS-scale-up { - from { - -webkit-transform: scale(0.85); - } - to { - -webkit-transform: scale(1); - } -} -@-webkit-keyframes -webkit-WinJS-scale-down { - from { - -webkit-transform: scale(1); - } - to { - -webkit-transform: scale(0.85); - } -} -@-webkit-keyframes -webkit-WinJS-default-remove { - from { - -webkit-transform: translateX(11px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-default-remove-rtl { - from { - -webkit-transform: translateX(-11px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-default-apply { - from { - -webkit-transform: none; - } - to { - -webkit-transform: translateX(11px); - } -} -@-webkit-keyframes -webkit-WinJS-default-apply-rtl { - from { - -webkit-transform: none; - } - to { - -webkit-transform: translateX(-11px); - } -} -@-webkit-keyframes -webkit-WinJS-showEdgeUI { - from { - -webkit-transform: translateY(-70px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-showPanel { - from { - -webkit-transform: translateX(364px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-showPanel-rtl { - from { - -webkit-transform: translateX(-364px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-hideEdgeUI { - from { - -webkit-transform: none; - } - to { - -webkit-transform: translateY(-70px); - } -} -@-webkit-keyframes -webkit-WinJS-hidePanel { - from { - -webkit-transform: none; - } - to { - -webkit-transform: translateX(364px); - } -} -@-webkit-keyframes -webkit-WinJS-hidePanel-rtl { - from { - -webkit-transform: none; - } - to { - -webkit-transform: translateX(-364px); - } -} -@-webkit-keyframes -webkit-WinJS-showPopup { - from { - -webkit-transform: translateY(50px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-dragSourceEnd { - from { - -webkit-transform: translateX(11px) scale(1.05); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-dragSourceEnd-rtl { - from { - -webkit-transform: translateX(-11px) scale(1.05); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-enterContent { - from { - -webkit-transform: translateY(28px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-exit { - from { - -webkit-transform: none; - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-enterPage { - from { - -webkit-transform: translateY(28px); - } - to { - -webkit-transform: none; - } -} -@-webkit-keyframes -webkit-WinJS-updateBadge { - from { - -webkit-transform: translateY(24px); - } - to { - -webkit-transform: none; - } -} -@font-face { - font-family: "Segoe UI Command"; - src: local("Segoe MDL2 Assets"); - font-weight: normal; - font-style: normal; -} -@font-face { - font-family: "Symbols"; - src: url(../fonts/Symbols.ttf); -} -.win-type-header, -.win-h1 { - font-size: 46px; - font-weight: 200; - line-height: 1.216; - letter-spacing: 0px; -} -.win-type-subheader, -.win-h2 { - font-size: 34px; - font-weight: 200; - line-height: 1.176; -} -.win-type-title, -.win-h3 { - font-size: 24px; - font-weight: 300; - line-height: 1.167; -} -.win-type-subtitle, -.win-h4 { - font-size: 20px; - font-weight: 400; - line-height: 1.2; -} -.win-type-body, -.win-h6 { - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-type-base, -.win-h5 { - font-size: 15px; - font-weight: 500; - line-height: 1.333; -} -.win-type-caption { - font-size: 12px; - font-weight: 400; - line-height: 1.167; -} -@font-face { - font-family: "Segoe UI"; - font-weight: 200; - src: local("Segoe UI Light"); -} -@font-face { - font-family: "Segoe UI"; - font-weight: 300; - src: local("Segoe UI Semilight"); -} -@font-face { - font-family: "Segoe UI"; - font-weight: 400; - src: local("Segoe UI"); -} -@font-face { - font-family: "Segoe UI"; - font-weight: 500; - src: local("Segoe UI Semibold"); -} -@font-face { - font-family: "Segoe UI"; - font-weight: 600; - src: local("Segoe UI Bold"); -} -@font-face { - font-family: "Segoe UI"; - font-style: italic; - font-weight: 400; - src: local("Segoe UI Italic"); -} -@font-face { - font-family: "Segoe UI"; - font-style: italic; - font-weight: 700; - src: local("Segoe UI Bold Italic"); -} -@font-face { - font-family: "Microsoft Yahei UI"; - font-weight: 200; - src: local("Microsoft Yahei UI Light"); -} -@font-face { - font-family: "Microsoft Yahei UI"; - font-weight: 300; - src: local("Microsoft Yahei UI"); -} -@font-face { - font-family: "Microsoft Yahei UI"; - font-weight: 500; - src: local("Microsoft Yahei UI"); -} -@font-face { - font-family: "Microsoft Yahei UI"; - font-weight: 600; - src: local("Microsoft Yahei UI Bold"); -} -@font-face { - font-family: "Microsoft JhengHei UI"; - font-weight: 200; - src: local("Microsoft JhengHei UI Light"); -} -@font-face { - font-family: "Microsoft JhengHei UI"; - font-weight: 300; - src: local("Microsoft JhengHei UI"); -} -@font-face { - font-family: "Microsoft JhengHei UI"; - font-weight: 500; - src: local("Microsoft JhengHei UI"); -} -@font-face { - font-family: "Microsoft JhengHei UI"; - font-weight: 600; - src: local("Microsoft JhengHei UI Bold"); -} -.win-type-header:-ms-lang(am, ti), -.win-type-subheader:-ms-lang(am, ti), -.win-type-title:-ms-lang(am, ti), -.win-type-subtitle:-ms-lang(am, ti), -.win-type-base:-ms-lang(am, ti), -.win-type-body:-ms-lang(am, ti), -.win-type-caption:-ms-lang(am, ti), -.win-h1:-ms-lang(am, ti), -.win-h2:-ms-lang(am, ti), -.win-h3:-ms-lang(am, ti), -.win-h4:-ms-lang(am, ti), -.win-h5:-ms-lang(am, ti), -.win-h6:-ms-lang(am, ti), -.win-button:-ms-lang(am, ti), -.win-dropdown:-ms-lang(am, ti), -.win-textbox:-ms-lang(am, ti), -.win-link:-ms-lang(am, ti), -.win-textarea:-ms-lang(am, ti) { - font-family: "Ebrima", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-type-subheader:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-type-title:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-type-subtitle:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-type-base:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-type-body:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-type-caption:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-h1:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-h2:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-h3:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-h4:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-h5:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-h6:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-button:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-dropdown:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-textbox:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-link:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te), -.win-textarea:-ms-lang(as, bn, gu, hi, kn, kok, ml, mr, ne, or, pa, sat-Olck, si, srb-Sora, ta, te) { - font-family: "Nirmala UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(chr-CHER-US), -.win-type-subheader:-ms-lang(chr-CHER-US), -.win-type-title:-ms-lang(chr-CHER-US), -.win-type-subtitle:-ms-lang(chr-CHER-US), -.win-type-base:-ms-lang(chr-CHER-US), -.win-type-body:-ms-lang(chr-CHER-US), -.win-type-caption:-ms-lang(chr-CHER-US), -.win-h1:-ms-lang(chr-CHER-US), -.win-h2:-ms-lang(chr-CHER-US), -.win-h3:-ms-lang(chr-CHER-US), -.win-h4:-ms-lang(chr-CHER-US), -.win-h5:-ms-lang(chr-CHER-US), -.win-h6:-ms-lang(chr-CHER-US), -.win-button:-ms-lang(chr-CHER-US), -.win-dropdown:-ms-lang(chr-CHER-US), -.win-textbox:-ms-lang(chr-CHER-US), -.win-link:-ms-lang(chr-CHER-US), -.win-textarea:-ms-lang(chr-CHER-US) { - font-family: "Gadugi", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(ja), -.win-type-subheader:-ms-lang(ja), -.win-type-title:-ms-lang(ja), -.win-type-subtitle:-ms-lang(ja), -.win-type-base:-ms-lang(ja), -.win-type-body:-ms-lang(ja), -.win-type-caption:-ms-lang(ja), -.win-h1:-ms-lang(ja), -.win-h2:-ms-lang(ja), -.win-h3:-ms-lang(ja), -.win-h4:-ms-lang(ja), -.win-h5:-ms-lang(ja), -.win-h6:-ms-lang(ja), -.win-button:-ms-lang(ja), -.win-dropdown:-ms-lang(ja), -.win-textbox:-ms-lang(ja), -.win-link:-ms-lang(ja), -.win-textarea:-ms-lang(ja) { - font-family: "Yu Gothic UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(km, lo, th, bug-Bugi), -.win-type-subheader:-ms-lang(km, lo, th, bug-Bugi), -.win-type-title:-ms-lang(km, lo, th, bug-Bugi), -.win-type-subtitle:-ms-lang(km, lo, th, bug-Bugi), -.win-type-base:-ms-lang(km, lo, th, bug-Bugi), -.win-type-body:-ms-lang(km, lo, th, bug-Bugi), -.win-type-caption:-ms-lang(km, lo, th, bug-Bugi), -.win-h1:-ms-lang(km, lo, th, bug-Bugi), -.win-h2:-ms-lang(km, lo, th, bug-Bugi), -.win-h3:-ms-lang(km, lo, th, bug-Bugi), -.win-h4:-ms-lang(km, lo, th, bug-Bugi), -.win-h5:-ms-lang(km, lo, th, bug-Bugi), -.win-h6:-ms-lang(km, lo, th, bug-Bugi), -.win-button:-ms-lang(km, lo, th, bug-Bugi), -.win-dropdown:-ms-lang(km, lo, th, bug-Bugi), -.win-textbox:-ms-lang(km, lo, th, bug-Bugi), -.win-link:-ms-lang(km, lo, th, bug-Bugi), -.win-textarea:-ms-lang(km, lo, th, bug-Bugi) { - font-family: "Leelawadee UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(ko), -.win-type-subheader:-ms-lang(ko), -.win-type-title:-ms-lang(ko), -.win-type-subtitle:-ms-lang(ko), -.win-type-base:-ms-lang(ko), -.win-type-body:-ms-lang(ko), -.win-type-caption:-ms-lang(ko), -.win-h1:-ms-lang(ko), -.win-h2:-ms-lang(ko), -.win-h3:-ms-lang(ko), -.win-h4:-ms-lang(ko), -.win-h5:-ms-lang(ko), -.win-h6:-ms-lang(ko), -.win-button:-ms-lang(ko), -.win-dropdown:-ms-lang(ko), -.win-textbox:-ms-lang(ko), -.win-link:-ms-lang(ko), -.win-textarea:-ms-lang(ko) { - font-family: "Malgun Gothic", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(jv-Java), -.win-type-subheader:-ms-lang(jv-Java), -.win-type-title:-ms-lang(jv-Java), -.win-type-subtitle:-ms-lang(jv-Java), -.win-type-base:-ms-lang(jv-Java), -.win-type-body:-ms-lang(jv-Java), -.win-type-caption:-ms-lang(jv-Java), -.win-h1:-ms-lang(jv-Java), -.win-h2:-ms-lang(jv-Java), -.win-h3:-ms-lang(jv-Java), -.win-h4:-ms-lang(jv-Java), -.win-h5:-ms-lang(jv-Java), -.win-h6:-ms-lang(jv-Java), -.win-button:-ms-lang(jv-Java), -.win-dropdown:-ms-lang(jv-Java), -.win-textbox:-ms-lang(jv-Java), -.win-link:-ms-lang(jv-Java), -.win-textarea:-ms-lang(jv-Java) { - font-family: "Javanese Text", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(cop-Copt), -.win-type-subheader:-ms-lang(cop-Copt), -.win-type-title:-ms-lang(cop-Copt), -.win-type-subtitle:-ms-lang(cop-Copt), -.win-type-base:-ms-lang(cop-Copt), -.win-type-body:-ms-lang(cop-Copt), -.win-type-caption:-ms-lang(cop-Copt), -.win-h1:-ms-lang(cop-Copt), -.win-h2:-ms-lang(cop-Copt), -.win-h3:-ms-lang(cop-Copt), -.win-h4:-ms-lang(cop-Copt), -.win-h5:-ms-lang(cop-Copt), -.win-h6:-ms-lang(cop-Copt), -.win-button:-ms-lang(cop-Copt), -.win-dropdown:-ms-lang(cop-Copt), -.win-textbox:-ms-lang(cop-Copt), -.win-link:-ms-lang(cop-Copt), -.win-textarea:-ms-lang(cop-Copt) { - font-family: "Segoe MDL2 Assets", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-type-subheader:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-type-title:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-type-subtitle:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-type-base:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-type-body:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-type-caption:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-h1:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-h2:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-h3:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-h4:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-h5:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-h6:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-button:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-dropdown:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-textbox:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-link:-ms-lang(zh-CN, zh-Hans, zh-SG), -.win-textarea:-ms-lang(zh-CN, zh-Hans, zh-SG) { - font-family: "Microsoft YaHei UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -.win-type-header:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-type-subheader:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-type-title:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-type-subtitle:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-type-base:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-type-body:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-type-caption:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-h1:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-h2:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-h3:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-h4:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-h5:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-h6:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-button:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-dropdown:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-textbox:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-link:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO), -.win-textarea:-ms-lang(zh-HK, zh-TW, zh-Hant, zh-MO) { - font-family: "Microsoft JhengHei UI", "Ebrima", "Nirmala UI", "Gadugi", "Segoe UI Emoji", "Segoe MDL2 Assets", "Symbols", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Leelawadee UI", "Microsoft YaHei UI", "Microsoft JhengHei UI", "Malgun Gothic", "Segoe UI Historic", "Estrangelo Edessa", "Microsoft Himalaya", "Microsoft New Tai Lue", "Microsoft PhagsPa", "Microsoft Tai Le", "Microsoft Yi Baiti", "Mongolian Baiti", "MV Boli", "Myanmar Text", "Javanese Text", "Cambria Math"; -} -html, -body { - width: 100%; - height: 100%; - margin: 0px; - cursor: default; - -webkit-touch-callout: none; - -ms-scroll-translation: vertical-to-horizontal; - -webkit-tap-highlight-color: rgba(0, 0, 0, 0); -} -html { - overflow: hidden; - direction: ltr; -} -html:lang(ar), -html:lang(dv), -html:lang(fa), -html:lang(he), -html:lang(ku-Arab), -html:lang(pa-Arab), -html:lang(prs), -html:lang(ps), -html:lang(sd-Arab), -html:lang(syr), -html:lang(ug), -html:lang(ur), -html:lang(qps-plocm) { - direction: rtl; -} -body { - -ms-content-zooming: none; -} -iframe { - border: 0; -} -.win-type-header, -.win-type-subheader, -.win-type-title, -.win-type-subtitle, -.win-type-base, -.win-type-body, -.win-type-caption, -.win-h1, -.win-h2, -.win-h3, -.win-h4, -.win-h5, -.win-h6, -.win-button, -.win-dropdown, -.win-textbox, -.win-link, -.win-textarea { - font-family: "Segoe UI", sans-serif, "Segoe MDL2 Assets", "Symbols"; -} -.win-textbox, -.win-textarea { - -ms-user-select: element; - border-style: solid; - border-width: 2px; - border-radius: 0; - margin: 8px 0px; - width: 296px; - min-width: 64px; - min-height: 28px; - background-clip: border-box; - box-sizing: border-box; - padding: 3px 6px 5px 10px; - outline: 0; - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-textbox::-ms-value { - margin: 0; - padding: 0; -} -.win-textbox::-ms-clear, -.win-textbox::-ms-reveal { - padding-right: 2px; - margin-right: -8px; - margin-left: 2px; - margin-top: -8px; - margin-bottom: -8px; - width: 30px; - height: 32px; -} -.win-textbox:lang(ar)::-ms-clear, -.win-textbox:lang(dv)::-ms-clear, -.win-textbox:lang(fa)::-ms-clear, -.win-textbox:lang(he)::-ms-clear, -.win-textbox:lang(ku-Arab)::-ms-clear, -.win-textbox:lang(pa-Arab)::-ms-clear, -.win-textbox:lang(prs)::-ms-clear, -.win-textbox:lang(ps)::-ms-clear, -.win-textbox:lang(sd-Arab)::-ms-clear, -.win-textbox:lang(syr)::-ms-clear, -.win-textbox:lang(ug)::-ms-clear, -.win-textbox:lang(ur)::-ms-clear, -.win-textbox:lang(qps-plocm)::-ms-clear, -.win-textbox:lang(ar)::-ms-reveal, -.win-textbox:lang(dv)::-ms-reveal, -.win-textbox:lang(fa)::-ms-reveal, -.win-textbox:lang(he)::-ms-reveal, -.win-textbox:lang(ku-Arab)::-ms-reveal, -.win-textbox:lang(pa-Arab)::-ms-reveal, -.win-textbox:lang(prs)::-ms-reveal, -.win-textbox:lang(ps)::-ms-reveal, -.win-textbox:lang(sd-Arab)::-ms-reveal, -.win-textbox:lang(syr)::-ms-reveal, -.win-textbox:lang(ug)::-ms-reveal, -.win-textbox:lang(ur)::-ms-reveal, -.win-textbox:lang(qps-plocm)::-ms-reveal { - margin-left: -8px; - margin-right: 2px; -} -.win-textarea { - resize: none; - overflow-y: auto; -} -.win-radio, -.win-checkbox { - width: 20px; - height: 20px; - margin-right: 8px; - margin-top: 12px; - margin-bottom: 12px; -} -.win-radio:lang(ar), -.win-checkbox:lang(ar), -.win-radio:lang(dv), -.win-checkbox:lang(dv), -.win-radio:lang(fa), -.win-checkbox:lang(fa), -.win-radio:lang(he), -.win-checkbox:lang(he), -.win-radio:lang(ku-Arab), -.win-checkbox:lang(ku-Arab), -.win-radio:lang(pa-Arab), -.win-checkbox:lang(pa-Arab), -.win-radio:lang(prs), -.win-checkbox:lang(prs), -.win-radio:lang(ps), -.win-checkbox:lang(ps), -.win-radio:lang(sd-Arab), -.win-checkbox:lang(sd-Arab), -.win-radio:lang(syr), -.win-checkbox:lang(syr), -.win-radio:lang(ug), -.win-checkbox:lang(ug), -.win-radio:lang(ur), -.win-checkbox:lang(ur), -.win-radio:lang(qps-plocm), -.win-checkbox:lang(qps-plocm) { - margin-left: 8px; - margin-right: 0px; -} -.win-radio::-ms-check, -.win-checkbox::-ms-check { - border-style: solid; - display: inline-block; - border-width: 2px; - background-clip: border-box; -} -.win-button { - border-style: solid; - margin: 0px; - min-height: 32px; - min-width: 120px; - padding: 4px 8px; - border-width: 2px; - background-clip: border-box; - border-radius: 0; - touch-action: manipulation; - -webkit-appearance: none; - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-button.win-button-file { - border: none; - min-width: 100px; - min-height: 20px; - width: 340px; - height: 32px; - padding: 0px; - margin: 7px 8px 21px 8px; - background-clip: padding-box; -} -.win-button.win-button-file::-ms-value { - margin: 0; - border-width: 2px; - border-style: solid; - border-right-style: none; - border-radius: 0; - background-clip: border-box; - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-button.win-button-file:lang(ar)::-ms-value, -.win-button.win-button-file:lang(dv)::-ms-value, -.win-button.win-button-file:lang(fa)::-ms-value, -.win-button.win-button-file:lang(he)::-ms-value, -.win-button.win-button-file:lang(ku-Arab)::-ms-value, -.win-button.win-button-file:lang(pa-Arab)::-ms-value, -.win-button.win-button-file:lang(prs)::-ms-value, -.win-button.win-button-file:lang(ps)::-ms-value, -.win-button.win-button-file:lang(sd-Arab)::-ms-value, -.win-button.win-button-file:lang(syr)::-ms-value, -.win-button.win-button-file:lang(ug)::-ms-value, -.win-button.win-button-file:lang(ur)::-ms-value, -.win-button.win-button-file:lang(qps-plocm)::-ms-value { - border-left-style: none; - border-right-style: solid; -} -.win-button.win-button-file::-ms-browse { - margin: 0; - padding: 0 18px; - border-width: 2px; - border-style: solid; - background-clip: padding-box; - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-dropdown { - min-width: 56px; - max-width: 368px; - min-height: 32px; - margin: 8px 0; - border-style: solid; - border-width: 2px; - background-clip: border-box; - background-image: none; - box-sizing: border-box; - border-radius: 0; - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-dropdown::-ms-value { - padding: 5px 12px 7px 12px; - margin: 0; -} -.win-dropdown::-ms-expand { - border: none; - margin-right: 5px; - margin-left: 3px; - margin-bottom: -2px; - font-size: 20px; -} -select[multiple].win-dropdown { - padding: 0 0 0 12px; - vertical-align: bottom; -} -.win-dropdown option { - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-progress-bar, -.win-progress-ring, -.win-ring { - width: 180px; - height: 4px; - -webkit-appearance: none; -} -.win-progress-bar:not(:indeterminate), -.win-progress-ring:not(:indeterminate), -.win-ring:not(:indeterminate) { - border-style: none; -} -.win-progress-bar::-ms-fill, -.win-progress-ring::-ms-fill, -.win-ring::-ms-fill { - border-style: none; -} -.win-progress-bar.win-medium, -.win-progress-ring.win-medium, -.win-ring.win-medium { - width: 296px; -} -.win-progress-bar.win-large, -.win-progress-ring.win-large, -.win-ring.win-large { - width: 100%; -} -.win-progress-bar:indeterminate::-webkit-progress-value, -.win-progress-ring:indeterminate::-webkit-progress-value, -.win-ring:indeterminate::-webkit-progress-value { - position: relative; - -webkit-animation: win-progress-indeterminate 3s linear infinite; -} -.win-progress-bar.win-paused:not(:indeterminate), -.win-progress-ring.win-paused:not(:indeterminate), -.win-ring.win-paused:not(:indeterminate) { - animation-name: win-progress-fade-out; - animation-duration: 3s; - animation-timing-function: cubic-bezier(0.03, 0.76, 0.31, 1); - opacity: 0.5; -} -.win-progress-bar.win-error::-ms-fill, -.win-progress-ring.win-error::-ms-fill, -.win-ring.win-error::-ms-fill { - opacity: 0; -} -.win-progress-ring, -.win-ring { - width: 20px; - height: 20px; -} -.win-progress-ring:indeterminate::-ms-fill, -.win-ring:indeterminate::-ms-fill { - animation-name: -ms-ring; -} -.win-progress-ring.win-medium, -.win-ring.win-medium { - width: 40px; - height: 40px; -} -.win-progress-ring.win-large, -.win-ring.win-large { - width: 60px; - height: 60px; -} -@-webkit-keyframes win-progress-indeterminate { - 0% { - left: 0; - width: 25%; - } - 50% { - left: calc(75%); - width: 25%; - } - 75% { - left: calc(100%); - width: 0%; - } - 75.1% { - left: 0; - width: 0%; - } - 100% { - left: 0; - width: 25%; - } -} -@keyframes win-progress-fade-out { - from { - opacity: 1.0; - } - to { - opacity: 0.5; - } -} -.win-slider { - -webkit-appearance: none; - width: 280px; - height: 22px; - padding-top: 17px; - padding-bottom: 32px; -} -.win-slider::-ms-track { - height: 2px; - border-style: none; -} -.win-slider::-webkit-slider-runnable-track { - height: 2px; - border-style: none; -} -.win-slider::-moz-range-track { - height: 2px; - border-style: none; -} -.win-slider::-ms-thumb { - width: 24px; - height: 8px; - border-radius: 4px; - border-style: none; -} -.win-slider::-webkit-slider-thumb { - -webkit-appearance: none; - margin-top: -4px; - width: 24px; - height: 8px; - border-radius: 4px; - border-style: none; -} -.win-slider::-moz-range-thumb { - width: 24px; - height: 8px; - border-radius: 4px; - border-style: none; -} -.win-slider.win-vertical { - writing-mode: bt-lr; - width: 22px; - height: 280px; -} -.win-slider.win-vertical::-ms-track { - width: 2px; - height: auto; -} -.win-slider.win-vertical::-ms-thumb { - width: 8px; - height: 24px; -} -.win-slider.win-vertical:lang(ar), -.win-slider.win-vertical:lang(dv), -.win-slider.win-vertical:lang(fa), -.win-slider.win-vertical:lang(he), -.win-slider.win-vertical:lang(ku-Arab), -.win-slider.win-vertical:lang(pa-Arab), -.win-slider.win-vertical:lang(prs), -.win-slider.win-vertical:lang(ps), -.win-slider.win-vertical:lang(sd-Arab), -.win-slider.win-vertical:lang(syr), -.win-slider.win-vertical:lang(ug), -.win-slider.win-vertical:lang(ur), -.win-slider.win-vertical:lang(qps-plocm) { - writing-mode: bt-rl; -} -.win-link { - text-decoration: underline; - cursor: pointer; - touch-action: manipulation; -} -.win-code { - font-family: "Consolas", "Menlo", "Monaco", "Courier New", monospace; - font-size: 15px; - font-weight: 400; - line-height: 1.333; -} -.win-type-ellipsis { - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; -} -h1.win-type-ellipsis, -.win-type-header.win-type-ellipsis, -.win-h1.win-type-ellipsis { - line-height: 1.4286; -} -h2.win-type-ellipsis, -.win-type-subheader.win-type-ellipsis, -.win-h2.win-type-ellipsis { - line-height: 1.5; -} -.win-scrollview { - overflow-x: auto; - overflow-y: hidden; - height: 400px; - width: 100%; -} -h1.win-type-header, -h2.win-type-subheader, -h3.win-type-title, -h4.win-type-subtitle, -h5.win-type-base, -h6.win-type-body, -h1.win-h1, -h2.win-h2, -h3.win-h3, -h4.win-h4, -h5.win-h5, -h6.win-h6 { - margin-top: 0px; - margin-bottom: 0px; -} -.win-type-body p, -p.win-type-body { - font-weight: 300; -} -.win-listview { - overflow: hidden; - height: 400px; -} -.win-listview .win-surface { - overflow: visible; -} -.win-listview > .win-viewport.win-horizontal .win-surface { - height: 100%; -} -.win-listview > .win-viewport.win-vertical .win-surface { - width: 100%; -} -.win-listview > .win-viewport { - position: relative; - width: 100%; - height: 100%; - z-index: 0; - -ms-overflow-style: -ms-autohiding-scrollbar; - -webkit-overflow-scrolling: touch; - white-space: nowrap; -} -.win-listview > .win-viewport.win-horizontal { - overflow-x: auto; - overflow-y: hidden; -} -.win-listview > .win-viewport.win-vertical { - overflow-x: hidden; - overflow-y: auto; -} -.win-listview .win-itemscontainer { - overflow: hidden; -} -.win-listview .win-itemscontainer-padder { - width: 0; - height: 0; - margin: 0; - padding: 0; - border: 0; - overflow: hidden; -} -.win-listview > .win-horizontal .win-container { - margin: 10px 5px 0px 5px; -} -.win-listview > .win-vertical .win-container { - margin: 10px 24px 0px 7px; -} -.win-listview.win-rtl > .win-vertical .win-container { - margin: 10px 7px 0px 24px; -} -.win-listview .win-container, -.win-listview .win-itembox, -.win-itemcontainer.win-container, -.win-itemcontainer .win-itembox { - cursor: default; - z-index: 0; -} -.win-listview .win-container { - touch-action: pan-x pan-y pinch-zoom; -} -.win-semanticzoom .win-listview > .win-viewport * { - touch-action: auto; -} -.win-semanticzoom .win-listview > .win-viewport.win-zooming-x { - overflow-x: visible; -} -.win-semanticzoom .win-listview > .win-viewport.win-zooming-y { - overflow-y: visible; -} -.win-listview .win-itembox, -.win-itemcontainer .win-itembox { - width: 100%; - height: 100%; -} -.win-listview .win-item, -.win-itemcontainer .win-item { - z-index: 1; -} -.win-listview .win-item, -.win-itemcontainer .win-item { - overflow: hidden; - position: relative; -} -.win-listview > .win-vertical .win-item { - width: 100%; -} -.win-listview .win-item:focus, -.win-itemcontainer .win-item:focus { - outline-style: none; -} -.win-listview .win-focusedoutline, -.win-itemcontainer .win-focusedoutline { - width: calc(100% - 4px); - height: calc(100% - 4px); - left: 2px; - top: 2px; - position: absolute; - z-index: 5; - pointer-events: none; -} -.win-container.win-selected .win-selectionborder { - border-width: 2px; - border-style: solid; -} -html.win-hoverable .win-container.win-selected:hover .win-selectionborder { - border-width: 2px; - border-style: solid; -} -html.win-hoverable .win-listview .win-itembox:hover::before, -html.win-hoverable .win-itemcontainer .win-itembox:hover::before { - position: absolute; - left: 0px; - top: 0px; - content: ""; - width: calc(100% - 4px); - height: calc(100% - 4px); - pointer-events: none; - border-style: solid; - border-width: 2px; - z-index: 3; -} -html.win-hoverable .win-listview.win-selectionstylefilled .win-itembox:hover::before, -html.win-hoverable .win-itemcontainer.win-selectionstylefilled .win-itembox:hover::before, -html.win-hoverable .win-listview .win-itembox.win-selected:hover::before, -html.win-hoverable .win-itemcontainer.win-itembox.win-selected:hover::before, -html.win-hoverable .win-itemcontainer.win-itembox.win-selected:hover::before { - display: none; -} -.win-listview .win-groupheader { - padding: 10px 10px 10px 2px; - overflow: hidden; - outline-width: 0.01px; - outline-style: none; - float: left; - font-size: 34px; - font-weight: 200; - line-height: 1.176; -} -.win-listview .win-groupheadercontainer { - z-index: 1; - touch-action: pan-x pan-y pinch-zoom; - overflow: hidden; -} -.win-listview .win-horizontal .win-headercontainer, -.win-listview .win-horizontal .win-footercontainer { - height: 100%; - display: inline-block; - overflow: hidden; - white-space: normal; -} -.win-listview .win-vertical .win-headercontainer, -.win-listview .win-vertical .win-footercontainer { - width: 100%; - display: block; - overflow: hidden; - white-space: normal; -} -.win-listview .win-groupheader.win-focused { - outline-style: dotted; -} -.win-listview.win-rtl .win-groupheader { - padding-left: 10px; - padding-right: 2px; - float: right; -} -.win-listview.win-groups .win-horizontal .win-groupleader { - margin-left: 70px; -} -.win-listview.win-groups.win-rtl .win-horizontal .win-groupleader { - margin-left: 0; - margin-right: 70px; -} -.win-listview.win-groups .win-vertical .win-listlayout .win-groupleader, -.win-listview.win-groups .win-vertical .win-gridlayout .win-groupleader { - margin-top: 70px; -} -.win-listview.win-groups > .win-vertical .win-surface.win-listlayout, -.win-listview.win-groups > .win-vertical .win-surface.win-gridlayout { - margin-top: -65px; -} -.win-listview.win-groups > .win-horizontal .win-surface { - margin-left: -70px; -} -.win-listview.win-groups.win-rtl > .win-horizontal .win-surface { - margin-left: 0; - margin-right: -70px; -} -.win-listview .win-surface { - -webkit-margin-collapse: separate; - white-space: normal; -} -.win-surface ._win-proxy { - position: relative; - overflow: hidden; - width: 0; - height: 0; - touch-action: none; -} -.win-selectionborder { - position: absolute; - opacity: inherit; - z-index: 2; - pointer-events: none; -} -.win-container.win-selected .win-selectionborder { - top: 0; - left: 0; - right: 0; - bottom: 0; -} -.win-selectionbackground { - position: absolute; - top: 0; - left: 0; - right: 0; - bottom: 0; - z-index: 0; -} -.win-selectioncheckmarkbackground { - position: absolute; - top: 2px; - right: 2px; - width: 14px; - height: 11px; - margin: 0; - padding: 0; - border-left-width: 2px; - border-right-width: 2px; - border-top-width: 4px; - border-bottom-width: 3px; - border-style: solid; - z-index: 3; - display: none; -} -.win-listview.win-rtl .win-selectioncheckmarkbackground, -.win-itemcontainer.win-rtl .win-selectioncheckmarkbackground { - left: 2px; - right: auto; -} -.win-selectionmode.win-itemcontainer .win-selectioncheckmarkbackground, -.win-selectionmode.win-itemcontainer.win-selectionmode .win-selectioncheckmark, -.win-selectionmode .win-itemcontainer .win-selectioncheckmarkbackground, -.win-selectionmode .win-itemcontainer.win-selectionmode .win-selectioncheckmark, -.win-listview .win-selectionmode .win-selectioncheckmarkbackground, -.win-listview .win-selectionmode .win-selectioncheckmark { - display: block; -} -.win-selectioncheckmark { - position: absolute; - margin: 0; - padding: 2px; - right: 1px; - top: 1px; - font-family: "Segoe MDL2 Assets", "Symbols"; - font-size: 14px; - z-index: 4; - line-height: 1; - display: none; -} -.win-rtl .win-selectioncheckmark { - right: auto; - left: 0px; -} -.win-selectionstylefilled.win-container, -.win-selectionstylefilled .win-container { - overflow: hidden; -} -.win-selectionmode .win-itemcontainer.win-container .win-itembox::after, -.win-selectionmode.win-itemcontainer.win-container .win-itembox::after, -.win-listview .win-surface.win-selectionmode .win-itembox::after { - content: ""; - position: absolute; - width: 18px; - height: 18px; - pointer-events: none; - right: 2px; - top: 2px; - z-index: 3; -} -.win-rtl .win-selectionmode .win-itemcontainer.win-container .win-itembox::after, -.win-itemcontainer.win-rtl.win-selectionmode.win-container .win-itembox::after, -.win-listview.win-rtl .win-surface.win-selectionmode .win-itembox::after { - right: auto; - left: 2px; -} -.win-listview.win-selectionstylefilled .win-surface.win-selectionmode .win-item { - transition: transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - -webkit-transition: -webkit-transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - transform: translate(40px, 0px); - -webkit-transform: translate(40px, 0px); -} -.win-listview.win-rtl.win-selectionstylefilled .win-surface.win-selectionmode .win-item { - transition: transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - -webkit-transition: -webkit-transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - transform: translate(-40px, 0px); - -webkit-transform: translate(-40px, 0px); -} -.win-listview.win-selectionstylefilled .win-surface.win-hidingselectionmode .win-item { - transition: transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - -webkit-transition: -webkit-transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - transform: none; - -webkit-transform: none; -} -.win-listview.win-rtl.win-selectionstylefilled .win-surface.win-hideselectionmode .win-item { - transition: transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - -webkit-transition: -webkit-transform 250ms cubic-bezier(0.17, 0.79, 0.215, 1.0025); - transform: none; - -webkit-transform: none; -} -.win-listview.win-selectionstylefilled .win-surface.win-selectionmode .win-itembox::after { - left: 12px; - right: auto; - top: 50%; - margin-top: -9px; - display: block; - border: 2px solid; - width: 16px; - height: 16px; -} -.win-listview.win-selectionstylefilled.win-rtl .win-surface.win-selectionmode .win-itembox::after { - left: auto; - right: 12px; -} -.win-listview.win-selectionstylefilled .win-surface.win-selectionmode .win-selectioncheckmarkbackground { - left: 12px; - top: 50%; - margin-top: -9px; - display: block; - border: 2px solid; - width: 16px; - height: 16px; -} -.win-listview.win-selectionstylefilled.win-rtl .win-surface.win-selectionmode .win-selectioncheckmarkbackground { - left: auto; - right: 12px; -} -.win-listview.win-selectionstylefilled .win-surface.win-selectionmode .win-selectioncheckmark { - left: 13px; - top: 50%; - margin-top: -8px; - display: block; - width: 14px; - height: 14px; -} -.win-listview.win-selectionstylefilled.win-rtl .win-surface.win-selectionmode .win-selectioncheckmark { - left: 0; - right: 10px; -} -.win-selectionmode .win-itemcontainer.win-selectionstylefilled.win-container .win-itembox.win-selected::after, -.win-itemcontainer.win-selectionmode.win-selectionstylefilled.win-container .win-itembox.win-selected::after, -.win-listview.win-selectionstylefilled .win-surface.win-selectionmode .win-itembox.win-nonselectable::after, -.win-listview .win-surface.win-selectionmode .win-itembox.win-selected::after { - display: none; -} -.win-listview .win-progress { - left: 50%; - top: 50%; - width: 60px; - height: 60px; - margin-left: -30px; - margin-top: -30px; - z-index: 1; - position: absolute; -} -.win-listview .win-progress::-ms-fill { - animation-name: -ms-ring; -} -.win-listview .win-itemsblock { - overflow: hidden; -} -.win-listview .win-surface.win-nocssgrid.win-gridlayout, -.win-listview .win-horizontal .win-nocssgrid.win-listlayout, -.win-listview .win-vertical .win-nocssgrid.win-listlayout.win-headerpositionleft { - display: -ms-inline-flexbox; - display: -webkit-inline-flex; - display: inline-flex; - vertical-align: top; -} -.win-listview .win-horizontal .win-surface.win-nocssgrid { - -ms-flex-direction: column; - -webkit-flex-direction: column; - flex-direction: column; - -ms-flex-wrap: wrap; - -webkit-flex-wrap: wrap; - flex-wrap: wrap; - -ms-flex-line-pack: start; - -webkit-align-content: flex-start; - align-content: flex-start; -} -.win-listview .win-vertical .win-surface.win-nocssgrid { - -ms-flex-direction: row; - -webkit-flex-direction: row; - flex-direction: row; - -ms-flex-wrap: wrap; - -webkit-flex-wrap: wrap; - flex-wrap: wrap; - -ms-flex-line-pack: start; - -webkit-align-content: flex-start; - align-content: flex-start; -} -.win-listview .win-vertical .win-structuralnodes.win-single-itemsblock.win-listlayout .win-itemscontainer.win-laidout, -.win-listview .win-horizontal .win-structuralnodes.win-single-itemsblock.win-listlayout .win-itemscontainer.win-laidout, -.win-listview .win-vertical .win-structuralnodes.win-single-itemsblock.win-gridlayout .win-uniformgridlayout.win-itemscontainer.win-laidout, -.win-listview .win-horizontal .win-structuralnodes.win-single-itemsblock.win-gridlayout .win-uniformgridlayout.win-itemscontainer.win-laidout { - display: block; -} -.win-listview .win-vertical .win-structuralnodes.win-single-itemsblock.win-listlayout .win-itemscontainer.win-laidout .win-itemscontainer-padder, -.win-listview .win-horizontal .win-structuralnodes.win-single-itemsblock.win-listlayout .win-itemscontainer.win-laidout .win-itemscontainer-padder, -.win-listview .win-vertical .win-structuralnodes.win-single-itemsblock.win-gridlayout .win-uniformgridlayout.win-itemscontainer.win-laidout .win-itemscontainer-padder, -.win-listview .win-horizontal .win-structuralnodes.win-single-itemsblock.win-gridlayout .win-uniformgridlayout.win-itemscontainer.win-laidout .win-itemscontainer-padder { - height: 0; - width: 0; -} -.win-listview.win-groups .win-vertical .win-listlayout.win-headerpositionleft .win-itemscontainer, -.win-listview.win-groups .win-vertical .win-listlayout.win-headerpositionleft .win-groupheadercontainer, -.win-listview.win-groups .win-horizontal .win-listlayout .win-itemscontainer, -.win-listview.win-groups .win-horizontal .win-listlayout .win-groupheadercontainer { - display: none; -} -.win-listview.win-groups .win-vertical .win-listlayout.win-headerpositionleft .win-itemscontainer.win-laidout, -.win-listview.win-groups .win-vertical .win-listlayout.win-headerpositionleft .win-groupheadercontainer.win-laidout, -.win-listview.win-groups .win-horizontal .win-listlayout .win-groupheadercontainer.win-laidout { - display: block; -} -.win-listview .win-listlayout .win-itemscontainer { - overflow: visible; -} -.win-listview .win-listlayout .win-itemsblock { - padding-bottom: 4px; - margin-bottom: -4px; -} -.win-listview > .win-vertical .win-listlayout.win-headerpositiontop .win-groupheader { - float: none; -} -.win-listview > .win-vertical .win-surface.win-listlayout { - margin-bottom: 5px; -} -.win-listview .win-vertical .win-listlayout.win-headerpositionleft.win-surface { - display: -ms-inline-grid; - -ms-grid-columns: auto 1fr; - -ms-grid-rows: auto; -} -.win-listview .win-vertical .win-listlayout.win-headerpositionleft .win-groupheadercontainer { - -ms-grid-column: 1; -} -.win-listview .win-vertical .win-listlayout.win-headerpositionleft .win-itemscontainer { - -ms-grid-column: 2; -} -.win-listview > .win-horizontal .win-surface.win-listlayout { - display: -ms-inline-grid; - -ms-grid-columns: auto; - -ms-grid-rows: auto; - vertical-align: top; -} -.win-listview .win-horizontal .win-listlayout .win-itemsblock { - height: 100%; -} -.win-listview .win-horizontal .win-listlayout .win-itemscontainer { - margin-bottom: 24px; -} -.win-listview .win-horizontal .win-listlayout .win-container { - height: calc(100% - 10px); -} -.win-listview > .win-horizontal .win-surface.win-listlayout.win-headerpositiontop { - -ms-grid-rows: auto 1fr; -} -.win-listview .win-horizontal .win-listlayout.win-headerpositiontop .win-groupheadercontainer { - -ms-grid-row: 1; -} -.win-listview .win-horizontal .win-listlayout.win-headerpositiontop .win-itemscontainer { - -ms-grid-row: 2; -} -.win-listview .win-gridlayout.win-surface { - display: -ms-inline-grid; - vertical-align: top; -} -.win-listview .win-gridlayout .win-container { - margin: 5px; -} -.win-listview .win-vertical .win-gridlayout.win-headerpositionleft .win-groupheadercontainer, -.win-listview .win-vertical .win-gridlayout.win-headerpositiontop .win-groupheadercontainer { - -ms-grid-column: 1; -} -.win-listview.win-groups .win-gridlayout .win-itemscontainer, -.win-listview.win-groups .win-gridlayout .win-groupheadercontainer { - display: none; -} -.win-listview.win-groups .win-gridlayout .win-groupheadercontainer.win-laidout { - display: block; -} -.win-listview .win-horizontal .win-gridlayout.win-headerpositiontop.win-surface { - -ms-grid-columns: auto; - -ms-grid-rows: auto 1fr; -} -.win-listview .win-horizontal .win-gridlayout.win-headerpositiontop .win-groupheadercontainer { - -ms-grid-row: 1; -} -.win-listview .win-horizontal .win-gridlayout.win-headerpositiontop .win-itemscontainer { - -ms-grid-row: 2; -} -.win-listview .win-horizontal .win-gridlayout.win-headerpositionleft.win-surface { - -ms-grid-columns: auto; - -ms-grid-rows: auto; -} -.win-listview .win-horizontal .win-gridlayout.win-headerpositionleft .win-groupheadercontainer { - -ms-grid-row: 1; -} -.win-listview .win-horizontal .win-gridlayout.win-headerpositionleft .win-itemscontainer { - -ms-grid-row: 1; -} -.win-listview .win-vertical .win-gridlayout.win-headerpositiontop.win-surface { - -ms-grid-columns: auto; - -ms-grid-rows: auto; -} -.win-listview .win-vertical .win-gridlayout.win-headerpositiontop .win-itemscontainer { - -ms-grid-column: 1; -} -.win-listview .win-vertical .win-gridlayout.win-headerpositionleft.win-surface { - -ms-grid-columns: auto 1fr; - -ms-grid-rows: auto; -} -.win-listview .win-vertical .win-gridlayout.win-headerpositionleft .win-itemscontainer { - -ms-grid-column: 2; -} -.win-listview .win-gridlayout.win-structuralnodes .win-uniformgridlayout.win-itemscontainer.win-laidout { - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-direction: row; - -webkit-flex-direction: row; - flex-direction: row; -} -.win-listview .win-horizontal .win-listlayout .win-itemscontainer, -.win-listview.win-groups .win-horizontal .win-listlayout .win-itemscontainer.win-laidout, -.win-listview .win-horizontal .win-listlayout .win-itemsblock, -.win-listview .win-horizontal .win-gridlayout .win-uniformgridlayout.win-itemscontainer.win-laidout, -.win-listview .win-horizontal .win-gridlayout .win-uniformgridlayout .win-itemsblock { - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-direction: column; - -webkit-flex-direction: column; - flex-direction: column; - -ms-flex-wrap: wrap; - -webkit-flex-wrap: wrap; - flex-wrap: wrap; - -ms-flex-line-pack: start; - -webkit-align-content: flex-start; - align-content: flex-start; -} -.win-listview .win-horizontal .win-itemscontainer-padder { - height: 100%; -} -.win-listview .win-horizontal .win-gridlayout .win-uniformgridlayout .win-itemsblock { - height: 100%; -} -.win-listview .win-horizontal .win-gridlayout .win-cellspanninggridlayout.win-itemscontainer.win-laidout { - display: -ms-grid; -} -.win-listview .win-vertical .win-gridlayout.win-structuralnodes .win-uniformgridlayout.win-itemscontainer.win-laidout { - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-direction: column; - -webkit-flex-direction: column; - flex-direction: column; -} -.win-listview .win-vertical .win-gridlayout .win-uniformgridlayout.win-itemscontainer.win-laidout, -.win-listview .win-vertical .win-gridlayout .win-uniformgridlayout .win-itemsblock { - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-direction: row; - -webkit-flex-direction: row; - flex-direction: row; - -ms-flex-wrap: wrap; - -webkit-flex-wrap: wrap; - flex-wrap: wrap; - -ms-flex-line-pack: start; - -webkit-align-content: flex-start; - align-content: flex-start; -} -.win-listview .win-vertical .win-gridlayout .win-uniformgridlayout .win-itemsblock { - width: 100%; -} -.win-listview .win-cellspanninggridlayout .win-container.win-laidout { - display: block; -} -.win-listview .win-cellspanninggridlayout .win-container { - display: none; -} -.win-listview .win-itembox { - position: relative; -} -.win-listview.win-dragover .win-itembox { - transform: scale(0.86); - -webkit-transform: scale(0.86); -} -.win-listview .win-itembox.win-dragsource, -.win-itemcontainer .win-itembox.win-dragsource { - opacity: 0.5; - transition: opacity cubic-bezier(0.1, 0.9, 0.2, 1) 167ms, transform cubic-bezier(0.1, 0.9, 0.2, 1) 220ms; - -webkit-transition: opacity cubic-bezier(0.1, 0.9, 0.2, 1) 167ms, transform cubic-bezier(0.1, 0.9, 0.2, 1) 220ms; -} -.win-listview.win-dragover .win-itembox.win-dragsource { - opacity: 0; - transition: none; - -webkit-transition: none; -} -html.win-hoverable .win-listview.win-dragover .win-container:hover { - outline: none; -} -.win-listview .win-itembox { - transition: transform cubic-bezier(0.1, 0.9, 0.2, 1) 220ms; - -webkit-transition: -webkit-transform cubic-bezier(0.1, 0.9, 0.2, 1) 220ms; -} -.win-listview.win-groups > .win-vertical .win-surface.win-listlayout.win-headerpositionleft { - margin-left: 70px; -} -.win-listview.win-groups.win-rtl > .win-vertical .win-surface.win-listlayout.win-headerpositionleft { - margin-left: 0px; - margin-right: 70px; -} -.win-listview > .win-horizontal .win-surface.win-listlayout { - margin-left: 70px; -} -.win-listview.win-rtl > .win-horizontal .win-surface.win-listlayout { - margin-left: 0px; - margin-right: 70px; -} -.win-listview .win-vertical .win-gridlayout.win-surface { - margin-left: 20px; -} -.win-listview.win-rtl .win-vertical .win-gridlayout.win-surface { - margin-left: 0px; - margin-right: 20px; -} -.win-itemcontainer .win-itembox, -.win-itemcontainer.win-container { - position: relative; -} -.win-itemcontainer { - touch-action: pan-x pan-y pinch-zoom; -} -html.win-hoverable .win-listview .win-itembox:hover::before, -html.win-hoverable .win-itemcontainer .win-itembox:hover::before { - opacity: 0.4; -} -html.win-hoverable .win-listview .win-pressed .win-itembox:hover::before, -html.win-hoverable .win-itemcontainer .win-pressed .win-itembox:hover::before, -html.win-hoverable .win-listview .win-pressed.win-itembox:hover::before, -html.win-hoverable .win-itemcontainer .win-pressed.win-itembox:hover::before { - opacity: 0.6; -} -html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover, -html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover, -html.win-hoverable .win-selectionstylefilled .win-itemcontainer.win-container:hover { - outline: none; -} -.win-selectionstylefilled.win-itemcontainer .win-itembox, -.win-selectionstylefilled .win-itemcontainer .win-itembox, -.win-listview.win-selectionstylefilled .win-itembox { - background-color: transparent; -} -.win-listview.win-selectionstylefilled .win-container.win-selected .win-selectionborder, -.win-itemcontainer.win-selectionstylefilled.win-container.win-selected .win-selectionborder { - border-color: transparent; -} -.win-listview.win-selectionstylefilled .win-surface.win-selectionmode .win-itembox::after { - background-color: transparent; -} -.win-listview.win-selectionstylefilled .win-selectioncheckmarkbackground, -.win-itemcontainer.win-selectionstylefilled .win-selectioncheckmarkbackground { - border-color: transparent; -} -.win-listview.win-selectionstylefilled .win-selected a, -.win-listview.win-selectionstylefilled .win-selected progress, -.win-listview.win-selectionstylefilled .win-selected .win-rating .win-star.win-full, -.win-itemcontainer.win-selectionstylefilled.win-selected a, -.win-itemcontainer.win-selectionstylefilled.win-selected progress, -.win-itemcontainer.win-selectionstylefilled.win-selected .win-rating .win-star.win-full { - color: #ffffff; -} -.win-listview.win-selectionstylefilled .win-selected.win-selected a:hover:active, -.win-itemcontainer.win-selectionstylefilled.win-selected.win-selected a:hover:active { - color: rgba(255, 255, 255, 0.6); -} -html.win-hoverable .win-listview.win-selectionstylefilled .win-selected a:hover, -html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-selected a:hover { - color: rgba(255, 255, 255, 0.8); -} -.win-listview.win-selectionstylefilled .win-selected button, -.win-listview.win-selectionstylefilled .win-selected input[type=button], -.win-listview.win-selectionstylefilled .win-selected input[type=reset], -.win-listview.win-selectionstylefilled .win-selected input[type=text], -.win-listview.win-selectionstylefilled .win-selected input[type=password], -.win-listview.win-selectionstylefilled .win-selected input[type=email], -.win-listview.win-selectionstylefilled .win-selected input[type=number], -.win-listview.win-selectionstylefilled .win-selected input[type=tel], -.win-listview.win-selectionstylefilled .win-selected input[type=url], -.win-listview.win-selectionstylefilled .win-selected input[type=search], -.win-listview.win-selectionstylefilled .win-selected input::-ms-check, -.win-listview.win-selectionstylefilled .win-selected textarea, -.win-listview.win-selectionstylefilled .win-selected .win-textarea, -.win-listview.win-selectionstylefilled .win-selected select, -.win-itemcontainer.win-selectionstylefilled.win-selected button, -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=button], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=reset], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=text], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=password], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=email], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=number], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=tel], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=url], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=search], -.win-itemcontainer.win-selectionstylefilled.win-selected input::-ms-check, -.win-itemcontainer.win-selectionstylefilled.win-selected textarea, -.win-itemcontainer.win-selectionstylefilled.win-selected .win-textarea, -.win-itemcontainer.win-selectionstylefilled.win-selected select { - background-clip: border-box; - background-color: rgba(255, 255, 255, 0.8); - border-color: transparent; - color: #000000; -} -.win-listview.win-selectionstylefilled .win-selected button[type=submit], -.win-listview.win-selectionstylefilled .win-selected input[type=submit], -.win-itemcontainer.win-selectionstylefilled.win-selected button[type=submit], -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=submit] { - border-color: #ffffff; -} -.win-listview.win-selectionstylefilled .win-selected input[type=range]::-ms-fill-lower, -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=range]::-ms-fill-lower { - background-color: #ffffff; -} -.win-listview.win-selectionstylefilled .win-selected input[type=range]::-ms-thumb, -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=range]::-ms-thumb { - background-color: #000000; -} -.win-listview.win-selectionstylefilled .win-selected input[type=range]::-ms-fill-upper, -.win-listview.win-selectionstylefilled .win-selected progress, -.win-itemcontainer.win-selectionstylefilled.win-selected input[type=range]::-ms-fill-upper, -.win-itemcontainer.win-selectionstylefilled.win-selected progress { - background-color: rgba(255, 255, 255, 0.16); -} -.win-listview.win-selectionstylefilled .win-selected progress:indeterminate, -.win-itemcontainer.win-selectionstylefilled.win-selected progress:indeterminate { - background-color: transparent; -} -.win-listview.win-selectionstylefilled .win-selected .win-rating .win-star.win-empty, -.win-itemcontainer.win-selectionstylefilled.win-selected .win-rating .win-star.win-empty { - color: rgba(255, 255, 255, 0.16); -} -.win-listview .win-viewport { - outline: none; -} -@media (-ms-high-contrast) { - .win-listview .win-groupheader { - color: WindowText; - } - .win-selectioncheckmark { - color: HighlightText; - } - .win-listview .win-focusedoutline, - .win-listview .win-groupheader, - .win-itemcontainer .win-focusedoutline { - outline-color: WindowText; - } - .win-listview.win-selectionstylefilled .win-itembox, - .win-itemcontainer.win-selectionstylefilled .win-itembox { - background-color: Window; - color: WindowText; - } - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover .win-itembox, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover .win-itembox { - background-color: Highlight; - color: HighlightText; - } - .win-listview.win-selectionstylefilled .win-container.win-selected .win-itembox, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container.win-selected:hover .win-itembox, - .win-itemcontainer.win-selectionstylefilled.win-container.win-selected .win-itembox, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container.win-selected:hover .win-itembox { - background-color: Highlight; - color: HighlightText; - } - .win-listview:not(.win-selectionstylefilled) .win-container.win-selected .win-selectionborder, - .win-itemcontainer:not(.win-selectionstylefilled).win-container.win-selected .win-selectionborder { - border-color: Highlight; - } - .win-listview.win-selectionstylefilled .win-container.win-selected .win-selectionborder, - .win-itemcontainer.win-selectionstylefilled.win-container.win-selected .win-selectionborder { - border-color: transparent; - } - html.win-hoverable .win-listview:not(.win-selectionstylefilled) .win-container.win-selected:hover .win-selectionborder, - html.win-hoverable .win-itemcontainer:not(.win-selectionstylefilled).win-container.win-selected:hover .win-selectionborder { - border-color: Highlight; - } - .win-listview.win-selectionstylefilled .win-selected .win-selectionbackground, - html.win-hoverable .win-listview.win-selectionstylefilled .win-selected:hover .win-selectionbackground, - .win-itemcontainer.win-selectionstylefilled.win-selected .win-selectionbackground, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-selected:hover .win-selectionbackground { - background-color: Highlight; - color: HighlightText; - } - .win-listview.win-selectionstylefilled .win-selectioncheckmarkbackground, - .win-itemcontainer.win-selectionstylefilled .win-selectioncheckmarkbackground { - border-color: transparent; - } - .win-listview.win-selectionstylefilled .win-selected a, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover a, - .win-listview.win-selectionstylefilled .win-selected progress, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover progress, - .win-listview.win-selectionstylefilled .win-selected .win-rating .win-star:after, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover .win-rating .win-star:after, - .win-itemcontainer.win-selectionstylefilled.win-selected a, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover a, - .win-itemcontainer.win-selectionstylefilled.win-selected progress, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover progress, - .win-itemcontainer.win-selectionstylefilled.win-selected .win-rating .win-star:after, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover .win-rating .win-star:after { - color: HighlightText; - } - .win-listview.win-selectionstylefilled .win-selected input, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover input, - .win-listview.win-selectionstylefilled .win-selected input::-ms-check, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover input::-ms-check, - .win-listview.win-selectionstylefilled .win-selected input::-ms-value, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover input::-ms-value, - .win-listview.win-selectionstylefilled .win-selected input::-ms-track, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover input::-ms-track, - .win-listview.win-selectionstylefilled .win-selected button, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover button, - .win-listview.win-selectionstylefilled .win-selected progress, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover progress, - .win-listview.win-selectionstylefilled .win-selected progress::-ms-fill, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover progress::-ms-fill, - .win-listview.win-selectionstylefilled .win-selected select, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover select, - .win-listview.win-selectionstylefilled .win-selected textarea, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover textarea, - .win-listview.win-selectionstylefilled.win-selected input, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover input, - .win-itemcontainer.win-selectionstylefilled.win-selected input::-ms-check, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover input::-ms-check, - .win-itemcontainer.win-selectionstylefilled.win-selected input::-ms-value, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover input::-ms-value, - .win-itemcontainer.win-selectionstylefilled.win-selected input::-ms-track, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover input::-ms-track, - .win-itemcontainer.win-selectionstylefilled.win-selected button, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover button, - .win-itemcontainer.win-selectionstylefilled.win-selected progress, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover progress, - .win-itemcontainer.win-selectionstylefilled.win-selected progress::-ms-fill, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover progress::-ms-fill, - .win-itemcontainer.win-selectionstylefilled.win-selected select, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover select, - .win-itemcontainer.win-selectionstylefilled.win-selected textarea, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover textarea { - border-color: HighlightText; - } - .win-listview.win-selectionstylefilled .win-selected input[type=range]::-ms-fill-lower, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover input[type=range]::-ms-fill-lower, - .win-listview.win-selectionstylefilled .win-selected progress::-ms-fill, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover progress::-ms-fill, - .win-itemcontainer.win-selectionstylefilled.win-selected input[type=range]::-ms-fill-lower, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover input[type=range]::-ms-fill-lower, - .win-itemcontainer.win-selectionstylefilled.win-selected progress::-ms-fill, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover progress::-ms-fill { - background-color: HighlightText; - } - .win-listview.win-selectionstylefilled .win-selected input[type=range]::-ms-fill-upper, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover input[type=range]::-ms-fill-upper, - .win-listview.win-selectionstylefilled .win-selected progress, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover progress, - .win-itemcontainer.win-selectionstylefilled.win-selected input[type=range]::-ms-fill-upper, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover input[type=range]::-ms-fill-upper, - .win-itemcontainer.win-selectionstylefilled.win-selected progress, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover progress { - background-color: Highlight; - } - .win-listview.win-selectionstylefilled .win-selected .win-rating .win-star.win-full:before, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover .win-rating .win-star.win-full:before, - .win-itemcontainer.win-selectionstylefilled.win-selected .win-rating .win-star.win-full:before, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover .win-rating .win-star.win-full:before { - color: ButtonFace; - } - .win-listview.win-selectionstylefilled .win-selected .win-rating .win-star.win-empty:before, - html.win-hoverable .win-listview.win-selectionstylefilled .win-container:hover .win-rating .win-star.win-empty:before, - .win-itemcontainer.win-selectionstylefilled.win-selected .win-rating .win-star.win-empty:before, - html.win-hoverable .win-itemcontainer.win-selectionstylefilled.win-container:hover .win-rating .win-star.win-empty:before { - color: Highlight; - } - html.win-hoverable .win-listview .win-container:hover, - html.win-hoverable .win-itemcontainer.win-container:hover { - outline: Highlight solid 3px; - } -} -.win-flipview { - overflow: hidden; - height: 400px; -} -.win-flipview .win-surface { - -ms-scroll-chaining: none; -} -.win-flipview .win-navleft { - left: 0%; - top: 50%; - margin-top: -19px; -} -.win-flipview .win-navright { - left: 100%; - top: 50%; - margin-left: -20px; - margin-top: -19px; -} -.win-flipview .win-navtop { - left: 50%; - top: 0%; - margin-left: -35px; -} -.win-flipview .win-navbottom { - left: 50%; - top: 100%; - margin-left: -35px; - margin-top: -36px; -} -.win-flipview .win-navbutton { - touch-action: manipulation; - border: none; - width: 20px; - height: 36px; - z-index: 1; - position: absolute; - font-family: "Segoe MDL2 Assets", "Symbols"; - font-size: 16px; - padding: 0; - min-width: 0; -} -.win-flipview .win-item, -.win-flipview .win-item > .win-template { - height: 100%; - width: 100%; - display: -ms-flexbox; - display: -webkit-flex; - display: flex; - -ms-flex-align: center; - -webkit-align-items: center; - align-items: center; - -ms-flex-pack: center; - -webkit-justify-content: center; - justify-content: center; -} -@media (-ms-high-contrast) { - .win-flipview .win-navbottom { - left: 50%; - top: 100%; - margin-left: -35px; - margin-top: -35px; - } - .win-flipview .win-navbutton { - background-color: ButtonFace; - color: ButtonText; - border: 2px solid ButtonText; - width: 65px; - height: 35px; - } - .win-flipview .win-navbutton.win-navbutton:hover:active, - .win-flipview .win-navbutton.win-navbutton:active { - background-color: ButtonText; - color: ButtonFace; - } - .win-flipview .win-navright { - margin-left: -65px; - } - html.win-hoverable .win-flipview .win-navbutton:hover { - background-color: Highlight; - color: HighlightText; - } -} -.win-datepicker { - display: -ms-inline-flexbox; - display: -webkit-inline-flex; - display: inline-flex; - height: auto; - width: auto; -} -.win-datepicker select { - min-width: 80px; - margin-top: 4px; - margin-bottom: 4px; -} -.win-datepicker .win-datepicker-month { - margin-right: 20px; -} -.win-datepicker .win-datepicker-date.win-order0, -.win-datepicker .win-datepicker-date.win-order1 { - margin-right: 20px; -} -.win-datepicker .win-datepicker-year.win-order0 { - margin-right: 20px; -} -.win-datepicker .win-datepicker-month:lang(ar), -.win-datepicker .win-datepicker-month:lang(dv), -.win-datepicker .win-datepicker-month:lang(fa), -.win-datepicker .win-datepicker-month:lang(he), -.win-datepicker .win-datepicker-month:lang(ku-Arab), -.win-datepicker .win-datepicker-month:lang(pa-Arab), -.win-datepicker .win-datepicker-month:lang(prs), -.win-datepicker .win-datepicker-month:lang(ps), -.win-datepicker .win-datepicker-month:lang(sd-Arab), -.win-datepicker .win-datepicker-month:lang(syr), -.win-datepicker .win-datepicker-month:lang(ug), -.win-datepicker .win-datepicker-month:lang(ur), -.win-datepicker .win-datepicker-month:lang(qps-plocm), -.win-datepicker .win-datepicker-date.win-order0:lang(ar), -.win-datepicker .win-datepicker-date.win-order0:lang(dv), -.win-datepicker .win-datepicker-date.win-order0:lang(fa), -.win-datepicker .win-datepicker-date.win-order0:lang(he), -.win-datepicker .win-datepicker-date.win-order0:lang(ku-Arab), -.win-datepicker .win-datepicker-date.win-order0:lang(pa-Arab), -.win-datepicker .win-datepicker-date.win-order0:lang(prs), -.win-datepicker .win-datepicker-date.win-order0:lang(ps), -.win-datepicker .win-datepicker-date.win-order0:lang(sd-Arab), -.win-datepicker .win-datepicker-date.win-order0:lang(syr), -.win-datepicker .win-datepicker-date.win-order0:lang(ug), -.win-datepicker .win-datepicker-date.win-order0:lang(ur), -.win-datepicker .win-datepicker-date.win-order0:lang(qps-plocm), -.win-datepicker .win-datepicker-date.win-order1:lang(ar), -.win-datepicker .win-datepicker-date.win-order1:lang(dv), -.win-datepicker .win-datepicker-date.win-order1:lang(fa), -.win-datepicker .win-datepicker-date.win-order1:lang(he), -.win-datepicker .win-datepicker-date.win-order1:lang(ku-Arab), -.win-datepicker .win-datepicker-date.win-order1:lang(pa-Arab), -.win-datepicker .win-datepicker-date.win-order1:lang(prs), -.win-datepicker .win-datepicker-date.win-order1:lang(ps), -.win-datepicker .win-datepicker-date.win-order1:lang(sd-Arab), -.win-datepicker .win-datepicker-date.win-order1:lang(syr), -.win-datepicker .win-datepicker-date.win-order1:lang(ug), -.win-datepicker .win-datepicker-date.win-order1:lang(ur), -.win-datepicker .win-datepicker-date.win-order1:lang(qps-plocm), -.win-datepicker .win-datepicker-year.win-order0:lang(ar), -.win-datepicker .win-datepicker-year.win-order0:lang(dv), -.win-datepicker .win-datepicker-year.win-order0:lang(fa), -.win-datepicker .win-datepicker-year.win-order0:lang(he), -.win-datepicker .win-datepicker-year.win-order0:lang(ku-Arab), -.win-datepicker .win-datepicker-year.win-order0:lang(pa-Arab), -.win-datepicker .win-datepicker-year.win-order0:lang(prs), -.win-datepicker .win-datepicker-year.win-order0:lang(ps), -.win-datepicker .win-datepicker-year.win-order0:lang(sd-Arab), -.win-datepicker .win-datepicker-year.win-order0:lang(syr), -.win-datepicker .win-datepicker-year.win-order0:lang(ug), -.win-datepicker .win-datepicker-year.win-order0:lang(ur), -.win-datepicker .win-datepicker-year.win-order0:lang(qps-plocm) { - margin-right: 0; - margin-left: 20px; -} -.win-timepicker { - display: -ms-inline-flexbox; - display: -webkit-inline-flex; - display: inline-flex; - height: auto; - width: auto; -} -.win-timepicker select { - min-width: 80px; - margin-top: 4px; - margin-bottom: 4px; -} -.win-timepicker .win-timepicker-hour { - margin-right: 20px; -} -.win-timepicker .win-timepicker-period.win-order0 { - margin-right: 20px; -} -.win-timepicker .win-timepicker-minute.win-order1 { - margin-right: 20px; -} -.win-timepicker .win-timepicker-period.win-order0:lang(ar), -.win-timepicker .win-timepicker-period.win-order0:lang(dv), -.win-timepicker .win-timepicker-period.win-order0:lang(fa), -.win-timepicker .win-timepicker-period.win-order0:lang(he), -.win-timepicker .win-timepicker-period.win-order0:lang(ku-Arab), -.win-timepicker .win-timepicker-period.win-order0:lang(pa-Arab), -.win-timepicker .win-timepicker-period.win-order0:lang(prs), -.win-timepicker .win-timepicker-period.win-order0:lang(ps), -.win-timepicker .win-timepicker-period.win-order0:lang(sd-Arab), -.win-timepicker .win-timepicker-period.win-order0:lang(syr), -.win-timepicker .win-timepicker-period.win-order0:lang(ug), -.win-timepicker .win-timepicker-period.win-order0:lang(ur), -.win-timepicker .win-timepicker-period.win-order0:lang(qps-plocm), -.win-timepicker .win-timepicker-hour:lang(ar), -.win-timepicker .win-timepicker-hour:lang(dv), -.win-timepicker .win-timepicker-hour:lang(fa), -.win-timepicker .win-timepicker-hour:lang(he), -.win-timepicker .win-timepicker-hour:lang(ku-Arab), -.win-timepicker .win-timepicker-hour:lang(pa-Arab), -.win-timepicker .win-timepicker-hour:lang(prs), -.win-timepicker .win-timepicker-hour:lang(ps), -.win-timepicker .win-timepicker-hour:lang(sd-Arab), -.win-timepicker .win-timepicker-hour:lang(syr), -.win-timepicker .win-timepicker-hour:lang(ug), -.win-timepicker .win-timepicker-hour:lang(ur), -.win-timepicker .win-timepicker-hour:lang(qps-plocm) { - margin-right: 0; - margin-left: 20px; -} -.win-timepicker .win-timepicker-minute.win-order1:lang(ar), -.win-timepicker .win-timepicker-minute.win-order1:lang(dv), -.win-timepicker .win-timepicker-minute.win-order1:lang(fa), -.win-timepicker .win-timepicker-minute.win-order1:lang(he), -.win-timepicker .win-timepicker-minute.win-order1:lang(ku-Arab), -.win-timepicker .win-timepicker-minute.win-order1:lang(pa-Arab), -.win-timepicker .win-timepicker-minute.win-order1:lang(prs), -.win-timepicker .win-timepicker-minute.win-order1:lang(ps), -.win-timepicker .win-timepicker-minute.win-order1:lang(sd-Arab), -.win-timepicker .win-timepicker-minute.win-order1:lang(syr), -.win-timepicker .win-timepicker-minute.win-order1:lang(ug), -.win-timepicker .win-timepicker-minute.win-order1:lang(ur), -.win-timepicker .win-timepicker-minute.win-order1:lang(qps-plocm), -.win-timepicker .win-timepicker-minute.win-order0:lang(ar), -.win-timepicker .win-timepicker-minute.win-order0:lang(dv), -.win-timepicker .win-timepicker-minute.win-order0:lang(fa), -.win-timepicker .win-timepicker-minute.win-order0:lang(he), -.win-timepicker .win-timepicker-minute.win-order0:lang(ku-Arab), -.win-timepicker .win-timepicker-minute.win-order0:lang(pa-Arab), -.win-timepicker .win-timepicker-minute.win-order0:lang(prs), -.win-timepicker .win-timepicker-minute.win-order0:lang(ps), -.win-timepicker .win-timepicker-minute.win-order0:lang(sd-Arab), -.win-timepicker .win-timepicker-minute.win-order0:lang(syr), -.win-timepicker .win-timepicker-minute.win-order0:lang(ug), -.win-timepicker .win-timepicker-minute.win-order0:lang(ur), -.win-timepicker .win-timepicker-minute.win-order0:lang(qps-plocm) { - margin-left: 20px; - margin-right: 0; -} -body > .win-navigation-backbutton { - position: absolute; - top: 50px; - left: 20px; -} -.win-backbutton, -.win-navigation-backbutton, -.win-back { - touch-action: manipulation; - display: inline-block; - min-width: 0; - min-height: 0; - padding: 0; - text-align: center; - width: 41px; - height: 41px; - font-size: 24px; - line-height: 41px; - vertical-align: baseline; -} -.win-backbutton::before, -.win-back::before { - font-family: "Segoe MDL2 Assets", "Symbols"; - font-weight: normal; - content: "\E0D5"; - vertical-align: 50%; -} -.win-backbutton:lang(ar)::before, -.win-backbutton:lang(dv)::before, -.win-backbutton:lang(fa)::before, -.win-backbutton:lang(he)::before, -.win-backbutton:lang(ku-Arab)::before, -.win-backbutton:lang(pa-Arab)::before, -.win-backbutton:lang(prs)::before, -.win-backbutton:lang(ps)::before, -.win-backbutton:lang(sd-Arab)::before, -.win-backbutton:lang(syr)::before, -.win-backbutton:lang(ug)::before, -.win-backbutton:lang(ur)::before, -.win-backbutton:lang(qps-plocm)::before, -.win-back:lang(ar)::before, -.win-back:lang(dv)::before, -.win-back:lang(fa)::before, -.win-back:lang(he)::before, -.win-back:lang(ku-Arab)::before, -.win-back:lang(pa-Arab)::before, -.win-back:lang(prs)::before, -.win-back:lang(ps)::before, -.win-back:lang(sd-Arab)::before, -.win-back:lang(syr)::before, -.win-back:lang(ug)::before, -.win-back:lang(ur)::before, -.win-back:lang(qps-plocm)::before { - content: "\E0AE"; -} -button.win-navigation-backbutton, -button.win-navigation-backbutton:active, -html.win-hoverable button.win-navigation-backbutton:enabled:hover, -button.win-navigation-backbutton:enabled:hover:active { - background-color: transparent; - border: none; -} -@media (-ms-high-contrast) { - button.win-navigation-backbutton, - button.win-navigation-backbutton:active, - html.win-hoverable button.win-navigation-backbutton:enabled:hover, - button.win-navigation-backbutton:enabled:hover:active { - /* Overwrite default background and border styles from BackButton control's ]]> - /// The BackButton control itself - /// The Back Arrow glyph - /// - /// - BackButton: _Base.Namespace._lazy(function () { - // Statics - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/backbuttonarialabel").value; }, - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get badButtonElement() { return "Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"; } - }; - - var BackButton = _Base.Class.define(function BackButton_ctor(element, options) { - /// - /// - /// Creates a new BackButton control - /// - /// - /// The DOM element that will host the control. If this parameter is null, this constructor creates one for you. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to - /// one of the control's properties or events. - /// - /// - /// A BackButton control. - /// - /// - /// - - // Check to make sure we weren't duplicated - if (element && element.winControl) { - throw new _ErrorFromName("WinJS.UI.BackButton.DuplicateConstruction", strings.duplicateConstruction); - } - - this._element = element || _Global.document.createElement("button"); - options = options || {}; - - this._initializeButton(); // This will also set the aria-label and tooltip - - this._disposed = false; - - // Remember ourselves - this._element.winControl = this; - - _Control.setOptions(this, options); - - // Add event handlers for this back button instance - this._buttonClickHandler = this._handleBackButtonClick.bind(this); - this._element.addEventListener('click', this._buttonClickHandler, false); - this._navigatedHandler = this._handleNavigatedEvent.bind(this); - Navigation.addEventListener('navigated', this._navigatedHandler, false); - - // Increment reference count / manage add global event handlers - singleton.addRef(); - }, { - - /// - element: { - get: function () { - return this._element; - } - }, - - dispose: function () { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; // Mark this control as disposed. - - // Remove 'navigated' eventhandler for this BackButton - Navigation.removeEventListener('navigated', this._navigatedHandler, false); - - singleton.release(); // Decrement reference count. - - }, - - refresh: function () { - /// - /// - /// Sets the 'disabled' attribute to correct the value based on the current navigation history stack. - /// - /// - /// - if (Navigation.canGoBack) { - this._element.disabled = false; - } else { - this._element.disabled = true; - } - }, - - _initializeButton: function () { - //Final EN-US HTML should be: - // - //Button will automatically be disabled if WinJS.Navigation.history.canGoBack is false. - - // Verify the HTML is a button - if (this._element.tagName !== "BUTTON") { - throw new _ErrorFromName("WinJS.UI.BackButton.BadButtonElement", strings.badButtonElement); - } - - // Attach our css classes - _ElementUtilities.addClass(this._element, navigationBackButtonClass); - - // Attach disposable class. - _ElementUtilities.addClass(this._element, "win-disposable"); - - // Create inner glyph element - this._element.innerHTML = ''; - - // Set the 'disabled' property to the correct value based on the current navigation history stack. - this.refresh(); - - // Set Aria-label and native tooltip to the same localized string equivalent of "Back" - this._element.setAttribute("aria-label", strings.ariaLabel); - this._element.setAttribute("title", strings.ariaLabel); - - // Explicitly set type attribute to avoid the default '; - this._headerTabStopElement = this._headerElement.firstElementChild; - // The purpose of headerWrapperElement is to lay out its children in a flexbox. Ideally, this flexbox would - // be on headerTabStopElement. However, firefox lays out flexboxes with display:flex differently. - // Firefox bug 1014285 (Button with display:inline-flex doesn't layout properly) - // https://bugzilla.mozilla.org/show_bug.cgi?id=1014285 - this._headerWrapperElement = this._headerTabStopElement.firstElementChild; - this._headerContentElement = this._headerWrapperElement.firstElementChild; - this._headerChevronElement = this._headerWrapperElement.lastElementChild; - element.appendChild(this._headerElement); - - this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._headerElement); - - this._contentElement = _Global.document.createElement("DIV"); - this._contentElement.className = HubSection._ClassName.hubSectionContent; - this._contentElement.style.visibility = "hidden"; - element.appendChild(this._contentElement); - - // Reparent any existing elements inside the new hub section content element. - var elementToMove = this.element.firstChild; - while (elementToMove !== this._headerElement) { - var nextElement = elementToMove.nextSibling; - this._contentElement.appendChild(elementToMove); - elementToMove = nextElement; - } - - this._processors = [ControlProcessor.processAll]; - - _Control.setOptions(this, options); - }, { - /// - element: { - get: function () { - return this._element; - } - }, - /// - /// Gets or sets a value that specifies whether the header is static. Set this value to true to disable clicks and other interactions. - /// - /// - isHeaderStatic: { - get: function () { - return this._isHeaderStatic; - }, - set: function (value) { - this._isHeaderStatic = value; - if (!this._isHeaderStatic) { - this._headerTabStopElement.setAttribute("role", "link"); - _ElementUtilities.addClass(this._headerTabStopElement, HubSection._ClassName.hubSectionInteractive); - } else { - this._headerTabStopElement.setAttribute("role", "heading"); - _ElementUtilities.removeClass(this._headerTabStopElement, HubSection._ClassName.hubSectionInteractive); - } - } - }, - /// - /// Gets the DOM element that hosts the HubSection's content. - /// - /// - contentElement: { - get: function () { - return this._contentElement; - } - }, - /// - /// Get or set the HubSection's header. After you set this property, the Hub renders the header again. - /// - /// - header: { - get: function () { - return this._header; - }, - set: function (value) { - // Render again even if it is equal to itself. - this._header = value; - this._renderHeader(); - } - }, - _setHeaderTemplate: function HubSection_setHeaderTemplate(template) { - this._template = _ElementUtilities._syncRenderer(template); - this._renderHeader(); - }, - _renderHeader: function HubSection_renderHeader() { - if (this._template) { - _Dispose._disposeElement(this._headerContentElement); - _ElementUtilities.empty(this._headerContentElement); - this._template(this, this._headerContentElement); - } - }, - _process: function HubSection_process() { - var that = this; - - this._processed = (this._processors || []).reduce(function (promise, processor) { - return promise.then(function () { - return processor(that.contentElement); - }); - }, this._processed || Promise.as()); - this._processors = null; - - return this._processed; - }, - dispose: function HubSection_dispose() { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - this._processors = null; - - _Dispose._disposeElement(this._headerContentElement); - _Dispose.disposeSubTree(this.contentElement); - } - }, { - // Names of classes used by the HubSection. - _ClassName: { - hubSection: "win-hub-section", - hubSectionHeader: "win-hub-section-header", - hubSectionHeaderTabStop: "win-hub-section-header-tabstop", - hubSectionHeaderWrapper: "win-hub-section-header-wrapper", - hubSectionInteractive: "win-hub-section-header-interactive", - hubSectionHeaderContent: "win-hub-section-header-content", - hubSectionHeaderChevron: "win-hub-section-header-chevron", - hubSectionContent: "win-hub-section-content" - }, - isDeclarativeControlContainer: _BaseUtils.markSupportedForProcessing(function (section, callback) { - if (callback === ControlProcessor.processAll) { - return; - } - - section._processors = section._processors || []; - section._processors.push(callback); - - // Once processed the first time synchronously queue up new processors as they come in - if (section._processed) { - section._process(); - } - }) - }); - - return HubSection; - }) - }); - -}); - - -define('require-style!less/styles-hub',[],function(){}); - -define('require-style!less/colors-hub',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/Hub',[ - '../Core/_Global', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_ErrorFromName', - '../Core/_Events', - '../Core/_Log', - '../Core/_Resources', - '../Core/_WriteProfilerMark', - '../_Accents', - '../Animations', - '../Animations/_TransitionAnimation', - '../BindingList', - '../ControlProcessor', - '../Promise', - '../_Signal', - '../Scheduler', - '../Utilities/_Control', - '../Utilities/_ElementUtilities', - '../Utilities/_Hoverable', - '../Utilities/_UI', - './Hub/_Section', - 'require-style!less/styles-hub', - 'require-style!less/colors-hub' -], function hubInit(_Global, _Base, _BaseUtils, _ErrorFromName, _Events, _Log, _Resources, _WriteProfilerMark, _Accents, Animations, _TransitionAnimation, BindingList, ControlProcessor, Promise, _Signal, Scheduler, _Control, _ElementUtilities, _Hoverable, _UI, _Section) { - "use strict"; - - _Accents.createAccentRule( - ".win-semanticzoom-zoomedoutview .win-hub-section-header-interactive .win-hub-section-header-content,\ - .win-hub-section-header-interactive .win-hub-section-header-chevron", - [{ name: "color", value: _Accents.ColorTypes.accent }]); - - _Base.Namespace.define("WinJS.UI", { - /// - /// - /// Displays sections of content. - /// - /// - /// - /// - /// - /// - ///
HubSection Content
- /// ]]>
- /// Raised when the Hub is about to play an entrance or a transition animation. - /// Raised when a header is invoked. - /// Raised when the loading state changes. - /// The entire Hub control. - /// The progress indicator for the Hub. - /// The viewport of the Hub. - /// The scrollable region of the Hub. - /// - /// - Hub: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - function hubDefaultHeaderTemplate(section) { - var element = _Global.document.createTextNode(typeof section.header === "object" ? JSON.stringify(section.header) : ('' + section.header)); - return element; - } - - var createEvent = _Events._createEventProperty; - var eventNames = { - contentAnimating: "contentanimating", - headerInvoked: "headerinvoked", - loadingStateChanged: "loadingstatechanged" - }; - - // Delay time before progress dots are shown when loading hub section(s) on screen. - var progressDelay = 500; - - var verticalNames = { - scrollPos: "scrollTop", - scrollSize: "scrollHeight", - offsetPos: "offsetTop", - offsetSize: "offsetHeight", - oppositeOffsetSize: "offsetWidth", - marginStart: "marginTop", - marginEnd: "marginBottom", - borderStart: "borderTopWidth", - borderEnd: "borderBottomWidth", - paddingStart: "paddingTop", - paddingEnd: "paddingBottom" - }; - var rtlHorizontalNames = { - scrollPos: "scrollLeft", - scrollSize: "scrollWidth", - offsetPos: "offsetLeft", - offsetSize: "offsetWidth", - oppositeOffsetSize: "offsetHeight", - marginStart: "marginRight", - marginEnd: "marginLeft", - borderStart: "borderRightWidth", - borderEnd: "borderLeftWidth", - paddingStart: "paddingRight", - paddingEnd: "paddingLeft" - }; - var ltrHorizontalNames = { - scrollPos: "scrollLeft", - scrollSize: "scrollWidth", - offsetPos: "offsetLeft", - offsetSize: "offsetWidth", - oppositeOffsetSize: "offsetHeight", - marginStart: "marginLeft", - marginEnd: "marginRight", - borderStart: "borderLeftWidth", - borderEnd: "borderRightWidth", - paddingStart: "paddingLeft", - paddingEnd: "paddingRight" - }; - - var Hub = _Base.Class.define(function Hub_ctor(element, options) { - /// - /// - /// Creates a new Hub control. - /// - /// - /// The DOM element that hosts the Hub control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". For example, to provide a handler for the contentanimating event, - /// add a property named "oncontentanimating" to the options object and set its value to the event handler. - /// - /// - /// The new Hub. - /// - /// - /// - element = element || _Global.document.createElement("DIV"); - options = options || {}; - - if (element.winControl) { - throw new _ErrorFromName("WinJS.UI.Hub.DuplicateConstruction", strings.duplicateConstruction); - } - - this._id = element.id || _ElementUtilities._uniqueID(element); - this._writeProfilerMark("constructor,StartTM"); - - this._windowKeyDownHandlerBound = this._windowKeyDownHandler.bind(this); - _Global.addEventListener('keydown', this._windowKeyDownHandlerBound); - - // Attaching JS control to DOM element - element.winControl = this; - this._element = element; - _ElementUtilities.addClass(this.element, Hub._ClassName.hub); - _ElementUtilities.addClass(this.element, "win-disposable"); - - this._viewportElement = _Global.document.createElement("DIV"); - this._viewportElement.className = Hub._ClassName.hubViewport; - this._element.appendChild(this._viewportElement); - this._viewportElement.setAttribute("role", "group"); - this._viewportElement.setAttribute("aria-label", strings.hubViewportAriaLabel); - - this._surfaceElement = _Global.document.createElement("DIV"); - this._surfaceElement.className = Hub._ClassName.hubSurface; - this._viewportElement.appendChild(this._surfaceElement); - - // Start invisible so that you do not see the content loading until the sections are ready. - this._visible = false; - this._viewportElement.style.opacity = 0; - - if (!options.orientation) { - this._orientation = _UI.Orientation.horizontal; - _ElementUtilities.addClass(this.element, Hub._ClassName.hubHorizontal); - } - - this._fireEntrance = true; - this._animateEntrance = true; - this._loadId = 0; - this.runningAnimations = new Promise.wrap(); - this._currentIndexForSezo = 0; - - // This internally assigns this.sections which causes section to be used (even from options) before - // scrollPosition or sectionOnScreen. - this._parse(); - - _Control.setOptions(this, options); - - _ElementUtilities._addEventListener(this.element, "focusin", this._focusin.bind(this), false); - this.element.addEventListener("keydown", this._keyDownHandler.bind(this)); - this.element.addEventListener("click", this._clickHandler.bind(this)); - this._resizeHandlerBound = this._resizeHandler.bind(this); - this.element.addEventListener("mselementresize", this._resizeHandlerBound); - _ElementUtilities._resizeNotifier.subscribe(this.element, this._resizeHandlerBound); - this._viewportElement.addEventListener("scroll", this._scrollHandler.bind(this)); - this._surfaceElement.addEventListener("mselementresize", this._contentResizeHandler.bind(this)); - - this._handleSectionChangedBind = this._handleSectionChanged.bind(this); - this._handleSectionInsertedBind = this._handleSectionInserted.bind(this); - this._handleSectionMovedBind = this._handleSectionMoved.bind(this); - this._handleSectionRemovedBind = this._handleSectionRemoved.bind(this); - this._handleSectionReloadBind = this._handleSectionReload.bind(this); - - this._refresh(); - - this._writeProfilerMark("constructor,StopTM"); - }, { - /// - element: { - get: function () { - return this._element; - } - }, - /// - /// Gets or sets the orientation of sections within the Hub. - /// - /// - orientation: { - get: function () { - return this._orientation; - }, - set: function (value) { - if (value === this._orientation) { - return; - } - this._measured = false; - // clear existing scroll before we switch orientation - if (this._names) { // handle setting orientation before we measure - var newScrollPos = {}; - newScrollPos[this._names.scrollPos] = 0; - _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); - } - if (value === _UI.Orientation.vertical) { - _ElementUtilities.removeClass(this.element, Hub._ClassName.hubHorizontal); - _ElementUtilities.addClass(this.element, Hub._ClassName.hubVertical); - } else { - value = _UI.Orientation.horizontal; - _ElementUtilities.removeClass(this.element, Hub._ClassName.hubVertical); - _ElementUtilities.addClass(this.element, Hub._ClassName.hubHorizontal); - } - this._orientation = value; - Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); - } - }, - /// - /// Gets or sets the WinJS.Binding.List of HubSection objects that belong to this Hub. - /// - /// - sections: { - get: function () { - if (this._pendingSections) { - return this._pendingSections; - } - return this._sections; - }, - set: function (value) { - var resetScrollPosition = !this._pendingSections; - this._pendingSections = value; - this._refresh(); - if (resetScrollPosition) { - this.scrollPosition = 0; - } - } - }, - /// - /// Gets or sets the WinJS.Binding.Template or template function that creates the DOM elements - /// which represent the header for each HubSection. Each header can - /// contain multiple DOM elements, but we recommend that it have a single - /// root element. - /// - /// - headerTemplate: { - get: function () { - if (this._pendingHeaderTemplate) { - return this._pendingHeaderTemplate; - } - - if (!this._headerTemplate) { - this._headerTemplate = hubDefaultHeaderTemplate; - } - - return this._headerTemplate; - }, - set: function (value) { - this._pendingHeaderTemplate = value || hubDefaultHeaderTemplate; - this._refresh(); - } - }, - /// - /// Gets or sets the position of the Hub's scrollbar. - /// - /// - scrollPosition: { - get: function () { - if (+this._pendingScrollLocation === this._pendingScrollLocation) { - return this._pendingScrollLocation; - } - - this._measure(); - return this._scrollPosition; - }, - set: function (value) { - value = Math.max(0, value); - if (this._pendingRefresh) { - // Unable to constrain length because sections may have changed. - this._pendingScrollLocation = value; - this._pendingSectionOnScreen = null; - } else { - this._measure(); - var targetScrollPos = Math.max(0, Math.min(this._scrollLength - this._viewportSize, value)); - this._scrollPosition = targetScrollPos; - var newScrollPos = {}; - newScrollPos[this._names.scrollPos] = targetScrollPos; - _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); - } - } - }, - - /// - /// Gets or sets the index of first section in view. This property is useful for restoring a previous view when your app launches or resumes. - /// - /// - sectionOnScreen: { - get: function () { - if (+this._pendingSectionOnScreen === this._pendingSectionOnScreen) { - return this._pendingSectionOnScreen; - } - - this._measure(); - for (var i = 0; i < this._sectionSizes.length; i++) { - var sectionSize = this._sectionSizes[i]; - if ((sectionSize.offset + sectionSize.size - sectionSize.borderEnd - sectionSize.paddingEnd) > (this._scrollPosition + this._startSpacer + sectionSize.borderStart + sectionSize.paddingStart)) { - return i; - } - } - return -1; - }, - set: function (value) { - value = Math.max(0, value); - if (this._pendingRefresh) { - this._pendingSectionOnScreen = value; - this._pendingScrollLocation = null; - } else { - this._measure(); - if (value >= 0 && value < this._sectionSizes.length) { - this._scrollToSection(value); - } - } - } - }, - /// - /// Gets or sets the index of first section at least partially in view. Use for animations. - /// - /// - indexOfFirstVisible: { - get: function () { - this._measure(); - for (var i = 0; i < this._sectionSizes.length; i++) { - var sectionSize = this._sectionSizes[i]; - if ((sectionSize.offset + sectionSize.size - sectionSize.borderEnd - sectionSize.paddingEnd) > this._scrollPosition) { - return i; - } - } - return -1; - } - }, - /// - /// Gets or sets the index of last section at least partially in view. Use for animations. - /// - /// - indexOfLastVisible: { - get: function () { - this._measure(); - for (var i = this._sectionSizes.length - 1; i >= 0; i--) { - var sectionSize = this._sectionSizes[i]; - if ((sectionSize.offset + sectionSize.paddingStart + sectionSize.borderStart) < (this._scrollPosition + this._viewportSize)) { - return i; - } - } - return -1; - } - }, - - /// - /// Raised when the user clicks on an interactive header. - /// - /// - onheaderinvoked: createEvent(eventNames.headerInvoked), - - /// - /// Raised when the loadingState of the Hub changes. - /// - /// - onloadingstatechanged: createEvent(eventNames.loadingStateChanged), - - /// - /// Raised when Hub is about to play entrance, contentTransition, insert, or remove animations. - /// - /// - oncontentanimating: createEvent(eventNames.contentAnimating), - - _refresh: function hub_refresh() { - if (this._pendingRefresh) { - return; - } - - this._loadId++; - this._setState(Hub.LoadingState.loading); - // This is to coalesce property setting operations such as sections and scrollPosition. - this._pendingRefresh = true; - - Scheduler.schedule(this._refreshImpl.bind(this), Scheduler.Priority.high); - }, - _refreshImpl: function hub_refreshImpl() { - if (this._disposed) { - return; - } - - var fadeOutAnimation = Promise.wrap(); - if (this._pendingSections) { - this._animateEntrance = true; - this._fireEntrance = !this._visible; - if (!this._fireEntrance) { - this._visible = false; - this._viewportElement.style.opacity = 0; - - if (_TransitionAnimation.isAnimationEnabled()) { - var animateTransition = this._fireEvent(Hub._EventName.contentAnimating, { - type: Hub.AnimationType.contentTransition - }); - - if (animateTransition) { - this._viewportElement.style["-ms-overflow-style"] = "none"; - fadeOutAnimation = Animations.fadeOut(this._viewportElement).then(function () { - this._viewportElement.style["-ms-overflow-style"] = ""; - }.bind(this)); - } - this._animateEntrance = animateTransition; - } - } - } - - fadeOutAnimation.done(this._applyProperties.bind(this)); - }, - _applyProperties: function hub_applyProperties() { - if (this._disposed) { - return; - } - - this._pendingRefresh = false; - - var needsToLoadSections = false; - if (this._pendingSections) { - needsToLoadSections = true; - this._updateEvents(this._sections, this._pendingSections); - this._sections = this._pendingSections; - this._pendingSections = null; - // Remove any declaratively specified hub sections before attachSections. - while (this.element.firstElementChild !== this._viewportElement) { - var toRemove = this.element.firstElementChild; - toRemove.parentNode.removeChild(toRemove); - } - _ElementUtilities.empty(this._surfaceElement); - } - - if (this._pendingHeaderTemplate) { - this._headerTemplate = this._pendingHeaderTemplate; - this._pendingHeaderTemplate = null; - } - - this._assignHeaderTemplate(); - - if (needsToLoadSections) { - this._attachSections(); - } - - // Scroll after headers are rendered and sections are attached so the scroll thumb is correct. - if (+this._pendingSectionOnScreen === this._pendingSectionOnScreen) { - // If there are both pending section on screen and scroll location use section on screen. - this.sectionOnScreen = this._pendingSectionOnScreen; - } else if (+this._pendingScrollLocation === this._pendingScrollLocation) { - this.scrollPosition = this._pendingScrollLocation; - } else { - // Sections reset without sectionOnScreen or scrollPosition APIs. - this.scrollPosition = 0; - } - - this._pendingSectionOnScreen = null; - this._pendingScrollLocation = null; - - // Using current (or new) scroll location load the sections - this._setState(Hub.LoadingState.loading); - this._loadSections(); - }, - _handleSectionChanged: function hub_handleSectionChanged(ev) { - // Change is triggered by binding list setAt() API. - if (this._pendingSections) { - return; - } - - var newSection = ev.detail.newValue; - var oldSection = ev.detail.oldValue; - newSection._setHeaderTemplate(this.headerTemplate); - if (newSection.element !== oldSection.element) { - if (newSection.element.parentNode === this._surfaceElement) { - throw new _ErrorFromName("WinJS.UI.Hub.DuplicateSection", strings.duplicateSection); - } - - this._surfaceElement.insertBefore(newSection.element, oldSection.element); - this._surfaceElement.removeChild(oldSection.element); - this._measured = false; - - this._setState(Hub.LoadingState.loading); - this._loadSections(); - } - }, - _handleSectionInserted: function hub_handleSectionInserted(ev) { - // Insert is triggered by binding list insert APIs such as splice(), push(), and unshift(). - if (this._pendingSections) { - return; - } - - var index = ev.detail.index; - var section = ev.detail.value; - - if (section._animation) { - section._animation.cancel(); - } - - var animation; - var result = this._fireEvent(Hub._EventName.contentAnimating, { - type: Hub.AnimationType.insert, - index: index, - section: section - }); - - if (result) { - - var affectedElements = []; - - for (var i = index + 1; i < this.sections.length; i++) { - affectedElements.push(this.sections.getAt(i).element); - } - - animation = new Animations._createUpdateListAnimation([section.element], [], affectedElements); - } - - if (section.element.parentNode === this._surfaceElement) { - throw new _ErrorFromName("WinJS.UI.Hub.DuplicateSection", strings.duplicateSection); - } - - section._setHeaderTemplate(this.headerTemplate); - if (index < this.sections.length - 1) { - this._surfaceElement.insertBefore(section.element, this.sections.getAt(index + 1).element); - } else { - this._surfaceElement.appendChild(section.element); - } - this._measured = false; - - if (animation) { - var insertAnimation = animation.execute(); - this.runningAnimations = Promise.join([this.runningAnimations, insertAnimation]); - } - - this._setState(Hub.LoadingState.loading); - this._loadSections(); - }, - _handleSectionMoved: function hub_handleSectionMoved(ev) { - // Move is triggered by binding list move() API. - if (this._pendingSections) { - return; - } - - var newIndex = ev.detail.newIndex; - var section = ev.detail.value; - - if (newIndex < this.sections.length - 1) { - this._surfaceElement.insertBefore(section.element, this.sections.getAt(newIndex + 1).element); - } else { - this._surfaceElement.appendChild(section.element); - } - this._measured = false; - - this._setState(Hub.LoadingState.loading); - this._loadSections(); - }, - _handleSectionRemoved: function hub_handleSectionRemoved(ev) { - // Removed is triggered by binding list removal APIs such as splice(), pop(), and shift(). - if (this._pendingSections) { - return; - } - - var section = ev.detail.value; - var index = ev.detail.index; - - var animationPromise = Promise.wrap(); - var result = this._fireEvent(Hub._EventName.contentAnimating, { - type: Hub.AnimationType.remove, - index: index, - section: section - }); - - if (result) { - var affectedElements = []; - - for (var i = index; i < this.sections.length; i++) { - affectedElements.push(this.sections.getAt(i).element); - } - - var animation = new Animations._createUpdateListAnimation([], [section.element], affectedElements); - - this._measure(); - var offsetTop = section.element.offsetTop; - var offsetLeft = section.element.offsetLeft; - section.element.style.position = "absolute"; - section.element.style.top = offsetTop; - section.element.style.left = offsetLeft; - section.element.style.opacity = 0; - this._measured = false; - - animationPromise = animation.execute().then(function () { - section.element.style.position = ""; - section.element.style.top = ""; - section.element.style.left = ""; - section.element.style.opacity = 1; - }.bind(this)); - } - - animationPromise.done(function () { - if (!this._disposed) { - this._surfaceElement.removeChild(section.element); - this._measured = false; - } - }.bind(this)); - - // Store animation promise in case it is inserted before remove animation finishes. - section._animation = animationPromise; - this.runningAnimations = Promise.join([this.runningAnimations, animationPromise]); - - this._setState(Hub.LoadingState.loading); - this._loadSections(); - }, - _handleSectionReload: function hub_handleSectionReload() { - // Reload is triggered by large operations on the binding list such as reverse(). This causes - // _pendingSections to be true which ignores future insert/remove/modified/moved events until the new - // sections list is applied. - this.sections = this.sections; - }, - _updateEvents: function hub_updateEvents(oldSections, newSections) { - if (oldSections) { - oldSections.removeEventListener("itemchanged", this._handleSectionChangedBind); - oldSections.removeEventListener("iteminserted", this._handleSectionInsertedBind); - oldSections.removeEventListener("itemmoved", this._handleSectionMovedBind); - oldSections.removeEventListener("itemremoved", this._handleSectionRemovedBind); - oldSections.removeEventListener("reload", this._handleSectionReloadBind); - } - - if (newSections) { - newSections.addEventListener("itemchanged", this._handleSectionChangedBind); - newSections.addEventListener("iteminserted", this._handleSectionInsertedBind); - newSections.addEventListener("itemmoved", this._handleSectionMovedBind); - newSections.addEventListener("itemremoved", this._handleSectionRemovedBind); - newSections.addEventListener("reload", this._handleSectionReloadBind); - } - }, - _attachSections: function hub_attachSections() { - this._measured = false; - for (var i = 0; i < this.sections.length; i++) { - var section = this._sections.getAt(i); - if (section._animation) { - section._animation.cancel(); - } - if (section.element.parentNode === this._surfaceElement) { - throw new _ErrorFromName("WinJS.UI.Hub.DuplicateSection", strings.duplicateSection); - } - this._surfaceElement.appendChild(section.element); - } - }, - _assignHeaderTemplate: function hub_assignHeaderTemplate() { - this._measured = false; - for (var i = 0; i < this.sections.length; i++) { - var section = this._sections.getAt(i); - section._setHeaderTemplate(this.headerTemplate); - } - }, - _loadSection: function hub_loadSection(index) { - var section = this._sections.getAt(index); - return section._process().then(function resetVisibility() { - var style = section.contentElement.style; - if (style.visibility !== "") { - style.visibility = ""; - } - }); - }, - _loadSections: function hub_loadSections() { - // Used to know if another load has interrupted this one. - this._loadId++; - var loadId = this._loadId; - var that = this; - var onScreenItemsAnimatedPromise = Promise.wrap(); - var sectionIndicesToLoad = []; - var allSectionsLoadedPromise = Promise.wrap(); - - function loadNextSectionAfterPromise(promise) { - promise.then(function () { - Scheduler.schedule(loadNextSection, Scheduler.Priority.idle); - }); - } - - function loadNextSection() { - if (loadId === that._loadId && !that._disposed) { - if (sectionIndicesToLoad.length) { - var index = sectionIndicesToLoad.shift(); - var loadedPromise = that._loadSection(index); - loadNextSectionAfterPromise(loadedPromise); - } else { - allSectionsLoadedSignal.complete(); - } - } - } - - if (!this._showProgressPromise) { - this._showProgressPromise = Promise.timeout(progressDelay).then(function () { - if (this._disposed) { - return; - } - - if (!this._progressBar) { - this._progressBar = _Global.document.createElement("progress"); - _ElementUtilities.addClass(this._progressBar, Hub._ClassName.hubProgress); - this._progressBar.max = 100; - } - if (!this._progressBar.parentNode) { - this.element.insertBefore(this._progressBar, this._viewportElement); - } - this._showProgressPromise = null; - }.bind(this), function () { - this._showProgressPromise = null; - }.bind(this)); - } - - if (this.sections.length) { - var allSectionsLoadedSignal = new _Signal(); - allSectionsLoadedPromise = allSectionsLoadedSignal.promise; - // Synchronously load the sections on screen. - var synchronousProcessPromises = []; - var start = Math.max(0, this.indexOfFirstVisible); - var end = Math.max(0, this.indexOfLastVisible); - for (var i = start; i <= end; i++) { - synchronousProcessPromises.push(this._loadSection(i)); - } - - // Determine the order to load the rest of the sections. - start--; - end++; - while (start >= 0 || end < this.sections.length) { - if (end < this.sections.length) { - sectionIndicesToLoad.push(end); - end++; - } - if (start >= 0) { - sectionIndicesToLoad.push(start); - start--; - } - } - - var onScreenSectionsLoadedPromise = Promise.join(synchronousProcessPromises); - - // In case there are overlapping load calls - onScreenSectionsLoadedPromise.done(function () { - if (loadId === this._loadId && !that._disposed) { - if (this._showProgressPromise) { - this._showProgressPromise.cancel(); - } - - if (this._progressBar && this._progressBar.parentNode) { - this._progressBar.parentNode.removeChild(this._progressBar); - } - - Scheduler.schedule(function Hub_entranceAnimation() { - if (loadId === this._loadId && !that._disposed) { - if (!this._visible) { - this._visible = true; - this._viewportElement.style.opacity = 1; - - if (this._animateEntrance && _TransitionAnimation.isAnimationEnabled()) { - var eventDetail = { - type: Hub.AnimationType.entrance - }; - - if (!this._fireEntrance || this._fireEvent(Hub._EventName.contentAnimating, eventDetail)) { - this._viewportElement.style["-ms-overflow-style"] = "none"; - onScreenItemsAnimatedPromise = Animations.enterContent(this._viewportElement).then(function () { - this._viewportElement.style["-ms-overflow-style"] = ""; - }.bind(this)); - } - } - if (this._element === _Global.document.activeElement) { - this._moveFocusIn(this.sectionOnScreen); - } - } - } - }, Scheduler.Priority.high, this, "WinJS.UI.Hub.entranceAnimation"); - } - }.bind(this)); - - loadNextSectionAfterPromise(onScreenSectionsLoadedPromise); - } else { - if (this._showProgressPromise) { - this._showProgressPromise.cancel(); - } - - if (this._progressBar && this._progressBar.parentNode) { - this._progressBar.parentNode.removeChild(this._progressBar); - } - } - - Promise.join([this.runningAnimations, onScreenItemsAnimatedPromise, allSectionsLoadedPromise]).done(function () { - if (loadId === this._loadId && !that._disposed) { - this.runningAnimations = Promise.wrap(); - if (this._measured && this._scrollLength !== this._viewportElement[this._names.scrollSize]) { - // A section changed size during processing. Invalidate the Hub's measurements so that its - // API's work correctly within the loadingState=complete handler. - this._measured = false; - } - this._setState(Hub.LoadingState.complete); - Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); - } - }.bind(this)); - }, - /// - loadingState: { - get: function () { - return this._loadingState; - } - }, - _setState: function Hub_setState(state) { - if (state !== this._loadingState) { - this._writeProfilerMark("loadingStateChanged:" + state + ",info"); - this._loadingState = state; - var eventObject = _Global.document.createEvent("CustomEvent"); - eventObject.initCustomEvent(Hub._EventName.loadingStateChanged, true, false, { loadingState: state }); - this._element.dispatchEvent(eventObject); - } - }, - _parse: function hub_parse() { - var hubSections = []; - var hubSectionEl = this.element.firstElementChild; - - while (hubSectionEl !== this._viewportElement) { - ControlProcessor.processAll(hubSectionEl); - - var hubSectionContent = hubSectionEl.winControl; - if (hubSectionContent) { - hubSections.push(hubSectionContent); - } else { - throw new _ErrorFromName("WinJS.UI.Hub.InvalidContent", strings.invalidContent); - } - - var nextSectionEl = hubSectionEl.nextElementSibling; - hubSectionEl = nextSectionEl; - } - - this.sections = new BindingList.List(hubSections); - }, - _fireEvent: function hub_fireEvent(type, detail) { - // Returns true if ev.preventDefault() was not called - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(type, true, true, detail); - return this.element.dispatchEvent(event); - }, - - _findHeaderTabStop: function hub_findHeaderTabStop(element) { - if (element.parentNode) { - if (_ElementUtilities._matchesSelector(element, ".win-hub-section-header-tabstop, .win-hub-section-header-tabstop *")) { - while (!_ElementUtilities.hasClass(element, "win-hub-section-header-tabstop")) { - element = element.parentElement; - } - return element; - } - } - return null; - }, - _isInteractive: function hub_isInteractive(element) { - // Helper method to skip keyboarding and clicks - - while (element && element !== _Global.document.body) { - if (element.classList.contains("win-interactive")) { - return true; - } - element = element.parentElement; - } - return false; - }, - _clickHandler: function hub_clickHandler(ev) { - var headerTabStopElement = this._findHeaderTabStop(ev.target); - if (headerTabStopElement && !this._isInteractive(ev.target)) { - var section = headerTabStopElement.parentElement.parentElement.winControl; - if (!section.isHeaderStatic) { - var sectionIndex = this.sections.indexOf(section); - this._fireEvent(Hub._EventName.headerInvoked, { - index: sectionIndex, - section: section - }); - } - } - }, - _resizeHandler: function hub_resizeHandler() { - // Viewport needs to be measured - this._measured = false; - Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); - }, - _contentResizeHandler: function hub_contentResizeHandler() { - // Sections and scroll length need to be measured - this._measured = false; - Scheduler.schedule(this._updateSnapList.bind(this), Scheduler.Priority.idle); - }, - _scrollHandler: function hub_scrollHandler() { - // Scroll location needs to be retrieved - this._measured = false; - - if (this._pendingSections) { - return; - } - - // Scroll events caused by users overwrite pending API modifications to scrollposition. - this._pendingScrollLocation = null; - this._pendingSectionOnScreen = null; - - if (!this._pendingScrollHandler) { - this._pendingScrollHandler = _BaseUtils._requestAnimationFrame(function () { - this._pendingScrollHandler = null; - - if (this._pendingSections) { - return; - } - - if (this.loadingState !== Hub.LoadingState.complete) { - this._loadSections(); - } - }.bind(this)); - } - }, - _measure: function hub_measure() { - // Any time a size changes (section growing, window resizing, etc) cachedSizes should be set to false - // and any time the variables need to be read again we should measure the variables. To avoid a lot of - // seperate layouts we measure the variables in a single batch. - if (!this._measured || this._scrollLength === 0) { - this._writeProfilerMark("measure,StartTM"); - this._measured = true; - - this._rtl = _Global.getComputedStyle(this._element, null).direction === "rtl"; - - if (this.orientation === _UI.Orientation.vertical) { - this._names = verticalNames; - } else { - if (this._rtl) { - this._names = rtlHorizontalNames; - } else { - this._names = ltrHorizontalNames; - } - } - - this._viewportSize = this._viewportElement[this._names.offsetSize]; - this._viewportOppositeSize = this._viewportElement[this._names.oppositeOffsetSize]; - this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportElement)[this._names.scrollPos]; - this._scrollLength = this._viewportElement[this._names.scrollSize]; - - var surfaceElementComputedStyle = _Global.getComputedStyle(this._surfaceElement); - this._startSpacer = parseFloat(surfaceElementComputedStyle[this._names.marginStart]) + parseFloat(surfaceElementComputedStyle[this._names.borderStart]) + parseFloat(surfaceElementComputedStyle[this._names.paddingStart]); - this._endSpacer = parseFloat(surfaceElementComputedStyle[this._names.marginEnd]) + parseFloat(surfaceElementComputedStyle[this._names.borderEnd]) + parseFloat(surfaceElementComputedStyle[this._names.paddingEnd]); - - this._sectionSizes = []; - for (var i = 0; i < this.sections.length; i++) { - var section = this.sections.getAt(i); - var computedSectionStyle = _Global.getComputedStyle(section.element); - this._sectionSizes[i] = { - offset: section.element[this._names.offsetPos], - // Reminder: offsetWidth doesn't include margins and also rounds. - size: section.element[this._names.offsetSize], - marginStart: parseFloat(computedSectionStyle[this._names.marginStart]), - marginEnd: parseFloat(computedSectionStyle[this._names.marginEnd]), - borderStart: parseFloat(computedSectionStyle[this._names.borderStart]), - borderEnd: parseFloat(computedSectionStyle[this._names.borderEnd]), - paddingStart: parseFloat(computedSectionStyle[this._names.paddingStart]), - paddingEnd: parseFloat(computedSectionStyle[this._names.paddingEnd]) - }; - - if (this._rtl && this.orientation === _UI.Orientation.horizontal) { - this._sectionSizes[i].offset = this._viewportSize - (this._sectionSizes[i].offset + this._sectionSizes[i].size); - } - } - - this._writeProfilerMark("measure,StopTM"); - } - }, - _updateSnapList: function hub_updateSnapList() { - this._writeProfilerMark("updateSnapList,StartTM"); - this._measure(); - - var snapList = "snapList("; - for (var i = 0; i < this._sectionSizes.length; i++) { - if (i > 0) { - snapList += ","; - } - var sectionSize = this._sectionSizes[i]; - snapList += (sectionSize.offset - sectionSize.marginStart - this._startSpacer) + "px"; - } - snapList += ")"; - - var snapListY = ""; - var snapListX = ""; - if (this.orientation === _UI.Orientation.vertical) { - snapListY = snapList; - } else { - snapListX = snapList; - } - - if (this._lastSnapPointY !== snapListY) { - this._lastSnapPointY = snapListY; - this._viewportElement.style['-ms-scroll-snap-points-y'] = snapListY; - } - - if (this._lastSnapPointX !== snapListX) { - this._lastSnapPointX = snapListX; - this._viewportElement.style['-ms-scroll-snap-points-x'] = snapListX; - } - - this._writeProfilerMark("updateSnapList,StopTM"); - }, - _scrollToSection: function Hub_scrollToSection(index, withAnimation) { - this._measure(); - var sectionSize = this._sectionSizes[index]; - var scrollPositionToShowStartMargin = Math.min(this._scrollLength - this._viewportSize, sectionSize.offset - sectionSize.marginStart - this._startSpacer); - - this._scrollTo(scrollPositionToShowStartMargin, withAnimation); - }, - _ensureVisible: function hub_ensureVisible(index, withAnimation) { - this._measure(); - var targetScrollPos = this._ensureVisibleMath(index, this._scrollPosition); - this._scrollTo(targetScrollPos, withAnimation); - }, - _ensureVisibleMath: function hub_ensureVisibleMath(index, targetScrollPos) { - this._measure(); - var sectionSize = this._sectionSizes[index]; - - var scrollPositionToShowStartMargin = Math.min(this._scrollLength - this._viewportSize, sectionSize.offset - sectionSize.marginStart - this._startSpacer); - var scrollPositionToShowEndMargin = Math.max(0, sectionSize.offset + sectionSize.size + sectionSize.marginEnd + this._endSpacer - this._viewportSize + 1); - if (targetScrollPos > scrollPositionToShowStartMargin) { - targetScrollPos = scrollPositionToShowStartMargin; - } else if (targetScrollPos < scrollPositionToShowEndMargin) { - targetScrollPos = Math.min(scrollPositionToShowStartMargin, scrollPositionToShowEndMargin); - } - - return targetScrollPos; - }, - _scrollTo: function hub_scrollTo(scrollPos, withAnimation) { - this._scrollPosition = scrollPos; - if (withAnimation) { - if (this.orientation === _UI.Orientation.vertical) { - _ElementUtilities._zoomTo(this._viewportElement, { contentX: 0, contentY: this._scrollPosition, viewportX: 0, viewportY: 0 }); - } else { - _ElementUtilities._zoomTo(this._viewportElement, { contentX: this._scrollPosition, contentY: 0, viewportX: 0, viewportY: 0 }); - } - } else { - var newScrollPos = {}; - newScrollPos[this._names.scrollPos] = this._scrollPosition; - _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); - } - }, - _windowKeyDownHandler: function hub_windowKeyDownHandler(ev) { - // Include tab and shift tab. Note: Alt Key + Tab and Windows Key + Tab do not fire keydown with ev.key === "Tab". - if (ev.keyCode === Key.tab) { - this._tabSeenLast = true; - - var that = this; - _BaseUtils._yieldForEvents(function () { - that._tabSeenLast = false; - }); - } - }, - _focusin: function hub_focusin(ev) { - // On focus we call ensureVisible to handle the tab or shift/tab to header. However if the - // focus was caused by a pointer down event we skip the focus. - if (this._tabSeenLast) { - var headerTabStopElement = this._findHeaderTabStop(ev.target); - if (headerTabStopElement && !this._isInteractive(ev.target)) { - var sectionIndex = this.sections.indexOf(headerTabStopElement.parentElement.parentElement.winControl); - if (sectionIndex > -1) { - this._ensureVisible(sectionIndex, true); - } - } - } - - // Always remember the focused section for SemanticZoom. - var sectionElement = ev.target; - while (sectionElement && !_ElementUtilities.hasClass(sectionElement, _Section.HubSection._ClassName.hubSection)) { - sectionElement = sectionElement.parentElement; - } - if (sectionElement) { - var sectionIndex = this.sections.indexOf(sectionElement.winControl); - if (sectionIndex > -1) { - this._currentIndexForSezo = sectionIndex; - } - } - - if (ev.target === this.element) { - var indexToFocus; - if (+this._sectionToFocus === this._sectionToFocus && this._sectionToFocus >= 0 && this._sectionToFocus < this.sections.length) { - indexToFocus = this._sectionToFocus; - this._sectionToFocus = null; - } else { - indexToFocus = this.sectionOnScreen; - } - - this._moveFocusIn(indexToFocus); - } - }, - _moveFocusIn: function hub_moveFocusIn(indexToFocus) { - if (indexToFocus >= 0) { - for (var i = indexToFocus; i < this.sections.length; i++) { - var section = this.sections.getAt(i); - - var focusAttempt = _ElementUtilities._trySetActive(section._headerTabStopElement, this._viewportElement); - - if (focusAttempt) { - return; - } - - if (_ElementUtilities._setActiveFirstFocusableElement(section.contentElement, this._viewportElement)) { - return; - } - } - - for (var i = indexToFocus - 1; i >= 0; i--) { - var section = this.sections.getAt(i); - - if (_ElementUtilities._setActiveFirstFocusableElement(section.contentElement, this._viewportElement)) { - return; - } - - var focusAttempt = _ElementUtilities._trySetActive(section._headerTabStopElement, this._viewportElement); - - if (focusAttempt) { - return; - } - } - } - }, - _keyDownHandler: function hub_keyDownHandler(ev) { - if (this._isInteractive(ev.target) || _ElementUtilities._hasCursorKeysBehaviors(ev.target)) { - return; - } - - var leftKey = this._rtl ? Key.rightArrow : Key.leftArrow; - var rightKey = this._rtl ? Key.leftArrow : Key.rightArrow; - - if (ev.keyCode === Key.upArrow || ev.keyCode === Key.downArrow || ev.keyCode === Key.leftArrow || ev.keyCode === Key.rightArrow || ev.keyCode === Key.pageUp || ev.keyCode === Key.pageDown) { - var headerTabStopElement = this._findHeaderTabStop(ev.target); - if (headerTabStopElement) { - var currentSection = this.sections.indexOf(headerTabStopElement.parentElement.parentElement.winControl); - var targetSectionIndex; - var useEnsureVisible = false; - // Page up/down go to the next/previous header and line it up with the app header. Up/Right/Down/Left - // move focus to the next/previous header and move it on screen (app header distance from either edge). - if (ev.keyCode === Key.pageDown || - (this.orientation === _UI.Orientation.horizontal && ev.keyCode === rightKey) || - (this.orientation === _UI.Orientation.vertical && ev.keyCode === Key.downArrow)) { - // Do not include hidden headers. - for (var i = currentSection + 1; i < this.sections.length; i++) { - if (this._tryFocus(i)) { - targetSectionIndex = i; - break; - } - } - } else if (ev.keyCode === Key.pageUp || - (this.orientation === _UI.Orientation.horizontal && ev.keyCode === leftKey) || - (this.orientation === _UI.Orientation.vertical && ev.keyCode === Key.upArrow)) { - // Do not include hidden headers. - for (var i = currentSection - 1; i >= 0; i--) { - if (this._tryFocus(i)) { - targetSectionIndex = i; - break; - } - } - } - if (ev.keyCode === Key.upArrow || ev.keyCode === Key.downArrow || ev.keyCode === Key.leftArrow || ev.keyCode === Key.rightArrow) { - useEnsureVisible = true; - } - - if (+targetSectionIndex === targetSectionIndex) { - if (useEnsureVisible) { - this._ensureVisible(targetSectionIndex, true); - } else { - this._scrollToSection(targetSectionIndex, true); - } - ev.preventDefault(); - } - } - } else if (ev.keyCode === Key.home || ev.keyCode === Key.end) { - // Home/End scroll to start/end and leave focus where it is. - this._measure(); - var maxScrollPos = Math.max(0, this._scrollLength - this._viewportSize); - this._scrollTo(ev.keyCode === Key.home ? 0 : maxScrollPos, true); - ev.preventDefault(); - } - }, - _tryFocus: function hub_tryFocus(index) { - var targetSection = this.sections.getAt(index); - - _ElementUtilities._setActive(targetSection._headerTabStopElement, this._viewportElement); - - return _Global.document.activeElement === targetSection._headerTabStopElement; - }, - /// - /// Gets a ZoomableView. This API supports the SemanticZoom infrastructure - /// and is not intended to be used directly from your code. - /// - /// - zoomableView: { - get: function zoomableView_get() { - if (!this._zoomableView) { - this._zoomableView = new ZoomableView(this); - } - - return this._zoomableView; - } - }, - _getPanAxis: function hub_getPanAxis() { - return this.orientation === _UI.Orientation.horizontal ? "horizontal" : "vertical"; - }, - _configureForZoom: function hub_configureForZoom() { - // Nothing to configure. - }, - _setCurrentItem: function hub_setCurrentItem(x, y) { - var offset; - if (this.orientation === _UI.Orientation.horizontal) { - offset = x; - } else { - offset = y; - } - - this._measure(); - offset = offset + this._scrollPosition; - this._currentIndexForSezo = this._sectionSizes.length - 1; - for (var i = 1; i < this._sectionSizes.length; i++) { - var sectionSize = this._sectionSizes[i]; - if (sectionSize.offset - sectionSize.marginStart > offset) { - this._currentIndexForSezo = i - 1; - break; - } - } - }, - _getCurrentItem: function hub_getCurrentItem() { - var itemPosition; - if (this._sectionSizes.length > 0) { - this._measure(); - var index = Math.max(0, Math.min(this._currentIndexForSezo, this._sectionSizes.length)); - var sectionSize = this._sectionSizes[index]; - if (this.orientation === _UI.Orientation.horizontal) { - itemPosition = { - left: Math.max(0, sectionSize.offset - sectionSize.marginStart - this._scrollPosition), - top: 0, - width: sectionSize.size, - height: this._viewportOppositeSize - }; - } else { - itemPosition = { - left: 0, - top: Math.max(0, sectionSize.offset - sectionSize.marginStart - this._scrollPosition), - width: this._viewportOppositeSize, - height: sectionSize.size, - }; - } - - var section = this.sections.getAt(index); - // BUGBUG: 53301 ListView and Hub should document what they expect to be returned from the - // getCurrentItem so that positionItem apis line up. ListView zoomed out expects an object with - // groupIndexHint, groupKey, or groupDescription. Hub expects an object with index. - return Promise.wrap({ item: { data: section, index: index, groupIndexHint: index }, position: itemPosition }); - } - }, - _beginZoom: function hub_beginZoom() { - // Hide scroll thumb. - this._viewportElement.style["-ms-overflow-style"] = "none"; - }, - _positionItem: function hub_positionItem(item, position) { - if (item.index >= 0 && item.index < this._sectionSizes.length) { - this._measure(); - var sectionSize = this._sectionSizes[item.index]; - - var offsetFromViewport; - if (this.orientation === _UI.Orientation.horizontal) { - offsetFromViewport = position.left; - } else { - offsetFromViewport = position.top; - } - - this._sectionToFocus = item.index; - - var targetScrollPosition = sectionSize.offset - offsetFromViewport; - // clamp section: - var targetScrollPosition = this._ensureVisibleMath(item.index, targetScrollPosition); - - this._scrollPosition = targetScrollPosition; - var newScrollPos = {}; - newScrollPos[this._names.scrollPos] = this._scrollPosition; - _ElementUtilities.setScrollPosition(this._viewportElement, newScrollPos); - } - }, - _endZoom: function hub_endZoom() { - // Show scroll thumb. - this._viewportElement.style["-ms-overflow-style"] = ""; - }, - _writeProfilerMark: function hub_writeProfilerMark(text) { - var message = "WinJS.UI.Hub:" + this._id + ":" + text; - _WriteProfilerMark(message); - _Log.log && _Log.log(message, null, "hubprofiler"); - }, - dispose: function hub_dispose() { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - - _Global.removeEventListener('keydown', this._windowKeyDownHandlerBound); - _ElementUtilities._resizeNotifier.unsubscribe(this.element, this._resizeHandlerBound); - - this._updateEvents(this._sections); - - for (var i = 0; i < this.sections.length; i++) { - this.sections.getAt(i).dispose(); - } - } - }, { - /// - /// Specifies whether the Hub animation is an entrance animation or a transition animation. - /// - /// - AnimationType: { - /// - /// The animation plays when the Hub is first displayed. - /// - /// - entrance: "entrance", - /// - /// The animation plays when the Hub is changing its content. - /// - /// - contentTransition: "contentTransition", - /// - /// The animation plays when a section is inserted into the Hub. - /// - /// - insert: "insert", - /// - /// The animation plays when a section is removed into the Hub. - /// - /// - remove: "remove", - }, - /// - /// Gets the current loading state of the Hub. - /// - /// - LoadingState: { - /// - /// The Hub is loading sections. - /// - /// - loading: "loading", - /// - /// All sections are loaded and animations are complete. - /// - /// - complete: "complete" - }, - // Names of classes used by the Hub. - _ClassName: { - hub: "win-hub", - hubSurface: "win-hub-surface", - hubProgress: "win-hub-progress", - hubViewport: "win-hub-viewport", - hubVertical: "win-hub-vertical", - hubHorizontal: "win-hub-horizontal", - }, - // Names of events fired by the Hub. - _EventName: { - contentAnimating: eventNames.contentAnimating, - headerInvoked: eventNames.headerInvoked, - loadingStateChanged: eventNames.loadingStateChanged - }, - }); - - _Base.Class.mix(Hub, _Control.DOMEventMixin); - - var ZoomableView = _Base.Class.define(function ZoomableView_ctor(hub) { - this._hub = hub; - }, { - getPanAxis: function () { - return this._hub._getPanAxis(); - }, - configureForZoom: function (isZoomedOut, isCurrentView, triggerZoom, prefetchedPages) { - this._hub._configureForZoom(isZoomedOut, isCurrentView, triggerZoom, prefetchedPages); - }, - setCurrentItem: function (x, y) { - this._hub._setCurrentItem(x, y); - }, - getCurrentItem: function () { - return this._hub._getCurrentItem(); - }, - beginZoom: function () { - this._hub._beginZoom(); - }, - positionItem: function (item, position) { - return this._hub._positionItem(item, position); - }, - endZoom: function (isCurrentView) { - this._hub._endZoom(isCurrentView); - } - }); - - var strings = { - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get duplicateSection() { return "Hub duplicate sections: Each HubSection must be unique"; }, - get invalidContent() { return "Invalid content: Hub content must be made up of HubSections."; }, - get hubViewportAriaLabel() { return _Resources._getWinJSString("ui/hubViewportAriaLabel").value; } - }; - - return Hub; - }) - }); - -}); - -define('require-style!less/styles-lightdismissservice',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -define('WinJS/_LightDismissService',["require", "exports", './Application', './Core/_Base', './Core/_BaseUtils', './Utilities/_ElementUtilities', './Core/_Global', './Utilities/_KeyboardBehavior', './Core/_Log', './Core/_Resources'], function (require, exports, Application, _Base, _BaseUtils, _ElementUtilities, _Global, _KeyboardBehavior, _Log, _Resources) { - require(["require-style!less/styles-lightdismissservice"]); - "use strict"; - var baseZIndex = 1000; - var Strings = { - get closeOverlay() { - return _Resources._getWinJSString("ui/closeOverlay").value; - } - }; - exports._ClassNames = { - _clickEater: "win-clickeater" - }; - var EventNames = { - requestingFocusOnKeyboardInput: "requestingfocusonkeyboardinput" - }; - exports.LightDismissalReasons = { - tap: "tap", - lostFocus: "lostFocus", - escape: "escape", - hardwareBackButton: "hardwareBackButton", - windowResize: "windowResize", - windowBlur: "windowBlur" - }; - // Built-in implementations of ILightDismissable's onShouldLightDismiss. - exports.DismissalPolicies = { - light: function LightDismissalPolicies_light_onShouldLightDismiss(info) { - switch (info.reason) { - case exports.LightDismissalReasons.tap: - case exports.LightDismissalReasons.escape: - if (info.active) { - return true; - } - else { - info.stopPropagation(); - return false; - } - break; - case exports.LightDismissalReasons.hardwareBackButton: - if (info.active) { - info.preventDefault(); // prevent backwards navigation in the app - return true; - } - else { - info.stopPropagation(); - return false; - } - break; - case exports.LightDismissalReasons.lostFocus: - case exports.LightDismissalReasons.windowResize: - case exports.LightDismissalReasons.windowBlur: - return true; - } - }, - modal: function LightDismissalPolicies_modal_onShouldLightDismiss(info) { - // Light dismiss cues should not be seen by dismissables behind the modal - info.stopPropagation(); - switch (info.reason) { - case exports.LightDismissalReasons.tap: - case exports.LightDismissalReasons.lostFocus: - case exports.LightDismissalReasons.windowResize: - case exports.LightDismissalReasons.windowBlur: - return false; - break; - case exports.LightDismissalReasons.escape: - return info.active; - break; - case exports.LightDismissalReasons.hardwareBackButton: - info.preventDefault(); // prevent backwards navigation in the app - return info.active; - break; - } - }, - sticky: function LightDismissalPolicies_sticky_onShouldLightDismiss(info) { - info.stopPropagation(); - return false; - } - }; - var KeyboardInfoType = { - keyDown: "keyDown", - keyUp: "keyUp", - keyPress: "keyPress" - }; - var AbstractDismissableElement = (function () { - function AbstractDismissableElement(args) { - this.element = args.element; - this.element.tabIndex = args.tabIndex; - this.onLightDismiss = args.onLightDismiss; - // Allow the caller to override the default implementations of our ILightDismissable methods. - if (args.onTakeFocus) { - this.onTakeFocus = args.onTakeFocus; - } - if (args.onShouldLightDismiss) { - this.onShouldLightDismiss = args.onShouldLightDismiss; - } - this._ldeOnKeyDownBound = this._ldeOnKeyDown.bind(this); - this._ldeOnKeyUpBound = this._ldeOnKeyUp.bind(this); - this._ldeOnKeyPressBound = this._ldeOnKeyPress.bind(this); - } - AbstractDismissableElement.prototype.restoreFocus = function () { - var activeElement = _Global.document.activeElement; - if (activeElement && this.containsElement(activeElement)) { - this._ldeCurrentFocus = activeElement; - return true; - } - else { - // If the last input type was keyboard, use focus() so a keyboard focus visual is drawn. - // Otherwise, use setActive() so no focus visual is drawn. - var useSetActive = !_KeyboardBehavior._keyboardSeenLast; - return this._ldeCurrentFocus && this.containsElement(this._ldeCurrentFocus) && _ElementUtilities._tryFocusOnAnyElement(this._ldeCurrentFocus, useSetActive); - } - }; - AbstractDismissableElement.prototype._ldeOnKeyDown = function (eventObject) { - this._ldeService.keyDown(this, eventObject); - }; - AbstractDismissableElement.prototype._ldeOnKeyUp = function (eventObject) { - this._ldeService.keyUp(this, eventObject); - }; - AbstractDismissableElement.prototype._ldeOnKeyPress = function (eventObject) { - this._ldeService.keyPress(this, eventObject); - }; - // ILightDismissable - // - AbstractDismissableElement.prototype.setZIndex = function (zIndex) { - this.element.style.zIndex = zIndex; - }; - AbstractDismissableElement.prototype.getZIndexCount = function () { - return 1; - }; - AbstractDismissableElement.prototype.containsElement = function (element) { - return this.element.contains(element); - }; - AbstractDismissableElement.prototype.onTakeFocus = function (useSetActive) { - this.restoreFocus() || _ElementUtilities._focusFirstFocusableElement(this.element, useSetActive) || _ElementUtilities._tryFocusOnAnyElement(this.element, useSetActive); - }; - AbstractDismissableElement.prototype.onFocus = function (element) { - this._ldeCurrentFocus = element; - }; - AbstractDismissableElement.prototype.onShow = function (service) { - this._ldeService = service; - this.element.addEventListener("keydown", this._ldeOnKeyDownBound); - this.element.addEventListener("keyup", this._ldeOnKeyUpBound); - this.element.addEventListener("keypress", this._ldeOnKeyPressBound); - }; - AbstractDismissableElement.prototype.onHide = function () { - this._ldeCurrentFocus = null; - this._ldeService = null; - this.element.removeEventListener("keydown", this._ldeOnKeyDownBound); - this.element.removeEventListener("keyup", this._ldeOnKeyUpBound); - this.element.removeEventListener("keypress", this._ldeOnKeyPressBound); - }; - // Concrete subclasses are expected to implement these. - AbstractDismissableElement.prototype.onKeyInStack = function (info) { - }; - AbstractDismissableElement.prototype.onShouldLightDismiss = function (info) { - return false; - }; - // Consumers of concrete subclasses of AbstractDismissableElement are expected to - // provide these as parameters to the constructor. - AbstractDismissableElement.prototype.onLightDismiss = function (info) { - }; - return AbstractDismissableElement; - })(); - var LightDismissableElement = (function (_super) { - __extends(LightDismissableElement, _super); - function LightDismissableElement() { - _super.apply(this, arguments); - } - LightDismissableElement.prototype.onKeyInStack = function (info) { - }; - LightDismissableElement.prototype.onShouldLightDismiss = function (info) { - return exports.DismissalPolicies.light(info); - }; - return LightDismissableElement; - })(AbstractDismissableElement); - exports.LightDismissableElement = LightDismissableElement; - var ModalElement = (function (_super) { - __extends(ModalElement, _super); - function ModalElement() { - _super.apply(this, arguments); - } - ModalElement.prototype.onKeyInStack = function (info) { - // stopPropagation so that none of the app's other event handlers will see the event. - // Don't preventDefault so that the browser's hotkeys will still work. - info.stopPropagation(); - }; - ModalElement.prototype.onShouldLightDismiss = function (info) { - return exports.DismissalPolicies.modal(info); - }; - return ModalElement; - })(AbstractDismissableElement); - exports.ModalElement = ModalElement; - // An implementation of ILightDismissable that represents the HTML body element. It can never be dismissed. The - // service should instantiate one of these to act as the bottommost light dismissable at all times (it isn't expected - // for anybody else to instantiate one). It takes care of restoring focus when the last dismissable is dismissed. - var LightDismissableBody = (function () { - function LightDismissableBody() { - } - LightDismissableBody.prototype.setZIndex = function (zIndex) { - }; - LightDismissableBody.prototype.getZIndexCount = function () { - return 1; - }; - LightDismissableBody.prototype.containsElement = function (element) { - return _Global.document.body.contains(element); - }; - LightDismissableBody.prototype.onTakeFocus = function (useSetActive) { - this.currentFocus && this.containsElement(this.currentFocus) && _ElementUtilities._tryFocusOnAnyElement(this.currentFocus, useSetActive); - }; - LightDismissableBody.prototype.onFocus = function (element) { - this.currentFocus = element; - }; - LightDismissableBody.prototype.onShow = function (service) { - }; - LightDismissableBody.prototype.onHide = function () { - this.currentFocus = null; - }; - LightDismissableBody.prototype.onKeyInStack = function (info) { - }; - LightDismissableBody.prototype.onShouldLightDismiss = function (info) { - return false; - }; - LightDismissableBody.prototype.onLightDismiss = function (info) { - }; - return LightDismissableBody; - })(); - ; - var LightDismissService = (function () { - function LightDismissService() { - this._debug = false; // Disables dismiss due to window blur. Useful during debugging. - this._clients = []; - this._notifying = false; - this._bodyClient = new LightDismissableBody(); - // State private to _updateDom. No other method should make use of it. - this._updateDom_rendered = { - serviceActive: false - }; - this._clickEaterEl = this._createClickEater(); - this._onBeforeRequestingFocusOnKeyboardInputBound = this._onBeforeRequestingFocusOnKeyboardInput.bind(this); - this._onFocusInBound = this._onFocusIn.bind(this); - this._onKeyDownBound = this._onKeyDown.bind(this); - this._onWindowResizeBound = this._onWindowResize.bind(this); - this._onClickEaterPointerUpBound = this._onClickEaterPointerUp.bind(this); - this._onClickEaterPointerCancelBound = this._onClickEaterPointerCancel.bind(this); - // Register for infrequent events. - Application.addEventListener("backclick", this._onBackClick.bind(this)); - // Focus handlers generally use _ElementUtilities._addEventListener with focusout/focusin. This - // uses the browser's blur event directly beacuse _addEventListener doesn't support focusout/focusin - // on window. - _Global.window.addEventListener("blur", this._onWindowBlur.bind(this)); - this.shown(this._bodyClient); - } - // Dismissables should call this as soon as they are ready to be shown. More specifically, they should call this: - // - After they are in the DOM and ready to receive focus (e.g. style.display cannot = "none") - // - Before their entrance animation is played - LightDismissService.prototype.shown = function (client) { - var index = this._clients.indexOf(client); - if (index === -1) { - this._clients.push(client); - client.onShow(this); - this._updateDom(); - } - }; - // Dismissables should call this when they are done being dismissed (i.e. after their exit animation has finished) - LightDismissService.prototype.hidden = function (client) { - var index = this._clients.indexOf(client); - if (index !== -1) { - this._clients.splice(index, 1); - client.setZIndex(""); - client.onHide(); - this._updateDom(); - } - }; - // Dismissables should call this when their state has changed such that it'll affect the behavior of some method - // in its ILightDismissable interface. For example, if the dismissable was altered such that getZIndexCount will - // now return 2 instead of 1, that dismissable should call *updated* so the LightDismissService can find out about - // this change. - LightDismissService.prototype.updated = function (client) { - this._updateDom(); - }; - LightDismissService.prototype.keyDown = function (client, eventObject) { - if (eventObject.keyCode === _ElementUtilities.Key.escape) { - this._escapePressed(eventObject); - } - else { - this._dispatchKeyboardEvent(client, KeyboardInfoType.keyDown, eventObject); - } - }; - LightDismissService.prototype.keyUp = function (client, eventObject) { - this._dispatchKeyboardEvent(client, KeyboardInfoType.keyUp, eventObject); - }; - LightDismissService.prototype.keyPress = function (client, eventObject) { - this._dispatchKeyboardEvent(client, KeyboardInfoType.keyPress, eventObject); - }; - LightDismissService.prototype.isShown = function (client) { - return this._clients.indexOf(client) !== -1; - }; - LightDismissService.prototype.isTopmost = function (client) { - return client === this._clients[this._clients.length - 1]; - }; - // Disables dismiss due to window blur. Useful during debugging. - LightDismissService.prototype._setDebug = function (debug) { - this._debug = debug; - }; - LightDismissService.prototype._updateDom = function (options) { - options = options || {}; - var activeDismissableNeedsFocus = !!options.activeDismissableNeedsFocus; - var rendered = this._updateDom_rendered; - if (this._notifying) { - return; - } - var serviceActive = this._clients.length > 1; - if (serviceActive !== rendered.serviceActive) { - // Unregister/register for events that occur frequently. - if (serviceActive) { - Application.addEventListener("beforerequestingfocusonkeyboardinput", this._onBeforeRequestingFocusOnKeyboardInputBound); - _ElementUtilities._addEventListener(_Global.document.documentElement, "focusin", this._onFocusInBound); - _Global.document.documentElement.addEventListener("keydown", this._onKeyDownBound); - _Global.window.addEventListener("resize", this._onWindowResizeBound); - this._bodyClient.currentFocus = _Global.document.activeElement; - _Global.document.body.appendChild(this._clickEaterEl); - } - else { - Application.removeEventListener("beforerequestingfocusonkeyboardinput", this._onBeforeRequestingFocusOnKeyboardInputBound); - _ElementUtilities._removeEventListener(_Global.document.documentElement, "focusin", this._onFocusInBound); - _Global.document.documentElement.removeEventListener("keydown", this._onKeyDownBound); - _Global.window.removeEventListener("resize", this._onWindowResizeBound); - var parent = this._clickEaterEl.parentNode; - parent && parent.removeChild(this._clickEaterEl); - } - rendered.serviceActive = serviceActive; - } - var zIndexGap = 0; - var lastUsedZIndex = baseZIndex + 1; - this._clients.forEach(function (c, i) { - var currentZIndex = lastUsedZIndex + zIndexGap; - c.setZIndex("" + currentZIndex); - lastUsedZIndex = currentZIndex; - // count + 1 so that there's an unused zIndex between each pair of - // dismissables that can be used by the click eater. - zIndexGap = c.getZIndexCount() + 1; - }); - if (serviceActive) { - this._clickEaterEl.style.zIndex = "" + (lastUsedZIndex - 1); - } - var activeDismissable = this._clients.length > 0 ? this._clients[this._clients.length - 1] : null; - if (this._activeDismissable !== activeDismissable) { - this._activeDismissable = activeDismissable; - activeDismissableNeedsFocus = true; - } - if (activeDismissableNeedsFocus) { - // If the last input type was keyboard, use focus() so a keyboard focus visual is drawn. - // Otherwise, use setActive() so no focus visual is drawn. - var useSetActive = !_KeyboardBehavior._keyboardSeenLast; - this._activeDismissable && this._activeDismissable.onTakeFocus(useSetActive); - } - }; - LightDismissService.prototype._dispatchKeyboardEvent = function (client, keyboardInfoType, eventObject) { - var index = this._clients.indexOf(client); - if (index !== -1) { - var info = { - type: keyboardInfoType, - keyCode: eventObject.keyCode, - propagationStopped: false, - stopPropagation: function () { - this.propagationStopped = true; - eventObject.stopPropagation(); - } - }; - var clients = this._clients.slice(0, index + 1); - for (var i = clients.length - 1; i >= 0 && !info.propagationStopped; i--) { - clients[i].onKeyInStack(info); - } - } - }; - LightDismissService.prototype._dispatchLightDismiss = function (reason, clients, options) { - if (this._notifying) { - _Log.log && _Log.log('_LightDismissService ignored dismiss trigger to avoid re-entrancy: "' + reason + '"', "winjs _LightDismissService", "warning"); - return; - } - clients = clients || this._clients.slice(0); - if (clients.length === 0) { - return; - } - this._notifying = true; - var lightDismissInfo = { - // Which of the LightDismissalReasons caused this event to fire? - reason: reason, - // Is this dismissable currently the active dismissable? - active: false, - _stop: false, - stopPropagation: function () { - this._stop = true; - }, - _doDefault: true, - preventDefault: function () { - this._doDefault = false; - } - }; - for (var i = clients.length - 1; i >= 0 && !lightDismissInfo._stop; i--) { - lightDismissInfo.active = this._activeDismissable === clients[i]; - if (clients[i].onShouldLightDismiss(lightDismissInfo)) { - clients[i].onLightDismiss(lightDismissInfo); - } - } - this._notifying = false; - this._updateDom(options); - return lightDismissInfo._doDefault; - }; - LightDismissService.prototype._onBeforeRequestingFocusOnKeyboardInput = function (eventObject) { - // Suppress the requestingFocusOnKeyboardInput event. - return true; - }; - // - // Light dismiss triggers - // - // Called by tests. - LightDismissService.prototype._clickEaterTapped = function () { - this._dispatchLightDismiss(exports.LightDismissalReasons.tap); - }; - LightDismissService.prototype._onFocusIn = function (eventObject) { - var target = eventObject.target; - for (var i = this._clients.length - 1; i >= 0; i--) { - if (this._clients[i].containsElement(target)) { - break; - } - } - if (i !== -1) { - this._clients[i].onFocus(target); - } - if (i + 1 < this._clients.length) { - this._dispatchLightDismiss(exports.LightDismissalReasons.lostFocus, this._clients.slice(i + 1), { - activeDismissableNeedsFocus: true - }); - } - }; - LightDismissService.prototype._onKeyDown = function (eventObject) { - if (eventObject.keyCode === _ElementUtilities.Key.escape) { - this._escapePressed(eventObject); - } - }; - LightDismissService.prototype._escapePressed = function (eventObject) { - eventObject.preventDefault(); - eventObject.stopPropagation(); - this._dispatchLightDismiss(exports.LightDismissalReasons.escape); - }; - // Called by tests. - LightDismissService.prototype._onBackClick = function (eventObject) { - var doDefault = this._dispatchLightDismiss(exports.LightDismissalReasons.hardwareBackButton); - return !doDefault; // Returns whether or not the event was handled. - }; - LightDismissService.prototype._onWindowResize = function (eventObject) { - this._dispatchLightDismiss(exports.LightDismissalReasons.windowResize); - }; - LightDismissService.prototype._onWindowBlur = function (eventObject) { - if (this._debug) { - return; - } - // Want to trigger a light dismiss on window blur. - // We get blur if we click off the window, including into an iframe within our window. - // Both blurs call this function, but fortunately document.hasFocus is true if either - // the document window or our iframe window has focus. - if (!_Global.document.hasFocus()) { - // The document doesn't have focus, so they clicked off the app, so light dismiss. - this._dispatchLightDismiss(exports.LightDismissalReasons.windowBlur); - } - else { - // We were trying to unfocus the window, but document still has focus, - // so make sure the iframe that took the focus will check for blur next time. - var active = _Global.document.activeElement; - if (active && active.tagName === "IFRAME" && !active["msLightDismissBlur"]) { - // - This will go away when the IFRAME goes away, and we only create one. - // - This only works in IE because other browsers don't fire focus events on iframe elements. - // - Can't use _ElementUtilities._addEventListener's focusout because it doesn't fire when an - // iframe loses focus due to changing windows. - active.addEventListener("blur", this._onWindowBlur.bind(this), false); - active["msLightDismissBlur"] = true; - } - } - }; - LightDismissService.prototype._createClickEater = function () { - var clickEater = _Global.document.createElement("section"); - clickEater.className = exports._ClassNames._clickEater; - _ElementUtilities._addEventListener(clickEater, "pointerdown", this._onClickEaterPointerDown.bind(this), true); - clickEater.addEventListener("click", this._onClickEaterClick.bind(this), true); - // Tell Aria that it's clickable - clickEater.setAttribute("role", "menuitem"); - clickEater.setAttribute("aria-label", Strings.closeOverlay); - // Prevent CED from removing any current selection - clickEater.setAttribute("unselectable", "on"); - return clickEater; - }; - LightDismissService.prototype._onClickEaterPointerDown = function (eventObject) { - eventObject.stopPropagation(); - eventObject.preventDefault(); - this._clickEaterPointerId = eventObject.pointerId; - if (!this._registeredClickEaterCleanUp) { - _ElementUtilities._addEventListener(_Global.window, "pointerup", this._onClickEaterPointerUpBound); - _ElementUtilities._addEventListener(_Global.window, "pointercancel", this._onClickEaterPointerCancelBound); - this._registeredClickEaterCleanUp = true; - } - }; - LightDismissService.prototype._onClickEaterPointerUp = function (eventObject) { - var _this = this; - eventObject.stopPropagation(); - eventObject.preventDefault(); - if (eventObject.pointerId === this._clickEaterPointerId) { - this._resetClickEaterPointerState(); - var element = _Global.document.elementFromPoint(eventObject.clientX, eventObject.clientY); - if (element === this._clickEaterEl) { - this._skipClickEaterClick = true; - _BaseUtils._yieldForEvents(function () { - _this._skipClickEaterClick = false; - }); - this._clickEaterTapped(); - } - } - }; - LightDismissService.prototype._onClickEaterClick = function (eventObject) { - eventObject.stopPropagation(); - eventObject.preventDefault(); - if (!this._skipClickEaterClick) { - // Handle the UIA invoke action on the click eater. this._skipClickEaterClick is false which tells - // us that we received a click event without an associated PointerUp event. This means that the click - // event was triggered thru UIA rather than thru the GUI. - this._clickEaterTapped(); - } - }; - LightDismissService.prototype._onClickEaterPointerCancel = function (eventObject) { - if (eventObject.pointerId === this._clickEaterPointerId) { - this._resetClickEaterPointerState(); - } - }; - LightDismissService.prototype._resetClickEaterPointerState = function () { - if (this._registeredClickEaterCleanUp) { - _ElementUtilities._removeEventListener(_Global.window, "pointerup", this._onClickEaterPointerUpBound); - _ElementUtilities._removeEventListener(_Global.window, "pointercancel", this._onClickEaterPointerCancelBound); - } - this._clickEaterPointerId = null; - this._registeredClickEaterCleanUp = false; - }; - return LightDismissService; - })(); - var service = new LightDismissService(); - exports.shown = service.shown.bind(service); - exports.hidden = service.hidden.bind(service); - exports.updated = service.updated.bind(service); - exports.isShown = service.isShown.bind(service); - exports.isTopmost = service.isTopmost.bind(service); - exports.keyDown = service.keyDown.bind(service); - exports.keyUp = service.keyUp.bind(service); - exports.keyPress = service.keyPress.bind(service); - exports._clickEaterTapped = service._clickEaterTapped.bind(service); - exports._onBackClick = service._onBackClick.bind(service); - exports._setDebug = service._setDebug.bind(service); - _Base.Namespace.define("WinJS.UI._LightDismissService", { - shown: exports.shown, - hidden: exports.hidden, - updated: exports.updated, - isShown: exports.isShown, - isTopmost: exports.isTopmost, - keyDown: exports.keyDown, - keyUp: exports.keyUp, - keyPress: exports.keyPress, - _clickEaterTapped: exports._clickEaterTapped, - _onBackClick: exports._onBackClick, - _setDebug: exports._setDebug, - LightDismissableElement: LightDismissableElement, - DismissalPolicies: exports.DismissalPolicies, - LightDismissalReasons: exports.LightDismissalReasons, - _ClassNames: exports._ClassNames, - _service: service - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/_LegacyAppBar/_Constants',[ - 'exports', - '../../Core/_Base', -], function appBarConstantsInit(exports, _Base) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, null, { - // AppBar class names. - appBarClass: "win-navbar", - firstDivClass: "win-firstdiv", - finalDivClass: "win-finaldiv", - invokeButtonClass: "win-navbar-invokebutton", - ellipsisClass: "win-navbar-ellipsis", - primaryCommandsClass: "win-primarygroup", - secondaryCommandsClass: "win-secondarygroup", - commandLayoutClass: "win-commandlayout", - menuLayoutClass: "win-menulayout", - topClass: "win-top", - bottomClass: "win-bottom", - showingClass : "win-navbar-opening", - shownClass : "win-navbar-opened", - hidingClass : "win-navbar-closing", - hiddenClass: "win-navbar-closed", - compactClass: "win-navbar-compact", - minimalClass: "win-navbar-minimal", - menuContainerClass: "win-navbar-menu", - - // Constants for AppBar placement - appBarPlacementTop: "top", - appBarPlacementBottom: "bottom", - - // Constants for AppBar layouts - appBarLayoutCustom: "custom", - appBarLayoutCommands: "commands", - appBarLayoutMenu: "menu", - - // Constant for AppBar invokebutton width - appBarInvokeButtonWidth: 32, - - // Constants for Commands - typeSeparator: "separator", - typeContent: "content", - typeButton: "button", - typeToggle: "toggle", - typeFlyout: "flyout", - appBarCommandClass: "win-command", - appBarCommandGlobalClass: "win-global", - appBarCommandSelectionClass: "win-selection", - sectionSelection: "selection", /* deprecated, use sectionSecondary */ - sectionGlobal: "global", /* deprecated, use sectionPrimary */ - sectionPrimary: "primary", - sectionSecondary: "secondary", - - // Constants for Menus - menuCommandClass: "win-command", - menuCommandButtonClass: "win-command-button", - menuCommandToggleClass: "win-command-toggle", - menuCommandFlyoutClass: "win-command-flyout", - menuCommandFlyoutActivatedClass: "win-command-flyout-activated", - menuCommandSeparatorClass: "win-command-separator", - _menuCommandInvokedEvent: "_invoked", // Private event - menuClass: "win-menu", - menuContainsToggleCommandClass: "win-menu-containstogglecommand", - menuContainsFlyoutCommandClass: "win-menu-containsflyoutcommand", - menuMouseSpacingClass: "win-menu-mousespacing", - menuTouchSpacingClass: "win-menu-touchspacing", - menuCommandHoverDelay: 400, - - // Other class names - overlayClass: "win-overlay", - flyoutClass: "win-flyout", - flyoutLightClass: "win-ui-light", - settingsFlyoutClass: "win-settingsflyout", - scrollsClass: "win-scrolls", - pinToRightEdge: -1, - pinToBottomEdge: -1, - - // Constants for AppBarCommand full-size widths. - separatorWidth: 34, - buttonWidth: 68, - - narrowClass: "win-narrow", - wideClass: "win-wide", - _visualViewportClass: "win-visualviewport-space", - - // Event names - commandPropertyMutated: "_commandpropertymutated", - commandVisibilityChanged: "commandvisibilitychanged", - }); -}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Utilities/_KeyboardInfo',["require", "exports", '../Core/_BaseCoreUtils', '../Core/_Global', '../Core/_WinRT'], function (require, exports, _BaseCoreUtils, _Global, _WinRT) { - "use strict"; - var _Constants = { - visualViewportClass: "win-visualviewport-space", - scrollTimeout: 150, - }; - // This private module provides accurate metrics for the Visual Viewport and WWA's IHM offsets in Win10 WWA - // where "-ms-device-fixed" CSS positioning is supported. WinJS controls will also use this module for - // positoning themselves relative to the viewport in a web browser outside of WWA. Their preference is still - // to rely on "-ms-device-fixed" positioning, but currently fallback to "fixed" positioning in enviornments where - // "-ms-device-fixed" is not supported. - exports._KeyboardInfo; - // WWA Soft Keyboard offsets - exports._KeyboardInfo = { - // Determine if the keyboard is visible or not. - get _visible() { - try { - return (_WinRT.Windows.UI.ViewManagement.InputPane && _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height > 0); - } - catch (e) { - return false; - } - }, - // See if we have to reserve extra space for the IHM - get _extraOccluded() { - var occluded = 0; - // Controls using -ms-device-fixed positioning only need to reposition themselves to remain visible - // If the IHM has not resized the viewport. - if (!exports._KeyboardInfo._isResized && _WinRT.Windows.UI.ViewManagement.InputPane) { - occluded = _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height; - } - return occluded; - }, - // See if the view has been resized to fit a keyboard - get _isResized() { - // Compare ratios. Very different includes IHM space. - var heightRatio = _Global.document.documentElement.clientHeight / _Global.innerHeight, widthRatio = _Global.document.documentElement.clientWidth / _Global.innerWidth; - // If they're nearly identical, then the view hasn't been resized for the IHM - // Only check one bound because we know the IHM will make it shorter, not skinnier. - return (widthRatio / heightRatio < 0.99); - }, - // Get the bottom of the visible area, relative to the top edge of the visible area. - get _visibleDocBottom() { - return exports._KeyboardInfo._visibleDocTop + exports._KeyboardInfo._visibleDocHeight; - }, - // Get the height of the visible area, e.g. the height of the visual viewport minus any IHM occlusion. - get _visibleDocHeight() { - return exports._KeyboardInfo._visualViewportHeight - exports._KeyboardInfo._extraOccluded; - }, - // Get the top offset of our visible area, aka the top of the visual viewport. - // This is always 0 when elements use -ms-device-fixed positioning. - get _visibleDocTop() { - return 0; - }, - // Get the offset for, and relative to, the bottom edge of the visual viewport plus any IHM occlusion. - get _visibleDocBottomOffset() { - // For -ms-device-fixed positioned elements, the bottom is just 0 when there's no IHM. - // When the IHM appears, the text input that invoked it may be in a position on the page that is occluded by the IHM. - // In that instance, the default browser behavior is to resize the visual viewport and scroll the input back into view. - // However, if the viewport resize is prevented by an IHM event listener, the keyboard will still occlude - // -ms-device-fixed elements, so we adjust the bottom offset of the appbar by the height of the occluded rect of the IHM. - return exports._KeyboardInfo._extraOccluded; - }, - // Get the visual viewport height. window.innerHeight doesn't return floating point values which are present with high DPI. - get _visualViewportHeight() { - var boundingRect = exports._KeyboardInfo._visualViewportSpace; - return boundingRect.height; - }, - // Get the visual viewport width. window.innerWidth doesn't return floating point values which are present with high DPI. - get _visualViewportWidth() { - var boundingRect = exports._KeyboardInfo._visualViewportSpace; - return boundingRect.width; - }, - // The visual viewport space element is hidden given -ms-device-fixed positioning and used to calculate - // the 4 edges of the visual viewport with floating point precision. - get _visualViewportSpace() { - var visualViewportSpace = _Global.document.body.querySelector("." + _Constants.visualViewportClass); - if (!visualViewportSpace) { - visualViewportSpace = _Global.document.createElement("DIV"); - visualViewportSpace.className = _Constants.visualViewportClass; - _Global.document.body.appendChild(visualViewportSpace); - } - return visualViewportSpace.getBoundingClientRect(); - }, - // Get total length of the IHM showPanel animation - get _animationShowLength() { - if (_BaseCoreUtils.hasWinRT) { - if (_WinRT.Windows.UI.Core.AnimationMetrics) { - // Desktop exposes the AnimationMetrics API that allows us to look up the relevant IHM animation metrics. - var a = _WinRT.Windows.UI.Core.AnimationMetrics, animationDescription = new a.AnimationDescription(a.AnimationEffect.showPanel, a.AnimationEffectTarget.primary); - var animations = animationDescription.animations; - var max = 0; - for (var i = 0; i < animations.size; i++) { - var animation = animations[i]; - max = Math.max(max, animation.delay + animation.duration); - } - return max; - } - else { - // Phone platform does not yet expose the Animation Metrics API. - // Hard code the correct values for the time being. - // https://github.com/winjs/winjs/issues/1060 - var animationDuration = 300; - var animationDelay = 50; - return animationDelay + animationDuration; - } - } - else { - return 0; - } - }, - // Padding for IHM timer to allow for first scroll event. Tpyically used in conjunction with the - // _animationShowLength to determine the length of time in which a showing IHM would have triggered - // a window resize to occur. - get _scrollTimeout() { - return _Constants.scrollTimeout; - }, - // _layoutViewportCoords is used with elements that use position:fixed instead of position:-ms-device-fixed - get _layoutViewportCoords() { - var topOffset = _Global.window.pageYOffset - _Global.document.documentElement.scrollTop; - var bottomOffset = _Global.document.documentElement.clientHeight - (topOffset + this._visibleDocHeight); - return { - visibleDocTop: topOffset, - visibleDocBottom: bottomOffset - }; - } - }; -}); - - -define('require-style!less/styles-overlay',[],function(){}); - -define('require-style!less/colors-overlay',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// animatable,appbar,appbars,divs,Flyout,Flyouts,iframe,Statics,unfocus,unselectable -define('WinJS/Controls/Flyout/_Overlay',[ - 'exports', - '../../Core/_Global', - '../../Core/_WinRT', - '../../Core/_Base', - '../../Core/_BaseUtils', - '../../Core/_ErrorFromName', - '../../Core/_Events', - '../../Core/_Resources', - '../../Core/_WriteProfilerMark', - '../../_Accents', - '../../Animations', - '../../Application', - '../../ControlProcessor', - '../../Promise', - '../../Scheduler', - '../../Utilities/_Control', - '../../Utilities/_ElementUtilities', - '../../Utilities/_KeyboardInfo', - '../_LegacyAppBar/_Constants', - 'require-style!less/styles-overlay', - 'require-style!less/colors-overlay' -], function overlayInit(exports, _Global, _WinRT, _Base, _BaseUtils, _ErrorFromName, _Events, _Resources, _WriteProfilerMark, _Accents, Animations, Application, ControlProcessor, Promise, Scheduler, _Control, _ElementUtilities, _KeyboardInfo, _Constants) { - "use strict"; - - _Accents.createAccentRule( - "button[aria-checked=true].win-command:before,\ - .win-menu-containsflyoutcommand button.win-command-flyout-activated:before", [ - { name: "background-color", value: _Accents.ColorTypes.accent }, - { name: "border-color", value: _Accents.ColorTypes.accent }, - ]); - - _Accents.createAccentRule(".win-flyout, .win-settingsflyout", [{ name: "border-color", value: _Accents.ColorTypes.accent }]); - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - _Overlay: _Base.Namespace._lazy(function () { - - // Helper for Global Event listeners. Invokes the specified callback member function on each _Overlay in the DOM. - function _allOverlaysCallback(event, nameOfFunctionCall, stopImmediatePropagationWhenHandled) { - var elements = _Global.document.querySelectorAll("." + _Constants.overlayClass); - if (elements) { - var len = elements.length; - for (var i = 0; i < len; i++) { - var element = elements[i]; - var overlay = element.winControl; - if (!overlay._disposed) { - if (overlay) { - var handled = overlay[nameOfFunctionCall](event); - if (stopImmediatePropagationWhenHandled && handled) { - // The caller has indicated we should exit as soon as the event is handled. - return handled; - } - } - } - } - } - } - - // _Overlay Global Events Listener Class. We hang a singleton instance of this class off of a static _Overlay property. - var _GlobalListener = _Base.Class.define(function _GlobalListener_ctor() { - this._currentState = _GlobalListener.states.off; - - this._inputPaneShowing = this._inputPaneShowing.bind(this); - this._inputPaneHiding = this._inputPaneHiding.bind(this); - this._documentScroll = this._documentScroll.bind(this); - this._windowResized = this._windowResized.bind(this); - }, { - initialize: function _GlobalListener_initialize() { - this._toggleListeners(_GlobalListener.states.on); - }, - // Expose this for unit tests. - reset: function _GlobalListener_reset() { - this._toggleListeners(_GlobalListener.states.off); - this._toggleListeners(_GlobalListener.states.on); - }, - _inputPaneShowing: function _GlobalListener_inputePaneShowing(event) { - _WriteProfilerMark(_GlobalListener.profilerString + "_showingKeyboard,StartTM"); - _allOverlaysCallback(event, "_showingKeyboard"); - _WriteProfilerMark(_GlobalListener.profilerString + "_showingKeyboard,StopTM"); - }, - _inputPaneHiding: function _GlobalListener_inputPaneHiding(event) { - _WriteProfilerMark(_GlobalListener.profilerString + "_hidingKeyboard,StartTM"); - _allOverlaysCallback(event, "_hidingKeyboard"); - _WriteProfilerMark(_GlobalListener.profilerString + "_hidingKeyboard,StopTM"); - }, - _documentScroll: function _GlobalListener_documentScroll(event) { - _WriteProfilerMark(_GlobalListener.profilerString + "_checkScrollPosition,StartTM"); - _allOverlaysCallback(event, "_checkScrollPosition"); - _WriteProfilerMark(_GlobalListener.profilerString + "_checkScrollPosition,StopTM"); - }, - _windowResized: function _GlobalListener_windowResized(event) { - _WriteProfilerMark(_GlobalListener.profilerString + "_baseResize,StartTM"); - _allOverlaysCallback(event, "_baseResize"); - _WriteProfilerMark(_GlobalListener.profilerString + "_baseResize,StopTM"); - }, - _toggleListeners: function _GlobalListener_toggleListeners(newState) { - // Add/Remove global event listeners for all _Overlays - var listenerOperation; - if (this._currentState !== newState) { - if (newState === _GlobalListener.states.on) { - listenerOperation = "addEventListener"; - } else if (newState === _GlobalListener.states.off) { - listenerOperation = "removeEventListener"; - } - - if (_WinRT.Windows.UI.ViewManagement.InputPane) { - // React to Soft Keyboard events - var inputPane = _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView(); - inputPane[listenerOperation]("showing", this._inputPaneShowing, false); - inputPane[listenerOperation]("hiding", this._inputPaneHiding, false); - - _Global.document[listenerOperation]("scroll", this._documentScroll, false); - } - - // Window resize event - _Global.addEventListener("resize", this._windowResized, false); - - this._currentState = newState; - } - }, - }, { - // Statics - profilerString: { - get: function () { - return "WinJS.UI._Overlay Global Listener:"; - } - }, - states: { - get: function () { - return { - off: 0, - on: 1, - }; - }, - }, - }); - - // Helper to get DOM elements from input single object or array or IDs/toolkit/dom elements - function _resolveElements(elements) { - // No input is just an empty array - if (!elements) { - return []; - } - - // Make sure it's in array form. - if (typeof elements === "string" || !elements || !elements.length) { - elements = [elements]; - } - - // Make sure we have a DOM element for each one, (could be string id name or toolkit object) - var i, - realElements = []; - for (i = 0; i < elements.length; i++) { - if (elements[i]) { - if (typeof elements[i] === "string") { - var element = _Global.document.getElementById(elements[i]); - if (element) { - realElements.push(element); - } - } else if (elements[i].element) { - realElements.push(elements[i].element); - } else { - realElements.push(elements[i]); - } - } - } - - return realElements; - } - - var strings = { - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get mustContainCommands() { return "Invalid HTML: AppBars/Menus must contain only AppBarCommands/MenuCommands"; }, - get closeOverlay() { return _Resources._getWinJSString("ui/closeOverlay").value; }, - }; - - var _Overlay = _Base.Class.define(function _Overlay_ctor(element, options) { - /// - /// - /// Constructs the Overlay control and associates it with the underlying DOM element. - /// - /// - /// The DOM element to be associated with the Overlay control. - /// - /// - /// The set of options to be applied initially to the Overlay control. - /// - /// A fully constructed Overlay control. - /// - this._baseOverlayConstructor(element, options); - }, { - // Functions/properties - _baseOverlayConstructor: function _Overlay_baseOverlayConstructor(element, options) { - - this._disposed = false; - - // Make sure there's an input element - if (!element) { - element = _Global.document.createElement("div"); - } - - // Check to make sure we weren't duplicated - var overlay = element.winControl; - if (overlay) { - throw new _ErrorFromName("WinJS.UI._Overlay.DuplicateConstruction", strings.duplicateConstruction); - } - - if (!this._element) { - this._element = element; - } - - if (!this._element.hasAttribute("tabIndex")) { - this._element.tabIndex = -1; - } - - this._sticky = false; - this._doNext = ""; - - this._element.style.visibility = "hidden"; - this._element.style.opacity = 0; - - // Remember ourselves - element.winControl = this; - - // Attach our css class - _ElementUtilities.addClass(this._element, _Constants.overlayClass); - _ElementUtilities.addClass(this._element, "win-disposable"); - - // We don't want to be selectable, set UNSELECTABLE - var unselectable = this._element.getAttribute("unselectable"); - if (unselectable === null || unselectable === undefined) { - this._element.setAttribute("unselectable", "on"); - } - - // Base animation is popIn/popOut - this._currentAnimateIn = this._baseAnimateIn; - this._currentAnimateOut = this._baseAnimateOut; - this._animationPromise = Promise.as(); - - // Command Animations to Queue - this._queuedToShow = []; - this._queuedToHide = []; - this._queuedCommandAnimation = false; - - if (options) { - _Control.setOptions(this, options); - } - - // Make sure _Overlay event handlers are hooked up (this aids light dismiss) - _Overlay._globalEventListeners.initialize(); - }, - - /// - element: { - get: function () { - return this._element; - } - }, - - dispose: function () { - /// - /// - /// Disposes this Overlay. - /// - /// - if (this._disposed) { - return; - } - - this._disposed = true; - this._dispose(); - }, - - _dispose: function _Overlay_dispose() { - // To be overridden by subclasses - }, - - _show: function _Overlay_show() { - // We call our base _baseShow because AppBar may need to override show - this._baseShow(); - }, - - _hide: function _Overlay_hide() { - // We call our base _baseHide because AppBar may need to override hide - this._baseHide(); - }, - - // Is the overlay "hidden"? - /// - hidden: { - get: function () { - return (this._element.style.visibility === "hidden" || - this._element.winAnimating === "hiding" || - this._doNext === "hide"); - }, - set: function (hidden) { - var currentlyHidden = this.hidden; - if (!hidden && currentlyHidden) { - this._show(); - } else if (hidden && !currentlyHidden) { - this._hide(); - } - } - }, - - addEventListener: function (type, listener, useCapture) { - /// - /// - /// Add an event listener to the DOM element for this Overlay - /// - /// Required. Event type to add, "beforehide", "afterhide", "beforeshow", or "aftershow" - /// Required. The event handler function to associate with this event. - /// Optional. True, register for the event capturing phase. False for the event bubbling phase. - /// - return this._element.addEventListener(type, listener, useCapture); - }, - - removeEventListener: function (type, listener, useCapture) { - /// - /// - /// Remove an event listener to the DOM element for this Overlay - /// - /// Required. Event type to remove, "beforehide", "afterhide", "beforeshow", or "aftershow" - /// Required. The event handler function to associate with this event. - /// Optional. True, register for the event capturing phase. False for the event bubbling phase. - /// - return this._element.removeEventListener(type, listener, useCapture); - }, - - _baseShow: function _Overlay_baseShow() { - // If we are already animating, just remember this for later - if (this._animating || this._needToHandleHidingKeyboard) { - this._doNext = "show"; - return false; - } - - if (this._element.style.visibility !== "visible") { - // Let us know we're showing. - this._element.winAnimating = "showing"; - - // Hiding, but not none - this._element.style.display = ""; - this._element.style.visibility = "hidden"; - - // In case their event is going to manipulate commands, see if there are - // any queued command animations we can handle while we're still hidden. - if (this._queuedCommandAnimation) { - this._showAndHideFast(this._queuedToShow, this._queuedToHide); - this._queuedToShow = []; - this._queuedToHide = []; - } - - // Send our "beforeShow" event - this._sendEvent(_Overlay.beforeShow); - - // Need to measure - this._findPosition(); - - // Make sure it's visible, and fully opaque. - // Do the popup thing, sending event afterward. - var that = this; - this._animationPromise = this._currentAnimateIn(). - then(function () { - that._baseEndShow(); - }, function () { - that._baseEndShow(); - }); - return true; - } - return false; - }, - - // Flyout in particular will need to measure our positioning. - _findPosition: function _Overlay_findPosition() { - }, - - _baseEndShow: function _Overlay_baseEndShow() { - if (this._disposed) { - return; - } - - // Make sure it's visible after showing - this._element.setAttribute("aria-hidden", "false"); - - this._element.winAnimating = ""; - - // Do our derived classes show stuff - this._endShow(); - - // We're shown now - if (this._doNext === "show") { - this._doNext = ""; - } - - // After showing, send the after showing event - this._sendEvent(_Overlay.afterShow); - this._writeProfilerMark("show,StopTM"); // Overlay writes the stop profiler mark for all of its derived classes. - - // If we had something queued, do that - Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); - - }, - - _endShow: function _Overlay_endShow() { - // Nothing by default - }, - - _baseHide: function _Overlay_baseHide() { - // If we are already animating, just remember this for later - if (this._animating) { - this._doNext = "hide"; - return false; - } - - // In the unlikely event we're between the hiding keyboard and the resize events, just snap it away: - if (this._needToHandleHidingKeyboard) { - // use the "uninitialized" flag - this._element.style.visibility = ""; - } - - if (this._element.style.visibility !== "hidden") { - // Let us know we're hiding, accessibility as well. - this._element.winAnimating = "hiding"; - this._element.setAttribute("aria-hidden", "true"); - - // Send our "beforeHide" event - this._sendEvent(_Overlay.beforeHide); - - // If our visibility is empty, then this is the first time, just hide it - if (this._element.style.visibility === "") { - // Initial hiding, just hide it - this._element.style.opacity = 0; - this._baseEndHide(); - } else { - // Make sure it's hidden, and fully transparent. - var that = this; - this._animationPromise = this._currentAnimateOut(). - then(function () { - that._baseEndHide(); - }, function () { - that._baseEndHide(); - }); - } - return true; - } - - return false; - }, - - _baseEndHide: function _Overlay_baseEndHide() { - if (this._disposed) { - return; - } - - // Do our derived classes hide stuff - this._beforeEndHide(); - - // Make sure animation is finished. - this._element.style.visibility = "hidden"; - this._element.style.display = "none"; - this._element.winAnimating = ""; - - // In case their event is going to manipulate commands, see if there - // are any queued command animations we can handle now we're hidden. - if (this._queuedCommandAnimation) { - this._showAndHideFast(this._queuedToShow, this._queuedToHide); - this._queuedToShow = []; - this._queuedToHide = []; - } - - // We're hidden now - if (this._doNext === "hide") { - this._doNext = ""; - } - - // After hiding, send our "afterHide" event - this._sendEvent(_Overlay.afterHide); - this._writeProfilerMark("hide,StopTM"); // Overlay writes the stop profiler mark for all of its derived classes. - - - // If we had something queued, do that. This has to be after - // the afterHide event in case it triggers a show() and they - // have something to do in beforeShow that requires afterHide first. - Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); - }, - - // Called after the animation but while the Overlay is still visible. It's - // important that this runs while the Overlay is visible because hiding - // a DOM element (e.g. visibility="hidden", display="none") while it contains - // focus has the side effect of moving focus to the body or null and triggering - // focus move events. _beforeEndHide is a good hook for the Overlay to move focus - // elsewhere before its DOM element gets hidden. - _beforeEndHide: function _Overlay_beforeEndHide() { - // Nothing by default - }, - - _checkDoNext: function _Overlay_checkDoNext() { - // Do nothing if we're still animating - if (this._animating || this._needToHandleHidingKeyboard || this._disposed) { - return; - } - - if (this._doNext === "hide") { - // Do hide first because animating commands would be easier - this._hide(); - this._doNext = ""; - } else if (this._queuedCommandAnimation) { - // Do queued commands before showing if possible - this._showAndHideQueue(); - } else if (this._doNext === "show") { - // Show last so that we don't unnecessarily animate commands - this._show(); - this._doNext = ""; - } - }, - - // Default animations - _baseAnimateIn: function _Overlay_baseAnimateIn() { - this._element.style.opacity = 0; - this._element.style.visibility = "visible"; - // touch opacity so that IE fades from the 0 we just set to 1 - _Global.getComputedStyle(this._element, null).opacity; - return Animations.fadeIn(this._element); - }, - - _baseAnimateOut: function _Overlay_baseAnimateOut() { - this._element.style.opacity = 1; - // touch opacity so that IE fades from the 1 we just set to 0 - _Global.getComputedStyle(this._element, null).opacity; - return Animations.fadeOut(this._element); - }, - - _animating: { - get: function _Overlay_animating_get() { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return !!this._element.winAnimating; - } - }, - - // Send one of our events - _sendEvent: function _Overlay_sendEvent(eventName, detail) { - if (this._disposed) { - return; - } - var event = _Global.document.createEvent("CustomEvent"); - event.initEvent(eventName, true, true, (detail || {})); - this._element.dispatchEvent(event); - }, - - // Show commands - _showCommands: function _Overlay_showCommands(commands, immediate) { - var showHide = this._resolveCommands(commands); - this._showAndHideCommands(showHide.commands, [], immediate); - }, - - // Hide commands - _hideCommands: function _Overlay_hideCommands(commands, immediate) { - var showHide = this._resolveCommands(commands); - this._showAndHideCommands([], showHide.commands, immediate); - }, - - // Hide commands - _showOnlyCommands: function _Overlay_showOnlyCommands(commands, immediate) { - var showHide = this._resolveCommands(commands); - this._showAndHideCommands(showHide.commands, showHide.others, immediate); - }, - - _showAndHideCommands: function _Overlay_showAndHideCommands(showCommands, hideCommands, immediate) { - // Immediate is "easy" - if (immediate || (this.hidden && !this._animating)) { - // Immediate mode (not animated) - this._showAndHideFast(showCommands, hideCommands); - // Need to remove them from queues, but others could be queued - this._removeFromQueue(showCommands, this._queuedToShow); - this._removeFromQueue(hideCommands, this._queuedToHide); - } else { - - // Queue Commands - this._updateAnimateQueue(showCommands, this._queuedToShow, this._queuedToHide); - this._updateAnimateQueue(hideCommands, this._queuedToHide, this._queuedToShow); - } - }, - - _removeFromQueue: function _Overlay_removeFromQueue(commands, queue) { - // remove commands from queue. - var count; - for (count = 0; count < commands.length; count++) { - // Remove if it was in queue - var countQ; - for (countQ = 0; countQ < queue.length; countQ++) { - if (queue[countQ] === commands[count]) { - queue.splice(countQ, 1); - break; - } - } - } - }, - - _updateAnimateQueue: function _Overlay_updateAnimateQueue(addCommands, toQueue, fromQueue) { - if (this._disposed) { - return; - } - - // Add addCommands to toQueue and remove addCommands from fromQueue. - var count; - for (count = 0; count < addCommands.length; count++) { - // See if it's already in toQueue - var countQ; - for (countQ = 0; countQ < toQueue.length; countQ++) { - if (toQueue[countQ] === addCommands[count]) { - break; - } - } - if (countQ === toQueue.length) { - // Not found, add it - toQueue[countQ] = addCommands[count]; - } - // Remove if it was in fromQueue - for (countQ = 0; countQ < fromQueue.length; countQ++) { - if (fromQueue[countQ] === addCommands[count]) { - fromQueue.splice(countQ, 1); - break; - } - } - } - // If we haven't queued the actual animation - if (!this._queuedCommandAnimation) { - // If not already animating, we'll need to call _checkDoNext - if (!this._animating) { - Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); - } - this._queuedCommandAnimation = true; - } - }, - - // show/hide commands without doing any animation. - _showAndHideFast: function _Overlay_showAndHideFast(showCommands, hideCommands) { - var count; - var command; - for (count = 0; count < showCommands.length; count++) { - command = showCommands[count]; - if (command && command.style) { - command.style.visibility = ""; - command.style.display = ""; - } - } - for (count = 0; count < hideCommands.length; count++) { - command = hideCommands[count]; - if (command && command.style) { - command.style.visibility = "hidden"; - command.style.display = "none"; - } - } - - this._commandsUpdated(); - - }, - - // show and hide the queued commands, perhaps animating if overlay isn't hidden. - _showAndHideQueue: function _Overlay_showAndHideQueue() { - // Only called if not currently animating. - // We'll be done with the queued stuff when we return. - this._queuedCommandAnimation = false; - - // Shortcut if hidden - if (this.hidden) { - this._showAndHideFast(this._queuedToShow, this._queuedToHide); - // Might be something else to do - Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._Overlay._checkDoNext"); - } else { - // Animation has 3 parts: "hiding", "showing", and "moving" - // PVL has "addToList" and "deleteFromList", both of which allow moving parts. - // So we'll set up "add" for showing, and use "delete" for "hiding" + moving, - // then trigger both at the same time. - var showCommands = this._queuedToShow; - var hideCommands = this._queuedToHide; - var siblings = this._findSiblings(showCommands.concat(hideCommands)); - - // Filter out the commands queued for animation that don't need to be animated. - var count; - for (count = 0; count < showCommands.length; count++) { - // If this one's not real or not attached, skip it - if (!showCommands[count] || - !showCommands[count].style || - !_Global.document.body.contains(showCommands[count])) { - // Not real, skip it - showCommands.splice(count, 1); - count--; - } else if (showCommands[count].style.visibility !== "hidden" && showCommands[count].style.opacity !== "0") { - // Don't need to animate showing this one, already visible, so now it's a sibling - siblings.push(showCommands[count]); - showCommands.splice(count, 1); - count--; - } - } - for (count = 0; count < hideCommands.length; count++) { - // If this one's not real or not attached, skip it - if (!hideCommands[count] || - !hideCommands[count].style || - !_Global.document.body.contains(hideCommands[count]) || - hideCommands[count].style.visibility === "hidden" || - hideCommands[count].style.opacity === "0") { - // Don't need to animate hiding this one, not real, or it's hidden, - // so don't even need it as a sibling. - hideCommands.splice(count, 1); - count--; - } - } - - // Start command animations. - var commandsAnimationPromise = this._baseBeginAnimateCommands(showCommands, hideCommands, siblings); - - // Hook end animations - var that = this; - if (commandsAnimationPromise) { - // Needed to animate - commandsAnimationPromise.done( - function () { that._baseEndAnimateCommands(hideCommands); }, - function () { that._baseEndAnimateCommands(hideCommands); } - ); - } else { - // Already positioned correctly - Scheduler.schedule(function Overlay_async_baseEndAnimationCommands() { that._baseEndAnimateCommands([]); }, - Scheduler.Priority.normal, null, - "WinJS.UI._Overlay._endAnimateCommandsWithoutAnimation"); - } - } - - // Done, clear queues - this._queuedToShow = []; - this._queuedToHide = []; - }, - - _baseBeginAnimateCommands: function _Overlay_baseBeginAnimateCommands(showCommands, hideCommands, siblings) { - // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. - // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. - // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE shceduled to hide. - // 3) siblings[]: i. All VISIBLE win-command elements that ARE NOT scheduled to hide. - // ii. All HIDDEN win-command elements that ARE NOT scheduled to hide OR show. - this._beginAnimateCommands(showCommands, hideCommands, this._getVisibleCommands(siblings)); - - var showAnimated = null, - hideAnimated = null; - - // Hide commands first, with siblings if necessary, - // so that the showing commands don't disrupt the hiding commands position. - if (hideCommands.length > 0) { - hideAnimated = Animations.createDeleteFromListAnimation(hideCommands, showCommands.length === 0 ? siblings : undefined); - } - if (showCommands.length > 0) { - showAnimated = Animations.createAddToListAnimation(showCommands, siblings); - } - - // Update hiding commands - for (var count = 0, len = hideCommands.length; count < len; count++) { - // Need to fix our position - var rectangle = hideCommands[count].getBoundingClientRect(), - style = _Global.getComputedStyle(hideCommands[count]); - - // Use the bounding box, adjusting for margins - hideCommands[count].style.top = (rectangle.top - parseFloat(style.marginTop)) + "px"; - hideCommands[count].style.left = (rectangle.left - parseFloat(style.marginLeft)) + "px"; - hideCommands[count].style.opacity = 0; - hideCommands[count].style.position = "fixed"; - } - - // Mark as animating - this._element.winAnimating = "rearranging"; - - // Start hiding animations - // Hide needs extra cleanup when done - var promise = null; - if (hideAnimated) { - promise = hideAnimated.execute(); - } - - // Update showing commands, - // After hiding commands so that the hiding ones fade in the right place. - for (count = 0; count < showCommands.length; count++) { - showCommands[count].style.visibility = ""; - showCommands[count].style.display = ""; - showCommands[count].style.opacity = 1; - } - - // Start showing animations - if (showAnimated) { - var newPromise = showAnimated.execute(); - if (promise) { - promise = Promise.join([promise, newPromise]); - } else { - promise = newPromise; - } - } - - return promise; - }, - - _beginAnimateCommands: function _Overlay_beginAnimateCommands() { - // Nothing by default - }, - - _getVisibleCommands: function _Overlay_getVisibleCommands(commandSubSet) { - var command, - commands = commandSubSet, - visibleCommands = []; - - if (!commands) { - // Crawl the inner HTML for the commands. - commands = this.element.querySelectorAll(".win-command"); - } - - for (var i = 0, len = commands.length; i < len; i++) { - command = commands[i].winControl || commands[i]; - if (!command.hidden) { - visibleCommands.push(command); - } - } - - return visibleCommands; - }, - - // Once animation is complete, ensure that the commands are display:none - // and check if there's another animation to start. - _baseEndAnimateCommands: function _Overlay_baseEndAnimateCommands(hideCommands) { - if (this._disposed) { - return; - } - - // Update us - var count; - for (count = 0; count < hideCommands.length; count++) { - // Force us back into our appbar so that we can show again correctly - hideCommands[count].style.position = ""; - hideCommands[count].style.top = ""; - hideCommands[count].style.left = ""; - hideCommands[count].getBoundingClientRect(); - // Now make us really hidden - hideCommands[count].style.visibility = "hidden"; - hideCommands[count].style.display = "none"; - hideCommands[count].style.opacity = 1; - } - // Done animating - this._element.winAnimating = ""; - - this._endAnimateCommands(); - - // Might be something else to do - this._checkDoNext(); - }, - - _endAnimateCommands: function _Overlay_endAnimateCommands() { - // Nothing by default - }, - - // Resolves our commands - _resolveCommands: function _Overlay_resolveCommands(commands) { - // First make sure they're all DOM elements. - commands = _resolveElements(commands); - - // Now make sure they're all in this container - var result = {}; - result.commands = []; - result.others = []; - var allCommands = this.element.querySelectorAll(".win-command"); - var countAll, countIn; - for (countAll = 0; countAll < allCommands.length; countAll++) { - var found = false; - for (countIn = 0; countIn < commands.length; countIn++) { - if (commands[countIn] === allCommands[countAll]) { - result.commands.push(allCommands[countAll]); - commands.splice(countIn, 1); - found = true; - break; - } - } - if (!found) { - result.others.push(allCommands[countAll]); - } - } - return result; - }, - - // Find siblings, all DOM elements now. - // Returns all .win-commands in this Overlay that are NOT in the passed in 'commands' array. - _findSiblings: function _Overlay_findSiblings(commands) { - // Now make sure they're all in this container - var siblings = []; - var allCommands = this.element.querySelectorAll(".win-command"); - var countAll, countIn; - for (countAll = 0; countAll < allCommands.length; countAll++) { - var found = false; - for (countIn = 0; countIn < commands.length; countIn++) { - if (commands[countIn] === allCommands[countAll]) { - commands.splice(countIn, 1); - found = true; - break; - } - } - if (!found) { - siblings.push(allCommands[countAll]); - } - } - return siblings; - }, - - _baseResize: function _Overlay_baseResize(event) { - // Call specific resize - this._resize(event); - }, - - _hideOrDismiss: function _Overlay_hideOrDismiss() { - var element = this._element; - if (element && _ElementUtilities.hasClass(element, _Constants.settingsFlyoutClass)) { - this._dismiss(); - } else if (element && _ElementUtilities.hasClass(element, _Constants.appBarClass)) { - this.close(); - } else { - this.hide(); - } - }, - - _resize: function _Overlay_resize() { - // Nothing by default - }, - - _commandsUpdated: function _Overlay_commandsUpdated() { - // Nothing by default - }, - - _checkScrollPosition: function _Overlay_checkScrollPosition() { - // Nothing by default - }, - - _showingKeyboard: function _Overlay_showingKeyboard() { - // Nothing by default - }, - - _hidingKeyboard: function _Overlay_hidingKeyboard() { - // Nothing by default - }, - - // Verify that this HTML AppBar only has AppBar/MenuCommands. - _verifyCommandsOnly: function _Overlay_verifyCommandsOnly(element, type) { - var children = element.children; - var commands = new Array(children.length); - for (var i = 0; i < children.length; i++) { - // If constructed they have win-command class, otherwise they have data-win-control - if (!_ElementUtilities.hasClass(children[i], "win-command") && - children[i].getAttribute("data-win-control") !== type) { - // Wasn't tagged with class or AppBar/MenuCommand, not an AppBar/MenuCommand - throw new _ErrorFromName("WinJS.UI._Overlay.MustContainCommands", strings.mustContainCommands); - } else { - // Instantiate the commands. - ControlProcessor.processAll(children[i]); - commands[i] = children[i].winControl; - } - } - return commands; - }, - - // Sets focus on what we think is the last tab stop. If nothing is focusable will - // try to set focus on itself. - _focusOnLastFocusableElementOrThis: function _Overlay_focusOnLastFocusableElementOrThis() { - if (!this._focusOnLastFocusableElement()) { - // Nothing is focusable. Set focus to this. - _Overlay._trySetActive(this._element); - } - }, - - // Sets focus to what we think is the last tab stop. This element must have - // a firstDiv with tabIndex equal to the lowest tabIndex in the element - // and a finalDiv with tabIndex equal to the highest tabIndex in the element. - // Also the firstDiv must be its first child and finalDiv be its last child. - // Returns true if successful, false otherwise. - _focusOnLastFocusableElement: function _Overlay_focusOnLastFocusableElement() { - if (this._element.firstElementChild) { - var oldFirstTabIndex = this._element.firstElementChild.tabIndex; - var oldLastTabIndex = this._element.lastElementChild.tabIndex; - this._element.firstElementChild.tabIndex = -1; - this._element.lastElementChild.tabIndex = -1; - - var tabResult = _ElementUtilities._focusLastFocusableElement(this._element); - - if (tabResult) { - _Overlay._trySelect(_Global.document.activeElement); - } - - this._element.firstElementChild.tabIndex = oldFirstTabIndex; - this._element.lastElementChild.tabIndex = oldLastTabIndex; - - return tabResult; - } else { - return false; - } - }, - - - // Sets focus on what we think is the first tab stop. If nothing is focusable will - // try to set focus on itself. - _focusOnFirstFocusableElementOrThis: function _Overlay_focusOnFirstFocusableElementOrThis() { - if (!this._focusOnFirstFocusableElement()) { - // Nothing is focusable. Set focus to this. - _Overlay._trySetActive(this._element); - } - }, - - // Sets focus to what we think is the first tab stop. This element must have - // a firstDiv with tabIndex equal to the lowest tabIndex in the element - // and a finalDiv with tabIndex equal to the highest tabIndex in the element. - // Also the firstDiv must be its first child and finalDiv be its last child. - // Returns true if successful, false otherwise. - _focusOnFirstFocusableElement: function _Overlay__focusOnFirstFocusableElement(useSetActive, scroller) { - if (this._element.firstElementChild) { - var oldFirstTabIndex = this._element.firstElementChild.tabIndex; - var oldLastTabIndex = this._element.lastElementChild.tabIndex; - this._element.firstElementChild.tabIndex = -1; - this._element.lastElementChild.tabIndex = -1; - - var tabResult = _ElementUtilities._focusFirstFocusableElement(this._element, useSetActive, scroller); - - if (tabResult) { - _Overlay._trySelect(_Global.document.activeElement); - } - - this._element.firstElementChild.tabIndex = oldFirstTabIndex; - this._element.lastElementChild.tabIndex = oldLastTabIndex; - - return tabResult; - } else { - return false; - } - }, - - _writeProfilerMark: function _Overlay_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI._Overlay:" + this._id + ":" + text); - } - }, - { - // Statics - - _isFlyoutVisible: function () { - var flyouts = _Global.document.querySelectorAll("." + _Constants.flyoutClass); - for (var i = 0; i < flyouts.length; i++) { - var flyoutControl = flyouts[i].winControl; - if (flyoutControl && !flyoutControl.hidden) { - return true; - } - } - - return false; - }, - - // Try to set us as active - _trySetActive: function (element, scroller) { - if (!element || !_Global.document.body || !_Global.document.body.contains(element)) { - return false; - } - if (!_ElementUtilities._setActive(element, scroller)) { - return false; - } - return (element === _Global.document.activeElement); - }, - - // Try to select the text so keyboard can be used. - _trySelect: function (element) { - try { - if (element && element.select) { - element.select(); - } - } catch (e) { } - }, - - _sizeOfDocument: function () { - return { - width: _Global.document.documentElement.offsetWidth, - height: _Global.document.documentElement.offsetHeight, - }; - }, - - _getParentControlUsingClassName: function (element, className) { - while (element && element !== _Global.document.body) { - if (_ElementUtilities.hasClass(element, className)) { - return element.winControl; - } - element = element.parentNode; - } - return null; - }, - - // Static controller for _Overlay global events registering/unregistering. - _globalEventListeners: new _GlobalListener(), - - // Show/Hide all bars - _hideAppBars: function _Overlay_hideAppBars(bars, keyboardInvoked) { - var allBarsAnimationPromises = bars.map(function (bar) { - bar.close(); - return bar._animationPromise; - }); - return Promise.join(allBarsAnimationPromises); - }, - - _showAppBars: function _Overlay_showAppBars(bars, keyboardInvoked) { - var allBarsAnimationPromises = bars.map(function (bar) { - bar._show(); - return bar._animationPromise; - }); - return Promise.join(allBarsAnimationPromises); - }, - - // WWA Soft Keyboard offsets - _keyboardInfo: _KeyboardInfo._KeyboardInfo, - - // Padding for IHM timer to allow for first scroll event - _scrollTimeout: _KeyboardInfo._KeyboardInfo._scrollTimeout, - - // Events - beforeShow: "beforeshow", - beforeHide: "beforehide", - afterShow: "aftershow", - afterHide: "afterhide", - - commonstrings: { - get cannotChangeCommandsWhenVisible() { return "Invalid argument: You must call hide() before changing {0} commands"; }, - get cannotChangeHiddenProperty() { return "Unable to set hidden property while parent {0} is visible."; } - }, - }); - - _Base.Class.mix(_Overlay, _Control.DOMEventMixin); - - return _Overlay; - }) - }); - -}); - - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// appbar,Flyout,Flyouts,Statics -define('WinJS/Controls/Flyout',[ - 'exports', - '../Core/_Global', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_ErrorFromName', - '../Core/_Events', - '../Core/_Log', - '../Core/_Resources', - '../Core/_WriteProfilerMark', - '../Animations', - '../_Signal', - '../_LightDismissService', - '../Utilities/_Dispose', - '../Utilities/_ElementUtilities', - '../Utilities/_KeyboardBehavior', - '../Utilities/_Hoverable', - './_LegacyAppBar/_Constants', - './Flyout/_Overlay' -], function flyoutInit(exports, _Global, _Base, _BaseUtils, _ErrorFromName, _Events, _Log, _Resources, _WriteProfilerMark, Animations, _Signal, _LightDismissService, _Dispose, _ElementUtilities, _KeyboardBehavior, _Hoverable, _Constants, _Overlay) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// - /// Displays lightweight UI that is either informational, or requires user interaction. - /// Unlike a dialog, a Flyout can be light dismissed by clicking or tapping off of it. - /// - /// - /// - /// Flyout - /// - /// - /// ]]> - /// Raised just before showing a flyout. - /// Raised immediately after a flyout is fully shown. - /// Raised just before hiding a flyout. - /// Raised immediately after a flyout is fully hidden. - /// The Flyout control itself. - /// - /// - Flyout: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - function getDimension(element, property) { - return _ElementUtilities.convertToPixels(element, _Global.getComputedStyle(element, null)[property]); - } - - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/flyoutAriaLabel").value; }, - get noAnchor() { return "Invalid argument: Flyout anchor element not found in DOM."; }, - get badPlacement() { return "Invalid argument: Flyout placement should be 'top' (default), 'bottom', 'left', 'right', 'auto', 'autohorizontal', or 'autovertical'."; }, - get badAlignment() { return "Invalid argument: Flyout alignment should be 'center' (default), 'left', or 'right'."; } - }; - - var createEvent = _Events._createEventProperty; - - // _LightDismissableLayer is an ILightDismissable which manages a set of ILightDismissables. - // It acts as a proxy between the LightDismissService and the light dismissables it manages. - // It enables multiple dismissables to be above the click eater at the same time. - var _LightDismissableLayer = _Base.Class.define(function _LightDismissableLayer_ctor(onLightDismiss) { - this._onLightDismiss = onLightDismiss; - this._currentlyFocusedClient = null; - this._clients = []; // Array of ILightDismissables - }, { - // Dismissables should call this as soon as they are ready to be shown. More specifically, they should call this: - // - After they are in the DOM and ready to receive focus (e.g. style.display cannot be "none") - // - Before their entrance animation is played - shown: function _LightDismissableLayer_shown(client /*: ILightDismissable */) { - client._focusable = true; - var index = this._clients.indexOf(client); - if (index === -1) { - this._clients.push(client); - client.onShow(this); - if (!_LightDismissService.isShown(this)) { - _LightDismissService.shown(this); - } else { - _LightDismissService.updated(this); - this._activateTopFocusableClientIfNeeded(); - } - } - }, - - // Dismissables should call this at the start of their exit animation. A "hiding", - // dismissable will still be rendered with the proper z-index but it will no - // longer be given focus. Also, focus is synchronously moved out of this dismissable. - hiding: function _LightDismissableLayer_hiding(client /*: ILightDismissable */) { - var index = this._clients.indexOf(client); - if (index !== -1) { - this._clients[index]._focusable = false; - this._activateTopFocusableClientIfNeeded(); - } - }, - - // Dismissables should call this when they are done being dismissed (i.e. after their exit animation has finished) - hidden: function _LightDismissableLayer_hidden(client /*: ILightDismissable */) { - var index = this._clients.indexOf(client); - if (index !== -1) { - this._clients.splice(index, 1); - client.setZIndex(""); - client.onHide(); - if (this._clients.length === 0) { - _LightDismissService.hidden(this); - } else { - _LightDismissService.updated(this); - this._activateTopFocusableClientIfNeeded(); - } - } - }, - - keyDown: function _LightDismissableLayer_keyDown(client /*: ILightDismissable */, eventObject) { - _LightDismissService.keyDown(this, eventObject); - }, - keyUp: function _LightDismissableLayer_keyUp(client /*: ILightDismissable */, eventObject) { - _LightDismissService.keyUp(this, eventObject); - }, - keyPress: function _LightDismissableLayer_keyPress(client /*: ILightDismissable */, eventObject) { - _LightDismissService.keyPress(this, eventObject); - }, - - // Used by tests. - clients: { - get: function _LightDismissableLayer_clients_get() { - return this._clients; - } - }, - - _clientForElement: function _LightDismissableLayer_clientForElement(element) { - for (var i = this._clients.length - 1; i >= 0; i--) { - if (this._clients[i].containsElement(element)) { - return this._clients[i]; - } - } - return null; - }, - - _focusableClientForElement: function _LightDismissableLayer_focusableClientForElement(element) { - for (var i = this._clients.length - 1; i >= 0; i--) { - if (this._clients[i]._focusable && this._clients[i].containsElement(element)) { - return this._clients[i]; - } - } - return null; - }, - - _getTopmostFocusableClient: function _LightDismissableLayer_getTopmostFocusableClient() { - for (var i = this._clients.length - 1; i >= 0; i--) { - var client = this._clients[i]; - if (client && client._focusable) { - return client; - } - } - return null; - }, - - _activateTopFocusableClientIfNeeded: function _LightDismissableLayer_activateTopFocusableClientIfNeeded() { - var topClient = this._getTopmostFocusableClient(); - if (topClient && _LightDismissService.isTopmost(this)) { - // If the last input type was keyboard, use focus() so a keyboard focus visual is drawn. - // Otherwise, use setActive() so no focus visual is drawn. - var useSetActive = !_KeyboardBehavior._keyboardSeenLast; - topClient.onTakeFocus(useSetActive); - } - }, - - // ILightDismissable - // - - setZIndex: function _LightDismissableLayer_setZIndex(zIndex) { - this._clients.forEach(function (client, index) { - client.setZIndex(zIndex + index); - }, this); - }, - getZIndexCount: function _LightDismissableLayer_getZIndexCount() { - return this._clients.length; - }, - containsElement: function _LightDismissableLayer_containsElement(element) { - return !!this._clientForElement(element); - }, - onTakeFocus: function _LightDismissableLayer_onTakeFocus(useSetActive) { - // Prefer the client that has focus - var client = this._focusableClientForElement(_Global.document.activeElement); - - if (!client && this._clients.indexOf(this._currentlyFocusedClient) !== -1 && this._currentlyFocusedClient._focusable) { - // Next try the client that had focus most recently - client = this._currentlyFocusedClient; - } - - if (!client) { - // Finally try the client at the top of the stack - client = this._getTopmostFocusableClient(); - } - - this._currentlyFocusedClient = client; - client && client.onTakeFocus(useSetActive); - }, - onFocus: function _LightDismissableLayer_onFocus(element) { - this._currentlyFocusedClient = this._clientForElement(element); - this._currentlyFocusedClient && this._currentlyFocusedClient.onFocus(element); - }, - onShow: function _LightDismissableLayer_onShow(service /*: ILightDismissService */) { }, - onHide: function _LightDismissableLayer_onHide() { - this._currentlyFocusedClient = null; - }, - onKeyInStack: function _LightDismissableLayer_onKeyInStack(info /*: IKeyboardInfo*/) { - // A keyboard event occurred in the light dismiss stack. Notify the flyouts to - // give them the opportunity to handle this evnet. - var index = this._clients.indexOf(this._currentlyFocusedClient); - if (index !== -1) { - var clients = this._clients.slice(0, index + 1); - for (var i = clients.length - 1; i >= 0 && !info.propagationStopped; i--) { - if (clients[i]._focusable) { - clients[i].onKeyInStack(info); - } - } - } - }, - onShouldLightDismiss: function _LightDismissableLayer_onShouldLightDismiss(info) { - return _LightDismissService.DismissalPolicies.light(info); - }, - onLightDismiss: function _LightDismissableLayer_onLightDismiss(info) { - this._onLightDismiss(info); - } - }); - - // Singleton class for managing cascading flyouts - var _CascadeManager = _Base.Class.define(function _CascadeManager_ctor() { - var that = this; - this._dismissableLayer = new _LightDismissableLayer(function _CascadeManager_onLightDismiss(info) { - if (info.reason === _LightDismissService.LightDismissalReasons.escape) { - that.collapseFlyout(that.getAt(that.length - 1)); - } else { - that.collapseAll(); - } - }); - this._cascadingStack = []; - this._handleKeyDownInCascade_bound = this._handleKeyDownInCascade.bind(this); - this._inputType = null; - }, - { - appendFlyout: function _CascadeManager_appendFlyout(flyoutToAdd) { - // PRECONDITION: flyoutToAdd must not already be in the cascade. - _Log.log && this.indexOf(flyoutToAdd) >= 0 && _Log.log('_CascadeManager is attempting to append a Flyout that is already in the cascade.', "winjs _CascadeManager", "error"); - // PRECONDITION: this.reentrancyLock must be false. appendFlyout should only be called from baseFlyoutShow() which is the function responsible for preventing reentrancy. - _Log.log && this.reentrancyLock && _Log.log('_CascadeManager is attempting to append a Flyout through reentrancy.', "winjs _CascadeManager", "error"); - - // IF the anchor element for flyoutToAdd is contained within another flyout, - // && that flyout is currently in the cascadingStack, consider that flyout to be the parent of flyoutToAdd: - // Remove from the cascadingStack, any subflyout descendants of the parent flyout. - // ELSE flyoutToAdd isn't anchored to any of the Flyouts in the existing cascade - // Collapse the entire cascadingStack to start a new cascade. - // FINALLY: - // add flyoutToAdd to the end of the cascading stack. Monitor it for events. - var indexOfParentFlyout = this.indexOfElement(flyoutToAdd._currentAnchor); - if (indexOfParentFlyout >= 0) { - this.collapseFlyout(this.getAt(indexOfParentFlyout + 1)); - } else { - this.collapseAll(); - } - - flyoutToAdd.element.addEventListener("keydown", this._handleKeyDownInCascade_bound, false); - this._cascadingStack.push(flyoutToAdd); - this._dismissableLayer.shown(flyoutToAdd._dismissable); - }, - collapseFlyout: function _CascadeManager_collapseFlyout(flyout) { - // Removes flyout param and its subflyout descendants from the _cascadingStack. - if (!this.reentrancyLock && flyout && this.indexOf(flyout) >= 0) { - this.reentrancyLock = true; - var signal = new _Signal(); - this.unlocked = signal.promise; - - var subFlyout; - while (this.length && flyout !== subFlyout) { - subFlyout = this._cascadingStack.pop(); - subFlyout.element.removeEventListener("keydown", this._handleKeyDownInCascade_bound, false); - subFlyout._hide(); // We use the reentrancyLock to prevent reentrancy here. - } - - if (this._cascadingStack.length === 0) { - // The cascade is empty so clear the input type. This gives us the opportunity - // to recalculate the input type when the next cascade starts. - this._inputType = null; - } - - this.reentrancyLock = false; - this.unlocked = null; - signal.complete(); - } - }, - flyoutHiding: function _CascadeManager_flyoutHiding(flyout) { - this._dismissableLayer.hiding(flyout._dismissable); - }, - flyoutHidden: function _CascadeManager_flyoutHidden(flyout) { - this._dismissableLayer.hidden(flyout._dismissable); - }, - collapseAll: function _CascadeManager_collapseAll() { - // Empties the _cascadingStack and hides all flyouts. - var headFlyout = this.getAt(0); - if (headFlyout) { - this.collapseFlyout(headFlyout); - } - }, - indexOf: function _CascadeManager_indexOf(flyout) { - return this._cascadingStack.indexOf(flyout); - }, - indexOfElement: function _CascadeManager_indexOfElement(el) { - // Returns an index cooresponding to the Flyout in the cascade whose element contains the element in question. - // Returns -1 if the element is not contained by any Flyouts in the cascade. - var indexOfAssociatedFlyout = -1; - for (var i = 0, len = this.length; i < len; i++) { - var currentFlyout = this.getAt(i); - if (currentFlyout.element.contains(el)) { - indexOfAssociatedFlyout = i; - break; - } - } - return indexOfAssociatedFlyout; - }, - length: { - get: function _CascadeManager_getLength() { - return this._cascadingStack.length; - } - }, - getAt: function _CascadeManager_getAt(index) { - return this._cascadingStack[index]; - }, - handleFocusIntoFlyout: function _CascadeManager_handleFocusIntoFlyout(event) { - // When a flyout in the cascade recieves focus, we close all subflyouts beneath it. - var index = this.indexOfElement(event.target); - if (index >= 0) { - var subFlyout = this.getAt(index + 1); - this.collapseFlyout(subFlyout); - } - }, - // Compute the input type that is associated with the cascading stack on demand. Allows - // each Flyout in the cascade to adjust its sizing based on the current input type - // and to do it in a way that is consistent with the rest of the Flyouts in the cascade. - inputType: { - get: function _CascadeManager_inputType_get() { - if (!this._inputType) { - this._inputType = _KeyboardBehavior._lastInputType; - } - return this._inputType; - } - }, - // Used by tests. - dismissableLayer: { - get: function _CascadeManager_dismissableLayer_get() { - return this._dismissableLayer; - } - }, - _handleKeyDownInCascade: function _CascadeManager_handleKeyDownInCascade(event) { - var rtl = _Global.getComputedStyle(event.target).direction === "rtl", - leftKey = rtl ? Key.rightArrow : Key.leftArrow, - target = event.target; - - if (event.keyCode === leftKey) { - // Left key press in a SubFlyout will close that subFlyout and any subFlyouts cascading from it. - var index = this.indexOfElement(target); - if (index >= 1) { - var subFlyout = this.getAt(index); - this.collapseFlyout(subFlyout); - // Prevent document scrolling - event.preventDefault(); - } - } else if (event.keyCode === Key.alt || event.keyCode === Key.F10) { - this.collapseAll(); - } - } - }); - - var AnimationOffsets = { - top: { top: "50px", left: "0px", keyframe: "WinJS-showFlyoutTop" }, - bottom: { top: "-50px", left: "0px", keyframe: "WinJS-showFlyoutBottom" }, - left: { top: "0px", left: "50px", keyframe: "WinJS-showFlyoutLeft" }, - right: { top: "0px", left: "-50px", keyframe: "WinJS-showFlyoutRight" }, - }; - - var Flyout = _Base.Class.derive(_Overlay._Overlay, function Flyout_ctor(element, options) { - /// - /// - /// Creates a new Flyout control. - /// - /// - /// The DOM element that hosts the control. - /// - /// - /// The set of properties and values to apply to the new Flyout. - /// - /// The new Flyout control. - /// - /// - - // Simplify checking later - options = options || {}; - - // Make sure there's an input element - this._element = element || _Global.document.createElement("div"); - this._id = this._element.id || _ElementUtilities._uniqueID(this._element); - this._writeProfilerMark("constructor,StartTM"); - - this._baseFlyoutConstructor(this._element, options); - - var _elms = this._element.getElementsByTagName("*"); - var firstDiv = this._addFirstDiv(); - firstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(_elms); - var finalDiv = this._addFinalDiv(); - finalDiv.tabIndex = _ElementUtilities._getHighestTabIndexInList(_elms); - - // Handle "esc" & "tab" key presses - this._element.addEventListener("keydown", this._handleKeyDown, true); - - this._writeProfilerMark("constructor,StopTM"); - return this; - }, { - _lastMaxHeight: null, - - _baseFlyoutConstructor: function Flyout_baseFlyoutContstructor(element, options) { - // Flyout constructor - - // We have some options with defaults - this._placement = "auto"; - this._alignment = "center"; - - // Call the base overlay constructor helper - this._baseOverlayConstructor(element, options); - - // Start flyouts hidden - this._element.style.visibilty = "hidden"; - this._element.style.display = "none"; - - // Attach our css class - _ElementUtilities.addClass(this._element, _Constants.flyoutClass); - - var that = this; - // Each flyout has an ILightDismissable that is managed through the - // CascasdeManager rather than by the _LightDismissService directly. - this._dismissable = new _LightDismissService.LightDismissableElement({ - element: this._element, - tabIndex: this._element.hasAttribute("tabIndex") ? this._element.tabIndex : -1, - onLightDismiss: function () { - that.hide(); - }, - onTakeFocus: function (useSetActive) { - if (!that._dismissable.restoreFocus()) { - if (!_ElementUtilities.hasClass(that.element, _Constants.menuClass)) { - // Put focus on the first child in the Flyout - that._focusOnFirstFocusableElementOrThis(); - } else { - // Make sure the menu has focus, but don't show a focus rect - _Overlay._Overlay._trySetActive(that._element); - } - } - } - }); - - // Make sure we have an ARIA role - var role = this._element.getAttribute("role"); - if (role === null || role === "" || role === undefined) { - if (_ElementUtilities.hasClass(this._element, _Constants.menuClass)) { - this._element.setAttribute("role", "menu"); - } else { - this._element.setAttribute("role", "dialog"); - } - } - var label = this._element.getAttribute("aria-label"); - if (label === null || label === "" || label === undefined) { - this._element.setAttribute("aria-label", strings.ariaLabel); - } - - // Base animation is popIn, but our flyout has different arguments - this._currentAnimateIn = this._flyoutAnimateIn; - this._currentAnimateOut = this._flyoutAnimateOut; - - _ElementUtilities._addEventListener(this.element, "focusin", this._handleFocusIn.bind(this), false); - }, - - /// - /// Gets or sets the Flyout control's anchor. The anchor element is the HTML element which the Flyout originates from and is positioned relative to. - /// (This setting can be overridden when you call the show method.) - /// - /// - anchor: { - get: function () { - return this._anchor; - }, - set: function (value) { - this._anchor = value; - } - }, - - /// - /// Gets or sets the default placement of this Flyout. (This setting can be overridden when you call the show method.) - /// - /// - placement: { - get: function () { - return this._placement; - }, - set: function (value) { - if (value !== "top" && value !== "bottom" && value !== "left" && value !== "right" && value !== "auto" && value !== "autohorizontal" && value !== "autovertical") { - // Not a legal placement value - throw new _ErrorFromName("WinJS.UI.Flyout.BadPlacement", strings.badPlacement); - } - this._placement = value; - } - }, - - /// - /// Gets or sets the default alignment for this Flyout. (This setting can be overridden when you call the show method.) - /// - /// - alignment: { - get: function () { - return this._alignment; - }, - set: function (value) { - if (value !== "right" && value !== "left" && value !== "center") { - // Not a legal alignment value - throw new _ErrorFromName("WinJS.UI.Flyout.BadAlignment", strings.badAlignment); - } - this._alignment = value; - } - }, - - /// Disable a Flyout, setting or getting the HTML disabled attribute. When disabled the Flyout will no longer display with show(), and will hide if currently visible. - disabled: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return !!this._element.disabled; - }, - set: function (value) { - // Force this check into a boolean because our current state could be a bit confused since we tie to the DOM element - value = !!value; - var oldValue = !!this._element.disabled; - if (oldValue !== value) { - this._element.disabled = value; - if (!this.hidden && this._element.disabled) { - this.hide(); - } - } - } - }, - - /// - /// Occurs immediately before the control is shown. - /// - onbeforeshow: createEvent(_Overlay._Overlay.beforeShow), - - /// - /// Occurs immediately after the control is shown. - /// - onaftershow: createEvent(_Overlay._Overlay.afterShow), - - /// - /// Occurs immediately before the control is hidden. - /// - onbeforehide: createEvent(_Overlay._Overlay.beforeHide), - - /// - /// Occurs immediately after the control is hidden. - /// - onafterhide: createEvent(_Overlay._Overlay.afterHide), - - _dispose: function Flyout_dispose() { - _Dispose.disposeSubTree(this.element); - this._hide(); - Flyout._cascadeManager.flyoutHidden(this); - this.anchor = null; - }, - - show: function (anchor, placement, alignment) { - /// - /// - /// Shows the Flyout, if hidden, regardless of other states. - /// - /// - /// The DOM element, or ID of a DOM element to anchor the Flyout, overriding the anchor property for this time only. - /// - /// - /// The placement of the Flyout to the anchor: 'auto' (default), 'top', 'bottom', 'left', or 'right'. This parameter overrides the placement property for this show only. - /// - /// - /// For 'top' or 'bottom' placement, the alignment of the Flyout to the anchor's edge: 'center' (default), 'left', or 'right'. - /// This parameter overrides the alignment property for this show only. - /// - /// - /// - this._writeProfilerMark("show,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndShow(). - this._show(anchor, placement, alignment); - }, - - _show: function Flyout_show(anchor, placement, alignment) { - this._baseFlyoutShow(anchor, placement, alignment); - }, - - hide: function () { - /// - /// - /// Hides the Flyout, if visible, regardless of other states. - /// - /// - /// - // Just wrap the private one, turning off keyboard invoked flag - this._writeProfilerMark("hide,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndHide(). - this._hide(); - }, - - _hide: function Flyout_hide() { - - // First close all subflyout descendants in the cascade. - // Any calls to collapseFlyout through reentrancy should nop. - Flyout._cascadeManager.collapseFlyout(this); - - if (this._baseHide()) { - Flyout._cascadeManager.flyoutHiding(this); - } - }, - - _beforeEndHide: function Flyout_beforeEndHide() { - Flyout._cascadeManager.flyoutHidden(this); - }, - - _baseFlyoutShow: function Flyout_baseFlyoutShow(anchor, placement, alignment) { - if (this.disabled || this._disposed) { - // Don't do anything. - return; - } - - // Pick up defaults - if (!anchor) { - anchor = this._anchor; - } - if (!placement) { - placement = this._placement; - } - if (!alignment) { - alignment = this._alignment; - } - - // Dereference the anchor if necessary - if (typeof anchor === "string") { - anchor = _Global.document.getElementById(anchor); - } else if (anchor && anchor.element) { - anchor = anchor.element; - } - - // We expect an anchor - if (!anchor) { - // If we have _nextLeft, etc., then we were continuing an old animation, so that's OK - if (!this._reuseCurrent) { - throw new _ErrorFromName("WinJS.UI.Flyout.NoAnchor", strings.noAnchor); - } - // Last call was incomplete, so reuse the previous _current values. - this._reuseCurrent = null; - } else { - // Remember the anchor so that if we lose focus we can go back - this._currentAnchor = anchor; - // Remember current values - this._currentPlacement = placement; - this._currentAlignment = alignment; - } - - // If we're animating (eg baseShow is going to fail), or the cascadeManager is in the middle of a updating the cascade, - // then don't mess up our current state. - if (this._element.winAnimating) { - this._reuseCurrent = true; - // Queue us up to wait for the current animation to finish. - // _checkDoNext() is always scheduled after the current animation completes. - this._doNext = "show"; - } else if (Flyout._cascadeManager.reentrancyLock) { - this._reuseCurrent = true; - // Queue us up to wait for the current animation to finish. - // Schedule a call to _checkDoNext() for when the cascadeManager unlocks. - this._doNext = "show"; - var that = this; - Flyout._cascadeManager.unlocked.then(function () { that._checkDoNext(); }); - } else { - // We call our base _baseShow to handle the actual animation - if (this._baseShow()) { - // (_baseShow shouldn't ever fail because we tested winAnimating above). - if (!_ElementUtilities.hasClass(this.element, "win-menu")) { - // Verify that the firstDiv is in the correct location. - // Move it to the correct location or add it if not. - var _elms = this._element.getElementsByTagName("*"); - var firstDiv = this.element.querySelectorAll(".win-first"); - if (this.element.children.length && !_ElementUtilities.hasClass(this.element.children[0], _Constants.firstDivClass)) { - if (firstDiv && firstDiv.length > 0) { - firstDiv.item(0).parentNode.removeChild(firstDiv.item(0)); - } - - firstDiv = this._addFirstDiv(); - } - firstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(_elms); - - // Verify that the finalDiv is in the correct location. - // Move it to the correct location or add it if not. - var finalDiv = this.element.querySelectorAll(".win-final"); - if (!_ElementUtilities.hasClass(this.element.children[this.element.children.length - 1], _Constants.finalDivClass)) { - if (finalDiv && finalDiv.length > 0) { - finalDiv.item(0).parentNode.removeChild(finalDiv.item(0)); - } - - finalDiv = this._addFinalDiv(); - } - finalDiv.tabIndex = _ElementUtilities._getHighestTabIndexInList(_elms); - } - - Flyout._cascadeManager.appendFlyout(this); - } - } - }, - - _lightDismiss: function Flyout_lightDismiss() { - Flyout._cascadeManager.collapseAll(); - }, - - // Find our new flyout position. - _findPosition: function Flyout_findPosition() { - this._adjustedHeight = 0; - this._nextTop = 0; - this._nextLeft = 0; - this._keyboardMovedUs = false; - this._doesScroll = false; - - // Make sure menu commands display correctly - if (this._checkMenuCommands) { - this._checkMenuCommands(); - } - - // Remove old height restrictions and scrolling. - this._clearAdjustedStyles(); - - this._setAlignment(this._currentAlignment); - - // Set up the new position, and prep the offset for showPopup. - this._getTopLeft(); - - // Adjust position - if (this._nextTop < 0) { - // Overran bottom, attach to bottom. - this._element.style.bottom = _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset + "px"; - this._element.style.top = "auto"; - } else { - // Normal, set top - this._element.style.top = this._nextTop + "px"; - this._element.style.bottom = "auto"; - } - if (this._nextLeft < 0) { - // Overran right, attach to right - this._element.style.right = "0px"; - this._element.style.left = "auto"; - } else { - // Normal, set left - this._element.style.left = this._nextLeft + "px"; - this._element.style.right = "auto"; - } - - // Adjust height/scrollbar - if (this._doesScroll) { - _ElementUtilities.addClass(this._element, _Constants.scrollsClass); - this._lastMaxHeight = this._element.style.maxHeight; - this._element.style.maxHeight = this._adjustedHeight + "px"; - } - - // May need to adjust if the IHM is showing. - if (_Overlay._Overlay._keyboardInfo._visible) { - // Use keyboard logic - this._checkKeyboardFit(); - - if (this._keyboardMovedUs) { - this._adjustForKeyboard(); - } - } - }, - - // This determines our positioning. We have 8 modes, the 1st four are explicit, the last 4 are automatic: - // * top - position explicitly on the top of the anchor, shrinking and adding scrollbar as needed. - // * bottom - position explicitly below the anchor, shrinking and adding scrollbar as needed. - // * left - position left of the anchor, shrinking and adding a vertical scrollbar as needed. - // * right - position right of the anchor, shrinking and adding a vertical scroolbar as needed. - // * auto - Automatic placement. - // * autohorizontal - Automatic placement (only left or right). - // * autovertical - Automatic placement (only top or bottom). - // * _cascasde - Private placement used by MenuCommand._activateFlyoutCommand - // Auto tests the height of the anchor and the flyout. For consistency in orientation, we imagine - // that the anchor is placed in the vertical center of the display. If the flyout would fit above - // that centered anchor, then we will place the flyout vertically in relation to the anchor, otherwise - // placement will be horizontal. - // Vertical auto or autovertical placement will be positioned on top of the anchor if room, otherwise below the anchor. - // - this is because touch users would be more likely to obscure flyouts below the anchor. - // Horizontal auto or autohorizontal placement will be positioned to the left of the anchor if room, otherwise to the right. - // - this is because right handed users would be more likely to obscure a flyout on the right of the anchor. - // All three auto placements will add a vertical scrollbar if necessary. - // - _getTopLeft: function Flyout_getTopLeft() { - - var that = this; - - function configureVerticalWithScroll(anchor) { - // Won't fit top or bottom. Pick the one with the most space and add a scrollbar. - if (topHasMoreRoom(anchor)) { - // Top - that._adjustedHeight = spaceAbove(anchor) - that._verticalMarginBorderPadding; - that._nextTop = _Overlay._Overlay._keyboardInfo._visibleDocTop; - that._nextAnimOffset = AnimationOffsets.top; - } else { - // Bottom - that._adjustedHeight = spaceBelow(anchor) - that._verticalMarginBorderPadding; - that._nextTop = _Constants.pinToBottomEdge; - that._nextAnimOffset = AnimationOffsets.bottom; - } - that._doesScroll = true; - } - - // If the anchor is centered vertically, would the flyout fit above it? - function fitsVerticallyWithCenteredAnchor(anchor, flyout) { - // Returns true if the flyout would always fit at least top - // or bottom of its anchor, regardless of the position of the anchor, - // as long as the anchor never changed its height, nor did the height of - // the visualViewport change. - return ((_Overlay._Overlay._keyboardInfo._visibleDocHeight - anchor.height) / 2) >= flyout.totalHeight; - } - - function spaceAbove(anchor) { - return anchor.top - _Overlay._Overlay._keyboardInfo._visibleDocTop; - } - - function spaceBelow(anchor) { - return _Overlay._Overlay._keyboardInfo._visibleDocBottom - anchor.bottom; - } - - function topHasMoreRoom(anchor) { - return spaceAbove(anchor) > spaceBelow(anchor); - } - - // See if we can fit in various places, fitting in the main view, - // ignoring viewport changes, like for the IHM. - function fitTop(bottomConstraint, flyout) { - that._nextTop = bottomConstraint - flyout.totalHeight; - that._nextAnimOffset = AnimationOffsets.top; - return (that._nextTop >= _Overlay._Overlay._keyboardInfo._visibleDocTop && - that._nextTop + flyout.totalHeight <= _Overlay._Overlay._keyboardInfo._visibleDocBottom); - } - - function fitBottom(topConstraint, flyout) { - that._nextTop = topConstraint; - that._nextAnimOffset = AnimationOffsets.bottom; - return (that._nextTop >= _Overlay._Overlay._keyboardInfo._visibleDocTop && - that._nextTop + flyout.totalHeight <= _Overlay._Overlay._keyboardInfo._visibleDocBottom); - } - - function fitLeft(leftConstraint, flyout) { - that._nextLeft = leftConstraint - flyout.totalWidth; - that._nextAnimOffset = AnimationOffsets.left; - return (that._nextLeft >= 0 && that._nextLeft + flyout.totalWidth <= _Overlay._Overlay._keyboardInfo._visualViewportWidth); - } - - function fitRight(rightConstraint, flyout) { - that._nextLeft = rightConstraint; - that._nextAnimOffset = AnimationOffsets.right; - return (that._nextLeft >= 0 && that._nextLeft + flyout.totalWidth <= _Overlay._Overlay._keyboardInfo._visualViewportWidth); - } - - function centerVertically(anchor, flyout) { - that._nextTop = anchor.top + anchor.height / 2 - flyout.totalHeight / 2; - if (that._nextTop < _Overlay._Overlay._keyboardInfo._visibleDocTop) { - that._nextTop = _Overlay._Overlay._keyboardInfo._visibleDocTop; - } else if (that._nextTop + flyout.totalHeight >= _Overlay._Overlay._keyboardInfo._visibleDocBottom) { - // Flag to pin to bottom edge of visual document. - that._nextTop = _Constants.pinToBottomEdge; - } - } - - function alignHorizontally(anchor, flyout, alignment) { - if (alignment === "center") { - that._nextLeft = anchor.left + anchor.width / 2 - flyout.totalWidth / 2; - } else if (alignment === "left") { - that._nextLeft = anchor.left; - } else if (alignment === "right") { - that._nextLeft = anchor.right - flyout.totalWidth; - } else { - throw new _ErrorFromName("WinJS.UI.Flyout.BadAlignment", strings.badAlignment); - } - if (that._nextLeft < 0) { - that._nextLeft = 0; - } else if (that._nextLeft + flyout.totalWidth >= _Overlay._Overlay._keyboardInfo._visualViewportWidth) { - // Flag to pin to right edge of visible document. - that._nextLeft = _Constants.pinToRightEdge; - } - } - - var anchorRawRectangle, - flyout = {}, - anchor = {}; - - try { - anchorRawRectangle = this._currentAnchor.getBoundingClientRect(); - } - catch (e) { - throw new _ErrorFromName("WinJS.UI.Flyout.NoAnchor", strings.noAnchor); - } - - // Adjust for the anchor's margins. - anchor.top = anchorRawRectangle.top; - anchor.bottom = anchorRawRectangle.bottom; - anchor.left = anchorRawRectangle.left; - anchor.right = anchorRawRectangle.right; - anchor.height = anchor.bottom - anchor.top; - anchor.width = anchor.right - anchor.left; - - // Get our flyout and margins, note that getDimension calls - // window.getComputedStyle, which ensures layout is updated. - flyout.marginTop = getDimension(this._element, "marginTop"); - flyout.marginBottom = getDimension(this._element, "marginBottom"); - flyout.marginLeft = getDimension(this._element, "marginLeft"); - flyout.marginRight = getDimension(this._element, "marginRight"); - flyout.totalWidth = _ElementUtilities.getTotalWidth(this._element); - flyout.totalHeight = _ElementUtilities.getTotalHeight(this._element); - flyout.contentWidth = _ElementUtilities.getContentWidth(this._element); - flyout.contentHeight = _ElementUtilities.getContentHeight(this._element); - this._verticalMarginBorderPadding = (flyout.totalHeight - flyout.contentHeight); - this._adjustedHeight = flyout.contentHeight; - - // Check fit for requested this._currentPlacement, doing fallback if necessary - switch (this._currentPlacement) { - case "top": - if (!fitTop(anchor.top, flyout)) { - // Didn't fit, needs scrollbar - this._nextTop = _Overlay._Overlay._keyboardInfo._visibleDocTop; - this._doesScroll = true; - this._adjustedHeight = spaceAbove(anchor) - this._verticalMarginBorderPadding; - } - alignHorizontally(anchor, flyout, this._currentAlignment); - break; - case "bottom": - if (!fitBottom(anchor.bottom, flyout)) { - // Didn't fit, needs scrollbar - this._nextTop = _Constants.pinToBottomEdge; - this._doesScroll = true; - this._adjustedHeight = spaceBelow(anchor) - this._verticalMarginBorderPadding; - } - alignHorizontally(anchor, flyout, this._currentAlignment); - break; - case "left": - if (!fitLeft(anchor.left, flyout)) { - // Didn't fit, just shove it to edge - this._nextLeft = 0; - } - centerVertically(anchor, flyout); - break; - case "right": - if (!fitRight(anchor.right, flyout)) { - // Didn't fit, just shove it to edge - this._nextLeft = _Constants.pinToRightEdge; - } - centerVertically(anchor, flyout); - break; - case "autovertical": - if (!fitTop(anchor.top, flyout)) { - // Didn't fit above (preferred), so go below. - if (!fitBottom(anchor.bottom, flyout)) { - // Didn't fit, needs scrollbar - configureVerticalWithScroll(anchor); - } - } - alignHorizontally(anchor, flyout, this._currentAlignment); - break; - case "autohorizontal": - if (!fitLeft(anchor.left, flyout)) { - // Didn't fit left (preferred), so go right. - if (!fitRight(anchor.right, flyout)) { - // Didn't fit,just shove it to edge - this._nextLeft = _Constants.pinToRightEdge; - } - } - centerVertically(anchor, flyout); - break; - case "auto": - // Auto, if the anchor was in the vertical center of the display would we fit above it? - if (fitsVerticallyWithCenteredAnchor(anchor, flyout)) { - // It will fit above or below the anchor - if (!fitTop(anchor.top, flyout)) { - // Didn't fit above (preferred), so go below. - fitBottom(anchor.bottom, flyout); - } - alignHorizontally(anchor, flyout, this._currentAlignment); - } else { - // Won't fit above or below, try a side - if (!fitLeft(anchor.left, flyout) && - !fitRight(anchor.right, flyout)) { - // Didn't fit left or right either - configureVerticalWithScroll(anchor); - alignHorizontally(anchor, flyout, this._currentAlignment); - } else { - centerVertically(anchor, flyout); - } - } - break; - case "_cascade": - // Align vertically - // PREFERRED: When there is enough room to align a subMenu to either the top or the bottom of its - // anchor element, the subMenu prefers to be top aligned. - // FALLBACK: When there is enough room to bottom align a subMenu but not enough room to top align it, - // then the subMenu will align to the bottom of its anchor element. - // LASTRESORT: When there is not enough room to top align or bottom align the subMenu to its anchor, - // then the subMenu will be center aligned to it's anchor's vertical midpoint. - if (!fitBottom(anchor.top - flyout.marginTop, flyout) && !fitTop(anchor.bottom + flyout.marginBottom, flyout)) { - centerVertically(anchor, flyout); - } - // Determine horizontal direction - // PREFERRED: When there is enough room to fit a subMenu on either side of the anchor, - // the subMenu prefers to go on the right hand side. - // FALLBACK: When there is only enough room to fit a subMenu on the left side of the anchor, - // the subMenu is placed to the left of the parent menu. - // LASTRESORT: When there is not enough room to fit a subMenu on either side of the anchor, - // the subMenu is pinned to the right edge of the window. - var rtl = _Global.getComputedStyle(this._element).direction === "rtl"; - - // Cascading Menus should overlap their ancestor menu by 4 pixels and we have a unit test to - // verify that behavior. Because we don't have access to the ancestor flyout we need to specify - // the overlap in terms of our anchor element. There is a 1px border around the menu that - // contains our anchor we need to overlap our anchor by 3px to ensure that we overlap the containing - // Menu by 4px. - var pixelsToOverlapAnchor = 3; - - var beginRight = anchor.right - flyout.marginLeft - pixelsToOverlapAnchor; - var beginLeft = anchor.left + flyout.marginRight + pixelsToOverlapAnchor; - - if (rtl) { - if (!fitLeft(beginLeft, flyout) && !fitRight(beginRight, flyout)) { - // Doesn't fit on either side, pin to the left edge. - that._nextLeft = 0; - that._nextAnimOffset = AnimationOffsets.left; - } - } else { - if (!fitRight(beginRight, flyout) && !fitLeft(beginLeft, flyout)) { - // Doesn't fit on either side, pin to the right edge of the visible document. - that._nextLeft = _Constants.pinToRightEdge; - that._nextAnimOffset = AnimationOffsets.right; - } - } - - break; - default: - // Not a legal this._currentPlacement value - throw new _ErrorFromName("WinJS.UI.Flyout.BadPlacement", strings.badPlacement); - } - }, - - _clearAdjustedStyles: function Flyout_clearAdjustedStyles() { - // Move to 0,0 in case it is off screen, so that it lays out at a reasonable size - this._element.style.top = "0px"; - this._element.style.bottom = "auto"; - this._element.style.left = "0px"; - this._element.style.right = "auto"; - - // Clear height restrictons and scrollbar class - _ElementUtilities.removeClass(this._element, _Constants.scrollsClass); - if (this._lastMaxHeight !== null) { - this._element.style.maxHeight = this._lastMaxHeight; - this._lastMaxHeight = null; - } - - // Clear Alignment - _ElementUtilities.removeClass(this._element, "win-rightalign"); - _ElementUtilities.removeClass(this._element, "win-leftalign"); - }, - - _setAlignment: function Flyout_setAlignment(alignment) { - // Alignment - switch (alignment) { - case "left": - _ElementUtilities.addClass(this._element, "win-leftalign"); - break; - case "right": - _ElementUtilities.addClass(this._element, "win-rightalign"); - break; - case "center": - case "none": - break; - } - }, - - _showingKeyboard: function Flyout_showingKeyboard(event) { - if (this.hidden) { - return; - } - - // The only way that we can be showing a keyboard when a flyout is up is because the input was - // in the flyout itself, in which case we'll be moving ourselves. There is no practical way - // for the application to override this as the focused element is in our flyout. - event.ensuredFocusedElementInView = true; - - // See if the keyboard is going to force us to move - this._checkKeyboardFit(); - - if (this._keyboardMovedUs) { - // Pop out immediately, then move to new spot - this._element.style.opacity = 0; - var that = this; - _Global.setTimeout(function () { that._adjustForKeyboard(); that._baseAnimateIn(); }, _Overlay._Overlay._keyboardInfo._animationShowLength); - } - }, - - _resize: function Flyout_resize() { - // If hidden and not busy animating, then nothing to do - if (!this.hidden || this._animating) { - - // This should only happen if the IHM is dismissing, - // the only other way is for viewstate changes, which - // would dismiss any flyout. - if (this._needToHandleHidingKeyboard) { - // Hiding keyboard, update our position, giving the anchor a chance to update first. - var that = this; - _BaseUtils._setImmediate(function () { - if (!that.hidden || that._animating) { - that._findPosition(); - } - }); - this._needToHandleHidingKeyboard = false; - } - } - }, - - // If you were not pinned to the bottom, you might have to be now. - _checkKeyboardFit: function Flyout_checkKeyboardFit() { - // Special Flyout positioning rules to determine if the Flyout needs to adjust its - // position because of the IHM. If the Flyout needs to adjust for the IHM, it will reposition - // itself to be pinned to either the top or bottom edge of the visual viewport. - // - Too Tall, above top, or below bottom. - - var keyboardMovedUs = false; - var viewportHeight = _Overlay._Overlay._keyboardInfo._visibleDocHeight; - var adjustedMarginBoxHeight = this._adjustedHeight + this._verticalMarginBorderPadding; - if (adjustedMarginBoxHeight > viewportHeight) { - // The Flyout is now too tall to fit in the viewport, pin to top and adjust height. - keyboardMovedUs = true; - this._nextTop = _Constants.pinToBottomEdge; - this._adjustedHeight = viewportHeight - this._verticalMarginBorderPadding; - this._doesScroll = true; - } else if (this._nextTop >= 0 && - this._nextTop + adjustedMarginBoxHeight > _Overlay._Overlay._keyboardInfo._visibleDocBottom) { - // Flyout clips the bottom of the viewport. Pin to bottom. - this._nextTop = _Constants.pinToBottomEdge; - keyboardMovedUs = true; - } else if (this._nextTop === _Constants.pinToBottomEdge) { - // We were already pinned to the bottom, so our position on screen will change - keyboardMovedUs = true; - } - - // Signals use of basic fadein animation - this._keyboardMovedUs = keyboardMovedUs; - }, - - _adjustForKeyboard: function Flyout_adjustForKeyboard() { - // Keyboard moved us, update our metrics as needed - if (this._doesScroll) { - // Add scrollbar if we didn't already have scrollsClass - if (!this._lastMaxHeight) { - _ElementUtilities.addClass(this._element, _Constants.scrollsClass); - this._lastMaxHeight = this._element.style.maxHeight; - } - // Adjust height - this._element.style.maxHeight = this._adjustedHeight + "px"; - } - - // Update top/bottom - this._checkScrollPosition(true); - }, - - _hidingKeyboard: function Flyout_hidingKeyboard() { - // If we aren't visible and not animating, or haven't been repositioned, then nothing to do - // We don't know if the keyboard moved the anchor, so _keyboardMovedUs doesn't help here - if (!this.hidden || this._animating) { - - // Snap to the final position - // We'll either just reveal the current space or resize the window - if (_Overlay._Overlay._keyboardInfo._isResized) { - // Flag resize that we'll need an updated position - this._needToHandleHidingKeyboard = true; - } else { - // Not resized, update our final position, giving the anchor a chance to update first. - var that = this; - _BaseUtils._setImmediate(function () { - if (!that.hidden || that._animating) { - that._findPosition(); - } - }); - } - } - }, - - _checkScrollPosition: function Flyout_checkScrollPosition(showing) { - if (this.hidden && !showing) { - return; - } - - // May need to adjust top by viewport offset - if (this._nextTop < 0) { - // Need to attach to bottom - this._element.style.bottom = _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset + "px"; - this._element.style.top = "auto"; - } else { - // Normal, attach to top - this._element.style.top = this._nextTop + "px"; - this._element.style.bottom = "auto"; - } - }, - - // AppBar flyout animations - _flyoutAnimateIn: function Flyout_flyoutAnimateIn() { - if (this._keyboardMovedUs) { - return this._baseAnimateIn(); - } else { - this._element.style.opacity = 1; - this._element.style.visibility = "visible"; - return Animations.showPopup(this._element, this._nextAnimOffset); - } - }, - - _flyoutAnimateOut: function Flyout_flyoutAnimateOut() { - if (this._keyboardMovedUs) { - return this._baseAnimateOut(); - } else { - this._element.style.opacity = 0; - return Animations.hidePopup(this._element, this._nextAnimOffset); - } - }, - - // Hide all other flyouts besides this one - _hideAllOtherFlyouts: function Flyout_hideAllOtherFlyouts(thisFlyout) { - var flyouts = _Global.document.querySelectorAll("." + _Constants.flyoutClass); - for (var i = 0; i < flyouts.length; i++) { - var flyoutControl = flyouts[i].winControl; - if (flyoutControl && !flyoutControl.hidden && (flyoutControl !== thisFlyout)) { - flyoutControl.hide(); - } - } - }, - - _handleKeyDown: function Flyout_handleKeyDown(event) { - if ((event.keyCode === Key.space || event.keyCode === Key.enter) - && (this === _Global.document.activeElement)) { - event.preventDefault(); - event.stopPropagation(); - this.winControl.hide(); - } else if (event.shiftKey && event.keyCode === Key.tab - && this === _Global.document.activeElement - && !event.altKey && !event.ctrlKey && !event.metaKey) { - event.preventDefault(); - event.stopPropagation(); - this.winControl._focusOnLastFocusableElementOrThis(); - } - }, - - _handleFocusIn: function Flyout_handleFocusIn(event) { - if (!this.element.contains(event.relatedTarget)) { - Flyout._cascadeManager.handleFocusIntoFlyout(event); - } - // Else focus is only moving between elements in the flyout. - // Doesn't need to be handled by cascadeManager. - }, - - // Create and add a new first div as the first child - _addFirstDiv: function Flyout_addFirstDiv() { - var firstDiv = _Global.document.createElement("div"); - firstDiv.className = _Constants.firstDivClass; - firstDiv.style.display = "inline"; - firstDiv.setAttribute("role", "menuitem"); - firstDiv.setAttribute("aria-hidden", "true"); - - // add to beginning - if (this._element.children[0]) { - this._element.insertBefore(firstDiv, this._element.children[0]); - } else { - this._element.appendChild(firstDiv); - } - - var that = this; - _ElementUtilities._addEventListener(firstDiv, "focusin", function () { that._focusOnLastFocusableElementOrThis(); }, false); - - return firstDiv; - }, - - // Create and add a new final div as the last child - _addFinalDiv: function Flyout_addFinalDiv() { - var finalDiv = _Global.document.createElement("div"); - finalDiv.className = _Constants.finalDivClass; - finalDiv.style.display = "inline"; - finalDiv.setAttribute("role", "menuitem"); - finalDiv.setAttribute("aria-hidden", "true"); - - this._element.appendChild(finalDiv); - var that = this; - _ElementUtilities._addEventListener(finalDiv, "focusin", function () { that._focusOnFirstFocusableElementOrThis(); }, false); - - return finalDiv; - }, - - _writeProfilerMark: function Flyout_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI.Flyout:" + this._id + ":" + text); - } - }, - { - _cascadeManager: new _CascadeManager(), - }); - return Flyout; - }) - }); - -}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/CommandingSurface/_Constants',["require", "exports"], function (require, exports) { - // CommandingSurface class names - exports.ClassNames = { - controlCssClass: "win-commandingsurface", - disposableCssClass: "win-disposable", - actionAreaCssClass: "win-commandingsurface-actionarea", - actionAreaContainerCssClass: "win-commandingsurface-actionareacontainer", - overflowButtonCssClass: "win-commandingsurface-overflowbutton", - spacerCssClass: "win-commandingsurface-spacer", - ellipsisCssClass: "win-commandingsurface-ellipsis", - overflowAreaCssClass: "win-commandingsurface-overflowarea", - overflowAreaContainerCssClass: "win-commandingsurface-overflowareacontainer", - contentFlyoutCssClass: "win-commandingsurface-contentflyout", - emptyCommandingSurfaceCssClass: "win-commandingsurface-empty", - menuCssClass: "win-menu", - menuContainsToggleCommandClass: "win-menu-containstogglecommand", - openedClass: "win-commandingsurface-opened", - closingClass: "win-commandingsurface-closing", - closedClass: "win-commandingsurface-closed", - noneClass: "win-commandingsurface-closeddisplaynone", - minimalClass: "win-commandingsurface-closeddisplayminimal", - compactClass: "win-commandingsurface-closeddisplaycompact", - fullClass: "win-commandingsurface-closeddisplayfull", - overflowTopClass: "win-commandingsurface-overflowtop", - overflowBottomClass: "win-commandingsurface-overflowbottom", - }; - exports.EventNames = { - beforeOpen: "beforeopen", - afterOpen: "afteropen", - beforeClose: "beforeclose", - afterClose: "afterclose", - commandPropertyMutated: "_commandpropertymutated", - }; - exports.actionAreaCommandWidth = 68; - exports.actionAreaSeparatorWidth = 34; - exports.actionAreaOverflowButtonWidth = 32; - exports.overflowCommandHeight = 44; - exports.overflowSeparatorHeight = 12; - exports.controlMinWidth = exports.actionAreaOverflowButtonWidth; - exports.overflowAreaMaxWidth = 480; - exports.heightOfMinimal = 24; - exports.heightOfCompact = 48; - exports.contentMenuCommandDefaultLabel = "Custom content"; - exports.defaultClosedDisplayMode = "compact"; - exports.defaultOpened = false; - exports.defaultOverflowDirection = "bottom"; - // Constants for commands - exports.typeSeparator = "separator"; - exports.typeContent = "content"; - exports.typeButton = "button"; - exports.typeToggle = "toggle"; - exports.typeFlyout = "flyout"; - exports.commandSelector = ".win-command"; - exports.primaryCommandSection = "primary"; - exports.secondaryCommandSection = "secondary"; -}); - -define('WinJS/Controls/ToolBar/_Constants',["require", "exports", "../CommandingSurface/_Constants"], function (require, exports, _CommandingSurfaceConstants) { - // toolbar class names - exports.ClassNames = { - controlCssClass: "win-toolbar", - disposableCssClass: "win-disposable", - actionAreaCssClass: "win-toolbar-actionarea", - overflowButtonCssClass: "win-toolbar-overflowbutton", - spacerCssClass: "win-toolbar-spacer", - ellipsisCssClass: "win-toolbar-ellipsis", - overflowAreaCssClass: "win-toolbar-overflowarea", - contentFlyoutCssClass: "win-toolbar-contentflyout", - emptytoolbarCssClass: "win-toolbar-empty", - menuCssClass: "win-menu", - menuContainsToggleCommandClass: "win-menu-containstogglecommand", - openedClass: "win-toolbar-opened", - closedClass: "win-toolbar-closed", - compactClass: "win-toolbar-closeddisplaycompact", - fullClass: "win-toolbar-closeddisplayfull", - overflowTopClass: "win-toolbar-overflowtop", - overflowBottomClass: "win-toolbar-overflowbottom", - placeHolderCssClass: "win-toolbar-placeholder", - }; - exports.EventNames = { - beforeOpen: "beforeopen", - afterOpen: "afteropen", - beforeClose: "beforeclose", - afterClose: "afterclose" - }; - exports.OverflowDirection = { - top: "top", - bottom: "bottom", - }; - exports.overflowAreaMaxWidth = _CommandingSurfaceConstants.overflowAreaMaxWidth; - exports.controlMinWidth = _CommandingSurfaceConstants.controlMinWidth; - exports.defaultClosedDisplayMode = "compact"; - exports.defaultOpened = false; - // Constants for commands - exports.typeSeparator = "separator"; - exports.typeContent = "content"; - exports.typeButton = "button"; - exports.typeToggle = "toggle"; - exports.typeFlyout = "flyout"; - exports.commandSelector = ".win-command"; - exports.primaryCommandSection = "primary"; - exports.secondaryCommandSection = "secondary"; -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -// Glyph Enumeration -/// Segoe -define('WinJS/Controls/AppBar/_Icon',[ - 'exports', - '../../Core/_Base', - '../../Core/_Resources' - ], function appBarIconInit(exports, _Base, _Resources) { - "use strict"; - - var glyphs = ["previous", - "next", - "play", - "pause", - "edit", - "save", - "clear", - "delete", - "remove", - "add", - "cancel", - "accept", - "more", - "redo", - "undo", - "home", - "up", - "forward", - "right", - "back", - "left", - "favorite", - "camera", - "settings", - "video", - "sync", - "download", - "mail", - "find", - "help", - "upload", - "emoji", - "twopage", - "leavechat", - "mailforward", - "clock", - "send", - "crop", - "rotatecamera", - "people", - "closepane", - "openpane", - "world", - "flag", - "previewlink", - "globe", - "trim", - "attachcamera", - "zoomin", - "bookmarks", - "document", - "protecteddocument", - "page", - "bullets", - "comment", - "mail2", - "contactinfo", - "hangup", - "viewall", - "mappin", - "phone", - "videochat", - "switch", - "contact", - "rename", - "pin", - "musicinfo", - "go", - "keyboard", - "dockleft", - "dockright", - "dockbottom", - "remote", - "refresh", - "rotate", - "shuffle", - "list", - "shop", - "selectall", - "orientation", - "import", - "importall", - "browsephotos", - "webcam", - "pictures", - "savelocal", - "caption", - "stop", - "showresults", - "volume", - "repair", - "message", - "page2", - "calendarday", - "calendarweek", - "calendar", - "characters", - "mailreplyall", - "read", - "link", - "accounts", - "showbcc", - "hidebcc", - "cut", - "attach", - "paste", - "filter", - "copy", - "emoji2", - "important", - "mailreply", - "slideshow", - "sort", - "manage", - "allapps", - "disconnectdrive", - "mapdrive", - "newwindow", - "openwith", - "contactpresence", - "priority", - "uploadskydrive", - "gototoday", - "font", - "fontcolor", - "contact2", - "folder", - "audio", - "placeholder", - "view", - "setlockscreen", - "settile", - "cc", - "stopslideshow", - "permissions", - "highlight", - "disableupdates", - "unfavorite", - "unpin", - "openlocal", - "mute", - "italic", - "underline", - "bold", - "movetofolder", - "likedislike", - "dislike", - "like", - "alignright", - "aligncenter", - "alignleft", - "zoom", - "zoomout", - "openfile", - "otheruser", - "admin", - "street", - "map", - "clearselection", - "fontdecrease", - "fontincrease", - "fontsize", - "cellphone", - "reshare", - "tag", - "repeatone", - "repeatall", - "outlinestar", - "solidstar", - "calculator", - "directions", - "target", - "library", - "phonebook", - "memo", - "microphone", - "postupdate", - "backtowindow", - "fullscreen", - "newfolder", - "calendarreply", - "unsyncfolder", - "reporthacked", - "syncfolder", - "blockcontact", - "switchapps", - "addfriend", - "touchpointer", - "gotostart", - "zerobars", - "onebar", - "twobars", - "threebars", - "fourbars", - "scan", - "preview", - "hamburger"]; - - // Provide properties to grab resources for each of the icons - /// - /// The AppBarIcon enumeration provides a set of glyphs for use with the AppBarCommand icon property. - /// - var icons = glyphs.reduce(function (fixedIcons, item) { - fixedIcons[item] = { get: function () { return _Resources._getWinJSString("ui/appBarIcons/" + item).value; } }; - return fixedIcons; - }, {}); - - _Base.Namespace._moduleDefine(exports, "WinJS.UI.AppBarIcon", icons); -}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -// AppBarCommand -/// appbar,appbars,Flyout,Flyouts,onclick,Statics -define('WinJS/Controls/AppBar/_Command',[ - 'exports', - '../../Core/_Global', - '../../Core/_WinRT', - '../../Core/_Base', - "../../Core/_BaseUtils", - '../../Core/_ErrorFromName', - "../../Core/_Events", - '../../Core/_Resources', - '../../Utilities/_Control', - '../../Utilities/_Dispose', - '../../Utilities/_ElementUtilities', - '../Flyout/_Overlay', - '../Tooltip', - '../_LegacyAppBar/_Constants', - './_Icon' -], function appBarCommandInit(exports, _Global, _WinRT, _Base, _BaseUtils, _ErrorFromName, _Events, _Resources, _Control, _Dispose, _ElementUtilities, _Overlay, Tooltip, _Constants, _Icon) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// - /// Represents a command to display in an AppBar. - /// - /// - /// - /// - /// ]]> - /// Raised after the hidden property has been programmatically changed. - /// The AppBarCommand control itself. - /// The AppBarCommand's icon box. - /// The AppBarCommand's icon's image formatting. - /// The AppBarCommand's label - /// - /// - AppBarCommand: _Base.Namespace._lazy(function () { - - function _handleClick(event) { - /*jshint validthis: true */ - var command = this.winControl; - if (command) { - if (command._type === _Constants.typeToggle) { - command.selected = !command.selected; - } else if (command._type === _Constants.typeFlyout && command._flyout) { - var flyout = command._flyout; - // Flyout may not have processAll'd, so this may be a DOM object - if (typeof flyout === "string") { - flyout = _Global.document.getElementById(flyout); - } - if (!flyout.show) { - flyout = flyout.winControl; - } - if (flyout && flyout.show) { - flyout.show(this, "autovertical"); - } - } - if (command.onclick) { - command.onclick(event); - } - } - } - - // Used by AppBarCommands to notify listeners that a property has changed. - var PropertyMutations = _Base.Class.define(function PropertyMutations_ctor() { - this._observer = _BaseUtils._merge({}, _Events.eventMixin); - }, { - bind: function (callback) { - this._observer.addEventListener(_Constants.commandPropertyMutated, callback); - }, - unbind: function (callback) { - this._observer.removeEventListener(_Constants.commandPropertyMutated, callback); - }, - dispatchEvent: function (type, detail) { - this._observer.dispatchEvent(type, detail); - }, - }); - - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/appBarCommandAriaLabel").value; }, - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get badClick() { return "Invalid argument: The onclick property for an {0} must be a function"; }, - get badDivElement() { return "Invalid argument: For a content command, the element must be null or a div element"; }, - get badHrElement() { return "Invalid argument: For a separator, the element must be null or an hr element"; }, - get badButtonElement() { return "Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"; }, - get badPriority() { return "Invalid argument: the priority of an {0} must be a non-negative integer"; } - }; - - var AppBarCommand = _Base.Class.define(function AppBarCommand_ctor(element, options) { - /// - /// - /// Creates a new AppBarCommand control. - /// - /// - /// The DOM element that will host the control. AppBarCommand will create one if null. - /// - /// - /// The set of properties and values to apply to the new AppBarCommand. - /// - /// - /// The new AppBarCommand control. - /// - /// - - // Check to make sure we weren't duplicated - if (element && element.winControl) { - throw new _ErrorFromName("WinJS.UI.AppBarCommand.DuplicateConstruction", strings.duplicateConstruction); - } - - this._disposed = false; - - // Don't blow up if they didn't pass options - if (!options) { - options = {}; - } - - // Need a type before we can create our element - if (!options.type) { - this._type = _Constants.typeButton; - } - - options.section = options.section || _Constants.sectionPrimary; - - // Go ahead and create it, separator and content types look different than buttons - // Don't forget to use passed in element if one was provided. - this._element = element; - - if (options.type === _Constants.typeContent) { - this._createContent(); - } else if (options.type === _Constants.typeSeparator) { - this._createSeparator(); - } else { - // This will also set the icon & label - this._createButton(); - } - _ElementUtilities.addClass(this._element, "win-disposable"); - - // Remember ourselves - this._element.winControl = this; - - // Attach our css class - _ElementUtilities.addClass(this._element, _Constants.appBarCommandClass); - - if (options.onclick) { - this.onclick = options.onclick; - } - // We want to handle some clicks - options.onclick = _handleClick; - - _Control.setOptions(this, options); - - if (this._type === _Constants.typeToggle && !options.selected) { - this.selected = false; - } - - // Set up pointerdown handler and clean up ARIA if needed - if (this._type !== _Constants.typeSeparator) { - - // Make sure we have an ARIA role - var role = this._element.getAttribute("role"); - if (role === null || role === "" || role === undefined) { - if (this._type === _Constants.typeToggle) { - role = "menuitemcheckbox"; - } else if (this._type === _Constants.typeContent) { - role = "group"; - } else { - role = "menuitem"; - } - this._element.setAttribute("role", role); - if (this._type === _Constants.typeFlyout) { - this._element.setAttribute("aria-haspopup", true); - } - } - // Label should've been set by label, but if it was missed for some reason: - var label = this._element.getAttribute("aria-label"); - if (label === null || label === "" || label === undefined) { - this._element.setAttribute("aria-label", strings.ariaLabel); - } - } - - this._propertyMutations = new PropertyMutations(); - var that = this; - ObservablePropertyWhiteList.forEach(function (propertyName) { - makeObservable(that, propertyName); - }); - }, { - /// - /// Gets or sets the ID of the AppBarCommand. - /// - id: { - get: function () { - return this._element.id; - }, - - set: function (value) { - // we allow setting first time only. otherwise we ignore it. - if (value && !this._element.id) { - this._element.id = value; - } - } - }, - - /// - /// Gets or sets the type of the AppBarCommand. Possible values are "button", "toggle", "flyout", "content" or "separator". - /// - type: { - get: function () { - return this._type; - }, - set: function (value) { - // we allow setting first time only. otherwise we ignore it. - if (!this._type) { - if (value !== _Constants.typeContent && value !== _Constants.typeFlyout && value !== _Constants.typeToggle && value !== _Constants.typeSeparator) { - this._type = _Constants.typeButton; - } else { - this._type = value; - } - } - } - }, - - /// - /// Gets or sets the label of the AppBarCommand. - /// - label: { - get: function () { - return this._label; - }, - set: function (value) { - this._label = value; - if (this._labelSpan) { - this._labelSpan.textContent = this.label; - } - - // Ensure that we have a tooltip, by updating already-constructed tooltips. Separators won't have these: - if (!this.tooltip && this._tooltipControl) { - this._tooltip = this.label; - this._tooltipControl.innerHTML = this.label; - } - - // Update aria-label - this._element.setAttribute("aria-label", this.label); - - // Check if we need to suppress the tooltip - this._testIdenticalTooltip(); - } - }, - - /// - /// Gets or sets the icon of the AppBarCommand. - /// - icon: { - get: function () { - return this._icon; - }, - set: function (value) { - - this._icon = _Icon[value] || value; - - if (this._imageSpan) { - // If the icon's a single character, presume a glyph - if (this._icon && this._icon.length === 1) { - // Set the glyph - this._imageSpan.textContent = this._icon; - this._imageSpan.style.backgroundImage = ""; - this._imageSpan.style.msHighContrastAdjust = ""; - _ElementUtilities.addClass(this._imageSpan, "win-commandglyph"); - } else { - // Must be an image, set that - this._imageSpan.textContent = ""; - this._imageSpan.style.backgroundImage = this._icon; - this._imageSpan.style.msHighContrastAdjust = "none"; - _ElementUtilities.removeClass(this._imageSpan, "win-commandglyph"); - } - } - } - }, - - /// - /// Gets or sets the function to invoke when the command is clicked. - /// - onclick: { - get: function () { - return this._onclick; - }, - set: function (value) { - if (value && typeof value !== "function") { - throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadClick", _Resources._formatString(strings.badClick, "AppBarCommand")); - } - this._onclick = value; - } - }, - - /// - /// Gets or sets the priority of the command - /// - priority: { - get: function () { - return this._priority; - }, - set: function (value) { - if (value === undefined || (typeof value === "number" && value >= 0)) { - this._priority = value; - } else { - throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadPriority", _Resources._formatString(strings.badPriority, "AppBarCommand")); - } - - } - }, - - /// - /// For flyout-type AppBarCommands, this property returns the WinJS.UI.Flyout that this command invokes. - /// When setting this property, you may also use the String ID of the flyout to invoke, the DOM object - /// for the flyout, or the WinJS.UI.Flyout object itself. - /// If the value is set to the String ID of the flyout to invoke, or the DOM object for the flyout, but this - /// has not been processed yet, the getter will return the DOM object until it is processed, and - /// subsequently return a flyout. - /// - flyout: { - get: function () { - // Resolve it to the flyout - var flyout = this._flyout; - if (typeof flyout === "string") { - flyout = _Global.document.getElementById(flyout); - } - // If it doesn't have a .element, then we need to getControl on it - if (flyout && !flyout.element && flyout.winControl) { - flyout = flyout.winControl; - } - - return flyout; - }, - set: function (value) { - // Need to update aria-owns with the new ID. - var id = value; - if (id && typeof id !== "string") { - // Our controls have .element properties - if (id.element) { - id = id.element; - } - // Hope it's a DOM element, get ID from DOM element - if (id) { - if (id.id) { - id = id.id; - } else { - // No id, have to fake one - id.id = _ElementUtilities._uniqueID(id); - id = id.id; - } - } - } - if (typeof id === "string") { - this._element.setAttribute("aria-owns", id); - } - - // Remember it - this._flyout = value; - } - }, - - /// - /// Gets or sets the section that the AppBarCommand is in. Possible values are "secondary" and "primary". - /// - section: { - get: function () { - return this._section; - }, - set: function (value) { - // we allow settings section only one time - if (!this._section || _WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { - this._setSection(value); - } - } - }, - - /// Gets or sets the tooltip text of the AppBarCommand. - tooltip: { - get: function () { - return this._tooltip; - }, - set: function (value) { - this._tooltip = value; - - // Update already-constructed tooltips. Separators and content commands won't have these: - if (this._tooltipControl) { - this._tooltipControl.innerHTML = this._tooltip; - } - - // Check if we need to suppress the tooltip - this._testIdenticalTooltip(); - } - }, - - /// Set or get the selected state of a toggle button. - selected: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return this._element.getAttribute("aria-checked") === "true"; - }, - set: function (value) { - this._element.setAttribute("aria-checked", value); - } - }, - - /// - element: { - get: function () { - return this._element; - } - }, - - /// - /// Gets or sets a value that indicates whether the AppBarCommand is disabled. A value of true disables the AppBarCommand, and a value of false enables it. - /// - disabled: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return !!this._element.disabled; - }, - set: function (value) { - this._element.disabled = value; - } - }, - - /// - hidden: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return this._element.style.visibility === "hidden"; - }, - set: function (value) { - if (value === this.hidden) { - // No changes to make. - return; - } - - var style = this._element.style; - var originalVisibility = style.visibility; - var originalDisplay = style.display; - - if (value) { - style.visibility = "hidden"; - style.display = "none"; - } else { - style.visibility = ""; - style.display = "inline-block"; - } - - if (!this._sendEvent(_Constants.commandVisibilityChanged)) { - style.visibility = originalVisibility; - style.display = originalDisplay; - } - } - }, - - /// - /// Gets or sets the HTMLElement within a "content" type AppBarCommand that should receive focus whenever focus moves via Home or the arrow keys, - /// from the previous AppBarCommand to the this AppBarCommand. Returns the AppBarCommand object's host element by default. - /// - firstElementFocus: { - get: function () { - return this._firstElementFocus || this._lastElementFocus || this._element; - }, - set: function (element) { - // Arguments of null and this.element should treated the same to ensure that this.element is never a tabstop when either focus property has been set. - this._firstElementFocus = (element === this.element) ? null : element; - this._updateTabStop(); - } - }, - - /// - /// Gets or sets the HTMLElement within a "content" type AppBarCommand that should receive focus whenever focus would move, via End or arrow keys, - /// from the next AppBarCommand to this AppBarCommand. Returns this AppBarCommand object's host element by default. - /// - lastElementFocus: { - get: function () { - return this._lastElementFocus || this._firstElementFocus || this._element; - }, - set: function (element) { - // Arguments of null and this.element should treated the same to ensure that this.element is never a tabstop when either focus property has been set. - this._lastElementFocus = (element === this.element) ? null : element; - this._updateTabStop(); - } - }, - - dispose: function () { - /// - /// - /// Disposes this control. - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - - if (this._tooltipControl) { - this._tooltipControl.dispose(); - } - - if (this._type === _Constants.typeContent) { - _Dispose.disposeSubTree(this.element); - } - }, - - addEventListener: function (type, listener, useCapture) { - /// - /// - /// Registers an event handler for the specified event. - /// - /// - /// Required. The name of the event to register. - /// - /// Required. The event handler function to associate with this event. - /// - /// Optional. Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. - /// - /// - return this._element.addEventListener(type, listener, useCapture); - }, - - removeEventListener: function (type, listener, useCapture) { - /// - /// - /// Removes an event handler that the addEventListener method registered. - /// - /// Required. The name of the event to remove. - /// Required. The event handler function to remove. - /// - /// Optional. Set to true to remove the capturing phase event handler; otherwise, set to false to remove the bubbling phase event handler. - /// - /// - return this._element.removeEventListener(type, listener, useCapture); - }, - - /// Adds an extra CSS class during construction. - extraClass: { - get: function () { - return this._extraClass; - }, - set: function (value) { - if (this._extraClass) { - _ElementUtilities.removeClass(this._element, this._extraClass); - } - this._extraClass = value; - _ElementUtilities.addClass(this._element, this._extraClass); - } - }, - - // Private - _testIdenticalTooltip: function AppBarCommand_testIdenticalToolTip() { - this._hideIfFullSize = (this._label === this._tooltip); - }, - - _createContent: function AppBarCommand_createContent() { - // Make sure there's an element - if (!this._element) { - this._element = _Global.document.createElement("div"); - } else { - // Verify the element was a div - if (this._element.tagName !== "DIV") { - throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadDivElement", strings.badDivElement); - } - } - - // If a tabIndex isnt set, default to 0; - if (parseInt(this._element.getAttribute("tabIndex"), 10) !== this._element.tabIndex) { - this._element.tabIndex = 0; - } - }, - - _createSeparator: function AppBarCommand_createSeparator() { - // Make sure there's an element - if (!this._element) { - this._element = _Global.document.createElement("hr"); - } else { - // Verify the element was an hr - if (this._element.tagName !== "HR") { - throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadHrElement", strings.badHrElement); - } - } - }, - - _createButton: function AppBarCommand_createButton() { - // Make sure there's an element - if (!this._element) { - this._element = _Global.document.createElement("button"); - } else { - // Verify the element was a button - if (this._element.tagName !== "BUTTON") { - throw new _ErrorFromName("WinJS.UI.AppBarCommand.BadButtonElement", strings.badButtonElement); - } - // Make sure it has a type="button" - var type = this._element.getAttribute("type"); - if (type === null || type === "" || type === undefined) { - this._element.setAttribute("type", "button"); - } - this._element.innerHTML = ""; - } - - // AppBarCommand buttons need to look like this: - //// - this._element.type = "button"; - this._iconSpan = _Global.document.createElement("span"); - this._iconSpan.setAttribute("aria-hidden", "true"); - this._iconSpan.className = "win-commandicon"; - this._iconSpan.tabIndex = -1; - this._element.appendChild(this._iconSpan); - this._imageSpan = _Global.document.createElement("span"); - this._imageSpan.setAttribute("aria-hidden", "true"); - this._imageSpan.className = "win-commandimage"; - this._imageSpan.tabIndex = -1; - this._iconSpan.appendChild(this._imageSpan); - this._labelSpan = _Global.document.createElement("span"); - this._labelSpan.setAttribute("aria-hidden", "true"); - this._labelSpan.className = "win-label"; - this._labelSpan.tabIndex = -1; - this._element.appendChild(this._labelSpan); - // 'win-global' or 'win-selection' are added later by caller. - // Label and icon are added later by caller. - - // Attach a tooltip - Note: we're going to stomp on it's setControl so we don't have to make another DOM element to hang it off of. - // This private _tooltipControl attribute is used by other pieces, changing the name could break them. - this._tooltipControl = new Tooltip.Tooltip(this._element); - var that = this; - this._tooltipControl.addEventListener("beforeopen", function () { - if (that._hideIfFullSize && !_Overlay._Overlay._getParentControlUsingClassName(that._element.parentElement, _Constants.reducedClass)) { - that._tooltipControl.close(); - } - }, false); - }, - - _setSection: function AppBarCommand_setSection(section) { - if (!section) { - section = _Constants.sectionPrimary; - } - - // _Constants.sectionSelection and _Constants.sectionGlobal are deprecated, so we will continue - // adding/removing its corresponding CSS class for app compat. - // _Constants.sectionPrimary and _Constants.sectionSecondary no longer apply CSS classes to the - // commands. - - if (this._section) { - // Remove the old section class - if (this._section === _Constants.sectionGlobal) { - _ElementUtilities.removeClass(this._element, _Constants.appBarCommandGlobalClass); - } else if (this.section === _Constants.sectionSelection) { - _ElementUtilities.removeClass(this._element, _Constants.appBarCommandSelectionClass); - } - } - // Add the new section class - this._section = section; - if (section === _Constants.sectionGlobal) { - _ElementUtilities.addClass(this._element, _Constants.appBarCommandGlobalClass); - } else if (section === _Constants.sectionSelection) { - _ElementUtilities.addClass(this._element, _Constants.appBarCommandSelectionClass); - } - }, - - _updateTabStop: function AppBarCommand_updateTabStop() { - // Whenever the firstElementFocus or lastElementFocus properties are set for content type AppBarCommands, - // the containing command element is no longer a tabstop. - - if (this._firstElementFocus || this._lastElementFocus) { - this.element.tabIndex = -1; - } else { - this.element.tabIndex = 0; - } - }, - - _isFocusable: function AppBarCommand_isFocusable() { - return (!this.hidden && this._type !== _Constants.typeSeparator && !this.element.disabled && - (this.firstElementFocus.tabIndex >= 0 || this.lastElementFocus.tabIndex >= 0)); - }, - - _sendEvent: function AppBarCommand_sendEvent(eventName, detail) { - if (this._disposed) { - return; - } - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(eventName, true, true, (detail || {})); - return this._element.dispatchEvent(event); - }, - }); - - - // The list of AppBarCommand properties that we care about firing an event - // for, whenever they are changed after initial construction. - var ObservablePropertyWhiteList = [ - "label", - "disabled", - "flyout", - "extraClass", - "selected", - "onclick", - "hidden", - ]; - - function makeObservable(command, propertyName) { - // Make a pre-existing AppBarCommand property observable by firing the "_commandpropertymutated" - // event whenever its value changes. - - // Preserve initial value in JS closure variable - var _value = command[propertyName]; - - // Preserve original getter/setter if they exist, else use inline proxy functions. - var proto = command.constructor.prototype; - var originalDesc = getPropertyDescriptor(proto, propertyName) || {}; - var getter = originalDesc.get.bind(command) || function getterProxy() { - return _value; - }; - var setter = originalDesc.set.bind(command) || function setterProxy(value) { - _value = value; - }; - - // Define new observable Get/Set for propertyName on the command instance - Object.defineProperty(command, propertyName, { - get: function observable_get() { - return getter(); - }, - set: function observable_set(value) { - - var oldValue = getter(); - - // Process value through the original setter & getter before deciding to send an event. - setter(value); - var newValue = getter(); - if (!this._disposed && oldValue !== value && oldValue !== newValue && !command._disposed) { - - command._propertyMutations.dispatchEvent( - _Constants.commandPropertyMutated, - { - command: command, - propertyName: propertyName, - oldValue: oldValue, - newValue: newValue, - }); - } - } - }); - } - - function getPropertyDescriptor(obj, propertyName) { - // Returns a matching property descriptor, or null, - // if no matching descriptor is found. - var desc = null; - while (obj && !desc) { - desc = Object.getOwnPropertyDescriptor(obj, propertyName); - obj = Object.getPrototypeOf(obj); - // Walk obj's prototype chain until we find a match. - } - return desc; - } - - return AppBarCommand; - }) - }); - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - Command: _Base.Namespace._lazy(function () { return exports.AppBarCommand; }) - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -// Menu Command -/// appbar,appbars,Flyout,Flyouts,onclick,Statics -define('WinJS/Controls/Menu/_Command',[ - 'exports', - '../../Core/_Global', - '../../Core/_Base', - '../../Core/_ErrorFromName', - '../../Core/_Resources', - '../../Promise', - '../../Utilities/_Control', - '../../Utilities/_ElementUtilities', - '../_LegacyAppBar/_Constants', - '../Flyout/_Overlay' -], function menuCommandInit(exports, _Global, _Base, _ErrorFromName, _Resources, Promise, _Control, _ElementUtilities, _Constants, _Overlay) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// - /// Represents a command to be displayed in a Menu. MenuCommand objects provide button, toggle button, flyout button, - /// or separator functionality for Menu controls. - /// - /// - /// - /// - /// - /// ]]> - /// The MenuCommand control itself - /// - /// - MenuCommand: _Base.Namespace._lazy(function () { - - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/menuCommandAriaLabel").value; }, - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get badClick() { return "Invalid argument: The onclick property for an {0} must be a function"; }, - get badHrElement() { return "Invalid argument: For a separator, the element must be null or an hr element"; }, - get badButtonElement() { return "Invalid argument: For a button, toggle, or flyout command, the element must be null or a button element"; } - }; - - var MenuCommand = _Base.Class.define(function MenuCommand_ctor(element, options) { - /// - /// - /// Creates a new MenuCommand object. - /// - /// - /// The DOM element that will host the control. - /// - /// - /// The set of properties and values to apply to the new MenuCommand. - /// - /// - /// A MenuCommand control. - /// - /// - /// - - // Check to make sure we weren't duplicated - if (element && element.winControl) { - throw new _ErrorFromName("WinJS.UI.MenuCommand.DuplicateConstruction", strings.duplicateConstruction); - } - - this._disposed = false; - - // Don't blow up if they didn't pass options - if (!options) { - options = {}; - } - - // Need a type before we can create our element - if (!options.type) { - this._type = _Constants.typeButton; - } - - // Go ahead and create it, separator types look different than buttons - // Don't forget to use passed in element if one was provided. - this._element = element; - if (options.type === _Constants.typeSeparator) { - this._createSeparator(); - } else { - // This will also set the icon & label - this._createButton(); - } - _ElementUtilities.addClass(this._element, "win-disposable"); - - // Remember ourselves - this._element.winControl = this; - - // Attach our css class - _ElementUtilities.addClass(this._element, _Constants.menuCommandClass); - - if (!options.selected && options.type === _Constants.typeToggle) { - // Make sure toggle's have selected false for CSS - this.selected = false; - } - - if (options.onclick) { - this.onclick = options.onclick; - } - options.onclick = this._handleClick.bind(this); - - _Control.setOptions(this, options); - - // Set our options - if (this._type !== _Constants.typeSeparator) { - // Make sure we have an ARIA role - var role = this._element.getAttribute("role"); - if (role === null || role === "" || role === undefined) { - role = "menuitem"; - if (this._type === _Constants.typeToggle) { - role = "menuitemcheckbox"; - } - this._element.setAttribute("role", role); - if (this._type === _Constants.typeFlyout) { - this._element.setAttribute("aria-haspopup", true); - } - } - var label = this._element.getAttribute("aria-label"); - if (label === null || label === "" || label === undefined) { - this._element.setAttribute("aria-label", strings.ariaLabel); - } - } - - }, { - /// - /// Gets the ID of the MenuCommand. - /// - /// - id: { - get: function () { - return this._element.id; - }, - set: function (value) { - // we allow setting first time only. otherwise we ignore it. - if (!this._element.id) { - this._element.id = value; - } - } - }, - - /// - /// Gets the type of the MenuCommand. Possible values are "button", "toggle", "flyout", or "separator". - /// - /// - type: { - get: function () { - return this._type; - }, - set: function (value) { - // we allow setting first time only. otherwise we ignore it. - if (!this._type) { - if (value !== _Constants.typeButton && value !== _Constants.typeFlyout && value !== _Constants.typeToggle && value !== _Constants.typeSeparator) { - value = _Constants.typeButton; - } - - this._type = value; - - if (value === _Constants.typeButton) { - _ElementUtilities.addClass(this.element, _Constants.menuCommandButtonClass); - } else if (value === _Constants.typeFlyout) { - _ElementUtilities.addClass(this.element, _Constants.menuCommandFlyoutClass); - this.element.addEventListener("keydown", this._handleKeyDown.bind(this), false); - } else if (value === _Constants.typeSeparator) { - _ElementUtilities.addClass(this.element, _Constants.menuCommandSeparatorClass); - } else if (value === _Constants.typeToggle) { - _ElementUtilities.addClass(this.element, _Constants.menuCommandToggleClass); - } - } - } - }, - - /// - /// The label of the MenuCommand - /// - /// - label: { - get: function () { - return this._label; - }, - set: function (value) { - this._label = value || ""; - if (this._labelSpan) { - this._labelSpan.textContent = this.label; - } - - // Update aria-label - this._element.setAttribute("aria-label", this.label); - } - }, - - /// - /// Gets or sets the function to invoke when the command is clicked. - /// - /// - onclick: { - get: function () { - return this._onclick; - }, - set: function (value) { - if (value && typeof value !== "function") { - throw new _ErrorFromName("WinJS.UI.MenuCommand.BadClick", _Resources._formatString(strings.badClick, "MenuCommand")); - } - this._onclick = value; - } - }, - - /// - /// For flyout type MenuCommands, this property returns the WinJS.UI.Flyout that this command invokes. When setting this property, you can set - /// it to the string ID of the Flyout, the DOM object that hosts the Flyout, or the Flyout object itself. - /// - /// - flyout: { - get: function () { - // Resolve it to the flyout - var flyout = this._flyout; - if (typeof flyout === "string") { - flyout = _Global.document.getElementById(flyout); - } - // If it doesn't have a .element, then we need to getControl on it - if (flyout && !flyout.element) { - flyout = flyout.winControl; - } - - return flyout; - }, - set: function (value) { - - // Need to update aria-owns with the new ID. - var id = value; - if (id && typeof id !== "string") { - // Our controls have .element properties - if (id.element) { - id = id.element; - } - // Hope it's a DOM element, get ID from DOM element - if (id) { - if (id.id) { - id = id.id; - } else { - // No id, have to fake one - id.id = _ElementUtilities._uniqueID(id); - id = id.id; - } - } - } - if (typeof id === "string") { - this._element.setAttribute("aria-owns", id); - } - - if (this._flyout !== value) { - MenuCommand._deactivateFlyoutCommand(this); - } - - // Remember it - this._flyout = value; - } - }, - - /// - /// Gets or sets the selected state of a toggle button. This property is true if the toggle button is selected; otherwise, it's false. - /// - /// - selected: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return this._element.getAttribute("aria-checked") === "true"; - }, - set: function (value) { - this._element.setAttribute("aria-checked", !!value); - } - }, - - /// - element: { - get: function () { - return this._element; - } - }, - - /// - /// Gets or sets a value that indicates whether the MenuCommand is disabled. This value is true if the MenuCommand is disabled; otherwise, false. - /// - /// - disabled: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return !!this._element.disabled; - }, - set: function (value) { - value = !!value; - if (value && this.type === _Constants.typeFlyout) { - MenuCommand._deactivateFlyoutCommand(this); - } - this._element.disabled = value; - } - }, - - /// - hidden: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return this._element.style.visibility === "hidden"; - }, - set: function (value) { - var menuControl = _Overlay._Overlay._getParentControlUsingClassName(this._element, _Constants.menuClass); - if (menuControl && !menuControl.hidden) { - throw new _ErrorFromName("WinJS.UI.MenuCommand.CannotChangeHiddenProperty", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeHiddenProperty, "Menu")); - } - - var style = this._element.style; - if (value) { - if (this.type === _Constants.typeFlyout) { - MenuCommand._deactivateFlyoutCommand(this); - } - style.visibility = "hidden"; - style.display = "none"; - } else { - style.visibility = ""; - style.display = "block"; - } - } - }, - - /// - /// Gets or sets the extra CSS class that is applied to the host DOM element. - /// - /// - extraClass: { - get: function () { - return this._extraClass; - }, - set: function (value) { - if (this._extraClass) { - _ElementUtilities.removeClass(this._element, this._extraClass); - } - this._extraClass = value; - _ElementUtilities.addClass(this._element, this._extraClass); - } - }, - - - dispose: function () { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - }, - - addEventListener: function (type, listener, useCapture) { - /// - /// - /// Registers an event handler for the specified event. - /// - /// The name of the event to register. - /// The function that handles the event. - /// - /// Set to true to register the event handler for the capturing phase; otherwise, set to false to register the event handler for the bubbling phase. - /// - /// - /// - return this._element.addEventListener(type, listener, useCapture); - }, - - removeEventListener: function (type, listener, useCapture) { - /// - /// - /// Removes the specified event handler that the addEventListener method registered. - /// - /// The name of the event to remove. - /// The event handler function to remove. - /// - /// Set to true to remove the capturing phase event handler; set to false to remove the bubbling phase event handler. - /// - /// - /// - return this._element.removeEventListener(type, listener, useCapture); - }, - - // Private properties - _createSeparator: function MenuCommand_createSeparator() { - // Make sure there's an input element - if (!this._element) { - this._element = _Global.document.createElement("hr"); - } else { - // Verify the input was an hr - if (this._element.tagName !== "HR") { - throw new _ErrorFromName("WinJS.UI.MenuCommand.BadHrElement", strings.badHrElement); - } - } - }, - - _createButton: function MenuCommand_createButton() { - // Make sure there's an element - if (!this._element) { - this._element = _Global.document.createElement("button"); - } else { - // Verify the input was a button - if (this._element.tagName !== "BUTTON") { - throw new _ErrorFromName("WinJS.UI.MenuCommand.BadButtonElement", strings.badButtonElement); - } - } - - // Create our inner HTML. We will set aria values on the button itself further down in the constructor. - this._element.innerHTML = - '
' + - '' + - '' + - '' + - '
'; - this._element.type = "button"; - - // The purpose of menuCommandLiner is to lay out the MenuCommand's children in a flexbox. Ideally, this flexbox would - // be on MenuCommand.element. However, firefox lays out buttons with display:flex differently. - // Firefox bug 1014285 (Button with display:inline-flex doesn't layout properly) - // https://bugzilla.mozilla.org/show_bug.cgi?id=1014285 - this._menuCommandLiner = this._element.firstElementChild; - this._toggleSpan = this._menuCommandLiner.firstElementChild; - this._labelSpan = this._toggleSpan.nextElementSibling; - this._flyoutSpan = this._labelSpan.nextElementSibling; - - }, - _sendEvent: function MenuCommand_sendEvent(eventName, detail) { - if (!this._disposed) { - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(eventName, true, true, (detail || {})); - this._element.dispatchEvent(event); - } - }, - - _invoke: function MenuCommand_invoke(event) { - if (!this.hidden && !this.disabled && !this._disposed) { - if (this._type === _Constants.typeToggle) { - this.selected = !this.selected; - } else if (this._type === _Constants.typeFlyout) { - MenuCommand._activateFlyoutCommand(this); - } - - if (event && event.type === "click" && this.onclick) { - this.onclick(event); - } - - // Bubble private 'invoked' event to Menu - this._sendEvent(_Constants._menuCommandInvokedEvent, { command: this }); - } - }, - - _handleClick: function MenuCommand_handleClick(event) { - this._invoke(event); - }, - - _handleKeyDown: function MenuCommand_handleKeyDown(event) { - var Key = _ElementUtilities.Key, - rtl = _Global.getComputedStyle(this.element).direction === "rtl", - rightKey = rtl ? Key.leftArrow : Key.rightArrow; - - if (event.keyCode === rightKey && this.type === _Constants.typeFlyout) { - this._invoke(event); - - // Prevent the page from scrolling - event.preventDefault(); - } - }, - }, { - // Statics - _activateFlyoutCommand: function MenuCommand_activateFlyoutCommand(menuCommand) { - // Activates the associated Flyout command and returns a promise once complete. - // A command is considered to be activated once the proper CSS class has been applied and its associated flyout has finished showing. - return new Promise(function (c, e) { - menuCommand = menuCommand.winControl || menuCommand; - var subFlyout = menuCommand.flyout; - // Flyout may not have processAll'd, so this may be a DOM object - if (subFlyout && subFlyout.hidden && subFlyout.show) { - _ElementUtilities.addClass(menuCommand.element, _Constants.menuCommandFlyoutActivatedClass); - - // Remove activation class from the command if the flyout is ever hidden. - subFlyout.addEventListener("beforehide", function beforeHide() { - subFlyout.removeEventListener("beforehide", beforeHide, false); - _ElementUtilities.removeClass(menuCommand.element, _Constants.menuCommandFlyoutActivatedClass); - }, false); - - subFlyout.addEventListener("aftershow", function afterShow() { - subFlyout.removeEventListener("aftershow", afterShow, false); - // We are considered activated once we start showing the flyout. - c(); - }, false); - - subFlyout.show(menuCommand, "_cascade"); - } else { - // Could not change command to activated state. - e(); - } - }); - }, - - _deactivateFlyoutCommand: function MenuCommand_deactivateFlyoutCommand(menuCommand) { - // Deactivates the associated Flyout command and returns a promise once complete. - // A command is considered to be deactivated once the proper CSS class has been applied and its associated flyout has finished hiding. - return new Promise(function (c) { - menuCommand = menuCommand.winControl || menuCommand; - _ElementUtilities.removeClass(menuCommand.element, _Constants.menuCommandFlyoutActivatedClass); - - var subFlyout = menuCommand.flyout; - // Flyout may not have processAll'd, so this may be a DOM object - if (subFlyout && !subFlyout.hidden && subFlyout.hide) { - - subFlyout.addEventListener("afterhide", function afterHide() { - subFlyout.removeEventListener("afterhide", afterHide, false); - c(); - }, false); - - subFlyout.hide(); - } else { - // subFlyout does not need to be hidden. - c(); - } - }); - }, - }); - return MenuCommand; - }) - }); - -}); - - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -define('WinJS/Controls/CommandingSurface/_MenuCommand',["require", "exports", "../Menu/_Command"], function (require, exports, _MenuCommandBase) { - var _MenuCommand = (function (_super) { - __extends(_MenuCommand, _super); - function _MenuCommand(element, options) { - if (options && options.beforeInvoke) { - this._beforeInvoke = options.beforeInvoke; - } - _super.call(this, element, options); - } - _MenuCommand.prototype._invoke = function (event) { - this._beforeInvoke && this._beforeInvoke(event); - _super.prototype._invoke.call(this, event); - }; - return _MenuCommand; - })(_MenuCommandBase.MenuCommand); - exports._MenuCommand = _MenuCommand; -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Utilities/_OpenCloseMachine',["require", "exports", '../Core/_Global', '../Promise', '../_Signal'], function (require, exports, _Global, Promise, _Signal) { - "use strict"; - // This module provides a state machine which is designed to be used by controls which need to - // open, close, and fire related events (e.g. beforeopen, afterclose). The state machine handles - // many edge cases. For example, what happens if: - // - open is called when we're already opened? - // - close is called while we're in the middle of opening? - // - dispose is called while we're in the middle of firing beforeopen? - // The state machine takes care of all of these edge cases so that the control doesn't have to. - // The control is responible for knowing how to play its open/close animations and update its DOM. - // The state machine is responsible for ensuring that these things happen at the appropriate times. - // This module is broken up into 3 major pieces: - // - OpenCloseMachine: Controls should instantiate one of these. The machine keeps track of the - // current state and has methods for forwarding calls to the current state. - // - IOpenCloseControl: Controls must provide an object which implements this interface. The - // interface gives the machine hooks for invoking the control's open and close animations. - // - States: The various states (e.g. Closed, Opened, Opening) that the machine can be in. Each - // implements IOpenCloseState. - // Example usage: - // class MyControl { - // element: HTMLElement; - // private _machine: OpenCloseMachine; - // - // constructor(element?: HTMLElement, options: any = {}) { - // this.element = element || document.createElement("div"); - // - // // Create the machine. - // this._machine = new OpenCloseMachine({ - // eventElement: this.element, - // onOpen: (): Promise => { - // // Do the work to render the contol in its opened state with an animation. - // // Return the animation promise. - // }, - // onClose: (): Promise => { - // // Do the work to render the contol in its closed state with an animation. - // // Return the animation promise. - // }, - // onUpdateDom() { - // // Do the work to render the internal state of the control to the DOM. If a - // // control restricts all its DOM modifications to onUpdateDom, the state machine - // // can guarantee that the control won't modify its DOM while it is animating. - // }, - // onUpdateDomWithIsOpened: (isOpened: boolean ) => { - // // Do the same work as onUpdateDom but ensure that the DOM is rendered with either - // // the opened or closed visual as dictacted by isOpened. The control should have some - // // internal state to track whether it is currently opened or closed. Treat this as a - // // cue to mutate that internal state to reflect the value of isOpened. - // }, - // }); - // - // // Initialize the control. During this time, the machine will not ask the control to - // // play any animations or update its DOM. - // this.opened = true; - // _Control.setOptions(this, options); - // - // // Tell the machine the control is initialized. After this, the machine will start asking - // // the control to play animations and update its DOM as appropriate. - // this._machine.exitInit(); - // } - // - // get opened() { - // return this._machine.opened; - // } - // set opened(value: boolean) { - // this._machine.opened = value; - // } - // open() { - // this._machine.open(); - // } - // close() { - // this._machine.close(); - // } - // forceLayout() { - // this._machine.updateDom(); - // } - // dispose() { - // this._machine.dispose(); - // } - // } - var EventNames = { - beforeOpen: "beforeopen", - afterOpen: "afteropen", - beforeClose: "beforeclose", - afterClose: "afterclose", - // Private events - // Indicates that the OpenCloseMachine has settled either into the Opened state - // or Closed state. This is more comprehensive than the "afteropen" and "afterclose" - // events because it fires even if the machine has reached the state due to: - // - Exiting the Init state - // - The beforeopen/beforeclose events being canceled - _openCloseStateSettled: "_openCloseStateSettled" - }; - // - // OpenCloseMachine - // - var OpenCloseMachine = (function () { - // - // Methods called by the control - // - // When the machine is created, it sits in the Init state. When in the Init state, calls to - // updateDom will be postponed until the machine exits the Init state. Consequently, while in - // this state, the control can feel free to call updateDom as many times as it wants without - // worrying about it being expensive due to updating the DOM many times. The control should call - // *exitInit* to move the machine out of the Init state. - function OpenCloseMachine(args) { - this._control = args; - this._initializedSignal = new _Signal(); - this._disposed = false; - this._setState(States.Init); - } - // Moves the machine out of the Init state and into the Opened or Closed state depending on whether - // open or close was called more recently. - OpenCloseMachine.prototype.exitInit = function () { - this._initializedSignal.complete(); - }; - // These method calls are forwarded to the current state. - OpenCloseMachine.prototype.updateDom = function () { - this._state.updateDom(); - }; - OpenCloseMachine.prototype.open = function () { - this._state.open(); - }; - OpenCloseMachine.prototype.close = function () { - this._state.close(); - }; - Object.defineProperty(OpenCloseMachine.prototype, "opened", { - get: function () { - return this._state.opened; - }, - set: function (value) { - if (value) { - this.open(); - } - else { - this.close(); - } - }, - enumerable: true, - configurable: true - }); - // Puts the machine into the Disposed state. - OpenCloseMachine.prototype.dispose = function () { - this._setState(States.Disposed); - this._disposed = true; - this._control = null; - }; - // - // Methods called by states - // - OpenCloseMachine.prototype._setState = function (NewState, arg0) { - if (!this._disposed) { - this._state && this._state.exit(); - this._state = new NewState(); - this._state.machine = this; - this._state.enter(arg0); - } - }; - // Triggers arbitrary app code - OpenCloseMachine.prototype._fireEvent = function (eventName, options) { - options = options || {}; - var detail = options.detail || null; - var cancelable = !!options.cancelable; - var eventObject = _Global.document.createEvent("CustomEvent"); - eventObject.initCustomEvent(eventName, true, cancelable, detail); - return this._control.eventElement.dispatchEvent(eventObject); - }; - // Triggers arbitrary app code - OpenCloseMachine.prototype._fireBeforeOpen = function () { - return this._fireEvent(EventNames.beforeOpen, { - cancelable: true - }); - }; - // Triggers arbitrary app code - OpenCloseMachine.prototype._fireBeforeClose = function () { - return this._fireEvent(EventNames.beforeClose, { - cancelable: true - }); - }; - return OpenCloseMachine; - })(); - exports.OpenCloseMachine = OpenCloseMachine; - // - // States (each implements IOpenCloseState) - // - // WinJS animation promises always complete successfully. This - // helper allows an animation promise to complete in the canceled state - // so that the success handler can be skipped when the animation is - // interrupted. - function cancelablePromise(animationPromise) { - return Promise._cancelBlocker(animationPromise, function () { - animationPromise.cancel(); - }); - } - // Noop function, used in the various states to indicate that they don't support a given - // message. Named with the somewhat cute name '_' because it reads really well in the states. - function _() { - } - // Implementing the control as a state machine helps us correctly handle: - // - re-entrancy while firing events - // - calls into the control during asynchronous operations (e.g. animations) - // - // Many of the states do their "enter" work within a promise chain. The idea is that if - // the state is interrupted and exits, the rest of its work can be skipped by canceling - // the promise chain. - // An interesting detail is that anytime the state may trigger app code (e.g. due to - // firing an event), the current promise must end and a new promise must be chained off of it. - // This is necessary because the app code may interact with the control and cause it to - // change states. If we didn't create a new promise, then the very next line of code that runs - // after triggering app code may not be valid because the state may have exited. Starting a - // new promise after each triggering of app code prevents us from having to worry about this - // problem. In this configuration, when a promise's success handler runs, it guarantees that - // the state hasn't exited. - // For similar reasons, each of the promise chains created in "enter" starts off with a _Signal - // which is completed at the end of the "enter" function (this boilerplate is abstracted away by - // the "interruptible" function). The reason is that we don't want any of the code in "enter" - // to run until the promise chain has been stored in a variable. If we didn't do this (e.g. instead, - // started the promise chain with Promise.wrap()), then the "enter" code could trigger the "exit" - // function (via app code) before the promise chain had been stored in a variable. Under these - // circumstances, the promise chain would be uncancelable and so the "enter" work would be - // unskippable. This wouldn't be good when we needed the state to exit early. - // These two functions manage interruptible work promises (one creates them the other cancels - // them). They communicate with each other thru the _interruptibleWorkPromises property which - // "interruptible" creates on your object. - function interruptible(object, workFn) { - object["_interruptibleWorkPromises"] = object["_interruptibleWorkPromises"] || []; - var workStoredSignal = new _Signal(); - object["_interruptibleWorkPromises"].push(workFn(workStoredSignal.promise)); - workStoredSignal.complete(); - } - function cancelInterruptibles() { - (this["_interruptibleWorkPromises"] || []).forEach(function (workPromise) { - workPromise.cancel(); - }); - } - // Transitions: - // When created, the state machine will take one of the following initialization - // transitions depending on how the machines's APIs have been used by the time - // exitInit() is called on it: - // Init -> Closed - // Init -> Opened - // Following that, the life of the machine will be dominated by the following - // sequences of transitions. In geneneral, these sequences are uninterruptible. - // Closed -> BeforeOpen -> Closed (when preventDefault is called on beforeopen event) - // Closed -> BeforeOpen -> Opening -> Opened - // Opened -> BeforeClose -> Opened (when preventDefault is called on beforeclose event) - // Opened -> BeforeClose -> Closing -> Closed - // However, any state can be interrupted to go to the Disposed state: - // * -> Disposed - var States; - (function (States) { - function updateDomImpl() { - this.machine._control.onUpdateDom(); - } - // Initial state. Gives the control the opportunity to initialize itself without - // triggering any animations or DOM modifications. When done, the control should - // call *exitInit* to move the machine to the next state. - var Init = (function () { - function Init() { - this.name = "Init"; - this.exit = cancelInterruptibles; - this.updateDom = _; // Postponed until immediately before we switch to another state - } - Init.prototype.enter = function () { - var _this = this; - interruptible(this, function (ready) { - return ready.then(function () { - return _this.machine._initializedSignal.promise; - }).then(function () { - _this.machine._control.onUpdateDomWithIsOpened(_this._opened); - _this.machine._setState(_this._opened ? Opened : Closed); - }); - }); - }; - Object.defineProperty(Init.prototype, "opened", { - get: function () { - return this._opened; - }, - enumerable: true, - configurable: true - }); - Init.prototype.open = function () { - this._opened = true; - }; - Init.prototype.close = function () { - this._opened = false; - }; - return Init; - })(); - States.Init = Init; - // A rest state. The control is closed and is waiting for the app to call open. - var Closed = (function () { - function Closed() { - this.name = "Closed"; - this.exit = _; - this.opened = false; - this.close = _; - this.updateDom = updateDomImpl; - } - Closed.prototype.enter = function (args) { - args = args || {}; - if (args.openIsPending) { - this.open(); - } - this.machine._fireEvent(EventNames._openCloseStateSettled); - }; - Closed.prototype.open = function () { - this.machine._setState(BeforeOpen); - }; - return Closed; - })(); - // An event state. The control fires the beforeopen event. - var BeforeOpen = (function () { - function BeforeOpen() { - this.name = "BeforeOpen"; - this.exit = cancelInterruptibles; - this.opened = false; - this.open = _; - this.close = _; - this.updateDom = updateDomImpl; - } - BeforeOpen.prototype.enter = function () { - var _this = this; - interruptible(this, function (ready) { - return ready.then(function () { - return _this.machine._fireBeforeOpen(); // Give opportunity for chain to be canceled when triggering app code - }).then(function (shouldOpen) { - if (shouldOpen) { - _this.machine._setState(Opening); - } - else { - _this.machine._setState(Closed); - } - }); - }); - }; - return BeforeOpen; - })(); - // An animation/event state. The control plays its open animation and fires afteropen. - var Opening = (function () { - function Opening() { - this.name = "Opening"; - this.exit = cancelInterruptibles; - this.updateDom = _; // Postponed until immediately before we switch to another state - } - Opening.prototype.enter = function () { - var _this = this; - interruptible(this, function (ready) { - return ready.then(function () { - _this._closeIsPending = false; - return cancelablePromise(_this.machine._control.onOpen()); - }).then(function () { - _this.machine._fireEvent(EventNames.afterOpen); // Give opportunity for chain to be canceled when triggering app code - }).then(function () { - _this.machine._control.onUpdateDom(); - _this.machine._setState(Opened, { closeIsPending: _this._closeIsPending }); - }); - }); - }; - Object.defineProperty(Opening.prototype, "opened", { - get: function () { - return !this._closeIsPending; - }, - enumerable: true, - configurable: true - }); - Opening.prototype.open = function () { - this._closeIsPending = false; - }; - Opening.prototype.close = function () { - this._closeIsPending = true; - }; - return Opening; - })(); - // A rest state. The control is opened and is waiting for the app to call close. - var Opened = (function () { - function Opened() { - this.name = "Opened"; - this.exit = _; - this.opened = true; - this.open = _; - this.updateDom = updateDomImpl; - } - Opened.prototype.enter = function (args) { - args = args || {}; - if (args.closeIsPending) { - this.close(); - } - this.machine._fireEvent(EventNames._openCloseStateSettled); - }; - Opened.prototype.close = function () { - this.machine._setState(BeforeClose); - }; - return Opened; - })(); - // An event state. The control fires the beforeclose event. - var BeforeClose = (function () { - function BeforeClose() { - this.name = "BeforeClose"; - this.exit = cancelInterruptibles; - this.opened = true; - this.open = _; - this.close = _; - this.updateDom = updateDomImpl; - } - BeforeClose.prototype.enter = function () { - var _this = this; - interruptible(this, function (ready) { - return ready.then(function () { - return _this.machine._fireBeforeClose(); // Give opportunity for chain to be canceled when triggering app code - }).then(function (shouldClose) { - if (shouldClose) { - _this.machine._setState(Closing); - } - else { - _this.machine._setState(Opened); - } - }); - }); - }; - return BeforeClose; - })(); - // An animation/event state. The control plays the close animation and fires the afterclose event. - var Closing = (function () { - function Closing() { - this.name = "Closing"; - this.exit = cancelInterruptibles; - this.updateDom = _; // Postponed until immediately before we switch to another state - } - Closing.prototype.enter = function () { - var _this = this; - interruptible(this, function (ready) { - return ready.then(function () { - _this._openIsPending = false; - return cancelablePromise(_this.machine._control.onClose()); - }).then(function () { - _this.machine._fireEvent(EventNames.afterClose); // Give opportunity for chain to be canceled when triggering app code - }).then(function () { - _this.machine._control.onUpdateDom(); - _this.machine._setState(Closed, { openIsPending: _this._openIsPending }); - }); - }); - }; - Object.defineProperty(Closing.prototype, "opened", { - get: function () { - return this._openIsPending; - }, - enumerable: true, - configurable: true - }); - Closing.prototype.open = function () { - this._openIsPending = true; - }; - Closing.prototype.close = function () { - this._openIsPending = false; - }; - return Closing; - })(); - var Disposed = (function () { - function Disposed() { - this.name = "Disposed"; - this.enter = _; - this.exit = _; - this.opened = false; - this.open = _; - this.close = _; - this.updateDom = _; - } - return Disposed; - })(); - States.Disposed = Disposed; - })(States || (States = {})); -}); - - -define('require-style!less/styles-commandingsurface',[],function(){}); - -define('require-style!less/colors-commandingsurface',[],function(){}); -define('WinJS/Controls/CommandingSurface/_CommandingSurface',["require", "exports", "../../Animations", "../../Core/_Base", "../../Core/_BaseUtils", "../../BindingList", "../../ControlProcessor", "../CommandingSurface/_Constants", "../AppBar/_Command", "../CommandingSurface/_MenuCommand", "../../Utilities/_Control", "../../Utilities/_Dispose", "../../Utilities/_ElementUtilities", "../../Core/_ErrorFromName", '../../Core/_Events', "../../Controls/Flyout", "../../Core/_Global", "../../Utilities/_Hoverable", "../../Utilities/_KeyboardBehavior", '../../Core/_Log', '../../Promise', "../../Core/_Resources", "../../Scheduler", '../../Utilities/_OpenCloseMachine', '../../_Signal', "../../Core/_WriteProfilerMark"], function (require, exports, Animations, _Base, _BaseUtils, BindingList, ControlProcessor, _Constants, _Command, _CommandingSurfaceMenuCommand, _Control, _Dispose, _ElementUtilities, _ErrorFromName, _Events, _Flyout, _Global, _Hoverable, _KeyboardBehavior, _Log, Promise, _Resources, Scheduler, _OpenCloseMachine, _Signal, _WriteProfilerMark) { - require(["require-style!less/styles-commandingsurface"]); - require(["require-style!less/colors-commandingsurface"]); - "use strict"; - var strings = { - get overflowButtonAriaLabel() { - return _Resources._getWinJSString("ui/commandingSurfaceOverflowButtonAriaLabel").value; - }, - get badData() { - return "Invalid argument: The data property must an instance of a WinJS.Binding.List"; - }, - get mustContainCommands() { - return "The commandingSurface can only contain WinJS.UI.Command or WinJS.UI.AppBarCommand controls"; - }, - get duplicateConstruction() { - return "Invalid argument: Controls may only be instantiated one time for each DOM element"; - } - }; - var CommandLayoutPipeline = { - newDataStage: 3, - measuringStage: 2, - layoutStage: 1, - idle: 0, - }; - var OverflowDirection = { - /// The _CommandingSurface expands towards the bottom of the screen when opened and the overflow area renders below the actionarea. - bottom: "bottom", - /// The _CommandingSurface expands towards the top of the screen when opened and the overflow area renders above the actionarea. - top: "top", - }; - var overflowDirectionClassMap = {}; - overflowDirectionClassMap[OverflowDirection.top] = _Constants.ClassNames.overflowTopClass; - overflowDirectionClassMap[OverflowDirection.bottom] = _Constants.ClassNames.overflowBottomClass; - var ClosedDisplayMode = { - /// When the _CommandingSurface is closed, the actionarea is not visible and doesn't take up any space. - none: "none", - /// When the _CommandingSurface is closed, the height of the actionarea is reduced to the minimal height required to display only the actionarea overflowbutton. All other content in the actionarea is not displayed. - minimal: "minimal", - /// When the _CommandingSurface is closed, the height of the actionarea is reduced such that button commands are still visible, but their labels are hidden. - compact: "compact", - /// When the _CommandingSurface is closed, the height of the actionarea is always sized to content and does not change between opened and closed states. - full: "full", - }; - var closedDisplayModeClassMap = {}; - closedDisplayModeClassMap[ClosedDisplayMode.none] = _Constants.ClassNames.noneClass; - closedDisplayModeClassMap[ClosedDisplayMode.minimal] = _Constants.ClassNames.minimalClass; - closedDisplayModeClassMap[ClosedDisplayMode.compact] = _Constants.ClassNames.compactClass; - closedDisplayModeClassMap[ClosedDisplayMode.full] = _Constants.ClassNames.fullClass; - // Versions of add/removeClass that are no ops when called with falsy class names. - function addClass(element, className) { - className && _ElementUtilities.addClass(element, className); - } - function removeClass(element, className) { - className && _ElementUtilities.removeClass(element, className); - } - function diffElements(lhs, rhs) { - // Subtract array rhs from array lhs. - // Returns a new Array containing the subset of elements in lhs that are not also in rhs. - return lhs.filter(function (commandElement) { - return rhs.indexOf(commandElement) < 0; - }); - } - /// Represents an apaptive surface for displaying commands. - var _CommandingSurface = (function () { - function _CommandingSurface(element, options) { - /// Creates a new CommandingSurface control. - /// @param element: The DOM element that will host the control. - /// @param options: The set of properties and values to apply to the new CommandingSurface control. - /// @return: The new CommandingSurface control. - var _this = this; - if (options === void 0) { options = {}; } - this._hoverable = _Hoverable.isHoverable; /* force dependency on hoverable module */ - this._dataChangedEvents = ["itemchanged", "iteminserted", "itemmoved", "itemremoved", "reload"]; - // State private to _updateDomImpl_renderDisplayMode. No other method should make use of it. - // - // Nothing has been rendered yet so these are all initialized to undefined. Because - // they are undefined, the first time _updateDomImpl is called, they will all be - // rendered. - this._updateDomImpl_renderedState = { - closedDisplayMode: undefined, - isOpenedMode: undefined, - overflowDirection: undefined, - overflowAlignmentOffset: undefined, - }; - this._writeProfilerMark("constructor,StartTM"); - // Check to make sure we weren't duplicated - if (element && element["winControl"]) { - throw new _ErrorFromName("WinJS.UI._CommandingSurface.DuplicateConstruction", strings.duplicateConstruction); - } - this._initializeDom(element || _Global.document.createElement("div")); - this._machine = options.openCloseMachine || new _OpenCloseMachine.OpenCloseMachine({ - eventElement: this._dom.root, - onOpen: function () { - _this.synchronousOpen(); - return Promise.wrap(); - }, - onClose: function () { - _this.synchronousClose(); - return Promise.wrap(); - }, - onUpdateDom: function () { - _this.updateDomImpl(); - }, - onUpdateDomWithIsOpened: function (isOpened) { - if (isOpened) { - _this.synchronousOpen(); - } - else { - _this.synchronousClose(); - } - } - }); - // Initialize private state. - this._disposed = false; - this._primaryCommands = []; - this._secondaryCommands = []; - this._refreshBound = this._refresh.bind(this); - this._resizeHandlerBound = this._resizeHandler.bind(this); - this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._dom.root); - this._refreshPending = false; - this._rtl = false; - this._initializedSignal = new _Signal(); - this._nextLayoutStage = CommandLayoutPipeline.idle; - this._isOpenedMode = _Constants.defaultOpened; - this._menuCommandProjections = []; - // Initialize public properties. - this.overflowDirection = _Constants.defaultOverflowDirection; - this.closedDisplayMode = _Constants.defaultClosedDisplayMode; - this.opened = this._isOpenedMode; - if (!options.data) { - // Shallow copy object so we can modify it. - options = _BaseUtils._shallowCopy(options); - // Set default data - options.data = options.data || this._getDataFromDOMElements(); - } - _Control.setOptions(this, options); - // Event handlers - _ElementUtilities._resizeNotifier.subscribe(this._dom.root, this._resizeHandlerBound); - this._dom.root.addEventListener('keydown', this._keyDownHandler.bind(this)); - // Exit the Init state. - _ElementUtilities._inDom(this._dom.root).then(function () { - _this._rtl = _Global.getComputedStyle(_this._dom.root).direction === 'rtl'; - if (!options.openCloseMachine) { - // We should only call exitInit on the machine when we own the machine. - _this._machine.exitInit(); - } - _this._initializedSignal.complete(); - _this._writeProfilerMark("constructor,StopTM"); - }); - } - Object.defineProperty(_CommandingSurface.prototype, "element", { - /// Gets the DOM element that hosts the CommandingSurface. - get: function () { - return this._dom.root; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(_CommandingSurface.prototype, "data", { - /// Gets or sets the Binding List of WinJS.UI.Command for the CommandingSurface. - get: function () { - return this._data; - }, - set: function (value) { - this._writeProfilerMark("set_data,info"); - if (value !== this.data) { - if (!(value instanceof BindingList.List)) { - throw new _ErrorFromName("WinJS.UI._CommandingSurface.BadData", strings.badData); - } - if (this._data) { - this._removeDataListeners(); - } - this._data = value; - this._addDataListeners(); - this._dataUpdated(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(_CommandingSurface.prototype, "closedDisplayMode", { - /// Gets or sets the closedDisplayMode for the CommandingSurface. Values are "none", "minimal", "compact", and "full". - get: function () { - return this._closedDisplayMode; - }, - set: function (value) { - this._writeProfilerMark("set_closedDisplayMode,info"); - var isChangingState = (value !== this._closedDisplayMode); - if (ClosedDisplayMode[value] && isChangingState) { - this._closedDisplayMode = value; - this._machine.updateDom(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(_CommandingSurface.prototype, "overflowDirection", { - /// Gets or sets which direction the commandingSurface overflows when opened. Values are "top" and "bottom" for. - get: function () { - return this._overflowDirection; - }, - set: function (value) { - var isChangingState = (value !== this._overflowDirection); - if (OverflowDirection[value] && isChangingState) { - this._overflowDirection = value; - this._machine.updateDom(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(_CommandingSurface.prototype, "opened", { - /// Gets or sets whether the _CommandingSurface is currently opened. - get: function () { - return this._machine.opened; - }, - set: function (value) { - this._machine.opened = value; - }, - enumerable: true, - configurable: true - }); - _CommandingSurface.prototype.open = function () { - /// Opens the _CommandingSurface's actionarea and overflowarea - this._machine.open(); - }; - _CommandingSurface.prototype.close = function () { - /// Closes the _CommandingSurface's actionarea and overflowarea - this._machine.close(); - }; - _CommandingSurface.prototype.dispose = function () { - /// Disposes this CommandingSurface. - if (this._disposed) { - return; - } - this._disposed = true; - this._machine.dispose(); - _ElementUtilities._resizeNotifier.unsubscribe(this._dom.root, this._resizeHandlerBound); - if (this._contentFlyout) { - this._contentFlyout.dispose(); - this._contentFlyout.element.parentNode.removeChild(this._contentFlyout.element); - } - _Dispose.disposeSubTree(this._dom.root); - }; - _CommandingSurface.prototype.forceLayout = function () { - /// Forces the CommandingSurface to update its layout. Use this function when the window did not change - /// size, but the container of the CommandingSurface changed size. - this._meaurementsDirty(); - this._machine.updateDom(); - }; - _CommandingSurface.prototype.getBoundingRects = function () { - return { - commandingSurface: this._dom.root.getBoundingClientRect(), - overflowArea: this._dom.overflowArea.getBoundingClientRect(), - }; - }; - _CommandingSurface.prototype.getCommandById = function (id) { - if (this._data) { - for (var i = 0, len = this._data.length; i < len; i++) { - var command = this._data.getAt(i); - if (command.id === id) { - return command; - } - } - } - return null; - }; - _CommandingSurface.prototype.showOnlyCommands = function (commands) { - if (this._data) { - for (var i = 0, len = this._data.length; i < len; i++) { - this._data.getAt(i).hidden = true; - } - for (var i = 0, len = commands.length; i < len; i++) { - // The array passed to showOnlyCommands can contain either command ids, or the commands themselves. - var command = (typeof commands[i] === "string" ? this.getCommandById(commands[i]) : commands[i]); - if (command) { - command.hidden = false; - } - } - } - }; - _CommandingSurface.prototype.deferredDomUpate = function () { - // Notify the machine that an update has been requested. - this._machine.updateDom(); - }; - _CommandingSurface.prototype.createOpenAnimation = function (closedHeight) { - // createOpenAnimation should only be called when the commanding surface is in a closed state. The control using the commanding surface is expected - // to call createOpenAnimation() before it opens the surface, then open the commanding surface, then call .execute() to start the animation. - // This function is overridden by our unit tests. - if (_Log.log) { - this._updateDomImpl_renderedState.isOpenedMode && _Log.log("The CommandingSurface should only attempt to create an open animation when it's not already opened"); - } - var that = this; - return { - execute: function () { - var boundingRects = that.getBoundingRects(); - // The overflowAreaContainer has no size by default. Measure the overflowArea's size and apply it to the overflowAreaContainer before animating - that._dom.overflowAreaContainer.style.width = boundingRects.overflowArea.width + "px"; - that._dom.overflowAreaContainer.style.height = boundingRects.overflowArea.height + "px"; - return Animations._commandingSurfaceOpenAnimation({ - actionAreaClipper: that._dom.actionAreaContainer, - actionArea: that._dom.actionArea, - overflowAreaClipper: that._dom.overflowAreaContainer, - overflowArea: that._dom.overflowArea, - oldHeight: closedHeight, - newHeight: boundingRects.commandingSurface.height, - overflowAreaHeight: boundingRects.overflowArea.height, - menuPositionedAbove: (that.overflowDirection === OverflowDirection.top), - }).then(function () { - that._clearAnimation(); - }); - } - }; - }; - _CommandingSurface.prototype.createCloseAnimation = function (closedHeight) { - // createCloseAnimation should only be called when the commanding surface is in an opened state. The control using the commanding surface is expected - // to call createCloseAnimation() before it closes the surface, then call execute() to let the animation run. Once the animation finishes, the control - // should close the commanding surface. - // This function is overridden by our unit tests. - if (_Log.log) { - !this._updateDomImpl_renderedState.isOpenedMode && _Log.log("The CommandingSurface should only attempt to create an closed animation when it's not already closed"); - } - var openedHeight = this.getBoundingRects().commandingSurface.height, overflowAreaOpenedHeight = this._dom.overflowArea.offsetHeight, oldOverflowTop = this._dom.overflowArea.offsetTop, that = this; - return { - execute: function () { - _ElementUtilities.addClass(that.element, _Constants.ClassNames.closingClass); - return Animations._commandingSurfaceCloseAnimation({ - actionAreaClipper: that._dom.actionAreaContainer, - actionArea: that._dom.actionArea, - overflowAreaClipper: that._dom.overflowAreaContainer, - overflowArea: that._dom.overflowArea, - oldHeight: openedHeight, - newHeight: closedHeight, - overflowAreaHeight: overflowAreaOpenedHeight, - menuPositionedAbove: (that.overflowDirection === OverflowDirection.top), - }).then(function () { - _ElementUtilities.removeClass(that.element, _Constants.ClassNames.closingClass); - that._clearAnimation(); - }); - } - }; - }; - Object.defineProperty(_CommandingSurface.prototype, "initialized", { - get: function () { - return this._initializedSignal.promise; - }, - enumerable: true, - configurable: true - }); - _CommandingSurface.prototype._writeProfilerMark = function (text) { - _WriteProfilerMark("WinJS.UI._CommandingSurface:" + this._id + ":" + text); - }; - _CommandingSurface.prototype._initializeDom = function (root) { - var _this = this; - this._writeProfilerMark("_intializeDom,info"); - // Attaching JS control to DOM element - root["winControl"] = this; - this._id = root.id || _ElementUtilities._uniqueID(root); - if (!root.hasAttribute("tabIndex")) { - root.tabIndex = -1; - } - _ElementUtilities.addClass(root, _Constants.ClassNames.controlCssClass); - _ElementUtilities.addClass(root, _Constants.ClassNames.disposableCssClass); - var actionArea = _Global.document.createElement("div"); - _ElementUtilities.addClass(actionArea, _Constants.ClassNames.actionAreaCssClass); - _ElementUtilities._reparentChildren(root, actionArea); - var actionAreaContainer = _Global.document.createElement("div"); - _ElementUtilities.addClass(actionAreaContainer, _Constants.ClassNames.actionAreaContainerCssClass); - actionAreaContainer.appendChild(actionArea); - root.appendChild(actionAreaContainer); - var spacer = _Global.document.createElement("div"); - _ElementUtilities.addClass(spacer, _Constants.ClassNames.spacerCssClass); - actionArea.appendChild(spacer); - var overflowButton = _Global.document.createElement("button"); - overflowButton.tabIndex = 0; - overflowButton.innerHTML = ""; - _ElementUtilities.addClass(overflowButton, _Constants.ClassNames.overflowButtonCssClass); - actionArea.appendChild(overflowButton); - overflowButton.addEventListener("click", function () { - _this.opened = !_this.opened; - }); - var overflowArea = _Global.document.createElement("div"); - _ElementUtilities.addClass(overflowArea, _Constants.ClassNames.overflowAreaCssClass); - _ElementUtilities.addClass(overflowArea, _Constants.ClassNames.menuCssClass); - var overflowAreaContainer = _Global.document.createElement("div"); - _ElementUtilities.addClass(overflowAreaContainer, _Constants.ClassNames.overflowAreaContainerCssClass); - overflowAreaContainer.appendChild(overflowArea); - root.appendChild(overflowAreaContainer); - this._dom = { - root: root, - actionArea: actionArea, - actionAreaContainer: actionAreaContainer, - spacer: spacer, - overflowButton: overflowButton, - overflowArea: overflowArea, - overflowAreaContainer: overflowAreaContainer - }; - }; - _CommandingSurface.prototype._getFocusableElementsInfo = function () { - var _this = this; - var focusableCommandsInfo = { - elements: [], - focusedIndex: -1 - }; - var elementsInReach = Array.prototype.slice.call(this._dom.actionArea.children); - var elementsInReach = Array.prototype.slice.call(this._dom.actionArea.children); - if (this._dom.overflowArea.style.display !== "none") { - elementsInReach = elementsInReach.concat(Array.prototype.slice.call(this._dom.overflowArea.children)); - } - elementsInReach.forEach(function (element) { - if (_this._isElementFocusable(element)) { - focusableCommandsInfo.elements.push(element); - if (element.contains(_Global.document.activeElement)) { - focusableCommandsInfo.focusedIndex = focusableCommandsInfo.elements.length - 1; - } - } - }); - return focusableCommandsInfo; - }; - _CommandingSurface.prototype._dataUpdated = function () { - var _this = this; - this._primaryCommands = []; - this._secondaryCommands = []; - if (this.data.length > 0) { - this.data.forEach(function (command) { - if (command.section === "secondary") { - _this._secondaryCommands.push(command); - } - else { - _this._primaryCommands.push(command); - } - }); - } - this._dataDirty(); - this._machine.updateDom(); - }; - _CommandingSurface.prototype._refresh = function () { - var _this = this; - if (!this._refreshPending) { - this._refreshPending = true; - // Batch calls to _dataUpdated - Scheduler.schedule(function () { - if (_this._refreshPending && !_this._disposed) { - _this._refreshPending = false; - _this._dataUpdated(); - } - }, Scheduler.Priority.high, null, "WinJS.UI._CommandingSurface._refresh"); - } - }; - _CommandingSurface.prototype._addDataListeners = function () { - var _this = this; - this._dataChangedEvents.forEach(function (eventName) { - _this._data.addEventListener(eventName, _this._refreshBound, false); - }); - }; - _CommandingSurface.prototype._removeDataListeners = function () { - var _this = this; - this._dataChangedEvents.forEach(function (eventName) { - _this._data.removeEventListener(eventName, _this._refreshBound, false); - }); - }; - _CommandingSurface.prototype._isElementFocusable = function (element) { - var focusable = false; - if (element) { - var command = element["winControl"]; - if (command) { - focusable = command.element.style.display !== "none" && command.type !== _Constants.typeSeparator && !command.hidden && !command.disabled && (!command.firstElementFocus || command.firstElementFocus.tabIndex >= 0 || command.lastElementFocus.tabIndex >= 0); - } - else { - // e.g. the overflow button - focusable = element.style.display !== "none" && getComputedStyle(element).visibility !== "hidden" && element.tabIndex >= 0; - } - } - return focusable; - }; - _CommandingSurface.prototype._isCommandInActionArea = function (element) { - // Returns true if the element is a command in the actionarea, false otherwise - return element && element["winControl"] && element.parentElement === this._dom.actionArea; - }; - _CommandingSurface.prototype._getLastElementFocus = function (element) { - if (this._isCommandInActionArea(element)) { - // Only commands in the actionarea support lastElementFocus - return element["winControl"].lastElementFocus; - } - else { - return element; - } - }; - _CommandingSurface.prototype._getFirstElementFocus = function (element) { - if (this._isCommandInActionArea(element)) { - // Only commands in the actionarea support firstElementFocus - return element["winControl"].firstElementFocus; - } - else { - return element; - } - }; - _CommandingSurface.prototype._keyDownHandler = function (ev) { - if (!ev.altKey) { - if (_ElementUtilities._matchesSelector(ev.target, ".win-interactive, .win-interactive *")) { - return; - } - var Key = _ElementUtilities.Key; - var focusableElementsInfo = this._getFocusableElementsInfo(); - var targetCommand; - if (focusableElementsInfo.elements.length) { - switch (ev.keyCode) { - case (this._rtl ? Key.rightArrow : Key.leftArrow): - case Key.upArrow: - var index = Math.max(0, focusableElementsInfo.focusedIndex - 1); - targetCommand = this._getLastElementFocus(focusableElementsInfo.elements[index % focusableElementsInfo.elements.length]); - break; - case (this._rtl ? Key.leftArrow : Key.rightArrow): - case Key.downArrow: - var index = Math.min(focusableElementsInfo.focusedIndex + 1, focusableElementsInfo.elements.length - 1); - targetCommand = this._getFirstElementFocus(focusableElementsInfo.elements[index]); - break; - case Key.home: - var index = 0; - targetCommand = this._getFirstElementFocus(focusableElementsInfo.elements[index]); - break; - case Key.end: - var index = focusableElementsInfo.elements.length - 1; - targetCommand = this._getLastElementFocus(focusableElementsInfo.elements[index]); - break; - } - } - if (targetCommand && targetCommand !== _Global.document.activeElement) { - targetCommand.focus(); - ev.preventDefault(); - } - } - }; - _CommandingSurface.prototype._getDataFromDOMElements = function () { - this._writeProfilerMark("_getDataFromDOMElements,info"); - ControlProcessor.processAll(this._dom.actionArea, true); - var commands = []; - var childrenLength = this._dom.actionArea.children.length; - var child; - for (var i = 0; i < childrenLength; i++) { - child = this._dom.actionArea.children[i]; - if (child["winControl"] && child["winControl"] instanceof _Command.AppBarCommand) { - commands.push(child["winControl"]); - } - else if (child !== this._dom.overflowButton && child !== this._dom.spacer) { - throw new _ErrorFromName("WinJS.UI._CommandingSurface.MustContainCommands", strings.mustContainCommands); - } - } - return new BindingList.List(commands); - }; - _CommandingSurface.prototype._resizeHandler = function () { - if (this._dom.root.offsetWidth) { - var currentActionAreaWidth = _ElementUtilities._getPreciseContentWidth(this._dom.actionArea); - if (this._cachedMeasurements && this._cachedMeasurements.actionAreaContentBoxWidth !== currentActionAreaWidth) { - this._cachedMeasurements.actionAreaContentBoxWidth = currentActionAreaWidth; - this._layoutDirty(); - this._machine.updateDom(); - } - } - }; - _CommandingSurface.prototype._dataDirty = function () { - this._nextLayoutStage = Math.max(CommandLayoutPipeline.newDataStage, this._nextLayoutStage); - }; - _CommandingSurface.prototype._meaurementsDirty = function () { - this._nextLayoutStage = Math.max(CommandLayoutPipeline.measuringStage, this._nextLayoutStage); - }; - _CommandingSurface.prototype._layoutDirty = function () { - this._nextLayoutStage = Math.max(CommandLayoutPipeline.layoutStage, this._nextLayoutStage); - }; - _CommandingSurface.prototype.synchronousOpen = function () { - this._overflowAlignmentOffset = 0; - this._isOpenedMode = true; - this.updateDomImpl(); - this._overflowAlignmentOffset = this._computeAdjustedOverflowAreaOffset(); - this.updateDomImpl(); - }; - _CommandingSurface.prototype._computeAdjustedOverflowAreaOffset = function () { - // Returns any negative offset needed to prevent the shown overflowarea from clipping outside of the viewport. - // This function should only be called when CommandingSurface has been rendered in the opened state with - // an overflowAlignmentOffset of 0. - if (_Log.log) { - !this._updateDomImpl_renderedState.isOpenedMode && _Log.log("The CommandingSurface should only attempt to compute adjusted overflowArea offset " + " when it has been rendered opened"); - this._updateDomImpl_renderedState.overflowAlignmentOffset !== 0 && _Log.log("The CommandingSurface should only attempt to compute adjusted overflowArea offset " + " when it has been rendered with an overflowAlignementOffset of 0"); - } - var overflowArea = this._dom.overflowArea, boundingClientRects = this.getBoundingRects(), adjustedOffset = 0; - if (this._rtl) { - // In RTL the left edge of overflowarea prefers to align to the LEFT edge of the commandingSurface. - // Make sure we avoid clipping through the RIGHT edge of the viewport - var viewportRight = window.innerWidth, rightOffsetFromViewport = boundingClientRects.overflowArea.right; - adjustedOffset = Math.min(viewportRight - rightOffsetFromViewport, 0); - } - else { - // In LTR the right edge of overflowarea prefers to align to the RIGHT edge of the commandingSurface. - // Make sure we avoid clipping through the LEFT edge of the viewport. - var leftOffsetFromViewport = boundingClientRects.overflowArea.left; - adjustedOffset = Math.min(0, leftOffsetFromViewport); - } - return adjustedOffset; - }; - _CommandingSurface.prototype.synchronousClose = function () { - this._isOpenedMode = false; - this.updateDomImpl(); - }; - _CommandingSurface.prototype.updateDomImpl = function () { - this._updateDomImpl_renderDisplayMode(); - this._updateDomImpl_updateCommands(); - }; - _CommandingSurface.prototype._updateDomImpl_renderDisplayMode = function () { - var rendered = this._updateDomImpl_renderedState; - if (rendered.isOpenedMode !== this._isOpenedMode) { - if (this._isOpenedMode) { - // Render opened - removeClass(this._dom.root, _Constants.ClassNames.closedClass); - addClass(this._dom.root, _Constants.ClassNames.openedClass); - } - else { - // Render closed - removeClass(this._dom.root, _Constants.ClassNames.openedClass); - addClass(this._dom.root, _Constants.ClassNames.closedClass); - } - rendered.isOpenedMode = this._isOpenedMode; - } - if (rendered.closedDisplayMode !== this.closedDisplayMode) { - removeClass(this._dom.root, closedDisplayModeClassMap[rendered.closedDisplayMode]); - addClass(this._dom.root, closedDisplayModeClassMap[this.closedDisplayMode]); - rendered.closedDisplayMode = this.closedDisplayMode; - } - if (rendered.overflowDirection !== this.overflowDirection) { - removeClass(this._dom.root, overflowDirectionClassMap[rendered.overflowDirection]); - addClass(this._dom.root, overflowDirectionClassMap[this.overflowDirection]); - rendered.overflowDirection = this.overflowDirection; - } - if (this._overflowAlignmentOffset !== rendered.overflowAlignmentOffset) { - var offsetProperty = (this._rtl ? "left" : "right"); - var offsetTextValue = this._overflowAlignmentOffset + "px"; - this._dom.overflowAreaContainer.style[offsetProperty] = offsetTextValue; - } - }; - _CommandingSurface.prototype._updateDomImpl_updateCommands = function () { - this._writeProfilerMark("_updateDomImpl_updateCommands,info"); - var nextStage = this._nextLayoutStage; - while (nextStage !== CommandLayoutPipeline.idle) { - var currentStage = nextStage; - var okToProceed = false; - switch (currentStage) { - case CommandLayoutPipeline.newDataStage: - nextStage = CommandLayoutPipeline.measuringStage; - okToProceed = this._processNewData(); - break; - case CommandLayoutPipeline.measuringStage: - nextStage = CommandLayoutPipeline.layoutStage; - okToProceed = this._measure(); - break; - case CommandLayoutPipeline.layoutStage: - nextStage = CommandLayoutPipeline.idle; - okToProceed = this._layoutCommands(); - break; - } - if (!okToProceed) { - // If a stage fails, exit the loop and track that stage - // to be restarted the next time _updateCommands is run. - nextStage = currentStage; - break; - } - } - this._nextLayoutStage = nextStage; - if (nextStage === CommandLayoutPipeline.idle) { - // Callback for unit tests. - this._layoutCompleteCallback && this._layoutCompleteCallback(); - } - }; - _CommandingSurface.prototype._getDataChangeInfo = function () { - var i = 0, len = 0; - var added = []; - var deleted = []; - var affected = []; - var currentShown = []; - var currentElements = []; - var newShown = []; - var newHidden = []; - var newElements = []; - Array.prototype.forEach.call(this._dom.actionArea.querySelectorAll(_Constants.commandSelector), function (commandElement) { - if (commandElement.style.display !== "none") { - currentShown.push(commandElement); - } - currentElements.push(commandElement); - }); - this.data.forEach(function (command) { - if (command.element.style.display !== "none") { - newShown.push(command.element); - } - else { - newHidden.push(command.element); - } - newElements.push(command.element); - }); - deleted = diffElements(currentShown, newShown); - affected = diffElements(currentShown, deleted); - // "added" must also include the elements from "newHidden" to ensure that we continue - // to animate any command elements that have underflowed back into the actionarea - // as a part of this data change. - added = diffElements(newShown, currentShown).concat(newHidden); - return { - newElements: newElements, - currentElements: currentElements, - added: added, - deleted: deleted, - affected: affected, - }; - }; - _CommandingSurface.prototype._processNewData = function () { - var _this = this; - this._writeProfilerMark("_processNewData,info"); - var changeInfo = this._getDataChangeInfo(); - // Take a snapshot of the current state - var updateCommandAnimation = Animations._createUpdateListAnimation(changeInfo.added, changeInfo.deleted, changeInfo.affected); - // Unbind property mutation event listener from deleted IObservableCommands - changeInfo.deleted.forEach(function (deletedElement) { - var command = (deletedElement['winControl']); - if (command && command['_propertyMutations']) { - command._propertyMutations.unbind(_this._refreshBound); - } - }); - // Bind property mutation event listener to added IObservable commands. - changeInfo.added.forEach(function (deletedElement) { - var command = (deletedElement['winControl']); - if (command && command['_propertyMutations']) { - command._propertyMutations.bind(_this._refreshBound); - } - }); - // Remove current ICommand elements - changeInfo.currentElements.forEach(function (element) { - if (element.parentElement) { - element.parentElement.removeChild(element); - } - }); - // Add new ICommand elements in the right order. - changeInfo.newElements.forEach(function (element) { - _this._dom.actionArea.appendChild(element); - }); - // Ensure that the overflow button is always the last element in the actionarea - this._dom.actionArea.appendChild(this._dom.overflowButton); - if (this.data.length > 0) { - _ElementUtilities.removeClass(this._dom.root, _Constants.ClassNames.emptyCommandingSurfaceCssClass); - } - else { - _ElementUtilities.addClass(this._dom.root, _Constants.ClassNames.emptyCommandingSurfaceCssClass); - } - // Execute the animation. - updateCommandAnimation.execute(); - // Indicate processing was successful. - return true; - }; - _CommandingSurface.prototype._measure = function () { - var _this = this; - this._writeProfilerMark("_measure,info"); - var canMeasure = (_Global.document.body.contains(this._dom.root) && this._dom.actionArea.offsetWidth > 0); - if (canMeasure) { - var overflowButtonWidth = _ElementUtilities._getPreciseTotalWidth(this._dom.overflowButton), actionAreaContentBoxWidth = _ElementUtilities._getPreciseContentWidth(this._dom.actionArea), separatorWidth = 0, standardCommandWidth = 0, contentCommandWidths = {}; - this._primaryCommands.forEach(function (command) { - // Ensure that the element we are measuring does not have display: none (e.g. it was just added, and it - // will be animated in) - var originalDisplayStyle = command.element.style.display; - command.element.style.display = ""; - if (command.type === _Constants.typeContent) { - // Measure each 'content' command type that we find - contentCommandWidths[_this._commandUniqueId(command)] = _ElementUtilities._getPreciseTotalWidth(command.element); - } - else if (command.type === _Constants.typeSeparator) { - // Measure the first 'separator' command type we find. - if (!separatorWidth) { - separatorWidth = _ElementUtilities._getPreciseTotalWidth(command.element); - } - } - else { - // Button, toggle, 'flyout' command types have the same width. Measure the first one we find. - if (!standardCommandWidth) { - standardCommandWidth = _ElementUtilities._getPreciseTotalWidth(command.element); - } - } - // Restore the original display style - command.element.style.display = originalDisplayStyle; - }); - this._cachedMeasurements = { - contentCommandWidths: contentCommandWidths, - separatorWidth: separatorWidth, - standardCommandWidth: standardCommandWidth, - overflowButtonWidth: overflowButtonWidth, - actionAreaContentBoxWidth: actionAreaContentBoxWidth, - }; - // Indicate measure was successful - return true; - } - else { - // Indicate measure was unsuccessful - return false; - } - }; - _CommandingSurface.prototype._layoutCommands = function () { - var _this = this; - this._writeProfilerMark("_layoutCommands,StartTM"); - // - // Filter commands that will not be visible in the actionarea - // - this._primaryCommands.forEach(function (command) { - command.element.style.display = (command.hidden ? "none" : ""); - }); - var primaryCommandsLocation = this._getVisiblePrimaryCommandsLocation(); - this._hideSeparatorsIfNeeded(primaryCommandsLocation.actionArea); - // Primary commands that will be mirrored in the overflow area should be hidden so - // that they are not visible in the actionarea. - primaryCommandsLocation.overflowArea.forEach(function (command) { - command.element.style.display = "none"; - }); - // The secondary commands in the actionarea should be hidden since they are always - // mirrored as new elements in the overflow area. - this._secondaryCommands.forEach(function (command) { - command.element.style.display = "none"; - }); - var overflowCommands = primaryCommandsLocation.overflowArea; - var showOverflowButton = (overflowCommands.length > 0 || this._secondaryCommands.length > 0); - this._dom.overflowButton.style.display = showOverflowButton ? "" : "none"; - // Set up a custom content flyout if there will be "content" typed commands in the overflowarea. - var isCustomContent = function (command) { - return command.type === _Constants.typeContent; - }; - var hasCustomContent = overflowCommands.some(isCustomContent) || this._secondaryCommands.some(isCustomContent); - if (hasCustomContent && !this._contentFlyout) { - this._contentFlyoutInterior = _Global.document.createElement("div"); - _ElementUtilities.addClass(this._contentFlyoutInterior, _Constants.ClassNames.contentFlyoutCssClass); - this._contentFlyout = new _Flyout.Flyout(); - this._contentFlyout.element.appendChild(this._contentFlyoutInterior); - _Global.document.body.appendChild(this._contentFlyout.element); - this._contentFlyout.onbeforeshow = function () { - _ElementUtilities.empty(_this._contentFlyoutInterior); - _ElementUtilities._reparentChildren(_this._chosenCommand.element, _this._contentFlyoutInterior); - }; - this._contentFlyout.onafterhide = function () { - _ElementUtilities._reparentChildren(_this._contentFlyoutInterior, _this._chosenCommand.element); - }; - } - // - // Project overflowing and secondary commands into the overflowArea as MenuCommands - // - // Clean up previous MenuCommand projections - _ElementUtilities.empty(this._dom.overflowArea); - this._menuCommandProjections.map(function (menuCommand) { - if (_this._contentFlyout && menuCommand.flyout === _this._contentFlyout) { - // Prevent our _contentFlyout from being disposed with the MenuCommand. - menuCommand.flyout = null; - } - menuCommand.dispose(); - }); - var hasToggleCommands = false, menuCommandProjections = []; - // Add primary commands that have overflowed. - overflowCommands.forEach(function (command) { - if (command.type === _Constants.typeToggle) { - hasToggleCommands = true; - } - menuCommandProjections.push(_this._projectAsMenuCommand(command)); - }); - // Add separator between primary and secondary command if applicable - var secondaryCommandsLength = this._secondaryCommands.length; - if (overflowCommands.length > 0 && secondaryCommandsLength > 0) { - var separator = new _CommandingSurfaceMenuCommand._MenuCommand(null, { - type: _Constants.typeSeparator - }); - menuCommandProjections.push(separator); - } - // Add secondary commands - this._secondaryCommands.forEach(function (command) { - if (!command.hidden) { - if (command.type === _Constants.typeToggle) { - hasToggleCommands = true; - } - menuCommandProjections.push(_this._projectAsMenuCommand(command)); - } - }); - this._hideSeparatorsIfNeeded(menuCommandProjections); - menuCommandProjections.forEach(function (command) { - _this._dom.overflowArea.appendChild(command.element); - }); - this._menuCommandProjections = menuCommandProjections; - _ElementUtilities[hasToggleCommands ? "addClass" : "removeClass"](this._dom.overflowArea, _Constants.ClassNames.menuContainsToggleCommandClass); - this._writeProfilerMark("_layoutCommands,StopTM"); - // Indicate layout was successful. - return true; - }; - _CommandingSurface.prototype._commandUniqueId = function (command) { - return _ElementUtilities._uniqueID(command.element); - }; - _CommandingSurface.prototype._getVisiblePrimaryCommandsInfo = function () { - var width = 0; - var commands = []; - var priority = 0; - var currentAssignedPriority = 0; - for (var i = this._primaryCommands.length - 1; i >= 0; i--) { - var command = this._primaryCommands[i]; - if (!command.hidden) { - if (command.priority === undefined) { - priority = currentAssignedPriority--; - } - else { - priority = command.priority; - } - width = (command.element.style.display === "none" ? 0 : this._getCommandWidth(command)); - commands.unshift({ - command: command, - width: width, - priority: priority - }); - } - } - return commands; - }; - _CommandingSurface.prototype._getVisiblePrimaryCommandsLocation = function () { - this._writeProfilerMark("_getVisiblePrimaryCommandsLocation,info"); - var actionAreaCommands = []; - var overflowAreaCommands = []; - var overflowButtonSpace = 0; - var hasSecondaryCommands = this._secondaryCommands.length > 0; - var commandsInfo = this._getVisiblePrimaryCommandsInfo(); - var sortedCommandsInfo = commandsInfo.slice(0).sort(function (commandInfo1, commandInfo2) { - return commandInfo1.priority - commandInfo2.priority; - }); - var maxPriority = Number.MAX_VALUE; - var availableWidth = this._cachedMeasurements.actionAreaContentBoxWidth; - for (var i = 0, len = sortedCommandsInfo.length; i < len; i++) { - availableWidth -= sortedCommandsInfo[i].width; - // The overflow button needs space if there are secondary commands, or we are not evaluating the last command. - overflowButtonSpace = (hasSecondaryCommands || (i < len - 1) ? this._cachedMeasurements.overflowButtonWidth : 0); - if (availableWidth - overflowButtonSpace < 0) { - maxPriority = sortedCommandsInfo[i].priority - 1; - break; - } - } - commandsInfo.forEach(function (commandInfo) { - if (commandInfo.priority <= maxPriority) { - actionAreaCommands.push(commandInfo.command); - } - else { - overflowAreaCommands.push(commandInfo.command); - } - }); - return { - actionArea: actionAreaCommands, - overflowArea: overflowAreaCommands - }; - }; - _CommandingSurface.prototype._getCommandWidth = function (command) { - if (command.type === _Constants.typeContent) { - return this._cachedMeasurements.contentCommandWidths[this._commandUniqueId(command)]; - } - else if (command.type === _Constants.typeSeparator) { - return this._cachedMeasurements.separatorWidth; - } - else { - return this._cachedMeasurements.standardCommandWidth; - } - }; - _CommandingSurface.prototype._projectAsMenuCommand = function (originalCommand) { - var _this = this; - var menuCommand = new _CommandingSurfaceMenuCommand._MenuCommand(null, { - label: originalCommand.label, - type: (originalCommand.type === _Constants.typeContent ? _Constants.typeFlyout : originalCommand.type) || _Constants.typeButton, - disabled: originalCommand.disabled, - flyout: originalCommand.flyout, - beforeInvoke: function () { - // Save the command that was selected - _this._chosenCommand = (menuCommand["_originalICommand"]); - // If this WinJS.UI.MenuCommand has type: toggle, we should also toggle the value of the original WinJS.UI.Command - if (_this._chosenCommand.type === _Constants.typeToggle) { - _this._chosenCommand.selected = !_this._chosenCommand.selected; - } - } - }); - if (originalCommand.selected) { - menuCommand.selected = true; - } - if (originalCommand.extraClass) { - menuCommand.extraClass = originalCommand.extraClass; - } - if (originalCommand.type === _Constants.typeContent) { - if (!menuCommand.label) { - menuCommand.label = _Constants.contentMenuCommandDefaultLabel; - } - menuCommand.flyout = this._contentFlyout; - } - else { - menuCommand.onclick = originalCommand.onclick; - } - menuCommand["_originalICommand"] = originalCommand; - return menuCommand; - }; - _CommandingSurface.prototype._hideSeparatorsIfNeeded = function (commands) { - var prevType = _Constants.typeSeparator; - var command; - // Hide all leading or consecutive separators - var commandsLength = commands.length; - commands.forEach(function (command) { - if (command.type === _Constants.typeSeparator && prevType === _Constants.typeSeparator) { - command.element.style.display = "none"; - } - prevType = command.type; - }); - for (var i = commandsLength - 1; i >= 0; i--) { - command = commands[i]; - if (command.type === _Constants.typeSeparator) { - command.element.style.display = "none"; - } - else { - break; - } - } - }; - _CommandingSurface.prototype._clearAnimation = function () { - var transformScriptName = _BaseUtils._browserStyleEquivalents["transform"].scriptName; - this._dom.actionAreaContainer.style[transformScriptName] = ""; - this._dom.actionArea.style[transformScriptName] = ""; - this._dom.overflowAreaContainer.style[transformScriptName] = ""; - this._dom.overflowArea.style[transformScriptName] = ""; - }; - /// Display options for the actionarea when the _CommandingSurface is closed. - _CommandingSurface.ClosedDisplayMode = ClosedDisplayMode; - /// Display options used by the _Commandingsurface to determine which direction it should expand when opening. - _CommandingSurface.OverflowDirection = OverflowDirection; - _CommandingSurface.supportedForProcessing = true; - return _CommandingSurface; - })(); - exports._CommandingSurface = _CommandingSurface; - _Base.Class.mix(_CommandingSurface, _Events.createEventProperties(_Constants.EventNames.beforeOpen, _Constants.EventNames.afterOpen, _Constants.EventNames.beforeClose, _Constants.EventNames.afterClose)); - // addEventListener, removeEventListener, dispatchEvent - _Base.Class.mix(_CommandingSurface, _Control.DOMEventMixin); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/CommandingSurface',["require", "exports"], function (require, exports) { - var module = null; - function getModule() { - if (!module) { - require(["./CommandingSurface/_CommandingSurface"], function (m) { - module = m; - }); - } - return module._CommandingSurface; - } - var publicMembers = Object.create({}, { - _CommandingSurface: { - get: function () { - return getModule(); - } - } - }); - return publicMembers; -}); - - -define('require-style!less/styles-toolbar',[],function(){}); -define('WinJS/Controls/ToolBar/_ToolBar',["require", "exports", "../../Core/_Base", "../ToolBar/_Constants", "../CommandingSurface", "../../Utilities/_Control", "../../Utilities/_Dispose", "../../Utilities/_ElementUtilities", "../../Core/_ErrorFromName", '../../Core/_Events', "../../Core/_Global", '../../_LightDismissService', "../../Core/_Resources", '../../Utilities/_OpenCloseMachine', "../../Core/_WriteProfilerMark"], function (require, exports, _Base, _Constants, _CommandingSurface, _Control, _Dispose, _ElementUtilities, _ErrorFromName, _Events, _Global, _LightDismissService, _Resources, _OpenCloseMachine, _WriteProfilerMark) { - require(["require-style!less/styles-toolbar"]); - "use strict"; - var strings = { - get ariaLabel() { - return _Resources._getWinJSString("ui/toolbarAriaLabel").value; - }, - get overflowButtonAriaLabel() { - return _Resources._getWinJSString("ui/toolbarOverflowButtonAriaLabel").value; - }, - get mustContainCommands() { - return "The toolbar can only contain WinJS.UI.Command or WinJS.UI.AppBarCommand controls"; - }, - get duplicateConstruction() { - return "Invalid argument: Controls may only be instantiated one time for each DOM element"; - } - }; - var ClosedDisplayMode = { - /// - /// When the ToolBar is closed, the height of the ToolBar is reduced such that button commands are still visible, but their labels are hidden. - /// - compact: "compact", - /// - /// When the ToolBar is closed, the height of the ToolBar is always sized to content. - /// - full: "full", - }; - var closedDisplayModeClassMap = {}; - closedDisplayModeClassMap[ClosedDisplayMode.compact] = _Constants.ClassNames.compactClass; - closedDisplayModeClassMap[ClosedDisplayMode.full] = _Constants.ClassNames.fullClass; - // Versions of add/removeClass that are no ops when called with falsy class names. - function addClass(element, className) { - className && _ElementUtilities.addClass(element, className); - } - function removeClass(element, className) { - className && _ElementUtilities.removeClass(element, className); - } - /// - /// - /// Displays ICommands within the flow of the app. Use the ToolBar around other statically positioned app content. - /// - /// - /// - /// - /// - /// - /// ]]> - /// The entire ToolBar control. - /// The toolbar overflow button. - /// The container for toolbar commands that overflow. - /// - /// - var ToolBar = (function () { - function ToolBar(element, options) { - /// - /// - /// Creates a new ToolBar control. - /// - /// - /// The DOM element that will host the control. - /// - /// - /// The set of properties and values to apply to the new ToolBar control. - /// - /// - /// The new ToolBar control. - /// - /// - var _this = this; - if (options === void 0) { options = {}; } - // State private to the _updateDomImpl family of method. No other methods should make use of it. - // - // Nothing has been rendered yet so these are all initialized to undefined. Because - // they are undefined, the first time _updateDomImpl is called, they will all be - // rendered. - this._updateDomImpl_renderedState = { - isOpenedMode: undefined, - closedDisplayMode: undefined, - prevInlineWidth: undefined, - }; - this._writeProfilerMark("constructor,StartTM"); - // Check to make sure we weren't duplicated - if (element && element["winControl"]) { - throw new _ErrorFromName("WinJS.UI.ToolBar.DuplicateConstruction", strings.duplicateConstruction); - } - this._initializeDom(element || _Global.document.createElement("div")); - var stateMachine = new _OpenCloseMachine.OpenCloseMachine({ - eventElement: this.element, - onOpen: function () { - var openAnimation = _this._commandingSurface.createOpenAnimation(_this._getClosedHeight()); - _this._synchronousOpen(); - return openAnimation.execute(); - }, - onClose: function () { - var closeAnimation = _this._commandingSurface.createCloseAnimation(_this._getClosedHeight()); - return closeAnimation.execute().then(function () { - _this._synchronousClose(); - }); - }, - onUpdateDom: function () { - _this._updateDomImpl(); - }, - onUpdateDomWithIsOpened: function (isOpened) { - _this._isOpenedMode = isOpened; - _this._updateDomImpl(); - } - }); - // Events - this._handleShowingKeyboardBound = this._handleShowingKeyboard.bind(this); - _ElementUtilities._inputPaneListener.addEventListener(this._dom.root, "showing", this._handleShowingKeyboardBound); - // Initialize private state. - this._disposed = false; - this._cachedClosedHeight = null; - this._commandingSurface = new _CommandingSurface._CommandingSurface(this._dom.commandingSurfaceEl, { openCloseMachine: stateMachine }); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-actionarea"), _Constants.ClassNames.actionAreaCssClass); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-overflowarea"), _Constants.ClassNames.overflowAreaCssClass); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-overflowbutton"), _Constants.ClassNames.overflowButtonCssClass); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-ellipsis"), _Constants.ClassNames.ellipsisCssClass); - this._isOpenedMode = _Constants.defaultOpened; - this._dismissable = new _LightDismissService.LightDismissableElement({ - element: this._dom.root, - tabIndex: this._dom.root.hasAttribute("tabIndex") ? this._dom.root.tabIndex : -1, - onLightDismiss: function () { - _this.close(); - } - }); - // Initialize public properties. - this.closedDisplayMode = _Constants.defaultClosedDisplayMode; - this.opened = this._isOpenedMode; - _Control.setOptions(this, options); - // Exit the Init state. - _ElementUtilities._inDom(this.element).then(function () { - return _this._commandingSurface.initialized; - }).then(function () { - stateMachine.exitInit(); - _this._writeProfilerMark("constructor,StopTM"); - }); - } - Object.defineProperty(ToolBar.prototype, "element", { - /// - get: function () { - return this._dom.root; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ToolBar.prototype, "data", { - /// - /// Gets or sets the Binding List of WinJS.UI.Command for the ToolBar. - /// - get: function () { - return this._commandingSurface.data; - }, - set: function (value) { - this._commandingSurface.data = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ToolBar.prototype, "closedDisplayMode", { - /// - /// Gets or sets the closedDisplayMode for the ToolBar. Values are "compact" and "full". - /// - get: function () { - return this._commandingSurface.closedDisplayMode; - }, - set: function (value) { - if (ClosedDisplayMode[value]) { - this._commandingSurface.closedDisplayMode = value; - this._cachedClosedHeight = null; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(ToolBar.prototype, "opened", { - /// - get: function () { - return this._commandingSurface.opened; - }, - set: function (value) { - this._commandingSurface.opened = value; - }, - enumerable: true, - configurable: true - }); - ToolBar.prototype.open = function () { - /// - /// - /// Opens the ToolBar - /// - /// - this._commandingSurface.open(); - }; - ToolBar.prototype.close = function () { - /// - /// - /// Closes the ToolBar - /// - /// - this._commandingSurface.close(); - }; - ToolBar.prototype.dispose = function () { - /// - /// - /// Disposes this ToolBar. - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - _LightDismissService.hidden(this._dismissable); - // Disposing the _commandingSurface will trigger dispose on its OpenCloseMachine and synchronously complete any animations that might have been running. - this._commandingSurface.dispose(); - // If page navigation is happening, we don't want the ToolBar left behind in the body. - // Synchronoulsy close the ToolBar to force it out of the body and back into its parent element. - this._synchronousClose(); - _ElementUtilities._inputPaneListener.removeEventListener(this._dom.root, "showing", this._handleShowingKeyboardBound); - _Dispose.disposeSubTree(this.element); - }; - ToolBar.prototype.forceLayout = function () { - /// - /// - /// Forces the ToolBar to update its layout. Use this function when the window did not change size, but the container of the ToolBar changed size. - /// - /// - this._commandingSurface.forceLayout(); - }; - ToolBar.prototype.getCommandById = function (id) { - /// - /// - /// Retrieves the command with the specified ID from this ToolBar. - /// If more than one command is found, this method returns the first command found. - /// - /// Id of the command to return. - /// - /// The command found, or null if no command is found. - /// - /// - return this._commandingSurface.getCommandById(id); - }; - ToolBar.prototype.showOnlyCommands = function (commands) { - /// - /// - /// Show the specified commands, hiding all of the others in the ToolBar. - /// - /// - /// An array of the commands to show. The array elements may be Command objects, or the string identifiers (IDs) of commands. - /// - /// - return this._commandingSurface.showOnlyCommands(commands); - }; - ToolBar.prototype._writeProfilerMark = function (text) { - _WriteProfilerMark("WinJS.UI.ToolBar:" + this._id + ":" + text); - }; - ToolBar.prototype._initializeDom = function (root) { - this._writeProfilerMark("_intializeDom,info"); - // Attaching JS control to DOM element - root["winControl"] = this; - this._id = root.id || _ElementUtilities._uniqueID(root); - _ElementUtilities.addClass(root, _Constants.ClassNames.controlCssClass); - _ElementUtilities.addClass(root, _Constants.ClassNames.disposableCssClass); - // Make sure we have an ARIA role - var role = root.getAttribute("role"); - if (!role) { - root.setAttribute("role", "menubar"); - } - var label = root.getAttribute("aria-label"); - if (!label) { - root.setAttribute("aria-label", strings.ariaLabel); - } - // Create element for commandingSurface and reparent any declarative Commands. - // The CommandingSurface constructor will parse child elements as AppBarCommands. - var commandingSurfaceEl = document.createElement("DIV"); - _ElementUtilities._reparentChildren(root, commandingSurfaceEl); - root.appendChild(commandingSurfaceEl); - // While the ToolBar is open, it will place itself in the so it can become a light dismissible - // overlay. It leaves the placeHolder element behind as stand in at the ToolBar's original DOM location - // to avoid reflowing surrounding app content and create the illusion that the ToolBar hasn't moved along - // the x or y planes. - var placeHolder = _Global.document.createElement("DIV"); - _ElementUtilities.addClass(placeHolder, _Constants.ClassNames.placeHolderCssClass); - // If the ToolBar's original HTML parent node is disposed while the ToolBar is open and repositioned as - // a temporary child of the , make sure that calling dispose on the placeHolder element will trigger - // dispose on the ToolBar as well. - _Dispose.markDisposable(placeHolder, this.dispose.bind(this)); - this._dom = { - root: root, - commandingSurfaceEl: commandingSurfaceEl, - placeHolder: placeHolder, - }; - }; - ToolBar.prototype._handleShowingKeyboard = function (event) { - // Because the ToolBar takes up layout space and is not an overlay, it doesn't have the same expectation - // to move itself to get out of the way of a showing IHM. Instsead we just close the ToolBar to avoid - // scenarios where the ToolBar is occluded, but the click-eating-div is still present since it may seem - // strange to end users that an occluded ToolBar (out of sight, out of mind) is still eating their first - // click. - // Mitigation: - // Because (1) custom content in a ToolBar can only be included as a 'content' type command, because (2) - // the ToolBar only supports closedDisplayModes 'compact' and 'full', and because (3) 'content' type - // commands in the overflowarea use a separate contentflyout to display their contents: - // Interactable custom content contained within the ToolBar actionarea or overflowarea, will remain - // visible and interactable even when showing the IHM closes the ToolBar. - this.close(); - }; - ToolBar.prototype._synchronousOpen = function () { - this._isOpenedMode = true; - this._updateDomImpl(); - }; - ToolBar.prototype._synchronousClose = function () { - this._isOpenedMode = false; - this._updateDomImpl(); - }; - ToolBar.prototype._updateDomImpl = function () { - var rendered = this._updateDomImpl_renderedState; - if (rendered.isOpenedMode !== this._isOpenedMode) { - if (this._isOpenedMode) { - this._updateDomImpl_renderOpened(); - } - else { - this._updateDomImpl_renderClosed(); - } - rendered.isOpenedMode = this._isOpenedMode; - } - if (rendered.closedDisplayMode !== this.closedDisplayMode) { - removeClass(this._dom.root, closedDisplayModeClassMap[rendered.closedDisplayMode]); - addClass(this._dom.root, closedDisplayModeClassMap[this.closedDisplayMode]); - rendered.closedDisplayMode = this.closedDisplayMode; - } - this._commandingSurface.updateDomImpl(); - }; - ToolBar.prototype._getClosedHeight = function () { - if (this._cachedClosedHeight === null) { - var wasOpen = this._isOpenedMode; - if (this._isOpenedMode) { - this._synchronousClose(); - } - this._cachedClosedHeight = this._commandingSurface.getBoundingRects().commandingSurface.height; - if (wasOpen) { - this._synchronousOpen(); - } - } - return this._cachedClosedHeight; - }; - ToolBar.prototype._updateDomImpl_renderOpened = function () { - var _this = this; - // Measure closed state. - this._updateDomImpl_renderedState.prevInlineWidth = this._dom.root.style.width; - var closedBorderBox = this._dom.root.getBoundingClientRect(); - var closedContentWidth = _ElementUtilities._getPreciseContentWidth(this._dom.root); - var closedContentHeight = _ElementUtilities._getPreciseContentHeight(this._dom.root); - var closedStyle = getComputedStyle(this._dom.root); - var closedPaddingTop = _ElementUtilities._convertToPrecisePixels(closedStyle.paddingTop); - var closedBorderTop = _ElementUtilities._convertToPrecisePixels(closedStyle.borderTopWidth); - var closedMargins = _ElementUtilities._getPreciseMargins(this._dom.root); - var closedContentBoxTop = closedBorderBox.top + closedBorderTop + closedPaddingTop; - var closedContentBoxBottom = closedContentBoxTop + closedContentHeight; - // Size our placeHolder. Set height and width to match borderbox of the closed ToolBar. - // Copy ToolBar margins to the placeholder. - var placeHolder = this._dom.placeHolder; - var placeHolderStyle = placeHolder.style; - placeHolderStyle.width = closedBorderBox.width + "px"; - placeHolderStyle.height = closedBorderBox.height + "px"; - placeHolderStyle.marginTop = closedMargins.top + "px"; - placeHolderStyle.marginRight = closedMargins.right + "px"; - placeHolderStyle.marginBottom = closedMargins.bottom + "px"; - placeHolderStyle.marginLeft = closedMargins.left + "px"; - _ElementUtilities._maintainFocus(function () { - // Move ToolBar element to the body in preparation of becoming a light dismissible. Leave an equal sized placeHolder element - // at our original DOM location to avoid reflowing surrounding app content. - _this._dom.root.parentElement.insertBefore(placeHolder, _this._dom.root); - _Global.document.body.appendChild(_this._dom.root); - // Position the ToolBar to completely cover the same region as the placeholder element. - _this._dom.root.style.width = closedContentWidth + "px"; - _this._dom.root.style.left = closedBorderBox.left - closedMargins.left + "px"; - // Determine which direction to expand the CommandingSurface elements when opened. The overflow area will be rendered at the corresponding edge of - // the ToolBar's content box, so we choose the direction that offers the most space between that edge and the corresponding edge of the viewport. - // This is to reduce the chance that the overflow area might clip through the edge of the viewport. - var topOfViewport = 0; - var bottomOfViewport = _Global.innerHeight; - var distanceFromTop = closedContentBoxTop - topOfViewport; - var distanceFromBottom = bottomOfViewport - closedContentBoxBottom; - if (distanceFromTop > distanceFromBottom) { - // CommandingSurface is going to expand updwards. - _this._commandingSurface.overflowDirection = _Constants.OverflowDirection.top; - // Position the bottom edge of the ToolBar marginbox over the bottom edge of the placeholder marginbox. - _this._dom.root.style.bottom = (bottomOfViewport - closedBorderBox.bottom) - closedMargins.bottom + "px"; - } - else { - // CommandingSurface is going to expand downwards. - _this._commandingSurface.overflowDirection = _Constants.OverflowDirection.bottom; - // Position the top edge of the ToolBar marginbox over the top edge of the placeholder marginbox. - _this._dom.root.style.top = (topOfViewport + closedBorderBox.top) - closedMargins.top + "px"; - } - // Render opened state - _ElementUtilities.addClass(_this._dom.root, _Constants.ClassNames.openedClass); - _ElementUtilities.removeClass(_this._dom.root, _Constants.ClassNames.closedClass); - }); - this._commandingSurface.synchronousOpen(); - _LightDismissService.shown(this._dismissable); // Call at the start of the open animation - }; - ToolBar.prototype._updateDomImpl_renderClosed = function () { - var _this = this; - _ElementUtilities._maintainFocus(function () { - if (_this._dom.placeHolder.parentElement) { - // Restore our placement in the DOM - var placeHolder = _this._dom.placeHolder; - placeHolder.parentElement.insertBefore(_this._dom.root, placeHolder); - placeHolder.parentElement.removeChild(placeHolder); - } - // Render Closed - _this._dom.root.style.top = ""; - _this._dom.root.style.right = ""; - _this._dom.root.style.bottom = ""; - _this._dom.root.style.left = ""; - _this._dom.root.style.width = _this._updateDomImpl_renderedState.prevInlineWidth; - _ElementUtilities.addClass(_this._dom.root, _Constants.ClassNames.closedClass); - _ElementUtilities.removeClass(_this._dom.root, _Constants.ClassNames.openedClass); - }); - this._commandingSurface.synchronousClose(); - _LightDismissService.hidden(this._dismissable); // Call after the close animation - }; - /// - /// Display options for the actionarea when the ToolBar is closed. - /// - ToolBar.ClosedDisplayMode = ClosedDisplayMode; - ToolBar.supportedForProcessing = true; - return ToolBar; - })(); - exports.ToolBar = ToolBar; - _Base.Class.mix(ToolBar, _Events.createEventProperties(_Constants.EventNames.beforeOpen, _Constants.EventNames.afterOpen, _Constants.EventNames.beforeClose, _Constants.EventNames.afterClose)); - // addEventListener, removeEventListener, dispatchEvent - _Base.Class.mix(ToolBar, _Control.DOMEventMixin); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/ToolBar',["require", "exports", '../Core/_Base'], function (require, exports, _Base) { - var module = null; - _Base.Namespace.define("WinJS.UI", { - ToolBar: { - get: function () { - if (!module) { - require(["./ToolBar/_ToolBar"], function (m) { - module = m; - }); - } - return module.ToolBar; - } - } - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/_LegacyAppBar/_Layouts',[ - 'exports', - '../../Animations/_TransitionAnimation', - '../../BindingList', - '../../Core/_BaseUtils', - '../../Core/_Global', - '../../Core/_Base', - '../../Core/_ErrorFromName', - '../../Core/_Resources', - '../../Core/_WriteProfilerMark', - '../../Controls/ToolBar', - '../../Controls/ToolBar/_Constants', - '../../Promise', - '../../Scheduler', - '../../Utilities/_Control', - '../../Utilities/_Dispose', - '../../Utilities/_ElementUtilities', - '../AppBar/_Command', - './_Constants' -], function appBarLayoutsInit(exports, _TransitionAnimation, BindingList, _BaseUtils, _Global, _Base, _ErrorFromName, _Resources, _WriteProfilerMark, ToolBar, _ToolBarConstants, Promise, Scheduler, _Control, _Dispose, _ElementUtilities, _Command, _Constants) { - "use strict"; - - // AppBar will use this when AppBar.layout property is set to "custom" - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - _AppBarBaseLayout: _Base.Namespace._lazy(function () { - var baseType = _Constants.appBarLayoutCustom; - - var strings = { - get nullCommand() { return "Invalid argument: command must not be null"; } - }; - - var _AppBarBaseLayout = _Base.Class.define(function _AppBarBaseLayout_ctor(appBarEl, options) { - this._disposed = false; - - options = options || {}; - _Control.setOptions(this, options); - - if (appBarEl) { - this.connect(appBarEl); - } - }, { - // Members - className: { - get: function _AppBarBaseLayout_get_className() { - return this._className; - }, - }, - type: { - get: function _AppBarBaseLayout_get_className() { - return this._type || baseType; - }, - }, - commandsInOrder: { - get: function _AppBarBaseLayout_get_commandsInOrder() { - // Get a DOM ordered collection of the AppBarCommand elements in the AppBar. - var commandElements = this.appBarEl.querySelectorAll("." + _Constants.appBarCommandClass); - - // Return an array of AppBarCommand objects. - return Array.prototype.map.call(commandElements, function (commandElement) { - return commandElement.winControl; - }); - } - }, - connect: function _AppBarBaseLayout_connect(appBarEl) { - if (this.className) { - _ElementUtilities.addClass(appBarEl, this.className); - } - this.appBarEl = appBarEl; - }, - disconnect: function _AppBarBaseLayout_disconnect() { - if (this.className) { - _ElementUtilities.removeClass(this.appBarEl, this.className); - } - this.appBarEl = null; - this.dispose(); - }, - layout: function _AppBarBaseLayout_layout(commands) { - // Append commands to the DOM. - var len = commands.length; - for (var i = 0; i < len; i++) { - var command = this.sanitizeCommand(commands[i]); - this.appBarEl.appendChild(command._element); - } - }, - showCommands: function _AppBarBaseLayout_showCommands(commands) { - // Use the default overlay showCommands implementation - this.appBarEl.winControl._showCommands(commands); - }, - showOnlyCommands: function _AppBarBaseLayout_showOnlyCommands(commands) { - // Use the default overlay _showOnlyCommands implementation - this.appBarEl.winControl._showOnlyCommands(commands); - }, - hideCommands: function _AppBarBaseLayout_hideCommands(commands) { - // Use the default overlay _hideCommands implementation - this.appBarEl.winControl._hideCommands(commands); - }, - sanitizeCommand: function _AppBarBaseLayout_sanitizeCommand(command) { - if (!command) { - throw new _ErrorFromName("WinJS.UI.AppBar.NullCommand", strings.nullCommand); - } - // See if it's a command already - command = command.winControl || command; - if (!command._element) { - // Not a command, so assume it is options for the command's constructor. - command = new _Command.AppBarCommand(null, command); - } - // If we were attached somewhere else, detach us - if (command._element.parentElement) { - command._element.parentElement.removeChild(command._element); - } - - return command; - }, - dispose: function _AppBarBaseLayout_dispose() { - this._disposed = true; - }, - disposeChildren: function _AppBarBaseLayout_disposeChildren() { - var appBarFirstDiv = this.appBarEl.querySelectorAll("." + _Constants.firstDivClass); - appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; - var appBarFinalDiv = this.appBarEl.querySelectorAll("." + _Constants.finalDivClass); - appBarFinalDiv = appBarFinalDiv.length >= 1 ? appBarFinalDiv[0] : null; - - var children = this.appBarEl.children; - var length = children.length; - for (var i = 0; i < length; i++) { - var element = children[i]; - if (element === appBarFirstDiv || element === appBarFinalDiv) { - continue; - } else { - _Dispose.disposeSubTree(element); - } - } - }, - handleKeyDown: function _AppBarBaseLayout_handleKeyDown() { - // NOP - }, - commandsUpdated: function _AppBarBaseLayout_commandsUpdated() { - // NOP - }, - beginAnimateCommands: function _AppBarBaseLayout_beginAnimateCommands() { - // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. - // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. - // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE scheduled to hide. - // 3) otherVisibleCommands[]: All VISIBLE win-command elements that ARE NOT scheduled to hide. - - // NOP - }, - endAnimateCommands: function _AppBarBaseLayout_endAnimateCommands() { - // NOP - }, - scale: function _AppBarBaseLayout_scale() { - // NOP - }, - resize: function _AppBarBaseLayout_resize() { - // NOP - }, - positionChanging: function _AppBarBaseLayout_positionChanging(fromPosition, toPosition) { - // NOP - return Promise.wrap(); - }, - setFocusOnShow: function _AppBarBaseLayout_setFocusOnShow() { - this.appBarEl.winControl._setFocusToAppBar(); - } - }); - return _AppBarBaseLayout; - }), - }); - - // AppBar will use this when AppBar.layout property is set to "commands" - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - _AppBarCommandsLayout: _Base.Namespace._lazy(function () { - var layoutClassName = _Constants.commandLayoutClass; - var layoutType = _Constants.appBarLayoutCommands; - - var _AppBarCommandsLayout = _Base.Class.derive(exports._AppBarBaseLayout, function _AppBarCommandsLayout_ctor(appBarEl) { - exports._AppBarBaseLayout.call(this, appBarEl, { _className: layoutClassName, _type: layoutType }); - this._commandLayoutsInit(appBarEl); - }, { - commandsInOrder: { - get: function _AppBarCommandsLayout_get_commandsInOrder() { - return this._originalCommands.filter(function (command) { - // Make sure the element is still in the AppBar. - return this.appBarEl.contains(command.element); - }, this); - } - }, - layout: function _AppBarCommandsLayout_layout(commands) { - // Insert commands and other layout specific DOM into the AppBar element. - - // Empty our tree. - _ElementUtilities.empty(this._primaryCommands); - _ElementUtilities.empty(this._secondaryCommands); - - // Keep track of the order we receive the commands in. - this._originalCommands = []; - - // Layout commands - for (var i = 0, len = commands.length; i < len; i++) { - var command = this.sanitizeCommand(commands[i]); - - this._originalCommands.push(command); - - if ("primary" === command.section || "global" === command.section) { - this._primaryCommands.appendChild(command._element); - } else { - this._secondaryCommands.appendChild(command._element); - } - } - - // Append layout containers to AppBar element. - // Secondary Commands should come first in Tab Order. - this.appBarEl.appendChild(this._secondaryCommands); - this.appBarEl.appendChild(this._primaryCommands); - - - // Need to measure all content commands after they have been added to the AppBar to make sure we allow - // user defined CSS rules based on the ancestor of the content command to take affect. - this._needToMeasureNewCommands = true; - - // In case this is called from the constructor before the AppBar element has been appended to the DOM, - // we schedule the initial scaling of commands, with the expectation that the element will be added - // synchronously, in the same block of code that called the constructor. - Scheduler.schedule(function () { - if (this._needToMeasureNewCommands && !this._disposed) { - this.scale(); - } - }.bind(this), Scheduler.Priority.idle, this, "WinJS._commandLayoutsMixin._scaleNewCommands"); - - }, - disposeChildren: function _AppBarCommandsLayout_disposeChildren() { - _Dispose.disposeSubTree(this._primaryCommands); - _Dispose.disposeSubTree(this._secondaryCommands); - }, - handleKeyDown: function _AppBarCommandsLayout_handleKeyDown(event) { - var Key = _ElementUtilities.Key; - - if (_ElementUtilities._matchesSelector(event.target, ".win-interactive, .win-interactive *")) { - return; // Ignore left, right, home & end keys if focused element has win-interactive class. - } - var rtl = _Global.getComputedStyle(this.appBarEl).direction === "rtl"; - var leftKey = rtl ? Key.rightArrow : Key.leftArrow; - var rightKey = rtl ? Key.leftArrow : Key.rightArrow; - - if (event.keyCode === leftKey || event.keyCode === rightKey || event.keyCode === Key.home || event.keyCode === Key.end) { - - var globalCommandHasFocus = this._primaryCommands.contains(_Global.document.activeElement); - var focusableCommands = this._getFocusableCommandsInLogicalOrder(globalCommandHasFocus); - var targetCommand; - - if (focusableCommands.length) { - switch (event.keyCode) { - case leftKey: - // Arrowing past the last command wraps back around to the first command. - var index = Math.max(-1, focusableCommands.focusedIndex - 1) + focusableCommands.length; - targetCommand = focusableCommands[index % focusableCommands.length].winControl.lastElementFocus; - break; - - case rightKey: - // Arrowing previous to the first command wraps back around to the last command. - var index = focusableCommands.focusedIndex + 1 + focusableCommands.length; - targetCommand = focusableCommands[index % focusableCommands.length].winControl.firstElementFocus; - break; - - case Key.home: - var index = 0; - targetCommand = focusableCommands[index].winControl.firstElementFocus; - break; - - case Key.end: - var index = focusableCommands.length - 1; - targetCommand = focusableCommands[index].winControl.lastElementFocus; - break; - } - } - - if (targetCommand && targetCommand !== _Global.document.activeElement) { - targetCommand.focus(); - // Prevent default so that the browser doesn't also evaluate the keydown event on the newly focused element. - event.preventDefault(); - } - } - }, - commandsUpdated: function _AppBarCommandsLayout_commandsUpdated(newSetOfVisibleCommands) { - // Whenever new commands are set or existing commands are hiding/showing in the AppBar, this - // function is called to update the cached width measurement of all visible AppBarCommands. - - var visibleCommands = (newSetOfVisibleCommands) ? newSetOfVisibleCommands : this.commandsInOrder.filter(function (command) { - return !command.hidden; - }); - this._fullSizeWidthOfLastKnownVisibleCommands = this._getWidthOfFullSizeCommands(visibleCommands); - }, - beginAnimateCommands: function _AppBarCommandsLayout_beginAnimateCommands(showCommands, hideCommands, otherVisibleCommands) { - // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. - // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. - // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE scheduled to hide. - // 3) otherVisibleCommands[]: All VISIBLE win-command elements that ARE NOT scheduled to hide. - - this._scaleAfterAnimations = false; - - // Determine if the overall width of visible commands in the primary row will be increasing OR decreasing. - var changeInWidth = this._getWidthOfFullSizeCommands(showCommands) - this._getWidthOfFullSizeCommands(hideCommands); - if (changeInWidth > 0) { - // Width of contents is going to increase, update our command counts now, to what they will be after we complete the animations. - var visibleCommandsAfterAnimations = otherVisibleCommands.concat(showCommands); - this.commandsUpdated(visibleCommandsAfterAnimations); - // Make sure we will have enough room to fit everything on a single row. - this.scale(); - } else if (changeInWidth < 0) { - // Width of contents is going to decrease. Once animations are complete, check if - // there is enough available space to make the remaining commands full size. - this._scaleAfterAnimations = true; - } - }, - endAnimateCommands: function _AppBarCommandsLayout_endAnimateCommands() { - if (this._scaleAfterAnimations) { - this.commandsUpdated(); - this.scale(); - } - }, - resize: function _AppBarCommandsLayout_resize() { - if (!this._disposed) { - // Check for horizontal window resizes. - this._appBarTotalKnownWidth = null; - if (this.appBarEl.winControl.opened) { - this.scale(); - } - } - }, - disconnect: function _AppBarCommandsLayout_disconnect() { - exports._AppBarBaseLayout.prototype.disconnect.call(this); - }, - _getWidthOfFullSizeCommands: function _AppBarCommandsLayout_getWidthOfFullSizeCommands(commands) { - // Commands layout puts primary commands and secondary commands into the primary row. - // Return the total width of all visible primary and secondary commands as if they were full-size. - - // Perform any pending measurements on "content" type AppBarCommands. - if (this._needToMeasureNewCommands) { - this._measureContentCommands(); - } - var accumulatedWidth = 0; - var separatorsCount = 0; - var buttonsCount = 0; - - if (!commands) { - // Return the cached full size width of the last known visible commands in the AppBar. - return this._fullSizeWidthOfLastKnownVisibleCommands; - } else { - // Return the width of the specified commands. - var command; - for (var i = 0, len = commands.length; i < len; i++) { - command = commands[i].winControl || commands[i]; - if (command._type === _Constants.typeSeparator) { - separatorsCount++; - } else if (command._type !== _Constants.typeContent) { - // button, toggle, and flyout types all have the same width. - buttonsCount++; - } else { - accumulatedWidth += command._fullSizeWidth; - } - } - } - return accumulatedWidth += (separatorsCount * _Constants.separatorWidth) + (buttonsCount * _Constants.buttonWidth); - }, - _getFocusableCommandsInLogicalOrder: function _AppBarCommandsLayout_getCommandsInLogicalOrder() { - // Function returns an array of all the contained AppBarCommands which are reachable by left/right arrows. - - var secondaryCommands = this._secondaryCommands.children, - primaryCommands = this._primaryCommands.children, - focusedIndex = -1; - - var getFocusableCommandsHelper = function (commandsInReach) { - var focusableCommands = []; - for (var i = 0, len = commandsInReach.length; i < len; i++) { - var element = commandsInReach[i]; - if (_ElementUtilities.hasClass(element, _Constants.appBarCommandClass) && element.winControl) { - var containsFocus = element.contains(_Global.document.activeElement); - // With the inclusion of content type commands, it may be possible to tab to elements in AppBarCommands that are not reachable by arrow keys. - // Regardless, when an AppBarCommand contains the element with focus, we just include the whole command so that we can determine which - // commands are adjacent to it when looking for the next focus destination. - if (element.winControl._isFocusable() || containsFocus) { - focusableCommands.push(element); - if (containsFocus) { - focusedIndex = focusableCommands.length - 1; - } - } - } - } - return focusableCommands; - }; - - // Determines which set of commands the user could potentially reach through Home, End, and arrow keys. - // All commands in the commands layout AppBar, from left to right are in reach. Secondary (previously known as Selection) - // then Primary (previously known as Global). - var commandsInReach = Array.prototype.slice.call(secondaryCommands).concat(Array.prototype.slice.call(primaryCommands)); - - var focusableCommands = getFocusableCommandsHelper(commandsInReach); - focusableCommands.focusedIndex = focusedIndex; - return focusableCommands; - }, - _commandLayoutsInit: function _AppBarCommandsLayout_commandLayoutsInit() { - // Create layout infrastructure - this._primaryCommands = _Global.document.createElement("DIV"); - this._secondaryCommands = _Global.document.createElement("DIV"); - _ElementUtilities.addClass(this._primaryCommands, _Constants.primaryCommandsClass); - _ElementUtilities.addClass(this._secondaryCommands, _Constants.secondaryCommandsClass); - }, - _scaleHelper: function _AppBarCommandsLayout_scaleHelper() { - // This exists as a single line function so that unit tests can - // overwrite it since they can't resize the WWA window. - - // It is expected that AppBar is an immediate child of the and will have 100% width. - // We measure the clientWidth of the documentElement so that we can scale the AppBar lazily - // even while its element is display: 'none' - var extraPadding = this.appBarEl.winControl.closedDisplayMode === "minimal" ? _Constants.appBarInvokeButtonWidth : 0; - return _Global.document.documentElement.clientWidth - extraPadding; - }, - _measureContentCommands: function _AppBarCommandsLayout_measureContentCommands() { - // AppBar measures the width of content commands when they are first added - // and then caches that value to avoid additional layouts in the future. - - // Can't measure unless We're in the document body - if (_Global.document.body.contains(this.appBarEl)) { - this._needToMeasureNewCommands = false; - - var hadHiddenClass = _ElementUtilities.hasClass(this.appBarEl, "win-navbar-closed"); - _ElementUtilities.removeClass(this.appBarEl, "win-navbar-closed"); - - // Make sure AppBar and children have width dimensions. - var prevAppBarDisplay = this.appBarEl.style.display; - this.appBarEl.style.display = ""; - var prevCommandDisplay; - - var contentElements = this.appBarEl.querySelectorAll("div." + _Constants.appBarCommandClass); - var element; - for (var i = 0, len = contentElements.length; i < len; i++) { - element = contentElements[i]; - if (element.winControl && element.winControl._type === _Constants.typeContent) { - // Make sure command has width dimensions before we measure. - prevCommandDisplay = element.style.display; - element.style.display = ""; - element.winControl._fullSizeWidth = _ElementUtilities.getTotalWidth(element) || 0; - element.style.display = prevCommandDisplay; - } - } - - // Restore state to AppBar. - this.appBarEl.style.display = prevAppBarDisplay; - if (hadHiddenClass) { - _ElementUtilities.addClass(this.appBarEl, "win-navbar-closed"); - } - - this.commandsUpdated(); - } - }, - }); - return _AppBarCommandsLayout; - }), - }); - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - _AppBarMenuLayout: _Base.Namespace._lazy(function () { - var layoutClassName = _Constants.menuLayoutClass; - var layoutType = _Constants.appBarLayoutMenu; - - // - // Resize animation - // The resize animation requires 2 animations to run simultaneously in sync with each other. It's implemented - // without PVL because PVL doesn't provide a way to guarantee that 2 animations will start at the same time. - // - var transformNames = _BaseUtils._browserStyleEquivalents["transform"]; - function transformWithTransition(element, transition) { - // transition's properties: - // - duration: Number representing the duration of the animation in milliseconds. - // - timing: String representing the CSS timing function that controls the progress of the animation. - // - to: The value of *element*'s transform property after the animation. - var duration = transition.duration * _TransitionAnimation._animationFactor; - var transitionProperty = _BaseUtils._browserStyleEquivalents["transition"].scriptName; - element.style[transitionProperty] = duration + "ms " + transformNames.cssName + " " + transition.timing; - element.style[transformNames.scriptName] = transition.to; - - var finish; - return new Promise(function (c) { - var onTransitionEnd = function (eventObject) { - if (eventObject.target === element && eventObject.propertyName === transformNames.cssName) { - finish(); - } - }; - - var didFinish = false; - finish = function () { - if (!didFinish) { - _Global.clearTimeout(timeoutId); - element.removeEventListener(_BaseUtils._browserEventEquivalents["transitionEnd"], onTransitionEnd); - element.style[transitionProperty] = ""; - didFinish = true; - } - c(); - }; - - // Watch dog timeout - var timeoutId = _Global.setTimeout(function () { - timeoutId = _Global.setTimeout(finish, duration); - }, 50); - - element.addEventListener(_BaseUtils._browserEventEquivalents["transitionEnd"], onTransitionEnd); - }, function () { - finish(); // On cancelation, complete the promise successfully to match PVL - }); - } - // See resizeTransition's comment for documentation on *args*. - function growTransition(elementClipper, element, args) { - var diff = args.anchorTrailingEdge ? args.to.total - args.from.total : args.from.total - args.to.total; - var translate = args.dimension === "width" ? "translateX" : "translateY"; - var size = args.dimension; - var duration = args.duration || 367; - var timing = args.timing || "cubic-bezier(0.1, 0.9, 0.2, 1)"; - - // Set up - elementClipper.style[size] = args.to.total + "px"; - elementClipper.style[transformNames.scriptName] = translate + "(" + diff + "px)"; - element.style[size] = args.to.content + "px"; - element.style[transformNames.scriptName] = translate + "(" + -diff + "px)"; - - // Resolve styles - _Global.getComputedStyle(elementClipper).opacity; - _Global.getComputedStyle(element).opacity; - - // Animate - var transition = { - duration: duration, - timing: timing, - to: "" - }; - return Promise.join([ - transformWithTransition(elementClipper, transition), - transformWithTransition(element, transition) - ]); - } - // See resizeTransition's comment for documentation on *args*. - function shrinkTransition(elementClipper, element, args) { - var diff = args.anchorTrailingEdge ? args.from.total - args.to.total : args.to.total - args.from.total; - var translate = args.dimension === "width" ? "translateX" : "translateY"; - var duration = args.duration || 367; - var timing = args.timing || "cubic-bezier(0.1, 0.9, 0.2, 1)"; - - // Set up - elementClipper.style[transformNames.scriptName] = ""; - element.style[transformNames.scriptName] = ""; - - // Resolve styles - _Global.getComputedStyle(elementClipper).opacity; - _Global.getComputedStyle(element).opacity; - - // Animate - var transition = { - duration: duration, - timing: timing - }; - var clipperTransition = _BaseUtils._merge(transition, { to: translate + "(" + diff + "px)" }); - var elementTransition = _BaseUtils._merge(transition, { to: translate + "(" + -diff + "px)" }); - return Promise.join([ - transformWithTransition(elementClipper, clipperTransition), - transformWithTransition(element, elementTransition) - ]); - } - // Plays an animation which makes an element look like it is resizing in 1 dimension. Arguments: - // - elementClipper: The parent of *element*. It shouldn't have any margin, border, or padding and its - // size should match element's size. Its purpose is to clip *element* during the animation to give - // it the illusion that it is resizing. - // - element: The element that should look like it's resizing. - // - args: An object with the following required properties: - // - from: An object representing the old width/height of the element. - // - to: An object representing the new width/height of the element. - // from/to are objects of the form { content: number; total: number; }. "content" is the - // width/height of *element*'s content box (e.g. getContentWidth). "total" is the width/height - // of *element*'s margin box (e.g. getTotalWidth). - // - duration: The CSS transition duration property. - // - timing: The CSS transition timing property. - // - dimension: The dimension on which *element* is resizing. Either "width" or "height". - // - anchorTrailingEdge: During the resize animation, one edge will move and the other edge will - // remain where it is. This flag specifies which edge is anchored (i.e. won't move). - // - function resizeTransition(elementClipper, element, args) { - if (args.to.total > args.from.total) { - return growTransition(elementClipper, element, args); - } else if (args.to.total < args.from.total) { - return shrinkTransition(elementClipper, element, args); - } else { - return Promise.as(); - } - } - - var _AppBarMenuLayout = _Base.Class.derive(exports._AppBarBaseLayout, function _AppBarMenuLayout_ctor(appBarEl) { - exports._AppBarBaseLayout.call(this, appBarEl, { _className: layoutClassName, _type: layoutType }); - this._tranformNames = _BaseUtils._browserStyleEquivalents["transform"]; - this._animationCompleteBound = this._animationComplete.bind(this); - this._positionToolBarBound = this._positionToolBar.bind(this); - }, { - commandsInOrder: { - get: function _AppBarMenuLayout_get_commandsInOrder() { - return this._originalCommands; - } - }, - layout: function _AppBarMenuLayout_layout(commands) { - this._writeProfilerMark("layout,info"); - - commands = commands || []; - this._originalCommands = []; - - var that = this; - commands.forEach(function (command) { - that._originalCommands.push(that.sanitizeCommand(command)); - }); - this._displayedCommands = this._originalCommands.slice(0); - - if (this._menu) { - _ElementUtilities.empty(this._menu); - } else { - this._menu = _Global.document.createElement("div"); - _ElementUtilities.addClass(this._menu, _Constants.menuContainerClass); - } - this.appBarEl.appendChild(this._menu); - - this._toolbarEl = _Global.document.createElement("div"); - this._menu.appendChild(this._toolbarEl); - - this._createToolBar(commands); - }, - - showCommands: function _AppBarMenuLayout_showCommands(commands) { - var elements = this._getCommandsElements(commands); - var data = []; - var newDisplayedCommands = []; - var that = this; - this._originalCommands.forEach(function (command) { - if (elements.indexOf(command.element) >= 0 || that._displayedCommands.indexOf(command) >= 0) { - newDisplayedCommands.push(command); - data.push(command); - } - }); - this._displayedCommands = newDisplayedCommands; - this._updateData(data); - }, - - showOnlyCommands: function _AppBarMenuLayout_showOnlyCommands(commands) { - this._displayedCommands = []; - this.showCommands(commands); - }, - - hideCommands: function _AppBarMenuLayout_hideCommands(commands) { - var elements = this._getCommandsElements(commands); - var data = []; - var newDisplayedCommands = []; - var that = this; - this._originalCommands.forEach(function (command) { - if (elements.indexOf(command.element) === -1 && that._displayedCommands.indexOf(command) >= 0) { - newDisplayedCommands.push(command); - data.push(command); - } - }); - this._displayedCommands = newDisplayedCommands; - this._updateData(data); - }, - - connect: function _AppBarMenuLayout_connect(appBarEl) { - this._writeProfilerMark("connect,info"); - - exports._AppBarBaseLayout.prototype.connect.call(this, appBarEl); - this._id = _ElementUtilities._uniqueID(appBarEl); - }, - - resize: function _AppBarMenuLayout_resize() { - this._writeProfilerMark("resize,info"); - - if (this._initialized) { - this._forceLayoutPending = true; - } - }, - - positionChanging: function _AppBarMenuLayout_positionChanging(fromPosition, toPosition) { - this._writeProfilerMark("positionChanging from:" + fromPosition + " to: " + toPosition + ",info"); - - this._animationPromise = this._animationPromise || Promise.wrap(); - - if (this._animating) { - this._animationPromise.cancel(); - } - - this._animating = true; - if (toPosition === "shown" || (fromPosition !== "shown" && toPosition === "compact")) { - this._positionToolBar(); - this._animationPromise = this._animateToolBarEntrance(); - } else { - if (fromPosition === "minimal" || fromPosition === "compact" || fromPosition === "hidden") { - this._animationPromise = Promise.wrap(); - } else { - this._animationPromise = this._animateToolBarExit(); - } - } - this._animationPromise.then(this._animationCompleteBound, this._animationCompleteBound); - return this._animationPromise; - }, - - disposeChildren: function _AppBarMenuLayout_disposeChildren() { - this._writeProfilerMark("disposeChildren,info"); - - if (this._toolbar) { - _Dispose.disposeSubTree(this._toolbarEl); - } - this._originalCommands = []; - this._displayedCommands = []; - }, - - setFocusOnShow: function _AppBarMenuLayout_setFocusOnShow() { - // Make sure the menu (used for clipping during the resize animation) - // doesn't scroll when we give focus to the AppBar. - this.appBarEl.winControl._setFocusToAppBar(true, this._menu); - }, - - _updateData: function _AppBarMenuLayout_updateData(data) { - var hadHiddenClass = _ElementUtilities.hasClass(this.appBarEl, "win-navbar-closed"); - var hadShownClass = _ElementUtilities.hasClass(this.appBarEl, "win-navbar-opened"); - _ElementUtilities.removeClass(this.appBarEl, "win-navbar-closed"); - - // Make sure AppBar and children have width dimensions. - var prevAppBarDisplay = this.appBarEl.style.display; - this.appBarEl.style.display = ""; - - - this._toolbar.data = new BindingList.List(data); - if (hadHiddenClass) { - this._positionToolBar(); - } - - // Restore state to AppBar. - this.appBarEl.style.display = prevAppBarDisplay; - if (hadHiddenClass) { - _ElementUtilities.addClass(this.appBarEl, "win-navbar-closed"); - } - - if (hadShownClass) { - this._positionToolBar(); - this._animateToolBarEntrance(); - } - }, - - _getCommandsElements: function _AppBarMenuLayout_getCommandsElements(commands) { - if (!commands) { - return []; - } - - if (typeof commands === "string" || !commands || !commands.length) { - commands = [commands]; - } - - var elements = []; - for (var i = 0, len = commands.length; i < len; i++) { - if (commands[i]) { - if (typeof commands[i] === "string") { - var element = _Global.document.getElementById(commands[i]); - if (element) { - elements.push(element); - } else { - // Check in the list we are tracking, since it might not be in the DOM yet - for (var j = 0, len2 = this._originalCommands.length; j < len2; j++) { - var element = this._originalCommands[j].element; - if (element.id === commands[i]) { - elements.push(element); - } - } - } - } else if (commands[i].element) { - elements.push(commands[i].element); - } else { - elements.push(commands[i]); - } - } - } - - return elements; - }, - - _animationComplete: function _AppBarMenuLayout_animationComplete() { - if (!this._disposed) { - this._animating = false; - } - }, - - _createToolBar: function _AppBarMenuLayout_createToolBar(commands) { - this._writeProfilerMark("_createToolBar,info"); - - var hadHiddenClass = _ElementUtilities.hasClass(this.appBarEl, "win-navbar-closed"); - _ElementUtilities.removeClass(this.appBarEl, "win-navbar-closed"); - - // Make sure AppBar and children have width dimensions. - var prevAppBarDisplay = this.appBarEl.style.display; - this.appBarEl.style.display = ""; - - this._toolbar = new ToolBar.ToolBar(this._toolbarEl, { - data: new BindingList.List(this._originalCommands), - shownDisplayMode: 'full', - }); - - var that = this; - this._appbarInvokeButton = this.appBarEl.querySelector("." + _Constants.invokeButtonClass); - this._overflowButton = this._toolbarEl.querySelector("." + _ToolBarConstants.overflowButtonCssClass); - this._overflowButton.addEventListener("click", function () { - that._appbarInvokeButton.click(); - }); - - this._positionToolBar(); - - // Restore state to AppBar. - this.appBarEl.style.display = prevAppBarDisplay; - if (hadHiddenClass) { - _ElementUtilities.addClass(this.appBarEl, "win-navbar-closed"); - } - }, - - _positionToolBar: function _AppBarMenuLayout_positionToolBar() { - if (!this._disposed) { - this._writeProfilerMark("_positionToolBar,info"); - this._initialized = true; - } - }, - - _animateToolBarEntrance: function _AppBarMenuLayout_animateToolBarEntrance() { - this._writeProfilerMark("_animateToolBarEntrance,info"); - - if (this._forceLayoutPending) { - this._forceLayoutPending = false; - this._toolbar.forceLayout(); - this._positionToolBar(); - } - var heightVisible = this._isMinimal() ? 0 : this.appBarEl.offsetHeight; - if (this._isBottom()) { - // Bottom AppBar Animation - var offsetTop = this._menu.offsetHeight - heightVisible; - return this._executeTranslate(this._menu, "translateY(" + -offsetTop + "px)"); - } else { - // Top AppBar Animation - return resizeTransition(this._menu, this._toolbarEl, { - from: { content: heightVisible, total: heightVisible }, - to: { content: this._menu.offsetHeight, total: this._menu.offsetHeight }, - dimension: "height", - duration: 400, - timing: "ease-in", - }); - } - }, - - _animateToolBarExit: function _AppBarMenuLayout_animateToolBarExit() { - this._writeProfilerMark("_animateToolBarExit,info"); - - var heightVisible = this._isMinimal() ? 0 : this.appBarEl.offsetHeight; - if (this._isBottom()) { - return this._executeTranslate(this._menu, "none"); - } else { - // Top AppBar Animation - return resizeTransition(this._menu, this._toolbarEl, { - from: { content: this._menu.offsetHeight, total: this._menu.offsetHeight }, - to: { content: heightVisible, total: heightVisible }, - dimension: "height", - duration: 400, - timing: "ease-in", - }); - } - }, - - _executeTranslate: function _AppBarMenuLayout_executeTranslate(element, value) { - return _TransitionAnimation.executeTransition(element, - { - property: this._tranformNames.cssName, - delay: 0, - duration: 400, - timing: "ease-in", - to: value - }); - }, - - _isMinimal: function _AppBarMenuLayout_isMinimal() { - return this.appBarEl.winControl.closedDisplayMode === "minimal"; - }, - - _isBottom: function _AppBarMenuLayout_isBottom() { - return this.appBarEl.winControl.placement === "bottom"; - }, - - _writeProfilerMark: function _AppBarMenuLayout_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI._AppBarMenuLayout:" + this._id + ":" + text); - } - }); - - return _AppBarMenuLayout; - }), - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -// _LegacyAppBar -/// appbar,appBars,Flyout,Flyouts,iframe,Statics,unfocus,WinJS -define('WinJS/Controls/_LegacyAppBar',[ - 'exports', - '../Core/_Global', - '../Core/_WinRT', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_ErrorFromName', - '../Core/_Events', - '../Core/_Resources', - '../Core/_WriteProfilerMark', - '../Animations', - '../Promise', - '../Scheduler', - '../_LightDismissService', - '../Utilities/_Control', - '../Utilities/_Dispose', - '../Utilities/_ElementUtilities', - '../Utilities/_Hoverable', - '../Utilities/_KeyboardBehavior', - './_LegacyAppBar/_Constants', - './_LegacyAppBar/_Layouts', - './AppBar/_Command', - './AppBar/_Icon', - './Flyout/_Overlay', - '../Application' -], function appBarInit(exports, _Global, _WinRT, _Base, _BaseUtils, _ErrorFromName, _Events, _Resources, _WriteProfilerMark, Animations, Promise, Scheduler, _LightDismissService, _Control, _Dispose, _ElementUtilities, _Hoverable, _KeyboardBehavior, _Constants, _Layouts, _Command, _Icon, _Overlay, Application) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// - /// Represents an application toolbar for display commands. - /// - /// - /// - /// - /// - /// - /// ]]> - /// Raised just before showing the _LegacyAppBar. - /// Raised immediately after the _LegacyAppBar is fully shown. - /// Raised just before hiding the _LegacyAppBar. - /// Raised immediately after the _LegacyAppBar is fully hidden. - /// The _LegacyAppBar control itself. - /// Style for a custom layout _LegacyAppBar. - /// - /// - _LegacyAppBar: _Base.Namespace._lazy(function () { - var EVENTS = { - beforeOpen: "beforeopen", - afterOpen: "afteropen", - beforeClose: "beforeclose", - afterClose: "afterclose", - }; - - var createEvent = _Events._createEventProperty; - - // Enum of known constant pixel values for display modes. - var knownVisibleHeights = { - none: 0, - hidden: 0, - minimal: 25, - compact: 48 - }; - - // Maps each notion of a display modes to the corresponding visible position - var displayModeVisiblePositions = { - none: "hidden", - hidden: "hidden", - minimal: "minimal", - shown: "shown", - compact: "compact" - }; - - // Enum of closedDisplayMode constants - var closedDisplayModes = { - none: "none", - minimal: "minimal", - compact: "compact" - }; - - // Constants shown/hidden states - var appbarShownState = "shown", - appbarHiddenState = "hidden"; - - // Hook into event - var globalEventsInitialized = false; - - function _allManipulationChanged(event) { - var elements = _Global.document.querySelectorAll("." + _Constants.appBarClass); - if (elements) { - var len = elements.length; - for (var i = 0; i < len; i++) { - var element = elements[i]; - var appbar = element.winControl; - if (appbar && !element.disabled) { - appbar._manipulationChanged(event); - } - } - } - } - - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/appBarAriaLabel").value; }, - get requiresCommands() { return "Invalid argument: commands must not be empty"; }, - get cannotChangePlacementWhenVisible() { return "Invalid argument: The placement property cannot be set when the AppBar is visible, call hide() first"; }, - get cannotChangeLayoutWhenVisible() { return "Invalid argument: The layout property cannot be set when the AppBar is visible, call hide() first"; } - }; - - var _LegacyAppBar = _Base.Class.derive(_Overlay._Overlay, function _LegacyAppBar_ctor(element, options) { - /// - /// - /// Creates a new _LegacyAppBar control. - /// - /// - /// The DOM element that will host the control. - /// - /// - /// The set of properties and values to apply to the new _LegacyAppBar control. - /// - /// - /// The new _LegacyAppBar control. - /// - /// - - this._initializing = true; - - // Simplify checking later - options = options || {}; - - // Make sure there's an element - this._element = element || _Global.document.createElement("div"); - this._id = this._element.id || _ElementUtilities._uniqueID(this._element); - this._writeProfilerMark("constructor,StartTM"); - - // Attach our css class. - _ElementUtilities.addClass(this._element, _Constants.appBarClass); - - var that = this; - this._dismissable = new _LightDismissService.LightDismissableElement({ - element: this._element, - tabIndex: this._element.hasAttribute("tabIndex") ? this._element.tabIndex : -1, - onLightDismiss: function () { - that.close(); - }, - onTakeFocus: function (useSetActive) { - if (!that._dismissable.restoreFocus()) { - that._layoutImpl.setFocusOnShow(); - } - }, - }); - - // Make sure we have an ARIA role - var role = this._element.getAttribute("role"); - if (!role) { - this._element.setAttribute("role", "menubar"); - } - var label = this._element.getAttribute("aria-label"); - if (!label) { - this._element.setAttribute("aria-label", strings.ariaLabel); - } - - // Call the _Overlay constructor helper to finish setting up our element. - // Don't pass constructor options, _LegacyAppBar needs to set those itself specific order. - this._baseOverlayConstructor(this._element); - - // Start off hidden - this._lastPositionVisited = displayModeVisiblePositions.none; - _ElementUtilities.addClass(this._element, _Constants.hiddenClass); - - // Add Invoke button. - this._invokeButton = _Global.document.createElement("button"); - this._invokeButton.tabIndex = 0; - this._invokeButton.setAttribute("type", "button"); - this._invokeButton.innerHTML = ""; - _ElementUtilities.addClass(this._invokeButton, _Constants.invokeButtonClass); - this._element.appendChild(this._invokeButton); - this._invokeButton.addEventListener("click", function () { - if (that.opened) { - that._hide(); - } else { - that._show(); - } - }, false); - - // Run layout setter immediately. We need to know our layout in order to correctly - // position any commands that may be getting set through the constructor. - this._layout = _Constants.appBarLayoutCustom; - delete options._layout; - - // Need to set placement before closedDisplayMode, closedDisplayMode sets our starting position, which is dependant on placement. - this.placement = options.placement || _Constants.appBarPlacementBottom; - this.closedDisplayMode = options.closedDisplayMode || closedDisplayModes.compact; - - _Control.setOptions(this, options); - - var commandsUpdatedBound = this._commandsUpdated.bind(this); - this._element.addEventListener(_Constants.commandVisibilityChanged, function (ev) { - if (that._disposed) { - return; - } - if (that.opened) { - ev.preventDefault(); - } - commandsUpdatedBound(); - }); - - this._initializing = false; - - this._setFocusToAppBarBound = this._setFocusToAppBar.bind(this); - - // Handle key down (left & right) - this._element.addEventListener("keydown", this._handleKeyDown.bind(this), false); - - // Attach global event handlers - if (!globalEventsInitialized) { - // Need to know if the IHM is done scrolling - _Global.document.addEventListener("MSManipulationStateChanged", _allManipulationChanged, false); - - globalEventsInitialized = true; - } - - if (this.closedDisplayMode === closedDisplayModes.none && this.layout === _Constants.appBarLayoutCommands) { - // Remove the commands layout _LegacyAppBar from the layout tree at this point so we don't cause unnecessary layout costs whenever - // the window resizes or when CSS changes are applied to the commands layout _LegacyAppBar's parent element. - this._element.style.display = "none"; - } - - this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._element); - - this._writeProfilerMark("constructor,StopTM"); - - return this; - }, { - // Public Properties - - /// The placement of the _LegacyAppBar on the display. Values are "top" or "bottom". - placement: { - get: function _LegacyAppBar_get_placement() { - return this._placement; - }, - set: function _LegacyAppBar_set_placement(value) { - // In designer we may have to move it - var wasShown = false; - if (_WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { - this._hide(); - wasShown = true; - } - - if (this.opened) { - throw new _ErrorFromName("WinJS.UI._LegacyAppBar.CannotChangePlacementWhenVisible", strings.cannotChangePlacementWhenVisible); - } - - // Set placement, coerce invalid values to 'bottom' - this._placement = (value === _Constants.appBarPlacementTop) ? _Constants.appBarPlacementTop : _Constants.appBarPlacementBottom; - - // Clean up win-top, win-bottom styles - if (this._placement === _Constants.appBarPlacementTop) { - _ElementUtilities.addClass(this._element, _Constants.topClass); - _ElementUtilities.removeClass(this._element, _Constants.bottomClass); - } else if (this._placement === _Constants.appBarPlacementBottom) { - _ElementUtilities.removeClass(this._element, _Constants.topClass); - _ElementUtilities.addClass(this._element, _Constants.bottomClass); - } - - // Update our position on screen. - this._ensurePosition(); - if (wasShown) { - // Show again if we hid ourselves for the designer - this._show(); - } - } - }, - - _layout: { - get: function _LegacyAppBar_get_layout() { - return this._layoutImpl.type; - }, - set: function (layout) { - if (layout !== _Constants.appBarLayoutCommands && - layout !== _Constants.appBarLayoutCustom && - layout !== _Constants.appBarLayoutMenu) { - } - - // In designer we may have to redraw it - var wasShown = false; - if (_WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { - this._hide(); - wasShown = true; - } - - if (this.opened) { - throw new _ErrorFromName("WinJS.UI._LegacyAppBar.CannotChangeLayoutWhenVisible", strings.cannotChangeLayoutWhenVisible); - } - - var commands; - if (!this._initializing) { - // Gather commands in preparation for hand off to new layout. - // We expect prev layout to return commands in the order they were set in, - // not necessarily the current DOM order the layout is using. - commands = this._layoutImpl.commandsInOrder; - this._layoutImpl.disconnect(); - } - - // Set layout - if (layout === _Constants.appBarLayoutCommands) { - this._layoutImpl = new _Layouts._AppBarCommandsLayout(); - } else if (layout === _Constants.appBarLayoutMenu) { - this._layoutImpl = new _Layouts._AppBarMenuLayout(); - } else { - // Custom layout uses Base _LegacyAppBar Layout class. - this._layoutImpl = new _Layouts._AppBarBaseLayout(); - } - this._layoutImpl.connect(this._element); - - if (commands && commands.length) { - // Reset _LegacyAppBar since layout changed. - this._layoutCommands(commands); - } - - // Show again if we hid ourselves for the designer - if (wasShown) { - this._show(); - } - }, - configurable: true - }, - - /// - /// Sets the AppBarCommands in the _LegacyAppBar. This property accepts an array of AppBarCommand objects. - /// - commands: { - set: function _LegacyAppBar_set_commands(commands) { - // Fail if trying to set when shown - if (this.opened) { - throw new _ErrorFromName("WinJS.UI._LegacyAppBar.CannotChangeCommandsWhenVisible", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeCommandsWhenVisible, "_LegacyAppBar")); - } - - // Dispose old commands before tossing them out. - if (!this._initializing) { - // AppBarCommands defined in markup don't want to be disposed during initialization. - this._disposeChildren(); - } - this._layoutCommands(commands); - } - }, - - _layoutCommands: function _LegacyAppBar_layoutCommands(commands) { - // Function precondition: _LegacyAppBar must not be shown. - - // Empties _LegacyAppBar HTML and repopulates with passed in commands. - _ElementUtilities.empty(this._element); - this._element.appendChild(this._invokeButton); // Keep our Show/Hide button. - - // In case they had only one command to set... - if (!Array.isArray(commands)) { - commands = [commands]; - } - - this._layoutImpl.layout(commands); - }, - - /// - /// Gets/Sets how _LegacyAppBar will display itself while hidden. Values are "none", "minimal" and '"compact". - /// - closedDisplayMode: { - get: function _LegacyAppBar_get_closedDisplayMode() { - return this._closedDisplayMode; - }, - set: function _LegacyAppBar_set_closedDisplayMode(value) { - var oldValue = this._closedDisplayMode; - - if (oldValue !== value) { - - // Determine if the visible position is changing. This can be used to determine if we need to delay updating closedDisplayMode related CSS classes - // to avoid affecting the animation. - var changeVisiblePosition = _ElementUtilities.hasClass(this._element, _Constants.hiddenClass) || _ElementUtilities.hasClass(this._element, _Constants.hidingClass); - - if (value === closedDisplayModes.none) { - this._closedDisplayMode = closedDisplayModes.none; - if (!changeVisiblePosition || !oldValue) { - _ElementUtilities.removeClass(this._element, _Constants.minimalClass); - _ElementUtilities.removeClass(this._element, _Constants.compactClass); - } - } else if (value === closedDisplayModes.minimal) { - this._closedDisplayMode = closedDisplayModes.minimal; - if (!changeVisiblePosition || !oldValue || oldValue === closedDisplayModes.none) { - _ElementUtilities.addClass(this._element, _Constants.minimalClass); - _ElementUtilities.removeClass(this._element, _Constants.compactClass); - } - } else { - // Compact is default fallback. - this._closedDisplayMode = closedDisplayModes.compact; - _ElementUtilities.addClass(this._element, _Constants.compactClass); - _ElementUtilities.removeClass(this._element, _Constants.minimalClass); - } - - // The invoke button has changed the amount of available space in the _LegacyAppBar. Layout might need to scale. - this._layoutImpl.resize(); - - if (changeVisiblePosition) { - // If the value is being set while we are not showing, change to our new position. - this._changeVisiblePosition(displayModeVisiblePositions[this._closedDisplayMode]); - } - } - }, - }, - - /// - opened: { - get: function () { - // Returns true if _LegacyAppBar is not 'hidden'. - return !_ElementUtilities.hasClass(this._element, _Constants.hiddenClass) && - !_ElementUtilities.hasClass(this._element, _Constants.hidingClass) && - this._doNext !== displayModeVisiblePositions.minimal && - this._doNext !== displayModeVisiblePositions.compact && - this._doNext !== displayModeVisiblePositions.none; - }, - set: function (opened) { - var currentlyOpen = this.opened; - if (opened && !currentlyOpen) { - this._show(); - } else if (!opened && currentlyOpen) { - this._hide(); - } - } - }, - - /// - /// Occurs immediately before the control is opened. - /// - onbeforeopen: createEvent(EVENTS.beforeOpen), - - /// - /// Occurs immediately after the control is opened. - /// - onafteropen: createEvent(EVENTS.afterOpen), - - /// - /// Occurs immediately before the control is closed. - /// - onbeforeclose: createEvent(EVENTS.beforeClose), - - /// - /// Occurs immediately after the control is closed. - /// - onafterclose: createEvent(EVENTS.afterClose), - - getCommandById: function (id) { - /// - /// - /// Retrieves the command with the specified ID from this _LegacyAppBar. - /// If more than one command is found, this method returns them all. - /// - /// Id of the command to return. - /// - /// The command found, an array of commands if more than one have the same ID, or null if no command is found. - /// - /// - var commands = this._layoutImpl.commandsInOrder.filter(function (command) { - return command.id === id || command.element.id === id; - }); - - if (commands.length === 1) { - return commands[0]; - } else if (commands.length === 0) { - return null; - } - - return commands; - }, - - showCommands: function (commands) { - /// - /// - /// Show the specified commands of the _LegacyAppBar. - /// - /// - /// An array of the commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - /// - /// - if (!commands) { - throw new _ErrorFromName("WinJS.UI._LegacyAppBar.RequiresCommands", strings.requiresCommands); - } - - this._layoutImpl.showCommands(commands); - }, - - hideCommands: function (commands) { - /// - /// - /// Hides the specified commands of the _LegacyAppBar. - /// - /// Required. Command or Commands to hide, either String, DOM elements, or WinJS objects. - /// - if (!commands) { - throw new _ErrorFromName("WinJS.UI._LegacyAppBar.RequiresCommands", strings.requiresCommands); - } - - this._layoutImpl.hideCommands(commands); - }, - - showOnlyCommands: function (commands) { - /// - /// - /// Show the specified commands, hiding all of the others in the _LegacyAppBar. - /// - /// - /// An array of the commands to show. The array elements may be AppBarCommand objects, or the string identifiers (IDs) of commands. - /// - /// - if (!commands) { - throw new _ErrorFromName("WinJS.UI._LegacyAppBar.RequiresCommands", strings.requiresCommands); - } - - this._layoutImpl.showOnlyCommands(commands); - }, - - open: function () { - /// - /// - /// Opens the _LegacyAppBar, if closed and not disabled, regardless of other state. - /// - /// - // Just wrap the private one, turning off keyboard invoked flag - this._writeProfilerMark("show,StartTM"); - this._show(); - }, - - _show: function _LegacyAppBar_show() { - - var toPosition = displayModeVisiblePositions.shown; - var showing = null; - - // If we're already shown, we are just going to animate our position, not fire events or manage focus. - if (!this.disabled && (_ElementUtilities.hasClass(this._element, _Constants.hiddenClass) || _ElementUtilities.hasClass(this._element, _Constants.hidingClass))) { - showing = appbarShownState; - } - - this._changeVisiblePosition(toPosition, showing); - - if (showing) { - // Clean up tabbing behavior by making sure first and final divs are correct after showing. - this._updateFirstAndFinalDiv(); - - _LightDismissService.shown(this._dismissable); - } - }, - - close: function () { - /// - /// - /// Closes the _LegacyAppBar. - /// - /// - // Just wrap the private one - this._writeProfilerMark("hide,StartTM"); - this._hide(); - }, - - _hide: function _LegacyAppBar_hide(toPosition) { - - var toPosition = toPosition || displayModeVisiblePositions[this.closedDisplayMode]; - var hiding = null; - - // If were already hidden, we are just going to animate our position, not fire events or manage focus again. - if (!_ElementUtilities.hasClass(this._element, _Constants.hiddenClass) && !_ElementUtilities.hasClass(this._element, _Constants.hidingClass)) { - hiding = appbarHiddenState; - } - - this._changeVisiblePosition(toPosition, hiding); - }, - - _dispose: function _LegacyAppBar_dispose() { - _Dispose.disposeSubTree(this.element); - _LightDismissService.hidden(this._dismissable); - this._layoutImpl.dispose(); - this.disabled = true; - this.close(); - }, - - _disposeChildren: function _LegacyAppBar_disposeChildren() { - // Be purposeful about what we dispose. - this._layoutImpl.disposeChildren(); - }, - - _handleKeyDown: function _LegacyAppBar_handleKeyDown(event) { - // On Left/Right arrow keys, moves focus to previous/next AppbarCommand element. - - // If the current active element isn't an intrinsic part of the _LegacyAppBar, - // Layout might want to handle additional keys. - if (!this._invokeButton.contains(_Global.document.activeElement)) { - this._layoutImpl.handleKeyDown(event); - } - }, - - _visiblePixels: { - get: function () { - // Returns object containing pixel height of each visible position - return { - hidden: knownVisibleHeights.hidden, - minimal: knownVisibleHeights.minimal, - compact: Math.max(this._heightWithoutLabels || 0, knownVisibleHeights.compact), - // Element can change size as content gets added or removed or if it - // experinces style changes. We have to look this up at run time. - shown: this._element.offsetHeight, - }; - } - }, - - _visiblePosition: { - // Returns string value of our nearest, stationary, visible position. - get: function () { - // If we're animating into a new posistion, return the position we're animating into. - if (this._animating && displayModeVisiblePositions[this._element.winAnimating]) { - return this._element.winAnimating; - } else { - return this._lastPositionVisited; - } - } - }, - - _visible: { - // Returns true if our visible position is not completely hidden, else false. - get: function () { - return (this._visiblePosition !== displayModeVisiblePositions.none); - } - }, - - _changeVisiblePosition: function (toPosition, newState) { - /// - /// - /// Changes the visible position of the _LegacyAppBar. - /// - /// - /// Name of the visible position we want to move to. - /// - /// - /// Name of the state we are entering. Values can be "showing", "hiding" or null. - /// If the value is null, then we are not changing states, only changing visible position. - /// - /// - - if ((this._visiblePosition === toPosition && !this._keyboardObscured) || - (this.disabled && toPosition !== displayModeVisiblePositions.disabled)) { - // If we want to go where we already are, or we're disabled, return false. - this._afterPositionChange(null); - } else if (this._animating || this._needToHandleShowingKeyboard || this._needToHandleHidingKeyboard) { - // Only do one thing at a time. If we are already animating, - // or the IHM is animating, schedule this for later. - this._doNext = toPosition; - this._afterPositionChange(null); - } else { - // Begin position changing sequence. - - // Set the animating flag to block any queued position changes until we're done. - this._element.winAnimating = toPosition; - var performAnimation = this._initializing ? false : true; - - // Assume we are animating from the last position visited. - var fromPosition = this._lastPositionVisited; - - // We'll need to measure our element to determine how far we need to animate. - // Make sure we have accurate dimensions. - this._element.style.display = ""; - - // Are we hiding completely, or about to become visible? - var hidingCompletely = (toPosition === displayModeVisiblePositions.hidden); - - if (this._keyboardObscured) { - // We're changing position while covered by the IHM. - if (hidingCompletely) { - // If we're covered by the IHM we already look hidden. - // We can skip our animation and just hide. - performAnimation = false; - } else { - // Some portion of the _LegacyAppBar should be visible to users after its position changes. - - // Un-obscure ourselves and become visible to the user again. - // Need to animate to our desired position as if we were coming up from behind the keyboard. - fromPosition = displayModeVisiblePositions.hidden; - } - this._keyboardObscured = false; - } - - // Fire "before" event if we are changing state. - if (newState === appbarShownState) { - this._beforeShow(); - } else if (newState === appbarHiddenState) { - this._beforeHide(); - } - - // Position our element into the correct "end of animation" position, - // also accounting for any viewport scrolling or soft keyboard positioning. - this._ensurePosition(); - - this._element.style.opacity = 1; - this._element.style.visibility = "visible"; - - this._animationPromise = (performAnimation) ? this._animatePositionChange(fromPosition, toPosition) : Promise.wrap(); - this._animationPromise.then( - function () { this._afterPositionChange(toPosition, newState); }.bind(this), - function () { this._afterPositionChange(toPosition, newState); }.bind(this) - ); - } - }, - - _afterPositionChange: function _LegacyAppBar_afterPositionChange(newPosition, newState) { - // Defines body of work to perform after changing positions. - if (this._disposed) { - return; - } - - if (newPosition) { - - // Update closedDisplayMode related CSS classes, which were delayed from the closedDisplayMode setter to avoid affecting the animation - if (newPosition === displayModeVisiblePositions.minimal) { - _ElementUtilities.addClass(this._element, _Constants.minimalClass); - _ElementUtilities.removeClass(this._element, _Constants.compactClass); - } - - if (newPosition === displayModeVisiblePositions.hidden && this.closedDisplayMode === closedDisplayModes.none) { - _ElementUtilities.removeClass(this._element, _Constants.minimalClass); - _ElementUtilities.removeClass(this._element, _Constants.compactClass); - } - - // Clear animation flag and record having visited this position. - this._element.winAnimating = ""; - this._lastPositionVisited = newPosition; - - if (this._doNext === this._lastPositionVisited) { - this._doNext = ""; - } - - if (newState === appbarHiddenState) { - _LightDismissService.hidden(this._dismissable); - } - - if (newPosition === displayModeVisiblePositions.hidden) { - // Make sure animation is finished. - this._element.style.visibility = "hidden"; - this._element.style.display = "none"; - } - - // Clean up animation transforms. - var transformProperty = _BaseUtils._browserStyleEquivalents["transform"].scriptName; - this._element.style[transformProperty] = ""; - - // Fire "after" event if we changed state. - if (newState === appbarShownState) { - this._afterShow(); - } else if (newState === appbarHiddenState) { - this._afterHide(); - } - - // If we had something queued, do that - Scheduler.schedule(this._checkDoNext, Scheduler.Priority.normal, this, "WinJS.UI._LegacyAppBar._checkDoNext"); - } - - this._afterPositionChangeCallBack(); - }, - - _afterPositionChangeCallBack: function () { - // Leave this blank for unit tests to overwrite. - }, - - _beforeShow: function _LegacyAppBar_beforeShow() { - // In case their event 'beforeopen' event listener is going to manipulate commands, - // first see if there are any queued command animations we can handle while we're still hidden. - if (this._queuedCommandAnimation) { - this._showAndHideFast(this._queuedToShow, this._queuedToHide); - this._queuedToShow = []; - this._queuedToHide = []; - } - - // Make sure everything fits before showing - this._layoutImpl.scale(); - - if (this.closedDisplayMode === closedDisplayModes.compact) { - this._heightWithoutLabels = this._element.offsetHeight; - } - - _ElementUtilities.removeClass(this._element, _Constants.hiddenClass); - _ElementUtilities.addClass(this._element, _Constants.showingClass); - - // Send our "beforeopen" event - this._sendEvent(EVENTS.beforeOpen); - }, - - _afterShow: function _LegacyAppBar_afterShow() { - _ElementUtilities.removeClass(this._element, _Constants.showingClass); - _ElementUtilities.addClass(this._element, _Constants.shownClass); - - // Send our "afteropen" event - this._sendEvent(EVENTS.afterOpen); - this._writeProfilerMark("show,StopTM"); - }, - - _beforeHide: function _LegacyAppBar_beforeHide() { - - _ElementUtilities.removeClass(this._element, _Constants.shownClass); - _ElementUtilities.addClass(this._element, _Constants.hidingClass); - - // Send our "beforeclose" event - this._sendEvent(EVENTS.beforeClose); - }, - - _afterHide: function _LegacyAppBar_afterHide() { - - // In case their 'afterclose' event handler is going to manipulate commands, - // first see if there are any queued command animations we can handle now we're hidden. - if (this._queuedCommandAnimation) { - this._showAndHideFast(this._queuedToShow, this._queuedToHide); - this._queuedToShow = []; - this._queuedToHide = []; - } - - _ElementUtilities.removeClass(this._element, _Constants.hidingClass); - _ElementUtilities.addClass(this._element, _Constants.hiddenClass); - - // Send our "afterclose" event - this._sendEvent(EVENTS.afterClose); - this._writeProfilerMark("hide,StopTM"); - }, - - _animatePositionChange: function _LegacyAppBar_animatePositionChange(fromPosition, toPosition) { - // Determines and executes the proper transition between visible positions - - var layoutElementsAnimationPromise = this._layoutImpl.positionChanging(fromPosition, toPosition), - appBarElementAnimationPromise; - - // Get values in terms of pixels to perform animation. - var beginningVisiblePixelHeight = this._visiblePixels[fromPosition], - endingVisiblePixelHeight = this._visiblePixels[toPosition], - distance = Math.abs(endingVisiblePixelHeight - beginningVisiblePixelHeight), - offsetTop = (this._placement === _Constants.appBarPlacementTop) ? -distance : distance; - - if ((this._placement === _Constants.appBarPlacementTop) && - ((fromPosition === displayModeVisiblePositions.shown && - toPosition === displayModeVisiblePositions.compact) || - (fromPosition === displayModeVisiblePositions.compact && - toPosition === displayModeVisiblePositions.shown))) { - // Command icons remain in the same location on a top appbar - // when going from compact > shown or shown > compact. - offsetTop = 0; - } - - // Animate - if (endingVisiblePixelHeight > beginningVisiblePixelHeight) { - var fromOffset = { top: offsetTop + "px", left: "0px" }; - appBarElementAnimationPromise = Animations.showEdgeUI(this._element, fromOffset, { mechanism: "transition" }); - } else { - var toOffset = { top: offsetTop + "px", left: "0px" }; - appBarElementAnimationPromise = Animations.hideEdgeUI(this._element, toOffset, { mechanism: "transition" }); - } - - return Promise.join([layoutElementsAnimationPromise, appBarElementAnimationPromise]); - }, - - _checkDoNext: function _LegacyAppBar_checkDoNext() { - // Do nothing if we're still animating - if (this._animating || this._needToHandleShowingKeyboard || this._needToHandleHidingKeyboard || this._disposed) { - return; - } - - if (this._doNext === displayModeVisiblePositions.disabled || - this._doNext === displayModeVisiblePositions.hidden || - this._doNext === displayModeVisiblePositions.minimal || - this._doNext === displayModeVisiblePositions.compact) { - // Do hide first because animating commands would be easier - this._hide(this._doNext); - this._doNext = ""; - } else if (this._queuedCommandAnimation) { - // Do queued commands before showing if possible - this._showAndHideQueue(); - } else if (this._doNext === displayModeVisiblePositions.shown) { - // Show last so that we don't unnecessarily animate commands - this._show(); - this._doNext = ""; - } - }, - - // Set focus to the passed in _LegacyAppBar - _setFocusToAppBar: function _LegacyAppBar_setFocusToAppBar(useSetActive, scroller) { - if (!this._focusOnFirstFocusableElement(useSetActive, scroller)) { - // No first element, set it to appbar itself - _Overlay._Overlay._trySetActive(this._element, scroller); - } - }, - - _commandsUpdated: function _LegacyAppBar_commandsUpdated() { - // If we are still initializing then we don't have a layout yet so it doesn't need updating. - if (!this._initializing) { - this._layoutImpl.commandsUpdated(); - this._layoutImpl.scale(); - } - }, - - _beginAnimateCommands: function _LegacyAppBar_beginAnimateCommands(showCommands, hideCommands, otherVisibleCommands) { - // The parameters are 3 mutually exclusive arrays of win-command elements contained in this Overlay. - // 1) showCommands[]: All of the HIDDEN win-command elements that ARE scheduled to show. - // 2) hideCommands[]: All of the VISIBLE win-command elements that ARE scheduled to hide. - // 3) otherVisibleCommands[]: All VISIBLE win-command elements that ARE NOT scheduled to hide. - this._layoutImpl.beginAnimateCommands(showCommands, hideCommands, otherVisibleCommands); - }, - - _endAnimateCommands: function _LegacyAppBar_endAnimateCommands() { - this._layoutImpl.endAnimateCommands(); - this._endAnimateCommandsCallBack(); - }, - - _endAnimateCommandsCallBack: function _LegacyAppBar_endAnimateCommandsCallBack() { - // Leave this blank for unit tests to overwrite. - }, - - // Get the top offset for top appbars. - _getTopOfVisualViewport: function _LegacyAppBar_getTopOfVisualViewPort() { - return _Overlay._Overlay._keyboardInfo._visibleDocTop; - }, - - // Get the bottom offset for bottom appbars. - _getAdjustedBottom: function _LegacyAppBar_getAdjustedBottom() { - // Need the distance the IHM moved as well. - return _Overlay._Overlay._keyboardInfo._visibleDocBottomOffset; - }, - - _showingKeyboard: function _LegacyAppBar_showingKeyboard(event) { - // Remember keyboard showing state. - this._keyboardObscured = false; - this._needToHandleHidingKeyboard = false; - - // If we're already moved, then ignore the whole thing - if (_Overlay._Overlay._keyboardInfo._visible && this._alreadyInPlace()) { - return; - } - - this._needToHandleShowingKeyboard = true; - // If focus is in the appbar, don't cause scrolling. - if (this.opened && this._element.contains(_Global.document.activeElement)) { - event.ensuredFocusedElementInView = true; - } - - // Check if appbar moves or if we're ok leaving it obscured instead. - if (this._visible && this._placement !== _Constants.appBarPlacementTop && _Overlay._Overlay._isFlyoutVisible()) { - // Remember that we're obscured - this._keyboardObscured = true; - } else { - // Don't be obscured, clear _scrollHappened flag to give us inference later on when to re-show ourselves. - this._scrollHappened = false; - } - - // Also set timeout regardless, so we can clean up our _keyboardShowing flag. - var that = this; - _Global.setTimeout(function (e) { that._checkKeyboardTimer(e); }, _Overlay._Overlay._keyboardInfo._animationShowLength + _Overlay._Overlay._scrollTimeout); - }, - - _hidingKeyboard: function _LegacyAppBar_hidingKeyboard() { - // We'll either just reveal the current space under the IHM or restore the window height. - - // We won't be obscured - this._keyboardObscured = false; - this._needToHandleShowingKeyboard = false; - this._needToHandleHidingKeyboard = true; - - // We'll either just reveal the current space or resize the window - if (!_Overlay._Overlay._keyboardInfo._isResized) { - // If we're not completely hidden, only fake hiding under keyboard, or already animating, - // then snap us to our final position. - if (this._visible || this._animating) { - // Not resized, update our final position immediately - this._checkScrollPosition(); - this._element.style.display = ""; - } - this._needToHandleHidingKeyboard = false; - } - // Else resize should clear keyboardHiding. - }, - - _resize: function _LegacyAppBar_resize(event) { - // If we're hidden by the keyboard, then hide bottom appbar so it doesn't pop up twice when it scrolls - if (this._needToHandleShowingKeyboard) { - // Top is allowed to scroll off the top, but we don't want bottom to peek up when - // scrolled into view since we'll show it ourselves and don't want a stutter effect. - if (this._visible) { - if (this._placement !== _Constants.appBarPlacementTop && !this._keyboardObscured) { - // If viewport doesn't match window, need to vanish momentarily so it doesn't scroll into view, - // however we don't want to toggle the visibility="hidden" hidden flag. - this._element.style.display = "none"; - } - } - // else if we're top we stay, and if there's a flyout, stay obscured by the keyboard. - } else if (this._needToHandleHidingKeyboard) { - this._needToHandleHidingKeyboard = false; - if (this._visible || this._animating) { - // Snap to final position - this._checkScrollPosition(); - this._element.style.display = ""; - } - } - - // Make sure everything still fits. - if (!this._initializing) { - this._layoutImpl.resize(event); - } - }, - - _checkKeyboardTimer: function _LegacyAppBar_checkKeyboardTimer() { - if (!this._scrollHappened) { - this._mayEdgeBackIn(); - } - }, - - _manipulationChanged: function _LegacyAppBar_manipulationChanged(event) { - // See if we're at the not manipulating state, and we had a scroll happen, - // which is implicitly after the keyboard animated. - if (event.currentState === 0 && this._scrollHappened) { - this._mayEdgeBackIn(); - } - }, - - _mayEdgeBackIn: function _LegacyAppBar_mayEdgeBackIn() { - // May need to react to IHM being resized event - if (this._needToHandleShowingKeyboard) { - // If not top appbar or viewport isn't still at top, then need to show again - this._needToHandleShowingKeyboard = false; - // If obscured (IHM + flyout showing), it's ok to stay obscured. - // If bottom we have to move, or if top scrolled off screen. - if (!this._keyboardObscured && - (this._placement !== _Constants.appBarPlacementTop || _Overlay._Overlay._keyboardInfo._visibleDocTop !== 0)) { - var toPosition = this._visiblePosition; - this._lastPositionVisited = displayModeVisiblePositions.hidden; - this._changeVisiblePosition(toPosition, false); - } else { - // Ensure any animations dropped during the showing keyboard are caught up. - this._checkDoNext(); - } - } - this._scrollHappened = false; - }, - - _ensurePosition: function _LegacyAppBar_ensurePosition() { - // Position the _LegacyAppBar element relative to the top or bottom edge of the visible - // document, based on the the visible position we think we need to be in. - var offSet = this._computePositionOffset(); - this._element.style.bottom = offSet.bottom; - this._element.style.top = offSet.top; - - }, - - _computePositionOffset: function _LegacyAppBar_computePositionOffset() { - // Calculates and returns top and bottom offsets for the _LegacyAppBar element, relative to the top or bottom edge of the visible - // document. - var positionOffSet = {}; - - if (this._placement === _Constants.appBarPlacementBottom) { - // If the IHM is open, the bottom of the visual viewport may or may not be obscured - // Use _getAdjustedBottom to account for the IHM if it is covering the bottom edge. - positionOffSet.bottom = this._getAdjustedBottom() + "px"; - positionOffSet.top = ""; - } else if (this._placement === _Constants.appBarPlacementTop) { - positionOffSet.bottom = ""; - positionOffSet.top = this._getTopOfVisualViewport() + "px"; - } - - return positionOffSet; - }, - - _checkScrollPosition: function _LegacyAppBar_checkScrollPosition() { - // If IHM has appeared, then remember we may come in - if (this._needToHandleShowingKeyboard) { - // Tag that it's OK to edge back in. - this._scrollHappened = true; - return; - } - - // We only need to update if we're not completely hidden. - if (this._visible || this._animating) { - this._ensurePosition(); - // Ensure any animations dropped during the showing keyboard are caught up. - this._checkDoNext(); - } - }, - - _alreadyInPlace: function _LegacyAppBar_alreadyInPlace() { - // See if we're already where we're supposed to be. - var offSet = this._computePositionOffset(); - return (offSet.top === this._element.style.top && offSet.bottom === this._element.style.bottom); - }, - - // If there is a shown non-sticky _LegacyAppBar then it sets the firstDiv tabIndex to - // the minimum tabIndex found in the _LegacyAppBars and finalDiv to the max found. - // Otherwise sets their tabIndex to -1 so they are not tab stops. - _updateFirstAndFinalDiv: function _LegacyAppBar_updateFirstAndFinalDiv() { - var appBarFirstDiv = this._element.querySelectorAll("." + _Constants.firstDivClass); - appBarFirstDiv = appBarFirstDiv.length >= 1 ? appBarFirstDiv[0] : null; - - var appBarFinalDiv = this._element.querySelectorAll("." + _Constants.finalDivClass); - appBarFinalDiv = appBarFinalDiv.length >= 1 ? appBarFinalDiv[0] : null; - - // Remove the firstDiv & finalDiv if they are not at the appropriate locations - if (appBarFirstDiv && (this._element.children[0] !== appBarFirstDiv)) { - appBarFirstDiv.parentNode.removeChild(appBarFirstDiv); - appBarFirstDiv = null; - } - if (appBarFinalDiv && (this._element.children[this._element.children.length - 1] !== appBarFinalDiv)) { - appBarFinalDiv.parentNode.removeChild(appBarFinalDiv); - appBarFinalDiv = null; - } - - // Create and add the firstDiv & finalDiv if they don't already exist - if (!appBarFirstDiv) { - // Add a firstDiv that will be the first child of the appBar. - // On focus set focus to the last element of the AppBar. - appBarFirstDiv = _Global.document.createElement("div"); - // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus - appBarFirstDiv.style.display = "inline"; - appBarFirstDiv.className = _Constants.firstDivClass; - appBarFirstDiv.tabIndex = -1; - appBarFirstDiv.setAttribute("aria-hidden", "true"); - _ElementUtilities._addEventListener(appBarFirstDiv, "focusin", this._focusOnLastFocusableElementOrThis.bind(this), false); - // add to beginning - if (this._element.children[0]) { - this._element.insertBefore(appBarFirstDiv, this._element.children[0]); - } else { - this._element.appendChild(appBarFirstDiv); - } - } - if (!appBarFinalDiv) { - // Add a finalDiv that will be the last child of the appBar. - // On focus set focus to the first element of the AppBar. - appBarFinalDiv = _Global.document.createElement("div"); - // display: inline is needed so that the div doesn't take up space and cause the page to scroll on focus - appBarFinalDiv.style.display = "inline"; - appBarFinalDiv.className = _Constants.finalDivClass; - appBarFinalDiv.tabIndex = -1; - appBarFinalDiv.setAttribute("aria-hidden", "true"); - _ElementUtilities._addEventListener(appBarFinalDiv, "focusin", this._focusOnFirstFocusableElementOrThis.bind(this), false); - this._element.appendChild(appBarFinalDiv); - } - - - // invokeButton should be the second to last element in the _LegacyAppBar's tab order. Second to the finalDiv. - if (this._element.children[this._element.children.length - 2] !== this._invokeButton) { - this._element.insertBefore(this._invokeButton, appBarFinalDiv); - } - var elms = this._element.getElementsByTagName("*"); - var highestTabIndex = _ElementUtilities._getHighestTabIndexInList(elms); - this._invokeButton.tabIndex = highestTabIndex; - - // Update the tabIndex of the firstDiv & finalDiv - if (appBarFirstDiv) { - appBarFirstDiv.tabIndex = _ElementUtilities._getLowestTabIndexInList(elms); - } - if (appBarFinalDiv) { - appBarFinalDiv.tabIndex = highestTabIndex; - } - }, - - _writeProfilerMark: function _LegacyAppBar_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI._LegacyAppBar:" + this._id + ":" + text); - } - }, { - // Statics - _Events: EVENTS, - }); - - return _LegacyAppBar; - }) - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -// Menu -/// Menu,Menus,Flyout,Flyouts,Statics -define('WinJS/Controls/Menu',[ - 'exports', - '../Core/_Global', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_ErrorFromName', - '../Core/_Resources', - '../Core/_WriteProfilerMark', - '../Promise', - '../Utilities/_ElementUtilities', - '../Utilities/_Hoverable', - '../Utilities/_KeyboardBehavior', - './_LegacyAppBar/_Constants', - './Flyout', - './Flyout/_Overlay', - './Menu/_Command' -], function menuInit(exports, _Global, _Base, _BaseUtils, _ErrorFromName, _Resources, _WriteProfilerMark, Promise, _ElementUtilities, _Hoverable, _KeyboardBehavior, _Constants, Flyout, _Overlay, _Command) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// Represents a menu flyout for displaying commands. - /// - /// - /// Menu - /// - /// - /// - /// - /// ]]> - /// Raised just before showing a menu. - /// Raised immediately after a menu is fully shown. - /// Raised just before hiding a menu. - /// Raised immediately after a menu is fully hidden. - /// The Menu control itself - /// - /// - Menu: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/menuAriaLabel").value; }, - get requiresCommands() { return "Invalid argument: commands must not be empty"; }, - get nullCommand() { return "Invalid argument: command must not be null"; }, - }; - - function isCommandInMenu(object) { - // Verifies that we have a menuCommand element and that it is in a Menu. - var element = object.element || object; - return _ElementUtilities._matchesSelector(element, "." + _Constants.menuClass + " " + "." + _Constants.menuCommandClass); - } - - var Menu = _Base.Class.derive(Flyout.Flyout, function Menu_ctor(element, options) { - /// - /// - /// Creates a new Menu control. - /// - /// - /// The DOM element that will host the control. - /// - /// - /// The set of properties and values to apply to the control. - /// - /// The new Menu control. - /// - /// - - // We need to be built on top of a Flyout, so stomp on the user's input - options = options || {}; - - // Make sure there's an input element - this._element = element || _Global.document.createElement("div"); - this._id = this._element.id || _ElementUtilities._uniqueID(this._element); - this._writeProfilerMark("constructor,StartTM"); - - // validate that if they didn't set commands, in which - // case any HTML only contains commands. Do this first - // so that we don't leave partial Menus in the DOM. - if (!options.commands && this._element) { - // Shallow copy object so we can modify it. - options = _BaseUtils._shallowCopy(options); - options.commands = this._verifyCommandsOnly(this._element, "WinJS.UI.MenuCommand"); - } - - // Remember aria role in case base constructor changes it - var role = this._element ? this._element.getAttribute("role") : null; - var label = this._element ? this._element.getAttribute("aria-label") : null; - - // Call the base overlay constructor helper - this._baseFlyoutConstructor(this._element, options); - - // Make sure we have an ARIA role - if (role === null || role === "" || role === undefined) { - this._element.setAttribute("role", "menu"); - } - if (label === null || label === "" || label === undefined) { - this._element.setAttribute("aria-label", strings.ariaLabel); - } - - // Handle "esc" & "up/down" key presses - this._element.addEventListener("keydown", this._handleKeyDown.bind(this), true); - this._element.addEventListener(_Constants._menuCommandInvokedEvent, this._handleCommandInvoked.bind(this), false); - this._element.addEventListener("mouseover", this._handleMouseOver.bind(this), false); - this._element.addEventListener("mouseout", this._handleMouseOut.bind(this), false); - - // Attach our css class - _ElementUtilities.addClass(this._element, _Constants.menuClass); - - this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._element); - - // Need to set our commands, making sure we're hidden first - this.hide(); - this._writeProfilerMark("constructor,StopTM"); - }, { - // Public Properties - - /// - /// Sets the MenuCommand objects that appear in the Menu. You can set this to a single MenuCommand or an array of MenuCommand objects. - /// - /// - commands: { - set: function (value) { - // Fail if trying to set when visible - if (!this.hidden) { - throw new _ErrorFromName("WinJS.UI.Menu.CannotChangeCommandsWhenVisible", _Resources._formatString(_Overlay._Overlay.commonstrings.cannotChangeCommandsWhenVisible, "Menu")); - } - - // Start from scratch - _ElementUtilities.empty(this._element); - - // In case they had only one... - if (!Array.isArray(value)) { - value = [value]; - } - - // Add commands - var len = value.length; - for (var i = 0; i < len; i++) { - this._addCommand(value[i]); - } - } - }, - - getCommandById: function (id) { - /// - /// - /// Retrieve the command with the specified ID from this Menu. If more than one command is found, all are returned. - /// - /// The ID of the command to find. - /// - /// The command found, an array of commands if more than one have the same ID, or null if no command is found. - /// - /// - /// - var commands = this.element.querySelectorAll("#" + id); - var newCommands = []; - for (var count = 0, len = commands.length; count < len; count++) { - if (commands[count].winControl) { - newCommands.push(commands[count].winControl); - } - } - - if (newCommands.length === 1) { - return newCommands[0]; - } else if (newCommands.length === 0) { - return null; - } - - return newCommands; - }, - - - showCommands: function (commands) { - /// - /// - /// Shows the specified commands of the Menu. - /// - /// - /// The commands to show. The array elements may be Menu objects, or the string identifiers (IDs) of commands. - /// - /// - /// - if (!commands) { - throw new _ErrorFromName("WinJS.UI.Menu.RequiresCommands", strings.requiresCommands); - } - - this._showCommands(commands, true); - }, - - hideCommands: function (commands) { - /// - /// - /// Hides the Menu. - /// - /// - /// Required. Command or Commands to hide, either String, DOM elements, or WinJS objects. - /// - /// - /// - if (!commands) { - throw new _ErrorFromName("WinJS.UI.Menu.RequiresCommands", strings.requiresCommands); - } - - this._hideCommands(commands, true); - }, - - showOnlyCommands: function (commands) { - /// - /// - /// Shows the specified commands of the Menu while hiding all other commands. - /// - /// - /// The commands to show. The array elements may be MenuCommand objects, or the string identifiers (IDs) of commands. - /// - /// - /// - if (!commands) { - throw new _ErrorFromName("WinJS.UI.Menu.RequiresCommands", strings.requiresCommands); - } - - this._showOnlyCommands(commands, true); - }, - - show: function (anchor, placement, alignment) { - /// - /// - /// Shows the Menu, if hidden, regardless of other states. - /// - /// - /// The DOM element, or ID of a DOM element, to anchor the Menu. This parameter overrides the anchor property for this method call only. - /// - /// - /// The placement of the Menu to the anchor: 'auto' (default), 'autohorizontal', 'autovertical', 'top', 'bottom', 'left', or 'right'. This parameter overrides the placement - /// property for this method call only. - /// - /// - /// For 'top' or 'bottom' placement, the alignment of the Menu to the anchor's edge: 'center' (default), 'left', or 'right'. This parameter - /// overrides the alignment property for this method call only. - /// - /// - /// - // Just call private version to make appbar flags happy - this._writeProfilerMark("show,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndShow(). - this._show(anchor, placement, alignment); - }, - - _show: function Menu_show(anchor, placement, alignment) { - if (!_ElementUtilities.hasClass(this.element, _Constants.menuMouseSpacingClass) && !_ElementUtilities.hasClass(this.element, _Constants.menuTouchSpacingClass)) { - // The Menu's spacing shouldn't change while it is already shown. Only - // add a spacing class if it doesn't already have one. It will get - // removed after the Menu hides. - _ElementUtilities.addClass( - this.element, - Flyout.Flyout._cascadeManager.inputType === _KeyboardBehavior._InputTypes.mouse || Flyout.Flyout._cascadeManager.inputType === _KeyboardBehavior._InputTypes.keyboard ? - _Constants.menuMouseSpacingClass : - _Constants.menuTouchSpacingClass - ); - } - // Call flyout show - this._baseFlyoutShow(anchor, placement, alignment); - - // Menu will need to adjust MenuCommand layouts based on the various - // types of commands visible in our Menu, but only after we send the beforeshow - // event, so the developer has a chance to show or hide more commands. - // Flyout's _findPosition will make that call. - }, - - _hide: function Menu_hide() { - if (this._hoverPromise) { - this._hoverPromise.cancel(); - } - Flyout.Flyout.prototype._hide.call(this); - }, - - _beforeEndHide: function Menu_beforeEndHide() { - _ElementUtilities.removeClass(this.element, _Constants.menuMouseSpacingClass); - _ElementUtilities.removeClass(this.element, _Constants.menuTouchSpacingClass); - Flyout.Flyout.prototype._beforeEndHide.call(this); - }, - - _addCommand: function Menu_addCommand(command) { - if (!command) { - throw new _ErrorFromName("WinJS.UI.Menu.NullCommand", strings.nullCommand); - } - // See if it's a command already - if (!command._element) { - // Not a command, so assume it's options for a command - command = new _Command.MenuCommand(null, command); - } - // If we were attached somewhere else, detach us - if (command._element.parentElement) { - command._element.parentElement.removeChild(command._element); - } - - // Reattach us - this._element.appendChild(command._element); - }, - - _dispose: function Menu_dispose() { - if (this._hoverPromise) { - this._hoverPromise.cancel(); - } - Flyout.Flyout.prototype._dispose.call(this); - - }, - - _commandsUpdated: function Menu_commandsUpdated() { - if (!this.hidden) { - this._checkMenuCommands(); - } - }, - - // Called when we show/hide commands or by flyout's _findPosition when the Menu is showing. - _checkMenuCommands: function Menu_checkMenuCommands() { - var menuCommands = this._element.querySelectorAll(".win-command"), - hasToggleCommands = false, - hasFlyoutCommands = false; - if (menuCommands) { - for (var i = 0, len = menuCommands.length; i < len; i++) { - var menuCommand = menuCommands[i].winControl; - if (menuCommand && !menuCommand.hidden) { - if (!hasToggleCommands && menuCommand.type === _Constants.typeToggle) { - hasToggleCommands = true; - } - if (!hasFlyoutCommands && menuCommand.type === _Constants.typeFlyout) { - hasFlyoutCommands = true; - } - } - } - } - - _ElementUtilities[hasToggleCommands ? 'addClass' : 'removeClass'](this._element, _Constants.menuContainsToggleCommandClass); - _ElementUtilities[hasFlyoutCommands ? 'addClass' : 'removeClass'](this._element, _Constants.menuContainsFlyoutCommandClass); - }, - - _handleKeyDown: function Menu_handleKeyDown(event) { - if (event.keyCode === Key.upArrow) { - Menu._focusOnPreviousElement(this.element); - - // Prevent the page from scrolling - event.preventDefault(); - } else if (event.keyCode === Key.downArrow) { - Menu._focusOnNextElement(this.element); - - // Prevent the page from scrolling - event.preventDefault(); - } else if ((event.keyCode === Key.space || event.keyCode === Key.enter) - && (this.element === _Global.document.activeElement)) { - event.preventDefault(); - this.hide(); - } else if (event.keyCode === Key.tab) { - event.preventDefault(); - } - }, - - _handleFocusIn: function Menu_handleFocusIn(event) { - // Menu focuses commands on mouseover. We need to handle cases involving activated flyout commands - // to ensure that mousing over different commands in a menu closes that command's sub flyout. - var target = event.target; - if (isCommandInMenu(target)) { - var command = target.winControl; - if (_ElementUtilities.hasClass(command.element, _Constants.menuCommandFlyoutActivatedClass)) { - // If it's an activated 'flyout' typed command, move focus onto the command's subFlyout. - // We expect this will collapse all decendant Flyouts of the subFlyout from the cascade. - command.flyout.element.focus(); - } else { - // Deactivate any currently activated command in the Menu to subsequently trigger all subFlyouts descendants to collapse. - var activatedSiblingCommand = this.element.querySelector("." + _Constants.menuCommandFlyoutActivatedClass); - if (activatedSiblingCommand) { - _Command.MenuCommand._deactivateFlyoutCommand(activatedSiblingCommand); - } - } - } else if (target === this.element) { - // The Menu itself is receiving focus. Rely on the Flyout base implementation to notify the cascadeManager. - // We expect this will only happen when other Menu event handling code causes the Menu to focus itself. - Flyout.Flyout.prototype._handleFocusIn.call(this, event); - } - }, - - _handleCommandInvoked: function Menu_handleCommandInvoked(event) { - // Cascading Menus hide when invoking a command commits an action, not when invoking a command opens a subFlyout. - if (this._hoverPromise) { - // Prevent pending duplicate invoke triggered via hover. - this._hoverPromise.cancel(); - } - var command = event.detail.command; - if (command._type !== _Constants.typeFlyout && command._type !== _Constants.typeSeparator) { - this._lightDismiss(); // Collapse all Menus/Flyouts. - } - }, - - _hoverPromise: null, - _handleMouseOver: function Menu_handleMouseOver(event) { - var target = event.target; - if (isCommandInMenu(target)) { - var command = target.winControl, - that = this; - - if (target.focus) { - target.focus(); - // remove keyboard focus rect since focus has been triggered by mouse over. - _ElementUtilities.removeClass(target, "win-keyboard"); - - if (command.type === _Constants.typeFlyout && command.flyout && command.flyout.hidden) { - this._hoverPromise = this._hoverPromise || Promise.timeout(_Constants.menuCommandHoverDelay).then( - function () { - if (!that.hidden && !that._disposed) { - command._invoke(event); - } - that._hoverPromise = null; - }, - function () { - that._hoverPromise = null; - }); - } - } - } - }, - - _handleMouseOut: function Menu_handleMouseOut(event) { - var target = event.target; - if (isCommandInMenu(target) && !target.contains(event.relatedTarget)) { - if (target === _Global.document.activeElement) { - // Menu gives focus to the menu itself - this.element.focus(); - } - if (this._hoverPromise) { - this._hoverPromise.cancel(); - } - } - }, - - _writeProfilerMark: function Menu_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI.Menu:" + this._id + ":" + text); - } - }); - - // Statics - - // Set focus to next focusable element in the menu (loop if necessary). - // Note: The loop works by first setting focus to the menu itself. If the menu is - // what had focus before, then we break. Otherwise we try the first child next. - // Focus remains on the menu if nothing is focusable. - Menu._focusOnNextElement = function (menu) { - var _currentElement = _Global.document.activeElement; - - do { - if (_currentElement === menu) { - _currentElement = _currentElement.firstElementChild; - } else { - _currentElement = _currentElement.nextElementSibling; - } - - if (_currentElement) { - _currentElement.focus(); - } else { - _currentElement = menu; - } - - } while (_currentElement !== _Global.document.activeElement); - }; - - // Set focus to previous focusable element in the menu (loop if necessary). - // Note: The loop works by first setting focus to the menu itself. If the menu is - // what had focus before, then we break. Otherwise we try the last child next. - // Focus remains on the menu if nothing is focusable. - Menu._focusOnPreviousElement = function (menu) { - var _currentElement = _Global.document.activeElement; - - do { - if (_currentElement === menu) { - _currentElement = _currentElement.lastElementChild; - } else { - _currentElement = _currentElement.previousElementSibling; - } - - if (_currentElement) { - _currentElement.focus(); - } else { - _currentElement = menu; - } - - } while (_currentElement !== _Global.document.activeElement); - }; - - return Menu; - }) - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/AutoSuggestBox/_SearchSuggestionManagerShim',[ - 'exports', - '../../_Signal', - '../../Core/_Base', - '../../Core/_BaseUtils', - '../../Core/_Events', - '../../BindingList', -], function SearchSuggestionManagerShimInit(exports, _Signal, _Base, _BaseUtils, _Events, BindingList) { - "use strict"; - - var CollectionChange = { - reset: 0, - itemInserted: 1, - itemRemoved: 2, - itemChanged: 3 - }; - var SearchSuggestionKind = { - Query: 0, - Result: 1, - Separator: 2 - }; - - var SuggestionVectorShim = _Base.Class.derive(Array, function SuggestionVectorShim_ctor() { - }, { - reset: function () { - this.length = 0; - this.dispatchEvent("vectorchanged", { collectionChange: CollectionChange.reset, index: 0 }); - }, - - insert: function (index, data) { - this.splice(index, 0, data); - this.dispatchEvent("vectorchanged", { collectionChange: CollectionChange.itemInserted, index: index }); - }, - - remove: function (index) { - this.splice(index, 1); - this.dispatchEvent("vectorchanged", { collectionChange: CollectionChange.itemRemoved, index: index }); - }, - }); - _Base.Class.mix(SuggestionVectorShim, _Events.eventMixin); - - var SearchSuggestionCollectionShim = _Base.Class.define(function SearchSuggestionCollectionShim_ctor() { - this._data = []; - }, { - size: { - get: function () { - return this._data.length; - } - }, - - appendQuerySuggestion: function (text) { - this._data.push({ kind: SearchSuggestionKind.Query, text: text }); - }, - appendQuerySuggestions: function (suggestions) { - suggestions.forEach(this.appendQuerySuggestion.bind(this)); - }, - appendResultSuggestion: function (text, detailText, tag, imageUrl, imageAlternateText) { - // 'image' must be null (not undefined) for SearchBox to fallback to use imageUrl instead - this._data.push({ kind: SearchSuggestionKind.Result, text: text, detailText: detailText, tag: tag, imageUrl: imageUrl, imageAlternateText: imageAlternateText, image: null }); - }, - appendSearchSeparator: function (label) { - this._data.push({ kind: SearchSuggestionKind.Separator, text: label }); - } - }); - - var SuggestionsRequestedEventArgShim = _Base.Class.define(function SuggestionsRequestedEventArgShim_ctor(queryText, language, linguisticDetails) { - this._queryText = queryText; - this._language = language; - this._linguisticDetails = linguisticDetails; - this._searchSuggestionCollection = new SearchSuggestionCollectionShim(); - }, { - language: { - get: function () { - return this._language; - } - }, - linguisticDetails: { - get: function () { - return this._linguisticDetails; - } - }, - queryText: { - get: function () { - return this._queryText; - } - }, - searchSuggestionCollection: { - get: function () { - return this._searchSuggestionCollection; - } - }, - getDeferral: function () { - return this._deferralSignal || (this._deferralSignal = new _Signal()); - }, - - _deferralSignal: null, - }); - - var SearchSuggestionManagerShim = _Base.Class.define(function SearchSuggestionManagerShim_ctor() { - this._updateVector = this._updateVector.bind(this); - - this._suggestionVector = new SuggestionVectorShim(); - this._query = ""; - this._history = { "": [] }; - - this._dataSource = []; - - this.searchHistoryContext = ""; - this.searchHistoryEnabled = true; - }, { - addToHistory: function (queryText /*, language */) { - if (!queryText || !queryText.trim()) { - return; - } - - var history = this._history[this.searchHistoryContext]; - var dupeIndex = -1; - for (var i = 0, l = history.length; i < l; i++) { - var item = history[i]; - if (item.text.toLowerCase() === queryText.toLowerCase()) { - dupeIndex = i; - break; - } - } - if (dupeIndex >= 0) { - history.splice(dupeIndex, 1); - } - - history.splice(0, 0, { text: queryText, kind: SearchSuggestionKind.Query }); - this._updateVector(); - }, - - clearHistory: function () { - this._history[this.searchHistoryContext] = []; - this._updateVector(); - }, - - setLocalContentSuggestionSettings: function (settings) { - }, - - setQuery: function (queryText) { - var that = this; - function update(arr) { - that._dataSource = arr; - that._updateVector(); - } - - this._query = queryText; - var arg = new SuggestionsRequestedEventArgShim(queryText); - this.dispatchEvent("suggestionsrequested", { request: arg }); - if (arg._deferralSignal) { - arg._deferralSignal.promise.then(update.bind(this, arg.searchSuggestionCollection._data)); - } else { - update(arg.searchSuggestionCollection._data); - } - }, - - searchHistoryContext: { - get: function () { - return "" + this._searchHistoryContext; - }, - set: function (value) { - value = "" + value; - if (!this._history[value]) { - this._history[value] = []; - } - this._searchHistoryContext = value; - } - }, - - searchHistoryEnabled: { - get: function () { - return this._searchHistoryEnabled; - }, - set: function (value) { - this._searchHistoryEnabled = value; - } - }, - - suggestions: { - get: function () { - return this._suggestionVector; - } - }, - - _updateVector: function () { - // Can never clear the entire suggestions list or it will cause a visual flash because - // the SearchBox control removes the suggestions list UI when the SSM fires vectorChanged - // with size === 0, then re-renders it when the first suggestion is added. - // Workaround is to insert a dummy entry, remove all old entries, add the new set of - // eligible suggestions, then remove the dummy entry. - this.suggestions.insert(this.suggestions.length, { text: "", kind: SearchSuggestionKind.Query }); - - while (this.suggestions.length > 1) { - this.suggestions.remove(0); - } - - var index = 0; - var added = {}; - if (this.searchHistoryEnabled) { - var q = this._query.toLowerCase(); - this._history[this.searchHistoryContext].forEach(function (item) { - var text = item.text.toLowerCase(); - if (text.indexOf(q) === 0) { - this.suggestions.insert(index, item); - added[text] = true; - index++; - } - }, this); - } - this._dataSource.forEach(function (item) { - if (item.kind === SearchSuggestionKind.Query) { - if (!added[item.text.toLowerCase()]) { - this.suggestions.insert(index, item); - index++; - } - } else { - this.suggestions.insert(index, item); - index++; - } - }, this); - - this.suggestions.remove(this.suggestions.length - 1); - }, - }); - _Base.Class.mix(SearchSuggestionManagerShim, _Events.eventMixin); - - _Base.Namespace._moduleDefine(exports, null, { - _CollectionChange: CollectionChange, - _SearchSuggestionKind: SearchSuggestionKind, - _SearchSuggestionManagerShim: SearchSuggestionManagerShim, - }); -}); - -define('require-style!less/styles-autosuggestbox',[],function(){}); - -define('require-style!less/colors-autosuggestbox',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/AutoSuggestBox',[ - "exports", - "../Core/_Global", - "../Core/_WinRT", - "../Core/_Base", - "../Core/_ErrorFromName", - "../Core/_Events", - "../Core/_Resources", - "../Utilities/_Control", - "../Utilities/_ElementListUtilities", - "../Utilities/_ElementUtilities", - '../Utilities/_Hoverable', - "../_Accents", - "../Animations", - "../BindingList", - "../Promise", - "./Repeater", - "./AutoSuggestBox/_SearchSuggestionManagerShim", - "require-style!less/styles-autosuggestbox", - "require-style!less/colors-autosuggestbox" -], function autoSuggestBoxInit(exports, _Global, _WinRT, _Base, _ErrorFromName, _Events, _Resources, _Control, _ElementListUtilities, _ElementUtilities, _Hoverable, _Accents, Animations, BindingList, Promise, Repeater, _SuggestionManagerShim) { - "use strict"; - - _Accents.createAccentRule("html.win-hoverable .win-autosuggestbox .win-autosuggestbox-suggestion-selected:hover", [{ name: "background-color", value: _Accents.ColorTypes.listSelectHover }]); - _Accents.createAccentRule(".win-autosuggestbox .win-autosuggestbox-suggestion-selected", [{ name: "background-color", value: _Accents.ColorTypes.listSelectRest }]); - _Accents.createAccentRule(".win-autosuggestbox .win-autosuggestbox-suggestion-selected.win-autosuggestbox-suggestion-selected:hover:active", [{ name: "background-color", value: _Accents.ColorTypes.listSelectPress }]); - - var ClassNames = { - asb: "win-autosuggestbox", - asbDisabled: "win-autosuggestbox-disabled", - asbFlyout: "win-autosuggestbox-flyout", - asbFlyoutAbove: "win-autosuggestbox-flyout-above", - asbBoxFlyoutHighlightText: "win-autosuggestbox-flyout-highlighttext", - asbHitHighlightSpan: "win-autosuggestbox-hithighlight-span", - asbInput: "win-autosuggestbox-input", - asbInputFocus: "win-autosuggestbox-input-focus", - asbSuggestionQuery: "win-autosuggestbox-suggestion-query", - asbSuggestionResult: "win-autosuggestbox-suggestion-result", - asbSuggestionResultText: "win-autosuggestbox-suggestion-result-text", - asbSuggestionResultDetailedText: "win-autosuggestbox-suggestion-result-detailed-text", - asbSuggestionSelected: "win-autosuggestbox-suggestion-selected", - asbSuggestionSeparator: "win-autosuggestbox-suggestion-separator", - }; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// - /// A rich input box that provides suggestions as the user types. - /// - /// - /// - /// - /// - /// ]]> - /// Raised when user or app changes the query text. - /// Raised when user presses Enter. - /// Raised when user clicks one of the displayed suggestions. - /// Raised when the system requests suggestions from this app. - /// Styles the entire Auto Suggest Box control. - /// Styles the query input box. - /// Styles the result suggestions flyout. - /// Styles the query type suggestion. - /// Styles the result type suggestion. - /// Styles the currently selected suggestion. - /// Styles the separator type suggestion. - /// - /// - AutoSuggestBox: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - var EventNames = { - querychanged: "querychanged", - querysubmitted: "querysubmitted", - resultsuggestionchosen: "resultsuggestionchosen", - suggestionsrequested: "suggestionsrequested" - }; - - var Strings = { - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get invalidSuggestionKind() { return "Error: Invalid suggestion kind."; }, - - get ariaLabel() { return _Resources._getWinJSString("ui/autoSuggestBoxAriaLabel").value; }, - get ariaLabelInputNoPlaceHolder() { return _Resources._getWinJSString("ui/autoSuggestBoxAriaLabelInputNoPlaceHolder").value; }, - get ariaLabelInputPlaceHolder() { return _Resources._getWinJSString("ui/autoSuggestBoxAriaLabelInputPlaceHolder").value; }, - get ariaLabelQuery() { return _Resources._getWinJSString("ui/autoSuggestBoxAriaLabelQuery").value; }, - get ariaLabelResult() { return _Resources._getWinJSString("ui/autoSuggestBoxAriaLabelResult").value; }, - get ariaLabelSeparator() { return _Resources._getWinJSString("ui/autoSuggestBoxAriaLabelSeparator").value; }, - }; - - var AutoSuggestBox = _Base.Class.define(function asb_ctor(element, options) { - /// - /// - /// Creates a new AutoSuggestBox. - /// - /// - /// The DOM element that hosts the AutoSuggestBox. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". For example, to provide a handler for the querychanged event, - /// add a property named "onquerychanged" to the options object and set its value to the event handler. - /// This parameter is optional. - /// - /// - /// The new AutoSuggestBox. - /// - /// - /// - element = element || _Global.document.createElement("div"); - options = options || {}; - - if (element.winControl) { - throw new _ErrorFromName("WinJS.UI.AutoSuggestBox.DuplicateConstruction", Strings.duplicateConstruction); - } - - this._suggestionsChangedHandler = this._suggestionsChangedHandler.bind(this); - this._suggestionsRequestedHandler = this._suggestionsRequestedHandler.bind(this); - - this._element = element; - element.winControl = this; - element.classList.add(ClassNames.asb); - element.classList.add("win-disposable"); - - this._setupDOM(); - this._setupSSM(); - - this._chooseSuggestionOnEnter = false; - this._currentFocusedIndex = -1; - this._currentSelectedIndex = -1; - this._flyoutOpenPromise = Promise.wrap(); - this._lastKeyPressLanguage = ""; - this._prevLinguisticDetails = this._getLinguisticDetails(); - this._prevQueryText = ""; - - _Control.setOptions(this, options); - - this._hideFlyout(); - }, { - /// - /// Raised when user clicks on one of the suggestions displayed. - /// - /// - onresultsuggestionchosen: _Events._createEventProperty(EventNames.resultsuggestionchosen), - - /// - /// Raised when user or app changes the query text. - /// - /// - onquerychanged: _Events._createEventProperty(EventNames.querychanged), - - /// - /// Raised when user submits the current query. - /// - /// - onquerysubmitted: _Events._createEventProperty(EventNames.querysubmitted), - - /// - /// Raised when Windows requests search suggestions from the app. - /// - /// - onsuggestionsrequested: _Events._createEventProperty(EventNames.suggestionsrequested), - - /// - element: { - get: function () { - return this._element; - } - }, - - /// - /// Gets or sets whether the first suggestion is chosen when the user presses Enter. When set to true, as the user types in the input box, a - /// focus rectangle is drawn on the first suggestion (if present and no IME composition in progress). Pressing enter will behave the same as - /// if clicked on the focused suggestion, and the down arrow key press will put real focus to the second suggestion and the up arrow key will - /// remove focus. - /// - /// - chooseSuggestionOnEnter: { - get: function () { - return this._chooseSuggestionOnEnter; - }, - set: function (value) { - this._chooseSuggestionOnEnter = !!value; - } - }, - - /// - /// Gets or sets a value that specifies whether the AutoSuggestBox is disabled. - /// - /// - disabled: { - get: function () { - return this._inputElement.disabled; - }, - set: function (value) { - if (this._inputElement.disabled === !!value) { - return; - } - - if (!value) { - this._enableControl(); - } else { - this._disableControl(); - } - } - }, - - /// - /// Gets or sets the placeholder text for the AutoSuggestBox. This text is displayed if there is no other text in the input box. - /// - /// - placeholderText: { - get: function () { - return this._inputElement.placeholder; - }, - set: function (value) { - this._inputElement.placeholder = value; - this._updateInputElementAriaLabel(); - } - }, - - /// - /// Gets or sets the query text for the AutoSuggestBox. - /// - /// - queryText: { - get: function () { - return this._inputElement.value; - }, - set: function (value) { - this._inputElement.value = ""; // This finalizes the IME composition - this._inputElement.value = value; - } - }, - - /// - /// Gets or sets a value that specifies whether history is disabled for the AutoSuggestBox. The default value is false. - /// - /// - searchHistoryDisabled: { - get: function () { - return !this._suggestionManager.searchHistoryEnabled; - }, - set: function (value) { - this._suggestionManager.searchHistoryEnabled = !value; - } - }, - - /// - /// Gets or sets the search history context for the AutoSuggestBox. The search history context string is used as a secondary key for storing search history. - /// (The primary key is the AppId.) An app can use the search history context string to store different search histories based on the context of the application. - /// If you don't set this property, the system assumes that all searches in your app occur in the same context. - /// If you update this property while the search pane is open with suggestions showing, the changes won't take effect until the user enters the next character. - /// - /// - searchHistoryContext: { - get: function () { - return this._suggestionManager.searchHistoryContext; - }, - set: function (value) { - this._suggestionManager.searchHistoryContext = value; - } - }, - - dispose: function asb_dispose() { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - - // Cancel pending promises. - this._flyoutOpenPromise.cancel(); - - this._suggestions.removeEventListener("vectorchanged", this._suggestionsChangedHandler); - this._suggestionManager.removeEventListener("suggestionsrequested", this._suggestionsRequestedHandler); - - this._suggestionManager = null; - this._suggestions = null; - this._hitFinder = null; - - this._disposed = true; - }, - - setLocalContentSuggestionSettings: function asb_setLocalContentSuggestionSettings(settings) { - /// - /// - /// Specifies whether suggestions based on local files are automatically displayed in the input field, and defines the criteria that - /// the system uses to locate and filter these suggestions. - /// - /// - /// The new settings for local content suggestions. - /// - /// - /// - this._suggestionManager.setLocalContentSuggestionSettings(settings); - }, - - // Constructor Helpers - _setupDOM: function asb_setupDOM() { - var flyoutPointerReleasedHandler = this._flyoutPointerReleasedHandler.bind(this); - var inputOrImeChangeHandler = this._inputOrImeChangeHandler.bind(this); - - // Root element - if (!this._element.getAttribute("aria-label")) { - this._element.setAttribute("aria-label", Strings.ariaLabel); - } - this._element.setAttribute("role", "group"); - - // Input element - this._inputElement = _Global.document.createElement("input"); - this._inputElement.autocorrect = "off"; - this._inputElement.type = "search"; - this._inputElement.classList.add(ClassNames.asbInput); - this._inputElement.classList.add("win-textbox"); - this._inputElement.setAttribute("role", "textbox"); - this._inputElement.addEventListener("keydown", this._keyDownHandler.bind(this)); - this._inputElement.addEventListener("keypress", this._keyPressHandler.bind(this)); - this._inputElement.addEventListener("keyup", this._keyUpHandler.bind(this)); - this._inputElement.addEventListener("focus", this._inputFocusHandler.bind(this)); - this._inputElement.addEventListener("blur", this._inputBlurHandler.bind(this)); - this._inputElement.addEventListener("input", inputOrImeChangeHandler); - this._inputElement.addEventListener("compositionstart", inputOrImeChangeHandler); - this._inputElement.addEventListener("compositionupdate", inputOrImeChangeHandler); - this._inputElement.addEventListener("compositionend", inputOrImeChangeHandler); - _ElementUtilities._addEventListener(this._inputElement, "pointerdown", this._inputPointerDownHandler.bind(this)); - this._updateInputElementAriaLabel(); - this._element.appendChild(this._inputElement); - var context = this._tryGetInputContext(); - if (context) { - context.addEventListener("MSCandidateWindowShow", this._msCandidateWindowShowHandler.bind(this)); - context.addEventListener("MSCandidateWindowHide", this._msCandidateWindowHideHandler.bind(this)); - } - - // Flyout element - this._flyoutElement = _Global.document.createElement("div"); - this._flyoutElement.classList.add(ClassNames.asbFlyout); - this._flyoutElement.addEventListener("blur", this._flyoutBlurHandler.bind(this)); - _ElementUtilities._addEventListener(this._flyoutElement, "pointerup", flyoutPointerReleasedHandler); - _ElementUtilities._addEventListener(this._flyoutElement, "pointercancel", flyoutPointerReleasedHandler); - _ElementUtilities._addEventListener(this._flyoutElement, "pointerout", flyoutPointerReleasedHandler); - _ElementUtilities._addEventListener(this._flyoutElement, "pointerdown", this._flyoutPointerDownHandler.bind(this)); - this._element.appendChild(this._flyoutElement); - - // Repeater - var that = this; - function repeaterTemplate(suggestion) { - return that._renderSuggestion(suggestion); - } - this._suggestionsData = new BindingList.List(); - this._repeaterElement = _Global.document.createElement("div"); - this._repeater = new Repeater.Repeater(this._repeaterElement, { - data: this._suggestionsData, - template: repeaterTemplate, - }); - _ElementUtilities._ensureId(this._repeaterElement); - this._repeaterElement.setAttribute("role", "listbox"); - this._repeaterElement.setAttribute("aria-live", "polite"); - this._flyoutElement.appendChild(this._repeaterElement); - }, - - _setupSSM: function asb_setupSSM() { - // Get the search suggestion provider if it is available - this._suggestionManager = new _SuggestionManagerShim._SearchSuggestionManagerShim(); - this._suggestions = this._suggestionManager.suggestions; - - this._suggestions.addEventListener("vectorchanged", this._suggestionsChangedHandler); - this._suggestionManager.addEventListener("suggestionsrequested", this._suggestionsRequestedHandler); - }, - - // Flyout functions - _hideFlyout: function asb_hideFlyout() { - if (this._isFlyoutShown()) { - this._flyoutElement.style.display = "none"; - } - }, - - _showFlyout: function asb_showFlyout() { - var prevNumSuggestions = this._prevNumSuggestions || 0; - this._prevNumSuggestions = this._suggestionsData.length; - - if (this._isFlyoutShown() && prevNumSuggestions === this._suggestionsData.length) { - return; - } - - if (this._suggestionsData.length === 0) { - return; - } - - this._flyoutElement.style.display = "block"; - - var inputRect = this._inputElement.getBoundingClientRect(); - var flyoutRect = this._flyoutElement.getBoundingClientRect(); - var documentClientWidth = _Global.document.documentElement.clientWidth; - - // Display above vs below - the ASB flyout always opens in the direction where there is more space - var spaceAbove = inputRect.top; - var spaceBelow = _Global.document.documentElement.clientHeight - inputRect.bottom; - this._flyoutBelowInput = spaceBelow >= spaceAbove; - if (this._flyoutBelowInput) { - this._flyoutElement.classList.remove(ClassNames.asbFlyoutAbove); - this._flyoutElement.scrollTop = 0; - } else { - this._flyoutElement.classList.add(ClassNames.asbFlyoutAbove); - this._flyoutElement.scrollTop = this._flyoutElement.scrollHeight - this._flyoutElement.clientHeight; - } - - this._addFlyoutIMEPaddingIfRequired(); - - // Align left vs right edge - var alignRight; - if (_Global.getComputedStyle(this._flyoutElement).direction === "rtl") { - // RTL: Align to the right edge if there is enough space to the left of the control's - // right edge, or if there is not enough space to fit the flyout aligned to either edge. - alignRight = ((inputRect.right - flyoutRect.width) >= 0) || ((inputRect.left + flyoutRect.width) > documentClientWidth); - - } else { - // LTR: Align to the right edge if there isn't enough space to the right of the control's - // left edge, but there is enough space to the left of the control's right edge. - alignRight = ((inputRect.left + flyoutRect.width) > documentClientWidth) && ((inputRect.right - flyoutRect.width) >= 0); - } - - if (alignRight) { - this._flyoutElement.style.left = (inputRect.width - flyoutRect.width - this._element.clientLeft) + "px"; - } else { - this._flyoutElement.style.left = "-" + this._element.clientLeft + "px"; - } - - // ms-scroll-chaining:none will still chain scroll parent element if child div does - // not have a scroll bar. Prevent this by setting and updating touch action - this._flyoutElement.style.touchAction = this._flyoutElement.scrollHeight > flyoutRect.height ? "pan-y" : "none"; - - this._flyoutOpenPromise.cancel(); - var animationKeyframe = this._flyoutBelowInput ? "WinJS-flyoutBelowASB-showPopup" : "WinJS-flyoutAboveASB-showPopup"; - this._flyoutOpenPromise = Animations.showPopup(this._flyoutElement, { top: "0px", left: "0px", keyframe: animationKeyframe }); - }, - - _addFlyoutIMEPaddingIfRequired: function asb_addFlyoutIMEPaddingIfRequired() { - // Check if we have InputContext APIs - var context = this._tryGetInputContext(); - if (!context) { - return; - } - - // Check if flyout is visible and below input - if (!this._isFlyoutShown() || !this._flyoutBelowInput) { - return; - } - - // Check if IME is occluding flyout - var flyoutRect = this._flyoutElement.getBoundingClientRect(); - var imeRect = context.getCandidateWindowClientRect(); - var inputRect = this._inputElement.getBoundingClientRect(); - var flyoutTop = inputRect.bottom; - var flyoutBottom = inputRect.bottom + flyoutRect.height; - if (imeRect.top > flyoutBottom || imeRect.bottom < flyoutTop) { - return; - } - - // Shift the flyout down or to the right depending on IME/ASB width ratio. - // When the IME width is less than 45% of the ASB's width, the flyout gets - // shifted right, otherwise shifted down. - var animation = Animations.createRepositionAnimation(this._flyoutElement); - if (imeRect.width < (inputRect.width * 0.45)) { - this._flyoutElement.style.marginLeft = imeRect.width + "px"; - } else { - this._flyoutElement.style.marginTop = (imeRect.bottom - imeRect.top + 4) + "px"; - } - animation.execute(); - }, - - _findNextSuggestionElementIndex: function asb_findNextSuggestionElementIndex(curIndex) { - // Returns -1 if there are no focusable elements after curIndex - // Returns first element if curIndex < 0 - var startIndex = curIndex < 0 ? 0 : curIndex + 1; - for (var i = startIndex; i < this._suggestionsData.length; i++) { - if ((this._repeater.elementFromIndex(i)) && (this._isSuggestionSelectable(this._suggestionsData.getAt(i)))) { - return i; - } - } - return -1; - }, - - _findPreviousSuggestionElementIndex: function asb_findPreviousSuggestionElementIndex(curIndex) { - // Returns -1 if there are no focusable elements before curIndex - // Returns last element if curIndex >= suggestionsdata.length - var startIndex = curIndex >= this._suggestionsData.length ? this._suggestionsData.length - 1 : curIndex - 1; - for (var i = startIndex; i >= 0; i--) { - if ((this._repeater.elementFromIndex(i)) && (this._isSuggestionSelectable(this._suggestionsData.getAt(i)))) { - return i; - } - } - return -1; - }, - - _isFlyoutShown: function asb_isFlyoutShown() { - return (this._flyoutElement.style.display !== "none"); - }, - - _isSuggestionSelectable: function asb_isSuggestionSelectable(suggestion) { - return ((suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Query) || - (suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Result)); - }, - - _processSuggestionChosen: function asb_processSuggestionChosen(item, event) { - this.queryText = item.text; - if (item.kind === _SuggestionManagerShim._SearchSuggestionKind.Query) { - this._submitQuery(item.text, false /*fillLinguisticDetails*/, event); // force empty linguistic details since explicitly chosen suggestion from list - } else if (item.kind === _SuggestionManagerShim._SearchSuggestionKind.Result) { - this._fireEvent(EventNames.resultsuggestionchosen, { - tag: item.tag, - keyModifiers: getKeyModifiers(event), - storageFile: null - }); - } - this._hideFlyout(); - }, - - _selectSuggestionAtIndex: function asb_selectSuggestionAtIndex(indexToSelect) { - var that = this; - function scrollToView(targetElement) { - var popupHeight = that._flyoutElement.getBoundingClientRect().bottom - that._flyoutElement.getBoundingClientRect().top; - if ((targetElement.offsetTop + targetElement.offsetHeight) > (that._flyoutElement.scrollTop + popupHeight)) { - // Element to scroll is below popup visible area - var scrollDifference = (targetElement.offsetTop + targetElement.offsetHeight) - (that._flyoutElement.scrollTop + popupHeight); - _ElementUtilities._zoomTo(that._flyoutElement, { contentX: 0, contentY: (that._flyoutElement.scrollTop + scrollDifference), viewportX: 0, viewportY: 0 }); - } else if (targetElement.offsetTop < that._flyoutElement.scrollTop) { - // Element to scroll is above popup visible area - _ElementUtilities._zoomTo(that._flyoutElement, { contentX: 0, contentY: targetElement.offsetTop, viewportX: 0, viewportY: 0 }); - } - } - - // Sets focus on the specified element and removes focus from others. - // Clears selection if index is outside of suggestiondata index range. - var curElement = null; - for (var i = 0; i < this._suggestionsData.length; i++) { - curElement = this._repeater.elementFromIndex(i); - if (i !== indexToSelect) { - curElement.classList.remove(ClassNames.asbSuggestionSelected); - curElement.setAttribute("aria-selected", "false"); - } else { - curElement.classList.add(ClassNames.asbSuggestionSelected); - scrollToView(curElement); - curElement.setAttribute("aria-selected", "true"); - } - } - this._currentSelectedIndex = indexToSelect; - if (curElement) { - this._inputElement.setAttribute("aria-activedescendant", this._repeaterElement.id + indexToSelect); - } else if (this._inputElement.hasAttribute("aria-activedescendant")) { - this._inputElement.removeAttribute("aria-activedescendant"); - } - }, - - _updateFakeFocus: function asb_updateFakeFocus() { - var firstElementIndex; - if (this._isFlyoutShown() && (this._chooseSuggestionOnEnter)) { - firstElementIndex = this._findNextSuggestionElementIndex(-1); - } else { - // This will clear the fake focus. - firstElementIndex = -1; - } - - this._selectSuggestionAtIndex(firstElementIndex); - }, - - _updateQueryTextWithSuggestionText: function asb_updateQueryTextWithSuggestionText(suggestionIndex) { - if ((suggestionIndex >= 0) && (suggestionIndex < this._suggestionsData.length)) { - this.queryText = this._suggestionsData.getAt(suggestionIndex).text; - } - }, - - // Helpers - _disableControl: function asb_disableControl() { - if (this._isFlyoutShown()) { - this._hideFlyout(); - } - this._element.disabled = true; - this._element.classList.add(ClassNames.asbDisabled); - this._inputElement.disabled = true; - }, - - _enableControl: function asb_enableControl() { - this._element.disabled = false; - this._element.classList.remove(ClassNames.asbDisabled); - this._inputElement.disabled = false; - if (_Global.document.activeElement === this._element) { - _ElementUtilities._setActive(this._inputElement); - } - }, - - _fireEvent: function asb_fireEvent(type, detail) { - // Returns true if ev.preventDefault() was not called - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(type, true, true, detail); - return this._element.dispatchEvent(event); - }, - - _getLinguisticDetails: function asb_getLinguisticDetails(useCache, createFilled) { // createFilled=false always creates an empty linguistic details object, otherwise generate it or use the cache - function createQueryLinguisticDetails(compositionAlternatives, compositionStartOffset, compositionLength, queryTextPrefix, queryTextSuffix) { - var linguisticDetails = null; - - // The linguistic alternatives we receive are only for the composition string being composed. We need to provide the linguistic alternatives - // in the form of the full query text with alternatives embedded. - var fullCompositionAlternatives = []; - for (var i = 0; i < compositionAlternatives.length; i++) { - fullCompositionAlternatives[i] = queryTextPrefix + compositionAlternatives[i] + queryTextSuffix; - } - - if (_WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails) { - try { - linguisticDetails = new _WinRT.Windows.ApplicationModel.Search.SearchQueryLinguisticDetails(fullCompositionAlternatives, compositionStartOffset, compositionLength); - } catch (e) { - // WP10 currently exposes SQLD API but throws on instantiation. - } - } - - if (!linguisticDetails) { - // If we're in web compartment, create a script version of the WinRT SearchQueryLinguisticDetails object - linguisticDetails = { - queryTextAlternatives: fullCompositionAlternatives, - queryTextCompositionStart: compositionStartOffset, - queryTextCompositionLength: compositionLength - }; - } - return linguisticDetails; - } - - var linguisticDetails = null; - if ((this._inputElement.value === this._prevQueryText) && useCache && this._prevLinguisticDetails && createFilled) { - linguisticDetails = this._prevLinguisticDetails; - } else { - var compositionAlternatives = []; - var compositionStartOffset = 0; - var compositionLength = 0; - var queryTextPrefix = ""; - var queryTextSuffix = ""; - if (createFilled) { - var context = this._tryGetInputContext(); - if (context && context.getCompositionAlternatives) { - compositionAlternatives = context.getCompositionAlternatives(); - compositionStartOffset = context.compositionStartOffset; - compositionLength = context.compositionEndOffset - context.compositionStartOffset; - - if ((this._inputElement.value !== this._prevQueryText) || (this._prevCompositionLength === 0) || (compositionLength > 0)) { - queryTextPrefix = this._inputElement.value.substring(0, compositionStartOffset); - queryTextSuffix = this._inputElement.value.substring(compositionStartOffset + compositionLength); - } else { - // composition ended, but alternatives have been kept, need to reuse the previous query prefix/suffix, but still report to the client that the composition has ended (start & length of composition of 0) - queryTextPrefix = this._inputElement.value.substring(0, this._prevCompositionStart); - queryTextSuffix = this._inputElement.value.substring(this._prevCompositionStart + this._prevCompositionLength); - } - } - } - linguisticDetails = createQueryLinguisticDetails(compositionAlternatives, compositionStartOffset, compositionLength, queryTextPrefix, queryTextSuffix); - } - return linguisticDetails; - }, - - _isElementInSearchControl: function asb_isElementInSearchControl(targetElement) { - return this.element.contains(targetElement) || (this.element === targetElement); - }, - - _renderSuggestion: function asb_renderSuggestion(suggestion) { - var root = null; - if (!suggestion) { - return root; - } - if (suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Query) { - root = querySuggestionRenderer(this, suggestion); - } else if (suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Separator) { - root = separatorSuggestionRenderer(suggestion); - } else if (suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Result) { - root = resultSuggestionRenderer(this, suggestion); - } else { - throw new _ErrorFromName("WinJS.UI.AutoSuggestBox.invalidSuggestionKind", Strings.invalidSuggestionKind); - } - return root; - }, - - _shouldIgnoreInput: function asb_shouldIgnoreInput() { - var processingIMEFocusLossKey = this._isProcessingDownKey || this._isProcessingUpKey || this._isProcessingTabKey || this._isProcessingEnterKey; - return processingIMEFocusLossKey || this._isFlyoutPointerDown; - }, - - _submitQuery: function asb_submitQuery(queryText, fillLinguisticDetails, event) { - if (this._disposed) { - return; - } - - // get the most up to date value of the input langauge from WinRT if available - if (_WinRT.Windows.Globalization.Language) { - this._lastKeyPressLanguage = _WinRT.Windows.Globalization.Language.currentInputMethodLanguageTag; - } - - this._fireEvent(EventNames.querysubmitted, { - language: this._lastKeyPressLanguage, - linguisticDetails: this._getLinguisticDetails(true /*useCache*/, fillLinguisticDetails), // allow caching, but generate empty linguistic details if suggestion is used - queryText: queryText, - keyModifiers: getKeyModifiers(event) - }); - - if (this._suggestionManager) { - this._suggestionManager.addToHistory(this._inputElement.value, this._lastKeyPressLanguage); - } - }, - - _tryGetInputContext: function asb_tryGetInputContext() { - // On WP, msGetInputContext is defined but throws when invoked - if (this._inputElement.msGetInputContext) { - try { - return this._inputElement.msGetInputContext(); - } catch (e) { - return null; - } - } - return null; - }, - - _updateInputElementAriaLabel: function asb_updateInputElementAriaLabel() { - this._inputElement.setAttribute("aria-label", - this._inputElement.placeholder ? _Resources._formatString(Strings.ariaLabelInputPlaceHolder, this._inputElement.placeholder) : Strings.ariaLabelInputNoPlaceHolder - ); - }, - - // Event Handlers - _flyoutBlurHandler: function asb_flyoutBlurHandler(event) { - if (this._isElementInSearchControl(_Global.document.activeElement)) { - this._internalFocusMove = true; - } else { - this._element.classList.remove(ClassNames.asbInputFocus); - this._hideFlyout(); - } - }, - - _flyoutPointerDownHandler: function asb_flyoutPointerDownHandler(ev) { - var that = this; - var srcElement = ev.target; - function findSuggestionElementIndex() { - if (srcElement) { - for (var i = 0; i < that._suggestionsData.length; i++) { - if (that._repeater.elementFromIndex(i) === srcElement) { - return i; - } - } - } - return -1; - } - - this._isFlyoutPointerDown = true; - while (srcElement && (srcElement.parentNode !== this._repeaterElement)) { - srcElement = srcElement.parentNode; - } - var index = findSuggestionElementIndex(); - if ((index >= 0) && (index < this._suggestionsData.length) && (this._currentFocusedIndex !== index)) { - if (this._isSuggestionSelectable(this._suggestionsData.getAt(index))) { - this._currentFocusedIndex = index; - this._selectSuggestionAtIndex(index); - this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); - } - } - // Prevent default so focus does not leave input element. - ev.preventDefault(); - }, - - _flyoutPointerReleasedHandler: function asb_flyoutPointerReleasedHandler() { - this._isFlyoutPointerDown = false; - - if (this._reflowImeOnPointerRelease) { - this._reflowImeOnPointerRelease = false; - var animation = Animations.createRepositionAnimation(this._flyoutElement); - this._flyoutElement.style.marginTop = ""; - this._flyoutElement.style.marginLeft = ""; - animation.execute(); - } - }, - - _inputBlurHandler: function asb_inputBlurHandler(event) { - // Hide flyout if focus is leaving the control - if (!this._isElementInSearchControl(_Global.document.activeElement)) { - this._element.classList.remove(ClassNames.asbInputFocus); - this._hideFlyout(); - } - this.queryText = this._prevQueryText; // Finalize IME composition - this._isProcessingDownKey = false; - this._isProcessingUpKey = false; - this._isProcessingTabKey = false; - this._isProcessingEnterKey = false; - }, - - _inputFocusHandler: function asb_inputFocusHandler(event) { - // Refresh hit highlighting if text has changed since focus was present - // This can happen if the user committed a suggestion previously. - if (this._inputElement.value !== this._prevQueryText) { - if (_WinRT.Windows.Data.Text.SemanticTextQuery) { - if (this._inputElement.value !== "") { - this._hitFinder = new _WinRT.Windows.Data.Text.SemanticTextQuery(this._inputElement.value, this._inputElement.lang); - } else { - this._hitFinder = null; - } - } - } - - // If focus is returning to the input box from outside the control, show the flyout and refresh the suggestions - if (event.target === this._inputElement && !this._internalFocusMove) { - this._showFlyout(); - if (this._currentFocusedIndex !== -1) { - // Focus is not in input - this._selectSuggestionAtIndex(this._currentFocusedIndex); - } else { - this._updateFakeFocus(); - } - - this._suggestionManager.setQuery( - this._inputElement.value, - this._lastKeyPressLanguage, - this._getLinguisticDetails(true /*useCache*/, true /*createFilled*/) - ); - } - - this._internalFocusMove = false; - this._element.classList.add(ClassNames.asbInputFocus); - }, - - _inputOrImeChangeHandler: function asb_inputImeChangeHandler() { - var that = this; - function hasLinguisticDetailsChanged(newLinguisticDetails) { - var hasLinguisticDetailsChanged = false; - if ((that._prevLinguisticDetails.queryTextCompositionStart !== newLinguisticDetails.queryTextCompositionStart) || - (that._prevLinguisticDetails.queryTextCompositionLength !== newLinguisticDetails.queryTextCompositionLength) || - (that._prevLinguisticDetails.queryTextAlternatives.length !== newLinguisticDetails.queryTextAlternatives.length)) { - hasLinguisticDetailsChanged = true; - } - that._prevLinguisticDetails = newLinguisticDetails; - return hasLinguisticDetailsChanged; - } - - // swallow the IME change event that gets fired when composition is ended due to keyboarding down to the suggestion list & mouse down on the button - if (!this._shouldIgnoreInput()) { - var linguisticDetails = this._getLinguisticDetails(false /*useCache*/, true /*createFilled*/); // never cache on explicit user changes - var hasLinguisticDetailsChanged = hasLinguisticDetailsChanged(linguisticDetails); // updates this._prevLinguisticDetails - - // Keep the previous composition cache up to date, execpt when composition ended with no text change and alternatives are kept. - // In that case, we need to use the cached values to correctly generate the query prefix/suffix for substituting alternatives, but still report to the client that the composition has ended (via start & length of composition of 0) - if ((this._inputElement.value !== this._prevQueryText) || (this._prevCompositionLength === 0) || (linguisticDetails.queryTextCompositionLength > 0)) { - this._prevCompositionStart = linguisticDetails.queryTextCompositionStart; - this._prevCompositionLength = linguisticDetails.queryTextCompositionLength; - } - - if ((this._prevQueryText === this._inputElement.value) && !hasLinguisticDetailsChanged) { - // Sometimes the input change is fired even if there is no change in input. - // Swallow event in those cases. - return; - } - this._prevQueryText = this._inputElement.value; - - // get the most up to date value of the input langauge from WinRT if available - if (_WinRT.Windows.Globalization.Language) { - this._lastKeyPressLanguage = _WinRT.Windows.Globalization.Language.currentInputMethodLanguageTag; - } - - if (_WinRT.Windows.Data.Text.SemanticTextQuery) { - if (this._inputElement.value !== "") { - this._hitFinder = new _WinRT.Windows.Data.Text.SemanticTextQuery(this._inputElement.value, this._lastKeyPressLanguage); - } else { - this._hitFinder = null; - } - } - - this._fireEvent(EventNames.querychanged, { - language: this._lastKeyPressLanguage, - queryText: this._inputElement.value, - linguisticDetails: linguisticDetails - }); - - this._suggestionManager.setQuery( - this._inputElement.value, - this._lastKeyPressLanguage, - linguisticDetails - ); - } - }, - - _inputPointerDownHandler: function asb_inputPointerDownHandler() { - if ((_Global.document.activeElement === this._inputElement) && (this._currentSelectedIndex !== -1)) { - this._currentFocusedIndex = -1; - this._selectSuggestionAtIndex(this._currentFocusedIndex); - } - }, - - _keyDownHandler: function asb_keyDownHandler(event) { - var that = this; - function setSelection(index) { - that._currentFocusedIndex = index; - that._selectSuggestionAtIndex(index); - event.preventDefault(); - event.stopPropagation(); - } - - this._lastKeyPressLanguage = event.locale; - if (event.keyCode === Key.tab) { - this._isProcessingTabKey = true; - } else if (event.keyCode === Key.upArrow) { - this._isProcessingUpKey = true; - } else if (event.keyCode === Key.downArrow) { - this._isProcessingDownKey = true; - } else if ((event.keyCode === Key.enter) && (event.locale === "ko")) { - this._isProcessingEnterKey = true; - } - // Ignore keys handled by ime. - if (event.keyCode !== Key.IME) { - if (event.keyCode === Key.tab) { - var closeFlyout = true; - if (event.shiftKey) { - if (this._currentFocusedIndex !== -1) { - // Focus is not in input - setSelection(-1); - closeFlyout = false; - } - } else if (this._currentFocusedIndex === -1) { - this._currentFocusedIndex = - this._flyoutBelowInput - ? this._findNextSuggestionElementIndex(this._currentFocusedIndex) - : this._findPreviousSuggestionElementIndex(this._suggestionsData.length); - if (this._currentFocusedIndex !== -1) { - // Found a selectable element - setSelection(this._currentFocusedIndex); - this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); - closeFlyout = false; - } - } - - if (closeFlyout) { - this._hideFlyout(); - } - } else if (event.keyCode === Key.escape) { - if (this._currentFocusedIndex !== -1) { - // Focus is not in input - this.queryText = this._prevQueryText; - setSelection(-1); - } else if (this.queryText !== "") { - this.queryText = ""; - this._inputOrImeChangeHandler(null); - event.preventDefault(); - event.stopPropagation(); - } - } else if ((this._flyoutBelowInput && event.keyCode === Key.upArrow) || (!this._flyoutBelowInput && event.keyCode === Key.downArrow)) { - var prevIndex; - if (this._currentSelectedIndex !== -1) { - prevIndex = this._findPreviousSuggestionElementIndex(this._currentSelectedIndex); - // Restore user entered query when user navigates back to input. - if (prevIndex === -1) { - this.queryText = this._prevQueryText; - } - } else { - prevIndex = this._findPreviousSuggestionElementIndex(this._suggestionsData.length); - } - setSelection(prevIndex); - this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); - } else if ((this._flyoutBelowInput && event.keyCode === Key.downArrow) || (!this._flyoutBelowInput && event.keyCode === Key.upArrow)) { - var nextIndex = this._findNextSuggestionElementIndex(this._currentSelectedIndex); - // Restore user entered query when user navigates back to input. - if ((this._currentSelectedIndex !== -1) && (nextIndex === -1)) { - this.queryText = this._prevQueryText; - } - setSelection(nextIndex); - this._updateQueryTextWithSuggestionText(this._currentFocusedIndex); - } else if (event.keyCode === Key.enter) { - if (this._currentSelectedIndex === -1) { - this._submitQuery(this._inputElement.value, true /*fillLinguisticDetails*/, event); - } else { - this._processSuggestionChosen(this._suggestionsData.getAt(this._currentSelectedIndex), event); - } - this._hideFlyout(); - } - } - }, - - _keyUpHandler: function asb_keyUpHandler(event) { - if (event.keyCode === Key.tab) { - this._isProcessingTabKey = false; - } else if (event.keyCode === Key.upArrow) { - this._isProcessingUpKey = false; - } else if (event.keyCode === Key.downArrow) { - this._isProcessingDownKey = false; - } else if (event.keyCode === Key.enter) { - this._isProcessingEnterKey = false; - } - }, - - _keyPressHandler: function asb_keyPressHandler(event) { - this._lastKeyPressLanguage = event.locale; - }, - - _msCandidateWindowHideHandler: function asb_msCandidateWindowHideHandler() { - if (!this._isFlyoutPointerDown) { - var animation = Animations.createRepositionAnimation(this._flyoutElement); - this._flyoutElement.style.marginTop = ""; - this._flyoutElement.style.marginLeft = ""; - animation.execute(); - } else { - this._reflowImeOnPointerRelease = true; - } - }, - - _msCandidateWindowShowHandler: function asb_msCandidateWindowShowHandler() { - this._addFlyoutIMEPaddingIfRequired(); - this._reflowImeOnPointerRelease = false; - }, - - _suggestionsChangedHandler: function asb_suggestionsChangedHandler(event) { - var collectionChange = event.collectionChange || event.detail.collectionChange; - var changeIndex = (+event.index === event.index) ? event.index : event.detail.index; - var ChangeEnum = _SuggestionManagerShim._CollectionChange; - if (collectionChange === ChangeEnum.reset) { - if (this._isFlyoutShown()) { - this._hideFlyout(); - } - this._suggestionsData.splice(0, this._suggestionsData.length); - } else if (collectionChange === ChangeEnum.itemInserted) { - var suggestion = this._suggestions[changeIndex]; - this._suggestionsData.splice(changeIndex, 0, suggestion); - - this._showFlyout(); - - } else if (collectionChange === ChangeEnum.itemRemoved) { - if ((this._suggestionsData.length === 1)) { - _ElementUtilities._setActive(this._inputElement); - - this._hideFlyout(); - } - this._suggestionsData.splice(changeIndex, 1); - } else if (collectionChange === ChangeEnum.itemChanged) { - var suggestion = this._suggestions[changeIndex]; - if (suggestion !== this._suggestionsData.getAt(changeIndex)) { - this._suggestionsData.setAt(changeIndex, suggestion); - } else { - // If the suggestions manager gives us an identical item, it means that only the hit highlighted text has changed. - var existingElement = this._repeater.elementFromIndex(changeIndex); - if (_ElementUtilities.hasClass(existingElement, ClassNames.asbSuggestionQuery)) { - addHitHighlightedText(existingElement, suggestion, suggestion.text); - } else { - var resultSuggestionDiv = existingElement.querySelector("." + ClassNames.asbSuggestionResultText); - if (resultSuggestionDiv) { - addHitHighlightedText(resultSuggestionDiv, suggestion, suggestion.text); - var resultSuggestionDetailDiv = existingElement.querySelector("." + ClassNames.asbSuggestionResultDetailedText); - if (resultSuggestionDetailDiv) { - addHitHighlightedText(resultSuggestionDetailDiv, suggestion, suggestion.detailText); - } - } - } - } - } - - if (_Global.document.activeElement === this._inputElement) { - this._updateFakeFocus(); - } - }, - - _suggestionsRequestedHandler: function asb_suggestionsRequestedHandler(event) { - // get the most up to date value of the input langauge from WinRT if available - if (_WinRT.Windows.Globalization.Language) { - this._lastKeyPressLanguage = _WinRT.Windows.Globalization.Language.currentInputMethodLanguageTag; - } - - var request = event.request || event.detail.request; - var deferral; - this._fireEvent(EventNames.suggestionsrequested, { - setPromise: function (promise) { - deferral = request.getDeferral(); - promise.then(function () { - deferral.complete(); - }); - }, - searchSuggestionCollection: request.searchSuggestionCollection, - language: this._lastKeyPressLanguage, - linguisticDetails: this._getLinguisticDetails(true /*useCache*/, true /*createFilled*/), - queryText: this._inputElement.value - }); - }, - }, { - createResultSuggestionImage: function asb_createResultSuggestionImage(url) { - /// - /// - /// Creates the image argument for SearchSuggestionCollection.appendResultSuggestion. - /// - /// - /// The url of the image. - /// - /// - /// - if (_WinRT.Windows.Foundation.Uri && _WinRT.Windows.Storage.Streams.RandomAccessStreamReference) { - return _WinRT.Windows.Storage.Streams.RandomAccessStreamReference.createFromUri(new _WinRT.Windows.Foundation.Uri(url)); - } - return url; - }, - - _EventNames: EventNames, - - _sortAndMergeHits: function asb_sortAndMergeHits(hitsProvided) { - function hitStartPositionAscendingSorter(firstHit, secondHit) { - var returnValue = 0; - if (firstHit.startPosition < secondHit.startPosition) { - returnValue = -1; - } else if (firstHit.startPosition > secondHit.startPosition) { - returnValue = 1; - } - return returnValue; - } - function hitIntersectionReducer(reducedHits, nextHit, currentIndex) { - if (currentIndex === 0) { - reducedHits.push(nextHit); - } else { - var curHit = reducedHits[reducedHits.length - 1]; - var curHitEndPosition = curHit.startPosition + curHit.length; - if (nextHit.startPosition <= curHitEndPosition) { - // The next hit intersects or is next to current hit. Merge it. - var nextHitEndPosition = nextHit.startPosition + nextHit.length; - if (nextHitEndPosition > curHitEndPosition) { - curHit.length = nextHitEndPosition - curHit.startPosition; - } - } else { - // No intersection, simply add to reduced list. - reducedHits.push(nextHit); - } - } - return reducedHits; - } - - var reducedHits = []; - if (hitsProvided) { - // Copy hitsprovided array as winrt objects are immutable. - var hits = new Array(hitsProvided.length); - for (var i = 0; i < hitsProvided.length; i++) { - hits.push({ startPosition: hitsProvided[i].startPosition, length: hitsProvided[i].length }); - } - hits.sort(hitStartPositionAscendingSorter); - hits.reduce(hitIntersectionReducer, reducedHits); - } - return reducedHits; - } - }); - - function addHitHighlightedText(element, item, text, hitFinder) { - function addNewSpan(element, textContent, insertBefore) { - // Adds new span element with specified inner text as child to element, placed before insertBefore - var spanElement = _Global.document.createElement("span"); - spanElement.textContent = textContent; - spanElement.setAttribute("aria-hidden", "true"); - spanElement.classList.add(ClassNames.asbHitHighlightSpan); - element.insertBefore(spanElement, insertBefore); - return spanElement; - } - - if (text) { - // Remove any existing hit highlighted text spans - _ElementListUtilities.query("." + ClassNames.asbHitHighlightSpan, element).forEach(function (childElement) { - childElement.parentNode.removeChild(childElement); - }); - - // Insert spans at the front of element - var firstChild = element.firstChild; - - var hitsProvided = item.hits; - if ((!hitsProvided) && (hitFinder) && (item.kind !== _SuggestionManagerShim._SearchSuggestionKind.Separator)) { - hitsProvided = hitFinder.find(text); - } - - var hits = AutoSuggestBox._sortAndMergeHits(hitsProvided); - - var lastPosition = 0; - for (var i = 0; i < hits.length; i++) { - var hit = hits[i]; - - // Add previous normal text - addNewSpan(element, text.substring(lastPosition, hit.startPosition), firstChild); - - lastPosition = hit.startPosition + hit.length; - - // Add hit highlighted text - var spanHitHighlightedText = addNewSpan(element, text.substring(hit.startPosition, lastPosition), firstChild); - _ElementUtilities.addClass(spanHitHighlightedText, ClassNames.asbBoxFlyoutHighlightText); - } - - // Add final normal text - if (lastPosition < text.length) { - addNewSpan(element, text.substring(lastPosition), firstChild); - } - } - } - - function getKeyModifiers(ev) { - // Returns the same value as https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.system.virtualkeymodifiers - var VirtualKeys = { - ctrlKey: 1, - altKey: 2, - shiftKey: 4 - }; - - var keyModifiers = 0; - if (ev.ctrlKey) { - keyModifiers |= VirtualKeys.ctrlKey; - } - if (ev.altKey) { - keyModifiers |= VirtualKeys.altKey; - } - if (ev.shiftKey) { - keyModifiers |= VirtualKeys.shiftKey; - } - return keyModifiers; - } - - function resultSuggestionRenderer(asb, item) { - function handleInvoke(e) { - asb._internalFocusMove = true; - asb._inputElement.focus(); - asb._processSuggestionChosen(item, e); - } - - var root = _Global.document.createElement("div"); - var image = new _Global.Image(); - image.style.opacity = 0; - var loadImage = function (url) { - function onload() { - image.removeEventListener("load", onload, false); - Animations.fadeIn(image); - } - image.addEventListener("load", onload, false); - image.src = url; - }; - - if (item.image !== null) { - item.image.openReadAsync().then(function (streamWithContentType) { - if (streamWithContentType !== null) { - loadImage(_Global.URL.createObjectURL(streamWithContentType, { oneTimeOnly: true })); - } - }); - } else if (item.imageUrl !== null) { - loadImage(item.imageUrl); - } - image.setAttribute("aria-hidden", "true"); - root.appendChild(image); - - var divElement = _Global.document.createElement("div"); - _ElementUtilities.addClass(divElement, ClassNames.asbSuggestionResultText); - addHitHighlightedText(divElement, item, item.text); - divElement.title = item.text; - divElement.setAttribute("aria-hidden", "true"); - root.appendChild(divElement); - - var brElement = _Global.document.createElement("br"); - divElement.appendChild(brElement); - - var divDetailElement = _Global.document.createElement("span"); - _ElementUtilities.addClass(divDetailElement, ClassNames.asbSuggestionResultDetailedText); - addHitHighlightedText(divDetailElement, item, item.detailText); - divDetailElement.title = item.detailText; - divDetailElement.setAttribute("aria-hidden", "true"); - divElement.appendChild(divDetailElement); - - _ElementUtilities.addClass(root, ClassNames.asbSuggestionResult); - - _ElementUtilities._addEventListener(root, "click", function (e) { - if (!asb._isFlyoutPointerDown) { - handleInvoke(e); - } - }); - _ElementUtilities._addEventListener(root, "pointerup", handleInvoke); - - root.setAttribute("role", "option"); - var ariaLabel = _Resources._formatString(Strings.ariaLabelResult, item.text, item.detailText); - root.setAttribute("aria-label", ariaLabel); - return root; - } - - function querySuggestionRenderer(asb, item) { - function handleInvoke(e) { - asb._internalFocusMove = true; - asb._inputElement.focus(); - asb._processSuggestionChosen(item, e); - } - - var root = _Global.document.createElement("div"); - - addHitHighlightedText(root, item, item.text); - root.title = item.text; - - root.classList.add(ClassNames.asbSuggestionQuery); - - _ElementUtilities._addEventListener(root, "click", function (e) { - if (!asb._isFlyoutPointerDown) { - handleInvoke(e); - } - }); - _ElementUtilities._addEventListener(root, "pointerup", handleInvoke); - - var ariaLabel = _Resources._formatString(Strings.ariaLabelQuery, item.text); - root.setAttribute("role", "option"); - root.setAttribute("aria-label", ariaLabel); - - return root; - } - - function separatorSuggestionRenderer(item) { - var root = _Global.document.createElement("div"); - if (item.text.length > 0) { - var textElement = _Global.document.createElement("div"); - textElement.textContent = item.text; - textElement.title = item.text; - textElement.setAttribute("aria-hidden", "true"); - root.appendChild(textElement); - } - root.insertAdjacentHTML("beforeend", "
"); - _ElementUtilities.addClass(root, ClassNames.asbSuggestionSeparator); - root.setAttribute("role", "separator"); - var ariaLabel = _Resources._formatString(Strings.ariaLabelSeparator, item.text); - root.setAttribute("aria-label", ariaLabel); - return root; - } - - _Base.Class.mix(AutoSuggestBox, _Control.DOMEventMixin); - return AutoSuggestBox; - }) - }); - exports.ClassNames = ClassNames; -}); - - -define('require-style!less/styles-searchbox',[],function(){}); - -define('require-style!less/colors-searchbox',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/SearchBox',[ - '../Core/_Global', - '../Core/_WinRT', - '../Core/_Base', - '../Core/_ErrorFromName', - '../Core/_Events', - '../Core/_Resources', - './AutoSuggestBox', - '../_Accents', - '../Utilities/_Control', - '../Utilities/_ElementUtilities', - './AutoSuggestBox/_SearchSuggestionManagerShim', - '../Application', - 'require-style!less/styles-searchbox', - 'require-style!less/colors-searchbox' -], function searchboxInit(_Global, _WinRT, _Base, _ErrorFromName, _Events, _Resources, AutoSuggestBox, _Accents, _Control, _ElementUtilities, _SuggestionManagerShim, Application) { - "use strict"; - - _Accents.createAccentRule("html.win-hoverable .win-searchbox-button:not(.win-searchbox-button-disabled):hover", [{ name: "color", value: _Accents.ColorTypes.accent }, ]); - _Accents.createAccentRule(".win-searchbox-button.win-searchbox-button:not(.win-searchbox-button-disabled):hover:active", [{ name: "background-color", value: _Accents.ColorTypes.accent }, ]); - - _Base.Namespace.define("WinJS.UI", { - /// - /// - /// Enables the user to perform search queries and select suggestions. - /// - /// - /// - /// - /// - /// ]]> - /// - /// Raised when the app automatically redirects focus to the search box. This event can only be raised when the focusOnKeyboardInput property is set to true. - /// - /// Styles the entire Search box control. - /// Styles the query input box. - /// Styles the search button. - /// Styles the result suggestions flyout. - /// Styles the result type suggestion. - /// Styles the query type suggestion. - /// - /// Styles the separator type suggestion. - /// - /// - /// Styles the currently selected suggestion. - /// - /// - /// - SearchBox: _Base.Namespace._lazy(function () { - - // Enums - var ClassName = { - searchBox: "win-searchbox", - searchBoxDisabled: "win-searchbox-disabled", - searchBoxInput: "win-searchbox-input", - searchBoxInputFocus: "win-searchbox-input-focus", - searchBoxButton: "win-searchbox-button", - searchBoxFlyout: "win-searchbox-flyout", - searchBoxFlyoutHighlightText: "win-searchbox-flyout-highlighttext", - searchBoxHitHighlightSpan: "win-searchbox-hithighlight-span", - searchBoxSuggestionResult: "win-searchbox-suggestion-result", - searchBoxSuggestionResultText: "win-searchbox-suggestion-result-text", - searchBoxSuggestionResultDetailedText: "win-searchbox-suggestion-result-detailed-text", - searchBoxSuggestionSelected: "win-searchbox-suggestion-selected", - searchBoxSuggestionQuery: "win-searchbox-suggestion-query", - searchBoxSuggestionSeparator: "win-searchbox-suggestion-separator", - searchBoxButtonInputFocus: "win-searchbox-button-input-focus", - searchBoxButtonDisabled: "win-searchbox-button-disabled" - }; - - var EventName = { - receivingfocusonkeyboardinput: "receivingfocusonkeyboardinput" - }; - - var strings = { - get invalidSearchBoxSuggestionKind() { return "Error: Invalid search suggestion kind."; }, - get ariaLabel() { return _Resources._getWinJSString("ui/searchBoxAriaLabel").value; }, - get ariaLabelInputNoPlaceHolder() { return _Resources._getWinJSString("ui/searchBoxAriaLabelInputNoPlaceHolder").value; }, - get ariaLabelInputPlaceHolder() { return _Resources._getWinJSString("ui/searchBoxAriaLabelInputPlaceHolder").value; }, - get searchBoxDeprecated() { return "SearchBox is deprecated and may not be available in future releases. Instead use AutoSuggestBox."; } - }; - - var SearchBox = _Base.Class.derive(AutoSuggestBox.AutoSuggestBox, function SearchBox_ctor(element, options) { - /// - /// - /// Creates a new SearchBox. - /// - /// - /// The DOM element that hosts the SearchBox. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". For example, to provide a handler for the querychanged event, - /// add a property named "onquerychanged" to the options object and set its value to the event handler. - /// This parameter is optional. - /// - /// - /// The new SearchBox. - /// - /// - /// SearchBox is deprecated and may not be available in future releases. Instead use AutoSuggestBox. - /// - /// - /// - - _ElementUtilities._deprecated(strings.searchBoxDeprecated); - - this._requestingFocusOnKeyboardInputHandlerBind = this._requestingFocusOnKeyboardInputHandler.bind(this); - - // Elements - this._buttonElement = _Global.document.createElement("div"); - - // Variables - this._focusOnKeyboardInput = false; - - // Calling the super constructor - since the super constructor processes the options, - // any property setter at this point must be functional. - AutoSuggestBox.AutoSuggestBox.call(this, element, options); - - // Add SearchBox classes to DOM elements - this.element.classList.add(ClassName.searchBox); - this._flyoutElement.classList.add(ClassName.searchBoxFlyout); - - this._inputElement.classList.add(ClassName.searchBoxInput); - this._inputElement.addEventListener("blur", this._searchboxInputBlurHandler.bind(this)); - this._inputElement.addEventListener("focus", this._searchboxInputFocusHandler.bind(this)); - - this._buttonElement.tabIndex = -1; - this._buttonElement.classList.add(ClassName.searchBoxButton); - this._buttonElement.addEventListener("click", this._buttonClickHandler.bind(this)); - _ElementUtilities._addEventListener(this._buttonElement, "pointerdown", this._buttonPointerDownHandler.bind(this)); - this.element.appendChild(this._buttonElement); - }, { - /// - /// Enable automatically focusing the search box when the user types into the app window (off by default) While this is enabled, - /// input on the current thread will be intercepted and redirected to the search box. Only textual input will trigger the search box to focus. - /// The caller will continue to receive non-text keys (such as arrows, tab, etc - /// This will also not affect WIN/CTRL/ALT key combinations (except for Ctrl-V for paste). - /// If the client needs more to happen than just set focus in the box (make control visible, etc.), they will need to handle the event. - /// If enabled, the app must be sure to disable this if the user puts focus in some other edit field. - /// - /// - focusOnKeyboardInput: { - get: function () { - return this._focusOnKeyboardInput; - }, - set: function (value) { - if (this._focusOnKeyboardInput && !value) { - Application._applicationListener.removeEventListener(this.element, "requestingfocusonkeyboardinput", this._requestingFocusOnKeyboardInputHandlerBind); - } else if (!this._focusOnKeyboardInput && !!value) { - Application._applicationListener.addEventListener(this.element, "requestingfocusonkeyboardinput", this._requestingFocusOnKeyboardInputHandlerBind); - } - this._focusOnKeyboardInput = !!value; - } - }, - - // Methods - dispose: function SearchBox() { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - AutoSuggestBox.AutoSuggestBox.prototype.dispose.call(this); - - if (this._focusOnKeyboardInput) { - Application._applicationListener.removeEventListener(this.element, "requestingfocusonkeyboardinput", this._requestingFocusOnKeyboardInputHandlerBind); - } - }, - - // Private methods - _disableControl: function SearchBox_disableControl() { - AutoSuggestBox.AutoSuggestBox.prototype._disableControl.call(this); - this._buttonElement.disabled = true; - this._buttonElement.classList.add(ClassName.searchBoxButtonDisabled); - this.element.classList.add(ClassName.searchBoxDisabled); - }, - - _enableControl: function SearchBox_enableControl() { - AutoSuggestBox.AutoSuggestBox.prototype._enableControl.call(this); - this._buttonElement.disabled = false; - this._buttonElement.classList.remove(ClassName.searchBoxButtonDisabled); - this.element.classList.remove(ClassName.searchBoxDisabled); - }, - - _renderSuggestion: function SearchBox_renderSuggestion(suggestion) { - // Overrides base class - var render = AutoSuggestBox.AutoSuggestBox.prototype._renderSuggestion.call(this, suggestion); - if (suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Query) { - render.classList.add(ClassName.searchBoxSuggestionQuery); - } else if (suggestion.kind === _SuggestionManagerShim._SearchSuggestionKind.Separator) { - render.classList.add(ClassName.searchBoxSuggestionSeparator); - } else { - render.classList.add(ClassName.searchBoxSuggestionResult); - - var resultText = render.querySelector("." + AutoSuggestBox.ClassNames.asbSuggestionResultText); - resultText.classList.add(ClassName.searchBoxSuggestionResultText); - - var resultDetailText = render.querySelector("." + AutoSuggestBox.ClassNames.asbSuggestionResultDetailedText); - resultDetailText.classList.add(ClassName.searchBoxSuggestionResultDetailedText); - - var spans = render.querySelectorAll("." + AutoSuggestBox.ClassNames.asbHitHighlightSpan); - for (var i = 0, len = spans.length; i < len; i++) { - spans[i].classList.add(ClassName.searchBoxHitHighlightSpan); - } - var highlightTexts = render.querySelectorAll("." + AutoSuggestBox.ClassNames.asbBoxFlyoutHighlightText); - for (var i = 0, len = highlightTexts.length; i < len; i++) { - highlightTexts[i].classList.add(ClassName.searchBoxFlyoutHighlightText); - } - } - return render; - }, - - _selectSuggestionAtIndex: function SearchBox_selectSuggestionAtIndex(indexToSelect) { - // Overrides base class - AutoSuggestBox.AutoSuggestBox.prototype._selectSuggestionAtIndex.call(this, indexToSelect); - - var currentSelected = this.element.querySelector("." + ClassName.searchBoxSuggestionSelected); - currentSelected && currentSelected.classList.remove(ClassName.searchBoxSuggestionSelected); - var newSelected = this.element.querySelector("." + AutoSuggestBox.ClassNames.asbSuggestionSelected); - newSelected && newSelected.classList.add(ClassName.searchBoxSuggestionSelected); - }, - - _shouldIgnoreInput: function SearchBox_shouldIgnoreInput() { - // Overrides base class - var shouldIgnore = AutoSuggestBox.AutoSuggestBox.prototype._shouldIgnoreInput(); - var isButtonDown = _ElementUtilities._matchesSelector(this._buttonElement, ":active"); - - return shouldIgnore || isButtonDown; - }, - - _updateInputElementAriaLabel: function SearchBox_updateInputElementAriaLabel() { - // Override base class - this._inputElement.setAttribute("aria-label", - this._inputElement.placeholder ? _Resources._formatString(strings.ariaLabelInputPlaceHolder, this._inputElement.placeholder) : strings.ariaLabelInputNoPlaceHolder - ); - }, - - // Event Handlers - _buttonPointerDownHandler: function SearchBox_buttonPointerDownHandler(e) { - this._inputElement.focus(); - e.preventDefault(); - }, - - _buttonClickHandler: function SearchBox_buttonClickHandler(event) { - this._inputElement.focus(); - this._submitQuery(this._inputElement.value, true /*fillLinguisticDetails*/, event); - this._hideFlyout(); - }, - - _searchboxInputBlurHandler: function SearchBox_inputBlurHandler() { - _ElementUtilities.removeClass(this.element, ClassName.searchBoxInputFocus); - _ElementUtilities.removeClass(this._buttonElement, ClassName.searchBoxButtonInputFocus); - }, - - _searchboxInputFocusHandler: function SearchBox_inputFocusHandler() { - _ElementUtilities.addClass(this.element, ClassName.searchBoxInputFocus); - _ElementUtilities.addClass(this._buttonElement, ClassName.searchBoxButtonInputFocus); - }, - - // Type to search helpers - _requestingFocusOnKeyboardInputHandler: function SearchBox_requestingFocusOnKeyboardInputHandler() { - this._fireEvent(EventName.receivingfocusonkeyboardinput, null); - if (_Global.document.activeElement !== this._inputElement) { - try { - this._inputElement.focus(); - } catch (e) { - } - } - } - - }, { - createResultSuggestionImage: function SearchBox_createResultSuggestionImage(url) { - /// - /// - /// Creates the image argument for SearchSuggestionCollection.appendResultSuggestion. - /// - /// - /// The url of the image. - /// - /// - /// - if (_WinRT.Windows.Foundation.Uri && _WinRT.Windows.Storage.Streams.RandomAccessStreamReference) { - return _WinRT.Windows.Storage.Streams.RandomAccessStreamReference.createFromUri(new _WinRT.Windows.Foundation.Uri(url)); - } - return url; - }, - - _getKeyModifiers: function SearchBox_getKeyModifiers(ev) { - // Returns the same value as https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.system.virtualkeymodifiers - var VirtualKeys = { - ctrlKey: 1, - altKey: 2, - shiftKey: 4 - }; - - var keyModifiers = 0; - if (ev.ctrlKey) { - keyModifiers |= VirtualKeys.ctrlKey; - } - if (ev.altKey) { - keyModifiers |= VirtualKeys.altKey; - } - if (ev.shiftKey) { - keyModifiers |= VirtualKeys.shiftKey; - } - return keyModifiers; - }, - - _isTypeToSearchKey: function searchBox__isTypeToSearchKey(event) { - if (event.shiftKey || event.ctrlKey || event.altKey) { - return false; - } - return true; - } - }); - _Base.Class.mix(SearchBox, _Control.DOMEventMixin); - return SearchBox; - }) - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// appbar,Flyout,Flyouts,registeredforsettings,SettingsFlyout,Statics,Syriac -define('WinJS/Controls/SettingsFlyout',[ - '../Core/_Global', - '../Core/_WinRT', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_ErrorFromName', - '../Core/_Events', - '../Core/_Resources', - '../Core/_WriteProfilerMark', - '../Animations', - '../Pages', - '../Promise', - '../_LightDismissService', - '../Utilities/_Dispose', - '../Utilities/_ElementUtilities', - '../Utilities/_ElementListUtilities', - '../Utilities/_Hoverable', - './_LegacyAppBar/_Constants', - './Flyout/_Overlay' - ], function settingsFlyoutInit(_Global, _WinRT, _Base, _BaseUtils, _ErrorFromName, _Events, _Resources, _WriteProfilerMark, Animations, Pages, Promise, _LightDismissService, _Dispose, _ElementUtilities, _ElementListUtilities, _Hoverable, _Constants, _Overlay) { - "use strict"; - - _Base.Namespace.define("WinJS.UI", { - /// - /// Provides users with fast, in-context access to settings that affect the current app. - /// - /// - /// Settings Flyout - /// - /// - /// - ///
- /// - ///
Custom Settings
- ///
- ///
- /// {Your Content Here} - ///
- /// ]]>
- /// Raised just before showing a SettingsFlyout. - /// Raised immediately after a SettingsFlyout is fully shown. - /// Raised just before hiding a SettingsFlyout. - /// Raised immediately after a SettingsFlyout is fully hidden. - /// The SettingsFlyout control itself. - /// - /// - SettingsFlyout: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - var createEvent = _Events._createEventProperty; - - var settingsPageIsFocusedOnce; - - // Constants for width - var settingsNarrow = "narrow", - settingsWide = "wide"; - - // Determine if the settings pane (system language) is RTL or not. - function _shouldAnimateFromLeft() { - if (_WinRT.Windows.UI.ApplicationSettings.SettingsEdgeLocation) { - var appSettings = _WinRT.Windows.UI.ApplicationSettings; - return (appSettings.SettingsPane.edge === appSettings.SettingsEdgeLocation.left); - } else { - return false; - } - } - - // Get the settings control by matching the settingsCommandId - // if no match we'll try to match element id - function _getChildSettingsControl(parentElement, id) { - var settingElements = parentElement.querySelectorAll("." + _Constants.settingsFlyoutClass); - var retValue, - control; - for (var i = 0; i < settingElements.length; i++) { - control = settingElements[i].winControl; - if (control) { - if (control.settingsCommandId === id) { - retValue = control; - break; - } - if (settingElements[i].id === id) { - retValue = retValue || control; - } - } - } - - return retValue; - } - - var SettingsFlyout = _Base.Class.derive(_Overlay._Overlay, function SettingsFlyout_ctor(element, options) { - /// - /// Creates a new SettingsFlyout control. - /// - /// The DOM element that will host the control. - /// - /// - /// The set of properties and values to apply to the new SettingsFlyout. - /// - /// The new SettingsFlyout control. - /// - /// SettingsFlyout is deprecated and may not be available in future releases. Instead, put - /// settings on their own page within the app. - /// - /// - /// - - _ElementUtilities._deprecated(strings.settingsFlyoutIsDeprecated); - - // Make sure there's an input element - this._element = element || _Global.document.createElement("div"); - this._id = this._element.id || _ElementUtilities._uniqueID(this._element); - this._writeProfilerMark("constructor,StartTM"); - - // Call the base overlay constructor helper - this._baseOverlayConstructor(this._element, options); - - this._addFirstDiv(); - this._addFinalDiv(); - - // Handle "esc" & "tab" key presses - this._element.addEventListener("keydown", this._handleKeyDown, true); - - // Start settings hidden - this._element.style.visibilty = "hidden"; - this._element.style.display = "none"; - - // Attach our css class - _ElementUtilities.addClass(this._element, _Constants.settingsFlyoutClass); - - var that = this; - this._dismissable = new _LightDismissService.LightDismissableElement({ - element: this._element, - tabIndex: this._element.hasAttribute("tabIndex") ? this._element.tabIndex : -1, - onLightDismiss: function () { - that.hide(); - }, - onTakeFocus: function (useSetActive) { - if (!that._dismissable.restoreFocus()) { - var firstDiv = that.element.querySelector("." + _Constants.firstDivClass); - if (firstDiv) { - if (!firstDiv.msSettingsFlyoutFocusOut) { - _ElementUtilities._addEventListener(firstDiv, "focusout", function () { settingsPageIsFocusedOnce = 1; }, false); - firstDiv.msSettingsFlyoutFocusOut = true; - } - - settingsPageIsFocusedOnce = 0; - _ElementUtilities._tryFocus(firstDiv, useSetActive); - } - } - }, - }); - - // apply the light theme styling to the win-content elements inside the SettingsFlyout - _ElementListUtilities.query("div.win-content", this._element). - forEach(function (e) { - if (!_ElementUtilities._matchesSelector(e, '.win-ui-dark, .win-ui-dark *')){ - _ElementUtilities.addClass(e, _Constants.flyoutLightClass); - } - }); - - // Make sure we have an ARIA role - var role = this._element.getAttribute("role"); - if (role === null || role === "" || role === undefined) { - this._element.setAttribute("role", "dialog"); - } - var label = this._element.getAttribute("aria-label"); - if (label === null || label === "" || label === undefined) { - this._element.setAttribute("aria-label", strings.ariaLabel); - } - - // Make sure animations are hooked up - this._currentAnimateIn = this._animateSlideIn; - this._currentAnimateOut = this._animateSlideOut; - this._writeProfilerMark("constructor,StopTM"); - }, { - // Public Properties - - /// - /// Width of the SettingsFlyout, "narrow", or "wide". - /// - /// SettingsFlyout.width may be altered or unavailable in future versions. Instead, style the CSS width property on elements with the .win-settingsflyout class. - /// - /// - /// - width: { - get: function () { - return this._width; - }, - - set: function (value) { - _ElementUtilities._deprecated(strings.widthDeprecationMessage); - if (value === this._width) { - return; - } - // Get rid of old class - if (this._width === settingsNarrow) { - _ElementUtilities.removeClass(this._element, _Constants.narrowClass); - } else if (this._width === settingsWide) { - _ElementUtilities.removeClass(this._element, _Constants.wideClass); - } - this._width = value; - - // Attach our new css class - if (this._width === settingsNarrow) { - _ElementUtilities.addClass(this._element, _Constants.narrowClass); - } else if (this._width === settingsWide) { - _ElementUtilities.addClass(this._element, _Constants.wideClass); - } - } - }, - - /// - /// Define the settings command Id for the SettingsFlyout control. - /// - /// - settingsCommandId: { - get: function () { - return this._settingsCommandId; - }, - - set: function (value) { - this._settingsCommandId = value; - } - }, - - /// Disable SettingsFlyout, setting or getting the HTML disabled attribute. When disabled the SettingsFlyout will no longer display with show(), and will hide if currently visible. - disabled: { - get: function () { - // Ensure it's a boolean because we're using the DOM element to keep in-sync - return !!this._element.disabled; - }, - set: function (value) { - // Force this check into a boolean because our current state could be a bit confused since we tie to the DOM element - value = !!value; - var oldValue = !!this._element.disabled; - if (oldValue !== value) { - this._element.disabled = value; - if (!this.hidden && this._element.disabled) { - this._dismiss(); - } - } - } - }, - - /// - /// Occurs immediately before the control is shown. - /// - onbeforeshow: createEvent(_Overlay._Overlay.beforeShow), - - /// - /// Occurs immediately after the control is shown. - /// - onaftershow: createEvent(_Overlay._Overlay.afterShow), - - /// - /// Occurs immediately before the control is hidden. - /// - onbeforehide: createEvent(_Overlay._Overlay.beforeHide), - - /// - /// Occurs immediately after the control is hidden. - /// - onafterhide: createEvent(_Overlay._Overlay.afterHide), - - show: function () { - /// - /// - /// Shows the SettingsFlyout, if hidden. - /// - /// - /// - // Just call private version to make appbar flags happy - - // Don't do anything if disabled - if (this.disabled) { - return; - } - this._writeProfilerMark("show,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndShow(). - this._show(); - }, - - _dispose: function SettingsFlyout_dispose() { - _LightDismissService.hidden(this._dismissable); - _Dispose.disposeSubTree(this.element); - this._dismiss(); - }, - - _show: function SettingsFlyout_show() { - // We call our base "_baseShow" because SettingsFlyout overrides show - if (this._baseShow()) { - // Verify that the firstDiv and finalDiv are in the correct location. - // Move them to the correct location or add them if they are not. - if (!_ElementUtilities.hasClass(this.element.children[0], _Constants.firstDivClass)) { - var firstDiv = this.element.querySelectorAll("." + _Constants.firstDivClass); - if (firstDiv && firstDiv.length > 0) { - firstDiv.item(0).parentNode.removeChild(firstDiv.item(0)); - } - - this._addFirstDiv(); - } - - if (!_ElementUtilities.hasClass(this.element.children[this.element.children.length - 1], _Constants.finalDivClass)) { - var finalDiv = this.element.querySelectorAll("." + _Constants.finalDivClass); - if (finalDiv && finalDiv.length > 0) { - finalDiv.item(0).parentNode.removeChild(finalDiv.item(0)); - } - - this._addFinalDiv(); - } - - this._setBackButtonsAriaLabel(); - - _LightDismissService.shown(this._dismissable); - } - }, - - _setBackButtonsAriaLabel: function SettingsFlyout_setBackButtonsAriaLabel() { - var backbuttons = this.element.querySelectorAll(".win-backbutton"); - var label; - for (var i = 0; i < backbuttons.length; i++) { - label = backbuttons[i].getAttribute("aria-label"); - if (label === null || label === "" || label === undefined) { - backbuttons[i].setAttribute("aria-label", strings.backbuttonAriaLabel); - } - } - }, - - hide: function () { - /// - /// - /// Hides the SettingsFlyout, if visible, regardless of other state. - /// - /// - /// - // Just call private version to make appbar flags happy - this._writeProfilerMark("hide,StartTM"); // The corresponding "stop" profiler mark is handled in _Overlay._baseEndHide(). - this._hide(); - }, - - _hide: function SettingsFlyout_hide() { - this._baseHide(); - }, - - _beforeEndHide: function SettingsFlyout_beforeEndHide() { - _LightDismissService.hidden(this._dismissable); - }, - - // SettingsFlyout animations - _animateSlideIn: function SettingsFlyout_animateSlideIn() { - var animateFromLeft = _shouldAnimateFromLeft(); - var offset = animateFromLeft ? "-100px" : "100px"; - _ElementListUtilities.query("div.win-content", this._element). - forEach(function (e) { Animations.enterPage(e, { left: offset }); }); - - var where, - width = this._element.offsetWidth; - // Slide in from right side or left side? - if (animateFromLeft) { - // RTL - where = { top: "0px", left: "-" + width + "px" }; - this._element.style.right = "auto"; - this._element.style.left = "0px"; - } else { - // From right side - where = { top: "0px", left: width + "px" }; - this._element.style.right = "0px"; - this._element.style.left = "auto"; - } - - this._element.style.opacity = 1; - this._element.style.visibility = "visible"; - - return Animations.showPanel(this._element, where); - }, - - _animateSlideOut: function SettingsFlyout_animateSlideOut() { - var where, - width = this._element.offsetWidth; - if (_shouldAnimateFromLeft()) { - // RTL - where = { top: "0px", left: width + "px" }; - this._element.style.right = "auto"; - this._element.style.left = "-" + width + "px"; - } else { - // From right side - where = { top: "0px", left: "-" + width + "px" }; - this._element.style.right = "-" + width + "px"; - this._element.style.left = "auto"; - } - - return Animations.showPanel(this._element, where); - }, - - _fragmentDiv: { - get: function SettingsFlyout_fragmentDiv_get() { - return this._fragDiv; - }, - - set: function SettingsFlyout_fragmentDiv_set(value) { - this._fragDiv = value; - } - }, - - _unloadPage: function SettingsFlyout_unloadPage(event) { - var settingsControl = event.currentTarget.winControl; - settingsControl.removeEventListener(_Overlay._Overlay.afterHide, this._unloadPage, false); - - Promise.as().then(function () { - if (settingsControl._fragmentDiv) { - _Global.document.body.removeChild(settingsControl._fragmentDiv); - settingsControl._fragmentDiv = null; - } - }); - }, - - _dismiss: function SettingsFlyout_dismiss() { - this.addEventListener(_Overlay._Overlay.afterHide, this._unloadPage, false); - this._hide(); - }, - - _handleKeyDown: function SettingsFlyout_handleKeyDown(event) { - if ((event.keyCode === Key.space || event.keyCode === Key.enter) - && (this.children[0] === _Global.document.activeElement)) { - event.preventDefault(); - event.stopPropagation(); - this.winControl._dismiss(); - } else if (event.shiftKey && event.keyCode === Key.tab - && this.children[0] === _Global.document.activeElement) { - event.preventDefault(); - event.stopPropagation(); - var _elms = this.getElementsByTagName("*"); - - for (var i = _elms.length - 2; i >= 0; i--) { - _elms[i].focus(); - - if (_elms[i] === _Global.document.activeElement) { - break; - } - } - } - }, - - _focusOnLastFocusableElementFromParent: function SettingsFlyout_focusOnLastFocusableElementFromParent() { - var active = _Global.document.activeElement; - if (!settingsPageIsFocusedOnce || !active || !_ElementUtilities.hasClass(active, _Constants.firstDivClass)) { - return; - } - - var _elms = this.parentElement.getElementsByTagName("*"); - - // There should be at least 1 element in addition to the firstDiv & finalDiv - if (_elms.length <= 2) { - return; - } - - // Get the tabIndex set to the finalDiv (which is the highest) - var _highestTabIndex = _elms[_elms.length - 1].tabIndex; - - // If there are positive tabIndices, set focus to the element with the highest tabIndex. - // Otherwise set focus to the last focusable element in DOM order. - var i; - if (_highestTabIndex) { - for (i = _elms.length - 2; i > 0; i--) { - if (_elms[i].tabIndex === _highestTabIndex) { - _elms[i].focus(); - break; - } - } - } else { - for (i = _elms.length - 2; i > 0; i--) { - // Skip
with undefined tabIndex (To work around Win8 bug #622245) - if ((_elms[i].tagName !== "DIV") || (_elms[i].getAttribute("tabIndex") !== null)) { - _elms[i].focus(); - - if (_elms[i] === _Global.document.activeElement) { - break; - } - } - } - } - }, - - _focusOnFirstFocusableElementFromParent: function SettingsFlyout_focusOnFirstFocusableElementFromParent() { - var active = _Global.document.activeElement; - if (!active || !_ElementUtilities.hasClass(active, _Constants.finalDivClass)) { - return; - } - var _elms = this.parentElement.getElementsByTagName("*"); - - // There should be at least 1 element in addition to the firstDiv & finalDiv - if (_elms.length <= 2) { - return; - } - - // Get the tabIndex set to the firstDiv (which is the lowest) - var _lowestTabIndex = _elms[0].tabIndex; - - // If there are positive tabIndices, set focus to the element with the lowest tabIndex. - // Otherwise set focus to the first focusable element in DOM order. - var i; - if (_lowestTabIndex) { - for (i = 1; i < _elms.length - 1; i++) { - if (_elms[i].tabIndex === _lowestTabIndex) { - _elms[i].focus(); - break; - } - } - } else { - for (i = 1; i < _elms.length - 1; i++) { - // Skip
with undefined tabIndex (To work around Win8 bug #622245) - if ((_elms[i].tagName !== "DIV") || (_elms[i].getAttribute("tabIndex") !== null)) { - _elms[i].focus(); - - if (_elms[i] === _Global.document.activeElement) { - break; - } - } - } - } - }, - - // Create and add a new first div to the beginning of the list - _addFirstDiv: function SettingsFlyout_addFirstDiv() { - var _elms = this._element.getElementsByTagName("*"); - var _minTab = 0; - for (var i = 0; i < _elms.length; i++) { - if ((0 < _elms[i].tabIndex) && (_minTab === 0 || _elms[i].tabIndex < _minTab)) { - _minTab = _elms[i].tabIndex; - } - } - var firstDiv = _Global.document.createElement("div"); - firstDiv.className = _Constants.firstDivClass; - firstDiv.style.display = "inline"; - firstDiv.setAttribute("role", "menuitem"); - firstDiv.setAttribute("aria-hidden", "true"); - firstDiv.tabIndex = _minTab; - _ElementUtilities._addEventListener(firstDiv, "focusin", this._focusOnLastFocusableElementFromParent, false); - - // add to beginning - if (this._element.children[0]) { - this._element.insertBefore(firstDiv, this._element.children[0]); - } else { - this._element.appendChild(firstDiv); - } - }, - - // Create and add a new final div to the end of the list - _addFinalDiv: function SettingsFlyout_addFinalDiv() { - var _elms = this._element.getElementsByTagName("*"); - var _maxTab = 0; - for (var i = 0; i < _elms.length; i++) { - if (_elms[i].tabIndex > _maxTab) { - _maxTab = _elms[i].tabIndex; - } - } - var finalDiv = _Global.document.createElement("div"); - finalDiv.className = _Constants.finalDivClass; - finalDiv.style.display = "inline"; - finalDiv.setAttribute("role", "menuitem"); - finalDiv.setAttribute("aria-hidden", "true"); - finalDiv.tabIndex = _maxTab; - _ElementUtilities._addEventListener(finalDiv, "focusin", this._focusOnFirstFocusableElementFromParent, false); - - this._element.appendChild(finalDiv); - }, - - _writeProfilerMark: function SettingsFlyout_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI.SettingsFlyout:" + this._id + ":" + text); - } - }); - - // Statics - SettingsFlyout.show = function () { - /// - /// - /// Shows the SettingsPane UI, if hidden, regardless of other states. - /// - /// - /// - /// Show the main settings pane - if (_WinRT.Windows.UI.ApplicationSettings.SettingsPane) { - _WinRT.Windows.UI.ApplicationSettings.SettingsPane.show(); - } - // And hide the WWA one - var elements = _Global.document.querySelectorAll('div[data-win-control="WinJS.UI.SettingsFlyout"]'); - var len = elements.length; - for (var i = 0; i < len; i++) { - var settingsFlyout = elements[i].winControl; - if (settingsFlyout) { - settingsFlyout._dismiss(); - } - } - }; - - var _settingsEvent = { event: undefined }; - SettingsFlyout.populateSettings = function (e) { - /// - /// - /// Loads a portion of the SettingsFlyout. Your app calls this when the user invokes a settings command and the WinJS.Application.onsettings event occurs. - /// - /// - /// An object that contains information about the event, received from the WinJS.Application.onsettings event. The detail property of this object contains - /// the applicationcommands sub-property that you set to an array of settings commands. - /// - /// - /// - _settingsEvent.event = e.detail; - - if (_settingsEvent.event.applicationcommands) { - var n = _WinRT.Windows.UI.ApplicationSettings; - Object.keys(_settingsEvent.event.applicationcommands).forEach(function (name) { - var setting = _settingsEvent.event.applicationcommands[name]; - if (!setting.title) { setting.title = name; } - var command = new n.SettingsCommand(name, setting.title, SettingsFlyout._onSettingsCommand); - _settingsEvent.event.e.request.applicationCommands.append(command); - }); - } - }; - - SettingsFlyout._onSettingsCommand = function (command) { - var id = command.id; - if (_settingsEvent.event.applicationcommands && _settingsEvent.event.applicationcommands[id]) { - SettingsFlyout.showSettings(id, _settingsEvent.event.applicationcommands[id].href); - } - }; - - SettingsFlyout.showSettings = function (id, path) { - /// - /// - /// Show the SettingsFlyout using the settings element identifier (ID) and the path of the page that contains the settings element. - /// - /// - /// The ID of the settings element. - /// - /// - /// The path of the page that contains the settings element. - /// - /// - /// - var control = _getChildSettingsControl(_Global.document, id); - if (control) { - control.show(); - } else if (path) { - var divElement = _Global.document.createElement("div"); - divElement = _Global.document.body.appendChild(divElement); - Pages.render(path, divElement).then(function () { - control = _getChildSettingsControl(divElement, id); - if (control) { - control._fragmentDiv = divElement; - control.show(); - } else { - _Global.document.body.removeChild(divElement); - } - }); - } else { - throw new _ErrorFromName("WinJS.UI.SettingsFlyout.BadReference", strings.badReference); - } - }; - - var strings = { - get ariaLabel() { return _Resources._getWinJSString("ui/settingsFlyoutAriaLabel").value; }, - get badReference() { return "Invalid argument: Invalid href to settings flyout fragment"; }, - get backbuttonAriaLabel() { return _Resources._getWinJSString("ui/backbuttonarialabel").value; }, - get widthDeprecationMessage() { return "SettingsFlyout.width may be altered or unavailable in future versions. Instead, style the CSS width property on elements with the .win-settingsflyout class."; }, - get settingsFlyoutIsDeprecated() { return "SettingsFlyout is deprecated and may not be available in future releases. Instead, put settings on their own page within the app."; } - }; - - return SettingsFlyout; - }) - }); - - -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/NavBar/_Command',[ - 'exports', - '../../Core/_Global', - '../../Core/_Base', - '../../Core/_ErrorFromName', - '../../Core/_Resources', - '../../ControlProcessor', - '../../Navigation', - '../../Utilities/_Control', - '../../Utilities/_ElementUtilities', - '../AppBar/_Icon' - ], function NavBarCommandInit(exports, _Global, _Base, _ErrorFromName, _Resources, ControlProcessor, Navigation, _Control, _ElementUtilities, _Icon) { - "use strict"; - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - _WinPressed: _Base.Namespace._lazy(function () { - var WinPressed = _Base.Class.define(function _WinPressed_ctor(element) { - // WinPressed is the combination of :hover:active - // :hover is delayed by trident for touch by 300ms so if you want :hover:active to work quickly you need to - // use this behavior. - // :active does not bubble to its parent like :hover does so this is also useful for that scenario. - this._element = element; - _ElementUtilities._addEventListener(this._element, "pointerdown", this._MSPointerDownButtonHandler.bind(this)); - }, { - _MSPointerDownButtonHandler: function _WinPressed_MSPointerDownButtonHandler(ev) { - if (!this._pointerUpBound) { - this._pointerUpBound = this._MSPointerUpHandler.bind(this); - this._pointerCancelBound = this._MSPointerCancelHandler.bind(this); - this._pointerOverBound = this._MSPointerOverHandler.bind(this); - this._pointerOutBound = this._MSPointerOutHandler.bind(this); - } - - if (ev.isPrimary) { - if (this._pointerId) { - this._resetPointer(); - } - - if (!_ElementUtilities._matchesSelector(ev.target, ".win-interactive, .win-interactive *")) { - this._pointerId = ev.pointerId; - - _ElementUtilities._addEventListener(_Global, "pointerup", this._pointerUpBound, true); - _ElementUtilities._addEventListener(_Global, "pointercancel", this._pointerCancelBound), true; - _ElementUtilities._addEventListener(this._element, "pointerover", this._pointerOverBound, true); - _ElementUtilities._addEventListener(this._element, "pointerout", this._pointerOutBound, true); - - _ElementUtilities.addClass(this._element, WinPressed.winPressed); - } - } - }, - - _MSPointerOverHandler: function _WinPressed_MSPointerOverHandler(ev) { - if (this._pointerId === ev.pointerId) { - _ElementUtilities.addClass(this._element, WinPressed.winPressed); - } - }, - - _MSPointerOutHandler: function _WinPressed_MSPointerOutHandler(ev) { - if (this._pointerId === ev.pointerId) { - _ElementUtilities.removeClass(this._element, WinPressed.winPressed); - } - }, - - _MSPointerCancelHandler: function _WinPressed_MSPointerCancelHandler(ev) { - if (this._pointerId === ev.pointerId) { - this._resetPointer(); - } - }, - - _MSPointerUpHandler: function _WinPressed_MSPointerUpHandler(ev) { - if (this._pointerId === ev.pointerId) { - this._resetPointer(); - } - }, - - _resetPointer: function _WinPressed_resetPointer() { - this._pointerId = null; - - _ElementUtilities._removeEventListener(_Global, "pointerup", this._pointerUpBound, true); - _ElementUtilities._removeEventListener(_Global, "pointercancel", this._pointerCancelBound, true); - _ElementUtilities._removeEventListener(this._element, "pointerover", this._pointerOverBound, true); - _ElementUtilities._removeEventListener(this._element, "pointerout", this._pointerOutBound, true); - - _ElementUtilities.removeClass(this._element, WinPressed.winPressed); - }, - - dispose: function _WinPressed_dispose() { - if (this._disposed) { - return; - } - this._disposed = true; - - this._resetPointer(); - } - }, { - winPressed: "win-pressed" - }); - - return WinPressed; - }), - /// - /// - /// Represents a navigation command in an NavBarContainer. - /// - /// - /// - /// - /// - ///
]]> - /// Styles the entire NavBarCommand control. - /// Styles the main button in a NavBarCommand. - /// Styles the split button in a NavBarCommand - /// Styles the icon in the main button of a NavBarCommand. - /// Styles the label in the main button of a NavBarCommand. - /// - /// - NavBarCommand: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - var strings = { - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; } - }; - - var NavBarCommand = _Base.Class.define(function NavBarCommand_ctor(element, options) { - /// - /// - /// Creates a new NavBarCommand. - /// - /// - /// The DOM element that will host the new NavBarCommand control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". - /// - /// - /// The new NavBarCommand. - /// - /// - /// - element = element || _Global.document.createElement("DIV"); - options = options || {}; - - if (element.winControl) { - throw new _ErrorFromName("WinJS.UI.NavBarCommand.DuplicateConstruction", strings.duplicateConstruction); - } - - // Attaching JS control to DOM element - element.winControl = this; - this._element = element; - _ElementUtilities.addClass(this.element, NavBarCommand._ClassName.navbarcommand); - _ElementUtilities.addClass(this.element, "win-disposable"); - - this._tooltip = null; - this._splitOpened = false; - this._buildDom(); - element.addEventListener('keydown', this._keydownHandler.bind(this)); - - _Control.setOptions(this, options); - }, { - /// - element: { - get: function () { - return this._element; - } - }, - - /// - /// Gets or sets the label of the NavBarCommand. - /// - /// - label: { - get: function () { - return this._label; - }, - set: function (value) { - this._label = value; - this._labelEl.textContent = value; - } - }, - - /// - /// Gets or sets the tooltip of the NavBarCommand. - /// - /// - tooltip: { - get: function () { - return this._tooltip; - }, - set: function (value) { - this._tooltip = value; - if (this._tooltip || this._tooltip === "") { - this._element.setAttribute('title', this._tooltip); - } else { - this._element.removeAttribute('title'); - } - } - }, - - /// - /// Gets or sets the icon of the NavBarCommand. This value is either one of the values of the AppBarIcon enumeration or the path of a custom PNG file. - /// - /// - icon: { - get: function () { - return this._icon; - }, - set: function (value) { - this._icon = (_Icon[value] || value); - - // If the icon's a single character, presume a glyph - if (this._icon && this._icon.length === 1) { - // Set the glyph - this._imageSpan.textContent = this._icon; - this._imageSpan.style.backgroundImage = ""; - this._imageSpan.style.msHighContrastAdjust = ""; - this._imageSpan.style.display = ""; - } else if (this._icon && this._icon.length > 1) { - // Must be an image, set that - this._imageSpan.textContent = ""; - this._imageSpan.style.backgroundImage = this._icon; - this._imageSpan.style.msHighContrastAdjust = "none"; - this._imageSpan.style.display = ""; - } else { - this._imageSpan.textContent = ""; - this._imageSpan.style.backgroundImage = ""; - this._imageSpan.style.msHighContrastAdjust = ""; - this._imageSpan.style.display = "none"; - } - } - }, - - /// - /// Gets or sets the command's target location. - /// - /// - location: { - get: function () { - return this._location; - }, - set: function (value) { - this._location = value; - } - }, - - /// - /// Gets or sets the state value used for navigation. The command passes this object to the WinJS.Navigation.navigate function. - /// - /// - state: { - get: function () { - return this._state; - }, - set: function (value) { - this._state = value; - } - }, - - /// - /// Gets or sets a value that specifies whether the NavBarCommand has a split button. - /// - /// - splitButton: { - get: function () { - return this._split; - }, - set: function (value) { - this._split = value; - if (this._split) { - this._splitButtonEl.style.display = ""; - } else { - this._splitButtonEl.style.display = "none"; - } - } - }, - - /// - splitOpened: { - get: function () { - return this._splitOpened; - }, - set: function (value) { - if (this._splitOpened !== !!value) { - this._toggleSplit(); - } - } - }, - - _toggleSplit: function NavBarCommand_toggleSplit() { - this._splitOpened = !this._splitOpened; - if (this._splitOpened) { - _ElementUtilities.addClass(this._splitButtonEl, NavBarCommand._ClassName.navbarcommandsplitbuttonopened); - this._splitButtonEl.setAttribute("aria-expanded", "true"); - } else { - _ElementUtilities.removeClass(this._splitButtonEl, NavBarCommand._ClassName.navbarcommandsplitbuttonopened); - this._splitButtonEl.setAttribute("aria-expanded", "false"); - } - this._fireEvent(NavBarCommand._EventName._splitToggle); - }, - - _rtl: { - get: function () { - return _Global.getComputedStyle(this.element).direction === "rtl"; - } - }, - - _keydownHandler: function NavBarCommand_keydownHandler(ev) { - if (_ElementUtilities._matchesSelector(ev.target, ".win-interactive, .win-interactive *")) { - return; - } - - var leftStr = this._rtl ? Key.rightArrow : Key.leftArrow; - var rightStr = this._rtl ? Key.leftArrow : Key.rightArrow; - - if (!ev.altKey && (ev.keyCode === leftStr || ev.keyCode === Key.home || ev.keyCode === Key.end) && ev.target === this._splitButtonEl) { - _ElementUtilities._setActive(this._buttonEl); - if (ev.keyCode === leftStr) { - ev.stopPropagation(); - } - ev.preventDefault(); - } else if (!ev.altKey && ev.keyCode === rightStr && this.splitButton && (ev.target === this._buttonEl || this._buttonEl.contains(ev.target))) { - _ElementUtilities._setActive(this._splitButtonEl); - if (ev.keyCode === rightStr) { - ev.stopPropagation(); - } - ev.preventDefault(); - } else if ((ev.keyCode === Key.space || ev.keyCode === Key.enter) && (ev.target === this._buttonEl || this._buttonEl.contains(ev.target))) { - if (this.location) { - Navigation.navigate(this.location, this.state); - } - this._fireEvent(NavBarCommand._EventName._invoked); - } else if ((ev.keyCode === Key.space || ev.keyCode === Key.enter) && ev.target === this._splitButtonEl) { - this._toggleSplit(); - } - }, - - _getFocusInto: function NavBarCommand_getFocusInto(keyCode) { - var leftStr = this._rtl ? Key.rightArrow : Key.leftArrow; - if ((keyCode === leftStr) && this.splitButton) { - return this._splitButtonEl; - } else { - return this._buttonEl; - } - }, - - _buildDom: function NavBarCommand_buildDom() { - var markup = - '' + - ''; - this.element.insertAdjacentHTML("afterBegin", markup); - - this._buttonEl = this.element.firstElementChild; - this._buttonPressedBehavior = new exports._WinPressed(this._buttonEl); - this._contentEl = this._buttonEl.firstElementChild; - this._imageSpan = this._contentEl.firstElementChild; - this._imageSpan.style.display = "none"; - this._labelEl = this._imageSpan.nextElementSibling; - this._splitButtonEl = this._buttonEl.nextElementSibling; - this._splitButtonPressedBehavior = new exports._WinPressed(this._splitButtonEl); - this._splitButtonEl.style.display = "none"; - - _ElementUtilities._ensureId(this._buttonEl); - this._splitButtonEl.setAttribute("aria-labelledby", this._buttonEl.id); - - this._buttonEl.addEventListener("click", this._handleButtonClick.bind(this)); - - var mutationObserver = new _ElementUtilities._MutationObserver(this._splitButtonAriaExpandedPropertyChangeHandler.bind(this)); - mutationObserver.observe(this._splitButtonEl, { attributes: true, attributeFilter: ["aria-expanded"] }); - this._splitButtonEl.addEventListener("click", this._handleSplitButtonClick.bind(this)); - - // reparent any other elements. - var tempEl = this._splitButtonEl.nextSibling; - while (tempEl) { - this._buttonEl.insertBefore(tempEl, this._contentEl); - if (tempEl.nodeName !== "#text") { - ControlProcessor.processAll(tempEl); - } - tempEl = this._splitButtonEl.nextSibling; - } - }, - - _handleButtonClick: function NavBarCommand_handleButtonClick(ev) { - var srcElement = ev.target; - if (!_ElementUtilities._matchesSelector(srcElement, ".win-interactive, .win-interactive *")) { - if (this.location) { - Navigation.navigate(this.location, this.state); - } - this._fireEvent(NavBarCommand._EventName._invoked); - } - }, - - _splitButtonAriaExpandedPropertyChangeHandler: function NavBarCommand_splitButtonAriaExpandedPropertyChangeHandler() { - if ((this._splitButtonEl.getAttribute("aria-expanded") === "true") !== this._splitOpened) { - this._toggleSplit(); - } - }, - - _handleSplitButtonClick: function NavBarCommand_handleSplitButtonClick() { - this._toggleSplit(); - }, - - _fireEvent: function NavBarCommand_fireEvent(type, detail) { - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(type, true, false, detail); - this.element.dispatchEvent(event); - }, - - dispose: function NavBarCommand_dispose() { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - - this._buttonPressedBehavior.dispose(); - this._splitButtonPressedBehavior.dispose(); - } - }, { - _ClassName: { - navbarcommand: "win-navbarcommand", - navbarcommandbutton: "win-navbarcommand-button", - navbarcommandbuttoncontent: "win-navbarcommand-button-content", - navbarcommandsplitbutton: "win-navbarcommand-splitbutton", - navbarcommandsplitbuttonopened: "win-navbarcommand-splitbutton-opened", - navbarcommandicon: "win-navbarcommand-icon", - navbarcommandlabel: "win-navbarcommand-label" - }, - _EventName: { - _invoked: "_invoked", - _splitToggle: "_splittoggle" - } - }); - _Base.Class.mix(NavBarCommand, _Control.DOMEventMixin); - return NavBarCommand; - }) - }); - -}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/NavBar/_Container',[ - 'exports', - '../../Core/_Global', - '../../Core/_Base', - '../../Core/_BaseUtils', - '../../Core/_ErrorFromName', - '../../Core/_Events', - '../../Core/_Log', - '../../Core/_Resources', - '../../Core/_WriteProfilerMark', - '../../Animations', - '../../Animations/_TransitionAnimation', - '../../BindingList', - '../../ControlProcessor', - '../../Navigation', - '../../Promise', - '../../Scheduler', - '../../Utilities/_Control', - '../../Utilities/_ElementUtilities', - '../../Utilities/_KeyboardBehavior', - '../../Utilities/_UI', - '../_LegacyAppBar/_Constants', - '../Repeater', - './_Command' -], function NavBarContainerInit(exports, _Global, _Base, _BaseUtils, _ErrorFromName, _Events, _Log, _Resources, _WriteProfilerMark, Animations, _TransitionAnimation, BindingList, ControlProcessor, Navigation, Promise, Scheduler, _Control, _ElementUtilities, _KeyboardBehavior, _UI, _Constants, Repeater, _Command) { - "use strict"; - - function nobodyHasFocus() { - return _Global.document.activeElement === null || _Global.document.activeElement === _Global.document.body; - } - - _Base.Namespace._moduleDefine(exports, "WinJS.UI", { - /// - /// - /// Contains a group of NavBarCommand objects in a NavBar. - /// - /// - /// - /// - /// - /// - ///
- ///
]]> - /// Raised when a NavBarCommand is invoked. - /// Raised when the split button on a NavBarCommand is toggled. - /// Styles the entire NavBarContainer control. - /// - /// Styles the page indication for the NavBarContainer. - /// - /// Styles the page indication for each page. - /// - /// Styles the indication of the current page. - /// - /// Styles the area that contains items for the NavBarContainer. - /// Styles left and right navigation arrows. - /// Styles the left navigation arrow. - /// Styles the right navigation arrow. - /// - /// - NavBarContainer: _Base.Namespace._lazy(function () { - var Key = _ElementUtilities.Key; - - var buttonFadeDelay = 3000; - var PT_TOUCH = _ElementUtilities._MSPointerEvent.MSPOINTER_TYPE_TOUCH || "touch"; - var MS_MANIPULATION_STATE_STOPPED = 0; - - var createEvent = _Events._createEventProperty; - var eventNames = { - invoked: "invoked", - splittoggle: "splittoggle" - }; - - var strings = { - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get navBarContainerViewportAriaLabel() { return _Resources._getWinJSString("ui/navBarContainerViewportAriaLabel").value; } - }; - - var NavBarContainer = _Base.Class.define(function NavBarContainer_ctor(element, options) { - /// - /// - /// Creates a new NavBarContainer. - /// - /// - /// The DOM element that will host the NavBarContainer control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". - /// - /// - /// The new NavBarContainer. - /// - /// - /// - - element = element || _Global.document.createElement("DIV"); - this._id = element.id || _ElementUtilities._uniqueID(element); - this._writeProfilerMark("constructor,StartTM"); - - options = options || {}; - - if (element.winControl) { - throw new _ErrorFromName("WinJS.UI.NavBarContainer.DuplicateConstruction", strings.duplicateConstruction); - } - - // Attaching JS control to DOM element - element.winControl = this; - this._element = element; - _ElementUtilities.addClass(this.element, NavBarContainer._ClassName.navbarcontainer); - _ElementUtilities.addClass(this.element, "win-disposable"); - if (!element.getAttribute("tabIndex")) { - element.tabIndex = -1; - } - - this._focusCurrentItemPassivelyBound = this._focusCurrentItemPassively.bind(this); - this._closeSplitAndResetBound = this._closeSplitAndReset.bind(this); - this._currentManipulationState = MS_MANIPULATION_STATE_STOPPED; - - this._panningDisabled = !_ElementUtilities._supportsSnapPoints; - this._fixedSize = false; - this._maxRows = 1; - this._sizes = {}; - - this._setupTree(); - - this._duringConstructor = true; - - this._dataChangingBound = this._dataChanging.bind(this); - this._dataChangedBound = this._dataChanged.bind(this); - - Navigation.addEventListener('navigated', this._closeSplitAndResetBound); - - // Don't use set options for the properties so we can control the ordering to avoid rendering multiple times. - this.layout = options.layout || _UI.Orientation.horizontal; - if (options.maxRows) { - this.maxRows = options.maxRows; - } - if (options.template) { - this.template = options.template; - } - if (options.data) { - this.data = options.data; - } - if (options.fixedSize) { - this.fixedSize = options.fixedSize; - } - - // Events only - _Control._setOptions(this, options, true); - - this._duringConstructor = false; - - if (options.currentIndex) { - this.currentIndex = options.currentIndex; - } - - this._updatePageUI(); - - Scheduler.schedule(function NavBarContainer_async_initialize() { - this._updateAppBarReference(); - }, Scheduler.Priority.normal, this, "WinJS.UI.NavBarContainer_async_initialize"); - - this._writeProfilerMark("constructor,StopTM"); - }, { - /// - element: { - get: function () { - return this._element; - } - }, - - /// - /// Gets or sets a Template or custom rendering function that defines the HTML of each item within the NavBarContainer. - /// - /// - template: { - get: function () { - return this._template; - }, - set: function (value) { - this._template = value; - if (this._repeater) { - var hadFocus = this.element.contains(_Global.document.activeElement); - - if (!this._duringConstructor) { - this._closeSplitIfOpen(); - } - - // the repeater's template is wired up to this._render() so just resetting it will rebuild the tree. - this._repeater.template = this._repeater.template; - - if (!this._duringConstructor) { - this._measured = false; - this._sizes.itemMeasured = false; - this._reset(); - if (hadFocus) { - this._keyboardBehavior._focus(0); - } - } - } - } - }, - - _render: function NavBarContainer_render(item) { - var navbarCommandEl = _Global.document.createElement('div'); - - var template = this._template; - if (template) { - if (template.render) { - template.render(item, navbarCommandEl); - } else if (template.winControl && template.winControl.render) { - template.winControl.render(item, navbarCommandEl); - } else { - navbarCommandEl.appendChild(template(item)); - } - } - - // Create the NavBarCommand after calling render so that the reparenting in navbarCommand works. - var navbarCommand = new _Command.NavBarCommand(navbarCommandEl, item); - return navbarCommand._element; - }, - - /// - /// Gets or sets the WinJS.Binding.List that provides the NavBarContainer with items to display. - /// - /// - data: { - get: function () { - return this._repeater && this._repeater.data; - }, - set: function (value) { - if (!value) { - value = new BindingList.List(); - } - - if (!this._duringConstructor) { - this._closeSplitIfOpen(); - } - - this._removeDataChangingEvents(); - this._removeDataChangedEvents(); - - var hadFocus = this.element.contains(_Global.document.activeElement); - - if (!this._repeater) { - this._surfaceEl.innerHTML = ""; - this._repeater = new Repeater.Repeater(this._surfaceEl, { - template: this._render.bind(this) - }); - } - - this._addDataChangingEvents(value); - this._repeater.data = value; - this._addDataChangedEvents(value); - - if (!this._duringConstructor) { - this._measured = false; - this._sizes.itemMeasured = false; - this._reset(); - if (hadFocus) { - this._keyboardBehavior._focus(0); - } - } - } - }, - - /// - /// Gets or sets the number of rows allowed to be used before items are placed on additional pages. - /// - /// - maxRows: { - get: function () { - return this._maxRows; - }, - set: function (value) { - value = (+value === value) ? value : 1; - this._maxRows = Math.max(1, value); - - if (!this._duringConstructor) { - this._closeSplitIfOpen(); - - this._measured = false; - this._reset(); - } - } - }, - - /// - /// Gets or sets a value that specifies whether the NavBarContainer has a horizontal or vertical layout. The default is "horizontal". - /// - /// - layout: { - get: function () { - return this._layout; - }, - set: function (value) { - if (value === _UI.Orientation.vertical) { - this._layout = _UI.Orientation.vertical; - _ElementUtilities.removeClass(this.element, NavBarContainer._ClassName.horizontal); - _ElementUtilities.addClass(this.element, NavBarContainer._ClassName.vertical); - } else { - this._layout = _UI.Orientation.horizontal; - _ElementUtilities.removeClass(this.element, NavBarContainer._ClassName.vertical); - _ElementUtilities.addClass(this.element, NavBarContainer._ClassName.horizontal); - } - - this._viewportEl.style.msScrollSnapType = ""; - this._zooming = false; - - if (!this._duringConstructor) { - this._measured = false; - this._sizes.itemMeasured = false; - this._ensureVisible(this._keyboardBehavior.currentIndex, true); - this._updatePageUI(); - this._closeSplitIfOpen(); - } - } - }, - - /// - currentIndex: { - get: function () { - return this._keyboardBehavior.currentIndex; - }, - set: function (value) { - if (value === +value) { - var hadFocus = this.element.contains(_Global.document.activeElement); - - this._keyboardBehavior.currentIndex = value; - - this._ensureVisible(this._keyboardBehavior.currentIndex, true); - - if (hadFocus) { - this._keyboardBehavior._focus(); - } - } - } - }, - - /// - /// Gets or sets a value that specifies whether child NavBarCommand objects should be a fixed width when there are multiple pages. A value of true indicates - /// that the NavBarCommand objects use a fixed width; a value of false indicates that they use a dynamic width. - /// - /// - fixedSize: { - get: function () { - return this._fixedSize; - }, - set: function (value) { - this._fixedSize = !!value; - - if (!this._duringConstructor) { - this._closeSplitIfOpen(); - - if (!this._measured) { - this._measure(); - } else if (this._surfaceEl.children.length > 0) { - this._updateGridStyles(); - } - } - } - }, - - /// - /// Raised when a NavBarCommand has been invoked. - /// - /// - oninvoked: createEvent(eventNames.invoked), - - /// - /// Raised when the split button on a NavBarCommand is toggled. - /// - /// - onsplittoggle: createEvent(eventNames.splittoggle), - - forceLayout: function NavBarContainer_forceLayout() { - /// - /// - /// Forces the NavBarContainer to update scroll positions and if the NavBar has changed size, it will also re-measure. - /// Use this function when making the NavBarContainer visible again after you set its style.display property to "none". - /// - /// - /// - this._resizeHandler(); - if (this._measured) { - this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportEl)[(this.layout === _UI.Orientation.horizontal ? "scrollLeft" : "scrollTop")]; - } - - this._duringForceLayout = true; - this._ensureVisible(this._keyboardBehavior.currentIndex, true); - this._updatePageUI(); - this._duringForceLayout = false; - }, - - _updateAppBarReference: function NavBarContainer_updateAppBarReference() { - if (!this._appBarEl || !this._appBarEl.contains(this.element)) { - if (this._appBarEl) { - this._appBarEl.removeEventListener('beforeopen', this._closeSplitAndResetBound); - this._appBarEl.removeEventListener('beforeopen', this._resizeImplBound); - this._appBarEl.removeEventListener('afteropen', this._focusCurrentItemPassivelyBound); - } - - var appBarEl = this.element.parentNode; - while (appBarEl && !_ElementUtilities.hasClass(appBarEl, _Constants.appBarClass)) { - appBarEl = appBarEl.parentNode; - } - this._appBarEl = appBarEl; - - if (this._appBarEl) { - this._appBarEl.addEventListener('beforeopen', this._closeSplitAndResetBound); - this._appBarEl.addEventListener('afteropen', this._focusCurrentItemPassivelyBound); - } - } - }, - - _closeSplitAndReset: function NavBarContainer_closeSplitAndReset() { - this._closeSplitIfOpen(); - this._reset(); - }, - - _dataChanging: function NavBarContainer_dataChanging(ev) { - // Store the element that was active so that we can detect - // if the focus went away because of the data change. - this._elementHadFocus = _Global.document.activeElement; - - if (this._currentSplitNavItem && this._currentSplitNavItem.splitOpened) { - if (ev.type === "itemremoved") { - if (this._surfaceEl.children[ev.detail.index].winControl === this._currentSplitNavItem) { - this._closeSplitIfOpen(); - } - } else if (ev.type === "itemchanged") { - if (this._surfaceEl.children[ev.detail.index].winControl === this._currentSplitNavItem) { - this._closeSplitIfOpen(); - } - } else if (ev.type === "itemmoved") { - if (this._surfaceEl.children[ev.detail.oldIndex].winControl === this._currentSplitNavItem) { - this._closeSplitIfOpen(); - } - } else if (ev.type === "reload") { - this._closeSplitIfOpen(); - } - } - }, - - _dataChanged: function NavBarContainer_dataChanged(ev) { - this._measured = false; - - if (ev.type === "itemremoved") { - if (ev.detail.index < this._keyboardBehavior.currentIndex) { - this._keyboardBehavior.currentIndex--; - } else if (ev.detail.index === this._keyboardBehavior.currentIndex) { - // This clamps if the item being removed was the last item in the list - this._keyboardBehavior.currentIndex = this._keyboardBehavior.currentIndex; - if (nobodyHasFocus() && this._elementHadFocus) { - this._keyboardBehavior._focus(); - } - } - } else if (ev.type === "itemchanged") { - if (ev.detail.index === this._keyboardBehavior.currentIndex) { - if (nobodyHasFocus() && this._elementHadFocus) { - this._keyboardBehavior._focus(); - } - } - } else if (ev.type === "iteminserted") { - if (ev.detail.index <= this._keyboardBehavior.currentIndex) { - this._keyboardBehavior.currentIndex++; - } - } else if (ev.type === "itemmoved") { - if (ev.detail.oldIndex === this._keyboardBehavior.currentIndex) { - this._keyboardBehavior.currentIndex = ev.detail.newIndex; - if (nobodyHasFocus() && this._elementHadFocus) { - this._keyboardBehavior._focus(); - } - } - } else if (ev.type === "reload") { - this._keyboardBehavior.currentIndex = 0; - if (nobodyHasFocus() && this._elementHadFocus) { - this._keyboardBehavior._focus(); - } - } - - this._ensureVisible(this._keyboardBehavior.currentIndex, true); - this._updatePageUI(); - }, - - _focusCurrentItemPassively: function NavBarContainer_focusCurrentItemPassively() { - if (this.element.contains(_Global.document.activeElement)) { - this._keyboardBehavior._focus(); - } - }, - - _reset: function NavBarContainer_reset() { - this._keyboardBehavior.currentIndex = 0; - - if (this.element.contains(_Global.document.activeElement)) { - this._keyboardBehavior._focus(0); - } - - this._viewportEl.style.msScrollSnapType = ""; - this._zooming = false; - - this._ensureVisible(0, true); - this._updatePageUI(); - }, - - _removeDataChangedEvents: function NavBarContainer_removeDataChangedEvents() { - if (this._repeater) { - this._repeater.data.removeEventListener("itemchanged", this._dataChangedBound); - this._repeater.data.removeEventListener("iteminserted", this._dataChangedBound); - this._repeater.data.removeEventListener("itemmoved", this._dataChangedBound); - this._repeater.data.removeEventListener("itemremoved", this._dataChangedBound); - this._repeater.data.removeEventListener("reload", this._dataChangedBound); - } - }, - - _addDataChangedEvents: function NavBarContainer_addDataChangedEvents() { - if (this._repeater) { - this._repeater.data.addEventListener("itemchanged", this._dataChangedBound); - this._repeater.data.addEventListener("iteminserted", this._dataChangedBound); - this._repeater.data.addEventListener("itemmoved", this._dataChangedBound); - this._repeater.data.addEventListener("itemremoved", this._dataChangedBound); - this._repeater.data.addEventListener("reload", this._dataChangedBound); - } - }, - - _removeDataChangingEvents: function NavBarContainer_removeDataChangingEvents() { - if (this._repeater) { - this._repeater.data.removeEventListener("itemchanged", this._dataChangingBound); - this._repeater.data.removeEventListener("iteminserted", this._dataChangingBound); - this._repeater.data.removeEventListener("itemmoved", this._dataChangingBound); - this._repeater.data.removeEventListener("itemremoved", this._dataChangingBound); - this._repeater.data.removeEventListener("reload", this._dataChangingBound); - } - }, - - _addDataChangingEvents: function NavBarContainer_addDataChangingEvents(bindingList) { - bindingList.addEventListener("itemchanged", this._dataChangingBound); - bindingList.addEventListener("iteminserted", this._dataChangingBound); - bindingList.addEventListener("itemmoved", this._dataChangingBound); - bindingList.addEventListener("itemremoved", this._dataChangingBound); - bindingList.addEventListener("reload", this._dataChangingBound); - }, - - _mouseleave: function NavBarContainer_mouseleave() { - if (this._mouseInViewport) { - this._mouseInViewport = false; - this._updateArrows(); - } - }, - - _MSPointerDown: function NavBarContainer_MSPointerDown(ev) { - if (ev.pointerType === PT_TOUCH) { - if (this._mouseInViewport) { - this._mouseInViewport = false; - this._updateArrows(); - } - } - }, - - _MSPointerMove: function NavBarContainer_MSPointerMove(ev) { - if (ev.pointerType !== PT_TOUCH) { - if (!this._mouseInViewport) { - this._mouseInViewport = true; - this._updateArrows(); - } - } - }, - - _setupTree: function NavBarContainer_setupTree() { - this._animateNextPreviousButtons = Promise.wrap(); - this._element.addEventListener('mouseleave', this._mouseleave.bind(this)); - _ElementUtilities._addEventListener(this._element, 'pointerdown', this._MSPointerDown.bind(this)); - _ElementUtilities._addEventListener(this._element, 'pointermove', this._MSPointerMove.bind(this)); - _ElementUtilities._addEventListener(this._element, "focusin", this._focusHandler.bind(this), false); - - this._pageindicatorsEl = _Global.document.createElement('div'); - _ElementUtilities.addClass(this._pageindicatorsEl, NavBarContainer._ClassName.pageindicators); - this._element.appendChild(this._pageindicatorsEl); - - this._ariaStartMarker = _Global.document.createElement("div"); - this._element.appendChild(this._ariaStartMarker); - - this._viewportEl = _Global.document.createElement('div'); - _ElementUtilities.addClass(this._viewportEl, NavBarContainer._ClassName.viewport); - this._element.appendChild(this._viewportEl); - this._viewportEl.setAttribute("role", "group"); - this._viewportEl.setAttribute("aria-label", strings.navBarContainerViewportAriaLabel); - - this._boundResizeHandler = this._resizeHandler.bind(this); - _ElementUtilities._resizeNotifier.subscribe(this._element, this._boundResizeHandler); - this._viewportEl.addEventListener("mselementresize", this._resizeHandler.bind(this)); - this._viewportEl.addEventListener("scroll", this._scrollHandler.bind(this)); - this._viewportEl.addEventListener("MSManipulationStateChanged", this._MSManipulationStateChangedHandler.bind(this)); - - this._ariaEndMarker = _Global.document.createElement("div"); - this._element.appendChild(this._ariaEndMarker); - - this._surfaceEl = _Global.document.createElement('div'); - _ElementUtilities.addClass(this._surfaceEl, NavBarContainer._ClassName.surface); - this._viewportEl.appendChild(this._surfaceEl); - - this._surfaceEl.addEventListener("_invoked", this._navbarCommandInvokedHandler.bind(this)); - this._surfaceEl.addEventListener("_splittoggle", this._navbarCommandSplitToggleHandler.bind(this)); - _ElementUtilities._addEventListener(this._surfaceEl, "focusin", this._itemsFocusHandler.bind(this), false); - this._surfaceEl.addEventListener("keydown", this._keyDownHandler.bind(this)); - - // Reparent NavBarCommands which were in declarative markup - var tempEl = this.element.firstElementChild; - while (tempEl !== this._pageindicatorsEl) { - this._surfaceEl.appendChild(tempEl); - ControlProcessor.process(tempEl); - tempEl = this.element.firstElementChild; - } - - this._leftArrowEl = _Global.document.createElement('div'); - _ElementUtilities.addClass(this._leftArrowEl, NavBarContainer._ClassName.navleftarrow); - _ElementUtilities.addClass(this._leftArrowEl, NavBarContainer._ClassName.navarrow); - this._element.appendChild(this._leftArrowEl); - this._leftArrowEl.addEventListener('click', this._goLeft.bind(this)); - this._leftArrowEl.style.opacity = 0; - this._leftArrowEl.style.visibility = 'hidden'; - this._leftArrowFadeOut = Promise.wrap(); - - this._rightArrowEl = _Global.document.createElement('div'); - _ElementUtilities.addClass(this._rightArrowEl, NavBarContainer._ClassName.navrightarrow); - _ElementUtilities.addClass(this._rightArrowEl, NavBarContainer._ClassName.navarrow); - this._element.appendChild(this._rightArrowEl); - this._rightArrowEl.addEventListener('click', this._goRight.bind(this)); - this._rightArrowEl.style.opacity = 0; - this._rightArrowEl.style.visibility = 'hidden'; - this._rightArrowFadeOut = Promise.wrap(); - - this._keyboardBehavior = new _KeyboardBehavior._KeyboardBehavior(this._surfaceEl, { - scroller: this._viewportEl - }); - this._winKeyboard = new _KeyboardBehavior._WinKeyboard(this._surfaceEl); - }, - - _goRight: function NavBarContainer_goRight() { - if (this._sizes.rtl) { - this._goPrev(); - } else { - this._goNext(); - } - }, - - _goLeft: function NavBarContainer_goLeft() { - if (this._sizes.rtl) { - this._goNext(); - } else { - this._goPrev(); - } - }, - - _goNext: function NavBarContainer_goNext() { - this._measure(); - var itemsPerPage = this._sizes.rowsPerPage * this._sizes.columnsPerPage; - var targetPage = Math.min(Math.floor(this._keyboardBehavior.currentIndex / itemsPerPage) + 1, this._sizes.pages - 1); - this._keyboardBehavior.currentIndex = Math.min(itemsPerPage * targetPage, this._surfaceEl.children.length); - this._keyboardBehavior._focus(); - }, - - _goPrev: function NavBarContainer_goPrev() { - this._measure(); - var itemsPerPage = this._sizes.rowsPerPage * this._sizes.columnsPerPage; - var targetPage = Math.max(0, Math.floor(this._keyboardBehavior.currentIndex / itemsPerPage) - 1); - this._keyboardBehavior.currentIndex = Math.max(itemsPerPage * targetPage, 0); - this._keyboardBehavior._focus(); - }, - - _currentPage: { - get: function () { - if (this.layout === _UI.Orientation.horizontal) { - this._measure(); - if (this._sizes.viewportOffsetWidth > 0) { - return Math.min(this._sizes.pages - 1, Math.round(this._scrollPosition / this._sizes.viewportOffsetWidth)); - } - } - return 0; - } - }, - - _resizeHandler: function NavBarContainer_resizeHandler() { - if (this._disposed) { return; } - if (!this._measured) { return; } - var viewportResized = this.layout === _UI.Orientation.horizontal - ? this._sizes.viewportOffsetWidth !== parseFloat(_Global.getComputedStyle(this._viewportEl).width) - : this._sizes.viewportOffsetHeight !== parseFloat(_Global.getComputedStyle(this._viewportEl).height); - if (!viewportResized) { return; } - - this._measured = false; - - if (!this._pendingResize) { - this._pendingResize = true; - - this._resizeImplBound = this._resizeImplBound || this._resizeImpl.bind(this); - - this._updateAppBarReference(); - - if (this._appBarEl && this._appBarEl.winControl && !this._appBarEl.winControl.opened) { - // Do resize lazily. - Scheduler.schedule(this._resizeImplBound, Scheduler.Priority.idle, null, "WinJS.UI.NavBarContainer._resizeImpl"); - this._appBarEl.addEventListener('beforeopen', this._resizeImplBound); - } else { - // Do resize now - this._resizeImpl(); - } - } - }, - - _resizeImpl: function NavBarContainer_resizeImpl() { - if (!this._disposed && this._pendingResize) { - this._pendingResize = false; - if (this._appBarEl) { - this._appBarEl.removeEventListener('beforeopen', this._resizeImplBound); - } - - this._keyboardBehavior.currentIndex = 0; - if (this.element.contains(_Global.document.activeElement)) { - this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex); - } - this._closeSplitIfOpen(); - this._ensureVisible(this._keyboardBehavior.currentIndex, true); - this._updatePageUI(); - } - }, - - _keyDownHandler: function NavBarContainer_keyDownHandler(ev) { - var keyCode = ev.keyCode; - if (!ev.altKey && (keyCode === Key.pageUp || keyCode === Key.pageDown)) { - var srcElement = ev.target; - if (_ElementUtilities._matchesSelector(srcElement, ".win-interactive, .win-interactive *")) { - return; - } - - var index = this._keyboardBehavior.currentIndex; - this._measure(); - - var sizes = this._sizes; - var page = Math.floor(index / (sizes.columnsPerPage * sizes.rowsPerPage)); - - var scrollPositionTarget = null; - if (keyCode === Key.pageUp) { - if (this.layout === _UI.Orientation.horizontal) { - var indexOfFirstItemOnPage = page * sizes.columnsPerPage * sizes.rowsPerPage; - if (index === indexOfFirstItemOnPage && this._surfaceEl.children[index].winControl._buttonEl === _Global.document.activeElement) { - // First item on page so go back 1 page. - index = index - sizes.columnsPerPage * sizes.rowsPerPage; - } else { - // Not first item on page so go to the first item on page. - index = indexOfFirstItemOnPage; - } - } else { - var currentItem = this._surfaceEl.children[index]; - var top = currentItem.offsetTop; - var bottom = top + currentItem.offsetHeight; - var scrollPosition = this._zooming ? this._zoomPosition : this._scrollPosition; - - if (top >= scrollPosition && bottom < scrollPosition + sizes.viewportOffsetHeight) { - // current item is fully on screen. - while (index > 0 && - this._surfaceEl.children[index - 1].offsetTop > scrollPosition) { - index--; - } - } - - if (this._keyboardBehavior.currentIndex === index) { - var scrollPositionForOnePageAboveItem = bottom - sizes.viewportOffsetHeight; - index = Math.max(0, index - 1); - while (index > 0 && - this._surfaceEl.children[index - 1].offsetTop > scrollPositionForOnePageAboveItem) { - index--; - } - if (index > 0) { - scrollPositionTarget = this._surfaceEl.children[index].offsetTop - this._sizes.itemMarginTop; - } else { - scrollPositionTarget = 0; - } - } - } - - index = Math.max(index, 0); - this._keyboardBehavior.currentIndex = index; - - var element = this._surfaceEl.children[index].winControl._buttonEl; - - if (scrollPositionTarget !== null) { - this._scrollTo(scrollPositionTarget); - } - - _ElementUtilities._setActive(element, this._viewportEl); - } else { - if (this.layout === _UI.Orientation.horizontal) { - var indexOfLastItemOnPage = (page + 1) * sizes.columnsPerPage * sizes.rowsPerPage - 1; - - if (index === indexOfLastItemOnPage) { - // Last item on page so go forward 1 page. - index = index + sizes.columnsPerPage * sizes.rowsPerPage; - } else { - // Not Last item on page so go to last item on page. - index = indexOfLastItemOnPage; - } - } else { - var currentItem = this._surfaceEl.children[this._keyboardBehavior.currentIndex]; - var top = currentItem.offsetTop; - var bottom = top + currentItem.offsetHeight; - var scrollPosition = this._zooming ? this._zoomPosition : this._scrollPosition; - - if (top >= scrollPosition && bottom < scrollPosition + sizes.viewportOffsetHeight) { - // current item is fully on screen. - while (index < this._surfaceEl.children.length - 1 && - this._surfaceEl.children[index + 1].offsetTop + this._surfaceEl.children[index + 1].offsetHeight < scrollPosition + sizes.viewportOffsetHeight) { - index++; - } - } - - if (index === this._keyboardBehavior.currentIndex) { - var scrollPositionForOnePageBelowItem = top + sizes.viewportOffsetHeight; - index = Math.min(this._surfaceEl.children.length - 1, index + 1); - while (index < this._surfaceEl.children.length - 1 && - this._surfaceEl.children[index + 1].offsetTop + this._surfaceEl.children[index + 1].offsetHeight < scrollPositionForOnePageBelowItem) { - index++; - } - - if (index < this._surfaceEl.children.length - 1) { - scrollPositionTarget = this._surfaceEl.children[index + 1].offsetTop - this._sizes.viewportOffsetHeight; - } else { - scrollPositionTarget = this._scrollLength - this._sizes.viewportOffsetHeight; - } - } - } - - index = Math.min(index, this._surfaceEl.children.length - 1); - this._keyboardBehavior.currentIndex = index; - - var element = this._surfaceEl.children[index].winControl._buttonEl; - - if (scrollPositionTarget !== null) { - this._scrollTo(scrollPositionTarget); - } - - try { - _ElementUtilities._setActive(element, this._viewportEl); - } catch (e) { - } - } - } - }, - - _focusHandler: function NavBarContainer_focusHandler(ev) { - var srcElement = ev.target; - if (!this._surfaceEl.contains(srcElement)) { - // Forward focus from NavBarContainer, viewport or surface to the currentIndex. - this._skipEnsureVisible = true; - this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex); - } - }, - - _itemsFocusHandler: function NavBarContainer_itemsFocusHandler(ev) { - // Find the item which is being focused and scroll it to view. - var srcElement = ev.target; - if (srcElement === this._surfaceEl) { - return; - } - - while (srcElement.parentNode !== this._surfaceEl) { - srcElement = srcElement.parentNode; - } - - var index = -1; - while (srcElement) { - index++; - srcElement = srcElement.previousSibling; - } - - if (this._skipEnsureVisible) { - this._skipEnsureVisible = false; - } else { - this._ensureVisible(index); - } - }, - - _ensureVisible: function NavBarContainer_ensureVisible(index, withoutAnimation) { - this._measure(); - - if (this.layout === _UI.Orientation.horizontal) { - var page = Math.floor(index / (this._sizes.rowsPerPage * this._sizes.columnsPerPage)); - this._scrollTo(page * this._sizes.viewportOffsetWidth, withoutAnimation); - } else { - var element = this._surfaceEl.children[index]; - var maxScrollPosition; - if (index > 0) { - maxScrollPosition = element.offsetTop - this._sizes.itemMarginTop; - } else { - maxScrollPosition = 0; - } - var minScrollPosition; - if (index < this._surfaceEl.children.length - 1) { - minScrollPosition = this._surfaceEl.children[index + 1].offsetTop - this._sizes.viewportOffsetHeight; - } else { - minScrollPosition = this._scrollLength - this._sizes.viewportOffsetHeight; - } - - var newScrollPosition = this._zooming ? this._zoomPosition : this._scrollPosition; - newScrollPosition = Math.max(newScrollPosition, minScrollPosition); - newScrollPosition = Math.min(newScrollPosition, maxScrollPosition); - this._scrollTo(newScrollPosition, withoutAnimation); - } - }, - - _scrollTo: function NavBarContainer_scrollTo(targetScrollPosition, withoutAnimation) { - this._measure(); - if (this.layout === _UI.Orientation.horizontal) { - targetScrollPosition = Math.max(0, Math.min(this._scrollLength - this._sizes.viewportOffsetWidth, targetScrollPosition)); - } else { - targetScrollPosition = Math.max(0, Math.min(this._scrollLength - this._sizes.viewportOffsetHeight, targetScrollPosition)); - } - - if (withoutAnimation) { - if (Math.abs(this._scrollPosition - targetScrollPosition) > 1) { - this._zooming = false; - - this._scrollPosition = targetScrollPosition; - this._updatePageUI(); - if (!this._duringForceLayout) { - this._closeSplitIfOpen(); - } - - var newScrollPos = {}; - newScrollPos[(this.layout === _UI.Orientation.horizontal ? "scrollLeft" : "scrollTop")] = targetScrollPosition; - _ElementUtilities.setScrollPosition(this._viewportEl, newScrollPos); - } - } else { - if ((!this._zooming && Math.abs(this._scrollPosition - targetScrollPosition) > 1) || (this._zooming && Math.abs(this._zoomPosition - targetScrollPosition) > 1)) { - this._zoomPosition = targetScrollPosition; - - this._zooming = true; - - if (this.layout === _UI.Orientation.horizontal) { - this._viewportEl.style.msScrollSnapType = "none"; - _ElementUtilities._zoomTo(this._viewportEl, { contentX: targetScrollPosition, contentY: 0, viewportX: 0, viewportY: 0 }); - } else { - _ElementUtilities._zoomTo(this._viewportEl, { contentX: 0, contentY: targetScrollPosition, viewportX: 0, viewportY: 0 }); - } - - this._closeSplitIfOpen(); - } - } - }, - - _MSManipulationStateChangedHandler: function NavBarContainer_MSManipulationStateChangedHandler(e) { - this._currentManipulationState = e.currentState; - - if (e.currentState === e.MS_MANIPULATION_STATE_ACTIVE) { - this._viewportEl.style.msScrollSnapType = ""; - this._zooming = false; - } - - _Global.clearTimeout(this._manipulationStateTimeoutId); - // The extra stop event is firing when an zoomTo is called during another zoomTo and - // also the first zoomTo after a resize. - if (e.currentState === e.MS_MANIPULATION_STATE_STOPPED) { - this._manipulationStateTimeoutId = _Global.setTimeout(function () { - this._viewportEl.style.msScrollSnapType = ""; - this._zooming = false; - this._updateCurrentIndexIfPageChanged(); - }.bind(this), 100); - } - }, - - _scrollHandler: function NavBarContainer_scrollHandler() { - if (this._disposed) { return; } - - this._measured = false; - if (!this._checkingScroll) { - var that = this; - this._checkingScroll = _BaseUtils._requestAnimationFrame(function () { - if (that._disposed) { return; } - that._checkingScroll = null; - - var newScrollPosition = _ElementUtilities.getScrollPosition(that._viewportEl)[(that.layout === _UI.Orientation.horizontal ? "scrollLeft" : "scrollTop")]; - if (newScrollPosition !== that._scrollPosition) { - that._scrollPosition = newScrollPosition; - that._closeSplitIfOpen(); - } - that._updatePageUI(); - - if (!that._zooming && that._currentManipulationState === MS_MANIPULATION_STATE_STOPPED) { - that._updateCurrentIndexIfPageChanged(); - } - }); - } - }, - - _updateCurrentIndexIfPageChanged: function NavBarContainer_updateCurrentIndexIfPageChanged() { - // If you change pages via pagination arrows, mouse wheel, or panning we need to update the current - // item to be the first item on the new page. - if (this.layout === _UI.Orientation.horizontal) { - this._measure(); - var currentPage = this._currentPage; - var firstIndexOnPage = currentPage * this._sizes.rowsPerPage * this._sizes.columnsPerPage; - var lastIndexOnPage = (currentPage + 1) * this._sizes.rowsPerPage * this._sizes.columnsPerPage - 1; - - if (this._keyboardBehavior.currentIndex < firstIndexOnPage || this._keyboardBehavior.currentIndex > lastIndexOnPage) { - // Page change occurred. - this._keyboardBehavior.currentIndex = firstIndexOnPage; - - if (this.element.contains(_Global.document.activeElement)) { - this._keyboardBehavior._focus(this._keyboardBehavior.currentIndex); - } - } - } - }, - - _measure: function NavBarContainer_measure() { - if (!this._measured) { - this._resizeImpl(); - this._writeProfilerMark("measure,StartTM"); - - var sizes = this._sizes; - - sizes.rtl = _Global.getComputedStyle(this._element).direction === "rtl"; - - var itemCount = this._surfaceEl.children.length; - if (itemCount > 0) { - if (!this._sizes.itemMeasured) { - this._writeProfilerMark("measureItem,StartTM"); - - var elementToMeasure = this._surfaceEl.firstElementChild; - // Clear inline margins set by NavBarContainer before measuring. - elementToMeasure.style.margin = ""; - elementToMeasure.style.width = ""; - var elementComputedStyle = _Global.getComputedStyle(elementToMeasure); - sizes.itemOffsetWidth = parseFloat(_Global.getComputedStyle(elementToMeasure).width); - if (elementToMeasure.offsetWidth === 0) { - sizes.itemOffsetWidth = 0; - } - sizes.itemMarginLeft = parseFloat(elementComputedStyle.marginLeft); - sizes.itemMarginRight = parseFloat(elementComputedStyle.marginRight); - sizes.itemWidth = sizes.itemOffsetWidth + sizes.itemMarginLeft + sizes.itemMarginRight; - sizes.itemOffsetHeight = parseFloat(_Global.getComputedStyle(elementToMeasure).height); - if (elementToMeasure.offsetHeight === 0) { - sizes.itemOffsetHeight = 0; - } - sizes.itemMarginTop = parseFloat(elementComputedStyle.marginTop); - sizes.itemMarginBottom = parseFloat(elementComputedStyle.marginBottom); - sizes.itemHeight = sizes.itemOffsetHeight + sizes.itemMarginTop + sizes.itemMarginBottom; - if (sizes.itemOffsetWidth > 0 && sizes.itemOffsetHeight > 0) { - sizes.itemMeasured = true; - } - this._writeProfilerMark("measureItem,StopTM"); - } - - sizes.viewportOffsetWidth = parseFloat(_Global.getComputedStyle(this._viewportEl).width); - if (this._viewportEl.offsetWidth === 0) { - sizes.viewportOffsetWidth = 0; - } - sizes.viewportOffsetHeight = parseFloat(_Global.getComputedStyle(this._viewportEl).height); - if (this._viewportEl.offsetHeight === 0) { - sizes.viewportOffsetHeight = 0; - } - - if (sizes.viewportOffsetWidth === 0 || sizes.itemOffsetHeight === 0) { - this._measured = false; - } else { - this._measured = true; - } - - if (this.layout === _UI.Orientation.horizontal) { - this._scrollPosition = _ElementUtilities.getScrollPosition(this._viewportEl).scrollLeft; - - sizes.leadingEdge = this._leftArrowEl.offsetWidth + parseInt(_Global.getComputedStyle(this._leftArrowEl).marginLeft) + parseInt(_Global.getComputedStyle(this._leftArrowEl).marginRight); - var usableSpace = sizes.viewportOffsetWidth - sizes.leadingEdge * 2; - sizes.maxColumns = sizes.itemWidth ? Math.max(1, Math.floor(usableSpace / sizes.itemWidth)) : 1; - sizes.rowsPerPage = Math.min(this.maxRows, Math.ceil(itemCount / sizes.maxColumns)); - sizes.columnsPerPage = Math.min(sizes.maxColumns, itemCount); - sizes.pages = Math.ceil(itemCount / (sizes.columnsPerPage * sizes.rowsPerPage)); - sizes.trailingEdge = sizes.leadingEdge; - sizes.extraSpace = usableSpace - (sizes.columnsPerPage * sizes.itemWidth); - - this._scrollLength = sizes.viewportOffsetWidth * sizes.pages; - - this._keyboardBehavior.fixedSize = sizes.rowsPerPage; - this._keyboardBehavior.fixedDirection = _KeyboardBehavior._KeyboardBehavior.FixedDirection.height; - - this._surfaceEl.style.height = (sizes.itemHeight * sizes.rowsPerPage) + "px"; - this._surfaceEl.style.width = this._scrollLength + "px"; - } else { - this._scrollPosition = this._viewportEl.scrollTop; - - sizes.leadingEdge = 0; - sizes.rowsPerPage = itemCount; - sizes.columnsPerPage = 1; - sizes.pages = 1; - sizes.trailingEdge = 0; - - // Reminder there is margin collapsing so just use scrollHeight instead of itemHeight * itemCount - this._scrollLength = this._viewportEl.scrollHeight; - - this._keyboardBehavior.fixedSize = sizes.columnsPerPage; - this._keyboardBehavior.fixedDirection = _KeyboardBehavior._KeyboardBehavior.FixedDirection.width; - - this._surfaceEl.style.height = ""; - this._surfaceEl.style.width = ""; - } - - this._updateGridStyles(); - } else { - sizes.pages = 1; - this._hasPreviousContent = false; - this._hasNextContent = false; - this._surfaceEl.style.height = ""; - this._surfaceEl.style.width = ""; - } - - this._writeProfilerMark("measure,StopTM"); - } - }, - - _updateGridStyles: function NavBarContainer_updateGridStyles() { - var sizes = this._sizes; - var itemCount = this._surfaceEl.children.length; - - for (var index = 0; index < itemCount; index++) { - var itemEl = this._surfaceEl.children[index]; - - var marginRight; - var marginLeft; - var width = ""; - - if (this.layout === _UI.Orientation.horizontal) { - var column = Math.floor(index / sizes.rowsPerPage); - var isFirstColumnOnPage = column % sizes.columnsPerPage === 0; - var isLastColumnOnPage = column % sizes.columnsPerPage === sizes.columnsPerPage - 1; - - var extraTrailingMargin = sizes.trailingEdge; - if (this.fixedSize) { - extraTrailingMargin += sizes.extraSpace; - } else { - var spaceToDistribute = sizes.extraSpace - (sizes.maxColumns - sizes.columnsPerPage) * sizes.itemWidth; - width = (sizes.itemOffsetWidth + (spaceToDistribute / sizes.maxColumns)) + "px"; - } - - var extraMarginRight; - var extraMarginLeft; - - if (sizes.rtl) { - extraMarginRight = (isFirstColumnOnPage ? sizes.leadingEdge : 0); - extraMarginLeft = (isLastColumnOnPage ? extraTrailingMargin : 0); - } else { - extraMarginRight = (isLastColumnOnPage ? extraTrailingMargin : 0); - extraMarginLeft = (isFirstColumnOnPage ? sizes.leadingEdge : 0); - } - - marginRight = extraMarginRight + sizes.itemMarginRight + "px"; - marginLeft = extraMarginLeft + sizes.itemMarginLeft + "px"; - } else { - marginRight = ""; - marginLeft = ""; - } - - if (itemEl.style.marginRight !== marginRight) { - itemEl.style.marginRight = marginRight; - } - if (itemEl.style.marginLeft !== marginLeft) { - itemEl.style.marginLeft = marginLeft; - } - if (itemEl.style.width !== width) { - itemEl.style.width = width; - } - } - }, - - _updatePageUI: function NavBarContainer_updatePageUI() { - this._measure(); - var currentPage = this._currentPage; - - this._hasPreviousContent = (currentPage !== 0); - this._hasNextContent = (currentPage < this._sizes.pages - 1); - this._updateArrows(); - - // Always output the pagination indicators so they reserves up space. - if (this._indicatorCount !== this._sizes.pages) { - this._indicatorCount = this._sizes.pages; - this._pageindicatorsEl.innerHTML = new Array(this._sizes.pages + 1).join(''); - } - - for (var i = 0; i < this._pageindicatorsEl.children.length; i++) { - if (i === currentPage) { - _ElementUtilities.addClass(this._pageindicatorsEl.children[i], NavBarContainer._ClassName.currentindicator); - } else { - _ElementUtilities.removeClass(this._pageindicatorsEl.children[i], NavBarContainer._ClassName.currentindicator); - } - } - - if (this._sizes.pages > 1) { - this._viewportEl.style.overflowX = this._panningDisabled ? "hidden" : ""; - this._pageindicatorsEl.style.visibility = ""; - } else { - this._viewportEl.style.overflowX = "hidden"; - this._pageindicatorsEl.style.visibility = "hidden"; - } - - if (this._sizes.pages <= 1 || this._layout !== _UI.Orientation.horizontal) { - this._ariaStartMarker.removeAttribute("aria-flowto"); - this._ariaEndMarker.removeAttribute("x-ms-aria-flowfrom"); - } else { - var firstIndexOnCurrentPage = currentPage * this._sizes.rowsPerPage * this._sizes.columnsPerPage; - var firstItem = this._surfaceEl.children[firstIndexOnCurrentPage].winControl._buttonEl; - _ElementUtilities._ensureId(firstItem); - this._ariaStartMarker.setAttribute("aria-flowto", firstItem.id); - - var lastIndexOnCurrentPage = Math.min(this._surfaceEl.children.length - 1, (currentPage + 1) * this._sizes.rowsPerPage * this._sizes.columnsPerPage - 1); - var lastItem = this._surfaceEl.children[lastIndexOnCurrentPage].winControl._buttonEl; - _ElementUtilities._ensureId(lastItem); - this._ariaEndMarker.setAttribute("x-ms-aria-flowfrom", lastItem.id); - } - }, - - _closeSplitIfOpen: function NavBarContainer_closeSplitIfOpen() { - if (this._currentSplitNavItem) { - if (this._currentSplitNavItem.splitOpened) { - this._currentSplitNavItem._toggleSplit(); - } - this._currentSplitNavItem = null; - } - }, - - _updateArrows: function NavBarContainer_updateArrows() { - var hasLeftContent = this._sizes.rtl ? this._hasNextContent : this._hasPreviousContent; - var hasRightContent = this._sizes.rtl ? this._hasPreviousContent : this._hasNextContent; - - var that = this; - // Previous and next are the arrows, not states. On mouse hover the arrows fade in immediately. If you - // mouse out the arrows fade out after a delay. When you reach the last/first page, the corresponding - // arrow fades out immediately as well. - if ((this._mouseInViewport || this._panningDisabled) && hasLeftContent) { - this._leftArrowWaitingToFadeOut && this._leftArrowWaitingToFadeOut.cancel(); - this._leftArrowWaitingToFadeOut = null; - this._leftArrowFadeOut && this._leftArrowFadeOut.cancel(); - this._leftArrowFadeOut = null; - this._leftArrowEl.style.visibility = ''; - this._leftArrowFadeIn = this._leftArrowFadeIn || Animations.fadeIn(this._leftArrowEl); - } else { - if (hasLeftContent) { - // If we need a delayed fade out and we are already running a delayed fade out just use that one, don't extend it. - // Otherwise create a delayed fade out. - this._leftArrowWaitingToFadeOut = this._leftArrowWaitingToFadeOut || Promise.timeout(_TransitionAnimation._animationTimeAdjustment(buttonFadeDelay)); - } else { - // If we need a immediate fade out and already have a delayed fade out cancel that one and create an immediate one. - this._leftArrowWaitingToFadeOut && this._leftArrowWaitingToFadeOut.cancel(); - this._leftArrowWaitingToFadeOut = Promise.wrap(); - } - this._leftArrowWaitingToFadeOut.then(function () { - // After the delay cancel any fade in if running. If we already were fading out continue it otherwise start the fade out. - this._leftArrowFadeIn && this._leftArrowFadeIn.cancel(); - this._leftArrowFadeIn = null; - this._leftArrowFadeOut = this._leftArrowFadeOut || Animations.fadeOut(this._leftArrowEl).then(function () { - that._leftArrowEl.style.visibility = 'hidden'; - }); - }.bind(this)); - } - - // Same pattern for Next arrow. - if ((this._mouseInViewport || this._panningDisabled) && hasRightContent) { - this._rightArrowWaitingToFadeOut && this._rightArrowWaitingToFadeOut.cancel(); - this._rightArrowWaitingToFadeOut = null; - this._rightArrowFadeOut && this._rightArrowFadeOut.cancel(); - this._rightArrowFadeOut = null; - this._rightArrowEl.style.visibility = ''; - this._rightArrowFadeIn = this._rightArrowFadeIn || Animations.fadeIn(this._rightArrowEl); - } else { - if (hasRightContent) { - this._rightArrowWaitingToFadeOut = this._rightArrowWaitingToFadeOut || Promise.timeout(_TransitionAnimation._animationTimeAdjustment(buttonFadeDelay)); - } else { - this._rightArrowWaitingToFadeOut && this._rightArrowWaitingToFadeOut.cancel(); - this._rightArrowWaitingToFadeOut = Promise.wrap(); - } - this._rightArrowWaitingToFadeOut.then(function () { - this._rightArrowFadeIn && this._rightArrowFadeIn.cancel(); - this._rightArrowFadeIn = null; - this._rightArrowFadeOut = this._rightArrowFadeOut || Animations.fadeOut(this._rightArrowEl).then(function () { - that._rightArrowEl.style.visibility = 'hidden'; - }); - }.bind(this)); - } - }, - - _navbarCommandInvokedHandler: function NavBarContainer_navbarCommandInvokedHandler(ev) { - var srcElement = ev.target; - var index = -1; - while (srcElement) { - index++; - srcElement = srcElement.previousSibling; - } - - this._fireEvent(NavBarContainer._EventName.invoked, { - index: index, - navbarCommand: ev.target.winControl, - data: this._repeater ? this._repeater.data.getAt(index) : null - }); - }, - - _navbarCommandSplitToggleHandler: function NavBarContainer_navbarCommandSplitToggleHandler(ev) { - var srcElement = ev.target; - var index = -1; - while (srcElement) { - index++; - srcElement = srcElement.previousSibling; - } - - var navbarCommand = ev.target.winControl; - - this._closeSplitIfOpen(); - - if (navbarCommand.splitOpened) { - this._currentSplitNavItem = navbarCommand; - } - - this._fireEvent(NavBarContainer._EventName.splitToggle, { - opened: navbarCommand.splitOpened, - index: index, - navbarCommand: navbarCommand, - data: this._repeater ? this._repeater.data.getAt(index) : null - }); - }, - - _fireEvent: function NavBarContainer_fireEvent(type, detail) { - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(type, true, false, detail); - this.element.dispatchEvent(event); - }, - - _writeProfilerMark: function NavBarContainer_writeProfilerMark(text) { - var message = "WinJS.UI.NavBarContainer:" + this._id + ":" + text; - _WriteProfilerMark(message); - _Log.log && _Log.log(message, null, "navbarcontainerprofiler"); - }, - - dispose: function NavBarContainer_dispose() { - /// - /// - /// Disposes this control. - /// - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - - if (this._appBarEl) { - this._appBarEl.removeEventListener('beforeopen', this._closeSplitAndResetBound); - this._appBarEl.removeEventListener('beforeopen', this._resizeImplBound); - } - - Navigation.removeEventListener('navigated', this._closeSplitAndResetBound); - - this._leftArrowWaitingToFadeOut && this._leftArrowWaitingToFadeOut.cancel(); - this._leftArrowFadeOut && this._leftArrowFadeOut.cancel(); - this._leftArrowFadeIn && this._leftArrowFadeIn.cancel(); - this._rightArrowWaitingToFadeOut && this._rightArrowWaitingToFadeOut.cancel(); - this._rightArrowFadeOut && this._rightArrowFadeOut.cancel(); - this._rightArrowFadeIn && this._rightArrowFadeIn.cancel(); - - _ElementUtilities._resizeNotifier.unsubscribe(this._element, this._boundResizeHandler); - - this._removeDataChangingEvents(); - this._removeDataChangedEvents(); - } - }, { - // Names of classes used by the NavBarContainer. - _ClassName: { - navbarcontainer: "win-navbarcontainer", - pageindicators: "win-navbarcontainer-pageindicator-box", - indicator: "win-navbarcontainer-pageindicator", - currentindicator: "win-navbarcontainer-pageindicator-current", - vertical: "win-navbarcontainer-vertical", - horizontal: "win-navbarcontainer-horizontal", - viewport: "win-navbarcontainer-viewport", - surface: "win-navbarcontainer-surface", - navarrow: "win-navbarcontainer-navarrow", - navleftarrow: "win-navbarcontainer-navleft", - navrightarrow: "win-navbarcontainer-navright" - }, - _EventName: { - invoked: eventNames.invoked, - splitToggle: eventNames.splittoggle - } - }); - _Base.Class.mix(NavBarContainer, _Control.DOMEventMixin); - return NavBarContainer; - }) - }); - -}); - - -define('require-style!less/styles-navbar',[],function(){}); - -define('require-style!less/colors-navbar',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/NavBar',[ - '../Core/_Global', - '../Core/_WinRT', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_Events', - '../Core/_WriteProfilerMark', - '../Promise', - '../Scheduler', - '../Utilities/_ElementUtilities', - '../Utilities/_Hoverable', - "../_Accents", - './_LegacyAppBar', - './NavBar/_Command', - './NavBar/_Container', - 'require-style!less/styles-navbar', - 'require-style!less/colors-navbar' -], function NavBarInit(_Global,_WinRT, _Base, _BaseUtils, _Events, _WriteProfilerMark, Promise, Scheduler, _ElementUtilities, _Hoverable, _Accents, _LegacyAppBar, _Command, _Container) { - "use strict"; - - _Accents.createAccentRule("html.win-hoverable .win-navbarcommand-splitbutton.win-navbarcommand-splitbutton-opened:hover", [{ name: "background-color", value: _Accents.ColorTypes.listSelectHover }]); - _Accents.createAccentRule("html.win-hoverable .win-navbarcommand-splitbutton.win-navbarcommand-splitbutton-opened:hover.win-pressed", [{ name: "background-color", value: _Accents.ColorTypes.listSelectPress }]); - _Accents.createAccentRule(".win-navbarcommand-splitbutton.win-navbarcommand-splitbutton-opened", [{ name: "background-color", value: _Accents.ColorTypes.listSelectRest }]); - _Accents.createAccentRule(".win-navbarcommand-splitbutton.win-navbarcommand-splitbutton-opened.win-pressed", [{ name: "background-color", value: _Accents.ColorTypes.listSelectPress }]); - - var customLayout = "custom"; - - _Base.Namespace.define("WinJS.UI", { - /// - /// - /// Displays navigation commands in a toolbar that the user can open or close. - /// - /// - /// - /// - /// - /// - ///
- ///
- ///
- /// ]]>
- /// Raised just before opening the NavBar. - /// Raised immediately after an NavBar is fully opened. - /// Raised just before closing the NavBar. - /// Raised immediately after the NavBar is fully closed. - /// Fired when children of NavBar control have been processed from a WinJS.UI.processAll call. - /// Styles the entire NavBar. - /// - /// - NavBar: _Base.Namespace._lazy(function () { - var childrenProcessedEventName = "childrenprocessed"; - var createEvent = _Events._createEventProperty; - - var NavBar = _Base.Class.derive(_LegacyAppBar._LegacyAppBar, function NavBar_ctor(element, options) { - /// - /// - /// Creates a new NavBar. - /// - /// - /// The DOM element that will host the new NavBar control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. Each property of the options object corresponds to one of the control's - /// properties or events. - /// - /// - /// The new NavBar control. - /// - /// - /// - - options = options || {}; - - // Shallow copy object so we can modify it. - options = _BaseUtils._shallowCopy(options); - - // Default to Placement = Top and Layout = Custom - options.placement = options.placement || "top"; - options.layout = customLayout; - options.closedDisplayMode = options.closedDisplayMode || "minimal"; - - _LegacyAppBar._LegacyAppBar.call(this, element, options); - - this._element.addEventListener("beforeopen", this._handleBeforeShow.bind(this)); - - _ElementUtilities.addClass(this.element, NavBar._ClassName.navbar); - - if (_WinRT.Windows.ApplicationModel.DesignMode.designModeEnabled) { - this._processChildren(); - } else { - Scheduler.schedule(this._processChildren.bind(this), Scheduler.Priority.idle, null, "WinJS.UI.NavBar.processChildren"); - } - }, { - - // Restrict values of closedDisplayMode to 'none' or 'minimal' - - /// - /// Gets/Sets how NavBar will display itself while hidden. Values are "none" and "minimal". - /// - closedDisplayMode: { - get: function () { - return this._closedDisplayMode; - }, - set: function (value) { - var newValue = (value === "none" ? "none" : "minimal"); - Object.getOwnPropertyDescriptor(_LegacyAppBar._LegacyAppBar.prototype, "closedDisplayMode").set.call(this, newValue); - this._closedDisplayMode = newValue; - }, - }, - - /// - /// Raised when children of NavBar control have been processed by a WinJS.UI.processAll call. - /// - /// - onchildrenprocessed: createEvent(childrenProcessedEventName), - - _processChildren: function NavBar_processChildren() { - // The NavBar control schedules processAll on its children at idle priority to avoid hurting startup - // performance. If the NavBar is shown before the scheduler gets to the idle job, the NavBar will - // immediately call processAll on its children. If your app needs the children to be processed before - // the scheduled job executes, you may call processChildren to force the processAll call. - if (!this._processed) { - this._processed = true; - - this._writeProfilerMark("processChildren,StartTM"); - var that = this; - var processed = Promise.as(); - if (this._processors) { - this._processors.forEach(function (processAll) { - for (var i = 0, len = that.element.children.length; i < len; i++) { - (function (child) { - processed = processed.then(function () { - processAll(child); - }); - }(that.element.children[i])); - } - }); - } - return processed.then( - function () { - that._writeProfilerMark("processChildren,StopTM"); - that._fireEvent(NavBar._EventName.childrenProcessed); - }, - function () { - that._writeProfilerMark("processChildren,StopTM"); - that._fireEvent(NavBar._EventName.childrenProcessed); - } - ); - } - return Promise.wrap(); - }, - - _show: function NavBar_show() { - // Override _show to call processChildren first. - // - if (this.disabled) { - return; - } - var that = this; - this._processChildren().then(function () { - _LegacyAppBar._LegacyAppBar.prototype._show.call(that); - }); - }, - - _handleBeforeShow: function NavBar_handleBeforeShow() { - // Navbar needs to ensure its elements to have their correct height and width after _LegacyAppBar changes display="none" - // to display="" and _LegacyAppBar needs the elements to have their final height before it measures its own element height - // to do the slide in animation over the correct amount of pixels. - if (this._disposed) { - return; - } - - var navbarcontainerEls = this.element.querySelectorAll('.win-navbarcontainer'); - for (var i = 0; i < navbarcontainerEls.length; i++) { - navbarcontainerEls[i].winControl.forceLayout(); - } - }, - - _fireEvent: function NavBar_fireEvent(type, detail) { - var event = _Global.document.createEvent("CustomEvent"); - event.initCustomEvent(type, true, false, detail || {}); - this.element.dispatchEvent(event); - }, - - _writeProfilerMark: function NavBar_writeProfilerMark(text) { - _WriteProfilerMark("WinJS.UI.NavBar:" + this._id + ":" + text); - } - }, { - _ClassName: { - navbar: "win-navbar" - }, - _EventName: { - childrenProcessed: childrenProcessedEventName - }, - isDeclarativeControlContainer: _BaseUtils.markSupportedForProcessing(function (navbar, callback) { - if (navbar._processed) { - for (var i = 0, len = navbar.element.children.length; i < len; i++) { - callback(navbar.element.children[i]); - } - } else { - navbar._processors = navbar._processors || []; - navbar._processors.push(callback); - } - }) - }); - - return NavBar; - }) - }); - -}); - -define('require-style!less/styles-viewbox',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -// ViewBox control -define('WinJS/Controls/ViewBox',[ - '../Core/_Global', - '../Core/_Base', - '../Core/_BaseUtils', - '../Core/_ErrorFromName', - '../Core/_Resources', - '../Scheduler', - '../Utilities/_Control', - '../Utilities/_Dispose', - '../Utilities/_ElementUtilities', - '../Utilities/_Hoverable', - 'require-style!less/styles-viewbox' - ], function viewboxInit(_Global, _Base, _BaseUtils, _ErrorFromName, _Resources, Scheduler, _Control, _Dispose, _ElementUtilities, _Hoverable) { - "use strict"; - - _Base.Namespace.define("WinJS.UI", { - /// - /// - /// Scales a single child element to fill the available space without - /// resizing it. This control reacts to changes in the size of the container as well as - /// changes in size of the child element. For example, a media query may result in - /// a change in aspect ratio. - /// - /// - /// View Box - /// - /// - ///
ViewBox
]]>
- /// - /// - ViewBox: _Base.Namespace._lazy(function () { - - var strings = { - get invalidViewBoxChildren() { return "ViewBox expects to only have one child element"; }, - }; - - function onresize(control) { - if (control && !control._resizing) { - control._resizing = control._resizing || 0; - control._resizing++; - try { - control._updateLayout(); - } finally { - control._resizing--; - } - } - } - - function onresizeBox(ev) { - if (ev.target) { - onresize(ev.target.winControl); - } - } - - function onresizeSizer(ev) { - if (ev.target) { - onresize(ev.target.parentElement.winControl); - } - } - - var ViewBox = _Base.Class.define(function ViewBox_ctor(element) { - /// - /// Initializes a new instance of the ViewBox control - /// - /// The DOM element that functions as the scaling box. This element fills 100% of the width and height allotted to it. - /// - /// - /// The set of options to be applied initially to the ViewBox control. - /// - /// A constructed ViewBox control. - /// - this._disposed = false; - - this._element = element || _Global.document.createElement("div"); - var box = this.element; - box.winControl = this; - _ElementUtilities.addClass(box, "win-disposable"); - _ElementUtilities.addClass(box, "win-viewbox"); - this.forceLayout(); - }, { - _sizer: null, - _element: null, - - /// - element: { - get: function () { return this._element; } - }, - - _rtl: { - get: function () { - return _Global.getComputedStyle(this.element).direction === "rtl"; - } - }, - - _initialize: function () { - var box = this.element; - if (box.firstElementChild !== this._sizer) { - if (_BaseUtils.validation) { - if (box.childElementCount !== 1) { - throw new _ErrorFromName("WinJS.UI.ViewBox.InvalidChildren", strings.invalidViewBoxChildren); - } - } - if (this._sizer) { - this._sizer.onresize = null; - } - var sizer = box.firstElementChild; - this._sizer = sizer; - if (sizer) { - _ElementUtilities._resizeNotifier.subscribe(box, onresizeBox); - box.addEventListener("mselementresize", onresizeBox); - _ElementUtilities._resizeNotifier.subscribe(sizer, onresizeSizer); - sizer.addEventListener("mselementresize", onresizeSizer); - } - if (box.clientWidth === 0 && box.clientHeight === 0) { - var that = this; - // Wait for the viewbox to get added to the DOM. It should be added - // in the synchronous block in which _initialize was called. - Scheduler.schedule(function ViewBox_async_initialize() { - that._updateLayout(); - }, Scheduler.Priority.normal, null, "WinJS.UI.ViewBox._updateLayout"); - } - } - }, - _updateLayout: function () { - var sizer = this._sizer; - if (sizer) { - var box = this.element; - var w = sizer.clientWidth; - var h = sizer.clientHeight; - var bw = box.clientWidth; - var bh = box.clientHeight; - var wRatio = bw / w; - var hRatio = bh / h; - var mRatio = Math.min(wRatio, hRatio); - var transX = Math.abs(bw - (w * mRatio)) / 2; - var transY = Math.abs(bh - (h * mRatio)) / 2; - var rtl = this._rtl; - this._sizer.style[_BaseUtils._browserStyleEquivalents["transform"].scriptName] = "translate(" + (rtl ? "-" : "") + transX + "px," + transY + "px) scale(" + mRatio + ")"; - this._sizer.style[_BaseUtils._browserStyleEquivalents["transform-origin"].scriptName] = rtl ? "top right" : "top left"; - } - }, - - dispose: function () { - /// - /// - /// Disposes this ViewBox. - /// - /// - if (this._disposed) { - return; - } - - if (this.element) { - _ElementUtilities._resizeNotifier.unsubscribe(this.element, onresizeBox); - } - if (this._sizer) { - _ElementUtilities._resizeNotifier.unsubscribe(this._sizer, onresizeSizer); - } - - this._disposed = true; - _Dispose.disposeSubTree(this._element); - }, - - forceLayout: function () { - this._initialize(); - this._updateLayout(); - } - }); - _Base.Class.mix(ViewBox, _Control.DOMEventMixin); - return ViewBox; - }) - }); - -}); - - -define('require-style!less/styles-contentdialog',[],function(){}); - -define('require-style!less/colors-contentdialog',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('WinJS/Controls/ContentDialog',[ - '../Application', - '../Utilities/_Dispose', - '../_Accents', - '../Promise', - '../_Signal', - '../_LightDismissService', - '../Core/_BaseUtils', - '../Core/_Global', - '../Core/_WinRT', - '../Core/_Base', - '../Core/_Events', - '../Core/_ErrorFromName', - '../Core/_Resources', - '../Utilities/_Control', - '../Utilities/_ElementUtilities', - '../Utilities/_Hoverable', - '../Animations', - 'require-style!less/styles-contentdialog', - 'require-style!less/colors-contentdialog' -], function contentDialogInit(Application, _Dispose, _Accents, Promise, _Signal, _LightDismissService, _BaseUtils, _Global, _WinRT, _Base, _Events, _ErrorFromName, _Resources, _Control, _ElementUtilities, _Hoverable, _Animations) { - "use strict"; - - _Accents.createAccentRule(".win-contentdialog-dialog", [{ name: "outline-color", value: _Accents.ColorTypes.accent }]); - - _Base.Namespace.define("WinJS.UI", { - /// - /// - /// Displays a modal dialog which can display arbitrary HTML content. - /// - /// - /// - /// - /// ]]> - /// Raised just before showing a dialog. Call preventDefault on this event to stop the dialog from being shown. - /// Raised immediately after a dialog is fully shown. - /// Raised just before hiding a dialog. Call preventDefault on this event to stop the dialog from being hidden. - /// Raised immediately after a dialog is fully hidden. - /// The entire ContentDialog control. - /// The full screen element which dims the content that is behind the dialog. - /// The main element of the dialog which holds the dialog's title, content, and commands. - /// The element which displays the dialog's title. - /// The element which contains the dialog's custom content. - /// The element which contains the dialog's primary and secondary commands. - /// The dialog's primary button. - /// The dialog's secondary button. - /// - /// - ContentDialog: _Base.Namespace._lazy(function () { - var Strings = { - get duplicateConstruction() { return "Invalid argument: Controls may only be instantiated one time for each DOM element"; }, - get controlDisposed() { return "Cannot interact with the control after it has been disposed"; }, - get contentDialogAlreadyShowing() { return "Cannot show a ContentDialog if there is already a ContentDialog that is showing"; } - }; - var DismissalResult = { - /// - /// The dialog was dismissed without the user selecting any of the commands. The user may have - /// dismissed the dialog by hitting the escape key or pressing the hardware back button. - /// - none: "none", - /// - /// The user dismissed the dialog by pressing the primary command. - /// - primary: "primary", - /// - /// The user dismissed the dialog by pressing the secondary command. - /// - secondary: "secondary" - }; - var ClassNames = { - contentDialog: "win-contentdialog", - backgroundOverlay: "win-contentdialog-backgroundoverlay", - dialog: "win-contentdialog-dialog", - title: "win-contentdialog-title", - content: "win-contentdialog-content", - commands: "win-contentdialog-commands", - primaryCommand: "win-contentdialog-primarycommand", - secondaryCommand: "win-contentdialog-secondarycommand", - - _verticalAlignment: "win-contentdialog-verticalalignment", - _scroller: "win-contentdialog-scroller", - _column0or1: "win-contentdialog-column0or1", - _visible: "win-contentdialog-visible", - _tabStop: "win-contentdialog-tabstop", - _commandSpacer: "win-contentdialog-commandspacer" - }; - var EventNames = { - beforeShow: "beforeshow", - afterShow: "aftershow", - beforeHide: "beforehide", - afterHide: "afterhide", - }; - var minContentHeightWithInputPane = 96; - - // WinJS animation promises always complete successfully. This - // helper allows an animation promise to complete in the canceled state - // so that the success handler can be skipped when the animation is - // interrupted. - function cancelablePromise(animationPromise) { - return Promise._cancelBlocker(animationPromise, function () { - animationPromise.cancel(); - }); - } - - function onInputPaneShown(eventObject) { - /*jshint validthis: true */ - eventObject.ensuredFocusedElementInView = true; - this.dialog._renderForInputPane(eventObject.occludedRect.height); - } - - function onInputPaneHidden() { - /*jshint validthis: true */ - this.dialog._clearInputPaneRendering(); - } - - // Noop function, used in the various states to indicate that they don't support a given - // message. Named with the somewhat cute name '_' because it reads really well in the states. - - function _() { } - - // Implementing the control as a state machine helps us correctly handle: - // - re-entrancy while firing events - // - calls into the control during asynchronous operations (e.g. animations) - // - // Many of the states do their "enter" work within a promise chain. The idea is that if - // the state is interrupted and exits, the rest of its work can be skipped by canceling - // the promise chain. - // An interesting detail is that anytime the state may call into app code (e.g. due to - // firing an event), the current promise must end and a new promise must be chained off of it. - // This is necessary because the app code may interact with the ContentDialog and cause it to - // change states. If we didn't create a new promise, then the very next line of code that runs - // after calling into app code may not be valid because the state may have exited. Starting a - // new promise after each call into app code prevents us from having to worry about this - // problem. In this configuration, when a promise's success handler runs, it guarantees that - // the state hasn't exited. - // For similar reasons, each of the promise chains created in "enter" starts off with a _Signal - // which is completed at the end of the "enter" function (this boilerplate is abstracted away by - // the "interruptible" function). The reason is that we don't want any of the code in "enter" - // to run until the promise chain has been stored in a variable. If we didn't do this (e.g. instead, - // started the promise chain with Promise.wrap()), then the "enter" code could trigger the "exit" - // function (via app code) before the promise chain had been stored in a variable. Under these - // circumstances, the promise chain would be uncancelable and so the "enter" work would be - // unskippable. This wouldn't be good when we needed the state to exit early. - - // These two functions manage interruptible work promises (one creates them the other cancels - // them). They communicate with each other thru the _interruptibleWorkPromises property which - // "interruptible" creates on your object. - - function interruptible(object, workFn) { - object._interruptibleWorkPromises = object._interruptibleWorkPromises || []; - var workStoredSignal = new _Signal(); - object._interruptibleWorkPromises.push(workFn(object, workStoredSignal.promise)); - workStoredSignal.complete(); - } - - function cancelInterruptibles() { - /*jshint validthis: true */ - (this._interruptibleWorkPromises || []).forEach(function (workPromise) { - workPromise.cancel(); - }); - } - - // Transitions: - // When created, the control will take the following initialization transition: - // Init -> Hidden - // Following that, the life of the dialog will be dominated by the following 3 - // sequences of transitions. In geneneral, these sequences are uninterruptible. - // Hidden -> BeforeShow -> Hidden (when preventDefault is called on beforeshow event) - // Hidden -> BeforeShow -> Showing -> Shown - // Shown -> BeforeHide -> Hiding -> Hidden - // Shown -> BeforeHide -> Shown (when preventDefault is called on beforehide event) - // However, any state can be interrupted to go to the Disposed state: - // * -> Disposed - // - // interface IContentDialogState { - // // Debugging - // name: string; - // // State lifecycle - // enter(arg0); - // exit(); - // // ContentDialog's public API surface - // hidden: boolean; - // show(); - // hide(dismissalResult); - // // Events - // onCommandClicked(dismissalResult); - // onInputPaneShown(eventObject); - // onInputPaneHidden(); - // // Provided by _setState for use within the state - // dialog: WinJS.UI.ContentDialog; - // } - - var States = { - // Initial state. Initializes state on the dialog shared by the various states. - Init: _Base.Class.define(null, { - name: "Init", - hidden: true, - enter: function ContentDialog_InitState_enter() { - var dialog = this.dialog; - dialog._dismissable = new _LightDismissService.ModalElement({ - element: dialog._dom.root, - tabIndex: dialog._dom.root.hasAttribute("tabIndex") ? dialog._dom.root.tabIndex : -1, - onLightDismiss: function () { - dialog.hide(DismissalResult.none); - }, - onTakeFocus: function (useSetActive) { - dialog._dismissable.restoreFocus() || - _ElementUtilities._focusFirstFocusableElement(dialog._dom.content) || - _ElementUtilities._tryFocusOnAnyElement(dialog._dom.dialog, useSetActive); - } - }); - this.dialog._dismissedSignal = null; // The signal will be created on demand when show() is called - this.dialog._setState(States.Hidden, false); - }, - exit: _, - show: function ContentDialog_InitState_show() { - throw "It's illegal to call show on the Init state"; - }, - hide: _, - onCommandClicked: _, - onInputPaneShown: _, - onInputPaneHidden: _ - }), - // A rest state. The dialog is hidden and is waiting for the app to call show. - Hidden: _Base.Class.define(null, { - name: "Hidden", - hidden: true, - enter: function ContentDialog_HiddenState_enter(showIsPending) { - if (showIsPending) { - this.show(); - } - }, - exit: _, - show: function ContentDialog_HiddenState_show() { - var dismissedSignal = this.dialog._dismissedSignal = new _Signal(); // save the signal in case it changes when switching states - this.dialog._setState(States.BeforeShow); - return dismissedSignal.promise; - }, - hide: _, - onCommandClicked: _, - onInputPaneShown: _, - onInputPaneHidden: _ - }), - // An event state. The dialog fires the beforeshow event. - BeforeShow: _Base.Class.define(null, { - name: "BeforeShow", - hidden: true, - enter: function ContentDialog_BeforeShowState_enter() { - interruptible(this, function (that, ready) { - return ready.then(function () { - return that.dialog._fireBeforeShow(); // Give opportunity for chain to be canceled when calling into app code - }).then(function (shouldShow) { - if (!shouldShow) { - that.dialog._cancelDismissalPromise(null); // Give opportunity for chain to be canceled when calling into app code - } - return shouldShow; - }).then(function (shouldShow) { - if (shouldShow) { - that.dialog._setState(States.Showing); - } else { - that.dialog._setState(States.Hidden, false); - } - }); - }); - }, - exit: cancelInterruptibles, - show: function ContentDialog_BeforeShowState_show() { - return Promise.wrapError(new _ErrorFromName("WinJS.UI.ContentDialog.ContentDialogAlreadyShowing", Strings.contentDialogAlreadyShowing)); - }, - hide: _, - onCommandClicked: _, - onInputPaneShown: _, - onInputPaneHidden: _ - }), - // An animation/event state. The dialog plays its entrance animation and fires aftershow. - Showing: _Base.Class.define(null, { - name: "Showing", - hidden: { - get: function ContentDialog_ShowingState_hidden_get() { - return !!this._pendingHide; - } - }, - enter: function ContentDialog_ShowingState_enter() { - interruptible(this, function (that, ready) { - return ready.then(function () { - that._pendingHide = null; - _ElementUtilities.addClass(that.dialog._dom.root, ClassNames._visible); - that.dialog._addExternalListeners(); - if (_WinRT.Windows.UI.ViewManagement.InputPane) { - var inputPaneHeight = _WinRT.Windows.UI.ViewManagement.InputPane.getForCurrentView().occludedRect.height; - if (inputPaneHeight > 0) { - that.dialog._renderForInputPane(inputPaneHeight); - } - } - _LightDismissService.shown(that.dialog._dismissable); - return that.dialog._playEntranceAnimation(); - }).then(function () { - that.dialog._fireEvent(EventNames.afterShow); // Give opportunity for chain to be canceled when calling into app code - }).then(function () { - that.dialog._setState(States.Shown, that._pendingHide); - }); - }); - }, - exit: cancelInterruptibles, - show: function ContentDialog_ShowingState_show() { - if (this._pendingHide) { - var dismissalResult = this._pendingHide.dismissalResult; - this._pendingHide = null; - return this.dialog._resetDismissalPromise(dismissalResult, new _Signal()).promise; - } else { - return Promise.wrapError(new _ErrorFromName("WinJS.UI.ContentDialog.ContentDialogAlreadyShowing", Strings.contentDialogAlreadyShowing)); - } - }, - hide: function ContentDialog_ShowingState_hide(dismissalResult) { - this._pendingHide = { dismissalResult: dismissalResult }; - }, - onCommandClicked: _, - onInputPaneShown: onInputPaneShown, - onInputPaneHidden: onInputPaneHidden - }), - // A rest state. The dialog is shown and is waiting for the user or the app to trigger hide. - Shown: _Base.Class.define(null, { - name: "Shown", - hidden: false, - enter: function ContentDialog_ShownState_enter(pendingHide) { - if (pendingHide) { - this.hide(pendingHide.dismissalResult); - } - }, - exit: _, - show: function ContentDialog_ShownState_show() { - return Promise.wrapError(new _ErrorFromName("WinJS.UI.ContentDialog.ContentDialogAlreadyShowing", Strings.contentDialogAlreadyShowing)); - }, - hide: function ContentDialog_ShownState_hide(dismissalResult) { - this.dialog._setState(States.BeforeHide, dismissalResult); - }, - onCommandClicked: function ContentDialog_ShownState_onCommandClicked(dismissalResult) { - this.hide(dismissalResult); - }, - onInputPaneShown: onInputPaneShown, - onInputPaneHidden: onInputPaneHidden - }), - // An event state. The dialog fires the beforehide event. - BeforeHide: _Base.Class.define(null, { - name: "BeforeHide", - hidden: false, - enter: function ContentDialog_BeforeHideState_enter(dismissalResult) { - interruptible(this, function (that, ready) { - return ready.then(function () { - return that.dialog._fireBeforeHide(dismissalResult); // Give opportunity for chain to be canceled when calling into app code - }).then(function (shouldHide) { - if (shouldHide) { - that.dialog._setState(States.Hiding, dismissalResult); - } else { - that.dialog._setState(States.Shown, null); - } - }); - }); - }, - exit: cancelInterruptibles, - show: function ContentDialog_BeforeHideState_show() { - return Promise.wrapError(new _ErrorFromName("WinJS.UI.ContentDialog.ContentDialogAlreadyShowing", Strings.contentDialogAlreadyShowing)); - }, - hide: _, - onCommandClicked: _, - onInputPaneShown: onInputPaneShown, - onInputPaneHidden: onInputPaneHidden - }), - // An animation/event state. The dialog plays the exit animation and fires the afterhide event. - Hiding: _Base.Class.define(null, { - name: "Hiding", - hidden: { - get: function ContentDialog_HidingState_hidden_get() { - return !this._showIsPending; - } - }, - enter: function ContentDialog_HidingState_enter(dismissalResult) { - interruptible(this, function (that, ready) { - return ready.then(function () { - that._showIsPending = false; - that.dialog._resetDismissalPromise(dismissalResult, null); // Give opportunity for chain to be canceled when calling into app code - }).then(function () { - return that.dialog._playExitAnimation(); - }).then(function () { - that.dialog._removeExternalListeners(); - _LightDismissService.hidden(that.dialog._dismissable); - _ElementUtilities.removeClass(that.dialog._dom.root, ClassNames._visible); - that.dialog._clearInputPaneRendering(); - that.dialog._fireAfterHide(dismissalResult); // Give opportunity for chain to be canceled when calling into app code - }).then(function () { - that.dialog._setState(States.Hidden, that._showIsPending); - }); - }); - }, - exit: cancelInterruptibles, - show: function ContentDialog_HidingState_show() { - if (this._showIsPending) { - return Promise.wrapError(new _ErrorFromName("WinJS.UI.ContentDialog.ContentDialogAlreadyShowing", Strings.contentDialogAlreadyShowing)); - } else { - this._showIsPending = true; - this.dialog._dismissedSignal = new _Signal(); - return this.dialog._dismissedSignal.promise; - } - }, - hide: function ContentDialog_HidingState_hide(dismissalResult) { - if (this._showIsPending) { - this._showIsPending = false; - this.dialog._resetDismissalPromise(dismissalResult, null); - } - }, - onCommandClicked: _, - onInputPaneShown: _, - onInputPaneHidden: _ - }), - Disposed: _Base.Class.define(null, { - name: "Disposed", - hidden: true, - enter: function ContentDialog_DisposedState_enter() { - _LightDismissService.hidden(this.dialog._dismissable); - this.dialog._removeExternalListeners(); - if (this.dialog._dismissedSignal) { - this.dialog._dismissedSignal.error(new _ErrorFromName("WinJS.UI.ContentDialog.ControlDisposed", Strings.controlDisposed)); - } - }, - exit: _, - show: function ContentDialog_DisposedState_show() { - return Promise.wrapError(new _ErrorFromName("WinJS.UI.ContentDialog.ControlDisposed", Strings.controlDisposed)); - }, - hide: _, - onCommandClicked: _, - onInputPaneShown: _, - onInputPaneHidden: _ - }), - }; - - var ContentDialog = _Base.Class.define(function ContentDialog_ctor(element, options) { - /// - /// - /// Creates a new ContentDialog control. - /// - /// - /// The DOM element that hosts the ContentDialog control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". For example, to provide a handler for the beforehide event, - /// add a property named "onbeforehide" to the options object and set its value to the event handler. - /// - /// - /// The new ContentDialog. - /// - /// - - // Check to make sure we weren't duplicated - if (element && element.winControl) { - throw new _ErrorFromName("WinJS.UI.ContentDialog.DuplicateConstruction", Strings.duplicateConstruction); - } - options = options || {}; - - this._onInputPaneShownBound = this._onInputPaneShown.bind(this); - this._onInputPaneHiddenBound = this._onInputPaneHidden.bind(this); - - this._disposed = false; - this._resizedForInputPane = false; - this._currentFocus = null; - - this._initializeDom(element || _Global.document.createElement("div")); - this._setState(States.Init); - - this.title = ""; - this.primaryCommandText = ""; - this.primaryCommandDisabled = false; - this.secondaryCommandText = ""; - this.secondaryCommandDisabled = false; - - _Control.setOptions(this, options); - }, { - /// - element: { - get: function ContentDialog_element_get() { - return this._dom.root; - } - }, - - /// - /// The text displayed as the title of the dialog. - /// - title: { - get: function ContentDialog_title_get() { - return this._title; - }, - set: function ContentDialog_title_set(value) { - value = value || ""; - if (this._title !== value) { - this._title = value; - this._dom.title.textContent = value; - this._dom.title.style.display = value ? "" : "none"; - } - } - }, - - /// - /// The text displayed on the primary command's button. - /// - primaryCommandText: { - get: function ContentDialog_primaryCommandText_get() { - return this._primaryCommandText; - }, - set: function ContentDialog_primaryCommandText_set(value) { - value = value || ""; - if (this._primaryCommandText !== value) { - this._primaryCommandText = value; - this._dom.commands[0].textContent = value; - this._updateCommandsUI(); - } - } - }, - - /// - /// The text displayed on the secondary command's button. - /// - secondaryCommandText: { - get: function ContentDialog_secondaryCommandText_get() { - return this._secondaryCommandText; - }, - set: function ContentDialog_secondaryCommandText_set(value) { - value = value || ""; - if (this._secondaryCommandText !== value) { - this._secondaryCommandText = value; - this._dom.commands[1].textContent = value; - this._updateCommandsUI(); - } - } - }, - - /// - /// Indicates whether the button representing the primary command is currently disabled. - /// - primaryCommandDisabled: { - get: function ContentDialog_primaryCommandDisabled_get() { - return this._primaryCommandDisabled; - }, - set: function ContentDialog_primaryCommandDisabled_set(value) { - value = !!value; - if (this._primaryCommandDisabled !== value) { - this._primaryCommandDisabled = value; - this._dom.commands[0].disabled = value; - } - } - }, - - /// - /// Indicates whether the button representing the secondary command is currently disabled. - /// - secondaryCommandDisabled: { - get: function ContentDialog_secondaryCommandDisabled_get() { - return this._secondaryCommandDisabled; - }, - set: function ContentDialog_secondaryCommandDisabled_set(value) { - value = !!value; - if (this._secondaryCommandDisabled !== value) { - this._secondaryCommandDisabled = value; - this._dom.commands[1].disabled = value; - } - } - }, - - /// - hidden: { - get: function ContentDialog_hidden_get() { - return this._state.hidden; - }, - set: function ContentDialog_hidden_set(hidden) { - if (!hidden && this._state.hidden) { - var nop = function () { - }; - // Show returns a promise. If hidden is set while the ContentDialog is disposed, show will return a promise - // error which will be impossible to handle and it'll cause the app to terminate. We'll eat the promise returned by show - // to stop that from happening. - this.show().done(nop, nop); - } else if (hidden && !this._state.hidden) { - this.hide(DismissalResult.none); - } - } - }, - - dispose: function ContentDialog_dispose() { - /// - /// - /// Disposes this control. - /// - /// - if (this._disposed) { - return; - } - this._setState(States.Disposed); - this._disposed = true; - _Dispose._disposeElement(this._dom.content); - }, - - show: function ContentDialog_show() { - /// - /// - /// Shows the ContentDialog. Only one ContentDialog may be shown at a time. If another - /// ContentDialog is already shown, this ContentDialog will remain hidden. - /// - /// - /// A promise which is successfully fulfilled when the dialog is dismissed. The - /// completion value indicates the dialog's dismissal result. This may - /// be 'primary', 'secondary', 'none', or whatever custom value was passed to hide. - /// If this ContentDialog cannot be shown because a ContentDialog is already showing - /// or the ContentDialog is disposed, then the return value is a promise which is in - /// an error state. If preventDefault() is called on the beforeshow event, then this - /// promise will be canceled. - /// - /// - return this._state.show(); - }, - - hide: function ContentDialog_hide(result) { - /// - /// - /// Hides the ContentDialog. - /// - /// - /// A value indicating why the dialog is being hidden. The promise returned - /// by show will be fulfilled with this value. - /// - /// - this._state.hide(result === undefined ? DismissalResult.none : result); - }, - - _initializeDom: function ContentDialog_initializeDom(root) { - // Reparent the children of the root element into the content element. - var contentEl = _Global.document.createElement("div"); - contentEl.className = ClassNames.content; - _ElementUtilities._reparentChildren(root, contentEl); - - root.winControl = this; - _ElementUtilities.addClass(root, ClassNames.contentDialog); - _ElementUtilities.addClass(root, ClassNames._verticalAlignment); - _ElementUtilities.addClass(root, "win-disposable"); - root.innerHTML = - '
' + - '
' + - '' + - '
' + - '
'; - - var dom = {}; - dom.root = root; - dom.backgroundOverlay = dom.root.firstElementChild; - dom.startBodyTab = dom.backgroundOverlay.nextElementSibling; - dom.dialog = dom.startBodyTab.nextElementSibling; - dom.title = dom.dialog.firstElementChild; - dom.scroller = dom.title.nextElementSibling; - dom.commandContainer = dom.scroller.nextElementSibling; - dom.commandSpacer = dom.commandContainer.firstElementChild; - dom.commands = []; - dom.commands.push(dom.commandSpacer.nextElementSibling); - dom.commands.push(dom.commands[0].nextElementSibling); - dom.endBodyTab = dom.dialog.nextElementSibling; - dom.content = contentEl; - this._dom = dom; - - // Put the developer's content into the scroller - dom.scroller.appendChild(dom.content); - - _ElementUtilities._ensureId(dom.title); - _ElementUtilities._ensureId(dom.startBodyTab); - _ElementUtilities._ensureId(dom.endBodyTab); - dom.dialog.setAttribute("aria-labelledby", dom.title.id); - dom.startBodyTab.setAttribute("x-ms-aria-flowfrom", dom.endBodyTab.id); - dom.endBodyTab.setAttribute("aria-flowto", dom.startBodyTab.id); - this._updateTabIndices(); - - dom.root.addEventListener("keydown", this._onKeyDownEnteringElement.bind(this), true); - _ElementUtilities._addEventListener(dom.root, "pointerdown", this._onPointerDown.bind(this)); - _ElementUtilities._addEventListener(dom.root, "pointerup", this._onPointerUp.bind(this)); - dom.root.addEventListener("click", this._onClick.bind(this)); - _ElementUtilities._addEventListener(dom.startBodyTab, "focusin", this._onStartBodyTabFocusIn.bind(this)); - _ElementUtilities._addEventListener(dom.endBodyTab, "focusin", this._onEndBodyTabFocusIn.bind(this)); - dom.commands[0].addEventListener("click", this._onCommandClicked.bind(this, DismissalResult.primary)); - dom.commands[1].addEventListener("click", this._onCommandClicked.bind(this, DismissalResult.secondary)); - }, - - _updateCommandsUI: function ContentDialog_updateCommandsUI() { - this._dom.commands[0].style.display = this.primaryCommandText ? "" : "none"; - this._dom.commands[1].style.display = this.secondaryCommandText ? "" : "none"; - - // commandSpacer's purpose is to ensure that when only 1 button is shown, that button takes up half - // the width of the dialog and is right-aligned. It works by: - // - When only one command is shown: - // - Coming before the other command in the DOM (so the other command will look right-aligned) - // - Having the same flex-grow as the other command (so it occupies half of the space) - // - Having visibility: hidden (so it's invisible but it takes up space) - // - When both commands are shown: - // - Having display: none (so it doesn't occupy any space and the two shown commands each take up half the dialog) - // - When 0 commands are shown: - // - Having display: none (so the commands area takes up no space) - this._dom.commandSpacer.style.display = this.primaryCommandText && !this.secondaryCommandText || !this.primaryCommandText && this.secondaryCommandText ? "" : "none"; - }, - - // _updateTabIndices and _updateTabIndicesImpl are used in tests - _updateTabIndices: function ContentDialog_updateTabIndices() { - if (!this._updateTabIndicesThrottled) { - this._updateTabIndicesThrottled = _BaseUtils._throttledFunction(100, this._updateTabIndicesImpl.bind(this)); - } - this._updateTabIndicesThrottled(); - }, - _updateTabIndicesImpl: function ContentDialog_updateTabIndicesImpl() { - var tabIndex = _ElementUtilities._getHighAndLowTabIndices(this._dom.content); - this._dom.startBodyTab.tabIndex = tabIndex.lowest; - this._dom.commands[0].tabIndex = tabIndex.highest; - this._dom.commands[1].tabIndex = tabIndex.highest; - this._dom.endBodyTab.tabIndex = tabIndex.highest; - }, - - _elementInDialog: function ContentDialog_elementInDialog(element) { - return this._dom.dialog.contains(element) || element === this._dom.startBodyTab || element === this._dom.endBodyTab; - }, - - _onCommandClicked: function ContentDialog_onCommandClicked(dismissalResult) { - this._state.onCommandClicked(dismissalResult); - }, - - _onPointerDown: function ContentDialog_onPointerDown(eventObject) { - eventObject.stopPropagation(); - if (!this._elementInDialog(eventObject.target)) { - eventObject.preventDefault(); - } - }, - - _onPointerUp: function ContentDialog_onPointerUp(eventObject) { - eventObject.stopPropagation(); - if (!this._elementInDialog(eventObject.target)) { - eventObject.preventDefault(); - } - }, - - _onClick: function ContentDialog_onClick(eventObject) { - eventObject.stopPropagation(); - if (!this._elementInDialog(eventObject.target)) { - eventObject.preventDefault(); - } - }, - - _onKeyDownEnteringElement: function ContentDialog_onKeyDownEnteringElement(eventObject) { - if (eventObject.keyCode === _ElementUtilities.Key.tab) { - this._updateTabIndices(); - } - }, - - _onStartBodyTabFocusIn: function ContentDialog_onStartBodyTabFocusIn() { - _ElementUtilities._focusLastFocusableElement(this._dom.dialog); - }, - - _onEndBodyTabFocusIn: function ContentDialog_onEndBodyTabFocusIn() { - _ElementUtilities._focusFirstFocusableElement(this._dom.dialog); - }, - - _onInputPaneShown: function ContentDialog_onInputPaneShown(eventObject) { - this._state.onInputPaneShown(eventObject.detail.originalEvent); - }, - - _onInputPaneHidden: function ContentDialog_onInputPaneHidden() { - this._state.onInputPaneHidden(); - }, - - // - // Methods called by states - // - - _setState: function ContentDialog_setState(NewState, arg0) { - if (!this._disposed) { - this._state && this._state.exit(); - this._state = new NewState(); - this._state.dialog = this; - this._state.enter(arg0); - } - }, - - // Calls into arbitrary app code - _resetDismissalPromise: function ContentDialog_resetDismissalPromise(dismissalResult, newSignal) { - var dismissedSignal = this._dismissedSignal; - var newDismissedSignal = this._dismissedSignal = newSignal; - dismissedSignal.complete({ result: dismissalResult }); - return newDismissedSignal; - }, - - // Calls into arbitrary app code - _cancelDismissalPromise: function ContentDialog_cancelDismissalPromise(newSignal) { - var dismissedSignal = this._dismissedSignal; - var newDismissedSignal = this._dismissedSignal = newSignal; - dismissedSignal.cancel(); - return newDismissedSignal; - }, - - // Calls into arbitrary app code - _fireEvent: function ContentDialog_fireEvent(eventName, options) { - options = options || {}; - var detail = options.detail || null; - var cancelable = !!options.cancelable; - - var eventObject = _Global.document.createEvent("CustomEvent"); - eventObject.initCustomEvent(eventName, true, cancelable, detail); - return this._dom.root.dispatchEvent(eventObject); - }, - - // Calls into arbitrary app code - _fireBeforeShow: function ContentDialog_fireBeforeShow() { - return this._fireEvent(EventNames.beforeShow, { - cancelable: true - }); - }, - - // Calls into arbitrary app code - _fireBeforeHide: function ContentDialog_fireBeforeHide(dismissalResult) { - return this._fireEvent(EventNames.beforeHide, { - detail: { result: dismissalResult }, - cancelable: true - }); - }, - - // Calls into arbitrary app code - _fireAfterHide: function ContentDialog_fireAfterHide(dismissalResult) { - this._fireEvent(EventNames.afterHide, { - detail: { result: dismissalResult } - }); - }, - - _playEntranceAnimation: function ContentDialog_playEntranceAnimation() { - return cancelablePromise(_Animations.fadeIn(this._dom.root)); - }, - - _playExitAnimation: function ContentDialog_playExitAnimation() { - return cancelablePromise(_Animations.fadeOut(this._dom.root)); - }, - - _addExternalListeners: function ContentDialog_addExternalListeners() { - _ElementUtilities._inputPaneListener.addEventListener(this._dom.root, "showing", this._onInputPaneShownBound); - _ElementUtilities._inputPaneListener.addEventListener(this._dom.root, "hiding", this._onInputPaneShownBound); - }, - - _removeExternalListeners: function ContentDialog_removeExternalListeners() { - _ElementUtilities._inputPaneListener.removeEventListener(this._dom.root, "showing", this._onInputPaneShownBound); - _ElementUtilities._inputPaneListener.removeEventListener(this._dom.root, "hiding", this._onInputPaneShownBound); - }, - - _renderForInputPane: function ContentDialog_renderForInputPane(inputPaneHeight) { - this._clearInputPaneRendering(); - - var dialog = this._dom.dialog; - var style = dialog.style; - var left = dialog.offsetLeft; - var top = dialog.offsetTop; - var height = dialog.offsetHeight; - var bottom = top + height; - var visibleBottom = this._dom.root.offsetHeight - inputPaneHeight; - var titleHeight = _ElementUtilities.getTotalHeight(this._dom.title); - var commandsHeight = _ElementUtilities.getTotalHeight(this._dom.commandContainer); - - if (bottom > visibleBottom) { - var newHeight = height - (bottom - visibleBottom); - if (newHeight - titleHeight - commandsHeight < minContentHeightWithInputPane) { - // Put title into scroller so there's more screen real estate for the content - this._dom.scroller.insertBefore(this._dom.title, this._dom.content); - } - - this._dom.root.style.display = "block"; - style.height = newHeight + "px"; - style.position = "absolute"; - style.left = left + "px"; - style.top = top + "px"; - style.minHeight = 0; - - this._resizedForInputPane = true; - _Global.document.activeElement.focus(); // Ensure activeElement is scrolled into view - } - }, - - _clearInputPaneRendering: function ContentDialog_clearInputPaneRendering() { - if (this._resizedForInputPane) { - if (this._dom.title.parentNode !== this._dom.dialog) { - // Make sure the title isn't in the scroller - this._dom.dialog.insertBefore(this._dom.title, this._dom.scroller); - } - - var style = this._dom.dialog.style; - this._dom.root.style.display = ""; - style.height = ""; - style.position = ""; - style.left = ""; - style.top = ""; - style.minHeight = ""; - this._resizedForInputPane = false; - } - } - }, { - /// - /// Specifies the result of dismissing the ContentDialog. - /// - DismissalResult: DismissalResult, - - _ClassNames: ClassNames - }); - _Base.Class.mix(ContentDialog, _Events.createEventProperties( - "beforeshow", - "aftershow", - "beforehide", - "afterhide" - )); - _Base.Class.mix(ContentDialog, _Control.DOMEventMixin); - return ContentDialog; - }) - }); -}); - - -define('require-style!less/styles-splitview',[],function(){}); - -define('require-style!less/colors-splitview',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/SplitView/_SplitView',["require", "exports", '../../Animations', '../../Core/_Base', '../../Core/_BaseUtils', '../../Utilities/_Control', '../../Utilities/_Dispose', '../../Utilities/_ElementUtilities', '../../Core/_ErrorFromName', '../../Core/_Events', '../../Core/_Global', '../../_LightDismissService', '../../Utilities/_OpenCloseMachine'], function (require, exports, Animations, _Base, _BaseUtils, _Control, _Dispose, _ElementUtilities, _ErrorFromName, _Events, _Global, _LightDismissService, _OpenCloseMachine) { - require(["require-style!less/styles-splitview"]); - require(["require-style!less/colors-splitview"]); - "use strict"; - var transformNames = _BaseUtils._browserStyleEquivalents["transform"]; - var Strings = { - get duplicateConstruction() { - return "Invalid argument: Controls may only be instantiated one time for each DOM element"; - } - }; - var ClassNames = { - splitView: "win-splitview", - pane: "win-splitview-pane", - content: "win-splitview-content", - // closed/opened - paneClosed: "win-splitview-pane-closed", - paneOpened: "win-splitview-pane-opened", - _panePlaceholder: "win-splitview-paneplaceholder", - _paneWrapper: "win-splitview-panewrapper", - _contentWrapper: "win-splitview-contentwrapper", - // placement - _placementLeft: "win-splitview-placementleft", - _placementRight: "win-splitview-placementright", - _placementTop: "win-splitview-placementtop", - _placementBottom: "win-splitview-placementbottom", - // closed display mode - _closedDisplayNone: "win-splitview-closeddisplaynone", - _closedDisplayInline: "win-splitview-closeddisplayinline", - // opened display mode - _openedDisplayInline: "win-splitview-openeddisplayinline", - _openedDisplayOverlay: "win-splitview-openeddisplayoverlay" - }; - var EventNames = { - beforeOpen: "beforeopen", - afterOpen: "afteropen", - beforeClose: "beforeclose", - afterClose: "afterclose" - }; - var Dimension = { - width: "width", - height: "height" - }; - var ClosedDisplayMode = { - /// - /// When the pane is closed, it is not visible and doesn't take up any space. - /// - none: "none", - /// - /// When the pane is closed, it occupies space leaving less room for the SplitView's content. - /// - inline: "inline" - }; - var OpenedDisplayMode = { - /// - /// When the pane is open, it occupies space leaving less room for the SplitView's content. - /// - inline: "inline", - /// - /// When the pane is open, it doesn't take up any space and it is light dismissable. - /// - overlay: "overlay" - }; - var PanePlacement = { - /// - /// Pane is positioned left of the SplitView's content. - /// - left: "left", - /// - /// Pane is positioned right of the SplitView's content. - /// - right: "right", - /// - /// Pane is positioned above the SplitView's content. - /// - top: "top", - /// - /// Pane is positioned below the SplitView's content. - /// - bottom: "bottom" - }; - var closedDisplayModeClassMap = {}; - closedDisplayModeClassMap[ClosedDisplayMode.none] = ClassNames._closedDisplayNone; - closedDisplayModeClassMap[ClosedDisplayMode.inline] = ClassNames._closedDisplayInline; - var openedDisplayModeClassMap = {}; - openedDisplayModeClassMap[OpenedDisplayMode.overlay] = ClassNames._openedDisplayOverlay; - openedDisplayModeClassMap[OpenedDisplayMode.inline] = ClassNames._openedDisplayInline; - var panePlacementClassMap = {}; - panePlacementClassMap[PanePlacement.left] = ClassNames._placementLeft; - panePlacementClassMap[PanePlacement.right] = ClassNames._placementRight; - panePlacementClassMap[PanePlacement.top] = ClassNames._placementTop; - panePlacementClassMap[PanePlacement.bottom] = ClassNames._placementBottom; - // Versions of add/removeClass that are no ops when called with falsy class names. - function addClass(element, className) { - className && _ElementUtilities.addClass(element, className); - } - function removeClass(element, className) { - className && _ElementUtilities.removeClass(element, className); - } - function rectToThickness(rect, dimension) { - return (dimension === Dimension.width) ? { - content: rect.contentWidth, - total: rect.totalWidth - } : { - content: rect.contentHeight, - total: rect.totalHeight - }; - } - /// - /// - /// Displays a SplitView which renders a collapsable pane next to arbitrary HTML content. - /// - /// - /// - /// - /// ]]> - /// Raised just before opening the pane. Call preventDefault on this event to stop the pane from opening. - /// Raised immediately after the pane is fully opened. - /// Raised just before closing the pane. Call preventDefault on this event to stop the pane from closing. - /// Raised immediately after the pane is fully closed. - /// The entire SplitView control. - /// The element which hosts the SplitView's pane. - /// The element which hosts the SplitView's content. - /// - /// - var SplitView = (function () { - function SplitView(element, options) { - /// - /// - /// Creates a new SplitView control. - /// - /// - /// The DOM element that hosts the SplitView control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". For example, to provide a handler for the beforeclose event, - /// add a property named "onbeforeclose" to the options object and set its value to the event handler. - /// - /// - /// The new SplitView. - /// - /// - var _this = this; - if (options === void 0) { options = {}; } - // State private to _updateDomImpl. No other method should make use of it. - // - // Nothing has been rendered yet so these are all initialized to undefined. Because - // they are undefined, the first time _updateDomImpl is called, they will all be - // rendered. - this._updateDomImpl_rendered = { - paneIsFirst: undefined, - isOpenedMode: undefined, - closedDisplayMode: undefined, - openedDisplayMode: undefined, - panePlacement: undefined, - panePlaceholderWidth: undefined, - panePlaceholderHeight: undefined, - isOverlayShown: undefined - }; - // Check to make sure we weren't duplicated - if (element && element["winControl"]) { - throw new _ErrorFromName("WinJS.UI.SplitView.DuplicateConstruction", Strings.duplicateConstruction); - } - this._initializeDom(element || _Global.document.createElement("div")); - this._machine = new _OpenCloseMachine.OpenCloseMachine({ - eventElement: this._dom.root, - onOpen: function () { - _this._cachedHiddenPaneThickness = null; - var hiddenPaneThickness = _this._getHiddenPaneThickness(); - _this._isOpenedMode = true; - _this._updateDomImpl(); - return _this._playShowAnimation(hiddenPaneThickness); - }, - onClose: function () { - return _this._playHideAnimation(_this._getHiddenPaneThickness()).then(function () { - _this._isOpenedMode = false; - _this._updateDomImpl(); - }); - }, - onUpdateDom: function () { - _this._updateDomImpl(); - }, - onUpdateDomWithIsOpened: function (isOpened) { - _this._isOpenedMode = isOpened; - _this._updateDomImpl(); - } - }); - // Initialize private state. - this._disposed = false; - this._dismissable = new _LightDismissService.LightDismissableElement({ - element: this._dom.paneWrapper, - tabIndex: -1, - onLightDismiss: function () { - _this.closePane(); - }, - onTakeFocus: function (useSetActive) { - _this._dismissable.restoreFocus() || _ElementUtilities._tryFocusOnAnyElement(_this._dom.pane, useSetActive); - } - }); - this._cachedHiddenPaneThickness = null; - // Initialize public properties. - this.paneOpened = false; - this.closedDisplayMode = ClosedDisplayMode.inline; - this.openedDisplayMode = OpenedDisplayMode.overlay; - this.panePlacement = PanePlacement.left; - _Control.setOptions(this, options); - // Exit the Init state. - _ElementUtilities._inDom(this._dom.root).then(function () { - _this._rtl = _Global.getComputedStyle(_this._dom.root).direction === 'rtl'; - _this._machine.exitInit(); - }); - } - Object.defineProperty(SplitView.prototype, "element", { - /// - get: function () { - return this._dom.root; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitView.prototype, "paneElement", { - /// - get: function () { - return this._dom.pane; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitView.prototype, "contentElement", { - /// - get: function () { - return this._dom.content; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitView.prototype, "closedDisplayMode", { - /// - /// Gets or sets the display mode of the SplitView's pane when it is hidden. - /// - get: function () { - return this._closedDisplayMode; - }, - set: function (value) { - if (ClosedDisplayMode[value] && this._closedDisplayMode !== value) { - this._closedDisplayMode = value; - this._cachedHiddenPaneThickness = null; - this._machine.updateDom(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitView.prototype, "openedDisplayMode", { - /// - /// Gets or sets the display mode of the SplitView's pane when it is open. - /// - get: function () { - return this._openedDisplayMode; - }, - set: function (value) { - if (OpenedDisplayMode[value] && this._openedDisplayMode !== value) { - this._openedDisplayMode = value; - this._cachedHiddenPaneThickness = null; - this._machine.updateDom(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitView.prototype, "panePlacement", { - /// - /// Gets or sets the placement of the SplitView's pane. - /// - get: function () { - return this._panePlacement; - }, - set: function (value) { - if (PanePlacement[value] && this._panePlacement !== value) { - this._panePlacement = value; - this._cachedHiddenPaneThickness = null; - this._machine.updateDom(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitView.prototype, "paneOpened", { - /// - get: function () { - return this._machine.opened; - }, - set: function (value) { - this._machine.opened = value; - }, - enumerable: true, - configurable: true - }); - SplitView.prototype.dispose = function () { - /// - /// - /// Disposes this control. - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - this._machine.dispose(); - _LightDismissService.hidden(this._dismissable); - _Dispose._disposeElement(this._dom.pane); - _Dispose._disposeElement(this._dom.content); - }; - SplitView.prototype.openPane = function () { - /// - /// - /// Opens the SplitView's pane. - /// - /// - this._machine.open(); - }; - SplitView.prototype.closePane = function () { - /// - /// - /// Closes the SplitView's pane. - /// - /// - this._machine.close(); - }; - SplitView.prototype._initializeDom = function (root) { - // The first child is the pane - var paneEl = root.firstElementChild || _Global.document.createElement("div"); - _ElementUtilities.addClass(paneEl, ClassNames.pane); - if (!paneEl.hasAttribute("tabIndex")) { - paneEl.tabIndex = -1; - } - // All other children are members of the content - var contentEl = _Global.document.createElement("div"); - _ElementUtilities.addClass(contentEl, ClassNames.content); - var child = paneEl.nextSibling; - while (child) { - var sibling = child.nextSibling; - contentEl.appendChild(child); - child = sibling; - } - // paneWrapper's purpose is to clip the pane during the pane resize animation - var paneWrapperEl = _Global.document.createElement("div"); - paneWrapperEl.className = ClassNames._paneWrapper; - paneWrapperEl.appendChild(paneEl); - var panePlaceholderEl = _Global.document.createElement("div"); - panePlaceholderEl.className = ClassNames._panePlaceholder; - // contentWrapper is an extra element we need to allow heights to be specified as percentages (e.g. height: 100%) - // for elements within the content area. It works around this Chrome bug: - // Issue 428049: 100% height doesn't work on child of a definite-flex-basis flex item (in vertical flex container) - // https://code.google.com/p/chromium/issues/detail?id=428049 - // The workaround is that putting a position: absolute element (_dom.content) within the flex item (_dom.contentWrapper) - // allows percentage heights to work within the absolutely positioned element (_dom.content). - var contentWrapperEl = _Global.document.createElement("div"); - contentWrapperEl.className = ClassNames._contentWrapper; - contentWrapperEl.appendChild(contentEl); - root["winControl"] = this; - _ElementUtilities.addClass(root, ClassNames.splitView); - _ElementUtilities.addClass(root, "win-disposable"); - this._dom = { - root: root, - pane: paneEl, - paneWrapper: paneWrapperEl, - panePlaceholder: panePlaceholderEl, - content: contentEl, - contentWrapper: contentWrapperEl - }; - }; - SplitView.prototype._measureElement = function (element) { - var style = getComputedStyle(element); - var position = _ElementUtilities._getPositionRelativeTo(element, this._dom.root); - var marginLeft = parseInt(style.marginLeft, 10); - var marginTop = parseInt(style.marginTop, 10); - return { - left: position.left - marginLeft, - top: position.top - marginTop, - contentWidth: _ElementUtilities.getContentWidth(element), - contentHeight: _ElementUtilities.getContentHeight(element), - totalWidth: _ElementUtilities.getTotalWidth(element), - totalHeight: _ElementUtilities.getTotalHeight(element) - }; - }; - SplitView.prototype._setContentRect = function (contentRect) { - var contentWrapperStyle = this._dom.contentWrapper.style; - contentWrapperStyle.left = contentRect.left + "px"; - contentWrapperStyle.top = contentRect.top + "px"; - contentWrapperStyle.height = contentRect.contentHeight + "px"; - contentWrapperStyle.width = contentRect.contentWidth + "px"; - }; - // Overridden by tests. - SplitView.prototype._prepareAnimation = function (paneRect, contentRect) { - var paneWrapperStyle = this._dom.paneWrapper.style; - paneWrapperStyle.position = "absolute"; - paneWrapperStyle.left = paneRect.left + "px"; - paneWrapperStyle.top = paneRect.top + "px"; - paneWrapperStyle.height = paneRect.totalHeight + "px"; - paneWrapperStyle.width = paneRect.totalWidth + "px"; - var contentWrapperStyle = this._dom.contentWrapper.style; - contentWrapperStyle.position = "absolute"; - this._setContentRect(contentRect); - }; - // Overridden by tests. - SplitView.prototype._clearAnimation = function () { - var paneWrapperStyle = this._dom.paneWrapper.style; - paneWrapperStyle.position = ""; - paneWrapperStyle.left = ""; - paneWrapperStyle.top = ""; - paneWrapperStyle.height = ""; - paneWrapperStyle.width = ""; - paneWrapperStyle[transformNames.scriptName] = ""; - var contentWrapperStyle = this._dom.contentWrapper.style; - contentWrapperStyle.position = ""; - contentWrapperStyle.left = ""; - contentWrapperStyle.top = ""; - contentWrapperStyle.height = ""; - contentWrapperStyle.width = ""; - contentWrapperStyle[transformNames.scriptName] = ""; - var paneStyle = this._dom.pane.style; - paneStyle.height = ""; - paneStyle.width = ""; - paneStyle[transformNames.scriptName] = ""; - }; - SplitView.prototype._getHiddenContentRect = function (shownContentRect, hiddenPaneThickness, shownPaneThickness) { - if (this.openedDisplayMode === OpenedDisplayMode.overlay) { - return shownContentRect; - } - else { - var placementRight = this._rtl ? PanePlacement.left : PanePlacement.right; - var multiplier = this.panePlacement === placementRight || this.panePlacement === PanePlacement.bottom ? 0 : 1; - var paneDiff = { - content: shownPaneThickness.content - hiddenPaneThickness.content, - total: shownPaneThickness.total - hiddenPaneThickness.total - }; - return this._horizontal ? { - left: shownContentRect.left - multiplier * paneDiff.total, - top: shownContentRect.top, - contentWidth: shownContentRect.contentWidth + paneDiff.content, - contentHeight: shownContentRect.contentHeight, - totalWidth: shownContentRect.totalWidth + paneDiff.total, - totalHeight: shownContentRect.totalHeight - } : { - left: shownContentRect.left, - top: shownContentRect.top - multiplier * paneDiff.total, - contentWidth: shownContentRect.contentWidth, - contentHeight: shownContentRect.contentHeight + paneDiff.content, - totalWidth: shownContentRect.totalWidth, - totalHeight: shownContentRect.totalHeight + paneDiff.total - }; - } - }; - Object.defineProperty(SplitView.prototype, "_horizontal", { - get: function () { - return this.panePlacement === PanePlacement.left || this.panePlacement === PanePlacement.right; - }, - enumerable: true, - configurable: true - }); - SplitView.prototype._getHiddenPaneThickness = function () { - if (this._cachedHiddenPaneThickness === null) { - if (this._closedDisplayMode === ClosedDisplayMode.none) { - this._cachedHiddenPaneThickness = { content: 0, total: 0 }; - } - else { - if (this._isOpenedMode) { - _ElementUtilities.removeClass(this._dom.root, ClassNames.paneOpened); - _ElementUtilities.addClass(this._dom.root, ClassNames.paneClosed); - } - var size = this._measureElement(this._dom.pane); - this._cachedHiddenPaneThickness = rectToThickness(size, this._horizontal ? Dimension.width : Dimension.height); - if (this._isOpenedMode) { - _ElementUtilities.removeClass(this._dom.root, ClassNames.paneClosed); - _ElementUtilities.addClass(this._dom.root, ClassNames.paneOpened); - } - } - } - return this._cachedHiddenPaneThickness; - }; - // Should be called while SplitView is rendered in its opened mode - // Overridden by tests. - SplitView.prototype._playShowAnimation = function (hiddenPaneThickness) { - var _this = this; - var dim = this._horizontal ? Dimension.width : Dimension.height; - var shownPaneRect = this._measureElement(this._dom.pane); - var shownContentRect = this._measureElement(this._dom.content); - var shownPaneThickness = rectToThickness(shownPaneRect, dim); - var hiddenContentRect = this._getHiddenContentRect(shownContentRect, hiddenPaneThickness, shownPaneThickness); - this._prepareAnimation(shownPaneRect, hiddenContentRect); - var playPaneAnimation = function () { - var placementRight = _this._rtl ? PanePlacement.left : PanePlacement.right; - // What percentage of the size change should be skipped? (e.g. let's do the first - // 30% of the size change instantly and then animate the other 70%) - var animationOffsetFactor = 0.3; - var from = hiddenPaneThickness.total + animationOffsetFactor * (shownPaneThickness.total - hiddenPaneThickness.total); - return Animations._resizeTransition(_this._dom.paneWrapper, _this._dom.pane, { - from: from, - to: shownPaneThickness.total, - actualSize: shownPaneThickness.total, - dimension: dim, - anchorTrailingEdge: _this.panePlacement === placementRight || _this.panePlacement === PanePlacement.bottom - }); - }; - var playShowAnimation = function () { - if (_this.openedDisplayMode === OpenedDisplayMode.inline) { - _this._setContentRect(shownContentRect); - } - return playPaneAnimation(); - }; - return playShowAnimation().then(function () { - _this._clearAnimation(); - }); - }; - // Should be called while SplitView is rendered in its opened mode - // Overridden by tests. - SplitView.prototype._playHideAnimation = function (hiddenPaneThickness) { - var _this = this; - var dim = this._horizontal ? Dimension.width : Dimension.height; - var shownPaneRect = this._measureElement(this._dom.pane); - var shownContentRect = this._measureElement(this._dom.content); - var shownPaneThickness = rectToThickness(shownPaneRect, dim); - var hiddenContentRect = this._getHiddenContentRect(shownContentRect, hiddenPaneThickness, shownPaneThickness); - this._prepareAnimation(shownPaneRect, shownContentRect); - var playPaneAnimation = function () { - var placementRight = _this._rtl ? PanePlacement.left : PanePlacement.right; - // What percentage of the size change should be skipped? (e.g. let's do the first - // 30% of the size change instantly and then animate the other 70%) - var animationOffsetFactor = 0.3; - var from = shownPaneThickness.total - animationOffsetFactor * (shownPaneThickness.total - hiddenPaneThickness.total); - return Animations._resizeTransition(_this._dom.paneWrapper, _this._dom.pane, { - from: from, - to: hiddenPaneThickness.total, - actualSize: shownPaneThickness.total, - dimension: dim, - anchorTrailingEdge: _this.panePlacement === placementRight || _this.panePlacement === PanePlacement.bottom - }); - }; - var playHideAnimation = function () { - if (_this.openedDisplayMode === OpenedDisplayMode.inline) { - _this._setContentRect(hiddenContentRect); - } - return playPaneAnimation(); - }; - return playHideAnimation().then(function () { - _this._clearAnimation(); - }); - }; - SplitView.prototype._updateDomImpl = function () { - var rendered = this._updateDomImpl_rendered; - var paneShouldBeFirst = this.panePlacement === PanePlacement.left || this.panePlacement === PanePlacement.top; - if (paneShouldBeFirst !== rendered.paneIsFirst) { - // TODO: restore focus - if (paneShouldBeFirst) { - this._dom.root.appendChild(this._dom.panePlaceholder); - this._dom.root.appendChild(this._dom.paneWrapper); - this._dom.root.appendChild(this._dom.contentWrapper); - } - else { - this._dom.root.appendChild(this._dom.contentWrapper); - this._dom.root.appendChild(this._dom.paneWrapper); - this._dom.root.appendChild(this._dom.panePlaceholder); - } - } - rendered.paneIsFirst = paneShouldBeFirst; - if (rendered.isOpenedMode !== this._isOpenedMode) { - if (this._isOpenedMode) { - _ElementUtilities.removeClass(this._dom.root, ClassNames.paneClosed); - _ElementUtilities.addClass(this._dom.root, ClassNames.paneOpened); - } - else { - _ElementUtilities.removeClass(this._dom.root, ClassNames.paneOpened); - _ElementUtilities.addClass(this._dom.root, ClassNames.paneClosed); - } - } - rendered.isOpenedMode = this._isOpenedMode; - if (rendered.panePlacement !== this.panePlacement) { - removeClass(this._dom.root, panePlacementClassMap[rendered.panePlacement]); - addClass(this._dom.root, panePlacementClassMap[this.panePlacement]); - rendered.panePlacement = this.panePlacement; - } - if (rendered.closedDisplayMode !== this.closedDisplayMode) { - removeClass(this._dom.root, closedDisplayModeClassMap[rendered.closedDisplayMode]); - addClass(this._dom.root, closedDisplayModeClassMap[this.closedDisplayMode]); - rendered.closedDisplayMode = this.closedDisplayMode; - } - if (rendered.openedDisplayMode !== this.openedDisplayMode) { - removeClass(this._dom.root, openedDisplayModeClassMap[rendered.openedDisplayMode]); - addClass(this._dom.root, openedDisplayModeClassMap[this.openedDisplayMode]); - rendered.openedDisplayMode = this.openedDisplayMode; - } - var isOverlayShown = this._isOpenedMode && this.openedDisplayMode === OpenedDisplayMode.overlay; - // panePlaceholder's purpose is to take up the amount of space occupied by the - // hidden pane while the pane is shown in overlay mode. Without this, the content - // would shift as the pane shows and hides in overlay mode. - var width, height; - if (isOverlayShown) { - var hiddenPaneThickness = this._getHiddenPaneThickness(); - if (this._horizontal) { - width = hiddenPaneThickness.total + "px"; - height = ""; - } - else { - width = ""; - height = hiddenPaneThickness.total + "px"; - } - } - else { - width = ""; - height = ""; - } - if (rendered.panePlaceholderWidth !== width || rendered.panePlaceholderHeight !== height) { - var style = this._dom.panePlaceholder.style; - style.width = width; - style.height = height; - rendered.panePlaceholderWidth = width; - rendered.panePlaceholderHeight = height; - } - if (rendered.isOverlayShown !== isOverlayShown) { - if (isOverlayShown) { - _LightDismissService.shown(this._dismissable); - } - else { - _LightDismissService.hidden(this._dismissable); - } - rendered.isOverlayShown = isOverlayShown; - } - }; - /// - /// Display options for a SplitView's pane when it is closed. - /// - SplitView.ClosedDisplayMode = ClosedDisplayMode; - /// - /// Display options for a SplitView's pane when it is open. - /// - SplitView.OpenedDisplayMode = OpenedDisplayMode; - /// - /// Placement options for a SplitView's pane. - /// - SplitView.PanePlacement = PanePlacement; - SplitView.supportedForProcessing = true; - SplitView._ClassNames = ClassNames; - return SplitView; - })(); - exports.SplitView = SplitView; - _Base.Class.mix(SplitView, _Events.createEventProperties(EventNames.beforeOpen, EventNames.afterOpen, EventNames.beforeClose, EventNames.afterClose)); - _Base.Class.mix(SplitView, _Control.DOMEventMixin); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/SplitView',["require", "exports", '../Core/_Base'], function (require, exports, _Base) { - var module = null; - _Base.Namespace.define("WinJS.UI", { - SplitView: { - get: function () { - if (!module) { - require(["./SplitView/_SplitView"], function (m) { - module = m; - }); - } - return module.SplitView; - } - } - }); -}); - - -define('require-style!less/styles-splitviewpanetoggle',[],function(){}); - -define('require-style!less/colors-splitviewpanetoggle',[],function(){}); -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/SplitViewPaneToggle/_SplitViewPaneToggle',["require", "exports", '../../Core/_Base', '../../Utilities/_Control', '../../Utilities/_ElementUtilities', '../../Core/_ErrorFromName', '../../Core/_Events', '../../Core/_Global', '../../Utilities/_KeyboardBehavior', '../../Utilities/_Hoverable'], function (require, exports, _Base, _Control, _ElementUtilities, _ErrorFromName, _Events, _Global, _KeyboardBehavior, _Hoverable) { - _Hoverable.isHoverable; // Force dependency on the hoverable module - require(["require-style!less/styles-splitviewpanetoggle"]); - require(["require-style!less/colors-splitviewpanetoggle"]); - "use strict"; - // This control has 2 modes depending on whether or not the app has provided a SplitView: - // - SplitView not provided - // SplitViewPaneToggle provides button visuals and fires the invoked event. The app - // intends to do everything else: - // - Handle the invoked event - // - Handle the SplitView opening and closing - // - Handle aria-expanded being mutated by UIA (i.e. screen readers) - // - Keep the aria-controls attribute, aria-expanded attribute, and SplitView in sync - // - SplitView is provided via splitView property - // SplitViewPaneToggle keeps the SplitView, the aria-controls attribute, and the - // aria-expands attribute in sync. In this use case, apps typically won't listen - // to the invoked event (but it's still fired). - var ClassNames = { - splitViewPaneToggle: "win-splitviewpanetoggle" - }; - var EventNames = { - // Fires when the user invokes the button with mouse/keyboard/touch. Does not - // fire if the SplitViewPaneToggle's state changes due to UIA (i.e. aria-expanded - // being set) or due to the SplitView pane opening/closing. - invoked: "invoked" - }; - var Strings = { - get duplicateConstruction() { - return "Invalid argument: Controls may only be instantiated one time for each DOM element"; - }, - get badButtonElement() { - return "Invalid argument: The SplitViewPaneToggle's element must be a button element"; - } - }; - // The splitViewElement may not have a winControl associated with it yet in the case - // that the SplitViewPaneToggle was constructed before the SplitView. This may happen - // when WinJS.UI.processAll is used to construct the controls because the order of construction - // depends on the order in which the SplitView and SplitViewPaneToggle appear in the DOM. - function getSplitViewControl(splitViewElement) { - return (splitViewElement && splitViewElement["winControl"]); - } - function getPaneOpened(splitViewElement) { - var splitViewControl = getSplitViewControl(splitViewElement); - return splitViewControl ? splitViewControl.paneOpened : false; - } - /// - /// - /// Displays a button which is used for opening and closing a SplitView's pane. - /// - /// - /// - /// - /// ]]> - /// The SplitViewPaneToggle control itself. - /// - /// - var SplitViewPaneToggle = (function () { - function SplitViewPaneToggle(element, options) { - /// - /// - /// Creates a new SplitViewPaneToggle control. - /// - /// - /// The DOM element that hosts the SplitViewPaneToggle control. - /// - /// - /// An object that contains one or more property/value pairs to apply to the new control. - /// Each property of the options object corresponds to one of the control's properties or events. - /// Event names must begin with "on". For example, to provide a handler for the invoked event, - /// add a property named "oninvoked" to the options object and set its value to the event handler. - /// - /// - /// The new SplitViewPaneToggle. - /// - /// - if (options === void 0) { options = {}; } - // State private to _updateDom. No other method should make use of it. - // - // Nothing has been rendered yet so these are all initialized to undefined. Because - // they are undefined, the first time _updateDom is called, they will all be - // rendered. - this._updateDom_rendered = { - splitView: undefined - }; - // Check to make sure we weren't duplicated - if (element && element["winControl"]) { - throw new _ErrorFromName("WinJS.UI.SplitViewPaneToggle.DuplicateConstruction", Strings.duplicateConstruction); - } - this._onPaneStateSettledBound = this._onPaneStateSettled.bind(this); - this._ariaExpandedMutationObserver = new _ElementUtilities._MutationObserver(this._onAriaExpandedPropertyChanged.bind(this)); - this._initializeDom(element || _Global.document.createElement("button")); - // Private state - this._disposed = false; - // Default values - this.splitView = null; - _Control.setOptions(this, options); - this._initialized = true; - this._updateDom(); - } - Object.defineProperty(SplitViewPaneToggle.prototype, "element", { - /// - get: function () { - return this._dom.root; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(SplitViewPaneToggle.prototype, "splitView", { - /// - get: function () { - return this._splitView; - }, - set: function (splitView) { - this._splitView = splitView; - if (splitView) { - this._opened = getPaneOpened(splitView); - } - this._updateDom(); - }, - enumerable: true, - configurable: true - }); - SplitViewPaneToggle.prototype.dispose = function () { - /// - /// - /// Disposes this control. - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - this._splitView && this._removeListeners(this._splitView); - }; - SplitViewPaneToggle.prototype._initializeDom = function (root) { - if (root.tagName !== "BUTTON") { - throw new _ErrorFromName("WinJS.UI.SplitViewPaneToggle.BadButtonElement", Strings.badButtonElement); - } - root["winControl"] = this; - _ElementUtilities.addClass(root, ClassNames.splitViewPaneToggle); - _ElementUtilities.addClass(root, "win-disposable"); - if (!root.hasAttribute("type")) { - root.type = "button"; - } - new _KeyboardBehavior._WinKeyboard(root); - root.addEventListener("click", this._onClick.bind(this)); - this._dom = { - root: root - }; - }; - SplitViewPaneToggle.prototype._updateDom = function () { - if (!this._initialized || this._disposed) { - return; - } - var rendered = this._updateDom_rendered; - if (this._splitView !== rendered.splitView) { - if (rendered.splitView) { - this._dom.root.removeAttribute("aria-controls"); - this._removeListeners(rendered.splitView); - } - if (this._splitView) { - _ElementUtilities._ensureId(this._splitView); - this._dom.root.setAttribute("aria-controls", this._splitView.id); - this._addListeners(this._splitView); - } - rendered.splitView = this._splitView; - } - // When no SplitView is provided, it's up to the app to manage aria-expanded. - if (this._splitView) { - // Always update aria-expanded and don't cache its most recently rendered value - // in _updateDom_rendered. The reason is that we're not the only ones that update - // aria-expanded. aria-expanded may be changed thru UIA APIs. Consequently, if we - // cached the last value we set in _updateDom_rendered, it may not reflect the current - // value in the DOM. - var expanded = this._opened ? "true" : "false"; - _ElementUtilities._setAttribute(this._dom.root, "aria-expanded", expanded); - // The splitView element may not have a winControl associated with it yet in the case - // that the SplitViewPaneToggle was constructed before the SplitView. This may happen - // when WinJS.UI.processAll is used to construct the controls because the order of construction - // depends on the order in which the SplitView and SplitViewPaneToggle appear in the DOM. - var splitViewControl = getSplitViewControl(this._splitView); - if (splitViewControl) { - splitViewControl.paneOpened = this._opened; - } - } - }; - SplitViewPaneToggle.prototype._addListeners = function (splitViewElement) { - splitViewElement.addEventListener("_openCloseStateSettled", this._onPaneStateSettledBound); - this._ariaExpandedMutationObserver.observe(this._dom.root, { - attributes: true, - attributeFilter: ["aria-expanded"] - }); - }; - SplitViewPaneToggle.prototype._removeListeners = function (splitViewElement) { - splitViewElement.removeEventListener("_openCloseStateSettled", this._onPaneStateSettledBound); - this._ariaExpandedMutationObserver.disconnect(); - }; - SplitViewPaneToggle.prototype._fireEvent = function (eventName) { - var eventObject = _Global.document.createEvent("CustomEvent"); - eventObject.initCustomEvent(eventName, true, false, null); - return this._dom.root.dispatchEvent(eventObject); - }; - // Inputs that change the SplitViewPaneToggle's state - // - SplitViewPaneToggle.prototype._onPaneStateSettled = function (eventObject) { - if (eventObject.target === this._splitView) { - this._opened = getPaneOpened(this._splitView); - this._updateDom(); - } - }; - // Called by tests. - SplitViewPaneToggle.prototype._onAriaExpandedPropertyChanged = function (mutations) { - var ariaExpanded = this._dom.root.getAttribute("aria-expanded") === "true"; - this._opened = ariaExpanded; - this._updateDom(); - }; - SplitViewPaneToggle.prototype._onClick = function (eventObject) { - this._invoked(); - }; - // Called by tests. - SplitViewPaneToggle.prototype._invoked = function () { - if (this._disposed) { - return; - } - if (this._splitView) { - this._opened = !this._opened; - this._updateDom(); - } - this._fireEvent(EventNames.invoked); - }; - SplitViewPaneToggle._ClassNames = ClassNames; - SplitViewPaneToggle.supportedForProcessing = true; - return SplitViewPaneToggle; - })(); - exports.SplitViewPaneToggle = SplitViewPaneToggle; - _Base.Class.mix(SplitViewPaneToggle, _Events.createEventProperties(EventNames.invoked)); - _Base.Class.mix(SplitViewPaneToggle, _Control.DOMEventMixin); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/SplitViewPaneToggle',["require", "exports", '../Core/_Base'], function (require, exports, _Base) { - var module = null; - _Base.Namespace.define("WinJS.UI", { - SplitViewPaneToggle: { - get: function () { - if (!module) { - require(["./SplitViewPaneToggle/_SplitViewPaneToggle"], function (m) { - module = m; - }); - } - return module.SplitViewPaneToggle; - } - } - }); -}); - -define('WinJS/Controls/AppBar/_Constants',["require", "exports", "../CommandingSurface/_Constants"], function (require, exports, _CommandingSurfaceConstants) { - // appbar class names - exports.ClassNames = { - controlCssClass: "win-appbar", - disposableCssClass: "win-disposable", - actionAreaCssClass: "win-appbar-actionarea", - overflowButtonCssClass: "win-appbar-overflowbutton", - spacerCssClass: "win-appbar-spacer", - ellipsisCssClass: "win-appbar-ellipsis", - overflowAreaCssClass: "win-appbar-overflowarea", - contentFlyoutCssClass: "win-appbar-contentflyout", - emptyappbarCssClass: "win-appbar-empty", - menuCssClass: "win-menu", - menuContainsToggleCommandClass: "win-menu-containstogglecommand", - openedClass: "win-appbar-opened", - closedClass: "win-appbar-closed", - noneClass: "win-appbar-closeddisplaynone", - minimalClass: "win-appbar-closeddisplayminimal", - compactClass: "win-appbar-closeddisplaycompact", - fullClass: "win-appbar-closeddisplayfull", - placementTopClass: "win-appbar-top", - placementBottomClass: "win-appbar-bottom", - }; - exports.EventNames = { - // AppBar - beforeOpen: "beforeopen", - afterOpen: "afteropen", - beforeClose: "beforeclose", - afterClose: "afterclose", - // AppBarCommand - commandPropertyMutated: "_commandpropertymutated", - }; - exports.controlMinWidth = _CommandingSurfaceConstants.controlMinWidth; - exports.defaultClosedDisplayMode = "compact"; - exports.defaultOpened = false; - exports.defaultPlacement = "bottom"; - // Constants for commands - exports.typeSeparator = "separator"; - exports.typeContent = "content"; - exports.typeButton = "button"; - exports.typeToggle = "toggle"; - exports.typeFlyout = "flyout"; - exports.commandSelector = ".win-command"; - exports.primaryCommandSection = "primary"; - exports.secondaryCommandSection = "secondary"; -}); - - -define('require-style!less/styles-appbar',[],function(){}); -define('WinJS/Controls/AppBar/_AppBar',["require", "exports", "../../Core/_Base", "../AppBar/_Constants", "../CommandingSurface", "../../Utilities/_Control", "../../Utilities/_Dispose", "../../Utilities/_ElementUtilities", "../../Core/_ErrorFromName", '../../Core/_Events', "../../Core/_Global", '../../Utilities/_KeyboardInfo', '../../_LightDismissService', '../../Promise', "../../Core/_Resources", '../../Utilities/_OpenCloseMachine', "../../Core/_WriteProfilerMark"], function (require, exports, _Base, _Constants, _CommandingSurface, _Control, _Dispose, _ElementUtilities, _ErrorFromName, _Events, _Global, _KeyboardInfo, _LightDismissService, Promise, _Resources, _OpenCloseMachine, _WriteProfilerMark) { - require(["require-style!less/styles-appbar"]); - "use strict"; - var keyboardInfo = _KeyboardInfo._KeyboardInfo; - var strings = { - get ariaLabel() { - return _Resources._getWinJSString("ui/appBarAriaLabel").value; - }, - get overflowButtonAriaLabel() { - return _Resources._getWinJSString("ui/appBarOverflowButtonAriaLabel").value; - }, - get mustContainCommands() { - return "The AppBar can only contain WinJS.UI.Command or WinJS.UI.AppBarCommand controls"; - }, - get duplicateConstruction() { - return "Invalid argument: Controls may only be instantiated one time for each DOM element"; - } - }; - var ClosedDisplayMode = { - /// - /// When the AppBar is closed, it is not visible and doesn't take up any space. - /// - none: "none", - /// - /// When the AppBar is closed, its height is reduced to the minimal height required to display only its overflowbutton. All other content in the AppBar is not displayed. - /// - minimal: "minimal", - /// - /// When the AppBar is closed, its height is reduced such that button commands are still visible, but their labels are hidden. - /// - compact: "compact", - /// - /// When the AppBar is closed, its height is always sized to content. - /// - full: "full", - }; - var closedDisplayModeClassMap = {}; - closedDisplayModeClassMap[ClosedDisplayMode.none] = _Constants.ClassNames.noneClass; - closedDisplayModeClassMap[ClosedDisplayMode.minimal] = _Constants.ClassNames.minimalClass; - closedDisplayModeClassMap[ClosedDisplayMode.compact] = _Constants.ClassNames.compactClass; - closedDisplayModeClassMap[ClosedDisplayMode.full] = _Constants.ClassNames.fullClass; - var Placement = { - /// - /// The AppBar appears at the top of the main view - /// - top: "top", - /// - /// The AppBar appears at the bottom of the main view - /// - bottom: "bottom", - }; - var placementClassMap = {}; - placementClassMap[Placement.top] = _Constants.ClassNames.placementTopClass; - placementClassMap[Placement.bottom] = _Constants.ClassNames.placementBottomClass; - // Versions of add/removeClass that are no ops when called with falsy class names. - function addClass(element, className) { - className && _ElementUtilities.addClass(element, className); - } - function removeClass(element, className) { - className && _ElementUtilities.removeClass(element, className); - } - /// - /// - /// Represents an appbar for displaying commands. - /// - /// - /// - /// - /// - /// - /// ]]> - /// The entire AppBar control. - /// The appbar overflow button. - /// The container for appbar commands that overflow. - /// - /// - var AppBar = (function () { - function AppBar(element, options) { - /// - /// - /// Creates a new AppBar control. - /// - /// - /// The DOM element that will host the control. - /// - /// - /// The set of properties and values to apply to the new AppBar control. - /// - /// - /// The new AppBar control. - /// - /// - var _this = this; - if (options === void 0) { options = {}; } - // State private to the _updateDomImpl family of method. No other methods should make use of it. - // - // Nothing has been rendered yet so these are all initialized to undefined. Because - // they are undefined, the first time _updateDomImpl is called, they will all be - // rendered. - this._updateDomImpl_renderedState = { - isOpenedMode: undefined, - placement: undefined, - closedDisplayMode: undefined, - adjustedOffsets: { top: undefined, bottom: undefined }, - }; - this._writeProfilerMark("constructor,StartTM"); - // Check to make sure we weren't duplicated - if (element && element["winControl"]) { - throw new _ErrorFromName("WinJS.UI.AppBar.DuplicateConstruction", strings.duplicateConstruction); - } - this._initializeDom(element || _Global.document.createElement("div")); - var stateMachine = new _OpenCloseMachine.OpenCloseMachine({ - eventElement: this.element, - onOpen: function () { - var openAnimation = _this._commandingSurface.createOpenAnimation(_this._getClosedHeight()); - // We're temporarily setting the AppBar's style from position=-ms-device-fixed to fixed to work around an animations bug in IE, - // where two AppBars will end up being rendered when animating instead of one. - // We need to recalculate our offsets relative to the top and bottom of the visible document because position fixed elements use layout viewport coordinates - // while position -ms-device-fixed use visual viewport coordinates.This difference in coordinate systems is especially pronounced if the IHM has caused the visual viewport to resize. - _this.element.style.position = "fixed"; - if (_this._placement === AppBar.Placement.top) { - _this.element.style.top = _KeyboardInfo._KeyboardInfo._layoutViewportCoords.visibleDocTop + "px"; - } - else { - _this.element.style.bottom = _KeyboardInfo._KeyboardInfo._layoutViewportCoords.visibleDocBottom + "px"; - } - _this._synchronousOpen(); - return openAnimation.execute().then(function () { - _this.element.style.position = ""; - _this.element.style.top = _this._adjustedOffsets.top; - _this.element.style.bottom = _this._adjustedOffsets.bottom; - }); - }, - onClose: function () { - var closeAnimation = _this._commandingSurface.createCloseAnimation(_this._getClosedHeight()); - // We're temporarily setting the AppBar's style from position=-ms-device-fixed to fixed to work around an animations bug in IE, - // where two AppBars will end up being rendered when animating instead of one. - // We need to recalculate our offsets relative to the top and bottom of the visible document because position fixed elements use layout viewport coordinates - // while position -ms-device-fixed use visual viewport coordinates.This difference in coordinate systems is especially pronounced if the IHM has caused the visual viewport to resize. - _this.element.style.position = "fixed"; - if (_this._placement === AppBar.Placement.top) { - _this.element.style.top = _KeyboardInfo._KeyboardInfo._layoutViewportCoords.visibleDocTop + "px"; - } - else { - _this.element.style.bottom = _KeyboardInfo._KeyboardInfo._layoutViewportCoords.visibleDocBottom + "px"; - } - return closeAnimation.execute().then(function () { - _this._synchronousClose(); - _this.element.style.position = ""; - _this.element.style.top = _this._adjustedOffsets.top; - _this.element.style.bottom = _this._adjustedOffsets.bottom; - }); - }, - onUpdateDom: function () { - _this._updateDomImpl(); - }, - onUpdateDomWithIsOpened: function (isOpened) { - _this._isOpenedMode = isOpened; - _this._updateDomImpl(); - } - }); - // Events - this._handleShowingKeyboardBound = this._handleShowingKeyboard.bind(this); - this._handleHidingKeyboardBound = this._handleHidingKeyboard.bind(this); - _ElementUtilities._inputPaneListener.addEventListener(this._dom.root, "showing", this._handleShowingKeyboardBound); - _ElementUtilities._inputPaneListener.addEventListener(this._dom.root, "hiding", this._handleHidingKeyboardBound); - // Initialize private state. - this._disposed = false; - this._cachedClosedHeight = null; - this._commandingSurface = new _CommandingSurface._CommandingSurface(this._dom.commandingSurfaceEl, { openCloseMachine: stateMachine }); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-actionarea"), _Constants.ClassNames.actionAreaCssClass); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-overflowarea"), _Constants.ClassNames.overflowAreaCssClass); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-overflowbutton"), _Constants.ClassNames.overflowButtonCssClass); - addClass(this._dom.commandingSurfaceEl.querySelector(".win-commandingsurface-ellipsis"), _Constants.ClassNames.ellipsisCssClass); - this._isOpenedMode = _Constants.defaultOpened; - this._dismissable = new _LightDismissService.LightDismissableElement({ - element: this._dom.root, - tabIndex: this._dom.root.hasAttribute("tabIndex") ? this._dom.root.tabIndex : -1, - onLightDismiss: function () { - _this.close(); - } - }); - // Initialize public properties. - this.closedDisplayMode = _Constants.defaultClosedDisplayMode; - this.placement = _Constants.defaultPlacement; - this.opened = this._isOpenedMode; - _Control.setOptions(this, options); - // Exit the Init state. - _ElementUtilities._inDom(this.element).then(function () { - return _this._commandingSurface.initialized; - }).then(function () { - stateMachine.exitInit(); - _this._writeProfilerMark("constructor,StopTM"); - }); - } - Object.defineProperty(AppBar.prototype, "element", { - /// - get: function () { - return this._dom.root; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AppBar.prototype, "data", { - /// - /// Gets or sets the Binding List of WinJS.UI.Command for the AppBar. - /// - get: function () { - return this._commandingSurface.data; - }, - set: function (value) { - this._commandingSurface.data = value; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AppBar.prototype, "closedDisplayMode", { - /// - /// Gets or sets the closedDisplayMode for the AppBar. Values are "none", "minimal", "compact" and "full". - /// - get: function () { - return this._commandingSurface.closedDisplayMode; - }, - set: function (value) { - if (ClosedDisplayMode[value]) { - this._commandingSurface.closedDisplayMode = value; - this._cachedClosedHeight = null; - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AppBar.prototype, "placement", { - /// - get: function () { - return this._placement; - }, - set: function (value) { - if (Placement[value] && this._placement !== value) { - this._placement = value; - switch (value) { - case Placement.top: - this._commandingSurface.overflowDirection = "bottom"; - break; - case Placement.bottom: - this._commandingSurface.overflowDirection = "top"; - break; - } - this._adjustedOffsets = this._computeAdjustedOffsets(); - this._commandingSurface.deferredDomUpate(); - } - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(AppBar.prototype, "opened", { - /// - get: function () { - return this._commandingSurface.opened; - }, - set: function (value) { - this._commandingSurface.opened = value; - }, - enumerable: true, - configurable: true - }); - AppBar.prototype.open = function () { - /// - /// - /// Opens the AppBar - /// - /// - this._commandingSurface.open(); - }; - AppBar.prototype.close = function () { - /// - /// - /// Closes the AppBar - /// - /// - this._commandingSurface.close(); - }; - AppBar.prototype.dispose = function () { - /// - /// - /// Disposes this AppBar. - /// - /// - if (this._disposed) { - return; - } - this._disposed = true; - _LightDismissService.hidden(this._dismissable); - // Disposing the _commandingSurface will trigger dispose on its OpenCloseMachine - // and synchronously complete any animations that might have been running. - this._commandingSurface.dispose(); - _ElementUtilities._inputPaneListener.removeEventListener(this._dom.root, "showing", this._handleShowingKeyboardBound); - _ElementUtilities._inputPaneListener.removeEventListener(this._dom.root, "hiding", this._handleHidingKeyboardBound); - _Dispose.disposeSubTree(this.element); - }; - AppBar.prototype.forceLayout = function () { - /// - /// - /// Forces the AppBar to update its layout. Use this function when the window did not change size, but the container of the AppBar changed size. - /// - /// - this._commandingSurface.forceLayout(); - }; - AppBar.prototype.getCommandById = function (id) { - /// - /// - /// Retrieves the command with the specified ID from this AppBar. - /// If more than one command is found, this method returns the first command found. - /// - /// Id of the command to return. - /// - /// The command found, or null if no command is found. - /// - /// - return this._commandingSurface.getCommandById(id); - }; - AppBar.prototype.showOnlyCommands = function (commands) { - /// - /// - /// Show the specified commands, hiding all of the others in the AppBar. - /// - /// - /// An array of the commands to show. The array elements may be Command objects, or the string identifiers (IDs) of commands. - /// - /// - return this._commandingSurface.showOnlyCommands(commands); - }; - AppBar.prototype._writeProfilerMark = function (text) { - _WriteProfilerMark("WinJS.UI.AppBar:" + this._id + ":" + text); - }; - AppBar.prototype._initializeDom = function (root) { - this._writeProfilerMark("_intializeDom,info"); - // Attaching JS control to DOM element - root["winControl"] = this; - this._id = root.id || _ElementUtilities._uniqueID(root); - _ElementUtilities.addClass(root, _Constants.ClassNames.controlCssClass); - _ElementUtilities.addClass(root, _Constants.ClassNames.disposableCssClass); - // Make sure we have an ARIA role - var role = root.getAttribute("role"); - if (!role) { - root.setAttribute("role", "menubar"); - } - var label = root.getAttribute("aria-label"); - if (!label) { - root.setAttribute("aria-label", strings.ariaLabel); - } - // Create element for commandingSurface and reparent any declarative Commands. - // commandingSurface will parse child elements as AppBarCommands. - var commandingSurfaceEl = document.createElement("DIV"); - _ElementUtilities._reparentChildren(root, commandingSurfaceEl); - root.appendChild(commandingSurfaceEl); - this._dom = { - root: root, - commandingSurfaceEl: commandingSurfaceEl, - }; - }; - AppBar.prototype._handleShowingKeyboard = function (event) { - // If the IHM resized the window, we can rely on -ms-device-fixed positioning to remain visible. - // If the IHM does not resize the window we will need to adjust our offsets to avoid being occluded - // The IHM does not cause a window resize to happen right away, set a timeout to check if the viewport - // has been resized after enough time has passed for both the IHM animation, and scroll-into-view, to - // complete. - var _this = this; - // If focus is in the AppBar, tell the platform we will move ourselves. - if (this._dom.root.contains(_Global.document.activeElement)) { - var inputPaneEvent = event.detail.originalEvent; - inputPaneEvent.ensuredFocusedElementInView = true; - } - var duration = keyboardInfo._animationShowLength + keyboardInfo._scrollTimeout; - // Returns a promise for unit tests to verify the correct behavior after the timeout. - return Promise.timeout(duration).then(function () { - if (_this._shouldAdjustForShowingKeyboard() && !_this._disposed) { - _this._adjustedOffsets = _this._computeAdjustedOffsets(); - _this._commandingSurface.deferredDomUpate(); - } - }); - }; - AppBar.prototype._shouldAdjustForShowingKeyboard = function () { - // Overwriteable for unit tests - // Determines if an AppBar needs to adjust its position to move in response to a shown IHM, or if it can - // just ride the bottom of the visual viewport to remain visible. The latter requires that the IHM has - // caused the viewport to resize. - return keyboardInfo._visible && !keyboardInfo._isResized; - }; - AppBar.prototype._handleHidingKeyboard = function () { - // Make sure AppBar has the correct offsets since it could have been displaced by the IHM. - this._adjustedOffsets = this._computeAdjustedOffsets(); - this._commandingSurface.deferredDomUpate(); - }; - AppBar.prototype._computeAdjustedOffsets = function () { - // Position the AppBar element relative to the top or bottom edge of the visible - // document. - var offsets = { top: "", bottom: "" }; - if (this._placement === Placement.bottom) { - // If the IHM is open, the bottom of the visual viewport may or may not be occluded - offsets.bottom = keyboardInfo._visibleDocBottomOffset + "px"; - } - else if (this._placement === Placement.top) { - offsets.top = keyboardInfo._visibleDocTop + "px"; - } - return offsets; - }; - AppBar.prototype._synchronousOpen = function () { - this._isOpenedMode = true; - this._updateDomImpl(); - }; - AppBar.prototype._synchronousClose = function () { - this._isOpenedMode = false; - this._updateDomImpl(); - }; - AppBar.prototype._updateDomImpl = function () { - var rendered = this._updateDomImpl_renderedState; - if (rendered.isOpenedMode !== this._isOpenedMode) { - if (this._isOpenedMode) { - this._updateDomImpl_renderOpened(); - } - else { - this._updateDomImpl_renderClosed(); - } - rendered.isOpenedMode = this._isOpenedMode; - } - if (rendered.placement !== this.placement) { - removeClass(this._dom.root, placementClassMap[rendered.placement]); - addClass(this._dom.root, placementClassMap[this.placement]); - rendered.placement = this.placement; - } - if (rendered.closedDisplayMode !== this.closedDisplayMode) { - removeClass(this._dom.root, closedDisplayModeClassMap[rendered.closedDisplayMode]); - addClass(this._dom.root, closedDisplayModeClassMap[this.closedDisplayMode]); - rendered.closedDisplayMode = this.closedDisplayMode; - } - if (rendered.adjustedOffsets.top !== this._adjustedOffsets.top) { - this._dom.root.style.top = this._adjustedOffsets.top; - rendered.adjustedOffsets.top = this._adjustedOffsets.top; - } - if (rendered.adjustedOffsets.bottom !== this._adjustedOffsets.bottom) { - this._dom.root.style.bottom = this._adjustedOffsets.bottom; - rendered.adjustedOffsets.bottom = this._adjustedOffsets.bottom; - } - this._commandingSurface.updateDomImpl(); - }; - AppBar.prototype._getClosedHeight = function () { - if (this._cachedClosedHeight === null) { - var wasOpen = this._isOpenedMode; - if (this._isOpenedMode) { - this._synchronousClose(); - } - this._cachedClosedHeight = this._commandingSurface.getBoundingRects().commandingSurface.height; - if (wasOpen) { - this._synchronousOpen(); - } - } - return this._cachedClosedHeight; - }; - AppBar.prototype._updateDomImpl_renderOpened = function () { - addClass(this._dom.root, _Constants.ClassNames.openedClass); - removeClass(this._dom.root, _Constants.ClassNames.closedClass); - this._commandingSurface.synchronousOpen(); - _LightDismissService.shown(this._dismissable); // Call at the start of the open animation - }; - AppBar.prototype._updateDomImpl_renderClosed = function () { - addClass(this._dom.root, _Constants.ClassNames.closedClass); - removeClass(this._dom.root, _Constants.ClassNames.openedClass); - this._commandingSurface.synchronousClose(); - _LightDismissService.hidden(this._dismissable); // Call after the close animation - }; - /// - /// Display options for the AppBar when closed. - /// - AppBar.ClosedDisplayMode = ClosedDisplayMode; - /// - /// Display options for AppBar placement in relation to the main view. - /// - AppBar.Placement = Placement; - AppBar.supportedForProcessing = true; - return AppBar; - })(); - exports.AppBar = AppBar; - _Base.Class.mix(AppBar, _Events.createEventProperties(_Constants.EventNames.beforeOpen, _Constants.EventNames.afterOpen, _Constants.EventNames.beforeClose, _Constants.EventNames.afterClose)); - // addEventListener, removeEventListener, dispatchEvent - _Base.Class.mix(AppBar, _Control.DOMEventMixin); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -/// -define('WinJS/Controls/AppBar',["require", "exports", '../Core/_Base'], function (require, exports, _Base) { - var module = null; - _Base.Namespace.define("WinJS.UI", { - AppBar: { - get: function () { - if (!module) { - require(["./AppBar/_AppBar"], function (m) { - module = m; - }); - } - return module.AppBar; - } - } - }); -}); - -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License.txt in the project root for license information. -define('ui',[ - 'WinJS/Core/_WinJS', - 'WinJS/VirtualizedDataSource', - 'WinJS/Controls/IntrinsicControls', - 'WinJS/Controls/ListView', - 'WinJS/Controls/FlipView', - 'WinJS/Controls/ItemContainer', - 'WinJS/Controls/Repeater', - 'WinJS/Controls/DatePicker', - 'WinJS/Controls/TimePicker', - 'WinJS/Controls/BackButton', - 'WinJS/Controls/Rating', - 'WinJS/Controls/ToggleSwitch', - 'WinJS/Controls/SemanticZoom', - 'WinJS/Controls/Pivot', - 'WinJS/Controls/Hub', - 'WinJS/Controls/Flyout', - 'WinJS/Controls/_LegacyAppBar', - 'WinJS/Controls/Menu', - 'WinJS/Controls/SearchBox', - 'WinJS/Controls/SettingsFlyout', - 'WinJS/Controls/NavBar', - 'WinJS/Controls/Tooltip', - 'WinJS/Controls/ViewBox', - 'WinJS/Controls/ContentDialog', - 'WinJS/Controls/SplitView', - 'WinJS/Controls/SplitViewPaneToggle', - 'WinJS/Controls/ToolBar', - 'WinJS/Controls/AppBar', - ], function (_WinJS) { - "use strict"; - - return _WinJS; -}); - - require(['WinJS/Core/_WinJS', 'ui'], function (_WinJS) { - // WinJS always publishes itself to global - globalObject.WinJS = _WinJS; - if (typeof module !== 'undefined') { - // This is a CommonJS context so publish to exports - module.exports = _WinJS; - } - }); - return globalObject.WinJS; - })); -}()); - diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/package.appxmanifest b/Samples/SimpleConversionDemo.UWP.WinJS/package.appxmanifest deleted file mode 100644 index 04818d1910..0000000000 --- a/Samples/SimpleConversionDemo.UWP.WinJS/package.appxmanifest +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - UnitsNet.TestApps.Uwp.WinJS - Andreas - images\storelogo.png - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/Samples/SimpleConversionDemo.UWP.WinJS/project.json b/Samples/SimpleConversionDemo.UWP.WinJS/project.json deleted file mode 100644 index 2f8c7f353b..0000000000 --- a/Samples/SimpleConversionDemo.UWP.WinJS/project.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "dependencies": { - "Microsoft.NETCore.UniversalWindowsPlatform": "6.1.9", - "System.ValueTuple": "4.5.0", - "UnitsNet.WindowsRuntimeComponent": "4.7.0" - }, - "frameworks": { - "uap10.0": {} - }, - "runtimes": { - "win10-arm": {}, - "win10-arm-aot": {}, - "win10-x86": {}, - "win10-x86-aot": {}, - "win10-x64": {}, - "win10-x64-aot": {} - } -} \ No newline at end of file diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index 97c0f95bb2..a1fc09b17e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component acceleration + nanoframework acceleration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index f017350ee2..27f55a4389 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component amountofsubstance + nanoframework amountofsubstance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index ca740d81ba..9890947de6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component amplituderatio + nanoframework amplituderatio unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index bf4f770f2d..1b307d7806 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component angle + nanoframework angle unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 41508535d7..57fb50ecf7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component apparentenergy + nanoframework apparentenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index a4a62cae22..fc3f56884c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component apparentpower + nanoframework apparentpower unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index 68d33161ca..893177ed95 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component area + nanoframework area unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index f74cf189de..263c0ce38c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component areadensity + nanoframework areadensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index 8f4b9d1d02..df09f8b6b5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component areamomentofinertia + nanoframework areamomentofinertia unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index 8feef21d00..32e641ab7d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component bitrate + nanoframework bitrate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 418c2c70cf..1c9925d23d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component brakespecificfuelconsumption + nanoframework brakespecificfuelconsumption unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index 66484b78b3..264be727e6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component capacitance + nanoframework capacitance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index e07c29312c..fc5339f5c0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component coefficientofthermalexpansion + nanoframework coefficientofthermalexpansion unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 09c2a3a30a..51ed8c8f00 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component density + nanoframework density unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index ca2ab9a564..e1b03f92d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component duration + nanoframework duration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 04f0e76b59..37ea9ca5e2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component dynamicviscosity + nanoframework dynamicviscosity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index c76b4bd344..87c05156f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricadmittance + nanoframework electricadmittance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index 29dbee7844..5618a9ea33 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electriccharge + nanoframework electriccharge unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index 0842dafc6e..adf680aafd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricchargedensity + nanoframework electricchargedensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 0464fa752a..440e565c56 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricconductance + nanoframework electricconductance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index 762a37ad07..cb78038f55 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricconductivity + nanoframework electricconductivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 65c451ac1a..4b2b1d2428 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electriccurrent + nanoframework electriccurrent unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index 6e3319bf2c..8a79ad5fb4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electriccurrentdensity + nanoframework electriccurrentdensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index f1c2ed2e8e..e39c260527 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electriccurrentgradient + nanoframework electriccurrentgradient unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index 61898dbad9..4efdf55afe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricfield + nanoframework electricfield unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index a1b67c8b3d..a40ef906ca 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricinductance + nanoframework electricinductance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index 0e7a7faa39..03e25ef962 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricpotential + nanoframework electricpotential unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index 877cafbbd6..7e01617230 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricpotentialac + nanoframework electricpotentialac unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 5aca5eb6c2..f64a29e26e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricpotentialchangerate + nanoframework electricpotentialchangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index cdda59a65d..ca8eb157e9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricpotentialdc + nanoframework electricpotentialdc unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 88ab790236..0e766fa393 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricresistance + nanoframework electricresistance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index da26ea304d..134d5d6aa4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricresistivity + nanoframework electricresistivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index 8708ae473d..5f04ac542b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component electricsurfacechargedensity + nanoframework electricsurfacechargedensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index b2543fcb59..6f5a7d8413 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component energy + nanoframework energy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 5424a6ea6a..0c44aa9a17 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component entropy + nanoframework entropy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index 39a55078a2..c4b1b885fb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component force + nanoframework force unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index edc355e757..16f16eda02 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component forcechangerate + nanoframework forcechangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index f0faeb3fa3..7c8980d7b2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component forceperlength + nanoframework forceperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 797d74f79c..755cf865f6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component frequency + nanoframework frequency unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index 728f25e9af..390524d587 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component fuelefficiency + nanoframework fuelefficiency unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index c64d071448..b646d2db9d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component heatflux + nanoframework heatflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index e1d1e8f648..fdf1dd77c7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component heattransfercoefficient + nanoframework heattransfercoefficient unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index 0b35d21996..d77213cb1e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component illuminance + nanoframework illuminance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index 8019c23240..f35f5309c5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component information + nanoframework information unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index c92cd46708..f382bfe5ba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component irradiance + nanoframework irradiance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index fa3ab150ec..3ea11e97f9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component irradiation + nanoframework irradiation unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index 5ef0324a26..869441fb02 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component kinematicviscosity + nanoframework kinematicviscosity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index 35421f8938..e5c2e29f44 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component lapserate + nanoframework lapserate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index b581c84dd4..5b3b62b2ee 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component length + nanoframework length unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index 8eadc5ab6c..7db084922d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component level + nanoframework level unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index badfee98d6..e4b8fc6204 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component lineardensity + nanoframework lineardensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index d842f11bfc..29144a71a0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component linearpowerdensity + nanoframework linearpowerdensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index 549e27defa..778709e74a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component luminosity + nanoframework luminosity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 3568f63909..8cf132e9c2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component luminousflux + nanoframework luminousflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index 5cabd560c8..e46f8aaff9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component luminousintensity + nanoframework luminousintensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index a872e64472..5aaaaf70cb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component magneticfield + nanoframework magneticfield unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 4150b36414..79bafea313 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component magneticflux + nanoframework magneticflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index 9b1893cf68..eb3442b01e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component magnetization + nanoframework magnetization unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index 7befed538b..ada47b667e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component mass + nanoframework mass unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index 9264204d33..0b6d256e12 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component massconcentration + nanoframework massconcentration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 7a26f7f99f..4a90ce8aae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component massflow + nanoframework massflow unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index 151a7c2636..3f3620a2e1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component massflux + nanoframework massflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 4fd33472a5..69b4d6ea6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component massfraction + nanoframework massfraction unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index 22742c3af8..475e49a5b4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component massmomentofinertia + nanoframework massmomentofinertia unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index c04da57229..b97ed6a39a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component molarenergy + nanoframework molarenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index c4b4772fd4..f633a24cff 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component molarentropy + nanoframework molarentropy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index 604843a75b..d836f05002 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component molarmass + nanoframework molarmass unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 55386675e2..381dab84b6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component molarity + nanoframework molarity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 1e4afdeff7..36575873cc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component permeability + nanoframework permeability unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index 005e87dba3..1374e8d844 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component permittivity + nanoframework permittivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index 0373133d25..0fb715cd32 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component power + nanoframework power unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index dd6f4de43e..c0182f5b7f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component powerdensity + nanoframework powerdensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index b77b67c0a6..c23bff0bde 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component powerratio + nanoframework powerratio unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 60feb536e0..798c80cd81 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component pressure + nanoframework pressure unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index 66848cc0c7..e96ddabe4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component pressurechangerate + nanoframework pressurechangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index 92a093584a..f2d44af979 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component ratio + nanoframework ratio unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index c27dcc9ad6..866a89cbe0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component ratiochangerate + nanoframework ratiochangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index 34c675c995..efdc430029 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component reactiveenergy + nanoframework reactiveenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 92207483f2..2e4cea472a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component reactivepower + nanoframework reactivepower unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index 948cdf7478..cf1e00c789 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component reciprocalarea + nanoframework reciprocalarea unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 96a41e4585..3c7b023ad3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component reciprocallength + nanoframework reciprocallength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index 3d81a09d51..c83f5fa97d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component relativehumidity + nanoframework relativehumidity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index eca4e2c58c..c2a6b4ce42 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component rotationalacceleration + nanoframework rotationalacceleration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index 4c44f24a46..a39490a45e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component rotationalspeed + nanoframework rotationalspeed unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 065f9aab09..eeb43b46ea 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component rotationalstiffness + nanoframework rotationalstiffness unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index a968761cea..978693b764 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component rotationalstiffnessperlength + nanoframework rotationalstiffnessperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index ab6c8c6772..a497fcbeb8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component scalar + nanoframework scalar unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 19ac11230e..45b7b2be00 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component solidangle + nanoframework solidangle unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 8aa3457c93..1e0cd08f55 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component specificenergy + nanoframework specificenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index 6261451101..ebfcbef793 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component specificentropy + nanoframework specificentropy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 721e6e9e38..a4629c50cb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component specificfuelconsumption + nanoframework specificfuelconsumption unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index 273648ebb3..e88e60cbeb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component specificvolume + nanoframework specificvolume unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 7401e8c85e..05897da007 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component specificweight + nanoframework specificweight unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index edbf0e44df..5f5bf0fee1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component speed + nanoframework speed unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 255279cf7a..488abbad58 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component standardvolumeflow + nanoframework standardvolumeflow unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index dcc1d731bf..44759b1152 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component temperature + nanoframework temperature unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 4fc0a4459b..5414a15dd6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component temperaturechangerate + nanoframework temperaturechangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 11239065e7..4c87e7f173 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component temperaturedelta + nanoframework temperaturedelta unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index 19e0399a3a..c50c773ff9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component thermalconductivity + nanoframework thermalconductivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index e3bc85d7cd..eeceae37a2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component thermalresistance + nanoframework thermalresistance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 3c6c4eea25..983d17496a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component torque + nanoframework torque unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index 70c6df9db8..a9633cf230 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component torqueperlength + nanoframework torqueperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 8986b343cf..cea033c1d3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component turbidity + nanoframework turbidity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index 669d871275..1b8dbbd95e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component vitamina + nanoframework vitamina unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index 7ef24bfddb..05b0c463bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component volume + nanoframework volume unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index 2b54b23d67..e2091d4f67 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component volumeconcentration + nanoframework volumeconcentration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index fe5daa4fcd..172d75c2d5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component volumeflow + nanoframework volumeflow unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index 231f74d839..d9da46988e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component volumeperlength + nanoframework volumeperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index d1dcef7e23..65ea3bd290 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component volumetricheatcapacity + nanoframework volumetricheatcapacity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 0d34c252d8..29043b6d43 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component warpingmomentofinertia + nanoframework warpingmomentofinertia unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.WindowsRuntimeComponent/AmbiguousUnitParseException.cs b/UnitsNet.WindowsRuntimeComponent/AmbiguousUnitParseException.cs deleted file mode 100644 index 7eaea890c4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/AmbiguousUnitParseException.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Unable to parse because more than one unit of the given quantity type had this exact unit abbreviation. - /// Example: Length.Parse("1 pt") will throw , because both - /// and - /// have "pt" as their abbreviation. - /// - internal class AmbiguousUnitParseException : UnitsNetException - { - /// - public AmbiguousUnitParseException(string message) : base(message) - { - HResult = 2; - } - - /// - public AmbiguousUnitParseException(string message, Exception innerException) : base(message, innerException) - { - HResult = 2; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/AssemblyInfo.cs b/UnitsNet.WindowsRuntimeComponent/AssemblyInfo.cs deleted file mode 100644 index ef8f9364ec..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/AssemblyInfo.cs +++ /dev/null @@ -1,5 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -[assembly: CLSCompliant(true)] diff --git a/UnitsNet.WindowsRuntimeComponent/BaseDimensions.cs b/UnitsNet.WindowsRuntimeComponent/BaseDimensions.cs deleted file mode 100644 index 4fecf8a80f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/BaseDimensions.cs +++ /dev/null @@ -1,188 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Text; -using System.Linq; - -namespace UnitsNet -{ - /// - /// Represents the base dimensions of a quantity. - /// - public sealed class BaseDimensions - { - /// - public BaseDimensions(int length, int mass, int time, int current, int temperature, int amount, int luminousIntensity) - { - Length = length; - Mass = mass; - Time = time; - Current = current; - Temperature = temperature; - Amount = amount; - LuminousIntensity = luminousIntensity; - } - - /// - /// Checks if the dimensions represent a base quantity. - /// - /// True if the dimensions represent a base quantity, otherwise false. - public bool IsBaseQuantity() - { - var dimensionsArray = new[]{Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity}; - bool onlyOneEqualsOne = dimensionsArray.Where(dimension => dimension == 1).Take(2).Count() == 1; - return onlyOneEqualsOne; - } - - /// - /// Checks if the dimensions represent a derived quantity. - /// - /// True if the dimensions represent a derived quantity, otherwise false. - public bool IsDerivedQuantity() - { - return !IsBaseQuantity() && !IsDimensionless(); - } - - /// - /// Checks if this base dimensions object represents a dimensionless quantity. - /// - /// True if this object represents a dimensionless quantity, otherwise false. - public bool IsDimensionless() - { - return Equals(this, Dimensionless); - } - - /// - public override bool Equals(object obj) - { - if(!(obj is BaseDimensions)) - return false; - - var other = (BaseDimensions)obj; - - return Length == other.Length && - Mass == other.Mass && - Time == other.Time && - Current == other.Current && - Temperature == other.Temperature && - Amount == other.Amount && - LuminousIntensity == other.LuminousIntensity; - } - - /// - public override int GetHashCode() - { - return new {Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity}.GetHashCode(); - } - - /// - /// Get resulting dimensions after multiplying two dimensions, by performing addition of each dimension. - /// - /// Other dimensions. - /// Resulting dimensions. - public BaseDimensions Multiply(BaseDimensions right) - { - if(right is null) - throw new ArgumentNullException(nameof(right)); - - return new BaseDimensions( - Length + right.Length, - Mass + right.Mass, - Time + right.Time, - Current + right.Current, - Temperature + right.Temperature, - Amount + right.Amount, - LuminousIntensity + right.LuminousIntensity); - } - - /// - /// Get resulting dimensions after dividing two dimensions, by performing subtraction of each dimension. - /// - /// Other dimensions. - /// Resulting dimensions. - public BaseDimensions Divide(BaseDimensions right) - { - if(right is null) - throw new ArgumentNullException(nameof(right)); - - return new BaseDimensions( - Length - right.Length, - Mass - right.Mass, - Time - right.Time, - Current - right.Current, - Temperature - right.Temperature, - Amount - right.Amount, - LuminousIntensity - right.LuminousIntensity); - } - - /// - public override string ToString() - { - var sb = new StringBuilder(); - - AppendDimensionString(sb, "Length", Length); - AppendDimensionString(sb, "Mass", Mass); - AppendDimensionString(sb, "Time", Time); - AppendDimensionString(sb, "Current", Current); - AppendDimensionString(sb, "Temperature", Temperature); - AppendDimensionString(sb, "Amount", Amount); - AppendDimensionString(sb, "LuminousIntensity", LuminousIntensity); - - return sb.ToString(); - } - - private static void AppendDimensionString(StringBuilder sb, string name, int value) - { - var absoluteValue = Math.Abs(value); - - if(absoluteValue > 0) - { - sb.AppendFormat("[{0}]", name); - - if(absoluteValue > 1) - sb.AppendFormat("^{0}", value); - } - } - - /// - /// Gets the length dimensions (L). - /// - public int Length { get; } - - /// - /// Gets the mass dimensions (M). - /// - public int Mass{ get; } - - /// - /// Gets the time dimensions (T). - /// - public int Time{ get; } - - /// - /// Gets the electric current dimensions (I). - /// - public int Current{ get; } - - /// - /// Gets the temperature dimensions (Θ). - /// - public int Temperature{ get; } - - /// - /// Gets the amount of substance dimensions (N). - /// - public int Amount{ get; } - - /// - /// Gets the luminous intensity dimensions (J). - /// - public int LuminousIntensity{ get; } - - /// - /// Represents a dimensionless (unitless) quantity. - /// - public static BaseDimensions Dimensionless { get; } = new BaseDimensions(0, 0, 0, 0, 0, 0, 0); - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/BaseUnits.cs b/UnitsNet.WindowsRuntimeComponent/BaseUnits.cs deleted file mode 100644 index 240f8e88d5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/BaseUnits.cs +++ /dev/null @@ -1,124 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System.Text; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Represents the base units for a quantity. All quantities, both base and derived, can be - /// represented by a combination of these seven base units. - /// - public sealed class BaseUnits - { - /// - /// Creates an instance of if the base units class that represents the base units for a quantity. - /// All quantities, both base and derived, can be represented by a combination of these seven base units. - /// - /// The length unit (L). - /// The mass unit (M). - /// The time unit (T). - /// The electric current unit (I). - /// The temperature unit (Θ). - /// The amount of substance unit (N). - /// The luminous intensity unit (J). - public BaseUnits(LengthUnit length, MassUnit mass, DurationUnit time, ElectricCurrentUnit current, - TemperatureUnit temperature, AmountOfSubstanceUnit amount, LuminousIntensityUnit luminousIntensity) - { - Length = length; - Mass = mass; - Time = time; - Current = current; - Temperature = temperature; - Amount = amount; - LuminousIntensity = luminousIntensity; - } - - /// - public override bool Equals(object obj) - { - if(obj is null || !(obj is BaseUnits)) - return false; - - return Equals((BaseUnits)obj); - } - - /// - /// Checks if all of the base units are equal to another instance's. - /// - /// The other instance to check if equal to. - /// True if equal, otherwise false. - [Windows.Foundation.Metadata.DefaultOverload] - public bool Equals(BaseUnits other) - { - if(other is null) - return false; - - return Length == other.Length && - Mass == other.Mass && - Time == other.Time && - Current == other.Current && - Temperature == other.Temperature && - Amount == other.Amount && - LuminousIntensity == other.LuminousIntensity; - } - - /// - public override int GetHashCode() - { - return new {Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity}.GetHashCode(); - } - - /// - public override string ToString() - { - var sb = new StringBuilder(); - - sb.AppendFormat("[Length]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Length)); - sb.AppendFormat("[Mass]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Mass)); - sb.AppendFormat("[Time]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Time)); - sb.AppendFormat("[Current]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Current)); - sb.AppendFormat("[Temperature]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Temperature)); - sb.AppendFormat("[Amount]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Amount)); - sb.AppendFormat("[LuminousIntensity]: {0}", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(LuminousIntensity)); - - return sb.ToString(); - } - - /// - /// Gets the length unit (L). - /// - public LengthUnit Length { get; } - - /// - /// Gets the mass unit (M). - /// - public MassUnit Mass{ get; } - - /// - /// Gets the time unit (T). - /// - public DurationUnit Time{ get; } - - /// - /// Gets the electric current unit (I). - /// - public ElectricCurrentUnit Current{ get; } - - /// - /// Gets the temperature unit (Θ). - /// - public TemperatureUnit Temperature{ get; } - - /// - /// Gets the amount of substance unit (N). - /// - public AmountOfSubstanceUnit Amount{ get; } - - /// - /// Gets the luminous intensity unit (J). - /// - public LuminousIntensityUnit LuminousIntensity{ get; } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/Comparison.cs b/UnitsNet.WindowsRuntimeComponent/Comparison.cs deleted file mode 100644 index 575707e6b5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/Comparison.cs +++ /dev/null @@ -1,125 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -namespace UnitsNet -{ - /// - /// Helper methods to perform relative and absolute comparison. - /// - public static class Comparison - { - /// - /// - /// Checks if two values are equal with a given relative or absolute tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a percentage of . A relative tolerance of - /// 0.01 means the - /// absolute difference of and must be within +/- - /// 1%. - /// - /// In this example, the two values will be equal if the value of b is within +/- 1% of a. - /// - /// Equals(a, b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a fixed number. - /// - /// In this example, the two values will be equal if abs( - - /// ) <= 0.01 - /// - /// Equals(a, b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// - /// The reference value. If using relative tolerance, it is the value which the relative - /// tolerance will be calculated against. - /// - /// The value to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// Whether the tolerance is absolute or relative. - /// - public static bool Equals(double referenceValue, double otherValue, double tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); - - switch (comparisonType) - { - case ComparisonType.Relative: - return EqualsRelative(referenceValue, otherValue, tolerance); - case ComparisonType.Absolute: - return EqualsAbsolute(referenceValue, otherValue, tolerance); - default: - throw new InvalidOperationException("The given ComparisonType is not supported."); - } - } - - /// - /// Checks if two values are equal with a given relative tolerance. - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a percentage of . A relative tolerance of - /// 0.01 means the - /// absolute difference of and must be within +/- - /// 1%. - /// - /// In this example, the two values will be equal if the value of b is within +/- 1% of a. - /// - /// EqualsRelative(a, b, 0.01); - /// - /// - /// - /// - /// The reference value which the tolerance will be calculated against. - /// The value to compare to. - /// The relative tolerance. Must be greater than or equal to 0. - /// True if the two values are equal within the given relative tolerance, otherwise false. - public static bool EqualsRelative(double referenceValue, double otherValue, double tolerance) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); - - var maxVariation = Math.Abs(referenceValue * tolerance); - return Math.Abs(referenceValue - otherValue) <= maxVariation; - } - - /// - /// Checks if two values are equal with a given absolute tolerance. - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a fixed number. - /// - /// In this example, the two values will be equal if abs( - - /// ) <= 0.01 - /// - /// Equals(a, b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// The first value. - /// The second value. - /// The absolute tolerance. Must be greater than or equal to 0. - /// True if the two values are equal within the given absolute tolerance, otherwise false. - public static bool EqualsAbsolute(double value1, double value2, double tolerance) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); - - return Math.Abs(value1 - value2) <= tolerance; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/ComparisonType.cs b/UnitsNet.WindowsRuntimeComponent/ComparisonType.cs deleted file mode 100644 index 18f76cfdd3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/ComparisonType.cs +++ /dev/null @@ -1,21 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -namespace UnitsNet -{ - /// - /// Specifies if the comparison between numbers is absolute or relative. - /// - public enum ComparisonType - { - /// - /// Error margin in relative size to a reference value. - /// - Relative, - - /// - /// Error margin as absolute size. - /// - Absolute - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/GlobalConfiguration.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/GlobalConfiguration.cs deleted file mode 100644 index 2dcae79bf9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/GlobalConfiguration.cs +++ /dev/null @@ -1,19 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - public sealed class GlobalConfiguration - { - /// - /// Defaults to when creating an instance with no culture provided. - /// Can be overridden, but note that this is static and will affect all subsequent usages. - /// - // Windows Runtime Component does not support exposing the IFormatProvider type in public API - internal static IFormatProvider DefaultCulture { get; set; } = CultureInfo.CurrentUICulture; - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/AmplitudeRatio.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/AmplitudeRatio.extra.cs deleted file mode 100644 index 4eaf72c7da..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/AmplitudeRatio.extra.cs +++ /dev/null @@ -1,77 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class AmplitudeRatio - { - /// - /// Initializes a new instance of the struct from the specified electric potential - /// referenced to one volt RMS. This assumes both the specified electric potential and the one volt reference have the - /// same - /// resistance. - /// - /// The electric potential referenced to one volt. - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - private AmplitudeRatio(ElectricPotential voltage) - : this() - { - if (voltage.Volts <= 0) - throw new ArgumentOutOfRangeException( - nameof(voltage), - "The base-10 logarithm of a number ≤ 0 is undefined. Voltage must be greater than 0 V."); - - // E(dBV) = 20*log10(value(V)/reference(V)) - _value = 20 * Math.Log10(voltage.Volts / 1); - _unit = AmplitudeRatioUnit.DecibelVolt; - } - - /// - /// Gets an from this . - /// - /// - /// Provides a nicer syntax for converting an amplitude ratio back to a voltage. - /// - /// var voltage = voltageRatio.ToElectricPotential(); - /// - /// - public ElectricPotential ToElectricPotential() - { - // E(V) = 1V * 10^(E(dBV)/20) - return ElectricPotential.FromVolts( Math.Pow( 10, DecibelVolts / 20 ) ); - } - - /// - /// Converts this to a . - /// - /// The input impedance of the load. This is usually 50, 75 or 600 ohms. - /// http://www.maximintegrated.com/en/app-notes/index.mvp/id/808 - public PowerRatio ToPowerRatio( ElectricResistance impedance ) - { - // P(dBW) = E(dBV) - 10*log10(Z(Ω)/1) - return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( impedance.Ohms / 1 ) ); - } - - #region Static Methods - - /// - /// Gets an in decibels (dB) relative to 1 volt RMS from an - /// . - /// - /// The voltage (electric potential) relative to one volt RMS. - public static AmplitudeRatio FromElectricPotential(ElectricPotential voltage) - { - return new AmplitudeRatio(voltage); - } - - #endregion - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Area.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Area.extra.cs deleted file mode 100644 index 1c04a0fb5b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Area.extra.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Area - { - public static Area FromCircleDiameter(Length diameter) - { - var radius = Length.FromMeters(diameter.Meters / 2d); - return FromCircleRadius(radius); - } - - public static Area FromCircleRadius(Length radius) - { - return FromSquareMeters(Math.PI * radius.Meters * radius.Meters); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Density.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Density.extra.cs deleted file mode 100644 index bd498e57a4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Density.extra.cs +++ /dev/null @@ -1,36 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - public sealed partial class Density - { - /// - /// Gets from this . - /// - /// - public Molarity ToMolarity(Mass molecularWeight) - { - return Molarity.FromMolesPerCubicMeter(KilogramsPerCubicMeter / molecularWeight.Kilograms); - } - - #region Static Methods - - /// - /// Get from . - /// - /// - /// - public static Density FromMolarity(Molarity molarity, Mass molecularWeight) - { - return new Density(molarity.MolesPerCubicMeter * molecularWeight.Kilograms, DensityUnit.KilogramPerCubicMeter); - } - - #endregion - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Duration.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Duration.extra.cs deleted file mode 100644 index 2b250848ec..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Duration.extra.cs +++ /dev/null @@ -1,27 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Duration - { - /// - /// Convert a Duration to a TimeSpan. - /// - /// Throws if the TimeSpan can't represent the Duration exactly - /// The TimeSpan with the same time as the duration - public TimeSpan ToTimeSpan() - { - if( Seconds > TimeSpan.MaxValue.TotalSeconds || - Seconds < TimeSpan.MinValue.TotalSeconds ) - throw new ArgumentOutOfRangeException( nameof( Duration ), "The duration is too large or small to fit in a TimeSpan" ); - return TimeSpan.FromSeconds( Seconds ); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/ElectricPotential.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/ElectricPotential.extra.cs deleted file mode 100644 index 1c6a921ed1..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/ElectricPotential.extra.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - - - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricPotential - { - /// - /// Gets an in decibels (dB) relative to 1 volt RMS from this . - /// - /// - /// Provides a nicer syntax for converting a voltage to an amplitude ratio (relative to 1 volt RMS). - /// - /// var voltageRatio = voltage.ToAmplitudeRatio(); - /// - /// - public AmplitudeRatio ToAmplitudeRatio() - { - return AmplitudeRatio.FromElectricPotential(this); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Force.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Force.extra.cs deleted file mode 100644 index 4d0b67dec1..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Force.extra.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Force - { - public static Force FromPressureByArea(Pressure p, Area area) - { - double newtons = p.Pascals * area.SquareMeters; - return new Force(newtons, ForceUnit.Newton); - } - - public static Force FromMassByAcceleration(Mass mass, Acceleration acceleration) - { - return new Force(mass.Kilograms * acceleration.MetersPerSecondSquared, ForceUnit.Newton); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Length.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Length.extra.cs deleted file mode 100644 index 9788cabb81..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Length.extra.cs +++ /dev/null @@ -1,69 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using JetBrains.Annotations; -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Length - { - private const double InchesInOneFoot = 12; - - /// - /// Converts the length to a customary feet/inches combination. - /// - public FeetInches FeetInches - { - get - { - var inInches = Inches; - var feet = Math.Truncate(inInches / InchesInOneFoot); - var inches = inInches % InchesInOneFoot; - - return new FeetInches(feet, inches); - } - } - - /// - /// Get length from combination of feet and inches. - /// - public static Length FromFeetInches(double feet, double inches) - { - return FromInches(InchesInOneFoot*feet + inches); - } - } - - public sealed class FeetInches - { - public FeetInches(double feet, double inches) - { - Feet = feet; - Inches = inches; - } - - public double Feet { get; } - public double Inches { get; } - - public override string ToString() - { - return ToString(null); - } - - public string ToString([CanBeNull] string cultureInfo) - { - // Note that it isn't customary to use fractions - one wouldn't say "I am 5 feet and 4.5 inches". - // So inches are rounded when converting from base units to feet/inches. - var footUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(LengthUnit.Foot); - var inchUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(LengthUnit.Inch); - - return string.Format(GlobalConfiguration.DefaultCulture, "{0:n0} {1} {2:n0} {3}", Feet, footUnit, Math.Round(Inches), - inchUnit); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Mass.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Mass.extra.cs deleted file mode 100644 index 65838e3a67..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Mass.extra.cs +++ /dev/null @@ -1,82 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using JetBrains.Annotations; -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Mass - { - public static Mass FromGravitationalForce(Force f) - { - return new Mass(f.KilogramsForce, MassUnit.Kilogram); - } - - /// - /// StonePounds related code makes it easier to work with Stone/Pound combination, which are customarily used in the UK - /// to express body weight. For example, someone weighs 11 stone 4 pounds (about 72 kilograms). - /// - private const double StonesInOnePound = 14.0; - - /// - /// Converts the mass to a customary stone/pounds combination. - /// - public StonePounds StonePounds - { - get - { - var inPounds = Pounds; - - var stones = Math.Truncate(inPounds / StonesInOnePound); - var pounds = inPounds % StonesInOnePound; - - return new StonePounds(stones, pounds); - } - } - - /// - /// Get Mass from combination of stone and pounds. - /// - public static Mass FromStonePounds(double stone, double pounds) - { - return FromPounds(StonesInOnePound*stone + pounds); - } - } - - public sealed class StonePounds - { - public StonePounds(double stone, double pounds) - { - Stone = stone; - Pounds = pounds; - } - - public double Stone { get; } - public double Pounds { get; } - - public override string ToString() - { - return ToString(null); - } - - public string ToString([CanBeNull] string cultureInfo) - { - // Note that it isn't customary to use fractions - one wouldn't say "I am 11 stone and 4.5 pounds". - // So pounds are rounded here. - - var culture = cultureInfo != null ? new CultureInfo(cultureInfo) : GlobalConfiguration.DefaultCulture; - var stoneUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(MassUnit.Stone, culture); - var poundUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(MassUnit.Pound, culture); - - return string.Format(culture, "{0:n0} {1} {2:n0} {3}", - Stone, stoneUnit, Math.Round(Pounds), poundUnit); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Molarity.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Molarity.extra.cs deleted file mode 100644 index cafadaa211..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Molarity.extra.cs +++ /dev/null @@ -1,35 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Molarity - { - /// - /// Get a from this . - /// - /// - public Density ToDensity(Mass molecularWeight) - { - return Density.FromKilogramsPerCubicMeter(MolesPerCubicMeter * molecularWeight.Kilograms); - } - - #region Static Methods - - /// - /// Get from . - /// - /// - /// - public static Molarity FromDensity(Density density, Mass molecularWeight) - { - return FromMolesPerCubicMeter(density.KilogramsPerCubicMeter / molecularWeight.Kilograms); - } - - #endregion - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Power.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Power.extra.cs deleted file mode 100644 index 9b7eddea43..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Power.extra.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Power - { - /// - /// Gets a from this relative to one watt. - /// - /// - /// Provides a nicer syntax for converting a power to a power ratio (relative to 1 watt). - /// - /// var powerRatio = power.ToPowerRatio(); - /// - /// - public PowerRatio ToPowerRatio() - { - return PowerRatio.FromPower(this); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/PowerRatio.extra.cs deleted file mode 100644 index bd00d8f5db..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/PowerRatio.extra.cs +++ /dev/null @@ -1,71 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class PowerRatio - { - /// - /// Initializes a new instance of the struct from the specified power referenced to one watt. - /// - /// The power relative to one watt. - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - private PowerRatio(Power power) - : this() - { - if (power.Watts <= 0) - throw new ArgumentOutOfRangeException( - nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); - - // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10(power.Watts / 1); - _unit = PowerRatioUnit.DecibelWatt; - } - - /// - /// Gets a from this (which is a power level relative to one watt). - /// - /// - /// Provides a nicer syntax for converting a power ratio back to a power. - /// - /// var power = powerRatio.ToPower(); - /// - /// - public Power ToPower() - { - // P(W) = 1W * 10^(P(dBW)/10) - return Power.FromWatts(Math.Pow(10, DecibelWatts / 10)); - } - - /// - /// Gets a from this . - /// - /// The input impedance of the load. This is usually 50, 75 or 600 ohms. - public AmplitudeRatio ToAmplitudeRatio(ElectricResistance impedance) - { - // E(dBV) = 10*log10(Z(Ω)/1) + P(dBW) - return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10(impedance.Ohms / 1) + DecibelWatts); - } - - #region Static Methods - - /// - /// Gets a from a relative to one watt. - /// - /// The power relative to one watt. - public static PowerRatio FromPower(Power power) - { - return new PowerRatio(power); - } - - #endregion - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Temperature.extra.cs deleted file mode 100644 index a9b912396a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantities/Temperature.extra.cs +++ /dev/null @@ -1,49 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Temperature - { - /// - /// Multiply temperature with a in a given . - /// - /// - /// Due to different temperature units having different zero points, we cannot simply - /// multiply or divide a temperature by a factor. We must first convert to the desired unit, then perform the - /// calculation. - /// - /// Factor to multiply by. - /// Unit to perform multiplication in. - /// The resulting . - public Temperature Multiply(double factor, TemperatureUnit unit) - { - double resultInUnit = As(unit) * factor; - return From(resultInUnit, unit); - } - - - /// - /// Divide temperature by a in a given . - /// - /// - /// Due to different temperature units having different zero points, we cannot simply - /// multiply or divide a temperature by a factor. We must first convert to the desired unit, then perform the - /// calculation. - /// - /// Factor to multiply by. - /// Unit to perform multiplication in. - /// The resulting . - public Temperature Divide(double divisor, TemperatureUnit unit) - { - double resultInUnit = As(unit) / divisor; - return From(resultInUnit, unit); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantity.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantity.cs deleted file mode 100644 index bcd047a4f0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/Quantity.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Linq; - -namespace UnitsNet -{ - internal partial class Quantity - { - static Quantity() - { - var quantityTypes = Enum.GetValues(typeof(QuantityType)).Cast().Except(new[] {QuantityType.Undefined}).ToArray(); - Types = quantityTypes; - Names = quantityTypes.Select(qt => qt.ToString()).ToArray(); - } - - /// - /// All enum values of , such as and . - /// - public static QuantityType[] Types { get; } - - /// - /// All enum value names of , such as "Length" and "Mass". - /// - public static string[] Names { get; } - - /// - /// Dynamically construct a quantity. - /// - /// Numeric value. - /// Unit enum value. - /// An object. - /// Unit value is not a know unit enum type. - internal static IQuantity From(double value, Enum unit) - { - if (TryFrom(value, unit, out IQuantity quantity)) - return quantity; - - throw new ArgumentException( - $"Unit value {unit} of type {unit.GetType()} is not a known unit enum type. Expected types like UnitsNet.Units.LengthUnit. Did you pass in a third-party enum type defined outside UnitsNet library?"); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/QuantityParser.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/QuantityParser.cs deleted file mode 100644 index bd859e98c9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/QuantityParser.cs +++ /dev/null @@ -1,217 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Globalization; -using System.Linq; -using System.Text.RegularExpressions; -using JetBrains.Annotations; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - - internal delegate TQuantity QuantityFromDelegate(double value, TUnitType fromUnit) - where TQuantity : IQuantity - where TUnitType : Enum; - - internal class QuantityParser - { - /// - /// Allow integer, floating point or exponential number formats. - /// - private const NumberStyles ParseNumberStyles = NumberStyles.Number | NumberStyles.Float | NumberStyles.AllowExponent; - - private readonly UnitAbbreviationsCache _unitAbbreviationsCache; - private UnitParser _unitParser; - - public static QuantityParser Default { get; } - - public QuantityParser(UnitAbbreviationsCache unitAbbreviationsCache) - { - _unitAbbreviationsCache = unitAbbreviationsCache ?? UnitAbbreviationsCache.Default; - _unitParser = new UnitParser(_unitAbbreviationsCache); - } - - static QuantityParser() - { - Default = new QuantityParser(UnitAbbreviationsCache.Default); - } - - [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal TQuantity Parse([NotNull] string str, - [CanBeNull] IFormatProvider formatProvider, - [NotNull] QuantityFromDelegate fromDelegate) - where TQuantity : IQuantity - where TUnitType : Enum - { - if (str == null) throw new ArgumentNullException(nameof(str)); - str = str.Trim(); - - var numFormat = formatProvider != null - ? (NumberFormatInfo) formatProvider.GetFormat(typeof(NumberFormatInfo)) - : NumberFormatInfo.CurrentInfo; - - if (numFormat == null) - throw new InvalidOperationException($"No number format was found for the given format provider: {formatProvider}"); - - var regex = CreateRegexForQuantity(formatProvider); - - if (!ExtractValueAndUnit(regex, str, out var valueString, out var unitString)) - { - var ex = new FormatException("Unable to parse quantity. Expected the form \"{value} {unit abbreviation}\", such as \"5.5 m\". The spacing is optional."); - ex.Data["input"] = str; - throw ex; - } - - return ParseWithRegex(valueString, unitString, fromDelegate, formatProvider); - } - - [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal bool TryParse([NotNull] string str, - [CanBeNull] IFormatProvider formatProvider, - [NotNull] QuantityFromDelegate fromDelegate, - out TQuantity result) - where TQuantity : IQuantity - where TUnitType : Enum - { - result = default; - - if(string.IsNullOrWhiteSpace(str)) return false; - str = str.Trim(); - - var numFormat = formatProvider != null - ? (NumberFormatInfo) formatProvider.GetFormat(typeof(NumberFormatInfo)) - : NumberFormatInfo.CurrentInfo; - - if(numFormat == null) - return false; - - var regex = CreateRegexForQuantity(formatProvider); - - if (!ExtractValueAndUnit(regex, str, out var valueString, out var unitString)) - return false; - - return TryParseWithRegex(valueString, unitString, fromDelegate, formatProvider, out result); - } - - /// - /// Workaround for C# not allowing to pass on 'out' param from type Length to IQuantity, even though the are compatible. - /// - [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal bool TryParse([NotNull] string str, - [CanBeNull] IFormatProvider formatProvider, - [NotNull] QuantityFromDelegate fromDelegate, - out IQuantity result) - where TQuantity : IQuantity - where TUnitType : Enum - { - if (TryParse(str, formatProvider, fromDelegate, out TQuantity parsedQuantity)) - { - result = parsedQuantity; - return true; - } - - result = default; - return false; - } - - internal string CreateRegexPatternForUnit( - TUnitType unit, - IFormatProvider formatProvider, - bool matchEntireString = true) - where TUnitType : Enum - { - var unitAbbreviations = _unitAbbreviationsCache.GetUnitAbbreviations(unit, formatProvider); - var pattern = GetRegexPatternForUnitAbbreviations(unitAbbreviations); - return matchEntireString ? $"^{pattern}$" : pattern; - } - - private static string GetRegexPatternForUnitAbbreviations(IEnumerable abbreviations) - { - var orderedAbbreviations = abbreviations - .OrderByDescending(s => s.Length) // Important to order by length -- if "m" is before "mm" and the input is "mm", it will match just "m" - .Select(Regex.Escape) // Escape special regex characters - .ToArray(); - - var abbreviationsPiped = $"{string.Join("|", orderedAbbreviations)}"; - return $@"(?.*?)\s?(?{abbreviationsPiped})"; - } - - /// - /// Parse a string given a particular regular expression. - /// - /// Error parsing string. - private TQuantity ParseWithRegex(string valueString, - string unitString, - QuantityFromDelegate fromDelegate, - IFormatProvider formatProvider) - where TQuantity : IQuantity - where TUnitType : Enum - { - var value = double.Parse(valueString, ParseNumberStyles, formatProvider); - var parsedUnit = _unitParser.Parse(unitString, formatProvider); - return fromDelegate(value, parsedUnit); - } - - /// - /// Parse a string given a particular regular expression. - /// - /// Error parsing string. - private bool TryParseWithRegex(string valueString, - string unitString, - QuantityFromDelegate fromDelegate, - IFormatProvider formatProvider, - out TQuantity result) - where TQuantity : IQuantity - where TUnitType : Enum - { - result = default; - - if (!double.TryParse(valueString, ParseNumberStyles, formatProvider, out var value)) - return false; - - if (!_unitParser.TryParse(unitString, formatProvider, out var parsedUnit)) - return false; - - result = fromDelegate(value, parsedUnit); - return true; - } - - private static bool ExtractValueAndUnit(Regex regex, string str, out string valueString, out string unitString) - { - var match = regex.Match(str); - var groups = match.Groups; - - var valueGroup = groups["value"]; - var unitGroup = groups["unit"]; - if (!valueGroup.Success || !unitGroup.Success) - { - valueString = null; - unitString = null; - return false; - } - - valueString = valueGroup.Value; - unitString = unitGroup.Value; - return true; - } - - private string CreateRegexPatternForQuantity(IFormatProvider formatProvider) where TUnitType : Enum - { - var unitAbbreviations = _unitAbbreviationsCache.GetAllUnitAbbreviationsForQuantity(typeof(TUnitType), formatProvider); - var pattern = GetRegexPatternForUnitAbbreviations(unitAbbreviations); - - // Match entire string exactly - return $"^{pattern}$"; - } - - private Regex CreateRegexForQuantity([CanBeNull] IFormatProvider formatProvider) where TUnitType : Enum - { - var pattern = CreateRegexPatternForQuantity(formatProvider); - return new Regex(pattern, RegexOptions.Singleline); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitAbbreviationsCache.cs deleted file mode 100644 index ab26d1f5e9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitAbbreviationsCache.cs +++ /dev/null @@ -1,221 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.InternalHelpers; -using UnitsNet.Units; - -using UnitTypeToLookup = System.Collections.Generic.Dictionary; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - public sealed partial class UnitAbbreviationsCache - { - private readonly Dictionary _lookupsForCulture; - - /// - /// Fallback culture used by and - /// if no abbreviations are found with a given culture. - /// - /// - /// User wants to call or with Russian - /// culture, but no translation is defined, so we return the US English definition as a last resort. If it's not - /// defined there either, an exception is thrown. - /// - private static readonly CultureInfo FallbackCulture = new CultureInfo("en-US"); - - public static UnitAbbreviationsCache Default { get; } - - public UnitAbbreviationsCache() - { - _lookupsForCulture = new Dictionary(); - - LoadGeneratedAbbreviations(); - } - - static UnitAbbreviationsCache() - { - Default = new UnitAbbreviationsCache(); - } - - private void LoadGeneratedAbbreviations() - { - foreach(var localization in GeneratedLocalizations) - { - var culture = new CultureInfo(localization.CultureName); - MapUnitToAbbreviation(localization.UnitType, localization.UnitValue, culture, localization.UnitAbbreviations); - } - } - - /// - /// Adds one or more unit abbreviation for the given unit enum value. - /// This is used to dynamically add abbreviations for existing unit enums such as or to extend with third-party unit enums - /// in order to or on them later. - /// - /// The unit enum type. - /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. - /// Unit abbreviations to add. - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - private void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, [NotNull] params string[] abbreviations) - { - PerformAbbreviationMapping(unitType, unitValue, formatProvider, false, abbreviations); - } - - private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider formatProvider, bool setAsDefault, [NotNull] params string[] abbreviations) - { - if (!unitType.Wrap().IsEnum) - throw new ArgumentException("Must be an enum type.", nameof(unitType)); - - if (abbreviations == null) - throw new ArgumentNullException(nameof(abbreviations)); - - formatProvider = formatProvider ?? GlobalConfiguration.DefaultCulture; - - if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) - quantitiesForProvider = _lookupsForCulture[formatProvider] = new UnitTypeToLookup(); - - if (!quantitiesForProvider.TryGetValue(unitType, out var unitToAbbreviations)) - unitToAbbreviations = quantitiesForProvider[unitType] = new UnitValueAbbreviationLookup(); - - foreach (var abbr in abbreviations) - { - unitToAbbreviations.Add(unitValue, abbr, setAsDefault); - } - } - - /// - /// Gets the default abbreviation for a given unit. If a unit has more than one abbreviation defined, then it returns the first one. - /// Example: GetDefaultAbbreviation<LengthUnit>(LengthUnit.Kilometer) => "km" - /// - /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. - /// The type of unit enum. - /// The default unit abbreviation string. - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal string GetDefaultAbbreviation(TUnitType unit, IFormatProvider formatProvider = null) where TUnitType : Enum - { - var unitType = typeof(TUnitType); - - if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) - { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unit, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}"); - } - - var abbreviations = lookup.GetAbbreviationsForUnit(unit); - if(abbreviations.Count == 0) - { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unit, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}"); - } - - return abbreviations.First(); - } - - /// - /// Gets the default abbreviation for a given unit type and its numeric enum value. - /// If a unit has more than one abbreviation defined, then it returns the first one. - /// Example: GetDefaultAbbreviation<LengthUnit>(typeof(LengthUnit), 1) => "cm" - /// - /// The unit enum type. - /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. - /// The default unit abbreviation string. - internal string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider = null) - { - if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) - { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unitType, unitValue, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}."); - } - - var abbreviations = lookup.GetAbbreviationsForUnit(unitValue); - if(abbreviations.Count == 0) - { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unitType, unitValue, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}."); - } - - return abbreviations.First(); - } - - /// - /// Get all abbreviations for unit. - /// - /// Enum type for units. - /// Enum value for unit. - /// The format provider to use for lookup. Defaults to if null. - /// Unit abbreviations associated with unit. - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider formatProvider = null) where TUnitType : Enum - { - return GetUnitAbbreviations(typeof(TUnitType), Convert.ToInt32(unit), formatProvider); - } - - /// - /// Get all abbreviations for unit. - /// - /// Enum type for unit. - /// Enum value for unit. - /// The format provider to use for lookup. Defaults to if null. - /// Unit abbreviations associated with unit. - private string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvider formatProvider = null) - { - formatProvider = formatProvider ?? GlobalConfiguration.DefaultCulture; - - if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) - return formatProvider != FallbackCulture ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) : new string[] { }; - - var abbreviations = lookup.GetAbbreviationsForUnit(unitValue); - if(abbreviations.Count == 0) - return formatProvider != FallbackCulture ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) : new string[] { }; - - return abbreviations.ToArray(); - } - - /// - /// Get all abbreviations for all units of a quantity. - /// - /// Enum type for unit. - /// The format provider to use for lookup. Defaults to if null. - /// Unit abbreviations associated with unit. - internal string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider formatProvider = null) - { - formatProvider = formatProvider ?? GlobalConfiguration.DefaultCulture; - - if(!TryGetUnitValueAbbreviationLookup(unitEnumType, formatProvider, out var lookup)) - return formatProvider != FallbackCulture ? GetAllUnitAbbreviationsForQuantity(unitEnumType, FallbackCulture) : new string[] { }; - - return lookup.GetAllUnitAbbreviationsForQuantity(); - } - - internal bool TryGetUnitValueAbbreviationLookup(Type unitType, IFormatProvider formatProvider, out UnitValueAbbreviationLookup unitToAbbreviations) - { - unitToAbbreviations = null; - - formatProvider = formatProvider ?? GlobalConfiguration.DefaultCulture; - - if(!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) - return formatProvider != FallbackCulture ? TryGetUnitValueAbbreviationLookup(unitType, FallbackCulture, out unitToAbbreviations) : false; - - if(!quantitiesForProvider.TryGetValue(unitType, out unitToAbbreviations)) - return formatProvider != FallbackCulture ? TryGetUnitValueAbbreviationLookup(unitType, FallbackCulture, out unitToAbbreviations) : false; - - return true; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitParser.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitParser.cs deleted file mode 100644 index b35a320459..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitParser.cs +++ /dev/null @@ -1,161 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - public sealed class UnitParser - { - private readonly UnitAbbreviationsCache _unitAbbreviationsCache; - - public static UnitParser Default { get; } - - public UnitParser(UnitAbbreviationsCache unitAbbreviationsCache) - { - _unitAbbreviationsCache = unitAbbreviationsCache ?? UnitAbbreviationsCache.Default; - } - - static UnitParser() - { - Default = new UnitParser(UnitAbbreviationsCache.Default); - } - - /// - /// Parses a unit abbreviation for a given unit enumeration type. - /// Example: Parse<LengthUnit>("km") => LengthUnit.Kilometer - /// - /// - /// The format provider to use for lookup. Defaults to if null. - /// - /// - internal TUnitType Parse(string unitAbbreviation, [CanBeNull] IFormatProvider formatProvider = null) where TUnitType : Enum - { - return (TUnitType)Parse(unitAbbreviation, typeof(TUnitType)); - } - - /// - /// Parse a unit abbreviation, such as "kg" or "m", to the unit enum value of the enum type - /// . - /// - /// - /// Unit abbreviation, such as "kg" or "m" for and - /// respectively. - /// - /// Unit enum type, such as and . - /// The format provider to use for lookup. Defaults to if null. - /// Unit enum value, such as . - /// No units match the abbreviation. - /// More than one unit matches the abbreviation. - internal Enum Parse([NotNull] string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider = null) - { - if (unitAbbreviation == null) throw new ArgumentNullException(nameof(unitAbbreviation)); - unitAbbreviation = unitAbbreviation.Trim(); - - if(!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations)) - throw new UnitNotFoundException($"No abbreviations defined for unit type [{unitType}] for culture [{formatProvider}]."); - - var unitIntValues = abbreviations.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true); - - // Narrow the search if too many hits, for example Megabar "Mbar" and Millibar "mbar" need to be distinguished - if (unitIntValues.Count > 1) - unitIntValues = abbreviations.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: false); - - switch (unitIntValues.Count) - { - case 1: - return (Enum) Enum.ToObject(unitType, unitIntValues[0]); - case 0: - throw new UnitNotFoundException($"Unit not found with abbreviation [{unitAbbreviation}] for unit type [{unitType}]."); - default: - string unitsCsv = string.Join(", ", unitIntValues.Select(x => Enum.GetName(unitType, x)).ToArray()); - throw new AmbiguousUnitParseException( - $"Cannot parse \"{unitAbbreviation}\" since it could be either of these: {unitsCsv}"); - } - } - - /// - /// Try to parse a unit abbreviation. - /// - /// The string value. - /// The unit enum value as out result. - /// Type of unit enum. - /// True if successful. - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal bool TryParse(string unitAbbreviation, out TUnitType unit) where TUnitType : Enum - { - return TryParse(unitAbbreviation, null, out unit); - } - - /// - /// Try to parse a unit abbreviation. - /// - /// The string value. - /// The format provider to use for lookup. Defaults to if null. - /// The unit enum value as out result. - /// Type of unit enum. - /// True if successful. - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal bool TryParse(string unitAbbreviation, [CanBeNull] IFormatProvider formatProvider, out TUnitType unit) where TUnitType : Enum - { - unit = default; - - if(!TryParse(unitAbbreviation, typeof(TUnitType), formatProvider, out var unitObj)) - return false; - - unit = (TUnitType)unitObj; - return true; - } - - /// - /// Try to parse a unit abbreviation. - /// - /// The string value. - /// Type of unit enum. - /// The unit enum value as out result. - /// True if successful. - internal bool TryParse(string unitAbbreviation, Type unitType, out Enum unit) - { - return TryParse(unitAbbreviation, unitType, null, out unit); - } - - /// - /// Try to parse a unit abbreviation. - /// - /// The string value. - /// Type of unit enum. - /// The format provider to use for lookup. Defaults to if null. - /// The unit enum value as out result. - /// True if successful. - internal bool TryParse(string unitAbbreviation, Type unitType, [CanBeNull] IFormatProvider formatProvider, out Enum unit) - { - if (unitAbbreviation == null) - { - unit = default; - return false; - } - - unitAbbreviation = unitAbbreviation.Trim(); - unit = default; - - if(!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations)) - return false; - - var unitIntValues = abbreviations.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true); - - // Narrow the search if too many hits, for example Megabar "Mbar" and Millibar "mbar" need to be distinguished - if (unitIntValues.Count > 1) - unitIntValues = abbreviations.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: false); - - if(unitIntValues.Count != 1) - return false; - - unit = (Enum)Enum.ToObject(unitType, unitIntValues[0]); - return true; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitValueAbbreviationLookup.cs b/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitValueAbbreviationLookup.cs deleted file mode 100644 index 48f2482b4a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/CustomCode/UnitValueAbbreviationLookup.cs +++ /dev/null @@ -1,80 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Collections.Generic; -using System.Linq; - -using UnitToAbbreviationMap = System.Collections.Generic.Dictionary>; -using AbbreviationToUnitMap = System.Collections.Generic.Dictionary>; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - internal class UnitValueAbbreviationLookup - { - private readonly UnitToAbbreviationMap unitToAbbreviationMap = new UnitToAbbreviationMap(); - private readonly AbbreviationToUnitMap abbreviationToUnitMap = new AbbreviationToUnitMap(); - private readonly AbbreviationToUnitMap lowerCaseAbbreviationToUnitMap = new AbbreviationToUnitMap(); - - internal string[] GetAllUnitAbbreviationsForQuantity() - { - return unitToAbbreviationMap.Values.SelectMany((abbreviations) => - { - return abbreviations; - } ).Distinct().ToArray(); - } - - internal List GetAbbreviationsForUnit(UnitType unit) where UnitType : Enum - { - return GetAbbreviationsForUnit(Convert.ToInt32(unit)); - } - - internal List GetAbbreviationsForUnit(int unit) - { - if(!unitToAbbreviationMap.TryGetValue(unit, out var abbreviations)) - unitToAbbreviationMap[unit] = abbreviations = new List(); - - return abbreviations.Distinct().ToList(); - } - - internal List GetUnitsForAbbreviation(string abbreviation, bool ignoreCase) - { - var lowerCaseAbbreviation = abbreviation.ToLower(); - var key = ignoreCase ? lowerCaseAbbreviation : abbreviation; - var map = ignoreCase ? lowerCaseAbbreviationToUnitMap : abbreviationToUnitMap; - - if(!map.TryGetValue(key, out List units)) - map[key] = units = new List(); - - return units.Distinct().ToList(); - } - - internal void Add(int unit, string abbreviation, bool setAsDefault = false) - { - var lowerCaseAbbreviation = abbreviation.ToLower(); - - if(!unitToAbbreviationMap.TryGetValue(unit, out var abbreviationsForUnit)) - abbreviationsForUnit = unitToAbbreviationMap[unit] = new List(); - - if(!abbreviationToUnitMap.TryGetValue(abbreviation, out var unitsForAbbreviation)) - abbreviationToUnitMap[abbreviation] = unitsForAbbreviation = new List(); - - if(!lowerCaseAbbreviationToUnitMap.TryGetValue(lowerCaseAbbreviation, out var unitsForLowerCaseAbbreviation)) - lowerCaseAbbreviationToUnitMap[lowerCaseAbbreviation] = unitsForLowerCaseAbbreviation = new List(); - - unitsForLowerCaseAbbreviation.Remove(unit); - unitsForLowerCaseAbbreviation.Add(unit); - - unitsForAbbreviation.Remove(unit); - unitsForAbbreviation.Add(unit); - - abbreviationsForUnit.Remove(abbreviation); - if (setAsDefault) - abbreviationsForUnit.Insert(0, abbreviation); - else - abbreviationsForUnit.Add(abbreviation); - - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.g.cs deleted file mode 100644 index 85cab970be..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Acceleration.g.cs +++ /dev/null @@ -1,801 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Acceleration : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AccelerationUnit? _unit; - - static Acceleration() - { - BaseDimensions = new BaseDimensions(1, 0, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Acceleration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit MeterPerSecondSquared. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Acceleration() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Acceleration(double value, AccelerationUnit unit) - { - if(unit == AccelerationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Acceleration, which is MeterPerSecondSquared. All conversions go via this value. - /// - public static AccelerationUnit BaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; - - /// - /// Represents the largest possible value of Acceleration - /// - public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Acceleration - /// - public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Acceleration; - - /// - /// All units of measurement for the Acceleration quantity. - /// - public static AccelerationUnit[] Units { get; } = Enum.GetValues(typeof(AccelerationUnit)).Cast().Except(new AccelerationUnit[]{ AccelerationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecondSquared. - /// - public static Acceleration Zero { get; } = new Acceleration(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Acceleration.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Acceleration.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Acceleration in CentimetersPerSecondSquared. - /// - public double CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); - - /// - /// Get Acceleration in DecimetersPerSecondSquared. - /// - public double DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); - - /// - /// Get Acceleration in FeetPerSecondSquared. - /// - public double FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); - - /// - /// Get Acceleration in InchesPerSecondSquared. - /// - public double InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); - - /// - /// Get Acceleration in KilometersPerSecondSquared. - /// - public double KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); - - /// - /// Get Acceleration in KnotsPerHour. - /// - public double KnotsPerHour => As(AccelerationUnit.KnotPerHour); - - /// - /// Get Acceleration in KnotsPerMinute. - /// - public double KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); - - /// - /// Get Acceleration in KnotsPerSecond. - /// - public double KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); - - /// - /// Get Acceleration in MetersPerSecondSquared. - /// - public double MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); - - /// - /// Get Acceleration in MicrometersPerSecondSquared. - /// - public double MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); - - /// - /// Get Acceleration in MillimetersPerSecondSquared. - /// - public double MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); - - /// - /// Get Acceleration in MillistandardGravity. - /// - public double MillistandardGravity => As(AccelerationUnit.MillistandardGravity); - - /// - /// Get Acceleration in NanometersPerSecondSquared. - /// - public double NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); - - /// - /// Get Acceleration in StandardGravity. - /// - public double StandardGravity => As(AccelerationUnit.StandardGravity); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AccelerationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AccelerationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Acceleration from CentimetersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromCentimetersPerSecondSquared(double centimeterspersecondsquared) - { - double value = (double) centimeterspersecondsquared; - return new Acceleration(value, AccelerationUnit.CentimeterPerSecondSquared); - } - /// - /// Get Acceleration from DecimetersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromDecimetersPerSecondSquared(double decimeterspersecondsquared) - { - double value = (double) decimeterspersecondsquared; - return new Acceleration(value, AccelerationUnit.DecimeterPerSecondSquared); - } - /// - /// Get Acceleration from FeetPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromFeetPerSecondSquared(double feetpersecondsquared) - { - double value = (double) feetpersecondsquared; - return new Acceleration(value, AccelerationUnit.FootPerSecondSquared); - } - /// - /// Get Acceleration from InchesPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromInchesPerSecondSquared(double inchespersecondsquared) - { - double value = (double) inchespersecondsquared; - return new Acceleration(value, AccelerationUnit.InchPerSecondSquared); - } - /// - /// Get Acceleration from KilometersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromKilometersPerSecondSquared(double kilometerspersecondsquared) - { - double value = (double) kilometerspersecondsquared; - return new Acceleration(value, AccelerationUnit.KilometerPerSecondSquared); - } - /// - /// Get Acceleration from KnotsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromKnotsPerHour(double knotsperhour) - { - double value = (double) knotsperhour; - return new Acceleration(value, AccelerationUnit.KnotPerHour); - } - /// - /// Get Acceleration from KnotsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromKnotsPerMinute(double knotsperminute) - { - double value = (double) knotsperminute; - return new Acceleration(value, AccelerationUnit.KnotPerMinute); - } - /// - /// Get Acceleration from KnotsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromKnotsPerSecond(double knotspersecond) - { - double value = (double) knotspersecond; - return new Acceleration(value, AccelerationUnit.KnotPerSecond); - } - /// - /// Get Acceleration from MetersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromMetersPerSecondSquared(double meterspersecondsquared) - { - double value = (double) meterspersecondsquared; - return new Acceleration(value, AccelerationUnit.MeterPerSecondSquared); - } - /// - /// Get Acceleration from MicrometersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromMicrometersPerSecondSquared(double micrometerspersecondsquared) - { - double value = (double) micrometerspersecondsquared; - return new Acceleration(value, AccelerationUnit.MicrometerPerSecondSquared); - } - /// - /// Get Acceleration from MillimetersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromMillimetersPerSecondSquared(double millimeterspersecondsquared) - { - double value = (double) millimeterspersecondsquared; - return new Acceleration(value, AccelerationUnit.MillimeterPerSecondSquared); - } - /// - /// Get Acceleration from MillistandardGravity. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromMillistandardGravity(double millistandardgravity) - { - double value = (double) millistandardgravity; - return new Acceleration(value, AccelerationUnit.MillistandardGravity); - } - /// - /// Get Acceleration from NanometersPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromNanometersPerSecondSquared(double nanometerspersecondsquared) - { - double value = (double) nanometerspersecondsquared; - return new Acceleration(value, AccelerationUnit.NanometerPerSecondSquared); - } - /// - /// Get Acceleration from StandardGravity. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Acceleration FromStandardGravity(double standardgravity) - { - double value = (double) standardgravity; - return new Acceleration(value, AccelerationUnit.StandardGravity); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Acceleration unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Acceleration From(double value, AccelerationUnit fromUnit) - { - return new Acceleration((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Acceleration Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Acceleration Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Acceleration result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Acceleration result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AccelerationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AccelerationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AccelerationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AccelerationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Acceleration objAcceleration)) throw new ArgumentException("Expected type Acceleration.", nameof(obj)); - - return CompareTo(objAcceleration); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Acceleration other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Acceleration objAcceleration)) - return false; - - return Equals(objAcceleration); - } - - public bool Equals(Acceleration other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Acceleration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Acceleration. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AccelerationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AccelerationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Acceleration to another Acceleration with the unit representation . - /// - /// A Acceleration with the specified unit. - public Acceleration ToUnit(AccelerationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Acceleration(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(AccelerationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.g.cs deleted file mode 100644 index 5ad5fa29f4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ /dev/null @@ -1,818 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class AmountOfSubstance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AmountOfSubstanceUnit? _unit; - - static AmountOfSubstance() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); - Info = new QuantityInfo(QuantityType.AmountOfSubstance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Mole. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public AmountOfSubstance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private AmountOfSubstance(double value, AmountOfSubstanceUnit unit) - { - if(unit == AmountOfSubstanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of AmountOfSubstance, which is Mole. All conversions go via this value. - /// - public static AmountOfSubstanceUnit BaseUnit { get; } = AmountOfSubstanceUnit.Mole; - - /// - /// Represents the largest possible value of AmountOfSubstance - /// - public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of AmountOfSubstance - /// - public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.AmountOfSubstance; - - /// - /// All units of measurement for the AmountOfSubstance quantity. - /// - public static AmountOfSubstanceUnit[] Units { get; } = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().Except(new AmountOfSubstanceUnit[]{ AmountOfSubstanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Mole. - /// - public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => AmountOfSubstance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => AmountOfSubstance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get AmountOfSubstance in Centimoles. - /// - public double Centimoles => As(AmountOfSubstanceUnit.Centimole); - - /// - /// Get AmountOfSubstance in CentipoundMoles. - /// - public double CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); - - /// - /// Get AmountOfSubstance in Decimoles. - /// - public double Decimoles => As(AmountOfSubstanceUnit.Decimole); - - /// - /// Get AmountOfSubstance in DecipoundMoles. - /// - public double DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); - - /// - /// Get AmountOfSubstance in Kilomoles. - /// - public double Kilomoles => As(AmountOfSubstanceUnit.Kilomole); - - /// - /// Get AmountOfSubstance in KilopoundMoles. - /// - public double KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); - - /// - /// Get AmountOfSubstance in Megamoles. - /// - public double Megamoles => As(AmountOfSubstanceUnit.Megamole); - - /// - /// Get AmountOfSubstance in Micromoles. - /// - public double Micromoles => As(AmountOfSubstanceUnit.Micromole); - - /// - /// Get AmountOfSubstance in MicropoundMoles. - /// - public double MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); - - /// - /// Get AmountOfSubstance in Millimoles. - /// - public double Millimoles => As(AmountOfSubstanceUnit.Millimole); - - /// - /// Get AmountOfSubstance in MillipoundMoles. - /// - public double MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); - - /// - /// Get AmountOfSubstance in Moles. - /// - public double Moles => As(AmountOfSubstanceUnit.Mole); - - /// - /// Get AmountOfSubstance in Nanomoles. - /// - public double Nanomoles => As(AmountOfSubstanceUnit.Nanomole); - - /// - /// Get AmountOfSubstance in NanopoundMoles. - /// - public double NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); - - /// - /// Get AmountOfSubstance in PoundMoles. - /// - public double PoundMoles => As(AmountOfSubstanceUnit.PoundMole); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AmountOfSubstanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AmountOfSubstanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get AmountOfSubstance from Centimoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromCentimoles(double centimoles) - { - double value = (double) centimoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Centimole); - } - /// - /// Get AmountOfSubstance from CentipoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromCentipoundMoles(double centipoundmoles) - { - double value = (double) centipoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.CentipoundMole); - } - /// - /// Get AmountOfSubstance from Decimoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromDecimoles(double decimoles) - { - double value = (double) decimoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Decimole); - } - /// - /// Get AmountOfSubstance from DecipoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromDecipoundMoles(double decipoundmoles) - { - double value = (double) decipoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.DecipoundMole); - } - /// - /// Get AmountOfSubstance from Kilomoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromKilomoles(double kilomoles) - { - double value = (double) kilomoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Kilomole); - } - /// - /// Get AmountOfSubstance from KilopoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromKilopoundMoles(double kilopoundmoles) - { - double value = (double) kilopoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.KilopoundMole); - } - /// - /// Get AmountOfSubstance from Megamoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromMegamoles(double megamoles) - { - double value = (double) megamoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Megamole); - } - /// - /// Get AmountOfSubstance from Micromoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromMicromoles(double micromoles) - { - double value = (double) micromoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Micromole); - } - /// - /// Get AmountOfSubstance from MicropoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromMicropoundMoles(double micropoundmoles) - { - double value = (double) micropoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.MicropoundMole); - } - /// - /// Get AmountOfSubstance from Millimoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromMillimoles(double millimoles) - { - double value = (double) millimoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Millimole); - } - /// - /// Get AmountOfSubstance from MillipoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromMillipoundMoles(double millipoundmoles) - { - double value = (double) millipoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.MillipoundMole); - } - /// - /// Get AmountOfSubstance from Moles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromMoles(double moles) - { - double value = (double) moles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Mole); - } - /// - /// Get AmountOfSubstance from Nanomoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromNanomoles(double nanomoles) - { - double value = (double) nanomoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.Nanomole); - } - /// - /// Get AmountOfSubstance from NanopoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromNanopoundMoles(double nanopoundmoles) - { - double value = (double) nanopoundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.NanopoundMole); - } - /// - /// Get AmountOfSubstance from PoundMoles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmountOfSubstance FromPoundMoles(double poundmoles) - { - double value = (double) poundmoles; - return new AmountOfSubstance(value, AmountOfSubstanceUnit.PoundMole); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// AmountOfSubstance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static AmountOfSubstance From(double value, AmountOfSubstanceUnit fromUnit) - { - return new AmountOfSubstance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static AmountOfSubstance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AmountOfSubstance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out AmountOfSubstance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out AmountOfSubstance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AmountOfSubstanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AmountOfSubstanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AmountOfSubstanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AmountOfSubstanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AmountOfSubstance objAmountOfSubstance)) throw new ArgumentException("Expected type AmountOfSubstance.", nameof(obj)); - - return CompareTo(objAmountOfSubstance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(AmountOfSubstance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) - return false; - - return Equals(objAmountOfSubstance); - } - - public bool Equals(AmountOfSubstance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current AmountOfSubstance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AmountOfSubstanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AmountOfSubstanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this AmountOfSubstance to another AmountOfSubstance with the unit representation . - /// - /// A AmountOfSubstance with the specified unit. - public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new AmountOfSubstance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(AmountOfSubstanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.g.cs deleted file mode 100644 index 32343032b5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ /dev/null @@ -1,631 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class AmplitudeRatio : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AmplitudeRatioUnit? _unit; - - static AmplitudeRatio() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.AmplitudeRatio, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DecibelVolt. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public AmplitudeRatio() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private AmplitudeRatio(double value, AmplitudeRatioUnit unit) - { - if(unit == AmplitudeRatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of AmplitudeRatio, which is DecibelVolt. All conversions go via this value. - /// - public static AmplitudeRatioUnit BaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; - - /// - /// Represents the largest possible value of AmplitudeRatio - /// - public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of AmplitudeRatio - /// - public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.AmplitudeRatio; - - /// - /// All units of measurement for the AmplitudeRatio quantity. - /// - public static AmplitudeRatioUnit[] Units { get; } = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().Except(new AmplitudeRatioUnit[]{ AmplitudeRatioUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DecibelVolt. - /// - public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => AmplitudeRatio.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => AmplitudeRatio.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get AmplitudeRatio in DecibelMicrovolts. - /// - public double DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); - - /// - /// Get AmplitudeRatio in DecibelMillivolts. - /// - public double DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); - - /// - /// Get AmplitudeRatio in DecibelsUnloaded. - /// - public double DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); - - /// - /// Get AmplitudeRatio in DecibelVolts. - /// - public double DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AmplitudeRatioUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AmplitudeRatioUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get AmplitudeRatio from DecibelMicrovolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmplitudeRatio FromDecibelMicrovolts(double decibelmicrovolts) - { - double value = (double) decibelmicrovolts; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMicrovolt); - } - /// - /// Get AmplitudeRatio from DecibelMillivolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmplitudeRatio FromDecibelMillivolts(double decibelmillivolts) - { - double value = (double) decibelmillivolts; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMillivolt); - } - /// - /// Get AmplitudeRatio from DecibelsUnloaded. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmplitudeRatio FromDecibelsUnloaded(double decibelsunloaded) - { - double value = (double) decibelsunloaded; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelUnloaded); - } - /// - /// Get AmplitudeRatio from DecibelVolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AmplitudeRatio FromDecibelVolts(double decibelvolts) - { - double value = (double) decibelvolts; - return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelVolt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// AmplitudeRatio unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static AmplitudeRatio From(double value, AmplitudeRatioUnit fromUnit) - { - return new AmplitudeRatio((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static AmplitudeRatio Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AmplitudeRatio Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out AmplitudeRatio result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out AmplitudeRatio result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AmplitudeRatioUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AmplitudeRatioUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AmplitudeRatioUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AmplitudeRatioUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AmplitudeRatio objAmplitudeRatio)) throw new ArgumentException("Expected type AmplitudeRatio.", nameof(obj)); - - return CompareTo(objAmplitudeRatio); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(AmplitudeRatio other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) - return false; - - return Equals(objAmplitudeRatio); - } - - public bool Equals(AmplitudeRatio other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current AmplitudeRatio. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AmplitudeRatioUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AmplitudeRatioUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this AmplitudeRatio to another AmplitudeRatio with the unit representation . - /// - /// A AmplitudeRatio with the specified unit. - public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new AmplitudeRatio(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(AmplitudeRatioUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.g.cs deleted file mode 100644 index c43fedfd87..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Angle.g.cs +++ /dev/null @@ -1,835 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Angle : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AngleUnit? _unit; - - static Angle() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Angle, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Degree. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Angle() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Angle(double value, AngleUnit unit) - { - if(unit == AngleUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Angle, which is Degree. All conversions go via this value. - /// - public static AngleUnit BaseUnit { get; } = AngleUnit.Degree; - - /// - /// Represents the largest possible value of Angle - /// - public static Angle MaxValue { get; } = new Angle(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Angle - /// - public static Angle MinValue { get; } = new Angle(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Angle; - - /// - /// All units of measurement for the Angle quantity. - /// - public static AngleUnit[] Units { get; } = Enum.GetValues(typeof(AngleUnit)).Cast().Except(new AngleUnit[]{ AngleUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Degree. - /// - public static Angle Zero { get; } = new Angle(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Angle.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Angle.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Angle in Arcminutes. - /// - public double Arcminutes => As(AngleUnit.Arcminute); - - /// - /// Get Angle in Arcseconds. - /// - public double Arcseconds => As(AngleUnit.Arcsecond); - - /// - /// Get Angle in Centiradians. - /// - public double Centiradians => As(AngleUnit.Centiradian); - - /// - /// Get Angle in Deciradians. - /// - public double Deciradians => As(AngleUnit.Deciradian); - - /// - /// Get Angle in Degrees. - /// - public double Degrees => As(AngleUnit.Degree); - - /// - /// Get Angle in Gradians. - /// - public double Gradians => As(AngleUnit.Gradian); - - /// - /// Get Angle in Microdegrees. - /// - public double Microdegrees => As(AngleUnit.Microdegree); - - /// - /// Get Angle in Microradians. - /// - public double Microradians => As(AngleUnit.Microradian); - - /// - /// Get Angle in Millidegrees. - /// - public double Millidegrees => As(AngleUnit.Millidegree); - - /// - /// Get Angle in Milliradians. - /// - public double Milliradians => As(AngleUnit.Milliradian); - - /// - /// Get Angle in Nanodegrees. - /// - public double Nanodegrees => As(AngleUnit.Nanodegree); - - /// - /// Get Angle in Nanoradians. - /// - public double Nanoradians => As(AngleUnit.Nanoradian); - - /// - /// Get Angle in NatoMils. - /// - public double NatoMils => As(AngleUnit.NatoMil); - - /// - /// Get Angle in Radians. - /// - public double Radians => As(AngleUnit.Radian); - - /// - /// Get Angle in Revolutions. - /// - public double Revolutions => As(AngleUnit.Revolution); - - /// - /// Get Angle in Tilt. - /// - public double Tilt => As(AngleUnit.Tilt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AngleUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AngleUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Angle from Arcminutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromArcminutes(double arcminutes) - { - double value = (double) arcminutes; - return new Angle(value, AngleUnit.Arcminute); - } - /// - /// Get Angle from Arcseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromArcseconds(double arcseconds) - { - double value = (double) arcseconds; - return new Angle(value, AngleUnit.Arcsecond); - } - /// - /// Get Angle from Centiradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromCentiradians(double centiradians) - { - double value = (double) centiradians; - return new Angle(value, AngleUnit.Centiradian); - } - /// - /// Get Angle from Deciradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromDeciradians(double deciradians) - { - double value = (double) deciradians; - return new Angle(value, AngleUnit.Deciradian); - } - /// - /// Get Angle from Degrees. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromDegrees(double degrees) - { - double value = (double) degrees; - return new Angle(value, AngleUnit.Degree); - } - /// - /// Get Angle from Gradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromGradians(double gradians) - { - double value = (double) gradians; - return new Angle(value, AngleUnit.Gradian); - } - /// - /// Get Angle from Microdegrees. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromMicrodegrees(double microdegrees) - { - double value = (double) microdegrees; - return new Angle(value, AngleUnit.Microdegree); - } - /// - /// Get Angle from Microradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromMicroradians(double microradians) - { - double value = (double) microradians; - return new Angle(value, AngleUnit.Microradian); - } - /// - /// Get Angle from Millidegrees. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromMillidegrees(double millidegrees) - { - double value = (double) millidegrees; - return new Angle(value, AngleUnit.Millidegree); - } - /// - /// Get Angle from Milliradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromMilliradians(double milliradians) - { - double value = (double) milliradians; - return new Angle(value, AngleUnit.Milliradian); - } - /// - /// Get Angle from Nanodegrees. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromNanodegrees(double nanodegrees) - { - double value = (double) nanodegrees; - return new Angle(value, AngleUnit.Nanodegree); - } - /// - /// Get Angle from Nanoradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromNanoradians(double nanoradians) - { - double value = (double) nanoradians; - return new Angle(value, AngleUnit.Nanoradian); - } - /// - /// Get Angle from NatoMils. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromNatoMils(double natomils) - { - double value = (double) natomils; - return new Angle(value, AngleUnit.NatoMil); - } - /// - /// Get Angle from Radians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromRadians(double radians) - { - double value = (double) radians; - return new Angle(value, AngleUnit.Radian); - } - /// - /// Get Angle from Revolutions. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromRevolutions(double revolutions) - { - double value = (double) revolutions; - return new Angle(value, AngleUnit.Revolution); - } - /// - /// Get Angle from Tilt. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Angle FromTilt(double tilt) - { - double value = (double) tilt; - return new Angle(value, AngleUnit.Tilt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Angle unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Angle From(double value, AngleUnit fromUnit) - { - return new Angle((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Angle Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Angle Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Angle result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Angle result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AngleUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AngleUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AngleUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AngleUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Angle objAngle)) throw new ArgumentException("Expected type Angle.", nameof(obj)); - - return CompareTo(objAngle); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Angle other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Angle objAngle)) - return false; - - return Equals(objAngle); - } - - public bool Equals(Angle other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Angle within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Angle. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AngleUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AngleUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Angle to another Angle with the unit representation . - /// - /// A Angle with the specified unit. - public Angle ToUnit(AngleUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Angle(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case AngleUnit.Arcminute: return _value/60; - case AngleUnit.Arcsecond: return _value/3600; - case AngleUnit.Centiradian: return (_value*180/Math.PI) * 1e-2d; - case AngleUnit.Deciradian: return (_value*180/Math.PI) * 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/Math.PI) * 1e-6d; - case AngleUnit.Millidegree: return (_value) * 1e-3d; - case AngleUnit.Milliradian: return (_value*180/Math.PI) * 1e-3d; - case AngleUnit.Nanodegree: return (_value) * 1e-9d; - case AngleUnit.Nanoradian: return (_value*180/Math.PI) * 1e-9d; - case AngleUnit.NatoMil: return _value*9/160; - case AngleUnit.Radian: return _value*180/Math.PI; - case AngleUnit.Revolution: return _value*360; - case AngleUnit.Tilt: return Math.Asin(_value)*180/Math.PI; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(AngleUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case AngleUnit.Arcminute: return baseUnitValue*60; - case AngleUnit.Arcsecond: return baseUnitValue*3600; - case AngleUnit.Centiradian: return (baseUnitValue/180*Math.PI) / 1e-2d; - case AngleUnit.Deciradian: return (baseUnitValue/180*Math.PI) / 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*Math.PI) / 1e-6d; - case AngleUnit.Millidegree: return (baseUnitValue) / 1e-3d; - case AngleUnit.Milliradian: return (baseUnitValue/180*Math.PI) / 1e-3d; - case AngleUnit.Nanodegree: return (baseUnitValue) / 1e-9d; - case AngleUnit.Nanoradian: return (baseUnitValue/180*Math.PI) / 1e-9d; - case AngleUnit.NatoMil: return baseUnitValue*160/9; - case AngleUnit.Radian: return baseUnitValue/180*Math.PI; - case AngleUnit.Revolution: return baseUnitValue/360; - case AngleUnit.Tilt: return Math.Sin(baseUnitValue/180*Math.PI); - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.g.cs deleted file mode 100644 index 3ddcbd6a6e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ApparentEnergy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ApparentEnergyUnit? _unit; - - static ApparentEnergy() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ApparentEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltampereHour. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ApparentEnergy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ApparentEnergy(double value, ApparentEnergyUnit unit) - { - if(unit == ApparentEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ApparentEnergy, which is VoltampereHour. All conversions go via this value. - /// - public static ApparentEnergyUnit BaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; - - /// - /// Represents the largest possible value of ApparentEnergy - /// - public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ApparentEnergy - /// - public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ApparentEnergy; - - /// - /// All units of measurement for the ApparentEnergy quantity. - /// - public static ApparentEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().Except(new ApparentEnergyUnit[]{ ApparentEnergyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereHour. - /// - public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ApparentEnergy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ApparentEnergy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ApparentEnergy in KilovoltampereHours. - /// - public double KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); - - /// - /// Get ApparentEnergy in MegavoltampereHours. - /// - public double MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); - - /// - /// Get ApparentEnergy in VoltampereHours. - /// - public double VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ApparentEnergyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ApparentEnergyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ApparentEnergy from KilovoltampereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentEnergy FromKilovoltampereHours(double kilovoltamperehours) - { - double value = (double) kilovoltamperehours; - return new ApparentEnergy(value, ApparentEnergyUnit.KilovoltampereHour); - } - /// - /// Get ApparentEnergy from MegavoltampereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentEnergy FromMegavoltampereHours(double megavoltamperehours) - { - double value = (double) megavoltamperehours; - return new ApparentEnergy(value, ApparentEnergyUnit.MegavoltampereHour); - } - /// - /// Get ApparentEnergy from VoltampereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentEnergy FromVoltampereHours(double voltamperehours) - { - double value = (double) voltamperehours; - return new ApparentEnergy(value, ApparentEnergyUnit.VoltampereHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ApparentEnergy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit) - { - return new ApparentEnergy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ApparentEnergy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ApparentEnergy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ApparentEnergy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ApparentEnergy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ApparentEnergyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ApparentEnergyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ApparentEnergyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ApparentEnergyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ApparentEnergy objApparentEnergy)) throw new ArgumentException("Expected type ApparentEnergy.", nameof(obj)); - - return CompareTo(objApparentEnergy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ApparentEnergy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ApparentEnergy objApparentEnergy)) - return false; - - return Equals(objApparentEnergy); - } - - public bool Equals(ApparentEnergy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ApparentEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ApparentEnergy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ApparentEnergyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ApparentEnergyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ApparentEnergy to another ApparentEnergy with the unit representation . - /// - /// A ApparentEnergy with the specified unit. - public ApparentEnergy ToUnit(ApparentEnergyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ApparentEnergy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ApparentEnergyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.g.cs deleted file mode 100644 index 0781f3b56a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ApparentPower.g.cs +++ /dev/null @@ -1,631 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ApparentPower : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ApparentPowerUnit? _unit; - - static ApparentPower() - { - BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ApparentPower, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Voltampere. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ApparentPower() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ApparentPower(double value, ApparentPowerUnit unit) - { - if(unit == ApparentPowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ApparentPower, which is Voltampere. All conversions go via this value. - /// - public static ApparentPowerUnit BaseUnit { get; } = ApparentPowerUnit.Voltampere; - - /// - /// Represents the largest possible value of ApparentPower - /// - public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ApparentPower - /// - public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ApparentPower; - - /// - /// All units of measurement for the ApparentPower quantity. - /// - public static ApparentPowerUnit[] Units { get; } = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().Except(new ApparentPowerUnit[]{ ApparentPowerUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Voltampere. - /// - public static ApparentPower Zero { get; } = new ApparentPower(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ApparentPowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ApparentPower.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ApparentPower.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ApparentPower in Gigavoltamperes. - /// - public double Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); - - /// - /// Get ApparentPower in Kilovoltamperes. - /// - public double Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); - - /// - /// Get ApparentPower in Megavoltamperes. - /// - public double Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); - - /// - /// Get ApparentPower in Voltamperes. - /// - public double Voltamperes => As(ApparentPowerUnit.Voltampere); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ApparentPowerUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ApparentPowerUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ApparentPower from Gigavoltamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentPower FromGigavoltamperes(double gigavoltamperes) - { - double value = (double) gigavoltamperes; - return new ApparentPower(value, ApparentPowerUnit.Gigavoltampere); - } - /// - /// Get ApparentPower from Kilovoltamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentPower FromKilovoltamperes(double kilovoltamperes) - { - double value = (double) kilovoltamperes; - return new ApparentPower(value, ApparentPowerUnit.Kilovoltampere); - } - /// - /// Get ApparentPower from Megavoltamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentPower FromMegavoltamperes(double megavoltamperes) - { - double value = (double) megavoltamperes; - return new ApparentPower(value, ApparentPowerUnit.Megavoltampere); - } - /// - /// Get ApparentPower from Voltamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ApparentPower FromVoltamperes(double voltamperes) - { - double value = (double) voltamperes; - return new ApparentPower(value, ApparentPowerUnit.Voltampere); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ApparentPower unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ApparentPower From(double value, ApparentPowerUnit fromUnit) - { - return new ApparentPower((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ApparentPower Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ApparentPower Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ApparentPower result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ApparentPower result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ApparentPowerUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ApparentPowerUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ApparentPowerUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ApparentPowerUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ApparentPower objApparentPower)) throw new ArgumentException("Expected type ApparentPower.", nameof(obj)); - - return CompareTo(objApparentPower); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ApparentPower other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ApparentPower objApparentPower)) - return false; - - return Equals(objApparentPower); - } - - public bool Equals(ApparentPower other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ApparentPower within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ApparentPower. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ApparentPowerUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ApparentPowerUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ApparentPower to another ApparentPower with the unit representation . - /// - /// A ApparentPower with the specified unit. - public ApparentPower ToUnit(ApparentPowerUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ApparentPower(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ApparentPowerUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs deleted file mode 100644 index 2e8dfb7f71..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Area.g.cs +++ /dev/null @@ -1,801 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Area : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AreaUnit? _unit; - - static Area() - { - BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Area, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit SquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Area() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Area(double value, AreaUnit unit) - { - if(unit == AreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Area, which is SquareMeter. All conversions go via this value. - /// - public static AreaUnit BaseUnit { get; } = AreaUnit.SquareMeter; - - /// - /// Represents the largest possible value of Area - /// - public static Area MaxValue { get; } = new Area(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Area - /// - public static Area MinValue { get; } = new Area(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Area; - - /// - /// All units of measurement for the Area quantity. - /// - public static AreaUnit[] Units { get; } = Enum.GetValues(typeof(AreaUnit)).Cast().Except(new AreaUnit[]{ AreaUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeter. - /// - public static Area Zero { get; } = new Area(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Area.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Area.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Area in Acres. - /// - public double Acres => As(AreaUnit.Acre); - - /// - /// Get Area in Hectares. - /// - public double Hectares => As(AreaUnit.Hectare); - - /// - /// Get Area in SquareCentimeters. - /// - public double SquareCentimeters => As(AreaUnit.SquareCentimeter); - - /// - /// Get Area in SquareDecimeters. - /// - public double SquareDecimeters => As(AreaUnit.SquareDecimeter); - - /// - /// Get Area in SquareFeet. - /// - public double SquareFeet => As(AreaUnit.SquareFoot); - - /// - /// Get Area in SquareInches. - /// - public double SquareInches => As(AreaUnit.SquareInch); - - /// - /// Get Area in SquareKilometers. - /// - public double SquareKilometers => As(AreaUnit.SquareKilometer); - - /// - /// Get Area in SquareMeters. - /// - public double SquareMeters => As(AreaUnit.SquareMeter); - - /// - /// Get Area in SquareMicrometers. - /// - public double SquareMicrometers => As(AreaUnit.SquareMicrometer); - - /// - /// Get Area in SquareMiles. - /// - public double SquareMiles => As(AreaUnit.SquareMile); - - /// - /// Get Area in SquareMillimeters. - /// - public double SquareMillimeters => As(AreaUnit.SquareMillimeter); - - /// - /// Get Area in SquareNauticalMiles. - /// - public double SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); - - /// - /// Get Area in SquareYards. - /// - public double SquareYards => As(AreaUnit.SquareYard); - - /// - /// Get Area in UsSurveySquareFeet. - /// - public double UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AreaUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AreaUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Area from Acres. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromAcres(double acres) - { - double value = (double) acres; - return new Area(value, AreaUnit.Acre); - } - /// - /// Get Area from Hectares. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromHectares(double hectares) - { - double value = (double) hectares; - return new Area(value, AreaUnit.Hectare); - } - /// - /// Get Area from SquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareCentimeters(double squarecentimeters) - { - double value = (double) squarecentimeters; - return new Area(value, AreaUnit.SquareCentimeter); - } - /// - /// Get Area from SquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareDecimeters(double squaredecimeters) - { - double value = (double) squaredecimeters; - return new Area(value, AreaUnit.SquareDecimeter); - } - /// - /// Get Area from SquareFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareFeet(double squarefeet) - { - double value = (double) squarefeet; - return new Area(value, AreaUnit.SquareFoot); - } - /// - /// Get Area from SquareInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareInches(double squareinches) - { - double value = (double) squareinches; - return new Area(value, AreaUnit.SquareInch); - } - /// - /// Get Area from SquareKilometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareKilometers(double squarekilometers) - { - double value = (double) squarekilometers; - return new Area(value, AreaUnit.SquareKilometer); - } - /// - /// Get Area from SquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareMeters(double squaremeters) - { - double value = (double) squaremeters; - return new Area(value, AreaUnit.SquareMeter); - } - /// - /// Get Area from SquareMicrometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareMicrometers(double squaremicrometers) - { - double value = (double) squaremicrometers; - return new Area(value, AreaUnit.SquareMicrometer); - } - /// - /// Get Area from SquareMiles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareMiles(double squaremiles) - { - double value = (double) squaremiles; - return new Area(value, AreaUnit.SquareMile); - } - /// - /// Get Area from SquareMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareMillimeters(double squaremillimeters) - { - double value = (double) squaremillimeters; - return new Area(value, AreaUnit.SquareMillimeter); - } - /// - /// Get Area from SquareNauticalMiles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareNauticalMiles(double squarenauticalmiles) - { - double value = (double) squarenauticalmiles; - return new Area(value, AreaUnit.SquareNauticalMile); - } - /// - /// Get Area from SquareYards. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromSquareYards(double squareyards) - { - double value = (double) squareyards; - return new Area(value, AreaUnit.SquareYard); - } - /// - /// Get Area from UsSurveySquareFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Area FromUsSurveySquareFeet(double ussurveysquarefeet) - { - double value = (double) ussurveysquarefeet; - return new Area(value, AreaUnit.UsSurveySquareFoot); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Area unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Area From(double value, AreaUnit fromUnit) - { - return new Area((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Area Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Area Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Area result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Area result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AreaUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AreaUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AreaUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AreaUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Area objArea)) throw new ArgumentException("Expected type Area.", nameof(obj)); - - return CompareTo(objArea); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Area other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Area objArea)) - return false; - - return Equals(objArea); - } - - public bool Equals(Area other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Area within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Area other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Area. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AreaUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AreaUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Area to another Area with the unit representation . - /// - /// A Area with the specified unit. - public Area ToUnit(AreaUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Area(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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*0.092903; - 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."); - } - } - - private double AsBaseNumericType(AreaUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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/0.092903; - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.g.cs deleted file mode 100644 index 0a351eab96..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaDensity.g.cs +++ /dev/null @@ -1,580 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The area density of a two-dimensional object is calculated as the mass per unit area. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class AreaDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AreaDensityUnit? _unit; - - static AreaDensity() - { - BaseDimensions = new BaseDimensions(-2, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.AreaDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public AreaDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private AreaDensity(double value, AreaDensityUnit unit) - { - if(unit == AreaDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of AreaDensity, which is KilogramPerSquareMeter. All conversions go via this value. - /// - public static AreaDensityUnit BaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; - - /// - /// Represents the largest possible value of AreaDensity - /// - public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of AreaDensity - /// - public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.AreaDensity; - - /// - /// All units of measurement for the AreaDensity quantity. - /// - public static AreaDensityUnit[] Units { get; } = Enum.GetValues(typeof(AreaDensityUnit)).Cast().Except(new AreaDensityUnit[]{ AreaDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSquareMeter. - /// - public static AreaDensity Zero { get; } = new AreaDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AreaDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => AreaDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => AreaDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get AreaDensity in KilogramsPerSquareMeter. - /// - public double KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AreaDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AreaDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get AreaDensity from KilogramsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaDensity FromKilogramsPerSquareMeter(double kilogramspersquaremeter) - { - double value = (double) kilogramspersquaremeter; - return new AreaDensity(value, AreaDensityUnit.KilogramPerSquareMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// AreaDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static AreaDensity From(double value, AreaDensityUnit fromUnit) - { - return new AreaDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static AreaDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AreaDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out AreaDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out AreaDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AreaDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AreaDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AreaDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AreaDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AreaDensity objAreaDensity)) throw new ArgumentException("Expected type AreaDensity.", nameof(obj)); - - return CompareTo(objAreaDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(AreaDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is AreaDensity objAreaDensity)) - return false; - - return Equals(objAreaDensity); - } - - public bool Equals(AreaDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another AreaDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current AreaDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AreaDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AreaDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this AreaDensity to another AreaDensity with the unit representation . - /// - /// A AreaDensity with the specified unit. - public AreaDensity ToUnit(AreaDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new AreaDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case AreaDensityUnit.KilogramPerSquareMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(AreaDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case AreaDensityUnit.KilogramPerSquareMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs deleted file mode 100644 index 6b9b75cc31..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ /dev/null @@ -1,665 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A geometric property of an area that reflects how its points are distributed with regard to an axis. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class AreaMomentOfInertia : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly AreaMomentOfInertiaUnit? _unit; - - static AreaMomentOfInertia() - { - BaseDimensions = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.AreaMomentOfInertia, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit MeterToTheFourth. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public AreaMomentOfInertia() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) - { - if(unit == AreaMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of AreaMomentOfInertia, which is MeterToTheFourth. All conversions go via this value. - /// - public static AreaMomentOfInertiaUnit BaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; - - /// - /// Represents the largest possible value of AreaMomentOfInertia - /// - public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of AreaMomentOfInertia - /// - public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.AreaMomentOfInertia; - - /// - /// All units of measurement for the AreaMomentOfInertia quantity. - /// - public static AreaMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().Except(new AreaMomentOfInertiaUnit[]{ AreaMomentOfInertiaUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheFourth. - /// - public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public AreaMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => AreaMomentOfInertia.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => AreaMomentOfInertia.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get AreaMomentOfInertia in CentimetersToTheFourth. - /// - public double CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); - - /// - /// Get AreaMomentOfInertia in DecimetersToTheFourth. - /// - public double DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); - - /// - /// Get AreaMomentOfInertia in FeetToTheFourth. - /// - public double FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); - - /// - /// Get AreaMomentOfInertia in InchesToTheFourth. - /// - public double InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); - - /// - /// Get AreaMomentOfInertia in MetersToTheFourth. - /// - public double MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); - - /// - /// Get AreaMomentOfInertia in MillimetersToTheFourth. - /// - public double MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(AreaMomentOfInertiaUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get AreaMomentOfInertia from CentimetersToTheFourth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaMomentOfInertia FromCentimetersToTheFourth(double centimeterstothefourth) - { - double value = (double) centimeterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.CentimeterToTheFourth); - } - /// - /// Get AreaMomentOfInertia from DecimetersToTheFourth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaMomentOfInertia FromDecimetersToTheFourth(double decimeterstothefourth) - { - double value = (double) decimeterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.DecimeterToTheFourth); - } - /// - /// Get AreaMomentOfInertia from FeetToTheFourth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaMomentOfInertia FromFeetToTheFourth(double feettothefourth) - { - double value = (double) feettothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.FootToTheFourth); - } - /// - /// Get AreaMomentOfInertia from InchesToTheFourth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaMomentOfInertia FromInchesToTheFourth(double inchestothefourth) - { - double value = (double) inchestothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.InchToTheFourth); - } - /// - /// Get AreaMomentOfInertia from MetersToTheFourth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaMomentOfInertia FromMetersToTheFourth(double meterstothefourth) - { - double value = (double) meterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MeterToTheFourth); - } - /// - /// Get AreaMomentOfInertia from MillimetersToTheFourth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static AreaMomentOfInertia FromMillimetersToTheFourth(double millimeterstothefourth) - { - double value = (double) millimeterstothefourth; - return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MillimeterToTheFourth); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// AreaMomentOfInertia unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static AreaMomentOfInertia From(double value, AreaMomentOfInertiaUnit fromUnit) - { - return new AreaMomentOfInertia((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static AreaMomentOfInertia Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AreaMomentOfInertia Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out AreaMomentOfInertia result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out AreaMomentOfInertia result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static AreaMomentOfInertiaUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static AreaMomentOfInertiaUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out AreaMomentOfInertiaUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out AreaMomentOfInertiaUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is AreaMomentOfInertia objAreaMomentOfInertia)) throw new ArgumentException("Expected type AreaMomentOfInertia.", nameof(obj)); - - return CompareTo(objAreaMomentOfInertia); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(AreaMomentOfInertia other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) - return false; - - return Equals(objAreaMomentOfInertia); - } - - public bool Equals(AreaMomentOfInertia other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current AreaMomentOfInertia. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((AreaMomentOfInertiaUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(AreaMomentOfInertiaUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this AreaMomentOfInertia to another AreaMomentOfInertia with the unit representation . - /// - /// A AreaMomentOfInertia with the specified unit. - public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new AreaMomentOfInertia(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return _value/1e8; - case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return _value/1e4; - case AreaMomentOfInertiaUnit.FootToTheFourth: return _value*Math.Pow(0.3048, 4); - case AreaMomentOfInertiaUnit.InchToTheFourth: return _value*Math.Pow(2.54e-2, 4); - case AreaMomentOfInertiaUnit.MeterToTheFourth: return _value; - case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return _value/1e12; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(AreaMomentOfInertiaUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case AreaMomentOfInertiaUnit.CentimeterToTheFourth: return baseUnitValue*1e8; - case AreaMomentOfInertiaUnit.DecimeterToTheFourth: return baseUnitValue*1e4; - case AreaMomentOfInertiaUnit.FootToTheFourth: return baseUnitValue/Math.Pow(0.3048, 4); - case AreaMomentOfInertiaUnit.InchToTheFourth: return baseUnitValue/Math.Pow(2.54e-2, 4); - case AreaMomentOfInertiaUnit.MeterToTheFourth: return baseUnitValue; - case AreaMomentOfInertiaUnit.MillimeterToTheFourth: return baseUnitValue*1e12; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.g.cs deleted file mode 100644 index 8f5502bd4e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BitRate.g.cs +++ /dev/null @@ -1,1008 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time. - /// - /// - /// https://en.wikipedia.org/wiki/Bit_rate - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class BitRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly decimal _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly BitRateUnit? _unit; - - static BitRate() - { - BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.BitRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit BitPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public BitRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private BitRate(decimal value, BitRateUnit unit) - { - if(unit == BitRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = value; - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of BitRate, which is BitPerSecond. All conversions go via this value. - /// - public static BitRateUnit BaseUnit { get; } = BitRateUnit.BitPerSecond; - - /// - /// Represents the largest possible value of BitRate - /// - public static BitRate MaxValue { get; } = new BitRate(decimal.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of BitRate - /// - public static BitRate MinValue { get; } = new BitRate(decimal.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.BitRate; - - /// - /// All units of measurement for the BitRate quantity. - /// - public static BitRateUnit[] Units { get; } = Enum.GetValues(typeof(BitRateUnit)).Cast().Except(new BitRateUnit[]{ BitRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit BitPerSecond. - /// - public static BitRate Zero { get; } = new BitRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public BitRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => BitRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => BitRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get BitRate in BitsPerSecond. - /// - public double BitsPerSecond => As(BitRateUnit.BitPerSecond); - - /// - /// Get BitRate in BytesPerSecond. - /// - public double BytesPerSecond => As(BitRateUnit.BytePerSecond); - - /// - /// Get BitRate in ExabitsPerSecond. - /// - public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); - - /// - /// Get BitRate in ExabytesPerSecond. - /// - public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); - - /// - /// Get BitRate in ExbibitsPerSecond. - /// - public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); - - /// - /// Get BitRate in ExbibytesPerSecond. - /// - public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); - - /// - /// Get BitRate in GibibitsPerSecond. - /// - public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); - - /// - /// Get BitRate in GibibytesPerSecond. - /// - public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); - - /// - /// Get BitRate in GigabitsPerSecond. - /// - public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); - - /// - /// Get BitRate in GigabytesPerSecond. - /// - public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); - - /// - /// Get BitRate in KibibitsPerSecond. - /// - public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); - - /// - /// Get BitRate in KibibytesPerSecond. - /// - public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); - - /// - /// Get BitRate in KilobitsPerSecond. - /// - public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); - - /// - /// Get BitRate in KilobytesPerSecond. - /// - public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); - - /// - /// Get BitRate in MebibitsPerSecond. - /// - public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); - - /// - /// Get BitRate in MebibytesPerSecond. - /// - public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); - - /// - /// Get BitRate in MegabitsPerSecond. - /// - public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); - - /// - /// Get BitRate in MegabytesPerSecond. - /// - public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); - - /// - /// Get BitRate in PebibitsPerSecond. - /// - public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); - - /// - /// Get BitRate in PebibytesPerSecond. - /// - public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); - - /// - /// Get BitRate in PetabitsPerSecond. - /// - public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); - - /// - /// Get BitRate in PetabytesPerSecond. - /// - public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); - - /// - /// Get BitRate in TebibitsPerSecond. - /// - public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); - - /// - /// Get BitRate in TebibytesPerSecond. - /// - public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); - - /// - /// Get BitRate in TerabitsPerSecond. - /// - public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); - - /// - /// Get BitRate in TerabytesPerSecond. - /// - public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(BitRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(BitRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get BitRate from BitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromBitsPerSecond(double bitspersecond) - { - decimal value = (decimal) bitspersecond; - return new BitRate(value, BitRateUnit.BitPerSecond); - } - /// - /// Get BitRate from BytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromBytesPerSecond(double bytespersecond) - { - decimal value = (decimal) bytespersecond; - return new BitRate(value, BitRateUnit.BytePerSecond); - } - /// - /// Get BitRate from ExabitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromExabitsPerSecond(double exabitspersecond) - { - decimal value = (decimal) exabitspersecond; - return new BitRate(value, BitRateUnit.ExabitPerSecond); - } - /// - /// Get BitRate from ExabytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromExabytesPerSecond(double exabytespersecond) - { - decimal value = (decimal) exabytespersecond; - return new BitRate(value, BitRateUnit.ExabytePerSecond); - } - /// - /// Get BitRate from ExbibitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromExbibitsPerSecond(double exbibitspersecond) - { - decimal value = (decimal) exbibitspersecond; - return new BitRate(value, BitRateUnit.ExbibitPerSecond); - } - /// - /// Get BitRate from ExbibytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromExbibytesPerSecond(double exbibytespersecond) - { - decimal value = (decimal) exbibytespersecond; - return new BitRate(value, BitRateUnit.ExbibytePerSecond); - } - /// - /// Get BitRate from GibibitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromGibibitsPerSecond(double gibibitspersecond) - { - decimal value = (decimal) gibibitspersecond; - return new BitRate(value, BitRateUnit.GibibitPerSecond); - } - /// - /// Get BitRate from GibibytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromGibibytesPerSecond(double gibibytespersecond) - { - decimal value = (decimal) gibibytespersecond; - return new BitRate(value, BitRateUnit.GibibytePerSecond); - } - /// - /// Get BitRate from GigabitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromGigabitsPerSecond(double gigabitspersecond) - { - decimal value = (decimal) gigabitspersecond; - return new BitRate(value, BitRateUnit.GigabitPerSecond); - } - /// - /// Get BitRate from GigabytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromGigabytesPerSecond(double gigabytespersecond) - { - decimal value = (decimal) gigabytespersecond; - return new BitRate(value, BitRateUnit.GigabytePerSecond); - } - /// - /// Get BitRate from KibibitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromKibibitsPerSecond(double kibibitspersecond) - { - decimal value = (decimal) kibibitspersecond; - return new BitRate(value, BitRateUnit.KibibitPerSecond); - } - /// - /// Get BitRate from KibibytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromKibibytesPerSecond(double kibibytespersecond) - { - decimal value = (decimal) kibibytespersecond; - return new BitRate(value, BitRateUnit.KibibytePerSecond); - } - /// - /// Get BitRate from KilobitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromKilobitsPerSecond(double kilobitspersecond) - { - decimal value = (decimal) kilobitspersecond; - return new BitRate(value, BitRateUnit.KilobitPerSecond); - } - /// - /// Get BitRate from KilobytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromKilobytesPerSecond(double kilobytespersecond) - { - decimal value = (decimal) kilobytespersecond; - return new BitRate(value, BitRateUnit.KilobytePerSecond); - } - /// - /// Get BitRate from MebibitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromMebibitsPerSecond(double mebibitspersecond) - { - decimal value = (decimal) mebibitspersecond; - return new BitRate(value, BitRateUnit.MebibitPerSecond); - } - /// - /// Get BitRate from MebibytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromMebibytesPerSecond(double mebibytespersecond) - { - decimal value = (decimal) mebibytespersecond; - return new BitRate(value, BitRateUnit.MebibytePerSecond); - } - /// - /// Get BitRate from MegabitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromMegabitsPerSecond(double megabitspersecond) - { - decimal value = (decimal) megabitspersecond; - return new BitRate(value, BitRateUnit.MegabitPerSecond); - } - /// - /// Get BitRate from MegabytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromMegabytesPerSecond(double megabytespersecond) - { - decimal value = (decimal) megabytespersecond; - return new BitRate(value, BitRateUnit.MegabytePerSecond); - } - /// - /// Get BitRate from PebibitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromPebibitsPerSecond(double pebibitspersecond) - { - decimal value = (decimal) pebibitspersecond; - return new BitRate(value, BitRateUnit.PebibitPerSecond); - } - /// - /// Get BitRate from PebibytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromPebibytesPerSecond(double pebibytespersecond) - { - decimal value = (decimal) pebibytespersecond; - return new BitRate(value, BitRateUnit.PebibytePerSecond); - } - /// - /// Get BitRate from PetabitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromPetabitsPerSecond(double petabitspersecond) - { - decimal value = (decimal) petabitspersecond; - return new BitRate(value, BitRateUnit.PetabitPerSecond); - } - /// - /// Get BitRate from PetabytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromPetabytesPerSecond(double petabytespersecond) - { - decimal value = (decimal) petabytespersecond; - return new BitRate(value, BitRateUnit.PetabytePerSecond); - } - /// - /// Get BitRate from TebibitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromTebibitsPerSecond(double tebibitspersecond) - { - decimal value = (decimal) tebibitspersecond; - return new BitRate(value, BitRateUnit.TebibitPerSecond); - } - /// - /// Get BitRate from TebibytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromTebibytesPerSecond(double tebibytespersecond) - { - decimal value = (decimal) tebibytespersecond; - return new BitRate(value, BitRateUnit.TebibytePerSecond); - } - /// - /// Get BitRate from TerabitsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromTerabitsPerSecond(double terabitspersecond) - { - decimal value = (decimal) terabitspersecond; - return new BitRate(value, BitRateUnit.TerabitPerSecond); - } - /// - /// Get BitRate from TerabytesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BitRate FromTerabytesPerSecond(double terabytespersecond) - { - decimal value = (decimal) terabytespersecond; - return new BitRate(value, BitRateUnit.TerabytePerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// BitRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static BitRate From(double value, BitRateUnit fromUnit) - { - return new BitRate((decimal)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static BitRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static BitRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out BitRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out BitRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static BitRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static BitRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out BitRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out BitRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is BitRate objBitRate)) throw new ArgumentException("Expected type BitRate.", nameof(obj)); - - return CompareTo(objBitRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(BitRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is BitRate objBitRate)) - return false; - - return Equals(objBitRate); - } - - public bool Equals(BitRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another BitRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current BitRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((BitRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(BitRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this BitRate to another BitRate with the unit representation . - /// - /// A BitRate with the specified unit. - public BitRate ToUnit(BitRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new BitRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private decimal AsBaseUnit() - { - switch(Unit) - { - case BitRateUnit.BitPerSecond: return _value; - case BitRateUnit.BytePerSecond: return _value*8m; - case BitRateUnit.ExabitPerSecond: return (_value) * 1e18m; - case BitRateUnit.ExabytePerSecond: return (_value*8m) * 1e18m; - case BitRateUnit.ExbibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.ExbibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.GibibitPerSecond: return (_value) * (1024m * 1024 * 1024); - case BitRateUnit.GibibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024); - case BitRateUnit.GigabitPerSecond: return (_value) * 1e9m; - case BitRateUnit.GigabytePerSecond: return (_value*8m) * 1e9m; - case BitRateUnit.KibibitPerSecond: return (_value) * 1024m; - case BitRateUnit.KibibytePerSecond: return (_value*8m) * 1024m; - case BitRateUnit.KilobitPerSecond: return (_value) * 1e3m; - case BitRateUnit.KilobytePerSecond: return (_value*8m) * 1e3m; - case BitRateUnit.MebibitPerSecond: return (_value) * (1024m * 1024); - case BitRateUnit.MebibytePerSecond: return (_value*8m) * (1024m * 1024); - case BitRateUnit.MegabitPerSecond: return (_value) * 1e6m; - case BitRateUnit.MegabytePerSecond: return (_value*8m) * 1e6m; - case BitRateUnit.PebibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PebibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PetabitPerSecond: return (_value) * 1e15m; - case BitRateUnit.PetabytePerSecond: return (_value*8m) * 1e15m; - case BitRateUnit.TebibitPerSecond: return (_value) * (1024m * 1024 * 1024 * 1024); - case BitRateUnit.TebibytePerSecond: return (_value*8m) * (1024m * 1024 * 1024 * 1024); - case BitRateUnit.TerabitPerSecond: return (_value) * 1e12m; - case BitRateUnit.TerabytePerSecond: return (_value*8m) * 1e12m; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private decimal AsBaseNumericType(BitRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case BitRateUnit.BitPerSecond: return baseUnitValue; - case BitRateUnit.BytePerSecond: return baseUnitValue/8m; - case BitRateUnit.ExabitPerSecond: return (baseUnitValue) / 1e18m; - case BitRateUnit.ExabytePerSecond: return (baseUnitValue/8m) / 1e18m; - case BitRateUnit.ExbibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.ExbibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.GibibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024); - case BitRateUnit.GibibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024); - case BitRateUnit.GigabitPerSecond: return (baseUnitValue) / 1e9m; - case BitRateUnit.GigabytePerSecond: return (baseUnitValue/8m) / 1e9m; - case BitRateUnit.KibibitPerSecond: return (baseUnitValue) / 1024m; - case BitRateUnit.KibibytePerSecond: return (baseUnitValue/8m) / 1024m; - case BitRateUnit.KilobitPerSecond: return (baseUnitValue) / 1e3m; - case BitRateUnit.KilobytePerSecond: return (baseUnitValue/8m) / 1e3m; - case BitRateUnit.MebibitPerSecond: return (baseUnitValue) / (1024m * 1024); - case BitRateUnit.MebibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024); - case BitRateUnit.MegabitPerSecond: return (baseUnitValue) / 1e6m; - case BitRateUnit.MegabytePerSecond: return (baseUnitValue/8m) / 1e6m; - case BitRateUnit.PebibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PebibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024); - case BitRateUnit.PetabitPerSecond: return (baseUnitValue) / 1e15m; - case BitRateUnit.PetabytePerSecond: return (baseUnitValue/8m) / 1e15m; - case BitRateUnit.TebibitPerSecond: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024); - case BitRateUnit.TebibytePerSecond: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024); - case BitRateUnit.TerabitPerSecond: return (baseUnitValue) / 1e12m; - case BitRateUnit.TerabytePerSecond: return (baseUnitValue/8m) / 1e12m; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs deleted file mode 100644 index 81d4e9c4d7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class BrakeSpecificFuelConsumption : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly BrakeSpecificFuelConsumptionUnit? _unit; - - static BrakeSpecificFuelConsumption() - { - BaseDimensions = new BaseDimensions(-2, 0, 2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.BrakeSpecificFuelConsumption, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerJoule. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public BrakeSpecificFuelConsumption() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) - { - if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of BrakeSpecificFuelConsumption, which is KilogramPerJoule. All conversions go via this value. - /// - public static BrakeSpecificFuelConsumptionUnit BaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; - - /// - /// Represents the largest possible value of BrakeSpecificFuelConsumption - /// - public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of BrakeSpecificFuelConsumption - /// - public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.BrakeSpecificFuelConsumption; - - /// - /// All units of measurement for the BrakeSpecificFuelConsumption quantity. - /// - public static BrakeSpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().Except(new BrakeSpecificFuelConsumptionUnit[]{ BrakeSpecificFuelConsumptionUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerJoule. - /// - public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public BrakeSpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => BrakeSpecificFuelConsumption.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => BrakeSpecificFuelConsumption.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get BrakeSpecificFuelConsumption in GramsPerKiloWattHour. - /// - public double GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); - - /// - /// Get BrakeSpecificFuelConsumption in KilogramsPerJoule. - /// - public double KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); - - /// - /// Get BrakeSpecificFuelConsumption in PoundsPerMechanicalHorsepowerHour. - /// - public double PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get BrakeSpecificFuelConsumption from GramsPerKiloWattHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(double gramsperkilowatthour) - { - double value = (double) gramsperkilowatthour; - return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); - } - /// - /// Get BrakeSpecificFuelConsumption from KilogramsPerJoule. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(double kilogramsperjoule) - { - double value = (double) kilogramsperjoule; - return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); - } - /// - /// Get BrakeSpecificFuelConsumption from PoundsPerMechanicalHorsepowerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(double poundspermechanicalhorsepowerhour) - { - double value = (double) poundspermechanicalhorsepowerhour; - return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// BrakeSpecificFuelConsumption unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static BrakeSpecificFuelConsumption From(double value, BrakeSpecificFuelConsumptionUnit fromUnit) - { - return new BrakeSpecificFuelConsumption((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static BrakeSpecificFuelConsumption Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static BrakeSpecificFuelConsumption Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out BrakeSpecificFuelConsumption result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out BrakeSpecificFuelConsumption result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out BrakeSpecificFuelConsumptionUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out BrakeSpecificFuelConsumptionUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) throw new ArgumentException("Expected type BrakeSpecificFuelConsumption.", nameof(obj)); - - return CompareTo(objBrakeSpecificFuelConsumption); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(BrakeSpecificFuelConsumption other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) - return false; - - return Equals(objBrakeSpecificFuelConsumption); - } - - public bool Equals(BrakeSpecificFuelConsumption other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another BrakeSpecificFuelConsumption within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current BrakeSpecificFuelConsumption. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((BrakeSpecificFuelConsumptionUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(BrakeSpecificFuelConsumptionUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this BrakeSpecificFuelConsumption to another BrakeSpecificFuelConsumption with the unit representation . - /// - /// A BrakeSpecificFuelConsumption with the specified unit. - public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new BrakeSpecificFuelConsumption(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(BrakeSpecificFuelConsumptionUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.g.cs deleted file mode 100644 index 211e9d682b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Capacitance.g.cs +++ /dev/null @@ -1,685 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Capacitance is the ability of a body to store an electric charge. - /// - /// - /// https://en.wikipedia.org/wiki/Capacitance - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Capacitance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly CapacitanceUnit? _unit; - - static Capacitance() - { - BaseDimensions = new BaseDimensions(-2, -1, 4, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Capacitance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Farad. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Capacitance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Capacitance(double value, CapacitanceUnit unit) - { - if(unit == CapacitanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Capacitance, which is Farad. All conversions go via this value. - /// - public static CapacitanceUnit BaseUnit { get; } = CapacitanceUnit.Farad; - - /// - /// Represents the largest possible value of Capacitance - /// - public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Capacitance - /// - public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Capacitance; - - /// - /// All units of measurement for the Capacitance quantity. - /// - public static CapacitanceUnit[] Units { get; } = Enum.GetValues(typeof(CapacitanceUnit)).Cast().Except(new CapacitanceUnit[]{ CapacitanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Farad. - /// - public static Capacitance Zero { get; } = new Capacitance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public CapacitanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Capacitance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Capacitance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Capacitance in Farads. - /// - public double Farads => As(CapacitanceUnit.Farad); - - /// - /// Get Capacitance in Kilofarads. - /// - public double Kilofarads => As(CapacitanceUnit.Kilofarad); - - /// - /// Get Capacitance in Megafarads. - /// - public double Megafarads => As(CapacitanceUnit.Megafarad); - - /// - /// Get Capacitance in Microfarads. - /// - public double Microfarads => As(CapacitanceUnit.Microfarad); - - /// - /// Get Capacitance in Millifarads. - /// - public double Millifarads => As(CapacitanceUnit.Millifarad); - - /// - /// Get Capacitance in Nanofarads. - /// - public double Nanofarads => As(CapacitanceUnit.Nanofarad); - - /// - /// Get Capacitance in Picofarads. - /// - public double Picofarads => As(CapacitanceUnit.Picofarad); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(CapacitanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(CapacitanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Capacitance from Farads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromFarads(double farads) - { - double value = (double) farads; - return new Capacitance(value, CapacitanceUnit.Farad); - } - /// - /// Get Capacitance from Kilofarads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromKilofarads(double kilofarads) - { - double value = (double) kilofarads; - return new Capacitance(value, CapacitanceUnit.Kilofarad); - } - /// - /// Get Capacitance from Megafarads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromMegafarads(double megafarads) - { - double value = (double) megafarads; - return new Capacitance(value, CapacitanceUnit.Megafarad); - } - /// - /// Get Capacitance from Microfarads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromMicrofarads(double microfarads) - { - double value = (double) microfarads; - return new Capacitance(value, CapacitanceUnit.Microfarad); - } - /// - /// Get Capacitance from Millifarads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromMillifarads(double millifarads) - { - double value = (double) millifarads; - return new Capacitance(value, CapacitanceUnit.Millifarad); - } - /// - /// Get Capacitance from Nanofarads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromNanofarads(double nanofarads) - { - double value = (double) nanofarads; - return new Capacitance(value, CapacitanceUnit.Nanofarad); - } - /// - /// Get Capacitance from Picofarads. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Capacitance FromPicofarads(double picofarads) - { - double value = (double) picofarads; - return new Capacitance(value, CapacitanceUnit.Picofarad); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Capacitance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Capacitance From(double value, CapacitanceUnit fromUnit) - { - return new Capacitance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Capacitance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Capacitance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Capacitance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Capacitance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static CapacitanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static CapacitanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out CapacitanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out CapacitanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Capacitance objCapacitance)) throw new ArgumentException("Expected type Capacitance.", nameof(obj)); - - return CompareTo(objCapacitance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Capacitance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Capacitance objCapacitance)) - return false; - - return Equals(objCapacitance); - } - - public bool Equals(Capacitance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Capacitance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Capacitance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((CapacitanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(CapacitanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Capacitance to another Capacitance with the unit representation . - /// - /// A Capacitance with the specified unit. - public Capacitance ToUnit(CapacitanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Capacitance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(CapacitanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs deleted file mode 100644 index a491a33eb4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A unit that represents a fractional change in size in response to a change in temperature. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class CoefficientOfThermalExpansion : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly CoefficientOfThermalExpansionUnit? _unit; - - static CoefficientOfThermalExpansion() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.CoefficientOfThermalExpansion, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit InverseKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public CoefficientOfThermalExpansion() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) - { - if(unit == CoefficientOfThermalExpansionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of CoefficientOfThermalExpansion, which is InverseKelvin. All conversions go via this value. - /// - public static CoefficientOfThermalExpansionUnit BaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; - - /// - /// Represents the largest possible value of CoefficientOfThermalExpansion - /// - public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of CoefficientOfThermalExpansion - /// - public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.CoefficientOfThermalExpansion; - - /// - /// All units of measurement for the CoefficientOfThermalExpansion quantity. - /// - public static CoefficientOfThermalExpansionUnit[] Units { get; } = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().Except(new CoefficientOfThermalExpansionUnit[]{ CoefficientOfThermalExpansionUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit InverseKelvin. - /// - public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public CoefficientOfThermalExpansionUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => CoefficientOfThermalExpansion.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => CoefficientOfThermalExpansion.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get CoefficientOfThermalExpansion in InverseDegreeCelsius. - /// - public double InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); - - /// - /// Get CoefficientOfThermalExpansion in InverseDegreeFahrenheit. - /// - public double InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); - - /// - /// Get CoefficientOfThermalExpansion in InverseKelvin. - /// - public double InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get CoefficientOfThermalExpansion from InverseDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(double inversedegreecelsius) - { - double value = (double) inversedegreecelsius; - return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); - } - /// - /// Get CoefficientOfThermalExpansion from InverseDegreeFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(double inversedegreefahrenheit) - { - double value = (double) inversedegreefahrenheit; - return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); - } - /// - /// Get CoefficientOfThermalExpansion from InverseKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static CoefficientOfThermalExpansion FromInverseKelvin(double inversekelvin) - { - double value = (double) inversekelvin; - return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// CoefficientOfThermalExpansion unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static CoefficientOfThermalExpansion From(double value, CoefficientOfThermalExpansionUnit fromUnit) - { - return new CoefficientOfThermalExpansion((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static CoefficientOfThermalExpansion Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static CoefficientOfThermalExpansion Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out CoefficientOfThermalExpansion result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out CoefficientOfThermalExpansion result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static CoefficientOfThermalExpansionUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static CoefficientOfThermalExpansionUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out CoefficientOfThermalExpansionUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out CoefficientOfThermalExpansionUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) throw new ArgumentException("Expected type CoefficientOfThermalExpansion.", nameof(obj)); - - return CompareTo(objCoefficientOfThermalExpansion); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(CoefficientOfThermalExpansion other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) - return false; - - return Equals(objCoefficientOfThermalExpansion); - } - - public bool Equals(CoefficientOfThermalExpansion other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another CoefficientOfThermalExpansion within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current CoefficientOfThermalExpansion. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((CoefficientOfThermalExpansionUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(CoefficientOfThermalExpansionUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this CoefficientOfThermalExpansion to another CoefficientOfThermalExpansion with the unit representation . - /// - /// A CoefficientOfThermalExpansion with the specified unit. - public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new CoefficientOfThermalExpansion(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(CoefficientOfThermalExpansionUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.g.cs deleted file mode 100644 index 4322085fa7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Density.g.cs +++ /dev/null @@ -1,1246 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume. - /// - /// - /// http://en.wikipedia.org/wiki/Density - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Density : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly DensityUnit? _unit; - - static Density() - { - BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Density, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerCubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Density() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Density(double value, DensityUnit unit) - { - if(unit == DensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Density, which is KilogramPerCubicMeter. All conversions go via this value. - /// - public static DensityUnit BaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; - - /// - /// Represents the largest possible value of Density - /// - public static Density MaxValue { get; } = new Density(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Density - /// - public static Density MinValue { get; } = new Density(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Density; - - /// - /// All units of measurement for the Density quantity. - /// - public static DensityUnit[] Units { get; } = Enum.GetValues(typeof(DensityUnit)).Cast().Except(new DensityUnit[]{ DensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. - /// - public static Density Zero { get; } = new Density(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public DensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Density.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Density.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Density in CentigramsPerDeciLiter. - /// - public double CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); - - /// - /// Get Density in CentigramsPerLiter. - /// - public double CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); - - /// - /// Get Density in CentigramsPerMilliliter. - /// - public double CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); - - /// - /// Get Density in DecigramsPerDeciLiter. - /// - public double DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); - - /// - /// Get Density in DecigramsPerLiter. - /// - public double DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); - - /// - /// Get Density in DecigramsPerMilliliter. - /// - public double DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); - - /// - /// Get Density in GramsPerCubicCentimeter. - /// - public double GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); - - /// - /// Get Density in GramsPerCubicMeter. - /// - public double GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); - - /// - /// Get Density in GramsPerCubicMillimeter. - /// - public double GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); - - /// - /// Get Density in GramsPerDeciLiter. - /// - public double GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); - - /// - /// Get Density in GramsPerLiter. - /// - public double GramsPerLiter => As(DensityUnit.GramPerLiter); - - /// - /// Get Density in GramsPerMilliliter. - /// - public double GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); - - /// - /// Get Density in KilogramsPerCubicCentimeter. - /// - public double KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); - - /// - /// Get Density in KilogramsPerCubicMeter. - /// - public double KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); - - /// - /// Get Density in KilogramsPerCubicMillimeter. - /// - public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); - - /// - /// Get Density in KilogramsPerLiter. - /// - public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); - - /// - /// Get Density in KilopoundsPerCubicFoot. - /// - public double KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); - - /// - /// Get Density in KilopoundsPerCubicInch. - /// - public double KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); - - /// - /// Get Density in MicrogramsPerCubicMeter. - /// - public double MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); - - /// - /// Get Density in MicrogramsPerDeciLiter. - /// - public double MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); - - /// - /// Get Density in MicrogramsPerLiter. - /// - public double MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); - - /// - /// Get Density in MicrogramsPerMilliliter. - /// - public double MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); - - /// - /// Get Density in MilligramsPerCubicMeter. - /// - public double MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); - - /// - /// Get Density in MilligramsPerDeciLiter. - /// - public double MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); - - /// - /// Get Density in MilligramsPerLiter. - /// - public double MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); - - /// - /// Get Density in MilligramsPerMilliliter. - /// - public double MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); - - /// - /// Get Density in NanogramsPerDeciLiter. - /// - public double NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); - - /// - /// Get Density in NanogramsPerLiter. - /// - public double NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); - - /// - /// Get Density in NanogramsPerMilliliter. - /// - public double NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); - - /// - /// Get Density in PicogramsPerDeciLiter. - /// - public double PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); - - /// - /// Get Density in PicogramsPerLiter. - /// - public double PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); - - /// - /// Get Density in PicogramsPerMilliliter. - /// - public double PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); - - /// - /// Get Density in PoundsPerCubicFoot. - /// - public double PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); - - /// - /// Get Density in PoundsPerCubicInch. - /// - public double PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); - - /// - /// Get Density in PoundsPerImperialGallon. - /// - public double PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); - - /// - /// Get Density in PoundsPerUSGallon. - /// - public double PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); - - /// - /// Get Density in SlugsPerCubicFoot. - /// - public double SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); - - /// - /// Get Density in TonnesPerCubicCentimeter. - /// - public double TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); - - /// - /// Get Density in TonnesPerCubicMeter. - /// - public double TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); - - /// - /// Get Density in TonnesPerCubicMillimeter. - /// - public double TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(DensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(DensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Density from CentigramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromCentigramsPerDeciLiter(double centigramsperdeciliter) - { - double value = (double) centigramsperdeciliter; - return new Density(value, DensityUnit.CentigramPerDeciliter); - } - /// - /// Get Density from CentigramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromCentigramsPerLiter(double centigramsperliter) - { - double value = (double) centigramsperliter; - return new Density(value, DensityUnit.CentigramPerLiter); - } - /// - /// Get Density from CentigramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromCentigramsPerMilliliter(double centigramspermilliliter) - { - double value = (double) centigramspermilliliter; - return new Density(value, DensityUnit.CentigramPerMilliliter); - } - /// - /// Get Density from DecigramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromDecigramsPerDeciLiter(double decigramsperdeciliter) - { - double value = (double) decigramsperdeciliter; - return new Density(value, DensityUnit.DecigramPerDeciliter); - } - /// - /// Get Density from DecigramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromDecigramsPerLiter(double decigramsperliter) - { - double value = (double) decigramsperliter; - return new Density(value, DensityUnit.DecigramPerLiter); - } - /// - /// Get Density from DecigramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromDecigramsPerMilliliter(double decigramspermilliliter) - { - double value = (double) decigramspermilliliter; - return new Density(value, DensityUnit.DecigramPerMilliliter); - } - /// - /// Get Density from GramsPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromGramsPerCubicCentimeter(double gramspercubiccentimeter) - { - double value = (double) gramspercubiccentimeter; - return new Density(value, DensityUnit.GramPerCubicCentimeter); - } - /// - /// Get Density from GramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromGramsPerCubicMeter(double gramspercubicmeter) - { - double value = (double) gramspercubicmeter; - return new Density(value, DensityUnit.GramPerCubicMeter); - } - /// - /// Get Density from GramsPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromGramsPerCubicMillimeter(double gramspercubicmillimeter) - { - double value = (double) gramspercubicmillimeter; - return new Density(value, DensityUnit.GramPerCubicMillimeter); - } - /// - /// Get Density from GramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromGramsPerDeciLiter(double gramsperdeciliter) - { - double value = (double) gramsperdeciliter; - return new Density(value, DensityUnit.GramPerDeciliter); - } - /// - /// Get Density from GramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromGramsPerLiter(double gramsperliter) - { - double value = (double) gramsperliter; - return new Density(value, DensityUnit.GramPerLiter); - } - /// - /// Get Density from GramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromGramsPerMilliliter(double gramspermilliliter) - { - double value = (double) gramspermilliliter; - return new Density(value, DensityUnit.GramPerMilliliter); - } - /// - /// Get Density from KilogramsPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromKilogramsPerCubicCentimeter(double kilogramspercubiccentimeter) - { - double value = (double) kilogramspercubiccentimeter; - return new Density(value, DensityUnit.KilogramPerCubicCentimeter); - } - /// - /// Get Density from KilogramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromKilogramsPerCubicMeter(double kilogramspercubicmeter) - { - double value = (double) kilogramspercubicmeter; - return new Density(value, DensityUnit.KilogramPerCubicMeter); - } - /// - /// Get Density from KilogramsPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromKilogramsPerCubicMillimeter(double kilogramspercubicmillimeter) - { - double value = (double) kilogramspercubicmillimeter; - return new Density(value, DensityUnit.KilogramPerCubicMillimeter); - } - /// - /// Get Density from KilogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromKilogramsPerLiter(double kilogramsperliter) - { - double value = (double) kilogramsperliter; - return new Density(value, DensityUnit.KilogramPerLiter); - } - /// - /// Get Density from KilopoundsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromKilopoundsPerCubicFoot(double kilopoundspercubicfoot) - { - double value = (double) kilopoundspercubicfoot; - return new Density(value, DensityUnit.KilopoundPerCubicFoot); - } - /// - /// Get Density from KilopoundsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromKilopoundsPerCubicInch(double kilopoundspercubicinch) - { - double value = (double) kilopoundspercubicinch; - return new Density(value, DensityUnit.KilopoundPerCubicInch); - } - /// - /// Get Density from MicrogramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMicrogramsPerCubicMeter(double microgramspercubicmeter) - { - double value = (double) microgramspercubicmeter; - return new Density(value, DensityUnit.MicrogramPerCubicMeter); - } - /// - /// Get Density from MicrogramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMicrogramsPerDeciLiter(double microgramsperdeciliter) - { - double value = (double) microgramsperdeciliter; - return new Density(value, DensityUnit.MicrogramPerDeciliter); - } - /// - /// Get Density from MicrogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMicrogramsPerLiter(double microgramsperliter) - { - double value = (double) microgramsperliter; - return new Density(value, DensityUnit.MicrogramPerLiter); - } - /// - /// Get Density from MicrogramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMicrogramsPerMilliliter(double microgramspermilliliter) - { - double value = (double) microgramspermilliliter; - return new Density(value, DensityUnit.MicrogramPerMilliliter); - } - /// - /// Get Density from MilligramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMilligramsPerCubicMeter(double milligramspercubicmeter) - { - double value = (double) milligramspercubicmeter; - return new Density(value, DensityUnit.MilligramPerCubicMeter); - } - /// - /// Get Density from MilligramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMilligramsPerDeciLiter(double milligramsperdeciliter) - { - double value = (double) milligramsperdeciliter; - return new Density(value, DensityUnit.MilligramPerDeciliter); - } - /// - /// Get Density from MilligramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMilligramsPerLiter(double milligramsperliter) - { - double value = (double) milligramsperliter; - return new Density(value, DensityUnit.MilligramPerLiter); - } - /// - /// Get Density from MilligramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromMilligramsPerMilliliter(double milligramspermilliliter) - { - double value = (double) milligramspermilliliter; - return new Density(value, DensityUnit.MilligramPerMilliliter); - } - /// - /// Get Density from NanogramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromNanogramsPerDeciLiter(double nanogramsperdeciliter) - { - double value = (double) nanogramsperdeciliter; - return new Density(value, DensityUnit.NanogramPerDeciliter); - } - /// - /// Get Density from NanogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromNanogramsPerLiter(double nanogramsperliter) - { - double value = (double) nanogramsperliter; - return new Density(value, DensityUnit.NanogramPerLiter); - } - /// - /// Get Density from NanogramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromNanogramsPerMilliliter(double nanogramspermilliliter) - { - double value = (double) nanogramspermilliliter; - return new Density(value, DensityUnit.NanogramPerMilliliter); - } - /// - /// Get Density from PicogramsPerDeciLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPicogramsPerDeciLiter(double picogramsperdeciliter) - { - double value = (double) picogramsperdeciliter; - return new Density(value, DensityUnit.PicogramPerDeciliter); - } - /// - /// Get Density from PicogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPicogramsPerLiter(double picogramsperliter) - { - double value = (double) picogramsperliter; - return new Density(value, DensityUnit.PicogramPerLiter); - } - /// - /// Get Density from PicogramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPicogramsPerMilliliter(double picogramspermilliliter) - { - double value = (double) picogramspermilliliter; - return new Density(value, DensityUnit.PicogramPerMilliliter); - } - /// - /// Get Density from PoundsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPoundsPerCubicFoot(double poundspercubicfoot) - { - double value = (double) poundspercubicfoot; - return new Density(value, DensityUnit.PoundPerCubicFoot); - } - /// - /// Get Density from PoundsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPoundsPerCubicInch(double poundspercubicinch) - { - double value = (double) poundspercubicinch; - return new Density(value, DensityUnit.PoundPerCubicInch); - } - /// - /// Get Density from PoundsPerImperialGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPoundsPerImperialGallon(double poundsperimperialgallon) - { - double value = (double) poundsperimperialgallon; - return new Density(value, DensityUnit.PoundPerImperialGallon); - } - /// - /// Get Density from PoundsPerUSGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromPoundsPerUSGallon(double poundsperusgallon) - { - double value = (double) poundsperusgallon; - return new Density(value, DensityUnit.PoundPerUSGallon); - } - /// - /// Get Density from SlugsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromSlugsPerCubicFoot(double slugspercubicfoot) - { - double value = (double) slugspercubicfoot; - return new Density(value, DensityUnit.SlugPerCubicFoot); - } - /// - /// Get Density from TonnesPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromTonnesPerCubicCentimeter(double tonnespercubiccentimeter) - { - double value = (double) tonnespercubiccentimeter; - return new Density(value, DensityUnit.TonnePerCubicCentimeter); - } - /// - /// Get Density from TonnesPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromTonnesPerCubicMeter(double tonnespercubicmeter) - { - double value = (double) tonnespercubicmeter; - return new Density(value, DensityUnit.TonnePerCubicMeter); - } - /// - /// Get Density from TonnesPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Density FromTonnesPerCubicMillimeter(double tonnespercubicmillimeter) - { - double value = (double) tonnespercubicmillimeter; - return new Density(value, DensityUnit.TonnePerCubicMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Density unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Density From(double value, DensityUnit fromUnit) - { - return new Density((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Density Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Density Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Density result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Density result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static DensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static DensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out DensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out DensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Density objDensity)) throw new ArgumentException("Expected type Density.", nameof(obj)); - - return CompareTo(objDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Density other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Density objDensity)) - return false; - - return Equals(objDensity); - } - - public bool Equals(Density other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Density within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Density other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Density. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((DensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(DensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Density to another Density with the unit representation . - /// - /// A Density with the specified unit. - public Density ToUnit(DensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Density(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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.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.PoundPerCubicFoot: return _value/0.062427961; - case DensityUnit.PoundPerCubicInch: return _value/3.6127298147753e-5; - case DensityUnit.PoundPerImperialGallon: return _value*9.9776398e1; - case DensityUnit.PoundPerUSGallon: return _value*1.19826427e2; - case DensityUnit.SlugPerCubicFoot: return _value*515.378818; - case DensityUnit.TonnePerCubicCentimeter: return _value/1e-9; - 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."); - } - } - - private double AsBaseNumericType(DensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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.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.PoundPerCubicFoot: return baseUnitValue*0.062427961; - case DensityUnit.PoundPerCubicInch: return baseUnitValue*3.6127298147753e-5; - case DensityUnit.PoundPerImperialGallon: return baseUnitValue/9.9776398e1; - case DensityUnit.PoundPerUSGallon: return baseUnitValue/1.19826427e2; - case DensityUnit.SlugPerCubicFoot: return baseUnitValue*0.00194032033; - case DensityUnit.TonnePerCubicCentimeter: return baseUnitValue*1e-9; - case DensityUnit.TonnePerCubicMeter: return baseUnitValue*0.001; - case DensityUnit.TonnePerCubicMillimeter: return baseUnitValue*1e-12; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.g.cs deleted file mode 100644 index 9a5441a262..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Duration.g.cs +++ /dev/null @@ -1,733 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Duration : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly DurationUnit? _unit; - - static Duration() - { - BaseDimensions = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Duration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Second. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Duration() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Duration(double value, DurationUnit unit) - { - if(unit == DurationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Duration, which is Second. All conversions go via this value. - /// - public static DurationUnit BaseUnit { get; } = DurationUnit.Second; - - /// - /// Represents the largest possible value of Duration - /// - public static Duration MaxValue { get; } = new Duration(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Duration - /// - public static Duration MinValue { get; } = new Duration(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Duration; - - /// - /// All units of measurement for the Duration quantity. - /// - public static DurationUnit[] Units { get; } = Enum.GetValues(typeof(DurationUnit)).Cast().Except(new DurationUnit[]{ DurationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Second. - /// - public static Duration Zero { get; } = new Duration(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public DurationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Duration.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Duration.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Duration in Days. - /// - public double Days => As(DurationUnit.Day); - - /// - /// Get Duration in Hours. - /// - public double Hours => As(DurationUnit.Hour); - - /// - /// Get Duration in Microseconds. - /// - public double Microseconds => As(DurationUnit.Microsecond); - - /// - /// Get Duration in Milliseconds. - /// - public double Milliseconds => As(DurationUnit.Millisecond); - - /// - /// Get Duration in Minutes. - /// - public double Minutes => As(DurationUnit.Minute); - - /// - /// Get Duration in Months30. - /// - public double Months30 => As(DurationUnit.Month30); - - /// - /// Get Duration in Nanoseconds. - /// - public double Nanoseconds => As(DurationUnit.Nanosecond); - - /// - /// Get Duration in Seconds. - /// - public double Seconds => As(DurationUnit.Second); - - /// - /// Get Duration in Weeks. - /// - public double Weeks => As(DurationUnit.Week); - - /// - /// Get Duration in Years365. - /// - public double Years365 => As(DurationUnit.Year365); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(DurationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(DurationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Duration from Days. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromDays(double days) - { - double value = (double) days; - return new Duration(value, DurationUnit.Day); - } - /// - /// Get Duration from Hours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromHours(double hours) - { - double value = (double) hours; - return new Duration(value, DurationUnit.Hour); - } - /// - /// Get Duration from Microseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromMicroseconds(double microseconds) - { - double value = (double) microseconds; - return new Duration(value, DurationUnit.Microsecond); - } - /// - /// Get Duration from Milliseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromMilliseconds(double milliseconds) - { - double value = (double) milliseconds; - return new Duration(value, DurationUnit.Millisecond); - } - /// - /// Get Duration from Minutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromMinutes(double minutes) - { - double value = (double) minutes; - return new Duration(value, DurationUnit.Minute); - } - /// - /// Get Duration from Months30. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromMonths30(double months30) - { - double value = (double) months30; - return new Duration(value, DurationUnit.Month30); - } - /// - /// Get Duration from Nanoseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromNanoseconds(double nanoseconds) - { - double value = (double) nanoseconds; - return new Duration(value, DurationUnit.Nanosecond); - } - /// - /// Get Duration from Seconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromSeconds(double seconds) - { - double value = (double) seconds; - return new Duration(value, DurationUnit.Second); - } - /// - /// Get Duration from Weeks. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromWeeks(double weeks) - { - double value = (double) weeks; - return new Duration(value, DurationUnit.Week); - } - /// - /// Get Duration from Years365. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Duration FromYears365(double years365) - { - double value = (double) years365; - return new Duration(value, DurationUnit.Year365); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Duration unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Duration From(double value, DurationUnit fromUnit) - { - return new Duration((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Duration Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Duration Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Duration result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Duration result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static DurationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static DurationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out DurationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out DurationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Duration objDuration)) throw new ArgumentException("Expected type Duration.", nameof(obj)); - - return CompareTo(objDuration); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Duration other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Duration objDuration)) - return false; - - return Equals(objDuration); - } - - public bool Equals(Duration other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Duration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Duration other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Duration. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((DurationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(DurationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Duration to another Duration with the unit representation . - /// - /// A Duration with the specified unit. - public Duration ToUnit(DurationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Duration(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case DurationUnit.Day: return _value*24*3600; - case DurationUnit.Hour: return _value*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."); - } - } - - private double AsBaseNumericType(DurationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case DurationUnit.Day: return baseUnitValue/(24*3600); - case DurationUnit.Hour: return baseUnitValue/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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.g.cs deleted file mode 100644 index 2975d76bd9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ /dev/null @@ -1,736 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The dynamic (shear) viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds - /// - /// - /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class DynamicViscosity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly DynamicViscosityUnit? _unit; - - static DynamicViscosity() - { - BaseDimensions = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.DynamicViscosity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public DynamicViscosity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private DynamicViscosity(double value, DynamicViscosityUnit unit) - { - if(unit == DynamicViscosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of DynamicViscosity, which is NewtonSecondPerMeterSquared. All conversions go via this value. - /// - public static DynamicViscosityUnit BaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; - - /// - /// Represents the largest possible value of DynamicViscosity - /// - public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of DynamicViscosity - /// - public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.DynamicViscosity; - - /// - /// All units of measurement for the DynamicViscosity quantity. - /// - public static DynamicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().Except(new DynamicViscosityUnit[]{ DynamicViscosityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared. - /// - public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public DynamicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => DynamicViscosity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => DynamicViscosity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get DynamicViscosity in Centipoise. - /// - public double Centipoise => As(DynamicViscosityUnit.Centipoise); - - /// - /// Get DynamicViscosity in MicropascalSeconds. - /// - public double MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); - - /// - /// Get DynamicViscosity in MillipascalSeconds. - /// - public double MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); - - /// - /// Get DynamicViscosity in NewtonSecondsPerMeterSquared. - /// - public double NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); - - /// - /// Get DynamicViscosity in PascalSeconds. - /// - public double PascalSeconds => As(DynamicViscosityUnit.PascalSecond); - - /// - /// Get DynamicViscosity in Poise. - /// - public double Poise => As(DynamicViscosityUnit.Poise); - - /// - /// Get DynamicViscosity in PoundsForceSecondPerSquareFoot. - /// - public double PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); - - /// - /// Get DynamicViscosity in PoundsForceSecondPerSquareInch. - /// - public double PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); - - /// - /// Get DynamicViscosity in PoundsPerFootSecond. - /// - public double PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); - - /// - /// Get DynamicViscosity in Reyns. - /// - public double Reyns => As(DynamicViscosityUnit.Reyn); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(DynamicViscosityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(DynamicViscosityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get DynamicViscosity from Centipoise. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromCentipoise(double centipoise) - { - double value = (double) centipoise; - return new DynamicViscosity(value, DynamicViscosityUnit.Centipoise); - } - /// - /// Get DynamicViscosity from MicropascalSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromMicropascalSeconds(double micropascalseconds) - { - double value = (double) micropascalseconds; - return new DynamicViscosity(value, DynamicViscosityUnit.MicropascalSecond); - } - /// - /// Get DynamicViscosity from MillipascalSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromMillipascalSeconds(double millipascalseconds) - { - double value = (double) millipascalseconds; - return new DynamicViscosity(value, DynamicViscosityUnit.MillipascalSecond); - } - /// - /// Get DynamicViscosity from NewtonSecondsPerMeterSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromNewtonSecondsPerMeterSquared(double newtonsecondspermetersquared) - { - double value = (double) newtonsecondspermetersquared; - return new DynamicViscosity(value, DynamicViscosityUnit.NewtonSecondPerMeterSquared); - } - /// - /// Get DynamicViscosity from PascalSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromPascalSeconds(double pascalseconds) - { - double value = (double) pascalseconds; - return new DynamicViscosity(value, DynamicViscosityUnit.PascalSecond); - } - /// - /// Get DynamicViscosity from Poise. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromPoise(double poise) - { - double value = (double) poise; - return new DynamicViscosity(value, DynamicViscosityUnit.Poise); - } - /// - /// Get DynamicViscosity from PoundsForceSecondPerSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(double poundsforcesecondpersquarefoot) - { - double value = (double) poundsforcesecondpersquarefoot; - return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); - } - /// - /// Get DynamicViscosity from PoundsForceSecondPerSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromPoundsForceSecondPerSquareInch(double poundsforcesecondpersquareinch) - { - double value = (double) poundsforcesecondpersquareinch; - return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareInch); - } - /// - /// Get DynamicViscosity from PoundsPerFootSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromPoundsPerFootSecond(double poundsperfootsecond) - { - double value = (double) poundsperfootsecond; - return new DynamicViscosity(value, DynamicViscosityUnit.PoundPerFootSecond); - } - /// - /// Get DynamicViscosity from Reyns. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static DynamicViscosity FromReyns(double reyns) - { - double value = (double) reyns; - return new DynamicViscosity(value, DynamicViscosityUnit.Reyn); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// DynamicViscosity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static DynamicViscosity From(double value, DynamicViscosityUnit fromUnit) - { - return new DynamicViscosity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static DynamicViscosity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static DynamicViscosity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out DynamicViscosity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out DynamicViscosity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static DynamicViscosityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static DynamicViscosityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out DynamicViscosityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out DynamicViscosityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is DynamicViscosity objDynamicViscosity)) throw new ArgumentException("Expected type DynamicViscosity.", nameof(obj)); - - return CompareTo(objDynamicViscosity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(DynamicViscosity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is DynamicViscosity objDynamicViscosity)) - return false; - - return Equals(objDynamicViscosity); - } - - public bool Equals(DynamicViscosity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another DynamicViscosity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current DynamicViscosity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((DynamicViscosityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(DynamicViscosityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this DynamicViscosity to another DynamicViscosity with the unit representation . - /// - /// A DynamicViscosity with the specified unit. - public DynamicViscosity ToUnit(DynamicViscosityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new DynamicViscosity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(DynamicViscosityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.g.cs deleted file mode 100644 index 519872df8f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ /dev/null @@ -1,631 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricAdmittance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricAdmittanceUnit? _unit; - - static ElectricAdmittance() - { - BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricAdmittance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Siemens. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricAdmittance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricAdmittance(double value, ElectricAdmittanceUnit unit) - { - if(unit == ElectricAdmittanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricAdmittance, which is Siemens. All conversions go via this value. - /// - public static ElectricAdmittanceUnit BaseUnit { get; } = ElectricAdmittanceUnit.Siemens; - - /// - /// Represents the largest possible value of ElectricAdmittance - /// - public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricAdmittance - /// - public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricAdmittance; - - /// - /// All units of measurement for the ElectricAdmittance quantity. - /// - public static ElectricAdmittanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().Except(new ElectricAdmittanceUnit[]{ ElectricAdmittanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. - /// - public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricAdmittanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricAdmittance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricAdmittance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricAdmittance in Microsiemens. - /// - public double Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); - - /// - /// Get ElectricAdmittance in Millisiemens. - /// - public double Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); - - /// - /// Get ElectricAdmittance in Nanosiemens. - /// - public double Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); - - /// - /// Get ElectricAdmittance in Siemens. - /// - public double Siemens => As(ElectricAdmittanceUnit.Siemens); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricAdmittanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricAdmittanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricAdmittance from Microsiemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricAdmittance FromMicrosiemens(double microsiemens) - { - double value = (double) microsiemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Microsiemens); - } - /// - /// Get ElectricAdmittance from Millisiemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricAdmittance FromMillisiemens(double millisiemens) - { - double value = (double) millisiemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Millisiemens); - } - /// - /// Get ElectricAdmittance from Nanosiemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricAdmittance FromNanosiemens(double nanosiemens) - { - double value = (double) nanosiemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Nanosiemens); - } - /// - /// Get ElectricAdmittance from Siemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricAdmittance FromSiemens(double siemens) - { - double value = (double) siemens; - return new ElectricAdmittance(value, ElectricAdmittanceUnit.Siemens); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricAdmittance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricAdmittance From(double value, ElectricAdmittanceUnit fromUnit) - { - return new ElectricAdmittance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricAdmittance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricAdmittance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricAdmittance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricAdmittance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricAdmittanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricAdmittanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricAdmittanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricAdmittanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricAdmittance objElectricAdmittance)) throw new ArgumentException("Expected type ElectricAdmittance.", nameof(obj)); - - return CompareTo(objElectricAdmittance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricAdmittance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) - return false; - - return Equals(objElectricAdmittance); - } - - public bool Equals(ElectricAdmittance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricAdmittance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricAdmittance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricAdmittanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricAdmittanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricAdmittance to another ElectricAdmittance with the unit representation . - /// - /// A ElectricAdmittance with the specified unit. - public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricAdmittance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricAdmittanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.g.cs deleted file mode 100644 index abb5480f7c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCharge.g.cs +++ /dev/null @@ -1,651 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Electric charge is the physical property of matter that causes it to experience a force when placed in an electromagnetic field. - /// - /// - /// https://en.wikipedia.org/wiki/Electric_charge - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricCharge : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricChargeUnit? _unit; - - static ElectricCharge() - { - BaseDimensions = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricCharge, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Coulomb. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricCharge() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricCharge(double value, ElectricChargeUnit unit) - { - if(unit == ElectricChargeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricCharge, which is Coulomb. All conversions go via this value. - /// - public static ElectricChargeUnit BaseUnit { get; } = ElectricChargeUnit.Coulomb; - - /// - /// Represents the largest possible value of ElectricCharge - /// - public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricCharge - /// - public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricCharge; - - /// - /// All units of measurement for the ElectricCharge quantity. - /// - public static ElectricChargeUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().Except(new ElectricChargeUnit[]{ ElectricChargeUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Coulomb. - /// - public static ElectricCharge Zero { get; } = new ElectricCharge(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricChargeUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCharge.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricCharge.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricCharge in AmpereHours. - /// - public double AmpereHours => As(ElectricChargeUnit.AmpereHour); - - /// - /// Get ElectricCharge in Coulombs. - /// - public double Coulombs => As(ElectricChargeUnit.Coulomb); - - /// - /// Get ElectricCharge in KiloampereHours. - /// - public double KiloampereHours => As(ElectricChargeUnit.KiloampereHour); - - /// - /// Get ElectricCharge in MegaampereHours. - /// - public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); - - /// - /// Get ElectricCharge in MilliampereHours. - /// - public double MilliampereHours => As(ElectricChargeUnit.MilliampereHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricChargeUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricChargeUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricCharge from AmpereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCharge FromAmpereHours(double amperehours) - { - double value = (double) amperehours; - return new ElectricCharge(value, ElectricChargeUnit.AmpereHour); - } - /// - /// Get ElectricCharge from Coulombs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCharge FromCoulombs(double coulombs) - { - double value = (double) coulombs; - return new ElectricCharge(value, ElectricChargeUnit.Coulomb); - } - /// - /// Get ElectricCharge from KiloampereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCharge FromKiloampereHours(double kiloamperehours) - { - double value = (double) kiloamperehours; - return new ElectricCharge(value, ElectricChargeUnit.KiloampereHour); - } - /// - /// Get ElectricCharge from MegaampereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCharge FromMegaampereHours(double megaamperehours) - { - double value = (double) megaamperehours; - return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); - } - /// - /// Get ElectricCharge from MilliampereHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCharge FromMilliampereHours(double milliamperehours) - { - double value = (double) milliamperehours; - return new ElectricCharge(value, ElectricChargeUnit.MilliampereHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricCharge unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricCharge From(double value, ElectricChargeUnit fromUnit) - { - return new ElectricCharge((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricCharge Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCharge Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricCharge result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricCharge result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricChargeUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricChargeUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricChargeUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricChargeUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCharge objElectricCharge)) throw new ArgumentException("Expected type ElectricCharge.", nameof(obj)); - - return CompareTo(objElectricCharge); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricCharge other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCharge objElectricCharge)) - return false; - - return Equals(objElectricCharge); - } - - public bool Equals(ElectricCharge other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricCharge within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricCharge. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricChargeUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricChargeUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricCharge to another ElectricCharge with the unit representation . - /// - /// A ElectricCharge with the specified unit. - public ElectricCharge ToUnit(ElectricChargeUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricCharge(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricChargeUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.g.cs deleted file mode 100644 index c56a49e549..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In electromagnetism, charge density is a measure of the amount of electric charge per volume. - /// - /// - /// https://en.wikipedia.org/wiki/Charge_density - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricChargeDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricChargeDensityUnit? _unit; - - static ElectricChargeDensity() - { - BaseDimensions = new BaseDimensions(-3, 0, 1, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricChargeDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit CoulombPerCubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricChargeDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) - { - if(unit == ElectricChargeDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricChargeDensity, which is CoulombPerCubicMeter. All conversions go via this value. - /// - public static ElectricChargeDensityUnit BaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; - - /// - /// Represents the largest possible value of ElectricChargeDensity - /// - public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricChargeDensity - /// - public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricChargeDensity; - - /// - /// All units of measurement for the ElectricChargeDensity quantity. - /// - public static ElectricChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().Except(new ElectricChargeDensityUnit[]{ ElectricChargeDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerCubicMeter. - /// - public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricChargeDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricChargeDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricChargeDensity in CoulombsPerCubicMeter. - /// - public double CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricChargeDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricChargeDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricChargeDensity from CoulombsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricChargeDensity FromCoulombsPerCubicMeter(double coulombspercubicmeter) - { - double value = (double) coulombspercubicmeter; - return new ElectricChargeDensity(value, ElectricChargeDensityUnit.CoulombPerCubicMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricChargeDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricChargeDensity From(double value, ElectricChargeDensityUnit fromUnit) - { - return new ElectricChargeDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricChargeDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricChargeDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricChargeDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricChargeDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricChargeDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricChargeDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricChargeDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricChargeDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricChargeDensity objElectricChargeDensity)) throw new ArgumentException("Expected type ElectricChargeDensity.", nameof(obj)); - - return CompareTo(objElectricChargeDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricChargeDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) - return false; - - return Equals(objElectricChargeDensity); - } - - public bool Equals(ElectricChargeDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricChargeDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricChargeDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricChargeDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricChargeDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricChargeDensity to another ElectricChargeDensity with the unit representation . - /// - /// A ElectricChargeDensity with the specified unit. - public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricChargeDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case ElectricChargeDensityUnit.CoulombPerCubicMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(ElectricChargeDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case ElectricChargeDensityUnit.CoulombPerCubicMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.g.cs deleted file mode 100644 index 89fe68bac9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductance.g.cs +++ /dev/null @@ -1,617 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor. - /// - /// - /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricConductance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricConductanceUnit? _unit; - - static ElectricConductance() - { - BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricConductance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Siemens. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricConductance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricConductance(double value, ElectricConductanceUnit unit) - { - if(unit == ElectricConductanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricConductance, which is Siemens. All conversions go via this value. - /// - public static ElectricConductanceUnit BaseUnit { get; } = ElectricConductanceUnit.Siemens; - - /// - /// Represents the largest possible value of ElectricConductance - /// - public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricConductance - /// - public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricConductance; - - /// - /// All units of measurement for the ElectricConductance quantity. - /// - public static ElectricConductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().Except(new ElectricConductanceUnit[]{ ElectricConductanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. - /// - public static ElectricConductance Zero { get; } = new ElectricConductance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricConductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricConductance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricConductance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricConductance in Microsiemens. - /// - public double Microsiemens => As(ElectricConductanceUnit.Microsiemens); - - /// - /// Get ElectricConductance in Millisiemens. - /// - public double Millisiemens => As(ElectricConductanceUnit.Millisiemens); - - /// - /// Get ElectricConductance in Siemens. - /// - public double Siemens => As(ElectricConductanceUnit.Siemens); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricConductanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricConductanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricConductance from Microsiemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricConductance FromMicrosiemens(double microsiemens) - { - double value = (double) microsiemens; - return new ElectricConductance(value, ElectricConductanceUnit.Microsiemens); - } - /// - /// Get ElectricConductance from Millisiemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricConductance FromMillisiemens(double millisiemens) - { - double value = (double) millisiemens; - return new ElectricConductance(value, ElectricConductanceUnit.Millisiemens); - } - /// - /// Get ElectricConductance from Siemens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricConductance FromSiemens(double siemens) - { - double value = (double) siemens; - return new ElectricConductance(value, ElectricConductanceUnit.Siemens); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricConductance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricConductance From(double value, ElectricConductanceUnit fromUnit) - { - return new ElectricConductance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricConductance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricConductance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricConductance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricConductance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricConductanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricConductanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricConductanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricConductanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricConductance objElectricConductance)) throw new ArgumentException("Expected type ElectricConductance.", nameof(obj)); - - return CompareTo(objElectricConductance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricConductance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricConductance objElectricConductance)) - return false; - - return Equals(objElectricConductance); - } - - public bool Equals(ElectricConductance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricConductance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricConductance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricConductanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricConductanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricConductance to another ElectricConductance with the unit representation . - /// - /// A ElectricConductance with the specified unit. - public ElectricConductance ToUnit(ElectricConductanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricConductance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricConductanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.g.cs deleted file mode 100644 index 1af5cf33cf..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ /dev/null @@ -1,617 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Electrical conductivity or specific conductance is the reciprocal of electrical resistivity, and measures a material's ability to conduct an electric current. - /// - /// - /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricConductivity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricConductivityUnit? _unit; - - static ElectricConductivity() - { - BaseDimensions = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricConductivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit SiemensPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricConductivity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricConductivity(double value, ElectricConductivityUnit unit) - { - if(unit == ElectricConductivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricConductivity, which is SiemensPerMeter. All conversions go via this value. - /// - public static ElectricConductivityUnit BaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; - - /// - /// Represents the largest possible value of ElectricConductivity - /// - public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricConductivity - /// - public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricConductivity; - - /// - /// All units of measurement for the ElectricConductivity quantity. - /// - public static ElectricConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().Except(new ElectricConductivityUnit[]{ ElectricConductivityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit SiemensPerMeter. - /// - public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricConductivity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricConductivity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricConductivity in SiemensPerFoot. - /// - public double SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); - - /// - /// Get ElectricConductivity in SiemensPerInch. - /// - public double SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); - - /// - /// Get ElectricConductivity in SiemensPerMeter. - /// - public double SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricConductivityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricConductivityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricConductivity from SiemensPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricConductivity FromSiemensPerFoot(double siemensperfoot) - { - double value = (double) siemensperfoot; - return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerFoot); - } - /// - /// Get ElectricConductivity from SiemensPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricConductivity FromSiemensPerInch(double siemensperinch) - { - double value = (double) siemensperinch; - return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerInch); - } - /// - /// Get ElectricConductivity from SiemensPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricConductivity FromSiemensPerMeter(double siemenspermeter) - { - double value = (double) siemenspermeter; - return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricConductivity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricConductivity From(double value, ElectricConductivityUnit fromUnit) - { - return new ElectricConductivity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricConductivity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricConductivity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricConductivity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricConductivity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricConductivityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricConductivityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricConductivityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricConductivityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricConductivity objElectricConductivity)) throw new ArgumentException("Expected type ElectricConductivity.", nameof(obj)); - - return CompareTo(objElectricConductivity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricConductivity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricConductivity objElectricConductivity)) - return false; - - return Equals(objElectricConductivity); - } - - public bool Equals(ElectricConductivity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricConductivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricConductivity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricConductivityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricConductivityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricConductivity to another ElectricConductivity with the unit representation . - /// - /// A ElectricConductivity with the specified unit. - public ElectricConductivity ToUnit(ElectricConductivityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricConductivity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricConductivityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.g.cs deleted file mode 100644 index 2842e7852c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ /dev/null @@ -1,699 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricCurrent : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricCurrentUnit? _unit; - - static ElectricCurrent() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricCurrent, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Ampere. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricCurrent() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricCurrent(double value, ElectricCurrentUnit unit) - { - if(unit == ElectricCurrentUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricCurrent, which is Ampere. All conversions go via this value. - /// - public static ElectricCurrentUnit BaseUnit { get; } = ElectricCurrentUnit.Ampere; - - /// - /// Represents the largest possible value of ElectricCurrent - /// - public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricCurrent - /// - public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrent; - - /// - /// All units of measurement for the ElectricCurrent quantity. - /// - public static ElectricCurrentUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().Except(new ElectricCurrentUnit[]{ ElectricCurrentUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Ampere. - /// - public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricCurrentUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCurrent.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricCurrent.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricCurrent in Amperes. - /// - public double Amperes => As(ElectricCurrentUnit.Ampere); - - /// - /// Get ElectricCurrent in Centiamperes. - /// - public double Centiamperes => As(ElectricCurrentUnit.Centiampere); - - /// - /// Get ElectricCurrent in Kiloamperes. - /// - public double Kiloamperes => As(ElectricCurrentUnit.Kiloampere); - - /// - /// Get ElectricCurrent in Megaamperes. - /// - public double Megaamperes => As(ElectricCurrentUnit.Megaampere); - - /// - /// Get ElectricCurrent in Microamperes. - /// - public double Microamperes => As(ElectricCurrentUnit.Microampere); - - /// - /// Get ElectricCurrent in Milliamperes. - /// - public double Milliamperes => As(ElectricCurrentUnit.Milliampere); - - /// - /// Get ElectricCurrent in Nanoamperes. - /// - public double Nanoamperes => As(ElectricCurrentUnit.Nanoampere); - - /// - /// Get ElectricCurrent in Picoamperes. - /// - public double Picoamperes => As(ElectricCurrentUnit.Picoampere); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricCurrentUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricCurrentUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricCurrent from Amperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromAmperes(double amperes) - { - double value = (double) amperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Ampere); - } - /// - /// Get ElectricCurrent from Centiamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromCentiamperes(double centiamperes) - { - double value = (double) centiamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Centiampere); - } - /// - /// Get ElectricCurrent from Kiloamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromKiloamperes(double kiloamperes) - { - double value = (double) kiloamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Kiloampere); - } - /// - /// Get ElectricCurrent from Megaamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromMegaamperes(double megaamperes) - { - double value = (double) megaamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Megaampere); - } - /// - /// Get ElectricCurrent from Microamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromMicroamperes(double microamperes) - { - double value = (double) microamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Microampere); - } - /// - /// Get ElectricCurrent from Milliamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromMilliamperes(double milliamperes) - { - double value = (double) milliamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Milliampere); - } - /// - /// Get ElectricCurrent from Nanoamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromNanoamperes(double nanoamperes) - { - double value = (double) nanoamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Nanoampere); - } - /// - /// Get ElectricCurrent from Picoamperes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrent FromPicoamperes(double picoamperes) - { - double value = (double) picoamperes; - return new ElectricCurrent(value, ElectricCurrentUnit.Picoampere); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricCurrent unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricCurrent From(double value, ElectricCurrentUnit fromUnit) - { - return new ElectricCurrent((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricCurrent Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCurrent Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricCurrent result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricCurrent result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricCurrentUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricCurrentUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricCurrentUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCurrent objElectricCurrent)) throw new ArgumentException("Expected type ElectricCurrent.", nameof(obj)); - - return CompareTo(objElectricCurrent); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricCurrent other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrent objElectricCurrent)) - return false; - - return Equals(objElectricCurrent); - } - - public bool Equals(ElectricCurrent other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricCurrent within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricCurrent. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricCurrentUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricCurrentUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricCurrent to another ElectricCurrent with the unit representation . - /// - /// A ElectricCurrent with the specified unit. - public ElectricCurrent ToUnit(ElectricCurrentUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricCurrent(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricCurrentUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs deleted file mode 100644 index 80778d222b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ /dev/null @@ -1,617 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In electromagnetism, current density is the electric current per unit area of cross section. - /// - /// - /// https://en.wikipedia.org/wiki/Current_density - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricCurrentDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricCurrentDensityUnit? _unit; - - static ElectricCurrentDensity() - { - BaseDimensions = new BaseDimensions(-2, 0, 0, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricCurrentDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit AmperePerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricCurrentDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) - { - if(unit == ElectricCurrentDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricCurrentDensity, which is AmperePerSquareMeter. All conversions go via this value. - /// - public static ElectricCurrentDensityUnit BaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; - - /// - /// Represents the largest possible value of ElectricCurrentDensity - /// - public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricCurrentDensity - /// - public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrentDensity; - - /// - /// All units of measurement for the ElectricCurrentDensity quantity. - /// - public static ElectricCurrentDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().Except(new ElectricCurrentDensityUnit[]{ ElectricCurrentDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSquareMeter. - /// - public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricCurrentDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCurrentDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricCurrentDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricCurrentDensity in AmperesPerSquareFoot. - /// - public double AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); - - /// - /// Get ElectricCurrentDensity in AmperesPerSquareInch. - /// - public double AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); - - /// - /// Get ElectricCurrentDensity in AmperesPerSquareMeter. - /// - public double AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricCurrentDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricCurrentDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricCurrentDensity from AmperesPerSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentDensity FromAmperesPerSquareFoot(double amperespersquarefoot) - { - double value = (double) amperespersquarefoot; - return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareFoot); - } - /// - /// Get ElectricCurrentDensity from AmperesPerSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentDensity FromAmperesPerSquareInch(double amperespersquareinch) - { - double value = (double) amperespersquareinch; - return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareInch); - } - /// - /// Get ElectricCurrentDensity from AmperesPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentDensity FromAmperesPerSquareMeter(double amperespersquaremeter) - { - double value = (double) amperespersquaremeter; - return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricCurrentDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricCurrentDensity From(double value, ElectricCurrentDensityUnit fromUnit) - { - return new ElectricCurrentDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricCurrentDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricCurrentDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricCurrentDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricCurrentDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricCurrentDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricCurrentDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCurrentDensity objElectricCurrentDensity)) throw new ArgumentException("Expected type ElectricCurrentDensity.", nameof(obj)); - - return CompareTo(objElectricCurrentDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricCurrentDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) - return false; - - return Equals(objElectricCurrentDensity); - } - - public bool Equals(ElectricCurrentDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricCurrentDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricCurrentDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricCurrentDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricCurrentDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricCurrentDensity to another ElectricCurrentDensity with the unit representation . - /// - /// A ElectricCurrentDensity with the specified unit. - public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricCurrentDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricCurrentDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs deleted file mode 100644 index 937a762793..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ /dev/null @@ -1,631 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In electromagnetism, the current gradient describes how the current changes in time. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricCurrentGradient : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricCurrentGradientUnit? _unit; - - static ElectricCurrentGradient() - { - BaseDimensions = new BaseDimensions(0, 0, -1, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricCurrentGradient, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit AmperePerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricCurrentGradient() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) - { - if(unit == ElectricCurrentGradientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricCurrentGradient, which is AmperePerSecond. All conversions go via this value. - /// - public static ElectricCurrentGradientUnit BaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; - - /// - /// Represents the largest possible value of ElectricCurrentGradient - /// - public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricCurrentGradient - /// - public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrentGradient; - - /// - /// All units of measurement for the ElectricCurrentGradient quantity. - /// - public static ElectricCurrentGradientUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().Except(new ElectricCurrentGradientUnit[]{ ElectricCurrentGradientUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSecond. - /// - public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricCurrentGradientUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCurrentGradient.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricCurrentGradient.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricCurrentGradient in AmperesPerMicrosecond. - /// - public double AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); - - /// - /// Get ElectricCurrentGradient in AmperesPerMillisecond. - /// - public double AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); - - /// - /// Get ElectricCurrentGradient in AmperesPerNanosecond. - /// - public double AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); - - /// - /// Get ElectricCurrentGradient in AmperesPerSecond. - /// - public double AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricCurrentGradientUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricCurrentGradientUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricCurrentGradient from AmperesPerMicrosecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentGradient FromAmperesPerMicrosecond(double amperespermicrosecond) - { - double value = (double) amperespermicrosecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMicrosecond); - } - /// - /// Get ElectricCurrentGradient from AmperesPerMillisecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentGradient FromAmperesPerMillisecond(double amperespermillisecond) - { - double value = (double) amperespermillisecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMillisecond); - } - /// - /// Get ElectricCurrentGradient from AmperesPerNanosecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentGradient FromAmperesPerNanosecond(double amperespernanosecond) - { - double value = (double) amperespernanosecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerNanosecond); - } - /// - /// Get ElectricCurrentGradient from AmperesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricCurrentGradient FromAmperesPerSecond(double amperespersecond) - { - double value = (double) amperespersecond; - return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricCurrentGradient unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricCurrentGradient From(double value, ElectricCurrentGradientUnit fromUnit) - { - return new ElectricCurrentGradient((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricCurrentGradient Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentGradient Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricCurrentGradient result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricCurrentGradient result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricCurrentGradientUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricCurrentGradientUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricCurrentGradientUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricCurrentGradientUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricCurrentGradient objElectricCurrentGradient)) throw new ArgumentException("Expected type ElectricCurrentGradient.", nameof(obj)); - - return CompareTo(objElectricCurrentGradient); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricCurrentGradient other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) - return false; - - return Equals(objElectricCurrentGradient); - } - - public bool Equals(ElectricCurrentGradient other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricCurrentGradient within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricCurrentGradient. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricCurrentGradientUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricCurrentGradientUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricCurrentGradient to another ElectricCurrentGradient with the unit representation . - /// - /// A ElectricCurrentGradient with the specified unit. - public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricCurrentGradient(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricCurrentGradientUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.g.cs deleted file mode 100644 index 22ef18d5f6..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricField.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// An electric field is a force field that surrounds electric charges that attracts or repels other electric charges. - /// - /// - /// https://en.wikipedia.org/wiki/Electric_field - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricField : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricFieldUnit? _unit; - - static ElectricField() - { - BaseDimensions = new BaseDimensions(1, 1, -3, -1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricField, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricField() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricField(double value, ElectricFieldUnit unit) - { - if(unit == ElectricFieldUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricField, which is VoltPerMeter. All conversions go via this value. - /// - public static ElectricFieldUnit BaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; - - /// - /// Represents the largest possible value of ElectricField - /// - public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricField - /// - public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricField; - - /// - /// All units of measurement for the ElectricField quantity. - /// - public static ElectricFieldUnit[] Units { get; } = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().Except(new ElectricFieldUnit[]{ ElectricFieldUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerMeter. - /// - public static ElectricField Zero { get; } = new ElectricField(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricField.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricField.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricField in VoltsPerMeter. - /// - public double VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricFieldUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricFieldUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricField from VoltsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricField FromVoltsPerMeter(double voltspermeter) - { - double value = (double) voltspermeter; - return new ElectricField(value, ElectricFieldUnit.VoltPerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricField unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricField From(double value, ElectricFieldUnit fromUnit) - { - return new ElectricField((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricField Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricField Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricField result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricField result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricFieldUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricFieldUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricFieldUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricFieldUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricField objElectricField)) throw new ArgumentException("Expected type ElectricField.", nameof(obj)); - - return CompareTo(objElectricField); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricField other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricField objElectricField)) - return false; - - return Equals(objElectricField); - } - - public bool Equals(ElectricField other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricField within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricField. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricFieldUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricFieldUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricField to another ElectricField with the unit representation . - /// - /// A ElectricField with the specified unit. - public ElectricField ToUnit(ElectricFieldUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricField(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case ElectricFieldUnit.VoltPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(ElectricFieldUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case ElectricFieldUnit.VoltPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.g.cs deleted file mode 100644 index 5109849aec..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricInductance.g.cs +++ /dev/null @@ -1,634 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Inductance is a property of an electrical conductor which opposes a change in current. - /// - /// - /// https://en.wikipedia.org/wiki/Inductance - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricInductance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricInductanceUnit? _unit; - - static ElectricInductance() - { - BaseDimensions = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricInductance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Henry. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricInductance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricInductance(double value, ElectricInductanceUnit unit) - { - if(unit == ElectricInductanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricInductance, which is Henry. All conversions go via this value. - /// - public static ElectricInductanceUnit BaseUnit { get; } = ElectricInductanceUnit.Henry; - - /// - /// Represents the largest possible value of ElectricInductance - /// - public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricInductance - /// - public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricInductance; - - /// - /// All units of measurement for the ElectricInductance quantity. - /// - public static ElectricInductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().Except(new ElectricInductanceUnit[]{ ElectricInductanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Henry. - /// - public static ElectricInductance Zero { get; } = new ElectricInductance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricInductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricInductance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricInductance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricInductance in Henries. - /// - public double Henries => As(ElectricInductanceUnit.Henry); - - /// - /// Get ElectricInductance in Microhenries. - /// - public double Microhenries => As(ElectricInductanceUnit.Microhenry); - - /// - /// Get ElectricInductance in Millihenries. - /// - public double Millihenries => As(ElectricInductanceUnit.Millihenry); - - /// - /// Get ElectricInductance in Nanohenries. - /// - public double Nanohenries => As(ElectricInductanceUnit.Nanohenry); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricInductanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricInductanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricInductance from Henries. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricInductance FromHenries(double henries) - { - double value = (double) henries; - return new ElectricInductance(value, ElectricInductanceUnit.Henry); - } - /// - /// Get ElectricInductance from Microhenries. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricInductance FromMicrohenries(double microhenries) - { - double value = (double) microhenries; - return new ElectricInductance(value, ElectricInductanceUnit.Microhenry); - } - /// - /// Get ElectricInductance from Millihenries. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricInductance FromMillihenries(double millihenries) - { - double value = (double) millihenries; - return new ElectricInductance(value, ElectricInductanceUnit.Millihenry); - } - /// - /// Get ElectricInductance from Nanohenries. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricInductance FromNanohenries(double nanohenries) - { - double value = (double) nanohenries; - return new ElectricInductance(value, ElectricInductanceUnit.Nanohenry); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricInductance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricInductance From(double value, ElectricInductanceUnit fromUnit) - { - return new ElectricInductance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricInductance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricInductance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricInductance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricInductance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricInductanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricInductanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricInductanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricInductanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricInductance objElectricInductance)) throw new ArgumentException("Expected type ElectricInductance.", nameof(obj)); - - return CompareTo(objElectricInductance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricInductance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricInductance objElectricInductance)) - return false; - - return Equals(objElectricInductance); - } - - public bool Equals(ElectricInductance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricInductance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricInductance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricInductanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricInductanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricInductance to another ElectricInductance with the unit representation . - /// - /// A ElectricInductance with the specified unit. - public ElectricInductance ToUnit(ElectricInductanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricInductance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricInductanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.g.cs deleted file mode 100644 index 7aa0e72cfb..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotential.g.cs +++ /dev/null @@ -1,648 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricPotential : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricPotentialUnit? _unit; - - static ElectricPotential() - { - BaseDimensions = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricPotential, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Volt. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricPotential() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricPotential(double value, ElectricPotentialUnit unit) - { - if(unit == ElectricPotentialUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricPotential, which is Volt. All conversions go via this value. - /// - public static ElectricPotentialUnit BaseUnit { get; } = ElectricPotentialUnit.Volt; - - /// - /// Represents the largest possible value of ElectricPotential - /// - public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotential - /// - public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotential; - - /// - /// All units of measurement for the ElectricPotential quantity. - /// - public static ElectricPotentialUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().Except(new ElectricPotentialUnit[]{ ElectricPotentialUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Volt. - /// - public static ElectricPotential Zero { get; } = new ElectricPotential(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricPotentialUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotential.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricPotential.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricPotential in Kilovolts. - /// - public double Kilovolts => As(ElectricPotentialUnit.Kilovolt); - - /// - /// Get ElectricPotential in Megavolts. - /// - public double Megavolts => As(ElectricPotentialUnit.Megavolt); - - /// - /// Get ElectricPotential in Microvolts. - /// - public double Microvolts => As(ElectricPotentialUnit.Microvolt); - - /// - /// Get ElectricPotential in Millivolts. - /// - public double Millivolts => As(ElectricPotentialUnit.Millivolt); - - /// - /// Get ElectricPotential in Volts. - /// - public double Volts => As(ElectricPotentialUnit.Volt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricPotentialUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricPotentialUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricPotential from Kilovolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotential FromKilovolts(double kilovolts) - { - double value = (double) kilovolts; - return new ElectricPotential(value, ElectricPotentialUnit.Kilovolt); - } - /// - /// Get ElectricPotential from Megavolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotential FromMegavolts(double megavolts) - { - double value = (double) megavolts; - return new ElectricPotential(value, ElectricPotentialUnit.Megavolt); - } - /// - /// Get ElectricPotential from Microvolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotential FromMicrovolts(double microvolts) - { - double value = (double) microvolts; - return new ElectricPotential(value, ElectricPotentialUnit.Microvolt); - } - /// - /// Get ElectricPotential from Millivolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotential FromMillivolts(double millivolts) - { - double value = (double) millivolts; - return new ElectricPotential(value, ElectricPotentialUnit.Millivolt); - } - /// - /// Get ElectricPotential from Volts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotential FromVolts(double volts) - { - double value = (double) volts; - return new ElectricPotential(value, ElectricPotentialUnit.Volt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricPotential unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricPotential From(double value, ElectricPotentialUnit fromUnit) - { - return new ElectricPotential((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricPotential Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotential Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricPotential result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricPotential result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricPotentialUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricPotentialUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricPotentialUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotential objElectricPotential)) throw new ArgumentException("Expected type ElectricPotential.", nameof(obj)); - - return CompareTo(objElectricPotential); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricPotential other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotential objElectricPotential)) - return false; - - return Equals(objElectricPotential); - } - - public bool Equals(ElectricPotential other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricPotential within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricPotential. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricPotentialUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricPotentialUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricPotential to another ElectricPotential with the unit representation . - /// - /// A ElectricPotential with the specified unit. - public ElectricPotential ToUnit(ElectricPotentialUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricPotential(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricPotentialUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.g.cs deleted file mode 100644 index e9df870b18..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ /dev/null @@ -1,648 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The Electric Potential of a system known to use Alternating Current. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricPotentialAc : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricPotentialAcUnit? _unit; - - static ElectricPotentialAc() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.ElectricPotentialAc, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltAc. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricPotentialAc() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) - { - if(unit == ElectricPotentialAcUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricPotentialAc, which is VoltAc. All conversions go via this value. - /// - public static ElectricPotentialAcUnit BaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; - - /// - /// Represents the largest possible value of ElectricPotentialAc - /// - public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotentialAc - /// - public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialAc; - - /// - /// All units of measurement for the ElectricPotentialAc quantity. - /// - public static ElectricPotentialAcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().Except(new ElectricPotentialAcUnit[]{ ElectricPotentialAcUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltAc. - /// - public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricPotentialAcUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotentialAc.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricPotentialAc.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricPotentialAc in KilovoltsAc. - /// - public double KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); - - /// - /// Get ElectricPotentialAc in MegavoltsAc. - /// - public double MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); - - /// - /// Get ElectricPotentialAc in MicrovoltsAc. - /// - public double MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); - - /// - /// Get ElectricPotentialAc in MillivoltsAc. - /// - public double MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); - - /// - /// Get ElectricPotentialAc in VoltsAc. - /// - public double VoltsAc => As(ElectricPotentialAcUnit.VoltAc); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricPotentialAcUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricPotentialAcUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricPotentialAc from KilovoltsAc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialAc FromKilovoltsAc(double kilovoltsac) - { - double value = (double) kilovoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.KilovoltAc); - } - /// - /// Get ElectricPotentialAc from MegavoltsAc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialAc FromMegavoltsAc(double megavoltsac) - { - double value = (double) megavoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MegavoltAc); - } - /// - /// Get ElectricPotentialAc from MicrovoltsAc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialAc FromMicrovoltsAc(double microvoltsac) - { - double value = (double) microvoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MicrovoltAc); - } - /// - /// Get ElectricPotentialAc from MillivoltsAc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialAc FromMillivoltsAc(double millivoltsac) - { - double value = (double) millivoltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MillivoltAc); - } - /// - /// Get ElectricPotentialAc from VoltsAc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialAc FromVoltsAc(double voltsac) - { - double value = (double) voltsac; - return new ElectricPotentialAc(value, ElectricPotentialAcUnit.VoltAc); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricPotentialAc unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricPotentialAc From(double value, ElectricPotentialAcUnit fromUnit) - { - return new ElectricPotentialAc((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricPotentialAc Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialAc Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricPotentialAc result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricPotentialAc result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricPotentialAcUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialAcUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricPotentialAcUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricPotentialAcUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotentialAc objElectricPotentialAc)) throw new ArgumentException("Expected type ElectricPotentialAc.", nameof(obj)); - - return CompareTo(objElectricPotentialAc); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricPotentialAc other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) - return false; - - return Equals(objElectricPotentialAc); - } - - public bool Equals(ElectricPotentialAc other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricPotentialAc within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricPotentialAc. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricPotentialAcUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricPotentialAcUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricPotentialAc to another ElectricPotentialAc with the unit representation . - /// - /// A ElectricPotentialAc with the specified unit. - public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricPotentialAc(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricPotentialAcUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs deleted file mode 100644 index f01bc555f9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ /dev/null @@ -1,903 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricPotentialChangeRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricPotentialChangeRateUnit? _unit; - - static ElectricPotentialChangeRate() - { - BaseDimensions = new BaseDimensions(2, 1, -4, -1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricPotentialChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricPotentialChangeRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) - { - if(unit == ElectricPotentialChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricPotentialChangeRate, which is VoltPerSecond. All conversions go via this value. - /// - public static ElectricPotentialChangeRateUnit BaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; - - /// - /// Represents the largest possible value of ElectricPotentialChangeRate - /// - public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotentialChangeRate - /// - public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialChangeRate; - - /// - /// All units of measurement for the ElectricPotentialChangeRate quantity. - /// - public static ElectricPotentialChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast().Except(new ElectricPotentialChangeRateUnit[]{ ElectricPotentialChangeRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerSecond. - /// - public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricPotentialChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotentialChangeRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricPotentialChangeRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricPotentialChangeRate in KilovoltsPerHours. - /// - public double KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); - - /// - /// Get ElectricPotentialChangeRate in KilovoltsPerMicroseconds. - /// - public double KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); - - /// - /// Get ElectricPotentialChangeRate in KilovoltsPerMinutes. - /// - public double KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); - - /// - /// Get ElectricPotentialChangeRate in KilovoltsPerSeconds. - /// - public double KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); - - /// - /// Get ElectricPotentialChangeRate in MegavoltsPerHours. - /// - public double MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); - - /// - /// Get ElectricPotentialChangeRate in MegavoltsPerMicroseconds. - /// - public double MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); - - /// - /// Get ElectricPotentialChangeRate in MegavoltsPerMinutes. - /// - public double MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); - - /// - /// Get ElectricPotentialChangeRate in MegavoltsPerSeconds. - /// - public double MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); - - /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerHours. - /// - public double MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); - - /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerMicroseconds. - /// - public double MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); - - /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerMinutes. - /// - public double MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); - - /// - /// Get ElectricPotentialChangeRate in MicrovoltsPerSeconds. - /// - public double MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); - - /// - /// Get ElectricPotentialChangeRate in MillivoltsPerHours. - /// - public double MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); - - /// - /// Get ElectricPotentialChangeRate in MillivoltsPerMicroseconds. - /// - public double MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); - - /// - /// Get ElectricPotentialChangeRate in MillivoltsPerMinutes. - /// - public double MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); - - /// - /// Get ElectricPotentialChangeRate in MillivoltsPerSeconds. - /// - public double MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); - - /// - /// Get ElectricPotentialChangeRate in VoltsPerHours. - /// - public double VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); - - /// - /// Get ElectricPotentialChangeRate in VoltsPerMicroseconds. - /// - public double VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); - - /// - /// Get ElectricPotentialChangeRate in VoltsPerMinutes. - /// - public double VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); - - /// - /// Get ElectricPotentialChangeRate in VoltsPerSeconds. - /// - public double VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricPotentialChangeRate from KilovoltsPerHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromKilovoltsPerHours(double kilovoltsperhours) - { - double value = (double) kilovoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerHour); - } - /// - /// Get ElectricPotentialChangeRate from KilovoltsPerMicroseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(double kilovoltspermicroseconds) - { - double value = (double) kilovoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); - } - /// - /// Get ElectricPotentialChangeRate from KilovoltsPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(double kilovoltsperminutes) - { - double value = (double) kilovoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMinute); - } - /// - /// Get ElectricPotentialChangeRate from KilovoltsPerSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(double kilovoltsperseconds) - { - double value = (double) kilovoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerSecond); - } - /// - /// Get ElectricPotentialChangeRate from MegavoltsPerHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMegavoltsPerHours(double megavoltsperhours) - { - double value = (double) megavoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerHour); - } - /// - /// Get ElectricPotentialChangeRate from MegavoltsPerMicroseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(double megavoltspermicroseconds) - { - double value = (double) megavoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); - } - /// - /// Get ElectricPotentialChangeRate from MegavoltsPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(double megavoltsperminutes) - { - double value = (double) megavoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMinute); - } - /// - /// Get ElectricPotentialChangeRate from MegavoltsPerSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(double megavoltsperseconds) - { - double value = (double) megavoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerSecond); - } - /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMicrovoltsPerHours(double microvoltsperhours) - { - double value = (double) microvoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerHour); - } - /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerMicroseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(double microvoltspermicroseconds) - { - double value = (double) microvoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); - } - /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(double microvoltsperminutes) - { - double value = (double) microvoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); - } - /// - /// Get ElectricPotentialChangeRate from MicrovoltsPerSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(double microvoltsperseconds) - { - double value = (double) microvoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); - } - /// - /// Get ElectricPotentialChangeRate from MillivoltsPerHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMillivoltsPerHours(double millivoltsperhours) - { - double value = (double) millivoltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerHour); - } - /// - /// Get ElectricPotentialChangeRate from MillivoltsPerMicroseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(double millivoltspermicroseconds) - { - double value = (double) millivoltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); - } - /// - /// Get ElectricPotentialChangeRate from MillivoltsPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(double millivoltsperminutes) - { - double value = (double) millivoltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMinute); - } - /// - /// Get ElectricPotentialChangeRate from MillivoltsPerSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(double millivoltsperseconds) - { - double value = (double) millivoltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerSecond); - } - /// - /// Get ElectricPotentialChangeRate from VoltsPerHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromVoltsPerHours(double voltsperhours) - { - double value = (double) voltsperhours; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerHour); - } - /// - /// Get ElectricPotentialChangeRate from VoltsPerMicroseconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(double voltspermicroseconds) - { - double value = (double) voltspermicroseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); - } - /// - /// Get ElectricPotentialChangeRate from VoltsPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromVoltsPerMinutes(double voltsperminutes) - { - double value = (double) voltsperminutes; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMinute); - } - /// - /// Get ElectricPotentialChangeRate from VoltsPerSeconds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialChangeRate FromVoltsPerSeconds(double voltsperseconds) - { - double value = (double) voltsperseconds; - return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricPotentialChangeRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricPotentialChangeRate From(double value, ElectricPotentialChangeRateUnit fromUnit) - { - return new ElectricPotentialChangeRate((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricPotentialChangeRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialChangeRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricPotentialChangeRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricPotentialChangeRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricPotentialChangeRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialChangeRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricPotentialChangeRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricPotentialChangeRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) throw new ArgumentException("Expected type ElectricPotentialChangeRate.", nameof(obj)); - - return CompareTo(objElectricPotentialChangeRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricPotentialChangeRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) - return false; - - return Equals(objElectricPotentialChangeRate); - } - - public bool Equals(ElectricPotentialChangeRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricPotentialChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialChangeRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricPotentialChangeRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricPotentialChangeRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricPotentialChangeRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricPotentialChangeRate to another ElectricPotentialChangeRate with the unit representation . - /// - /// A ElectricPotentialChangeRate with the specified unit. - public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricPotentialChangeRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricPotentialChangeRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.g.cs deleted file mode 100644 index 9b7dacb193..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ /dev/null @@ -1,648 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The Electric Potential of a system known to use Direct Current. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricPotentialDc : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricPotentialDcUnit? _unit; - - static ElectricPotentialDc() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.ElectricPotentialDc, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltDc. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricPotentialDc() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) - { - if(unit == ElectricPotentialDcUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricPotentialDc, which is VoltDc. All conversions go via this value. - /// - public static ElectricPotentialDcUnit BaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; - - /// - /// Represents the largest possible value of ElectricPotentialDc - /// - public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotentialDc - /// - public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialDc; - - /// - /// All units of measurement for the ElectricPotentialDc quantity. - /// - public static ElectricPotentialDcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().Except(new ElectricPotentialDcUnit[]{ ElectricPotentialDcUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltDc. - /// - public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricPotentialDcUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotentialDc.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricPotentialDc.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricPotentialDc in KilovoltsDc. - /// - public double KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); - - /// - /// Get ElectricPotentialDc in MegavoltsDc. - /// - public double MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); - - /// - /// Get ElectricPotentialDc in MicrovoltsDc. - /// - public double MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); - - /// - /// Get ElectricPotentialDc in MillivoltsDc. - /// - public double MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); - - /// - /// Get ElectricPotentialDc in VoltsDc. - /// - public double VoltsDc => As(ElectricPotentialDcUnit.VoltDc); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricPotentialDcUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricPotentialDcUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricPotentialDc from KilovoltsDc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialDc FromKilovoltsDc(double kilovoltsdc) - { - double value = (double) kilovoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.KilovoltDc); - } - /// - /// Get ElectricPotentialDc from MegavoltsDc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialDc FromMegavoltsDc(double megavoltsdc) - { - double value = (double) megavoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MegavoltDc); - } - /// - /// Get ElectricPotentialDc from MicrovoltsDc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialDc FromMicrovoltsDc(double microvoltsdc) - { - double value = (double) microvoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MicrovoltDc); - } - /// - /// Get ElectricPotentialDc from MillivoltsDc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialDc FromMillivoltsDc(double millivoltsdc) - { - double value = (double) millivoltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MillivoltDc); - } - /// - /// Get ElectricPotentialDc from VoltsDc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricPotentialDc FromVoltsDc(double voltsdc) - { - double value = (double) voltsdc; - return new ElectricPotentialDc(value, ElectricPotentialDcUnit.VoltDc); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricPotentialDc unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricPotentialDc From(double value, ElectricPotentialDcUnit fromUnit) - { - return new ElectricPotentialDc((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricPotentialDc Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialDc Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricPotentialDc result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricPotentialDc result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricPotentialDcUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricPotentialDcUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricPotentialDcUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricPotentialDcUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricPotentialDc objElectricPotentialDc)) throw new ArgumentException("Expected type ElectricPotentialDc.", nameof(obj)); - - return CompareTo(objElectricPotentialDc); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricPotentialDc other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) - return false; - - return Equals(objElectricPotentialDc); - } - - public bool Equals(ElectricPotentialDc other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricPotentialDc within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricPotentialDc. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricPotentialDcUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricPotentialDcUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricPotentialDc to another ElectricPotentialDc with the unit representation . - /// - /// A ElectricPotentialDc with the specified unit. - public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricPotentialDc(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricPotentialDcUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.g.cs deleted file mode 100644 index 62c594e09e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistance.g.cs +++ /dev/null @@ -1,665 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricResistance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricResistanceUnit? _unit; - - static ElectricResistance() - { - BaseDimensions = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricResistance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Ohm. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricResistance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricResistance(double value, ElectricResistanceUnit unit) - { - if(unit == ElectricResistanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricResistance, which is Ohm. All conversions go via this value. - /// - public static ElectricResistanceUnit BaseUnit { get; } = ElectricResistanceUnit.Ohm; - - /// - /// Represents the largest possible value of ElectricResistance - /// - public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricResistance - /// - public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricResistance; - - /// - /// All units of measurement for the ElectricResistance quantity. - /// - public static ElectricResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().Except(new ElectricResistanceUnit[]{ ElectricResistanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Ohm. - /// - public static ElectricResistance Zero { get; } = new ElectricResistance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricResistance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricResistance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricResistance in Gigaohms. - /// - public double Gigaohms => As(ElectricResistanceUnit.Gigaohm); - - /// - /// Get ElectricResistance in Kiloohms. - /// - public double Kiloohms => As(ElectricResistanceUnit.Kiloohm); - - /// - /// Get ElectricResistance in Megaohms. - /// - public double Megaohms => As(ElectricResistanceUnit.Megaohm); - - /// - /// Get ElectricResistance in Microohms. - /// - public double Microohms => As(ElectricResistanceUnit.Microohm); - - /// - /// Get ElectricResistance in Milliohms. - /// - public double Milliohms => As(ElectricResistanceUnit.Milliohm); - - /// - /// Get ElectricResistance in Ohms. - /// - public double Ohms => As(ElectricResistanceUnit.Ohm); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricResistanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricResistanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricResistance from Gigaohms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistance FromGigaohms(double gigaohms) - { - double value = (double) gigaohms; - return new ElectricResistance(value, ElectricResistanceUnit.Gigaohm); - } - /// - /// Get ElectricResistance from Kiloohms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistance FromKiloohms(double kiloohms) - { - double value = (double) kiloohms; - return new ElectricResistance(value, ElectricResistanceUnit.Kiloohm); - } - /// - /// Get ElectricResistance from Megaohms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistance FromMegaohms(double megaohms) - { - double value = (double) megaohms; - return new ElectricResistance(value, ElectricResistanceUnit.Megaohm); - } - /// - /// Get ElectricResistance from Microohms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistance FromMicroohms(double microohms) - { - double value = (double) microohms; - return new ElectricResistance(value, ElectricResistanceUnit.Microohm); - } - /// - /// Get ElectricResistance from Milliohms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistance FromMilliohms(double milliohms) - { - double value = (double) milliohms; - return new ElectricResistance(value, ElectricResistanceUnit.Milliohm); - } - /// - /// Get ElectricResistance from Ohms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistance FromOhms(double ohms) - { - double value = (double) ohms; - return new ElectricResistance(value, ElectricResistanceUnit.Ohm); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricResistance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricResistance From(double value, ElectricResistanceUnit fromUnit) - { - return new ElectricResistance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricResistance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricResistance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricResistance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricResistance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricResistanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricResistanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricResistanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricResistanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricResistance objElectricResistance)) throw new ArgumentException("Expected type ElectricResistance.", nameof(obj)); - - return CompareTo(objElectricResistance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricResistance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricResistance objElectricResistance)) - return false; - - return Equals(objElectricResistance); - } - - public bool Equals(ElectricResistance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricResistance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricResistance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricResistanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricResistanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricResistance to another ElectricResistance with the unit representation . - /// - /// A ElectricResistance with the specified unit. - public ElectricResistance ToUnit(ElectricResistanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricResistance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricResistanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.g.cs deleted file mode 100644 index c47de6271c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ /dev/null @@ -1,804 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Electrical resistivity (also known as resistivity, specific electrical resistance, or volume resistivity) is a fundamental property that quantifies how strongly a given material opposes the flow of electric current. - /// - /// - /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricResistivity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricResistivityUnit? _unit; - - static ElectricResistivity() - { - BaseDimensions = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricResistivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit OhmMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricResistivity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricResistivity(double value, ElectricResistivityUnit unit) - { - if(unit == ElectricResistivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricResistivity, which is OhmMeter. All conversions go via this value. - /// - public static ElectricResistivityUnit BaseUnit { get; } = ElectricResistivityUnit.OhmMeter; - - /// - /// Represents the largest possible value of ElectricResistivity - /// - public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricResistivity - /// - public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricResistivity; - - /// - /// All units of measurement for the ElectricResistivity quantity. - /// - public static ElectricResistivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().Except(new ElectricResistivityUnit[]{ ElectricResistivityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit OhmMeter. - /// - public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricResistivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricResistivity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricResistivity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricResistivity in KiloohmsCentimeter. - /// - public double KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); - - /// - /// Get ElectricResistivity in KiloohmMeters. - /// - public double KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); - - /// - /// Get ElectricResistivity in MegaohmsCentimeter. - /// - public double MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); - - /// - /// Get ElectricResistivity in MegaohmMeters. - /// - public double MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); - - /// - /// Get ElectricResistivity in MicroohmsCentimeter. - /// - public double MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); - - /// - /// Get ElectricResistivity in MicroohmMeters. - /// - public double MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); - - /// - /// Get ElectricResistivity in MilliohmsCentimeter. - /// - public double MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); - - /// - /// Get ElectricResistivity in MilliohmMeters. - /// - public double MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); - - /// - /// Get ElectricResistivity in NanoohmsCentimeter. - /// - public double NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); - - /// - /// Get ElectricResistivity in NanoohmMeters. - /// - public double NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); - - /// - /// Get ElectricResistivity in OhmsCentimeter. - /// - public double OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); - - /// - /// Get ElectricResistivity in OhmMeters. - /// - public double OhmMeters => As(ElectricResistivityUnit.OhmMeter); - - /// - /// Get ElectricResistivity in PicoohmsCentimeter. - /// - public double PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); - - /// - /// Get ElectricResistivity in PicoohmMeters. - /// - public double PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricResistivityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricResistivityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricResistivity from KiloohmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromKiloohmsCentimeter(double kiloohmscentimeter) - { - double value = (double) kiloohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmCentimeter); - } - /// - /// Get ElectricResistivity from KiloohmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromKiloohmMeters(double kiloohmmeters) - { - double value = (double) kiloohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmMeter); - } - /// - /// Get ElectricResistivity from MegaohmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromMegaohmsCentimeter(double megaohmscentimeter) - { - double value = (double) megaohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmCentimeter); - } - /// - /// Get ElectricResistivity from MegaohmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromMegaohmMeters(double megaohmmeters) - { - double value = (double) megaohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmMeter); - } - /// - /// Get ElectricResistivity from MicroohmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromMicroohmsCentimeter(double microohmscentimeter) - { - double value = (double) microohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmCentimeter); - } - /// - /// Get ElectricResistivity from MicroohmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromMicroohmMeters(double microohmmeters) - { - double value = (double) microohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmMeter); - } - /// - /// Get ElectricResistivity from MilliohmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromMilliohmsCentimeter(double milliohmscentimeter) - { - double value = (double) milliohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmCentimeter); - } - /// - /// Get ElectricResistivity from MilliohmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromMilliohmMeters(double milliohmmeters) - { - double value = (double) milliohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmMeter); - } - /// - /// Get ElectricResistivity from NanoohmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromNanoohmsCentimeter(double nanoohmscentimeter) - { - double value = (double) nanoohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmCentimeter); - } - /// - /// Get ElectricResistivity from NanoohmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromNanoohmMeters(double nanoohmmeters) - { - double value = (double) nanoohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmMeter); - } - /// - /// Get ElectricResistivity from OhmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromOhmsCentimeter(double ohmscentimeter) - { - double value = (double) ohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.OhmCentimeter); - } - /// - /// Get ElectricResistivity from OhmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromOhmMeters(double ohmmeters) - { - double value = (double) ohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.OhmMeter); - } - /// - /// Get ElectricResistivity from PicoohmsCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromPicoohmsCentimeter(double picoohmscentimeter) - { - double value = (double) picoohmscentimeter; - return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmCentimeter); - } - /// - /// Get ElectricResistivity from PicoohmMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricResistivity FromPicoohmMeters(double picoohmmeters) - { - double value = (double) picoohmmeters; - return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricResistivity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricResistivity From(double value, ElectricResistivityUnit fromUnit) - { - return new ElectricResistivity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricResistivity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricResistivity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricResistivity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricResistivity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricResistivityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricResistivityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricResistivityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricResistivityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricResistivity objElectricResistivity)) throw new ArgumentException("Expected type ElectricResistivity.", nameof(obj)); - - return CompareTo(objElectricResistivity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricResistivity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricResistivity objElectricResistivity)) - return false; - - return Equals(objElectricResistivity); - } - - public bool Equals(ElectricResistivity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricResistivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricResistivity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricResistivityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricResistivityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricResistivity to another ElectricResistivity with the unit representation . - /// - /// A ElectricResistivity with the specified unit. - public ElectricResistivity ToUnit(ElectricResistivityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricResistivity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricResistivityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs deleted file mode 100644 index f56800c357..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ /dev/null @@ -1,617 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In electromagnetism, surface charge density is a measure of the amount of electric charge per surface area. - /// - /// - /// https://en.wikipedia.org/wiki/Charge_density - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ElectricSurfaceChargeDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ElectricSurfaceChargeDensityUnit? _unit; - - static ElectricSurfaceChargeDensity() - { - BaseDimensions = new BaseDimensions(-2, 0, 1, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ElectricSurfaceChargeDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit CoulombPerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ElectricSurfaceChargeDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) - { - if(unit == ElectricSurfaceChargeDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ElectricSurfaceChargeDensity, which is CoulombPerSquareMeter. All conversions go via this value. - /// - public static ElectricSurfaceChargeDensityUnit BaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; - - /// - /// Represents the largest possible value of ElectricSurfaceChargeDensity - /// - public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ElectricSurfaceChargeDensity - /// - public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ElectricSurfaceChargeDensity; - - /// - /// All units of measurement for the ElectricSurfaceChargeDensity quantity. - /// - public static ElectricSurfaceChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast().Except(new ElectricSurfaceChargeDensityUnit[]{ ElectricSurfaceChargeDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerSquareMeter. - /// - public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ElectricSurfaceChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricSurfaceChargeDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ElectricSurfaceChargeDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ElectricSurfaceChargeDensity in CoulombsPerSquareCentimeter. - /// - public double CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); - - /// - /// Get ElectricSurfaceChargeDensity in CoulombsPerSquareInch. - /// - public double CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); - - /// - /// Get ElectricSurfaceChargeDensity in CoulombsPerSquareMeter. - /// - public double CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ElectricSurfaceChargeDensity from CoulombsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(double coulombspersquarecentimeter) - { - double value = (double) coulombspersquarecentimeter; - return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); - } - /// - /// Get ElectricSurfaceChargeDensity from CoulombsPerSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(double coulombspersquareinch) - { - double value = (double) coulombspersquareinch; - return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); - } - /// - /// Get ElectricSurfaceChargeDensity from CoulombsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(double coulombspersquaremeter) - { - double value = (double) coulombspersquaremeter; - return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ElectricSurfaceChargeDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ElectricSurfaceChargeDensity From(double value, ElectricSurfaceChargeDensityUnit fromUnit) - { - return new ElectricSurfaceChargeDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ElectricSurfaceChargeDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricSurfaceChargeDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ElectricSurfaceChargeDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ElectricSurfaceChargeDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ElectricSurfaceChargeDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ElectricSurfaceChargeDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ElectricSurfaceChargeDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ElectricSurfaceChargeDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) throw new ArgumentException("Expected type ElectricSurfaceChargeDensity.", nameof(obj)); - - return CompareTo(objElectricSurfaceChargeDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ElectricSurfaceChargeDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) - return false; - - return Equals(objElectricSurfaceChargeDensity); - } - - public bool Equals(ElectricSurfaceChargeDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ElectricSurfaceChargeDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ElectricSurfaceChargeDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ElectricSurfaceChargeDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ElectricSurfaceChargeDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ElectricSurfaceChargeDensity to another ElectricSurfaceChargeDensity with the unit representation . - /// - /// A ElectricSurfaceChargeDensity with the specified unit. - public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ElectricSurfaceChargeDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ElectricSurfaceChargeDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.g.cs deleted file mode 100644 index c1bbd532f8..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Energy.g.cs +++ /dev/null @@ -1,1175 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Energy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly EnergyUnit? _unit; - - static Energy() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Energy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Joule. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Energy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Energy(double value, EnergyUnit unit) - { - if(unit == EnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Energy, which is Joule. All conversions go via this value. - /// - public static EnergyUnit BaseUnit { get; } = EnergyUnit.Joule; - - /// - /// Represents the largest possible value of Energy - /// - public static Energy MaxValue { get; } = new Energy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Energy - /// - public static Energy MinValue { get; } = new Energy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Energy; - - /// - /// All units of measurement for the Energy quantity. - /// - public static EnergyUnit[] Units { get; } = Enum.GetValues(typeof(EnergyUnit)).Cast().Except(new EnergyUnit[]{ EnergyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Joule. - /// - public static Energy Zero { get; } = new Energy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public EnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Energy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Energy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Energy in BritishThermalUnits. - /// - public double BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); - - /// - /// Get Energy in Calories. - /// - public double Calories => As(EnergyUnit.Calorie); - - /// - /// Get Energy in DecathermsEc. - /// - public double DecathermsEc => As(EnergyUnit.DecathermEc); - - /// - /// Get Energy in DecathermsImperial. - /// - public double DecathermsImperial => As(EnergyUnit.DecathermImperial); - - /// - /// Get Energy in DecathermsUs. - /// - public double DecathermsUs => As(EnergyUnit.DecathermUs); - - /// - /// Get Energy in ElectronVolts. - /// - public double ElectronVolts => As(EnergyUnit.ElectronVolt); - - /// - /// Get Energy in Ergs. - /// - public double Ergs => As(EnergyUnit.Erg); - - /// - /// Get Energy in FootPounds. - /// - public double FootPounds => As(EnergyUnit.FootPound); - - /// - /// Get Energy in GigabritishThermalUnits. - /// - public double GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); - - /// - /// Get Energy in GigaelectronVolts. - /// - public double GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); - - /// - /// Get Energy in Gigajoules. - /// - public double Gigajoules => As(EnergyUnit.Gigajoule); - - /// - /// Get Energy in GigawattDays. - /// - public double GigawattDays => As(EnergyUnit.GigawattDay); - - /// - /// Get Energy in GigawattHours. - /// - public double GigawattHours => As(EnergyUnit.GigawattHour); - - /// - /// Get Energy in HorsepowerHours. - /// - public double HorsepowerHours => As(EnergyUnit.HorsepowerHour); - - /// - /// Get Energy in Joules. - /// - public double Joules => As(EnergyUnit.Joule); - - /// - /// Get Energy in KilobritishThermalUnits. - /// - public double KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); - - /// - /// Get Energy in Kilocalories. - /// - public double Kilocalories => As(EnergyUnit.Kilocalorie); - - /// - /// Get Energy in KiloelectronVolts. - /// - public double KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); - - /// - /// Get Energy in Kilojoules. - /// - public double Kilojoules => As(EnergyUnit.Kilojoule); - - /// - /// Get Energy in KilowattDays. - /// - public double KilowattDays => As(EnergyUnit.KilowattDay); - - /// - /// Get Energy in KilowattHours. - /// - public double KilowattHours => As(EnergyUnit.KilowattHour); - - /// - /// Get Energy in MegabritishThermalUnits. - /// - public double MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); - - /// - /// Get Energy in Megacalories. - /// - public double Megacalories => As(EnergyUnit.Megacalorie); - - /// - /// Get Energy in MegaelectronVolts. - /// - public double MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); - - /// - /// Get Energy in Megajoules. - /// - public double Megajoules => As(EnergyUnit.Megajoule); - - /// - /// Get Energy in MegawattDays. - /// - public double MegawattDays => As(EnergyUnit.MegawattDay); - - /// - /// Get Energy in MegawattHours. - /// - public double MegawattHours => As(EnergyUnit.MegawattHour); - - /// - /// Get Energy in Millijoules. - /// - public double Millijoules => As(EnergyUnit.Millijoule); - - /// - /// Get Energy in TeraelectronVolts. - /// - public double TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); - - /// - /// Get Energy in TerawattDays. - /// - public double TerawattDays => As(EnergyUnit.TerawattDay); - - /// - /// Get Energy in TerawattHours. - /// - public double TerawattHours => As(EnergyUnit.TerawattHour); - - /// - /// Get Energy in ThermsEc. - /// - public double ThermsEc => As(EnergyUnit.ThermEc); - - /// - /// Get Energy in ThermsImperial. - /// - public double ThermsImperial => As(EnergyUnit.ThermImperial); - - /// - /// Get Energy in ThermsUs. - /// - public double ThermsUs => As(EnergyUnit.ThermUs); - - /// - /// Get Energy in WattDays. - /// - public double WattDays => As(EnergyUnit.WattDay); - - /// - /// Get Energy in WattHours. - /// - public double WattHours => As(EnergyUnit.WattHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(EnergyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(EnergyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Energy from BritishThermalUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromBritishThermalUnits(double britishthermalunits) - { - double value = (double) britishthermalunits; - return new Energy(value, EnergyUnit.BritishThermalUnit); - } - /// - /// Get Energy from Calories. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromCalories(double calories) - { - double value = (double) calories; - return new Energy(value, EnergyUnit.Calorie); - } - /// - /// Get Energy from DecathermsEc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromDecathermsEc(double decathermsec) - { - double value = (double) decathermsec; - return new Energy(value, EnergyUnit.DecathermEc); - } - /// - /// Get Energy from DecathermsImperial. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromDecathermsImperial(double decathermsimperial) - { - double value = (double) decathermsimperial; - return new Energy(value, EnergyUnit.DecathermImperial); - } - /// - /// Get Energy from DecathermsUs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromDecathermsUs(double decathermsus) - { - double value = (double) decathermsus; - return new Energy(value, EnergyUnit.DecathermUs); - } - /// - /// Get Energy from ElectronVolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromElectronVolts(double electronvolts) - { - double value = (double) electronvolts; - return new Energy(value, EnergyUnit.ElectronVolt); - } - /// - /// Get Energy from Ergs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromErgs(double ergs) - { - double value = (double) ergs; - return new Energy(value, EnergyUnit.Erg); - } - /// - /// Get Energy from FootPounds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromFootPounds(double footpounds) - { - double value = (double) footpounds; - return new Energy(value, EnergyUnit.FootPound); - } - /// - /// Get Energy from GigabritishThermalUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromGigabritishThermalUnits(double gigabritishthermalunits) - { - double value = (double) gigabritishthermalunits; - return new Energy(value, EnergyUnit.GigabritishThermalUnit); - } - /// - /// Get Energy from GigaelectronVolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromGigaelectronVolts(double gigaelectronvolts) - { - double value = (double) gigaelectronvolts; - return new Energy(value, EnergyUnit.GigaelectronVolt); - } - /// - /// Get Energy from Gigajoules. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromGigajoules(double gigajoules) - { - double value = (double) gigajoules; - return new Energy(value, EnergyUnit.Gigajoule); - } - /// - /// Get Energy from GigawattDays. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromGigawattDays(double gigawattdays) - { - double value = (double) gigawattdays; - return new Energy(value, EnergyUnit.GigawattDay); - } - /// - /// Get Energy from GigawattHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromGigawattHours(double gigawatthours) - { - double value = (double) gigawatthours; - return new Energy(value, EnergyUnit.GigawattHour); - } - /// - /// Get Energy from HorsepowerHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromHorsepowerHours(double horsepowerhours) - { - double value = (double) horsepowerhours; - return new Energy(value, EnergyUnit.HorsepowerHour); - } - /// - /// Get Energy from Joules. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromJoules(double joules) - { - double value = (double) joules; - return new Energy(value, EnergyUnit.Joule); - } - /// - /// Get Energy from KilobritishThermalUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromKilobritishThermalUnits(double kilobritishthermalunits) - { - double value = (double) kilobritishthermalunits; - return new Energy(value, EnergyUnit.KilobritishThermalUnit); - } - /// - /// Get Energy from Kilocalories. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromKilocalories(double kilocalories) - { - double value = (double) kilocalories; - return new Energy(value, EnergyUnit.Kilocalorie); - } - /// - /// Get Energy from KiloelectronVolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromKiloelectronVolts(double kiloelectronvolts) - { - double value = (double) kiloelectronvolts; - return new Energy(value, EnergyUnit.KiloelectronVolt); - } - /// - /// Get Energy from Kilojoules. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromKilojoules(double kilojoules) - { - double value = (double) kilojoules; - return new Energy(value, EnergyUnit.Kilojoule); - } - /// - /// Get Energy from KilowattDays. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromKilowattDays(double kilowattdays) - { - double value = (double) kilowattdays; - return new Energy(value, EnergyUnit.KilowattDay); - } - /// - /// Get Energy from KilowattHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromKilowattHours(double kilowatthours) - { - double value = (double) kilowatthours; - return new Energy(value, EnergyUnit.KilowattHour); - } - /// - /// Get Energy from MegabritishThermalUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMegabritishThermalUnits(double megabritishthermalunits) - { - double value = (double) megabritishthermalunits; - return new Energy(value, EnergyUnit.MegabritishThermalUnit); - } - /// - /// Get Energy from Megacalories. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMegacalories(double megacalories) - { - double value = (double) megacalories; - return new Energy(value, EnergyUnit.Megacalorie); - } - /// - /// Get Energy from MegaelectronVolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMegaelectronVolts(double megaelectronvolts) - { - double value = (double) megaelectronvolts; - return new Energy(value, EnergyUnit.MegaelectronVolt); - } - /// - /// Get Energy from Megajoules. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMegajoules(double megajoules) - { - double value = (double) megajoules; - return new Energy(value, EnergyUnit.Megajoule); - } - /// - /// Get Energy from MegawattDays. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMegawattDays(double megawattdays) - { - double value = (double) megawattdays; - return new Energy(value, EnergyUnit.MegawattDay); - } - /// - /// Get Energy from MegawattHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMegawattHours(double megawatthours) - { - double value = (double) megawatthours; - return new Energy(value, EnergyUnit.MegawattHour); - } - /// - /// Get Energy from Millijoules. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromMillijoules(double millijoules) - { - double value = (double) millijoules; - return new Energy(value, EnergyUnit.Millijoule); - } - /// - /// Get Energy from TeraelectronVolts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromTeraelectronVolts(double teraelectronvolts) - { - double value = (double) teraelectronvolts; - return new Energy(value, EnergyUnit.TeraelectronVolt); - } - /// - /// Get Energy from TerawattDays. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromTerawattDays(double terawattdays) - { - double value = (double) terawattdays; - return new Energy(value, EnergyUnit.TerawattDay); - } - /// - /// Get Energy from TerawattHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromTerawattHours(double terawatthours) - { - double value = (double) terawatthours; - return new Energy(value, EnergyUnit.TerawattHour); - } - /// - /// Get Energy from ThermsEc. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromThermsEc(double thermsec) - { - double value = (double) thermsec; - return new Energy(value, EnergyUnit.ThermEc); - } - /// - /// Get Energy from ThermsImperial. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromThermsImperial(double thermsimperial) - { - double value = (double) thermsimperial; - return new Energy(value, EnergyUnit.ThermImperial); - } - /// - /// Get Energy from ThermsUs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromThermsUs(double thermsus) - { - double value = (double) thermsus; - return new Energy(value, EnergyUnit.ThermUs); - } - /// - /// Get Energy from WattDays. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromWattDays(double wattdays) - { - double value = (double) wattdays; - return new Energy(value, EnergyUnit.WattDay); - } - /// - /// Get Energy from WattHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Energy FromWattHours(double watthours) - { - double value = (double) watthours; - return new Energy(value, EnergyUnit.WattHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Energy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Energy From(double value, EnergyUnit fromUnit) - { - return new Energy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Energy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Energy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Energy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Energy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static EnergyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static EnergyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out EnergyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out EnergyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Energy objEnergy)) throw new ArgumentException("Expected type Energy.", nameof(obj)); - - return CompareTo(objEnergy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Energy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Energy objEnergy)) - return false; - - return Equals(objEnergy); - } - - public bool Equals(Energy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Energy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Energy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Energy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((EnergyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(EnergyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Energy to another Energy with the unit representation . - /// - /// A Energy with the specified unit. - public Energy ToUnit(EnergyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Energy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(EnergyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.g.cs deleted file mode 100644 index 724b9a22d6..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Entropy.g.cs +++ /dev/null @@ -1,682 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Entropy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly EntropyUnit? _unit; - - static Entropy() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.Entropy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Entropy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Entropy(double value, EntropyUnit unit) - { - if(unit == EntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Entropy, which is JoulePerKelvin. All conversions go via this value. - /// - public static EntropyUnit BaseUnit { get; } = EntropyUnit.JoulePerKelvin; - - /// - /// Represents the largest possible value of Entropy - /// - public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Entropy - /// - public static Entropy MinValue { get; } = new Entropy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Entropy; - - /// - /// All units of measurement for the Entropy quantity. - /// - public static EntropyUnit[] Units { get; } = Enum.GetValues(typeof(EntropyUnit)).Cast().Except(new EntropyUnit[]{ EntropyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKelvin. - /// - public static Entropy Zero { get; } = new Entropy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public EntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Entropy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Entropy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Entropy in CaloriesPerKelvin. - /// - public double CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); - - /// - /// Get Entropy in JoulesPerDegreeCelsius. - /// - public double JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); - - /// - /// Get Entropy in JoulesPerKelvin. - /// - public double JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); - - /// - /// Get Entropy in KilocaloriesPerKelvin. - /// - public double KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); - - /// - /// Get Entropy in KilojoulesPerDegreeCelsius. - /// - public double KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); - - /// - /// Get Entropy in KilojoulesPerKelvin. - /// - public double KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); - - /// - /// Get Entropy in MegajoulesPerKelvin. - /// - public double MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(EntropyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(EntropyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Entropy from CaloriesPerKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromCaloriesPerKelvin(double caloriesperkelvin) - { - double value = (double) caloriesperkelvin; - return new Entropy(value, EntropyUnit.CaloriePerKelvin); - } - /// - /// Get Entropy from JoulesPerDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromJoulesPerDegreeCelsius(double joulesperdegreecelsius) - { - double value = (double) joulesperdegreecelsius; - return new Entropy(value, EntropyUnit.JoulePerDegreeCelsius); - } - /// - /// Get Entropy from JoulesPerKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromJoulesPerKelvin(double joulesperkelvin) - { - double value = (double) joulesperkelvin; - return new Entropy(value, EntropyUnit.JoulePerKelvin); - } - /// - /// Get Entropy from KilocaloriesPerKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromKilocaloriesPerKelvin(double kilocaloriesperkelvin) - { - double value = (double) kilocaloriesperkelvin; - return new Entropy(value, EntropyUnit.KilocaloriePerKelvin); - } - /// - /// Get Entropy from KilojoulesPerDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromKilojoulesPerDegreeCelsius(double kilojoulesperdegreecelsius) - { - double value = (double) kilojoulesperdegreecelsius; - return new Entropy(value, EntropyUnit.KilojoulePerDegreeCelsius); - } - /// - /// Get Entropy from KilojoulesPerKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromKilojoulesPerKelvin(double kilojoulesperkelvin) - { - double value = (double) kilojoulesperkelvin; - return new Entropy(value, EntropyUnit.KilojoulePerKelvin); - } - /// - /// Get Entropy from MegajoulesPerKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Entropy FromMegajoulesPerKelvin(double megajoulesperkelvin) - { - double value = (double) megajoulesperkelvin; - return new Entropy(value, EntropyUnit.MegajoulePerKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Entropy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Entropy From(double value, EntropyUnit fromUnit) - { - return new Entropy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Entropy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Entropy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Entropy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Entropy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static EntropyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static EntropyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out EntropyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out EntropyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Entropy objEntropy)) throw new ArgumentException("Expected type Entropy.", nameof(obj)); - - return CompareTo(objEntropy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Entropy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Entropy objEntropy)) - return false; - - return Equals(objEntropy); - } - - public bool Equals(Entropy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Entropy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Entropy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((EntropyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(EntropyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Entropy to another Entropy with the unit representation . - /// - /// A Entropy with the specified unit. - public Entropy ToUnit(EntropyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Entropy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(EntropyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.g.cs deleted file mode 100644 index dbc95e816f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Force.g.cs +++ /dev/null @@ -1,818 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Force : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ForceUnit? _unit; - - static Force() - { - BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Force, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Newton. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Force() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Force(double value, ForceUnit unit) - { - if(unit == ForceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Force, which is Newton. All conversions go via this value. - /// - public static ForceUnit BaseUnit { get; } = ForceUnit.Newton; - - /// - /// Represents the largest possible value of Force - /// - public static Force MaxValue { get; } = new Force(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Force - /// - public static Force MinValue { get; } = new Force(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Force; - - /// - /// All units of measurement for the Force quantity. - /// - public static ForceUnit[] Units { get; } = Enum.GetValues(typeof(ForceUnit)).Cast().Except(new ForceUnit[]{ ForceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Newton. - /// - public static Force Zero { get; } = new Force(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ForceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Force.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Force.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Force in Decanewtons. - /// - public double Decanewtons => As(ForceUnit.Decanewton); - - /// - /// Get Force in Dyne. - /// - public double Dyne => As(ForceUnit.Dyn); - - /// - /// Get Force in KilogramsForce. - /// - public double KilogramsForce => As(ForceUnit.KilogramForce); - - /// - /// Get Force in Kilonewtons. - /// - public double Kilonewtons => As(ForceUnit.Kilonewton); - - /// - /// Get Force in KiloPonds. - /// - public double KiloPonds => As(ForceUnit.KiloPond); - - /// - /// Get Force in KilopoundsForce. - /// - public double KilopoundsForce => As(ForceUnit.KilopoundForce); - - /// - /// Get Force in Meganewtons. - /// - public double Meganewtons => As(ForceUnit.Meganewton); - - /// - /// Get Force in Micronewtons. - /// - public double Micronewtons => As(ForceUnit.Micronewton); - - /// - /// Get Force in Millinewtons. - /// - public double Millinewtons => As(ForceUnit.Millinewton); - - /// - /// Get Force in Newtons. - /// - public double Newtons => As(ForceUnit.Newton); - - /// - /// Get Force in OunceForce. - /// - public double OunceForce => As(ForceUnit.OunceForce); - - /// - /// Get Force in Poundals. - /// - public double Poundals => As(ForceUnit.Poundal); - - /// - /// Get Force in PoundsForce. - /// - public double PoundsForce => As(ForceUnit.PoundForce); - - /// - /// Get Force in ShortTonsForce. - /// - public double ShortTonsForce => As(ForceUnit.ShortTonForce); - - /// - /// Get Force in TonnesForce. - /// - public double TonnesForce => As(ForceUnit.TonneForce); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ForceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ForceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Force from Decanewtons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromDecanewtons(double decanewtons) - { - double value = (double) decanewtons; - return new Force(value, ForceUnit.Decanewton); - } - /// - /// Get Force from Dyne. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromDyne(double dyne) - { - double value = (double) dyne; - return new Force(value, ForceUnit.Dyn); - } - /// - /// Get Force from KilogramsForce. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromKilogramsForce(double kilogramsforce) - { - double value = (double) kilogramsforce; - return new Force(value, ForceUnit.KilogramForce); - } - /// - /// Get Force from Kilonewtons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromKilonewtons(double kilonewtons) - { - double value = (double) kilonewtons; - return new Force(value, ForceUnit.Kilonewton); - } - /// - /// Get Force from KiloPonds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromKiloPonds(double kiloponds) - { - double value = (double) kiloponds; - return new Force(value, ForceUnit.KiloPond); - } - /// - /// Get Force from KilopoundsForce. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromKilopoundsForce(double kilopoundsforce) - { - double value = (double) kilopoundsforce; - return new Force(value, ForceUnit.KilopoundForce); - } - /// - /// Get Force from Meganewtons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromMeganewtons(double meganewtons) - { - double value = (double) meganewtons; - return new Force(value, ForceUnit.Meganewton); - } - /// - /// Get Force from Micronewtons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromMicronewtons(double micronewtons) - { - double value = (double) micronewtons; - return new Force(value, ForceUnit.Micronewton); - } - /// - /// Get Force from Millinewtons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromMillinewtons(double millinewtons) - { - double value = (double) millinewtons; - return new Force(value, ForceUnit.Millinewton); - } - /// - /// Get Force from Newtons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromNewtons(double newtons) - { - double value = (double) newtons; - return new Force(value, ForceUnit.Newton); - } - /// - /// Get Force from OunceForce. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromOunceForce(double ounceforce) - { - double value = (double) ounceforce; - return new Force(value, ForceUnit.OunceForce); - } - /// - /// Get Force from Poundals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromPoundals(double poundals) - { - double value = (double) poundals; - return new Force(value, ForceUnit.Poundal); - } - /// - /// Get Force from PoundsForce. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromPoundsForce(double poundsforce) - { - double value = (double) poundsforce; - return new Force(value, ForceUnit.PoundForce); - } - /// - /// Get Force from ShortTonsForce. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromShortTonsForce(double shorttonsforce) - { - double value = (double) shorttonsforce; - return new Force(value, ForceUnit.ShortTonForce); - } - /// - /// Get Force from TonnesForce. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Force FromTonnesForce(double tonnesforce) - { - double value = (double) tonnesforce; - return new Force(value, ForceUnit.TonneForce); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Force unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Force From(double value, ForceUnit fromUnit) - { - return new Force((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Force Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Force Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Force result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Force result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ForceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ForceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ForceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ForceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Force objForce)) throw new ArgumentException("Expected type Force.", nameof(obj)); - - return CompareTo(objForce); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Force other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Force objForce)) - return false; - - return Equals(objForce); - } - - public bool Equals(Force other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Force within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Force other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Force. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ForceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ForceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Force to another Force with the unit representation . - /// - /// A Force with the specified unit. - public Force ToUnit(ForceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Force(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ForceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.g.cs deleted file mode 100644 index f6e0d5bd50..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ /dev/null @@ -1,818 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ForceChangeRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ForceChangeRateUnit? _unit; - - static ForceChangeRate() - { - BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ForceChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ForceChangeRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ForceChangeRate(double value, ForceChangeRateUnit unit) - { - if(unit == ForceChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ForceChangeRate, which is NewtonPerSecond. All conversions go via this value. - /// - public static ForceChangeRateUnit BaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; - - /// - /// Represents the largest possible value of ForceChangeRate - /// - public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ForceChangeRate - /// - public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ForceChangeRate; - - /// - /// All units of measurement for the ForceChangeRate quantity. - /// - public static ForceChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().Except(new ForceChangeRateUnit[]{ ForceChangeRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerSecond. - /// - public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ForceChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ForceChangeRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ForceChangeRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ForceChangeRate in CentinewtonsPerSecond. - /// - public double CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); - - /// - /// Get ForceChangeRate in DecanewtonsPerMinute. - /// - public double DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); - - /// - /// Get ForceChangeRate in DecanewtonsPerSecond. - /// - public double DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); - - /// - /// Get ForceChangeRate in DecinewtonsPerSecond. - /// - public double DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); - - /// - /// Get ForceChangeRate in KilonewtonsPerMinute. - /// - public double KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); - - /// - /// Get ForceChangeRate in KilonewtonsPerSecond. - /// - public double KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); - - /// - /// Get ForceChangeRate in KilopoundsForcePerMinute. - /// - public double KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); - - /// - /// Get ForceChangeRate in KilopoundsForcePerSecond. - /// - public double KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); - - /// - /// Get ForceChangeRate in MicronewtonsPerSecond. - /// - public double MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); - - /// - /// Get ForceChangeRate in MillinewtonsPerSecond. - /// - public double MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); - - /// - /// Get ForceChangeRate in NanonewtonsPerSecond. - /// - public double NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); - - /// - /// Get ForceChangeRate in NewtonsPerMinute. - /// - public double NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); - - /// - /// Get ForceChangeRate in NewtonsPerSecond. - /// - public double NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); - - /// - /// Get ForceChangeRate in PoundsForcePerMinute. - /// - public double PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); - - /// - /// Get ForceChangeRate in PoundsForcePerSecond. - /// - public double PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ForceChangeRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ForceChangeRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ForceChangeRate from CentinewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromCentinewtonsPerSecond(double centinewtonspersecond) - { - double value = (double) centinewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.CentinewtonPerSecond); - } - /// - /// Get ForceChangeRate from DecanewtonsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromDecanewtonsPerMinute(double decanewtonsperminute) - { - double value = (double) decanewtonsperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerMinute); - } - /// - /// Get ForceChangeRate from DecanewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromDecanewtonsPerSecond(double decanewtonspersecond) - { - double value = (double) decanewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerSecond); - } - /// - /// Get ForceChangeRate from DecinewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromDecinewtonsPerSecond(double decinewtonspersecond) - { - double value = (double) decinewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.DecinewtonPerSecond); - } - /// - /// Get ForceChangeRate from KilonewtonsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromKilonewtonsPerMinute(double kilonewtonsperminute) - { - double value = (double) kilonewtonsperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerMinute); - } - /// - /// Get ForceChangeRate from KilonewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromKilonewtonsPerSecond(double kilonewtonspersecond) - { - double value = (double) kilonewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerSecond); - } - /// - /// Get ForceChangeRate from KilopoundsForcePerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromKilopoundsForcePerMinute(double kilopoundsforceperminute) - { - double value = (double) kilopoundsforceperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerMinute); - } - /// - /// Get ForceChangeRate from KilopoundsForcePerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromKilopoundsForcePerSecond(double kilopoundsforcepersecond) - { - double value = (double) kilopoundsforcepersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerSecond); - } - /// - /// Get ForceChangeRate from MicronewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromMicronewtonsPerSecond(double micronewtonspersecond) - { - double value = (double) micronewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.MicronewtonPerSecond); - } - /// - /// Get ForceChangeRate from MillinewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromMillinewtonsPerSecond(double millinewtonspersecond) - { - double value = (double) millinewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.MillinewtonPerSecond); - } - /// - /// Get ForceChangeRate from NanonewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromNanonewtonsPerSecond(double nanonewtonspersecond) - { - double value = (double) nanonewtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.NanonewtonPerSecond); - } - /// - /// Get ForceChangeRate from NewtonsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromNewtonsPerMinute(double newtonsperminute) - { - double value = (double) newtonsperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerMinute); - } - /// - /// Get ForceChangeRate from NewtonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromNewtonsPerSecond(double newtonspersecond) - { - double value = (double) newtonspersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerSecond); - } - /// - /// Get ForceChangeRate from PoundsForcePerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromPoundsForcePerMinute(double poundsforceperminute) - { - double value = (double) poundsforceperminute; - return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerMinute); - } - /// - /// Get ForceChangeRate from PoundsForcePerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForceChangeRate FromPoundsForcePerSecond(double poundsforcepersecond) - { - double value = (double) poundsforcepersecond; - return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ForceChangeRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit) - { - return new ForceChangeRate((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ForceChangeRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ForceChangeRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ForceChangeRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ForceChangeRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ForceChangeRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ForceChangeRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ForceChangeRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ForceChangeRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ForceChangeRate objForceChangeRate)) throw new ArgumentException("Expected type ForceChangeRate.", nameof(obj)); - - return CompareTo(objForceChangeRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ForceChangeRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ForceChangeRate objForceChangeRate)) - return false; - - return Equals(objForceChangeRate); - } - - public bool Equals(ForceChangeRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ForceChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ForceChangeRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ForceChangeRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ForceChangeRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ForceChangeRate to another ForceChangeRate with the unit representation . - /// - /// A ForceChangeRate with the specified unit. - public ForceChangeRate ToUnit(ForceChangeRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ForceChangeRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ForceChangeRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.g.cs deleted file mode 100644 index 9ba947a00e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ForcePerLength.g.cs +++ /dev/null @@ -1,1209 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The magnitude of force per unit length. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ForcePerLength : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ForcePerLengthUnit? _unit; - - static ForcePerLength() - { - BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ForcePerLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ForcePerLength() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ForcePerLength(double value, ForcePerLengthUnit unit) - { - if(unit == ForcePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ForcePerLength, which is NewtonPerMeter. All conversions go via this value. - /// - public static ForcePerLengthUnit BaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; - - /// - /// Represents the largest possible value of ForcePerLength - /// - public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ForcePerLength - /// - public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ForcePerLength; - - /// - /// All units of measurement for the ForcePerLength quantity. - /// - public static ForcePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().Except(new ForcePerLengthUnit[]{ ForcePerLengthUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerMeter. - /// - public static ForcePerLength Zero { get; } = new ForcePerLength(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ForcePerLength.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ForcePerLength.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ForcePerLength in CentinewtonsPerCentimeter. - /// - public double CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); - - /// - /// Get ForcePerLength in CentinewtonsPerMeter. - /// - public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); - - /// - /// Get ForcePerLength in CentinewtonsPerMillimeter. - /// - public double CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); - - /// - /// Get ForcePerLength in DecanewtonsPerCentimeter. - /// - public double DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); - - /// - /// Get ForcePerLength in DecanewtonsPerMeter. - /// - public double DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); - - /// - /// Get ForcePerLength in DecanewtonsPerMillimeter. - /// - public double DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); - - /// - /// Get ForcePerLength in DecinewtonsPerCentimeter. - /// - public double DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); - - /// - /// Get ForcePerLength in DecinewtonsPerMeter. - /// - public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); - - /// - /// Get ForcePerLength in DecinewtonsPerMillimeter. - /// - public double DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); - - /// - /// Get ForcePerLength in KilogramsForcePerCentimeter. - /// - public double KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); - - /// - /// Get ForcePerLength in KilogramsForcePerMeter. - /// - public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); - - /// - /// Get ForcePerLength in KilogramsForcePerMillimeter. - /// - public double KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); - - /// - /// Get ForcePerLength in KilonewtonsPerCentimeter. - /// - public double KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); - - /// - /// Get ForcePerLength in KilonewtonsPerMeter. - /// - public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); - - /// - /// Get ForcePerLength in KilonewtonsPerMillimeter. - /// - public double KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); - - /// - /// Get ForcePerLength in KilopoundsForcePerFoot. - /// - public double KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); - - /// - /// Get ForcePerLength in KilopoundsForcePerInch. - /// - public double KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); - - /// - /// Get ForcePerLength in MeganewtonsPerCentimeter. - /// - public double MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); - - /// - /// Get ForcePerLength in MeganewtonsPerMeter. - /// - public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); - - /// - /// Get ForcePerLength in MeganewtonsPerMillimeter. - /// - public double MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); - - /// - /// Get ForcePerLength in MicronewtonsPerCentimeter. - /// - public double MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); - - /// - /// Get ForcePerLength in MicronewtonsPerMeter. - /// - public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); - - /// - /// Get ForcePerLength in MicronewtonsPerMillimeter. - /// - public double MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); - - /// - /// Get ForcePerLength in MillinewtonsPerCentimeter. - /// - public double MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); - - /// - /// Get ForcePerLength in MillinewtonsPerMeter. - /// - public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); - - /// - /// Get ForcePerLength in MillinewtonsPerMillimeter. - /// - public double MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); - - /// - /// Get ForcePerLength in NanonewtonsPerCentimeter. - /// - public double NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); - - /// - /// Get ForcePerLength in NanonewtonsPerMeter. - /// - public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); - - /// - /// Get ForcePerLength in NanonewtonsPerMillimeter. - /// - public double NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); - - /// - /// Get ForcePerLength in NewtonsPerCentimeter. - /// - public double NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); - - /// - /// Get ForcePerLength in NewtonsPerMeter. - /// - public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); - - /// - /// Get ForcePerLength in NewtonsPerMillimeter. - /// - public double NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); - - /// - /// Get ForcePerLength in PoundsForcePerFoot. - /// - public double PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); - - /// - /// Get ForcePerLength in PoundsForcePerInch. - /// - public double PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); - - /// - /// Get ForcePerLength in PoundsForcePerYard. - /// - public double PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); - - /// - /// Get ForcePerLength in TonnesForcePerCentimeter. - /// - public double TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); - - /// - /// Get ForcePerLength in TonnesForcePerMeter. - /// - public double TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); - - /// - /// Get ForcePerLength in TonnesForcePerMillimeter. - /// - public double TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ForcePerLengthUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ForcePerLengthUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ForcePerLength from CentinewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromCentinewtonsPerCentimeter(double centinewtonspercentimeter) - { - double value = (double) centinewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerCentimeter); - } - /// - /// Get ForcePerLength from CentinewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromCentinewtonsPerMeter(double centinewtonspermeter) - { - double value = (double) centinewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter); - } - /// - /// Get ForcePerLength from CentinewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromCentinewtonsPerMillimeter(double centinewtonspermillimeter) - { - double value = (double) centinewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMillimeter); - } - /// - /// Get ForcePerLength from DecanewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromDecanewtonsPerCentimeter(double decanewtonspercentimeter) - { - double value = (double) decanewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerCentimeter); - } - /// - /// Get ForcePerLength from DecanewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromDecanewtonsPerMeter(double decanewtonspermeter) - { - double value = (double) decanewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMeter); - } - /// - /// Get ForcePerLength from DecanewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromDecanewtonsPerMillimeter(double decanewtonspermillimeter) - { - double value = (double) decanewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMillimeter); - } - /// - /// Get ForcePerLength from DecinewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromDecinewtonsPerCentimeter(double decinewtonspercentimeter) - { - double value = (double) decinewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerCentimeter); - } - /// - /// Get ForcePerLength from DecinewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromDecinewtonsPerMeter(double decinewtonspermeter) - { - double value = (double) decinewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter); - } - /// - /// Get ForcePerLength from DecinewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromDecinewtonsPerMillimeter(double decinewtonspermillimeter) - { - double value = (double) decinewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMillimeter); - } - /// - /// Get ForcePerLength from KilogramsForcePerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilogramsForcePerCentimeter(double kilogramsforcepercentimeter) - { - double value = (double) kilogramsforcepercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerCentimeter); - } - /// - /// Get ForcePerLength from KilogramsForcePerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilogramsForcePerMeter(double kilogramsforcepermeter) - { - double value = (double) kilogramsforcepermeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter); - } - /// - /// Get ForcePerLength from KilogramsForcePerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilogramsForcePerMillimeter(double kilogramsforcepermillimeter) - { - double value = (double) kilogramsforcepermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMillimeter); - } - /// - /// Get ForcePerLength from KilonewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilonewtonsPerCentimeter(double kilonewtonspercentimeter) - { - double value = (double) kilonewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerCentimeter); - } - /// - /// Get ForcePerLength from KilonewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilonewtonsPerMeter(double kilonewtonspermeter) - { - double value = (double) kilonewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter); - } - /// - /// Get ForcePerLength from KilonewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilonewtonsPerMillimeter(double kilonewtonspermillimeter) - { - double value = (double) kilonewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMillimeter); - } - /// - /// Get ForcePerLength from KilopoundsForcePerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilopoundsForcePerFoot(double kilopoundsforceperfoot) - { - double value = (double) kilopoundsforceperfoot; - return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerFoot); - } - /// - /// Get ForcePerLength from KilopoundsForcePerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromKilopoundsForcePerInch(double kilopoundsforceperinch) - { - double value = (double) kilopoundsforceperinch; - return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerInch); - } - /// - /// Get ForcePerLength from MeganewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMeganewtonsPerCentimeter(double meganewtonspercentimeter) - { - double value = (double) meganewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerCentimeter); - } - /// - /// Get ForcePerLength from MeganewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMeganewtonsPerMeter(double meganewtonspermeter) - { - double value = (double) meganewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter); - } - /// - /// Get ForcePerLength from MeganewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMeganewtonsPerMillimeter(double meganewtonspermillimeter) - { - double value = (double) meganewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMillimeter); - } - /// - /// Get ForcePerLength from MicronewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMicronewtonsPerCentimeter(double micronewtonspercentimeter) - { - double value = (double) micronewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerCentimeter); - } - /// - /// Get ForcePerLength from MicronewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMicronewtonsPerMeter(double micronewtonspermeter) - { - double value = (double) micronewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter); - } - /// - /// Get ForcePerLength from MicronewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMicronewtonsPerMillimeter(double micronewtonspermillimeter) - { - double value = (double) micronewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMillimeter); - } - /// - /// Get ForcePerLength from MillinewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMillinewtonsPerCentimeter(double millinewtonspercentimeter) - { - double value = (double) millinewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerCentimeter); - } - /// - /// Get ForcePerLength from MillinewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMillinewtonsPerMeter(double millinewtonspermeter) - { - double value = (double) millinewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter); - } - /// - /// Get ForcePerLength from MillinewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromMillinewtonsPerMillimeter(double millinewtonspermillimeter) - { - double value = (double) millinewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMillimeter); - } - /// - /// Get ForcePerLength from NanonewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromNanonewtonsPerCentimeter(double nanonewtonspercentimeter) - { - double value = (double) nanonewtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerCentimeter); - } - /// - /// Get ForcePerLength from NanonewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromNanonewtonsPerMeter(double nanonewtonspermeter) - { - double value = (double) nanonewtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter); - } - /// - /// Get ForcePerLength from NanonewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromNanonewtonsPerMillimeter(double nanonewtonspermillimeter) - { - double value = (double) nanonewtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMillimeter); - } - /// - /// Get ForcePerLength from NewtonsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromNewtonsPerCentimeter(double newtonspercentimeter) - { - double value = (double) newtonspercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerCentimeter); - } - /// - /// Get ForcePerLength from NewtonsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromNewtonsPerMeter(double newtonspermeter) - { - double value = (double) newtonspermeter; - return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter); - } - /// - /// Get ForcePerLength from NewtonsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromNewtonsPerMillimeter(double newtonspermillimeter) - { - double value = (double) newtonspermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMillimeter); - } - /// - /// Get ForcePerLength from PoundsForcePerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromPoundsForcePerFoot(double poundsforceperfoot) - { - double value = (double) poundsforceperfoot; - return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerFoot); - } - /// - /// Get ForcePerLength from PoundsForcePerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromPoundsForcePerInch(double poundsforceperinch) - { - double value = (double) poundsforceperinch; - return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerInch); - } - /// - /// Get ForcePerLength from PoundsForcePerYard. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromPoundsForcePerYard(double poundsforceperyard) - { - double value = (double) poundsforceperyard; - return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerYard); - } - /// - /// Get ForcePerLength from TonnesForcePerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromTonnesForcePerCentimeter(double tonnesforcepercentimeter) - { - double value = (double) tonnesforcepercentimeter; - return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerCentimeter); - } - /// - /// Get ForcePerLength from TonnesForcePerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromTonnesForcePerMeter(double tonnesforcepermeter) - { - double value = (double) tonnesforcepermeter; - return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMeter); - } - /// - /// Get ForcePerLength from TonnesForcePerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ForcePerLength FromTonnesForcePerMillimeter(double tonnesforcepermillimeter) - { - double value = (double) tonnesforcepermillimeter; - return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ForcePerLength unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ForcePerLength From(double value, ForcePerLengthUnit fromUnit) - { - return new ForcePerLength((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ForcePerLength Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ForcePerLength Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ForcePerLength result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ForcePerLength result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ForcePerLengthUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ForcePerLengthUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ForcePerLengthUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ForcePerLengthUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ForcePerLength objForcePerLength)) throw new ArgumentException("Expected type ForcePerLength.", nameof(obj)); - - return CompareTo(objForcePerLength); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ForcePerLength other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ForcePerLength objForcePerLength)) - return false; - - return Equals(objForcePerLength); - } - - public bool Equals(ForcePerLength other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ForcePerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ForcePerLength. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ForcePerLengthUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ForcePerLengthUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ForcePerLength to another ForcePerLength with the unit representation . - /// - /// A ForcePerLength with the specified unit. - public ForcePerLength ToUnit(ForcePerLengthUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ForcePerLength(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ForcePerLengthUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.g.cs deleted file mode 100644 index a0f99c7cb5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Frequency.g.cs +++ /dev/null @@ -1,750 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The number of occurrences of a repeating event per unit time. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Frequency : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly FrequencyUnit? _unit; - - static Frequency() - { - BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Frequency, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Hertz. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Frequency() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Frequency(double value, FrequencyUnit unit) - { - if(unit == FrequencyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Frequency, which is Hertz. All conversions go via this value. - /// - public static FrequencyUnit BaseUnit { get; } = FrequencyUnit.Hertz; - - /// - /// Represents the largest possible value of Frequency - /// - public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Frequency - /// - public static Frequency MinValue { get; } = new Frequency(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Frequency; - - /// - /// All units of measurement for the Frequency quantity. - /// - public static FrequencyUnit[] Units { get; } = Enum.GetValues(typeof(FrequencyUnit)).Cast().Except(new FrequencyUnit[]{ FrequencyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Hertz. - /// - public static Frequency Zero { get; } = new Frequency(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public FrequencyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Frequency.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Frequency.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Frequency in BeatsPerMinute. - /// - public double BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); - - /// - /// Get Frequency in BUnits. - /// - public double BUnits => As(FrequencyUnit.BUnit); - - /// - /// Get Frequency in CyclesPerHour. - /// - public double CyclesPerHour => As(FrequencyUnit.CyclePerHour); - - /// - /// Get Frequency in CyclesPerMinute. - /// - public double CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); - - /// - /// Get Frequency in Gigahertz. - /// - public double Gigahertz => As(FrequencyUnit.Gigahertz); - - /// - /// Get Frequency in Hertz. - /// - public double Hertz => As(FrequencyUnit.Hertz); - - /// - /// Get Frequency in Kilohertz. - /// - public double Kilohertz => As(FrequencyUnit.Kilohertz); - - /// - /// Get Frequency in Megahertz. - /// - public double Megahertz => As(FrequencyUnit.Megahertz); - - /// - /// Get Frequency in PerSecond. - /// - public double PerSecond => As(FrequencyUnit.PerSecond); - - /// - /// Get Frequency in RadiansPerSecond. - /// - public double RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); - - /// - /// Get Frequency in Terahertz. - /// - public double Terahertz => As(FrequencyUnit.Terahertz); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(FrequencyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(FrequencyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Frequency from BeatsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromBeatsPerMinute(double beatsperminute) - { - double value = (double) beatsperminute; - return new Frequency(value, FrequencyUnit.BeatPerMinute); - } - /// - /// Get Frequency from BUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromBUnits(double bunits) - { - double value = (double) bunits; - return new Frequency(value, FrequencyUnit.BUnit); - } - /// - /// Get Frequency from CyclesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromCyclesPerHour(double cyclesperhour) - { - double value = (double) cyclesperhour; - return new Frequency(value, FrequencyUnit.CyclePerHour); - } - /// - /// Get Frequency from CyclesPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromCyclesPerMinute(double cyclesperminute) - { - double value = (double) cyclesperminute; - return new Frequency(value, FrequencyUnit.CyclePerMinute); - } - /// - /// Get Frequency from Gigahertz. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromGigahertz(double gigahertz) - { - double value = (double) gigahertz; - return new Frequency(value, FrequencyUnit.Gigahertz); - } - /// - /// Get Frequency from Hertz. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromHertz(double hertz) - { - double value = (double) hertz; - return new Frequency(value, FrequencyUnit.Hertz); - } - /// - /// Get Frequency from Kilohertz. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromKilohertz(double kilohertz) - { - double value = (double) kilohertz; - return new Frequency(value, FrequencyUnit.Kilohertz); - } - /// - /// Get Frequency from Megahertz. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromMegahertz(double megahertz) - { - double value = (double) megahertz; - return new Frequency(value, FrequencyUnit.Megahertz); - } - /// - /// Get Frequency from PerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromPerSecond(double persecond) - { - double value = (double) persecond; - return new Frequency(value, FrequencyUnit.PerSecond); - } - /// - /// Get Frequency from RadiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromRadiansPerSecond(double radianspersecond) - { - double value = (double) radianspersecond; - return new Frequency(value, FrequencyUnit.RadianPerSecond); - } - /// - /// Get Frequency from Terahertz. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Frequency FromTerahertz(double terahertz) - { - double value = (double) terahertz; - return new Frequency(value, FrequencyUnit.Terahertz); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Frequency unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Frequency From(double value, FrequencyUnit fromUnit) - { - return new Frequency((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Frequency Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Frequency Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Frequency result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Frequency result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static FrequencyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static FrequencyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out FrequencyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out FrequencyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Frequency objFrequency)) throw new ArgumentException("Expected type Frequency.", nameof(obj)); - - return CompareTo(objFrequency); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Frequency other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Frequency objFrequency)) - return false; - - return Equals(objFrequency); - } - - public bool Equals(Frequency other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Frequency within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Frequency. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((FrequencyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(FrequencyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Frequency to another Frequency with the unit representation . - /// - /// A Frequency with the specified unit. - public Frequency ToUnit(FrequencyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Frequency(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(FrequencyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/FuelEfficiency.g.cs deleted file mode 100644 index 1a17cc3fc7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ /dev/null @@ -1,634 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as "fuel consumption" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon). - /// - /// - /// https://en.wikipedia.org/wiki/Fuel_efficiency - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class FuelEfficiency : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly FuelEfficiencyUnit? _unit; - - static FuelEfficiency() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.FuelEfficiency, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit LiterPer100Kilometers. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public FuelEfficiency() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private FuelEfficiency(double value, FuelEfficiencyUnit unit) - { - if(unit == FuelEfficiencyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of FuelEfficiency, which is LiterPer100Kilometers. All conversions go via this value. - /// - public static FuelEfficiencyUnit BaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; - - /// - /// Represents the largest possible value of FuelEfficiency - /// - public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of FuelEfficiency - /// - public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.FuelEfficiency; - - /// - /// All units of measurement for the FuelEfficiency quantity. - /// - public static FuelEfficiencyUnit[] Units { get; } = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast().Except(new FuelEfficiencyUnit[]{ FuelEfficiencyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit LiterPer100Kilometers. - /// - public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public FuelEfficiencyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => FuelEfficiency.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => FuelEfficiency.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get FuelEfficiency in KilometersPerLiters. - /// - public double KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); - - /// - /// Get FuelEfficiency in LitersPer100Kilometers. - /// - public double LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); - - /// - /// Get FuelEfficiency in MilesPerUkGallon. - /// - public double MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); - - /// - /// Get FuelEfficiency in MilesPerUsGallon. - /// - public double MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(FuelEfficiencyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(FuelEfficiencyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get FuelEfficiency from KilometersPerLiters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static FuelEfficiency FromKilometersPerLiters(double kilometersperliters) - { - double value = (double) kilometersperliters; - return new FuelEfficiency(value, FuelEfficiencyUnit.KilometerPerLiter); - } - /// - /// Get FuelEfficiency from LitersPer100Kilometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static FuelEfficiency FromLitersPer100Kilometers(double litersper100kilometers) - { - double value = (double) litersper100kilometers; - return new FuelEfficiency(value, FuelEfficiencyUnit.LiterPer100Kilometers); - } - /// - /// Get FuelEfficiency from MilesPerUkGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static FuelEfficiency FromMilesPerUkGallon(double milesperukgallon) - { - double value = (double) milesperukgallon; - return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUkGallon); - } - /// - /// Get FuelEfficiency from MilesPerUsGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static FuelEfficiency FromMilesPerUsGallon(double milesperusgallon) - { - double value = (double) milesperusgallon; - return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUsGallon); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// FuelEfficiency unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static FuelEfficiency From(double value, FuelEfficiencyUnit fromUnit) - { - return new FuelEfficiency((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static FuelEfficiency Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static FuelEfficiency Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out FuelEfficiency result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out FuelEfficiency result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static FuelEfficiencyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static FuelEfficiencyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out FuelEfficiencyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out FuelEfficiencyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is FuelEfficiency objFuelEfficiency)) throw new ArgumentException("Expected type FuelEfficiency.", nameof(obj)); - - return CompareTo(objFuelEfficiency); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(FuelEfficiency other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is FuelEfficiency objFuelEfficiency)) - return false; - - return Equals(objFuelEfficiency); - } - - public bool Equals(FuelEfficiency other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another FuelEfficiency within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(FuelEfficiency other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current FuelEfficiency. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((FuelEfficiencyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(FuelEfficiencyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this FuelEfficiency to another FuelEfficiency with the unit representation . - /// - /// A FuelEfficiency with the specified unit. - public FuelEfficiency ToUnit(FuelEfficiencyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new FuelEfficiency(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(FuelEfficiencyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.g.cs deleted file mode 100644 index b0899f7903..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatFlux.g.cs +++ /dev/null @@ -1,869 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Heat flux is the flow of energy per unit of area per unit of time - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class HeatFlux : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly HeatFluxUnit? _unit; - - static HeatFlux() - { - BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.HeatFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit WattPerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public HeatFlux() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private HeatFlux(double value, HeatFluxUnit unit) - { - if(unit == HeatFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of HeatFlux, which is WattPerSquareMeter. All conversions go via this value. - /// - public static HeatFluxUnit BaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; - - /// - /// Represents the largest possible value of HeatFlux - /// - public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of HeatFlux - /// - public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.HeatFlux; - - /// - /// All units of measurement for the HeatFlux quantity. - /// - public static HeatFluxUnit[] Units { get; } = Enum.GetValues(typeof(HeatFluxUnit)).Cast().Except(new HeatFluxUnit[]{ HeatFluxUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. - /// - public static HeatFlux Zero { get; } = new HeatFlux(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public HeatFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => HeatFlux.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => HeatFlux.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get HeatFlux in BtusPerHourSquareFoot. - /// - public double BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); - - /// - /// Get HeatFlux in BtusPerMinuteSquareFoot. - /// - public double BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); - - /// - /// Get HeatFlux in BtusPerSecondSquareFoot. - /// - public double BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); - - /// - /// Get HeatFlux in BtusPerSecondSquareInch. - /// - public double BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); - - /// - /// Get HeatFlux in CaloriesPerSecondSquareCentimeter. - /// - public double CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); - - /// - /// Get HeatFlux in CentiwattsPerSquareMeter. - /// - public double CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); - - /// - /// Get HeatFlux in DeciwattsPerSquareMeter. - /// - public double DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); - - /// - /// Get HeatFlux in KilocaloriesPerHourSquareMeter. - /// - public double KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); - - /// - /// Get HeatFlux in KilocaloriesPerSecondSquareCentimeter. - /// - public double KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); - - /// - /// Get HeatFlux in KilowattsPerSquareMeter. - /// - public double KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); - - /// - /// Get HeatFlux in MicrowattsPerSquareMeter. - /// - public double MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); - - /// - /// Get HeatFlux in MilliwattsPerSquareMeter. - /// - public double MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); - - /// - /// Get HeatFlux in NanowattsPerSquareMeter. - /// - public double NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); - - /// - /// Get HeatFlux in PoundsForcePerFootSecond. - /// - public double PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); - - /// - /// Get HeatFlux in PoundsPerSecondCubed. - /// - public double PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); - - /// - /// Get HeatFlux in WattsPerSquareFoot. - /// - public double WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); - - /// - /// Get HeatFlux in WattsPerSquareInch. - /// - public double WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); - - /// - /// Get HeatFlux in WattsPerSquareMeter. - /// - public double WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(HeatFluxUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(HeatFluxUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get HeatFlux from BtusPerHourSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromBtusPerHourSquareFoot(double btusperhoursquarefoot) - { - double value = (double) btusperhoursquarefoot; - return new HeatFlux(value, HeatFluxUnit.BtuPerHourSquareFoot); - } - /// - /// Get HeatFlux from BtusPerMinuteSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromBtusPerMinuteSquareFoot(double btusperminutesquarefoot) - { - double value = (double) btusperminutesquarefoot; - return new HeatFlux(value, HeatFluxUnit.BtuPerMinuteSquareFoot); - } - /// - /// Get HeatFlux from BtusPerSecondSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromBtusPerSecondSquareFoot(double btuspersecondsquarefoot) - { - double value = (double) btuspersecondsquarefoot; - return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareFoot); - } - /// - /// Get HeatFlux from BtusPerSecondSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromBtusPerSecondSquareInch(double btuspersecondsquareinch) - { - double value = (double) btuspersecondsquareinch; - return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareInch); - } - /// - /// Get HeatFlux from CaloriesPerSecondSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromCaloriesPerSecondSquareCentimeter(double caloriespersecondsquarecentimeter) - { - double value = (double) caloriespersecondsquarecentimeter; - return new HeatFlux(value, HeatFluxUnit.CaloriePerSecondSquareCentimeter); - } - /// - /// Get HeatFlux from CentiwattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromCentiwattsPerSquareMeter(double centiwattspersquaremeter) - { - double value = (double) centiwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.CentiwattPerSquareMeter); - } - /// - /// Get HeatFlux from DeciwattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromDeciwattsPerSquareMeter(double deciwattspersquaremeter) - { - double value = (double) deciwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.DeciwattPerSquareMeter); - } - /// - /// Get HeatFlux from KilocaloriesPerHourSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromKilocaloriesPerHourSquareMeter(double kilocaloriesperhoursquaremeter) - { - double value = (double) kilocaloriesperhoursquaremeter; - return new HeatFlux(value, HeatFluxUnit.KilocaloriePerHourSquareMeter); - } - /// - /// Get HeatFlux from KilocaloriesPerSecondSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(double kilocaloriespersecondsquarecentimeter) - { - double value = (double) kilocaloriespersecondsquarecentimeter; - return new HeatFlux(value, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); - } - /// - /// Get HeatFlux from KilowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromKilowattsPerSquareMeter(double kilowattspersquaremeter) - { - double value = (double) kilowattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.KilowattPerSquareMeter); - } - /// - /// Get HeatFlux from MicrowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromMicrowattsPerSquareMeter(double microwattspersquaremeter) - { - double value = (double) microwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.MicrowattPerSquareMeter); - } - /// - /// Get HeatFlux from MilliwattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromMilliwattsPerSquareMeter(double milliwattspersquaremeter) - { - double value = (double) milliwattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.MilliwattPerSquareMeter); - } - /// - /// Get HeatFlux from NanowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromNanowattsPerSquareMeter(double nanowattspersquaremeter) - { - double value = (double) nanowattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.NanowattPerSquareMeter); - } - /// - /// Get HeatFlux from PoundsForcePerFootSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromPoundsForcePerFootSecond(double poundsforceperfootsecond) - { - double value = (double) poundsforceperfootsecond; - return new HeatFlux(value, HeatFluxUnit.PoundForcePerFootSecond); - } - /// - /// Get HeatFlux from PoundsPerSecondCubed. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromPoundsPerSecondCubed(double poundspersecondcubed) - { - double value = (double) poundspersecondcubed; - return new HeatFlux(value, HeatFluxUnit.PoundPerSecondCubed); - } - /// - /// Get HeatFlux from WattsPerSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromWattsPerSquareFoot(double wattspersquarefoot) - { - double value = (double) wattspersquarefoot; - return new HeatFlux(value, HeatFluxUnit.WattPerSquareFoot); - } - /// - /// Get HeatFlux from WattsPerSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromWattsPerSquareInch(double wattspersquareinch) - { - double value = (double) wattspersquareinch; - return new HeatFlux(value, HeatFluxUnit.WattPerSquareInch); - } - /// - /// Get HeatFlux from WattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatFlux FromWattsPerSquareMeter(double wattspersquaremeter) - { - double value = (double) wattspersquaremeter; - return new HeatFlux(value, HeatFluxUnit.WattPerSquareMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// HeatFlux unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static HeatFlux From(double value, HeatFluxUnit fromUnit) - { - return new HeatFlux((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static HeatFlux Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static HeatFlux Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out HeatFlux result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out HeatFlux result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static HeatFluxUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static HeatFluxUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out HeatFluxUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out HeatFluxUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is HeatFlux objHeatFlux)) throw new ArgumentException("Expected type HeatFlux.", nameof(obj)); - - return CompareTo(objHeatFlux); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(HeatFlux other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is HeatFlux objHeatFlux)) - return false; - - return Equals(objHeatFlux); - } - - public bool Equals(HeatFlux other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another HeatFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current HeatFlux. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((HeatFluxUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(HeatFluxUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this HeatFlux to another HeatFlux with the unit representation . - /// - /// A HeatFlux with the specified unit. - public HeatFlux ToUnit(HeatFluxUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new HeatFlux(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(HeatFluxUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs deleted file mode 100644 index eb4cdc4691..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class HeatTransferCoefficient : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly HeatTransferCoefficientUnit? _unit; - - static HeatTransferCoefficient() - { - BaseDimensions = new BaseDimensions(0, 1, -3, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.HeatTransferCoefficient, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit WattPerSquareMeterKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public HeatTransferCoefficient() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) - { - if(unit == HeatTransferCoefficientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of HeatTransferCoefficient, which is WattPerSquareMeterKelvin. All conversions go via this value. - /// - public static HeatTransferCoefficientUnit BaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; - - /// - /// Represents the largest possible value of HeatTransferCoefficient - /// - public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of HeatTransferCoefficient - /// - public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.HeatTransferCoefficient; - - /// - /// All units of measurement for the HeatTransferCoefficient quantity. - /// - public static HeatTransferCoefficientUnit[] Units { get; } = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().Except(new HeatTransferCoefficientUnit[]{ HeatTransferCoefficientUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeterKelvin. - /// - public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public HeatTransferCoefficientUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => HeatTransferCoefficient.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => HeatTransferCoefficient.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get HeatTransferCoefficient in BtusPerSquareFootDegreeFahrenheit. - /// - public double BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); - - /// - /// Get HeatTransferCoefficient in WattsPerSquareMeterCelsius. - /// - public double WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); - - /// - /// Get HeatTransferCoefficient in WattsPerSquareMeterKelvin. - /// - public double WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(HeatTransferCoefficientUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(HeatTransferCoefficientUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get HeatTransferCoefficient from BtusPerSquareFootDegreeFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(double btuspersquarefootdegreefahrenheit) - { - double value = (double) btuspersquarefootdegreefahrenheit; - return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); - } - /// - /// Get HeatTransferCoefficient from WattsPerSquareMeterCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(double wattspersquaremetercelsius) - { - double value = (double) wattspersquaremetercelsius; - return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); - } - /// - /// Get HeatTransferCoefficient from WattsPerSquareMeterKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(double wattspersquaremeterkelvin) - { - double value = (double) wattspersquaremeterkelvin; - return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// HeatTransferCoefficient unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static HeatTransferCoefficient From(double value, HeatTransferCoefficientUnit fromUnit) - { - return new HeatTransferCoefficient((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static HeatTransferCoefficient Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static HeatTransferCoefficient Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out HeatTransferCoefficient result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out HeatTransferCoefficient result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static HeatTransferCoefficientUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static HeatTransferCoefficientUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out HeatTransferCoefficientUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out HeatTransferCoefficientUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is HeatTransferCoefficient objHeatTransferCoefficient)) throw new ArgumentException("Expected type HeatTransferCoefficient.", nameof(obj)); - - return CompareTo(objHeatTransferCoefficient); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(HeatTransferCoefficient other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) - return false; - - return Equals(objHeatTransferCoefficient); - } - - public bool Equals(HeatTransferCoefficient other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another HeatTransferCoefficient within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current HeatTransferCoefficient. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((HeatTransferCoefficientUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(HeatTransferCoefficientUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this HeatTransferCoefficient to another HeatTransferCoefficient with the unit representation . - /// - /// A HeatTransferCoefficient with the specified unit. - public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new HeatTransferCoefficient(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(HeatTransferCoefficientUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.g.cs deleted file mode 100644 index 543b303667..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Illuminance.g.cs +++ /dev/null @@ -1,634 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In photometry, illuminance is the total luminous flux incident on a surface, per unit area. - /// - /// - /// https://en.wikipedia.org/wiki/Illuminance - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Illuminance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly IlluminanceUnit? _unit; - - static Illuminance() - { - BaseDimensions = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); - Info = new QuantityInfo(QuantityType.Illuminance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Lux. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Illuminance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Illuminance(double value, IlluminanceUnit unit) - { - if(unit == IlluminanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Illuminance, which is Lux. All conversions go via this value. - /// - public static IlluminanceUnit BaseUnit { get; } = IlluminanceUnit.Lux; - - /// - /// Represents the largest possible value of Illuminance - /// - public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Illuminance - /// - public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Illuminance; - - /// - /// All units of measurement for the Illuminance quantity. - /// - public static IlluminanceUnit[] Units { get; } = Enum.GetValues(typeof(IlluminanceUnit)).Cast().Except(new IlluminanceUnit[]{ IlluminanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Lux. - /// - public static Illuminance Zero { get; } = new Illuminance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public IlluminanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Illuminance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Illuminance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Illuminance in Kilolux. - /// - public double Kilolux => As(IlluminanceUnit.Kilolux); - - /// - /// Get Illuminance in Lux. - /// - public double Lux => As(IlluminanceUnit.Lux); - - /// - /// Get Illuminance in Megalux. - /// - public double Megalux => As(IlluminanceUnit.Megalux); - - /// - /// Get Illuminance in Millilux. - /// - public double Millilux => As(IlluminanceUnit.Millilux); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(IlluminanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(IlluminanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Illuminance from Kilolux. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Illuminance FromKilolux(double kilolux) - { - double value = (double) kilolux; - return new Illuminance(value, IlluminanceUnit.Kilolux); - } - /// - /// Get Illuminance from Lux. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Illuminance FromLux(double lux) - { - double value = (double) lux; - return new Illuminance(value, IlluminanceUnit.Lux); - } - /// - /// Get Illuminance from Megalux. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Illuminance FromMegalux(double megalux) - { - double value = (double) megalux; - return new Illuminance(value, IlluminanceUnit.Megalux); - } - /// - /// Get Illuminance from Millilux. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Illuminance FromMillilux(double millilux) - { - double value = (double) millilux; - return new Illuminance(value, IlluminanceUnit.Millilux); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Illuminance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Illuminance From(double value, IlluminanceUnit fromUnit) - { - return new Illuminance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Illuminance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Illuminance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Illuminance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Illuminance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static IlluminanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static IlluminanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out IlluminanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out IlluminanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Illuminance objIlluminance)) throw new ArgumentException("Expected type Illuminance.", nameof(obj)); - - return CompareTo(objIlluminance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Illuminance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Illuminance objIlluminance)) - return false; - - return Equals(objIlluminance); - } - - public bool Equals(Illuminance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Illuminance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Illuminance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((IlluminanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(IlluminanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Illuminance to another Illuminance with the unit representation . - /// - /// A Illuminance with the specified unit. - public Illuminance ToUnit(IlluminanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Illuminance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(IlluminanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.g.cs deleted file mode 100644 index 493d68e580..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Information.g.cs +++ /dev/null @@ -1,1005 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Information : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly decimal _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly InformationUnit? _unit; - - static Information() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Information, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Bit. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Information() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Information(decimal value, InformationUnit unit) - { - if(unit == InformationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = value; - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Information, which is Bit. All conversions go via this value. - /// - public static InformationUnit BaseUnit { get; } = InformationUnit.Bit; - - /// - /// Represents the largest possible value of Information - /// - public static Information MaxValue { get; } = new Information(decimal.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Information - /// - public static Information MinValue { get; } = new Information(decimal.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Information; - - /// - /// All units of measurement for the Information quantity. - /// - public static InformationUnit[] Units { get; } = Enum.GetValues(typeof(InformationUnit)).Cast().Except(new InformationUnit[]{ InformationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Bit. - /// - public static Information Zero { get; } = new Information(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public InformationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Information.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Information.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Information in Bits. - /// - public double Bits => As(InformationUnit.Bit); - - /// - /// Get Information in Bytes. - /// - public double Bytes => As(InformationUnit.Byte); - - /// - /// Get Information in Exabits. - /// - public double Exabits => As(InformationUnit.Exabit); - - /// - /// Get Information in Exabytes. - /// - public double Exabytes => As(InformationUnit.Exabyte); - - /// - /// Get Information in Exbibits. - /// - public double Exbibits => As(InformationUnit.Exbibit); - - /// - /// Get Information in Exbibytes. - /// - public double Exbibytes => As(InformationUnit.Exbibyte); - - /// - /// Get Information in Gibibits. - /// - public double Gibibits => As(InformationUnit.Gibibit); - - /// - /// Get Information in Gibibytes. - /// - public double Gibibytes => As(InformationUnit.Gibibyte); - - /// - /// Get Information in Gigabits. - /// - public double Gigabits => As(InformationUnit.Gigabit); - - /// - /// Get Information in Gigabytes. - /// - public double Gigabytes => As(InformationUnit.Gigabyte); - - /// - /// Get Information in Kibibits. - /// - public double Kibibits => As(InformationUnit.Kibibit); - - /// - /// Get Information in Kibibytes. - /// - public double Kibibytes => As(InformationUnit.Kibibyte); - - /// - /// Get Information in Kilobits. - /// - public double Kilobits => As(InformationUnit.Kilobit); - - /// - /// Get Information in Kilobytes. - /// - public double Kilobytes => As(InformationUnit.Kilobyte); - - /// - /// Get Information in Mebibits. - /// - public double Mebibits => As(InformationUnit.Mebibit); - - /// - /// Get Information in Mebibytes. - /// - public double Mebibytes => As(InformationUnit.Mebibyte); - - /// - /// Get Information in Megabits. - /// - public double Megabits => As(InformationUnit.Megabit); - - /// - /// Get Information in Megabytes. - /// - public double Megabytes => As(InformationUnit.Megabyte); - - /// - /// Get Information in Pebibits. - /// - public double Pebibits => As(InformationUnit.Pebibit); - - /// - /// Get Information in Pebibytes. - /// - public double Pebibytes => As(InformationUnit.Pebibyte); - - /// - /// Get Information in Petabits. - /// - public double Petabits => As(InformationUnit.Petabit); - - /// - /// Get Information in Petabytes. - /// - public double Petabytes => As(InformationUnit.Petabyte); - - /// - /// Get Information in Tebibits. - /// - public double Tebibits => As(InformationUnit.Tebibit); - - /// - /// Get Information in Tebibytes. - /// - public double Tebibytes => As(InformationUnit.Tebibyte); - - /// - /// Get Information in Terabits. - /// - public double Terabits => As(InformationUnit.Terabit); - - /// - /// Get Information in Terabytes. - /// - public double Terabytes => As(InformationUnit.Terabyte); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(InformationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(InformationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Information from Bits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromBits(double bits) - { - decimal value = (decimal) bits; - return new Information(value, InformationUnit.Bit); - } - /// - /// Get Information from Bytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromBytes(double bytes) - { - decimal value = (decimal) bytes; - return new Information(value, InformationUnit.Byte); - } - /// - /// Get Information from Exabits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromExabits(double exabits) - { - decimal value = (decimal) exabits; - return new Information(value, InformationUnit.Exabit); - } - /// - /// Get Information from Exabytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromExabytes(double exabytes) - { - decimal value = (decimal) exabytes; - return new Information(value, InformationUnit.Exabyte); - } - /// - /// Get Information from Exbibits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromExbibits(double exbibits) - { - decimal value = (decimal) exbibits; - return new Information(value, InformationUnit.Exbibit); - } - /// - /// Get Information from Exbibytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromExbibytes(double exbibytes) - { - decimal value = (decimal) exbibytes; - return new Information(value, InformationUnit.Exbibyte); - } - /// - /// Get Information from Gibibits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromGibibits(double gibibits) - { - decimal value = (decimal) gibibits; - return new Information(value, InformationUnit.Gibibit); - } - /// - /// Get Information from Gibibytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromGibibytes(double gibibytes) - { - decimal value = (decimal) gibibytes; - return new Information(value, InformationUnit.Gibibyte); - } - /// - /// Get Information from Gigabits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromGigabits(double gigabits) - { - decimal value = (decimal) gigabits; - return new Information(value, InformationUnit.Gigabit); - } - /// - /// Get Information from Gigabytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromGigabytes(double gigabytes) - { - decimal value = (decimal) gigabytes; - return new Information(value, InformationUnit.Gigabyte); - } - /// - /// Get Information from Kibibits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromKibibits(double kibibits) - { - decimal value = (decimal) kibibits; - return new Information(value, InformationUnit.Kibibit); - } - /// - /// Get Information from Kibibytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromKibibytes(double kibibytes) - { - decimal value = (decimal) kibibytes; - return new Information(value, InformationUnit.Kibibyte); - } - /// - /// Get Information from Kilobits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromKilobits(double kilobits) - { - decimal value = (decimal) kilobits; - return new Information(value, InformationUnit.Kilobit); - } - /// - /// Get Information from Kilobytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromKilobytes(double kilobytes) - { - decimal value = (decimal) kilobytes; - return new Information(value, InformationUnit.Kilobyte); - } - /// - /// Get Information from Mebibits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromMebibits(double mebibits) - { - decimal value = (decimal) mebibits; - return new Information(value, InformationUnit.Mebibit); - } - /// - /// Get Information from Mebibytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromMebibytes(double mebibytes) - { - decimal value = (decimal) mebibytes; - return new Information(value, InformationUnit.Mebibyte); - } - /// - /// Get Information from Megabits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromMegabits(double megabits) - { - decimal value = (decimal) megabits; - return new Information(value, InformationUnit.Megabit); - } - /// - /// Get Information from Megabytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromMegabytes(double megabytes) - { - decimal value = (decimal) megabytes; - return new Information(value, InformationUnit.Megabyte); - } - /// - /// Get Information from Pebibits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromPebibits(double pebibits) - { - decimal value = (decimal) pebibits; - return new Information(value, InformationUnit.Pebibit); - } - /// - /// Get Information from Pebibytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromPebibytes(double pebibytes) - { - decimal value = (decimal) pebibytes; - return new Information(value, InformationUnit.Pebibyte); - } - /// - /// Get Information from Petabits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromPetabits(double petabits) - { - decimal value = (decimal) petabits; - return new Information(value, InformationUnit.Petabit); - } - /// - /// Get Information from Petabytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromPetabytes(double petabytes) - { - decimal value = (decimal) petabytes; - return new Information(value, InformationUnit.Petabyte); - } - /// - /// Get Information from Tebibits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromTebibits(double tebibits) - { - decimal value = (decimal) tebibits; - return new Information(value, InformationUnit.Tebibit); - } - /// - /// Get Information from Tebibytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromTebibytes(double tebibytes) - { - decimal value = (decimal) tebibytes; - return new Information(value, InformationUnit.Tebibyte); - } - /// - /// Get Information from Terabits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromTerabits(double terabits) - { - decimal value = (decimal) terabits; - return new Information(value, InformationUnit.Terabit); - } - /// - /// Get Information from Terabytes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Information FromTerabytes(double terabytes) - { - decimal value = (decimal) terabytes; - return new Information(value, InformationUnit.Terabyte); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Information unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Information From(double value, InformationUnit fromUnit) - { - return new Information((decimal)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Information Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Information Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Information result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Information result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static InformationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static InformationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out InformationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out InformationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Information objInformation)) throw new ArgumentException("Expected type Information.", nameof(obj)); - - return CompareTo(objInformation); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Information other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Information objInformation)) - return false; - - return Equals(objInformation); - } - - public bool Equals(Information other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Information within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Information other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Information. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((InformationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(InformationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Information to another Information with the unit representation . - /// - /// A Information with the specified unit. - public Information ToUnit(InformationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Information(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private decimal AsBaseUnit() - { - switch(Unit) - { - case InformationUnit.Bit: return _value; - case InformationUnit.Byte: return _value*8m; - case InformationUnit.Exabit: return (_value) * 1e18m; - case InformationUnit.Exabyte: return (_value*8m) * 1e18m; - case InformationUnit.Exbibit: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Exbibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Gibibit: return (_value) * (1024m * 1024 * 1024); - case InformationUnit.Gibibyte: return (_value*8m) * (1024m * 1024 * 1024); - case InformationUnit.Gigabit: return (_value) * 1e9m; - case InformationUnit.Gigabyte: return (_value*8m) * 1e9m; - case InformationUnit.Kibibit: return (_value) * 1024m; - case InformationUnit.Kibibyte: return (_value*8m) * 1024m; - case InformationUnit.Kilobit: return (_value) * 1e3m; - case InformationUnit.Kilobyte: return (_value*8m) * 1e3m; - case InformationUnit.Mebibit: return (_value) * (1024m * 1024); - case InformationUnit.Mebibyte: return (_value*8m) * (1024m * 1024); - case InformationUnit.Megabit: return (_value) * 1e6m; - case InformationUnit.Megabyte: return (_value*8m) * 1e6m; - case InformationUnit.Pebibit: return (_value) * (1024m * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Pebibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Petabit: return (_value) * 1e15m; - case InformationUnit.Petabyte: return (_value*8m) * 1e15m; - case InformationUnit.Tebibit: return (_value) * (1024m * 1024 * 1024 * 1024); - case InformationUnit.Tebibyte: return (_value*8m) * (1024m * 1024 * 1024 * 1024); - case InformationUnit.Terabit: return (_value) * 1e12m; - case InformationUnit.Terabyte: return (_value*8m) * 1e12m; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private decimal AsBaseNumericType(InformationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case InformationUnit.Bit: return baseUnitValue; - case InformationUnit.Byte: return baseUnitValue/8m; - case InformationUnit.Exabit: return (baseUnitValue) / 1e18m; - case InformationUnit.Exabyte: return (baseUnitValue/8m) / 1e18m; - case InformationUnit.Exbibit: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Exbibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Gibibit: return (baseUnitValue) / (1024m * 1024 * 1024); - case InformationUnit.Gibibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024); - case InformationUnit.Gigabit: return (baseUnitValue) / 1e9m; - case InformationUnit.Gigabyte: return (baseUnitValue/8m) / 1e9m; - case InformationUnit.Kibibit: return (baseUnitValue) / 1024m; - case InformationUnit.Kibibyte: return (baseUnitValue/8m) / 1024m; - case InformationUnit.Kilobit: return (baseUnitValue) / 1e3m; - case InformationUnit.Kilobyte: return (baseUnitValue/8m) / 1e3m; - case InformationUnit.Mebibit: return (baseUnitValue) / (1024m * 1024); - case InformationUnit.Mebibyte: return (baseUnitValue/8m) / (1024m * 1024); - case InformationUnit.Megabit: return (baseUnitValue) / 1e6m; - case InformationUnit.Megabyte: return (baseUnitValue/8m) / 1e6m; - case InformationUnit.Pebibit: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Pebibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024 * 1024); - case InformationUnit.Petabit: return (baseUnitValue) / 1e15m; - case InformationUnit.Petabyte: return (baseUnitValue/8m) / 1e15m; - case InformationUnit.Tebibit: return (baseUnitValue) / (1024m * 1024 * 1024 * 1024); - case InformationUnit.Tebibyte: return (baseUnitValue/8m) / (1024m * 1024 * 1024 * 1024); - case InformationUnit.Terabit: return (baseUnitValue) / 1e12m; - case InformationUnit.Terabyte: return (baseUnitValue/8m) / 1e12m; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.g.cs deleted file mode 100644 index c144fc7db5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiance.g.cs +++ /dev/null @@ -1,801 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Irradiance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly IrradianceUnit? _unit; - - static Irradiance() - { - BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Irradiance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit WattPerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Irradiance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Irradiance(double value, IrradianceUnit unit) - { - if(unit == IrradianceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Irradiance, which is WattPerSquareMeter. All conversions go via this value. - /// - public static IrradianceUnit BaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; - - /// - /// Represents the largest possible value of Irradiance - /// - public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Irradiance - /// - public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Irradiance; - - /// - /// All units of measurement for the Irradiance quantity. - /// - public static IrradianceUnit[] Units { get; } = Enum.GetValues(typeof(IrradianceUnit)).Cast().Except(new IrradianceUnit[]{ IrradianceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. - /// - public static Irradiance Zero { get; } = new Irradiance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public IrradianceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Irradiance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Irradiance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Irradiance in KilowattsPerSquareCentimeter. - /// - public double KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); - - /// - /// Get Irradiance in KilowattsPerSquareMeter. - /// - public double KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); - - /// - /// Get Irradiance in MegawattsPerSquareCentimeter. - /// - public double MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); - - /// - /// Get Irradiance in MegawattsPerSquareMeter. - /// - public double MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); - - /// - /// Get Irradiance in MicrowattsPerSquareCentimeter. - /// - public double MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); - - /// - /// Get Irradiance in MicrowattsPerSquareMeter. - /// - public double MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); - - /// - /// Get Irradiance in MilliwattsPerSquareCentimeter. - /// - public double MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); - - /// - /// Get Irradiance in MilliwattsPerSquareMeter. - /// - public double MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); - - /// - /// Get Irradiance in NanowattsPerSquareCentimeter. - /// - public double NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); - - /// - /// Get Irradiance in NanowattsPerSquareMeter. - /// - public double NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); - - /// - /// Get Irradiance in PicowattsPerSquareCentimeter. - /// - public double PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); - - /// - /// Get Irradiance in PicowattsPerSquareMeter. - /// - public double PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); - - /// - /// Get Irradiance in WattsPerSquareCentimeter. - /// - public double WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); - - /// - /// Get Irradiance in WattsPerSquareMeter. - /// - public double WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(IrradianceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(IrradianceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Irradiance from KilowattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromKilowattsPerSquareCentimeter(double kilowattspersquarecentimeter) - { - double value = (double) kilowattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.KilowattPerSquareCentimeter); - } - /// - /// Get Irradiance from KilowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromKilowattsPerSquareMeter(double kilowattspersquaremeter) - { - double value = (double) kilowattspersquaremeter; - return new Irradiance(value, IrradianceUnit.KilowattPerSquareMeter); - } - /// - /// Get Irradiance from MegawattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromMegawattsPerSquareCentimeter(double megawattspersquarecentimeter) - { - double value = (double) megawattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.MegawattPerSquareCentimeter); - } - /// - /// Get Irradiance from MegawattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromMegawattsPerSquareMeter(double megawattspersquaremeter) - { - double value = (double) megawattspersquaremeter; - return new Irradiance(value, IrradianceUnit.MegawattPerSquareMeter); - } - /// - /// Get Irradiance from MicrowattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromMicrowattsPerSquareCentimeter(double microwattspersquarecentimeter) - { - double value = (double) microwattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.MicrowattPerSquareCentimeter); - } - /// - /// Get Irradiance from MicrowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromMicrowattsPerSquareMeter(double microwattspersquaremeter) - { - double value = (double) microwattspersquaremeter; - return new Irradiance(value, IrradianceUnit.MicrowattPerSquareMeter); - } - /// - /// Get Irradiance from MilliwattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromMilliwattsPerSquareCentimeter(double milliwattspersquarecentimeter) - { - double value = (double) milliwattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.MilliwattPerSquareCentimeter); - } - /// - /// Get Irradiance from MilliwattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromMilliwattsPerSquareMeter(double milliwattspersquaremeter) - { - double value = (double) milliwattspersquaremeter; - return new Irradiance(value, IrradianceUnit.MilliwattPerSquareMeter); - } - /// - /// Get Irradiance from NanowattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromNanowattsPerSquareCentimeter(double nanowattspersquarecentimeter) - { - double value = (double) nanowattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.NanowattPerSquareCentimeter); - } - /// - /// Get Irradiance from NanowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromNanowattsPerSquareMeter(double nanowattspersquaremeter) - { - double value = (double) nanowattspersquaremeter; - return new Irradiance(value, IrradianceUnit.NanowattPerSquareMeter); - } - /// - /// Get Irradiance from PicowattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromPicowattsPerSquareCentimeter(double picowattspersquarecentimeter) - { - double value = (double) picowattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.PicowattPerSquareCentimeter); - } - /// - /// Get Irradiance from PicowattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromPicowattsPerSquareMeter(double picowattspersquaremeter) - { - double value = (double) picowattspersquaremeter; - return new Irradiance(value, IrradianceUnit.PicowattPerSquareMeter); - } - /// - /// Get Irradiance from WattsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromWattsPerSquareCentimeter(double wattspersquarecentimeter) - { - double value = (double) wattspersquarecentimeter; - return new Irradiance(value, IrradianceUnit.WattPerSquareCentimeter); - } - /// - /// Get Irradiance from WattsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiance FromWattsPerSquareMeter(double wattspersquaremeter) - { - double value = (double) wattspersquaremeter; - return new Irradiance(value, IrradianceUnit.WattPerSquareMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Irradiance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Irradiance From(double value, IrradianceUnit fromUnit) - { - return new Irradiance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Irradiance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Irradiance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Irradiance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Irradiance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static IrradianceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static IrradianceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out IrradianceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out IrradianceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Irradiance objIrradiance)) throw new ArgumentException("Expected type Irradiance.", nameof(obj)); - - return CompareTo(objIrradiance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Irradiance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Irradiance objIrradiance)) - return false; - - return Equals(objIrradiance); - } - - public bool Equals(Irradiance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Irradiance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Irradiance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((IrradianceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(IrradianceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Irradiance to another Irradiance with the unit representation . - /// - /// A Irradiance with the specified unit. - public Irradiance ToUnit(IrradianceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Irradiance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(IrradianceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.g.cs deleted file mode 100644 index cc5a256723..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Irradiation.g.cs +++ /dev/null @@ -1,685 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources. - /// - /// - /// https://en.wikipedia.org/wiki/Irradiation - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Irradiation : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly IrradiationUnit? _unit; - - static Irradiation() - { - BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Irradiation, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Irradiation() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Irradiation(double value, IrradiationUnit unit) - { - if(unit == IrradiationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Irradiation, which is JoulePerSquareMeter. All conversions go via this value. - /// - public static IrradiationUnit BaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; - - /// - /// Represents the largest possible value of Irradiation - /// - public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Irradiation - /// - public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Irradiation; - - /// - /// All units of measurement for the Irradiation quantity. - /// - public static IrradiationUnit[] Units { get; } = Enum.GetValues(typeof(IrradiationUnit)).Cast().Except(new IrradiationUnit[]{ IrradiationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerSquareMeter. - /// - public static Irradiation Zero { get; } = new Irradiation(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public IrradiationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Irradiation.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Irradiation.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Irradiation in JoulesPerSquareCentimeter. - /// - public double JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); - - /// - /// Get Irradiation in JoulesPerSquareMeter. - /// - public double JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); - - /// - /// Get Irradiation in JoulesPerSquareMillimeter. - /// - public double JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); - - /// - /// Get Irradiation in KilojoulesPerSquareMeter. - /// - public double KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); - - /// - /// Get Irradiation in KilowattHoursPerSquareMeter. - /// - public double KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); - - /// - /// Get Irradiation in MillijoulesPerSquareCentimeter. - /// - public double MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); - - /// - /// Get Irradiation in WattHoursPerSquareMeter. - /// - public double WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(IrradiationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(IrradiationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Irradiation from JoulesPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromJoulesPerSquareCentimeter(double joulespersquarecentimeter) - { - double value = (double) joulespersquarecentimeter; - return new Irradiation(value, IrradiationUnit.JoulePerSquareCentimeter); - } - /// - /// Get Irradiation from JoulesPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromJoulesPerSquareMeter(double joulespersquaremeter) - { - double value = (double) joulespersquaremeter; - return new Irradiation(value, IrradiationUnit.JoulePerSquareMeter); - } - /// - /// Get Irradiation from JoulesPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromJoulesPerSquareMillimeter(double joulespersquaremillimeter) - { - double value = (double) joulespersquaremillimeter; - return new Irradiation(value, IrradiationUnit.JoulePerSquareMillimeter); - } - /// - /// Get Irradiation from KilojoulesPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromKilojoulesPerSquareMeter(double kilojoulespersquaremeter) - { - double value = (double) kilojoulespersquaremeter; - return new Irradiation(value, IrradiationUnit.KilojoulePerSquareMeter); - } - /// - /// Get Irradiation from KilowattHoursPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromKilowattHoursPerSquareMeter(double kilowatthourspersquaremeter) - { - double value = (double) kilowatthourspersquaremeter; - return new Irradiation(value, IrradiationUnit.KilowattHourPerSquareMeter); - } - /// - /// Get Irradiation from MillijoulesPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromMillijoulesPerSquareCentimeter(double millijoulespersquarecentimeter) - { - double value = (double) millijoulespersquarecentimeter; - return new Irradiation(value, IrradiationUnit.MillijoulePerSquareCentimeter); - } - /// - /// Get Irradiation from WattHoursPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Irradiation FromWattHoursPerSquareMeter(double watthourspersquaremeter) - { - double value = (double) watthourspersquaremeter; - return new Irradiation(value, IrradiationUnit.WattHourPerSquareMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Irradiation unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Irradiation From(double value, IrradiationUnit fromUnit) - { - return new Irradiation((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Irradiation Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Irradiation Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Irradiation result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Irradiation result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static IrradiationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static IrradiationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out IrradiationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out IrradiationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Irradiation objIrradiation)) throw new ArgumentException("Expected type Irradiation.", nameof(obj)); - - return CompareTo(objIrradiation); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Irradiation other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Irradiation objIrradiation)) - return false; - - return Equals(objIrradiation); - } - - public bool Equals(Irradiation other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Irradiation within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Irradiation. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((IrradiationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(IrradiationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Irradiation to another Irradiation with the unit representation . - /// - /// A Irradiation with the specified unit. - public Irradiation ToUnit(IrradiationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Irradiation(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(IrradiationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.g.cs deleted file mode 100644 index c8783a04c9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ /dev/null @@ -1,719 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress. - /// - /// - /// http://en.wikipedia.org/wiki/Viscosity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class KinematicViscosity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly KinematicViscosityUnit? _unit; - - static KinematicViscosity() - { - BaseDimensions = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.KinematicViscosity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit SquareMeterPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public KinematicViscosity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private KinematicViscosity(double value, KinematicViscosityUnit unit) - { - if(unit == KinematicViscosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of KinematicViscosity, which is SquareMeterPerSecond. All conversions go via this value. - /// - public static KinematicViscosityUnit BaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; - - /// - /// Represents the largest possible value of KinematicViscosity - /// - public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of KinematicViscosity - /// - public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.KinematicViscosity; - - /// - /// All units of measurement for the KinematicViscosity quantity. - /// - public static KinematicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().Except(new KinematicViscosityUnit[]{ KinematicViscosityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterPerSecond. - /// - public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public KinematicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => KinematicViscosity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => KinematicViscosity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get KinematicViscosity in Centistokes. - /// - public double Centistokes => As(KinematicViscosityUnit.Centistokes); - - /// - /// Get KinematicViscosity in Decistokes. - /// - public double Decistokes => As(KinematicViscosityUnit.Decistokes); - - /// - /// Get KinematicViscosity in Kilostokes. - /// - public double Kilostokes => As(KinematicViscosityUnit.Kilostokes); - - /// - /// Get KinematicViscosity in Microstokes. - /// - public double Microstokes => As(KinematicViscosityUnit.Microstokes); - - /// - /// Get KinematicViscosity in Millistokes. - /// - public double Millistokes => As(KinematicViscosityUnit.Millistokes); - - /// - /// Get KinematicViscosity in Nanostokes. - /// - public double Nanostokes => As(KinematicViscosityUnit.Nanostokes); - - /// - /// Get KinematicViscosity in SquareFeetPerSecond. - /// - public double SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); - - /// - /// Get KinematicViscosity in SquareMetersPerSecond. - /// - public double SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); - - /// - /// Get KinematicViscosity in Stokes. - /// - public double Stokes => As(KinematicViscosityUnit.Stokes); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(KinematicViscosityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(KinematicViscosityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get KinematicViscosity from Centistokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromCentistokes(double centistokes) - { - double value = (double) centistokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Centistokes); - } - /// - /// Get KinematicViscosity from Decistokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromDecistokes(double decistokes) - { - double value = (double) decistokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Decistokes); - } - /// - /// Get KinematicViscosity from Kilostokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromKilostokes(double kilostokes) - { - double value = (double) kilostokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Kilostokes); - } - /// - /// Get KinematicViscosity from Microstokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromMicrostokes(double microstokes) - { - double value = (double) microstokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Microstokes); - } - /// - /// Get KinematicViscosity from Millistokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromMillistokes(double millistokes) - { - double value = (double) millistokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Millistokes); - } - /// - /// Get KinematicViscosity from Nanostokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromNanostokes(double nanostokes) - { - double value = (double) nanostokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Nanostokes); - } - /// - /// Get KinematicViscosity from SquareFeetPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromSquareFeetPerSecond(double squarefeetpersecond) - { - double value = (double) squarefeetpersecond; - return new KinematicViscosity(value, KinematicViscosityUnit.SquareFootPerSecond); - } - /// - /// Get KinematicViscosity from SquareMetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromSquareMetersPerSecond(double squaremeterspersecond) - { - double value = (double) squaremeterspersecond; - return new KinematicViscosity(value, KinematicViscosityUnit.SquareMeterPerSecond); - } - /// - /// Get KinematicViscosity from Stokes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static KinematicViscosity FromStokes(double stokes) - { - double value = (double) stokes; - return new KinematicViscosity(value, KinematicViscosityUnit.Stokes); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// KinematicViscosity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static KinematicViscosity From(double value, KinematicViscosityUnit fromUnit) - { - return new KinematicViscosity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static KinematicViscosity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static KinematicViscosity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out KinematicViscosity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out KinematicViscosity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static KinematicViscosityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static KinematicViscosityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out KinematicViscosityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out KinematicViscosityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is KinematicViscosity objKinematicViscosity)) throw new ArgumentException("Expected type KinematicViscosity.", nameof(obj)); - - return CompareTo(objKinematicViscosity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(KinematicViscosity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is KinematicViscosity objKinematicViscosity)) - return false; - - return Equals(objKinematicViscosity); - } - - public bool Equals(KinematicViscosity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another KinematicViscosity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current KinematicViscosity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((KinematicViscosityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(KinematicViscosityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this KinematicViscosity to another KinematicViscosity with the unit representation . - /// - /// A KinematicViscosity with the specified unit. - public KinematicViscosity ToUnit(KinematicViscosityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new KinematicViscosity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(KinematicViscosityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.g.cs deleted file mode 100644 index ae4b7fe44c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LapseRate.g.cs +++ /dev/null @@ -1,580 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class LapseRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LapseRateUnit? _unit; - - static LapseRate() - { - BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0); - Info = new QuantityInfo(QuantityType.LapseRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public LapseRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private LapseRate(double value, LapseRateUnit unit) - { - if(unit == LapseRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of LapseRate, which is DegreeCelsiusPerKilometer. All conversions go via this value. - /// - public static LapseRateUnit BaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; - - /// - /// Represents the largest possible value of LapseRate - /// - public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of LapseRate - /// - public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.LapseRate; - - /// - /// All units of measurement for the LapseRate quantity. - /// - public static LapseRateUnit[] Units { get; } = Enum.GetValues(typeof(LapseRateUnit)).Cast().Except(new LapseRateUnit[]{ LapseRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer. - /// - public static LapseRate Zero { get; } = new LapseRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LapseRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => LapseRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => LapseRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get LapseRate in DegreesCelciusPerKilometer. - /// - public double DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LapseRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LapseRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get LapseRate from DegreesCelciusPerKilometer. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LapseRate FromDegreesCelciusPerKilometer(double degreescelciusperkilometer) - { - double value = (double) degreescelciusperkilometer; - return new LapseRate(value, LapseRateUnit.DegreeCelsiusPerKilometer); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// LapseRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static LapseRate From(double value, LapseRateUnit fromUnit) - { - return new LapseRate((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static LapseRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LapseRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out LapseRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out LapseRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LapseRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LapseRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LapseRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LapseRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LapseRate objLapseRate)) throw new ArgumentException("Expected type LapseRate.", nameof(obj)); - - return CompareTo(objLapseRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(LapseRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is LapseRate objLapseRate)) - return false; - - return Equals(objLapseRate); - } - - public bool Equals(LapseRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another LapseRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current LapseRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LapseRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LapseRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this LapseRate to another LapseRate with the unit representation . - /// - /// A LapseRate with the specified unit. - public LapseRate ToUnit(LapseRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new LapseRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case LapseRateUnit.DegreeCelsiusPerKilometer: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(LapseRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case LapseRateUnit.DegreeCelsiusPerKilometer: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.g.cs deleted file mode 100644 index f901c4999c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Length.g.cs +++ /dev/null @@ -1,1124 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Length : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LengthUnit? _unit; - - static Length() - { - BaseDimensions = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Length, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Meter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Length() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Length(double value, LengthUnit unit) - { - if(unit == LengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Length, which is Meter. All conversions go via this value. - /// - public static LengthUnit BaseUnit { get; } = LengthUnit.Meter; - - /// - /// Represents the largest possible value of Length - /// - public static Length MaxValue { get; } = new Length(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Length - /// - public static Length MinValue { get; } = new Length(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Length; - - /// - /// All units of measurement for the Length quantity. - /// - public static LengthUnit[] Units { get; } = Enum.GetValues(typeof(LengthUnit)).Cast().Except(new LengthUnit[]{ LengthUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Meter. - /// - public static Length Zero { get; } = new Length(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Length.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Length.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Length in AstronomicalUnits. - /// - public double AstronomicalUnits => As(LengthUnit.AstronomicalUnit); - - /// - /// Get Length in Centimeters. - /// - public double Centimeters => As(LengthUnit.Centimeter); - - /// - /// Get Length in Chains. - /// - public double Chains => As(LengthUnit.Chain); - - /// - /// Get Length in Decimeters. - /// - public double Decimeters => As(LengthUnit.Decimeter); - - /// - /// Get Length in DtpPicas. - /// - public double DtpPicas => As(LengthUnit.DtpPica); - - /// - /// Get Length in DtpPoints. - /// - public double DtpPoints => As(LengthUnit.DtpPoint); - - /// - /// Get Length in Fathoms. - /// - public double Fathoms => As(LengthUnit.Fathom); - - /// - /// Get Length in Feet. - /// - public double Feet => As(LengthUnit.Foot); - - /// - /// Get Length in Hands. - /// - public double Hands => As(LengthUnit.Hand); - - /// - /// Get Length in Hectometers. - /// - public double Hectometers => As(LengthUnit.Hectometer); - - /// - /// Get Length in Inches. - /// - public double Inches => As(LengthUnit.Inch); - - /// - /// Get Length in KilolightYears. - /// - public double KilolightYears => As(LengthUnit.KilolightYear); - - /// - /// Get Length in Kilometers. - /// - public double Kilometers => As(LengthUnit.Kilometer); - - /// - /// Get Length in Kiloparsecs. - /// - public double Kiloparsecs => As(LengthUnit.Kiloparsec); - - /// - /// Get Length in LightYears. - /// - public double LightYears => As(LengthUnit.LightYear); - - /// - /// Get Length in MegalightYears. - /// - public double MegalightYears => As(LengthUnit.MegalightYear); - - /// - /// Get Length in Megaparsecs. - /// - public double Megaparsecs => As(LengthUnit.Megaparsec); - - /// - /// Get Length in Meters. - /// - public double Meters => As(LengthUnit.Meter); - - /// - /// Get Length in Microinches. - /// - public double Microinches => As(LengthUnit.Microinch); - - /// - /// Get Length in Micrometers. - /// - public double Micrometers => As(LengthUnit.Micrometer); - - /// - /// Get Length in Mils. - /// - public double Mils => As(LengthUnit.Mil); - - /// - /// Get Length in Miles. - /// - public double Miles => As(LengthUnit.Mile); - - /// - /// Get Length in Millimeters. - /// - public double Millimeters => As(LengthUnit.Millimeter); - - /// - /// Get Length in Nanometers. - /// - public double Nanometers => As(LengthUnit.Nanometer); - - /// - /// Get Length in NauticalMiles. - /// - public double NauticalMiles => As(LengthUnit.NauticalMile); - - /// - /// Get Length in Parsecs. - /// - public double Parsecs => As(LengthUnit.Parsec); - - /// - /// Get Length in PrinterPicas. - /// - public double PrinterPicas => As(LengthUnit.PrinterPica); - - /// - /// Get Length in PrinterPoints. - /// - public double PrinterPoints => As(LengthUnit.PrinterPoint); - - /// - /// Get Length in Shackles. - /// - public double Shackles => As(LengthUnit.Shackle); - - /// - /// Get Length in SolarRadiuses. - /// - public double SolarRadiuses => As(LengthUnit.SolarRadius); - - /// - /// Get Length in Twips. - /// - public double Twips => As(LengthUnit.Twip); - - /// - /// Get Length in UsSurveyFeet. - /// - public double UsSurveyFeet => As(LengthUnit.UsSurveyFoot); - - /// - /// Get Length in Yards. - /// - public double Yards => As(LengthUnit.Yard); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LengthUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LengthUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Length from AstronomicalUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromAstronomicalUnits(double astronomicalunits) - { - double value = (double) astronomicalunits; - return new Length(value, LengthUnit.AstronomicalUnit); - } - /// - /// Get Length from Centimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromCentimeters(double centimeters) - { - double value = (double) centimeters; - return new Length(value, LengthUnit.Centimeter); - } - /// - /// Get Length from Chains. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromChains(double chains) - { - double value = (double) chains; - return new Length(value, LengthUnit.Chain); - } - /// - /// Get Length from Decimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromDecimeters(double decimeters) - { - double value = (double) decimeters; - return new Length(value, LengthUnit.Decimeter); - } - /// - /// Get Length from DtpPicas. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromDtpPicas(double dtppicas) - { - double value = (double) dtppicas; - return new Length(value, LengthUnit.DtpPica); - } - /// - /// Get Length from DtpPoints. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromDtpPoints(double dtppoints) - { - double value = (double) dtppoints; - return new Length(value, LengthUnit.DtpPoint); - } - /// - /// Get Length from Fathoms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromFathoms(double fathoms) - { - double value = (double) fathoms; - return new Length(value, LengthUnit.Fathom); - } - /// - /// Get Length from Feet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromFeet(double feet) - { - double value = (double) feet; - return new Length(value, LengthUnit.Foot); - } - /// - /// Get Length from Hands. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromHands(double hands) - { - double value = (double) hands; - return new Length(value, LengthUnit.Hand); - } - /// - /// Get Length from Hectometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromHectometers(double hectometers) - { - double value = (double) hectometers; - return new Length(value, LengthUnit.Hectometer); - } - /// - /// Get Length from Inches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromInches(double inches) - { - double value = (double) inches; - return new Length(value, LengthUnit.Inch); - } - /// - /// Get Length from KilolightYears. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromKilolightYears(double kilolightyears) - { - double value = (double) kilolightyears; - return new Length(value, LengthUnit.KilolightYear); - } - /// - /// Get Length from Kilometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromKilometers(double kilometers) - { - double value = (double) kilometers; - return new Length(value, LengthUnit.Kilometer); - } - /// - /// Get Length from Kiloparsecs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromKiloparsecs(double kiloparsecs) - { - double value = (double) kiloparsecs; - return new Length(value, LengthUnit.Kiloparsec); - } - /// - /// Get Length from LightYears. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromLightYears(double lightyears) - { - double value = (double) lightyears; - return new Length(value, LengthUnit.LightYear); - } - /// - /// Get Length from MegalightYears. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMegalightYears(double megalightyears) - { - double value = (double) megalightyears; - return new Length(value, LengthUnit.MegalightYear); - } - /// - /// Get Length from Megaparsecs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMegaparsecs(double megaparsecs) - { - double value = (double) megaparsecs; - return new Length(value, LengthUnit.Megaparsec); - } - /// - /// Get Length from Meters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMeters(double meters) - { - double value = (double) meters; - return new Length(value, LengthUnit.Meter); - } - /// - /// Get Length from Microinches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMicroinches(double microinches) - { - double value = (double) microinches; - return new Length(value, LengthUnit.Microinch); - } - /// - /// Get Length from Micrometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMicrometers(double micrometers) - { - double value = (double) micrometers; - return new Length(value, LengthUnit.Micrometer); - } - /// - /// Get Length from Mils. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMils(double mils) - { - double value = (double) mils; - return new Length(value, LengthUnit.Mil); - } - /// - /// Get Length from Miles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMiles(double miles) - { - double value = (double) miles; - return new Length(value, LengthUnit.Mile); - } - /// - /// Get Length from Millimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromMillimeters(double millimeters) - { - double value = (double) millimeters; - return new Length(value, LengthUnit.Millimeter); - } - /// - /// Get Length from Nanometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromNanometers(double nanometers) - { - double value = (double) nanometers; - return new Length(value, LengthUnit.Nanometer); - } - /// - /// Get Length from NauticalMiles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromNauticalMiles(double nauticalmiles) - { - double value = (double) nauticalmiles; - return new Length(value, LengthUnit.NauticalMile); - } - /// - /// Get Length from Parsecs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromParsecs(double parsecs) - { - double value = (double) parsecs; - return new Length(value, LengthUnit.Parsec); - } - /// - /// Get Length from PrinterPicas. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromPrinterPicas(double printerpicas) - { - double value = (double) printerpicas; - return new Length(value, LengthUnit.PrinterPica); - } - /// - /// Get Length from PrinterPoints. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromPrinterPoints(double printerpoints) - { - double value = (double) printerpoints; - return new Length(value, LengthUnit.PrinterPoint); - } - /// - /// Get Length from Shackles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromShackles(double shackles) - { - double value = (double) shackles; - return new Length(value, LengthUnit.Shackle); - } - /// - /// Get Length from SolarRadiuses. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromSolarRadiuses(double solarradiuses) - { - double value = (double) solarradiuses; - return new Length(value, LengthUnit.SolarRadius); - } - /// - /// Get Length from Twips. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromTwips(double twips) - { - double value = (double) twips; - return new Length(value, LengthUnit.Twip); - } - /// - /// Get Length from UsSurveyFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromUsSurveyFeet(double ussurveyfeet) - { - double value = (double) ussurveyfeet; - return new Length(value, LengthUnit.UsSurveyFoot); - } - /// - /// Get Length from Yards. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Length FromYards(double yards) - { - double value = (double) yards; - return new Length(value, LengthUnit.Yard); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Length unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Length From(double value, LengthUnit fromUnit) - { - return new Length((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Length Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Length Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Length result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Length result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LengthUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LengthUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LengthUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LengthUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Length objLength)) throw new ArgumentException("Expected type Length.", nameof(obj)); - - return CompareTo(objLength); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Length other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Length objLength)) - return false; - - return Equals(objLength); - } - - public bool Equals(Length other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Length within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Length other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Length. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LengthUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LengthUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Length to another Length with the unit representation . - /// - /// A Length with the specified unit. - public Length ToUnit(LengthUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Length(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case LengthUnit.AstronomicalUnit: return _value * 1.4959787070e11; - case LengthUnit.Centimeter: return (_value) * 1e-2d; - case LengthUnit.Chain: return _value*20.1168; - 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."); - } - } - - private double AsBaseNumericType(LengthUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case LengthUnit.AstronomicalUnit: return baseUnitValue / 1.4959787070e11; - case LengthUnit.Centimeter: return (baseUnitValue) / 1e-2d; - case LengthUnit.Chain: return baseUnitValue/20.1168; - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.g.cs deleted file mode 100644 index 498a843642..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Level.g.cs +++ /dev/null @@ -1,597 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Level : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LevelUnit? _unit; - - static Level() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Level, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Decibel. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Level() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Level(double value, LevelUnit unit) - { - if(unit == LevelUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Level, which is Decibel. All conversions go via this value. - /// - public static LevelUnit BaseUnit { get; } = LevelUnit.Decibel; - - /// - /// Represents the largest possible value of Level - /// - public static Level MaxValue { get; } = new Level(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Level - /// - public static Level MinValue { get; } = new Level(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Level; - - /// - /// All units of measurement for the Level quantity. - /// - public static LevelUnit[] Units { get; } = Enum.GetValues(typeof(LevelUnit)).Cast().Except(new LevelUnit[]{ LevelUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Decibel. - /// - public static Level Zero { get; } = new Level(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LevelUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Level.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Level.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Level in Decibels. - /// - public double Decibels => As(LevelUnit.Decibel); - - /// - /// Get Level in Nepers. - /// - public double Nepers => As(LevelUnit.Neper); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LevelUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LevelUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Level from Decibels. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Level FromDecibels(double decibels) - { - double value = (double) decibels; - return new Level(value, LevelUnit.Decibel); - } - /// - /// Get Level from Nepers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Level FromNepers(double nepers) - { - double value = (double) nepers; - return new Level(value, LevelUnit.Neper); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Level unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Level From(double value, LevelUnit fromUnit) - { - return new Level((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Level Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Level Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Level result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Level result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LevelUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LevelUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LevelUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LevelUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Level objLevel)) throw new ArgumentException("Expected type Level.", nameof(obj)); - - return CompareTo(objLevel); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Level other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Level objLevel)) - return false; - - return Equals(objLevel); - } - - public bool Equals(Level other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Level within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Level other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Level. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LevelUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LevelUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Level to another Level with the unit representation . - /// - /// A Level with the specified unit. - public Level ToUnit(LevelUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Level(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case LevelUnit.Decibel: return _value; - case LevelUnit.Neper: return (1/0.115129254)*_value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(LevelUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case LevelUnit.Decibel: return baseUnitValue; - case LevelUnit.Neper: return 0.115129254*baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.g.cs deleted file mode 100644 index da30246f8b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearDensity.g.cs +++ /dev/null @@ -1,804 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The Linear Density, or more precisely, the linear mass density, of a substance is its mass per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension. - /// - /// - /// http://en.wikipedia.org/wiki/Linear_density - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class LinearDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LinearDensityUnit? _unit; - - static LinearDensity() - { - BaseDimensions = new BaseDimensions(-1, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.LinearDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public LinearDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private LinearDensity(double value, LinearDensityUnit unit) - { - if(unit == LinearDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of LinearDensity, which is KilogramPerMeter. All conversions go via this value. - /// - public static LinearDensityUnit BaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; - - /// - /// Represents the largest possible value of LinearDensity - /// - public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of LinearDensity - /// - public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.LinearDensity; - - /// - /// All units of measurement for the LinearDensity quantity. - /// - public static LinearDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearDensityUnit)).Cast().Except(new LinearDensityUnit[]{ LinearDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMeter. - /// - public static LinearDensity Zero { get; } = new LinearDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LinearDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => LinearDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => LinearDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get LinearDensity in GramsPerCentimeter. - /// - public double GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); - - /// - /// Get LinearDensity in GramsPerMeter. - /// - public double GramsPerMeter => As(LinearDensityUnit.GramPerMeter); - - /// - /// Get LinearDensity in GramsPerMillimeter. - /// - public double GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); - - /// - /// Get LinearDensity in KilogramsPerCentimeter. - /// - public double KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); - - /// - /// Get LinearDensity in KilogramsPerMeter. - /// - public double KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); - - /// - /// Get LinearDensity in KilogramsPerMillimeter. - /// - public double KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); - - /// - /// Get LinearDensity in MicrogramsPerCentimeter. - /// - public double MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); - - /// - /// Get LinearDensity in MicrogramsPerMeter. - /// - public double MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); - - /// - /// Get LinearDensity in MicrogramsPerMillimeter. - /// - public double MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); - - /// - /// Get LinearDensity in MilligramsPerCentimeter. - /// - public double MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); - - /// - /// Get LinearDensity in MilligramsPerMeter. - /// - public double MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); - - /// - /// Get LinearDensity in MilligramsPerMillimeter. - /// - public double MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); - - /// - /// Get LinearDensity in PoundsPerFoot. - /// - public double PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); - - /// - /// Get LinearDensity in PoundsPerInch. - /// - public double PoundsPerInch => As(LinearDensityUnit.PoundPerInch); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LinearDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LinearDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get LinearDensity from GramsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromGramsPerCentimeter(double gramspercentimeter) - { - double value = (double) gramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.GramPerCentimeter); - } - /// - /// Get LinearDensity from GramsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromGramsPerMeter(double gramspermeter) - { - double value = (double) gramspermeter; - return new LinearDensity(value, LinearDensityUnit.GramPerMeter); - } - /// - /// Get LinearDensity from GramsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromGramsPerMillimeter(double gramspermillimeter) - { - double value = (double) gramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.GramPerMillimeter); - } - /// - /// Get LinearDensity from KilogramsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromKilogramsPerCentimeter(double kilogramspercentimeter) - { - double value = (double) kilogramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.KilogramPerCentimeter); - } - /// - /// Get LinearDensity from KilogramsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromKilogramsPerMeter(double kilogramspermeter) - { - double value = (double) kilogramspermeter; - return new LinearDensity(value, LinearDensityUnit.KilogramPerMeter); - } - /// - /// Get LinearDensity from KilogramsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromKilogramsPerMillimeter(double kilogramspermillimeter) - { - double value = (double) kilogramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.KilogramPerMillimeter); - } - /// - /// Get LinearDensity from MicrogramsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromMicrogramsPerCentimeter(double microgramspercentimeter) - { - double value = (double) microgramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.MicrogramPerCentimeter); - } - /// - /// Get LinearDensity from MicrogramsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromMicrogramsPerMeter(double microgramspermeter) - { - double value = (double) microgramspermeter; - return new LinearDensity(value, LinearDensityUnit.MicrogramPerMeter); - } - /// - /// Get LinearDensity from MicrogramsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromMicrogramsPerMillimeter(double microgramspermillimeter) - { - double value = (double) microgramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.MicrogramPerMillimeter); - } - /// - /// Get LinearDensity from MilligramsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromMilligramsPerCentimeter(double milligramspercentimeter) - { - double value = (double) milligramspercentimeter; - return new LinearDensity(value, LinearDensityUnit.MilligramPerCentimeter); - } - /// - /// Get LinearDensity from MilligramsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromMilligramsPerMeter(double milligramspermeter) - { - double value = (double) milligramspermeter; - return new LinearDensity(value, LinearDensityUnit.MilligramPerMeter); - } - /// - /// Get LinearDensity from MilligramsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromMilligramsPerMillimeter(double milligramspermillimeter) - { - double value = (double) milligramspermillimeter; - return new LinearDensity(value, LinearDensityUnit.MilligramPerMillimeter); - } - /// - /// Get LinearDensity from PoundsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromPoundsPerFoot(double poundsperfoot) - { - double value = (double) poundsperfoot; - return new LinearDensity(value, LinearDensityUnit.PoundPerFoot); - } - /// - /// Get LinearDensity from PoundsPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearDensity FromPoundsPerInch(double poundsperinch) - { - double value = (double) poundsperinch; - return new LinearDensity(value, LinearDensityUnit.PoundPerInch); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// LinearDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static LinearDensity From(double value, LinearDensityUnit fromUnit) - { - return new LinearDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static LinearDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LinearDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out LinearDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out LinearDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LinearDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LinearDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LinearDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LinearDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LinearDensity objLinearDensity)) throw new ArgumentException("Expected type LinearDensity.", nameof(obj)); - - return CompareTo(objLinearDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(LinearDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is LinearDensity objLinearDensity)) - return false; - - return Equals(objLinearDensity); - } - - public bool Equals(LinearDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another LinearDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current LinearDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LinearDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LinearDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this LinearDensity to another LinearDensity with the unit representation . - /// - /// A LinearDensity with the specified unit. - public LinearDensity ToUnit(LinearDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new LinearDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(LinearDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearPowerDensity.g.cs deleted file mode 100644 index 3bfbb20af2..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ /dev/null @@ -1,991 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The Linear Power Density of a substance is its power per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension. - /// - /// - /// http://en.wikipedia.org/wiki/Linear_density - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class LinearPowerDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LinearPowerDensityUnit? _unit; - - static LinearPowerDensity() - { - BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.LinearPowerDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit WattPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public LinearPowerDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private LinearPowerDensity(double value, LinearPowerDensityUnit unit) - { - if(unit == LinearPowerDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of LinearPowerDensity, which is WattPerMeter. All conversions go via this value. - /// - public static LinearPowerDensityUnit BaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; - - /// - /// Represents the largest possible value of LinearPowerDensity - /// - public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of LinearPowerDensity - /// - public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.LinearPowerDensity; - - /// - /// All units of measurement for the LinearPowerDensity quantity. - /// - public static LinearPowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast().Except(new LinearPowerDensityUnit[]{ LinearPowerDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeter. - /// - public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LinearPowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => LinearPowerDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => LinearPowerDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get LinearPowerDensity in GigawattsPerCentimeter. - /// - public double GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); - - /// - /// Get LinearPowerDensity in GigawattsPerFoot. - /// - public double GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); - - /// - /// Get LinearPowerDensity in GigawattsPerInch. - /// - public double GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); - - /// - /// Get LinearPowerDensity in GigawattsPerMeter. - /// - public double GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); - - /// - /// Get LinearPowerDensity in GigawattsPerMillimeter. - /// - public double GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); - - /// - /// Get LinearPowerDensity in KilowattsPerCentimeter. - /// - public double KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); - - /// - /// Get LinearPowerDensity in KilowattsPerFoot. - /// - public double KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); - - /// - /// Get LinearPowerDensity in KilowattsPerInch. - /// - public double KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); - - /// - /// Get LinearPowerDensity in KilowattsPerMeter. - /// - public double KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); - - /// - /// Get LinearPowerDensity in KilowattsPerMillimeter. - /// - public double KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); - - /// - /// Get LinearPowerDensity in MegawattsPerCentimeter. - /// - public double MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); - - /// - /// Get LinearPowerDensity in MegawattsPerFoot. - /// - public double MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); - - /// - /// Get LinearPowerDensity in MegawattsPerInch. - /// - public double MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); - - /// - /// Get LinearPowerDensity in MegawattsPerMeter. - /// - public double MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); - - /// - /// Get LinearPowerDensity in MegawattsPerMillimeter. - /// - public double MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); - - /// - /// Get LinearPowerDensity in MilliwattsPerCentimeter. - /// - public double MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); - - /// - /// Get LinearPowerDensity in MilliwattsPerFoot. - /// - public double MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); - - /// - /// Get LinearPowerDensity in MilliwattsPerInch. - /// - public double MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); - - /// - /// Get LinearPowerDensity in MilliwattsPerMeter. - /// - public double MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); - - /// - /// Get LinearPowerDensity in MilliwattsPerMillimeter. - /// - public double MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); - - /// - /// Get LinearPowerDensity in WattsPerCentimeter. - /// - public double WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); - - /// - /// Get LinearPowerDensity in WattsPerFoot. - /// - public double WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); - - /// - /// Get LinearPowerDensity in WattsPerInch. - /// - public double WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); - - /// - /// Get LinearPowerDensity in WattsPerMeter. - /// - public double WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); - - /// - /// Get LinearPowerDensity in WattsPerMillimeter. - /// - public double WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LinearPowerDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LinearPowerDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get LinearPowerDensity from GigawattsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromGigawattsPerCentimeter(double gigawattspercentimeter) - { - double value = (double) gigawattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerCentimeter); - } - /// - /// Get LinearPowerDensity from GigawattsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromGigawattsPerFoot(double gigawattsperfoot) - { - double value = (double) gigawattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerFoot); - } - /// - /// Get LinearPowerDensity from GigawattsPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromGigawattsPerInch(double gigawattsperinch) - { - double value = (double) gigawattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerInch); - } - /// - /// Get LinearPowerDensity from GigawattsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromGigawattsPerMeter(double gigawattspermeter) - { - double value = (double) gigawattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMeter); - } - /// - /// Get LinearPowerDensity from GigawattsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromGigawattsPerMillimeter(double gigawattspermillimeter) - { - double value = (double) gigawattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMillimeter); - } - /// - /// Get LinearPowerDensity from KilowattsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromKilowattsPerCentimeter(double kilowattspercentimeter) - { - double value = (double) kilowattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerCentimeter); - } - /// - /// Get LinearPowerDensity from KilowattsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromKilowattsPerFoot(double kilowattsperfoot) - { - double value = (double) kilowattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerFoot); - } - /// - /// Get LinearPowerDensity from KilowattsPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromKilowattsPerInch(double kilowattsperinch) - { - double value = (double) kilowattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerInch); - } - /// - /// Get LinearPowerDensity from KilowattsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromKilowattsPerMeter(double kilowattspermeter) - { - double value = (double) kilowattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMeter); - } - /// - /// Get LinearPowerDensity from KilowattsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromKilowattsPerMillimeter(double kilowattspermillimeter) - { - double value = (double) kilowattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMillimeter); - } - /// - /// Get LinearPowerDensity from MegawattsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMegawattsPerCentimeter(double megawattspercentimeter) - { - double value = (double) megawattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerCentimeter); - } - /// - /// Get LinearPowerDensity from MegawattsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMegawattsPerFoot(double megawattsperfoot) - { - double value = (double) megawattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerFoot); - } - /// - /// Get LinearPowerDensity from MegawattsPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMegawattsPerInch(double megawattsperinch) - { - double value = (double) megawattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerInch); - } - /// - /// Get LinearPowerDensity from MegawattsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMegawattsPerMeter(double megawattspermeter) - { - double value = (double) megawattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMeter); - } - /// - /// Get LinearPowerDensity from MegawattsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMegawattsPerMillimeter(double megawattspermillimeter) - { - double value = (double) megawattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMillimeter); - } - /// - /// Get LinearPowerDensity from MilliwattsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMilliwattsPerCentimeter(double milliwattspercentimeter) - { - double value = (double) milliwattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerCentimeter); - } - /// - /// Get LinearPowerDensity from MilliwattsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMilliwattsPerFoot(double milliwattsperfoot) - { - double value = (double) milliwattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerFoot); - } - /// - /// Get LinearPowerDensity from MilliwattsPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMilliwattsPerInch(double milliwattsperinch) - { - double value = (double) milliwattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerInch); - } - /// - /// Get LinearPowerDensity from MilliwattsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMilliwattsPerMeter(double milliwattspermeter) - { - double value = (double) milliwattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMeter); - } - /// - /// Get LinearPowerDensity from MilliwattsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromMilliwattsPerMillimeter(double milliwattspermillimeter) - { - double value = (double) milliwattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMillimeter); - } - /// - /// Get LinearPowerDensity from WattsPerCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromWattsPerCentimeter(double wattspercentimeter) - { - double value = (double) wattspercentimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerCentimeter); - } - /// - /// Get LinearPowerDensity from WattsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromWattsPerFoot(double wattsperfoot) - { - double value = (double) wattsperfoot; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerFoot); - } - /// - /// Get LinearPowerDensity from WattsPerInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromWattsPerInch(double wattsperinch) - { - double value = (double) wattsperinch; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerInch); - } - /// - /// Get LinearPowerDensity from WattsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromWattsPerMeter(double wattspermeter) - { - double value = (double) wattspermeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMeter); - } - /// - /// Get LinearPowerDensity from WattsPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LinearPowerDensity FromWattsPerMillimeter(double wattspermillimeter) - { - double value = (double) wattspermillimeter; - return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// LinearPowerDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static LinearPowerDensity From(double value, LinearPowerDensityUnit fromUnit) - { - return new LinearPowerDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static LinearPowerDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LinearPowerDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out LinearPowerDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out LinearPowerDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LinearPowerDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LinearPowerDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LinearPowerDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LinearPowerDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LinearPowerDensity objLinearPowerDensity)) throw new ArgumentException("Expected type LinearPowerDensity.", nameof(obj)); - - return CompareTo(objLinearPowerDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(LinearPowerDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) - return false; - - return Equals(objLinearPowerDensity); - } - - public bool Equals(LinearPowerDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another LinearPowerDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current LinearPowerDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LinearPowerDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LinearPowerDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this LinearPowerDensity to another LinearPowerDensity with the unit representation . - /// - /// A LinearPowerDensity with the specified unit. - public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new LinearPowerDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(LinearPowerDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Luminosity.g.cs deleted file mode 100644 index 7ee56e2f39..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Luminosity.g.cs +++ /dev/null @@ -1,804 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object. - /// - /// - /// https://en.wikipedia.org/wiki/Luminosity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Luminosity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LuminosityUnit? _unit; - - static Luminosity() - { - BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Luminosity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Watt. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Luminosity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Luminosity(double value, LuminosityUnit unit) - { - if(unit == LuminosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Luminosity, which is Watt. All conversions go via this value. - /// - public static LuminosityUnit BaseUnit { get; } = LuminosityUnit.Watt; - - /// - /// Represents the largest possible value of Luminosity - /// - public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Luminosity - /// - public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Luminosity; - - /// - /// All units of measurement for the Luminosity quantity. - /// - public static LuminosityUnit[] Units { get; } = Enum.GetValues(typeof(LuminosityUnit)).Cast().Except(new LuminosityUnit[]{ LuminosityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Watt. - /// - public static Luminosity Zero { get; } = new Luminosity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LuminosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Luminosity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Luminosity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Luminosity in Decawatts. - /// - public double Decawatts => As(LuminosityUnit.Decawatt); - - /// - /// Get Luminosity in Deciwatts. - /// - public double Deciwatts => As(LuminosityUnit.Deciwatt); - - /// - /// Get Luminosity in Femtowatts. - /// - public double Femtowatts => As(LuminosityUnit.Femtowatt); - - /// - /// Get Luminosity in Gigawatts. - /// - public double Gigawatts => As(LuminosityUnit.Gigawatt); - - /// - /// Get Luminosity in Kilowatts. - /// - public double Kilowatts => As(LuminosityUnit.Kilowatt); - - /// - /// Get Luminosity in Megawatts. - /// - public double Megawatts => As(LuminosityUnit.Megawatt); - - /// - /// Get Luminosity in Microwatts. - /// - public double Microwatts => As(LuminosityUnit.Microwatt); - - /// - /// Get Luminosity in Milliwatts. - /// - public double Milliwatts => As(LuminosityUnit.Milliwatt); - - /// - /// Get Luminosity in Nanowatts. - /// - public double Nanowatts => As(LuminosityUnit.Nanowatt); - - /// - /// Get Luminosity in Petawatts. - /// - public double Petawatts => As(LuminosityUnit.Petawatt); - - /// - /// Get Luminosity in Picowatts. - /// - public double Picowatts => As(LuminosityUnit.Picowatt); - - /// - /// Get Luminosity in SolarLuminosities. - /// - public double SolarLuminosities => As(LuminosityUnit.SolarLuminosity); - - /// - /// Get Luminosity in Terawatts. - /// - public double Terawatts => As(LuminosityUnit.Terawatt); - - /// - /// Get Luminosity in Watts. - /// - public double Watts => As(LuminosityUnit.Watt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LuminosityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LuminosityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Luminosity from Decawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromDecawatts(double decawatts) - { - double value = (double) decawatts; - return new Luminosity(value, LuminosityUnit.Decawatt); - } - /// - /// Get Luminosity from Deciwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromDeciwatts(double deciwatts) - { - double value = (double) deciwatts; - return new Luminosity(value, LuminosityUnit.Deciwatt); - } - /// - /// Get Luminosity from Femtowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromFemtowatts(double femtowatts) - { - double value = (double) femtowatts; - return new Luminosity(value, LuminosityUnit.Femtowatt); - } - /// - /// Get Luminosity from Gigawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromGigawatts(double gigawatts) - { - double value = (double) gigawatts; - return new Luminosity(value, LuminosityUnit.Gigawatt); - } - /// - /// Get Luminosity from Kilowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromKilowatts(double kilowatts) - { - double value = (double) kilowatts; - return new Luminosity(value, LuminosityUnit.Kilowatt); - } - /// - /// Get Luminosity from Megawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromMegawatts(double megawatts) - { - double value = (double) megawatts; - return new Luminosity(value, LuminosityUnit.Megawatt); - } - /// - /// Get Luminosity from Microwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromMicrowatts(double microwatts) - { - double value = (double) microwatts; - return new Luminosity(value, LuminosityUnit.Microwatt); - } - /// - /// Get Luminosity from Milliwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromMilliwatts(double milliwatts) - { - double value = (double) milliwatts; - return new Luminosity(value, LuminosityUnit.Milliwatt); - } - /// - /// Get Luminosity from Nanowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromNanowatts(double nanowatts) - { - double value = (double) nanowatts; - return new Luminosity(value, LuminosityUnit.Nanowatt); - } - /// - /// Get Luminosity from Petawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromPetawatts(double petawatts) - { - double value = (double) petawatts; - return new Luminosity(value, LuminosityUnit.Petawatt); - } - /// - /// Get Luminosity from Picowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromPicowatts(double picowatts) - { - double value = (double) picowatts; - return new Luminosity(value, LuminosityUnit.Picowatt); - } - /// - /// Get Luminosity from SolarLuminosities. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromSolarLuminosities(double solarluminosities) - { - double value = (double) solarluminosities; - return new Luminosity(value, LuminosityUnit.SolarLuminosity); - } - /// - /// Get Luminosity from Terawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromTerawatts(double terawatts) - { - double value = (double) terawatts; - return new Luminosity(value, LuminosityUnit.Terawatt); - } - /// - /// Get Luminosity from Watts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Luminosity FromWatts(double watts) - { - double value = (double) watts; - return new Luminosity(value, LuminosityUnit.Watt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Luminosity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Luminosity From(double value, LuminosityUnit fromUnit) - { - return new Luminosity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Luminosity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Luminosity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Luminosity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Luminosity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LuminosityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LuminosityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LuminosityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LuminosityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Luminosity objLuminosity)) throw new ArgumentException("Expected type Luminosity.", nameof(obj)); - - return CompareTo(objLuminosity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Luminosity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Luminosity objLuminosity)) - return false; - - return Equals(objLuminosity); - } - - public bool Equals(Luminosity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Luminosity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Luminosity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Luminosity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LuminosityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LuminosityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Luminosity to another Luminosity with the unit representation . - /// - /// A Luminosity with the specified unit. - public Luminosity ToUnit(LuminosityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Luminosity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(LuminosityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.g.cs deleted file mode 100644 index c197dc10fd..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousFlux.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In photometry, luminous flux or luminous power is the measure of the perceived power of light. - /// - /// - /// https://en.wikipedia.org/wiki/Luminous_flux - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class LuminousFlux : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LuminousFluxUnit? _unit; - - static LuminousFlux() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); - Info = new QuantityInfo(QuantityType.LuminousFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Lumen. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public LuminousFlux() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private LuminousFlux(double value, LuminousFluxUnit unit) - { - if(unit == LuminousFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of LuminousFlux, which is Lumen. All conversions go via this value. - /// - public static LuminousFluxUnit BaseUnit { get; } = LuminousFluxUnit.Lumen; - - /// - /// Represents the largest possible value of LuminousFlux - /// - public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of LuminousFlux - /// - public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.LuminousFlux; - - /// - /// All units of measurement for the LuminousFlux quantity. - /// - public static LuminousFluxUnit[] Units { get; } = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().Except(new LuminousFluxUnit[]{ LuminousFluxUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Lumen. - /// - public static LuminousFlux Zero { get; } = new LuminousFlux(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LuminousFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => LuminousFlux.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => LuminousFlux.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get LuminousFlux in Lumens. - /// - public double Lumens => As(LuminousFluxUnit.Lumen); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LuminousFluxUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LuminousFluxUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get LuminousFlux from Lumens. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LuminousFlux FromLumens(double lumens) - { - double value = (double) lumens; - return new LuminousFlux(value, LuminousFluxUnit.Lumen); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// LuminousFlux unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static LuminousFlux From(double value, LuminousFluxUnit fromUnit) - { - return new LuminousFlux((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static LuminousFlux Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LuminousFlux Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out LuminousFlux result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out LuminousFlux result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LuminousFluxUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LuminousFluxUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LuminousFluxUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LuminousFluxUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LuminousFlux objLuminousFlux)) throw new ArgumentException("Expected type LuminousFlux.", nameof(obj)); - - return CompareTo(objLuminousFlux); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(LuminousFlux other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is LuminousFlux objLuminousFlux)) - return false; - - return Equals(objLuminousFlux); - } - - public bool Equals(LuminousFlux other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another LuminousFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current LuminousFlux. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LuminousFluxUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LuminousFluxUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this LuminousFlux to another LuminousFlux with the unit representation . - /// - /// A LuminousFlux with the specified unit. - public LuminousFlux ToUnit(LuminousFluxUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new LuminousFlux(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case LuminousFluxUnit.Lumen: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(LuminousFluxUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case LuminousFluxUnit.Lumen: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.g.cs deleted file mode 100644 index 143e64a04a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In photometry, luminous intensity is a measure of the wavelength-weighted power emitted by a light source in a particular direction per unit solid angle, based on the luminosity function, a standardized model of the sensitivity of the human eye. - /// - /// - /// https://en.wikipedia.org/wiki/Luminous_intensity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class LuminousIntensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly LuminousIntensityUnit? _unit; - - static LuminousIntensity() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); - Info = new QuantityInfo(QuantityType.LuminousIntensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Candela. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public LuminousIntensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private LuminousIntensity(double value, LuminousIntensityUnit unit) - { - if(unit == LuminousIntensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of LuminousIntensity, which is Candela. All conversions go via this value. - /// - public static LuminousIntensityUnit BaseUnit { get; } = LuminousIntensityUnit.Candela; - - /// - /// Represents the largest possible value of LuminousIntensity - /// - public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of LuminousIntensity - /// - public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.LuminousIntensity; - - /// - /// All units of measurement for the LuminousIntensity quantity. - /// - public static LuminousIntensityUnit[] Units { get; } = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().Except(new LuminousIntensityUnit[]{ LuminousIntensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Candela. - /// - public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public LuminousIntensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => LuminousIntensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => LuminousIntensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get LuminousIntensity in Candela. - /// - public double Candela => As(LuminousIntensityUnit.Candela); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(LuminousIntensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(LuminousIntensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get LuminousIntensity from Candela. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static LuminousIntensity FromCandela(double candela) - { - double value = (double) candela; - return new LuminousIntensity(value, LuminousIntensityUnit.Candela); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// LuminousIntensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static LuminousIntensity From(double value, LuminousIntensityUnit fromUnit) - { - return new LuminousIntensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static LuminousIntensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LuminousIntensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out LuminousIntensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out LuminousIntensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static LuminousIntensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static LuminousIntensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out LuminousIntensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out LuminousIntensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is LuminousIntensity objLuminousIntensity)) throw new ArgumentException("Expected type LuminousIntensity.", nameof(obj)); - - return CompareTo(objLuminousIntensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(LuminousIntensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is LuminousIntensity objLuminousIntensity)) - return false; - - return Equals(objLuminousIntensity); - } - - public bool Equals(LuminousIntensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another LuminousIntensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current LuminousIntensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((LuminousIntensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(LuminousIntensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this LuminousIntensity to another LuminousIntensity with the unit representation . - /// - /// A LuminousIntensity with the specified unit. - public LuminousIntensity ToUnit(LuminousIntensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new LuminousIntensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case LuminousIntensityUnit.Candela: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(LuminousIntensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case LuminousIntensityUnit.Candela: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.g.cs deleted file mode 100644 index a7777d5c1a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticField.g.cs +++ /dev/null @@ -1,668 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A magnetic field is a force field that is created by moving electric charges (electric currents) and magnetic dipoles, and exerts a force on other nearby moving charges and magnetic dipoles. - /// - /// - /// https://en.wikipedia.org/wiki/Magnetic_field - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MagneticField : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MagneticFieldUnit? _unit; - - static MagneticField() - { - BaseDimensions = new BaseDimensions(0, 1, -2, -1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MagneticField, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Tesla. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MagneticField() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MagneticField(double value, MagneticFieldUnit unit) - { - if(unit == MagneticFieldUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MagneticField, which is Tesla. All conversions go via this value. - /// - public static MagneticFieldUnit BaseUnit { get; } = MagneticFieldUnit.Tesla; - - /// - /// Represents the largest possible value of MagneticField - /// - public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MagneticField - /// - public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MagneticField; - - /// - /// All units of measurement for the MagneticField quantity. - /// - public static MagneticFieldUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().Except(new MagneticFieldUnit[]{ MagneticFieldUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Tesla. - /// - public static MagneticField Zero { get; } = new MagneticField(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MagneticFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MagneticField.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MagneticField.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MagneticField in Gausses. - /// - public double Gausses => As(MagneticFieldUnit.Gauss); - - /// - /// Get MagneticField in Microteslas. - /// - public double Microteslas => As(MagneticFieldUnit.Microtesla); - - /// - /// Get MagneticField in Milligausses. - /// - public double Milligausses => As(MagneticFieldUnit.Milligauss); - - /// - /// Get MagneticField in Milliteslas. - /// - public double Milliteslas => As(MagneticFieldUnit.Millitesla); - - /// - /// Get MagneticField in Nanoteslas. - /// - public double Nanoteslas => As(MagneticFieldUnit.Nanotesla); - - /// - /// Get MagneticField in Teslas. - /// - public double Teslas => As(MagneticFieldUnit.Tesla); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MagneticFieldUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MagneticFieldUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MagneticField from Gausses. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticField FromGausses(double gausses) - { - double value = (double) gausses; - return new MagneticField(value, MagneticFieldUnit.Gauss); - } - /// - /// Get MagneticField from Microteslas. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticField FromMicroteslas(double microteslas) - { - double value = (double) microteslas; - return new MagneticField(value, MagneticFieldUnit.Microtesla); - } - /// - /// Get MagneticField from Milligausses. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticField FromMilligausses(double milligausses) - { - double value = (double) milligausses; - return new MagneticField(value, MagneticFieldUnit.Milligauss); - } - /// - /// Get MagneticField from Milliteslas. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticField FromMilliteslas(double milliteslas) - { - double value = (double) milliteslas; - return new MagneticField(value, MagneticFieldUnit.Millitesla); - } - /// - /// Get MagneticField from Nanoteslas. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticField FromNanoteslas(double nanoteslas) - { - double value = (double) nanoteslas; - return new MagneticField(value, MagneticFieldUnit.Nanotesla); - } - /// - /// Get MagneticField from Teslas. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticField FromTeslas(double teslas) - { - double value = (double) teslas; - return new MagneticField(value, MagneticFieldUnit.Tesla); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MagneticField unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MagneticField From(double value, MagneticFieldUnit fromUnit) - { - return new MagneticField((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MagneticField Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MagneticField Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MagneticField result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MagneticField result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MagneticFieldUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MagneticFieldUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MagneticFieldUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MagneticFieldUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MagneticField objMagneticField)) throw new ArgumentException("Expected type MagneticField.", nameof(obj)); - - return CompareTo(objMagneticField); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MagneticField other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MagneticField objMagneticField)) - return false; - - return Equals(objMagneticField); - } - - public bool Equals(MagneticField other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MagneticField within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MagneticField. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MagneticFieldUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MagneticFieldUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MagneticField to another MagneticField with the unit representation . - /// - /// A MagneticField with the specified unit. - public MagneticField ToUnit(MagneticFieldUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MagneticField(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MagneticFieldUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.g.cs deleted file mode 100644 index ebce2331a4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MagneticFlux.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In physics, specifically electromagnetism, the magnetic flux through a surface is the surface integral of the normal component of the magnetic field B passing through that surface. - /// - /// - /// https://en.wikipedia.org/wiki/Magnetic_flux - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MagneticFlux : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MagneticFluxUnit? _unit; - - static MagneticFlux() - { - BaseDimensions = new BaseDimensions(2, 1, -2, -1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MagneticFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Weber. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MagneticFlux() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MagneticFlux(double value, MagneticFluxUnit unit) - { - if(unit == MagneticFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MagneticFlux, which is Weber. All conversions go via this value. - /// - public static MagneticFluxUnit BaseUnit { get; } = MagneticFluxUnit.Weber; - - /// - /// Represents the largest possible value of MagneticFlux - /// - public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MagneticFlux - /// - public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MagneticFlux; - - /// - /// All units of measurement for the MagneticFlux quantity. - /// - public static MagneticFluxUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().Except(new MagneticFluxUnit[]{ MagneticFluxUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Weber. - /// - public static MagneticFlux Zero { get; } = new MagneticFlux(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MagneticFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MagneticFlux.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MagneticFlux.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MagneticFlux in Webers. - /// - public double Webers => As(MagneticFluxUnit.Weber); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MagneticFluxUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MagneticFluxUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MagneticFlux from Webers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MagneticFlux FromWebers(double webers) - { - double value = (double) webers; - return new MagneticFlux(value, MagneticFluxUnit.Weber); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MagneticFlux unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MagneticFlux From(double value, MagneticFluxUnit fromUnit) - { - return new MagneticFlux((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MagneticFlux Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MagneticFlux Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MagneticFlux result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MagneticFlux result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MagneticFluxUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MagneticFluxUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MagneticFluxUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MagneticFluxUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MagneticFlux objMagneticFlux)) throw new ArgumentException("Expected type MagneticFlux.", nameof(obj)); - - return CompareTo(objMagneticFlux); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MagneticFlux other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MagneticFlux objMagneticFlux)) - return false; - - return Equals(objMagneticFlux); - } - - public bool Equals(MagneticFlux other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MagneticFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MagneticFlux. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MagneticFluxUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MagneticFluxUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MagneticFlux to another MagneticFlux with the unit representation . - /// - /// A MagneticFlux with the specified unit. - public MagneticFlux ToUnit(MagneticFluxUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MagneticFlux(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case MagneticFluxUnit.Weber: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(MagneticFluxUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case MagneticFluxUnit.Weber: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.g.cs deleted file mode 100644 index b0b66874e3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Magnetization.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In classical electromagnetism, magnetization is the vector field that expresses the density of permanent or induced magnetic dipole moments in a magnetic material. - /// - /// - /// https://en.wikipedia.org/wiki/Magnetization - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Magnetization : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MagnetizationUnit? _unit; - - static Magnetization() - { - BaseDimensions = new BaseDimensions(-1, 0, 0, 1, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Magnetization, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit AmperePerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Magnetization() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Magnetization(double value, MagnetizationUnit unit) - { - if(unit == MagnetizationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Magnetization, which is AmperePerMeter. All conversions go via this value. - /// - public static MagnetizationUnit BaseUnit { get; } = MagnetizationUnit.AmperePerMeter; - - /// - /// Represents the largest possible value of Magnetization - /// - public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Magnetization - /// - public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Magnetization; - - /// - /// All units of measurement for the Magnetization quantity. - /// - public static MagnetizationUnit[] Units { get; } = Enum.GetValues(typeof(MagnetizationUnit)).Cast().Except(new MagnetizationUnit[]{ MagnetizationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerMeter. - /// - public static Magnetization Zero { get; } = new Magnetization(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MagnetizationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Magnetization.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Magnetization.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Magnetization in AmperesPerMeter. - /// - public double AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MagnetizationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MagnetizationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Magnetization from AmperesPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Magnetization FromAmperesPerMeter(double amperespermeter) - { - double value = (double) amperespermeter; - return new Magnetization(value, MagnetizationUnit.AmperePerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Magnetization unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Magnetization From(double value, MagnetizationUnit fromUnit) - { - return new Magnetization((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Magnetization Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Magnetization Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Magnetization result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Magnetization result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MagnetizationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MagnetizationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MagnetizationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MagnetizationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Magnetization objMagnetization)) throw new ArgumentException("Expected type Magnetization.", nameof(obj)); - - return CompareTo(objMagnetization); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Magnetization other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Magnetization objMagnetization)) - return false; - - return Equals(objMagnetization); - } - - public bool Equals(Magnetization other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Magnetization within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Magnetization. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MagnetizationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MagnetizationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Magnetization to another Magnetization with the unit representation . - /// - /// A Magnetization with the specified unit. - public Magnetization ToUnit(MagnetizationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Magnetization(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case MagnetizationUnit.AmperePerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(MagnetizationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case MagnetizationUnit.AmperePerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.g.cs deleted file mode 100644 index 5e49ff77b0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Mass.g.cs +++ /dev/null @@ -1,988 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Mass : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MassUnit? _unit; - - static Mass() - { - BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Mass, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Kilogram. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Mass() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Mass(double value, MassUnit unit) - { - if(unit == MassUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Mass, which is Kilogram. All conversions go via this value. - /// - public static MassUnit BaseUnit { get; } = MassUnit.Kilogram; - - /// - /// Represents the largest possible value of Mass - /// - public static Mass MaxValue { get; } = new Mass(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Mass - /// - public static Mass MinValue { get; } = new Mass(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Mass; - - /// - /// All units of measurement for the Mass quantity. - /// - public static MassUnit[] Units { get; } = Enum.GetValues(typeof(MassUnit)).Cast().Except(new MassUnit[]{ MassUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Kilogram. - /// - public static Mass Zero { get; } = new Mass(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MassUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Mass.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Mass.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Mass in Centigrams. - /// - public double Centigrams => As(MassUnit.Centigram); - - /// - /// Get Mass in Decagrams. - /// - public double Decagrams => As(MassUnit.Decagram); - - /// - /// Get Mass in Decigrams. - /// - public double Decigrams => As(MassUnit.Decigram); - - /// - /// Get Mass in EarthMasses. - /// - public double EarthMasses => As(MassUnit.EarthMass); - - /// - /// Get Mass in Grains. - /// - public double Grains => As(MassUnit.Grain); - - /// - /// Get Mass in Grams. - /// - public double Grams => As(MassUnit.Gram); - - /// - /// Get Mass in Hectograms. - /// - public double Hectograms => As(MassUnit.Hectogram); - - /// - /// Get Mass in Kilograms. - /// - public double Kilograms => As(MassUnit.Kilogram); - - /// - /// Get Mass in Kilopounds. - /// - public double Kilopounds => As(MassUnit.Kilopound); - - /// - /// Get Mass in Kilotonnes. - /// - public double Kilotonnes => As(MassUnit.Kilotonne); - - /// - /// Get Mass in LongHundredweight. - /// - public double LongHundredweight => As(MassUnit.LongHundredweight); - - /// - /// Get Mass in LongTons. - /// - public double LongTons => As(MassUnit.LongTon); - - /// - /// Get Mass in Megapounds. - /// - public double Megapounds => As(MassUnit.Megapound); - - /// - /// Get Mass in Megatonnes. - /// - public double Megatonnes => As(MassUnit.Megatonne); - - /// - /// Get Mass in Micrograms. - /// - public double Micrograms => As(MassUnit.Microgram); - - /// - /// Get Mass in Milligrams. - /// - public double Milligrams => As(MassUnit.Milligram); - - /// - /// Get Mass in Nanograms. - /// - public double Nanograms => As(MassUnit.Nanogram); - - /// - /// Get Mass in Ounces. - /// - public double Ounces => As(MassUnit.Ounce); - - /// - /// Get Mass in Pounds. - /// - public double Pounds => As(MassUnit.Pound); - - /// - /// Get Mass in ShortHundredweight. - /// - public double ShortHundredweight => As(MassUnit.ShortHundredweight); - - /// - /// Get Mass in ShortTons. - /// - public double ShortTons => As(MassUnit.ShortTon); - - /// - /// Get Mass in Slugs. - /// - public double Slugs => As(MassUnit.Slug); - - /// - /// Get Mass in SolarMasses. - /// - public double SolarMasses => As(MassUnit.SolarMass); - - /// - /// Get Mass in Stone. - /// - public double Stone => As(MassUnit.Stone); - - /// - /// Get Mass in Tonnes. - /// - public double Tonnes => As(MassUnit.Tonne); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MassUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MassUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Mass from Centigrams. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromCentigrams(double centigrams) - { - double value = (double) centigrams; - return new Mass(value, MassUnit.Centigram); - } - /// - /// Get Mass from Decagrams. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromDecagrams(double decagrams) - { - double value = (double) decagrams; - return new Mass(value, MassUnit.Decagram); - } - /// - /// Get Mass from Decigrams. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromDecigrams(double decigrams) - { - double value = (double) decigrams; - return new Mass(value, MassUnit.Decigram); - } - /// - /// Get Mass from EarthMasses. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromEarthMasses(double earthmasses) - { - double value = (double) earthmasses; - return new Mass(value, MassUnit.EarthMass); - } - /// - /// Get Mass from Grains. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromGrains(double grains) - { - double value = (double) grains; - return new Mass(value, MassUnit.Grain); - } - /// - /// Get Mass from Grams. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromGrams(double grams) - { - double value = (double) grams; - return new Mass(value, MassUnit.Gram); - } - /// - /// Get Mass from Hectograms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromHectograms(double hectograms) - { - double value = (double) hectograms; - return new Mass(value, MassUnit.Hectogram); - } - /// - /// Get Mass from Kilograms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromKilograms(double kilograms) - { - double value = (double) kilograms; - return new Mass(value, MassUnit.Kilogram); - } - /// - /// Get Mass from Kilopounds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromKilopounds(double kilopounds) - { - double value = (double) kilopounds; - return new Mass(value, MassUnit.Kilopound); - } - /// - /// Get Mass from Kilotonnes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromKilotonnes(double kilotonnes) - { - double value = (double) kilotonnes; - return new Mass(value, MassUnit.Kilotonne); - } - /// - /// Get Mass from LongHundredweight. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromLongHundredweight(double longhundredweight) - { - double value = (double) longhundredweight; - return new Mass(value, MassUnit.LongHundredweight); - } - /// - /// Get Mass from LongTons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromLongTons(double longtons) - { - double value = (double) longtons; - return new Mass(value, MassUnit.LongTon); - } - /// - /// Get Mass from Megapounds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromMegapounds(double megapounds) - { - double value = (double) megapounds; - return new Mass(value, MassUnit.Megapound); - } - /// - /// Get Mass from Megatonnes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromMegatonnes(double megatonnes) - { - double value = (double) megatonnes; - return new Mass(value, MassUnit.Megatonne); - } - /// - /// Get Mass from Micrograms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromMicrograms(double micrograms) - { - double value = (double) micrograms; - return new Mass(value, MassUnit.Microgram); - } - /// - /// Get Mass from Milligrams. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromMilligrams(double milligrams) - { - double value = (double) milligrams; - return new Mass(value, MassUnit.Milligram); - } - /// - /// Get Mass from Nanograms. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromNanograms(double nanograms) - { - double value = (double) nanograms; - return new Mass(value, MassUnit.Nanogram); - } - /// - /// Get Mass from Ounces. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromOunces(double ounces) - { - double value = (double) ounces; - return new Mass(value, MassUnit.Ounce); - } - /// - /// Get Mass from Pounds. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromPounds(double pounds) - { - double value = (double) pounds; - return new Mass(value, MassUnit.Pound); - } - /// - /// Get Mass from ShortHundredweight. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromShortHundredweight(double shorthundredweight) - { - double value = (double) shorthundredweight; - return new Mass(value, MassUnit.ShortHundredweight); - } - /// - /// Get Mass from ShortTons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromShortTons(double shorttons) - { - double value = (double) shorttons; - return new Mass(value, MassUnit.ShortTon); - } - /// - /// Get Mass from Slugs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromSlugs(double slugs) - { - double value = (double) slugs; - return new Mass(value, MassUnit.Slug); - } - /// - /// Get Mass from SolarMasses. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromSolarMasses(double solarmasses) - { - double value = (double) solarmasses; - return new Mass(value, MassUnit.SolarMass); - } - /// - /// Get Mass from Stone. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromStone(double stone) - { - double value = (double) stone; - return new Mass(value, MassUnit.Stone); - } - /// - /// Get Mass from Tonnes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Mass FromTonnes(double tonnes) - { - double value = (double) tonnes; - return new Mass(value, MassUnit.Tonne); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Mass unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Mass From(double value, MassUnit fromUnit) - { - return new Mass((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Mass Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Mass Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Mass result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Mass result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MassUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MassUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MassUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Mass objMass)) throw new ArgumentException("Expected type Mass.", nameof(obj)); - - return CompareTo(objMass); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Mass other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Mass objMass)) - return false; - - return Equals(objMass); - } - - public bool Equals(Mass other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Mass within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Mass. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MassUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MassUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Mass to another Mass with the unit representation . - /// - /// A Mass with the specified unit. - public Mass ToUnit(MassUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Mass(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MassUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassConcentration.g.cs deleted file mode 100644 index 3dee8e60c8..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassConcentration.g.cs +++ /dev/null @@ -1,1399 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In chemistry, the mass concentration ρi (or γi) is defined as the mass of a constituent mi divided by the volume of the mixture V - /// - /// - /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MassConcentration : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MassConcentrationUnit? _unit; - - static MassConcentration() - { - BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassConcentration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerCubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MassConcentration() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MassConcentration(double value, MassConcentrationUnit unit) - { - if(unit == MassConcentrationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MassConcentration, which is KilogramPerCubicMeter. All conversions go via this value. - /// - public static MassConcentrationUnit BaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; - - /// - /// Represents the largest possible value of MassConcentration - /// - public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MassConcentration - /// - public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MassConcentration; - - /// - /// All units of measurement for the MassConcentration quantity. - /// - public static MassConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(MassConcentrationUnit)).Cast().Except(new MassConcentrationUnit[]{ MassConcentrationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. - /// - public static MassConcentration Zero { get; } = new MassConcentration(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MassConcentrationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MassConcentration.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MassConcentration.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MassConcentration in CentigramsPerDeciliter. - /// - public double CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); - - /// - /// Get MassConcentration in CentigramsPerLiter. - /// - public double CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); - - /// - /// Get MassConcentration in CentigramsPerMicroliter. - /// - public double CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); - - /// - /// Get MassConcentration in CentigramsPerMilliliter. - /// - public double CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); - - /// - /// Get MassConcentration in DecigramsPerDeciliter. - /// - public double DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); - - /// - /// Get MassConcentration in DecigramsPerLiter. - /// - public double DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); - - /// - /// Get MassConcentration in DecigramsPerMicroliter. - /// - public double DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); - - /// - /// Get MassConcentration in DecigramsPerMilliliter. - /// - public double DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); - - /// - /// Get MassConcentration in GramsPerCubicCentimeter. - /// - public double GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); - - /// - /// Get MassConcentration in GramsPerCubicMeter. - /// - public double GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); - - /// - /// Get MassConcentration in GramsPerCubicMillimeter. - /// - public double GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); - - /// - /// Get MassConcentration in GramsPerDeciliter. - /// - public double GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); - - /// - /// Get MassConcentration in GramsPerLiter. - /// - public double GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); - - /// - /// Get MassConcentration in GramsPerMicroliter. - /// - public double GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); - - /// - /// Get MassConcentration in GramsPerMilliliter. - /// - public double GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); - - /// - /// Get MassConcentration in KilogramsPerCubicCentimeter. - /// - public double KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); - - /// - /// Get MassConcentration in KilogramsPerCubicMeter. - /// - public double KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); - - /// - /// Get MassConcentration in KilogramsPerCubicMillimeter. - /// - public double KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); - - /// - /// Get MassConcentration in KilogramsPerLiter. - /// - public double KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); - - /// - /// Get MassConcentration in KilopoundsPerCubicFoot. - /// - public double KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); - - /// - /// Get MassConcentration in KilopoundsPerCubicInch. - /// - public double KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); - - /// - /// Get MassConcentration in MicrogramsPerCubicMeter. - /// - public double MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); - - /// - /// Get MassConcentration in MicrogramsPerDeciliter. - /// - public double MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); - - /// - /// Get MassConcentration in MicrogramsPerLiter. - /// - public double MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); - - /// - /// Get MassConcentration in MicrogramsPerMicroliter. - /// - public double MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); - - /// - /// Get MassConcentration in MicrogramsPerMilliliter. - /// - public double MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); - - /// - /// Get MassConcentration in MilligramsPerCubicMeter. - /// - public double MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); - - /// - /// Get MassConcentration in MilligramsPerDeciliter. - /// - public double MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); - - /// - /// Get MassConcentration in MilligramsPerLiter. - /// - public double MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); - - /// - /// Get MassConcentration in MilligramsPerMicroliter. - /// - public double MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); - - /// - /// Get MassConcentration in MilligramsPerMilliliter. - /// - public double MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); - - /// - /// Get MassConcentration in NanogramsPerDeciliter. - /// - public double NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); - - /// - /// Get MassConcentration in NanogramsPerLiter. - /// - public double NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); - - /// - /// Get MassConcentration in NanogramsPerMicroliter. - /// - public double NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); - - /// - /// Get MassConcentration in NanogramsPerMilliliter. - /// - public double NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); - - /// - /// Get MassConcentration in OuncesPerImperialGallon. - /// - public double OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); - - /// - /// Get MassConcentration in OuncesPerUSGallon. - /// - public double OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); - - /// - /// Get MassConcentration in PicogramsPerDeciliter. - /// - public double PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); - - /// - /// Get MassConcentration in PicogramsPerLiter. - /// - public double PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); - - /// - /// Get MassConcentration in PicogramsPerMicroliter. - /// - public double PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); - - /// - /// Get MassConcentration in PicogramsPerMilliliter. - /// - public double PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); - - /// - /// Get MassConcentration in PoundsPerCubicFoot. - /// - public double PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); - - /// - /// Get MassConcentration in PoundsPerCubicInch. - /// - public double PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); - - /// - /// Get MassConcentration in PoundsPerImperialGallon. - /// - public double PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); - - /// - /// Get MassConcentration in PoundsPerUSGallon. - /// - public double PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); - - /// - /// Get MassConcentration in SlugsPerCubicFoot. - /// - public double SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); - - /// - /// Get MassConcentration in TonnesPerCubicCentimeter. - /// - public double TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); - - /// - /// Get MassConcentration in TonnesPerCubicMeter. - /// - public double TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); - - /// - /// Get MassConcentration in TonnesPerCubicMillimeter. - /// - public double TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MassConcentrationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MassConcentrationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MassConcentration from CentigramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromCentigramsPerDeciliter(double centigramsperdeciliter) - { - double value = (double) centigramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerDeciliter); - } - /// - /// Get MassConcentration from CentigramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromCentigramsPerLiter(double centigramsperliter) - { - double value = (double) centigramsperliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerLiter); - } - /// - /// Get MassConcentration from CentigramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromCentigramsPerMicroliter(double centigramspermicroliter) - { - double value = (double) centigramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerMicroliter); - } - /// - /// Get MassConcentration from CentigramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromCentigramsPerMilliliter(double centigramspermilliliter) - { - double value = (double) centigramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.CentigramPerMilliliter); - } - /// - /// Get MassConcentration from DecigramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromDecigramsPerDeciliter(double decigramsperdeciliter) - { - double value = (double) decigramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerDeciliter); - } - /// - /// Get MassConcentration from DecigramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromDecigramsPerLiter(double decigramsperliter) - { - double value = (double) decigramsperliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerLiter); - } - /// - /// Get MassConcentration from DecigramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromDecigramsPerMicroliter(double decigramspermicroliter) - { - double value = (double) decigramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerMicroliter); - } - /// - /// Get MassConcentration from DecigramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromDecigramsPerMilliliter(double decigramspermilliliter) - { - double value = (double) decigramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.DecigramPerMilliliter); - } - /// - /// Get MassConcentration from GramsPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerCubicCentimeter(double gramspercubiccentimeter) - { - double value = (double) gramspercubiccentimeter; - return new MassConcentration(value, MassConcentrationUnit.GramPerCubicCentimeter); - } - /// - /// Get MassConcentration from GramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerCubicMeter(double gramspercubicmeter) - { - double value = (double) gramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMeter); - } - /// - /// Get MassConcentration from GramsPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerCubicMillimeter(double gramspercubicmillimeter) - { - double value = (double) gramspercubicmillimeter; - return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMillimeter); - } - /// - /// Get MassConcentration from GramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerDeciliter(double gramsperdeciliter) - { - double value = (double) gramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerDeciliter); - } - /// - /// Get MassConcentration from GramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerLiter(double gramsperliter) - { - double value = (double) gramsperliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerLiter); - } - /// - /// Get MassConcentration from GramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerMicroliter(double gramspermicroliter) - { - double value = (double) gramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerMicroliter); - } - /// - /// Get MassConcentration from GramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromGramsPerMilliliter(double gramspermilliliter) - { - double value = (double) gramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.GramPerMilliliter); - } - /// - /// Get MassConcentration from KilogramsPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromKilogramsPerCubicCentimeter(double kilogramspercubiccentimeter) - { - double value = (double) kilogramspercubiccentimeter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicCentimeter); - } - /// - /// Get MassConcentration from KilogramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromKilogramsPerCubicMeter(double kilogramspercubicmeter) - { - double value = (double) kilogramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMeter); - } - /// - /// Get MassConcentration from KilogramsPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromKilogramsPerCubicMillimeter(double kilogramspercubicmillimeter) - { - double value = (double) kilogramspercubicmillimeter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMillimeter); - } - /// - /// Get MassConcentration from KilogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromKilogramsPerLiter(double kilogramsperliter) - { - double value = (double) kilogramsperliter; - return new MassConcentration(value, MassConcentrationUnit.KilogramPerLiter); - } - /// - /// Get MassConcentration from KilopoundsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromKilopoundsPerCubicFoot(double kilopoundspercubicfoot) - { - double value = (double) kilopoundspercubicfoot; - return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicFoot); - } - /// - /// Get MassConcentration from KilopoundsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromKilopoundsPerCubicInch(double kilopoundspercubicinch) - { - double value = (double) kilopoundspercubicinch; - return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicInch); - } - /// - /// Get MassConcentration from MicrogramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMicrogramsPerCubicMeter(double microgramspercubicmeter) - { - double value = (double) microgramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerCubicMeter); - } - /// - /// Get MassConcentration from MicrogramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMicrogramsPerDeciliter(double microgramsperdeciliter) - { - double value = (double) microgramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerDeciliter); - } - /// - /// Get MassConcentration from MicrogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMicrogramsPerLiter(double microgramsperliter) - { - double value = (double) microgramsperliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerLiter); - } - /// - /// Get MassConcentration from MicrogramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMicrogramsPerMicroliter(double microgramspermicroliter) - { - double value = (double) microgramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMicroliter); - } - /// - /// Get MassConcentration from MicrogramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMicrogramsPerMilliliter(double microgramspermilliliter) - { - double value = (double) microgramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMilliliter); - } - /// - /// Get MassConcentration from MilligramsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMilligramsPerCubicMeter(double milligramspercubicmeter) - { - double value = (double) milligramspercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerCubicMeter); - } - /// - /// Get MassConcentration from MilligramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMilligramsPerDeciliter(double milligramsperdeciliter) - { - double value = (double) milligramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerDeciliter); - } - /// - /// Get MassConcentration from MilligramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMilligramsPerLiter(double milligramsperliter) - { - double value = (double) milligramsperliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerLiter); - } - /// - /// Get MassConcentration from MilligramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMilligramsPerMicroliter(double milligramspermicroliter) - { - double value = (double) milligramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerMicroliter); - } - /// - /// Get MassConcentration from MilligramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromMilligramsPerMilliliter(double milligramspermilliliter) - { - double value = (double) milligramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.MilligramPerMilliliter); - } - /// - /// Get MassConcentration from NanogramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromNanogramsPerDeciliter(double nanogramsperdeciliter) - { - double value = (double) nanogramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerDeciliter); - } - /// - /// Get MassConcentration from NanogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromNanogramsPerLiter(double nanogramsperliter) - { - double value = (double) nanogramsperliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerLiter); - } - /// - /// Get MassConcentration from NanogramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromNanogramsPerMicroliter(double nanogramspermicroliter) - { - double value = (double) nanogramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerMicroliter); - } - /// - /// Get MassConcentration from NanogramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromNanogramsPerMilliliter(double nanogramspermilliliter) - { - double value = (double) nanogramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.NanogramPerMilliliter); - } - /// - /// Get MassConcentration from OuncesPerImperialGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromOuncesPerImperialGallon(double ouncesperimperialgallon) - { - double value = (double) ouncesperimperialgallon; - return new MassConcentration(value, MassConcentrationUnit.OuncePerImperialGallon); - } - /// - /// Get MassConcentration from OuncesPerUSGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromOuncesPerUSGallon(double ouncesperusgallon) - { - double value = (double) ouncesperusgallon; - return new MassConcentration(value, MassConcentrationUnit.OuncePerUSGallon); - } - /// - /// Get MassConcentration from PicogramsPerDeciliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPicogramsPerDeciliter(double picogramsperdeciliter) - { - double value = (double) picogramsperdeciliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerDeciliter); - } - /// - /// Get MassConcentration from PicogramsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPicogramsPerLiter(double picogramsperliter) - { - double value = (double) picogramsperliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerLiter); - } - /// - /// Get MassConcentration from PicogramsPerMicroliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPicogramsPerMicroliter(double picogramspermicroliter) - { - double value = (double) picogramspermicroliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerMicroliter); - } - /// - /// Get MassConcentration from PicogramsPerMilliliter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPicogramsPerMilliliter(double picogramspermilliliter) - { - double value = (double) picogramspermilliliter; - return new MassConcentration(value, MassConcentrationUnit.PicogramPerMilliliter); - } - /// - /// Get MassConcentration from PoundsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPoundsPerCubicFoot(double poundspercubicfoot) - { - double value = (double) poundspercubicfoot; - return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicFoot); - } - /// - /// Get MassConcentration from PoundsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPoundsPerCubicInch(double poundspercubicinch) - { - double value = (double) poundspercubicinch; - return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicInch); - } - /// - /// Get MassConcentration from PoundsPerImperialGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPoundsPerImperialGallon(double poundsperimperialgallon) - { - double value = (double) poundsperimperialgallon; - return new MassConcentration(value, MassConcentrationUnit.PoundPerImperialGallon); - } - /// - /// Get MassConcentration from PoundsPerUSGallon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromPoundsPerUSGallon(double poundsperusgallon) - { - double value = (double) poundsperusgallon; - return new MassConcentration(value, MassConcentrationUnit.PoundPerUSGallon); - } - /// - /// Get MassConcentration from SlugsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromSlugsPerCubicFoot(double slugspercubicfoot) - { - double value = (double) slugspercubicfoot; - return new MassConcentration(value, MassConcentrationUnit.SlugPerCubicFoot); - } - /// - /// Get MassConcentration from TonnesPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromTonnesPerCubicCentimeter(double tonnespercubiccentimeter) - { - double value = (double) tonnespercubiccentimeter; - return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicCentimeter); - } - /// - /// Get MassConcentration from TonnesPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromTonnesPerCubicMeter(double tonnespercubicmeter) - { - double value = (double) tonnespercubicmeter; - return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMeter); - } - /// - /// Get MassConcentration from TonnesPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassConcentration FromTonnesPerCubicMillimeter(double tonnespercubicmillimeter) - { - double value = (double) tonnespercubicmillimeter; - return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MassConcentration unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MassConcentration From(double value, MassConcentrationUnit fromUnit) - { - return new MassConcentration((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MassConcentration Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassConcentration Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MassConcentration result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MassConcentration result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MassConcentrationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassConcentrationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MassConcentrationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MassConcentrationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassConcentration objMassConcentration)) throw new ArgumentException("Expected type MassConcentration.", nameof(obj)); - - return CompareTo(objMassConcentration); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MassConcentration other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassConcentration objMassConcentration)) - return false; - - return Equals(objMassConcentration); - } - - public bool Equals(MassConcentration other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MassConcentration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassConcentration other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MassConcentration. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MassConcentrationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MassConcentrationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MassConcentration to another MassConcentration with the unit representation . - /// - /// A MassConcentration with the specified unit. - public MassConcentration ToUnit(MassConcentrationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MassConcentration(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MassConcentrationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.g.cs deleted file mode 100644 index 690395d14f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlow.g.cs +++ /dev/null @@ -1,1124 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MassFlow : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MassFlowUnit? _unit; - - static MassFlow() - { - BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassFlow, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit GramPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MassFlow() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MassFlow(double value, MassFlowUnit unit) - { - if(unit == MassFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MassFlow, which is GramPerSecond. All conversions go via this value. - /// - public static MassFlowUnit BaseUnit { get; } = MassFlowUnit.GramPerSecond; - - /// - /// Represents the largest possible value of MassFlow - /// - public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MassFlow - /// - public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MassFlow; - - /// - /// All units of measurement for the MassFlow quantity. - /// - public static MassFlowUnit[] Units { get; } = Enum.GetValues(typeof(MassFlowUnit)).Cast().Except(new MassFlowUnit[]{ MassFlowUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit GramPerSecond. - /// - public static MassFlow Zero { get; } = new MassFlow(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MassFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MassFlow.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MassFlow.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MassFlow in CentigramsPerDay. - /// - public double CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); - - /// - /// Get MassFlow in CentigramsPerSecond. - /// - public double CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); - - /// - /// Get MassFlow in DecagramsPerDay. - /// - public double DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); - - /// - /// Get MassFlow in DecagramsPerSecond. - /// - public double DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); - - /// - /// Get MassFlow in DecigramsPerDay. - /// - public double DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); - - /// - /// Get MassFlow in DecigramsPerSecond. - /// - public double DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); - - /// - /// Get MassFlow in GramsPerDay. - /// - public double GramsPerDay => As(MassFlowUnit.GramPerDay); - - /// - /// Get MassFlow in GramsPerHour. - /// - public double GramsPerHour => As(MassFlowUnit.GramPerHour); - - /// - /// Get MassFlow in GramsPerSecond. - /// - public double GramsPerSecond => As(MassFlowUnit.GramPerSecond); - - /// - /// Get MassFlow in HectogramsPerDay. - /// - public double HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); - - /// - /// Get MassFlow in HectogramsPerSecond. - /// - public double HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); - - /// - /// Get MassFlow in KilogramsPerDay. - /// - public double KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); - - /// - /// Get MassFlow in KilogramsPerHour. - /// - public double KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); - - /// - /// Get MassFlow in KilogramsPerMinute. - /// - public double KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); - - /// - /// Get MassFlow in KilogramsPerSecond. - /// - public double KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); - - /// - /// Get MassFlow in MegagramsPerDay. - /// - public double MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); - - /// - /// Get MassFlow in MegapoundsPerDay. - /// - public double MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); - - /// - /// Get MassFlow in MegapoundsPerHour. - /// - public double MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); - - /// - /// Get MassFlow in MegapoundsPerMinute. - /// - public double MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); - - /// - /// Get MassFlow in MegapoundsPerSecond. - /// - public double MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); - - /// - /// Get MassFlow in MicrogramsPerDay. - /// - public double MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); - - /// - /// Get MassFlow in MicrogramsPerSecond. - /// - public double MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); - - /// - /// Get MassFlow in MilligramsPerDay. - /// - public double MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); - - /// - /// Get MassFlow in MilligramsPerSecond. - /// - public double MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); - - /// - /// Get MassFlow in NanogramsPerDay. - /// - public double NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); - - /// - /// Get MassFlow in NanogramsPerSecond. - /// - public double NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); - - /// - /// Get MassFlow in PoundsPerDay. - /// - public double PoundsPerDay => As(MassFlowUnit.PoundPerDay); - - /// - /// Get MassFlow in PoundsPerHour. - /// - public double PoundsPerHour => As(MassFlowUnit.PoundPerHour); - - /// - /// Get MassFlow in PoundsPerMinute. - /// - public double PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); - - /// - /// Get MassFlow in PoundsPerSecond. - /// - public double PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); - - /// - /// Get MassFlow in ShortTonsPerHour. - /// - public double ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); - - /// - /// Get MassFlow in TonnesPerDay. - /// - public double TonnesPerDay => As(MassFlowUnit.TonnePerDay); - - /// - /// Get MassFlow in TonnesPerHour. - /// - public double TonnesPerHour => As(MassFlowUnit.TonnePerHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MassFlowUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MassFlowUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MassFlow from CentigramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromCentigramsPerDay(double centigramsperday) - { - double value = (double) centigramsperday; - return new MassFlow(value, MassFlowUnit.CentigramPerDay); - } - /// - /// Get MassFlow from CentigramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromCentigramsPerSecond(double centigramspersecond) - { - double value = (double) centigramspersecond; - return new MassFlow(value, MassFlowUnit.CentigramPerSecond); - } - /// - /// Get MassFlow from DecagramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromDecagramsPerDay(double decagramsperday) - { - double value = (double) decagramsperday; - return new MassFlow(value, MassFlowUnit.DecagramPerDay); - } - /// - /// Get MassFlow from DecagramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromDecagramsPerSecond(double decagramspersecond) - { - double value = (double) decagramspersecond; - return new MassFlow(value, MassFlowUnit.DecagramPerSecond); - } - /// - /// Get MassFlow from DecigramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromDecigramsPerDay(double decigramsperday) - { - double value = (double) decigramsperday; - return new MassFlow(value, MassFlowUnit.DecigramPerDay); - } - /// - /// Get MassFlow from DecigramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromDecigramsPerSecond(double decigramspersecond) - { - double value = (double) decigramspersecond; - return new MassFlow(value, MassFlowUnit.DecigramPerSecond); - } - /// - /// Get MassFlow from GramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromGramsPerDay(double gramsperday) - { - double value = (double) gramsperday; - return new MassFlow(value, MassFlowUnit.GramPerDay); - } - /// - /// Get MassFlow from GramsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromGramsPerHour(double gramsperhour) - { - double value = (double) gramsperhour; - return new MassFlow(value, MassFlowUnit.GramPerHour); - } - /// - /// Get MassFlow from GramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromGramsPerSecond(double gramspersecond) - { - double value = (double) gramspersecond; - return new MassFlow(value, MassFlowUnit.GramPerSecond); - } - /// - /// Get MassFlow from HectogramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromHectogramsPerDay(double hectogramsperday) - { - double value = (double) hectogramsperday; - return new MassFlow(value, MassFlowUnit.HectogramPerDay); - } - /// - /// Get MassFlow from HectogramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromHectogramsPerSecond(double hectogramspersecond) - { - double value = (double) hectogramspersecond; - return new MassFlow(value, MassFlowUnit.HectogramPerSecond); - } - /// - /// Get MassFlow from KilogramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromKilogramsPerDay(double kilogramsperday) - { - double value = (double) kilogramsperday; - return new MassFlow(value, MassFlowUnit.KilogramPerDay); - } - /// - /// Get MassFlow from KilogramsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromKilogramsPerHour(double kilogramsperhour) - { - double value = (double) kilogramsperhour; - return new MassFlow(value, MassFlowUnit.KilogramPerHour); - } - /// - /// Get MassFlow from KilogramsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromKilogramsPerMinute(double kilogramsperminute) - { - double value = (double) kilogramsperminute; - return new MassFlow(value, MassFlowUnit.KilogramPerMinute); - } - /// - /// Get MassFlow from KilogramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromKilogramsPerSecond(double kilogramspersecond) - { - double value = (double) kilogramspersecond; - return new MassFlow(value, MassFlowUnit.KilogramPerSecond); - } - /// - /// Get MassFlow from MegagramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMegagramsPerDay(double megagramsperday) - { - double value = (double) megagramsperday; - return new MassFlow(value, MassFlowUnit.MegagramPerDay); - } - /// - /// Get MassFlow from MegapoundsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMegapoundsPerDay(double megapoundsperday) - { - double value = (double) megapoundsperday; - return new MassFlow(value, MassFlowUnit.MegapoundPerDay); - } - /// - /// Get MassFlow from MegapoundsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMegapoundsPerHour(double megapoundsperhour) - { - double value = (double) megapoundsperhour; - return new MassFlow(value, MassFlowUnit.MegapoundPerHour); - } - /// - /// Get MassFlow from MegapoundsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMegapoundsPerMinute(double megapoundsperminute) - { - double value = (double) megapoundsperminute; - return new MassFlow(value, MassFlowUnit.MegapoundPerMinute); - } - /// - /// Get MassFlow from MegapoundsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMegapoundsPerSecond(double megapoundspersecond) - { - double value = (double) megapoundspersecond; - return new MassFlow(value, MassFlowUnit.MegapoundPerSecond); - } - /// - /// Get MassFlow from MicrogramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMicrogramsPerDay(double microgramsperday) - { - double value = (double) microgramsperday; - return new MassFlow(value, MassFlowUnit.MicrogramPerDay); - } - /// - /// Get MassFlow from MicrogramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMicrogramsPerSecond(double microgramspersecond) - { - double value = (double) microgramspersecond; - return new MassFlow(value, MassFlowUnit.MicrogramPerSecond); - } - /// - /// Get MassFlow from MilligramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMilligramsPerDay(double milligramsperday) - { - double value = (double) milligramsperday; - return new MassFlow(value, MassFlowUnit.MilligramPerDay); - } - /// - /// Get MassFlow from MilligramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromMilligramsPerSecond(double milligramspersecond) - { - double value = (double) milligramspersecond; - return new MassFlow(value, MassFlowUnit.MilligramPerSecond); - } - /// - /// Get MassFlow from NanogramsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromNanogramsPerDay(double nanogramsperday) - { - double value = (double) nanogramsperday; - return new MassFlow(value, MassFlowUnit.NanogramPerDay); - } - /// - /// Get MassFlow from NanogramsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromNanogramsPerSecond(double nanogramspersecond) - { - double value = (double) nanogramspersecond; - return new MassFlow(value, MassFlowUnit.NanogramPerSecond); - } - /// - /// Get MassFlow from PoundsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromPoundsPerDay(double poundsperday) - { - double value = (double) poundsperday; - return new MassFlow(value, MassFlowUnit.PoundPerDay); - } - /// - /// Get MassFlow from PoundsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromPoundsPerHour(double poundsperhour) - { - double value = (double) poundsperhour; - return new MassFlow(value, MassFlowUnit.PoundPerHour); - } - /// - /// Get MassFlow from PoundsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromPoundsPerMinute(double poundsperminute) - { - double value = (double) poundsperminute; - return new MassFlow(value, MassFlowUnit.PoundPerMinute); - } - /// - /// Get MassFlow from PoundsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromPoundsPerSecond(double poundspersecond) - { - double value = (double) poundspersecond; - return new MassFlow(value, MassFlowUnit.PoundPerSecond); - } - /// - /// Get MassFlow from ShortTonsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromShortTonsPerHour(double shorttonsperhour) - { - double value = (double) shorttonsperhour; - return new MassFlow(value, MassFlowUnit.ShortTonPerHour); - } - /// - /// Get MassFlow from TonnesPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromTonnesPerDay(double tonnesperday) - { - double value = (double) tonnesperday; - return new MassFlow(value, MassFlowUnit.TonnePerDay); - } - /// - /// Get MassFlow from TonnesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlow FromTonnesPerHour(double tonnesperhour) - { - double value = (double) tonnesperhour; - return new MassFlow(value, MassFlowUnit.TonnePerHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MassFlow unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MassFlow From(double value, MassFlowUnit fromUnit) - { - return new MassFlow((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MassFlow Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassFlow Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MassFlow result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MassFlow result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MassFlowUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassFlowUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MassFlowUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MassFlowUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassFlow objMassFlow)) throw new ArgumentException("Expected type MassFlow.", nameof(obj)); - - return CompareTo(objMassFlow); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MassFlow other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFlow objMassFlow)) - return false; - - return Equals(objMassFlow); - } - - public bool Equals(MassFlow other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MassFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MassFlow. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MassFlowUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MassFlowUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MassFlow to another MassFlow with the unit representation . - /// - /// A MassFlow with the specified unit. - public MassFlow ToUnit(MassFlowUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MassFlow(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MassFlowUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.g.cs deleted file mode 100644 index 6c9c1c2519..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFlux.g.cs +++ /dev/null @@ -1,767 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Mass flux is the mass flow rate per unit area. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MassFlux : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MassFluxUnit? _unit; - - static MassFlux() - { - BaseDimensions = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassFlux, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MassFlux() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MassFlux(double value, MassFluxUnit unit) - { - if(unit == MassFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MassFlux, which is KilogramPerSecondPerSquareMeter. All conversions go via this value. - /// - public static MassFluxUnit BaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; - - /// - /// Represents the largest possible value of MassFlux - /// - public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MassFlux - /// - public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MassFlux; - - /// - /// All units of measurement for the MassFlux quantity. - /// - public static MassFluxUnit[] Units { get; } = Enum.GetValues(typeof(MassFluxUnit)).Cast().Except(new MassFluxUnit[]{ MassFluxUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter. - /// - public static MassFlux Zero { get; } = new MassFlux(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MassFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MassFlux.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MassFlux.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MassFlux in GramsPerHourPerSquareCentimeter. - /// - public double GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); - - /// - /// Get MassFlux in GramsPerHourPerSquareMeter. - /// - public double GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); - - /// - /// Get MassFlux in GramsPerHourPerSquareMillimeter. - /// - public double GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); - - /// - /// Get MassFlux in GramsPerSecondPerSquareCentimeter. - /// - public double GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); - - /// - /// Get MassFlux in GramsPerSecondPerSquareMeter. - /// - public double GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); - - /// - /// Get MassFlux in GramsPerSecondPerSquareMillimeter. - /// - public double GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); - - /// - /// Get MassFlux in KilogramsPerHourPerSquareCentimeter. - /// - public double KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); - - /// - /// Get MassFlux in KilogramsPerHourPerSquareMeter. - /// - public double KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); - - /// - /// Get MassFlux in KilogramsPerHourPerSquareMillimeter. - /// - public double KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); - - /// - /// Get MassFlux in KilogramsPerSecondPerSquareCentimeter. - /// - public double KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); - - /// - /// Get MassFlux in KilogramsPerSecondPerSquareMeter. - /// - public double KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); - - /// - /// Get MassFlux in KilogramsPerSecondPerSquareMillimeter. - /// - public double KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MassFluxUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MassFluxUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MassFlux from GramsPerHourPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromGramsPerHourPerSquareCentimeter(double gramsperhourpersquarecentimeter) - { - double value = (double) gramsperhourpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareCentimeter); - } - /// - /// Get MassFlux from GramsPerHourPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromGramsPerHourPerSquareMeter(double gramsperhourpersquaremeter) - { - double value = (double) gramsperhourpersquaremeter; - return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMeter); - } - /// - /// Get MassFlux from GramsPerHourPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromGramsPerHourPerSquareMillimeter(double gramsperhourpersquaremillimeter) - { - double value = (double) gramsperhourpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMillimeter); - } - /// - /// Get MassFlux from GramsPerSecondPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromGramsPerSecondPerSquareCentimeter(double gramspersecondpersquarecentimeter) - { - double value = (double) gramspersecondpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareCentimeter); - } - /// - /// Get MassFlux from GramsPerSecondPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromGramsPerSecondPerSquareMeter(double gramspersecondpersquaremeter) - { - double value = (double) gramspersecondpersquaremeter; - return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMeter); - } - /// - /// Get MassFlux from GramsPerSecondPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromGramsPerSecondPerSquareMillimeter(double gramspersecondpersquaremillimeter) - { - double value = (double) gramspersecondpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMillimeter); - } - /// - /// Get MassFlux from KilogramsPerHourPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromKilogramsPerHourPerSquareCentimeter(double kilogramsperhourpersquarecentimeter) - { - double value = (double) kilogramsperhourpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareCentimeter); - } - /// - /// Get MassFlux from KilogramsPerHourPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromKilogramsPerHourPerSquareMeter(double kilogramsperhourpersquaremeter) - { - double value = (double) kilogramsperhourpersquaremeter; - return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMeter); - } - /// - /// Get MassFlux from KilogramsPerHourPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromKilogramsPerHourPerSquareMillimeter(double kilogramsperhourpersquaremillimeter) - { - double value = (double) kilogramsperhourpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMillimeter); - } - /// - /// Get MassFlux from KilogramsPerSecondPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(double kilogramspersecondpersquarecentimeter) - { - double value = (double) kilogramspersecondpersquarecentimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); - } - /// - /// Get MassFlux from KilogramsPerSecondPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromKilogramsPerSecondPerSquareMeter(double kilogramspersecondpersquaremeter) - { - double value = (double) kilogramspersecondpersquaremeter; - return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMeter); - } - /// - /// Get MassFlux from KilogramsPerSecondPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(double kilogramspersecondpersquaremillimeter) - { - double value = (double) kilogramspersecondpersquaremillimeter; - return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MassFlux unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MassFlux From(double value, MassFluxUnit fromUnit) - { - return new MassFlux((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MassFlux Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassFlux Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MassFlux result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MassFlux result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MassFluxUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassFluxUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MassFluxUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MassFluxUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassFlux objMassFlux)) throw new ArgumentException("Expected type MassFlux.", nameof(obj)); - - return CompareTo(objMassFlux); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MassFlux other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFlux objMassFlux)) - return false; - - return Equals(objMassFlux); - } - - public bool Equals(MassFlux other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MassFlux within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MassFlux. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MassFluxUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MassFluxUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MassFlux to another MassFlux with the unit representation . - /// - /// A MassFlux with the specified unit. - public MassFlux ToUnit(MassFluxUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MassFlux(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MassFluxUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFraction.g.cs deleted file mode 100644 index 45d38ca472..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassFraction.g.cs +++ /dev/null @@ -1,974 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The mass fraction is defined as the mass of a constituent divided by the total mass of the mixture. - /// - /// - /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MassFraction : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MassFractionUnit? _unit; - - static MassFraction() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.MassFraction, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DecimalFraction. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MassFraction() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MassFraction(double value, MassFractionUnit unit) - { - if(unit == MassFractionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MassFraction, which is DecimalFraction. All conversions go via this value. - /// - public static MassFractionUnit BaseUnit { get; } = MassFractionUnit.DecimalFraction; - - /// - /// Represents the largest possible value of MassFraction - /// - public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MassFraction - /// - public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MassFraction; - - /// - /// All units of measurement for the MassFraction quantity. - /// - public static MassFractionUnit[] Units { get; } = Enum.GetValues(typeof(MassFractionUnit)).Cast().Except(new MassFractionUnit[]{ MassFractionUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. - /// - public static MassFraction Zero { get; } = new MassFraction(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MassFractionUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MassFraction.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MassFraction.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MassFraction in CentigramsPerGram. - /// - public double CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); - - /// - /// Get MassFraction in CentigramsPerKilogram. - /// - public double CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); - - /// - /// Get MassFraction in DecagramsPerGram. - /// - public double DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); - - /// - /// Get MassFraction in DecagramsPerKilogram. - /// - public double DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); - - /// - /// Get MassFraction in DecigramsPerGram. - /// - public double DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); - - /// - /// Get MassFraction in DecigramsPerKilogram. - /// - public double DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); - - /// - /// Get MassFraction in DecimalFractions. - /// - public double DecimalFractions => As(MassFractionUnit.DecimalFraction); - - /// - /// Get MassFraction in GramsPerGram. - /// - public double GramsPerGram => As(MassFractionUnit.GramPerGram); - - /// - /// Get MassFraction in GramsPerKilogram. - /// - public double GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); - - /// - /// Get MassFraction in HectogramsPerGram. - /// - public double HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); - - /// - /// Get MassFraction in HectogramsPerKilogram. - /// - public double HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); - - /// - /// Get MassFraction in KilogramsPerGram. - /// - public double KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); - - /// - /// Get MassFraction in KilogramsPerKilogram. - /// - public double KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); - - /// - /// Get MassFraction in MicrogramsPerGram. - /// - public double MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); - - /// - /// Get MassFraction in MicrogramsPerKilogram. - /// - public double MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); - - /// - /// Get MassFraction in MilligramsPerGram. - /// - public double MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); - - /// - /// Get MassFraction in MilligramsPerKilogram. - /// - public double MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); - - /// - /// Get MassFraction in NanogramsPerGram. - /// - public double NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); - - /// - /// Get MassFraction in NanogramsPerKilogram. - /// - public double NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); - - /// - /// Get MassFraction in PartsPerBillion. - /// - public double PartsPerBillion => As(MassFractionUnit.PartPerBillion); - - /// - /// Get MassFraction in PartsPerMillion. - /// - public double PartsPerMillion => As(MassFractionUnit.PartPerMillion); - - /// - /// Get MassFraction in PartsPerThousand. - /// - public double PartsPerThousand => As(MassFractionUnit.PartPerThousand); - - /// - /// Get MassFraction in PartsPerTrillion. - /// - public double PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); - - /// - /// Get MassFraction in Percent. - /// - public double Percent => As(MassFractionUnit.Percent); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MassFractionUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MassFractionUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MassFraction from CentigramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromCentigramsPerGram(double centigramspergram) - { - double value = (double) centigramspergram; - return new MassFraction(value, MassFractionUnit.CentigramPerGram); - } - /// - /// Get MassFraction from CentigramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromCentigramsPerKilogram(double centigramsperkilogram) - { - double value = (double) centigramsperkilogram; - return new MassFraction(value, MassFractionUnit.CentigramPerKilogram); - } - /// - /// Get MassFraction from DecagramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromDecagramsPerGram(double decagramspergram) - { - double value = (double) decagramspergram; - return new MassFraction(value, MassFractionUnit.DecagramPerGram); - } - /// - /// Get MassFraction from DecagramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromDecagramsPerKilogram(double decagramsperkilogram) - { - double value = (double) decagramsperkilogram; - return new MassFraction(value, MassFractionUnit.DecagramPerKilogram); - } - /// - /// Get MassFraction from DecigramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromDecigramsPerGram(double decigramspergram) - { - double value = (double) decigramspergram; - return new MassFraction(value, MassFractionUnit.DecigramPerGram); - } - /// - /// Get MassFraction from DecigramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromDecigramsPerKilogram(double decigramsperkilogram) - { - double value = (double) decigramsperkilogram; - return new MassFraction(value, MassFractionUnit.DecigramPerKilogram); - } - /// - /// Get MassFraction from DecimalFractions. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromDecimalFractions(double decimalfractions) - { - double value = (double) decimalfractions; - return new MassFraction(value, MassFractionUnit.DecimalFraction); - } - /// - /// Get MassFraction from GramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromGramsPerGram(double gramspergram) - { - double value = (double) gramspergram; - return new MassFraction(value, MassFractionUnit.GramPerGram); - } - /// - /// Get MassFraction from GramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromGramsPerKilogram(double gramsperkilogram) - { - double value = (double) gramsperkilogram; - return new MassFraction(value, MassFractionUnit.GramPerKilogram); - } - /// - /// Get MassFraction from HectogramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromHectogramsPerGram(double hectogramspergram) - { - double value = (double) hectogramspergram; - return new MassFraction(value, MassFractionUnit.HectogramPerGram); - } - /// - /// Get MassFraction from HectogramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromHectogramsPerKilogram(double hectogramsperkilogram) - { - double value = (double) hectogramsperkilogram; - return new MassFraction(value, MassFractionUnit.HectogramPerKilogram); - } - /// - /// Get MassFraction from KilogramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromKilogramsPerGram(double kilogramspergram) - { - double value = (double) kilogramspergram; - return new MassFraction(value, MassFractionUnit.KilogramPerGram); - } - /// - /// Get MassFraction from KilogramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromKilogramsPerKilogram(double kilogramsperkilogram) - { - double value = (double) kilogramsperkilogram; - return new MassFraction(value, MassFractionUnit.KilogramPerKilogram); - } - /// - /// Get MassFraction from MicrogramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromMicrogramsPerGram(double microgramspergram) - { - double value = (double) microgramspergram; - return new MassFraction(value, MassFractionUnit.MicrogramPerGram); - } - /// - /// Get MassFraction from MicrogramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromMicrogramsPerKilogram(double microgramsperkilogram) - { - double value = (double) microgramsperkilogram; - return new MassFraction(value, MassFractionUnit.MicrogramPerKilogram); - } - /// - /// Get MassFraction from MilligramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromMilligramsPerGram(double milligramspergram) - { - double value = (double) milligramspergram; - return new MassFraction(value, MassFractionUnit.MilligramPerGram); - } - /// - /// Get MassFraction from MilligramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromMilligramsPerKilogram(double milligramsperkilogram) - { - double value = (double) milligramsperkilogram; - return new MassFraction(value, MassFractionUnit.MilligramPerKilogram); - } - /// - /// Get MassFraction from NanogramsPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromNanogramsPerGram(double nanogramspergram) - { - double value = (double) nanogramspergram; - return new MassFraction(value, MassFractionUnit.NanogramPerGram); - } - /// - /// Get MassFraction from NanogramsPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromNanogramsPerKilogram(double nanogramsperkilogram) - { - double value = (double) nanogramsperkilogram; - return new MassFraction(value, MassFractionUnit.NanogramPerKilogram); - } - /// - /// Get MassFraction from PartsPerBillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromPartsPerBillion(double partsperbillion) - { - double value = (double) partsperbillion; - return new MassFraction(value, MassFractionUnit.PartPerBillion); - } - /// - /// Get MassFraction from PartsPerMillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromPartsPerMillion(double partspermillion) - { - double value = (double) partspermillion; - return new MassFraction(value, MassFractionUnit.PartPerMillion); - } - /// - /// Get MassFraction from PartsPerThousand. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromPartsPerThousand(double partsperthousand) - { - double value = (double) partsperthousand; - return new MassFraction(value, MassFractionUnit.PartPerThousand); - } - /// - /// Get MassFraction from PartsPerTrillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromPartsPerTrillion(double partspertrillion) - { - double value = (double) partspertrillion; - return new MassFraction(value, MassFractionUnit.PartPerTrillion); - } - /// - /// Get MassFraction from Percent. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassFraction FromPercent(double percent) - { - double value = (double) percent; - return new MassFraction(value, MassFractionUnit.Percent); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MassFraction unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MassFraction From(double value, MassFractionUnit fromUnit) - { - return new MassFraction((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MassFraction Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassFraction Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MassFraction result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MassFraction result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MassFractionUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassFractionUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MassFractionUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MassFractionUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassFraction objMassFraction)) throw new ArgumentException("Expected type MassFraction.", nameof(obj)); - - return CompareTo(objMassFraction); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MassFraction other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFraction objMassFraction)) - return false; - - return Equals(objMassFraction); - } - - public bool Equals(MassFraction other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MassFraction within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFraction other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MassFraction. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MassFractionUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MassFractionUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MassFraction to another MassFraction with the unit representation . - /// - /// A MassFraction with the specified unit. - public MassFraction ToUnit(MassFractionUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MassFraction(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MassFractionUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.g.cs deleted file mode 100644 index c0632713dc..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ /dev/null @@ -1,1039 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A property of body reflects how its mass is distributed with regard to an axis. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MassMomentOfInertia : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MassMomentOfInertiaUnit? _unit; - - static MassMomentOfInertia() - { - BaseDimensions = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.MassMomentOfInertia, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MassMomentOfInertia() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) - { - if(unit == MassMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MassMomentOfInertia, which is KilogramSquareMeter. All conversions go via this value. - /// - public static MassMomentOfInertiaUnit BaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; - - /// - /// Represents the largest possible value of MassMomentOfInertia - /// - public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MassMomentOfInertia - /// - public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MassMomentOfInertia; - - /// - /// All units of measurement for the MassMomentOfInertia quantity. - /// - public static MassMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().Except(new MassMomentOfInertiaUnit[]{ MassMomentOfInertiaUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramSquareMeter. - /// - public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MassMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MassMomentOfInertia.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MassMomentOfInertia.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MassMomentOfInertia in GramSquareCentimeters. - /// - public double GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); - - /// - /// Get MassMomentOfInertia in GramSquareDecimeters. - /// - public double GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); - - /// - /// Get MassMomentOfInertia in GramSquareMeters. - /// - public double GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); - - /// - /// Get MassMomentOfInertia in GramSquareMillimeters. - /// - public double GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); - - /// - /// Get MassMomentOfInertia in KilogramSquareCentimeters. - /// - public double KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); - - /// - /// Get MassMomentOfInertia in KilogramSquareDecimeters. - /// - public double KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); - - /// - /// Get MassMomentOfInertia in KilogramSquareMeters. - /// - public double KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); - - /// - /// Get MassMomentOfInertia in KilogramSquareMillimeters. - /// - public double KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); - - /// - /// Get MassMomentOfInertia in KilotonneSquareCentimeters. - /// - public double KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); - - /// - /// Get MassMomentOfInertia in KilotonneSquareDecimeters. - /// - public double KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); - - /// - /// Get MassMomentOfInertia in KilotonneSquareMeters. - /// - public double KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); - - /// - /// Get MassMomentOfInertia in KilotonneSquareMilimeters. - /// - public double KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); - - /// - /// Get MassMomentOfInertia in MegatonneSquareCentimeters. - /// - public double MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); - - /// - /// Get MassMomentOfInertia in MegatonneSquareDecimeters. - /// - public double MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); - - /// - /// Get MassMomentOfInertia in MegatonneSquareMeters. - /// - public double MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); - - /// - /// Get MassMomentOfInertia in MegatonneSquareMilimeters. - /// - public double MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); - - /// - /// Get MassMomentOfInertia in MilligramSquareCentimeters. - /// - public double MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); - - /// - /// Get MassMomentOfInertia in MilligramSquareDecimeters. - /// - public double MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); - - /// - /// Get MassMomentOfInertia in MilligramSquareMeters. - /// - public double MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); - - /// - /// Get MassMomentOfInertia in MilligramSquareMillimeters. - /// - public double MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); - - /// - /// Get MassMomentOfInertia in PoundSquareFeet. - /// - public double PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); - - /// - /// Get MassMomentOfInertia in PoundSquareInches. - /// - public double PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); - - /// - /// Get MassMomentOfInertia in SlugSquareFeet. - /// - public double SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); - - /// - /// Get MassMomentOfInertia in SlugSquareInches. - /// - public double SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); - - /// - /// Get MassMomentOfInertia in TonneSquareCentimeters. - /// - public double TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); - - /// - /// Get MassMomentOfInertia in TonneSquareDecimeters. - /// - public double TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); - - /// - /// Get MassMomentOfInertia in TonneSquareMeters. - /// - public double TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); - - /// - /// Get MassMomentOfInertia in TonneSquareMilimeters. - /// - public double TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MassMomentOfInertiaUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MassMomentOfInertiaUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MassMomentOfInertia from GramSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromGramSquareCentimeters(double gramsquarecentimeters) - { - double value = (double) gramsquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareCentimeter); - } - /// - /// Get MassMomentOfInertia from GramSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromGramSquareDecimeters(double gramsquaredecimeters) - { - double value = (double) gramsquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareDecimeter); - } - /// - /// Get MassMomentOfInertia from GramSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromGramSquareMeters(double gramsquaremeters) - { - double value = (double) gramsquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMeter); - } - /// - /// Get MassMomentOfInertia from GramSquareMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromGramSquareMillimeters(double gramsquaremillimeters) - { - double value = (double) gramsquaremillimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMillimeter); - } - /// - /// Get MassMomentOfInertia from KilogramSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilogramSquareCentimeters(double kilogramsquarecentimeters) - { - double value = (double) kilogramsquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareCentimeter); - } - /// - /// Get MassMomentOfInertia from KilogramSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilogramSquareDecimeters(double kilogramsquaredecimeters) - { - double value = (double) kilogramsquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareDecimeter); - } - /// - /// Get MassMomentOfInertia from KilogramSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilogramSquareMeters(double kilogramsquaremeters) - { - double value = (double) kilogramsquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMeter); - } - /// - /// Get MassMomentOfInertia from KilogramSquareMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilogramSquareMillimeters(double kilogramsquaremillimeters) - { - double value = (double) kilogramsquaremillimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMillimeter); - } - /// - /// Get MassMomentOfInertia from KilotonneSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilotonneSquareCentimeters(double kilotonnesquarecentimeters) - { - double value = (double) kilotonnesquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); - } - /// - /// Get MassMomentOfInertia from KilotonneSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilotonneSquareDecimeters(double kilotonnesquaredecimeters) - { - double value = (double) kilotonnesquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); - } - /// - /// Get MassMomentOfInertia from KilotonneSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilotonneSquareMeters(double kilotonnesquaremeters) - { - double value = (double) kilotonnesquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMeter); - } - /// - /// Get MassMomentOfInertia from KilotonneSquareMilimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromKilotonneSquareMilimeters(double kilotonnesquaremilimeters) - { - double value = (double) kilotonnesquaremilimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); - } - /// - /// Get MassMomentOfInertia from MegatonneSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMegatonneSquareCentimeters(double megatonnesquarecentimeters) - { - double value = (double) megatonnesquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); - } - /// - /// Get MassMomentOfInertia from MegatonneSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMegatonneSquareDecimeters(double megatonnesquaredecimeters) - { - double value = (double) megatonnesquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); - } - /// - /// Get MassMomentOfInertia from MegatonneSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMegatonneSquareMeters(double megatonnesquaremeters) - { - double value = (double) megatonnesquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMeter); - } - /// - /// Get MassMomentOfInertia from MegatonneSquareMilimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMegatonneSquareMilimeters(double megatonnesquaremilimeters) - { - double value = (double) megatonnesquaremilimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); - } - /// - /// Get MassMomentOfInertia from MilligramSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMilligramSquareCentimeters(double milligramsquarecentimeters) - { - double value = (double) milligramsquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareCentimeter); - } - /// - /// Get MassMomentOfInertia from MilligramSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMilligramSquareDecimeters(double milligramsquaredecimeters) - { - double value = (double) milligramsquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareDecimeter); - } - /// - /// Get MassMomentOfInertia from MilligramSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMilligramSquareMeters(double milligramsquaremeters) - { - double value = (double) milligramsquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMeter); - } - /// - /// Get MassMomentOfInertia from MilligramSquareMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromMilligramSquareMillimeters(double milligramsquaremillimeters) - { - double value = (double) milligramsquaremillimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMillimeter); - } - /// - /// Get MassMomentOfInertia from PoundSquareFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromPoundSquareFeet(double poundsquarefeet) - { - double value = (double) poundsquarefeet; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareFoot); - } - /// - /// Get MassMomentOfInertia from PoundSquareInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromPoundSquareInches(double poundsquareinches) - { - double value = (double) poundsquareinches; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareInch); - } - /// - /// Get MassMomentOfInertia from SlugSquareFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromSlugSquareFeet(double slugsquarefeet) - { - double value = (double) slugsquarefeet; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareFoot); - } - /// - /// Get MassMomentOfInertia from SlugSquareInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromSlugSquareInches(double slugsquareinches) - { - double value = (double) slugsquareinches; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareInch); - } - /// - /// Get MassMomentOfInertia from TonneSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromTonneSquareCentimeters(double tonnesquarecentimeters) - { - double value = (double) tonnesquarecentimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareCentimeter); - } - /// - /// Get MassMomentOfInertia from TonneSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromTonneSquareDecimeters(double tonnesquaredecimeters) - { - double value = (double) tonnesquaredecimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareDecimeter); - } - /// - /// Get MassMomentOfInertia from TonneSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromTonneSquareMeters(double tonnesquaremeters) - { - double value = (double) tonnesquaremeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMeter); - } - /// - /// Get MassMomentOfInertia from TonneSquareMilimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MassMomentOfInertia FromTonneSquareMilimeters(double tonnesquaremilimeters) - { - double value = (double) tonnesquaremilimeters; - return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMilimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MassMomentOfInertia unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MassMomentOfInertia From(double value, MassMomentOfInertiaUnit fromUnit) - { - return new MassMomentOfInertia((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MassMomentOfInertia Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassMomentOfInertia Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MassMomentOfInertia result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MassMomentOfInertia result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MassMomentOfInertiaUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MassMomentOfInertiaUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MassMomentOfInertiaUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MassMomentOfInertiaUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MassMomentOfInertia objMassMomentOfInertia)) throw new ArgumentException("Expected type MassMomentOfInertia.", nameof(obj)); - - return CompareTo(objMassMomentOfInertia); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MassMomentOfInertia other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) - return false; - - return Equals(objMassMomentOfInertia); - } - - public bool Equals(MassMomentOfInertia other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MassMomentOfInertia within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MassMomentOfInertia. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MassMomentOfInertiaUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MassMomentOfInertiaUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MassMomentOfInertia to another MassMomentOfInertia with the unit representation . - /// - /// A MassMomentOfInertia with the specified unit. - public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MassMomentOfInertia(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MassMomentOfInertiaUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.g.cs deleted file mode 100644 index f1bb8ab9b1..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEnergy.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Molar energy is the amount of energy stored in 1 mole of a substance. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MolarEnergy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MolarEnergyUnit? _unit; - - static MolarEnergy() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, -1, 0); - Info = new QuantityInfo(QuantityType.MolarEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerMole. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MolarEnergy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MolarEnergy(double value, MolarEnergyUnit unit) - { - if(unit == MolarEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MolarEnergy, which is JoulePerMole. All conversions go via this value. - /// - public static MolarEnergyUnit BaseUnit { get; } = MolarEnergyUnit.JoulePerMole; - - /// - /// Represents the largest possible value of MolarEnergy - /// - public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MolarEnergy - /// - public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MolarEnergy; - - /// - /// All units of measurement for the MolarEnergy quantity. - /// - public static MolarEnergyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().Except(new MolarEnergyUnit[]{ MolarEnergyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMole. - /// - public static MolarEnergy Zero { get; } = new MolarEnergy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MolarEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MolarEnergy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MolarEnergy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MolarEnergy in JoulesPerMole. - /// - public double JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); - - /// - /// Get MolarEnergy in KilojoulesPerMole. - /// - public double KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); - - /// - /// Get MolarEnergy in MegajoulesPerMole. - /// - public double MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MolarEnergyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MolarEnergyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MolarEnergy from JoulesPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarEnergy FromJoulesPerMole(double joulespermole) - { - double value = (double) joulespermole; - return new MolarEnergy(value, MolarEnergyUnit.JoulePerMole); - } - /// - /// Get MolarEnergy from KilojoulesPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarEnergy FromKilojoulesPerMole(double kilojoulespermole) - { - double value = (double) kilojoulespermole; - return new MolarEnergy(value, MolarEnergyUnit.KilojoulePerMole); - } - /// - /// Get MolarEnergy from MegajoulesPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarEnergy FromMegajoulesPerMole(double megajoulespermole) - { - double value = (double) megajoulespermole; - return new MolarEnergy(value, MolarEnergyUnit.MegajoulePerMole); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MolarEnergy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MolarEnergy From(double value, MolarEnergyUnit fromUnit) - { - return new MolarEnergy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MolarEnergy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarEnergy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MolarEnergy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MolarEnergy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MolarEnergyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarEnergyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MolarEnergyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MolarEnergyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MolarEnergy objMolarEnergy)) throw new ArgumentException("Expected type MolarEnergy.", nameof(obj)); - - return CompareTo(objMolarEnergy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MolarEnergy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarEnergy objMolarEnergy)) - return false; - - return Equals(objMolarEnergy); - } - - public bool Equals(MolarEnergy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MolarEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MolarEnergy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MolarEnergyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MolarEnergyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MolarEnergy to another MolarEnergy with the unit representation . - /// - /// A MolarEnergy with the specified unit. - public MolarEnergy ToUnit(MolarEnergyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MolarEnergy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MolarEnergyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.g.cs deleted file mode 100644 index 055bcd576b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarEntropy.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MolarEntropy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MolarEntropyUnit? _unit; - - static MolarEntropy() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, -1, 0); - Info = new QuantityInfo(QuantityType.MolarEntropy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerMoleKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MolarEntropy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MolarEntropy(double value, MolarEntropyUnit unit) - { - if(unit == MolarEntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MolarEntropy, which is JoulePerMoleKelvin. All conversions go via this value. - /// - public static MolarEntropyUnit BaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; - - /// - /// Represents the largest possible value of MolarEntropy - /// - public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MolarEntropy - /// - public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MolarEntropy; - - /// - /// All units of measurement for the MolarEntropy quantity. - /// - public static MolarEntropyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().Except(new MolarEntropyUnit[]{ MolarEntropyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMoleKelvin. - /// - public static MolarEntropy Zero { get; } = new MolarEntropy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MolarEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MolarEntropy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MolarEntropy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MolarEntropy in JoulesPerMoleKelvin. - /// - public double JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); - - /// - /// Get MolarEntropy in KilojoulesPerMoleKelvin. - /// - public double KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); - - /// - /// Get MolarEntropy in MegajoulesPerMoleKelvin. - /// - public double MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MolarEntropyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MolarEntropyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MolarEntropy from JoulesPerMoleKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarEntropy FromJoulesPerMoleKelvin(double joulespermolekelvin) - { - double value = (double) joulespermolekelvin; - return new MolarEntropy(value, MolarEntropyUnit.JoulePerMoleKelvin); - } - /// - /// Get MolarEntropy from KilojoulesPerMoleKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarEntropy FromKilojoulesPerMoleKelvin(double kilojoulespermolekelvin) - { - double value = (double) kilojoulespermolekelvin; - return new MolarEntropy(value, MolarEntropyUnit.KilojoulePerMoleKelvin); - } - /// - /// Get MolarEntropy from MegajoulesPerMoleKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarEntropy FromMegajoulesPerMoleKelvin(double megajoulespermolekelvin) - { - double value = (double) megajoulespermolekelvin; - return new MolarEntropy(value, MolarEntropyUnit.MegajoulePerMoleKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MolarEntropy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MolarEntropy From(double value, MolarEntropyUnit fromUnit) - { - return new MolarEntropy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MolarEntropy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarEntropy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MolarEntropy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MolarEntropy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MolarEntropyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarEntropyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MolarEntropyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MolarEntropyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MolarEntropy objMolarEntropy)) throw new ArgumentException("Expected type MolarEntropy.", nameof(obj)); - - return CompareTo(objMolarEntropy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MolarEntropy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarEntropy objMolarEntropy)) - return false; - - return Equals(objMolarEntropy); - } - - public bool Equals(MolarEntropy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MolarEntropy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MolarEntropy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MolarEntropyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MolarEntropyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MolarEntropy to another MolarEntropy with the unit representation . - /// - /// A MolarEntropy with the specified unit. - public MolarEntropy ToUnit(MolarEntropyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MolarEntropy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MolarEntropyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.g.cs deleted file mode 100644 index e00565a7fd..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/MolarMass.g.cs +++ /dev/null @@ -1,767 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class MolarMass : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MolarMassUnit? _unit; - - static MolarMass() - { - BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, -1, 0); - Info = new QuantityInfo(QuantityType.MolarMass, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit KilogramPerMole. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public MolarMass() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private MolarMass(double value, MolarMassUnit unit) - { - if(unit == MolarMassUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of MolarMass, which is KilogramPerMole. All conversions go via this value. - /// - public static MolarMassUnit BaseUnit { get; } = MolarMassUnit.KilogramPerMole; - - /// - /// Represents the largest possible value of MolarMass - /// - public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of MolarMass - /// - public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.MolarMass; - - /// - /// All units of measurement for the MolarMass quantity. - /// - public static MolarMassUnit[] Units { get; } = Enum.GetValues(typeof(MolarMassUnit)).Cast().Except(new MolarMassUnit[]{ MolarMassUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMole. - /// - public static MolarMass Zero { get; } = new MolarMass(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MolarMassUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => MolarMass.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => MolarMass.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get MolarMass in CentigramsPerMole. - /// - public double CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); - - /// - /// Get MolarMass in DecagramsPerMole. - /// - public double DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); - - /// - /// Get MolarMass in DecigramsPerMole. - /// - public double DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); - - /// - /// Get MolarMass in GramsPerMole. - /// - public double GramsPerMole => As(MolarMassUnit.GramPerMole); - - /// - /// Get MolarMass in HectogramsPerMole. - /// - public double HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); - - /// - /// Get MolarMass in KilogramsPerMole. - /// - public double KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); - - /// - /// Get MolarMass in KilopoundsPerMole. - /// - public double KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); - - /// - /// Get MolarMass in MegapoundsPerMole. - /// - public double MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); - - /// - /// Get MolarMass in MicrogramsPerMole. - /// - public double MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); - - /// - /// Get MolarMass in MilligramsPerMole. - /// - public double MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); - - /// - /// Get MolarMass in NanogramsPerMole. - /// - public double NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); - - /// - /// Get MolarMass in PoundsPerMole. - /// - public double PoundsPerMole => As(MolarMassUnit.PoundPerMole); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MolarMassUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MolarMassUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get MolarMass from CentigramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromCentigramsPerMole(double centigramspermole) - { - double value = (double) centigramspermole; - return new MolarMass(value, MolarMassUnit.CentigramPerMole); - } - /// - /// Get MolarMass from DecagramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromDecagramsPerMole(double decagramspermole) - { - double value = (double) decagramspermole; - return new MolarMass(value, MolarMassUnit.DecagramPerMole); - } - /// - /// Get MolarMass from DecigramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromDecigramsPerMole(double decigramspermole) - { - double value = (double) decigramspermole; - return new MolarMass(value, MolarMassUnit.DecigramPerMole); - } - /// - /// Get MolarMass from GramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromGramsPerMole(double gramspermole) - { - double value = (double) gramspermole; - return new MolarMass(value, MolarMassUnit.GramPerMole); - } - /// - /// Get MolarMass from HectogramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromHectogramsPerMole(double hectogramspermole) - { - double value = (double) hectogramspermole; - return new MolarMass(value, MolarMassUnit.HectogramPerMole); - } - /// - /// Get MolarMass from KilogramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromKilogramsPerMole(double kilogramspermole) - { - double value = (double) kilogramspermole; - return new MolarMass(value, MolarMassUnit.KilogramPerMole); - } - /// - /// Get MolarMass from KilopoundsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromKilopoundsPerMole(double kilopoundspermole) - { - double value = (double) kilopoundspermole; - return new MolarMass(value, MolarMassUnit.KilopoundPerMole); - } - /// - /// Get MolarMass from MegapoundsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromMegapoundsPerMole(double megapoundspermole) - { - double value = (double) megapoundspermole; - return new MolarMass(value, MolarMassUnit.MegapoundPerMole); - } - /// - /// Get MolarMass from MicrogramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromMicrogramsPerMole(double microgramspermole) - { - double value = (double) microgramspermole; - return new MolarMass(value, MolarMassUnit.MicrogramPerMole); - } - /// - /// Get MolarMass from MilligramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromMilligramsPerMole(double milligramspermole) - { - double value = (double) milligramspermole; - return new MolarMass(value, MolarMassUnit.MilligramPerMole); - } - /// - /// Get MolarMass from NanogramsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromNanogramsPerMole(double nanogramspermole) - { - double value = (double) nanogramspermole; - return new MolarMass(value, MolarMassUnit.NanogramPerMole); - } - /// - /// Get MolarMass from PoundsPerMole. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static MolarMass FromPoundsPerMole(double poundspermole) - { - double value = (double) poundspermole; - return new MolarMass(value, MolarMassUnit.PoundPerMole); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// MolarMass unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static MolarMass From(double value, MolarMassUnit fromUnit) - { - return new MolarMass((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static MolarMass Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarMass Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out MolarMass result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out MolarMass result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MolarMassUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarMassUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MolarMassUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MolarMassUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is MolarMass objMolarMass)) throw new ArgumentException("Expected type MolarMass.", nameof(obj)); - - return CompareTo(objMolarMass); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(MolarMass other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarMass objMolarMass)) - return false; - - return Equals(objMolarMass); - } - - public bool Equals(MolarMass other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another MolarMass within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current MolarMass. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MolarMassUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MolarMassUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this MolarMass to another MolarMass with the unit representation . - /// - /// A MolarMass with the specified unit. - public MolarMass ToUnit(MolarMassUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new MolarMass(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(MolarMassUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.g.cs deleted file mode 100644 index 008ec84178..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Molarity.g.cs +++ /dev/null @@ -1,702 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. - /// - /// - /// https://en.wikipedia.org/wiki/Molar_concentration - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Molarity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly MolarityUnit? _unit; - - static Molarity() - { - BaseDimensions = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); - Info = new QuantityInfo(QuantityType.Molarity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit MolesPerCubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Molarity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Molarity(double value, MolarityUnit unit) - { - if(unit == MolarityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Molarity, which is MolesPerCubicMeter. All conversions go via this value. - /// - public static MolarityUnit BaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; - - /// - /// Represents the largest possible value of Molarity - /// - public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Molarity - /// - public static Molarity MinValue { get; } = new Molarity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Molarity; - - /// - /// All units of measurement for the Molarity quantity. - /// - public static MolarityUnit[] Units { get; } = Enum.GetValues(typeof(MolarityUnit)).Cast().Except(new MolarityUnit[]{ MolarityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit MolesPerCubicMeter. - /// - public static Molarity Zero { get; } = new Molarity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public MolarityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Molarity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Molarity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Molarity in CentimolesPerLiter. - /// - public double CentimolesPerLiter => As(MolarityUnit.CentimolesPerLiter); - - /// - /// Get Molarity in DecimolesPerLiter. - /// - public double DecimolesPerLiter => As(MolarityUnit.DecimolesPerLiter); - - /// - /// Get Molarity in MicromolesPerLiter. - /// - public double MicromolesPerLiter => As(MolarityUnit.MicromolesPerLiter); - - /// - /// Get Molarity in MillimolesPerLiter. - /// - public double MillimolesPerLiter => As(MolarityUnit.MillimolesPerLiter); - - /// - /// Get Molarity in MolesPerCubicMeter. - /// - public double MolesPerCubicMeter => As(MolarityUnit.MolesPerCubicMeter); - - /// - /// Get Molarity in MolesPerLiter. - /// - public double MolesPerLiter => As(MolarityUnit.MolesPerLiter); - - /// - /// Get Molarity in NanomolesPerLiter. - /// - public double NanomolesPerLiter => As(MolarityUnit.NanomolesPerLiter); - - /// - /// Get Molarity in PicomolesPerLiter. - /// - public double PicomolesPerLiter => As(MolarityUnit.PicomolesPerLiter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(MolarityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(MolarityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Molarity from CentimolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromCentimolesPerLiter(double centimolesperliter) - { - double value = (double) centimolesperliter; - return new Molarity(value, MolarityUnit.CentimolesPerLiter); - } - /// - /// Get Molarity from DecimolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromDecimolesPerLiter(double decimolesperliter) - { - double value = (double) decimolesperliter; - return new Molarity(value, MolarityUnit.DecimolesPerLiter); - } - /// - /// Get Molarity from MicromolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromMicromolesPerLiter(double micromolesperliter) - { - double value = (double) micromolesperliter; - return new Molarity(value, MolarityUnit.MicromolesPerLiter); - } - /// - /// Get Molarity from MillimolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromMillimolesPerLiter(double millimolesperliter) - { - double value = (double) millimolesperliter; - return new Molarity(value, MolarityUnit.MillimolesPerLiter); - } - /// - /// Get Molarity from MolesPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromMolesPerCubicMeter(double molespercubicmeter) - { - double value = (double) molespercubicmeter; - return new Molarity(value, MolarityUnit.MolesPerCubicMeter); - } - /// - /// Get Molarity from MolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromMolesPerLiter(double molesperliter) - { - double value = (double) molesperliter; - return new Molarity(value, MolarityUnit.MolesPerLiter); - } - /// - /// Get Molarity from NanomolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromNanomolesPerLiter(double nanomolesperliter) - { - double value = (double) nanomolesperliter; - return new Molarity(value, MolarityUnit.NanomolesPerLiter); - } - /// - /// Get Molarity from PicomolesPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Molarity FromPicomolesPerLiter(double picomolesperliter) - { - double value = (double) picomolesperliter; - return new Molarity(value, MolarityUnit.PicomolesPerLiter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Molarity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Molarity From(double value, MolarityUnit fromUnit) - { - return new Molarity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Molarity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Molarity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Molarity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Molarity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static MolarityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static MolarityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out MolarityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out MolarityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Molarity objMolarity)) throw new ArgumentException("Expected type Molarity.", nameof(obj)); - - return CompareTo(objMolarity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Molarity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Molarity objMolarity)) - return false; - - return Equals(objMolarity); - } - - public bool Equals(Molarity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Molarity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Molarity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((MolarityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(MolarityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Molarity to another Molarity with the unit representation . - /// - /// A Molarity with the specified unit. - public Molarity ToUnit(MolarityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Molarity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case MolarityUnit.CentimolesPerLiter: return (_value/1e-3) * 1e-2d; - case MolarityUnit.DecimolesPerLiter: return (_value/1e-3) * 1e-1d; - case MolarityUnit.MicromolesPerLiter: return (_value/1e-3) * 1e-6d; - case MolarityUnit.MillimolesPerLiter: return (_value/1e-3) * 1e-3d; - case MolarityUnit.MolesPerCubicMeter: return _value; - case MolarityUnit.MolesPerLiter: return _value/1e-3; - case MolarityUnit.NanomolesPerLiter: return (_value/1e-3) * 1e-9d; - case MolarityUnit.PicomolesPerLiter: return (_value/1e-3) * 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(MolarityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case MolarityUnit.CentimolesPerLiter: return (baseUnitValue*1e-3) / 1e-2d; - case MolarityUnit.DecimolesPerLiter: return (baseUnitValue*1e-3) / 1e-1d; - case MolarityUnit.MicromolesPerLiter: return (baseUnitValue*1e-3) / 1e-6d; - case MolarityUnit.MillimolesPerLiter: return (baseUnitValue*1e-3) / 1e-3d; - case MolarityUnit.MolesPerCubicMeter: return baseUnitValue; - case MolarityUnit.MolesPerLiter: return baseUnitValue*1e-3; - case MolarityUnit.NanomolesPerLiter: return (baseUnitValue*1e-3) / 1e-9d; - case MolarityUnit.PicomolesPerLiter: return (baseUnitValue*1e-3) / 1e-12d; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.g.cs deleted file mode 100644 index 398cf90dae..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permeability.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In electromagnetism, permeability is the measure of the ability of a material to support the formation of a magnetic field within itself. - /// - /// - /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Permeability : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PermeabilityUnit? _unit; - - static Permeability() - { - BaseDimensions = new BaseDimensions(1, 1, -2, -2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Permeability, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit HenryPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Permeability() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Permeability(double value, PermeabilityUnit unit) - { - if(unit == PermeabilityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Permeability, which is HenryPerMeter. All conversions go via this value. - /// - public static PermeabilityUnit BaseUnit { get; } = PermeabilityUnit.HenryPerMeter; - - /// - /// Represents the largest possible value of Permeability - /// - public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Permeability - /// - public static Permeability MinValue { get; } = new Permeability(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Permeability; - - /// - /// All units of measurement for the Permeability quantity. - /// - public static PermeabilityUnit[] Units { get; } = Enum.GetValues(typeof(PermeabilityUnit)).Cast().Except(new PermeabilityUnit[]{ PermeabilityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit HenryPerMeter. - /// - public static Permeability Zero { get; } = new Permeability(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PermeabilityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Permeability.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Permeability.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Permeability in HenriesPerMeter. - /// - public double HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PermeabilityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PermeabilityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Permeability from HenriesPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Permeability FromHenriesPerMeter(double henriespermeter) - { - double value = (double) henriespermeter; - return new Permeability(value, PermeabilityUnit.HenryPerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Permeability unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Permeability From(double value, PermeabilityUnit fromUnit) - { - return new Permeability((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Permeability Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Permeability Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Permeability result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Permeability result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PermeabilityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PermeabilityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PermeabilityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PermeabilityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Permeability objPermeability)) throw new ArgumentException("Expected type Permeability.", nameof(obj)); - - return CompareTo(objPermeability); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Permeability other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Permeability objPermeability)) - return false; - - return Equals(objPermeability); - } - - public bool Equals(Permeability other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Permeability within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Permeability. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PermeabilityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PermeabilityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Permeability to another Permeability with the unit representation . - /// - /// A Permeability with the specified unit. - public Permeability ToUnit(PermeabilityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Permeability(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case PermeabilityUnit.HenryPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(PermeabilityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case PermeabilityUnit.HenryPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.g.cs deleted file mode 100644 index 21a5a1eda3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Permittivity.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In electromagnetism, permittivity is the measure of resistance that is encountered when forming an electric field in a particular medium. - /// - /// - /// https://en.wikipedia.org/wiki/Permittivity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Permittivity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PermittivityUnit? _unit; - - static Permittivity() - { - BaseDimensions = new BaseDimensions(-3, -1, 4, 2, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Permittivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit FaradPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Permittivity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Permittivity(double value, PermittivityUnit unit) - { - if(unit == PermittivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Permittivity, which is FaradPerMeter. All conversions go via this value. - /// - public static PermittivityUnit BaseUnit { get; } = PermittivityUnit.FaradPerMeter; - - /// - /// Represents the largest possible value of Permittivity - /// - public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Permittivity - /// - public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Permittivity; - - /// - /// All units of measurement for the Permittivity quantity. - /// - public static PermittivityUnit[] Units { get; } = Enum.GetValues(typeof(PermittivityUnit)).Cast().Except(new PermittivityUnit[]{ PermittivityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit FaradPerMeter. - /// - public static Permittivity Zero { get; } = new Permittivity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PermittivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Permittivity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Permittivity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Permittivity in FaradsPerMeter. - /// - public double FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PermittivityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PermittivityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Permittivity from FaradsPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Permittivity FromFaradsPerMeter(double faradspermeter) - { - double value = (double) faradspermeter; - return new Permittivity(value, PermittivityUnit.FaradPerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Permittivity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Permittivity From(double value, PermittivityUnit fromUnit) - { - return new Permittivity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Permittivity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Permittivity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Permittivity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Permittivity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PermittivityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PermittivityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PermittivityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PermittivityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Permittivity objPermittivity)) throw new ArgumentException("Expected type Permittivity.", nameof(obj)); - - return CompareTo(objPermittivity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Permittivity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Permittivity objPermittivity)) - return false; - - return Equals(objPermittivity); - } - - public bool Equals(Permittivity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Permittivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Permittivity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PermittivityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PermittivityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Permittivity to another Permittivity with the unit representation . - /// - /// A Permittivity with the specified unit. - public Permittivity ToUnit(PermittivityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Permittivity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case PermittivityUnit.FaradPerMeter: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(PermittivityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case PermittivityUnit.FaradPerMeter: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.g.cs deleted file mode 100644 index fb8c263383..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Power.g.cs +++ /dev/null @@ -1,988 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Power : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly decimal _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PowerUnit? _unit; - - static Power() - { - BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Power, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Watt. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Power() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Power(decimal value, PowerUnit unit) - { - if(unit == PowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = value; - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Power, which is Watt. All conversions go via this value. - /// - public static PowerUnit BaseUnit { get; } = PowerUnit.Watt; - - /// - /// Represents the largest possible value of Power - /// - public static Power MaxValue { get; } = new Power(decimal.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Power - /// - public static Power MinValue { get; } = new Power(decimal.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Power; - - /// - /// All units of measurement for the Power quantity. - /// - public static PowerUnit[] Units { get; } = Enum.GetValues(typeof(PowerUnit)).Cast().Except(new PowerUnit[]{ PowerUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Watt. - /// - public static Power Zero { get; } = new Power(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Power.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Power.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Power in BoilerHorsepower. - /// - public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); - - /// - /// Get Power in BritishThermalUnitsPerHour. - /// - public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); - - /// - /// Get Power in Decawatts. - /// - public double Decawatts => As(PowerUnit.Decawatt); - - /// - /// Get Power in Deciwatts. - /// - public double Deciwatts => As(PowerUnit.Deciwatt); - - /// - /// Get Power in ElectricalHorsepower. - /// - public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); - - /// - /// Get Power in Femtowatts. - /// - public double Femtowatts => As(PowerUnit.Femtowatt); - - /// - /// Get Power in GigajoulesPerHour. - /// - public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); - - /// - /// Get Power in Gigawatts. - /// - public double Gigawatts => As(PowerUnit.Gigawatt); - - /// - /// Get Power in HydraulicHorsepower. - /// - public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); - - /// - /// Get Power in JoulesPerHour. - /// - public double JoulesPerHour => As(PowerUnit.JoulePerHour); - - /// - /// Get Power in KilobritishThermalUnitsPerHour. - /// - public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); - - /// - /// Get Power in KilojoulesPerHour. - /// - public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); - - /// - /// Get Power in Kilowatts. - /// - public double Kilowatts => As(PowerUnit.Kilowatt); - - /// - /// Get Power in MechanicalHorsepower. - /// - public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); - - /// - /// Get Power in MegajoulesPerHour. - /// - public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); - - /// - /// Get Power in Megawatts. - /// - public double Megawatts => As(PowerUnit.Megawatt); - - /// - /// Get Power in MetricHorsepower. - /// - public double MetricHorsepower => As(PowerUnit.MetricHorsepower); - - /// - /// Get Power in Microwatts. - /// - public double Microwatts => As(PowerUnit.Microwatt); - - /// - /// Get Power in MillijoulesPerHour. - /// - public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); - - /// - /// Get Power in Milliwatts. - /// - public double Milliwatts => As(PowerUnit.Milliwatt); - - /// - /// Get Power in Nanowatts. - /// - public double Nanowatts => As(PowerUnit.Nanowatt); - - /// - /// Get Power in Petawatts. - /// - public double Petawatts => As(PowerUnit.Petawatt); - - /// - /// Get Power in Picowatts. - /// - public double Picowatts => As(PowerUnit.Picowatt); - - /// - /// Get Power in Terawatts. - /// - public double Terawatts => As(PowerUnit.Terawatt); - - /// - /// Get Power in Watts. - /// - public double Watts => As(PowerUnit.Watt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PowerUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PowerUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Power from BoilerHorsepower. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromBoilerHorsepower(double boilerhorsepower) - { - decimal value = (decimal) boilerhorsepower; - return new Power(value, PowerUnit.BoilerHorsepower); - } - /// - /// Get Power from BritishThermalUnitsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromBritishThermalUnitsPerHour(double britishthermalunitsperhour) - { - decimal value = (decimal) britishthermalunitsperhour; - return new Power(value, PowerUnit.BritishThermalUnitPerHour); - } - /// - /// Get Power from Decawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromDecawatts(double decawatts) - { - decimal value = (decimal) decawatts; - return new Power(value, PowerUnit.Decawatt); - } - /// - /// Get Power from Deciwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromDeciwatts(double deciwatts) - { - decimal value = (decimal) deciwatts; - return new Power(value, PowerUnit.Deciwatt); - } - /// - /// Get Power from ElectricalHorsepower. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromElectricalHorsepower(double electricalhorsepower) - { - decimal value = (decimal) electricalhorsepower; - return new Power(value, PowerUnit.ElectricalHorsepower); - } - /// - /// Get Power from Femtowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromFemtowatts(double femtowatts) - { - decimal value = (decimal) femtowatts; - return new Power(value, PowerUnit.Femtowatt); - } - /// - /// Get Power from GigajoulesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromGigajoulesPerHour(double gigajoulesperhour) - { - decimal value = (decimal) gigajoulesperhour; - return new Power(value, PowerUnit.GigajoulePerHour); - } - /// - /// Get Power from Gigawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromGigawatts(double gigawatts) - { - decimal value = (decimal) gigawatts; - return new Power(value, PowerUnit.Gigawatt); - } - /// - /// Get Power from HydraulicHorsepower. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromHydraulicHorsepower(double hydraulichorsepower) - { - decimal value = (decimal) hydraulichorsepower; - return new Power(value, PowerUnit.HydraulicHorsepower); - } - /// - /// Get Power from JoulesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromJoulesPerHour(double joulesperhour) - { - decimal value = (decimal) joulesperhour; - return new Power(value, PowerUnit.JoulePerHour); - } - /// - /// Get Power from KilobritishThermalUnitsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromKilobritishThermalUnitsPerHour(double kilobritishthermalunitsperhour) - { - decimal value = (decimal) kilobritishthermalunitsperhour; - return new Power(value, PowerUnit.KilobritishThermalUnitPerHour); - } - /// - /// Get Power from KilojoulesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromKilojoulesPerHour(double kilojoulesperhour) - { - decimal value = (decimal) kilojoulesperhour; - return new Power(value, PowerUnit.KilojoulePerHour); - } - /// - /// Get Power from Kilowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromKilowatts(double kilowatts) - { - decimal value = (decimal) kilowatts; - return new Power(value, PowerUnit.Kilowatt); - } - /// - /// Get Power from MechanicalHorsepower. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMechanicalHorsepower(double mechanicalhorsepower) - { - decimal value = (decimal) mechanicalhorsepower; - return new Power(value, PowerUnit.MechanicalHorsepower); - } - /// - /// Get Power from MegajoulesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMegajoulesPerHour(double megajoulesperhour) - { - decimal value = (decimal) megajoulesperhour; - return new Power(value, PowerUnit.MegajoulePerHour); - } - /// - /// Get Power from Megawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMegawatts(double megawatts) - { - decimal value = (decimal) megawatts; - return new Power(value, PowerUnit.Megawatt); - } - /// - /// Get Power from MetricHorsepower. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMetricHorsepower(double metrichorsepower) - { - decimal value = (decimal) metrichorsepower; - return new Power(value, PowerUnit.MetricHorsepower); - } - /// - /// Get Power from Microwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMicrowatts(double microwatts) - { - decimal value = (decimal) microwatts; - return new Power(value, PowerUnit.Microwatt); - } - /// - /// Get Power from MillijoulesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMillijoulesPerHour(double millijoulesperhour) - { - decimal value = (decimal) millijoulesperhour; - return new Power(value, PowerUnit.MillijoulePerHour); - } - /// - /// Get Power from Milliwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromMilliwatts(double milliwatts) - { - decimal value = (decimal) milliwatts; - return new Power(value, PowerUnit.Milliwatt); - } - /// - /// Get Power from Nanowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromNanowatts(double nanowatts) - { - decimal value = (decimal) nanowatts; - return new Power(value, PowerUnit.Nanowatt); - } - /// - /// Get Power from Petawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromPetawatts(double petawatts) - { - decimal value = (decimal) petawatts; - return new Power(value, PowerUnit.Petawatt); - } - /// - /// Get Power from Picowatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromPicowatts(double picowatts) - { - decimal value = (decimal) picowatts; - return new Power(value, PowerUnit.Picowatt); - } - /// - /// Get Power from Terawatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromTerawatts(double terawatts) - { - decimal value = (decimal) terawatts; - return new Power(value, PowerUnit.Terawatt); - } - /// - /// Get Power from Watts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Power FromWatts(double watts) - { - decimal value = (decimal) watts; - return new Power(value, PowerUnit.Watt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Power unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Power From(double value, PowerUnit fromUnit) - { - return new Power((decimal)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Power Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Power Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Power result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Power result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PowerUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PowerUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PowerUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PowerUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Power objPower)) throw new ArgumentException("Expected type Power.", nameof(obj)); - - return CompareTo(objPower); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Power other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Power objPower)) - return false; - - return Equals(objPower); - } - - public bool Equals(Power other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Power within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Power other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Power. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PowerUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PowerUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Power to another Power with the unit representation . - /// - /// A Power with the specified unit. - public Power ToUnit(PowerUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Power(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private decimal AsBaseUnit() - { - switch(Unit) - { - case PowerUnit.BoilerHorsepower: return _value*9812.5m; - case PowerUnit.BritishThermalUnitPerHour: return _value*0.293071m; - case PowerUnit.Decawatt: return (_value) * 1e1m; - case PowerUnit.Deciwatt: return (_value) * 1e-1m; - case PowerUnit.ElectricalHorsepower: return _value*746m; - case PowerUnit.Femtowatt: return (_value) * 1e-15m; - case PowerUnit.GigajoulePerHour: return (_value/3600m) * 1e9m; - case PowerUnit.Gigawatt: return (_value) * 1e9m; - case PowerUnit.HydraulicHorsepower: return _value*745.69988145m; - case PowerUnit.JoulePerHour: return _value/3600m; - case PowerUnit.KilobritishThermalUnitPerHour: return (_value*0.293071m) * 1e3m; - case PowerUnit.KilojoulePerHour: return (_value/3600m) * 1e3m; - case PowerUnit.Kilowatt: return (_value) * 1e3m; - case PowerUnit.MechanicalHorsepower: return _value*745.69m; - case PowerUnit.MegajoulePerHour: return (_value/3600m) * 1e6m; - case PowerUnit.Megawatt: return (_value) * 1e6m; - case PowerUnit.MetricHorsepower: return _value*735.49875m; - case PowerUnit.Microwatt: return (_value) * 1e-6m; - case PowerUnit.MillijoulePerHour: return (_value/3600m) * 1e-3m; - case PowerUnit.Milliwatt: return (_value) * 1e-3m; - case PowerUnit.Nanowatt: return (_value) * 1e-9m; - case PowerUnit.Petawatt: return (_value) * 1e15m; - case PowerUnit.Picowatt: return (_value) * 1e-12m; - case PowerUnit.Terawatt: return (_value) * 1e12m; - case PowerUnit.Watt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private decimal AsBaseNumericType(PowerUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case PowerUnit.BoilerHorsepower: return baseUnitValue/9812.5m; - case PowerUnit.BritishThermalUnitPerHour: return baseUnitValue/0.293071m; - case PowerUnit.Decawatt: return (baseUnitValue) / 1e1m; - case PowerUnit.Deciwatt: return (baseUnitValue) / 1e-1m; - case PowerUnit.ElectricalHorsepower: return baseUnitValue/746m; - case PowerUnit.Femtowatt: return (baseUnitValue) / 1e-15m; - case PowerUnit.GigajoulePerHour: return (baseUnitValue*3600m) / 1e9m; - case PowerUnit.Gigawatt: return (baseUnitValue) / 1e9m; - case PowerUnit.HydraulicHorsepower: return baseUnitValue/745.69988145m; - case PowerUnit.JoulePerHour: return baseUnitValue*3600m; - case PowerUnit.KilobritishThermalUnitPerHour: return (baseUnitValue/0.293071m) / 1e3m; - case PowerUnit.KilojoulePerHour: return (baseUnitValue*3600m) / 1e3m; - case PowerUnit.Kilowatt: return (baseUnitValue) / 1e3m; - case PowerUnit.MechanicalHorsepower: return baseUnitValue/745.69m; - case PowerUnit.MegajoulePerHour: return (baseUnitValue*3600m) / 1e6m; - case PowerUnit.Megawatt: return (baseUnitValue) / 1e6m; - case PowerUnit.MetricHorsepower: return baseUnitValue/735.49875m; - case PowerUnit.Microwatt: return (baseUnitValue) / 1e-6m; - case PowerUnit.MillijoulePerHour: return (baseUnitValue*3600m) / 1e-3m; - case PowerUnit.Milliwatt: return (baseUnitValue) / 1e-3m; - case PowerUnit.Nanowatt: return (baseUnitValue) / 1e-9m; - case PowerUnit.Petawatt: return (baseUnitValue) / 1e15m; - case PowerUnit.Picowatt: return (baseUnitValue) / 1e-12m; - case PowerUnit.Terawatt: return (baseUnitValue) / 1e12m; - case PowerUnit.Watt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.g.cs deleted file mode 100644 index e374a600e1..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerDensity.g.cs +++ /dev/null @@ -1,1311 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The amount of power in a volume. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class PowerDensity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PowerDensityUnit? _unit; - - static PowerDensity() - { - BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.PowerDensity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit WattPerCubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public PowerDensity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private PowerDensity(double value, PowerDensityUnit unit) - { - if(unit == PowerDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of PowerDensity, which is WattPerCubicMeter. All conversions go via this value. - /// - public static PowerDensityUnit BaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; - - /// - /// Represents the largest possible value of PowerDensity - /// - public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of PowerDensity - /// - public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.PowerDensity; - - /// - /// All units of measurement for the PowerDensity quantity. - /// - public static PowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(PowerDensityUnit)).Cast().Except(new PowerDensityUnit[]{ PowerDensityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit WattPerCubicMeter. - /// - public static PowerDensity Zero { get; } = new PowerDensity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => PowerDensity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => PowerDensity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get PowerDensity in DecawattsPerCubicFoot. - /// - public double DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); - - /// - /// Get PowerDensity in DecawattsPerCubicInch. - /// - public double DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); - - /// - /// Get PowerDensity in DecawattsPerCubicMeter. - /// - public double DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); - - /// - /// Get PowerDensity in DecawattsPerLiter. - /// - public double DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); - - /// - /// Get PowerDensity in DeciwattsPerCubicFoot. - /// - public double DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); - - /// - /// Get PowerDensity in DeciwattsPerCubicInch. - /// - public double DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); - - /// - /// Get PowerDensity in DeciwattsPerCubicMeter. - /// - public double DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); - - /// - /// Get PowerDensity in DeciwattsPerLiter. - /// - public double DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); - - /// - /// Get PowerDensity in GigawattsPerCubicFoot. - /// - public double GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); - - /// - /// Get PowerDensity in GigawattsPerCubicInch. - /// - public double GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); - - /// - /// Get PowerDensity in GigawattsPerCubicMeter. - /// - public double GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); - - /// - /// Get PowerDensity in GigawattsPerLiter. - /// - public double GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); - - /// - /// Get PowerDensity in KilowattsPerCubicFoot. - /// - public double KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); - - /// - /// Get PowerDensity in KilowattsPerCubicInch. - /// - public double KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); - - /// - /// Get PowerDensity in KilowattsPerCubicMeter. - /// - public double KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); - - /// - /// Get PowerDensity in KilowattsPerLiter. - /// - public double KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); - - /// - /// Get PowerDensity in MegawattsPerCubicFoot. - /// - public double MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); - - /// - /// Get PowerDensity in MegawattsPerCubicInch. - /// - public double MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); - - /// - /// Get PowerDensity in MegawattsPerCubicMeter. - /// - public double MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); - - /// - /// Get PowerDensity in MegawattsPerLiter. - /// - public double MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); - - /// - /// Get PowerDensity in MicrowattsPerCubicFoot. - /// - public double MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); - - /// - /// Get PowerDensity in MicrowattsPerCubicInch. - /// - public double MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); - - /// - /// Get PowerDensity in MicrowattsPerCubicMeter. - /// - public double MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); - - /// - /// Get PowerDensity in MicrowattsPerLiter. - /// - public double MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); - - /// - /// Get PowerDensity in MilliwattsPerCubicFoot. - /// - public double MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); - - /// - /// Get PowerDensity in MilliwattsPerCubicInch. - /// - public double MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); - - /// - /// Get PowerDensity in MilliwattsPerCubicMeter. - /// - public double MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); - - /// - /// Get PowerDensity in MilliwattsPerLiter. - /// - public double MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); - - /// - /// Get PowerDensity in NanowattsPerCubicFoot. - /// - public double NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); - - /// - /// Get PowerDensity in NanowattsPerCubicInch. - /// - public double NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); - - /// - /// Get PowerDensity in NanowattsPerCubicMeter. - /// - public double NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); - - /// - /// Get PowerDensity in NanowattsPerLiter. - /// - public double NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); - - /// - /// Get PowerDensity in PicowattsPerCubicFoot. - /// - public double PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); - - /// - /// Get PowerDensity in PicowattsPerCubicInch. - /// - public double PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); - - /// - /// Get PowerDensity in PicowattsPerCubicMeter. - /// - public double PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); - - /// - /// Get PowerDensity in PicowattsPerLiter. - /// - public double PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); - - /// - /// Get PowerDensity in TerawattsPerCubicFoot. - /// - public double TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); - - /// - /// Get PowerDensity in TerawattsPerCubicInch. - /// - public double TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); - - /// - /// Get PowerDensity in TerawattsPerCubicMeter. - /// - public double TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); - - /// - /// Get PowerDensity in TerawattsPerLiter. - /// - public double TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); - - /// - /// Get PowerDensity in WattsPerCubicFoot. - /// - public double WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); - - /// - /// Get PowerDensity in WattsPerCubicInch. - /// - public double WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); - - /// - /// Get PowerDensity in WattsPerCubicMeter. - /// - public double WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); - - /// - /// Get PowerDensity in WattsPerLiter. - /// - public double WattsPerLiter => As(PowerDensityUnit.WattPerLiter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PowerDensityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PowerDensityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get PowerDensity from DecawattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDecawattsPerCubicFoot(double decawattspercubicfoot) - { - double value = (double) decawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicFoot); - } - /// - /// Get PowerDensity from DecawattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDecawattsPerCubicInch(double decawattspercubicinch) - { - double value = (double) decawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicInch); - } - /// - /// Get PowerDensity from DecawattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDecawattsPerCubicMeter(double decawattspercubicmeter) - { - double value = (double) decawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicMeter); - } - /// - /// Get PowerDensity from DecawattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDecawattsPerLiter(double decawattsperliter) - { - double value = (double) decawattsperliter; - return new PowerDensity(value, PowerDensityUnit.DecawattPerLiter); - } - /// - /// Get PowerDensity from DeciwattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDeciwattsPerCubicFoot(double deciwattspercubicfoot) - { - double value = (double) deciwattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicFoot); - } - /// - /// Get PowerDensity from DeciwattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDeciwattsPerCubicInch(double deciwattspercubicinch) - { - double value = (double) deciwattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicInch); - } - /// - /// Get PowerDensity from DeciwattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDeciwattsPerCubicMeter(double deciwattspercubicmeter) - { - double value = (double) deciwattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicMeter); - } - /// - /// Get PowerDensity from DeciwattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromDeciwattsPerLiter(double deciwattsperliter) - { - double value = (double) deciwattsperliter; - return new PowerDensity(value, PowerDensityUnit.DeciwattPerLiter); - } - /// - /// Get PowerDensity from GigawattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromGigawattsPerCubicFoot(double gigawattspercubicfoot) - { - double value = (double) gigawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicFoot); - } - /// - /// Get PowerDensity from GigawattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromGigawattsPerCubicInch(double gigawattspercubicinch) - { - double value = (double) gigawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicInch); - } - /// - /// Get PowerDensity from GigawattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromGigawattsPerCubicMeter(double gigawattspercubicmeter) - { - double value = (double) gigawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicMeter); - } - /// - /// Get PowerDensity from GigawattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromGigawattsPerLiter(double gigawattsperliter) - { - double value = (double) gigawattsperliter; - return new PowerDensity(value, PowerDensityUnit.GigawattPerLiter); - } - /// - /// Get PowerDensity from KilowattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromKilowattsPerCubicFoot(double kilowattspercubicfoot) - { - double value = (double) kilowattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicFoot); - } - /// - /// Get PowerDensity from KilowattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromKilowattsPerCubicInch(double kilowattspercubicinch) - { - double value = (double) kilowattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicInch); - } - /// - /// Get PowerDensity from KilowattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromKilowattsPerCubicMeter(double kilowattspercubicmeter) - { - double value = (double) kilowattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicMeter); - } - /// - /// Get PowerDensity from KilowattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromKilowattsPerLiter(double kilowattsperliter) - { - double value = (double) kilowattsperliter; - return new PowerDensity(value, PowerDensityUnit.KilowattPerLiter); - } - /// - /// Get PowerDensity from MegawattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMegawattsPerCubicFoot(double megawattspercubicfoot) - { - double value = (double) megawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicFoot); - } - /// - /// Get PowerDensity from MegawattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMegawattsPerCubicInch(double megawattspercubicinch) - { - double value = (double) megawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicInch); - } - /// - /// Get PowerDensity from MegawattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMegawattsPerCubicMeter(double megawattspercubicmeter) - { - double value = (double) megawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicMeter); - } - /// - /// Get PowerDensity from MegawattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMegawattsPerLiter(double megawattsperliter) - { - double value = (double) megawattsperliter; - return new PowerDensity(value, PowerDensityUnit.MegawattPerLiter); - } - /// - /// Get PowerDensity from MicrowattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMicrowattsPerCubicFoot(double microwattspercubicfoot) - { - double value = (double) microwattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicFoot); - } - /// - /// Get PowerDensity from MicrowattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMicrowattsPerCubicInch(double microwattspercubicinch) - { - double value = (double) microwattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicInch); - } - /// - /// Get PowerDensity from MicrowattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMicrowattsPerCubicMeter(double microwattspercubicmeter) - { - double value = (double) microwattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicMeter); - } - /// - /// Get PowerDensity from MicrowattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMicrowattsPerLiter(double microwattsperliter) - { - double value = (double) microwattsperliter; - return new PowerDensity(value, PowerDensityUnit.MicrowattPerLiter); - } - /// - /// Get PowerDensity from MilliwattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMilliwattsPerCubicFoot(double milliwattspercubicfoot) - { - double value = (double) milliwattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicFoot); - } - /// - /// Get PowerDensity from MilliwattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMilliwattsPerCubicInch(double milliwattspercubicinch) - { - double value = (double) milliwattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicInch); - } - /// - /// Get PowerDensity from MilliwattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMilliwattsPerCubicMeter(double milliwattspercubicmeter) - { - double value = (double) milliwattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicMeter); - } - /// - /// Get PowerDensity from MilliwattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromMilliwattsPerLiter(double milliwattsperliter) - { - double value = (double) milliwattsperliter; - return new PowerDensity(value, PowerDensityUnit.MilliwattPerLiter); - } - /// - /// Get PowerDensity from NanowattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromNanowattsPerCubicFoot(double nanowattspercubicfoot) - { - double value = (double) nanowattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicFoot); - } - /// - /// Get PowerDensity from NanowattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromNanowattsPerCubicInch(double nanowattspercubicinch) - { - double value = (double) nanowattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicInch); - } - /// - /// Get PowerDensity from NanowattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromNanowattsPerCubicMeter(double nanowattspercubicmeter) - { - double value = (double) nanowattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicMeter); - } - /// - /// Get PowerDensity from NanowattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromNanowattsPerLiter(double nanowattsperliter) - { - double value = (double) nanowattsperliter; - return new PowerDensity(value, PowerDensityUnit.NanowattPerLiter); - } - /// - /// Get PowerDensity from PicowattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromPicowattsPerCubicFoot(double picowattspercubicfoot) - { - double value = (double) picowattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicFoot); - } - /// - /// Get PowerDensity from PicowattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromPicowattsPerCubicInch(double picowattspercubicinch) - { - double value = (double) picowattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicInch); - } - /// - /// Get PowerDensity from PicowattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromPicowattsPerCubicMeter(double picowattspercubicmeter) - { - double value = (double) picowattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicMeter); - } - /// - /// Get PowerDensity from PicowattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromPicowattsPerLiter(double picowattsperliter) - { - double value = (double) picowattsperliter; - return new PowerDensity(value, PowerDensityUnit.PicowattPerLiter); - } - /// - /// Get PowerDensity from TerawattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromTerawattsPerCubicFoot(double terawattspercubicfoot) - { - double value = (double) terawattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicFoot); - } - /// - /// Get PowerDensity from TerawattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromTerawattsPerCubicInch(double terawattspercubicinch) - { - double value = (double) terawattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicInch); - } - /// - /// Get PowerDensity from TerawattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromTerawattsPerCubicMeter(double terawattspercubicmeter) - { - double value = (double) terawattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicMeter); - } - /// - /// Get PowerDensity from TerawattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromTerawattsPerLiter(double terawattsperliter) - { - double value = (double) terawattsperliter; - return new PowerDensity(value, PowerDensityUnit.TerawattPerLiter); - } - /// - /// Get PowerDensity from WattsPerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromWattsPerCubicFoot(double wattspercubicfoot) - { - double value = (double) wattspercubicfoot; - return new PowerDensity(value, PowerDensityUnit.WattPerCubicFoot); - } - /// - /// Get PowerDensity from WattsPerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromWattsPerCubicInch(double wattspercubicinch) - { - double value = (double) wattspercubicinch; - return new PowerDensity(value, PowerDensityUnit.WattPerCubicInch); - } - /// - /// Get PowerDensity from WattsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromWattsPerCubicMeter(double wattspercubicmeter) - { - double value = (double) wattspercubicmeter; - return new PowerDensity(value, PowerDensityUnit.WattPerCubicMeter); - } - /// - /// Get PowerDensity from WattsPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerDensity FromWattsPerLiter(double wattsperliter) - { - double value = (double) wattsperliter; - return new PowerDensity(value, PowerDensityUnit.WattPerLiter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// PowerDensity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static PowerDensity From(double value, PowerDensityUnit fromUnit) - { - return new PowerDensity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static PowerDensity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PowerDensity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out PowerDensity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out PowerDensity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PowerDensityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PowerDensityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PowerDensityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PowerDensityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is PowerDensity objPowerDensity)) throw new ArgumentException("Expected type PowerDensity.", nameof(obj)); - - return CompareTo(objPowerDensity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(PowerDensity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is PowerDensity objPowerDensity)) - return false; - - return Equals(objPowerDensity); - } - - public bool Equals(PowerDensity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another PowerDensity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current PowerDensity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PowerDensityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PowerDensityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this PowerDensity to another PowerDensity with the unit representation . - /// - /// A PowerDensity with the specified unit. - public PowerDensity ToUnit(PowerDensityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new PowerDensity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(PowerDensityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.g.cs deleted file mode 100644 index 56e646575b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PowerRatio.g.cs +++ /dev/null @@ -1,597 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The strength of a signal expressed in decibels (dB) relative to one watt. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class PowerRatio : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PowerRatioUnit? _unit; - - static PowerRatio() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.PowerRatio, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DecibelWatt. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public PowerRatio() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private PowerRatio(double value, PowerRatioUnit unit) - { - if(unit == PowerRatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of PowerRatio, which is DecibelWatt. All conversions go via this value. - /// - public static PowerRatioUnit BaseUnit { get; } = PowerRatioUnit.DecibelWatt; - - /// - /// Represents the largest possible value of PowerRatio - /// - public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of PowerRatio - /// - public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.PowerRatio; - - /// - /// All units of measurement for the PowerRatio quantity. - /// - public static PowerRatioUnit[] Units { get; } = Enum.GetValues(typeof(PowerRatioUnit)).Cast().Except(new PowerRatioUnit[]{ PowerRatioUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DecibelWatt. - /// - public static PowerRatio Zero { get; } = new PowerRatio(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PowerRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => PowerRatio.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => PowerRatio.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get PowerRatio in DecibelMilliwatts. - /// - public double DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); - - /// - /// Get PowerRatio in DecibelWatts. - /// - public double DecibelWatts => As(PowerRatioUnit.DecibelWatt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PowerRatioUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PowerRatioUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get PowerRatio from DecibelMilliwatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerRatio FromDecibelMilliwatts(double decibelmilliwatts) - { - double value = (double) decibelmilliwatts; - return new PowerRatio(value, PowerRatioUnit.DecibelMilliwatt); - } - /// - /// Get PowerRatio from DecibelWatts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PowerRatio FromDecibelWatts(double decibelwatts) - { - double value = (double) decibelwatts; - return new PowerRatio(value, PowerRatioUnit.DecibelWatt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// PowerRatio unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static PowerRatio From(double value, PowerRatioUnit fromUnit) - { - return new PowerRatio((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static PowerRatio Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PowerRatio Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out PowerRatio result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out PowerRatio result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PowerRatioUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PowerRatioUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PowerRatioUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PowerRatioUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is PowerRatio objPowerRatio)) throw new ArgumentException("Expected type PowerRatio.", nameof(obj)); - - return CompareTo(objPowerRatio); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(PowerRatio other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is PowerRatio objPowerRatio)) - return false; - - return Equals(objPowerRatio); - } - - public bool Equals(PowerRatio other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another PowerRatio within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current PowerRatio. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PowerRatioUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PowerRatioUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this PowerRatio to another PowerRatio with the unit representation . - /// - /// A PowerRatio with the specified unit. - public PowerRatio ToUnit(PowerRatioUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new PowerRatio(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case PowerRatioUnit.DecibelMilliwatt: return _value - 30; - case PowerRatioUnit.DecibelWatt: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(PowerRatioUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case PowerRatioUnit.DecibelMilliwatt: return baseUnitValue + 30; - case PowerRatioUnit.DecibelWatt: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.g.cs deleted file mode 100644 index 4e242094bb..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Pressure.g.cs +++ /dev/null @@ -1,1311 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Pressure : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PressureUnit? _unit; - - static Pressure() - { - BaseDimensions = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Pressure, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Pascal. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Pressure() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Pressure(double value, PressureUnit unit) - { - if(unit == PressureUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Pressure, which is Pascal. All conversions go via this value. - /// - public static PressureUnit BaseUnit { get; } = PressureUnit.Pascal; - - /// - /// Represents the largest possible value of Pressure - /// - public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Pressure - /// - public static Pressure MinValue { get; } = new Pressure(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Pressure; - - /// - /// All units of measurement for the Pressure quantity. - /// - public static PressureUnit[] Units { get; } = Enum.GetValues(typeof(PressureUnit)).Cast().Except(new PressureUnit[]{ PressureUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Pascal. - /// - public static Pressure Zero { get; } = new Pressure(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PressureUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Pressure.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Pressure.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Pressure in Atmospheres. - /// - public double Atmospheres => As(PressureUnit.Atmosphere); - - /// - /// Get Pressure in Bars. - /// - public double Bars => As(PressureUnit.Bar); - - /// - /// Get Pressure in Centibars. - /// - public double Centibars => As(PressureUnit.Centibar); - - /// - /// Get Pressure in Decapascals. - /// - public double Decapascals => As(PressureUnit.Decapascal); - - /// - /// Get Pressure in Decibars. - /// - public double Decibars => As(PressureUnit.Decibar); - - /// - /// Get Pressure in DynesPerSquareCentimeter. - /// - public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); - - /// - /// Get Pressure in FeetOfElevation. - /// - public double FeetOfElevation => As(PressureUnit.FootOfElevation); - - /// - /// Get Pressure in FeetOfHead. - /// - public double FeetOfHead => As(PressureUnit.FootOfHead); - - /// - /// Get Pressure in Gigapascals. - /// - public double Gigapascals => As(PressureUnit.Gigapascal); - - /// - /// Get Pressure in Hectopascals. - /// - public double Hectopascals => As(PressureUnit.Hectopascal); - - /// - /// Get Pressure in InchesOfMercury. - /// - public double InchesOfMercury => As(PressureUnit.InchOfMercury); - - /// - /// Get Pressure in InchesOfWaterColumn. - /// - public double InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); - - /// - /// Get Pressure in Kilobars. - /// - public double Kilobars => As(PressureUnit.Kilobar); - - /// - /// Get Pressure in KilogramsForcePerSquareCentimeter. - /// - public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); - - /// - /// Get Pressure in KilogramsForcePerSquareMeter. - /// - public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); - - /// - /// Get Pressure in KilogramsForcePerSquareMillimeter. - /// - public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); - - /// - /// Get Pressure in KilonewtonsPerSquareCentimeter. - /// - public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); - - /// - /// Get Pressure in KilonewtonsPerSquareMeter. - /// - public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); - - /// - /// Get Pressure in KilonewtonsPerSquareMillimeter. - /// - public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); - - /// - /// Get Pressure in Kilopascals. - /// - public double Kilopascals => As(PressureUnit.Kilopascal); - - /// - /// Get Pressure in KilopoundsForcePerSquareFoot. - /// - public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); - - /// - /// Get Pressure in KilopoundsForcePerSquareInch. - /// - public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); - - /// - /// Get Pressure in Megabars. - /// - public double Megabars => As(PressureUnit.Megabar); - - /// - /// Get Pressure in MeganewtonsPerSquareMeter. - /// - public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); - - /// - /// Get Pressure in Megapascals. - /// - public double Megapascals => As(PressureUnit.Megapascal); - - /// - /// Get Pressure in MetersOfElevation. - /// - public double MetersOfElevation => As(PressureUnit.MeterOfElevation); - - /// - /// Get Pressure in MetersOfHead. - /// - public double MetersOfHead => As(PressureUnit.MeterOfHead); - - /// - /// Get Pressure in Microbars. - /// - public double Microbars => As(PressureUnit.Microbar); - - /// - /// Get Pressure in Micropascals. - /// - public double Micropascals => As(PressureUnit.Micropascal); - - /// - /// Get Pressure in Millibars. - /// - public double Millibars => As(PressureUnit.Millibar); - - /// - /// Get Pressure in MillimetersOfMercury. - /// - public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); - - /// - /// Get Pressure in Millipascals. - /// - public double Millipascals => As(PressureUnit.Millipascal); - - /// - /// Get Pressure in NewtonsPerSquareCentimeter. - /// - public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); - - /// - /// Get Pressure in NewtonsPerSquareMeter. - /// - public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); - - /// - /// Get Pressure in NewtonsPerSquareMillimeter. - /// - public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); - - /// - /// Get Pressure in Pascals. - /// - public double Pascals => As(PressureUnit.Pascal); - - /// - /// Get Pressure in PoundsForcePerSquareFoot. - /// - public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); - - /// - /// Get Pressure in PoundsForcePerSquareInch. - /// - public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); - - /// - /// Get Pressure in PoundsPerInchSecondSquared. - /// - public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); - - /// - /// Get Pressure in TechnicalAtmospheres. - /// - public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); - - /// - /// Get Pressure in TonnesForcePerSquareCentimeter. - /// - public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); - - /// - /// Get Pressure in TonnesForcePerSquareMeter. - /// - public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); - - /// - /// Get Pressure in TonnesForcePerSquareMillimeter. - /// - public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); - - /// - /// Get Pressure in Torrs. - /// - public double Torrs => As(PressureUnit.Torr); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PressureUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PressureUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Pressure from Atmospheres. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromAtmospheres(double atmospheres) - { - double value = (double) atmospheres; - return new Pressure(value, PressureUnit.Atmosphere); - } - /// - /// Get Pressure from Bars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromBars(double bars) - { - double value = (double) bars; - return new Pressure(value, PressureUnit.Bar); - } - /// - /// Get Pressure from Centibars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromCentibars(double centibars) - { - double value = (double) centibars; - return new Pressure(value, PressureUnit.Centibar); - } - /// - /// Get Pressure from Decapascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromDecapascals(double decapascals) - { - double value = (double) decapascals; - return new Pressure(value, PressureUnit.Decapascal); - } - /// - /// Get Pressure from Decibars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromDecibars(double decibars) - { - double value = (double) decibars; - return new Pressure(value, PressureUnit.Decibar); - } - /// - /// Get Pressure from DynesPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromDynesPerSquareCentimeter(double dynespersquarecentimeter) - { - double value = (double) dynespersquarecentimeter; - return new Pressure(value, PressureUnit.DynePerSquareCentimeter); - } - /// - /// Get Pressure from FeetOfElevation. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromFeetOfElevation(double feetofelevation) - { - double value = (double) feetofelevation; - return new Pressure(value, PressureUnit.FootOfElevation); - } - /// - /// Get Pressure from FeetOfHead. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromFeetOfHead(double feetofhead) - { - double value = (double) feetofhead; - return new Pressure(value, PressureUnit.FootOfHead); - } - /// - /// Get Pressure from Gigapascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromGigapascals(double gigapascals) - { - double value = (double) gigapascals; - return new Pressure(value, PressureUnit.Gigapascal); - } - /// - /// Get Pressure from Hectopascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromHectopascals(double hectopascals) - { - double value = (double) hectopascals; - return new Pressure(value, PressureUnit.Hectopascal); - } - /// - /// Get Pressure from InchesOfMercury. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromInchesOfMercury(double inchesofmercury) - { - double value = (double) inchesofmercury; - return new Pressure(value, PressureUnit.InchOfMercury); - } - /// - /// Get Pressure from InchesOfWaterColumn. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromInchesOfWaterColumn(double inchesofwatercolumn) - { - double value = (double) inchesofwatercolumn; - return new Pressure(value, PressureUnit.InchOfWaterColumn); - } - /// - /// Get Pressure from Kilobars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilobars(double kilobars) - { - double value = (double) kilobars; - return new Pressure(value, PressureUnit.Kilobar); - } - /// - /// Get Pressure from KilogramsForcePerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilogramsForcePerSquareCentimeter(double kilogramsforcepersquarecentimeter) - { - double value = (double) kilogramsforcepersquarecentimeter; - return new Pressure(value, PressureUnit.KilogramForcePerSquareCentimeter); - } - /// - /// Get Pressure from KilogramsForcePerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilogramsForcePerSquareMeter(double kilogramsforcepersquaremeter) - { - double value = (double) kilogramsforcepersquaremeter; - return new Pressure(value, PressureUnit.KilogramForcePerSquareMeter); - } - /// - /// Get Pressure from KilogramsForcePerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilogramsForcePerSquareMillimeter(double kilogramsforcepersquaremillimeter) - { - double value = (double) kilogramsforcepersquaremillimeter; - return new Pressure(value, PressureUnit.KilogramForcePerSquareMillimeter); - } - /// - /// Get Pressure from KilonewtonsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilonewtonsPerSquareCentimeter(double kilonewtonspersquarecentimeter) - { - double value = (double) kilonewtonspersquarecentimeter; - return new Pressure(value, PressureUnit.KilonewtonPerSquareCentimeter); - } - /// - /// Get Pressure from KilonewtonsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilonewtonsPerSquareMeter(double kilonewtonspersquaremeter) - { - double value = (double) kilonewtonspersquaremeter; - return new Pressure(value, PressureUnit.KilonewtonPerSquareMeter); - } - /// - /// Get Pressure from KilonewtonsPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilonewtonsPerSquareMillimeter(double kilonewtonspersquaremillimeter) - { - double value = (double) kilonewtonspersquaremillimeter; - return new Pressure(value, PressureUnit.KilonewtonPerSquareMillimeter); - } - /// - /// Get Pressure from Kilopascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilopascals(double kilopascals) - { - double value = (double) kilopascals; - return new Pressure(value, PressureUnit.Kilopascal); - } - /// - /// Get Pressure from KilopoundsForcePerSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilopoundsForcePerSquareFoot(double kilopoundsforcepersquarefoot) - { - double value = (double) kilopoundsforcepersquarefoot; - return new Pressure(value, PressureUnit.KilopoundForcePerSquareFoot); - } - /// - /// Get Pressure from KilopoundsForcePerSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromKilopoundsForcePerSquareInch(double kilopoundsforcepersquareinch) - { - double value = (double) kilopoundsforcepersquareinch; - return new Pressure(value, PressureUnit.KilopoundForcePerSquareInch); - } - /// - /// Get Pressure from Megabars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMegabars(double megabars) - { - double value = (double) megabars; - return new Pressure(value, PressureUnit.Megabar); - } - /// - /// Get Pressure from MeganewtonsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMeganewtonsPerSquareMeter(double meganewtonspersquaremeter) - { - double value = (double) meganewtonspersquaremeter; - return new Pressure(value, PressureUnit.MeganewtonPerSquareMeter); - } - /// - /// Get Pressure from Megapascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMegapascals(double megapascals) - { - double value = (double) megapascals; - return new Pressure(value, PressureUnit.Megapascal); - } - /// - /// Get Pressure from MetersOfElevation. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMetersOfElevation(double metersofelevation) - { - double value = (double) metersofelevation; - return new Pressure(value, PressureUnit.MeterOfElevation); - } - /// - /// Get Pressure from MetersOfHead. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMetersOfHead(double metersofhead) - { - double value = (double) metersofhead; - return new Pressure(value, PressureUnit.MeterOfHead); - } - /// - /// Get Pressure from Microbars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMicrobars(double microbars) - { - double value = (double) microbars; - return new Pressure(value, PressureUnit.Microbar); - } - /// - /// Get Pressure from Micropascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMicropascals(double micropascals) - { - double value = (double) micropascals; - return new Pressure(value, PressureUnit.Micropascal); - } - /// - /// Get Pressure from Millibars. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMillibars(double millibars) - { - double value = (double) millibars; - return new Pressure(value, PressureUnit.Millibar); - } - /// - /// Get Pressure from MillimetersOfMercury. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMillimetersOfMercury(double millimetersofmercury) - { - double value = (double) millimetersofmercury; - return new Pressure(value, PressureUnit.MillimeterOfMercury); - } - /// - /// Get Pressure from Millipascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromMillipascals(double millipascals) - { - double value = (double) millipascals; - return new Pressure(value, PressureUnit.Millipascal); - } - /// - /// Get Pressure from NewtonsPerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromNewtonsPerSquareCentimeter(double newtonspersquarecentimeter) - { - double value = (double) newtonspersquarecentimeter; - return new Pressure(value, PressureUnit.NewtonPerSquareCentimeter); - } - /// - /// Get Pressure from NewtonsPerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromNewtonsPerSquareMeter(double newtonspersquaremeter) - { - double value = (double) newtonspersquaremeter; - return new Pressure(value, PressureUnit.NewtonPerSquareMeter); - } - /// - /// Get Pressure from NewtonsPerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromNewtonsPerSquareMillimeter(double newtonspersquaremillimeter) - { - double value = (double) newtonspersquaremillimeter; - return new Pressure(value, PressureUnit.NewtonPerSquareMillimeter); - } - /// - /// Get Pressure from Pascals. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromPascals(double pascals) - { - double value = (double) pascals; - return new Pressure(value, PressureUnit.Pascal); - } - /// - /// Get Pressure from PoundsForcePerSquareFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromPoundsForcePerSquareFoot(double poundsforcepersquarefoot) - { - double value = (double) poundsforcepersquarefoot; - return new Pressure(value, PressureUnit.PoundForcePerSquareFoot); - } - /// - /// Get Pressure from PoundsForcePerSquareInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromPoundsForcePerSquareInch(double poundsforcepersquareinch) - { - double value = (double) poundsforcepersquareinch; - return new Pressure(value, PressureUnit.PoundForcePerSquareInch); - } - /// - /// Get Pressure from PoundsPerInchSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromPoundsPerInchSecondSquared(double poundsperinchsecondsquared) - { - double value = (double) poundsperinchsecondsquared; - return new Pressure(value, PressureUnit.PoundPerInchSecondSquared); - } - /// - /// Get Pressure from TechnicalAtmospheres. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromTechnicalAtmospheres(double technicalatmospheres) - { - double value = (double) technicalatmospheres; - return new Pressure(value, PressureUnit.TechnicalAtmosphere); - } - /// - /// Get Pressure from TonnesForcePerSquareCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromTonnesForcePerSquareCentimeter(double tonnesforcepersquarecentimeter) - { - double value = (double) tonnesforcepersquarecentimeter; - return new Pressure(value, PressureUnit.TonneForcePerSquareCentimeter); - } - /// - /// Get Pressure from TonnesForcePerSquareMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromTonnesForcePerSquareMeter(double tonnesforcepersquaremeter) - { - double value = (double) tonnesforcepersquaremeter; - return new Pressure(value, PressureUnit.TonneForcePerSquareMeter); - } - /// - /// Get Pressure from TonnesForcePerSquareMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromTonnesForcePerSquareMillimeter(double tonnesforcepersquaremillimeter) - { - double value = (double) tonnesforcepersquaremillimeter; - return new Pressure(value, PressureUnit.TonneForcePerSquareMillimeter); - } - /// - /// Get Pressure from Torrs. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Pressure FromTorrs(double torrs) - { - double value = (double) torrs; - return new Pressure(value, PressureUnit.Torr); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Pressure unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Pressure From(double value, PressureUnit fromUnit) - { - return new Pressure((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Pressure Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Pressure Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Pressure result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Pressure result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PressureUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PressureUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PressureUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PressureUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Pressure objPressure)) throw new ArgumentException("Expected type Pressure.", nameof(obj)); - - return CompareTo(objPressure); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Pressure other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Pressure objPressure)) - return false; - - return Equals(objPressure); - } - - public bool Equals(Pressure other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Pressure within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Pressure. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PressureUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PressureUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Pressure to another Pressure with the unit representation . - /// - /// A Pressure with the specified unit. - public Pressure ToUnit(PressureUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Pressure(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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.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."); - } - } - - private double AsBaseNumericType(PressureUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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.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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.g.cs deleted file mode 100644 index 4c20c6aba2..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ /dev/null @@ -1,784 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class PressureChangeRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly PressureChangeRateUnit? _unit; - - static PressureChangeRate() - { - BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.PressureChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit PascalPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public PressureChangeRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private PressureChangeRate(double value, PressureChangeRateUnit unit) - { - if(unit == PressureChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of PressureChangeRate, which is PascalPerSecond. All conversions go via this value. - /// - public static PressureChangeRateUnit BaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; - - /// - /// Represents the largest possible value of PressureChangeRate - /// - public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of PressureChangeRate - /// - public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.PressureChangeRate; - - /// - /// All units of measurement for the PressureChangeRate quantity. - /// - public static PressureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().Except(new PressureChangeRateUnit[]{ PressureChangeRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit PascalPerSecond. - /// - public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public PressureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => PressureChangeRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => PressureChangeRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get PressureChangeRate in AtmospheresPerSecond. - /// - public double AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); - - /// - /// Get PressureChangeRate in KilopascalsPerMinute. - /// - public double KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); - - /// - /// Get PressureChangeRate in KilopascalsPerSecond. - /// - public double KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); - - /// - /// Get PressureChangeRate in KilopoundsForcePerSquareInchPerMinute. - /// - public double KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); - - /// - /// Get PressureChangeRate in KilopoundsForcePerSquareInchPerSecond. - /// - public double KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); - - /// - /// Get PressureChangeRate in MegapascalsPerMinute. - /// - public double MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); - - /// - /// Get PressureChangeRate in MegapascalsPerSecond. - /// - public double MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); - - /// - /// Get PressureChangeRate in MegapoundsForcePerSquareInchPerMinute. - /// - public double MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); - - /// - /// Get PressureChangeRate in MegapoundsForcePerSquareInchPerSecond. - /// - public double MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); - - /// - /// Get PressureChangeRate in PascalsPerMinute. - /// - public double PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); - - /// - /// Get PressureChangeRate in PascalsPerSecond. - /// - public double PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); - - /// - /// Get PressureChangeRate in PoundsForcePerSquareInchPerMinute. - /// - public double PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); - - /// - /// Get PressureChangeRate in PoundsForcePerSquareInchPerSecond. - /// - public double PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(PressureChangeRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(PressureChangeRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get PressureChangeRate from AtmospheresPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromAtmospheresPerSecond(double atmospherespersecond) - { - double value = (double) atmospherespersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.AtmospherePerSecond); - } - /// - /// Get PressureChangeRate from KilopascalsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromKilopascalsPerMinute(double kilopascalsperminute) - { - double value = (double) kilopascalsperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerMinute); - } - /// - /// Get PressureChangeRate from KilopascalsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromKilopascalsPerSecond(double kilopascalspersecond) - { - double value = (double) kilopascalspersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerSecond); - } - /// - /// Get PressureChangeRate from KilopoundsForcePerSquareInchPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(double kilopoundsforcepersquareinchperminute) - { - double value = (double) kilopoundsforcepersquareinchperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); - } - /// - /// Get PressureChangeRate from KilopoundsForcePerSquareInchPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(double kilopoundsforcepersquareinchpersecond) - { - double value = (double) kilopoundsforcepersquareinchpersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); - } - /// - /// Get PressureChangeRate from MegapascalsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromMegapascalsPerMinute(double megapascalsperminute) - { - double value = (double) megapascalsperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerMinute); - } - /// - /// Get PressureChangeRate from MegapascalsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromMegapascalsPerSecond(double megapascalspersecond) - { - double value = (double) megapascalspersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerSecond); - } - /// - /// Get PressureChangeRate from MegapoundsForcePerSquareInchPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(double megapoundsforcepersquareinchperminute) - { - double value = (double) megapoundsforcepersquareinchperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); - } - /// - /// Get PressureChangeRate from MegapoundsForcePerSquareInchPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(double megapoundsforcepersquareinchpersecond) - { - double value = (double) megapoundsforcepersquareinchpersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); - } - /// - /// Get PressureChangeRate from PascalsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromPascalsPerMinute(double pascalsperminute) - { - double value = (double) pascalsperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerMinute); - } - /// - /// Get PressureChangeRate from PascalsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromPascalsPerSecond(double pascalspersecond) - { - double value = (double) pascalspersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerSecond); - } - /// - /// Get PressureChangeRate from PoundsForcePerSquareInchPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(double poundsforcepersquareinchperminute) - { - double value = (double) poundsforcepersquareinchperminute; - return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); - } - /// - /// Get PressureChangeRate from PoundsForcePerSquareInchPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(double poundsforcepersquareinchpersecond) - { - double value = (double) poundsforcepersquareinchpersecond; - return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// PressureChangeRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static PressureChangeRate From(double value, PressureChangeRateUnit fromUnit) - { - return new PressureChangeRate((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static PressureChangeRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PressureChangeRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out PressureChangeRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out PressureChangeRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static PressureChangeRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static PressureChangeRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out PressureChangeRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out PressureChangeRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is PressureChangeRate objPressureChangeRate)) throw new ArgumentException("Expected type PressureChangeRate.", nameof(obj)); - - return CompareTo(objPressureChangeRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(PressureChangeRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is PressureChangeRate objPressureChangeRate)) - return false; - - return Equals(objPressureChangeRate); - } - - public bool Equals(PressureChangeRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another PressureChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current PressureChangeRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((PressureChangeRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(PressureChangeRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this PressureChangeRate to another PressureChangeRate with the unit representation . - /// - /// A PressureChangeRate with the specified unit. - public PressureChangeRate ToUnit(PressureChangeRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new PressureChangeRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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.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."); - } - } - - private double AsBaseNumericType(PressureChangeRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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.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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.g.cs deleted file mode 100644 index bcfd882a71..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Ratio.g.cs +++ /dev/null @@ -1,665 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Ratio : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RatioUnit? _unit; - - static Ratio() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Ratio, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DecimalFraction. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Ratio() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Ratio(double value, RatioUnit unit) - { - if(unit == RatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Ratio, which is DecimalFraction. All conversions go via this value. - /// - public static RatioUnit BaseUnit { get; } = RatioUnit.DecimalFraction; - - /// - /// Represents the largest possible value of Ratio - /// - public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Ratio - /// - public static Ratio MinValue { get; } = new Ratio(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Ratio; - - /// - /// All units of measurement for the Ratio quantity. - /// - public static RatioUnit[] Units { get; } = Enum.GetValues(typeof(RatioUnit)).Cast().Except(new RatioUnit[]{ RatioUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. - /// - public static Ratio Zero { get; } = new Ratio(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Ratio.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Ratio.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Ratio in DecimalFractions. - /// - public double DecimalFractions => As(RatioUnit.DecimalFraction); - - /// - /// Get Ratio in PartsPerBillion. - /// - public double PartsPerBillion => As(RatioUnit.PartPerBillion); - - /// - /// Get Ratio in PartsPerMillion. - /// - public double PartsPerMillion => As(RatioUnit.PartPerMillion); - - /// - /// Get Ratio in PartsPerThousand. - /// - public double PartsPerThousand => As(RatioUnit.PartPerThousand); - - /// - /// Get Ratio in PartsPerTrillion. - /// - public double PartsPerTrillion => As(RatioUnit.PartPerTrillion); - - /// - /// Get Ratio in Percent. - /// - public double Percent => As(RatioUnit.Percent); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RatioUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RatioUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Ratio from DecimalFractions. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Ratio FromDecimalFractions(double decimalfractions) - { - double value = (double) decimalfractions; - return new Ratio(value, RatioUnit.DecimalFraction); - } - /// - /// Get Ratio from PartsPerBillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Ratio FromPartsPerBillion(double partsperbillion) - { - double value = (double) partsperbillion; - return new Ratio(value, RatioUnit.PartPerBillion); - } - /// - /// Get Ratio from PartsPerMillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Ratio FromPartsPerMillion(double partspermillion) - { - double value = (double) partspermillion; - return new Ratio(value, RatioUnit.PartPerMillion); - } - /// - /// Get Ratio from PartsPerThousand. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Ratio FromPartsPerThousand(double partsperthousand) - { - double value = (double) partsperthousand; - return new Ratio(value, RatioUnit.PartPerThousand); - } - /// - /// Get Ratio from PartsPerTrillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Ratio FromPartsPerTrillion(double partspertrillion) - { - double value = (double) partspertrillion; - return new Ratio(value, RatioUnit.PartPerTrillion); - } - /// - /// Get Ratio from Percent. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Ratio FromPercent(double percent) - { - double value = (double) percent; - return new Ratio(value, RatioUnit.Percent); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Ratio unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Ratio From(double value, RatioUnit fromUnit) - { - return new Ratio((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Ratio Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Ratio Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Ratio result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Ratio result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RatioUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RatioUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RatioUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RatioUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Ratio objRatio)) throw new ArgumentException("Expected type Ratio.", nameof(obj)); - - return CompareTo(objRatio); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Ratio other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Ratio objRatio)) - return false; - - return Equals(objRatio); - } - - public bool Equals(Ratio other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Ratio within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Ratio. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RatioUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RatioUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Ratio to another Ratio with the unit representation . - /// - /// A Ratio with the specified unit. - public Ratio ToUnit(RatioUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Ratio(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(RatioUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RatioChangeRate.g.cs deleted file mode 100644 index f81a5299e9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ /dev/null @@ -1,597 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The change in ratio per unit of time. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class RatioChangeRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RatioChangeRateUnit? _unit; - - static RatioChangeRate() - { - BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RatioChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DecimalFractionPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public RatioChangeRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private RatioChangeRate(double value, RatioChangeRateUnit unit) - { - if(unit == RatioChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of RatioChangeRate, which is DecimalFractionPerSecond. All conversions go via this value. - /// - public static RatioChangeRateUnit BaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; - - /// - /// Represents the largest possible value of RatioChangeRate - /// - public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of RatioChangeRate - /// - public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.RatioChangeRate; - - /// - /// All units of measurement for the RatioChangeRate quantity. - /// - public static RatioChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast().Except(new RatioChangeRateUnit[]{ RatioChangeRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFractionPerSecond. - /// - public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RatioChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => RatioChangeRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => RatioChangeRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get RatioChangeRate in DecimalFractionsPerSecond. - /// - public double DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); - - /// - /// Get RatioChangeRate in PercentsPerSecond. - /// - public double PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RatioChangeRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RatioChangeRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get RatioChangeRate from DecimalFractionsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RatioChangeRate FromDecimalFractionsPerSecond(double decimalfractionspersecond) - { - double value = (double) decimalfractionspersecond; - return new RatioChangeRate(value, RatioChangeRateUnit.DecimalFractionPerSecond); - } - /// - /// Get RatioChangeRate from PercentsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RatioChangeRate FromPercentsPerSecond(double percentspersecond) - { - double value = (double) percentspersecond; - return new RatioChangeRate(value, RatioChangeRateUnit.PercentPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// RatioChangeRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static RatioChangeRate From(double value, RatioChangeRateUnit fromUnit) - { - return new RatioChangeRate((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static RatioChangeRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RatioChangeRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out RatioChangeRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out RatioChangeRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RatioChangeRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RatioChangeRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RatioChangeRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RatioChangeRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RatioChangeRate objRatioChangeRate)) throw new ArgumentException("Expected type RatioChangeRate.", nameof(obj)); - - return CompareTo(objRatioChangeRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(RatioChangeRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is RatioChangeRate objRatioChangeRate)) - return false; - - return Equals(objRatioChangeRate); - } - - public bool Equals(RatioChangeRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another RatioChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RatioChangeRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current RatioChangeRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RatioChangeRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RatioChangeRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this RatioChangeRate to another RatioChangeRate with the unit representation . - /// - /// A RatioChangeRate with the specified unit. - public RatioChangeRate ToUnit(RatioChangeRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new RatioChangeRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case RatioChangeRateUnit.DecimalFractionPerSecond: return _value; - case RatioChangeRateUnit.PercentPerSecond: return _value/1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(RatioChangeRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case RatioChangeRateUnit.DecimalFractionPerSecond: return baseUnitValue; - case RatioChangeRateUnit.PercentPerSecond: return baseUnitValue*1e2; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.g.cs deleted file mode 100644 index 851d24d687..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ReactiveEnergy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ReactiveEnergyUnit? _unit; - - static ReactiveEnergy() - { - BaseDimensions = new BaseDimensions(2, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ReactiveEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltampereReactiveHour. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ReactiveEnergy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ReactiveEnergy(double value, ReactiveEnergyUnit unit) - { - if(unit == ReactiveEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ReactiveEnergy, which is VoltampereReactiveHour. All conversions go via this value. - /// - public static ReactiveEnergyUnit BaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; - - /// - /// Represents the largest possible value of ReactiveEnergy - /// - public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ReactiveEnergy - /// - public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ReactiveEnergy; - - /// - /// All units of measurement for the ReactiveEnergy quantity. - /// - public static ReactiveEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().Except(new ReactiveEnergyUnit[]{ ReactiveEnergyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactiveHour. - /// - public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ReactiveEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ReactiveEnergy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ReactiveEnergy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ReactiveEnergy in KilovoltampereReactiveHours. - /// - public double KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); - - /// - /// Get ReactiveEnergy in MegavoltampereReactiveHours. - /// - public double MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); - - /// - /// Get ReactiveEnergy in VoltampereReactiveHours. - /// - public double VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ReactiveEnergyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ReactiveEnergyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ReactiveEnergy from KilovoltampereReactiveHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactiveEnergy FromKilovoltampereReactiveHours(double kilovoltamperereactivehours) - { - double value = (double) kilovoltamperereactivehours; - return new ReactiveEnergy(value, ReactiveEnergyUnit.KilovoltampereReactiveHour); - } - /// - /// Get ReactiveEnergy from MegavoltampereReactiveHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactiveEnergy FromMegavoltampereReactiveHours(double megavoltamperereactivehours) - { - double value = (double) megavoltamperereactivehours; - return new ReactiveEnergy(value, ReactiveEnergyUnit.MegavoltampereReactiveHour); - } - /// - /// Get ReactiveEnergy from VoltampereReactiveHours. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactiveEnergy FromVoltampereReactiveHours(double voltamperereactivehours) - { - double value = (double) voltamperereactivehours; - return new ReactiveEnergy(value, ReactiveEnergyUnit.VoltampereReactiveHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ReactiveEnergy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ReactiveEnergy From(double value, ReactiveEnergyUnit fromUnit) - { - return new ReactiveEnergy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ReactiveEnergy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReactiveEnergy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ReactiveEnergy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ReactiveEnergy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ReactiveEnergyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReactiveEnergyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ReactiveEnergyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ReactiveEnergyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ReactiveEnergy objReactiveEnergy)) throw new ArgumentException("Expected type ReactiveEnergy.", nameof(obj)); - - return CompareTo(objReactiveEnergy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ReactiveEnergy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) - return false; - - return Equals(objReactiveEnergy); - } - - public bool Equals(ReactiveEnergy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ReactiveEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ReactiveEnergy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ReactiveEnergyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ReactiveEnergyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ReactiveEnergy to another ReactiveEnergy with the unit representation . - /// - /// A ReactiveEnergy with the specified unit. - public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ReactiveEnergy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ReactiveEnergyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.g.cs deleted file mode 100644 index 47e1add8ac..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReactivePower.g.cs +++ /dev/null @@ -1,631 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ReactivePower : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ReactivePowerUnit? _unit; - - static ReactivePower() - { - BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ReactivePower, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit VoltampereReactive. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ReactivePower() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ReactivePower(double value, ReactivePowerUnit unit) - { - if(unit == ReactivePowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ReactivePower, which is VoltampereReactive. All conversions go via this value. - /// - public static ReactivePowerUnit BaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; - - /// - /// Represents the largest possible value of ReactivePower - /// - public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ReactivePower - /// - public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ReactivePower; - - /// - /// All units of measurement for the ReactivePower quantity. - /// - public static ReactivePowerUnit[] Units { get; } = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().Except(new ReactivePowerUnit[]{ ReactivePowerUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactive. - /// - public static ReactivePower Zero { get; } = new ReactivePower(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ReactivePowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ReactivePower.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ReactivePower.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ReactivePower in GigavoltamperesReactive. - /// - public double GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); - - /// - /// Get ReactivePower in KilovoltamperesReactive. - /// - public double KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); - - /// - /// Get ReactivePower in MegavoltamperesReactive. - /// - public double MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); - - /// - /// Get ReactivePower in VoltamperesReactive. - /// - public double VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ReactivePowerUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ReactivePowerUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ReactivePower from GigavoltamperesReactive. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactivePower FromGigavoltamperesReactive(double gigavoltamperesreactive) - { - double value = (double) gigavoltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.GigavoltampereReactive); - } - /// - /// Get ReactivePower from KilovoltamperesReactive. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactivePower FromKilovoltamperesReactive(double kilovoltamperesreactive) - { - double value = (double) kilovoltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.KilovoltampereReactive); - } - /// - /// Get ReactivePower from MegavoltamperesReactive. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactivePower FromMegavoltamperesReactive(double megavoltamperesreactive) - { - double value = (double) megavoltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.MegavoltampereReactive); - } - /// - /// Get ReactivePower from VoltamperesReactive. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReactivePower FromVoltamperesReactive(double voltamperesreactive) - { - double value = (double) voltamperesreactive; - return new ReactivePower(value, ReactivePowerUnit.VoltampereReactive); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ReactivePower unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ReactivePower From(double value, ReactivePowerUnit fromUnit) - { - return new ReactivePower((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ReactivePower Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReactivePower Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ReactivePower result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ReactivePower result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ReactivePowerUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReactivePowerUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ReactivePowerUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ReactivePowerUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ReactivePower objReactivePower)) throw new ArgumentException("Expected type ReactivePower.", nameof(obj)); - - return CompareTo(objReactivePower); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ReactivePower other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReactivePower objReactivePower)) - return false; - - return Equals(objReactivePower); - } - - public bool Equals(ReactivePower other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ReactivePower within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ReactivePower. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ReactivePowerUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ReactivePowerUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ReactivePower to another ReactivePower with the unit representation . - /// - /// A ReactivePower with the specified unit. - public ReactivePower ToUnit(ReactivePowerUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ReactivePower(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ReactivePowerUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalArea.g.cs deleted file mode 100644 index ff9fa40dce..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ /dev/null @@ -1,753 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Reciprocal area (Inverse-square) quantity is used to specify a physical quantity inversely proportional to the square of the distance. - /// - /// - /// https://en.wikipedia.org/wiki/Inverse-square_law - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ReciprocalArea : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ReciprocalAreaUnit? _unit; - - static ReciprocalArea() - { - BaseDimensions = new BaseDimensions(-2, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ReciprocalArea, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit InverseSquareMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ReciprocalArea() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ReciprocalArea(double value, ReciprocalAreaUnit unit) - { - if(unit == ReciprocalAreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ReciprocalArea, which is InverseSquareMeter. All conversions go via this value. - /// - public static ReciprocalAreaUnit BaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; - - /// - /// Represents the largest possible value of ReciprocalArea - /// - public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ReciprocalArea - /// - public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ReciprocalArea; - - /// - /// All units of measurement for the ReciprocalArea quantity. - /// - public static ReciprocalAreaUnit[] Units { get; } = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast().Except(new ReciprocalAreaUnit[]{ ReciprocalAreaUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit InverseSquareMeter. - /// - public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ReciprocalAreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ReciprocalArea.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ReciprocalArea.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ReciprocalArea in InverseSquareCentimeters. - /// - public double InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); - - /// - /// Get ReciprocalArea in InverseSquareDecimeters. - /// - public double InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); - - /// - /// Get ReciprocalArea in InverseSquareFeet. - /// - public double InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); - - /// - /// Get ReciprocalArea in InverseSquareInches. - /// - public double InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); - - /// - /// Get ReciprocalArea in InverseSquareKilometers. - /// - public double InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); - - /// - /// Get ReciprocalArea in InverseSquareMeters. - /// - public double InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); - - /// - /// Get ReciprocalArea in InverseSquareMicrometers. - /// - public double InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); - - /// - /// Get ReciprocalArea in InverseSquareMiles. - /// - public double InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); - - /// - /// Get ReciprocalArea in InverseSquareMillimeters. - /// - public double InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); - - /// - /// Get ReciprocalArea in InverseSquareYards. - /// - public double InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); - - /// - /// Get ReciprocalArea in InverseUsSurveySquareFeet. - /// - public double InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ReciprocalAreaUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ReciprocalAreaUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ReciprocalArea from InverseSquareCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareCentimeters(double inversesquarecentimeters) - { - double value = (double) inversesquarecentimeters; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareCentimeter); - } - /// - /// Get ReciprocalArea from InverseSquareDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareDecimeters(double inversesquaredecimeters) - { - double value = (double) inversesquaredecimeters; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareDecimeter); - } - /// - /// Get ReciprocalArea from InverseSquareFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareFeet(double inversesquarefeet) - { - double value = (double) inversesquarefeet; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareFoot); - } - /// - /// Get ReciprocalArea from InverseSquareInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareInches(double inversesquareinches) - { - double value = (double) inversesquareinches; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareInch); - } - /// - /// Get ReciprocalArea from InverseSquareKilometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareKilometers(double inversesquarekilometers) - { - double value = (double) inversesquarekilometers; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareKilometer); - } - /// - /// Get ReciprocalArea from InverseSquareMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareMeters(double inversesquaremeters) - { - double value = (double) inversesquaremeters; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMeter); - } - /// - /// Get ReciprocalArea from InverseSquareMicrometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareMicrometers(double inversesquaremicrometers) - { - double value = (double) inversesquaremicrometers; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMicrometer); - } - /// - /// Get ReciprocalArea from InverseSquareMiles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareMiles(double inversesquaremiles) - { - double value = (double) inversesquaremiles; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMile); - } - /// - /// Get ReciprocalArea from InverseSquareMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareMillimeters(double inversesquaremillimeters) - { - double value = (double) inversesquaremillimeters; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMillimeter); - } - /// - /// Get ReciprocalArea from InverseSquareYards. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseSquareYards(double inversesquareyards) - { - double value = (double) inversesquareyards; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareYard); - } - /// - /// Get ReciprocalArea from InverseUsSurveySquareFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalArea FromInverseUsSurveySquareFeet(double inverseussurveysquarefeet) - { - double value = (double) inverseussurveysquarefeet; - return new ReciprocalArea(value, ReciprocalAreaUnit.InverseUsSurveySquareFoot); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ReciprocalArea unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ReciprocalArea From(double value, ReciprocalAreaUnit fromUnit) - { - return new ReciprocalArea((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ReciprocalArea Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReciprocalArea Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ReciprocalArea result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ReciprocalArea result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ReciprocalAreaUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReciprocalAreaUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ReciprocalAreaUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ReciprocalAreaUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ReciprocalArea objReciprocalArea)) throw new ArgumentException("Expected type ReciprocalArea.", nameof(obj)); - - return CompareTo(objReciprocalArea); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ReciprocalArea other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReciprocalArea objReciprocalArea)) - return false; - - return Equals(objReciprocalArea); - } - - public bool Equals(ReciprocalArea other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ReciprocalArea within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReciprocalArea other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ReciprocalArea. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ReciprocalAreaUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ReciprocalAreaUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ReciprocalArea to another ReciprocalArea with the unit representation . - /// - /// A ReciprocalArea with the specified unit. - public ReciprocalArea ToUnit(ReciprocalAreaUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ReciprocalArea(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ReciprocalAreaUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalLength.g.cs deleted file mode 100644 index 8a0d4d8d1d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ /dev/null @@ -1,736 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Reciprocal (Inverse) Length is used in various fields of science and mathematics. It is defined as the inverse value of a length unit. - /// - /// - /// https://en.wikipedia.org/wiki/Reciprocal_length - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ReciprocalLength : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ReciprocalLengthUnit? _unit; - - static ReciprocalLength() - { - BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.ReciprocalLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit InverseMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ReciprocalLength() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ReciprocalLength(double value, ReciprocalLengthUnit unit) - { - if(unit == ReciprocalLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ReciprocalLength, which is InverseMeter. All conversions go via this value. - /// - public static ReciprocalLengthUnit BaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; - - /// - /// Represents the largest possible value of ReciprocalLength - /// - public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ReciprocalLength - /// - public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ReciprocalLength; - - /// - /// All units of measurement for the ReciprocalLength quantity. - /// - public static ReciprocalLengthUnit[] Units { get; } = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast().Except(new ReciprocalLengthUnit[]{ ReciprocalLengthUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit InverseMeter. - /// - public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ReciprocalLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ReciprocalLength.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ReciprocalLength.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ReciprocalLength in InverseCentimeters. - /// - public double InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); - - /// - /// Get ReciprocalLength in InverseFeet. - /// - public double InverseFeet => As(ReciprocalLengthUnit.InverseFoot); - - /// - /// Get ReciprocalLength in InverseInches. - /// - public double InverseInches => As(ReciprocalLengthUnit.InverseInch); - - /// - /// Get ReciprocalLength in InverseMeters. - /// - public double InverseMeters => As(ReciprocalLengthUnit.InverseMeter); - - /// - /// Get ReciprocalLength in InverseMicroinches. - /// - public double InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); - - /// - /// Get ReciprocalLength in InverseMils. - /// - public double InverseMils => As(ReciprocalLengthUnit.InverseMil); - - /// - /// Get ReciprocalLength in InverseMiles. - /// - public double InverseMiles => As(ReciprocalLengthUnit.InverseMile); - - /// - /// Get ReciprocalLength in InverseMillimeters. - /// - public double InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); - - /// - /// Get ReciprocalLength in InverseUsSurveyFeet. - /// - public double InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); - - /// - /// Get ReciprocalLength in InverseYards. - /// - public double InverseYards => As(ReciprocalLengthUnit.InverseYard); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ReciprocalLengthUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ReciprocalLengthUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ReciprocalLength from InverseCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseCentimeters(double inversecentimeters) - { - double value = (double) inversecentimeters; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseCentimeter); - } - /// - /// Get ReciprocalLength from InverseFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseFeet(double inversefeet) - { - double value = (double) inversefeet; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseFoot); - } - /// - /// Get ReciprocalLength from InverseInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseInches(double inverseinches) - { - double value = (double) inverseinches; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseInch); - } - /// - /// Get ReciprocalLength from InverseMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseMeters(double inversemeters) - { - double value = (double) inversemeters; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMeter); - } - /// - /// Get ReciprocalLength from InverseMicroinches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseMicroinches(double inversemicroinches) - { - double value = (double) inversemicroinches; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMicroinch); - } - /// - /// Get ReciprocalLength from InverseMils. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseMils(double inversemils) - { - double value = (double) inversemils; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMil); - } - /// - /// Get ReciprocalLength from InverseMiles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseMiles(double inversemiles) - { - double value = (double) inversemiles; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMile); - } - /// - /// Get ReciprocalLength from InverseMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseMillimeters(double inversemillimeters) - { - double value = (double) inversemillimeters; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMillimeter); - } - /// - /// Get ReciprocalLength from InverseUsSurveyFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseUsSurveyFeet(double inverseussurveyfeet) - { - double value = (double) inverseussurveyfeet; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseUsSurveyFoot); - } - /// - /// Get ReciprocalLength from InverseYards. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ReciprocalLength FromInverseYards(double inverseyards) - { - double value = (double) inverseyards; - return new ReciprocalLength(value, ReciprocalLengthUnit.InverseYard); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ReciprocalLength unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ReciprocalLength From(double value, ReciprocalLengthUnit fromUnit) - { - return new ReciprocalLength((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ReciprocalLength Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReciprocalLength Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ReciprocalLength result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ReciprocalLength result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ReciprocalLengthUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ReciprocalLengthUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ReciprocalLengthUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ReciprocalLengthUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ReciprocalLength objReciprocalLength)) throw new ArgumentException("Expected type ReciprocalLength.", nameof(obj)); - - return CompareTo(objReciprocalLength); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ReciprocalLength other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReciprocalLength objReciprocalLength)) - return false; - - return Equals(objReciprocalLength); - } - - public bool Equals(ReciprocalLength other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ReciprocalLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ReciprocalLength. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ReciprocalLengthUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ReciprocalLengthUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ReciprocalLength to another ReciprocalLength with the unit representation . - /// - /// A ReciprocalLength with the specified unit. - public ReciprocalLength ToUnit(ReciprocalLengthUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ReciprocalLength(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(ReciprocalLengthUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RelativeHumidity.g.cs deleted file mode 100644 index 4eab60e0a5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ /dev/null @@ -1,580 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class RelativeHumidity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RelativeHumidityUnit? _unit; - - static RelativeHumidity() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.RelativeHumidity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Percent. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public RelativeHumidity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private RelativeHumidity(double value, RelativeHumidityUnit unit) - { - if(unit == RelativeHumidityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of RelativeHumidity, which is Percent. All conversions go via this value. - /// - public static RelativeHumidityUnit BaseUnit { get; } = RelativeHumidityUnit.Percent; - - /// - /// Represents the largest possible value of RelativeHumidity - /// - public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of RelativeHumidity - /// - public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.RelativeHumidity; - - /// - /// All units of measurement for the RelativeHumidity quantity. - /// - public static RelativeHumidityUnit[] Units { get; } = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast().Except(new RelativeHumidityUnit[]{ RelativeHumidityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Percent. - /// - public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RelativeHumidityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => RelativeHumidity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => RelativeHumidity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get RelativeHumidity in Percent. - /// - public double Percent => As(RelativeHumidityUnit.Percent); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RelativeHumidityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RelativeHumidityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get RelativeHumidity from Percent. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RelativeHumidity FromPercent(double percent) - { - double value = (double) percent; - return new RelativeHumidity(value, RelativeHumidityUnit.Percent); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// RelativeHumidity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static RelativeHumidity From(double value, RelativeHumidityUnit fromUnit) - { - return new RelativeHumidity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static RelativeHumidity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RelativeHumidity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out RelativeHumidity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out RelativeHumidity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RelativeHumidityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RelativeHumidityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RelativeHumidityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RelativeHumidityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RelativeHumidity objRelativeHumidity)) throw new ArgumentException("Expected type RelativeHumidity.", nameof(obj)); - - return CompareTo(objRelativeHumidity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(RelativeHumidity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is RelativeHumidity objRelativeHumidity)) - return false; - - return Equals(objRelativeHumidity); - } - - public bool Equals(RelativeHumidity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another RelativeHumidity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current RelativeHumidity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RelativeHumidityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RelativeHumidityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this RelativeHumidity to another RelativeHumidity with the unit representation . - /// - /// A RelativeHumidity with the specified unit. - public RelativeHumidity ToUnit(RelativeHumidityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new RelativeHumidity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case RelativeHumidityUnit.Percent: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(RelativeHumidityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case RelativeHumidityUnit.Percent: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.g.cs deleted file mode 100644 index 5a0de083e2..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ /dev/null @@ -1,631 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Angular acceleration is the rate of change of rotational speed. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class RotationalAcceleration : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RotationalAccelerationUnit? _unit; - - static RotationalAcceleration() - { - BaseDimensions = new BaseDimensions(0, 0, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RotationalAcceleration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit RadianPerSecondSquared. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public RotationalAcceleration() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private RotationalAcceleration(double value, RotationalAccelerationUnit unit) - { - if(unit == RotationalAccelerationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of RotationalAcceleration, which is RadianPerSecondSquared. All conversions go via this value. - /// - public static RotationalAccelerationUnit BaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; - - /// - /// Represents the largest possible value of RotationalAcceleration - /// - public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of RotationalAcceleration - /// - public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.RotationalAcceleration; - - /// - /// All units of measurement for the RotationalAcceleration quantity. - /// - public static RotationalAccelerationUnit[] Units { get; } = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().Except(new RotationalAccelerationUnit[]{ RotationalAccelerationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecondSquared. - /// - public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RotationalAccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalAcceleration.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => RotationalAcceleration.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get RotationalAcceleration in DegreesPerSecondSquared. - /// - public double DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); - - /// - /// Get RotationalAcceleration in RadiansPerSecondSquared. - /// - public double RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); - - /// - /// Get RotationalAcceleration in RevolutionsPerMinutePerSecond. - /// - public double RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); - - /// - /// Get RotationalAcceleration in RevolutionsPerSecondSquared. - /// - public double RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RotationalAccelerationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RotationalAccelerationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get RotationalAcceleration from DegreesPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalAcceleration FromDegreesPerSecondSquared(double degreespersecondsquared) - { - double value = (double) degreespersecondsquared; - return new RotationalAcceleration(value, RotationalAccelerationUnit.DegreePerSecondSquared); - } - /// - /// Get RotationalAcceleration from RadiansPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalAcceleration FromRadiansPerSecondSquared(double radianspersecondsquared) - { - double value = (double) radianspersecondsquared; - return new RotationalAcceleration(value, RotationalAccelerationUnit.RadianPerSecondSquared); - } - /// - /// Get RotationalAcceleration from RevolutionsPerMinutePerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(double revolutionsperminutepersecond) - { - double value = (double) revolutionsperminutepersecond; - return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); - } - /// - /// Get RotationalAcceleration from RevolutionsPerSecondSquared. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalAcceleration FromRevolutionsPerSecondSquared(double revolutionspersecondsquared) - { - double value = (double) revolutionspersecondsquared; - return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerSecondSquared); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// RotationalAcceleration unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static RotationalAcceleration From(double value, RotationalAccelerationUnit fromUnit) - { - return new RotationalAcceleration((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static RotationalAcceleration Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalAcceleration Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out RotationalAcceleration result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out RotationalAcceleration result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RotationalAccelerationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalAccelerationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RotationalAccelerationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RotationalAccelerationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalAcceleration objRotationalAcceleration)) throw new ArgumentException("Expected type RotationalAcceleration.", nameof(obj)); - - return CompareTo(objRotationalAcceleration); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(RotationalAcceleration other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) - return false; - - return Equals(objRotationalAcceleration); - } - - public bool Equals(RotationalAcceleration other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another RotationalAcceleration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current RotationalAcceleration. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RotationalAccelerationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RotationalAccelerationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this RotationalAcceleration to another RotationalAcceleration with the unit representation . - /// - /// A RotationalAcceleration with the specified unit. - public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new RotationalAcceleration(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case RotationalAccelerationUnit.DegreePerSecondSquared: return (Math.PI/180)*_value; - case RotationalAccelerationUnit.RadianPerSecondSquared: return _value; - case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return ((2*Math.PI)/60)*_value; - case RotationalAccelerationUnit.RevolutionPerSecondSquared: return (2*Math.PI)*_value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(RotationalAccelerationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case RotationalAccelerationUnit.DegreePerSecondSquared: return (180/Math.PI)*baseUnitValue; - case RotationalAccelerationUnit.RadianPerSecondSquared: return baseUnitValue; - case RotationalAccelerationUnit.RevolutionPerMinutePerSecond: return (60/(2*Math.PI))*baseUnitValue; - case RotationalAccelerationUnit.RevolutionPerSecondSquared: return (1/(2*Math.PI))*baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.g.cs deleted file mode 100644 index 99b6922094..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ /dev/null @@ -1,784 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class RotationalSpeed : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RotationalSpeedUnit? _unit; - - static RotationalSpeed() - { - BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RotationalSpeed, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit RadianPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public RotationalSpeed() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private RotationalSpeed(double value, RotationalSpeedUnit unit) - { - if(unit == RotationalSpeedUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of RotationalSpeed, which is RadianPerSecond. All conversions go via this value. - /// - public static RotationalSpeedUnit BaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; - - /// - /// Represents the largest possible value of RotationalSpeed - /// - public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of RotationalSpeed - /// - public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.RotationalSpeed; - - /// - /// All units of measurement for the RotationalSpeed quantity. - /// - public static RotationalSpeedUnit[] Units { get; } = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().Except(new RotationalSpeedUnit[]{ RotationalSpeedUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecond. - /// - public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RotationalSpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalSpeed.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => RotationalSpeed.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get RotationalSpeed in CentiradiansPerSecond. - /// - public double CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); - - /// - /// Get RotationalSpeed in DeciradiansPerSecond. - /// - public double DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); - - /// - /// Get RotationalSpeed in DegreesPerMinute. - /// - public double DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); - - /// - /// Get RotationalSpeed in DegreesPerSecond. - /// - public double DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); - - /// - /// Get RotationalSpeed in MicrodegreesPerSecond. - /// - public double MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); - - /// - /// Get RotationalSpeed in MicroradiansPerSecond. - /// - public double MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); - - /// - /// Get RotationalSpeed in MillidegreesPerSecond. - /// - public double MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); - - /// - /// Get RotationalSpeed in MilliradiansPerSecond. - /// - public double MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); - - /// - /// Get RotationalSpeed in NanodegreesPerSecond. - /// - public double NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); - - /// - /// Get RotationalSpeed in NanoradiansPerSecond. - /// - public double NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); - - /// - /// Get RotationalSpeed in RadiansPerSecond. - /// - public double RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); - - /// - /// Get RotationalSpeed in RevolutionsPerMinute. - /// - public double RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); - - /// - /// Get RotationalSpeed in RevolutionsPerSecond. - /// - public double RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RotationalSpeedUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RotationalSpeedUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get RotationalSpeed from CentiradiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromCentiradiansPerSecond(double centiradianspersecond) - { - double value = (double) centiradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.CentiradianPerSecond); - } - /// - /// Get RotationalSpeed from DeciradiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromDeciradiansPerSecond(double deciradianspersecond) - { - double value = (double) deciradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.DeciradianPerSecond); - } - /// - /// Get RotationalSpeed from DegreesPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromDegreesPerMinute(double degreesperminute) - { - double value = (double) degreesperminute; - return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerMinute); - } - /// - /// Get RotationalSpeed from DegreesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromDegreesPerSecond(double degreespersecond) - { - double value = (double) degreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerSecond); - } - /// - /// Get RotationalSpeed from MicrodegreesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromMicrodegreesPerSecond(double microdegreespersecond) - { - double value = (double) microdegreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MicrodegreePerSecond); - } - /// - /// Get RotationalSpeed from MicroradiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromMicroradiansPerSecond(double microradianspersecond) - { - double value = (double) microradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MicroradianPerSecond); - } - /// - /// Get RotationalSpeed from MillidegreesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromMillidegreesPerSecond(double millidegreespersecond) - { - double value = (double) millidegreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MillidegreePerSecond); - } - /// - /// Get RotationalSpeed from MilliradiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromMilliradiansPerSecond(double milliradianspersecond) - { - double value = (double) milliradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.MilliradianPerSecond); - } - /// - /// Get RotationalSpeed from NanodegreesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromNanodegreesPerSecond(double nanodegreespersecond) - { - double value = (double) nanodegreespersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.NanodegreePerSecond); - } - /// - /// Get RotationalSpeed from NanoradiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromNanoradiansPerSecond(double nanoradianspersecond) - { - double value = (double) nanoradianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.NanoradianPerSecond); - } - /// - /// Get RotationalSpeed from RadiansPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromRadiansPerSecond(double radianspersecond) - { - double value = (double) radianspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.RadianPerSecond); - } - /// - /// Get RotationalSpeed from RevolutionsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromRevolutionsPerMinute(double revolutionsperminute) - { - double value = (double) revolutionsperminute; - return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerMinute); - } - /// - /// Get RotationalSpeed from RevolutionsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalSpeed FromRevolutionsPerSecond(double revolutionspersecond) - { - double value = (double) revolutionspersecond; - return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// RotationalSpeed unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit) - { - return new RotationalSpeed((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static RotationalSpeed Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalSpeed Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out RotationalSpeed result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out RotationalSpeed result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RotationalSpeedUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalSpeedUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RotationalSpeedUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RotationalSpeedUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalSpeed objRotationalSpeed)) throw new ArgumentException("Expected type RotationalSpeed.", nameof(obj)); - - return CompareTo(objRotationalSpeed); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(RotationalSpeed other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalSpeed objRotationalSpeed)) - return false; - - return Equals(objRotationalSpeed); - } - - public bool Equals(RotationalSpeed other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another RotationalSpeed within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current RotationalSpeed. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RotationalSpeedUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RotationalSpeedUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this RotationalSpeed to another RotationalSpeed with the unit representation . - /// - /// A RotationalSpeed with the specified unit. - public RotationalSpeed ToUnit(RotationalSpeedUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new RotationalSpeed(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case RotationalSpeedUnit.CentiradianPerSecond: return (_value) * 1e-2d; - case RotationalSpeedUnit.DeciradianPerSecond: return (_value) * 1e-1d; - case RotationalSpeedUnit.DegreePerMinute: return (Math.PI/(180*60))*_value; - case RotationalSpeedUnit.DegreePerSecond: return (Math.PI/180)*_value; - case RotationalSpeedUnit.MicrodegreePerSecond: return ((Math.PI/180)*_value) * 1e-6d; - case RotationalSpeedUnit.MicroradianPerSecond: return (_value) * 1e-6d; - case RotationalSpeedUnit.MillidegreePerSecond: return ((Math.PI/180)*_value) * 1e-3d; - case RotationalSpeedUnit.MilliradianPerSecond: return (_value) * 1e-3d; - case RotationalSpeedUnit.NanodegreePerSecond: return ((Math.PI/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."); - } - } - - private double AsBaseNumericType(RotationalSpeedUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case RotationalSpeedUnit.CentiradianPerSecond: return (baseUnitValue) / 1e-2d; - case RotationalSpeedUnit.DeciradianPerSecond: return (baseUnitValue) / 1e-1d; - case RotationalSpeedUnit.DegreePerMinute: return (180*60/Math.PI)*baseUnitValue; - case RotationalSpeedUnit.DegreePerSecond: return (180/Math.PI)*baseUnitValue; - case RotationalSpeedUnit.MicrodegreePerSecond: return ((180/Math.PI)*baseUnitValue) / 1e-6d; - case RotationalSpeedUnit.MicroradianPerSecond: return (baseUnitValue) / 1e-6d; - case RotationalSpeedUnit.MillidegreePerSecond: return ((180/Math.PI)*baseUnitValue) / 1e-3d; - case RotationalSpeedUnit.MilliradianPerSecond: return (baseUnitValue) / 1e-3d; - case RotationalSpeedUnit.NanodegreePerSecond: return ((180/Math.PI)*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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.g.cs deleted file mode 100644 index b7879af272..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ /dev/null @@ -1,1124 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class RotationalStiffness : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RotationalStiffnessUnit? _unit; - - static RotationalStiffness() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RotationalStiffness, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonMeterPerRadian. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public RotationalStiffness() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private RotationalStiffness(double value, RotationalStiffnessUnit unit) - { - if(unit == RotationalStiffnessUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of RotationalStiffness, which is NewtonMeterPerRadian. All conversions go via this value. - /// - public static RotationalStiffnessUnit BaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; - - /// - /// Represents the largest possible value of RotationalStiffness - /// - public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of RotationalStiffness - /// - public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.RotationalStiffness; - - /// - /// All units of measurement for the RotationalStiffness quantity. - /// - public static RotationalStiffnessUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().Except(new RotationalStiffnessUnit[]{ RotationalStiffnessUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadian. - /// - public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RotationalStiffnessUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalStiffness.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => RotationalStiffness.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get RotationalStiffness in CentinewtonMetersPerDegree. - /// - public double CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in CentinewtonMillimetersPerDegree. - /// - public double CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in CentinewtonMillimetersPerRadian. - /// - public double CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in DecanewtonMetersPerDegree. - /// - public double DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in DecanewtonMillimetersPerDegree. - /// - public double DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in DecanewtonMillimetersPerRadian. - /// - public double DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in DecinewtonMetersPerDegree. - /// - public double DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in DecinewtonMillimetersPerDegree. - /// - public double DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in DecinewtonMillimetersPerRadian. - /// - public double DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in KilonewtonMetersPerDegree. - /// - public double KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in KilonewtonMetersPerRadian. - /// - public double KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); - - /// - /// Get RotationalStiffness in KilonewtonMillimetersPerDegree. - /// - public double KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in KilonewtonMillimetersPerRadian. - /// - public double KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in KilopoundForceFeetPerDegrees. - /// - public double KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); - - /// - /// Get RotationalStiffness in MeganewtonMetersPerDegree. - /// - public double MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in MeganewtonMetersPerRadian. - /// - public double MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); - - /// - /// Get RotationalStiffness in MeganewtonMillimetersPerDegree. - /// - public double MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in MeganewtonMillimetersPerRadian. - /// - public double MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in MicronewtonMetersPerDegree. - /// - public double MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in MicronewtonMillimetersPerDegree. - /// - public double MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in MicronewtonMillimetersPerRadian. - /// - public double MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in MillinewtonMetersPerDegree. - /// - public double MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in MillinewtonMillimetersPerDegree. - /// - public double MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in MillinewtonMillimetersPerRadian. - /// - public double MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in NanonewtonMetersPerDegree. - /// - public double NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in NanonewtonMillimetersPerDegree. - /// - public double NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in NanonewtonMillimetersPerRadian. - /// - public double NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in NewtonMetersPerDegree. - /// - public double NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); - - /// - /// Get RotationalStiffness in NewtonMetersPerRadian. - /// - public double NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); - - /// - /// Get RotationalStiffness in NewtonMillimetersPerDegree. - /// - public double NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); - - /// - /// Get RotationalStiffness in NewtonMillimetersPerRadian. - /// - public double NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); - - /// - /// Get RotationalStiffness in PoundForceFeetPerRadian. - /// - public double PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); - - /// - /// Get RotationalStiffness in PoundForceFeetPerDegrees. - /// - public double PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RotationalStiffnessUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RotationalStiffnessUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get RotationalStiffness from CentinewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromCentinewtonMetersPerDegree(double centinewtonmetersperdegree) - { - double value = (double) centinewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from CentinewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromCentinewtonMillimetersPerDegree(double centinewtonmillimetersperdegree) - { - double value = (double) centinewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from CentinewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromCentinewtonMillimetersPerRadian(double centinewtonmillimetersperradian) - { - double value = (double) centinewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from DecanewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromDecanewtonMetersPerDegree(double decanewtonmetersperdegree) - { - double value = (double) decanewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from DecanewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromDecanewtonMillimetersPerDegree(double decanewtonmillimetersperdegree) - { - double value = (double) decanewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from DecanewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromDecanewtonMillimetersPerRadian(double decanewtonmillimetersperradian) - { - double value = (double) decanewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from DecinewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromDecinewtonMetersPerDegree(double decinewtonmetersperdegree) - { - double value = (double) decinewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from DecinewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromDecinewtonMillimetersPerDegree(double decinewtonmillimetersperdegree) - { - double value = (double) decinewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from DecinewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromDecinewtonMillimetersPerRadian(double decinewtonmillimetersperradian) - { - double value = (double) decinewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from KilonewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromKilonewtonMetersPerDegree(double kilonewtonmetersperdegree) - { - double value = (double) kilonewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from KilonewtonMetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromKilonewtonMetersPerRadian(double kilonewtonmetersperradian) - { - double value = (double) kilonewtonmetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerRadian); - } - /// - /// Get RotationalStiffness from KilonewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromKilonewtonMillimetersPerDegree(double kilonewtonmillimetersperdegree) - { - double value = (double) kilonewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from KilonewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromKilonewtonMillimetersPerRadian(double kilonewtonmillimetersperradian) - { - double value = (double) kilonewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from KilopoundForceFeetPerDegrees. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromKilopoundForceFeetPerDegrees(double kilopoundforcefeetperdegrees) - { - double value = (double) kilopoundforcefeetperdegrees; - return new RotationalStiffness(value, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); - } - /// - /// Get RotationalStiffness from MeganewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMeganewtonMetersPerDegree(double meganewtonmetersperdegree) - { - double value = (double) meganewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from MeganewtonMetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMeganewtonMetersPerRadian(double meganewtonmetersperradian) - { - double value = (double) meganewtonmetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerRadian); - } - /// - /// Get RotationalStiffness from MeganewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMeganewtonMillimetersPerDegree(double meganewtonmillimetersperdegree) - { - double value = (double) meganewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from MeganewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMeganewtonMillimetersPerRadian(double meganewtonmillimetersperradian) - { - double value = (double) meganewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from MicronewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMicronewtonMetersPerDegree(double micronewtonmetersperdegree) - { - double value = (double) micronewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from MicronewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMicronewtonMillimetersPerDegree(double micronewtonmillimetersperdegree) - { - double value = (double) micronewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from MicronewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMicronewtonMillimetersPerRadian(double micronewtonmillimetersperradian) - { - double value = (double) micronewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from MillinewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMillinewtonMetersPerDegree(double millinewtonmetersperdegree) - { - double value = (double) millinewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from MillinewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMillinewtonMillimetersPerDegree(double millinewtonmillimetersperdegree) - { - double value = (double) millinewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from MillinewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromMillinewtonMillimetersPerRadian(double millinewtonmillimetersperradian) - { - double value = (double) millinewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from NanonewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNanonewtonMetersPerDegree(double nanonewtonmetersperdegree) - { - double value = (double) nanonewtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from NanonewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNanonewtonMillimetersPerDegree(double nanonewtonmillimetersperdegree) - { - double value = (double) nanonewtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from NanonewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNanonewtonMillimetersPerRadian(double nanonewtonmillimetersperradian) - { - double value = (double) nanonewtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from NewtonMetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNewtonMetersPerDegree(double newtonmetersperdegree) - { - double value = (double) newtonmetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerDegree); - } - /// - /// Get RotationalStiffness from NewtonMetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNewtonMetersPerRadian(double newtonmetersperradian) - { - double value = (double) newtonmetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerRadian); - } - /// - /// Get RotationalStiffness from NewtonMillimetersPerDegree. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNewtonMillimetersPerDegree(double newtonmillimetersperdegree) - { - double value = (double) newtonmillimetersperdegree; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerDegree); - } - /// - /// Get RotationalStiffness from NewtonMillimetersPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromNewtonMillimetersPerRadian(double newtonmillimetersperradian) - { - double value = (double) newtonmillimetersperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerRadian); - } - /// - /// Get RotationalStiffness from PoundForceFeetPerRadian. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromPoundForceFeetPerRadian(double poundforcefeetperradian) - { - double value = (double) poundforcefeetperradian; - return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFeetPerRadian); - } - /// - /// Get RotationalStiffness from PoundForceFeetPerDegrees. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffness FromPoundForceFeetPerDegrees(double poundforcefeetperdegrees) - { - double value = (double) poundforcefeetperdegrees; - return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFootPerDegrees); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// RotationalStiffness unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static RotationalStiffness From(double value, RotationalStiffnessUnit fromUnit) - { - return new RotationalStiffness((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static RotationalStiffness Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalStiffness Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out RotationalStiffness result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out RotationalStiffness result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RotationalStiffnessUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalStiffnessUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RotationalStiffnessUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RotationalStiffnessUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalStiffness objRotationalStiffness)) throw new ArgumentException("Expected type RotationalStiffness.", nameof(obj)); - - return CompareTo(objRotationalStiffness); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(RotationalStiffness other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalStiffness objRotationalStiffness)) - return false; - - return Equals(objRotationalStiffness); - } - - public bool Equals(RotationalStiffness other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another RotationalStiffness within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current RotationalStiffness. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RotationalStiffnessUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RotationalStiffnessUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this RotationalStiffness to another RotationalStiffness with the unit representation . - /// - /// A RotationalStiffness with the specified unit. - public RotationalStiffness ToUnit(RotationalStiffnessUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new RotationalStiffness(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case RotationalStiffnessUnit.CentinewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerRadian: return (_value*0.001) * 1e-2d; - case RotationalStiffnessUnit.DecanewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerRadian: return (_value*0.001) * 1e1d; - case RotationalStiffnessUnit.DecinewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerRadian: return (_value*0.001) * 1e-1d; - case RotationalStiffnessUnit.KilonewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (_value) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerRadian: return (_value*0.001) * 1e3d; - case RotationalStiffnessUnit.KilopoundForceFootPerDegrees: return _value*77682.6; - case RotationalStiffnessUnit.MeganewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (_value) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerRadian: return (_value*0.001) * 1e6d; - case RotationalStiffnessUnit.MicronewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerRadian: return (_value*0.001) * 1e-6d; - case RotationalStiffnessUnit.MillinewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerRadian: return (_value*0.001) * 1e-3d; - case RotationalStiffnessUnit.NanonewtonMeterPerDegree: return (_value*(180/Math.PI)) * 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerDegree: return (_value*180/Math.PI*0.001) * 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerRadian: return (_value*0.001) * 1e-9d; - case RotationalStiffnessUnit.NewtonMeterPerDegree: return _value*(180/Math.PI); - case RotationalStiffnessUnit.NewtonMeterPerRadian: return _value; - case RotationalStiffnessUnit.NewtonMillimeterPerDegree: return _value*180/Math.PI*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."); - } - } - - private double AsBaseNumericType(RotationalStiffnessUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case RotationalStiffnessUnit.CentinewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e-2d; - case RotationalStiffnessUnit.CentinewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-2d; - case RotationalStiffnessUnit.DecanewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e1d; - case RotationalStiffnessUnit.DecanewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e1d; - case RotationalStiffnessUnit.DecinewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e-1d; - case RotationalStiffnessUnit.DecinewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-1d; - case RotationalStiffnessUnit.KilonewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e3d; - case RotationalStiffnessUnit.KilonewtonMeterPerRadian: return (baseUnitValue) / 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e3d; - case RotationalStiffnessUnit.KilonewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e3d; - case RotationalStiffnessUnit.KilopoundForceFootPerDegrees: return baseUnitValue/77682.6; - case RotationalStiffnessUnit.MeganewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e6d; - case RotationalStiffnessUnit.MeganewtonMeterPerRadian: return (baseUnitValue) / 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e6d; - case RotationalStiffnessUnit.MeganewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e6d; - case RotationalStiffnessUnit.MicronewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e-6d; - case RotationalStiffnessUnit.MicronewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-6d; - case RotationalStiffnessUnit.MillinewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e-3d; - case RotationalStiffnessUnit.MillinewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-3d; - case RotationalStiffnessUnit.NanonewtonMeterPerDegree: return (baseUnitValue/(180/Math.PI)) / 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerDegree: return (baseUnitValue/180*Math.PI*1000) / 1e-9d; - case RotationalStiffnessUnit.NanonewtonMillimeterPerRadian: return (baseUnitValue*1000) / 1e-9d; - case RotationalStiffnessUnit.NewtonMeterPerDegree: return baseUnitValue/(180/Math.PI); - case RotationalStiffnessUnit.NewtonMeterPerRadian: return baseUnitValue; - case RotationalStiffnessUnit.NewtonMillimeterPerDegree: return baseUnitValue/180*Math.PI*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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs deleted file mode 100644 index cec23a5888..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ /dev/null @@ -1,648 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class RotationalStiffnessPerLength : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly RotationalStiffnessPerLengthUnit? _unit; - - static RotationalStiffnessPerLength() - { - BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.RotationalStiffnessPerLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public RotationalStiffnessPerLength() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) - { - if(unit == RotationalStiffnessPerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of RotationalStiffnessPerLength, which is NewtonMeterPerRadianPerMeter. All conversions go via this value. - /// - public static RotationalStiffnessPerLengthUnit BaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; - - /// - /// Represents the largest possible value of RotationalStiffnessPerLength - /// - public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of RotationalStiffnessPerLength - /// - public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.RotationalStiffnessPerLength; - - /// - /// All units of measurement for the RotationalStiffnessPerLength quantity. - /// - public static RotationalStiffnessPerLengthUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().Except(new RotationalStiffnessPerLengthUnit[]{ RotationalStiffnessPerLengthUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter. - /// - public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public RotationalStiffnessPerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalStiffnessPerLength.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => RotationalStiffnessPerLength.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get RotationalStiffnessPerLength in KilonewtonMetersPerRadianPerMeter. - /// - public double KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); - - /// - /// Get RotationalStiffnessPerLength in KilopoundForceFeetPerDegreesPerFeet. - /// - public double KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); - - /// - /// Get RotationalStiffnessPerLength in MeganewtonMetersPerRadianPerMeter. - /// - public double MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); - - /// - /// Get RotationalStiffnessPerLength in NewtonMetersPerRadianPerMeter. - /// - public double NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); - - /// - /// Get RotationalStiffnessPerLength in PoundForceFeetPerDegreesPerFeet. - /// - public double PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get RotationalStiffnessPerLength from KilonewtonMetersPerRadianPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(double kilonewtonmetersperradianpermeter) - { - double value = (double) kilonewtonmetersperradianpermeter; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); - } - /// - /// Get RotationalStiffnessPerLength from KilopoundForceFeetPerDegreesPerFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(double kilopoundforcefeetperdegreesperfeet) - { - double value = (double) kilopoundforcefeetperdegreesperfeet; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); - } - /// - /// Get RotationalStiffnessPerLength from MeganewtonMetersPerRadianPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(double meganewtonmetersperradianpermeter) - { - double value = (double) meganewtonmetersperradianpermeter; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); - } - /// - /// Get RotationalStiffnessPerLength from NewtonMetersPerRadianPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(double newtonmetersperradianpermeter) - { - double value = (double) newtonmetersperradianpermeter; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); - } - /// - /// Get RotationalStiffnessPerLength from PoundForceFeetPerDegreesPerFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(double poundforcefeetperdegreesperfeet) - { - double value = (double) poundforcefeetperdegreesperfeet; - return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// RotationalStiffnessPerLength unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static RotationalStiffnessPerLength From(double value, RotationalStiffnessPerLengthUnit fromUnit) - { - return new RotationalStiffnessPerLength((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static RotationalStiffnessPerLength Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalStiffnessPerLength Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out RotationalStiffnessPerLength result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out RotationalStiffnessPerLength result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static RotationalStiffnessPerLengthUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static RotationalStiffnessPerLengthUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out RotationalStiffnessPerLengthUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out RotationalStiffnessPerLengthUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) throw new ArgumentException("Expected type RotationalStiffnessPerLength.", nameof(obj)); - - return CompareTo(objRotationalStiffnessPerLength); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(RotationalStiffnessPerLength other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) - return false; - - return Equals(objRotationalStiffnessPerLength); - } - - public bool Equals(RotationalStiffnessPerLength other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another RotationalStiffnessPerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current RotationalStiffnessPerLength. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((RotationalStiffnessPerLengthUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(RotationalStiffnessPerLengthUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this RotationalStiffnessPerLength to another RotationalStiffnessPerLength with the unit representation . - /// - /// A RotationalStiffnessPerLength with the specified unit. - public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new RotationalStiffnessPerLength(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(RotationalStiffnessPerLengthUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Scalar.g.cs deleted file mode 100644 index 39d68ea3b5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Scalar.g.cs +++ /dev/null @@ -1,580 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A way of representing a number of items. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Scalar : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ScalarUnit? _unit; - - static Scalar() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Scalar, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Amount. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Scalar() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Scalar(double value, ScalarUnit unit) - { - if(unit == ScalarUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Scalar, which is Amount. All conversions go via this value. - /// - public static ScalarUnit BaseUnit { get; } = ScalarUnit.Amount; - - /// - /// Represents the largest possible value of Scalar - /// - public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Scalar - /// - public static Scalar MinValue { get; } = new Scalar(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Scalar; - - /// - /// All units of measurement for the Scalar quantity. - /// - public static ScalarUnit[] Units { get; } = Enum.GetValues(typeof(ScalarUnit)).Cast().Except(new ScalarUnit[]{ ScalarUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Amount. - /// - public static Scalar Zero { get; } = new Scalar(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ScalarUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Scalar.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Scalar.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Scalar in Amount. - /// - public double Amount => As(ScalarUnit.Amount); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ScalarUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ScalarUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Scalar from Amount. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Scalar FromAmount(double amount) - { - double value = (double) amount; - return new Scalar(value, ScalarUnit.Amount); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Scalar unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Scalar From(double value, ScalarUnit fromUnit) - { - return new Scalar((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Scalar Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Scalar Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Scalar result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Scalar result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ScalarUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ScalarUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ScalarUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ScalarUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Scalar objScalar)) throw new ArgumentException("Expected type Scalar.", nameof(obj)); - - return CompareTo(objScalar); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Scalar other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Scalar objScalar)) - return false; - - return Equals(objScalar); - } - - public bool Equals(Scalar other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Scalar within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Scalar. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ScalarUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ScalarUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Scalar to another Scalar with the unit representation . - /// - /// A Scalar with the specified unit. - public Scalar ToUnit(ScalarUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Scalar(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case ScalarUnit.Amount: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(ScalarUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case ScalarUnit.Amount: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.g.cs deleted file mode 100644 index b7163491e9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SolidAngle.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In geometry, a solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point. - /// - /// - /// https://en.wikipedia.org/wiki/Solid_angle - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class SolidAngle : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SolidAngleUnit? _unit; - - static SolidAngle() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.SolidAngle, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Steradian. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public SolidAngle() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private SolidAngle(double value, SolidAngleUnit unit) - { - if(unit == SolidAngleUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of SolidAngle, which is Steradian. All conversions go via this value. - /// - public static SolidAngleUnit BaseUnit { get; } = SolidAngleUnit.Steradian; - - /// - /// Represents the largest possible value of SolidAngle - /// - public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of SolidAngle - /// - public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.SolidAngle; - - /// - /// All units of measurement for the SolidAngle quantity. - /// - public static SolidAngleUnit[] Units { get; } = Enum.GetValues(typeof(SolidAngleUnit)).Cast().Except(new SolidAngleUnit[]{ SolidAngleUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Steradian. - /// - public static SolidAngle Zero { get; } = new SolidAngle(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SolidAngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => SolidAngle.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => SolidAngle.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get SolidAngle in Steradians. - /// - public double Steradians => As(SolidAngleUnit.Steradian); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SolidAngleUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SolidAngleUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get SolidAngle from Steradians. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SolidAngle FromSteradians(double steradians) - { - double value = (double) steradians; - return new SolidAngle(value, SolidAngleUnit.Steradian); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// SolidAngle unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static SolidAngle From(double value, SolidAngleUnit fromUnit) - { - return new SolidAngle((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static SolidAngle Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SolidAngle Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out SolidAngle result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out SolidAngle result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SolidAngleUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SolidAngleUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SolidAngleUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SolidAngleUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SolidAngle objSolidAngle)) throw new ArgumentException("Expected type SolidAngle.", nameof(obj)); - - return CompareTo(objSolidAngle); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(SolidAngle other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is SolidAngle objSolidAngle)) - return false; - - return Equals(objSolidAngle); - } - - public bool Equals(SolidAngle other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another SolidAngle within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current SolidAngle. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SolidAngleUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SolidAngleUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this SolidAngle to another SolidAngle with the unit representation . - /// - /// A SolidAngle with the specified unit. - public SolidAngle ToUnit(SolidAngleUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new SolidAngle(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case SolidAngleUnit.Steradian: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(SolidAngleUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case SolidAngleUnit.Steradian: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.g.cs deleted file mode 100644 index 87c65ba238..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ /dev/null @@ -1,991 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The SpecificEnergy - /// - /// - /// https://en.wikipedia.org/wiki/Specific_energy - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class SpecificEnergy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SpecificEnergyUnit? _unit; - - static SpecificEnergy() - { - BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificEnergy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerKilogram. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public SpecificEnergy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private SpecificEnergy(double value, SpecificEnergyUnit unit) - { - if(unit == SpecificEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of SpecificEnergy, which is JoulePerKilogram. All conversions go via this value. - /// - public static SpecificEnergyUnit BaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; - - /// - /// Represents the largest possible value of SpecificEnergy - /// - public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of SpecificEnergy - /// - public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.SpecificEnergy; - - /// - /// All units of measurement for the SpecificEnergy quantity. - /// - public static SpecificEnergyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().Except(new SpecificEnergyUnit[]{ SpecificEnergyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogram. - /// - public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SpecificEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificEnergy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => SpecificEnergy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get SpecificEnergy in BtuPerPound. - /// - public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); - - /// - /// Get SpecificEnergy in CaloriesPerGram. - /// - public double CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); - - /// - /// Get SpecificEnergy in GigawattDaysPerKilogram. - /// - public double GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); - - /// - /// Get SpecificEnergy in GigawattDaysPerShortTon. - /// - public double GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); - - /// - /// Get SpecificEnergy in GigawattDaysPerTonne. - /// - public double GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); - - /// - /// Get SpecificEnergy in GigawattHoursPerKilogram. - /// - public double GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); - - /// - /// Get SpecificEnergy in JoulesPerKilogram. - /// - public double JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); - - /// - /// Get SpecificEnergy in KilocaloriesPerGram. - /// - public double KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); - - /// - /// Get SpecificEnergy in KilojoulesPerKilogram. - /// - public double KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); - - /// - /// Get SpecificEnergy in KilowattDaysPerKilogram. - /// - public double KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); - - /// - /// Get SpecificEnergy in KilowattDaysPerShortTon. - /// - public double KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); - - /// - /// Get SpecificEnergy in KilowattDaysPerTonne. - /// - public double KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); - - /// - /// Get SpecificEnergy in KilowattHoursPerKilogram. - /// - public double KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); - - /// - /// Get SpecificEnergy in MegajoulesPerKilogram. - /// - public double MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); - - /// - /// Get SpecificEnergy in MegawattDaysPerKilogram. - /// - public double MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); - - /// - /// Get SpecificEnergy in MegawattDaysPerShortTon. - /// - public double MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); - - /// - /// Get SpecificEnergy in MegawattDaysPerTonne. - /// - public double MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); - - /// - /// Get SpecificEnergy in MegawattHoursPerKilogram. - /// - public double MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); - - /// - /// Get SpecificEnergy in TerawattDaysPerKilogram. - /// - public double TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); - - /// - /// Get SpecificEnergy in TerawattDaysPerShortTon. - /// - public double TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); - - /// - /// Get SpecificEnergy in TerawattDaysPerTonne. - /// - public double TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); - - /// - /// Get SpecificEnergy in WattDaysPerKilogram. - /// - public double WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); - - /// - /// Get SpecificEnergy in WattDaysPerShortTon. - /// - public double WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); - - /// - /// Get SpecificEnergy in WattDaysPerTonne. - /// - public double WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); - - /// - /// Get SpecificEnergy in WattHoursPerKilogram. - /// - public double WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SpecificEnergyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SpecificEnergyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get SpecificEnergy from BtuPerPound. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromBtuPerPound(double btuperpound) - { - double value = (double) btuperpound; - return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound); - } - /// - /// Get SpecificEnergy from CaloriesPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromCaloriesPerGram(double caloriespergram) - { - double value = (double) caloriespergram; - return new SpecificEnergy(value, SpecificEnergyUnit.CaloriePerGram); - } - /// - /// Get SpecificEnergy from GigawattDaysPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromGigawattDaysPerKilogram(double gigawattdaysperkilogram) - { - double value = (double) gigawattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerKilogram); - } - /// - /// Get SpecificEnergy from GigawattDaysPerShortTon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromGigawattDaysPerShortTon(double gigawattdayspershortton) - { - double value = (double) gigawattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerShortTon); - } - /// - /// Get SpecificEnergy from GigawattDaysPerTonne. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromGigawattDaysPerTonne(double gigawattdayspertonne) - { - double value = (double) gigawattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerTonne); - } - /// - /// Get SpecificEnergy from GigawattHoursPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromGigawattHoursPerKilogram(double gigawatthoursperkilogram) - { - double value = (double) gigawatthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerKilogram); - } - /// - /// Get SpecificEnergy from JoulesPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromJoulesPerKilogram(double joulesperkilogram) - { - double value = (double) joulesperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.JoulePerKilogram); - } - /// - /// Get SpecificEnergy from KilocaloriesPerGram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromKilocaloriesPerGram(double kilocaloriespergram) - { - double value = (double) kilocaloriespergram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilocaloriePerGram); - } - /// - /// Get SpecificEnergy from KilojoulesPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromKilojoulesPerKilogram(double kilojoulesperkilogram) - { - double value = (double) kilojoulesperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilojoulePerKilogram); - } - /// - /// Get SpecificEnergy from KilowattDaysPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromKilowattDaysPerKilogram(double kilowattdaysperkilogram) - { - double value = (double) kilowattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerKilogram); - } - /// - /// Get SpecificEnergy from KilowattDaysPerShortTon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromKilowattDaysPerShortTon(double kilowattdayspershortton) - { - double value = (double) kilowattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerShortTon); - } - /// - /// Get SpecificEnergy from KilowattDaysPerTonne. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromKilowattDaysPerTonne(double kilowattdayspertonne) - { - double value = (double) kilowattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerTonne); - } - /// - /// Get SpecificEnergy from KilowattHoursPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromKilowattHoursPerKilogram(double kilowatthoursperkilogram) - { - double value = (double) kilowatthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerKilogram); - } - /// - /// Get SpecificEnergy from MegajoulesPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromMegajoulesPerKilogram(double megajoulesperkilogram) - { - double value = (double) megajoulesperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.MegajoulePerKilogram); - } - /// - /// Get SpecificEnergy from MegawattDaysPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromMegawattDaysPerKilogram(double megawattdaysperkilogram) - { - double value = (double) megawattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerKilogram); - } - /// - /// Get SpecificEnergy from MegawattDaysPerShortTon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromMegawattDaysPerShortTon(double megawattdayspershortton) - { - double value = (double) megawattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerShortTon); - } - /// - /// Get SpecificEnergy from MegawattDaysPerTonne. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromMegawattDaysPerTonne(double megawattdayspertonne) - { - double value = (double) megawattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerTonne); - } - /// - /// Get SpecificEnergy from MegawattHoursPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromMegawattHoursPerKilogram(double megawatthoursperkilogram) - { - double value = (double) megawatthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerKilogram); - } - /// - /// Get SpecificEnergy from TerawattDaysPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromTerawattDaysPerKilogram(double terawattdaysperkilogram) - { - double value = (double) terawattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerKilogram); - } - /// - /// Get SpecificEnergy from TerawattDaysPerShortTon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromTerawattDaysPerShortTon(double terawattdayspershortton) - { - double value = (double) terawattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerShortTon); - } - /// - /// Get SpecificEnergy from TerawattDaysPerTonne. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromTerawattDaysPerTonne(double terawattdayspertonne) - { - double value = (double) terawattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerTonne); - } - /// - /// Get SpecificEnergy from WattDaysPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromWattDaysPerKilogram(double wattdaysperkilogram) - { - double value = (double) wattdaysperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerKilogram); - } - /// - /// Get SpecificEnergy from WattDaysPerShortTon. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromWattDaysPerShortTon(double wattdayspershortton) - { - double value = (double) wattdayspershortton; - return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerShortTon); - } - /// - /// Get SpecificEnergy from WattDaysPerTonne. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromWattDaysPerTonne(double wattdayspertonne) - { - double value = (double) wattdayspertonne; - return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerTonne); - } - /// - /// Get SpecificEnergy from WattHoursPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEnergy FromWattHoursPerKilogram(double watthoursperkilogram) - { - double value = (double) watthoursperkilogram; - return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerKilogram); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// SpecificEnergy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static SpecificEnergy From(double value, SpecificEnergyUnit fromUnit) - { - return new SpecificEnergy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static SpecificEnergy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificEnergy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out SpecificEnergy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out SpecificEnergy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SpecificEnergyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificEnergyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SpecificEnergyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SpecificEnergyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificEnergy objSpecificEnergy)) throw new ArgumentException("Expected type SpecificEnergy.", nameof(obj)); - - return CompareTo(objSpecificEnergy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(SpecificEnergy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificEnergy objSpecificEnergy)) - return false; - - return Equals(objSpecificEnergy); - } - - public bool Equals(SpecificEnergy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another SpecificEnergy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current SpecificEnergy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SpecificEnergyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SpecificEnergyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this SpecificEnergy to another SpecificEnergy with the unit representation . - /// - /// A SpecificEnergy with the specified unit. - public SpecificEnergy ToUnit(SpecificEnergyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new SpecificEnergy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(SpecificEnergyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.g.cs deleted file mode 100644 index a24c093d9e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ /dev/null @@ -1,716 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class SpecificEntropy : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SpecificEntropyUnit? _unit; - - static SpecificEntropy() - { - BaseDimensions = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificEntropy, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerKilogramKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public SpecificEntropy() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private SpecificEntropy(double value, SpecificEntropyUnit unit) - { - if(unit == SpecificEntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of SpecificEntropy, which is JoulePerKilogramKelvin. All conversions go via this value. - /// - public static SpecificEntropyUnit BaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; - - /// - /// Represents the largest possible value of SpecificEntropy - /// - public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of SpecificEntropy - /// - public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.SpecificEntropy; - - /// - /// All units of measurement for the SpecificEntropy quantity. - /// - public static SpecificEntropyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().Except(new SpecificEntropyUnit[]{ SpecificEntropyUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogramKelvin. - /// - public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SpecificEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificEntropy.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => SpecificEntropy.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get SpecificEntropy in BtusPerPoundFahrenheit. - /// - public double BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); - - /// - /// Get SpecificEntropy in CaloriesPerGramKelvin. - /// - public double CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); - - /// - /// Get SpecificEntropy in JoulesPerKilogramDegreeCelsius. - /// - public double JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); - - /// - /// Get SpecificEntropy in JoulesPerKilogramKelvin. - /// - public double JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); - - /// - /// Get SpecificEntropy in KilocaloriesPerGramKelvin. - /// - public double KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); - - /// - /// Get SpecificEntropy in KilojoulesPerKilogramDegreeCelsius. - /// - public double KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); - - /// - /// Get SpecificEntropy in KilojoulesPerKilogramKelvin. - /// - public double KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); - - /// - /// Get SpecificEntropy in MegajoulesPerKilogramDegreeCelsius. - /// - public double MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); - - /// - /// Get SpecificEntropy in MegajoulesPerKilogramKelvin. - /// - public double MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SpecificEntropyUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SpecificEntropyUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get SpecificEntropy from BtusPerPoundFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromBtusPerPoundFahrenheit(double btusperpoundfahrenheit) - { - double value = (double) btusperpoundfahrenheit; - return new SpecificEntropy(value, SpecificEntropyUnit.BtuPerPoundFahrenheit); - } - /// - /// Get SpecificEntropy from CaloriesPerGramKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromCaloriesPerGramKelvin(double caloriespergramkelvin) - { - double value = (double) caloriespergramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.CaloriePerGramKelvin); - } - /// - /// Get SpecificEntropy from JoulesPerKilogramDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(double joulesperkilogramdegreecelsius) - { - double value = (double) joulesperkilogramdegreecelsius; - return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); - } - /// - /// Get SpecificEntropy from JoulesPerKilogramKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromJoulesPerKilogramKelvin(double joulesperkilogramkelvin) - { - double value = (double) joulesperkilogramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramKelvin); - } - /// - /// Get SpecificEntropy from KilocaloriesPerGramKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromKilocaloriesPerGramKelvin(double kilocaloriespergramkelvin) - { - double value = (double) kilocaloriespergramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.KilocaloriePerGramKelvin); - } - /// - /// Get SpecificEntropy from KilojoulesPerKilogramDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(double kilojoulesperkilogramdegreecelsius) - { - double value = (double) kilojoulesperkilogramdegreecelsius; - return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); - } - /// - /// Get SpecificEntropy from KilojoulesPerKilogramKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromKilojoulesPerKilogramKelvin(double kilojoulesperkilogramkelvin) - { - double value = (double) kilojoulesperkilogramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramKelvin); - } - /// - /// Get SpecificEntropy from MegajoulesPerKilogramDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(double megajoulesperkilogramdegreecelsius) - { - double value = (double) megajoulesperkilogramdegreecelsius; - return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); - } - /// - /// Get SpecificEntropy from MegajoulesPerKilogramKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificEntropy FromMegajoulesPerKilogramKelvin(double megajoulesperkilogramkelvin) - { - double value = (double) megajoulesperkilogramkelvin; - return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// SpecificEntropy unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static SpecificEntropy From(double value, SpecificEntropyUnit fromUnit) - { - return new SpecificEntropy((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static SpecificEntropy Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificEntropy Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out SpecificEntropy result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out SpecificEntropy result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SpecificEntropyUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificEntropyUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SpecificEntropyUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SpecificEntropyUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificEntropy objSpecificEntropy)) throw new ArgumentException("Expected type SpecificEntropy.", nameof(obj)); - - return CompareTo(objSpecificEntropy); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(SpecificEntropy other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificEntropy objSpecificEntropy)) - return false; - - return Equals(objSpecificEntropy); - } - - public bool Equals(SpecificEntropy other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another SpecificEntropy within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current SpecificEntropy. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SpecificEntropyUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SpecificEntropyUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this SpecificEntropy to another SpecificEntropy with the unit representation . - /// - /// A SpecificEntropy with the specified unit. - public SpecificEntropy ToUnit(SpecificEntropyUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new SpecificEntropy(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(SpecificEntropyUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs deleted file mode 100644 index 26129abb06..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ /dev/null @@ -1,634 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// SFC is the fuel efficiency of an engine design with respect to thrust output - /// - /// - /// https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class SpecificFuelConsumption : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SpecificFuelConsumptionUnit? _unit; - - static SpecificFuelConsumption() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.SpecificFuelConsumption, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit GramPerKiloNewtonSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public SpecificFuelConsumption() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) - { - if(unit == SpecificFuelConsumptionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of SpecificFuelConsumption, which is GramPerKiloNewtonSecond. All conversions go via this value. - /// - public static SpecificFuelConsumptionUnit BaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; - - /// - /// Represents the largest possible value of SpecificFuelConsumption - /// - public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of SpecificFuelConsumption - /// - public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.SpecificFuelConsumption; - - /// - /// All units of measurement for the SpecificFuelConsumption quantity. - /// - public static SpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast().Except(new SpecificFuelConsumptionUnit[]{ SpecificFuelConsumptionUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit GramPerKiloNewtonSecond. - /// - public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificFuelConsumption.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => SpecificFuelConsumption.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get SpecificFuelConsumption in GramsPerKiloNewtonSecond. - /// - public double GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); - - /// - /// Get SpecificFuelConsumption in KilogramsPerKilogramForceHour. - /// - public double KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); - - /// - /// Get SpecificFuelConsumption in KilogramsPerKiloNewtonSecond. - /// - public double KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); - - /// - /// Get SpecificFuelConsumption in PoundsMassPerPoundForceHour. - /// - public double PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SpecificFuelConsumptionUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SpecificFuelConsumptionUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get SpecificFuelConsumption from GramsPerKiloNewtonSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(double gramsperkilonewtonsecond) - { - double value = (double) gramsperkilonewtonsecond; - return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); - } - /// - /// Get SpecificFuelConsumption from KilogramsPerKilogramForceHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(double kilogramsperkilogramforcehour) - { - double value = (double) kilogramsperkilogramforcehour; - return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); - } - /// - /// Get SpecificFuelConsumption from KilogramsPerKiloNewtonSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(double kilogramsperkilonewtonsecond) - { - double value = (double) kilogramsperkilonewtonsecond; - return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); - } - /// - /// Get SpecificFuelConsumption from PoundsMassPerPoundForceHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(double poundsmassperpoundforcehour) - { - double value = (double) poundsmassperpoundforcehour; - return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// SpecificFuelConsumption unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static SpecificFuelConsumption From(double value, SpecificFuelConsumptionUnit fromUnit) - { - return new SpecificFuelConsumption((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static SpecificFuelConsumption Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificFuelConsumption Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out SpecificFuelConsumption result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out SpecificFuelConsumption result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SpecificFuelConsumptionUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificFuelConsumptionUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SpecificFuelConsumptionUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SpecificFuelConsumptionUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificFuelConsumption objSpecificFuelConsumption)) throw new ArgumentException("Expected type SpecificFuelConsumption.", nameof(obj)); - - return CompareTo(objSpecificFuelConsumption); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(SpecificFuelConsumption other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificFuelConsumption objSpecificFuelConsumption)) - return false; - - return Equals(objSpecificFuelConsumption); - } - - public bool Equals(SpecificFuelConsumption other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another SpecificFuelConsumption within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current SpecificFuelConsumption. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SpecificFuelConsumptionUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SpecificFuelConsumptionUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this SpecificFuelConsumption to another SpecificFuelConsumption with the unit representation . - /// - /// A SpecificFuelConsumption with the specified unit. - public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new SpecificFuelConsumption(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(SpecificFuelConsumptionUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.g.cs deleted file mode 100644 index b0fbec3944..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificVolume.g.cs +++ /dev/null @@ -1,614 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class SpecificVolume : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SpecificVolumeUnit? _unit; - - static SpecificVolume() - { - BaseDimensions = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificVolume, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit CubicMeterPerKilogram. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public SpecificVolume() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private SpecificVolume(double value, SpecificVolumeUnit unit) - { - if(unit == SpecificVolumeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of SpecificVolume, which is CubicMeterPerKilogram. All conversions go via this value. - /// - public static SpecificVolumeUnit BaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; - - /// - /// Represents the largest possible value of SpecificVolume - /// - public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of SpecificVolume - /// - public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.SpecificVolume; - - /// - /// All units of measurement for the SpecificVolume quantity. - /// - public static SpecificVolumeUnit[] Units { get; } = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().Except(new SpecificVolumeUnit[]{ SpecificVolumeUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerKilogram. - /// - public static SpecificVolume Zero { get; } = new SpecificVolume(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SpecificVolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificVolume.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => SpecificVolume.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get SpecificVolume in CubicFeetPerPound. - /// - public double CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); - - /// - /// Get SpecificVolume in CubicMetersPerKilogram. - /// - public double CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); - - /// - /// Get SpecificVolume in MillicubicMetersPerKilogram. - /// - public double MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SpecificVolumeUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SpecificVolumeUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get SpecificVolume from CubicFeetPerPound. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificVolume FromCubicFeetPerPound(double cubicfeetperpound) - { - double value = (double) cubicfeetperpound; - return new SpecificVolume(value, SpecificVolumeUnit.CubicFootPerPound); - } - /// - /// Get SpecificVolume from CubicMetersPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificVolume FromCubicMetersPerKilogram(double cubicmetersperkilogram) - { - double value = (double) cubicmetersperkilogram; - return new SpecificVolume(value, SpecificVolumeUnit.CubicMeterPerKilogram); - } - /// - /// Get SpecificVolume from MillicubicMetersPerKilogram. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificVolume FromMillicubicMetersPerKilogram(double millicubicmetersperkilogram) - { - double value = (double) millicubicmetersperkilogram; - return new SpecificVolume(value, SpecificVolumeUnit.MillicubicMeterPerKilogram); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// SpecificVolume unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static SpecificVolume From(double value, SpecificVolumeUnit fromUnit) - { - return new SpecificVolume((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static SpecificVolume Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificVolume Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out SpecificVolume result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out SpecificVolume result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SpecificVolumeUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificVolumeUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SpecificVolumeUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SpecificVolumeUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificVolume objSpecificVolume)) throw new ArgumentException("Expected type SpecificVolume.", nameof(obj)); - - return CompareTo(objSpecificVolume); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(SpecificVolume other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificVolume objSpecificVolume)) - return false; - - return Equals(objSpecificVolume); - } - - public bool Equals(SpecificVolume other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another SpecificVolume within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current SpecificVolume. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SpecificVolumeUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SpecificVolumeUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this SpecificVolume to another SpecificVolume with the unit representation . - /// - /// A SpecificVolume with the specified unit. - public SpecificVolume ToUnit(SpecificVolumeUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new SpecificVolume(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(SpecificVolumeUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.g.cs deleted file mode 100644 index 129be9de76..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/SpecificWeight.g.cs +++ /dev/null @@ -1,855 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The SpecificWeight, or more precisely, the volumetric weight density, of a substance is its weight per unit volume. - /// - /// - /// http://en.wikipedia.org/wiki/Specificweight - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class SpecificWeight : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SpecificWeightUnit? _unit; - - static SpecificWeight() - { - BaseDimensions = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.SpecificWeight, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonPerCubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public SpecificWeight() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private SpecificWeight(double value, SpecificWeightUnit unit) - { - if(unit == SpecificWeightUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of SpecificWeight, which is NewtonPerCubicMeter. All conversions go via this value. - /// - public static SpecificWeightUnit BaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; - - /// - /// Represents the largest possible value of SpecificWeight - /// - public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of SpecificWeight - /// - public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.SpecificWeight; - - /// - /// All units of measurement for the SpecificWeight quantity. - /// - public static SpecificWeightUnit[] Units { get; } = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().Except(new SpecificWeightUnit[]{ SpecificWeightUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerCubicMeter. - /// - public static SpecificWeight Zero { get; } = new SpecificWeight(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SpecificWeightUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificWeight.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => SpecificWeight.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get SpecificWeight in KilogramsForcePerCubicCentimeter. - /// - public double KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); - - /// - /// Get SpecificWeight in KilogramsForcePerCubicMeter. - /// - public double KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); - - /// - /// Get SpecificWeight in KilogramsForcePerCubicMillimeter. - /// - public double KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); - - /// - /// Get SpecificWeight in KilonewtonsPerCubicCentimeter. - /// - public double KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); - - /// - /// Get SpecificWeight in KilonewtonsPerCubicMeter. - /// - public double KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); - - /// - /// Get SpecificWeight in KilonewtonsPerCubicMillimeter. - /// - public double KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); - - /// - /// Get SpecificWeight in KilopoundsForcePerCubicFoot. - /// - public double KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); - - /// - /// Get SpecificWeight in KilopoundsForcePerCubicInch. - /// - public double KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); - - /// - /// Get SpecificWeight in MeganewtonsPerCubicMeter. - /// - public double MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); - - /// - /// Get SpecificWeight in NewtonsPerCubicCentimeter. - /// - public double NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); - - /// - /// Get SpecificWeight in NewtonsPerCubicMeter. - /// - public double NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); - - /// - /// Get SpecificWeight in NewtonsPerCubicMillimeter. - /// - public double NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); - - /// - /// Get SpecificWeight in PoundsForcePerCubicFoot. - /// - public double PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); - - /// - /// Get SpecificWeight in PoundsForcePerCubicInch. - /// - public double PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); - - /// - /// Get SpecificWeight in TonnesForcePerCubicCentimeter. - /// - public double TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); - - /// - /// Get SpecificWeight in TonnesForcePerCubicMeter. - /// - public double TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); - - /// - /// Get SpecificWeight in TonnesForcePerCubicMillimeter. - /// - public double TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SpecificWeightUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SpecificWeightUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get SpecificWeight from KilogramsForcePerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilogramsForcePerCubicCentimeter(double kilogramsforcepercubiccentimeter) - { - double value = (double) kilogramsforcepercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicCentimeter); - } - /// - /// Get SpecificWeight from KilogramsForcePerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilogramsForcePerCubicMeter(double kilogramsforcepercubicmeter) - { - double value = (double) kilogramsforcepercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMeter); - } - /// - /// Get SpecificWeight from KilogramsForcePerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilogramsForcePerCubicMillimeter(double kilogramsforcepercubicmillimeter) - { - double value = (double) kilogramsforcepercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMillimeter); - } - /// - /// Get SpecificWeight from KilonewtonsPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilonewtonsPerCubicCentimeter(double kilonewtonspercubiccentimeter) - { - double value = (double) kilonewtonspercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicCentimeter); - } - /// - /// Get SpecificWeight from KilonewtonsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilonewtonsPerCubicMeter(double kilonewtonspercubicmeter) - { - double value = (double) kilonewtonspercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMeter); - } - /// - /// Get SpecificWeight from KilonewtonsPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilonewtonsPerCubicMillimeter(double kilonewtonspercubicmillimeter) - { - double value = (double) kilonewtonspercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMillimeter); - } - /// - /// Get SpecificWeight from KilopoundsForcePerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilopoundsForcePerCubicFoot(double kilopoundsforcepercubicfoot) - { - double value = (double) kilopoundsforcepercubicfoot; - return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicFoot); - } - /// - /// Get SpecificWeight from KilopoundsForcePerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromKilopoundsForcePerCubicInch(double kilopoundsforcepercubicinch) - { - double value = (double) kilopoundsforcepercubicinch; - return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicInch); - } - /// - /// Get SpecificWeight from MeganewtonsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromMeganewtonsPerCubicMeter(double meganewtonspercubicmeter) - { - double value = (double) meganewtonspercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.MeganewtonPerCubicMeter); - } - /// - /// Get SpecificWeight from NewtonsPerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromNewtonsPerCubicCentimeter(double newtonspercubiccentimeter) - { - double value = (double) newtonspercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicCentimeter); - } - /// - /// Get SpecificWeight from NewtonsPerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromNewtonsPerCubicMeter(double newtonspercubicmeter) - { - double value = (double) newtonspercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMeter); - } - /// - /// Get SpecificWeight from NewtonsPerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromNewtonsPerCubicMillimeter(double newtonspercubicmillimeter) - { - double value = (double) newtonspercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMillimeter); - } - /// - /// Get SpecificWeight from PoundsForcePerCubicFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromPoundsForcePerCubicFoot(double poundsforcepercubicfoot) - { - double value = (double) poundsforcepercubicfoot; - return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicFoot); - } - /// - /// Get SpecificWeight from PoundsForcePerCubicInch. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromPoundsForcePerCubicInch(double poundsforcepercubicinch) - { - double value = (double) poundsforcepercubicinch; - return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicInch); - } - /// - /// Get SpecificWeight from TonnesForcePerCubicCentimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromTonnesForcePerCubicCentimeter(double tonnesforcepercubiccentimeter) - { - double value = (double) tonnesforcepercubiccentimeter; - return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicCentimeter); - } - /// - /// Get SpecificWeight from TonnesForcePerCubicMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromTonnesForcePerCubicMeter(double tonnesforcepercubicmeter) - { - double value = (double) tonnesforcepercubicmeter; - return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMeter); - } - /// - /// Get SpecificWeight from TonnesForcePerCubicMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static SpecificWeight FromTonnesForcePerCubicMillimeter(double tonnesforcepercubicmillimeter) - { - double value = (double) tonnesforcepercubicmillimeter; - return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// SpecificWeight unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static SpecificWeight From(double value, SpecificWeightUnit fromUnit) - { - return new SpecificWeight((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static SpecificWeight Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificWeight Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out SpecificWeight result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out SpecificWeight result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SpecificWeightUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpecificWeightUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SpecificWeightUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SpecificWeightUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is SpecificWeight objSpecificWeight)) throw new ArgumentException("Expected type SpecificWeight.", nameof(obj)); - - return CompareTo(objSpecificWeight); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(SpecificWeight other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificWeight objSpecificWeight)) - return false; - - return Equals(objSpecificWeight); - } - - public bool Equals(SpecificWeight other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another SpecificWeight within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current SpecificWeight. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SpecificWeightUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SpecificWeightUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this SpecificWeight to another SpecificWeight with the unit representation . - /// - /// A SpecificWeight with the specified unit. - public SpecificWeight ToUnit(SpecificWeightUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new SpecificWeight(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(SpecificWeightUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.g.cs deleted file mode 100644 index 563c5ac20c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Speed.g.cs +++ /dev/null @@ -1,1107 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Speed : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly SpeedUnit? _unit; - - static Speed() - { - BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Speed, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit MeterPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Speed() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Speed(double value, SpeedUnit unit) - { - if(unit == SpeedUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Speed, which is MeterPerSecond. All conversions go via this value. - /// - public static SpeedUnit BaseUnit { get; } = SpeedUnit.MeterPerSecond; - - /// - /// Represents the largest possible value of Speed - /// - public static Speed MaxValue { get; } = new Speed(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Speed - /// - public static Speed MinValue { get; } = new Speed(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Speed; - - /// - /// All units of measurement for the Speed quantity. - /// - public static SpeedUnit[] Units { get; } = Enum.GetValues(typeof(SpeedUnit)).Cast().Except(new SpeedUnit[]{ SpeedUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecond. - /// - public static Speed Zero { get; } = new Speed(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public SpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Speed.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Speed.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Speed in CentimetersPerHour. - /// - public double CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); - - /// - /// Get Speed in CentimetersPerMinutes. - /// - public double CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); - - /// - /// Get Speed in CentimetersPerSecond. - /// - public double CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); - - /// - /// Get Speed in DecimetersPerMinutes. - /// - public double DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); - - /// - /// Get Speed in DecimetersPerSecond. - /// - public double DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); - - /// - /// Get Speed in FeetPerHour. - /// - public double FeetPerHour => As(SpeedUnit.FootPerHour); - - /// - /// Get Speed in FeetPerMinute. - /// - public double FeetPerMinute => As(SpeedUnit.FootPerMinute); - - /// - /// Get Speed in FeetPerSecond. - /// - public double FeetPerSecond => As(SpeedUnit.FootPerSecond); - - /// - /// Get Speed in InchesPerHour. - /// - public double InchesPerHour => As(SpeedUnit.InchPerHour); - - /// - /// Get Speed in InchesPerMinute. - /// - public double InchesPerMinute => As(SpeedUnit.InchPerMinute); - - /// - /// Get Speed in InchesPerSecond. - /// - public double InchesPerSecond => As(SpeedUnit.InchPerSecond); - - /// - /// Get Speed in KilometersPerHour. - /// - public double KilometersPerHour => As(SpeedUnit.KilometerPerHour); - - /// - /// Get Speed in KilometersPerMinutes. - /// - public double KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); - - /// - /// Get Speed in KilometersPerSecond. - /// - public double KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); - - /// - /// Get Speed in Knots. - /// - public double Knots => As(SpeedUnit.Knot); - - /// - /// Get Speed in MetersPerHour. - /// - public double MetersPerHour => As(SpeedUnit.MeterPerHour); - - /// - /// Get Speed in MetersPerMinutes. - /// - public double MetersPerMinutes => As(SpeedUnit.MeterPerMinute); - - /// - /// Get Speed in MetersPerSecond. - /// - public double MetersPerSecond => As(SpeedUnit.MeterPerSecond); - - /// - /// Get Speed in MicrometersPerMinutes. - /// - public double MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); - - /// - /// Get Speed in MicrometersPerSecond. - /// - public double MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); - - /// - /// Get Speed in MilesPerHour. - /// - public double MilesPerHour => As(SpeedUnit.MilePerHour); - - /// - /// Get Speed in MillimetersPerHour. - /// - public double MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); - - /// - /// Get Speed in MillimetersPerMinutes. - /// - public double MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); - - /// - /// Get Speed in MillimetersPerSecond. - /// - public double MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); - - /// - /// Get Speed in NanometersPerMinutes. - /// - public double NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); - - /// - /// Get Speed in NanometersPerSecond. - /// - public double NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); - - /// - /// Get Speed in UsSurveyFeetPerHour. - /// - public double UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); - - /// - /// Get Speed in UsSurveyFeetPerMinute. - /// - public double UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); - - /// - /// Get Speed in UsSurveyFeetPerSecond. - /// - public double UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); - - /// - /// Get Speed in YardsPerHour. - /// - public double YardsPerHour => As(SpeedUnit.YardPerHour); - - /// - /// Get Speed in YardsPerMinute. - /// - public double YardsPerMinute => As(SpeedUnit.YardPerMinute); - - /// - /// Get Speed in YardsPerSecond. - /// - public double YardsPerSecond => As(SpeedUnit.YardPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(SpeedUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(SpeedUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Speed from CentimetersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromCentimetersPerHour(double centimetersperhour) - { - double value = (double) centimetersperhour; - return new Speed(value, SpeedUnit.CentimeterPerHour); - } - /// - /// Get Speed from CentimetersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromCentimetersPerMinutes(double centimetersperminutes) - { - double value = (double) centimetersperminutes; - return new Speed(value, SpeedUnit.CentimeterPerMinute); - } - /// - /// Get Speed from CentimetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromCentimetersPerSecond(double centimeterspersecond) - { - double value = (double) centimeterspersecond; - return new Speed(value, SpeedUnit.CentimeterPerSecond); - } - /// - /// Get Speed from DecimetersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromDecimetersPerMinutes(double decimetersperminutes) - { - double value = (double) decimetersperminutes; - return new Speed(value, SpeedUnit.DecimeterPerMinute); - } - /// - /// Get Speed from DecimetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromDecimetersPerSecond(double decimeterspersecond) - { - double value = (double) decimeterspersecond; - return new Speed(value, SpeedUnit.DecimeterPerSecond); - } - /// - /// Get Speed from FeetPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromFeetPerHour(double feetperhour) - { - double value = (double) feetperhour; - return new Speed(value, SpeedUnit.FootPerHour); - } - /// - /// Get Speed from FeetPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromFeetPerMinute(double feetperminute) - { - double value = (double) feetperminute; - return new Speed(value, SpeedUnit.FootPerMinute); - } - /// - /// Get Speed from FeetPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromFeetPerSecond(double feetpersecond) - { - double value = (double) feetpersecond; - return new Speed(value, SpeedUnit.FootPerSecond); - } - /// - /// Get Speed from InchesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromInchesPerHour(double inchesperhour) - { - double value = (double) inchesperhour; - return new Speed(value, SpeedUnit.InchPerHour); - } - /// - /// Get Speed from InchesPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromInchesPerMinute(double inchesperminute) - { - double value = (double) inchesperminute; - return new Speed(value, SpeedUnit.InchPerMinute); - } - /// - /// Get Speed from InchesPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromInchesPerSecond(double inchespersecond) - { - double value = (double) inchespersecond; - return new Speed(value, SpeedUnit.InchPerSecond); - } - /// - /// Get Speed from KilometersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromKilometersPerHour(double kilometersperhour) - { - double value = (double) kilometersperhour; - return new Speed(value, SpeedUnit.KilometerPerHour); - } - /// - /// Get Speed from KilometersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromKilometersPerMinutes(double kilometersperminutes) - { - double value = (double) kilometersperminutes; - return new Speed(value, SpeedUnit.KilometerPerMinute); - } - /// - /// Get Speed from KilometersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromKilometersPerSecond(double kilometerspersecond) - { - double value = (double) kilometerspersecond; - return new Speed(value, SpeedUnit.KilometerPerSecond); - } - /// - /// Get Speed from Knots. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromKnots(double knots) - { - double value = (double) knots; - return new Speed(value, SpeedUnit.Knot); - } - /// - /// Get Speed from MetersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMetersPerHour(double metersperhour) - { - double value = (double) metersperhour; - return new Speed(value, SpeedUnit.MeterPerHour); - } - /// - /// Get Speed from MetersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMetersPerMinutes(double metersperminutes) - { - double value = (double) metersperminutes; - return new Speed(value, SpeedUnit.MeterPerMinute); - } - /// - /// Get Speed from MetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMetersPerSecond(double meterspersecond) - { - double value = (double) meterspersecond; - return new Speed(value, SpeedUnit.MeterPerSecond); - } - /// - /// Get Speed from MicrometersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMicrometersPerMinutes(double micrometersperminutes) - { - double value = (double) micrometersperminutes; - return new Speed(value, SpeedUnit.MicrometerPerMinute); - } - /// - /// Get Speed from MicrometersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMicrometersPerSecond(double micrometerspersecond) - { - double value = (double) micrometerspersecond; - return new Speed(value, SpeedUnit.MicrometerPerSecond); - } - /// - /// Get Speed from MilesPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMilesPerHour(double milesperhour) - { - double value = (double) milesperhour; - return new Speed(value, SpeedUnit.MilePerHour); - } - /// - /// Get Speed from MillimetersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMillimetersPerHour(double millimetersperhour) - { - double value = (double) millimetersperhour; - return new Speed(value, SpeedUnit.MillimeterPerHour); - } - /// - /// Get Speed from MillimetersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMillimetersPerMinutes(double millimetersperminutes) - { - double value = (double) millimetersperminutes; - return new Speed(value, SpeedUnit.MillimeterPerMinute); - } - /// - /// Get Speed from MillimetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromMillimetersPerSecond(double millimeterspersecond) - { - double value = (double) millimeterspersecond; - return new Speed(value, SpeedUnit.MillimeterPerSecond); - } - /// - /// Get Speed from NanometersPerMinutes. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromNanometersPerMinutes(double nanometersperminutes) - { - double value = (double) nanometersperminutes; - return new Speed(value, SpeedUnit.NanometerPerMinute); - } - /// - /// Get Speed from NanometersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromNanometersPerSecond(double nanometerspersecond) - { - double value = (double) nanometerspersecond; - return new Speed(value, SpeedUnit.NanometerPerSecond); - } - /// - /// Get Speed from UsSurveyFeetPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromUsSurveyFeetPerHour(double ussurveyfeetperhour) - { - double value = (double) ussurveyfeetperhour; - return new Speed(value, SpeedUnit.UsSurveyFootPerHour); - } - /// - /// Get Speed from UsSurveyFeetPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromUsSurveyFeetPerMinute(double ussurveyfeetperminute) - { - double value = (double) ussurveyfeetperminute; - return new Speed(value, SpeedUnit.UsSurveyFootPerMinute); - } - /// - /// Get Speed from UsSurveyFeetPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromUsSurveyFeetPerSecond(double ussurveyfeetpersecond) - { - double value = (double) ussurveyfeetpersecond; - return new Speed(value, SpeedUnit.UsSurveyFootPerSecond); - } - /// - /// Get Speed from YardsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromYardsPerHour(double yardsperhour) - { - double value = (double) yardsperhour; - return new Speed(value, SpeedUnit.YardPerHour); - } - /// - /// Get Speed from YardsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromYardsPerMinute(double yardsperminute) - { - double value = (double) yardsperminute; - return new Speed(value, SpeedUnit.YardPerMinute); - } - /// - /// Get Speed from YardsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Speed FromYardsPerSecond(double yardspersecond) - { - double value = (double) yardspersecond; - return new Speed(value, SpeedUnit.YardPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Speed unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Speed From(double value, SpeedUnit fromUnit) - { - return new Speed((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Speed Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Speed Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Speed result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Speed result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static SpeedUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static SpeedUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out SpeedUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out SpeedUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Speed objSpeed)) throw new ArgumentException("Expected type Speed.", nameof(obj)); - - return CompareTo(objSpeed); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Speed other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Speed objSpeed)) - return false; - - return Equals(objSpeed); - } - - public bool Equals(Speed other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Speed within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Speed. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((SpeedUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(SpeedUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Speed to another Speed with the unit representation . - /// - /// A Speed with the specified unit. - public Speed ToUnit(SpeedUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Speed(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(SpeedUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/StandardVolumeFlow.g.cs deleted file mode 100644 index 38b7664b58..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ /dev/null @@ -1,716 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class StandardVolumeFlow : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly StandardVolumeFlowUnit? _unit; - - static StandardVolumeFlow() - { - BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.StandardVolumeFlow, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit StandardCubicMeterPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public StandardVolumeFlow() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) - { - if(unit == StandardVolumeFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of StandardVolumeFlow, which is StandardCubicMeterPerSecond. All conversions go via this value. - /// - public static StandardVolumeFlowUnit BaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; - - /// - /// Represents the largest possible value of StandardVolumeFlow - /// - public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of StandardVolumeFlow - /// - public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.StandardVolumeFlow; - - /// - /// All units of measurement for the StandardVolumeFlow quantity. - /// - public static StandardVolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast().Except(new StandardVolumeFlowUnit[]{ StandardVolumeFlowUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit StandardCubicMeterPerSecond. - /// - public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public StandardVolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => StandardVolumeFlow.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => StandardVolumeFlow.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get StandardVolumeFlow in StandardCubicCentimetersPerMinute. - /// - public double StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); - - /// - /// Get StandardVolumeFlow in StandardCubicFeetPerHour. - /// - public double StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); - - /// - /// Get StandardVolumeFlow in StandardCubicFeetPerMinute. - /// - public double StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); - - /// - /// Get StandardVolumeFlow in StandardCubicFeetPerSecond. - /// - public double StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); - - /// - /// Get StandardVolumeFlow in StandardCubicMetersPerDay. - /// - public double StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); - - /// - /// Get StandardVolumeFlow in StandardCubicMetersPerHour. - /// - public double StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); - - /// - /// Get StandardVolumeFlow in StandardCubicMetersPerMinute. - /// - public double StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); - - /// - /// Get StandardVolumeFlow in StandardCubicMetersPerSecond. - /// - public double StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); - - /// - /// Get StandardVolumeFlow in StandardLitersPerMinute. - /// - public double StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(StandardVolumeFlowUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(StandardVolumeFlowUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get StandardVolumeFlow from StandardCubicCentimetersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(double standardcubiccentimetersperminute) - { - double value = (double) standardcubiccentimetersperminute; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); - } - /// - /// Get StandardVolumeFlow from StandardCubicFeetPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicFeetPerHour(double standardcubicfeetperhour) - { - double value = (double) standardcubicfeetperhour; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerHour); - } - /// - /// Get StandardVolumeFlow from StandardCubicFeetPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicFeetPerMinute(double standardcubicfeetperminute) - { - double value = (double) standardcubicfeetperminute; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerMinute); - } - /// - /// Get StandardVolumeFlow from StandardCubicFeetPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicFeetPerSecond(double standardcubicfeetpersecond) - { - double value = (double) standardcubicfeetpersecond; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerSecond); - } - /// - /// Get StandardVolumeFlow from StandardCubicMetersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicMetersPerDay(double standardcubicmetersperday) - { - double value = (double) standardcubicmetersperday; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerDay); - } - /// - /// Get StandardVolumeFlow from StandardCubicMetersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicMetersPerHour(double standardcubicmetersperhour) - { - double value = (double) standardcubicmetersperhour; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerHour); - } - /// - /// Get StandardVolumeFlow from StandardCubicMetersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicMetersPerMinute(double standardcubicmetersperminute) - { - double value = (double) standardcubicmetersperminute; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerMinute); - } - /// - /// Get StandardVolumeFlow from StandardCubicMetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardCubicMetersPerSecond(double standardcubicmeterspersecond) - { - double value = (double) standardcubicmeterspersecond; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerSecond); - } - /// - /// Get StandardVolumeFlow from StandardLitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static StandardVolumeFlow FromStandardLitersPerMinute(double standardlitersperminute) - { - double value = (double) standardlitersperminute; - return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardLiterPerMinute); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// StandardVolumeFlow unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static StandardVolumeFlow From(double value, StandardVolumeFlowUnit fromUnit) - { - return new StandardVolumeFlow((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static StandardVolumeFlow Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static StandardVolumeFlow Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out StandardVolumeFlow result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out StandardVolumeFlow result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static StandardVolumeFlowUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static StandardVolumeFlowUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out StandardVolumeFlowUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out StandardVolumeFlowUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is StandardVolumeFlow objStandardVolumeFlow)) throw new ArgumentException("Expected type StandardVolumeFlow.", nameof(obj)); - - return CompareTo(objStandardVolumeFlow); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(StandardVolumeFlow other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is StandardVolumeFlow objStandardVolumeFlow)) - return false; - - return Equals(objStandardVolumeFlow); - } - - public bool Equals(StandardVolumeFlow other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another StandardVolumeFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current StandardVolumeFlow. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((StandardVolumeFlowUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(StandardVolumeFlowUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this StandardVolumeFlow to another StandardVolumeFlow with the unit representation . - /// - /// A StandardVolumeFlow with the specified unit. - public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new StandardVolumeFlow(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(StandardVolumeFlowUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.g.cs deleted file mode 100644 index 7060f1fdd0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Temperature.g.cs +++ /dev/null @@ -1,733 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Temperature : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly TemperatureUnit? _unit; - - static Temperature() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); - Info = new QuantityInfo(QuantityType.Temperature, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Kelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Temperature() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Temperature(double value, TemperatureUnit unit) - { - if(unit == TemperatureUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Temperature, which is Kelvin. All conversions go via this value. - /// - public static TemperatureUnit BaseUnit { get; } = TemperatureUnit.Kelvin; - - /// - /// Represents the largest possible value of Temperature - /// - public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Temperature - /// - public static Temperature MinValue { get; } = new Temperature(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Temperature; - - /// - /// All units of measurement for the Temperature quantity. - /// - public static TemperatureUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureUnit)).Cast().Except(new TemperatureUnit[]{ TemperatureUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. - /// - public static Temperature Zero { get; } = new Temperature(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public TemperatureUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Temperature.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Temperature.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Temperature in DegreesCelsius. - /// - public double DegreesCelsius => As(TemperatureUnit.DegreeCelsius); - - /// - /// Get Temperature in DegreesDelisle. - /// - public double DegreesDelisle => As(TemperatureUnit.DegreeDelisle); - - /// - /// Get Temperature in DegreesFahrenheit. - /// - public double DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); - - /// - /// Get Temperature in DegreesNewton. - /// - public double DegreesNewton => As(TemperatureUnit.DegreeNewton); - - /// - /// Get Temperature in DegreesRankine. - /// - public double DegreesRankine => As(TemperatureUnit.DegreeRankine); - - /// - /// Get Temperature in DegreesReaumur. - /// - public double DegreesReaumur => As(TemperatureUnit.DegreeReaumur); - - /// - /// Get Temperature in DegreesRoemer. - /// - public double DegreesRoemer => As(TemperatureUnit.DegreeRoemer); - - /// - /// Get Temperature in Kelvins. - /// - public double Kelvins => As(TemperatureUnit.Kelvin); - - /// - /// Get Temperature in MillidegreesCelsius. - /// - public double MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); - - /// - /// Get Temperature in SolarTemperatures. - /// - public double SolarTemperatures => As(TemperatureUnit.SolarTemperature); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TemperatureUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(TemperatureUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Temperature from DegreesCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesCelsius(double degreescelsius) - { - double value = (double) degreescelsius; - return new Temperature(value, TemperatureUnit.DegreeCelsius); - } - /// - /// Get Temperature from DegreesDelisle. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesDelisle(double degreesdelisle) - { - double value = (double) degreesdelisle; - return new Temperature(value, TemperatureUnit.DegreeDelisle); - } - /// - /// Get Temperature from DegreesFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesFahrenheit(double degreesfahrenheit) - { - double value = (double) degreesfahrenheit; - return new Temperature(value, TemperatureUnit.DegreeFahrenheit); - } - /// - /// Get Temperature from DegreesNewton. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesNewton(double degreesnewton) - { - double value = (double) degreesnewton; - return new Temperature(value, TemperatureUnit.DegreeNewton); - } - /// - /// Get Temperature from DegreesRankine. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesRankine(double degreesrankine) - { - double value = (double) degreesrankine; - return new Temperature(value, TemperatureUnit.DegreeRankine); - } - /// - /// Get Temperature from DegreesReaumur. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesReaumur(double degreesreaumur) - { - double value = (double) degreesreaumur; - return new Temperature(value, TemperatureUnit.DegreeReaumur); - } - /// - /// Get Temperature from DegreesRoemer. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromDegreesRoemer(double degreesroemer) - { - double value = (double) degreesroemer; - return new Temperature(value, TemperatureUnit.DegreeRoemer); - } - /// - /// Get Temperature from Kelvins. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromKelvins(double kelvins) - { - double value = (double) kelvins; - return new Temperature(value, TemperatureUnit.Kelvin); - } - /// - /// Get Temperature from MillidegreesCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromMillidegreesCelsius(double millidegreescelsius) - { - double value = (double) millidegreescelsius; - return new Temperature(value, TemperatureUnit.MillidegreeCelsius); - } - /// - /// Get Temperature from SolarTemperatures. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Temperature FromSolarTemperatures(double solartemperatures) - { - double value = (double) solartemperatures; - return new Temperature(value, TemperatureUnit.SolarTemperature); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Temperature unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Temperature From(double value, TemperatureUnit fromUnit) - { - return new Temperature((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Temperature Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Temperature Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Temperature result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Temperature result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static TemperatureUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TemperatureUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out TemperatureUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out TemperatureUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Temperature objTemperature)) throw new ArgumentException("Expected type Temperature.", nameof(obj)); - - return CompareTo(objTemperature); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Temperature other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Temperature objTemperature)) - return false; - - return Equals(objTemperature); - } - - public bool Equals(Temperature other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Temperature within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Temperature. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((TemperatureUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(TemperatureUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Temperature to another Temperature with the unit representation . - /// - /// A Temperature with the specified unit. - public Temperature ToUnit(TemperatureUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Temperature(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(TemperatureUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.g.cs deleted file mode 100644 index 8cf1566aa2..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ /dev/null @@ -1,733 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class TemperatureChangeRate : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly TemperatureChangeRateUnit? _unit; - - static TemperatureChangeRate() - { - BaseDimensions = new BaseDimensions(0, 0, -1, 0, 1, 0, 0); - Info = new QuantityInfo(QuantityType.TemperatureChangeRate, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DegreeCelsiusPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public TemperatureChangeRate() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) - { - if(unit == TemperatureChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of TemperatureChangeRate, which is DegreeCelsiusPerSecond. All conversions go via this value. - /// - public static TemperatureChangeRateUnit BaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; - - /// - /// Represents the largest possible value of TemperatureChangeRate - /// - public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of TemperatureChangeRate - /// - public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.TemperatureChangeRate; - - /// - /// All units of measurement for the TemperatureChangeRate quantity. - /// - public static TemperatureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().Except(new TemperatureChangeRateUnit[]{ TemperatureChangeRateUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerSecond. - /// - public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public TemperatureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => TemperatureChangeRate.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => TemperatureChangeRate.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get TemperatureChangeRate in CentidegreesCelsiusPerSecond. - /// - public double CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in DecadegreesCelsiusPerSecond. - /// - public double DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in DecidegreesCelsiusPerSecond. - /// - public double DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in DegreesCelsiusPerMinute. - /// - public double DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); - - /// - /// Get TemperatureChangeRate in DegreesCelsiusPerSecond. - /// - public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in HectodegreesCelsiusPerSecond. - /// - public double HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in KilodegreesCelsiusPerSecond. - /// - public double KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in MicrodegreesCelsiusPerSecond. - /// - public double MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in MillidegreesCelsiusPerSecond. - /// - public double MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); - - /// - /// Get TemperatureChangeRate in NanodegreesCelsiusPerSecond. - /// - public double NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TemperatureChangeRateUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(TemperatureChangeRateUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get TemperatureChangeRate from CentidegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(double centidegreescelsiuspersecond) - { - double value = (double) centidegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from DecadegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(double decadegreescelsiuspersecond) - { - double value = (double) decadegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from DecidegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(double decidegreescelsiuspersecond) - { - double value = (double) decidegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from DegreesCelsiusPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromDegreesCelsiusPerMinute(double degreescelsiusperminute) - { - double value = (double) degreescelsiusperminute; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); - } - /// - /// Get TemperatureChangeRate from DegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromDegreesCelsiusPerSecond(double degreescelsiuspersecond) - { - double value = (double) degreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from HectodegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(double hectodegreescelsiuspersecond) - { - double value = (double) hectodegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from KilodegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(double kilodegreescelsiuspersecond) - { - double value = (double) kilodegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from MicrodegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(double microdegreescelsiuspersecond) - { - double value = (double) microdegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from MillidegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(double millidegreescelsiuspersecond) - { - double value = (double) millidegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); - } - /// - /// Get TemperatureChangeRate from NanodegreesCelsiusPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(double nanodegreescelsiuspersecond) - { - double value = (double) nanodegreescelsiuspersecond; - return new TemperatureChangeRate(value, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// TemperatureChangeRate unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static TemperatureChangeRate From(double value, TemperatureChangeRateUnit fromUnit) - { - return new TemperatureChangeRate((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static TemperatureChangeRate Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TemperatureChangeRate Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out TemperatureChangeRate result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out TemperatureChangeRate result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static TemperatureChangeRateUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TemperatureChangeRateUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out TemperatureChangeRateUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out TemperatureChangeRateUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is TemperatureChangeRate objTemperatureChangeRate)) throw new ArgumentException("Expected type TemperatureChangeRate.", nameof(obj)); - - return CompareTo(objTemperatureChangeRate); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(TemperatureChangeRate other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) - return false; - - return Equals(objTemperatureChangeRate); - } - - public bool Equals(TemperatureChangeRate other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another TemperatureChangeRate within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current TemperatureChangeRate. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((TemperatureChangeRateUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(TemperatureChangeRateUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this TemperatureChangeRate to another TemperatureChangeRate with the unit representation . - /// - /// A TemperatureChangeRate with the specified unit. - public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new TemperatureChangeRate(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(TemperatureChangeRateUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.g.cs deleted file mode 100644 index 90c7179d75..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ /dev/null @@ -1,716 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Difference between two temperatures. The conversions are different than for Temperature. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class TemperatureDelta : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly TemperatureDeltaUnit? _unit; - - static TemperatureDelta() - { - BaseDimensions = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); - Info = new QuantityInfo(QuantityType.TemperatureDelta, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit Kelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public TemperatureDelta() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private TemperatureDelta(double value, TemperatureDeltaUnit unit) - { - if(unit == TemperatureDeltaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of TemperatureDelta, which is Kelvin. All conversions go via this value. - /// - public static TemperatureDeltaUnit BaseUnit { get; } = TemperatureDeltaUnit.Kelvin; - - /// - /// Represents the largest possible value of TemperatureDelta - /// - public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of TemperatureDelta - /// - public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.TemperatureDelta; - - /// - /// All units of measurement for the TemperatureDelta quantity. - /// - public static TemperatureDeltaUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().Except(new TemperatureDeltaUnit[]{ TemperatureDeltaUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. - /// - public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public TemperatureDeltaUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => TemperatureDelta.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => TemperatureDelta.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get TemperatureDelta in DegreesCelsius. - /// - public double DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); - - /// - /// Get TemperatureDelta in DegreesDelisle. - /// - public double DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); - - /// - /// Get TemperatureDelta in DegreesFahrenheit. - /// - public double DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); - - /// - /// Get TemperatureDelta in DegreesNewton. - /// - public double DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); - - /// - /// Get TemperatureDelta in DegreesRankine. - /// - public double DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); - - /// - /// Get TemperatureDelta in DegreesReaumur. - /// - public double DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); - - /// - /// Get TemperatureDelta in DegreesRoemer. - /// - public double DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); - - /// - /// Get TemperatureDelta in Kelvins. - /// - public double Kelvins => As(TemperatureDeltaUnit.Kelvin); - - /// - /// Get TemperatureDelta in MillidegreesCelsius. - /// - public double MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TemperatureDeltaUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(TemperatureDeltaUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get TemperatureDelta from DegreesCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesCelsius(double degreescelsius) - { - double value = (double) degreescelsius; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsius); - } - /// - /// Get TemperatureDelta from DegreesDelisle. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesDelisle(double degreesdelisle) - { - double value = (double) degreesdelisle; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisle); - } - /// - /// Get TemperatureDelta from DegreesFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesFahrenheit(double degreesfahrenheit) - { - double value = (double) degreesfahrenheit; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheit); - } - /// - /// Get TemperatureDelta from DegreesNewton. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesNewton(double degreesnewton) - { - double value = (double) degreesnewton; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewton); - } - /// - /// Get TemperatureDelta from DegreesRankine. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesRankine(double degreesrankine) - { - double value = (double) degreesrankine; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankine); - } - /// - /// Get TemperatureDelta from DegreesReaumur. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesReaumur(double degreesreaumur) - { - double value = (double) degreesreaumur; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumur); - } - /// - /// Get TemperatureDelta from DegreesRoemer. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromDegreesRoemer(double degreesroemer) - { - double value = (double) degreesroemer; - return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemer); - } - /// - /// Get TemperatureDelta from Kelvins. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromKelvins(double kelvins) - { - double value = (double) kelvins; - return new TemperatureDelta(value, TemperatureDeltaUnit.Kelvin); - } - /// - /// Get TemperatureDelta from MillidegreesCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TemperatureDelta FromMillidegreesCelsius(double millidegreescelsius) - { - double value = (double) millidegreescelsius; - return new TemperatureDelta(value, TemperatureDeltaUnit.MillidegreeCelsius); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// TemperatureDelta unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static TemperatureDelta From(double value, TemperatureDeltaUnit fromUnit) - { - return new TemperatureDelta((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static TemperatureDelta Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TemperatureDelta Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out TemperatureDelta result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out TemperatureDelta result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static TemperatureDeltaUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TemperatureDeltaUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out TemperatureDeltaUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out TemperatureDeltaUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is TemperatureDelta objTemperatureDelta)) throw new ArgumentException("Expected type TemperatureDelta.", nameof(obj)); - - return CompareTo(objTemperatureDelta); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(TemperatureDelta other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureDelta objTemperatureDelta)) - return false; - - return Equals(objTemperatureDelta); - } - - public bool Equals(TemperatureDelta other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another TemperatureDelta within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current TemperatureDelta. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((TemperatureDeltaUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(TemperatureDeltaUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this TemperatureDelta to another TemperatureDelta with the unit representation . - /// - /// A TemperatureDelta with the specified unit. - public TemperatureDelta ToUnit(TemperatureDeltaUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new TemperatureDelta(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(TemperatureDeltaUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.g.cs deleted file mode 100644 index d1dca98373..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ /dev/null @@ -1,600 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Thermal conductivity is the property of a material to conduct heat. - /// - /// - /// https://en.wikipedia.org/wiki/Thermal_Conductivity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ThermalConductivity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ThermalConductivityUnit? _unit; - - static ThermalConductivity() - { - BaseDimensions = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.ThermalConductivity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit WattPerMeterKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ThermalConductivity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ThermalConductivity(double value, ThermalConductivityUnit unit) - { - if(unit == ThermalConductivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ThermalConductivity, which is WattPerMeterKelvin. All conversions go via this value. - /// - public static ThermalConductivityUnit BaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; - - /// - /// Represents the largest possible value of ThermalConductivity - /// - public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ThermalConductivity - /// - public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ThermalConductivity; - - /// - /// All units of measurement for the ThermalConductivity quantity. - /// - public static ThermalConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().Except(new ThermalConductivityUnit[]{ ThermalConductivityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeterKelvin. - /// - public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ThermalConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ThermalConductivity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ThermalConductivity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ThermalConductivity in BtusPerHourFootFahrenheit. - /// - public double BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); - - /// - /// Get ThermalConductivity in WattsPerMeterKelvin. - /// - public double WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ThermalConductivityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ThermalConductivityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ThermalConductivity from BtusPerHourFootFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalConductivity FromBtusPerHourFootFahrenheit(double btusperhourfootfahrenheit) - { - double value = (double) btusperhourfootfahrenheit; - return new ThermalConductivity(value, ThermalConductivityUnit.BtuPerHourFootFahrenheit); - } - /// - /// Get ThermalConductivity from WattsPerMeterKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalConductivity FromWattsPerMeterKelvin(double wattspermeterkelvin) - { - double value = (double) wattspermeterkelvin; - return new ThermalConductivity(value, ThermalConductivityUnit.WattPerMeterKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ThermalConductivity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ThermalConductivity From(double value, ThermalConductivityUnit fromUnit) - { - return new ThermalConductivity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ThermalConductivity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ThermalConductivity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ThermalConductivity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ThermalConductivity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ThermalConductivityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ThermalConductivityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ThermalConductivityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ThermalConductivityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ThermalConductivity objThermalConductivity)) throw new ArgumentException("Expected type ThermalConductivity.", nameof(obj)); - - return CompareTo(objThermalConductivity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ThermalConductivity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ThermalConductivity objThermalConductivity)) - return false; - - return Equals(objThermalConductivity); - } - - public bool Equals(ThermalConductivity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ThermalConductivity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ThermalConductivity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ThermalConductivityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ThermalConductivityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ThermalConductivity to another ThermalConductivity with the unit representation . - /// - /// A ThermalConductivity with the specified unit. - public ThermalConductivity ToUnit(ThermalConductivityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ThermalConductivity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return _value*1.73073467; - case ThermalConductivityUnit.WattPerMeterKelvin: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(ThermalConductivityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case ThermalConductivityUnit.BtuPerHourFootFahrenheit: return baseUnitValue/1.73073467; - case ThermalConductivityUnit.WattPerMeterKelvin: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.g.cs deleted file mode 100644 index e379250e72..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/ThermalResistance.g.cs +++ /dev/null @@ -1,648 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class ThermalResistance : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly ThermalResistanceUnit? _unit; - - static ThermalResistance() - { - BaseDimensions = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); - Info = new QuantityInfo(QuantityType.ThermalResistance, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public ThermalResistance() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private ThermalResistance(double value, ThermalResistanceUnit unit) - { - if(unit == ThermalResistanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of ThermalResistance, which is SquareMeterKelvinPerKilowatt. All conversions go via this value. - /// - public static ThermalResistanceUnit BaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; - - /// - /// Represents the largest possible value of ThermalResistance - /// - public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of ThermalResistance - /// - public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.ThermalResistance; - - /// - /// All units of measurement for the ThermalResistance quantity. - /// - public static ThermalResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().Except(new ThermalResistanceUnit[]{ ThermalResistanceUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt. - /// - public static ThermalResistance Zero { get; } = new ThermalResistance(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public ThermalResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => ThermalResistance.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => ThermalResistance.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get ThermalResistance in HourSquareFeetDegreesFahrenheitPerBtu. - /// - public double HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); - - /// - /// Get ThermalResistance in SquareCentimeterHourDegreesCelsiusPerKilocalorie. - /// - public double SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); - - /// - /// Get ThermalResistance in SquareCentimeterKelvinsPerWatt. - /// - public double SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); - - /// - /// Get ThermalResistance in SquareMeterDegreesCelsiusPerWatt. - /// - public double SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); - - /// - /// Get ThermalResistance in SquareMeterKelvinsPerKilowatt. - /// - public double SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(ThermalResistanceUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(ThermalResistanceUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get ThermalResistance from HourSquareFeetDegreesFahrenheitPerBtu. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(double hoursquarefeetdegreesfahrenheitperbtu) - { - double value = (double) hoursquarefeetdegreesfahrenheitperbtu; - return new ThermalResistance(value, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); - } - /// - /// Get ThermalResistance from SquareCentimeterHourDegreesCelsiusPerKilocalorie. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(double squarecentimeterhourdegreescelsiusperkilocalorie) - { - double value = (double) squarecentimeterhourdegreescelsiusperkilocalorie; - return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); - } - /// - /// Get ThermalResistance from SquareCentimeterKelvinsPerWatt. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(double squarecentimeterkelvinsperwatt) - { - double value = (double) squarecentimeterkelvinsperwatt; - return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); - } - /// - /// Get ThermalResistance from SquareMeterDegreesCelsiusPerWatt. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(double squaremeterdegreescelsiusperwatt) - { - double value = (double) squaremeterdegreescelsiusperwatt; - return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); - } - /// - /// Get ThermalResistance from SquareMeterKelvinsPerKilowatt. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(double squaremeterkelvinsperkilowatt) - { - double value = (double) squaremeterkelvinsperkilowatt; - return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// ThermalResistance unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static ThermalResistance From(double value, ThermalResistanceUnit fromUnit) - { - return new ThermalResistance((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static ThermalResistance Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ThermalResistance Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out ThermalResistance result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out ThermalResistance result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static ThermalResistanceUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static ThermalResistanceUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out ThermalResistanceUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out ThermalResistanceUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is ThermalResistance objThermalResistance)) throw new ArgumentException("Expected type ThermalResistance.", nameof(obj)); - - return CompareTo(objThermalResistance); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(ThermalResistance other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is ThermalResistance objThermalResistance)) - return false; - - return Equals(objThermalResistance); - } - - public bool Equals(ThermalResistance other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another ThermalResistance within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current ThermalResistance. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((ThermalResistanceUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(ThermalResistanceUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this ThermalResistance to another ThermalResistance with the unit representation . - /// - /// A ThermalResistance with the specified unit. - public ThermalResistance ToUnit(ThermalResistanceUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new ThermalResistance(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(ThermalResistanceUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.g.cs deleted file mode 100644 index 60673bb5f7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Torque.g.cs +++ /dev/null @@ -1,937 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Torque : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly TorqueUnit? _unit; - - static Torque() - { - BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Torque, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Torque() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Torque(double value, TorqueUnit unit) - { - if(unit == TorqueUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Torque, which is NewtonMeter. All conversions go via this value. - /// - public static TorqueUnit BaseUnit { get; } = TorqueUnit.NewtonMeter; - - /// - /// Represents the largest possible value of Torque - /// - public static Torque MaxValue { get; } = new Torque(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Torque - /// - public static Torque MinValue { get; } = new Torque(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Torque; - - /// - /// All units of measurement for the Torque quantity. - /// - public static TorqueUnit[] Units { get; } = Enum.GetValues(typeof(TorqueUnit)).Cast().Except(new TorqueUnit[]{ TorqueUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeter. - /// - public static Torque Zero { get; } = new Torque(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public TorqueUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Torque.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Torque.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Torque in KilogramForceCentimeters. - /// - public double KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); - - /// - /// Get Torque in KilogramForceMeters. - /// - public double KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); - - /// - /// Get Torque in KilogramForceMillimeters. - /// - public double KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); - - /// - /// Get Torque in KilonewtonCentimeters. - /// - public double KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); - - /// - /// Get Torque in KilonewtonMeters. - /// - public double KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); - - /// - /// Get Torque in KilonewtonMillimeters. - /// - public double KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); - - /// - /// Get Torque in KilopoundForceFeet. - /// - public double KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); - - /// - /// Get Torque in KilopoundForceInches. - /// - public double KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); - - /// - /// Get Torque in MeganewtonCentimeters. - /// - public double MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); - - /// - /// Get Torque in MeganewtonMeters. - /// - public double MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); - - /// - /// Get Torque in MeganewtonMillimeters. - /// - public double MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); - - /// - /// Get Torque in MegapoundForceFeet. - /// - public double MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); - - /// - /// Get Torque in MegapoundForceInches. - /// - public double MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); - - /// - /// Get Torque in NewtonCentimeters. - /// - public double NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); - - /// - /// Get Torque in NewtonMeters. - /// - public double NewtonMeters => As(TorqueUnit.NewtonMeter); - - /// - /// Get Torque in NewtonMillimeters. - /// - public double NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); - - /// - /// Get Torque in PoundalFeet. - /// - public double PoundalFeet => As(TorqueUnit.PoundalFoot); - - /// - /// Get Torque in PoundForceFeet. - /// - public double PoundForceFeet => As(TorqueUnit.PoundForceFoot); - - /// - /// Get Torque in PoundForceInches. - /// - public double PoundForceInches => As(TorqueUnit.PoundForceInch); - - /// - /// Get Torque in TonneForceCentimeters. - /// - public double TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); - - /// - /// Get Torque in TonneForceMeters. - /// - public double TonneForceMeters => As(TorqueUnit.TonneForceMeter); - - /// - /// Get Torque in TonneForceMillimeters. - /// - public double TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TorqueUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(TorqueUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Torque from KilogramForceCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilogramForceCentimeters(double kilogramforcecentimeters) - { - double value = (double) kilogramforcecentimeters; - return new Torque(value, TorqueUnit.KilogramForceCentimeter); - } - /// - /// Get Torque from KilogramForceMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilogramForceMeters(double kilogramforcemeters) - { - double value = (double) kilogramforcemeters; - return new Torque(value, TorqueUnit.KilogramForceMeter); - } - /// - /// Get Torque from KilogramForceMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilogramForceMillimeters(double kilogramforcemillimeters) - { - double value = (double) kilogramforcemillimeters; - return new Torque(value, TorqueUnit.KilogramForceMillimeter); - } - /// - /// Get Torque from KilonewtonCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilonewtonCentimeters(double kilonewtoncentimeters) - { - double value = (double) kilonewtoncentimeters; - return new Torque(value, TorqueUnit.KilonewtonCentimeter); - } - /// - /// Get Torque from KilonewtonMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilonewtonMeters(double kilonewtonmeters) - { - double value = (double) kilonewtonmeters; - return new Torque(value, TorqueUnit.KilonewtonMeter); - } - /// - /// Get Torque from KilonewtonMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilonewtonMillimeters(double kilonewtonmillimeters) - { - double value = (double) kilonewtonmillimeters; - return new Torque(value, TorqueUnit.KilonewtonMillimeter); - } - /// - /// Get Torque from KilopoundForceFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilopoundForceFeet(double kilopoundforcefeet) - { - double value = (double) kilopoundforcefeet; - return new Torque(value, TorqueUnit.KilopoundForceFoot); - } - /// - /// Get Torque from KilopoundForceInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromKilopoundForceInches(double kilopoundforceinches) - { - double value = (double) kilopoundforceinches; - return new Torque(value, TorqueUnit.KilopoundForceInch); - } - /// - /// Get Torque from MeganewtonCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromMeganewtonCentimeters(double meganewtoncentimeters) - { - double value = (double) meganewtoncentimeters; - return new Torque(value, TorqueUnit.MeganewtonCentimeter); - } - /// - /// Get Torque from MeganewtonMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromMeganewtonMeters(double meganewtonmeters) - { - double value = (double) meganewtonmeters; - return new Torque(value, TorqueUnit.MeganewtonMeter); - } - /// - /// Get Torque from MeganewtonMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromMeganewtonMillimeters(double meganewtonmillimeters) - { - double value = (double) meganewtonmillimeters; - return new Torque(value, TorqueUnit.MeganewtonMillimeter); - } - /// - /// Get Torque from MegapoundForceFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromMegapoundForceFeet(double megapoundforcefeet) - { - double value = (double) megapoundforcefeet; - return new Torque(value, TorqueUnit.MegapoundForceFoot); - } - /// - /// Get Torque from MegapoundForceInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromMegapoundForceInches(double megapoundforceinches) - { - double value = (double) megapoundforceinches; - return new Torque(value, TorqueUnit.MegapoundForceInch); - } - /// - /// Get Torque from NewtonCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromNewtonCentimeters(double newtoncentimeters) - { - double value = (double) newtoncentimeters; - return new Torque(value, TorqueUnit.NewtonCentimeter); - } - /// - /// Get Torque from NewtonMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromNewtonMeters(double newtonmeters) - { - double value = (double) newtonmeters; - return new Torque(value, TorqueUnit.NewtonMeter); - } - /// - /// Get Torque from NewtonMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromNewtonMillimeters(double newtonmillimeters) - { - double value = (double) newtonmillimeters; - return new Torque(value, TorqueUnit.NewtonMillimeter); - } - /// - /// Get Torque from PoundalFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromPoundalFeet(double poundalfeet) - { - double value = (double) poundalfeet; - return new Torque(value, TorqueUnit.PoundalFoot); - } - /// - /// Get Torque from PoundForceFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromPoundForceFeet(double poundforcefeet) - { - double value = (double) poundforcefeet; - return new Torque(value, TorqueUnit.PoundForceFoot); - } - /// - /// Get Torque from PoundForceInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromPoundForceInches(double poundforceinches) - { - double value = (double) poundforceinches; - return new Torque(value, TorqueUnit.PoundForceInch); - } - /// - /// Get Torque from TonneForceCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromTonneForceCentimeters(double tonneforcecentimeters) - { - double value = (double) tonneforcecentimeters; - return new Torque(value, TorqueUnit.TonneForceCentimeter); - } - /// - /// Get Torque from TonneForceMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromTonneForceMeters(double tonneforcemeters) - { - double value = (double) tonneforcemeters; - return new Torque(value, TorqueUnit.TonneForceMeter); - } - /// - /// Get Torque from TonneForceMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Torque FromTonneForceMillimeters(double tonneforcemillimeters) - { - double value = (double) tonneforcemillimeters; - return new Torque(value, TorqueUnit.TonneForceMillimeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Torque unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Torque From(double value, TorqueUnit fromUnit) - { - return new Torque((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Torque Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Torque Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Torque result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Torque result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static TorqueUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TorqueUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out TorqueUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out TorqueUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Torque objTorque)) throw new ArgumentException("Expected type Torque.", nameof(obj)); - - return CompareTo(objTorque); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Torque other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Torque objTorque)) - return false; - - return Equals(objTorque); - } - - public bool Equals(Torque other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Torque within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Torque other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Torque. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((TorqueUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(TorqueUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Torque to another Torque with the unit representation . - /// - /// A Torque with the specified unit. - public Torque ToUnit(TorqueUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Torque(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case TorqueUnit.KilogramForceCentimeter: return _value*0.0980665019960652; - case TorqueUnit.KilogramForceMeter: return _value*9.80665019960652; - case TorqueUnit.KilogramForceMillimeter: return _value*0.00980665019960652; - 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*98.0665019960652; - case TorqueUnit.TonneForceMeter: return _value*9806.65019960653; - case TorqueUnit.TonneForceMillimeter: return _value*9.80665019960652; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(TorqueUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case TorqueUnit.KilogramForceCentimeter: return baseUnitValue*10.1971619222242; - case TorqueUnit.KilogramForceMeter: return baseUnitValue*0.101971619222242; - case TorqueUnit.KilogramForceMillimeter: return baseUnitValue*101.971619222242; - 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*0.0101971619222242; - case TorqueUnit.TonneForceMeter: return baseUnitValue*0.000101971619222242; - case TorqueUnit.TonneForceMillimeter: return baseUnitValue*0.101971619222242; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TorquePerLength.g.cs deleted file mode 100644 index 66e8eb26b3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/TorquePerLength.g.cs +++ /dev/null @@ -1,920 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The magnitude of torque per unit length. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class TorquePerLength : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly TorquePerLengthUnit? _unit; - - static TorquePerLength() - { - BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.TorquePerLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NewtonMeterPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public TorquePerLength() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private TorquePerLength(double value, TorquePerLengthUnit unit) - { - if(unit == TorquePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of TorquePerLength, which is NewtonMeterPerMeter. All conversions go via this value. - /// - public static TorquePerLengthUnit BaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; - - /// - /// Represents the largest possible value of TorquePerLength - /// - public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of TorquePerLength - /// - public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.TorquePerLength; - - /// - /// All units of measurement for the TorquePerLength quantity. - /// - public static TorquePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().Except(new TorquePerLengthUnit[]{ TorquePerLengthUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerMeter. - /// - public static TorquePerLength Zero { get; } = new TorquePerLength(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public TorquePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => TorquePerLength.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => TorquePerLength.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get TorquePerLength in KilogramForceCentimetersPerMeter. - /// - public double KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); - - /// - /// Get TorquePerLength in KilogramForceMetersPerMeter. - /// - public double KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); - - /// - /// Get TorquePerLength in KilogramForceMillimetersPerMeter. - /// - public double KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); - - /// - /// Get TorquePerLength in KilonewtonCentimetersPerMeter. - /// - public double KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); - - /// - /// Get TorquePerLength in KilonewtonMetersPerMeter. - /// - public double KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); - - /// - /// Get TorquePerLength in KilonewtonMillimetersPerMeter. - /// - public double KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); - - /// - /// Get TorquePerLength in KilopoundForceFeetPerFoot. - /// - public double KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); - - /// - /// Get TorquePerLength in KilopoundForceInchesPerFoot. - /// - public double KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); - - /// - /// Get TorquePerLength in MeganewtonCentimetersPerMeter. - /// - public double MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); - - /// - /// Get TorquePerLength in MeganewtonMetersPerMeter. - /// - public double MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); - - /// - /// Get TorquePerLength in MeganewtonMillimetersPerMeter. - /// - public double MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); - - /// - /// Get TorquePerLength in MegapoundForceFeetPerFoot. - /// - public double MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); - - /// - /// Get TorquePerLength in MegapoundForceInchesPerFoot. - /// - public double MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); - - /// - /// Get TorquePerLength in NewtonCentimetersPerMeter. - /// - public double NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); - - /// - /// Get TorquePerLength in NewtonMetersPerMeter. - /// - public double NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); - - /// - /// Get TorquePerLength in NewtonMillimetersPerMeter. - /// - public double NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); - - /// - /// Get TorquePerLength in PoundForceFeetPerFoot. - /// - public double PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); - - /// - /// Get TorquePerLength in PoundForceInchesPerFoot. - /// - public double PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); - - /// - /// Get TorquePerLength in TonneForceCentimetersPerMeter. - /// - public double TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); - - /// - /// Get TorquePerLength in TonneForceMetersPerMeter. - /// - public double TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); - - /// - /// Get TorquePerLength in TonneForceMillimetersPerMeter. - /// - public double TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TorquePerLengthUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(TorquePerLengthUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get TorquePerLength from KilogramForceCentimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilogramForceCentimetersPerMeter(double kilogramforcecentimeterspermeter) - { - double value = (double) kilogramforcecentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); - } - /// - /// Get TorquePerLength from KilogramForceMetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilogramForceMetersPerMeter(double kilogramforcemeterspermeter) - { - double value = (double) kilogramforcemeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMeterPerMeter); - } - /// - /// Get TorquePerLength from KilogramForceMillimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilogramForceMillimetersPerMeter(double kilogramforcemillimeterspermeter) - { - double value = (double) kilogramforcemillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); - } - /// - /// Get TorquePerLength from KilonewtonCentimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilonewtonCentimetersPerMeter(double kilonewtoncentimeterspermeter) - { - double value = (double) kilonewtoncentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); - } - /// - /// Get TorquePerLength from KilonewtonMetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilonewtonMetersPerMeter(double kilonewtonmeterspermeter) - { - double value = (double) kilonewtonmeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMeterPerMeter); - } - /// - /// Get TorquePerLength from KilonewtonMillimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilonewtonMillimetersPerMeter(double kilonewtonmillimeterspermeter) - { - double value = (double) kilonewtonmillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); - } - /// - /// Get TorquePerLength from KilopoundForceFeetPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilopoundForceFeetPerFoot(double kilopoundforcefeetperfoot) - { - double value = (double) kilopoundforcefeetperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceFootPerFoot); - } - /// - /// Get TorquePerLength from KilopoundForceInchesPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromKilopoundForceInchesPerFoot(double kilopoundforceinchesperfoot) - { - double value = (double) kilopoundforceinchesperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceInchPerFoot); - } - /// - /// Get TorquePerLength from MeganewtonCentimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromMeganewtonCentimetersPerMeter(double meganewtoncentimeterspermeter) - { - double value = (double) meganewtoncentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); - } - /// - /// Get TorquePerLength from MeganewtonMetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromMeganewtonMetersPerMeter(double meganewtonmeterspermeter) - { - double value = (double) meganewtonmeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMeterPerMeter); - } - /// - /// Get TorquePerLength from MeganewtonMillimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromMeganewtonMillimetersPerMeter(double meganewtonmillimeterspermeter) - { - double value = (double) meganewtonmillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); - } - /// - /// Get TorquePerLength from MegapoundForceFeetPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromMegapoundForceFeetPerFoot(double megapoundforcefeetperfoot) - { - double value = (double) megapoundforcefeetperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceFootPerFoot); - } - /// - /// Get TorquePerLength from MegapoundForceInchesPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromMegapoundForceInchesPerFoot(double megapoundforceinchesperfoot) - { - double value = (double) megapoundforceinchesperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceInchPerFoot); - } - /// - /// Get TorquePerLength from NewtonCentimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromNewtonCentimetersPerMeter(double newtoncentimeterspermeter) - { - double value = (double) newtoncentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.NewtonCentimeterPerMeter); - } - /// - /// Get TorquePerLength from NewtonMetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromNewtonMetersPerMeter(double newtonmeterspermeter) - { - double value = (double) newtonmeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.NewtonMeterPerMeter); - } - /// - /// Get TorquePerLength from NewtonMillimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromNewtonMillimetersPerMeter(double newtonmillimeterspermeter) - { - double value = (double) newtonmillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.NewtonMillimeterPerMeter); - } - /// - /// Get TorquePerLength from PoundForceFeetPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromPoundForceFeetPerFoot(double poundforcefeetperfoot) - { - double value = (double) poundforcefeetperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.PoundForceFootPerFoot); - } - /// - /// Get TorquePerLength from PoundForceInchesPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromPoundForceInchesPerFoot(double poundforceinchesperfoot) - { - double value = (double) poundforceinchesperfoot; - return new TorquePerLength(value, TorquePerLengthUnit.PoundForceInchPerFoot); - } - /// - /// Get TorquePerLength from TonneForceCentimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromTonneForceCentimetersPerMeter(double tonneforcecentimeterspermeter) - { - double value = (double) tonneforcecentimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceCentimeterPerMeter); - } - /// - /// Get TorquePerLength from TonneForceMetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromTonneForceMetersPerMeter(double tonneforcemeterspermeter) - { - double value = (double) tonneforcemeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMeterPerMeter); - } - /// - /// Get TorquePerLength from TonneForceMillimetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static TorquePerLength FromTonneForceMillimetersPerMeter(double tonneforcemillimeterspermeter) - { - double value = (double) tonneforcemillimeterspermeter; - return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMillimeterPerMeter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// TorquePerLength unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static TorquePerLength From(double value, TorquePerLengthUnit fromUnit) - { - return new TorquePerLength((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static TorquePerLength Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TorquePerLength Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out TorquePerLength result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out TorquePerLength result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static TorquePerLengthUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TorquePerLengthUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out TorquePerLengthUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out TorquePerLengthUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is TorquePerLength objTorquePerLength)) throw new ArgumentException("Expected type TorquePerLength.", nameof(obj)); - - return CompareTo(objTorquePerLength); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(TorquePerLength other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is TorquePerLength objTorquePerLength)) - return false; - - return Equals(objTorquePerLength); - } - - public bool Equals(TorquePerLength other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another TorquePerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TorquePerLength other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current TorquePerLength. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((TorquePerLengthUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(TorquePerLengthUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this TorquePerLength to another TorquePerLength with the unit representation . - /// - /// A TorquePerLength with the specified unit. - public TorquePerLength ToUnit(TorquePerLengthUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new TorquePerLength(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(TorquePerLengthUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Turbidity.g.cs deleted file mode 100644 index 7ce077db8c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Turbidity.g.cs +++ /dev/null @@ -1,583 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are generally invisible to the naked eye, similar to smoke in air. The measurement of turbidity is a key test of water quality. - /// - /// - /// https://en.wikipedia.org/wiki/Turbidity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Turbidity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly TurbidityUnit? _unit; - - static Turbidity() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.Turbidity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit NTU. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Turbidity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Turbidity(double value, TurbidityUnit unit) - { - if(unit == TurbidityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Turbidity, which is NTU. All conversions go via this value. - /// - public static TurbidityUnit BaseUnit { get; } = TurbidityUnit.NTU; - - /// - /// Represents the largest possible value of Turbidity - /// - public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Turbidity - /// - public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Turbidity; - - /// - /// All units of measurement for the Turbidity quantity. - /// - public static TurbidityUnit[] Units { get; } = Enum.GetValues(typeof(TurbidityUnit)).Cast().Except(new TurbidityUnit[]{ TurbidityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit NTU. - /// - public static Turbidity Zero { get; } = new Turbidity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public TurbidityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Turbidity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Turbidity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Turbidity in NTU. - /// - public double NTU => As(TurbidityUnit.NTU); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(TurbidityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(TurbidityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Turbidity from NTU. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Turbidity FromNTU(double ntu) - { - double value = (double) ntu; - return new Turbidity(value, TurbidityUnit.NTU); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Turbidity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Turbidity From(double value, TurbidityUnit fromUnit) - { - return new Turbidity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Turbidity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Turbidity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Turbidity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Turbidity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static TurbidityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static TurbidityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out TurbidityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out TurbidityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Turbidity objTurbidity)) throw new ArgumentException("Expected type Turbidity.", nameof(obj)); - - return CompareTo(objTurbidity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Turbidity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Turbidity objTurbidity)) - return false; - - return Equals(objTurbidity); - } - - public bool Equals(Turbidity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Turbidity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Turbidity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((TurbidityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(TurbidityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Turbidity to another Turbidity with the unit representation . - /// - /// A Turbidity with the specified unit. - public Turbidity ToUnit(TurbidityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Turbidity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case TurbidityUnit.NTU: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(TurbidityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case TurbidityUnit.NTU: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.g.cs deleted file mode 100644 index 08118cc8ff..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VitaminA.g.cs +++ /dev/null @@ -1,580 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class VitaminA : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly VitaminAUnit? _unit; - - static VitaminA() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.VitaminA, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit InternationalUnit. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public VitaminA() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private VitaminA(double value, VitaminAUnit unit) - { - if(unit == VitaminAUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of VitaminA, which is InternationalUnit. All conversions go via this value. - /// - public static VitaminAUnit BaseUnit { get; } = VitaminAUnit.InternationalUnit; - - /// - /// Represents the largest possible value of VitaminA - /// - public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of VitaminA - /// - public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.VitaminA; - - /// - /// All units of measurement for the VitaminA quantity. - /// - public static VitaminAUnit[] Units { get; } = Enum.GetValues(typeof(VitaminAUnit)).Cast().Except(new VitaminAUnit[]{ VitaminAUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit InternationalUnit. - /// - public static VitaminA Zero { get; } = new VitaminA(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public VitaminAUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => VitaminA.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => VitaminA.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get VitaminA in InternationalUnits. - /// - public double InternationalUnits => As(VitaminAUnit.InternationalUnit); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(VitaminAUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(VitaminAUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get VitaminA from InternationalUnits. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VitaminA FromInternationalUnits(double internationalunits) - { - double value = (double) internationalunits; - return new VitaminA(value, VitaminAUnit.InternationalUnit); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// VitaminA unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static VitaminA From(double value, VitaminAUnit fromUnit) - { - return new VitaminA((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static VitaminA Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VitaminA Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out VitaminA result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out VitaminA result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static VitaminAUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VitaminAUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out VitaminAUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out VitaminAUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VitaminA objVitaminA)) throw new ArgumentException("Expected type VitaminA.", nameof(obj)); - - return CompareTo(objVitaminA); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(VitaminA other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is VitaminA objVitaminA)) - return false; - - return Equals(objVitaminA); - } - - public bool Equals(VitaminA other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another VitaminA within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current VitaminA. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((VitaminAUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(VitaminAUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this VitaminA to another VitaminA with the unit representation . - /// - /// A VitaminA with the specified unit. - public VitaminA ToUnit(VitaminAUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new VitaminA(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - case VitaminAUnit.InternationalUnit: return _value; - default: - throw new NotImplementedException($"Can not convert {Unit} to base units."); - } - } - - private double AsBaseNumericType(VitaminAUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - case VitaminAUnit.InternationalUnit: return baseUnitValue; - default: - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.g.cs deleted file mode 100644 index f81ce7cd6f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/Volume.g.cs +++ /dev/null @@ -1,1430 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class Volume : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly VolumeUnit? _unit; - - static Volume() - { - BaseDimensions = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.Volume, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit CubicMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public Volume() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private Volume(double value, VolumeUnit unit) - { - if(unit == VolumeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of Volume, which is CubicMeter. All conversions go via this value. - /// - public static VolumeUnit BaseUnit { get; } = VolumeUnit.CubicMeter; - - /// - /// Represents the largest possible value of Volume - /// - public static Volume MaxValue { get; } = new Volume(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of Volume - /// - public static Volume MinValue { get; } = new Volume(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.Volume; - - /// - /// All units of measurement for the Volume quantity. - /// - public static VolumeUnit[] Units { get; } = Enum.GetValues(typeof(VolumeUnit)).Cast().Except(new VolumeUnit[]{ VolumeUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeter. - /// - public static Volume Zero { get; } = new Volume(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public VolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => Volume.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => Volume.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get Volume in AcreFeet. - /// - public double AcreFeet => As(VolumeUnit.AcreFoot); - - /// - /// Get Volume in AuTablespoons. - /// - public double AuTablespoons => As(VolumeUnit.AuTablespoon); - - /// - /// Get Volume in BoardFeet. - /// - public double BoardFeet => As(VolumeUnit.BoardFoot); - - /// - /// Get Volume in Centiliters. - /// - public double Centiliters => As(VolumeUnit.Centiliter); - - /// - /// Get Volume in CubicCentimeters. - /// - public double CubicCentimeters => As(VolumeUnit.CubicCentimeter); - - /// - /// Get Volume in CubicDecimeters. - /// - public double CubicDecimeters => As(VolumeUnit.CubicDecimeter); - - /// - /// Get Volume in CubicFeet. - /// - public double CubicFeet => As(VolumeUnit.CubicFoot); - - /// - /// Get Volume in CubicHectometers. - /// - public double CubicHectometers => As(VolumeUnit.CubicHectometer); - - /// - /// Get Volume in CubicInches. - /// - public double CubicInches => As(VolumeUnit.CubicInch); - - /// - /// Get Volume in CubicKilometers. - /// - public double CubicKilometers => As(VolumeUnit.CubicKilometer); - - /// - /// Get Volume in CubicMeters. - /// - public double CubicMeters => As(VolumeUnit.CubicMeter); - - /// - /// Get Volume in CubicMicrometers. - /// - public double CubicMicrometers => As(VolumeUnit.CubicMicrometer); - - /// - /// Get Volume in CubicMiles. - /// - public double CubicMiles => As(VolumeUnit.CubicMile); - - /// - /// Get Volume in CubicMillimeters. - /// - public double CubicMillimeters => As(VolumeUnit.CubicMillimeter); - - /// - /// Get Volume in CubicYards. - /// - public double CubicYards => As(VolumeUnit.CubicYard); - - /// - /// Get Volume in DecausGallons. - /// - public double DecausGallons => As(VolumeUnit.DecausGallon); - - /// - /// Get Volume in Deciliters. - /// - public double Deciliters => As(VolumeUnit.Deciliter); - - /// - /// Get Volume in DeciusGallons. - /// - public double DeciusGallons => As(VolumeUnit.DeciusGallon); - - /// - /// Get Volume in HectocubicFeet. - /// - public double HectocubicFeet => As(VolumeUnit.HectocubicFoot); - - /// - /// Get Volume in HectocubicMeters. - /// - public double HectocubicMeters => As(VolumeUnit.HectocubicMeter); - - /// - /// Get Volume in Hectoliters. - /// - public double Hectoliters => As(VolumeUnit.Hectoliter); - - /// - /// Get Volume in HectousGallons. - /// - public double HectousGallons => As(VolumeUnit.HectousGallon); - - /// - /// Get Volume in ImperialBeerBarrels. - /// - public double ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); - - /// - /// Get Volume in ImperialGallons. - /// - public double ImperialGallons => As(VolumeUnit.ImperialGallon); - - /// - /// Get Volume in ImperialOunces. - /// - public double ImperialOunces => As(VolumeUnit.ImperialOunce); - - /// - /// Get Volume in ImperialPints. - /// - public double ImperialPints => As(VolumeUnit.ImperialPint); - - /// - /// Get Volume in KilocubicFeet. - /// - public double KilocubicFeet => As(VolumeUnit.KilocubicFoot); - - /// - /// Get Volume in KilocubicMeters. - /// - public double KilocubicMeters => As(VolumeUnit.KilocubicMeter); - - /// - /// Get Volume in KiloimperialGallons. - /// - public double KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); - - /// - /// Get Volume in Kiloliters. - /// - public double Kiloliters => As(VolumeUnit.Kiloliter); - - /// - /// Get Volume in KilousGallons. - /// - public double KilousGallons => As(VolumeUnit.KilousGallon); - - /// - /// Get Volume in Liters. - /// - public double Liters => As(VolumeUnit.Liter); - - /// - /// Get Volume in MegacubicFeet. - /// - public double MegacubicFeet => As(VolumeUnit.MegacubicFoot); - - /// - /// Get Volume in MegaimperialGallons. - /// - public double MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); - - /// - /// Get Volume in Megaliters. - /// - public double Megaliters => As(VolumeUnit.Megaliter); - - /// - /// Get Volume in MegausGallons. - /// - public double MegausGallons => As(VolumeUnit.MegausGallon); - - /// - /// Get Volume in MetricCups. - /// - public double MetricCups => As(VolumeUnit.MetricCup); - - /// - /// Get Volume in MetricTeaspoons. - /// - public double MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); - - /// - /// Get Volume in Microliters. - /// - public double Microliters => As(VolumeUnit.Microliter); - - /// - /// Get Volume in Milliliters. - /// - public double Milliliters => As(VolumeUnit.Milliliter); - - /// - /// Get Volume in OilBarrels. - /// - public double OilBarrels => As(VolumeUnit.OilBarrel); - - /// - /// Get Volume in UkTablespoons. - /// - public double UkTablespoons => As(VolumeUnit.UkTablespoon); - - /// - /// Get Volume in UsBeerBarrels. - /// - public double UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); - - /// - /// Get Volume in UsCustomaryCups. - /// - public double UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); - - /// - /// Get Volume in UsGallons. - /// - public double UsGallons => As(VolumeUnit.UsGallon); - - /// - /// Get Volume in UsLegalCups. - /// - public double UsLegalCups => As(VolumeUnit.UsLegalCup); - - /// - /// Get Volume in UsOunces. - /// - public double UsOunces => As(VolumeUnit.UsOunce); - - /// - /// Get Volume in UsPints. - /// - public double UsPints => As(VolumeUnit.UsPint); - - /// - /// Get Volume in UsQuarts. - /// - public double UsQuarts => As(VolumeUnit.UsQuart); - - /// - /// Get Volume in UsTablespoons. - /// - public double UsTablespoons => As(VolumeUnit.UsTablespoon); - - /// - /// Get Volume in UsTeaspoons. - /// - public double UsTeaspoons => As(VolumeUnit.UsTeaspoon); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(VolumeUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(VolumeUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get Volume from AcreFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromAcreFeet(double acrefeet) - { - double value = (double) acrefeet; - return new Volume(value, VolumeUnit.AcreFoot); - } - /// - /// Get Volume from AuTablespoons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromAuTablespoons(double autablespoons) - { - double value = (double) autablespoons; - return new Volume(value, VolumeUnit.AuTablespoon); - } - /// - /// Get Volume from BoardFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromBoardFeet(double boardfeet) - { - double value = (double) boardfeet; - return new Volume(value, VolumeUnit.BoardFoot); - } - /// - /// Get Volume from Centiliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCentiliters(double centiliters) - { - double value = (double) centiliters; - return new Volume(value, VolumeUnit.Centiliter); - } - /// - /// Get Volume from CubicCentimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicCentimeters(double cubiccentimeters) - { - double value = (double) cubiccentimeters; - return new Volume(value, VolumeUnit.CubicCentimeter); - } - /// - /// Get Volume from CubicDecimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicDecimeters(double cubicdecimeters) - { - double value = (double) cubicdecimeters; - return new Volume(value, VolumeUnit.CubicDecimeter); - } - /// - /// Get Volume from CubicFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicFeet(double cubicfeet) - { - double value = (double) cubicfeet; - return new Volume(value, VolumeUnit.CubicFoot); - } - /// - /// Get Volume from CubicHectometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicHectometers(double cubichectometers) - { - double value = (double) cubichectometers; - return new Volume(value, VolumeUnit.CubicHectometer); - } - /// - /// Get Volume from CubicInches. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicInches(double cubicinches) - { - double value = (double) cubicinches; - return new Volume(value, VolumeUnit.CubicInch); - } - /// - /// Get Volume from CubicKilometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicKilometers(double cubickilometers) - { - double value = (double) cubickilometers; - return new Volume(value, VolumeUnit.CubicKilometer); - } - /// - /// Get Volume from CubicMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicMeters(double cubicmeters) - { - double value = (double) cubicmeters; - return new Volume(value, VolumeUnit.CubicMeter); - } - /// - /// Get Volume from CubicMicrometers. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicMicrometers(double cubicmicrometers) - { - double value = (double) cubicmicrometers; - return new Volume(value, VolumeUnit.CubicMicrometer); - } - /// - /// Get Volume from CubicMiles. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicMiles(double cubicmiles) - { - double value = (double) cubicmiles; - return new Volume(value, VolumeUnit.CubicMile); - } - /// - /// Get Volume from CubicMillimeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicMillimeters(double cubicmillimeters) - { - double value = (double) cubicmillimeters; - return new Volume(value, VolumeUnit.CubicMillimeter); - } - /// - /// Get Volume from CubicYards. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromCubicYards(double cubicyards) - { - double value = (double) cubicyards; - return new Volume(value, VolumeUnit.CubicYard); - } - /// - /// Get Volume from DecausGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromDecausGallons(double decausgallons) - { - double value = (double) decausgallons; - return new Volume(value, VolumeUnit.DecausGallon); - } - /// - /// Get Volume from Deciliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromDeciliters(double deciliters) - { - double value = (double) deciliters; - return new Volume(value, VolumeUnit.Deciliter); - } - /// - /// Get Volume from DeciusGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromDeciusGallons(double deciusgallons) - { - double value = (double) deciusgallons; - return new Volume(value, VolumeUnit.DeciusGallon); - } - /// - /// Get Volume from HectocubicFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromHectocubicFeet(double hectocubicfeet) - { - double value = (double) hectocubicfeet; - return new Volume(value, VolumeUnit.HectocubicFoot); - } - /// - /// Get Volume from HectocubicMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromHectocubicMeters(double hectocubicmeters) - { - double value = (double) hectocubicmeters; - return new Volume(value, VolumeUnit.HectocubicMeter); - } - /// - /// Get Volume from Hectoliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromHectoliters(double hectoliters) - { - double value = (double) hectoliters; - return new Volume(value, VolumeUnit.Hectoliter); - } - /// - /// Get Volume from HectousGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromHectousGallons(double hectousgallons) - { - double value = (double) hectousgallons; - return new Volume(value, VolumeUnit.HectousGallon); - } - /// - /// Get Volume from ImperialBeerBarrels. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromImperialBeerBarrels(double imperialbeerbarrels) - { - double value = (double) imperialbeerbarrels; - return new Volume(value, VolumeUnit.ImperialBeerBarrel); - } - /// - /// Get Volume from ImperialGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromImperialGallons(double imperialgallons) - { - double value = (double) imperialgallons; - return new Volume(value, VolumeUnit.ImperialGallon); - } - /// - /// Get Volume from ImperialOunces. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromImperialOunces(double imperialounces) - { - double value = (double) imperialounces; - return new Volume(value, VolumeUnit.ImperialOunce); - } - /// - /// Get Volume from ImperialPints. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromImperialPints(double imperialpints) - { - double value = (double) imperialpints; - return new Volume(value, VolumeUnit.ImperialPint); - } - /// - /// Get Volume from KilocubicFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromKilocubicFeet(double kilocubicfeet) - { - double value = (double) kilocubicfeet; - return new Volume(value, VolumeUnit.KilocubicFoot); - } - /// - /// Get Volume from KilocubicMeters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromKilocubicMeters(double kilocubicmeters) - { - double value = (double) kilocubicmeters; - return new Volume(value, VolumeUnit.KilocubicMeter); - } - /// - /// Get Volume from KiloimperialGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromKiloimperialGallons(double kiloimperialgallons) - { - double value = (double) kiloimperialgallons; - return new Volume(value, VolumeUnit.KiloimperialGallon); - } - /// - /// Get Volume from Kiloliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromKiloliters(double kiloliters) - { - double value = (double) kiloliters; - return new Volume(value, VolumeUnit.Kiloliter); - } - /// - /// Get Volume from KilousGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromKilousGallons(double kilousgallons) - { - double value = (double) kilousgallons; - return new Volume(value, VolumeUnit.KilousGallon); - } - /// - /// Get Volume from Liters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromLiters(double liters) - { - double value = (double) liters; - return new Volume(value, VolumeUnit.Liter); - } - /// - /// Get Volume from MegacubicFeet. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMegacubicFeet(double megacubicfeet) - { - double value = (double) megacubicfeet; - return new Volume(value, VolumeUnit.MegacubicFoot); - } - /// - /// Get Volume from MegaimperialGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMegaimperialGallons(double megaimperialgallons) - { - double value = (double) megaimperialgallons; - return new Volume(value, VolumeUnit.MegaimperialGallon); - } - /// - /// Get Volume from Megaliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMegaliters(double megaliters) - { - double value = (double) megaliters; - return new Volume(value, VolumeUnit.Megaliter); - } - /// - /// Get Volume from MegausGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMegausGallons(double megausgallons) - { - double value = (double) megausgallons; - return new Volume(value, VolumeUnit.MegausGallon); - } - /// - /// Get Volume from MetricCups. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMetricCups(double metriccups) - { - double value = (double) metriccups; - return new Volume(value, VolumeUnit.MetricCup); - } - /// - /// Get Volume from MetricTeaspoons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMetricTeaspoons(double metricteaspoons) - { - double value = (double) metricteaspoons; - return new Volume(value, VolumeUnit.MetricTeaspoon); - } - /// - /// Get Volume from Microliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMicroliters(double microliters) - { - double value = (double) microliters; - return new Volume(value, VolumeUnit.Microliter); - } - /// - /// Get Volume from Milliliters. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromMilliliters(double milliliters) - { - double value = (double) milliliters; - return new Volume(value, VolumeUnit.Milliliter); - } - /// - /// Get Volume from OilBarrels. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromOilBarrels(double oilbarrels) - { - double value = (double) oilbarrels; - return new Volume(value, VolumeUnit.OilBarrel); - } - /// - /// Get Volume from UkTablespoons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUkTablespoons(double uktablespoons) - { - double value = (double) uktablespoons; - return new Volume(value, VolumeUnit.UkTablespoon); - } - /// - /// Get Volume from UsBeerBarrels. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsBeerBarrels(double usbeerbarrels) - { - double value = (double) usbeerbarrels; - return new Volume(value, VolumeUnit.UsBeerBarrel); - } - /// - /// Get Volume from UsCustomaryCups. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsCustomaryCups(double uscustomarycups) - { - double value = (double) uscustomarycups; - return new Volume(value, VolumeUnit.UsCustomaryCup); - } - /// - /// Get Volume from UsGallons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsGallons(double usgallons) - { - double value = (double) usgallons; - return new Volume(value, VolumeUnit.UsGallon); - } - /// - /// Get Volume from UsLegalCups. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsLegalCups(double uslegalcups) - { - double value = (double) uslegalcups; - return new Volume(value, VolumeUnit.UsLegalCup); - } - /// - /// Get Volume from UsOunces. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsOunces(double usounces) - { - double value = (double) usounces; - return new Volume(value, VolumeUnit.UsOunce); - } - /// - /// Get Volume from UsPints. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsPints(double uspints) - { - double value = (double) uspints; - return new Volume(value, VolumeUnit.UsPint); - } - /// - /// Get Volume from UsQuarts. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsQuarts(double usquarts) - { - double value = (double) usquarts; - return new Volume(value, VolumeUnit.UsQuart); - } - /// - /// Get Volume from UsTablespoons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsTablespoons(double ustablespoons) - { - double value = (double) ustablespoons; - return new Volume(value, VolumeUnit.UsTablespoon); - } - /// - /// Get Volume from UsTeaspoons. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static Volume FromUsTeaspoons(double usteaspoons) - { - double value = (double) usteaspoons; - return new Volume(value, VolumeUnit.UsTeaspoon); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// Volume unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static Volume From(double value, VolumeUnit fromUnit) - { - return new Volume((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static Volume Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static Volume Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out Volume result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out Volume result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static VolumeUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumeUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out VolumeUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out VolumeUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is Volume objVolume)) throw new ArgumentException("Expected type Volume.", nameof(obj)); - - return CompareTo(objVolume); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(Volume other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is Volume objVolume)) - return false; - - return Equals(objVolume); - } - - public bool Equals(Volume other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another Volume within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Volume other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current Volume. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((VolumeUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(VolumeUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this Volume to another Volume with the unit representation . - /// - /// A Volume with the specified unit. - public Volume ToUnit(VolumeUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new Volume(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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*0.0283168; - 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.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*0.0283168) * 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*0.0283168) * 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*0.0283168) * 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."); - } - } - - private double AsBaseNumericType(VolumeUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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/0.0283168; - 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.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/0.0283168) / 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/0.0283168) / 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/0.0283168) / 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeConcentration.g.cs deleted file mode 100644 index de9d7c8e36..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ /dev/null @@ -1,906 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The volume concentration (not to be confused with volume fraction) is defined as the volume of a constituent divided by the total volume of the mixture. - /// - /// - /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class VolumeConcentration : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly VolumeConcentrationUnit? _unit; - - static VolumeConcentration() - { - BaseDimensions = BaseDimensions.Dimensionless; - Info = new QuantityInfo(QuantityType.VolumeConcentration, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit DecimalFraction. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public VolumeConcentration() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private VolumeConcentration(double value, VolumeConcentrationUnit unit) - { - if(unit == VolumeConcentrationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of VolumeConcentration, which is DecimalFraction. All conversions go via this value. - /// - public static VolumeConcentrationUnit BaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; - - /// - /// Represents the largest possible value of VolumeConcentration - /// - public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of VolumeConcentration - /// - public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.VolumeConcentration; - - /// - /// All units of measurement for the VolumeConcentration quantity. - /// - public static VolumeConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast().Except(new VolumeConcentrationUnit[]{ VolumeConcentrationUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. - /// - public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public VolumeConcentrationUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => VolumeConcentration.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => VolumeConcentration.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get VolumeConcentration in CentilitersPerLiter. - /// - public double CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); - - /// - /// Get VolumeConcentration in CentilitersPerMililiter. - /// - public double CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); - - /// - /// Get VolumeConcentration in DecilitersPerLiter. - /// - public double DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); - - /// - /// Get VolumeConcentration in DecilitersPerMililiter. - /// - public double DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); - - /// - /// Get VolumeConcentration in DecimalFractions. - /// - public double DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); - - /// - /// Get VolumeConcentration in LitersPerLiter. - /// - public double LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); - - /// - /// Get VolumeConcentration in LitersPerMililiter. - /// - public double LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); - - /// - /// Get VolumeConcentration in MicrolitersPerLiter. - /// - public double MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); - - /// - /// Get VolumeConcentration in MicrolitersPerMililiter. - /// - public double MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); - - /// - /// Get VolumeConcentration in MillilitersPerLiter. - /// - public double MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); - - /// - /// Get VolumeConcentration in MillilitersPerMililiter. - /// - public double MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); - - /// - /// Get VolumeConcentration in NanolitersPerLiter. - /// - public double NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); - - /// - /// Get VolumeConcentration in NanolitersPerMililiter. - /// - public double NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); - - /// - /// Get VolumeConcentration in PartsPerBillion. - /// - public double PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); - - /// - /// Get VolumeConcentration in PartsPerMillion. - /// - public double PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); - - /// - /// Get VolumeConcentration in PartsPerThousand. - /// - public double PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); - - /// - /// Get VolumeConcentration in PartsPerTrillion. - /// - public double PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); - - /// - /// Get VolumeConcentration in Percent. - /// - public double Percent => As(VolumeConcentrationUnit.Percent); - - /// - /// Get VolumeConcentration in PicolitersPerLiter. - /// - public double PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); - - /// - /// Get VolumeConcentration in PicolitersPerMililiter. - /// - public double PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(VolumeConcentrationUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(VolumeConcentrationUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get VolumeConcentration from CentilitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromCentilitersPerLiter(double centilitersperliter) - { - double value = (double) centilitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerLiter); - } - /// - /// Get VolumeConcentration from CentilitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromCentilitersPerMililiter(double centiliterspermililiter) - { - double value = (double) centiliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerMililiter); - } - /// - /// Get VolumeConcentration from DecilitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromDecilitersPerLiter(double decilitersperliter) - { - double value = (double) decilitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerLiter); - } - /// - /// Get VolumeConcentration from DecilitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromDecilitersPerMililiter(double deciliterspermililiter) - { - double value = (double) deciliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerMililiter); - } - /// - /// Get VolumeConcentration from DecimalFractions. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromDecimalFractions(double decimalfractions) - { - double value = (double) decimalfractions; - return new VolumeConcentration(value, VolumeConcentrationUnit.DecimalFraction); - } - /// - /// Get VolumeConcentration from LitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromLitersPerLiter(double litersperliter) - { - double value = (double) litersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerLiter); - } - /// - /// Get VolumeConcentration from LitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromLitersPerMililiter(double literspermililiter) - { - double value = (double) literspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerMililiter); - } - /// - /// Get VolumeConcentration from MicrolitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromMicrolitersPerLiter(double microlitersperliter) - { - double value = (double) microlitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerLiter); - } - /// - /// Get VolumeConcentration from MicrolitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromMicrolitersPerMililiter(double microliterspermililiter) - { - double value = (double) microliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerMililiter); - } - /// - /// Get VolumeConcentration from MillilitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromMillilitersPerLiter(double millilitersperliter) - { - double value = (double) millilitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerLiter); - } - /// - /// Get VolumeConcentration from MillilitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromMillilitersPerMililiter(double milliliterspermililiter) - { - double value = (double) milliliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerMililiter); - } - /// - /// Get VolumeConcentration from NanolitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromNanolitersPerLiter(double nanolitersperliter) - { - double value = (double) nanolitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerLiter); - } - /// - /// Get VolumeConcentration from NanolitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromNanolitersPerMililiter(double nanoliterspermililiter) - { - double value = (double) nanoliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerMililiter); - } - /// - /// Get VolumeConcentration from PartsPerBillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPartsPerBillion(double partsperbillion) - { - double value = (double) partsperbillion; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerBillion); - } - /// - /// Get VolumeConcentration from PartsPerMillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPartsPerMillion(double partspermillion) - { - double value = (double) partspermillion; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerMillion); - } - /// - /// Get VolumeConcentration from PartsPerThousand. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPartsPerThousand(double partsperthousand) - { - double value = (double) partsperthousand; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerThousand); - } - /// - /// Get VolumeConcentration from PartsPerTrillion. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPartsPerTrillion(double partspertrillion) - { - double value = (double) partspertrillion; - return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerTrillion); - } - /// - /// Get VolumeConcentration from Percent. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPercent(double percent) - { - double value = (double) percent; - return new VolumeConcentration(value, VolumeConcentrationUnit.Percent); - } - /// - /// Get VolumeConcentration from PicolitersPerLiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPicolitersPerLiter(double picolitersperliter) - { - double value = (double) picolitersperliter; - return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerLiter); - } - /// - /// Get VolumeConcentration from PicolitersPerMililiter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeConcentration FromPicolitersPerMililiter(double picoliterspermililiter) - { - double value = (double) picoliterspermililiter; - return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerMililiter); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// VolumeConcentration unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static VolumeConcentration From(double value, VolumeConcentrationUnit fromUnit) - { - return new VolumeConcentration((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static VolumeConcentration Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumeConcentration Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out VolumeConcentration result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out VolumeConcentration result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static VolumeConcentrationUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumeConcentrationUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out VolumeConcentrationUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out VolumeConcentrationUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumeConcentration objVolumeConcentration)) throw new ArgumentException("Expected type VolumeConcentration.", nameof(obj)); - - return CompareTo(objVolumeConcentration); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(VolumeConcentration other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeConcentration objVolumeConcentration)) - return false; - - return Equals(objVolumeConcentration); - } - - public bool Equals(VolumeConcentration other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another VolumeConcentration within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeConcentration other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current VolumeConcentration. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((VolumeConcentrationUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(VolumeConcentrationUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this VolumeConcentration to another VolumeConcentration with the unit representation . - /// - /// A VolumeConcentration with the specified unit. - public VolumeConcentration ToUnit(VolumeConcentrationUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new VolumeConcentration(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(VolumeConcentrationUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.g.cs deleted file mode 100644 index 966db193d7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumeFlow.g.cs +++ /dev/null @@ -1,1515 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class VolumeFlow : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly VolumeFlowUnit? _unit; - - static VolumeFlow() - { - BaseDimensions = new BaseDimensions(3, 0, -1, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.VolumeFlow, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit CubicMeterPerSecond. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public VolumeFlow() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private VolumeFlow(double value, VolumeFlowUnit unit) - { - if(unit == VolumeFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of VolumeFlow, which is CubicMeterPerSecond. All conversions go via this value. - /// - public static VolumeFlowUnit BaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; - - /// - /// Represents the largest possible value of VolumeFlow - /// - public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of VolumeFlow - /// - public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.VolumeFlow; - - /// - /// All units of measurement for the VolumeFlow quantity. - /// - public static VolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().Except(new VolumeFlowUnit[]{ VolumeFlowUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerSecond. - /// - public static VolumeFlow Zero { get; } = new VolumeFlow(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public VolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => VolumeFlow.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => VolumeFlow.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get VolumeFlow in AcreFeetPerDay. - /// - public double AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); - - /// - /// Get VolumeFlow in AcreFeetPerHour. - /// - public double AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); - - /// - /// Get VolumeFlow in AcreFeetPerMinute. - /// - public double AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); - - /// - /// Get VolumeFlow in AcreFeetPerSecond. - /// - public double AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); - - /// - /// Get VolumeFlow in CentilitersPerDay. - /// - public double CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); - - /// - /// Get VolumeFlow in CentilitersPerMinute. - /// - public double CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); - - /// - /// Get VolumeFlow in CentilitersPerSecond. - /// - public double CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); - - /// - /// Get VolumeFlow in CubicCentimetersPerMinute. - /// - public double CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); - - /// - /// Get VolumeFlow in CubicDecimetersPerMinute. - /// - public double CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); - - /// - /// Get VolumeFlow in CubicFeetPerHour. - /// - public double CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); - - /// - /// Get VolumeFlow in CubicFeetPerMinute. - /// - public double CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); - - /// - /// Get VolumeFlow in CubicFeetPerSecond. - /// - public double CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); - - /// - /// Get VolumeFlow in CubicMetersPerDay. - /// - public double CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); - - /// - /// Get VolumeFlow in CubicMetersPerHour. - /// - public double CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); - - /// - /// Get VolumeFlow in CubicMetersPerMinute. - /// - public double CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); - - /// - /// Get VolumeFlow in CubicMetersPerSecond. - /// - public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); - - /// - /// Get VolumeFlow in CubicMillimetersPerSecond. - /// - public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); - - /// - /// Get VolumeFlow in CubicYardsPerDay. - /// - public double CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); - - /// - /// Get VolumeFlow in CubicYardsPerHour. - /// - public double CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); - - /// - /// Get VolumeFlow in CubicYardsPerMinute. - /// - public double CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); - - /// - /// Get VolumeFlow in CubicYardsPerSecond. - /// - public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); - - /// - /// Get VolumeFlow in DecilitersPerDay. - /// - public double DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); - - /// - /// Get VolumeFlow in DecilitersPerMinute. - /// - public double DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); - - /// - /// Get VolumeFlow in DecilitersPerSecond. - /// - public double DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); - - /// - /// Get VolumeFlow in KilolitersPerDay. - /// - public double KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); - - /// - /// Get VolumeFlow in KilolitersPerMinute. - /// - public double KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); - - /// - /// Get VolumeFlow in KilolitersPerSecond. - /// - public double KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); - - /// - /// Get VolumeFlow in KilousGallonsPerMinute. - /// - public double KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); - - /// - /// Get VolumeFlow in LitersPerDay. - /// - public double LitersPerDay => As(VolumeFlowUnit.LiterPerDay); - - /// - /// Get VolumeFlow in LitersPerHour. - /// - public double LitersPerHour => As(VolumeFlowUnit.LiterPerHour); - - /// - /// Get VolumeFlow in LitersPerMinute. - /// - public double LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); - - /// - /// Get VolumeFlow in LitersPerSecond. - /// - public double LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); - - /// - /// Get VolumeFlow in MegalitersPerDay. - /// - public double MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); - - /// - /// Get VolumeFlow in MegaukGallonsPerSecond. - /// - public double MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); - - /// - /// Get VolumeFlow in MicrolitersPerDay. - /// - public double MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); - - /// - /// Get VolumeFlow in MicrolitersPerMinute. - /// - public double MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); - - /// - /// Get VolumeFlow in MicrolitersPerSecond. - /// - public double MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); - - /// - /// Get VolumeFlow in MillilitersPerDay. - /// - public double MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); - - /// - /// Get VolumeFlow in MillilitersPerMinute. - /// - public double MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); - - /// - /// Get VolumeFlow in MillilitersPerSecond. - /// - public double MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); - - /// - /// Get VolumeFlow in MillionUsGallonsPerDay. - /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay); - - /// - /// Get VolumeFlow in NanolitersPerDay. - /// - public double NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); - - /// - /// Get VolumeFlow in NanolitersPerMinute. - /// - public double NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); - - /// - /// Get VolumeFlow in NanolitersPerSecond. - /// - public double NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); - - /// - /// Get VolumeFlow in OilBarrelsPerDay. - /// - public double OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); - - /// - /// Get VolumeFlow in OilBarrelsPerHour. - /// - public double OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); - - /// - /// Get VolumeFlow in OilBarrelsPerMinute. - /// - public double OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); - - /// - /// Get VolumeFlow in OilBarrelsPerSecond. - /// - public double OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); - - /// - /// Get VolumeFlow in UkGallonsPerDay. - /// - public double UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); - - /// - /// Get VolumeFlow in UkGallonsPerHour. - /// - public double UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); - - /// - /// Get VolumeFlow in UkGallonsPerMinute. - /// - public double UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); - - /// - /// Get VolumeFlow in UkGallonsPerSecond. - /// - public double UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); - - /// - /// Get VolumeFlow in UsGallonsPerDay. - /// - public double UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); - - /// - /// Get VolumeFlow in UsGallonsPerHour. - /// - public double UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); - - /// - /// Get VolumeFlow in UsGallonsPerMinute. - /// - public double UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); - - /// - /// Get VolumeFlow in UsGallonsPerSecond. - /// - public double UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(VolumeFlowUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(VolumeFlowUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get VolumeFlow from AcreFeetPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromAcreFeetPerDay(double acrefeetperday) - { - double value = (double) acrefeetperday; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerDay); - } - /// - /// Get VolumeFlow from AcreFeetPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromAcreFeetPerHour(double acrefeetperhour) - { - double value = (double) acrefeetperhour; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerHour); - } - /// - /// Get VolumeFlow from AcreFeetPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromAcreFeetPerMinute(double acrefeetperminute) - { - double value = (double) acrefeetperminute; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerMinute); - } - /// - /// Get VolumeFlow from AcreFeetPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromAcreFeetPerSecond(double acrefeetpersecond) - { - double value = (double) acrefeetpersecond; - return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerSecond); - } - /// - /// Get VolumeFlow from CentilitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCentilitersPerDay(double centilitersperday) - { - double value = (double) centilitersperday; - return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerDay); - } - /// - /// Get VolumeFlow from CentilitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCentilitersPerMinute(double centilitersperminute) - { - double value = (double) centilitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerMinute); - } - /// - /// Get VolumeFlow from CentilitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCentilitersPerSecond(double centiliterspersecond) - { - double value = (double) centiliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerSecond); - } - /// - /// Get VolumeFlow from CubicCentimetersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicCentimetersPerMinute(double cubiccentimetersperminute) - { - double value = (double) cubiccentimetersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicCentimeterPerMinute); - } - /// - /// Get VolumeFlow from CubicDecimetersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicDecimetersPerMinute(double cubicdecimetersperminute) - { - double value = (double) cubicdecimetersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicDecimeterPerMinute); - } - /// - /// Get VolumeFlow from CubicFeetPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicFeetPerHour(double cubicfeetperhour) - { - double value = (double) cubicfeetperhour; - return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerHour); - } - /// - /// Get VolumeFlow from CubicFeetPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicFeetPerMinute(double cubicfeetperminute) - { - double value = (double) cubicfeetperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerMinute); - } - /// - /// Get VolumeFlow from CubicFeetPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicFeetPerSecond(double cubicfeetpersecond) - { - double value = (double) cubicfeetpersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerSecond); - } - /// - /// Get VolumeFlow from CubicMetersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicMetersPerDay(double cubicmetersperday) - { - double value = (double) cubicmetersperday; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerDay); - } - /// - /// Get VolumeFlow from CubicMetersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicMetersPerHour(double cubicmetersperhour) - { - double value = (double) cubicmetersperhour; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerHour); - } - /// - /// Get VolumeFlow from CubicMetersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicMetersPerMinute(double cubicmetersperminute) - { - double value = (double) cubicmetersperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerMinute); - } - /// - /// Get VolumeFlow from CubicMetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicMetersPerSecond(double cubicmeterspersecond) - { - double value = (double) cubicmeterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond); - } - /// - /// Get VolumeFlow from CubicMillimetersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicMillimetersPerSecond(double cubicmillimeterspersecond) - { - double value = (double) cubicmillimeterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond); - } - /// - /// Get VolumeFlow from CubicYardsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicYardsPerDay(double cubicyardsperday) - { - double value = (double) cubicyardsperday; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerDay); - } - /// - /// Get VolumeFlow from CubicYardsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicYardsPerHour(double cubicyardsperhour) - { - double value = (double) cubicyardsperhour; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerHour); - } - /// - /// Get VolumeFlow from CubicYardsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicYardsPerMinute(double cubicyardsperminute) - { - double value = (double) cubicyardsperminute; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerMinute); - } - /// - /// Get VolumeFlow from CubicYardsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromCubicYardsPerSecond(double cubicyardspersecond) - { - double value = (double) cubicyardspersecond; - return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerSecond); - } - /// - /// Get VolumeFlow from DecilitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromDecilitersPerDay(double decilitersperday) - { - double value = (double) decilitersperday; - return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerDay); - } - /// - /// Get VolumeFlow from DecilitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromDecilitersPerMinute(double decilitersperminute) - { - double value = (double) decilitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerMinute); - } - /// - /// Get VolumeFlow from DecilitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromDecilitersPerSecond(double deciliterspersecond) - { - double value = (double) deciliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerSecond); - } - /// - /// Get VolumeFlow from KilolitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromKilolitersPerDay(double kilolitersperday) - { - double value = (double) kilolitersperday; - return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerDay); - } - /// - /// Get VolumeFlow from KilolitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromKilolitersPerMinute(double kilolitersperminute) - { - double value = (double) kilolitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerMinute); - } - /// - /// Get VolumeFlow from KilolitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromKilolitersPerSecond(double kiloliterspersecond) - { - double value = (double) kiloliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerSecond); - } - /// - /// Get VolumeFlow from KilousGallonsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromKilousGallonsPerMinute(double kilousgallonsperminute) - { - double value = (double) kilousgallonsperminute; - return new VolumeFlow(value, VolumeFlowUnit.KilousGallonPerMinute); - } - /// - /// Get VolumeFlow from LitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromLitersPerDay(double litersperday) - { - double value = (double) litersperday; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerDay); - } - /// - /// Get VolumeFlow from LitersPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromLitersPerHour(double litersperhour) - { - double value = (double) litersperhour; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerHour); - } - /// - /// Get VolumeFlow from LitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromLitersPerMinute(double litersperminute) - { - double value = (double) litersperminute; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerMinute); - } - /// - /// Get VolumeFlow from LitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromLitersPerSecond(double literspersecond) - { - double value = (double) literspersecond; - return new VolumeFlow(value, VolumeFlowUnit.LiterPerSecond); - } - /// - /// Get VolumeFlow from MegalitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMegalitersPerDay(double megalitersperday) - { - double value = (double) megalitersperday; - return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerDay); - } - /// - /// Get VolumeFlow from MegaukGallonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMegaukGallonsPerSecond(double megaukgallonspersecond) - { - double value = (double) megaukgallonspersecond; - return new VolumeFlow(value, VolumeFlowUnit.MegaukGallonPerSecond); - } - /// - /// Get VolumeFlow from MicrolitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMicrolitersPerDay(double microlitersperday) - { - double value = (double) microlitersperday; - return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerDay); - } - /// - /// Get VolumeFlow from MicrolitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMicrolitersPerMinute(double microlitersperminute) - { - double value = (double) microlitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerMinute); - } - /// - /// Get VolumeFlow from MicrolitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMicrolitersPerSecond(double microliterspersecond) - { - double value = (double) microliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerSecond); - } - /// - /// Get VolumeFlow from MillilitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMillilitersPerDay(double millilitersperday) - { - double value = (double) millilitersperday; - return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerDay); - } - /// - /// Get VolumeFlow from MillilitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMillilitersPerMinute(double millilitersperminute) - { - double value = (double) millilitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerMinute); - } - /// - /// Get VolumeFlow from MillilitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMillilitersPerSecond(double milliliterspersecond) - { - double value = (double) milliliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerSecond); - } - /// - /// Get VolumeFlow from MillionUsGallonsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromMillionUsGallonsPerDay(double millionusgallonsperday) - { - double value = (double) millionusgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonsPerDay); - } - /// - /// Get VolumeFlow from NanolitersPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromNanolitersPerDay(double nanolitersperday) - { - double value = (double) nanolitersperday; - return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerDay); - } - /// - /// Get VolumeFlow from NanolitersPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromNanolitersPerMinute(double nanolitersperminute) - { - double value = (double) nanolitersperminute; - return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerMinute); - } - /// - /// Get VolumeFlow from NanolitersPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromNanolitersPerSecond(double nanoliterspersecond) - { - double value = (double) nanoliterspersecond; - return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerSecond); - } - /// - /// Get VolumeFlow from OilBarrelsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromOilBarrelsPerDay(double oilbarrelsperday) - { - double value = (double) oilbarrelsperday; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerDay); - } - /// - /// Get VolumeFlow from OilBarrelsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromOilBarrelsPerHour(double oilbarrelsperhour) - { - double value = (double) oilbarrelsperhour; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerHour); - } - /// - /// Get VolumeFlow from OilBarrelsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromOilBarrelsPerMinute(double oilbarrelsperminute) - { - double value = (double) oilbarrelsperminute; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerMinute); - } - /// - /// Get VolumeFlow from OilBarrelsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromOilBarrelsPerSecond(double oilbarrelspersecond) - { - double value = (double) oilbarrelspersecond; - return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerSecond); - } - /// - /// Get VolumeFlow from UkGallonsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUkGallonsPerDay(double ukgallonsperday) - { - double value = (double) ukgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerDay); - } - /// - /// Get VolumeFlow from UkGallonsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUkGallonsPerHour(double ukgallonsperhour) - { - double value = (double) ukgallonsperhour; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerHour); - } - /// - /// Get VolumeFlow from UkGallonsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUkGallonsPerMinute(double ukgallonsperminute) - { - double value = (double) ukgallonsperminute; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerMinute); - } - /// - /// Get VolumeFlow from UkGallonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUkGallonsPerSecond(double ukgallonspersecond) - { - double value = (double) ukgallonspersecond; - return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerSecond); - } - /// - /// Get VolumeFlow from UsGallonsPerDay. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUsGallonsPerDay(double usgallonsperday) - { - double value = (double) usgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerDay); - } - /// - /// Get VolumeFlow from UsGallonsPerHour. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUsGallonsPerHour(double usgallonsperhour) - { - double value = (double) usgallonsperhour; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerHour); - } - /// - /// Get VolumeFlow from UsGallonsPerMinute. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUsGallonsPerMinute(double usgallonsperminute) - { - double value = (double) usgallonsperminute; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerMinute); - } - /// - /// Get VolumeFlow from UsGallonsPerSecond. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumeFlow FromUsGallonsPerSecond(double usgallonspersecond) - { - double value = (double) usgallonspersecond; - return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerSecond); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// VolumeFlow unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static VolumeFlow From(double value, VolumeFlowUnit fromUnit) - { - return new VolumeFlow((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static VolumeFlow Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumeFlow Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out VolumeFlow result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out VolumeFlow result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static VolumeFlowUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumeFlowUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out VolumeFlowUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out VolumeFlowUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumeFlow objVolumeFlow)) throw new ArgumentException("Expected type VolumeFlow.", nameof(obj)); - - return CompareTo(objVolumeFlow); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(VolumeFlow other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeFlow objVolumeFlow)) - return false; - - return Equals(objVolumeFlow); - } - - public bool Equals(VolumeFlow other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another VolumeFlow within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current VolumeFlow. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((VolumeFlowUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(VolumeFlowUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this VolumeFlow to another VolumeFlow with the unit representation . - /// - /// A VolumeFlow with the specified unit. - public VolumeFlow ToUnit(VolumeFlowUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new VolumeFlow(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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.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.DeciliterPerMinute: return (_value/60000.00000) * 1e-1d; - case VolumeFlowUnit.DeciliterPerSecond: return (_value/1000) * 1e-1d; - case VolumeFlowUnit.KiloliterPerDay: return (_value/86400000) * 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.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.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.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."); - } - } - - private double AsBaseNumericType(VolumeFlowUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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.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.DeciliterPerMinute: return (baseUnitValue*60000.00000) / 1e-1d; - case VolumeFlowUnit.DeciliterPerSecond: return (baseUnitValue*1000) / 1e-1d; - case VolumeFlowUnit.KiloliterPerDay: return (baseUnitValue*86400000) / 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.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.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.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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumePerLength.g.cs deleted file mode 100644 index 81ab899959..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumePerLength.g.cs +++ /dev/null @@ -1,682 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// Volume, typically of fluid, that a container can hold within a unit of length. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class VolumePerLength : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly VolumePerLengthUnit? _unit; - - static VolumePerLength() - { - BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.VolumePerLength, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit CubicMeterPerMeter. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public VolumePerLength() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private VolumePerLength(double value, VolumePerLengthUnit unit) - { - if(unit == VolumePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of VolumePerLength, which is CubicMeterPerMeter. All conversions go via this value. - /// - public static VolumePerLengthUnit BaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; - - /// - /// Represents the largest possible value of VolumePerLength - /// - public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of VolumePerLength - /// - public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.VolumePerLength; - - /// - /// All units of measurement for the VolumePerLength quantity. - /// - public static VolumePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast().Except(new VolumePerLengthUnit[]{ VolumePerLengthUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerMeter. - /// - public static VolumePerLength Zero { get; } = new VolumePerLength(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public VolumePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => VolumePerLength.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => VolumePerLength.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get VolumePerLength in CubicMetersPerMeter. - /// - public double CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); - - /// - /// Get VolumePerLength in CubicYardsPerFoot. - /// - public double CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); - - /// - /// Get VolumePerLength in CubicYardsPerUsSurveyFoot. - /// - public double CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); - - /// - /// Get VolumePerLength in LitersPerKilometer. - /// - public double LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); - - /// - /// Get VolumePerLength in LitersPerMeter. - /// - public double LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); - - /// - /// Get VolumePerLength in LitersPerMillimeter. - /// - public double LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); - - /// - /// Get VolumePerLength in OilBarrelsPerFoot. - /// - public double OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(VolumePerLengthUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(VolumePerLengthUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get VolumePerLength from CubicMetersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromCubicMetersPerMeter(double cubicmeterspermeter) - { - double value = (double) cubicmeterspermeter; - return new VolumePerLength(value, VolumePerLengthUnit.CubicMeterPerMeter); - } - /// - /// Get VolumePerLength from CubicYardsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromCubicYardsPerFoot(double cubicyardsperfoot) - { - double value = (double) cubicyardsperfoot; - return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerFoot); - } - /// - /// Get VolumePerLength from CubicYardsPerUsSurveyFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromCubicYardsPerUsSurveyFoot(double cubicyardsperussurveyfoot) - { - double value = (double) cubicyardsperussurveyfoot; - return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); - } - /// - /// Get VolumePerLength from LitersPerKilometer. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromLitersPerKilometer(double litersperkilometer) - { - double value = (double) litersperkilometer; - return new VolumePerLength(value, VolumePerLengthUnit.LiterPerKilometer); - } - /// - /// Get VolumePerLength from LitersPerMeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromLitersPerMeter(double literspermeter) - { - double value = (double) literspermeter; - return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMeter); - } - /// - /// Get VolumePerLength from LitersPerMillimeter. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromLitersPerMillimeter(double literspermillimeter) - { - double value = (double) literspermillimeter; - return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMillimeter); - } - /// - /// Get VolumePerLength from OilBarrelsPerFoot. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumePerLength FromOilBarrelsPerFoot(double oilbarrelsperfoot) - { - double value = (double) oilbarrelsperfoot; - return new VolumePerLength(value, VolumePerLengthUnit.OilBarrelPerFoot); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// VolumePerLength unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static VolumePerLength From(double value, VolumePerLengthUnit fromUnit) - { - return new VolumePerLength((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static VolumePerLength Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumePerLength Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out VolumePerLength result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out VolumePerLength result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static VolumePerLengthUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumePerLengthUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out VolumePerLengthUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out VolumePerLengthUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumePerLength objVolumePerLength)) throw new ArgumentException("Expected type VolumePerLength.", nameof(obj)); - - return CompareTo(objVolumePerLength); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(VolumePerLength other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumePerLength objVolumePerLength)) - return false; - - return Equals(objVolumePerLength); - } - - public bool Equals(VolumePerLength other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another VolumePerLength within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumePerLength other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current VolumePerLength. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((VolumePerLengthUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(VolumePerLengthUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this VolumePerLength to another VolumePerLength with the unit representation . - /// - /// A VolumePerLength with the specified unit. - public VolumePerLength ToUnit(VolumePerLengthUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new VolumePerLength(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(VolumePerLengthUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs deleted file mode 100644 index a836761c8a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ /dev/null @@ -1,719 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// The volumetric heat capacity is the amount of energy that must be added, in the form of heat, to one unit of volume of the material in order to cause an increase of one unit in its temperature. - /// - /// - /// https://en.wikipedia.org/wiki/Volumetric_heat_capacity - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class VolumetricHeatCapacity : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly VolumetricHeatCapacityUnit? _unit; - - static VolumetricHeatCapacity() - { - BaseDimensions = new BaseDimensions(-1, 1, -2, 0, -1, 0, 0); - Info = new QuantityInfo(QuantityType.VolumetricHeatCapacity, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit JoulePerCubicMeterKelvin. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public VolumetricHeatCapacity() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) - { - if(unit == VolumetricHeatCapacityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of VolumetricHeatCapacity, which is JoulePerCubicMeterKelvin. All conversions go via this value. - /// - public static VolumetricHeatCapacityUnit BaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; - - /// - /// Represents the largest possible value of VolumetricHeatCapacity - /// - public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of VolumetricHeatCapacity - /// - public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.VolumetricHeatCapacity; - - /// - /// All units of measurement for the VolumetricHeatCapacity quantity. - /// - public static VolumetricHeatCapacityUnit[] Units { get; } = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast().Except(new VolumetricHeatCapacityUnit[]{ VolumetricHeatCapacityUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerCubicMeterKelvin. - /// - public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public VolumetricHeatCapacityUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => VolumetricHeatCapacity.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => VolumetricHeatCapacity.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get VolumetricHeatCapacity in BtusPerCubicFootDegreeFahrenheit. - /// - public double BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); - - /// - /// Get VolumetricHeatCapacity in CaloriesPerCubicCentimeterDegreeCelsius. - /// - public double CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); - - /// - /// Get VolumetricHeatCapacity in JoulesPerCubicMeterDegreeCelsius. - /// - public double JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); - - /// - /// Get VolumetricHeatCapacity in JoulesPerCubicMeterKelvin. - /// - public double JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); - - /// - /// Get VolumetricHeatCapacity in KilocaloriesPerCubicCentimeterDegreeCelsius. - /// - public double KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); - - /// - /// Get VolumetricHeatCapacity in KilojoulesPerCubicMeterDegreeCelsius. - /// - public double KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); - - /// - /// Get VolumetricHeatCapacity in KilojoulesPerCubicMeterKelvin. - /// - public double KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); - - /// - /// Get VolumetricHeatCapacity in MegajoulesPerCubicMeterDegreeCelsius. - /// - public double MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); - - /// - /// Get VolumetricHeatCapacity in MegajoulesPerCubicMeterKelvin. - /// - public double MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(VolumetricHeatCapacityUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(VolumetricHeatCapacityUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get VolumetricHeatCapacity from BtusPerCubicFootDegreeFahrenheit. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(double btuspercubicfootdegreefahrenheit) - { - double value = (double) btuspercubicfootdegreefahrenheit; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); - } - /// - /// Get VolumetricHeatCapacity from CaloriesPerCubicCentimeterDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius(double caloriespercubiccentimeterdegreecelsius) - { - double value = (double) caloriespercubiccentimeterdegreecelsius; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); - } - /// - /// Get VolumetricHeatCapacity from JoulesPerCubicMeterDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(double joulespercubicmeterdegreecelsius) - { - double value = (double) joulespercubicmeterdegreecelsius; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); - } - /// - /// Get VolumetricHeatCapacity from JoulesPerCubicMeterKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(double joulespercubicmeterkelvin) - { - double value = (double) joulespercubicmeterkelvin; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); - } - /// - /// Get VolumetricHeatCapacity from KilocaloriesPerCubicCentimeterDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCelsius(double kilocaloriespercubiccentimeterdegreecelsius) - { - double value = (double) kilocaloriespercubiccentimeterdegreecelsius; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); - } - /// - /// Get VolumetricHeatCapacity from KilojoulesPerCubicMeterDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(double kilojoulespercubicmeterdegreecelsius) - { - double value = (double) kilojoulespercubicmeterdegreecelsius; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); - } - /// - /// Get VolumetricHeatCapacity from KilojoulesPerCubicMeterKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(double kilojoulespercubicmeterkelvin) - { - double value = (double) kilojoulespercubicmeterkelvin; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); - } - /// - /// Get VolumetricHeatCapacity from MegajoulesPerCubicMeterDegreeCelsius. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(double megajoulespercubicmeterdegreecelsius) - { - double value = (double) megajoulespercubicmeterdegreecelsius; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); - } - /// - /// Get VolumetricHeatCapacity from MegajoulesPerCubicMeterKelvin. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(double megajoulespercubicmeterkelvin) - { - double value = (double) megajoulespercubicmeterkelvin; - return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// VolumetricHeatCapacity unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static VolumetricHeatCapacity From(double value, VolumetricHeatCapacityUnit fromUnit) - { - return new VolumetricHeatCapacity((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static VolumetricHeatCapacity Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumetricHeatCapacity Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out VolumetricHeatCapacity result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out VolumetricHeatCapacity result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static VolumetricHeatCapacityUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static VolumetricHeatCapacityUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out VolumetricHeatCapacityUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out VolumetricHeatCapacityUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is VolumetricHeatCapacity objVolumetricHeatCapacity)) throw new ArgumentException("Expected type VolumetricHeatCapacity.", nameof(obj)); - - return CompareTo(objVolumetricHeatCapacity); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(VolumetricHeatCapacity other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumetricHeatCapacity objVolumetricHeatCapacity)) - return false; - - return Equals(objVolumetricHeatCapacity); - } - - public bool Equals(VolumetricHeatCapacity other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another VolumetricHeatCapacity within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current VolumetricHeatCapacity. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((VolumetricHeatCapacityUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(VolumetricHeatCapacityUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this VolumetricHeatCapacity to another VolumetricHeatCapacity with the unit representation . - /// - /// A VolumetricHeatCapacity with the specified unit. - public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new VolumetricHeatCapacity(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(VolumetricHeatCapacityUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs deleted file mode 100644 index 74bc407b4d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ /dev/null @@ -1,665 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.Units; -using UnitsNet.InternalHelpers; - -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - /// - /// A geometric property of an area that is used to determine the warping stress. - /// - // Windows Runtime Component has constraints on public types: https://msdn.microsoft.com/en-us/library/br230301.aspx#Declaring types in Windows Runtime Components - // Public structures can't have any members other than public fields, and those fields must be value types or strings. - // Public classes must be sealed (NotInheritable in Visual Basic). If your programming model requires polymorphism, you can create a public interface and implement that interface on the classes that must be polymorphic. - public sealed partial class WarpingMomentOfInertia : IQuantity - { - /// - /// The numeric value this quantity was constructed with. - /// - private readonly double _value; - - /// - /// The unit this quantity was constructed with. - /// - private readonly WarpingMomentOfInertiaUnit? _unit; - - static WarpingMomentOfInertia() - { - BaseDimensions = new BaseDimensions(6, 0, 0, 0, 0, 0, 0); - Info = new QuantityInfo(QuantityType.WarpingMomentOfInertia, Units.Cast().ToArray(), BaseUnit, Zero, BaseDimensions); - } - - /// - /// Creates the quantity with a value of 0 in the base unit MeterToTheSixth. - /// - /// - /// Windows Runtime Component requires a default constructor. - /// - public WarpingMomentOfInertia() - { - _value = 0; - _unit = BaseUnit; - } - - /// - /// Creates the quantity with the given numeric value and unit. - /// - /// The numeric value to construct this quantity with. - /// The unit representation to construct this quantity with. - /// Value parameter cannot be named 'value' due to constraint when targeting Windows Runtime Component. - /// If value is NaN or Infinity. - private WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) - { - if(unit == WarpingMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - - _value = Guard.EnsureValidNumber(value, nameof(value)); - _unit = unit; - } - - #region Static Properties - - /// - /// Information about the quantity type, such as unit values and names. - /// - internal static QuantityInfo Info { get; } - - /// - /// The of this quantity. - /// - public static BaseDimensions BaseDimensions { get; } - - /// - /// The base unit of WarpingMomentOfInertia, which is MeterToTheSixth. All conversions go via this value. - /// - public static WarpingMomentOfInertiaUnit BaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; - - /// - /// Represents the largest possible value of WarpingMomentOfInertia - /// - public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, BaseUnit); - - /// - /// Represents the smallest possible value of WarpingMomentOfInertia - /// - public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, BaseUnit); - - /// - /// The of this quantity. - /// - public static QuantityType QuantityType { get; } = QuantityType.WarpingMomentOfInertia; - - /// - /// All units of measurement for the WarpingMomentOfInertia quantity. - /// - public static WarpingMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast().Except(new WarpingMomentOfInertiaUnit[]{ WarpingMomentOfInertiaUnit.Undefined }).ToArray(); - - /// - /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheSixth. - /// - public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, BaseUnit); - - #endregion - - #region Properties - - /// - /// The numeric value this quantity was constructed with. - /// - public double Value => Convert.ToDouble(_value); - - /// - object IQuantity.Unit => Unit; - - /// - /// The unit this quantity was constructed with -or- if default ctor was used. - /// - public WarpingMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); - - internal QuantityInfo QuantityInfo => Info; - - /// - /// The of this quantity. - /// - public QuantityType Type => WarpingMomentOfInertia.QuantityType; - - /// - /// The of this quantity. - /// - public BaseDimensions Dimensions => WarpingMomentOfInertia.BaseDimensions; - - #endregion - - #region Conversion Properties - - /// - /// Get WarpingMomentOfInertia in CentimetersToTheSixth. - /// - public double CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); - - /// - /// Get WarpingMomentOfInertia in DecimetersToTheSixth. - /// - public double DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); - - /// - /// Get WarpingMomentOfInertia in FeetToTheSixth. - /// - public double FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); - - /// - /// Get WarpingMomentOfInertia in InchesToTheSixth. - /// - public double InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); - - /// - /// Get WarpingMomentOfInertia in MetersToTheSixth. - /// - public double MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); - - /// - /// Get WarpingMomentOfInertia in MillimetersToTheSixth. - /// - public double MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); - - #endregion - - #region Static Methods - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit) - { - return GetAbbreviation(unit, null); - } - - /// - /// Get unit abbreviation string. - /// - /// Unit to get abbreviation for. - /// Unit abbreviation string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); - } - - #endregion - - #region Static Factory Methods - - /// - /// Get WarpingMomentOfInertia from CentimetersToTheSixth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static WarpingMomentOfInertia FromCentimetersToTheSixth(double centimeterstothesixth) - { - double value = (double) centimeterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); - } - /// - /// Get WarpingMomentOfInertia from DecimetersToTheSixth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static WarpingMomentOfInertia FromDecimetersToTheSixth(double decimeterstothesixth) - { - double value = (double) decimeterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); - } - /// - /// Get WarpingMomentOfInertia from FeetToTheSixth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static WarpingMomentOfInertia FromFeetToTheSixth(double feettothesixth) - { - double value = (double) feettothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.FootToTheSixth); - } - /// - /// Get WarpingMomentOfInertia from InchesToTheSixth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static WarpingMomentOfInertia FromInchesToTheSixth(double inchestothesixth) - { - double value = (double) inchestothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.InchToTheSixth); - } - /// - /// Get WarpingMomentOfInertia from MetersToTheSixth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static WarpingMomentOfInertia FromMetersToTheSixth(double meterstothesixth) - { - double value = (double) meterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MeterToTheSixth); - } - /// - /// Get WarpingMomentOfInertia from MillimetersToTheSixth. - /// - /// If value is NaN or Infinity. - [Windows.Foundation.Metadata.DefaultOverload] - public static WarpingMomentOfInertia FromMillimetersToTheSixth(double millimeterstothesixth) - { - double value = (double) millimeterstothesixth; - return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); - } - - /// - /// Dynamically convert from value and unit enum to . - /// - /// Value to convert from. - /// Unit to convert from. - /// WarpingMomentOfInertia unit value. - // Fix name conflict with parameter "value" - [return: System.Runtime.InteropServices.WindowsRuntime.ReturnValueName("returnValue")] - public static WarpingMomentOfInertia From(double value, WarpingMomentOfInertiaUnit fromUnit) - { - return new WarpingMomentOfInertia((double)value, fromUnit); - } - - #endregion - - #region Static Parse Methods - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - public static WarpingMomentOfInertia Parse(string str) - { - return Parse(str, null); - } - - /// - /// Parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// - /// Expected string to have one or two pairs of quantity and unit in the format - /// "<quantity> <unit>". Eg. "5.5 m" or "1ft 2in" - /// - /// - /// More than one unit is represented by the specified unit abbreviation. - /// Example: Volume.Parse("1 cup") will throw, because it can refer to any of - /// , and . - /// - /// - /// If anything else goes wrong, typically due to a bug or unhandled case. - /// We wrap exceptions in to allow you to distinguish - /// Units.NET exceptions from other exceptions. - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static WarpingMomentOfInertia Parse(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.Parse( - str, - provider, - From); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - public static bool TryParse([CanBeNull] string str, out WarpingMomentOfInertia result) - { - return TryParse(str, null, out result); - } - - /// - /// Try to parse a string with one or two quantities of the format "<quantity> <unit>". - /// - /// String to parse. Typically in the form: {number} {unit} - /// Resulting unit quantity if successful. - /// True if successful, otherwise false. - /// - /// Length.Parse("5.5 m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParse([CanBeNull] string str, [CanBeNull] string cultureName, out WarpingMomentOfInertia result) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return QuantityParser.Default.TryParse( - str, - provider, - From, - out result); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - public static WarpingMomentOfInertiaUnit ParseUnit(string str) - { - return ParseUnit(str, null); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// - /// Length.ParseUnit("m", new CultureInfo("en-US")); - /// - /// The value of 'str' cannot be null. - /// Error parsing string. - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static WarpingMomentOfInertiaUnit ParseUnit(string str, [CanBeNull] string cultureName) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.Parse(str, provider); - } - - public static bool TryParseUnit(string str, out WarpingMomentOfInertiaUnit unit) - { - return TryParseUnit(str, null, out unit); - } - - /// - /// Parse a unit string. - /// - /// String to parse. Typically in the form: {number} {unit} - /// The parsed unit if successful. - /// True if successful, otherwise false. - /// - /// Length.TryParseUnit("m", new CultureInfo("en-US")); - /// - /// Name of culture (ex: "en-US") to use when parsing number and unit. Defaults to if null. - public static bool TryParseUnit(string str, [CanBeNull] string cultureName, out WarpingMomentOfInertiaUnit unit) - { - IFormatProvider provider = GetFormatProviderFromCultureName(cultureName); - return UnitParser.Default.TryParse(str, provider, out unit); - } - - #endregion - - #region Equality / IComparable - - public int CompareTo(object obj) - { - if(obj is null) throw new ArgumentNullException(nameof(obj)); - if(!(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) throw new ArgumentException("Expected type WarpingMomentOfInertia.", nameof(obj)); - - return CompareTo(objWarpingMomentOfInertia); - } - - // Windows Runtime Component does not allow public methods/ctors with same number of parameters: https://msdn.microsoft.com/en-us/library/br230301.aspx#Overloaded methods - internal int CompareTo(WarpingMomentOfInertia other) - { - return _value.CompareTo(other.AsBaseNumericType(this.Unit)); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public override bool Equals(object obj) - { - if(obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) - return false; - - return Equals(objWarpingMomentOfInertia); - } - - public bool Equals(WarpingMomentOfInertia other) - { - return _value.Equals(other.AsBaseNumericType(this.Unit)); - } - - /// - /// - /// Compare equality to another WarpingMomentOfInertia within the given absolute or relative tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a percentage of this quantity's value. will be converted into - /// this quantity's unit for comparison. A relative tolerance of 0.01 means the absolute difference must be within +/- 1% of - /// this quantity's value to be considered equal. - /// - /// In this example, the two quantities will be equal if the value of b is within +/- 1% of a (0.02m or 2cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between this quantity's value and - /// as a fixed number in this quantity's unit. will be converted into - /// this quantity's unit for comparison. - /// - /// In this example, the two quantities will be equal if the value of b is within 0.01 of a (0.01m or 1cm). - /// - /// var a = Length.FromMeters(2.0); - /// var b = Length.FromInches(50.0); - /// a.Equals(b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// Note that it is advised against specifying zero difference, due to the nature - /// of floating point operations and using System.Double internally. - /// - /// - /// The other quantity to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// The comparison type: either relative or absolute. - /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonType comparisonType) - { - if(tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); - - return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); - } - - /// - /// Returns the hash code for this instance. - /// - /// A hash code for the current WarpingMomentOfInertia. - public override int GetHashCode() - { - return new { QuantityType, Value, Unit }.GetHashCode(); - } - - #endregion - - #region Conversion Methods - - double IQuantity.As(object unit) => As((WarpingMomentOfInertiaUnit)unit); - - /// - /// Convert to the unit representation . - /// - /// Value converted to the specified unit. - public double As(WarpingMomentOfInertiaUnit unit) - { - if(Unit == unit) - return Convert.ToDouble(Value); - - var converted = AsBaseNumericType(unit); - return Convert.ToDouble(converted); - } - - /// - /// Converts this WarpingMomentOfInertia to another WarpingMomentOfInertia with the unit representation . - /// - /// A WarpingMomentOfInertia with the specified unit. - public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit) - { - var convertedValue = AsBaseNumericType(unit); - return new WarpingMomentOfInertia(convertedValue, unit); - } - - /// - /// Converts the current value + unit to the base unit. - /// This is typically the first step in converting from one unit to another. - /// - /// The value in the base unit representation. - private double AsBaseUnit() - { - switch(Unit) - { - 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."); - } - } - - private double AsBaseNumericType(WarpingMomentOfInertiaUnit unit) - { - if(Unit == unit) - return _value; - - var baseUnitValue = AsBaseUnit(); - - switch(unit) - { - 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}."); - } - } - - #endregion - - #region ToString Methods - - /// - /// Get default string representation of value and unit. - /// - /// String representation. - public override string ToString() - { - return ToString(null); - } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName) - { - var provider = cultureName; - return ToString(provider, 2); - } - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString(string cultureName, int significantDigitsAfterRadix) - { - var provider = cultureName; - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - public string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args) - { - var provider = GetFormatProviderFromCultureName(cultureName); - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? GlobalConfiguration.DefaultCulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - - #endregion - - private static IFormatProvider GetFormatProviderFromCultureName([CanBeNull] string cultureName) - { - return cultureName != null ? new CultureInfo(cultureName) : (IFormatProvider)null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantity.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantity.g.cs deleted file mode 100644 index 77af9b86c2..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Quantity.g.cs +++ /dev/null @@ -1,758 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Linq; -using JetBrains.Annotations; -using UnitsNet.InternalHelpers; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Dynamically parse or construct quantities when types are only known at runtime. - /// - internal static partial class Quantity - { - /// - /// Try to dynamically construct a quantity. - /// - /// Numeric value. - /// Unit enum value. - /// The resulting quantity if successful, otherwise default. - /// True if successful with assigned the value, otherwise false. - internal static bool TryFrom(double value, Enum unit, out IQuantity quantity) - { - switch (unit) - { - case AccelerationUnit accelerationUnit: - quantity = Acceleration.From(value, accelerationUnit); - return true; - case AmountOfSubstanceUnit amountOfSubstanceUnit: - quantity = AmountOfSubstance.From(value, amountOfSubstanceUnit); - return true; - case AmplitudeRatioUnit amplitudeRatioUnit: - quantity = AmplitudeRatio.From(value, amplitudeRatioUnit); - return true; - case AngleUnit angleUnit: - quantity = Angle.From(value, angleUnit); - return true; - case ApparentEnergyUnit apparentEnergyUnit: - quantity = ApparentEnergy.From(value, apparentEnergyUnit); - return true; - case ApparentPowerUnit apparentPowerUnit: - quantity = ApparentPower.From(value, apparentPowerUnit); - return true; - case AreaUnit areaUnit: - quantity = Area.From(value, areaUnit); - return true; - case AreaDensityUnit areaDensityUnit: - quantity = AreaDensity.From(value, areaDensityUnit); - return true; - case AreaMomentOfInertiaUnit areaMomentOfInertiaUnit: - quantity = AreaMomentOfInertia.From(value, areaMomentOfInertiaUnit); - return true; - case BitRateUnit bitRateUnit: - quantity = BitRate.From(value, bitRateUnit); - return true; - case BrakeSpecificFuelConsumptionUnit brakeSpecificFuelConsumptionUnit: - quantity = BrakeSpecificFuelConsumption.From(value, brakeSpecificFuelConsumptionUnit); - return true; - case CapacitanceUnit capacitanceUnit: - quantity = Capacitance.From(value, capacitanceUnit); - return true; - case CoefficientOfThermalExpansionUnit coefficientOfThermalExpansionUnit: - quantity = CoefficientOfThermalExpansion.From(value, coefficientOfThermalExpansionUnit); - return true; - case DensityUnit densityUnit: - quantity = Density.From(value, densityUnit); - return true; - case DurationUnit durationUnit: - quantity = Duration.From(value, durationUnit); - return true; - case DynamicViscosityUnit dynamicViscosityUnit: - quantity = DynamicViscosity.From(value, dynamicViscosityUnit); - return true; - case ElectricAdmittanceUnit electricAdmittanceUnit: - quantity = ElectricAdmittance.From(value, electricAdmittanceUnit); - return true; - case ElectricChargeUnit electricChargeUnit: - quantity = ElectricCharge.From(value, electricChargeUnit); - return true; - case ElectricChargeDensityUnit electricChargeDensityUnit: - quantity = ElectricChargeDensity.From(value, electricChargeDensityUnit); - return true; - case ElectricConductanceUnit electricConductanceUnit: - quantity = ElectricConductance.From(value, electricConductanceUnit); - return true; - case ElectricConductivityUnit electricConductivityUnit: - quantity = ElectricConductivity.From(value, electricConductivityUnit); - return true; - case ElectricCurrentUnit electricCurrentUnit: - quantity = ElectricCurrent.From(value, electricCurrentUnit); - return true; - case ElectricCurrentDensityUnit electricCurrentDensityUnit: - quantity = ElectricCurrentDensity.From(value, electricCurrentDensityUnit); - return true; - case ElectricCurrentGradientUnit electricCurrentGradientUnit: - quantity = ElectricCurrentGradient.From(value, electricCurrentGradientUnit); - return true; - case ElectricFieldUnit electricFieldUnit: - quantity = ElectricField.From(value, electricFieldUnit); - return true; - case ElectricInductanceUnit electricInductanceUnit: - quantity = ElectricInductance.From(value, electricInductanceUnit); - return true; - case ElectricPotentialUnit electricPotentialUnit: - quantity = ElectricPotential.From(value, electricPotentialUnit); - return true; - case ElectricPotentialAcUnit electricPotentialAcUnit: - quantity = ElectricPotentialAc.From(value, electricPotentialAcUnit); - return true; - case ElectricPotentialChangeRateUnit electricPotentialChangeRateUnit: - quantity = ElectricPotentialChangeRate.From(value, electricPotentialChangeRateUnit); - return true; - case ElectricPotentialDcUnit electricPotentialDcUnit: - quantity = ElectricPotentialDc.From(value, electricPotentialDcUnit); - return true; - case ElectricResistanceUnit electricResistanceUnit: - quantity = ElectricResistance.From(value, electricResistanceUnit); - return true; - case ElectricResistivityUnit electricResistivityUnit: - quantity = ElectricResistivity.From(value, electricResistivityUnit); - return true; - case ElectricSurfaceChargeDensityUnit electricSurfaceChargeDensityUnit: - quantity = ElectricSurfaceChargeDensity.From(value, electricSurfaceChargeDensityUnit); - return true; - case EnergyUnit energyUnit: - quantity = Energy.From(value, energyUnit); - return true; - case EntropyUnit entropyUnit: - quantity = Entropy.From(value, entropyUnit); - return true; - case ForceUnit forceUnit: - quantity = Force.From(value, forceUnit); - return true; - case ForceChangeRateUnit forceChangeRateUnit: - quantity = ForceChangeRate.From(value, forceChangeRateUnit); - return true; - case ForcePerLengthUnit forcePerLengthUnit: - quantity = ForcePerLength.From(value, forcePerLengthUnit); - return true; - case FrequencyUnit frequencyUnit: - quantity = Frequency.From(value, frequencyUnit); - return true; - case FuelEfficiencyUnit fuelEfficiencyUnit: - quantity = FuelEfficiency.From(value, fuelEfficiencyUnit); - return true; - case HeatFluxUnit heatFluxUnit: - quantity = HeatFlux.From(value, heatFluxUnit); - return true; - case HeatTransferCoefficientUnit heatTransferCoefficientUnit: - quantity = HeatTransferCoefficient.From(value, heatTransferCoefficientUnit); - return true; - case IlluminanceUnit illuminanceUnit: - quantity = Illuminance.From(value, illuminanceUnit); - return true; - case InformationUnit informationUnit: - quantity = Information.From(value, informationUnit); - return true; - case IrradianceUnit irradianceUnit: - quantity = Irradiance.From(value, irradianceUnit); - return true; - case IrradiationUnit irradiationUnit: - quantity = Irradiation.From(value, irradiationUnit); - return true; - case KinematicViscosityUnit kinematicViscosityUnit: - quantity = KinematicViscosity.From(value, kinematicViscosityUnit); - return true; - case LapseRateUnit lapseRateUnit: - quantity = LapseRate.From(value, lapseRateUnit); - return true; - case LengthUnit lengthUnit: - quantity = Length.From(value, lengthUnit); - return true; - case LevelUnit levelUnit: - quantity = Level.From(value, levelUnit); - return true; - case LinearDensityUnit linearDensityUnit: - quantity = LinearDensity.From(value, linearDensityUnit); - return true; - case LinearPowerDensityUnit linearPowerDensityUnit: - quantity = LinearPowerDensity.From(value, linearPowerDensityUnit); - return true; - case LuminosityUnit luminosityUnit: - quantity = Luminosity.From(value, luminosityUnit); - return true; - case LuminousFluxUnit luminousFluxUnit: - quantity = LuminousFlux.From(value, luminousFluxUnit); - return true; - case LuminousIntensityUnit luminousIntensityUnit: - quantity = LuminousIntensity.From(value, luminousIntensityUnit); - return true; - case MagneticFieldUnit magneticFieldUnit: - quantity = MagneticField.From(value, magneticFieldUnit); - return true; - case MagneticFluxUnit magneticFluxUnit: - quantity = MagneticFlux.From(value, magneticFluxUnit); - return true; - case MagnetizationUnit magnetizationUnit: - quantity = Magnetization.From(value, magnetizationUnit); - return true; - case MassUnit massUnit: - quantity = Mass.From(value, massUnit); - return true; - case MassConcentrationUnit massConcentrationUnit: - quantity = MassConcentration.From(value, massConcentrationUnit); - return true; - case MassFlowUnit massFlowUnit: - quantity = MassFlow.From(value, massFlowUnit); - return true; - case MassFluxUnit massFluxUnit: - quantity = MassFlux.From(value, massFluxUnit); - return true; - case MassFractionUnit massFractionUnit: - quantity = MassFraction.From(value, massFractionUnit); - return true; - case MassMomentOfInertiaUnit massMomentOfInertiaUnit: - quantity = MassMomentOfInertia.From(value, massMomentOfInertiaUnit); - return true; - case MolarEnergyUnit molarEnergyUnit: - quantity = MolarEnergy.From(value, molarEnergyUnit); - return true; - case MolarEntropyUnit molarEntropyUnit: - quantity = MolarEntropy.From(value, molarEntropyUnit); - return true; - case MolarityUnit molarityUnit: - quantity = Molarity.From(value, molarityUnit); - return true; - case MolarMassUnit molarMassUnit: - quantity = MolarMass.From(value, molarMassUnit); - return true; - case PermeabilityUnit permeabilityUnit: - quantity = Permeability.From(value, permeabilityUnit); - return true; - case PermittivityUnit permittivityUnit: - quantity = Permittivity.From(value, permittivityUnit); - return true; - case PowerUnit powerUnit: - quantity = Power.From(value, powerUnit); - return true; - case PowerDensityUnit powerDensityUnit: - quantity = PowerDensity.From(value, powerDensityUnit); - return true; - case PowerRatioUnit powerRatioUnit: - quantity = PowerRatio.From(value, powerRatioUnit); - return true; - case PressureUnit pressureUnit: - quantity = Pressure.From(value, pressureUnit); - return true; - case PressureChangeRateUnit pressureChangeRateUnit: - quantity = PressureChangeRate.From(value, pressureChangeRateUnit); - return true; - case RatioUnit ratioUnit: - quantity = Ratio.From(value, ratioUnit); - return true; - case RatioChangeRateUnit ratioChangeRateUnit: - quantity = RatioChangeRate.From(value, ratioChangeRateUnit); - return true; - case ReactiveEnergyUnit reactiveEnergyUnit: - quantity = ReactiveEnergy.From(value, reactiveEnergyUnit); - return true; - case ReactivePowerUnit reactivePowerUnit: - quantity = ReactivePower.From(value, reactivePowerUnit); - return true; - case ReciprocalAreaUnit reciprocalAreaUnit: - quantity = ReciprocalArea.From(value, reciprocalAreaUnit); - return true; - case ReciprocalLengthUnit reciprocalLengthUnit: - quantity = ReciprocalLength.From(value, reciprocalLengthUnit); - return true; - case RelativeHumidityUnit relativeHumidityUnit: - quantity = RelativeHumidity.From(value, relativeHumidityUnit); - return true; - case RotationalAccelerationUnit rotationalAccelerationUnit: - quantity = RotationalAcceleration.From(value, rotationalAccelerationUnit); - return true; - case RotationalSpeedUnit rotationalSpeedUnit: - quantity = RotationalSpeed.From(value, rotationalSpeedUnit); - return true; - case RotationalStiffnessUnit rotationalStiffnessUnit: - quantity = RotationalStiffness.From(value, rotationalStiffnessUnit); - return true; - case RotationalStiffnessPerLengthUnit rotationalStiffnessPerLengthUnit: - quantity = RotationalStiffnessPerLength.From(value, rotationalStiffnessPerLengthUnit); - return true; - case ScalarUnit scalarUnit: - quantity = Scalar.From(value, scalarUnit); - return true; - case SolidAngleUnit solidAngleUnit: - quantity = SolidAngle.From(value, solidAngleUnit); - return true; - case SpecificEnergyUnit specificEnergyUnit: - quantity = SpecificEnergy.From(value, specificEnergyUnit); - return true; - case SpecificEntropyUnit specificEntropyUnit: - quantity = SpecificEntropy.From(value, specificEntropyUnit); - return true; - case SpecificFuelConsumptionUnit specificFuelConsumptionUnit: - quantity = SpecificFuelConsumption.From(value, specificFuelConsumptionUnit); - return true; - case SpecificVolumeUnit specificVolumeUnit: - quantity = SpecificVolume.From(value, specificVolumeUnit); - return true; - case SpecificWeightUnit specificWeightUnit: - quantity = SpecificWeight.From(value, specificWeightUnit); - return true; - case SpeedUnit speedUnit: - quantity = Speed.From(value, speedUnit); - return true; - case StandardVolumeFlowUnit standardVolumeFlowUnit: - quantity = StandardVolumeFlow.From(value, standardVolumeFlowUnit); - return true; - case TemperatureUnit temperatureUnit: - quantity = Temperature.From(value, temperatureUnit); - return true; - case TemperatureChangeRateUnit temperatureChangeRateUnit: - quantity = TemperatureChangeRate.From(value, temperatureChangeRateUnit); - return true; - case TemperatureDeltaUnit temperatureDeltaUnit: - quantity = TemperatureDelta.From(value, temperatureDeltaUnit); - return true; - case ThermalConductivityUnit thermalConductivityUnit: - quantity = ThermalConductivity.From(value, thermalConductivityUnit); - return true; - case ThermalResistanceUnit thermalResistanceUnit: - quantity = ThermalResistance.From(value, thermalResistanceUnit); - return true; - case TorqueUnit torqueUnit: - quantity = Torque.From(value, torqueUnit); - return true; - case TorquePerLengthUnit torquePerLengthUnit: - quantity = TorquePerLength.From(value, torquePerLengthUnit); - return true; - case TurbidityUnit turbidityUnit: - quantity = Turbidity.From(value, turbidityUnit); - return true; - case VitaminAUnit vitaminAUnit: - quantity = VitaminA.From(value, vitaminAUnit); - return true; - case VolumeUnit volumeUnit: - quantity = Volume.From(value, volumeUnit); - return true; - case VolumeConcentrationUnit volumeConcentrationUnit: - quantity = VolumeConcentration.From(value, volumeConcentrationUnit); - return true; - case VolumeFlowUnit volumeFlowUnit: - quantity = VolumeFlow.From(value, volumeFlowUnit); - return true; - case VolumePerLengthUnit volumePerLengthUnit: - quantity = VolumePerLength.From(value, volumePerLengthUnit); - return true; - case VolumetricHeatCapacityUnit volumetricHeatCapacityUnit: - quantity = VolumetricHeatCapacity.From(value, volumetricHeatCapacityUnit); - return true; - case WarpingMomentOfInertiaUnit warpingMomentOfInertiaUnit: - quantity = WarpingMomentOfInertia.From(value, warpingMomentOfInertiaUnit); - return true; - default: - { - quantity = default(IQuantity); - return false; - } - } - } - - /// - internal static IQuantity Parse(Type quantityType, string quantityString) => Parse(null, quantityType, quantityString); - - /// - /// Dynamically parse a quantity string representation. - /// - /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . - /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. - /// The parsed quantity. - /// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type. - internal static IQuantity Parse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString) - { - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) - throw new ArgumentException($"Type {quantityType} must be of type UnitsNet.IQuantity."); - - if (TryParse(formatProvider, quantityType, quantityString, out IQuantity quantity)) return quantity; - - throw new ArgumentException($"Quantity string could not be parsed to quantity {quantityType}."); - } - - /// - internal static bool TryParse(Type quantityType, string quantityString, out IQuantity quantity) => - TryParse(null, quantityType, quantityString, out quantity); - - /// - /// Try to dynamically parse a quantity string representation. - /// - /// The format provider to use for lookup. Defaults to if null. - /// Type of quantity, such as . - /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. - /// The resulting quantity if successful, otherwise default. - /// The parsed quantity. - internal static bool TryParse([CanBeNull] IFormatProvider formatProvider, Type quantityType, string quantityString, out IQuantity quantity) - { - quantity = default(IQuantity); - - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) - return false; - - var parser = QuantityParser.Default; - - if (quantityType == typeof(Acceleration)) - return parser.TryParse(quantityString, formatProvider, Acceleration.From, out quantity); - - if (quantityType == typeof(AmountOfSubstance)) - return parser.TryParse(quantityString, formatProvider, AmountOfSubstance.From, out quantity); - - if (quantityType == typeof(AmplitudeRatio)) - return parser.TryParse(quantityString, formatProvider, AmplitudeRatio.From, out quantity); - - if (quantityType == typeof(Angle)) - return parser.TryParse(quantityString, formatProvider, Angle.From, out quantity); - - if (quantityType == typeof(ApparentEnergy)) - return parser.TryParse(quantityString, formatProvider, ApparentEnergy.From, out quantity); - - if (quantityType == typeof(ApparentPower)) - return parser.TryParse(quantityString, formatProvider, ApparentPower.From, out quantity); - - if (quantityType == typeof(Area)) - return parser.TryParse(quantityString, formatProvider, Area.From, out quantity); - - if (quantityType == typeof(AreaDensity)) - return parser.TryParse(quantityString, formatProvider, AreaDensity.From, out quantity); - - if (quantityType == typeof(AreaMomentOfInertia)) - return parser.TryParse(quantityString, formatProvider, AreaMomentOfInertia.From, out quantity); - - if (quantityType == typeof(BitRate)) - return parser.TryParse(quantityString, formatProvider, BitRate.From, out quantity); - - if (quantityType == typeof(BrakeSpecificFuelConsumption)) - return parser.TryParse(quantityString, formatProvider, BrakeSpecificFuelConsumption.From, out quantity); - - if (quantityType == typeof(Capacitance)) - return parser.TryParse(quantityString, formatProvider, Capacitance.From, out quantity); - - if (quantityType == typeof(CoefficientOfThermalExpansion)) - return parser.TryParse(quantityString, formatProvider, CoefficientOfThermalExpansion.From, out quantity); - - if (quantityType == typeof(Density)) - return parser.TryParse(quantityString, formatProvider, Density.From, out quantity); - - if (quantityType == typeof(Duration)) - return parser.TryParse(quantityString, formatProvider, Duration.From, out quantity); - - if (quantityType == typeof(DynamicViscosity)) - return parser.TryParse(quantityString, formatProvider, DynamicViscosity.From, out quantity); - - if (quantityType == typeof(ElectricAdmittance)) - return parser.TryParse(quantityString, formatProvider, ElectricAdmittance.From, out quantity); - - if (quantityType == typeof(ElectricCharge)) - return parser.TryParse(quantityString, formatProvider, ElectricCharge.From, out quantity); - - if (quantityType == typeof(ElectricChargeDensity)) - return parser.TryParse(quantityString, formatProvider, ElectricChargeDensity.From, out quantity); - - if (quantityType == typeof(ElectricConductance)) - return parser.TryParse(quantityString, formatProvider, ElectricConductance.From, out quantity); - - if (quantityType == typeof(ElectricConductivity)) - return parser.TryParse(quantityString, formatProvider, ElectricConductivity.From, out quantity); - - if (quantityType == typeof(ElectricCurrent)) - return parser.TryParse(quantityString, formatProvider, ElectricCurrent.From, out quantity); - - if (quantityType == typeof(ElectricCurrentDensity)) - return parser.TryParse(quantityString, formatProvider, ElectricCurrentDensity.From, out quantity); - - if (quantityType == typeof(ElectricCurrentGradient)) - return parser.TryParse(quantityString, formatProvider, ElectricCurrentGradient.From, out quantity); - - if (quantityType == typeof(ElectricField)) - return parser.TryParse(quantityString, formatProvider, ElectricField.From, out quantity); - - if (quantityType == typeof(ElectricInductance)) - return parser.TryParse(quantityString, formatProvider, ElectricInductance.From, out quantity); - - if (quantityType == typeof(ElectricPotential)) - return parser.TryParse(quantityString, formatProvider, ElectricPotential.From, out quantity); - - if (quantityType == typeof(ElectricPotentialAc)) - return parser.TryParse(quantityString, formatProvider, ElectricPotentialAc.From, out quantity); - - if (quantityType == typeof(ElectricPotentialChangeRate)) - return parser.TryParse(quantityString, formatProvider, ElectricPotentialChangeRate.From, out quantity); - - if (quantityType == typeof(ElectricPotentialDc)) - return parser.TryParse(quantityString, formatProvider, ElectricPotentialDc.From, out quantity); - - if (quantityType == typeof(ElectricResistance)) - return parser.TryParse(quantityString, formatProvider, ElectricResistance.From, out quantity); - - if (quantityType == typeof(ElectricResistivity)) - return parser.TryParse(quantityString, formatProvider, ElectricResistivity.From, out quantity); - - if (quantityType == typeof(ElectricSurfaceChargeDensity)) - return parser.TryParse(quantityString, formatProvider, ElectricSurfaceChargeDensity.From, out quantity); - - if (quantityType == typeof(Energy)) - return parser.TryParse(quantityString, formatProvider, Energy.From, out quantity); - - if (quantityType == typeof(Entropy)) - return parser.TryParse(quantityString, formatProvider, Entropy.From, out quantity); - - if (quantityType == typeof(Force)) - return parser.TryParse(quantityString, formatProvider, Force.From, out quantity); - - if (quantityType == typeof(ForceChangeRate)) - return parser.TryParse(quantityString, formatProvider, ForceChangeRate.From, out quantity); - - if (quantityType == typeof(ForcePerLength)) - return parser.TryParse(quantityString, formatProvider, ForcePerLength.From, out quantity); - - if (quantityType == typeof(Frequency)) - return parser.TryParse(quantityString, formatProvider, Frequency.From, out quantity); - - if (quantityType == typeof(FuelEfficiency)) - return parser.TryParse(quantityString, formatProvider, FuelEfficiency.From, out quantity); - - if (quantityType == typeof(HeatFlux)) - return parser.TryParse(quantityString, formatProvider, HeatFlux.From, out quantity); - - if (quantityType == typeof(HeatTransferCoefficient)) - return parser.TryParse(quantityString, formatProvider, HeatTransferCoefficient.From, out quantity); - - if (quantityType == typeof(Illuminance)) - return parser.TryParse(quantityString, formatProvider, Illuminance.From, out quantity); - - if (quantityType == typeof(Information)) - return parser.TryParse(quantityString, formatProvider, Information.From, out quantity); - - if (quantityType == typeof(Irradiance)) - return parser.TryParse(quantityString, formatProvider, Irradiance.From, out quantity); - - if (quantityType == typeof(Irradiation)) - return parser.TryParse(quantityString, formatProvider, Irradiation.From, out quantity); - - if (quantityType == typeof(KinematicViscosity)) - return parser.TryParse(quantityString, formatProvider, KinematicViscosity.From, out quantity); - - if (quantityType == typeof(LapseRate)) - return parser.TryParse(quantityString, formatProvider, LapseRate.From, out quantity); - - if (quantityType == typeof(Length)) - return parser.TryParse(quantityString, formatProvider, Length.From, out quantity); - - if (quantityType == typeof(Level)) - return parser.TryParse(quantityString, formatProvider, Level.From, out quantity); - - if (quantityType == typeof(LinearDensity)) - return parser.TryParse(quantityString, formatProvider, LinearDensity.From, out quantity); - - if (quantityType == typeof(LinearPowerDensity)) - return parser.TryParse(quantityString, formatProvider, LinearPowerDensity.From, out quantity); - - if (quantityType == typeof(Luminosity)) - return parser.TryParse(quantityString, formatProvider, Luminosity.From, out quantity); - - if (quantityType == typeof(LuminousFlux)) - return parser.TryParse(quantityString, formatProvider, LuminousFlux.From, out quantity); - - if (quantityType == typeof(LuminousIntensity)) - return parser.TryParse(quantityString, formatProvider, LuminousIntensity.From, out quantity); - - if (quantityType == typeof(MagneticField)) - return parser.TryParse(quantityString, formatProvider, MagneticField.From, out quantity); - - if (quantityType == typeof(MagneticFlux)) - return parser.TryParse(quantityString, formatProvider, MagneticFlux.From, out quantity); - - if (quantityType == typeof(Magnetization)) - return parser.TryParse(quantityString, formatProvider, Magnetization.From, out quantity); - - if (quantityType == typeof(Mass)) - return parser.TryParse(quantityString, formatProvider, Mass.From, out quantity); - - if (quantityType == typeof(MassConcentration)) - return parser.TryParse(quantityString, formatProvider, MassConcentration.From, out quantity); - - if (quantityType == typeof(MassFlow)) - return parser.TryParse(quantityString, formatProvider, MassFlow.From, out quantity); - - if (quantityType == typeof(MassFlux)) - return parser.TryParse(quantityString, formatProvider, MassFlux.From, out quantity); - - if (quantityType == typeof(MassFraction)) - return parser.TryParse(quantityString, formatProvider, MassFraction.From, out quantity); - - if (quantityType == typeof(MassMomentOfInertia)) - return parser.TryParse(quantityString, formatProvider, MassMomentOfInertia.From, out quantity); - - if (quantityType == typeof(MolarEnergy)) - return parser.TryParse(quantityString, formatProvider, MolarEnergy.From, out quantity); - - if (quantityType == typeof(MolarEntropy)) - return parser.TryParse(quantityString, formatProvider, MolarEntropy.From, out quantity); - - if (quantityType == typeof(Molarity)) - return parser.TryParse(quantityString, formatProvider, Molarity.From, out quantity); - - if (quantityType == typeof(MolarMass)) - return parser.TryParse(quantityString, formatProvider, MolarMass.From, out quantity); - - if (quantityType == typeof(Permeability)) - return parser.TryParse(quantityString, formatProvider, Permeability.From, out quantity); - - if (quantityType == typeof(Permittivity)) - return parser.TryParse(quantityString, formatProvider, Permittivity.From, out quantity); - - if (quantityType == typeof(Power)) - return parser.TryParse(quantityString, formatProvider, Power.From, out quantity); - - if (quantityType == typeof(PowerDensity)) - return parser.TryParse(quantityString, formatProvider, PowerDensity.From, out quantity); - - if (quantityType == typeof(PowerRatio)) - return parser.TryParse(quantityString, formatProvider, PowerRatio.From, out quantity); - - if (quantityType == typeof(Pressure)) - return parser.TryParse(quantityString, formatProvider, Pressure.From, out quantity); - - if (quantityType == typeof(PressureChangeRate)) - return parser.TryParse(quantityString, formatProvider, PressureChangeRate.From, out quantity); - - if (quantityType == typeof(Ratio)) - return parser.TryParse(quantityString, formatProvider, Ratio.From, out quantity); - - if (quantityType == typeof(RatioChangeRate)) - return parser.TryParse(quantityString, formatProvider, RatioChangeRate.From, out quantity); - - if (quantityType == typeof(ReactiveEnergy)) - return parser.TryParse(quantityString, formatProvider, ReactiveEnergy.From, out quantity); - - if (quantityType == typeof(ReactivePower)) - return parser.TryParse(quantityString, formatProvider, ReactivePower.From, out quantity); - - if (quantityType == typeof(ReciprocalArea)) - return parser.TryParse(quantityString, formatProvider, ReciprocalArea.From, out quantity); - - if (quantityType == typeof(ReciprocalLength)) - return parser.TryParse(quantityString, formatProvider, ReciprocalLength.From, out quantity); - - if (quantityType == typeof(RelativeHumidity)) - return parser.TryParse(quantityString, formatProvider, RelativeHumidity.From, out quantity); - - if (quantityType == typeof(RotationalAcceleration)) - return parser.TryParse(quantityString, formatProvider, RotationalAcceleration.From, out quantity); - - if (quantityType == typeof(RotationalSpeed)) - return parser.TryParse(quantityString, formatProvider, RotationalSpeed.From, out quantity); - - if (quantityType == typeof(RotationalStiffness)) - return parser.TryParse(quantityString, formatProvider, RotationalStiffness.From, out quantity); - - if (quantityType == typeof(RotationalStiffnessPerLength)) - return parser.TryParse(quantityString, formatProvider, RotationalStiffnessPerLength.From, out quantity); - - if (quantityType == typeof(Scalar)) - return parser.TryParse(quantityString, formatProvider, Scalar.From, out quantity); - - if (quantityType == typeof(SolidAngle)) - return parser.TryParse(quantityString, formatProvider, SolidAngle.From, out quantity); - - if (quantityType == typeof(SpecificEnergy)) - return parser.TryParse(quantityString, formatProvider, SpecificEnergy.From, out quantity); - - if (quantityType == typeof(SpecificEntropy)) - return parser.TryParse(quantityString, formatProvider, SpecificEntropy.From, out quantity); - - if (quantityType == typeof(SpecificFuelConsumption)) - return parser.TryParse(quantityString, formatProvider, SpecificFuelConsumption.From, out quantity); - - if (quantityType == typeof(SpecificVolume)) - return parser.TryParse(quantityString, formatProvider, SpecificVolume.From, out quantity); - - if (quantityType == typeof(SpecificWeight)) - return parser.TryParse(quantityString, formatProvider, SpecificWeight.From, out quantity); - - if (quantityType == typeof(Speed)) - return parser.TryParse(quantityString, formatProvider, Speed.From, out quantity); - - if (quantityType == typeof(StandardVolumeFlow)) - return parser.TryParse(quantityString, formatProvider, StandardVolumeFlow.From, out quantity); - - if (quantityType == typeof(Temperature)) - return parser.TryParse(quantityString, formatProvider, Temperature.From, out quantity); - - if (quantityType == typeof(TemperatureChangeRate)) - return parser.TryParse(quantityString, formatProvider, TemperatureChangeRate.From, out quantity); - - if (quantityType == typeof(TemperatureDelta)) - return parser.TryParse(quantityString, formatProvider, TemperatureDelta.From, out quantity); - - if (quantityType == typeof(ThermalConductivity)) - return parser.TryParse(quantityString, formatProvider, ThermalConductivity.From, out quantity); - - if (quantityType == typeof(ThermalResistance)) - return parser.TryParse(quantityString, formatProvider, ThermalResistance.From, out quantity); - - if (quantityType == typeof(Torque)) - return parser.TryParse(quantityString, formatProvider, Torque.From, out quantity); - - if (quantityType == typeof(TorquePerLength)) - return parser.TryParse(quantityString, formatProvider, TorquePerLength.From, out quantity); - - if (quantityType == typeof(Turbidity)) - return parser.TryParse(quantityString, formatProvider, Turbidity.From, out quantity); - - if (quantityType == typeof(VitaminA)) - return parser.TryParse(quantityString, formatProvider, VitaminA.From, out quantity); - - if (quantityType == typeof(Volume)) - return parser.TryParse(quantityString, formatProvider, Volume.From, out quantity); - - if (quantityType == typeof(VolumeConcentration)) - return parser.TryParse(quantityString, formatProvider, VolumeConcentration.From, out quantity); - - if (quantityType == typeof(VolumeFlow)) - return parser.TryParse(quantityString, formatProvider, VolumeFlow.From, out quantity); - - if (quantityType == typeof(VolumePerLength)) - return parser.TryParse(quantityString, formatProvider, VolumePerLength.From, out quantity); - - if (quantityType == typeof(VolumetricHeatCapacity)) - return parser.TryParse(quantityString, formatProvider, VolumetricHeatCapacity.From, out quantity); - - if (quantityType == typeof(WarpingMomentOfInertia)) - return parser.TryParse(quantityString, formatProvider, WarpingMomentOfInertia.From, out quantity); - - throw new ArgumentException( - $"Type {quantityType} is not a known quantity type. Did you pass in a third-party quantity type defined outside UnitsNet library?"); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/QuantityType.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/QuantityType.g.cs deleted file mode 100644 index 1ec94a2e45..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/QuantityType.g.cs +++ /dev/null @@ -1,143 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - /// - /// Lists all generated quantities with the same name as the quantity struct type, - /// such as Length, Mass, Force etc. - /// This is useful for populating options in the UI, such as creating a generic conversion - /// tool with inputValue, quantityName, fromUnit and toUnit selectors. - /// - public enum QuantityType - { - Undefined = 0, - Acceleration, - AmountOfSubstance, - AmplitudeRatio, - Angle, - ApparentEnergy, - ApparentPower, - Area, - AreaDensity, - AreaMomentOfInertia, - BitRate, - BrakeSpecificFuelConsumption, - Capacitance, - CoefficientOfThermalExpansion, - Density, - Duration, - DynamicViscosity, - ElectricAdmittance, - ElectricCharge, - ElectricChargeDensity, - ElectricConductance, - ElectricConductivity, - ElectricCurrent, - ElectricCurrentDensity, - ElectricCurrentGradient, - ElectricField, - ElectricInductance, - ElectricPotential, - ElectricPotentialAc, - ElectricPotentialChangeRate, - ElectricPotentialDc, - ElectricResistance, - ElectricResistivity, - ElectricSurfaceChargeDensity, - Energy, - Entropy, - Force, - ForceChangeRate, - ForcePerLength, - Frequency, - FuelEfficiency, - HeatFlux, - HeatTransferCoefficient, - Illuminance, - Information, - Irradiance, - Irradiation, - KinematicViscosity, - LapseRate, - Length, - Level, - LinearDensity, - LinearPowerDensity, - Luminosity, - LuminousFlux, - LuminousIntensity, - MagneticField, - MagneticFlux, - Magnetization, - Mass, - MassConcentration, - MassFlow, - MassFlux, - MassFraction, - MassMomentOfInertia, - MolarEnergy, - MolarEntropy, - Molarity, - MolarMass, - Permeability, - Permittivity, - Power, - PowerDensity, - PowerRatio, - Pressure, - PressureChangeRate, - Ratio, - RatioChangeRate, - ReactiveEnergy, - ReactivePower, - ReciprocalArea, - ReciprocalLength, - RelativeHumidity, - RotationalAcceleration, - RotationalSpeed, - RotationalStiffness, - RotationalStiffnessPerLength, - Scalar, - SolidAngle, - SpecificEnergy, - SpecificEntropy, - SpecificFuelConsumption, - SpecificVolume, - SpecificWeight, - Speed, - StandardVolumeFlow, - Temperature, - TemperatureChangeRate, - TemperatureDelta, - ThermalConductivity, - ThermalResistance, - Torque, - TorquePerLength, - Turbidity, - VitaminA, - Volume, - VolumeConcentration, - VolumeFlow, - VolumePerLength, - VolumetricHeatCapacity, - WarpingMomentOfInertia, - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs deleted file mode 100644 index cedd8a0a84..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/UnitAbbreviationsCache.g.cs +++ /dev/null @@ -1,1722 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using UnitsNet.Units; - -// ReSharper disable RedundantCommaInArrayInitializer -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - public sealed partial class UnitAbbreviationsCache - { - private static readonly (string CultureName, Type UnitType, int UnitValue, string[] UnitAbbreviations)[] GeneratedLocalizations - = new [] - { - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.CentimeterPerSecondSquared, new string[]{"cm/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.CentimeterPerSecondSquared, new string[]{"см/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.DecimeterPerSecondSquared, new string[]{"dm/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.DecimeterPerSecondSquared, new string[]{"дм/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.FootPerSecondSquared, new string[]{"ft/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.FootPerSecondSquared, new string[]{"фут/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.InchPerSecondSquared, new string[]{"in/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.InchPerSecondSquared, new string[]{"дюйм/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.KilometerPerSecondSquared, new string[]{"km/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.KilometerPerSecondSquared, new string[]{"км/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.KnotPerHour, new string[]{"kn/h"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.KnotPerHour, new string[]{"узел/час"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.KnotPerMinute, new string[]{"kn/min"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.KnotPerMinute, new string[]{"узел/мин"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.KnotPerSecond, new string[]{"kn/s"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.KnotPerSecond, new string[]{"узел/с"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.MeterPerSecondSquared, new string[]{"m/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.MeterPerSecondSquared, new string[]{"м/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.MicrometerPerSecondSquared, new string[]{"µm/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.MicrometerPerSecondSquared, new string[]{"мкм/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.MillimeterPerSecondSquared, new string[]{"mm/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.MillimeterPerSecondSquared, new string[]{"мм/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.MillistandardGravity, new string[]{"mg"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.MillistandardGravity, new string[]{"мg"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.NanometerPerSecondSquared, new string[]{"nm/s²"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.NanometerPerSecondSquared, new string[]{"нм/с²"}), - ("en-US", typeof(AccelerationUnit), (int)AccelerationUnit.StandardGravity, new string[]{"g"}), - ("ru-RU", typeof(AccelerationUnit), (int)AccelerationUnit.StandardGravity, new string[]{"g"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Centimole, new string[]{"cmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.CentipoundMole, new string[]{"clbmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Decimole, new string[]{"dmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.DecipoundMole, new string[]{"dlbmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Kilomole, new string[]{"kmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.KilopoundMole, new string[]{"klbmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Megamole, new string[]{"Mmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Micromole, new string[]{"µmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.MicropoundMole, new string[]{"µlbmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Millimole, new string[]{"mmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.MillipoundMole, new string[]{"mlbmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Mole, new string[]{"mol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.Nanomole, new string[]{"nmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.NanopoundMole, new string[]{"nlbmol"}), - ("en-US", typeof(AmountOfSubstanceUnit), (int)AmountOfSubstanceUnit.PoundMole, new string[]{"lbmol"}), - ("en-US", typeof(AmplitudeRatioUnit), (int)AmplitudeRatioUnit.DecibelMicrovolt, new string[]{"dBµV"}), - ("en-US", typeof(AmplitudeRatioUnit), (int)AmplitudeRatioUnit.DecibelMillivolt, new string[]{"dBmV"}), - ("en-US", typeof(AmplitudeRatioUnit), (int)AmplitudeRatioUnit.DecibelUnloaded, new string[]{"dBu"}), - ("en-US", typeof(AmplitudeRatioUnit), (int)AmplitudeRatioUnit.DecibelVolt, new string[]{"dBV"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Arcminute, new string[]{"'", "arcmin", "amin", "min"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Arcsecond, new string[]{"″", "arcsec", "asec", "sec"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Centiradian, new string[]{"crad"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Centiradian, new string[]{"срад"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Deciradian, new string[]{"drad"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Deciradian, new string[]{"драд"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Degree, new string[]{"°", "deg"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Degree, new string[]{"°"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Gradian, new string[]{"g"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Gradian, new string[]{"g"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Microdegree, new string[]{"µ°", "µdeg"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Microdegree, new string[]{"мк°"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Microradian, new string[]{"µrad"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Microradian, new string[]{"мкрад"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Millidegree, new string[]{"m°", "mdeg"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Millidegree, new string[]{"м°"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Milliradian, new string[]{"mrad"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Milliradian, new string[]{"мрад"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Nanodegree, new string[]{"n°", "ndeg"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Nanodegree, new string[]{"н°"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Nanoradian, new string[]{"nrad"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Nanoradian, new string[]{"нрад"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.NatoMil, new string[]{"mil"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Radian, new string[]{"rad"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Radian, new string[]{"рад"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Revolution, new string[]{"r"}), - ("ru-RU", typeof(AngleUnit), (int)AngleUnit.Revolution, new string[]{"r"}), - ("en-US", typeof(AngleUnit), (int)AngleUnit.Tilt, new string[]{"sin(θ)"}), - ("en-US", typeof(ApparentEnergyUnit), (int)ApparentEnergyUnit.KilovoltampereHour, new string[]{"kVAh"}), - ("en-US", typeof(ApparentEnergyUnit), (int)ApparentEnergyUnit.MegavoltampereHour, new string[]{"MVAh"}), - ("en-US", typeof(ApparentEnergyUnit), (int)ApparentEnergyUnit.VoltampereHour, new string[]{"VAh"}), - ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Gigavoltampere, new string[]{"GVA"}), - ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Kilovoltampere, new string[]{"kVA"}), - ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Megavoltampere, new string[]{"MVA"}), - ("en-US", typeof(ApparentPowerUnit), (int)ApparentPowerUnit.Voltampere, new string[]{"VA"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.Acre, new string[]{"ac"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.Acre, new string[]{"акр"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.Acre, new string[]{"英亩"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.Hectare, new string[]{"ha"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.Hectare, new string[]{"га"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.Hectare, new string[]{"英亩"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"cm²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"см²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareCentimeter, new string[]{"平方厘米"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareDecimeter, new string[]{"dm²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareDecimeter, new string[]{"дм²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareDecimeter, new string[]{"平方分米"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareFoot, new string[]{"ft²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareFoot, new string[]{"фут²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareFoot, new string[]{"平方英尺"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareInch, new string[]{"in²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareInch, new string[]{"дюйм²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareInch, new string[]{"平方英寸"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareKilometer, new string[]{"km²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareKilometer, new string[]{"км²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareKilometer, new string[]{"平方公里"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareMeter, new string[]{"m²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareMeter, new string[]{"м²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareMeter, new string[]{"平方米"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareMicrometer, new string[]{"µm²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareMicrometer, new string[]{"мкм²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareMicrometer, new string[]{"平方微米"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareMile, new string[]{"mi²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareMile, new string[]{"миля²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareMile, new string[]{"平方英里"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareMillimeter, new string[]{"mm²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareMillimeter, new string[]{"мм²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareMillimeter, new string[]{"平方毫米"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareNauticalMile, new string[]{"nmi²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareNauticalMile, new string[]{"морск.миля²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareNauticalMile, new string[]{"平方海里"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.SquareYard, new string[]{"yd²"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.SquareYard, new string[]{"ярд²"}), - ("zh-CN", typeof(AreaUnit), (int)AreaUnit.SquareYard, new string[]{"平方码"}), - ("en-US", typeof(AreaUnit), (int)AreaUnit.UsSurveySquareFoot, new string[]{"ft² (US)"}), - ("ru-RU", typeof(AreaUnit), (int)AreaUnit.UsSurveySquareFoot, new string[]{"фут² (US)"}), - ("en-US", typeof(AreaDensityUnit), (int)AreaDensityUnit.KilogramPerSquareMeter, new string[]{"kg/m²"}), - ("en-US", typeof(AreaMomentOfInertiaUnit), (int)AreaMomentOfInertiaUnit.CentimeterToTheFourth, new string[]{"cm⁴", "cm^4"}), - ("en-US", typeof(AreaMomentOfInertiaUnit), (int)AreaMomentOfInertiaUnit.DecimeterToTheFourth, new string[]{"dm⁴", "dm^4"}), - ("en-US", typeof(AreaMomentOfInertiaUnit), (int)AreaMomentOfInertiaUnit.FootToTheFourth, new string[]{"ft⁴", "ft^4"}), - ("en-US", typeof(AreaMomentOfInertiaUnit), (int)AreaMomentOfInertiaUnit.InchToTheFourth, new string[]{"in⁴", "in^4"}), - ("en-US", typeof(AreaMomentOfInertiaUnit), (int)AreaMomentOfInertiaUnit.MeterToTheFourth, new string[]{"m⁴", "m^4"}), - ("en-US", typeof(AreaMomentOfInertiaUnit), (int)AreaMomentOfInertiaUnit.MillimeterToTheFourth, new string[]{"mm⁴", "mm^4"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.BitPerSecond, new string[]{"bit/s", "bps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.BytePerSecond, new string[]{"B/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.ExabitPerSecond, new string[]{"Ebit/s", "Ebps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.ExabytePerSecond, new string[]{"EB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.ExbibitPerSecond, new string[]{"Eibit/s", "Eibps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.ExbibytePerSecond, new string[]{"EiB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.GibibitPerSecond, new string[]{"Gibit/s", "Gibps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.GibibytePerSecond, new string[]{"GiB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.GigabitPerSecond, new string[]{"Gbit/s", "Gbps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.GigabytePerSecond, new string[]{"GB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.KibibitPerSecond, new string[]{"Kibit/s", "Kibps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.KibibytePerSecond, new string[]{"KiB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.KilobitPerSecond, new string[]{"kbit/s", "kbps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.KilobytePerSecond, new string[]{"kB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.MebibitPerSecond, new string[]{"Mibit/s", "Mibps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.MebibytePerSecond, new string[]{"MiB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.MegabitPerSecond, new string[]{"Mbit/s", "Mbps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.MegabytePerSecond, new string[]{"MB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.PebibitPerSecond, new string[]{"Pibit/s", "Pibps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.PebibytePerSecond, new string[]{"PiB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.PetabitPerSecond, new string[]{"Pbit/s", "Pbps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.PetabytePerSecond, new string[]{"PB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.TebibitPerSecond, new string[]{"Tibit/s", "Tibps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.TebibytePerSecond, new string[]{"TiB/s"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.TerabitPerSecond, new string[]{"Tbit/s", "Tbps"}), - ("en-US", typeof(BitRateUnit), (int)BitRateUnit.TerabytePerSecond, new string[]{"TB/s"}), - ("en-US", typeof(BrakeSpecificFuelConsumptionUnit), (int)BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, new string[]{"g/kWh"}), - ("en-US", typeof(BrakeSpecificFuelConsumptionUnit), (int)BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, new string[]{"kg/J"}), - ("en-US", typeof(BrakeSpecificFuelConsumptionUnit), (int)BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, new string[]{"lb/hph"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Farad, new string[]{"F"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Kilofarad, new string[]{"kF"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Megafarad, new string[]{"MF"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Microfarad, new string[]{"µF"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Millifarad, new string[]{"mF"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Nanofarad, new string[]{"nF"}), - ("en-US", typeof(CapacitanceUnit), (int)CapacitanceUnit.Picofarad, new string[]{"pF"}), - ("en-US", typeof(CoefficientOfThermalExpansionUnit), (int)CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, new string[]{"°C⁻¹", "1/°C"}), - ("en-US", typeof(CoefficientOfThermalExpansionUnit), (int)CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, new string[]{"°F⁻¹", "1/°F"}), - ("en-US", typeof(CoefficientOfThermalExpansionUnit), (int)CoefficientOfThermalExpansionUnit.InverseKelvin, new string[]{"K⁻¹", "1/K"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.CentigramPerDeciliter, new string[]{"cg/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.CentigramPerLiter, new string[]{"cg/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.CentigramPerMilliliter, new string[]{"cg/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.DecigramPerDeciliter, new string[]{"dg/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.DecigramPerLiter, new string[]{"dg/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.DecigramPerMilliliter, new string[]{"dg/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.GramPerCubicCentimeter, new string[]{"g/cm³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.GramPerCubicMeter, new string[]{"g/m³"}), - ("ru-RU", typeof(DensityUnit), (int)DensityUnit.GramPerCubicMeter, new string[]{"г/м³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.GramPerCubicMillimeter, new string[]{"g/mm³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.GramPerDeciliter, new string[]{"g/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.GramPerLiter, new string[]{"g/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.GramPerMilliliter, new string[]{"g/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicCentimeter, new string[]{"kg/cm³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMeter, new string[]{"kg/m³"}), - ("ru-RU", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMeter, new string[]{"кг/м³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.KilogramPerCubicMillimeter, new string[]{"kg/mm³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.KilogramPerLiter, new string[]{"kg/l"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.KilopoundPerCubicFoot, new string[]{"kip/ft³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.KilopoundPerCubicInch, new string[]{"kip/in³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MicrogramPerCubicMeter, new string[]{"µg/m³"}), - ("ru-RU", typeof(DensityUnit), (int)DensityUnit.MicrogramPerCubicMeter, new string[]{"мкг/м³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MicrogramPerDeciliter, new string[]{"µg/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MicrogramPerLiter, new string[]{"µg/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MicrogramPerMilliliter, new string[]{"µg/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MilligramPerCubicMeter, new string[]{"mg/m³"}), - ("ru-RU", typeof(DensityUnit), (int)DensityUnit.MilligramPerCubicMeter, new string[]{"мг/м³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MilligramPerDeciliter, new string[]{"mg/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MilligramPerLiter, new string[]{"mg/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.MilligramPerMilliliter, new string[]{"mg/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.NanogramPerDeciliter, new string[]{"ng/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.NanogramPerLiter, new string[]{"ng/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.NanogramPerMilliliter, new string[]{"ng/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PicogramPerDeciliter, new string[]{"pg/dl"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PicogramPerLiter, new string[]{"pg/L"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PicogramPerMilliliter, new string[]{"pg/ml"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PoundPerCubicFoot, new string[]{"lb/ft³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PoundPerCubicInch, new string[]{"lb/in³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PoundPerImperialGallon, new string[]{"ppg (imp.)"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.PoundPerUSGallon, new string[]{"ppg (U.S.)"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.SlugPerCubicFoot, new string[]{"slug/ft³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.TonnePerCubicCentimeter, new string[]{"t/cm³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.TonnePerCubicMeter, new string[]{"t/m³"}), - ("en-US", typeof(DensityUnit), (int)DensityUnit.TonnePerCubicMillimeter, new string[]{"t/mm³"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Day, new string[]{"d", "day", "days"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Day, new string[]{"сут", "д"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Hour, new string[]{"h", "hr", "hrs", "hour", "hours"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Hour, new string[]{"ч", "час"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Microsecond, new string[]{"µs", "µsec", "µsecs", "µsecond", "µseconds"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Microsecond, new string[]{"мксек", "мкс"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Millisecond, new string[]{"ms", "msec", "msecs", "msecond", "mseconds"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Millisecond, new string[]{"мсек", "мс"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Minute, new string[]{"m", "min", "minute", "minutes"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Minute, new string[]{"мин"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Month30, new string[]{"mo", "month", "months"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Month30, new string[]{"месяц"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Nanosecond, new string[]{"ns", "nsec", "nsecs", "nsecond", "nseconds"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Nanosecond, new string[]{"нсек", "нс"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Second, new string[]{"s", "sec", "secs", "second", "seconds"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Second, new string[]{"сек", "с"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Week, new string[]{"wk", "week", "weeks"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Week, new string[]{"нед"}), - ("en-US", typeof(DurationUnit), (int)DurationUnit.Year365, new string[]{"yr", "year", "years"}), - ("ru-RU", typeof(DurationUnit), (int)DurationUnit.Year365, new string[]{"год"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.Centipoise, new string[]{"cP"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.MicropascalSecond, new string[]{"µPa·s", "µPaS"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.MillipascalSecond, new string[]{"mPa·s", "mPaS"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.NewtonSecondPerMeterSquared, new string[]{"Ns/m²"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.PascalSecond, new string[]{"Pa·s", "PaS"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.Poise, new string[]{"P"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.PoundForceSecondPerSquareFoot, new string[]{"lbf·s/ft²"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.PoundForceSecondPerSquareInch, new string[]{"lbf·s/in²"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.PoundPerFootSecond, new string[]{"lb/ft·s"}), - ("en-US", typeof(DynamicViscosityUnit), (int)DynamicViscosityUnit.Reyn, new string[]{"reyn"}), - ("en-US", typeof(ElectricAdmittanceUnit), (int)ElectricAdmittanceUnit.Microsiemens, new string[]{"µS"}), - ("en-US", typeof(ElectricAdmittanceUnit), (int)ElectricAdmittanceUnit.Millisiemens, new string[]{"mS"}), - ("en-US", typeof(ElectricAdmittanceUnit), (int)ElectricAdmittanceUnit.Nanosiemens, new string[]{"nS"}), - ("en-US", typeof(ElectricAdmittanceUnit), (int)ElectricAdmittanceUnit.Siemens, new string[]{"S"}), - ("en-US", typeof(ElectricChargeUnit), (int)ElectricChargeUnit.AmpereHour, new string[]{"A-h", "Ah"}), - ("en-US", typeof(ElectricChargeUnit), (int)ElectricChargeUnit.Coulomb, new string[]{"C"}), - ("en-US", typeof(ElectricChargeUnit), (int)ElectricChargeUnit.KiloampereHour, new string[]{"kA-h", "kAh"}), - ("en-US", typeof(ElectricChargeUnit), (int)ElectricChargeUnit.MegaampereHour, new string[]{"MA-h", "MAh"}), - ("en-US", typeof(ElectricChargeUnit), (int)ElectricChargeUnit.MilliampereHour, new string[]{"mA-h", "mAh"}), - ("en-US", typeof(ElectricChargeDensityUnit), (int)ElectricChargeDensityUnit.CoulombPerCubicMeter, new string[]{"C/m³"}), - ("en-US", typeof(ElectricConductanceUnit), (int)ElectricConductanceUnit.Microsiemens, new string[]{"µS"}), - ("en-US", typeof(ElectricConductanceUnit), (int)ElectricConductanceUnit.Millisiemens, new string[]{"mS"}), - ("en-US", typeof(ElectricConductanceUnit), (int)ElectricConductanceUnit.Siemens, new string[]{"S"}), - ("en-US", typeof(ElectricConductivityUnit), (int)ElectricConductivityUnit.SiemensPerFoot, new string[]{"S/ft"}), - ("en-US", typeof(ElectricConductivityUnit), (int)ElectricConductivityUnit.SiemensPerInch, new string[]{"S/in"}), - ("en-US", typeof(ElectricConductivityUnit), (int)ElectricConductivityUnit.SiemensPerMeter, new string[]{"S/m"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Ampere, new string[]{"A"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Centiampere, new string[]{"cA"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Kiloampere, new string[]{"kA"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Megaampere, new string[]{"MA"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Microampere, new string[]{"µA"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Milliampere, new string[]{"mA"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Nanoampere, new string[]{"nA"}), - ("en-US", typeof(ElectricCurrentUnit), (int)ElectricCurrentUnit.Picoampere, new string[]{"pA"}), - ("en-US", typeof(ElectricCurrentDensityUnit), (int)ElectricCurrentDensityUnit.AmperePerSquareFoot, new string[]{"A/ft²"}), - ("en-US", typeof(ElectricCurrentDensityUnit), (int)ElectricCurrentDensityUnit.AmperePerSquareInch, new string[]{"A/in²"}), - ("en-US", typeof(ElectricCurrentDensityUnit), (int)ElectricCurrentDensityUnit.AmperePerSquareMeter, new string[]{"A/m²"}), - ("en-US", typeof(ElectricCurrentGradientUnit), (int)ElectricCurrentGradientUnit.AmperePerMicrosecond, new string[]{"A/μs"}), - ("en-US", typeof(ElectricCurrentGradientUnit), (int)ElectricCurrentGradientUnit.AmperePerMillisecond, new string[]{"A/ms"}), - ("en-US", typeof(ElectricCurrentGradientUnit), (int)ElectricCurrentGradientUnit.AmperePerNanosecond, new string[]{"A/ns"}), - ("en-US", typeof(ElectricCurrentGradientUnit), (int)ElectricCurrentGradientUnit.AmperePerSecond, new string[]{"A/s"}), - ("en-US", typeof(ElectricFieldUnit), (int)ElectricFieldUnit.VoltPerMeter, new string[]{"V/m"}), - ("en-US", typeof(ElectricInductanceUnit), (int)ElectricInductanceUnit.Henry, new string[]{"H"}), - ("en-US", typeof(ElectricInductanceUnit), (int)ElectricInductanceUnit.Microhenry, new string[]{"µH"}), - ("en-US", typeof(ElectricInductanceUnit), (int)ElectricInductanceUnit.Millihenry, new string[]{"mH"}), - ("en-US", typeof(ElectricInductanceUnit), (int)ElectricInductanceUnit.Nanohenry, new string[]{"nH"}), - ("en-US", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Kilovolt, new string[]{"kV"}), - ("ru-RU", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Kilovolt, new string[]{"кВ"}), - ("en-US", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Megavolt, new string[]{"MV"}), - ("ru-RU", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Megavolt, new string[]{"МВ"}), - ("en-US", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Microvolt, new string[]{"µV"}), - ("ru-RU", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Microvolt, new string[]{"мкВ"}), - ("en-US", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Millivolt, new string[]{"mV"}), - ("ru-RU", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Millivolt, new string[]{"мВ"}), - ("en-US", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Volt, new string[]{"V"}), - ("ru-RU", typeof(ElectricPotentialUnit), (int)ElectricPotentialUnit.Volt, new string[]{"В"}), - ("en-US", typeof(ElectricPotentialAcUnit), (int)ElectricPotentialAcUnit.KilovoltAc, new string[]{"kVac"}), - ("en-US", typeof(ElectricPotentialAcUnit), (int)ElectricPotentialAcUnit.MegavoltAc, new string[]{"MVac"}), - ("en-US", typeof(ElectricPotentialAcUnit), (int)ElectricPotentialAcUnit.MicrovoltAc, new string[]{"µVac"}), - ("en-US", typeof(ElectricPotentialAcUnit), (int)ElectricPotentialAcUnit.MillivoltAc, new string[]{"mVac"}), - ("en-US", typeof(ElectricPotentialAcUnit), (int)ElectricPotentialAcUnit.VoltAc, new string[]{"Vac"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.KilovoltPerHour, new string[]{"kV/h"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, new string[]{"kV/μs"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.KilovoltPerMinute, new string[]{"kV/min"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.KilovoltPerSecond, new string[]{"kV/s"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MegavoltPerHour, new string[]{"MV/h"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, new string[]{"MV/μs"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MegavoltPerMinute, new string[]{"MV/min"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MegavoltPerSecond, new string[]{"MV/s"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MicrovoltPerHour, new string[]{"µV/h"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, new string[]{"µV/μs"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MicrovoltPerMinute, new string[]{"µV/min"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MicrovoltPerSecond, new string[]{"µV/s"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MillivoltPerHour, new string[]{"mV/h"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, new string[]{"mV/μs"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MillivoltPerMinute, new string[]{"mV/min"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.MillivoltPerSecond, new string[]{"mV/s"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.VoltPerHour, new string[]{"V/h"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.VoltPerMicrosecond, new string[]{"V/μs"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.VoltPerMinute, new string[]{"V/min"}), - ("en-US", typeof(ElectricPotentialChangeRateUnit), (int)ElectricPotentialChangeRateUnit.VoltPerSecond, new string[]{"V/s"}), - ("en-US", typeof(ElectricPotentialDcUnit), (int)ElectricPotentialDcUnit.KilovoltDc, new string[]{"kVdc"}), - ("en-US", typeof(ElectricPotentialDcUnit), (int)ElectricPotentialDcUnit.MegavoltDc, new string[]{"MVdc"}), - ("en-US", typeof(ElectricPotentialDcUnit), (int)ElectricPotentialDcUnit.MicrovoltDc, new string[]{"µVdc"}), - ("en-US", typeof(ElectricPotentialDcUnit), (int)ElectricPotentialDcUnit.MillivoltDc, new string[]{"mVdc"}), - ("en-US", typeof(ElectricPotentialDcUnit), (int)ElectricPotentialDcUnit.VoltDc, new string[]{"Vdc"}), - ("en-US", typeof(ElectricResistanceUnit), (int)ElectricResistanceUnit.Gigaohm, new string[]{"GΩ"}), - ("en-US", typeof(ElectricResistanceUnit), (int)ElectricResistanceUnit.Kiloohm, new string[]{"kΩ"}), - ("en-US", typeof(ElectricResistanceUnit), (int)ElectricResistanceUnit.Megaohm, new string[]{"MΩ"}), - ("en-US", typeof(ElectricResistanceUnit), (int)ElectricResistanceUnit.Microohm, new string[]{"µΩ"}), - ("en-US", typeof(ElectricResistanceUnit), (int)ElectricResistanceUnit.Milliohm, new string[]{"mΩ"}), - ("en-US", typeof(ElectricResistanceUnit), (int)ElectricResistanceUnit.Ohm, new string[]{"Ω"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.KiloohmCentimeter, new string[]{"kΩ·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.KiloohmMeter, new string[]{"kΩ·m"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.MegaohmCentimeter, new string[]{"MΩ·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.MegaohmMeter, new string[]{"MΩ·m"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.MicroohmCentimeter, new string[]{"µΩ·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.MicroohmMeter, new string[]{"µΩ·m"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.MilliohmCentimeter, new string[]{"mΩ·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.MilliohmMeter, new string[]{"mΩ·m"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.NanoohmCentimeter, new string[]{"nΩ·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.NanoohmMeter, new string[]{"nΩ·m"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.OhmCentimeter, new string[]{"Ω·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.OhmMeter, new string[]{"Ω·m"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.PicoohmCentimeter, new string[]{"pΩ·cm"}), - ("en-US", typeof(ElectricResistivityUnit), (int)ElectricResistivityUnit.PicoohmMeter, new string[]{"pΩ·m"}), - ("en-US", typeof(ElectricSurfaceChargeDensityUnit), (int)ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, new string[]{"C/cm²"}), - ("en-US", typeof(ElectricSurfaceChargeDensityUnit), (int)ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, new string[]{"C/in²"}), - ("en-US", typeof(ElectricSurfaceChargeDensityUnit), (int)ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, new string[]{"C/m²"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.BritishThermalUnit, new string[]{"BTU"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Calorie, new string[]{"cal"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.DecathermEc, new string[]{"Dth (E.C.)"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.DecathermEc, new string[]{"Европейский декатерм"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.DecathermImperial, new string[]{"Dth (imp.)"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.DecathermImperial, new string[]{"Английский декатерм"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.DecathermUs, new string[]{"Dth (U.S.)"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.DecathermUs, new string[]{"Американский декатерм"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.ElectronVolt, new string[]{"eV"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.ElectronVolt, new string[]{"эВ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Erg, new string[]{"erg"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.FootPound, new string[]{"ft·lb"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.GigabritishThermalUnit, new string[]{"GBTU"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.GigaelectronVolt, new string[]{"GeV"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.GigaelectronVolt, new string[]{"ГэВ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Gigajoule, new string[]{"GJ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.GigawattDay, new string[]{"GWd"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.GigawattDay, new string[]{"ГВт/д"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.GigawattHour, new string[]{"GWh"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.GigawattHour, new string[]{"ГВт/ч"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.HorsepowerHour, new string[]{"hp·h"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Joule, new string[]{"J"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.KilobritishThermalUnit, new string[]{"kBTU"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Kilocalorie, new string[]{"kcal"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.KiloelectronVolt, new string[]{"keV"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.KiloelectronVolt, new string[]{"кэВ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Kilojoule, new string[]{"kJ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.KilowattDay, new string[]{"kWd"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.KilowattDay, new string[]{"кВт/д"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.KilowattHour, new string[]{"kWh"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.KilowattHour, new string[]{"кВт/ч"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.MegabritishThermalUnit, new string[]{"MBTU"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Megacalorie, new string[]{"Mcal"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.MegaelectronVolt, new string[]{"MeV"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.MegaelectronVolt, new string[]{"МэВ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Megajoule, new string[]{"MJ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.MegawattDay, new string[]{"MWd"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.MegawattDay, new string[]{"МВт/д"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.MegawattHour, new string[]{"MWh"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.MegawattHour, new string[]{"МВт/ч"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.Millijoule, new string[]{"mJ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.TeraelectronVolt, new string[]{"TeV"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.TeraelectronVolt, new string[]{"ТэВ"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.TerawattDay, new string[]{"TWd"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.TerawattDay, new string[]{"ТВт/д"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.TerawattHour, new string[]{"TWh"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.TerawattHour, new string[]{"ТВт/ч"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.ThermEc, new string[]{"th (E.C.)"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.ThermEc, new string[]{"Европейский терм"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.ThermImperial, new string[]{"th (imp.)"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.ThermImperial, new string[]{"Английский терм"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.ThermUs, new string[]{"th (U.S.)"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.ThermUs, new string[]{"Американский терм"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.WattDay, new string[]{"Wd"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.WattDay, new string[]{"Вт/д"}), - ("en-US", typeof(EnergyUnit), (int)EnergyUnit.WattHour, new string[]{"Wh"}), - ("ru-RU", typeof(EnergyUnit), (int)EnergyUnit.WattHour, new string[]{"Вт/ч"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.CaloriePerKelvin, new string[]{"cal/K"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.JoulePerDegreeCelsius, new string[]{"J/C"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.JoulePerKelvin, new string[]{"J/K"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.KilocaloriePerKelvin, new string[]{"kcal/K"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.KilojoulePerDegreeCelsius, new string[]{"kJ/C"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.KilojoulePerKelvin, new string[]{"kJ/K"}), - ("en-US", typeof(EntropyUnit), (int)EntropyUnit.MegajoulePerKelvin, new string[]{"MJ/K"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Decanewton, new string[]{"daN"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Decanewton, new string[]{"даН"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Dyn, new string[]{"dyn"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Dyn, new string[]{"дин"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.KilogramForce, new string[]{"kgf"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.KilogramForce, new string[]{"кгс"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Kilonewton, new string[]{"kN"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Kilonewton, new string[]{"кН"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.KiloPond, new string[]{"kp"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.KiloPond, new string[]{"кгс"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.KilopoundForce, new string[]{"kipf", "kip", "k"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.KilopoundForce, new string[]{"кипф", "койка", "К"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Meganewton, new string[]{"MN"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Meganewton, new string[]{"МН"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Micronewton, new string[]{"µN"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Micronewton, new string[]{"мкН"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Millinewton, new string[]{"mN"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Millinewton, new string[]{"мН"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Newton, new string[]{"N"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Newton, new string[]{"Н"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.OunceForce, new string[]{"ozf"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.Poundal, new string[]{"pdl"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.Poundal, new string[]{"паундаль"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.PoundForce, new string[]{"lbf"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.PoundForce, new string[]{"фунт-сила"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.ShortTonForce, new string[]{"tf (short)", "t (US)f", "short tons-force"}), - ("en-US", typeof(ForceUnit), (int)ForceUnit.TonneForce, new string[]{"tf", "Ton"}), - ("ru-RU", typeof(ForceUnit), (int)ForceUnit.TonneForce, new string[]{"тс"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.CentinewtonPerSecond, new string[]{"cN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.DecanewtonPerMinute, new string[]{"daN/min"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.DecanewtonPerSecond, new string[]{"daN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.DecinewtonPerSecond, new string[]{"dN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.KilonewtonPerMinute, new string[]{"kN/min"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.KilonewtonPerSecond, new string[]{"kN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.KilopoundForcePerMinute, new string[]{"kipf/min", "kip/min", "k/min"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.KilopoundForcePerSecond, new string[]{"kipf/s", "kip/s", "k/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.MicronewtonPerSecond, new string[]{"µN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.MillinewtonPerSecond, new string[]{"mN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.NanonewtonPerSecond, new string[]{"nN/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.NewtonPerMinute, new string[]{"N/min"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.NewtonPerSecond, new string[]{"N/s"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.PoundForcePerMinute, new string[]{"lbf/min"}), - ("en-US", typeof(ForceChangeRateUnit), (int)ForceChangeRateUnit.PoundForcePerSecond, new string[]{"lbf/s"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.CentinewtonPerCentimeter, new string[]{"cN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.CentinewtonPerMeter, new string[]{"cN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.CentinewtonPerMillimeter, new string[]{"cN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.DecanewtonPerCentimeter, new string[]{"daN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.DecanewtonPerMeter, new string[]{"daN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.DecanewtonPerMillimeter, new string[]{"daN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.DecinewtonPerCentimeter, new string[]{"dN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.DecinewtonPerMeter, new string[]{"dN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.DecinewtonPerMillimeter, new string[]{"dN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilogramForcePerCentimeter, new string[]{"kgf/cm"}), - ("ru-RU", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilogramForcePerCentimeter, new string[]{"кгс/см"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilogramForcePerMeter, new string[]{"kgf/m"}), - ("ru-RU", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilogramForcePerMeter, new string[]{"кгс/м"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilogramForcePerMillimeter, new string[]{"kgf/mm"}), - ("ru-RU", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilogramForcePerMillimeter, new string[]{"кгс/мм"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilonewtonPerCentimeter, new string[]{"kN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilonewtonPerMeter, new string[]{"kN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilonewtonPerMillimeter, new string[]{"kN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilopoundForcePerFoot, new string[]{"kipf/ft", "kip/ft", "k/ft"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.KilopoundForcePerInch, new string[]{"kipf/in", "kip/in", "k/in"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MeganewtonPerCentimeter, new string[]{"MN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MeganewtonPerMeter, new string[]{"MN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MeganewtonPerMillimeter, new string[]{"MN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MicronewtonPerCentimeter, new string[]{"µN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MicronewtonPerMeter, new string[]{"µN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MicronewtonPerMillimeter, new string[]{"µN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MillinewtonPerCentimeter, new string[]{"mN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MillinewtonPerMeter, new string[]{"mN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.MillinewtonPerMillimeter, new string[]{"mN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.NanonewtonPerCentimeter, new string[]{"nN/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.NanonewtonPerMeter, new string[]{"nN/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.NanonewtonPerMillimeter, new string[]{"nN/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.NewtonPerCentimeter, new string[]{"N/cm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.NewtonPerMeter, new string[]{"N/m"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.NewtonPerMillimeter, new string[]{"N/mm"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.PoundForcePerFoot, new string[]{"lbf/ft"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.PoundForcePerInch, new string[]{"lbf/in"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.PoundForcePerYard, new string[]{"lbf/yd"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.TonneForcePerCentimeter, new string[]{"tf/cm"}), - ("ru-RU", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.TonneForcePerCentimeter, new string[]{"тс/см"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.TonneForcePerMeter, new string[]{"tf/m"}), - ("ru-RU", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.TonneForcePerMeter, new string[]{"тс/м"}), - ("en-US", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.TonneForcePerMillimeter, new string[]{"tf/mm"}), - ("ru-RU", typeof(ForcePerLengthUnit), (int)ForcePerLengthUnit.TonneForcePerMillimeter, new string[]{"тс/мм"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.BeatPerMinute, new string[]{"bpm"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.BUnit, new string[]{"B Units"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.CyclePerHour, new string[]{"cph"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.CyclePerMinute, new string[]{"cpm"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.Gigahertz, new string[]{"GHz"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.Gigahertz, new string[]{"ГГц"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.Hertz, new string[]{"Hz"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.Hertz, new string[]{"Гц"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.Kilohertz, new string[]{"kHz"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.Kilohertz, new string[]{"кГц"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.Megahertz, new string[]{"MHz"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.Megahertz, new string[]{"МГц"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.PerSecond, new string[]{"s⁻¹"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.PerSecond, new string[]{"с⁻¹"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.RadianPerSecond, new string[]{"rad/s"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.RadianPerSecond, new string[]{"рад/с"}), - ("en-US", typeof(FrequencyUnit), (int)FrequencyUnit.Terahertz, new string[]{"THz"}), - ("ru-RU", typeof(FrequencyUnit), (int)FrequencyUnit.Terahertz, new string[]{"ТГц"}), - ("en-US", typeof(FuelEfficiencyUnit), (int)FuelEfficiencyUnit.KilometerPerLiter, new string[]{"km/L"}), - ("en-US", typeof(FuelEfficiencyUnit), (int)FuelEfficiencyUnit.LiterPer100Kilometers, new string[]{"L/100km"}), - ("en-US", typeof(FuelEfficiencyUnit), (int)FuelEfficiencyUnit.MilePerUkGallon, new string[]{"mpg (imp.)"}), - ("en-US", typeof(FuelEfficiencyUnit), (int)FuelEfficiencyUnit.MilePerUsGallon, new string[]{"mpg (U.S.)"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.BtuPerHourSquareFoot, new string[]{"BTU/h·ft²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.BtuPerMinuteSquareFoot, new string[]{"BTU/min·ft²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.BtuPerSecondSquareFoot, new string[]{"BTU/s·ft²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.BtuPerSecondSquareInch, new string[]{"BTU/s·in²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.CaloriePerSecondSquareCentimeter, new string[]{"cal/s·cm²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.CentiwattPerSquareMeter, new string[]{"cW/m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.DeciwattPerSquareMeter, new string[]{"dW/m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.KilocaloriePerHourSquareMeter, new string[]{"kcal/h·m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, new string[]{"kcal/s·cm²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.KilowattPerSquareMeter, new string[]{"kW/m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.MicrowattPerSquareMeter, new string[]{"µW/m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.MilliwattPerSquareMeter, new string[]{"mW/m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.NanowattPerSquareMeter, new string[]{"nW/m²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.PoundForcePerFootSecond, new string[]{"lbf/(ft·s)"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.PoundPerSecondCubed, new string[]{"lb/s³", "lbm/s³"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.WattPerSquareFoot, new string[]{"W/ft²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.WattPerSquareInch, new string[]{"W/in²"}), - ("en-US", typeof(HeatFluxUnit), (int)HeatFluxUnit.WattPerSquareMeter, new string[]{"W/m²"}), - ("en-US", typeof(HeatTransferCoefficientUnit), (int)HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, new string[]{"Btu/ft²·hr·°F"}), - ("en-US", typeof(HeatTransferCoefficientUnit), (int)HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, new string[]{"W/m²·°C"}), - ("en-US", typeof(HeatTransferCoefficientUnit), (int)HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, new string[]{"W/m²·K"}), - ("en-US", typeof(IlluminanceUnit), (int)IlluminanceUnit.Kilolux, new string[]{"klx"}), - ("en-US", typeof(IlluminanceUnit), (int)IlluminanceUnit.Lux, new string[]{"lx"}), - ("en-US", typeof(IlluminanceUnit), (int)IlluminanceUnit.Megalux, new string[]{"Mlx"}), - ("en-US", typeof(IlluminanceUnit), (int)IlluminanceUnit.Millilux, new string[]{"mlx"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Bit, new string[]{"b"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Byte, new string[]{"B"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Exabit, new string[]{"Eb"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Exabyte, new string[]{"EB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Exbibit, new string[]{"Eib"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Exbibyte, new string[]{"EiB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Gibibit, new string[]{"Gib"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Gibibyte, new string[]{"GiB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Gigabit, new string[]{"Gb"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Gigabyte, new string[]{"GB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Kibibit, new string[]{"Kib"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Kibibyte, new string[]{"KiB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Kilobit, new string[]{"kb"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Kilobyte, new string[]{"kB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Mebibit, new string[]{"Mib"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Mebibyte, new string[]{"MiB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Megabit, new string[]{"Mb"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Megabyte, new string[]{"MB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Pebibit, new string[]{"Pib"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Pebibyte, new string[]{"PiB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Petabit, new string[]{"Pb"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Petabyte, new string[]{"PB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Tebibit, new string[]{"Tib"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Tebibyte, new string[]{"TiB"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Terabit, new string[]{"Tb"}), - ("en-US", typeof(InformationUnit), (int)InformationUnit.Terabyte, new string[]{"TB"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.KilowattPerSquareCentimeter, new string[]{"kW/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.KilowattPerSquareMeter, new string[]{"kW/m²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.MegawattPerSquareCentimeter, new string[]{"MW/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.MegawattPerSquareMeter, new string[]{"MW/m²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.MicrowattPerSquareCentimeter, new string[]{"µW/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.MicrowattPerSquareMeter, new string[]{"µW/m²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.MilliwattPerSquareCentimeter, new string[]{"mW/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.MilliwattPerSquareMeter, new string[]{"mW/m²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.NanowattPerSquareCentimeter, new string[]{"nW/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.NanowattPerSquareMeter, new string[]{"nW/m²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.PicowattPerSquareCentimeter, new string[]{"pW/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.PicowattPerSquareMeter, new string[]{"pW/m²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.WattPerSquareCentimeter, new string[]{"W/cm²"}), - ("en-US", typeof(IrradianceUnit), (int)IrradianceUnit.WattPerSquareMeter, new string[]{"W/m²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.JoulePerSquareCentimeter, new string[]{"J/cm²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.JoulePerSquareMeter, new string[]{"J/m²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.JoulePerSquareMillimeter, new string[]{"J/mm²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.KilojoulePerSquareMeter, new string[]{"kJ/m²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.KilowattHourPerSquareMeter, new string[]{"kWh/m²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.MillijoulePerSquareCentimeter, new string[]{"mJ/cm²"}), - ("en-US", typeof(IrradiationUnit), (int)IrradiationUnit.WattHourPerSquareMeter, new string[]{"Wh/m²"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Centistokes, new string[]{"cSt"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Centistokes, new string[]{"сСт"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Decistokes, new string[]{"dSt"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Decistokes, new string[]{"дСт"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Kilostokes, new string[]{"kSt"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Kilostokes, new string[]{"кСт"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Microstokes, new string[]{"µSt"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Microstokes, new string[]{"мкСт"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Millistokes, new string[]{"mSt"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Millistokes, new string[]{"мСт"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Nanostokes, new string[]{"nSt"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Nanostokes, new string[]{"нСт"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.SquareFootPerSecond, new string[]{"ft²/s"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.SquareMeterPerSecond, new string[]{"m²/s"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.SquareMeterPerSecond, new string[]{"м²/с"}), - ("en-US", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Stokes, new string[]{"St"}), - ("ru-RU", typeof(KinematicViscosityUnit), (int)KinematicViscosityUnit.Stokes, new string[]{"Ст"}), - ("en-US", typeof(LapseRateUnit), (int)LapseRateUnit.DegreeCelsiusPerKilometer, new string[]{"∆°C/km"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.AstronomicalUnit, new string[]{"au", "ua"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Centimeter, new string[]{"cm"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Centimeter, new string[]{"см"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Centimeter, new string[]{"厘米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Chain, new string[]{"ch"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Decimeter, new string[]{"dm"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Decimeter, new string[]{"дм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Decimeter, new string[]{"分米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.DtpPica, new string[]{"pica"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.DtpPoint, new string[]{"pt"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Fathom, new string[]{"fathom"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Foot, new string[]{"ft", "'", "′"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Foot, new string[]{"фут"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Foot, new string[]{"英尺"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Hand, new string[]{"h", "hh"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Hectometer, new string[]{"hm"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Hectometer, new string[]{"гм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Hectometer, new string[]{"百米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Inch, new string[]{"in", "\"", "″"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Inch, new string[]{"дюйм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Inch, new string[]{"英寸"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.KilolightYear, new string[]{"kly"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Kilometer, new string[]{"km"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Kilometer, new string[]{"км"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Kilometer, new string[]{"千米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Kiloparsec, new string[]{"kpc"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.LightYear, new string[]{"ly"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.MegalightYear, new string[]{"Mly"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Megaparsec, new string[]{"Mpc"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Meter, new string[]{"m"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Meter, new string[]{"м"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Meter, new string[]{"米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Microinch, new string[]{"µin"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Microinch, new string[]{"микродюйм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Microinch, new string[]{"微英寸"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Micrometer, new string[]{"µm"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Micrometer, new string[]{"мкм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Micrometer, new string[]{"微米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Mil, new string[]{"mil"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Mil, new string[]{"мил"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Mil, new string[]{"密耳"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Mile, new string[]{"mi"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Mile, new string[]{"миля"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Mile, new string[]{"英里"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Millimeter, new string[]{"mm"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Millimeter, new string[]{"мм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Millimeter, new string[]{"毫米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Nanometer, new string[]{"nm"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Nanometer, new string[]{"нм"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Nanometer, new string[]{"纳米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.NauticalMile, new string[]{"NM"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.NauticalMile, new string[]{"мил"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.NauticalMile, new string[]{"纳米"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Parsec, new string[]{"pc"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.PrinterPica, new string[]{"pica"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.PrinterPoint, new string[]{"pt"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Shackle, new string[]{"shackle"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.SolarRadius, new string[]{"R⊙"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Twip, new string[]{"twip"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.UsSurveyFoot, new string[]{"ftUS"}), - ("en-US", typeof(LengthUnit), (int)LengthUnit.Yard, new string[]{"yd"}), - ("ru-RU", typeof(LengthUnit), (int)LengthUnit.Yard, new string[]{"ярд"}), - ("zh-CN", typeof(LengthUnit), (int)LengthUnit.Yard, new string[]{"码"}), - ("en-US", typeof(LevelUnit), (int)LevelUnit.Decibel, new string[]{"dB"}), - ("en-US", typeof(LevelUnit), (int)LevelUnit.Neper, new string[]{"Np"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.GramPerCentimeter, new string[]{"g/cm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.GramPerMeter, new string[]{"g/m"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.GramPerMillimeter, new string[]{"g/mm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.KilogramPerCentimeter, new string[]{"kg/cm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.KilogramPerMeter, new string[]{"kg/m"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.KilogramPerMillimeter, new string[]{"kg/mm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.MicrogramPerCentimeter, new string[]{"µg/cm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.MicrogramPerMeter, new string[]{"µg/m"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.MicrogramPerMillimeter, new string[]{"µg/mm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.MilligramPerCentimeter, new string[]{"mg/cm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.MilligramPerMeter, new string[]{"mg/m"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.MilligramPerMillimeter, new string[]{"mg/mm"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.PoundPerFoot, new string[]{"lb/ft"}), - ("en-US", typeof(LinearDensityUnit), (int)LinearDensityUnit.PoundPerInch, new string[]{"lb/in"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.GigawattPerCentimeter, new string[]{"GW/cm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.GigawattPerFoot, new string[]{"GW/ft"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.GigawattPerInch, new string[]{"GW/in"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.GigawattPerMeter, new string[]{"GW/m"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.GigawattPerMillimeter, new string[]{"GW/mm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.KilowattPerCentimeter, new string[]{"kW/cm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.KilowattPerFoot, new string[]{"kW/ft"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.KilowattPerInch, new string[]{"kW/in"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.KilowattPerMeter, new string[]{"kW/m"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.KilowattPerMillimeter, new string[]{"kW/mm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MegawattPerCentimeter, new string[]{"MW/cm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MegawattPerFoot, new string[]{"MW/ft"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MegawattPerInch, new string[]{"MW/in"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MegawattPerMeter, new string[]{"MW/m"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MegawattPerMillimeter, new string[]{"MW/mm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MilliwattPerCentimeter, new string[]{"mW/cm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MilliwattPerFoot, new string[]{"mW/ft"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MilliwattPerInch, new string[]{"mW/in"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MilliwattPerMeter, new string[]{"mW/m"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.MilliwattPerMillimeter, new string[]{"mW/mm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.WattPerCentimeter, new string[]{"W/cm"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.WattPerFoot, new string[]{"W/ft"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.WattPerInch, new string[]{"W/in"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.WattPerMeter, new string[]{"W/m"}), - ("en-US", typeof(LinearPowerDensityUnit), (int)LinearPowerDensityUnit.WattPerMillimeter, new string[]{"W/mm"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Decawatt, new string[]{"daW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Deciwatt, new string[]{"dW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Femtowatt, new string[]{"fW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Gigawatt, new string[]{"GW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Kilowatt, new string[]{"kW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Megawatt, new string[]{"MW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Microwatt, new string[]{"µW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Milliwatt, new string[]{"mW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Nanowatt, new string[]{"nW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Petawatt, new string[]{"PW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Picowatt, new string[]{"pW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.SolarLuminosity, new string[]{"L⊙"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Terawatt, new string[]{"TW"}), - ("en-US", typeof(LuminosityUnit), (int)LuminosityUnit.Watt, new string[]{"W"}), - ("en-US", typeof(LuminousFluxUnit), (int)LuminousFluxUnit.Lumen, new string[]{"lm"}), - ("en-US", typeof(LuminousIntensityUnit), (int)LuminousIntensityUnit.Candela, new string[]{"cd"}), - ("en-US", typeof(MagneticFieldUnit), (int)MagneticFieldUnit.Gauss, new string[]{"G"}), - ("en-US", typeof(MagneticFieldUnit), (int)MagneticFieldUnit.Microtesla, new string[]{"µT"}), - ("en-US", typeof(MagneticFieldUnit), (int)MagneticFieldUnit.Milligauss, new string[]{"mG"}), - ("en-US", typeof(MagneticFieldUnit), (int)MagneticFieldUnit.Millitesla, new string[]{"mT"}), - ("en-US", typeof(MagneticFieldUnit), (int)MagneticFieldUnit.Nanotesla, new string[]{"nT"}), - ("en-US", typeof(MagneticFieldUnit), (int)MagneticFieldUnit.Tesla, new string[]{"T"}), - ("en-US", typeof(MagneticFluxUnit), (int)MagneticFluxUnit.Weber, new string[]{"Wb"}), - ("en-US", typeof(MagnetizationUnit), (int)MagnetizationUnit.AmperePerMeter, new string[]{"A/m"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Centigram, new string[]{"cg"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Centigram, new string[]{"сг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Centigram, new string[]{"厘克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Decagram, new string[]{"dag"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Decagram, new string[]{"даг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Decagram, new string[]{"十克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Decigram, new string[]{"dg"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Decigram, new string[]{"дг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Decigram, new string[]{"分克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.EarthMass, new string[]{"em"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Grain, new string[]{"gr"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Gram, new string[]{"g"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Gram, new string[]{"г"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Gram, new string[]{"克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Hectogram, new string[]{"hg"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Hectogram, new string[]{"гг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Hectogram, new string[]{"百克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Kilogram, new string[]{"kg"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Kilogram, new string[]{"кг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Kilogram, new string[]{"千克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Kilopound, new string[]{"klb", "klbs", "klbm"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Kilopound, new string[]{"кфунт"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Kilopound, new string[]{"千磅"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Kilotonne, new string[]{"kt"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Kilotonne, new string[]{"кт"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Kilotonne, new string[]{"千吨"}), - ("en-US", typeof(MassUnit), (int)MassUnit.LongHundredweight, new string[]{"cwt"}), - ("en-US", typeof(MassUnit), (int)MassUnit.LongTon, new string[]{"long tn"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.LongTon, new string[]{"тонна большая"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.LongTon, new string[]{"长吨"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Megapound, new string[]{"Mlb", "Mlbs", "Mlbm"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Megapound, new string[]{"Мфунт"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Megapound, new string[]{"兆磅"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Megatonne, new string[]{"Mt"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Megatonne, new string[]{"Мт"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Megatonne, new string[]{"兆吨"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Microgram, new string[]{"µg"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Microgram, new string[]{"мкг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Microgram, new string[]{"微克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Milligram, new string[]{"mg"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Milligram, new string[]{"мг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Milligram, new string[]{"毫克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Nanogram, new string[]{"ng"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Nanogram, new string[]{"нг"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Nanogram, new string[]{"纳克"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Ounce, new string[]{"oz"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Ounce, new string[]{"盎司"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Pound, new string[]{"lb", "lbs", "lbm"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Pound, new string[]{"фунт"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Pound, new string[]{"磅"}), - ("en-US", typeof(MassUnit), (int)MassUnit.ShortHundredweight, new string[]{"cwt"}), - ("en-US", typeof(MassUnit), (int)MassUnit.ShortTon, new string[]{"t (short)", "short tn", "ST"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.ShortTon, new string[]{"тонна малая"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.ShortTon, new string[]{"短吨"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Slug, new string[]{"slug"}), - ("en-US", typeof(MassUnit), (int)MassUnit.SolarMass, new string[]{"M⊙"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Stone, new string[]{"st"}), - ("en-US", typeof(MassUnit), (int)MassUnit.Tonne, new string[]{"t"}), - ("ru-RU", typeof(MassUnit), (int)MassUnit.Tonne, new string[]{"т"}), - ("zh-CN", typeof(MassUnit), (int)MassUnit.Tonne, new string[]{"吨"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.CentigramPerDeciliter, new string[]{"cg/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.CentigramPerLiter, new string[]{"cg/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.CentigramPerMicroliter, new string[]{"cg/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.CentigramPerMilliliter, new string[]{"cg/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.DecigramPerDeciliter, new string[]{"dg/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.DecigramPerLiter, new string[]{"dg/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.DecigramPerMicroliter, new string[]{"dg/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.DecigramPerMilliliter, new string[]{"dg/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerCubicCentimeter, new string[]{"g/cm³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerCubicMeter, new string[]{"g/m³"}), - ("ru-RU", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerCubicMeter, new string[]{"г/м³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerCubicMillimeter, new string[]{"g/mm³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerDeciliter, new string[]{"g/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerLiter, new string[]{"g/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerMicroliter, new string[]{"g/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.GramPerMilliliter, new string[]{"g/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilogramPerCubicCentimeter, new string[]{"kg/cm³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilogramPerCubicMeter, new string[]{"kg/m³"}), - ("ru-RU", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilogramPerCubicMeter, new string[]{"кг/м³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilogramPerCubicMillimeter, new string[]{"kg/mm³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilogramPerLiter, new string[]{"kg/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilopoundPerCubicFoot, new string[]{"kip/ft³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.KilopoundPerCubicInch, new string[]{"kip/in³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MicrogramPerCubicMeter, new string[]{"µg/m³"}), - ("ru-RU", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MicrogramPerCubicMeter, new string[]{"мкг/м³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MicrogramPerDeciliter, new string[]{"µg/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MicrogramPerLiter, new string[]{"µg/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MicrogramPerMicroliter, new string[]{"µg/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MicrogramPerMilliliter, new string[]{"µg/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MilligramPerCubicMeter, new string[]{"mg/m³"}), - ("ru-RU", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MilligramPerCubicMeter, new string[]{"мг/м³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MilligramPerDeciliter, new string[]{"mg/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MilligramPerLiter, new string[]{"mg/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MilligramPerMicroliter, new string[]{"mg/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.MilligramPerMilliliter, new string[]{"mg/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.NanogramPerDeciliter, new string[]{"ng/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.NanogramPerLiter, new string[]{"ng/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.NanogramPerMicroliter, new string[]{"ng/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.NanogramPerMilliliter, new string[]{"ng/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.OuncePerImperialGallon, new string[]{"oz/gal (imp.)"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.OuncePerUSGallon, new string[]{"oz/gal (U.S.)"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PicogramPerDeciliter, new string[]{"pg/dL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PicogramPerLiter, new string[]{"pg/L"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PicogramPerMicroliter, new string[]{"pg/μL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PicogramPerMilliliter, new string[]{"pg/mL"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PoundPerCubicFoot, new string[]{"lb/ft³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PoundPerCubicInch, new string[]{"lb/in³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PoundPerImperialGallon, new string[]{"ppg (imp.)"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.PoundPerUSGallon, new string[]{"ppg (U.S.)"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.SlugPerCubicFoot, new string[]{"slug/ft³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.TonnePerCubicCentimeter, new string[]{"t/cm³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.TonnePerCubicMeter, new string[]{"t/m³"}), - ("en-US", typeof(MassConcentrationUnit), (int)MassConcentrationUnit.TonnePerCubicMillimeter, new string[]{"t/mm³"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.CentigramPerDay, new string[]{"cg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.CentigramPerSecond, new string[]{"cg/s", "cg/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.DecagramPerDay, new string[]{"dag/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.DecagramPerSecond, new string[]{"dag/s", "dag/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.DecigramPerDay, new string[]{"dg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.DecigramPerSecond, new string[]{"dg/s", "dg/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.GramPerDay, new string[]{"g/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.GramPerHour, new string[]{"g/h"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.GramPerSecond, new string[]{"g/s", "g/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.HectogramPerDay, new string[]{"hg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.HectogramPerSecond, new string[]{"hg/s", "hg/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.KilogramPerDay, new string[]{"kg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.KilogramPerHour, new string[]{"kg/h"}), - ("ru-RU", typeof(MassFlowUnit), (int)MassFlowUnit.KilogramPerHour, new string[]{"кг/ч"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.KilogramPerMinute, new string[]{"kg/min"}), - ("ru-RU", typeof(MassFlowUnit), (int)MassFlowUnit.KilogramPerMinute, new string[]{"кг/мин"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.KilogramPerSecond, new string[]{"kg/s", "kg/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MegagramPerDay, new string[]{"Mg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MegapoundPerDay, new string[]{"Mlb/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MegapoundPerHour, new string[]{"Mlb/h"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MegapoundPerMinute, new string[]{"Mlb/min"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MegapoundPerSecond, new string[]{"Mlb/s"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MicrogramPerDay, new string[]{"µg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MicrogramPerSecond, new string[]{"µg/s", "µg/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MilligramPerDay, new string[]{"mg/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.MilligramPerSecond, new string[]{"mg/s", "mg/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.NanogramPerDay, new string[]{"ng/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.NanogramPerSecond, new string[]{"ng/s", "ng/S"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.PoundPerDay, new string[]{"lb/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.PoundPerHour, new string[]{"lb/h"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.PoundPerMinute, new string[]{"lb/min"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.PoundPerSecond, new string[]{"lb/s"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.ShortTonPerHour, new string[]{"short tn/h"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.TonnePerDay, new string[]{"t/d"}), - ("en-US", typeof(MassFlowUnit), (int)MassFlowUnit.TonnePerHour, new string[]{"t/h"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.GramPerHourPerSquareCentimeter, new string[]{"g·h⁻¹·cm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.GramPerHourPerSquareMeter, new string[]{"g·h⁻¹·m⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.GramPerHourPerSquareMillimeter, new string[]{"g·h⁻¹·mm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.GramPerSecondPerSquareCentimeter, new string[]{"g·s⁻¹·cm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.GramPerSecondPerSquareMeter, new string[]{"g·s⁻¹·m⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.GramPerSecondPerSquareMillimeter, new string[]{"g·s⁻¹·mm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.KilogramPerHourPerSquareCentimeter, new string[]{"kg·h⁻¹·cm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.KilogramPerHourPerSquareMeter, new string[]{"kg·h⁻¹·m⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.KilogramPerHourPerSquareMillimeter, new string[]{"kg·h⁻¹·mm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.KilogramPerSecondPerSquareCentimeter, new string[]{"kg·s⁻¹·cm⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.KilogramPerSecondPerSquareMeter, new string[]{"kg·s⁻¹·m⁻²"}), - ("en-US", typeof(MassFluxUnit), (int)MassFluxUnit.KilogramPerSecondPerSquareMillimeter, new string[]{"kg·s⁻¹·mm⁻²"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.CentigramPerGram, new string[]{"cg/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.CentigramPerKilogram, new string[]{"cg/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.DecagramPerGram, new string[]{"dag/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.DecagramPerKilogram, new string[]{"dag/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.DecigramPerGram, new string[]{"dg/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.DecigramPerKilogram, new string[]{"dg/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.DecimalFraction, new string[]{""}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.GramPerGram, new string[]{"g/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.GramPerKilogram, new string[]{"g/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.HectogramPerGram, new string[]{"hg/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.HectogramPerKilogram, new string[]{"hg/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.KilogramPerGram, new string[]{"kg/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.KilogramPerKilogram, new string[]{"kg/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.MicrogramPerGram, new string[]{"µg/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.MicrogramPerKilogram, new string[]{"µg/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.MilligramPerGram, new string[]{"mg/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.MilligramPerKilogram, new string[]{"mg/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.NanogramPerGram, new string[]{"ng/g"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.NanogramPerKilogram, new string[]{"ng/kg"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.PartPerBillion, new string[]{"ppb"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.PartPerMillion, new string[]{"ppm"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.PartPerThousand, new string[]{"‰"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.PartPerTrillion, new string[]{"ppt"}), - ("en-US", typeof(MassFractionUnit), (int)MassFractionUnit.Percent, new string[]{"%", "% (w/w)"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.GramSquareCentimeter, new string[]{"g·cm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.GramSquareDecimeter, new string[]{"g·dm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.GramSquareMeter, new string[]{"g·m²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.GramSquareMillimeter, new string[]{"g·mm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilogramSquareCentimeter, new string[]{"kg·cm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilogramSquareDecimeter, new string[]{"kg·dm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilogramSquareMeter, new string[]{"kg·m²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilogramSquareMillimeter, new string[]{"kg·mm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilotonneSquareCentimeter, new string[]{"kt·cm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilotonneSquareDecimeter, new string[]{"kt·dm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilotonneSquareMeter, new string[]{"kt·m²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.KilotonneSquareMilimeter, new string[]{"kt·mm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MegatonneSquareCentimeter, new string[]{"Mt·cm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MegatonneSquareDecimeter, new string[]{"Mt·dm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MegatonneSquareMeter, new string[]{"Mt·m²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MegatonneSquareMilimeter, new string[]{"Mt·mm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MilligramSquareCentimeter, new string[]{"mg·cm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MilligramSquareDecimeter, new string[]{"mg·dm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MilligramSquareMeter, new string[]{"mg·m²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.MilligramSquareMillimeter, new string[]{"mg·mm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.PoundSquareFoot, new string[]{"lb·ft²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.PoundSquareInch, new string[]{"lb·in²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.SlugSquareFoot, new string[]{"slug·ft²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.SlugSquareInch, new string[]{"slug·in²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.TonneSquareCentimeter, new string[]{"t·cm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.TonneSquareDecimeter, new string[]{"t·dm²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.TonneSquareMeter, new string[]{"t·m²"}), - ("en-US", typeof(MassMomentOfInertiaUnit), (int)MassMomentOfInertiaUnit.TonneSquareMilimeter, new string[]{"t·mm²"}), - ("en-US", typeof(MolarEnergyUnit), (int)MolarEnergyUnit.JoulePerMole, new string[]{"J/mol"}), - ("en-US", typeof(MolarEnergyUnit), (int)MolarEnergyUnit.KilojoulePerMole, new string[]{"kJ/mol"}), - ("en-US", typeof(MolarEnergyUnit), (int)MolarEnergyUnit.MegajoulePerMole, new string[]{"MJ/mol"}), - ("en-US", typeof(MolarEntropyUnit), (int)MolarEntropyUnit.JoulePerMoleKelvin, new string[]{"J/(mol*K)"}), - ("en-US", typeof(MolarEntropyUnit), (int)MolarEntropyUnit.KilojoulePerMoleKelvin, new string[]{"kJ/(mol*K)"}), - ("en-US", typeof(MolarEntropyUnit), (int)MolarEntropyUnit.MegajoulePerMoleKelvin, new string[]{"MJ/(mol*K)"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.CentimolesPerLiter, new string[]{"cmol/L", "cM"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.DecimolesPerLiter, new string[]{"dmol/L", "dM"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.MicromolesPerLiter, new string[]{"µmol/L", "µM"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.MillimolesPerLiter, new string[]{"mmol/L", "mM"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.MolesPerCubicMeter, new string[]{"mol/m³"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.MolesPerLiter, new string[]{"mol/L", "M"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.NanomolesPerLiter, new string[]{"nmol/L", "nM"}), - ("en-US", typeof(MolarityUnit), (int)MolarityUnit.PicomolesPerLiter, new string[]{"pmol/L", "pM"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.CentigramPerMole, new string[]{"cg/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.CentigramPerMole, new string[]{"сг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.DecagramPerMole, new string[]{"dag/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.DecagramPerMole, new string[]{"даг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.DecigramPerMole, new string[]{"dg/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.DecigramPerMole, new string[]{"дг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.GramPerMole, new string[]{"g/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.GramPerMole, new string[]{"г/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.HectogramPerMole, new string[]{"hg/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.HectogramPerMole, new string[]{"гг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.KilogramPerMole, new string[]{"kg/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.KilogramPerMole, new string[]{"кг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.KilopoundPerMole, new string[]{"klb/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.KilopoundPerMole, new string[]{"кфунт/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.MegapoundPerMole, new string[]{"Mlb/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.MegapoundPerMole, new string[]{"Мфунт/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.MicrogramPerMole, new string[]{"µg/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.MicrogramPerMole, new string[]{"мкг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.MilligramPerMole, new string[]{"mg/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.MilligramPerMole, new string[]{"мг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.NanogramPerMole, new string[]{"ng/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.NanogramPerMole, new string[]{"нг/моль"}), - ("en-US", typeof(MolarMassUnit), (int)MolarMassUnit.PoundPerMole, new string[]{"lb/mol"}), - ("ru-RU", typeof(MolarMassUnit), (int)MolarMassUnit.PoundPerMole, new string[]{"фунт/моль"}), - ("en-US", typeof(PermeabilityUnit), (int)PermeabilityUnit.HenryPerMeter, new string[]{"H/m"}), - ("en-US", typeof(PermittivityUnit), (int)PermittivityUnit.FaradPerMeter, new string[]{"F/m"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.BoilerHorsepower, new string[]{"hp(S)"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.BritishThermalUnitPerHour, new string[]{"Btu/h", "Btu/hr"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Decawatt, new string[]{"daW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Deciwatt, new string[]{"dW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.ElectricalHorsepower, new string[]{"hp(E)"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Femtowatt, new string[]{"fW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.GigajoulePerHour, new string[]{"GJ/h"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Gigawatt, new string[]{"GW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.HydraulicHorsepower, new string[]{"hp(H)"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.JoulePerHour, new string[]{"J/h"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.KilobritishThermalUnitPerHour, new string[]{"kBtu/h", "kBtu/hr"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.KilojoulePerHour, new string[]{"kJ/h"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Kilowatt, new string[]{"kW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.MechanicalHorsepower, new string[]{"hp(I)"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.MegajoulePerHour, new string[]{"MJ/h"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Megawatt, new string[]{"MW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.MetricHorsepower, new string[]{"hp(M)"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Microwatt, new string[]{"µW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.MillijoulePerHour, new string[]{"mJ/h"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Milliwatt, new string[]{"mW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Nanowatt, new string[]{"nW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Petawatt, new string[]{"PW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Picowatt, new string[]{"pW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Terawatt, new string[]{"TW"}), - ("en-US", typeof(PowerUnit), (int)PowerUnit.Watt, new string[]{"W"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DecawattPerCubicFoot, new string[]{"daW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DecawattPerCubicInch, new string[]{"daW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DecawattPerCubicMeter, new string[]{"daW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DecawattPerLiter, new string[]{"daW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DeciwattPerCubicFoot, new string[]{"dW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DeciwattPerCubicInch, new string[]{"dW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DeciwattPerCubicMeter, new string[]{"dW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.DeciwattPerLiter, new string[]{"dW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.GigawattPerCubicFoot, new string[]{"GW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.GigawattPerCubicInch, new string[]{"GW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.GigawattPerCubicMeter, new string[]{"GW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.GigawattPerLiter, new string[]{"GW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.KilowattPerCubicFoot, new string[]{"kW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.KilowattPerCubicInch, new string[]{"kW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.KilowattPerCubicMeter, new string[]{"kW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.KilowattPerLiter, new string[]{"kW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MegawattPerCubicFoot, new string[]{"MW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MegawattPerCubicInch, new string[]{"MW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MegawattPerCubicMeter, new string[]{"MW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MegawattPerLiter, new string[]{"MW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MicrowattPerCubicFoot, new string[]{"µW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MicrowattPerCubicInch, new string[]{"µW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MicrowattPerCubicMeter, new string[]{"µW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MicrowattPerLiter, new string[]{"µW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MilliwattPerCubicFoot, new string[]{"mW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MilliwattPerCubicInch, new string[]{"mW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MilliwattPerCubicMeter, new string[]{"mW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.MilliwattPerLiter, new string[]{"mW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.NanowattPerCubicFoot, new string[]{"nW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.NanowattPerCubicInch, new string[]{"nW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.NanowattPerCubicMeter, new string[]{"nW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.NanowattPerLiter, new string[]{"nW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.PicowattPerCubicFoot, new string[]{"pW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.PicowattPerCubicInch, new string[]{"pW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.PicowattPerCubicMeter, new string[]{"pW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.PicowattPerLiter, new string[]{"pW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.TerawattPerCubicFoot, new string[]{"TW/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.TerawattPerCubicInch, new string[]{"TW/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.TerawattPerCubicMeter, new string[]{"TW/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.TerawattPerLiter, new string[]{"TW/l"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.WattPerCubicFoot, new string[]{"W/ft³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.WattPerCubicInch, new string[]{"W/in³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.WattPerCubicMeter, new string[]{"W/m³"}), - ("en-US", typeof(PowerDensityUnit), (int)PowerDensityUnit.WattPerLiter, new string[]{"W/l"}), - ("en-US", typeof(PowerRatioUnit), (int)PowerRatioUnit.DecibelMilliwatt, new string[]{"dBmW", "dBm"}), - ("en-US", typeof(PowerRatioUnit), (int)PowerRatioUnit.DecibelWatt, new string[]{"dBW"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Atmosphere, new string[]{"atm"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Atmosphere, new string[]{"атм"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Bar, new string[]{"bar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Bar, new string[]{"бар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Centibar, new string[]{"cbar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Centibar, new string[]{"сбар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Decapascal, new string[]{"daPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Decapascal, new string[]{"даПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Decibar, new string[]{"dbar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Decibar, new string[]{"дбар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.DynePerSquareCentimeter, new string[]{"dyn/cm²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.FootOfElevation, new string[]{"ft of elevation"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.FootOfHead, new string[]{"ft of head"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Gigapascal, new string[]{"GPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Gigapascal, new string[]{"ГПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Hectopascal, new string[]{"hPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Hectopascal, new string[]{"гПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.InchOfMercury, new string[]{"inHg"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.InchOfWaterColumn, new string[]{"wc"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Kilobar, new string[]{"kbar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Kilobar, new string[]{"кбар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilogramForcePerSquareCentimeter, new string[]{"kgf/cm²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilogramForcePerSquareCentimeter, new string[]{"кгс/см²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilogramForcePerSquareMeter, new string[]{"kgf/m²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilogramForcePerSquareMeter, new string[]{"кгс/м²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilogramForcePerSquareMillimeter, new string[]{"kgf/mm²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilogramForcePerSquareMillimeter, new string[]{"кгс/мм²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilonewtonPerSquareCentimeter, new string[]{"kN/cm²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilonewtonPerSquareCentimeter, new string[]{"кН/см²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilonewtonPerSquareMeter, new string[]{"kN/m²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilonewtonPerSquareMeter, new string[]{"кН/м²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilonewtonPerSquareMillimeter, new string[]{"kN/mm²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilonewtonPerSquareMillimeter, new string[]{"кН/мм²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Kilopascal, new string[]{"kPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Kilopascal, new string[]{"кПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilopoundForcePerSquareFoot, new string[]{"kipf/ft²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.KilopoundForcePerSquareInch, new string[]{"ksi", "kipf/in²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.KilopoundForcePerSquareInch, new string[]{"ksi", "kipf/in²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Megabar, new string[]{"Mbar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Megabar, new string[]{"Мбар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.MeganewtonPerSquareMeter, new string[]{"MN/m²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.MeganewtonPerSquareMeter, new string[]{"МН/м²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Megapascal, new string[]{"MPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Megapascal, new string[]{"МПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.MeterOfElevation, new string[]{"m of elevation"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.MeterOfHead, new string[]{"m of head"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Microbar, new string[]{"µbar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Microbar, new string[]{"мкбар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Micropascal, new string[]{"µPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Micropascal, new string[]{"мкПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Millibar, new string[]{"mbar"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Millibar, new string[]{"мбар"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.MillimeterOfMercury, new string[]{"mmHg"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.MillimeterOfMercury, new string[]{"мм рт.ст."}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Millipascal, new string[]{"mPa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Millipascal, new string[]{"мПа"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.NewtonPerSquareCentimeter, new string[]{"N/cm²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.NewtonPerSquareCentimeter, new string[]{"Н/см²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.NewtonPerSquareMeter, new string[]{"N/m²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.NewtonPerSquareMeter, new string[]{"Н/м²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.NewtonPerSquareMillimeter, new string[]{"N/mm²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.NewtonPerSquareMillimeter, new string[]{"Н/мм²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Pascal, new string[]{"Pa"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Pascal, new string[]{"Па"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.PoundForcePerSquareFoot, new string[]{"lb/ft²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.PoundForcePerSquareInch, new string[]{"psi", "lb/in²"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.PoundForcePerSquareInch, new string[]{"psi", "lb/in²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.PoundPerInchSecondSquared, new string[]{"lbm/(in·s²)", "lb/(in·s²)"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.TechnicalAtmosphere, new string[]{"at"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.TechnicalAtmosphere, new string[]{"ат"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.TonneForcePerSquareCentimeter, new string[]{"tf/cm²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.TonneForcePerSquareMeter, new string[]{"tf/m²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.TonneForcePerSquareMillimeter, new string[]{"tf/mm²"}), - ("en-US", typeof(PressureUnit), (int)PressureUnit.Torr, new string[]{"torr"}), - ("ru-RU", typeof(PressureUnit), (int)PressureUnit.Torr, new string[]{"торр"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.AtmospherePerSecond, new string[]{"atm/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.AtmospherePerSecond, new string[]{"атм/с"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopascalPerMinute, new string[]{"kPa/min"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopascalPerMinute, new string[]{"кПа/мин"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopascalPerSecond, new string[]{"kPa/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopascalPerSecond, new string[]{"кПа/с"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, new string[]{"ksi/min", "kipf/in²/min"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, new string[]{"ksi/мин", "kipf/in²/мин"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, new string[]{"ksi/s", "kipf/in²/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, new string[]{"ksi/с", "kipf/in²/с"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapascalPerMinute, new string[]{"MPa/min"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapascalPerMinute, new string[]{"МПа/мин"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapascalPerSecond, new string[]{"MPa/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapascalPerSecond, new string[]{"МПа/с"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, new string[]{"Mpsi/min", "Mlb/in²/min"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, new string[]{"Мpsi/мин", "Мlb/in²/мин"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, new string[]{"Mpsi/s", "Mlb/in²/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, new string[]{"Мpsi/с", "Мlb/in²/с"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PascalPerMinute, new string[]{"Pa/min"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PascalPerMinute, new string[]{"Па/мин"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PascalPerSecond, new string[]{"Pa/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PascalPerSecond, new string[]{"Па/с"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, new string[]{"psi/min", "lb/in²/min"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, new string[]{"psi/мин", "lb/in²/мин"}), - ("en-US", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, new string[]{"psi/s", "lb/in²/s"}), - ("ru-RU", typeof(PressureChangeRateUnit), (int)PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, new string[]{"psi/с", "lb/in²/с"}), - ("en-US", typeof(RatioUnit), (int)RatioUnit.DecimalFraction, new string[]{""}), - ("en-US", typeof(RatioUnit), (int)RatioUnit.PartPerBillion, new string[]{"ppb"}), - ("en-US", typeof(RatioUnit), (int)RatioUnit.PartPerMillion, new string[]{"ppm"}), - ("en-US", typeof(RatioUnit), (int)RatioUnit.PartPerThousand, new string[]{"‰"}), - ("en-US", typeof(RatioUnit), (int)RatioUnit.PartPerTrillion, new string[]{"ppt"}), - ("en-US", typeof(RatioUnit), (int)RatioUnit.Percent, new string[]{"%"}), - ("en-US", typeof(RatioChangeRateUnit), (int)RatioChangeRateUnit.DecimalFractionPerSecond, new string[]{"/s"}), - ("en-US", typeof(RatioChangeRateUnit), (int)RatioChangeRateUnit.PercentPerSecond, new string[]{"%/s"}), - ("en-US", typeof(ReactiveEnergyUnit), (int)ReactiveEnergyUnit.KilovoltampereReactiveHour, new string[]{"kvarh"}), - ("en-US", typeof(ReactiveEnergyUnit), (int)ReactiveEnergyUnit.MegavoltampereReactiveHour, new string[]{"Mvarh"}), - ("en-US", typeof(ReactiveEnergyUnit), (int)ReactiveEnergyUnit.VoltampereReactiveHour, new string[]{"varh"}), - ("en-US", typeof(ReactivePowerUnit), (int)ReactivePowerUnit.GigavoltampereReactive, new string[]{"Gvar"}), - ("en-US", typeof(ReactivePowerUnit), (int)ReactivePowerUnit.KilovoltampereReactive, new string[]{"kvar"}), - ("en-US", typeof(ReactivePowerUnit), (int)ReactivePowerUnit.MegavoltampereReactive, new string[]{"Mvar"}), - ("en-US", typeof(ReactivePowerUnit), (int)ReactivePowerUnit.VoltampereReactive, new string[]{"var"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareCentimeter, new string[]{"cm⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareDecimeter, new string[]{"dm⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareFoot, new string[]{"ft⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareInch, new string[]{"in⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareKilometer, new string[]{"km⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareMeter, new string[]{"m⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareMicrometer, new string[]{"µm⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareMile, new string[]{"mi⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareMillimeter, new string[]{"mm⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseSquareYard, new string[]{"yd⁻²"}), - ("en-US", typeof(ReciprocalAreaUnit), (int)ReciprocalAreaUnit.InverseUsSurveySquareFoot, new string[]{"ft⁻² (US)"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseCentimeter, new string[]{"cm⁻¹", "1/cm"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseFoot, new string[]{"ft⁻¹", "1/ft"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseInch, new string[]{"in⁻¹", "1/in"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseMeter, new string[]{"m⁻¹", "1/m"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseMicroinch, new string[]{"µin⁻¹", "1/µin"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseMil, new string[]{"mil⁻¹", "1/mil"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseMile, new string[]{"mi⁻¹", "1/mi"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseMillimeter, new string[]{"mm⁻¹", "1/mm"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseUsSurveyFoot, new string[]{"ftUS⁻¹", "1/ftUS"}), - ("en-US", typeof(ReciprocalLengthUnit), (int)ReciprocalLengthUnit.InverseYard, new string[]{"yd⁻¹", "1/yd"}), - ("en-US", typeof(RelativeHumidityUnit), (int)RelativeHumidityUnit.Percent, new string[]{"%RH"}), - ("en-US", typeof(RotationalAccelerationUnit), (int)RotationalAccelerationUnit.DegreePerSecondSquared, new string[]{"°/s²", "deg/s²"}), - ("en-US", typeof(RotationalAccelerationUnit), (int)RotationalAccelerationUnit.RadianPerSecondSquared, new string[]{"rad/s²"}), - ("en-US", typeof(RotationalAccelerationUnit), (int)RotationalAccelerationUnit.RevolutionPerMinutePerSecond, new string[]{"rpm/s"}), - ("en-US", typeof(RotationalAccelerationUnit), (int)RotationalAccelerationUnit.RevolutionPerSecondSquared, new string[]{"r/s²"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.CentiradianPerSecond, new string[]{"crad/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.CentiradianPerSecond, new string[]{"срад/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.DeciradianPerSecond, new string[]{"drad/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.DeciradianPerSecond, new string[]{"драд/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.DegreePerMinute, new string[]{"°/min", "deg/min"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.DegreePerSecond, new string[]{"°/s", "deg/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.DegreePerSecond, new string[]{"°/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MicrodegreePerSecond, new string[]{"µ°/s", "µdeg/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MicrodegreePerSecond, new string[]{"мк°/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MicroradianPerSecond, new string[]{"µrad/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MicroradianPerSecond, new string[]{"мкрад/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MillidegreePerSecond, new string[]{"m°/s", "mdeg/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MillidegreePerSecond, new string[]{"м°/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MilliradianPerSecond, new string[]{"mrad/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.MilliradianPerSecond, new string[]{"мрад/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.NanodegreePerSecond, new string[]{"n°/s", "ndeg/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.NanodegreePerSecond, new string[]{"н°/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.NanoradianPerSecond, new string[]{"nrad/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.NanoradianPerSecond, new string[]{"нрад/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.RadianPerSecond, new string[]{"rad/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.RadianPerSecond, new string[]{"рад/с"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.RevolutionPerMinute, new string[]{"rpm", "r/min"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.RevolutionPerMinute, new string[]{"об/мин"}), - ("en-US", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.RevolutionPerSecond, new string[]{"r/s"}), - ("ru-RU", typeof(RotationalSpeedUnit), (int)RotationalSpeedUnit.RevolutionPerSecond, new string[]{"об/с"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.CentinewtonMeterPerDegree, new string[]{"cN·m/deg", "cNm/deg", "cN·m/°", "cNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, new string[]{"cN·mm/deg", "cNmm/deg", "cN·mm/°", "cNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, new string[]{"cN·mm/rad", "cNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.DecanewtonMeterPerDegree, new string[]{"daN·m/deg", "daNm/deg", "daN·m/°", "daNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, new string[]{"daN·mm/deg", "daNmm/deg", "daN·mm/°", "daNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, new string[]{"daN·mm/rad", "daNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.DecinewtonMeterPerDegree, new string[]{"dN·m/deg", "dNm/deg", "dN·m/°", "dNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, new string[]{"dN·mm/deg", "dNmm/deg", "dN·mm/°", "dNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, new string[]{"dN·mm/rad", "dNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.KilonewtonMeterPerDegree, new string[]{"kN·m/deg", "kNm/deg", "kN·m/°", "kNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.KilonewtonMeterPerRadian, new string[]{"kN·m/rad", "kNm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, new string[]{"kN·mm/deg", "kNmm/deg", "kN·mm/°", "kNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, new string[]{"kN·mm/rad", "kNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.KilopoundForceFootPerDegrees, new string[]{"kipf·ft/°", "kip·ft/°g", "k·ft/°", "kipf·ft/deg", "kip·ft/deg", "k·ft/deg"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MeganewtonMeterPerDegree, new string[]{"MN·m/deg", "MNm/deg", "MN·m/°", "MNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MeganewtonMeterPerRadian, new string[]{"MN·m/rad", "MNm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, new string[]{"MN·mm/deg", "MNmm/deg", "MN·mm/°", "MNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, new string[]{"MN·mm/rad", "MNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MicronewtonMeterPerDegree, new string[]{"µN·m/deg", "µNm/deg", "µN·m/°", "µNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, new string[]{"µN·mm/deg", "µNmm/deg", "µN·mm/°", "µNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, new string[]{"µN·mm/rad", "µNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MillinewtonMeterPerDegree, new string[]{"mN·m/deg", "mNm/deg", "mN·m/°", "mNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, new string[]{"mN·mm/deg", "mNmm/deg", "mN·mm/°", "mNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, new string[]{"mN·mm/rad", "mNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NanonewtonMeterPerDegree, new string[]{"nN·m/deg", "nNm/deg", "nN·m/°", "nNm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, new string[]{"nN·mm/deg", "nNmm/deg", "nN·mm/°", "nNmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, new string[]{"nN·mm/rad", "nNmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NewtonMeterPerDegree, new string[]{"N·m/deg", "Nm/deg", "N·m/°", "Nm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NewtonMeterPerRadian, new string[]{"N·m/rad", "Nm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NewtonMillimeterPerDegree, new string[]{"N·mm/deg", "Nmm/deg", "N·mm/°", "Nmm/°"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.NewtonMillimeterPerRadian, new string[]{"N·mm/rad", "Nmm/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.PoundForceFeetPerRadian, new string[]{"lbf·ft/rad"}), - ("en-US", typeof(RotationalStiffnessUnit), (int)RotationalStiffnessUnit.PoundForceFootPerDegrees, new string[]{"lbf·ft/deg"}), - ("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, new string[]{"kN·m/rad/m", "kNm/rad/m"}), - ("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, new string[]{"kipf·ft/°/ft", "kip·ft/°/ft", "k·ft/°/ft", "kipf·ft/deg/ft", "kip·ft/deg/ft", "k·ft/deg/ft"}), - ("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, new string[]{"MN·m/rad/m", "MNm/rad/m"}), - ("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, new string[]{"N·m/rad/m", "Nm/rad/m"}), - ("en-US", typeof(RotationalStiffnessPerLengthUnit), (int)RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, new string[]{"lbf·ft/deg/ft"}), - ("en-US", typeof(ScalarUnit), (int)ScalarUnit.Amount, new string[]{""}), - ("en-US", typeof(SolidAngleUnit), (int)SolidAngleUnit.Steradian, new string[]{"sr"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.BtuPerPound, new string[]{"btu/lb"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.CaloriePerGram, new string[]{"cal/g"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.GigawattDayPerKilogram, new string[]{"GWd/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.GigawattDayPerShortTon, new string[]{"GWd/ST"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.GigawattDayPerTonne, new string[]{"GWd/t"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.GigawattHourPerKilogram, new string[]{"GWh/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.JoulePerKilogram, new string[]{"J/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilocaloriePerGram, new string[]{"kcal/g"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilojoulePerKilogram, new string[]{"kJ/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilowattDayPerKilogram, new string[]{"kWd/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilowattDayPerShortTon, new string[]{"kWd/ST"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilowattDayPerTonne, new string[]{"kWd/t"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.KilowattHourPerKilogram, new string[]{"kWh/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.MegajoulePerKilogram, new string[]{"MJ/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.MegawattDayPerKilogram, new string[]{"MWd/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.MegawattDayPerShortTon, new string[]{"MWd/ST"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.MegawattDayPerTonne, new string[]{"MWd/t"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.MegawattHourPerKilogram, new string[]{"MWh/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.TerawattDayPerKilogram, new string[]{"TWd/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.TerawattDayPerShortTon, new string[]{"TWd/ST"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.TerawattDayPerTonne, new string[]{"TWd/t"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.WattDayPerKilogram, new string[]{"Wd/kg"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.WattDayPerShortTon, new string[]{"Wd/ST"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.WattDayPerTonne, new string[]{"Wd/t"}), - ("en-US", typeof(SpecificEnergyUnit), (int)SpecificEnergyUnit.WattHourPerKilogram, new string[]{"Wh/kg"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.BtuPerPoundFahrenheit, new string[]{"BTU/lb·°F", "BTU/lbm·°F"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.CaloriePerGramKelvin, new string[]{"cal/g.K"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, new string[]{"J/kg.C"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.JoulePerKilogramKelvin, new string[]{"J/kg.K"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.KilocaloriePerGramKelvin, new string[]{"kcal/g.K"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, new string[]{"kJ/kg.C"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.KilojoulePerKilogramKelvin, new string[]{"kJ/kg.K"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, new string[]{"MJ/kg.C"}), - ("en-US", typeof(SpecificEntropyUnit), (int)SpecificEntropyUnit.MegajoulePerKilogramKelvin, new string[]{"MJ/kg.K"}), - ("en-US", typeof(SpecificFuelConsumptionUnit), (int)SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, new string[]{"g/(kN�s)"}), - ("en-US", typeof(SpecificFuelConsumptionUnit), (int)SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, new string[]{"kg/(kgf�h)"}), - ("en-US", typeof(SpecificFuelConsumptionUnit), (int)SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, new string[]{"kg/(kN�s)"}), - ("en-US", typeof(SpecificFuelConsumptionUnit), (int)SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, new string[]{"lb/(lbf�h)"}), - ("en-US", typeof(SpecificVolumeUnit), (int)SpecificVolumeUnit.CubicFootPerPound, new string[]{"ft³/lb"}), - ("en-US", typeof(SpecificVolumeUnit), (int)SpecificVolumeUnit.CubicMeterPerKilogram, new string[]{"m³/kg"}), - ("en-US", typeof(SpecificVolumeUnit), (int)SpecificVolumeUnit.MillicubicMeterPerKilogram, new string[]{"mm³/kg"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilogramForcePerCubicCentimeter, new string[]{"kgf/cm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilogramForcePerCubicMeter, new string[]{"kgf/m³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilogramForcePerCubicMillimeter, new string[]{"kgf/mm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilonewtonPerCubicCentimeter, new string[]{"kN/cm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilonewtonPerCubicMeter, new string[]{"kN/m³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilonewtonPerCubicMillimeter, new string[]{"kN/mm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilopoundForcePerCubicFoot, new string[]{"kipf/ft³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.KilopoundForcePerCubicInch, new string[]{"kipf/in³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.MeganewtonPerCubicMeter, new string[]{"MN/m³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.NewtonPerCubicCentimeter, new string[]{"N/cm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.NewtonPerCubicMeter, new string[]{"N/m³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.NewtonPerCubicMillimeter, new string[]{"N/mm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.PoundForcePerCubicFoot, new string[]{"lbf/ft³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.PoundForcePerCubicInch, new string[]{"lbf/in³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.TonneForcePerCubicCentimeter, new string[]{"tf/cm³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.TonneForcePerCubicMeter, new string[]{"tf/m³"}), - ("en-US", typeof(SpecificWeightUnit), (int)SpecificWeightUnit.TonneForcePerCubicMillimeter, new string[]{"tf/mm³"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.CentimeterPerHour, new string[]{"cm/h"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.CentimeterPerHour, new string[]{"см/ч"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.CentimeterPerMinute, new string[]{"cm/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.CentimeterPerMinute, new string[]{"см/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.CentimeterPerSecond, new string[]{"cm/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.CentimeterPerSecond, new string[]{"см/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.DecimeterPerMinute, new string[]{"dm/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.DecimeterPerMinute, new string[]{"дм/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.DecimeterPerSecond, new string[]{"dm/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.DecimeterPerSecond, new string[]{"дм/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.FootPerHour, new string[]{"ft/h"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.FootPerHour, new string[]{"фут/ч"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.FootPerMinute, new string[]{"ft/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.FootPerMinute, new string[]{"фут/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.FootPerSecond, new string[]{"ft/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.FootPerSecond, new string[]{"фут/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.InchPerHour, new string[]{"in/h"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.InchPerMinute, new string[]{"in/min"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.InchPerSecond, new string[]{"in/s"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.KilometerPerHour, new string[]{"km/h"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.KilometerPerHour, new string[]{"км/ч"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.KilometerPerMinute, new string[]{"km/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.KilometerPerMinute, new string[]{"км/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.KilometerPerSecond, new string[]{"km/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.KilometerPerSecond, new string[]{"км/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.Knot, new string[]{"kn", "kt", "knot", "knots"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.Knot, new string[]{"уз."}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MeterPerHour, new string[]{"m/h"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MeterPerHour, new string[]{"м/ч"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MeterPerMinute, new string[]{"m/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MeterPerMinute, new string[]{"м/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MeterPerSecond, new string[]{"m/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MeterPerSecond, new string[]{"м/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MicrometerPerMinute, new string[]{"µm/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MicrometerPerMinute, new string[]{"мкм/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MicrometerPerSecond, new string[]{"µm/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MicrometerPerSecond, new string[]{"мкм/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MilePerHour, new string[]{"mph"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MilePerHour, new string[]{"миль/ч"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MillimeterPerHour, new string[]{"mm/h"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MillimeterPerHour, new string[]{"мм/ч"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MillimeterPerMinute, new string[]{"mm/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MillimeterPerMinute, new string[]{"мм/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.MillimeterPerSecond, new string[]{"mm/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.MillimeterPerSecond, new string[]{"мм/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.NanometerPerMinute, new string[]{"nm/min"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.NanometerPerMinute, new string[]{"нм/мин"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.NanometerPerSecond, new string[]{"nm/s"}), - ("ru-RU", typeof(SpeedUnit), (int)SpeedUnit.NanometerPerSecond, new string[]{"нм/с"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.UsSurveyFootPerHour, new string[]{"ftUS/h"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.UsSurveyFootPerMinute, new string[]{"ftUS/min"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.UsSurveyFootPerSecond, new string[]{"ftUS/s"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.YardPerHour, new string[]{"yd/h"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.YardPerMinute, new string[]{"yd/min"}), - ("en-US", typeof(SpeedUnit), (int)SpeedUnit.YardPerSecond, new string[]{"yd/s"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, new string[]{"sccm"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicFootPerHour, new string[]{"scfh"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicFootPerMinute, new string[]{"scfm"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicFootPerSecond, new string[]{"Sft³/s"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicMeterPerDay, new string[]{"Sm³/d"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicMeterPerHour, new string[]{"Sm³/h"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicMeterPerMinute, new string[]{"Sm³/min"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardCubicMeterPerSecond, new string[]{"Sm³/s"}), - ("en-US", typeof(StandardVolumeFlowUnit), (int)StandardVolumeFlowUnit.StandardLiterPerMinute, new string[]{"slm"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeCelsius, new string[]{"°C"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeDelisle, new string[]{"°De"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeFahrenheit, new string[]{"°F"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeNewton, new string[]{"°N"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeRankine, new string[]{"°R"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeReaumur, new string[]{"°Ré"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.DegreeRoemer, new string[]{"°Rø"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.Kelvin, new string[]{"K"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.MillidegreeCelsius, new string[]{"m°C"}), - ("en-US", typeof(TemperatureUnit), (int)TemperatureUnit.SolarTemperature, new string[]{"T⊙"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, new string[]{"c°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, new string[]{"da°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, new string[]{"d°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.DegreeCelsiusPerMinute, new string[]{"°C/min"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.DegreeCelsiusPerSecond, new string[]{"°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, new string[]{"h°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, new string[]{"k°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, new string[]{"µ°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, new string[]{"m°C/s"}), - ("en-US", typeof(TemperatureChangeRateUnit), (int)TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, new string[]{"n°C/s"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeCelsius, new string[]{"∆°C"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeDelisle, new string[]{"∆°De"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeFahrenheit, new string[]{"∆°F"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeNewton, new string[]{"∆°N"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeRankine, new string[]{"∆°R"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeReaumur, new string[]{"∆°Ré"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.DegreeRoemer, new string[]{"∆°Rø"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.Kelvin, new string[]{"∆K"}), - ("en-US", typeof(TemperatureDeltaUnit), (int)TemperatureDeltaUnit.MillidegreeCelsius, new string[]{"∆m°C"}), - ("en-US", typeof(ThermalConductivityUnit), (int)ThermalConductivityUnit.BtuPerHourFootFahrenheit, new string[]{"BTU/h·ft·°F"}), - ("en-US", typeof(ThermalConductivityUnit), (int)ThermalConductivityUnit.WattPerMeterKelvin, new string[]{"W/m·K"}), - ("en-US", typeof(ThermalResistanceUnit), (int)ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, new string[]{"Hrft²°F/Btu"}), - ("en-US", typeof(ThermalResistanceUnit), (int)ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, new string[]{"cm²Hr°C/kcal"}), - ("en-US", typeof(ThermalResistanceUnit), (int)ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, new string[]{"cm²K/W"}), - ("en-US", typeof(ThermalResistanceUnit), (int)ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, new string[]{"m²°C/W"}), - ("en-US", typeof(ThermalResistanceUnit), (int)ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, new string[]{"m²K/kW"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilogramForceCentimeter, new string[]{"kgf·cm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilogramForceMeter, new string[]{"kgf·m"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilogramForceMillimeter, new string[]{"kgf·mm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilonewtonCentimeter, new string[]{"kN·cm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilonewtonMeter, new string[]{"kN·m"}), - ("ru-RU", typeof(TorqueUnit), (int)TorqueUnit.KilonewtonMeter, new string[]{"кН·м"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilonewtonMillimeter, new string[]{"kN·mm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilopoundForceFoot, new string[]{"kipf·ft"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.KilopoundForceInch, new string[]{"kipf·in"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonCentimeter, new string[]{"MN·cm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMeter, new string[]{"MN·m"}), - ("ru-RU", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMeter, new string[]{"МН·м"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.MeganewtonMillimeter, new string[]{"MN·mm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.MegapoundForceFoot, new string[]{"Mlbf·ft"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.MegapoundForceInch, new string[]{"Mlbf·in"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.NewtonCentimeter, new string[]{"N·cm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.NewtonMeter, new string[]{"N·m"}), - ("ru-RU", typeof(TorqueUnit), (int)TorqueUnit.NewtonMeter, new string[]{"Н·м"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.NewtonMillimeter, new string[]{"N·mm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.PoundalFoot, new string[]{"pdl·ft"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.PoundForceFoot, new string[]{"lbf·ft"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.PoundForceInch, new string[]{"lbf·in"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.TonneForceCentimeter, new string[]{"tf·cm"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.TonneForceMeter, new string[]{"tf·m"}), - ("en-US", typeof(TorqueUnit), (int)TorqueUnit.TonneForceMillimeter, new string[]{"tf·mm"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilogramForceCentimeterPerMeter, new string[]{"kgf·cm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilogramForceMeterPerMeter, new string[]{"kgf·m/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilogramForceMillimeterPerMeter, new string[]{"kgf·mm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilonewtonCentimeterPerMeter, new string[]{"kN·cm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilonewtonMeterPerMeter, new string[]{"kN·m/m"}), - ("ru-RU", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilonewtonMeterPerMeter, new string[]{"кН·м/м"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilonewtonMillimeterPerMeter, new string[]{"kN·mm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilopoundForceFootPerFoot, new string[]{"kipf·ft/ft"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.KilopoundForceInchPerFoot, new string[]{"kipf·in/ft"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.MeganewtonCentimeterPerMeter, new string[]{"MN·cm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.MeganewtonMeterPerMeter, new string[]{"MN·m/m"}), - ("ru-RU", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.MeganewtonMeterPerMeter, new string[]{"МН·м/м"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.MeganewtonMillimeterPerMeter, new string[]{"MN·mm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.MegapoundForceFootPerFoot, new string[]{"Mlbf·ft/ft"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.MegapoundForceInchPerFoot, new string[]{"Mlbf·in/ft"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.NewtonCentimeterPerMeter, new string[]{"N·cm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.NewtonMeterPerMeter, new string[]{"N·m/m"}), - ("ru-RU", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.NewtonMeterPerMeter, new string[]{"Н·м/м"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.NewtonMillimeterPerMeter, new string[]{"N·mm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.PoundForceFootPerFoot, new string[]{"lbf·ft/ft"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.PoundForceInchPerFoot, new string[]{"lbf·in/ft"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.TonneForceCentimeterPerMeter, new string[]{"tf·cm/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.TonneForceMeterPerMeter, new string[]{"tf·m/m"}), - ("en-US", typeof(TorquePerLengthUnit), (int)TorquePerLengthUnit.TonneForceMillimeterPerMeter, new string[]{"tf·mm/m"}), - ("en-US", typeof(TurbidityUnit), (int)TurbidityUnit.NTU, new string[]{"NTU"}), - ("en-US", typeof(VitaminAUnit), (int)VitaminAUnit.InternationalUnit, new string[]{"IU"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.AcreFoot, new string[]{"ac-ft", "acre-foot", "acre-feet"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.AuTablespoon, new string[]{""}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.AuTablespoon, new string[]{""}), - ("nb-NO", typeof(VolumeUnit), (int)VolumeUnit.AuTablespoon, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.BoardFoot, new string[]{"bf", "board foot", "board feet"}), - ("fr-CA", typeof(VolumeUnit), (int)VolumeUnit.BoardFoot, new string[]{"pmp", "pied-planche", "pied de planche"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Centiliter, new string[]{"cl"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Centiliter, new string[]{"сл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicCentimeter, new string[]{"cm³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicCentimeter, new string[]{"см³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicDecimeter, new string[]{"dm³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicDecimeter, new string[]{"дм³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicFoot, new string[]{"ft³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicFoot, new string[]{"фут³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicHectometer, new string[]{"hm³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicHectometer, new string[]{"гм³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicInch, new string[]{"in³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicInch, new string[]{"дюйм³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicKilometer, new string[]{"km³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicKilometer, new string[]{"км³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicMeter, new string[]{"m³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicMeter, new string[]{"м³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicMicrometer, new string[]{"µm³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicMicrometer, new string[]{"мкм³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicMile, new string[]{"mi³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicMile, new string[]{"миля³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicMillimeter, new string[]{"mm³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicMillimeter, new string[]{"мм³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.CubicYard, new string[]{"yd³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.CubicYard, new string[]{"ярд³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.DecausGallon, new string[]{"dagal (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.DecausGallon, new string[]{"даАмериканский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Deciliter, new string[]{"dl"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Deciliter, new string[]{"дл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.DeciusGallon, new string[]{"dgal (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.DeciusGallon, new string[]{"дАмериканский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.HectocubicFoot, new string[]{"hft³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.HectocubicFoot, new string[]{"гфут³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.HectocubicMeter, new string[]{"hm³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.HectocubicMeter, new string[]{"гм³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Hectoliter, new string[]{"hl"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Hectoliter, new string[]{"гл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.HectousGallon, new string[]{"hgal (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.HectousGallon, new string[]{"гАмериканский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.ImperialBeerBarrel, new string[]{"bl (imp.)"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.ImperialGallon, new string[]{"gal (imp.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.ImperialGallon, new string[]{"Английский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.ImperialOunce, new string[]{"oz (imp.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.ImperialOunce, new string[]{"Английская унция"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.ImperialPint, new string[]{"pt (imp.)", "UK pt", "pt", "p"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.KilocubicFoot, new string[]{"kft³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.KilocubicFoot, new string[]{"кфут³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.KilocubicMeter, new string[]{"km³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.KilocubicMeter, new string[]{"км³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.KiloimperialGallon, new string[]{"kgal (imp.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.KiloimperialGallon, new string[]{"кАнглийский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Kiloliter, new string[]{"kl"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Kiloliter, new string[]{"кл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.KilousGallon, new string[]{"kgal (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.KilousGallon, new string[]{"кАмериканский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Liter, new string[]{"l"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Liter, new string[]{"л"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.MegacubicFoot, new string[]{"Mft³"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.MegacubicFoot, new string[]{"Мфут³"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.MegaimperialGallon, new string[]{"Mgal (imp.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.MegaimperialGallon, new string[]{"МАнглийский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Megaliter, new string[]{"Ml"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Megaliter, new string[]{"Мл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.MegausGallon, new string[]{"Mgal (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.MegausGallon, new string[]{"МАмериканский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.MetricCup, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.MetricTeaspoon, new string[]{"tsp", "t", "ts", "tspn", "t.", "ts.", "tsp.", "tspn.", "teaspoon"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.MetricTeaspoon, new string[]{""}), - ("nb-NO", typeof(VolumeUnit), (int)VolumeUnit.MetricTeaspoon, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Microliter, new string[]{"µl"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Microliter, new string[]{"мкл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.Milliliter, new string[]{"ml"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.Milliliter, new string[]{"мл"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.OilBarrel, new string[]{"bbl"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UkTablespoon, new string[]{""}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.UkTablespoon, new string[]{""}), - ("nb-NO", typeof(VolumeUnit), (int)VolumeUnit.UkTablespoon, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsBeerBarrel, new string[]{"bl (U.S.)"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsCustomaryCup, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsGallon, new string[]{"gal (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.UsGallon, new string[]{"Американский галлон"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsLegalCup, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsOunce, new string[]{"oz (U.S.)"}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.UsOunce, new string[]{"Американская унция"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsPint, new string[]{"pt (U.S.)"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsQuart, new string[]{"qt (U.S.)"}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsTablespoon, new string[]{""}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.UsTablespoon, new string[]{""}), - ("nb-NO", typeof(VolumeUnit), (int)VolumeUnit.UsTablespoon, new string[]{""}), - ("en-US", typeof(VolumeUnit), (int)VolumeUnit.UsTeaspoon, new string[]{""}), - ("ru-RU", typeof(VolumeUnit), (int)VolumeUnit.UsTeaspoon, new string[]{""}), - ("nb-NO", typeof(VolumeUnit), (int)VolumeUnit.UsTeaspoon, new string[]{""}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.CentilitersPerLiter, new string[]{"cL/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.CentilitersPerMililiter, new string[]{"cL/mL"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.DecilitersPerLiter, new string[]{"dL/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.DecilitersPerMililiter, new string[]{"dL/mL"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.DecimalFraction, new string[]{""}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.LitersPerLiter, new string[]{"L/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.LitersPerMililiter, new string[]{"L/mL"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.MicrolitersPerLiter, new string[]{"µL/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.MicrolitersPerMililiter, new string[]{"µL/mL"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.MillilitersPerLiter, new string[]{"mL/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.MillilitersPerMililiter, new string[]{"mL/mL"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.NanolitersPerLiter, new string[]{"nL/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.NanolitersPerMililiter, new string[]{"nL/mL"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.PartPerBillion, new string[]{"ppb"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.PartPerMillion, new string[]{"ppm"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.PartPerThousand, new string[]{"‰"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.PartPerTrillion, new string[]{"ppt"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.Percent, new string[]{"%", "% (v/v)"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.PicolitersPerLiter, new string[]{"pL/L"}), - ("en-US", typeof(VolumeConcentrationUnit), (int)VolumeConcentrationUnit.PicolitersPerMililiter, new string[]{"pL/mL"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.AcreFootPerDay, new string[]{"af/d"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.AcreFootPerHour, new string[]{"af/h"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.AcreFootPerMinute, new string[]{"af/m"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.AcreFootPerSecond, new string[]{"af/s"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CentiliterPerDay, new string[]{"cl/day", "cL/d", "cLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CentiliterPerMinute, new string[]{"cL/min", "cLPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CentiliterPerMinute, new string[]{"сл/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CentiliterPerSecond, new string[]{"cL/s", "cLPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CentiliterPerSecond, new string[]{"сл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicCentimeterPerMinute, new string[]{"cm³/min"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicCentimeterPerMinute, new string[]{"см³/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicDecimeterPerMinute, new string[]{"dm³/min"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicDecimeterPerMinute, new string[]{"дм³/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicFootPerHour, new string[]{"ft³/h", "cf/hr"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicFootPerMinute, new string[]{"ft³/min"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicFootPerSecond, new string[]{"ft³/s"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerDay, new string[]{"m³/d"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerHour, new string[]{"m³/h"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerHour, new string[]{"м³/ч"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerMinute, new string[]{"m³/min"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerMinute, new string[]{"м³/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerSecond, new string[]{"m³/s"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMeterPerSecond, new string[]{"м³/с"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMillimeterPerSecond, new string[]{"mm³/s"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicMillimeterPerSecond, new string[]{"мм³/с"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicYardPerDay, new string[]{"cy/day"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicYardPerHour, new string[]{"yd³/h"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicYardPerMinute, new string[]{"yd³/min"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.CubicYardPerSecond, new string[]{"yd³/s"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.DeciliterPerDay, new string[]{"dl/day", "dL/d", "dLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.DeciliterPerMinute, new string[]{"dL/min", "dLPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.DeciliterPerMinute, new string[]{"дл/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.DeciliterPerSecond, new string[]{"dL/s", "dLPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.DeciliterPerSecond, new string[]{"дл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.KiloliterPerDay, new string[]{"kl/day", "kL/d", "kLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.KiloliterPerMinute, new string[]{"kL/min", "kLPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.KiloliterPerMinute, new string[]{"кл/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.KiloliterPerSecond, new string[]{"kL/s", "kLPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.KiloliterPerSecond, new string[]{"кл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.KilousGallonPerMinute, new string[]{"kgal (U.S.)/min", "KGPM"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerDay, new string[]{"l/day", "L/d", "LPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerHour, new string[]{"L/h", "LPH"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerHour, new string[]{"л/ч"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerMinute, new string[]{"L/min", "LPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerMinute, new string[]{"л/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerSecond, new string[]{"L/s", "LPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.LiterPerSecond, new string[]{"л/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MegaliterPerDay, new string[]{"Ml/day", "ML/d", "MLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MegaukGallonPerSecond, new string[]{"Mgal (imp.)/s"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MicroliterPerDay, new string[]{"µl/day", "µL/d", "µLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MicroliterPerMinute, new string[]{"µL/min", "µLPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MicroliterPerMinute, new string[]{"мкл/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MicroliterPerSecond, new string[]{"µL/s", "µLPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MicroliterPerSecond, new string[]{"мкл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerDay, new string[]{"ml/day", "mL/d", "mLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerMinute, new string[]{"mL/min", "mLPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerMinute, new string[]{"мл/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerSecond, new string[]{"mL/s", "mLPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerSecond, new string[]{"мл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MillionUsGallonsPerDay, new string[]{"MGD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerDay, new string[]{"nl/day", "nL/d", "nLPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerMinute, new string[]{"nL/min", "nLPM"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerMinute, new string[]{"нл/мин"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerSecond, new string[]{"nL/s", "nLPS"}), - ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerSecond, new string[]{"нл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.OilBarrelPerDay, new string[]{"bbl/d", "BOPD"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.OilBarrelPerHour, new string[]{"bbl/hr", "bph"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.OilBarrelPerMinute, new string[]{"bbl/min", "bpm"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.OilBarrelPerSecond, new string[]{"bbl/s"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UkGallonPerDay, new string[]{"gal (U. K.)/d"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UkGallonPerHour, new string[]{"gal (imp.)/h"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UkGallonPerMinute, new string[]{"gal (imp.)/min"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UkGallonPerSecond, new string[]{"gal (imp.)/s"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UsGallonPerDay, new string[]{"gpd", "gal/d"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UsGallonPerHour, new string[]{"gal (U.S.)/h"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UsGallonPerMinute, new string[]{"gal (U.S.)/min", "GPM"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.UsGallonPerSecond, new string[]{"gal (U.S.)/s"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.CubicMeterPerMeter, new string[]{"m³/m"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.CubicYardPerFoot, new string[]{"yd³/ft"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.CubicYardPerUsSurveyFoot, new string[]{"yd³/ftUS"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.LiterPerKilometer, new string[]{"l/km"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.LiterPerMeter, new string[]{"l/m"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.LiterPerMillimeter, new string[]{"l/mm"}), - ("en-US", typeof(VolumePerLengthUnit), (int)VolumePerLengthUnit.OilBarrelPerFoot, new string[]{"bbl/ft"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, new string[]{"BTU/ft³·°F"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, new string[]{"cal/cm³·°C"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius, new string[]{"J/m³·°C"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, new string[]{"J/m³·K"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, new string[]{"kcal/cm³·°C"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, new string[]{"kJ/m³·°C"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, new string[]{"kJ/m³·K"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, new string[]{"MJ/m³·°C"}), - ("en-US", typeof(VolumetricHeatCapacityUnit), (int)VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, new string[]{"MJ/m³·K"}), - ("en-US", typeof(WarpingMomentOfInertiaUnit), (int)WarpingMomentOfInertiaUnit.CentimeterToTheSixth, new string[]{"cm⁶", "cm^6"}), - ("en-US", typeof(WarpingMomentOfInertiaUnit), (int)WarpingMomentOfInertiaUnit.DecimeterToTheSixth, new string[]{"dm⁶", "dm^6"}), - ("en-US", typeof(WarpingMomentOfInertiaUnit), (int)WarpingMomentOfInertiaUnit.FootToTheSixth, new string[]{"ft⁶", "ft^6"}), - ("en-US", typeof(WarpingMomentOfInertiaUnit), (int)WarpingMomentOfInertiaUnit.InchToTheSixth, new string[]{"in⁶", "in^6"}), - ("en-US", typeof(WarpingMomentOfInertiaUnit), (int)WarpingMomentOfInertiaUnit.MeterToTheSixth, new string[]{"m⁶", "m^6"}), - ("en-US", typeof(WarpingMomentOfInertiaUnit), (int)WarpingMomentOfInertiaUnit.MillimeterToTheSixth, new string[]{"mm⁶", "mm^6"}), - }; - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AccelerationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AccelerationUnit.g.cs deleted file mode 100644 index 149fda76fb..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AccelerationUnit.g.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AccelerationUnit - { - Undefined = 0, - CentimeterPerSecondSquared, - DecimeterPerSecondSquared, - FootPerSecondSquared, - InchPerSecondSquared, - KilometerPerSecondSquared, - KnotPerHour, - KnotPerMinute, - KnotPerSecond, - MeterPerSecondSquared, - MicrometerPerSecondSquared, - MillimeterPerSecondSquared, - MillistandardGravity, - NanometerPerSecondSquared, - StandardGravity, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs deleted file mode 100644 index ebd46a97d7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AmountOfSubstanceUnit - { - Undefined = 0, - Centimole, - CentipoundMole, - Decimole, - DecipoundMole, - Kilomole, - KilopoundMole, - Megamole, - Micromole, - MicropoundMole, - Millimole, - MillipoundMole, - Mole, - Nanomole, - NanopoundMole, - PoundMole, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmplitudeRatioUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmplitudeRatioUnit.g.cs deleted file mode 100644 index b7bb6ae224..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AmplitudeRatioUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AmplitudeRatioUnit - { - Undefined = 0, - DecibelMicrovolt, - DecibelMillivolt, - DecibelUnloaded, - DecibelVolt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AngleUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AngleUnit.g.cs deleted file mode 100644 index b61f169b80..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AngleUnit.g.cs +++ /dev/null @@ -1,48 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AngleUnit - { - Undefined = 0, - Arcminute, - Arcsecond, - Centiradian, - Deciradian, - Degree, - Gradian, - Microdegree, - Microradian, - Millidegree, - Milliradian, - Nanodegree, - Nanoradian, - NatoMil, - Radian, - Revolution, - Tilt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentEnergyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentEnergyUnit.g.cs deleted file mode 100644 index e7b4f42ee4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentEnergyUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ApparentEnergyUnit - { - Undefined = 0, - KilovoltampereHour, - MegavoltampereHour, - VoltampereHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentPowerUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentPowerUnit.g.cs deleted file mode 100644 index cd5563c699..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ApparentPowerUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ApparentPowerUnit - { - Undefined = 0, - Gigavoltampere, - Kilovoltampere, - Megavoltampere, - Voltampere, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaDensityUnit.g.cs deleted file mode 100644 index 84924b7cf3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaDensityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AreaDensityUnit - { - Undefined = 0, - KilogramPerSquareMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs deleted file mode 100644 index 3ca2fc3574..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AreaMomentOfInertiaUnit - { - Undefined = 0, - CentimeterToTheFourth, - DecimeterToTheFourth, - FootToTheFourth, - InchToTheFourth, - MeterToTheFourth, - MillimeterToTheFourth, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs deleted file mode 100644 index 2db395608c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/AreaUnit.g.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum AreaUnit - { - Undefined = 0, - Acre, - Hectare, - SquareCentimeter, - SquareDecimeter, - SquareFoot, - SquareInch, - SquareKilometer, - SquareMeter, - SquareMicrometer, - SquareMile, - SquareMillimeter, - SquareNauticalMile, - SquareYard, - UsSurveySquareFoot, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BitRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BitRateUnit.g.cs deleted file mode 100644 index e6328d9e65..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BitRateUnit.g.cs +++ /dev/null @@ -1,58 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum BitRateUnit - { - Undefined = 0, - BitPerSecond, - BytePerSecond, - ExabitPerSecond, - ExabytePerSecond, - ExbibitPerSecond, - ExbibytePerSecond, - GibibitPerSecond, - GibibytePerSecond, - GigabitPerSecond, - GigabytePerSecond, - KibibitPerSecond, - KibibytePerSecond, - KilobitPerSecond, - KilobytePerSecond, - MebibitPerSecond, - MebibytePerSecond, - MegabitPerSecond, - MegabytePerSecond, - PebibitPerSecond, - PebibytePerSecond, - PetabitPerSecond, - PetabytePerSecond, - TebibitPerSecond, - TebibytePerSecond, - TerabitPerSecond, - TerabytePerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs deleted file mode 100644 index bb10b001c3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum BrakeSpecificFuelConsumptionUnit - { - Undefined = 0, - GramPerKiloWattHour, - KilogramPerJoule, - - /// - /// The pound per horse power hour uses mechanical horse power and the imperial pound - /// - PoundPerMechanicalHorsepowerHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CapacitanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CapacitanceUnit.g.cs deleted file mode 100644 index 9b6a538fb9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CapacitanceUnit.g.cs +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum CapacitanceUnit - { - Undefined = 0, - Farad, - Kilofarad, - Megafarad, - Microfarad, - Millifarad, - Nanofarad, - Picofarad, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs deleted file mode 100644 index 9db9fa9d0d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum CoefficientOfThermalExpansionUnit - { - Undefined = 0, - InverseDegreeCelsius, - InverseDegreeFahrenheit, - InverseKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs deleted file mode 100644 index 94f3fd7948..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DensityUnit.g.cs +++ /dev/null @@ -1,72 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum DensityUnit - { - Undefined = 0, - CentigramPerDeciliter, - CentigramPerLiter, - CentigramPerMilliliter, - DecigramPerDeciliter, - DecigramPerLiter, - DecigramPerMilliliter, - GramPerCubicCentimeter, - GramPerCubicMeter, - GramPerCubicMillimeter, - GramPerDeciliter, - GramPerLiter, - GramPerMilliliter, - KilogramPerCubicCentimeter, - KilogramPerCubicMeter, - KilogramPerCubicMillimeter, - KilogramPerLiter, - KilopoundPerCubicFoot, - KilopoundPerCubicInch, - MicrogramPerCubicMeter, - MicrogramPerDeciliter, - MicrogramPerLiter, - MicrogramPerMilliliter, - MilligramPerCubicMeter, - MilligramPerDeciliter, - MilligramPerLiter, - MilligramPerMilliliter, - NanogramPerDeciliter, - NanogramPerLiter, - NanogramPerMilliliter, - PicogramPerDeciliter, - PicogramPerLiter, - PicogramPerMilliliter, - PoundPerCubicFoot, - PoundPerCubicInch, - PoundPerImperialGallon, - PoundPerUSGallon, - SlugPerCubicFoot, - TonnePerCubicCentimeter, - TonnePerCubicMeter, - TonnePerCubicMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DurationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DurationUnit.g.cs deleted file mode 100644 index 63af8ab3f0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DurationUnit.g.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum DurationUnit - { - Undefined = 0, - Day, - Hour, - Microsecond, - Millisecond, - Minute, - Month30, - Nanosecond, - Second, - Week, - Year365, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DynamicViscosityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DynamicViscosityUnit.g.cs deleted file mode 100644 index a0d6fc8e13..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/DynamicViscosityUnit.g.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum DynamicViscosityUnit - { - Undefined = 0, - Centipoise, - MicropascalSecond, - MillipascalSecond, - NewtonSecondPerMeterSquared, - PascalSecond, - Poise, - PoundForceSecondPerSquareFoot, - PoundForceSecondPerSquareInch, - PoundPerFootSecond, - Reyn, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs deleted file mode 100644 index 21e8f4edfa..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricAdmittanceUnit - { - Undefined = 0, - Microsiemens, - Millisiemens, - Nanosiemens, - Siemens, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs deleted file mode 100644 index 8797383f4a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricChargeDensityUnit - { - Undefined = 0, - CoulombPerCubicMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeUnit.g.cs deleted file mode 100644 index 65c4b8b58d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricChargeUnit.g.cs +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricChargeUnit - { - Undefined = 0, - AmpereHour, - Coulomb, - KiloampereHour, - MegaampereHour, - MilliampereHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductanceUnit.g.cs deleted file mode 100644 index 5b852833d7..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductanceUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricConductanceUnit - { - Undefined = 0, - Microsiemens, - Millisiemens, - Siemens, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductivityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductivityUnit.g.cs deleted file mode 100644 index 6afee546c8..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricConductivityUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricConductivityUnit - { - Undefined = 0, - SiemensPerFoot, - SiemensPerInch, - SiemensPerMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs deleted file mode 100644 index 9a0a8c9715..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricCurrentDensityUnit - { - Undefined = 0, - AmperePerSquareFoot, - AmperePerSquareInch, - AmperePerSquareMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs deleted file mode 100644 index ec7e9f0e02..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricCurrentGradientUnit - { - Undefined = 0, - AmperePerMicrosecond, - AmperePerMillisecond, - AmperePerNanosecond, - AmperePerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentUnit.g.cs deleted file mode 100644 index a2b690d5c4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricCurrentUnit.g.cs +++ /dev/null @@ -1,40 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricCurrentUnit - { - Undefined = 0, - Ampere, - Centiampere, - Kiloampere, - Megaampere, - Microampere, - Milliampere, - Nanoampere, - Picoampere, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricFieldUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricFieldUnit.g.cs deleted file mode 100644 index c3710d6ad6..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricFieldUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricFieldUnit - { - Undefined = 0, - VoltPerMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricInductanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricInductanceUnit.g.cs deleted file mode 100644 index 1cac8bbe3c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricInductanceUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricInductanceUnit - { - Undefined = 0, - Henry, - Microhenry, - Millihenry, - Nanohenry, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs deleted file mode 100644 index 87ba58a573..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricPotentialAcUnit - { - Undefined = 0, - KilovoltAc, - MegavoltAc, - MicrovoltAc, - MillivoltAc, - VoltAc, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs deleted file mode 100644 index d77a1dd97b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricPotentialChangeRateUnit - { - Undefined = 0, - KilovoltPerHour, - KilovoltPerMicrosecond, - KilovoltPerMinute, - KilovoltPerSecond, - MegavoltPerHour, - MegavoltPerMicrosecond, - MegavoltPerMinute, - MegavoltPerSecond, - MicrovoltPerHour, - MicrovoltPerMicrosecond, - MicrovoltPerMinute, - MicrovoltPerSecond, - MillivoltPerHour, - MillivoltPerMicrosecond, - MillivoltPerMinute, - MillivoltPerSecond, - VoltPerHour, - VoltPerMicrosecond, - VoltPerMinute, - VoltPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs deleted file mode 100644 index 8743571009..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricPotentialDcUnit - { - Undefined = 0, - KilovoltDc, - MegavoltDc, - MicrovoltDc, - MillivoltDc, - VoltDc, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialUnit.g.cs deleted file mode 100644 index a50136ad6b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricPotentialUnit.g.cs +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricPotentialUnit - { - Undefined = 0, - Kilovolt, - Megavolt, - Microvolt, - Millivolt, - Volt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistanceUnit.g.cs deleted file mode 100644 index e0cdbd4632..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistanceUnit.g.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricResistanceUnit - { - Undefined = 0, - Gigaohm, - Kiloohm, - Megaohm, - Microohm, - Milliohm, - Ohm, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistivityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistivityUnit.g.cs deleted file mode 100644 index cb6360eda3..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricResistivityUnit.g.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricResistivityUnit - { - Undefined = 0, - KiloohmCentimeter, - KiloohmMeter, - MegaohmCentimeter, - MegaohmMeter, - MicroohmCentimeter, - MicroohmMeter, - MilliohmCentimeter, - MilliohmMeter, - NanoohmCentimeter, - NanoohmMeter, - OhmCentimeter, - OhmMeter, - PicoohmCentimeter, - PicoohmMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs deleted file mode 100644 index 1e96388035..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ElectricSurfaceChargeDensityUnit - { - Undefined = 0, - CoulombPerSquareCentimeter, - CoulombPerSquareInch, - CoulombPerSquareMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EnergyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EnergyUnit.g.cs deleted file mode 100644 index f0fb9bb49d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EnergyUnit.g.cs +++ /dev/null @@ -1,68 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum EnergyUnit - { - Undefined = 0, - BritishThermalUnit, - Calorie, - DecathermEc, - DecathermImperial, - DecathermUs, - ElectronVolt, - Erg, - FootPound, - GigabritishThermalUnit, - GigaelectronVolt, - Gigajoule, - GigawattDay, - GigawattHour, - HorsepowerHour, - Joule, - KilobritishThermalUnit, - Kilocalorie, - KiloelectronVolt, - Kilojoule, - KilowattDay, - KilowattHour, - MegabritishThermalUnit, - Megacalorie, - MegaelectronVolt, - Megajoule, - MegawattDay, - MegawattHour, - Millijoule, - TeraelectronVolt, - TerawattDay, - TerawattHour, - ThermEc, - ThermImperial, - ThermUs, - WattDay, - WattHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EntropyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EntropyUnit.g.cs deleted file mode 100644 index 527b5b7f3c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/EntropyUnit.g.cs +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum EntropyUnit - { - Undefined = 0, - CaloriePerKelvin, - JoulePerDegreeCelsius, - JoulePerKelvin, - KilocaloriePerKelvin, - KilojoulePerDegreeCelsius, - KilojoulePerKelvin, - MegajoulePerKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceChangeRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceChangeRateUnit.g.cs deleted file mode 100644 index 872ff7774c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceChangeRateUnit.g.cs +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ForceChangeRateUnit - { - Undefined = 0, - CentinewtonPerSecond, - DecanewtonPerMinute, - DecanewtonPerSecond, - DecinewtonPerSecond, - KilonewtonPerMinute, - KilonewtonPerSecond, - KilopoundForcePerMinute, - KilopoundForcePerSecond, - MicronewtonPerSecond, - MillinewtonPerSecond, - NanonewtonPerSecond, - NewtonPerMinute, - NewtonPerSecond, - PoundForcePerMinute, - PoundForcePerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForcePerLengthUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForcePerLengthUnit.g.cs deleted file mode 100644 index e5f004605f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForcePerLengthUnit.g.cs +++ /dev/null @@ -1,70 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ForcePerLengthUnit - { - Undefined = 0, - CentinewtonPerCentimeter, - CentinewtonPerMeter, - CentinewtonPerMillimeter, - DecanewtonPerCentimeter, - DecanewtonPerMeter, - DecanewtonPerMillimeter, - DecinewtonPerCentimeter, - DecinewtonPerMeter, - DecinewtonPerMillimeter, - KilogramForcePerCentimeter, - KilogramForcePerMeter, - KilogramForcePerMillimeter, - KilonewtonPerCentimeter, - KilonewtonPerMeter, - KilonewtonPerMillimeter, - KilopoundForcePerFoot, - KilopoundForcePerInch, - MeganewtonPerCentimeter, - MeganewtonPerMeter, - MeganewtonPerMillimeter, - MicronewtonPerCentimeter, - MicronewtonPerMeter, - MicronewtonPerMillimeter, - MillinewtonPerCentimeter, - MillinewtonPerMeter, - MillinewtonPerMillimeter, - NanonewtonPerCentimeter, - NanonewtonPerMeter, - NanonewtonPerMillimeter, - NewtonPerCentimeter, - NewtonPerMeter, - NewtonPerMillimeter, - PoundForcePerFoot, - PoundForcePerInch, - PoundForcePerYard, - TonneForcePerCentimeter, - TonneForcePerMeter, - TonneForcePerMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceUnit.g.cs deleted file mode 100644 index b3124108bd..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ForceUnit.g.cs +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ForceUnit - { - Undefined = 0, - Decanewton, - Dyn, - KilogramForce, - Kilonewton, - KiloPond, - KilopoundForce, - Meganewton, - Micronewton, - Millinewton, - Newton, - OunceForce, - Poundal, - PoundForce, - - /// - /// The short ton-force is a unit of force equal to 2,000 pounds-force (907.18474 kgf), that is most commonly used in the United States – known there simply as the ton or US ton. - /// - /// https://en.wikipedia.org/wiki/Ton-force#Short_ton-force - ShortTonForce, - TonneForce, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FrequencyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FrequencyUnit.g.cs deleted file mode 100644 index fd5c104061..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FrequencyUnit.g.cs +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum FrequencyUnit - { - Undefined = 0, - BeatPerMinute, - BUnit, - CyclePerHour, - CyclePerMinute, - Gigahertz, - Hertz, - Kilohertz, - Megahertz, - PerSecond, - RadianPerSecond, - Terahertz, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FuelEfficiencyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FuelEfficiencyUnit.g.cs deleted file mode 100644 index 7dbfd0ab36..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/FuelEfficiencyUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum FuelEfficiencyUnit - { - Undefined = 0, - KilometerPerLiter, - LiterPer100Kilometers, - MilePerUkGallon, - MilePerUsGallon, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatFluxUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatFluxUnit.g.cs deleted file mode 100644 index bc76552e32..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatFluxUnit.g.cs +++ /dev/null @@ -1,50 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum HeatFluxUnit - { - Undefined = 0, - BtuPerHourSquareFoot, - BtuPerMinuteSquareFoot, - BtuPerSecondSquareFoot, - BtuPerSecondSquareInch, - CaloriePerSecondSquareCentimeter, - CentiwattPerSquareMeter, - DeciwattPerSquareMeter, - KilocaloriePerHourSquareMeter, - KilocaloriePerSecondSquareCentimeter, - KilowattPerSquareMeter, - MicrowattPerSquareMeter, - MilliwattPerSquareMeter, - NanowattPerSquareMeter, - PoundForcePerFootSecond, - PoundPerSecondCubed, - WattPerSquareFoot, - WattPerSquareInch, - WattPerSquareMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs deleted file mode 100644 index 6494d31478..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum HeatTransferCoefficientUnit - { - Undefined = 0, - BtuPerSquareFootDegreeFahrenheit, - WattPerSquareMeterCelsius, - WattPerSquareMeterKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IlluminanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IlluminanceUnit.g.cs deleted file mode 100644 index 3584e96825..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IlluminanceUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum IlluminanceUnit - { - Undefined = 0, - Kilolux, - Lux, - Megalux, - Millilux, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/InformationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/InformationUnit.g.cs deleted file mode 100644 index 2986de4b20..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/InformationUnit.g.cs +++ /dev/null @@ -1,58 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum InformationUnit - { - Undefined = 0, - Bit, - Byte, - Exabit, - Exabyte, - Exbibit, - Exbibyte, - Gibibit, - Gibibyte, - Gigabit, - Gigabyte, - Kibibit, - Kibibyte, - Kilobit, - Kilobyte, - Mebibit, - Mebibyte, - Megabit, - Megabyte, - Pebibit, - Pebibyte, - Petabit, - Petabyte, - Tebibit, - Tebibyte, - Terabit, - Terabyte, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradianceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradianceUnit.g.cs deleted file mode 100644 index 285e771afa..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradianceUnit.g.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum IrradianceUnit - { - Undefined = 0, - KilowattPerSquareCentimeter, - KilowattPerSquareMeter, - MegawattPerSquareCentimeter, - MegawattPerSquareMeter, - MicrowattPerSquareCentimeter, - MicrowattPerSquareMeter, - MilliwattPerSquareCentimeter, - MilliwattPerSquareMeter, - NanowattPerSquareCentimeter, - NanowattPerSquareMeter, - PicowattPerSquareCentimeter, - PicowattPerSquareMeter, - WattPerSquareCentimeter, - WattPerSquareMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradiationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradiationUnit.g.cs deleted file mode 100644 index 1a13e8d425..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/IrradiationUnit.g.cs +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum IrradiationUnit - { - Undefined = 0, - JoulePerSquareCentimeter, - JoulePerSquareMeter, - JoulePerSquareMillimeter, - KilojoulePerSquareMeter, - KilowattHourPerSquareMeter, - MillijoulePerSquareCentimeter, - WattHourPerSquareMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/KinematicViscosityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/KinematicViscosityUnit.g.cs deleted file mode 100644 index af0c4a0e22..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/KinematicViscosityUnit.g.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum KinematicViscosityUnit - { - Undefined = 0, - Centistokes, - Decistokes, - Kilostokes, - Microstokes, - Millistokes, - Nanostokes, - SquareFootPerSecond, - SquareMeterPerSecond, - Stokes, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LapseRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LapseRateUnit.g.cs deleted file mode 100644 index 0db5758f3e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LapseRateUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LapseRateUnit - { - Undefined = 0, - DegreeCelsiusPerKilometer, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LengthUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LengthUnit.g.cs deleted file mode 100644 index d2987f8ad4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LengthUnit.g.cs +++ /dev/null @@ -1,85 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LengthUnit - { - Undefined = 0, - - /// - /// One Astronomical Unit is the distance from the solar system Star, the sun, to planet Earth. - /// - /// https://en.wikipedia.org/wiki/Astronomical_unit - AstronomicalUnit, - Centimeter, - Chain, - Decimeter, - DtpPica, - DtpPoint, - Fathom, - Foot, - Hand, - Hectometer, - Inch, - KilolightYear, - Kilometer, - Kiloparsec, - - /// - /// A Light Year (ly) is the distance that light travel during an Earth year, ie 365 days. - /// - /// https://en.wikipedia.org/wiki/Light-year - LightYear, - MegalightYear, - Megaparsec, - Meter, - Microinch, - Micrometer, - Mil, - Mile, - Millimeter, - Nanometer, - NauticalMile, - - /// - /// A parsec is defined as the distance at which one astronomical unit (AU) subtends an angle of one arcsecond. - /// - /// https://en.wikipedia.org/wiki/Parsec - Parsec, - PrinterPica, - PrinterPoint, - Shackle, - - /// - /// Solar radius is a ratio unit to the radius of the solar system star, the sun. - /// - /// https://en.wikipedia.org/wiki/Stellar_classification - SolarRadius, - Twip, - UsSurveyFoot, - Yard, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LevelUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LevelUnit.g.cs deleted file mode 100644 index d1cd5c65ed..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LevelUnit.g.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LevelUnit - { - Undefined = 0, - Decibel, - Neper, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearDensityUnit.g.cs deleted file mode 100644 index 70a4f47764..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearDensityUnit.g.cs +++ /dev/null @@ -1,46 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LinearDensityUnit - { - Undefined = 0, - GramPerCentimeter, - GramPerMeter, - GramPerMillimeter, - KilogramPerCentimeter, - KilogramPerMeter, - KilogramPerMillimeter, - MicrogramPerCentimeter, - MicrogramPerMeter, - MicrogramPerMillimeter, - MilligramPerCentimeter, - MilligramPerMeter, - MilligramPerMillimeter, - PoundPerFoot, - PoundPerInch, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearPowerDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearPowerDensityUnit.g.cs deleted file mode 100644 index 0f744effb5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LinearPowerDensityUnit.g.cs +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LinearPowerDensityUnit - { - Undefined = 0, - GigawattPerCentimeter, - GigawattPerFoot, - GigawattPerInch, - GigawattPerMeter, - GigawattPerMillimeter, - KilowattPerCentimeter, - KilowattPerFoot, - KilowattPerInch, - KilowattPerMeter, - KilowattPerMillimeter, - MegawattPerCentimeter, - MegawattPerFoot, - MegawattPerInch, - MegawattPerMeter, - MegawattPerMillimeter, - MilliwattPerCentimeter, - MilliwattPerFoot, - MilliwattPerInch, - MilliwattPerMeter, - MilliwattPerMillimeter, - WattPerCentimeter, - WattPerFoot, - WattPerInch, - WattPerMeter, - WattPerMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminosityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminosityUnit.g.cs deleted file mode 100644 index 309e51093d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminosityUnit.g.cs +++ /dev/null @@ -1,47 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LuminosityUnit - { - Undefined = 0, - Decawatt, - Deciwatt, - Femtowatt, - Gigawatt, - Kilowatt, - Megawatt, - Microwatt, - Milliwatt, - Nanowatt, - Petawatt, - Picowatt, - /// https://www.britannica.com/science/luminosity - SolarLuminosity, - Terawatt, - Watt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousFluxUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousFluxUnit.g.cs deleted file mode 100644 index 7d3122939f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousFluxUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LuminousFluxUnit - { - Undefined = 0, - Lumen, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousIntensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousIntensityUnit.g.cs deleted file mode 100644 index 16feeb4596..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/LuminousIntensityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum LuminousIntensityUnit - { - Undefined = 0, - Candela, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFieldUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFieldUnit.g.cs deleted file mode 100644 index 5ce5acdc3f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFieldUnit.g.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MagneticFieldUnit - { - Undefined = 0, - Gauss, - Microtesla, - Milligauss, - Millitesla, - Nanotesla, - Tesla, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFluxUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFluxUnit.g.cs deleted file mode 100644 index 241a0fc57b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagneticFluxUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MagneticFluxUnit - { - Undefined = 0, - Weber, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagnetizationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagnetizationUnit.g.cs deleted file mode 100644 index 96438162e4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MagnetizationUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MagnetizationUnit - { - Undefined = 0, - AmperePerMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassConcentrationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassConcentrationUnit.g.cs deleted file mode 100644 index 75513af502..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassConcentrationUnit.g.cs +++ /dev/null @@ -1,81 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MassConcentrationUnit - { - Undefined = 0, - CentigramPerDeciliter, - CentigramPerLiter, - CentigramPerMicroliter, - CentigramPerMilliliter, - DecigramPerDeciliter, - DecigramPerLiter, - DecigramPerMicroliter, - DecigramPerMilliliter, - GramPerCubicCentimeter, - GramPerCubicMeter, - GramPerCubicMillimeter, - GramPerDeciliter, - GramPerLiter, - GramPerMicroliter, - GramPerMilliliter, - KilogramPerCubicCentimeter, - KilogramPerCubicMeter, - KilogramPerCubicMillimeter, - KilogramPerLiter, - KilopoundPerCubicFoot, - KilopoundPerCubicInch, - MicrogramPerCubicMeter, - MicrogramPerDeciliter, - MicrogramPerLiter, - MicrogramPerMicroliter, - MicrogramPerMilliliter, - MilligramPerCubicMeter, - MilligramPerDeciliter, - MilligramPerLiter, - MilligramPerMicroliter, - MilligramPerMilliliter, - NanogramPerDeciliter, - NanogramPerLiter, - NanogramPerMicroliter, - NanogramPerMilliliter, - OuncePerImperialGallon, - OuncePerUSGallon, - PicogramPerDeciliter, - PicogramPerLiter, - PicogramPerMicroliter, - PicogramPerMilliliter, - PoundPerCubicFoot, - PoundPerCubicInch, - PoundPerImperialGallon, - PoundPerUSGallon, - SlugPerCubicFoot, - TonnePerCubicCentimeter, - TonnePerCubicMeter, - TonnePerCubicMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFlowUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFlowUnit.g.cs deleted file mode 100644 index acf8b9cba6..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFlowUnit.g.cs +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MassFlowUnit - { - Undefined = 0, - CentigramPerDay, - CentigramPerSecond, - DecagramPerDay, - DecagramPerSecond, - DecigramPerDay, - DecigramPerSecond, - GramPerDay, - GramPerHour, - GramPerSecond, - HectogramPerDay, - HectogramPerSecond, - KilogramPerDay, - KilogramPerHour, - KilogramPerMinute, - KilogramPerSecond, - MegagramPerDay, - MegapoundPerDay, - MegapoundPerHour, - MegapoundPerMinute, - MegapoundPerSecond, - MicrogramPerDay, - MicrogramPerSecond, - MilligramPerDay, - MilligramPerSecond, - NanogramPerDay, - NanogramPerSecond, - PoundPerDay, - PoundPerHour, - PoundPerMinute, - PoundPerSecond, - ShortTonPerHour, - TonnePerDay, - TonnePerHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFluxUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFluxUnit.g.cs deleted file mode 100644 index 2723abf13a..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFluxUnit.g.cs +++ /dev/null @@ -1,44 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MassFluxUnit - { - Undefined = 0, - GramPerHourPerSquareCentimeter, - GramPerHourPerSquareMeter, - GramPerHourPerSquareMillimeter, - GramPerSecondPerSquareCentimeter, - GramPerSecondPerSquareMeter, - GramPerSecondPerSquareMillimeter, - KilogramPerHourPerSquareCentimeter, - KilogramPerHourPerSquareMeter, - KilogramPerHourPerSquareMillimeter, - KilogramPerSecondPerSquareCentimeter, - KilogramPerSecondPerSquareMeter, - KilogramPerSecondPerSquareMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFractionUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFractionUnit.g.cs deleted file mode 100644 index 8151a08dfd..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassFractionUnit.g.cs +++ /dev/null @@ -1,56 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MassFractionUnit - { - Undefined = 0, - CentigramPerGram, - CentigramPerKilogram, - DecagramPerGram, - DecagramPerKilogram, - DecigramPerGram, - DecigramPerKilogram, - DecimalFraction, - GramPerGram, - GramPerKilogram, - HectogramPerGram, - HectogramPerKilogram, - KilogramPerGram, - KilogramPerKilogram, - MicrogramPerGram, - MicrogramPerKilogram, - MilligramPerGram, - MilligramPerKilogram, - NanogramPerGram, - NanogramPerKilogram, - PartPerBillion, - PartPerMillion, - PartPerThousand, - PartPerTrillion, - Percent, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs deleted file mode 100644 index 972b52d375..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs +++ /dev/null @@ -1,60 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MassMomentOfInertiaUnit - { - Undefined = 0, - GramSquareCentimeter, - GramSquareDecimeter, - GramSquareMeter, - GramSquareMillimeter, - KilogramSquareCentimeter, - KilogramSquareDecimeter, - KilogramSquareMeter, - KilogramSquareMillimeter, - KilotonneSquareCentimeter, - KilotonneSquareDecimeter, - KilotonneSquareMeter, - KilotonneSquareMilimeter, - MegatonneSquareCentimeter, - MegatonneSquareDecimeter, - MegatonneSquareMeter, - MegatonneSquareMilimeter, - MilligramSquareCentimeter, - MilligramSquareDecimeter, - MilligramSquareMeter, - MilligramSquareMillimeter, - PoundSquareFoot, - PoundSquareInch, - SlugSquareFoot, - SlugSquareInch, - TonneSquareCentimeter, - TonneSquareDecimeter, - TonneSquareMeter, - TonneSquareMilimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassUnit.g.cs deleted file mode 100644 index 37a441d742..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MassUnit.g.cs +++ /dev/null @@ -1,111 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MassUnit - { - Undefined = 0, - Centigram, - Decagram, - Decigram, - - /// - /// Earth mass is a ratio unit to the mass of planet Earth. - /// - /// https://en.wikipedia.org/wiki/Earth_mass - EarthMass, - - /// - /// A grain is a unit of measurement of mass, and in the troy weight, avoirdupois, and Apothecaries' system, equal to exactly 64.79891 milligrams. - /// - /// https://en.wikipedia.org/wiki/Grain_(unit) - Grain, - Gram, - Hectogram, - Kilogram, - Kilopound, - Kilotonne, - - /// - /// The long or imperial hundredweight (abbreviation cwt) is a unit of mass equal to 112 pounds in US and Canada. - /// - /// https://en.wikipedia.org/wiki/Hundredweight - LongHundredweight, - - /// - /// Long ton (weight ton or Imperial ton) is a unit of mass equal to 2,240 pounds (1,016 kg) and is the name for the unit called the "ton" in the avoirdupois or Imperial system of measurements that was used in the United Kingdom and several other Commonwealth countries before metrication. - /// - /// http://en.wikipedia.org/wiki/Long_ton - LongTon, - Megapound, - Megatonne, - Microgram, - Milligram, - Nanogram, - - /// - /// An ounce (abbreviated oz) is usually the international avoirdupois ounce as used in the United States customary and British imperial systems, which is equal to one-sixteenth of a pound or approximately 28 grams. The abbreviation 'oz' derives from the Italian word onza (now spelled oncia). - /// - /// http://en.wikipedia.org/wiki/Ounce - Ounce, - - /// - /// The pound or pound-mass (abbreviations: lb, lbm) is a unit of mass used in the imperial, United States customary and other systems of measurement. A number of different definitions have been used, the most common today being the international avoirdupois pound which is legally defined as exactly 0.45359237 kilograms, and which is divided into 16 avoirdupois ounces. - /// - Pound, - - /// - /// The short hundredweight (abbreviation cwt) is a unit of mass equal to 100 pounds in US and Canada. In British English, the short hundredweight is referred to as the "cental". - /// - /// https://en.wikipedia.org/wiki/Hundredweight - ShortHundredweight, - - /// - /// The short ton is a unit of mass equal to 2,000 pounds (907.18474 kg), that is most commonly used in the United States – known there simply as the ton. - /// - /// http://en.wikipedia.org/wiki/Short_ton - ShortTon, - - /// - /// The slug (abbreviation slug) is a unit of mass that is accelerated by 1 ft/s² when a force of one pound (lbf) is exerted on it. - /// - /// http://en.wikipedia.org/wiki/Slug_(unit) - Slug, - - /// - /// Solar mass is a ratio unit to the mass of the solar system star, the sun. - /// - /// https://en.wikipedia.org/wiki/Solar_mass - SolarMass, - - /// - /// The stone (abbreviation st) is a unit of mass equal to 14 pounds avoirdupois (about 6.35 kilograms) used in Great Britain and Ireland for measuring human body weight. - /// - /// http://en.wikipedia.org/wiki/Stone_(unit) - Stone, - Tonne, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEnergyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEnergyUnit.g.cs deleted file mode 100644 index cd0ba80e11..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEnergyUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MolarEnergyUnit - { - Undefined = 0, - JoulePerMole, - KilojoulePerMole, - MegajoulePerMole, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEntropyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEntropyUnit.g.cs deleted file mode 100644 index edd5decabe..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarEntropyUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MolarEntropyUnit - { - Undefined = 0, - JoulePerMoleKelvin, - KilojoulePerMoleKelvin, - MegajoulePerMoleKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarMassUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarMassUnit.g.cs deleted file mode 100644 index 2e955277a5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarMassUnit.g.cs +++ /dev/null @@ -1,44 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MolarMassUnit - { - Undefined = 0, - CentigramPerMole, - DecagramPerMole, - DecigramPerMole, - GramPerMole, - HectogramPerMole, - KilogramPerMole, - KilopoundPerMole, - MegapoundPerMole, - MicrogramPerMole, - MilligramPerMole, - NanogramPerMole, - PoundPerMole, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarityUnit.g.cs deleted file mode 100644 index 854a8969e0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/MolarityUnit.g.cs +++ /dev/null @@ -1,40 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum MolarityUnit - { - Undefined = 0, - CentimolesPerLiter, - DecimolesPerLiter, - MicromolesPerLiter, - MillimolesPerLiter, - MolesPerCubicMeter, - MolesPerLiter, - NanomolesPerLiter, - PicomolesPerLiter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermeabilityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermeabilityUnit.g.cs deleted file mode 100644 index 9d236dbc9c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermeabilityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PermeabilityUnit - { - Undefined = 0, - HenryPerMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermittivityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermittivityUnit.g.cs deleted file mode 100644 index 02caf933de..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PermittivityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PermittivityUnit - { - Undefined = 0, - FaradPerMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerDensityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerDensityUnit.g.cs deleted file mode 100644 index 10946ecb5b..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerDensityUnit.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PowerDensityUnit - { - Undefined = 0, - DecawattPerCubicFoot, - DecawattPerCubicInch, - DecawattPerCubicMeter, - DecawattPerLiter, - DeciwattPerCubicFoot, - DeciwattPerCubicInch, - DeciwattPerCubicMeter, - DeciwattPerLiter, - GigawattPerCubicFoot, - GigawattPerCubicInch, - GigawattPerCubicMeter, - GigawattPerLiter, - KilowattPerCubicFoot, - KilowattPerCubicInch, - KilowattPerCubicMeter, - KilowattPerLiter, - MegawattPerCubicFoot, - MegawattPerCubicInch, - MegawattPerCubicMeter, - MegawattPerLiter, - MicrowattPerCubicFoot, - MicrowattPerCubicInch, - MicrowattPerCubicMeter, - MicrowattPerLiter, - MilliwattPerCubicFoot, - MilliwattPerCubicInch, - MilliwattPerCubicMeter, - MilliwattPerLiter, - NanowattPerCubicFoot, - NanowattPerCubicInch, - NanowattPerCubicMeter, - NanowattPerLiter, - PicowattPerCubicFoot, - PicowattPerCubicInch, - PicowattPerCubicMeter, - PicowattPerLiter, - TerawattPerCubicFoot, - TerawattPerCubicInch, - TerawattPerCubicMeter, - TerawattPerLiter, - WattPerCubicFoot, - WattPerCubicInch, - WattPerCubicMeter, - WattPerLiter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerRatioUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerRatioUnit.g.cs deleted file mode 100644 index e4a29c66ed..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerRatioUnit.g.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PowerRatioUnit - { - Undefined = 0, - DecibelMilliwatt, - DecibelWatt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerUnit.g.cs deleted file mode 100644 index 43701759dc..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PowerUnit.g.cs +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PowerUnit - { - Undefined = 0, - BoilerHorsepower, - BritishThermalUnitPerHour, - Decawatt, - Deciwatt, - ElectricalHorsepower, - Femtowatt, - GigajoulePerHour, - Gigawatt, - HydraulicHorsepower, - JoulePerHour, - KilobritishThermalUnitPerHour, - KilojoulePerHour, - Kilowatt, - MechanicalHorsepower, - MegajoulePerHour, - Megawatt, - MetricHorsepower, - Microwatt, - MillijoulePerHour, - Milliwatt, - Nanowatt, - Petawatt, - Picowatt, - Terawatt, - Watt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureChangeRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureChangeRateUnit.g.cs deleted file mode 100644 index 60fe8b12a9..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureChangeRateUnit.g.cs +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PressureChangeRateUnit - { - Undefined = 0, - AtmospherePerSecond, - KilopascalPerMinute, - KilopascalPerSecond, - KilopoundForcePerSquareInchPerMinute, - KilopoundForcePerSquareInchPerSecond, - MegapascalPerMinute, - MegapascalPerSecond, - MegapoundForcePerSquareInchPerMinute, - MegapoundForcePerSquareInchPerSecond, - PascalPerMinute, - PascalPerSecond, - PoundForcePerSquareInchPerMinute, - PoundForcePerSquareInchPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureUnit.g.cs deleted file mode 100644 index 19dc745d2f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/PressureUnit.g.cs +++ /dev/null @@ -1,76 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum PressureUnit - { - Undefined = 0, - Atmosphere, - Bar, - Centibar, - Decapascal, - Decibar, - DynePerSquareCentimeter, - FootOfElevation, - FootOfHead, - Gigapascal, - Hectopascal, - InchOfMercury, - InchOfWaterColumn, - Kilobar, - KilogramForcePerSquareCentimeter, - KilogramForcePerSquareMeter, - KilogramForcePerSquareMillimeter, - KilonewtonPerSquareCentimeter, - KilonewtonPerSquareMeter, - KilonewtonPerSquareMillimeter, - Kilopascal, - KilopoundForcePerSquareFoot, - KilopoundForcePerSquareInch, - Megabar, - MeganewtonPerSquareMeter, - Megapascal, - MeterOfElevation, - MeterOfHead, - Microbar, - Micropascal, - Millibar, - MillimeterOfMercury, - Millipascal, - NewtonPerSquareCentimeter, - NewtonPerSquareMeter, - NewtonPerSquareMillimeter, - Pascal, - PoundForcePerSquareFoot, - PoundForcePerSquareInch, - PoundPerInchSecondSquared, - TechnicalAtmosphere, - TonneForcePerSquareCentimeter, - TonneForcePerSquareMeter, - TonneForcePerSquareMillimeter, - Torr, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioChangeRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioChangeRateUnit.g.cs deleted file mode 100644 index bcde32166e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioChangeRateUnit.g.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RatioChangeRateUnit - { - Undefined = 0, - DecimalFractionPerSecond, - PercentPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioUnit.g.cs deleted file mode 100644 index c4d62326dc..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RatioUnit.g.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RatioUnit - { - Undefined = 0, - DecimalFraction, - PartPerBillion, - PartPerMillion, - PartPerThousand, - PartPerTrillion, - Percent, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactiveEnergyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactiveEnergyUnit.g.cs deleted file mode 100644 index 9c5e12ddb0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactiveEnergyUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ReactiveEnergyUnit - { - Undefined = 0, - KilovoltampereReactiveHour, - MegavoltampereReactiveHour, - VoltampereReactiveHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactivePowerUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactivePowerUnit.g.cs deleted file mode 100644 index 6dcb0a2687..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReactivePowerUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ReactivePowerUnit - { - Undefined = 0, - GigavoltampereReactive, - KilovoltampereReactive, - MegavoltampereReactive, - VoltampereReactive, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalAreaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalAreaUnit.g.cs deleted file mode 100644 index 822c6e03eb..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalAreaUnit.g.cs +++ /dev/null @@ -1,43 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ReciprocalAreaUnit - { - Undefined = 0, - InverseSquareCentimeter, - InverseSquareDecimeter, - InverseSquareFoot, - InverseSquareInch, - InverseSquareKilometer, - InverseSquareMeter, - InverseSquareMicrometer, - InverseSquareMile, - InverseSquareMillimeter, - InverseSquareYard, - InverseUsSurveySquareFoot, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalLengthUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalLengthUnit.g.cs deleted file mode 100644 index 166f08af87..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ReciprocalLengthUnit.g.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ReciprocalLengthUnit - { - Undefined = 0, - InverseCentimeter, - InverseFoot, - InverseInch, - InverseMeter, - InverseMicroinch, - InverseMil, - InverseMile, - InverseMillimeter, - InverseUsSurveyFoot, - InverseYard, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RelativeHumidityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RelativeHumidityUnit.g.cs deleted file mode 100644 index d1ff2b1726..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RelativeHumidityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RelativeHumidityUnit - { - Undefined = 0, - Percent, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalAccelerationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalAccelerationUnit.g.cs deleted file mode 100644 index e207d6c1ae..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalAccelerationUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RotationalAccelerationUnit - { - Undefined = 0, - DegreePerSecondSquared, - RadianPerSecondSquared, - RevolutionPerMinutePerSecond, - RevolutionPerSecondSquared, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalSpeedUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalSpeedUnit.g.cs deleted file mode 100644 index 93b644ac7c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalSpeedUnit.g.cs +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RotationalSpeedUnit - { - Undefined = 0, - CentiradianPerSecond, - DeciradianPerSecond, - DegreePerMinute, - DegreePerSecond, - MicrodegreePerSecond, - MicroradianPerSecond, - MillidegreePerSecond, - MilliradianPerSecond, - NanodegreePerSecond, - NanoradianPerSecond, - RadianPerSecond, - RevolutionPerMinute, - RevolutionPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs deleted file mode 100644 index 479001f79c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RotationalStiffnessPerLengthUnit - { - Undefined = 0, - KilonewtonMeterPerRadianPerMeter, - KilopoundForceFootPerDegreesPerFoot, - MeganewtonMeterPerRadianPerMeter, - NewtonMeterPerRadianPerMeter, - PoundForceFootPerDegreesPerFoot, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessUnit.g.cs deleted file mode 100644 index 1ca970ecb1..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/RotationalStiffnessUnit.g.cs +++ /dev/null @@ -1,65 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum RotationalStiffnessUnit - { - Undefined = 0, - CentinewtonMeterPerDegree, - CentinewtonMillimeterPerDegree, - CentinewtonMillimeterPerRadian, - DecanewtonMeterPerDegree, - DecanewtonMillimeterPerDegree, - DecanewtonMillimeterPerRadian, - DecinewtonMeterPerDegree, - DecinewtonMillimeterPerDegree, - DecinewtonMillimeterPerRadian, - KilonewtonMeterPerDegree, - KilonewtonMeterPerRadian, - KilonewtonMillimeterPerDegree, - KilonewtonMillimeterPerRadian, - KilopoundForceFootPerDegrees, - MeganewtonMeterPerDegree, - MeganewtonMeterPerRadian, - MeganewtonMillimeterPerDegree, - MeganewtonMillimeterPerRadian, - MicronewtonMeterPerDegree, - MicronewtonMillimeterPerDegree, - MicronewtonMillimeterPerRadian, - MillinewtonMeterPerDegree, - MillinewtonMillimeterPerDegree, - MillinewtonMillimeterPerRadian, - NanonewtonMeterPerDegree, - NanonewtonMillimeterPerDegree, - NanonewtonMillimeterPerRadian, - NewtonMeterPerDegree, - NewtonMeterPerRadian, - NewtonMillimeterPerDegree, - NewtonMillimeterPerRadian, - PoundForceFeetPerRadian, - PoundForceFootPerDegrees, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ScalarUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ScalarUnit.g.cs deleted file mode 100644 index 3b0891f314..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ScalarUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ScalarUnit - { - Undefined = 0, - Amount, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SolidAngleUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SolidAngleUnit.g.cs deleted file mode 100644 index 1fa9137298..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SolidAngleUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SolidAngleUnit - { - Undefined = 0, - Steradian, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEnergyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEnergyUnit.g.cs deleted file mode 100644 index 3c59f4a00f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEnergyUnit.g.cs +++ /dev/null @@ -1,57 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SpecificEnergyUnit - { - Undefined = 0, - BtuPerPound, - CaloriePerGram, - GigawattDayPerKilogram, - GigawattDayPerShortTon, - GigawattDayPerTonne, - GigawattHourPerKilogram, - JoulePerKilogram, - KilocaloriePerGram, - KilojoulePerKilogram, - KilowattDayPerKilogram, - KilowattDayPerShortTon, - KilowattDayPerTonne, - KilowattHourPerKilogram, - MegajoulePerKilogram, - MegawattDayPerKilogram, - MegawattDayPerShortTon, - MegawattDayPerTonne, - MegawattHourPerKilogram, - TerawattDayPerKilogram, - TerawattDayPerShortTon, - TerawattDayPerTonne, - WattDayPerKilogram, - WattDayPerShortTon, - WattDayPerTonne, - WattHourPerKilogram, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEntropyUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEntropyUnit.g.cs deleted file mode 100644 index 744c7608bf..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificEntropyUnit.g.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SpecificEntropyUnit - { - Undefined = 0, - BtuPerPoundFahrenheit, - CaloriePerGramKelvin, - JoulePerKilogramDegreeCelsius, - JoulePerKilogramKelvin, - KilocaloriePerGramKelvin, - KilojoulePerKilogramDegreeCelsius, - KilojoulePerKilogramKelvin, - MegajoulePerKilogramDegreeCelsius, - MegajoulePerKilogramKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs deleted file mode 100644 index f83628860d..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs +++ /dev/null @@ -1,36 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SpecificFuelConsumptionUnit - { - Undefined = 0, - GramPerKiloNewtonSecond, - KilogramPerKilogramForceHour, - KilogramPerKiloNewtonSecond, - PoundMassPerPoundForceHour, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificVolumeUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificVolumeUnit.g.cs deleted file mode 100644 index 64f2e15212..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificVolumeUnit.g.cs +++ /dev/null @@ -1,35 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SpecificVolumeUnit - { - Undefined = 0, - CubicFootPerPound, - CubicMeterPerKilogram, - MillicubicMeterPerKilogram, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificWeightUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificWeightUnit.g.cs deleted file mode 100644 index 21c71caacf..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpecificWeightUnit.g.cs +++ /dev/null @@ -1,49 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SpecificWeightUnit - { - Undefined = 0, - KilogramForcePerCubicCentimeter, - KilogramForcePerCubicMeter, - KilogramForcePerCubicMillimeter, - KilonewtonPerCubicCentimeter, - KilonewtonPerCubicMeter, - KilonewtonPerCubicMillimeter, - KilopoundForcePerCubicFoot, - KilopoundForcePerCubicInch, - MeganewtonPerCubicMeter, - NewtonPerCubicCentimeter, - NewtonPerCubicMeter, - NewtonPerCubicMillimeter, - PoundForcePerCubicFoot, - PoundForcePerCubicInch, - TonneForcePerCubicCentimeter, - TonneForcePerCubicMeter, - TonneForcePerCubicMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpeedUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpeedUnit.g.cs deleted file mode 100644 index 77335fd679..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/SpeedUnit.g.cs +++ /dev/null @@ -1,64 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum SpeedUnit - { - Undefined = 0, - CentimeterPerHour, - CentimeterPerMinute, - CentimeterPerSecond, - DecimeterPerMinute, - DecimeterPerSecond, - FootPerHour, - FootPerMinute, - FootPerSecond, - InchPerHour, - InchPerMinute, - InchPerSecond, - KilometerPerHour, - KilometerPerMinute, - KilometerPerSecond, - Knot, - MeterPerHour, - MeterPerMinute, - MeterPerSecond, - MicrometerPerMinute, - MicrometerPerSecond, - MilePerHour, - MillimeterPerHour, - MillimeterPerMinute, - MillimeterPerSecond, - NanometerPerMinute, - NanometerPerSecond, - UsSurveyFootPerHour, - UsSurveyFootPerMinute, - UsSurveyFootPerSecond, - YardPerHour, - YardPerMinute, - YardPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs deleted file mode 100644 index 86f6e5d486..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum StandardVolumeFlowUnit - { - Undefined = 0, - StandardCubicCentimeterPerMinute, - StandardCubicFootPerHour, - StandardCubicFootPerMinute, - StandardCubicFootPerSecond, - StandardCubicMeterPerDay, - StandardCubicMeterPerHour, - StandardCubicMeterPerMinute, - StandardCubicMeterPerSecond, - StandardLiterPerMinute, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs deleted file mode 100644 index 1170aab72f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum TemperatureChangeRateUnit - { - Undefined = 0, - CentidegreeCelsiusPerSecond, - DecadegreeCelsiusPerSecond, - DecidegreeCelsiusPerSecond, - DegreeCelsiusPerMinute, - DegreeCelsiusPerSecond, - HectodegreeCelsiusPerSecond, - KilodegreeCelsiusPerSecond, - MicrodegreeCelsiusPerSecond, - MillidegreeCelsiusPerSecond, - NanodegreeCelsiusPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureDeltaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureDeltaUnit.g.cs deleted file mode 100644 index 7fded81179..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureDeltaUnit.g.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum TemperatureDeltaUnit - { - Undefined = 0, - DegreeCelsius, - DegreeDelisle, - DegreeFahrenheit, - DegreeNewton, - DegreeRankine, - DegreeReaumur, - DegreeRoemer, - Kelvin, - MillidegreeCelsius, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureUnit.g.cs deleted file mode 100644 index 9fef394aec..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TemperatureUnit.g.cs +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum TemperatureUnit - { - Undefined = 0, - DegreeCelsius, - DegreeDelisle, - DegreeFahrenheit, - DegreeNewton, - DegreeRankine, - DegreeReaumur, - DegreeRoemer, - Kelvin, - MillidegreeCelsius, - SolarTemperature, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalConductivityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalConductivityUnit.g.cs deleted file mode 100644 index b57d36aa6e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalConductivityUnit.g.cs +++ /dev/null @@ -1,34 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ThermalConductivityUnit - { - Undefined = 0, - BtuPerHourFootFahrenheit, - WattPerMeterKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalResistanceUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalResistanceUnit.g.cs deleted file mode 100644 index 643e5ba89f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/ThermalResistanceUnit.g.cs +++ /dev/null @@ -1,37 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum ThermalResistanceUnit - { - Undefined = 0, - HourSquareFeetDegreeFahrenheitPerBtu, - SquareCentimeterHourDegreeCelsiusPerKilocalorie, - SquareCentimeterKelvinPerWatt, - SquareMeterDegreeCelsiusPerWatt, - SquareMeterKelvinPerKilowatt, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorquePerLengthUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorquePerLengthUnit.g.cs deleted file mode 100644 index f400c141d5..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorquePerLengthUnit.g.cs +++ /dev/null @@ -1,53 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum TorquePerLengthUnit - { - Undefined = 0, - KilogramForceCentimeterPerMeter, - KilogramForceMeterPerMeter, - KilogramForceMillimeterPerMeter, - KilonewtonCentimeterPerMeter, - KilonewtonMeterPerMeter, - KilonewtonMillimeterPerMeter, - KilopoundForceFootPerFoot, - KilopoundForceInchPerFoot, - MeganewtonCentimeterPerMeter, - MeganewtonMeterPerMeter, - MeganewtonMillimeterPerMeter, - MegapoundForceFootPerFoot, - MegapoundForceInchPerFoot, - NewtonCentimeterPerMeter, - NewtonMeterPerMeter, - NewtonMillimeterPerMeter, - PoundForceFootPerFoot, - PoundForceInchPerFoot, - TonneForceCentimeterPerMeter, - TonneForceMeterPerMeter, - TonneForceMillimeterPerMeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorqueUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorqueUnit.g.cs deleted file mode 100644 index b8f52ad98e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TorqueUnit.g.cs +++ /dev/null @@ -1,54 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum TorqueUnit - { - Undefined = 0, - KilogramForceCentimeter, - KilogramForceMeter, - KilogramForceMillimeter, - KilonewtonCentimeter, - KilonewtonMeter, - KilonewtonMillimeter, - KilopoundForceFoot, - KilopoundForceInch, - MeganewtonCentimeter, - MeganewtonMeter, - MeganewtonMillimeter, - MegapoundForceFoot, - MegapoundForceInch, - NewtonCentimeter, - NewtonMeter, - NewtonMillimeter, - PoundalFoot, - PoundForceFoot, - PoundForceInch, - TonneForceCentimeter, - TonneForceMeter, - TonneForceMillimeter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TurbidityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TurbidityUnit.g.cs deleted file mode 100644 index 8e9c870a04..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/TurbidityUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum TurbidityUnit - { - Undefined = 0, - NTU, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VitaminAUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VitaminAUnit.g.cs deleted file mode 100644 index 566de16722..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VitaminAUnit.g.cs +++ /dev/null @@ -1,33 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum VitaminAUnit - { - Undefined = 0, - InternationalUnit, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeConcentrationUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeConcentrationUnit.g.cs deleted file mode 100644 index 5fa899ebe4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeConcentrationUnit.g.cs +++ /dev/null @@ -1,52 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum VolumeConcentrationUnit - { - Undefined = 0, - CentilitersPerLiter, - CentilitersPerMililiter, - DecilitersPerLiter, - DecilitersPerMililiter, - DecimalFraction, - LitersPerLiter, - LitersPerMililiter, - MicrolitersPerLiter, - MicrolitersPerMililiter, - MillilitersPerLiter, - MillilitersPerMililiter, - NanolitersPerLiter, - NanolitersPerMililiter, - PartPerBillion, - PartPerMillion, - PartPerThousand, - PartPerTrillion, - Percent, - PicolitersPerLiter, - PicolitersPerMililiter, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeFlowUnit.g.cs deleted file mode 100644 index f4333f63ec..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ /dev/null @@ -1,88 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum VolumeFlowUnit - { - Undefined = 0, - AcreFootPerDay, - AcreFootPerHour, - AcreFootPerMinute, - AcreFootPerSecond, - CentiliterPerDay, - CentiliterPerMinute, - CentiliterPerSecond, - CubicCentimeterPerMinute, - CubicDecimeterPerMinute, - CubicFootPerHour, - CubicFootPerMinute, - CubicFootPerSecond, - CubicMeterPerDay, - CubicMeterPerHour, - CubicMeterPerMinute, - CubicMeterPerSecond, - CubicMillimeterPerSecond, - CubicYardPerDay, - CubicYardPerHour, - CubicYardPerMinute, - CubicYardPerSecond, - DeciliterPerDay, - DeciliterPerMinute, - DeciliterPerSecond, - KiloliterPerDay, - KiloliterPerMinute, - KiloliterPerSecond, - KilousGallonPerMinute, - LiterPerDay, - LiterPerHour, - LiterPerMinute, - LiterPerSecond, - MegaliterPerDay, - MegaukGallonPerSecond, - MicroliterPerDay, - MicroliterPerMinute, - MicroliterPerSecond, - MilliliterPerDay, - MilliliterPerMinute, - MilliliterPerSecond, - MillionUsGallonsPerDay, - NanoliterPerDay, - NanoliterPerMinute, - NanoliterPerSecond, - OilBarrelPerDay, - OilBarrelPerHour, - OilBarrelPerMinute, - OilBarrelPerSecond, - UkGallonPerDay, - UkGallonPerHour, - UkGallonPerMinute, - UkGallonPerSecond, - UsGallonPerDay, - UsGallonPerHour, - UsGallonPerMinute, - UsGallonPerSecond, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumePerLengthUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumePerLengthUnit.g.cs deleted file mode 100644 index 9fe06e5e68..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumePerLengthUnit.g.cs +++ /dev/null @@ -1,39 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum VolumePerLengthUnit - { - Undefined = 0, - CubicMeterPerMeter, - CubicYardPerFoot, - CubicYardPerUsSurveyFoot, - LiterPerKilometer, - LiterPerMeter, - LiterPerMillimeter, - OilBarrelPerFoot, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeUnit.g.cs deleted file mode 100644 index 2f659cf5d4..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumeUnit.g.cs +++ /dev/null @@ -1,83 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum VolumeUnit - { - Undefined = 0, - AcreFoot, - AuTablespoon, - BoardFoot, - Centiliter, - CubicCentimeter, - CubicDecimeter, - CubicFoot, - CubicHectometer, - CubicInch, - CubicKilometer, - CubicMeter, - CubicMicrometer, - CubicMile, - CubicMillimeter, - CubicYard, - DecausGallon, - Deciliter, - DeciusGallon, - HectocubicFoot, - HectocubicMeter, - Hectoliter, - HectousGallon, - ImperialBeerBarrel, - ImperialGallon, - ImperialOunce, - ImperialPint, - KilocubicFoot, - KilocubicMeter, - KiloimperialGallon, - Kiloliter, - KilousGallon, - Liter, - MegacubicFoot, - MegaimperialGallon, - Megaliter, - MegausGallon, - MetricCup, - MetricTeaspoon, - Microliter, - Milliliter, - OilBarrel, - UkTablespoon, - UsBeerBarrel, - UsCustomaryCup, - UsGallon, - UsLegalCup, - UsOunce, - UsPint, - UsQuart, - UsTablespoon, - UsTeaspoon, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs deleted file mode 100644 index 2f18602337..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs +++ /dev/null @@ -1,41 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum VolumetricHeatCapacityUnit - { - Undefined = 0, - BtuPerCubicFootDegreeFahrenheit, - CaloriePerCubicCentimeterDegreeCelsius, - JoulePerCubicMeterDegreeCelsius, - JoulePerCubicMeterKelvin, - KilocaloriePerCubicCentimeterDegreeCelsius, - KilojoulePerCubicMeterDegreeCelsius, - KilojoulePerCubicMeterKelvin, - MegajoulePerCubicMeterDegreeCelsius, - MegajoulePerCubicMeterKelvin, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs b/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs deleted file mode 100644 index a7e6d93c2e..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs +++ /dev/null @@ -1,38 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet.Units -{ - // Disable missing XML comment warnings for the generated unit enums. - #pragma warning disable 1591 - - public enum WarpingMomentOfInertiaUnit - { - Undefined = 0, - CentimeterToTheSixth, - DecimeterToTheSixth, - FootToTheSixth, - InchToTheSixth, - MeterToTheSixth, - MillimeterToTheSixth, - } - - #pragma warning restore 1591 -} diff --git a/UnitsNet.WindowsRuntimeComponent/IQuantity.cs b/UnitsNet.WindowsRuntimeComponent/IQuantity.cs deleted file mode 100644 index 34286b6c49..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/IQuantity.cs +++ /dev/null @@ -1,62 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using JetBrains.Annotations; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Represents a quantity. - /// - public interface IQuantity - { - /// - /// The of this quantity. - /// - QuantityType Type { get; } - - /// - /// The of this quantity. - /// - BaseDimensions Dimensions { get; } - - /// - /// Dynamically convert to another unit representation. - /// - /// The unit enum value. The unit must be compatible, so for you should provide a value. - /// Value converted to the specified unit. - /// Wrong unit enum type was given. - double As(object unit); - - /// - /// The unit this quantity was constructed with or the BaseUnit if the default constructor was used. - /// - object Unit { get; } - - /// - /// Get string representation of value and unit. Using two significant digits after radix. - /// - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - string ToString([CanBeNull] string cultureName); - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - string ToString(string cultureName, int significantDigitsAfterRadix); - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implictly included as arguments 0 and 1. - /// String representation. - /// Name of culture (ex: "en-US") to use for localization and number formatting. Defaults to if null. - string ToString([CanBeNull] string cultureName, [NotNull] string format, [NotNull] params object[] args); - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/InternalHelpers/Guard.cs b/UnitsNet.WindowsRuntimeComponent/InternalHelpers/Guard.cs deleted file mode 100644 index 0c4f48ce27..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/InternalHelpers/Guard.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using JetBrains.Annotations; - -namespace UnitsNet.InternalHelpers -{ - /// - /// Guard methods to ensure parameter values satisfy pre-conditions and use a consistent exception message. - /// - internal static class Guard - { - /// - /// Throws if value is , - /// or . - /// - /// The value to check. - /// Name of parameter in calling method. - /// The given if valid. - /// If is invalid. - internal static double EnsureValidNumber(double value, [InvokerParameterName] string paramName) - { - if (double.IsNaN(value)) throw new ArgumentException("NaN is not a valid number.", paramName); - if (double.IsInfinity(value)) throw new ArgumentException("PositiveInfinity or NegativeInfinity is not a valid number.", paramName); - return value; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/InternalHelpers/ReflectionBridgeExtensions.cs b/UnitsNet.WindowsRuntimeComponent/InternalHelpers/ReflectionBridgeExtensions.cs deleted file mode 100644 index f5a9341450..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/InternalHelpers/ReflectionBridgeExtensions.cs +++ /dev/null @@ -1,89 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Runtime.CompilerServices; -#if NET40 || NET35 || NET20 || SILVERLIGHT -using UniformTypeInfo = System.Type; -#else -using UniformTypeInfo = System.Reflection.TypeInfo; -#endif - -[assembly: - InternalsVisibleTo( - "UnitsNet.Serialization.JsonNet, PublicKey=002400000480000094000000060200000024000052534131000400000100010089abdcb0025f7d1c4c766686dd852b978ca5bb9fd80bba9d3539e8399b01170ae0ea10c0c3baa301b1d13090d5aff770532de00c88b67c4b24669fde7f9d87218f1c6c073a09016cbb2f87119b94227c2301f4e2a096043e30f7c47c872bbd8e0b80d924952e6b36990f13f847e83e9efb107ec2121fe39d7edaaa4e235af8c4")] - -// Based on -// https://github.com/StefH/ReflectionBridge/blob/c1e34e57fe3fc93507e83d5cebc1677396645397/ReflectionBridge/src/ReflectionBridge/Extensions/ReflectionBridgeExtensions.cs -// MIT license -namespace UnitsNet.InternalHelpers -{ - internal struct TypeWrapper - { - private readonly Type _type; - - public TypeWrapper(Type type) - { - _type = type; - } - - internal Assembly Assembly => _type.ToUniformType().Assembly; - internal bool IsEnum => _type.ToUniformType().IsEnum; - internal bool IsClass => _type.ToUniformType().IsClass; - internal bool IsAssignableFrom(Type other) => _type.ToUniformType().IsAssignableFrom(other.ToUniformType()); - internal bool IsValueType => _type.ToUniformType().IsValueType; - - internal PropertyInfo GetProperty(string name) - { -#if NET40 || NET35 || NET20 || SILVERLIGHT - return _type.GetProperty(name); -#else - return _type.GetTypeInfo().GetDeclaredProperty(name); -#endif - } - - internal IEnumerable GetDeclaredMethods() - { - var t = _type.ToUniformType(); - while (t != null) - { -#if NET40 || NET35 || NET20 || SILVERLIGHT - foreach (MethodInfo m in t.GetMethods()) -#else - foreach (MethodInfo m in t.DeclaredMethods) -#endif - yield return m; - - t = t.BaseType?.ToUniformType(); - } - } - } - - internal static class ReflectionBridgeExtensions - { - /// - /// Wrap the type to make it .NET agnostic using Type for old targets and the newer TypeInfo for newer targets. - /// - public static TypeWrapper Wrap(this Type type) - { - return new TypeWrapper(type); - } - - /// - /// Returns the type or type info object depending on compile target, such as TypeInfo for .NET 4.5+ and Type for .NET - /// 4.0 and older. - /// The APIs of these two objects are similar, but obtaining them is slightly different. - /// The idea is to get fewer #if pragma statements in the code. - /// - public static UniformTypeInfo ToUniformType(this Type type) - { -#if NET40 || NET35 || NET20 || SILVERLIGHT - return type; -#else - return type.GetTypeInfo(); -#endif - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs b/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs deleted file mode 100644 index 86bf33263c..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,22 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System.Reflection; -using System.Resources; -using System.Runtime.CompilerServices; - -using System.Runtime.InteropServices; -[assembly: ComVisible(false)] - -[assembly: AssemblyTitle("Units.NET")] -[assembly: AssemblyDescription("Units.NET gives you all the common units of measurement and the conversions between them. It is light-weight, unit tested and supports PCL.")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("Andreas Gullberg Larsen")] -[assembly: AssemblyProduct("Units.NET")] -[assembly: AssemblyCopyright("Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com).")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] -[assembly: NeutralResourcesLanguage("")] -[assembly: AssemblyVersion("5.0.0")] -[assembly: AssemblyFileVersion("5.0.0")] -[assembly: InternalsVisibleTo("UnitsNet.WindowsRuntimeComponent.Tests")] diff --git a/UnitsNet.WindowsRuntimeComponent/QuantityInfo.cs b/UnitsNet.WindowsRuntimeComponent/QuantityInfo.cs deleted file mode 100644 index 874d8dfb16..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/QuantityInfo.cs +++ /dev/null @@ -1,107 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Linq; -using System.Reflection; -using JetBrains.Annotations; -using UnitsNet.InternalHelpers; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Information about the quantity, such as names, unit values and zero quantity. - /// This is useful to enumerate units and present names with quantities and units - /// chose dynamically at runtime, such as unit conversion apps or allowing the user to change the - /// unit representation. - /// - /// - /// Typically you obtain this by looking it up via quantities, like or . - /// - internal class QuantityInfo - { - private static readonly string UnitEnumNamespace = typeof(LengthUnit).Namespace; - - private static readonly Type[] UnitEnumTypes = typeof(Length) - .Wrap() - .Assembly - .GetExportedTypes() - .Where(t => t.Wrap().IsEnum && t.Namespace == UnitEnumNamespace && t.Name.EndsWith("Unit")) - .ToArray(); - - public QuantityInfo(QuantityType quantityType, [NotNull] Enum[] units, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions) - { - if(quantityType == QuantityType.Undefined) throw new ArgumentException("Quantity type can not be undefined.", nameof(quantityType)); - if(units == null) throw new ArgumentNullException(nameof(units)); - if(baseUnit == null) throw new ArgumentNullException(nameof(baseUnit)); - if(zero == null) throw new ArgumentNullException(nameof(zero)); - if(baseDimensions == null) throw new ArgumentNullException(nameof(baseDimensions)); - - Name = quantityType.ToString(); - QuantityType = quantityType; - UnitType = UnitEnumTypes.First(t => t.Name == $"{quantityType}Unit"); - UnitInfos = units.Select(unit => new UnitInfo(unit)).ToArray(); - UnitNames = UnitInfos.Select(unitInfo => unitInfo.Name).ToArray(); - Units = units; - BaseUnitInfo = new UnitInfo(baseUnit); - BaseUnit = BaseUnitInfo.Value; - Zero = zero; - ValueType = zero.GetType(); - BaseDimensions = baseDimensions; - } - - /// - /// Quantity name, such as "Length" or "Mass". - /// - public string Name { get; } - - /// - /// Quantity type, such as or . - /// - public QuantityType QuantityType { get; } - - public UnitInfo[] UnitInfos { get; } - - /// - /// All unit names for the quantity, such as ["Centimeter", "Decimeter", "Meter", ...]. - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the UnitInfos property.")] - public string[] UnitNames { get; } - - /// - /// All unit enum values for the quantity, such as [, - /// , , ...]. - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the UnitInfos property.")] - public Enum[] Units { get; } - - public UnitInfo BaseUnitInfo { get; } - - /// - /// The base unit for the quantity, such as . - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the BaseUnitInfo property.")] - public Enum BaseUnit { get; } - - /// - /// Zero value of quantity, such as . - /// - public IQuantity Zero { get; } - - /// - /// Unit enum type, such as or . - /// - public Type UnitType { get; } - - /// - /// Quantity value type, such as or . - /// - public Type ValueType { get; } - - /// - /// The for a quantity. - /// - public BaseDimensions BaseDimensions { get; } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/QuantityNotFoundException.cs b/UnitsNet.WindowsRuntimeComponent/QuantityNotFoundException.cs deleted file mode 100644 index 4e288edb04..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/QuantityNotFoundException.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -namespace UnitsNet -{ - /// - /// Quantity type was not found. This is typically thrown for dynamic conversions, - /// such as . - /// - internal class QuantityNotFoundException : UnitsNetException - { - public QuantityNotFoundException() - { - } - - public QuantityNotFoundException(string message) : base(message) - { - } - - public QuantityNotFoundException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/UnitConverter.cs b/UnitsNet.WindowsRuntimeComponent/UnitConverter.cs deleted file mode 100644 index 6a06da69cb..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitConverter.cs +++ /dev/null @@ -1,422 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Linq; -using System.Reflection; -using JetBrains.Annotations; -using UnitsNet.InternalHelpers; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Convert between units of a quantity, such as converting from meters to centimeters of a given length. - /// - [PublicAPI] - public static class UnitConverter - { - private static readonly string UnitTypeNamespace = typeof(LengthUnit).Namespace; - private static readonly Assembly UnitsNetAssembly = typeof(Length).Wrap().Assembly; - - private static readonly Type[] QuantityTypes = UnitsNetAssembly.GetTypes() - .Where(typeof(IQuantity).Wrap().IsAssignableFrom) - .Where(x => x.Wrap().IsClass || x.Wrap().IsValueType) // Future-proofing: we are discussing changing quantities from struct to class - .ToArray(); - - private static readonly Type[] UnitTypes = UnitsNetAssembly.GetTypes() - .Where(x => x.Namespace == UnitTypeNamespace && x.Wrap().IsEnum && x.Name.EndsWith("Unit")) - .ToArray(); - - /// - /// Convert between any two quantity units given a numeric value and two unit enum values. - /// - /// Numeric value. - /// From unit enum value. - /// To unit enum value, must be compatible with . - /// The converted value in the new unit representation. - internal static double Convert(double fromValue, Enum fromUnitValue, Enum toUnitValue) - { - return Quantity - .From(fromValue, fromUnitValue) - .As(toUnitValue); - } - - /// - /// Try to convert between any two quantity units given a numeric value and two unit enum values. - /// - /// Numeric value. - /// From unit enum value. - /// To unit enum value, must be compatible with . - /// The converted value, if successful. Otherwise default. - /// True if successful. - internal static bool TryConvert(double fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue) - { - convertedValue = 0; - if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity from)) return false; - - try - { - // We're not going to implement TryAs() in all quantities, so let's just try-catch here - convertedValue = from.As(toUnitValue); - return true; - } - catch - { - return false; - } - } - - /// - /// Convert between any two quantity units by their names, such as converting a "Length" of N "Meter" to "Centimeter". - /// This is particularly useful for creating things like a generated unit conversion UI, - /// where you list some selectors: - /// a) Quantity: Length, Mass, Force etc. - /// b) From unit: Meter, Centimeter etc if Length is selected - /// c) To unit: Meter, Centimeter etc if Length is selected - /// - /// - /// Input value, which together with represents the quantity to - /// convert from. - /// - /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// double centimeters = ConvertByName(5, "Length", "Meter", "Centimeter"); // 500 - /// Output value as the result of converting to . - /// No quantities were found that match . - /// No units match the abbreviation. - /// More than one unit matches the abbreviation. - public static double ConvertByName(double fromValue, string quantityName, string fromUnit, string toUnit) - { - if (!TryGetUnitType(quantityName, out Type unitType)) - throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); - - if (!TryParseUnit(unitType, fromUnit, out Enum fromUnitValue)) // ex: LengthUnit.Meter - { - var e = new UnitNotFoundException($"Unit not found [{fromUnit}]."); - e.Data["unitName"] = fromUnit; - throw e; - } - - if (!TryParseUnit(unitType, toUnit, out Enum toUnitValue)) // ex: LengthUnit.Centimeter - { - var e = new UnitNotFoundException($"Unit not found [{toUnit}]."); - e.Data["unitName"] = toUnit; - throw e; - } - - return Convert(fromValue, fromUnitValue, toUnitValue); - } - - /// - /// Convert between any two quantity units by their names, such as converting a "Length" of N "Meter" to "Centimeter". - /// This is particularly useful for creating things like a generated unit conversion UI, - /// where you list some selectors: - /// a) Quantity: Length, Mass, Force etc. - /// b) From unit: Meter, Centimeter etc if Length is selected - /// c) To unit: Meter, Centimeter etc if Length is selected - /// - /// - /// Input value, which together with represents the quantity to - /// convert from. - /// - /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// Result if conversion was successful, 0 if not. - /// bool ok = TryConvertByName(5, "Length", "Meter", "Centimeter", out double centimeters); // 500 - /// True if conversion was successful. - public static bool TryConvertByName(double inputValue, string quantityName, string fromUnit, string toUnit, out double result) - { - result = 0d; - - if (!TryGetUnitType(quantityName, out var unitType)) - return false; - - if (!TryParseUnit(unitType, fromUnit, out var fromUnitValue)) // ex: LengthUnit.Meter - return false; - - if (!TryParseUnit(unitType, toUnit, out var toUnitValue)) // ex: LengthUnit.Centimeter - return false; - - result = Convert(inputValue, fromUnitValue, toUnitValue); - return true; - } - - /// - /// Convert between any two quantity units by their abbreviations, such as converting a "Length" of N "m" to "cm". - /// This is particularly useful for creating things like a generated unit conversion UI, - /// where you list some selectors: - /// a) Quantity: Length, Mass, Force etc. - /// b) From unit: Meter, Centimeter etc if Length is selected - /// c) To unit: Meter, Centimeter etc if Length is selected - /// - /// - /// Input value, which together with represents the quantity to - /// convert from. - /// - /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 - /// Output value as the result of converting to . - public static double ConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) - { - // WindowsRuntimeComponent does not support default values on public methods - // ReSharper disable once IntroduceOptionalParameters.Global - return ConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, null); - } - - /// - /// Convert between any two quantity units by their abbreviations, such as converting a "Length" of N "m" to "cm". - /// This is particularly useful for creating things like a generated unit conversion UI, - /// where you list some selectors: - /// a) Quantity: Length, Mass, Force etc. - /// b) From unit: Meter, Centimeter etc if Length is selected - /// c) To unit: Meter, Centimeter etc if Length is selected - /// - /// - /// Input value, which together with represents the quantity to - /// convert from. - /// - /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// Culture to parse abbreviations with. - /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 - /// Output value as the result of converting to . - /// No quantity types match the . - /// - /// No unit types match the prefix of or no units - /// are mapped to the abbreviation. - /// - /// More than one unit matches the abbreviation. - public static double ConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string culture) - { - if (!TryGetQuantityType(quantityName, out var quantityType)) - throw new QuantityNotFoundException($"The given quantity name was not found: {quantityName}"); - - if (!TryGetUnitType(quantityName, out var unitType)) - throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); - - var cultureInfo = string.IsNullOrWhiteSpace(culture) ? GlobalConfiguration.DefaultCulture : new CultureInfo(culture); - - var fromUnitValue = UnitParser.Default.Parse(fromUnitAbbrev, unitType, cultureInfo); // ex: ("m", LengthUnit) => LengthUnit.Meter - var toUnitValue = UnitParser.Default.Parse(toUnitAbbrev, unitType, cultureInfo); // ex:("cm", LengthUnit) => LengthUnit.Centimeter - - var fromMethod = GetStaticFromMethod(quantityType, unitType); // ex: UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - var fromResult = fromMethod.Invoke(null, new object[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) - - var asMethod = GetAsMethod(quantityType, unitType); // ex: quantity.As(LengthUnit outputUnit) - var asResult = asMethod.Invoke(fromResult, new object[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) - - return (double) asResult; - } - - /// - /// Convert between any two quantity units by their abbreviations, such as converting a "Length" of N "m" to "cm". - /// This is particularly useful for creating things like a generated unit conversion UI, - /// where you list some selectors: - /// a) Quantity: Length, Mass, Force etc. - /// b) From unit: Meter, Centimeter etc if Length is selected - /// c) To unit: Meter, Centimeter etc if Length is selected - /// - /// - /// Input value, which together with represents the quantity to - /// convert from. - /// - /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// Result if conversion was successful, 0 if not. - /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 - /// True if conversion was successful. - public static bool TryConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result) - { - return TryConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, out result, null); - } - - /// - /// Convert between any two quantity units by their abbreviations, such as converting a "Length" of N "m" to "cm". - /// This is particularly useful for creating things like a generated unit conversion UI, - /// where you list some selectors: - /// a) Quantity: Length, Mass, Force etc. - /// b) From unit: Meter, Centimeter etc if Length is selected - /// c) To unit: Meter, Centimeter etc if Length is selected - /// - /// - /// Input value, which together with represents the quantity to - /// convert from. - /// - /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// - /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as - /// . - /// - /// Culture to parse abbreviations with. - /// Result if conversion was successful, 0 if not. - /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 - /// True if conversion was successful. - public static bool TryConvertByAbbreviation(double fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result, - string culture) - { - result = 0d; - - if (!TryGetQuantityType(quantityName, out var quantityType)) - return false; - - if (!TryGetUnitType(quantityName, out var unitType)) - return false; - - var cultureInfo = string.IsNullOrWhiteSpace(culture) ? GlobalConfiguration.DefaultCulture : new CultureInfo(culture); - - if (!UnitParser.Default.TryParse(fromUnitAbbrev, unitType, cultureInfo, out var fromUnitValue)) // ex: ("m", LengthUnit) => LengthUnit.Meter - return false; - - if (!UnitParser.Default.TryParse(toUnitAbbrev, unitType, cultureInfo, out var toUnitValue)) // ex:("cm", LengthUnit) => LengthUnit.Centimeter - return false; - - var fromMethod = GetStaticFromMethod(quantityType, unitType); // ex: UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - var fromResult = fromMethod.Invoke(null, new object[] {fromValue, fromUnitValue}); // ex: Length quantity = UnitsNet.Length.From(5, LengthUnit.Meter) - - var asMethod = GetAsMethod(quantityType, unitType); // ex: quantity.As(LengthUnit outputUnit) - var asResult = asMethod.Invoke(fromResult, new object[] {toUnitValue}); // ex: double outputValue = quantity.As(LengthUnit.Centimeter) - - result = (double) asResult; - return true; - } - - private static MethodInfo GetAsMethod(Type quantityType, Type unitType) - { - // Only a single As() method as of this writing, but let's safe-guard a bit for future-proofing - // ex: double result = quantity.As(LengthUnit outputUnit); - return quantityType.Wrap().GetDeclaredMethods() - .Single(m => m.Name == "As" && - !m.IsStatic && - m.IsPublic && - HasParameterTypes(m, unitType) && - m.ReturnType == typeof(double)); - } - - private static MethodInfo GetStaticFromMethod(Type quantityType, Type unitType) - { - // Want to match: Length l = UnitsNet.Length.From(double inputValue, LengthUnit inputUnit) - // Do NOT match : Length? UnitsNet.Length.From(double? inputValue, LengthUnit inputUnit) - return quantityType.Wrap().GetDeclaredMethods() - .Single(m => m.Name == "From" && - m.IsStatic && - m.IsPublic && - HasParameterTypes(m, typeof(double), unitType) && - m.ReturnType == quantityType); - } - - private static bool HasParameterTypes(MethodInfo methodInfo, params Type[] expectedTypes) - { - var parameters = methodInfo.GetParameters(); - if (parameters.Length != expectedTypes.Length) - throw new ArgumentException($"The number of parameters {parameters.Length} did not match the number of types {expectedTypes.Length}."); - - for (var i = 0; i < parameters.Length; i++) - { - var p = parameters[i]; - var t = expectedTypes[i]; - if (p.ParameterType != t) - return false; - } - - return true; - } - - - /// - /// Parse a unit by the unit enum type and a unit enum value > - /// - /// Unit type, such as . - /// Unit name, such as "Meter" corresponding to . - /// The return enum value, such as boxed as an object. - /// True if succeeded, otherwise false. - /// No unit values match the . - private static bool TryParseUnit(Type unitType, string unitName, out Enum unitValue) - { - unitValue = null; - var eNames = Enum.GetNames(unitType); - unitName = eNames.FirstOrDefault(x => x.Equals(unitName, StringComparison.OrdinalIgnoreCase)); - if (unitName == null) - return false; - - unitValue = (Enum) Enum.Parse(unitType, unitName); - return true; - } - - private static bool TryGetUnitType(string quantityName, out Type unitType) - { - var unitTypeName = quantityName + "Unit"; // ex. LengthUnit - - unitType = UnitTypes.FirstOrDefault(x => - x.Name.Equals(unitTypeName, StringComparison.OrdinalIgnoreCase)); - - return unitType != null; - } - - private static bool TryGetQuantityType(string quantityName, out Type quantityType) - { - quantityType = QuantityTypes.FirstOrDefault(x => x.Name.Equals(quantityName, StringComparison.OrdinalIgnoreCase)); - - return quantityType != null; - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/UnitFormatter.cs b/UnitsNet.WindowsRuntimeComponent/UnitFormatter.cs deleted file mode 100644 index 3e1259b718..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitFormatter.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Collections.Generic; -using System.Linq; -using JetBrains.Annotations; - -namespace UnitsNet -{ - /// - /// Utility class for formatting units and values. - /// - internal static class UnitFormatter - { - /// - /// Gets the default ToString format for the specified value. - /// - /// The value to format. - /// - /// The number of digits after the radix point to display in the formatted - /// string. - /// - /// A ToString format for the specified value. - public static string GetFormat(double value, int significantDigitsAfterRadix) - { - double v = Math.Abs(value); - var sigDigitsAfterRadixStr = new string('#', significantDigitsAfterRadix); - string format; - - if (NearlyEqual(v, 0)) - { - format = "{0} {1}"; - } - // Values below 1e-3 are displayed in scientific notation. - else if (v < 1e-3) - { - format = "{0:0." + sigDigitsAfterRadixStr + "e-00} {1}"; - } - // Values from 1e-3 to 1 use fixed point notation. - else if ((v > 1e-4) && (v < 1)) - { - format = "{0:g" + significantDigitsAfterRadix + "} {1}"; - } - // Values between 1 and 1e5 use fixed point notation with digit grouping. - else if ((v >= 1) && (v < 1e6)) - { - // The comma will be automatically replaced with the correct digit separator if a different culture is used. - format = "{0:#,0." + sigDigitsAfterRadixStr + "} {1}"; - } - // Values above 1e5 use scientific notation. - else - { - format = "{0:0." + sigDigitsAfterRadixStr + "e+00} {1}"; - } - - return format; - } - - private static bool NearlyEqual(double a, double b) - { - return Math.Abs(a - b) < 1e-150; - } - - /// - /// Gets ToString format arguments. - /// - /// The type of units to format. - /// The units - /// The unit value to format. - /// The current culture. - /// The list of format arguments. - /// An array of ToString format arguments. - public static object[] GetFormatArgs(TUnitType unit, double value, [CanBeNull] IFormatProvider culture, IEnumerable args) - where TUnitType : Enum - { - string abbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(typeof(TUnitType), Convert.ToInt32(unit), culture); - return new object[] {value, abbreviation}.Concat(args).ToArray(); - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/UnitInfo.cs b/UnitsNet.WindowsRuntimeComponent/UnitInfo.cs deleted file mode 100644 index 9ca2c85e89..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitInfo.cs +++ /dev/null @@ -1,37 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using UnitsNet.Units; - -namespace UnitsNet -{ - /// - /// Information about the unit, such as its name and value. - /// This is useful to enumerate units and present names with quantities and units - /// chosen dynamically at runtime, such as unit conversion apps or allowing the user to change the - /// unit representation. - /// - /// - /// Typically you obtain this by looking it up via . - /// - internal class UnitInfo - { - public UnitInfo(Enum value) - { - Value = value; - Name = value.ToString(); - } - - /// - /// The enum value of the unit, such as [, - /// , , ...]. - /// - public Enum Value; - - /// - /// The name of the unit, such as ["Centimeter", "Decimeter", "Meter", ...]. - /// - public string Name { get; } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/UnitNotFoundException.cs b/UnitsNet.WindowsRuntimeComponent/UnitNotFoundException.cs deleted file mode 100644 index 9469b77172..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitNotFoundException.cs +++ /dev/null @@ -1,26 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -namespace UnitsNet -{ - /// - /// Unit was not found. This is typically thrown for dynamic conversions, - /// such as . - /// - internal class UnitNotFoundException : UnitsNetException - { - public UnitNotFoundException() - { - } - - public UnitNotFoundException(string message) : base(message) - { - } - - public UnitNotFoundException(string message, Exception innerException) : base(message, innerException) - { - } - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/UnitSystem.cs b/UnitsNet.WindowsRuntimeComponent/UnitSystem.cs deleted file mode 100644 index c116359e7f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitSystem.cs +++ /dev/null @@ -1,72 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using UnitsNet.Units; - -namespace UnitsNet -{ - public sealed class UnitSystem - { - /// - /// Creates an instance of a unit system with the specified base units. - /// - /// The base units for the unit system. - public UnitSystem(BaseUnits baseUnits) - { - if(baseUnits is null) - throw new ArgumentNullException(nameof(baseUnits)); - - if(baseUnits.Length == LengthUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - if(baseUnits.Mass == MassUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - if(baseUnits.Time == DurationUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - if(baseUnits.Current == ElectricCurrentUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - if(baseUnits.Temperature == TemperatureUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - if(baseUnits.Amount == AmountOfSubstanceUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - if(baseUnits.LuminousIntensity == LuminousIntensityUnit.Undefined) - throw new ArgumentException("A unit system must have all base units defined.", nameof(baseUnits)); - - BaseUnits = baseUnits; - } - - /// - public override bool Equals(object obj) - { - if(obj is null || !(obj is UnitSystem)) - return false; - - return Equals((UnitSystem)obj); - } - - [Windows.Foundation.Metadata.DefaultOverload] - public bool Equals(UnitSystem other) - { - if(other is null) - return false; - - return BaseUnits.Equals(other.BaseUnits); - } - - /// - public override int GetHashCode() - { - return new {BaseUnits}.GetHashCode(); - } - - public BaseUnits BaseUnits{ get; } - - private static readonly BaseUnits SIBaseUnits = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, - ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela); - - /// - /// Gets the SI unit system. - /// - public static UnitSystem SI{ get; } = new UnitSystem(SIBaseUnits); - } -} diff --git a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj b/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj deleted file mode 100644 index ce4686a21f..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj +++ /dev/null @@ -1,141 +0,0 @@ - - - - - Debug - AnyCPU - {2DA428CA-BFE1-43FA-86D2-7CB42289D596} - winmdobj - Properties - UnitsNet - UnitsNet - en-US - UAP - 10.0.16299.0 - 10.0.10586.0 - 14 - 512 - {A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - false - ..\Artifacts\UnitsNet.WindowsRuntimeComponent - 7.3 - - - - CS0618;CS1591 - - - true - true - $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb - - - - AnyCPU - true - full - false - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - prompt - 4 - - - AnyCPU - pdbonly - true - TRACE;NETFX_CORE;WINDOWS_UWP - prompt - 4 - true - ..\Artifacts\UnitsNet.WindowsRuntimeComponent\UnitsNet.XML - - - x86 - true - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - full - x86 - false - prompt - - - x86 - TRACE;NETFX_CORE;WINDOWS_UWP - true - pdbonly - x86 - false - prompt - - - ARM - true - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - full - ARM - false - prompt - - - ARM - TRACE;NETFX_CORE;WINDOWS_UWP - true - pdbonly - ARM - false - prompt - - - x64 - true - DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP - full - x64 - false - prompt - - - x64 - TRACE;NETFX_CORE;WINDOWS_UWP - true - pdbonly - x64 - false - prompt - - - PackageReference - - - - - - - Common\%(RecursiveDir)%(Filename)%(Extension) - - - - - 6.0.6 - - - 11.1.0 - - - - 4.5.0 - - - - - 14.0 - - - - diff --git a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj.DotSettings b/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj.DotSettings deleted file mode 100644 index 0b0edaecd0..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec b/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec deleted file mode 100644 index 7ec22d2949..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitsNet.WindowsRuntimeComponent.nuspec +++ /dev/null @@ -1,25 +0,0 @@ - - - - UnitsNet.WindowsRuntimeComponent - 5.0.0-alpha001 - Units.NET - Windows Runtime Component - Andreas Gullberg Larsen - Andreas Gullberg Larsen - MIT - https://github.com/angularsen/UnitsNet - false - For C#/VB Universal Windows code (UWP), use UnitsNet instead. This is a Windows Runtime Component with reduced functionality to support all UWP languages, such as JavaScript and C++, and other runtime components. - For C#/VB Universal Windows code (UWP), use UnitsNet instead. - https://raw.githubusercontent.com/angularsen/UnitsNet/ce85185429be345d77eb2ce09c99d59cc9ab8aed/Docs/Images/logo-32.png - - - Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). - en-US - unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component - - - - - - diff --git a/UnitsNet.WindowsRuntimeComponent/UnitsNetException.cs b/UnitsNet.WindowsRuntimeComponent/UnitsNetException.cs deleted file mode 100644 index 380601c549..0000000000 --- a/UnitsNet.WindowsRuntimeComponent/UnitsNetException.cs +++ /dev/null @@ -1,25 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -namespace UnitsNet -{ - internal class UnitsNetException : Exception - { - public UnitsNetException() - { - HResult = 1; - } - - public UnitsNetException(string message) : base(message) - { - HResult = 1; - } - - public UnitsNetException(string message, Exception innerException) : base(message, innerException) - { - HResult = 1; - } - } -} diff --git a/UnitsNet.sln b/UnitsNet.sln index 4e089aca8d..6ae0d3d8b3 100644 --- a/UnitsNet.sln +++ b/UnitsNet.sln @@ -28,7 +28,7 @@ ProjectSection(SolutionItems) = preProject .gitignore = .gitignore appveyor.yml = appveyor.yml build.bat = build.bat - build-with-wrc.bat = build-with-wrc.bat + build-all-targets.bat = build-all-targets.bat clean.bat = clean.bat CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md CONTRIBUTING.md = CONTRIBUTING.md diff --git a/appveyor.yml b/appveyor.yml index 6d208de68f..731a9d66b2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -42,7 +42,7 @@ cache: build_script: - ps: | # Build, test, pack and push nugets - .\\build-with-wrc.bat + .\\build-all-targets.bat $BuildExitCode = $LASTEXITCODE # Upload test results to AppVeyor diff --git a/build-with-wrc.bat b/build-all-targets.bat similarity index 52% rename from build-with-wrc.bat rename to build-all-targets.bat index f1ba255c18..267a7888e5 100644 --- a/build-with-wrc.bat +++ b/build-all-targets.bat @@ -1,2 +1,2 @@ @echo off -powershell -ExecutionPolicy Bypass -NoProfile -File "%~dp0\Build\build.ps1" -IncludeWindowsRuntimeComponent -IncludeNanoFramework +powershell -ExecutionPolicy Bypass -NoProfile -File "%~dp0\Build\build.ps1" -IncludeNanoFramework diff --git a/build.bat b/build.bat index 3d1f4d0ddc..ca317c4339 100644 --- a/build.bat +++ b/build.bat @@ -1,2 +1,2 @@ @echo off -powershell -ExecutionPolicy Bypass -NoProfile -File %~dp0\Build\build.ps1 +powershell -ExecutionPolicy Bypass -NoProfile -File "%~dp0\Build\build.ps1" From d11361ce2c66b8b019b4fd94cf823294e75fe1f9 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 21:52:02 +0100 Subject: [PATCH 06/66] JsonNet: 5.0.0-alpha001 --- Build/set-version-json.sh | 16 ++++++++++++++++ .../UnitsNet.Serialization.JsonNet.csproj | 6 +++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 Build/set-version-json.sh diff --git a/Build/set-version-json.sh b/Build/set-version-json.sh new file mode 100644 index 0000000000..aa2e9f342c --- /dev/null +++ b/Build/set-version-json.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# Sets version of nuget UnitNets.Serialization.JsonNet. +script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +set_version_script="$script_dir/set-version-UnitsNet.Serialization.JsonNet.ps1" + +if [ $# -eq 1 ]; then + powershell -NoProfile $set_version_script -setVersion $1 + exit 0 +else + echo "Usage: ./set-version-json.sh " + echo "" + echo "Examples:" + echo "$ ./set-version-json.sh 5.0.0-alpha001" + echo "$ ./set-version-json.sh 5.1.2" + exit 1 +fi \ No newline at end of file diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 907ea8d71d..c790ec5e8e 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -1,8 +1,8 @@ - + UnitsNet.Serialization.JsonNet - 4.4.0 + 5.0.0-alpha001 Andreas Gullberg Larsen Units.NET Serialization with Json.NET A helper library for serializing and deserializing types in Units.NET using Json.NET. @@ -20,7 +20,7 @@ - 4.0.0.0 + 5.0.0.0 latest UnitsNet.Serialization.JsonNet netstandard2.0 From a2da56c6c96260515376411f1d5455e5f8c115b4 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 21:57:51 +0100 Subject: [PATCH 07/66] Rename json field "BaseType" to "ValueType" --- .../NanoFrameworkGen/QuantityGenerator.cs | 26 +++++++++---------- CodeGen/Generators/NanoFrameworkGenerator.cs | 2 +- CodeGen/Generators/QuantityJsonFilesParser.cs | 2 +- .../UnitsNetGen/QuantityGenerator.cs | 16 ++++++------ .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 10 +++---- CodeGen/JsonTypes/Quantity.cs | 2 +- Common/UnitDefinitions/BitRate.json | 2 +- Common/UnitDefinitions/Information.json | 2 +- Common/UnitDefinitions/Luminosity.json | 1 - Common/UnitDefinitions/Power.json | 2 +- 10 files changed, 32 insertions(+), 33 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 9a915bb586..a6c303f5d5 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -44,7 +44,7 @@ public struct {_quantity.Name} /// /// The numeric value this quantity was constructed with. /// - private readonly {_quantity.BaseType} _value; + private readonly {_quantity.ValueType} _value; /// /// The unit this quantity was constructed with. @@ -54,7 +54,7 @@ public struct {_quantity.Name} /// /// The numeric value this quantity was constructed with. /// - public {_quantity.BaseType} Value => _value; + public {_quantity.ValueType} Value => _value; /// public {_unitEnumName} Unit => _unit;"); @@ -66,7 +66,7 @@ public struct {_quantity.Name} /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public {_quantity.Name}({_quantity.BaseType} value, {_unitEnumName} unit) + public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) {{ _value = value; _unit = unit; @@ -82,16 +82,16 @@ public struct {_quantity.Name} /// "); // Non decimal - Writer.WLCondition(_quantity.BaseType != "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.BaseType}.MaxValue, BaseUnit); + Writer.WLCondition(_quantity.ValueType != "decimal", $@" + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.BaseType}.MinValue, BaseUnit);"); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, BaseUnit);"); // Decimal MaxValue = 79228162514264337593543950335M - Writer.WLCondition(_quantity.BaseType == "decimal", $@" + Writer.WLCondition(_quantity.ValueType == "decimal", $@" public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, BaseUnit); /// @@ -129,7 +129,7 @@ private void GenerateConversionProperties() /// Get {_quantity.Name} in {unit.PluralName}. /// "); Writer.WL($@" - public {_quantity.BaseType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -153,7 +153,7 @@ private void GenerateStaticFactoryMethods() /// /// If value is NaN or Infinity."); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}({_quantity.BaseType} {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName}); + public static {_quantity.Name} From{unit.PluralName}({_quantity.ValueType} {valueParamName}) => new {_quantity.Name}({valueParamName}, {_unitEnumName}.{unit.SingularName}); "); } @@ -165,7 +165,7 @@ private void GenerateStaticFactoryMethods() /// Value to convert from. /// Unit to convert from. /// {_quantity.Name} unit value. - public static {_quantity.Name} From({_quantity.BaseType} value, {_unitEnumName} fromUnit) + public static {_quantity.Name} From({_quantity.ValueType} value, {_unitEnumName} fromUnit) {{ return new {_quantity.Name}(value, fromUnit); }} @@ -183,7 +183,7 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public {_quantity.BaseType} As({_unitEnumName} unit) => GetValueAs(unit); + public {_quantity.ValueType} As({_unitEnumName} unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -202,7 +202,7 @@ private void GenerateConversionMethods() /// This is typically the first step in converting from one unit to another. /// /// The value in the base unit representation. - private {_quantity.BaseType} GetValueInBaseUnit() + private {_quantity.ValueType} GetValueInBaseUnit() {{ switch(Unit) {{"); @@ -219,7 +219,7 @@ private void GenerateConversionMethods() }} }} - private {_quantity.BaseType} GetValueAs({_unitEnumName} unit) + private {_quantity.ValueType} GetValueAs({_unitEnumName} unit) {{ if(Unit == unit) return _value; diff --git a/CodeGen/Generators/NanoFrameworkGenerator.cs b/CodeGen/Generators/NanoFrameworkGenerator.cs index a61492d970..79fd51a35c 100644 --- a/CodeGen/Generators/NanoFrameworkGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGenerator.cs @@ -87,7 +87,7 @@ public static void Generate(string rootDir, Quantity[] quantities) GenerateProject(quantity, Path.Combine(projectPath, $"{quantity.Name}.nfproj"), versions); // Convert decimal based units to floats; decimals are not supported by nanoFramework - if (quantity.BaseType == "decimal") + if (quantity.ValueType == "decimal") { var replacements = new Dictionary { diff --git a/CodeGen/Generators/QuantityJsonFilesParser.cs b/CodeGen/Generators/QuantityJsonFilesParser.cs index aa57cef1d2..b01aa4e622 100644 --- a/CodeGen/Generators/QuantityJsonFilesParser.cs +++ b/CodeGen/Generators/QuantityJsonFilesParser.cs @@ -65,7 +65,7 @@ private static void FixConversionFunctionsForDecimalValueTypes(Quantity quantity foreach (var u in quantity.Units) // Use decimal for internal calculations if base type is not double, such as for long or int. { - if (string.Equals(quantity.BaseType, "decimal", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(quantity.ValueType, "decimal", StringComparison.OrdinalIgnoreCase)) { // Change any double literals like "1024d" to decimal literals "1024m" u.FromUnitToBaseFunc = u.FromUnitToBaseFunc.Replace("d", "m"); diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 4d95b67f21..307b6ac44c 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -25,7 +25,7 @@ public QuantityGenerator(Quantity quantity) throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", nameof(quantity)); - _valueType = quantity.BaseType; + _valueType = quantity.ValueType; _unitEnumName = $"{quantity.Name}Unit"; BaseDimensions baseDimensions = quantity.BaseDimensions; @@ -73,7 +73,7 @@ namespace UnitsNet Writer.W(@$" [DataContract] public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); - if (_quantity.BaseType == "decimal") + if (_quantity.ValueType == "decimal") { Writer.W("IDecimalQuantity, "); } @@ -85,7 +85,7 @@ public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); /// The numeric value this quantity was constructed with. /// [DataMember(Name = ""Value"", Order = 0)] - private readonly {_quantity.BaseType} _value; + private readonly {_quantity.ValueType} _value; /// /// The unit this quantity was constructed with. @@ -174,13 +174,13 @@ private void GenerateInstanceConstructors() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public {_quantity.Name}({_quantity.BaseType} value, {_unitEnumName} unit) + public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) {{ if(unit == {_unitEnumName}.Undefined) throw new ArgumentException(""The quantity can not be created with an undefined unit."", nameof(unit)); "); - Writer.WL(_quantity.BaseType == "double" + Writer.WL(_quantity.ValueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" : @" @@ -205,7 +205,7 @@ private void GenerateInstanceConstructors() var firstUnitInfo = unitInfos.FirstOrDefault(); "); - Writer.WL(_quantity.BaseType == "double" + Writer.WL(_quantity.ValueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" : @" @@ -278,11 +278,11 @@ private void GenerateProperties() "); // Need to provide explicit interface implementation for decimal quantities like Information - if (_quantity.BaseType != "double") + if (_quantity.ValueType != "double") Writer.WL(@" double IQuantity.Value => (double) _value; "); - if (_quantity.BaseType == "decimal") + if (_quantity.ValueType == "decimal") Writer.WL(@" /// decimal IDecimalQuantity.Value => _value; diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index b0c7b9a5d6..fbdf147c5c 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -54,7 +54,7 @@ public UnitTestBaseClassGenerator(Quantity quantity) _unitEnumName = $"{quantity.Name}Unit"; _baseUnitEnglishAbbreviation = GetEnglishAbbreviation(_baseUnit); _baseUnitFullName = $"{_unitEnumName}.{_baseUnit.SingularName}"; - _numberSuffix = quantity.BaseType == "decimal" ? "m" : ""; + _numberSuffix = quantity.ValueType == "decimal" ? "m" : ""; } private string GetUnitFullName(Unit unit) => $"{_unitEnumName}.{unit.SingularName}"; @@ -108,7 +108,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase [Fact] public void Ctor_WithUndefinedUnit_ThrowsArgumentException() {{ - Assert.Throws(() => new {_quantity.Name}(({_quantity.BaseType})0.0, {_unitEnumName}.Undefined)); + Assert.Throws(() => new {_quantity.Name}(({_quantity.ValueType})0.0, {_unitEnumName}.Undefined)); }} [Fact] @@ -116,14 +116,14 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() {{ var quantity = new {_quantity.Name}(); Assert.Equal(0, quantity.Value);"); - if (_quantity.BaseType == "decimal") Writer.WL($@" + if (_quantity.ValueType == "decimal") Writer.WL($@" Assert.Equal(0m, ((IDecimalQuantity)quantity).Value);"); Writer.WL($@" Assert.Equal({_baseUnitFullName}, quantity.Unit); }} "); - if (_quantity.BaseType == "double") Writer.WL($@" + if (_quantity.ValueType == "double") Writer.WL($@" [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() {{ @@ -205,7 +205,7 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() Writer.WL($@" }} "); - if (_quantity.BaseType == "double") Writer.WL($@" + if (_quantity.ValueType == "double") Writer.WL($@" [Fact] public void From{_baseUnit.PluralName}_WithInfinityValue_ThrowsArgumentException() {{ diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index 0888bf8464..c49f547ad5 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -12,7 +12,7 @@ internal class Quantity #pragma warning disable 0649 public BaseDimensions BaseDimensions = new BaseDimensions(); // Default to empty - public string BaseType = "double"; // TODO Rename to ValueType + public string ValueType = "double"; public string BaseUnit; // TODO Rename to DefaultUnit or IntermediateConversionUnit to avoid confusion with Unit.BaseUnits public bool GenerateArithmetic = true; public bool Logarithmic = false; diff --git a/Common/UnitDefinitions/BitRate.json b/Common/UnitDefinitions/BitRate.json index afa72e498d..d85f00293e 100644 --- a/Common/UnitDefinitions/BitRate.json +++ b/Common/UnitDefinitions/BitRate.json @@ -1,7 +1,7 @@ { "Name": "BitRate", "BaseUnit": "BitPerSecond", - "BaseType": "decimal", + "ValueType": "decimal", "XmlDoc": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate", "BaseDimensions": { "T": -1 }, diff --git a/Common/UnitDefinitions/Information.json b/Common/UnitDefinitions/Information.json index 465fea7e23..0e20012d5c 100644 --- a/Common/UnitDefinitions/Information.json +++ b/Common/UnitDefinitions/Information.json @@ -1,7 +1,7 @@ { "Name": "Information", "BaseUnit": "Bit", - "BaseType": "decimal", + "ValueType": "decimal", "XmlDoc": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.", "Units": [ { diff --git a/Common/UnitDefinitions/Luminosity.json b/Common/UnitDefinitions/Luminosity.json index 11e3ee837b..2a6c5e69c6 100644 --- a/Common/UnitDefinitions/Luminosity.json +++ b/Common/UnitDefinitions/Luminosity.json @@ -1,7 +1,6 @@ { "Name": "Luminosity", "BaseUnit": "Watt", - "BaseType": "double", "XmlDoc": "Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index 32081d4e6a..89fa86aa3d 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -1,7 +1,7 @@ { "Name": "Power", "BaseUnit": "Watt", - "BaseType": "decimal", + "ValueType": "decimal", "XmlDoc": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.", "BaseDimensions": { "L": 2, From 4e88583527db4dfedaa0807069a29936a9e98d4f Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:06:46 +0100 Subject: [PATCH 08/66] =?UTF-8?q?=F0=9F=92=A5=20Rename=20BaseUnit=20to=20C?= =?UTF-8?q?onversionBaseUnit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rename JSON field and quantity class property. --- .../NanoFrameworkGen/QuantityGenerator.cs | 18 +- .../UnitsNetGen/QuantityGenerator.cs | 22 +- .../UnitsNetGen/StaticQuantityGenerator.cs | 4 +- .../UnitsNetGen/UnitConverterGenerator.cs | 8 +- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 8 +- CodeGen/JsonTypes/Quantity.cs | 4 +- Common/UnitDefinitions/Acceleration.json | 2 +- Common/UnitDefinitions/AmountOfSubstance.json | 2 +- Common/UnitDefinitions/AmplitudeRatio.json | 2 +- Common/UnitDefinitions/Angle.json | 2 +- Common/UnitDefinitions/ApparentEnergy.json | 2 +- Common/UnitDefinitions/ApparentPower.json | 2 +- Common/UnitDefinitions/Area.json | 2 +- Common/UnitDefinitions/AreaDensity.json | 2 +- .../UnitDefinitions/AreaMomentOfInertia.json | 2 +- Common/UnitDefinitions/BitRate.json | 2 +- .../BrakeSpecificFuelConsumption.json | 2 +- Common/UnitDefinitions/Capacitance.json | 2 +- .../CoefficientOfThermalExpansion.json | 2 +- Common/UnitDefinitions/Density.json | 2 +- Common/UnitDefinitions/Duration.json | 2 +- Common/UnitDefinitions/DynamicViscosity.json | 2 +- .../UnitDefinitions/ElectricAdmittance.json | 2 +- Common/UnitDefinitions/ElectricCharge.json | 2 +- .../ElectricChargeDensity.json | 2 +- .../UnitDefinitions/ElectricConductance.json | 2 +- .../UnitDefinitions/ElectricConductivity.json | 2 +- Common/UnitDefinitions/ElectricCurrent.json | 2 +- .../ElectricCurrentDensity.json | 2 +- .../ElectricCurrentGradient.json | 2 +- Common/UnitDefinitions/ElectricField.json | 2 +- .../UnitDefinitions/ElectricInductance.json | 2 +- Common/UnitDefinitions/ElectricPotential.json | 2 +- .../UnitDefinitions/ElectricPotentialAc.json | 2 +- .../ElectricPotentialChangeRate.json | 2 +- .../UnitDefinitions/ElectricPotentialDc.json | 2 +- .../UnitDefinitions/ElectricResistance.json | 2 +- .../UnitDefinitions/ElectricResistivity.json | 2 +- .../ElectricSurfaceChargeDensity.json | 2 +- Common/UnitDefinitions/Energy.json | 2 +- Common/UnitDefinitions/Entropy.json | 2 +- Common/UnitDefinitions/Force.json | 2 +- Common/UnitDefinitions/ForceChangeRate.json | 2 +- Common/UnitDefinitions/ForcePerLength.json | 2 +- Common/UnitDefinitions/Frequency.json | 2 +- Common/UnitDefinitions/FuelEfficiency.json | 2 +- Common/UnitDefinitions/HeatFlux.json | 2 +- .../HeatTransferCoefficient.json | 2 +- Common/UnitDefinitions/Illuminance.json | 2 +- Common/UnitDefinitions/Information.json | 2 +- Common/UnitDefinitions/Irradiance.json | 2 +- Common/UnitDefinitions/Irradiation.json | 2 +- .../UnitDefinitions/KinematicViscosity.json | 2 +- Common/UnitDefinitions/LapseRate.json | 2 +- Common/UnitDefinitions/Length.json | 2 +- Common/UnitDefinitions/Level.json | 2 +- Common/UnitDefinitions/LinearDensity.json | 2 +- .../UnitDefinitions/LinearPowerDensity.json | 2 +- Common/UnitDefinitions/Luminosity.json | 2 +- Common/UnitDefinitions/LuminousFlux.json | 2 +- Common/UnitDefinitions/LuminousIntensity.json | 2 +- Common/UnitDefinitions/MagneticField.json | 2 +- Common/UnitDefinitions/MagneticFlux.json | 2 +- Common/UnitDefinitions/Magnetization.json | 2 +- Common/UnitDefinitions/Mass.json | 2 +- Common/UnitDefinitions/MassConcentration.json | 2 +- Common/UnitDefinitions/MassFlow.json | 2 +- Common/UnitDefinitions/MassFlux.json | 2 +- Common/UnitDefinitions/MassFraction.json | 2 +- .../UnitDefinitions/MassMomentOfInertia.json | 2 +- Common/UnitDefinitions/MolarEnergy.json | 2 +- Common/UnitDefinitions/MolarEntropy.json | 2 +- Common/UnitDefinitions/MolarMass.json | 2 +- Common/UnitDefinitions/Molarity.json | 2 +- Common/UnitDefinitions/Permeability.json | 2 +- Common/UnitDefinitions/Permittivity.json | 2 +- Common/UnitDefinitions/Power.json | 2 +- Common/UnitDefinitions/PowerDensity.json | 2 +- Common/UnitDefinitions/PowerRatio.json | 2 +- Common/UnitDefinitions/Pressure.json | 2 +- .../UnitDefinitions/PressureChangeRate.json | 2 +- Common/UnitDefinitions/Ratio.json | 2 +- Common/UnitDefinitions/RatioChangeRate.json | 2 +- Common/UnitDefinitions/ReactiveEnergy.json | 2 +- Common/UnitDefinitions/ReactivePower.json | 2 +- Common/UnitDefinitions/ReciprocalArea.json | 3 +- Common/UnitDefinitions/ReciprocalLength.json | 2 +- Common/UnitDefinitions/RelativeHumidity.json | 2 +- .../RotationalAcceleration.json | 2 +- Common/UnitDefinitions/RotationalSpeed.json | 2 +- .../UnitDefinitions/RotationalStiffness.json | 2 +- .../RotationalStiffnessPerLength.json | 2 +- Common/UnitDefinitions/Scalar.json | 2 +- Common/UnitDefinitions/SolidAngle.json | 2 +- Common/UnitDefinitions/SpecificEnergy.json | 2 +- Common/UnitDefinitions/SpecificEntropy.json | 2 +- .../SpecificFuelConsumption.json | 10 +- Common/UnitDefinitions/SpecificVolume.json | 2 +- Common/UnitDefinitions/SpecificWeight.json | 2 +- Common/UnitDefinitions/Speed.json | 2 +- .../UnitDefinitions/StandardVolumeFlow.json | 2 +- Common/UnitDefinitions/Temperature.json | 2 +- .../TemperatureChangeRate.json | 2 +- Common/UnitDefinitions/TemperatureDelta.json | 2 +- .../UnitDefinitions/ThermalConductivity.json | 2 +- Common/UnitDefinitions/ThermalResistance.json | 2 +- Common/UnitDefinitions/Torque.json | 2 +- Common/UnitDefinitions/TorquePerLength.json | 2 +- Common/UnitDefinitions/Turbidity.json | 2 +- Common/UnitDefinitions/VitaminA.json | 2 +- Common/UnitDefinitions/Volume.json | 2 +- .../UnitDefinitions/VolumeConcentration.json | 2 +- Common/UnitDefinitions/VolumeFlow.json | 2 +- Common/UnitDefinitions/VolumePerLength.json | 2 +- .../VolumetricHeatCapacity.json | 2 +- .../WarpingMomentOfInertia.json | 2 +- .../Quantities/Acceleration.g.cs | 8 +- .../Quantities/AmountOfSubstance.g.cs | 8 +- .../Quantities/AmplitudeRatio.g.cs | 8 +- .../GeneratedCode/Quantities/Angle.g.cs | 8 +- .../Quantities/ApparentEnergy.g.cs | 8 +- .../Quantities/ApparentPower.g.cs | 8 +- .../GeneratedCode/Quantities/Area.g.cs | 8 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 8 +- .../Quantities/AreaMomentOfInertia.g.cs | 8 +- .../GeneratedCode/Quantities/BitRate.g.cs | 8 +- .../BrakeSpecificFuelConsumption.g.cs | 8 +- .../GeneratedCode/Quantities/Capacitance.g.cs | 8 +- .../CoefficientOfThermalExpansion.g.cs | 8 +- .../GeneratedCode/Quantities/Density.g.cs | 8 +- .../GeneratedCode/Quantities/Duration.g.cs | 8 +- .../Quantities/DynamicViscosity.g.cs | 8 +- .../Quantities/ElectricAdmittance.g.cs | 8 +- .../Quantities/ElectricCharge.g.cs | 8 +- .../Quantities/ElectricChargeDensity.g.cs | 8 +- .../Quantities/ElectricConductance.g.cs | 8 +- .../Quantities/ElectricConductivity.g.cs | 8 +- .../Quantities/ElectricCurrent.g.cs | 8 +- .../Quantities/ElectricCurrentDensity.g.cs | 8 +- .../Quantities/ElectricCurrentGradient.g.cs | 8 +- .../Quantities/ElectricField.g.cs | 8 +- .../Quantities/ElectricInductance.g.cs | 8 +- .../Quantities/ElectricPotential.g.cs | 8 +- .../Quantities/ElectricPotentialAc.g.cs | 8 +- .../ElectricPotentialChangeRate.g.cs | 8 +- .../Quantities/ElectricPotentialDc.g.cs | 8 +- .../Quantities/ElectricResistance.g.cs | 8 +- .../Quantities/ElectricResistivity.g.cs | 8 +- .../ElectricSurfaceChargeDensity.g.cs | 8 +- .../GeneratedCode/Quantities/Energy.g.cs | 8 +- .../GeneratedCode/Quantities/Entropy.g.cs | 8 +- .../GeneratedCode/Quantities/Force.g.cs | 8 +- .../Quantities/ForceChangeRate.g.cs | 8 +- .../Quantities/ForcePerLength.g.cs | 8 +- .../GeneratedCode/Quantities/Frequency.g.cs | 8 +- .../Quantities/FuelEfficiency.g.cs | 8 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 8 +- .../Quantities/HeatTransferCoefficient.g.cs | 8 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 8 +- .../GeneratedCode/Quantities/Information.g.cs | 8 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 8 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 8 +- .../Quantities/KinematicViscosity.g.cs | 8 +- .../GeneratedCode/Quantities/LapseRate.g.cs | 8 +- .../GeneratedCode/Quantities/Length.g.cs | 8 +- .../GeneratedCode/Quantities/Level.g.cs | 8 +- .../Quantities/LinearDensity.g.cs | 8 +- .../Quantities/LinearPowerDensity.g.cs | 8 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 8 +- .../Quantities/LuminousFlux.g.cs | 8 +- .../Quantities/LuminousIntensity.g.cs | 8 +- .../Quantities/MagneticField.g.cs | 8 +- .../Quantities/MagneticFlux.g.cs | 8 +- .../Quantities/Magnetization.g.cs | 8 +- .../GeneratedCode/Quantities/Mass.g.cs | 8 +- .../Quantities/MassConcentration.g.cs | 8 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 8 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 8 +- .../Quantities/MassFraction.g.cs | 8 +- .../Quantities/MassMomentOfInertia.g.cs | 8 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 8 +- .../Quantities/MolarEntropy.g.cs | 8 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 8 +- .../GeneratedCode/Quantities/Molarity.g.cs | 8 +- .../Quantities/Permeability.g.cs | 8 +- .../Quantities/Permittivity.g.cs | 8 +- .../GeneratedCode/Quantities/Power.g.cs | 8 +- .../Quantities/PowerDensity.g.cs | 8 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 8 +- .../GeneratedCode/Quantities/Pressure.g.cs | 8 +- .../Quantities/PressureChangeRate.g.cs | 8 +- .../GeneratedCode/Quantities/Ratio.g.cs | 8 +- .../Quantities/RatioChangeRate.g.cs | 8 +- .../Quantities/ReactiveEnergy.g.cs | 8 +- .../Quantities/ReactivePower.g.cs | 8 +- .../Quantities/ReciprocalArea.g.cs | 8 +- .../Quantities/ReciprocalLength.g.cs | 8 +- .../Quantities/RelativeHumidity.g.cs | 8 +- .../Quantities/RotationalAcceleration.g.cs | 8 +- .../Quantities/RotationalSpeed.g.cs | 8 +- .../Quantities/RotationalStiffness.g.cs | 8 +- .../RotationalStiffnessPerLength.g.cs | 8 +- .../GeneratedCode/Quantities/Scalar.g.cs | 8 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 8 +- .../Quantities/SpecificEnergy.g.cs | 8 +- .../Quantities/SpecificEntropy.g.cs | 8 +- .../Quantities/SpecificFuelConsumption.g.cs | 8 +- .../Quantities/SpecificVolume.g.cs | 8 +- .../Quantities/SpecificWeight.g.cs | 8 +- .../GeneratedCode/Quantities/Speed.g.cs | 8 +- .../Quantities/StandardVolumeFlow.g.cs | 8 +- .../GeneratedCode/Quantities/Temperature.g.cs | 8 +- .../Quantities/TemperatureChangeRate.g.cs | 8 +- .../Quantities/TemperatureDelta.g.cs | 8 +- .../Quantities/ThermalConductivity.g.cs | 8 +- .../Quantities/ThermalResistance.g.cs | 8 +- .../GeneratedCode/Quantities/Torque.g.cs | 8 +- .../Quantities/TorquePerLength.g.cs | 8 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 8 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 8 +- .../GeneratedCode/Quantities/Volume.g.cs | 8 +- .../Quantities/VolumeConcentration.g.cs | 8 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 8 +- .../Quantities/VolumePerLength.g.cs | 8 +- .../Quantities/VolumetricHeatCapacity.g.cs | 8 +- .../Quantities/WarpingMomentOfInertia.g.cs | 8 +- .../UnitsNetJsonConverter.cs | 8 +- .../CustomCode/MassConcentrationTests.cs | 4 +- .../TestsBase/AccelerationTestsBase.g.cs | 4 +- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 4 +- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 4 +- .../TestsBase/AngleTestsBase.g.cs | 4 +- .../TestsBase/ApparentEnergyTestsBase.g.cs | 4 +- .../TestsBase/ApparentPowerTestsBase.g.cs | 4 +- .../TestsBase/AreaDensityTestsBase.g.cs | 4 +- .../AreaMomentOfInertiaTestsBase.g.cs | 4 +- .../TestsBase/AreaTestsBase.g.cs | 4 +- .../TestsBase/BitRateTestsBase.g.cs | 4 +- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 4 +- .../TestsBase/CapacitanceTestsBase.g.cs | 4 +- ...oefficientOfThermalExpansionTestsBase.g.cs | 4 +- .../TestsBase/DensityTestsBase.g.cs | 4 +- .../TestsBase/DurationTestsBase.g.cs | 4 +- .../TestsBase/DynamicViscosityTestsBase.g.cs | 4 +- .../ElectricAdmittanceTestsBase.g.cs | 4 +- .../ElectricChargeDensityTestsBase.g.cs | 4 +- .../TestsBase/ElectricChargeTestsBase.g.cs | 4 +- .../ElectricConductanceTestsBase.g.cs | 4 +- .../ElectricConductivityTestsBase.g.cs | 4 +- .../ElectricCurrentDensityTestsBase.g.cs | 4 +- .../ElectricCurrentGradientTestsBase.g.cs | 4 +- .../TestsBase/ElectricCurrentTestsBase.g.cs | 4 +- .../TestsBase/ElectricFieldTestsBase.g.cs | 4 +- .../ElectricInductanceTestsBase.g.cs | 4 +- .../ElectricPotentialAcTestsBase.g.cs | 4 +- .../ElectricPotentialChangeRateTestsBase.g.cs | 4 +- .../ElectricPotentialDcTestsBase.g.cs | 4 +- .../TestsBase/ElectricPotentialTestsBase.g.cs | 4 +- .../ElectricResistanceTestsBase.g.cs | 4 +- .../ElectricResistivityTestsBase.g.cs | 4 +- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 4 +- .../TestsBase/EnergyTestsBase.g.cs | 4 +- .../TestsBase/EntropyTestsBase.g.cs | 4 +- .../TestsBase/ForceChangeRateTestsBase.g.cs | 4 +- .../TestsBase/ForcePerLengthTestsBase.g.cs | 4 +- .../TestsBase/ForceTestsBase.g.cs | 4 +- .../TestsBase/FrequencyTestsBase.g.cs | 4 +- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 4 +- .../TestsBase/HeatFluxTestsBase.g.cs | 4 +- .../HeatTransferCoefficientTestsBase.g.cs | 4 +- .../TestsBase/IlluminanceTestsBase.g.cs | 4 +- .../TestsBase/InformationTestsBase.g.cs | 4 +- .../TestsBase/IrradianceTestsBase.g.cs | 4 +- .../TestsBase/IrradiationTestsBase.g.cs | 4 +- .../KinematicViscosityTestsBase.g.cs | 4 +- .../TestsBase/LapseRateTestsBase.g.cs | 4 +- .../TestsBase/LengthTestsBase.g.cs | 4 +- .../TestsBase/LevelTestsBase.g.cs | 4 +- .../TestsBase/LinearDensityTestsBase.g.cs | 4 +- .../LinearPowerDensityTestsBase.g.cs | 4 +- .../TestsBase/LuminosityTestsBase.g.cs | 4 +- .../TestsBase/LuminousFluxTestsBase.g.cs | 4 +- .../TestsBase/LuminousIntensityTestsBase.g.cs | 4 +- .../TestsBase/MagneticFieldTestsBase.g.cs | 4 +- .../TestsBase/MagneticFluxTestsBase.g.cs | 4 +- .../TestsBase/MagnetizationTestsBase.g.cs | 4 +- .../TestsBase/MassConcentrationTestsBase.g.cs | 4 +- .../TestsBase/MassFlowTestsBase.g.cs | 4 +- .../TestsBase/MassFluxTestsBase.g.cs | 4 +- .../TestsBase/MassFractionTestsBase.g.cs | 4 +- .../MassMomentOfInertiaTestsBase.g.cs | 4 +- .../TestsBase/MassTestsBase.g.cs | 4 +- .../TestsBase/MolarEnergyTestsBase.g.cs | 4 +- .../TestsBase/MolarEntropyTestsBase.g.cs | 4 +- .../TestsBase/MolarMassTestsBase.g.cs | 4 +- .../TestsBase/MolarityTestsBase.g.cs | 4 +- .../TestsBase/PermeabilityTestsBase.g.cs | 4 +- .../TestsBase/PermittivityTestsBase.g.cs | 4 +- .../TestsBase/PowerDensityTestsBase.g.cs | 4 +- .../TestsBase/PowerRatioTestsBase.g.cs | 4 +- .../TestsBase/PowerTestsBase.g.cs | 4 +- .../PressureChangeRateTestsBase.g.cs | 4 +- .../TestsBase/PressureTestsBase.g.cs | 4 +- .../TestsBase/RatioChangeRateTestsBase.g.cs | 4 +- .../TestsBase/RatioTestsBase.g.cs | 4 +- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 4 +- .../TestsBase/ReactivePowerTestsBase.g.cs | 4 +- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 4 +- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 4 +- .../TestsBase/RelativeHumidityTestsBase.g.cs | 4 +- .../RotationalAccelerationTestsBase.g.cs | 4 +- .../TestsBase/RotationalSpeedTestsBase.g.cs | 4 +- ...RotationalStiffnessPerLengthTestsBase.g.cs | 4 +- .../RotationalStiffnessTestsBase.g.cs | 4 +- .../TestsBase/ScalarTestsBase.g.cs | 4 +- .../TestsBase/SolidAngleTestsBase.g.cs | 4 +- .../TestsBase/SpecificEnergyTestsBase.g.cs | 4 +- .../TestsBase/SpecificEntropyTestsBase.g.cs | 4 +- .../SpecificFuelConsumptionTestsBase.g.cs | 4 +- .../TestsBase/SpecificVolumeTestsBase.g.cs | 4 +- .../TestsBase/SpecificWeightTestsBase.g.cs | 4 +- .../TestsBase/SpeedTestsBase.g.cs | 4 +- .../StandardVolumeFlowTestsBase.g.cs | 4 +- .../TemperatureChangeRateTestsBase.g.cs | 4 +- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 4 +- .../TestsBase/TemperatureTestsBase.g.cs | 4 +- .../ThermalConductivityTestsBase.g.cs | 4 +- .../TestsBase/ThermalResistanceTestsBase.g.cs | 4 +- .../TestsBase/TorquePerLengthTestsBase.g.cs | 4 +- .../TestsBase/TorqueTestsBase.g.cs | 4 +- .../TestsBase/TurbidityTestsBase.g.cs | 4 +- .../TestsBase/VitaminATestsBase.g.cs | 4 +- .../VolumeConcentrationTestsBase.g.cs | 4 +- .../TestsBase/VolumeFlowTestsBase.g.cs | 4 +- .../TestsBase/VolumePerLengthTestsBase.g.cs | 4 +- .../TestsBase/VolumeTestsBase.g.cs | 4 +- .../VolumetricHeatCapacityTestsBase.g.cs | 4 +- .../WarpingMomentOfInertiaTestsBase.g.cs | 4 +- UnitsNet.Tests/QuantityInfoTest.cs | 32 +- UnitsNet.Tests/QuantityTest.cs | 2 +- .../DefaultDataContractJsonSerializerTests.cs | 14 +- UnitsNet.Tests/UnitMathTests.cs | 2 +- .../Quantities/Acceleration.g.cs | 14 +- .../Quantities/AmountOfSubstance.g.cs | 14 +- .../Quantities/AmplitudeRatio.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 14 +- .../Quantities/ApparentEnergy.g.cs | 14 +- .../Quantities/ApparentPower.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 14 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 14 +- .../Quantities/AreaMomentOfInertia.g.cs | 14 +- .../GeneratedCode/Quantities/BitRate.g.cs | 14 +- .../BrakeSpecificFuelConsumption.g.cs | 14 +- .../GeneratedCode/Quantities/Capacitance.g.cs | 14 +- .../CoefficientOfThermalExpansion.g.cs | 14 +- .../GeneratedCode/Quantities/Density.g.cs | 14 +- .../GeneratedCode/Quantities/Duration.g.cs | 14 +- .../Quantities/DynamicViscosity.g.cs | 14 +- .../Quantities/ElectricAdmittance.g.cs | 14 +- .../Quantities/ElectricCharge.g.cs | 14 +- .../Quantities/ElectricChargeDensity.g.cs | 14 +- .../Quantities/ElectricConductance.g.cs | 14 +- .../Quantities/ElectricConductivity.g.cs | 14 +- .../Quantities/ElectricCurrent.g.cs | 14 +- .../Quantities/ElectricCurrentDensity.g.cs | 14 +- .../Quantities/ElectricCurrentGradient.g.cs | 14 +- .../Quantities/ElectricField.g.cs | 14 +- .../Quantities/ElectricInductance.g.cs | 14 +- .../Quantities/ElectricPotential.g.cs | 14 +- .../Quantities/ElectricPotentialAc.g.cs | 14 +- .../ElectricPotentialChangeRate.g.cs | 14 +- .../Quantities/ElectricPotentialDc.g.cs | 14 +- .../Quantities/ElectricResistance.g.cs | 14 +- .../Quantities/ElectricResistivity.g.cs | 14 +- .../ElectricSurfaceChargeDensity.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 14 +- .../GeneratedCode/Quantities/Entropy.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 14 +- .../Quantities/ForceChangeRate.g.cs | 14 +- .../Quantities/ForcePerLength.g.cs | 14 +- .../GeneratedCode/Quantities/Frequency.g.cs | 14 +- .../Quantities/FuelEfficiency.g.cs | 14 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 14 +- .../Quantities/HeatTransferCoefficient.g.cs | 14 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 14 +- .../GeneratedCode/Quantities/Information.g.cs | 14 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 14 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 14 +- .../Quantities/KinematicViscosity.g.cs | 14 +- .../GeneratedCode/Quantities/LapseRate.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 14 +- .../Quantities/LinearDensity.g.cs | 14 +- .../Quantities/LinearPowerDensity.g.cs | 14 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 14 +- .../Quantities/LuminousFlux.g.cs | 14 +- .../Quantities/LuminousIntensity.g.cs | 14 +- .../Quantities/MagneticField.g.cs | 14 +- .../Quantities/MagneticFlux.g.cs | 14 +- .../Quantities/Magnetization.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 14 +- .../Quantities/MassConcentration.g.cs | 14 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 14 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 14 +- .../Quantities/MassFraction.g.cs | 14 +- .../Quantities/MassMomentOfInertia.g.cs | 14 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 14 +- .../Quantities/MolarEntropy.g.cs | 14 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 14 +- .../GeneratedCode/Quantities/Molarity.g.cs | 16 +- .../Quantities/Permeability.g.cs | 14 +- .../Quantities/Permittivity.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 14 +- .../Quantities/PowerDensity.g.cs | 14 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 14 +- .../GeneratedCode/Quantities/Pressure.g.cs | 14 +- .../Quantities/PressureChangeRate.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 14 +- .../Quantities/RatioChangeRate.g.cs | 14 +- .../Quantities/ReactiveEnergy.g.cs | 14 +- .../Quantities/ReactivePower.g.cs | 14 +- .../Quantities/ReciprocalArea.g.cs | 14 +- .../Quantities/ReciprocalLength.g.cs | 14 +- .../Quantities/RelativeHumidity.g.cs | 14 +- .../Quantities/RotationalAcceleration.g.cs | 14 +- .../Quantities/RotationalSpeed.g.cs | 14 +- .../Quantities/RotationalStiffness.g.cs | 14 +- .../RotationalStiffnessPerLength.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 14 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 14 +- .../Quantities/SpecificEnergy.g.cs | 14 +- .../Quantities/SpecificEntropy.g.cs | 14 +- .../Quantities/SpecificFuelConsumption.g.cs | 14 +- .../Quantities/SpecificVolume.g.cs | 14 +- .../Quantities/SpecificWeight.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 14 +- .../Quantities/StandardVolumeFlow.g.cs | 14 +- .../GeneratedCode/Quantities/Temperature.g.cs | 14 +- .../Quantities/TemperatureChangeRate.g.cs | 14 +- .../Quantities/TemperatureDelta.g.cs | 14 +- .../Quantities/ThermalConductivity.g.cs | 14 +- .../Quantities/ThermalResistance.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 14 +- .../Quantities/TorquePerLength.g.cs | 14 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 14 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 14 +- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 14 +- .../Quantities/VolumeConcentration.g.cs | 14 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 14 +- .../Quantities/VolumePerLength.g.cs | 14 +- .../Quantities/VolumetricHeatCapacity.g.cs | 14 +- .../Quantities/WarpingMomentOfInertia.g.cs | 14 +- UnitsNet/GeneratedCode/Quantity.g.cs | 440 +- UnitsNet/GeneratedCode/UnitConverter.g.cs | 5084 ++++++++--------- UnitsNet/IQuantity.cs | 2 +- UnitsNet/QuantityInfo.cs | 10 +- ...GenerateUnitConverterDefaultSourceCode.ps1 | 52 - 457 files changed, 4376 insertions(+), 4429 deletions(-) delete mode 100644 UnitsNet/Scripts/Include-GenerateUnitConverterDefaultSourceCode.ps1 diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index a6c303f5d5..9e214485f6 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -14,7 +14,7 @@ internal class QuantityGenerator : GeneratorBase public QuantityGenerator(Quantity quantity) { _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); - _unitEnumName = $"{quantity.Name}Unit"; + _unitEnumName = $"{quantity.Name}Unit"; } public override string Generate() @@ -75,7 +75,7 @@ public struct {_quantity.Name} /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static {_unitEnumName} BaseUnit {{ get; }} = {_unitEnumName}.{_quantity.BaseUnit}; + public static {_unitEnumName} ConversionBaseUnit {{ get; }} = {_unitEnumName}.{_quantity.ConversionBaseUnit}; /// /// Represents the largest possible value of Duration @@ -83,27 +83,27 @@ public struct {_quantity.Name} // Non decimal Writer.WLCondition(_quantity.ValueType != "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, BaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, BaseUnit);"); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, ConversionBaseUnit);"); // Decimal MaxValue = 79228162514264337593543950335M Writer.WLCondition(_quantity.ValueType == "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, BaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, BaseUnit);"); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, ConversionBaseUnit);"); Writer.WL($@" /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, BaseUnit);"); + public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, ConversionBaseUnit);"); GenerateConversionProperties(); GenerateStaticFactoryMethods(); @@ -183,7 +183,7 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public {_quantity.ValueType} As({_unitEnumName} unit) => GetValueAs(unit); + public {_quantity.ValueType} As({_unitEnumName} unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -191,7 +191,7 @@ private void GenerateConversionMethods() /// A Duration with the specified unit. public {_quantity.Name} ToUnit({_unitEnumName} unit) {{ - + var convertedValue = GetValueAs(unit); return new {_quantity.Name}(convertedValue, unit); }} diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 307b6ac44c..394502da1d 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -21,8 +21,8 @@ public QuantityGenerator(Quantity quantity) { _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); - _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.BaseUnit) ?? - throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", + _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.ConversionBaseUnit) ?? + throw new ArgumentException($"No unit found with SingularName equal to ConversionBaseUnit [{_quantity.ConversionBaseUnit}]. This unit must be defined.", nameof(quantity)); _valueType = quantity.ValueType; @@ -160,7 +160,7 @@ private void GenerateStaticConstructor() Writer.WL($@" }}, - BaseUnit, Zero, BaseDimensions, QuantityType.{_quantity.Name}); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.{_quantity.Name}); }} "); } @@ -230,21 +230,21 @@ private void GenerateStaticProperties() public static BaseDimensions BaseDimensions {{ get; }} /// - /// The base unit of {_quantity.Name}, which is {_quantity.BaseUnit}. All conversions go via this value. + /// The base unit of {_quantity.Name}, which is {_quantity.ConversionBaseUnit}. All conversions go via this value. /// - public static {_unitEnumName} BaseUnit {{ get; }} = {_unitEnumName}.{_quantity.BaseUnit}; + public static {_unitEnumName} ConversionBaseUnit {{ get; }} = {_unitEnumName}.{_quantity.ConversionBaseUnit}; /// /// Represents the largest possible value of {_quantity.Name} /// [Obsolete(""MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848."")] - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_valueType}.MaxValue, BaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_valueType}.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of {_quantity.Name} /// [Obsolete(""MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848."")] - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_valueType}.MinValue, BaseUnit); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_valueType}.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -258,9 +258,9 @@ private void GenerateStaticProperties() public static {_unitEnumName}[] Units {{ get; }} = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().Except(new {_unitEnumName}[]{{ {_unitEnumName}.Undefined }}).ToArray(); /// - /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.BaseUnit}. + /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.ConversionBaseUnit}. /// - public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, BaseUnit); + public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, ConversionBaseUnit); #endregion "); @@ -292,7 +292,7 @@ private void GenerateProperties() Enum IQuantity.Unit => Unit; /// - public {_unitEnumName} Unit => _unit.GetValueOrDefault(BaseUnit); + public {_unitEnumName} Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo<{_unitEnumName}> QuantityInfo => Info; @@ -933,7 +933,7 @@ IQuantity IQuantity.ToUnit(Enum unit) internal {_quantity.Name} ToBaseUnit() {{ var baseUnitValue = GetValueInBaseUnit(); - return new {_quantity.Name}(baseUnitValue, BaseUnit); + return new {_quantity.Name}(baseUnitValue, ConversionBaseUnit); }} private {_valueType} GetValueAs({_unitEnumName} unit) diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 5e646a0605..050975208d 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -69,7 +69,7 @@ public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValu var quantityName = quantity.Name; Writer.WL($@" case QuantityType.{quantityName}: - return {quantityName}.From(value, {quantityName}.BaseUnit);"); + return {quantityName}.From(value, {quantityName}.ConversionBaseUnit);"); } Writer.WL(@" @@ -93,7 +93,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu var quantityName = quantity.Name; Writer.WL($@" case ""{quantityName}"": - return {quantityName}.From(value, {quantityName}.BaseUnit);"); + return {quantityName}.From(value, {quantityName}.ConversionBaseUnit);"); } Writer.WL(@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs index 09047b06e9..83de92800a 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs @@ -37,12 +37,12 @@ public static void RegisterDefaultConversions(UnitConverter unitConverter) foreach (Quantity quantity in _quantities) foreach (Unit unit in quantity.Units) { - Writer.WL(quantity.BaseUnit == unit.SingularName + Writer.WL(quantity.ConversionBaseUnit == unit.SingularName ? $@" - unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.BaseUnit, {quantity.Name}.BaseUnit, q => q);" + unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.ConversionBaseUnit, {quantity.Name}.ConversionBaseUnit, q => q);" : $@" - unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.BaseUnit, {quantity.Name}Unit.{unit.SingularName}, q => q.ToUnit({quantity.Name}Unit.{unit.SingularName})); - unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}Unit.{unit.SingularName}, {quantity.Name}.BaseUnit, q => q.ToBaseUnit());"); + unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}.ConversionBaseUnit, {quantity.Name}Unit.{unit.SingularName}, q => q.ToUnit({quantity.Name}Unit.{unit.SingularName})); + unitConverter.SetConversionFunction<{quantity.Name}>({quantity.Name}Unit.{unit.SingularName}, {quantity.Name}.ConversionBaseUnit, q => q.ToBaseUnit());"); } Writer.WL($@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index fbdf147c5c..d292a6d908 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -48,8 +48,8 @@ internal class UnitTestBaseClassGenerator : GeneratorBase public UnitTestBaseClassGenerator(Quantity quantity) { _quantity = quantity; - _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.BaseUnit) ?? - throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", + _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.ConversionBaseUnit) ?? + throw new ArgumentException($"No unit found with SingularName equal to ConversionBaseUnit [{_quantity.ConversionBaseUnit}]. This unit must be defined.", nameof(quantity)); _unitEnumName = $"{quantity.Name}Unit"; _baseUnitEnglishAbbreviation = GetEnglishAbbreviation(_baseUnit); @@ -232,7 +232,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() {{ - var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -267,7 +267,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() {{ var quantityInBaseUnit = {_quantity.Name}.From{_baseUnit.PluralName}(1).ToBaseUnit(); - Assert.Equal({_quantity.Name}.BaseUnit, quantityInBaseUnit.Unit);"); + Assert.Equal({_quantity.Name}.ConversionBaseUnit, quantityInBaseUnit.Unit);"); Writer.WL($@" }} diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index c49f547ad5..884afd60e2 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -11,9 +11,9 @@ internal class Quantity // 0649 Field is never assigned to #pragma warning disable 0649 - public BaseDimensions BaseDimensions = new BaseDimensions(); // Default to empty + public BaseDimensions BaseDimensions = new(); // Default to empty public string ValueType = "double"; - public string BaseUnit; // TODO Rename to DefaultUnit or IntermediateConversionUnit to avoid confusion with Unit.BaseUnits + public string ConversionBaseUnit; public bool GenerateArithmetic = true; public bool Logarithmic = false; public int LogarithmicScalingFactor = 1; diff --git a/Common/UnitDefinitions/Acceleration.json b/Common/UnitDefinitions/Acceleration.json index 1cb4c0b3ad..db4627d2d6 100644 --- a/Common/UnitDefinitions/Acceleration.json +++ b/Common/UnitDefinitions/Acceleration.json @@ -1,6 +1,6 @@ { "Name": "Acceleration", - "BaseUnit": "MeterPerSecondSquared", + "ConversionBaseUnit": "MeterPerSecondSquared", "XmlDoc": "Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/AmountOfSubstance.json b/Common/UnitDefinitions/AmountOfSubstance.json index 4f3502c9e6..d90a962f71 100644 --- a/Common/UnitDefinitions/AmountOfSubstance.json +++ b/Common/UnitDefinitions/AmountOfSubstance.json @@ -1,6 +1,6 @@ { "Name": "AmountOfSubstance", - "BaseUnit": "Mole", + "ConversionBaseUnit": "Mole", "XmlDoc": "Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals.", "BaseDimensions": { "N": 1 diff --git a/Common/UnitDefinitions/AmplitudeRatio.json b/Common/UnitDefinitions/AmplitudeRatio.json index 6c99ecf788..23c8942e47 100644 --- a/Common/UnitDefinitions/AmplitudeRatio.json +++ b/Common/UnitDefinitions/AmplitudeRatio.json @@ -1,6 +1,6 @@ { "Name": "AmplitudeRatio", - "BaseUnit": "DecibelVolt", + "ConversionBaseUnit": "DecibelVolt", "Logarithmic": "True", "LogarithmicScalingFactor": "2", "XmlDoc": "The strength of a signal expressed in decibels (dB) relative to one volt RMS.", diff --git a/Common/UnitDefinitions/Angle.json b/Common/UnitDefinitions/Angle.json index 7efaf8ce80..2adf55ad66 100644 --- a/Common/UnitDefinitions/Angle.json +++ b/Common/UnitDefinitions/Angle.json @@ -1,6 +1,6 @@ { "Name": "Angle", - "BaseUnit": "Degree", + "ConversionBaseUnit": "Degree", "XmlDoc": "In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.", "Units": [ { diff --git a/Common/UnitDefinitions/ApparentEnergy.json b/Common/UnitDefinitions/ApparentEnergy.json index 6fe008ac20..2a0e048864 100644 --- a/Common/UnitDefinitions/ApparentEnergy.json +++ b/Common/UnitDefinitions/ApparentEnergy.json @@ -1,6 +1,6 @@ { "Name": "ApparentEnergy", - "BaseUnit": "VoltampereHour", + "ConversionBaseUnit": "VoltampereHour", "XmlDoc": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ApparentPower.json b/Common/UnitDefinitions/ApparentPower.json index 66958d8f1a..4d1e224f10 100644 --- a/Common/UnitDefinitions/ApparentPower.json +++ b/Common/UnitDefinitions/ApparentPower.json @@ -1,6 +1,6 @@ { "Name": "ApparentPower", - "BaseUnit": "Voltampere", + "ConversionBaseUnit": "Voltampere", "XmlDoc": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Area.json b/Common/UnitDefinitions/Area.json index fed60e94ff..365352b412 100644 --- a/Common/UnitDefinitions/Area.json +++ b/Common/UnitDefinitions/Area.json @@ -1,6 +1,6 @@ { "Name": "Area", - "BaseUnit": "SquareMeter", + "ConversionBaseUnit": "SquareMeter", "XmlDoc": "Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept).", "BaseDimensions": { "L": 2 diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index bb4acc6f49..18c748d875 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -1,6 +1,6 @@ { "Name": "AreaDensity", - "BaseUnit": "KilogramPerSquareMeter", + "ConversionBaseUnit": "KilogramPerSquareMeter", "XmlDoc": "The area density of a two-dimensional object is calculated as the mass per unit area.", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/AreaMomentOfInertia.json b/Common/UnitDefinitions/AreaMomentOfInertia.json index 76b54cc681..b780a45854 100644 --- a/Common/UnitDefinitions/AreaMomentOfInertia.json +++ b/Common/UnitDefinitions/AreaMomentOfInertia.json @@ -1,6 +1,6 @@ { "Name": "AreaMomentOfInertia", - "BaseUnit": "MeterToTheFourth", + "ConversionBaseUnit": "MeterToTheFourth", "XmlDoc": "A geometric property of an area that reflects how its points are distributed with regard to an axis.", "BaseDimensions": { "L": 4 diff --git a/Common/UnitDefinitions/BitRate.json b/Common/UnitDefinitions/BitRate.json index d85f00293e..d1a8741587 100644 --- a/Common/UnitDefinitions/BitRate.json +++ b/Common/UnitDefinitions/BitRate.json @@ -1,6 +1,6 @@ { "Name": "BitRate", - "BaseUnit": "BitPerSecond", + "ConversionBaseUnit": "BitPerSecond", "ValueType": "decimal", "XmlDoc": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate", diff --git a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json index d0924fd6d0..c6d3130457 100644 --- a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json +++ b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json @@ -1,6 +1,6 @@ { "Name": "BrakeSpecificFuelConsumption", - "BaseUnit": "KilogramPerJoule", + "ConversionBaseUnit": "KilogramPerJoule", "XmlDoc": "Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/Capacitance.json b/Common/UnitDefinitions/Capacitance.json index f1634cf471..16068b00df 100644 --- a/Common/UnitDefinitions/Capacitance.json +++ b/Common/UnitDefinitions/Capacitance.json @@ -1,6 +1,6 @@ { "Name": "Capacitance", - "BaseUnit": "Farad", + "ConversionBaseUnit": "Farad", "XmlDoc": "Capacitance is the ability of a body to store an electric charge.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Capacitance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json index ea8ff3ad97..1c3630b9c6 100644 --- a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json +++ b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json @@ -1,6 +1,6 @@ { "Name": "CoefficientOfThermalExpansion", - "BaseUnit": "InverseKelvin", + "ConversionBaseUnit": "InverseKelvin", "XmlDoc": "A unit that represents a fractional change in size in response to a change in temperature.", "BaseDimensions": { "Θ": -1 diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json index 5e00c2ab12..a8bed90a85 100644 --- a/Common/UnitDefinitions/Density.json +++ b/Common/UnitDefinitions/Density.json @@ -1,6 +1,6 @@ { "Name": "Density", - "BaseUnit": "KilogramPerCubicMeter", + "ConversionBaseUnit": "KilogramPerCubicMeter", "XmlDoc": "The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Duration.json b/Common/UnitDefinitions/Duration.json index e0836fcae6..ee7a2f81ca 100644 --- a/Common/UnitDefinitions/Duration.json +++ b/Common/UnitDefinitions/Duration.json @@ -1,6 +1,6 @@ { "Name": "Duration", - "BaseUnit": "Second", + "ConversionBaseUnit": "Second", "XmlDoc": "Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them.", "BaseDimensions": { "T": 1 diff --git a/Common/UnitDefinitions/DynamicViscosity.json b/Common/UnitDefinitions/DynamicViscosity.json index a6a03e4d71..c14e04f7b4 100644 --- a/Common/UnitDefinitions/DynamicViscosity.json +++ b/Common/UnitDefinitions/DynamicViscosity.json @@ -1,6 +1,6 @@ { "Name": "DynamicViscosity", - "BaseUnit": "NewtonSecondPerMeterSquared", + "ConversionBaseUnit": "NewtonSecondPerMeterSquared", "XmlDoc": "The dynamic (shear) viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricAdmittance.json b/Common/UnitDefinitions/ElectricAdmittance.json index 357c8015ba..bf07ea62e1 100644 --- a/Common/UnitDefinitions/ElectricAdmittance.json +++ b/Common/UnitDefinitions/ElectricAdmittance.json @@ -1,6 +1,6 @@ { "Name": "ElectricAdmittance", - "BaseUnit": "Siemens", + "ConversionBaseUnit": "Siemens", "XmlDoc": "Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S).", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/ElectricCharge.json b/Common/UnitDefinitions/ElectricCharge.json index e7a3c7999b..54a00b15c2 100644 --- a/Common/UnitDefinitions/ElectricCharge.json +++ b/Common/UnitDefinitions/ElectricCharge.json @@ -1,6 +1,6 @@ { "Name": "ElectricCharge", - "BaseUnit": "Coulomb", + "ConversionBaseUnit": "Coulomb", "XmlDoc": "Electric charge is the physical property of matter that causes it to experience a force when placed in an electromagnetic field.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_charge", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricChargeDensity.json b/Common/UnitDefinitions/ElectricChargeDensity.json index 164214135f..1742e046f7 100644 --- a/Common/UnitDefinitions/ElectricChargeDensity.json +++ b/Common/UnitDefinitions/ElectricChargeDensity.json @@ -1,6 +1,6 @@ { "Name": "ElectricChargeDensity", - "BaseUnit": "CoulombPerCubicMeter", + "ConversionBaseUnit": "CoulombPerCubicMeter", "XmlDoc": "In electromagnetism, charge density is a measure of the amount of electric charge per volume.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Charge_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricConductance.json b/Common/UnitDefinitions/ElectricConductance.json index 4c0ec9d9ad..16ec1b6911 100644 --- a/Common/UnitDefinitions/ElectricConductance.json +++ b/Common/UnitDefinitions/ElectricConductance.json @@ -1,6 +1,6 @@ { "Name": "ElectricConductance", - "BaseUnit": "Siemens", + "ConversionBaseUnit": "Siemens", "XmlDoc": "The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricConductivity.json b/Common/UnitDefinitions/ElectricConductivity.json index 7d0c4302cb..d1a49af29d 100644 --- a/Common/UnitDefinitions/ElectricConductivity.json +++ b/Common/UnitDefinitions/ElectricConductivity.json @@ -1,6 +1,6 @@ { "Name": "ElectricConductivity", - "BaseUnit": "SiemensPerMeter", + "ConversionBaseUnit": "SiemensPerMeter", "XmlDoc": "Electrical conductivity or specific conductance is the reciprocal of electrical resistivity, and measures a material's ability to conduct an electric current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricCurrent.json b/Common/UnitDefinitions/ElectricCurrent.json index a9e5c91187..0d41c4fcc9 100644 --- a/Common/UnitDefinitions/ElectricCurrent.json +++ b/Common/UnitDefinitions/ElectricCurrent.json @@ -1,6 +1,6 @@ { "Name": "ElectricCurrent", - "BaseUnit": "Ampere", + "ConversionBaseUnit": "Ampere", "XmlDoc": "An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma.", "BaseDimensions": { "I": 1 diff --git a/Common/UnitDefinitions/ElectricCurrentDensity.json b/Common/UnitDefinitions/ElectricCurrentDensity.json index 0c3c1b11e8..2d6638e9ca 100644 --- a/Common/UnitDefinitions/ElectricCurrentDensity.json +++ b/Common/UnitDefinitions/ElectricCurrentDensity.json @@ -1,6 +1,6 @@ { "Name": "ElectricCurrentDensity", - "BaseUnit": "AmperePerSquareMeter", + "ConversionBaseUnit": "AmperePerSquareMeter", "XmlDoc": "In electromagnetism, current density is the electric current per unit area of cross section.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Current_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricCurrentGradient.json b/Common/UnitDefinitions/ElectricCurrentGradient.json index 982039f8d2..8d5281a601 100644 --- a/Common/UnitDefinitions/ElectricCurrentGradient.json +++ b/Common/UnitDefinitions/ElectricCurrentGradient.json @@ -1,6 +1,6 @@ { "Name": "ElectricCurrentGradient", - "BaseUnit": "AmperePerSecond", + "ConversionBaseUnit": "AmperePerSecond", "XmlDoc": "In electromagnetism, the current gradient describes how the current changes in time.", "BaseDimensions": { "T": -1, diff --git a/Common/UnitDefinitions/ElectricField.json b/Common/UnitDefinitions/ElectricField.json index 5a0f02d902..9e3284c025 100644 --- a/Common/UnitDefinitions/ElectricField.json +++ b/Common/UnitDefinitions/ElectricField.json @@ -1,6 +1,6 @@ { "Name": "ElectricField", - "BaseUnit": "VoltPerMeter", + "ConversionBaseUnit": "VoltPerMeter", "XmlDoc": "An electric field is a force field that surrounds electric charges that attracts or repels other electric charges.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_field", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricInductance.json b/Common/UnitDefinitions/ElectricInductance.json index e1c405a349..1b8e943fea 100644 --- a/Common/UnitDefinitions/ElectricInductance.json +++ b/Common/UnitDefinitions/ElectricInductance.json @@ -1,6 +1,6 @@ { "Name": "ElectricInductance", - "BaseUnit": "Henry", + "ConversionBaseUnit": "Henry", "XmlDoc": "Inductance is a property of an electrical conductor which opposes a change in current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inductance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricPotential.json b/Common/UnitDefinitions/ElectricPotential.json index 1ebb7755da..ed0c8466e4 100644 --- a/Common/UnitDefinitions/ElectricPotential.json +++ b/Common/UnitDefinitions/ElectricPotential.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotential", - "BaseUnit": "Volt", + "ConversionBaseUnit": "Volt", "XmlDoc": "In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricPotentialAc.json b/Common/UnitDefinitions/ElectricPotentialAc.json index 8128b3f86d..642a5af934 100644 --- a/Common/UnitDefinitions/ElectricPotentialAc.json +++ b/Common/UnitDefinitions/ElectricPotentialAc.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotentialAc", - "BaseUnit": "VoltAc", + "ConversionBaseUnit": "VoltAc", "XmlDoc": "The Electric Potential of a system known to use Alternating Current.", "Units": [ { diff --git a/Common/UnitDefinitions/ElectricPotentialChangeRate.json b/Common/UnitDefinitions/ElectricPotentialChangeRate.json index 1245353d5d..775804e042 100644 --- a/Common/UnitDefinitions/ElectricPotentialChangeRate.json +++ b/Common/UnitDefinitions/ElectricPotentialChangeRate.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotentialChangeRate", - "BaseUnit": "VoltPerSecond", + "ConversionBaseUnit": "VoltPerSecond", "XmlDoc": "ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time).", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricPotentialDc.json b/Common/UnitDefinitions/ElectricPotentialDc.json index 1f997605b2..c8c6591118 100644 --- a/Common/UnitDefinitions/ElectricPotentialDc.json +++ b/Common/UnitDefinitions/ElectricPotentialDc.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotentialDc", - "BaseUnit": "VoltDc", + "ConversionBaseUnit": "VoltDc", "XmlDoc": "The Electric Potential of a system known to use Direct Current.", "Units": [ { diff --git a/Common/UnitDefinitions/ElectricResistance.json b/Common/UnitDefinitions/ElectricResistance.json index 30aab9f8a2..b51f9e9fc1 100644 --- a/Common/UnitDefinitions/ElectricResistance.json +++ b/Common/UnitDefinitions/ElectricResistance.json @@ -1,6 +1,6 @@ { "Name": "ElectricResistance", - "BaseUnit": "Ohm", + "ConversionBaseUnit": "Ohm", "XmlDoc": "The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricResistivity.json b/Common/UnitDefinitions/ElectricResistivity.json index 1342678174..41624faf93 100644 --- a/Common/UnitDefinitions/ElectricResistivity.json +++ b/Common/UnitDefinitions/ElectricResistivity.json @@ -1,6 +1,6 @@ { "Name": "ElectricResistivity", - "BaseUnit": "OhmMeter", + "ConversionBaseUnit": "OhmMeter", "XmlDoc": "Electrical resistivity (also known as resistivity, specific electrical resistance, or volume resistivity) is a fundamental property that quantifies how strongly a given material opposes the flow of electric current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json index ffa0724aeb..305a1811ac 100644 --- a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json +++ b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json @@ -1,6 +1,6 @@ { "Name": "ElectricSurfaceChargeDensity", - "BaseUnit": "CoulombPerSquareMeter", + "ConversionBaseUnit": "CoulombPerSquareMeter", "XmlDoc": "In electromagnetism, surface charge density is a measure of the amount of electric charge per surface area.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Charge_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Energy.json b/Common/UnitDefinitions/Energy.json index 8cc55036ba..1c5602c3ae 100644 --- a/Common/UnitDefinitions/Energy.json +++ b/Common/UnitDefinitions/Energy.json @@ -1,6 +1,6 @@ { "Name": "Energy", - "BaseUnit": "Joule", + "ConversionBaseUnit": "Joule", "XmlDoc": "The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Entropy.json b/Common/UnitDefinitions/Entropy.json index 715e8a5ddd..770b896ee9 100644 --- a/Common/UnitDefinitions/Entropy.json +++ b/Common/UnitDefinitions/Entropy.json @@ -1,6 +1,6 @@ { "Name": "Entropy", - "BaseUnit": "JoulePerKelvin", + "ConversionBaseUnit": "JoulePerKelvin", "XmlDoc": "Entropy is an important concept in the branch of science known as thermodynamics. The idea of \"irreversibility\" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Force.json b/Common/UnitDefinitions/Force.json index b3ee6a66c9..d50a8febc7 100644 --- a/Common/UnitDefinitions/Force.json +++ b/Common/UnitDefinitions/Force.json @@ -1,6 +1,6 @@ { "Name": "Force", - "BaseUnit": "Newton", + "ConversionBaseUnit": "Newton", "XmlDoc": "In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/ForceChangeRate.json b/Common/UnitDefinitions/ForceChangeRate.json index c2722b5cb9..5f02e5b533 100644 --- a/Common/UnitDefinitions/ForceChangeRate.json +++ b/Common/UnitDefinitions/ForceChangeRate.json @@ -1,6 +1,6 @@ { "Name": "ForceChangeRate", - "BaseUnit": "NewtonPerSecond", + "ConversionBaseUnit": "NewtonPerSecond", "XmlDoc": "Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time).", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/ForcePerLength.json b/Common/UnitDefinitions/ForcePerLength.json index b9c4037d3c..2e8aed1b91 100644 --- a/Common/UnitDefinitions/ForcePerLength.json +++ b/Common/UnitDefinitions/ForcePerLength.json @@ -1,6 +1,6 @@ { "Name": "ForcePerLength", - "BaseUnit": "NewtonPerMeter", + "ConversionBaseUnit": "NewtonPerMeter", "XmlDoc": "The magnitude of force per unit length.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Frequency.json b/Common/UnitDefinitions/Frequency.json index 6c4d13698f..b5ebcb545d 100644 --- a/Common/UnitDefinitions/Frequency.json +++ b/Common/UnitDefinitions/Frequency.json @@ -1,6 +1,6 @@ { "Name": "Frequency", - "BaseUnit": "Hertz", + "ConversionBaseUnit": "Hertz", "XmlDoc": "The number of occurrences of a repeating event per unit time.", "BaseDimensions": { "T": -1 diff --git a/Common/UnitDefinitions/FuelEfficiency.json b/Common/UnitDefinitions/FuelEfficiency.json index 2da60218f7..81e30d4106 100644 --- a/Common/UnitDefinitions/FuelEfficiency.json +++ b/Common/UnitDefinitions/FuelEfficiency.json @@ -1,6 +1,6 @@ { "Name": "FuelEfficiency", - "BaseUnit": "LiterPer100Kilometers", + "ConversionBaseUnit": "LiterPer100Kilometers", "XmlDoc": "Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as \"fuel consumption\" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fuel_efficiency", "Units": [{ diff --git a/Common/UnitDefinitions/HeatFlux.json b/Common/UnitDefinitions/HeatFlux.json index 00d7d389bd..a3c573ce8e 100644 --- a/Common/UnitDefinitions/HeatFlux.json +++ b/Common/UnitDefinitions/HeatFlux.json @@ -1,6 +1,6 @@ { "Name": "HeatFlux", - "BaseUnit": "WattPerSquareMeter", + "ConversionBaseUnit": "WattPerSquareMeter", "XmlDoc": "Heat flux is the flow of energy per unit of area per unit of time", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/HeatTransferCoefficient.json b/Common/UnitDefinitions/HeatTransferCoefficient.json index 108f1c7c51..c904d3bfc6 100644 --- a/Common/UnitDefinitions/HeatTransferCoefficient.json +++ b/Common/UnitDefinitions/HeatTransferCoefficient.json @@ -1,6 +1,6 @@ { "Name": "HeatTransferCoefficient", - "BaseUnit": "WattPerSquareMeterKelvin", + "ConversionBaseUnit": "WattPerSquareMeterKelvin", "XmlDoc": "The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT)", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Illuminance.json b/Common/UnitDefinitions/Illuminance.json index c8268f093f..ac931d6092 100644 --- a/Common/UnitDefinitions/Illuminance.json +++ b/Common/UnitDefinitions/Illuminance.json @@ -1,6 +1,6 @@ { "Name": "Illuminance", - "BaseUnit": "Lux", + "ConversionBaseUnit": "Lux", "XmlDoc": "In photometry, illuminance is the total luminous flux incident on a surface, per unit area.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Illuminance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Information.json b/Common/UnitDefinitions/Information.json index 0e20012d5c..3646353415 100644 --- a/Common/UnitDefinitions/Information.json +++ b/Common/UnitDefinitions/Information.json @@ -1,6 +1,6 @@ { "Name": "Information", - "BaseUnit": "Bit", + "ConversionBaseUnit": "Bit", "ValueType": "decimal", "XmlDoc": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.", "Units": [ diff --git a/Common/UnitDefinitions/Irradiance.json b/Common/UnitDefinitions/Irradiance.json index 8f97326c4e..a1dee85b1e 100644 --- a/Common/UnitDefinitions/Irradiance.json +++ b/Common/UnitDefinitions/Irradiance.json @@ -1,6 +1,6 @@ { "Name": "Irradiance", - "BaseUnit": "WattPerSquareMeter", + "ConversionBaseUnit": "WattPerSquareMeter", "XmlDoc": "Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Irradiation.json b/Common/UnitDefinitions/Irradiation.json index 826586bd64..07e33181e8 100644 --- a/Common/UnitDefinitions/Irradiation.json +++ b/Common/UnitDefinitions/Irradiation.json @@ -1,6 +1,6 @@ { "Name": "Irradiation", - "BaseUnit": "JoulePerSquareMeter", + "ConversionBaseUnit": "JoulePerSquareMeter", "XmlDoc": "Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Irradiation", "BaseDimensions": { diff --git a/Common/UnitDefinitions/KinematicViscosity.json b/Common/UnitDefinitions/KinematicViscosity.json index 71499981eb..85df2707f5 100644 --- a/Common/UnitDefinitions/KinematicViscosity.json +++ b/Common/UnitDefinitions/KinematicViscosity.json @@ -1,6 +1,6 @@ { "Name": "KinematicViscosity", - "BaseUnit": "SquareMeterPerSecond", + "ConversionBaseUnit": "SquareMeterPerSecond", "XmlDoc": "The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Viscosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LapseRate.json b/Common/UnitDefinitions/LapseRate.json index c43b48b49c..c55cbb2e8f 100644 --- a/Common/UnitDefinitions/LapseRate.json +++ b/Common/UnitDefinitions/LapseRate.json @@ -1,6 +1,6 @@ { "Name": "LapseRate", - "BaseUnit": "DegreeCelsiusPerKilometer", + "ConversionBaseUnit": "DegreeCelsiusPerKilometer", "XmlDoc": "Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude.", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json index 7e17c888f6..3a533a2f1a 100644 --- a/Common/UnitDefinitions/Length.json +++ b/Common/UnitDefinitions/Length.json @@ -1,6 +1,6 @@ { "Name": "Length", - "BaseUnit": "Meter", + "ConversionBaseUnit": "Meter", "XmlDoc": "Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units.", "BaseDimensions": { "L": 1 diff --git a/Common/UnitDefinitions/Level.json b/Common/UnitDefinitions/Level.json index 6b601f1f84..c5e7cfba60 100644 --- a/Common/UnitDefinitions/Level.json +++ b/Common/UnitDefinitions/Level.json @@ -1,6 +1,6 @@ { "Name": "Level", - "BaseUnit": "Decibel", + "ConversionBaseUnit": "Decibel", "Logarithmic": "True", "LogarithmicScalingFactor": "1", "XmlDoc": "Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units.", diff --git a/Common/UnitDefinitions/LinearDensity.json b/Common/UnitDefinitions/LinearDensity.json index 9da3d68ca0..87b6176508 100644 --- a/Common/UnitDefinitions/LinearDensity.json +++ b/Common/UnitDefinitions/LinearDensity.json @@ -1,6 +1,6 @@ { "Name": "LinearDensity", - "BaseUnit": "KilogramPerMeter", + "ConversionBaseUnit": "KilogramPerMeter", "XmlDoc": "The Linear Density, or more precisely, the linear mass density, of a substance is its mass per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Linear_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LinearPowerDensity.json b/Common/UnitDefinitions/LinearPowerDensity.json index f8fe4b768e..81b374fd39 100644 --- a/Common/UnitDefinitions/LinearPowerDensity.json +++ b/Common/UnitDefinitions/LinearPowerDensity.json @@ -1,6 +1,6 @@ { "Name": "LinearPowerDensity", - "BaseUnit": "WattPerMeter", + "ConversionBaseUnit": "WattPerMeter", "XmlDoc": "The Linear Power Density of a substance is its power per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Linear_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Luminosity.json b/Common/UnitDefinitions/Luminosity.json index 2a6c5e69c6..1f949e02ea 100644 --- a/Common/UnitDefinitions/Luminosity.json +++ b/Common/UnitDefinitions/Luminosity.json @@ -1,6 +1,6 @@ { "Name": "Luminosity", - "BaseUnit": "Watt", + "ConversionBaseUnit": "Watt", "XmlDoc": "Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LuminousFlux.json b/Common/UnitDefinitions/LuminousFlux.json index 8b5238d7fa..9676c42d6e 100644 --- a/Common/UnitDefinitions/LuminousFlux.json +++ b/Common/UnitDefinitions/LuminousFlux.json @@ -1,6 +1,6 @@ { "Name": "LuminousFlux", - "BaseUnit": "Lumen", + "ConversionBaseUnit": "Lumen", "XmlDoc": "In photometry, luminous flux or luminous power is the measure of the perceived power of light.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminous_flux", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LuminousIntensity.json b/Common/UnitDefinitions/LuminousIntensity.json index 9a13ad312a..5f0bca8b87 100644 --- a/Common/UnitDefinitions/LuminousIntensity.json +++ b/Common/UnitDefinitions/LuminousIntensity.json @@ -1,6 +1,6 @@ { "Name": "LuminousIntensity", - "BaseUnit": "Candela", + "ConversionBaseUnit": "Candela", "XmlDoc": "In photometry, luminous intensity is a measure of the wavelength-weighted power emitted by a light source in a particular direction per unit solid angle, based on the luminosity function, a standardized model of the sensitivity of the human eye.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminous_intensity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/MagneticField.json b/Common/UnitDefinitions/MagneticField.json index d0992477f9..6e72a0c517 100644 --- a/Common/UnitDefinitions/MagneticField.json +++ b/Common/UnitDefinitions/MagneticField.json @@ -1,6 +1,6 @@ { "Name": "MagneticField", - "BaseUnit": "Tesla", + "ConversionBaseUnit": "Tesla", "XmlDoc": "A magnetic field is a force field that is created by moving electric charges (electric currents) and magnetic dipoles, and exerts a force on other nearby moving charges and magnetic dipoles.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetic_field", "BaseDimensions": { diff --git a/Common/UnitDefinitions/MagneticFlux.json b/Common/UnitDefinitions/MagneticFlux.json index 0748c24cdd..9b2f348306 100644 --- a/Common/UnitDefinitions/MagneticFlux.json +++ b/Common/UnitDefinitions/MagneticFlux.json @@ -1,6 +1,6 @@ { "Name": "MagneticFlux", - "BaseUnit": "Weber", + "ConversionBaseUnit": "Weber", "XmlDoc": "In physics, specifically electromagnetism, the magnetic flux through a surface is the surface integral of the normal component of the magnetic field B passing through that surface.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetic_flux", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Magnetization.json b/Common/UnitDefinitions/Magnetization.json index 2e15c7de36..287cab25ba 100644 --- a/Common/UnitDefinitions/Magnetization.json +++ b/Common/UnitDefinitions/Magnetization.json @@ -1,6 +1,6 @@ { "Name": "Magnetization", - "BaseUnit": "AmperePerMeter", + "ConversionBaseUnit": "AmperePerMeter", "XmlDoc": "In classical electromagnetism, magnetization is the vector field that expresses the density of permanent or induced magnetic dipole moments in a magnetic material.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetization", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Mass.json b/Common/UnitDefinitions/Mass.json index bbda2f4f61..e9d0066a73 100644 --- a/Common/UnitDefinitions/Mass.json +++ b/Common/UnitDefinitions/Mass.json @@ -1,6 +1,6 @@ { "Name": "Mass", - "BaseUnit": "Kilogram", + "ConversionBaseUnit": "Kilogram", "XmlDoc": "In physics, mass (from Greek μᾶζα \"barley cake, lump [of dough]\") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg).", "BaseDimensions": { "M": 1 diff --git a/Common/UnitDefinitions/MassConcentration.json b/Common/UnitDefinitions/MassConcentration.json index 8e1951cd1c..03a525a120 100644 --- a/Common/UnitDefinitions/MassConcentration.json +++ b/Common/UnitDefinitions/MassConcentration.json @@ -1,6 +1,6 @@ { "Name": "MassConcentration", - "BaseUnit": "KilogramPerCubicMeter", + "ConversionBaseUnit": "KilogramPerCubicMeter", "XmlDoc": "In chemistry, the mass concentration ρi (or γi) is defined as the mass of a constituent mi divided by the volume of the mixture V", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Mass_concentration_(chemistry)", "BaseDimensions": { diff --git a/Common/UnitDefinitions/MassFlow.json b/Common/UnitDefinitions/MassFlow.json index d37466a9d2..aff587dd6b 100644 --- a/Common/UnitDefinitions/MassFlow.json +++ b/Common/UnitDefinitions/MassFlow.json @@ -1,6 +1,6 @@ { "Name": "MassFlow", - "BaseUnit": "GramPerSecond", + "ConversionBaseUnit": "GramPerSecond", "XmlDoc": "Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time).", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/MassFlux.json b/Common/UnitDefinitions/MassFlux.json index 45492311a3..be7fb9911a 100644 --- a/Common/UnitDefinitions/MassFlux.json +++ b/Common/UnitDefinitions/MassFlux.json @@ -1,6 +1,6 @@ { "Name": "MassFlux", - "BaseUnit": "KilogramPerSecondPerSquareMeter", + "ConversionBaseUnit": "KilogramPerSecondPerSquareMeter", "XmlDoc": "Mass flux is the mass flow rate per unit area.", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/MassFraction.json b/Common/UnitDefinitions/MassFraction.json index fdfc016073..720e9efd4f 100644 --- a/Common/UnitDefinitions/MassFraction.json +++ b/Common/UnitDefinitions/MassFraction.json @@ -1,6 +1,6 @@ { "Name": "MassFraction", - "BaseUnit": "DecimalFraction", + "ConversionBaseUnit": "DecimalFraction", "XmlDoc": "The mass fraction is defined as the mass of a constituent divided by the total mass of the mixture.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Mass_fraction_(chemistry)", "Units": [ diff --git a/Common/UnitDefinitions/MassMomentOfInertia.json b/Common/UnitDefinitions/MassMomentOfInertia.json index e3916595d5..57f4699e3e 100644 --- a/Common/UnitDefinitions/MassMomentOfInertia.json +++ b/Common/UnitDefinitions/MassMomentOfInertia.json @@ -1,6 +1,6 @@ { "Name": "MassMomentOfInertia", - "BaseUnit": "KilogramSquareMeter", + "ConversionBaseUnit": "KilogramSquareMeter", "XmlDoc": "A property of body reflects how its mass is distributed with regard to an axis.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/MolarEnergy.json b/Common/UnitDefinitions/MolarEnergy.json index 3012cef97e..88dcaa0de9 100644 --- a/Common/UnitDefinitions/MolarEnergy.json +++ b/Common/UnitDefinitions/MolarEnergy.json @@ -1,6 +1,6 @@ { "Name": "MolarEnergy", - "BaseUnit": "JoulePerMole", + "ConversionBaseUnit": "JoulePerMole", "XmlDoc": "Molar energy is the amount of energy stored in 1 mole of a substance.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/MolarEntropy.json b/Common/UnitDefinitions/MolarEntropy.json index 5771bc43a3..5a2d7ff1ef 100644 --- a/Common/UnitDefinitions/MolarEntropy.json +++ b/Common/UnitDefinitions/MolarEntropy.json @@ -1,6 +1,6 @@ { "Name": "MolarEntropy", - "BaseUnit": "JoulePerMoleKelvin", + "ConversionBaseUnit": "JoulePerMoleKelvin", "XmlDoc": "Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/MolarMass.json b/Common/UnitDefinitions/MolarMass.json index 55dad2b8e6..6105c7b2dc 100644 --- a/Common/UnitDefinitions/MolarMass.json +++ b/Common/UnitDefinitions/MolarMass.json @@ -1,6 +1,6 @@ { "Name": "MolarMass", - "BaseUnit": "KilogramPerMole", + "ConversionBaseUnit": "KilogramPerMole", "XmlDoc": "In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Molarity.json b/Common/UnitDefinitions/Molarity.json index 60e1689ba8..9ca7d6b912 100644 --- a/Common/UnitDefinitions/Molarity.json +++ b/Common/UnitDefinitions/Molarity.json @@ -1,6 +1,6 @@ { "Name": "Molarity", - "BaseUnit": "MolesPerCubicMeter", + "ConversionBaseUnit": "MolesPerCubicMeter", "XmlDoc": "Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. ", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Molar_concentration", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Permeability.json b/Common/UnitDefinitions/Permeability.json index 8b2db18f37..793c5416fd 100644 --- a/Common/UnitDefinitions/Permeability.json +++ b/Common/UnitDefinitions/Permeability.json @@ -1,6 +1,6 @@ { "Name": "Permeability", - "BaseUnit": "HenryPerMeter", + "ConversionBaseUnit": "HenryPerMeter", "XmlDoc": "In electromagnetism, permeability is the measure of the ability of a material to support the formation of a magnetic field within itself.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Permeability_(electromagnetism)", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Permittivity.json b/Common/UnitDefinitions/Permittivity.json index 337b5624ad..f65c5b8930 100644 --- a/Common/UnitDefinitions/Permittivity.json +++ b/Common/UnitDefinitions/Permittivity.json @@ -1,6 +1,6 @@ { "Name": "Permittivity", - "BaseUnit": "FaradPerMeter", + "ConversionBaseUnit": "FaradPerMeter", "XmlDoc": "In electromagnetism, permittivity is the measure of resistance that is encountered when forming an electric field in a particular medium.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Permittivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index 89fa86aa3d..a8763a1c71 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -1,6 +1,6 @@ { "Name": "Power", - "BaseUnit": "Watt", + "ConversionBaseUnit": "Watt", "ValueType": "decimal", "XmlDoc": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.", "BaseDimensions": { diff --git a/Common/UnitDefinitions/PowerDensity.json b/Common/UnitDefinitions/PowerDensity.json index 5fa791ba0d..6315002766 100644 --- a/Common/UnitDefinitions/PowerDensity.json +++ b/Common/UnitDefinitions/PowerDensity.json @@ -1,6 +1,6 @@ { "Name": "PowerDensity", - "BaseUnit": "WattPerCubicMeter", + "ConversionBaseUnit": "WattPerCubicMeter", "XmlDoc": "The amount of power in a volume.", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/PowerRatio.json b/Common/UnitDefinitions/PowerRatio.json index 1c143a1dfd..f57d0e23b8 100644 --- a/Common/UnitDefinitions/PowerRatio.json +++ b/Common/UnitDefinitions/PowerRatio.json @@ -1,6 +1,6 @@ { "Name": "PowerRatio", - "BaseUnit": "DecibelWatt", + "ConversionBaseUnit": "DecibelWatt", "Logarithmic": "True", "LogarithmicScalingFactor": "1", "XmlDoc": "The strength of a signal expressed in decibels (dB) relative to one watt.", diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json index 8d548cee5f..53b973b356 100644 --- a/Common/UnitDefinitions/Pressure.json +++ b/Common/UnitDefinitions/Pressure.json @@ -1,6 +1,6 @@ { "Name": "Pressure", - "BaseUnit": "Pascal", + "ConversionBaseUnit": "Pascal", "XmlDoc": "Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa).", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/PressureChangeRate.json b/Common/UnitDefinitions/PressureChangeRate.json index 8f301bdea0..3f183fb0ec 100644 --- a/Common/UnitDefinitions/PressureChangeRate.json +++ b/Common/UnitDefinitions/PressureChangeRate.json @@ -1,6 +1,6 @@ { "Name": "PressureChangeRate", - "BaseUnit": "PascalPerSecond", + "ConversionBaseUnit": "PascalPerSecond", "XmlDoc": "Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time).", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/Ratio.json b/Common/UnitDefinitions/Ratio.json index 3254d3e8f8..83cf9b4e8f 100644 --- a/Common/UnitDefinitions/Ratio.json +++ b/Common/UnitDefinitions/Ratio.json @@ -1,6 +1,6 @@ { "Name": "Ratio", - "BaseUnit": "DecimalFraction", + "ConversionBaseUnit": "DecimalFraction", "XmlDoc": "In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as \"a to b\" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).", "Units": [ { diff --git a/Common/UnitDefinitions/RatioChangeRate.json b/Common/UnitDefinitions/RatioChangeRate.json index 20f246c6f2..77b6a49760 100644 --- a/Common/UnitDefinitions/RatioChangeRate.json +++ b/Common/UnitDefinitions/RatioChangeRate.json @@ -1,6 +1,6 @@ { "Name": "RatioChangeRate", - "BaseUnit": "DecimalFractionPerSecond", + "ConversionBaseUnit": "DecimalFractionPerSecond", "XmlDoc": "The change in ratio per unit of time.", "BaseDimensions": { "T": -1 }, "Units": [ diff --git a/Common/UnitDefinitions/ReactiveEnergy.json b/Common/UnitDefinitions/ReactiveEnergy.json index bb07b95432..4a510e6425 100644 --- a/Common/UnitDefinitions/ReactiveEnergy.json +++ b/Common/UnitDefinitions/ReactiveEnergy.json @@ -1,6 +1,6 @@ { "Name": "ReactiveEnergy", - "BaseUnit": "VoltampereReactiveHour", + "ConversionBaseUnit": "VoltampereReactiveHour", "XmlDoc": "The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ReactivePower.json b/Common/UnitDefinitions/ReactivePower.json index 16ed7d341d..762a287ca3 100644 --- a/Common/UnitDefinitions/ReactivePower.json +++ b/Common/UnitDefinitions/ReactivePower.json @@ -1,6 +1,6 @@ { "Name": "ReactivePower", - "BaseUnit": "VoltampereReactive", + "ConversionBaseUnit": "VoltampereReactive", "XmlDoc": "Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ReciprocalArea.json b/Common/UnitDefinitions/ReciprocalArea.json index 99be49adfe..5eb4d597d1 100644 --- a/Common/UnitDefinitions/ReciprocalArea.json +++ b/Common/UnitDefinitions/ReciprocalArea.json @@ -1,6 +1,6 @@ { "Name": "ReciprocalArea", - "BaseUnit": "InverseSquareMeter", + "ConversionBaseUnit": "InverseSquareMeter", "XmlDoc": "Reciprocal area (Inverse-square) quantity is used to specify a physical quantity inversely proportional to the square of the distance.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inverse-square_law", "BaseDimensions": { @@ -141,4 +141,3 @@ } ] } - \ No newline at end of file diff --git a/Common/UnitDefinitions/ReciprocalLength.json b/Common/UnitDefinitions/ReciprocalLength.json index 175cbfd729..605ce11a38 100644 --- a/Common/UnitDefinitions/ReciprocalLength.json +++ b/Common/UnitDefinitions/ReciprocalLength.json @@ -1,6 +1,6 @@ { "Name": "ReciprocalLength", - "BaseUnit": "InverseMeter", + "ConversionBaseUnit": "InverseMeter", "XmlDoc": "Reciprocal (Inverse) Length is used in various fields of science and mathematics. It is defined as the inverse value of a length unit.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Reciprocal_length", "BaseDimensions": { diff --git a/Common/UnitDefinitions/RelativeHumidity.json b/Common/UnitDefinitions/RelativeHumidity.json index 8b977ba00a..a94db549a3 100644 --- a/Common/UnitDefinitions/RelativeHumidity.json +++ b/Common/UnitDefinitions/RelativeHumidity.json @@ -1,6 +1,6 @@ { "Name": "RelativeHumidity", - "BaseUnit": "Percent", + "ConversionBaseUnit": "Percent", "XmlDoc": "Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature.", "Units": [ { diff --git a/Common/UnitDefinitions/RotationalAcceleration.json b/Common/UnitDefinitions/RotationalAcceleration.json index a73705d3e4..47f694531a 100644 --- a/Common/UnitDefinitions/RotationalAcceleration.json +++ b/Common/UnitDefinitions/RotationalAcceleration.json @@ -1,6 +1,6 @@ { "Name": "RotationalAcceleration", - "BaseUnit": "RadianPerSecondSquared", + "ConversionBaseUnit": "RadianPerSecondSquared", "XmlDoc": "Angular acceleration is the rate of change of rotational speed.", "BaseDimensions": { "T": -2 diff --git a/Common/UnitDefinitions/RotationalSpeed.json b/Common/UnitDefinitions/RotationalSpeed.json index dfb22c16c4..0ac3e3acf6 100644 --- a/Common/UnitDefinitions/RotationalSpeed.json +++ b/Common/UnitDefinitions/RotationalSpeed.json @@ -1,6 +1,6 @@ { "Name": "RotationalSpeed", - "BaseUnit": "RadianPerSecond", + "ConversionBaseUnit": "RadianPerSecond", "XmlDoc": "Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter \"omega\").", "BaseDimensions": { "T": -1 diff --git a/Common/UnitDefinitions/RotationalStiffness.json b/Common/UnitDefinitions/RotationalStiffness.json index 8f0d7fa6b2..08aa3f079f 100644 --- a/Common/UnitDefinitions/RotationalStiffness.json +++ b/Common/UnitDefinitions/RotationalStiffness.json @@ -1,6 +1,6 @@ { "Name": "RotationalStiffness", - "BaseUnit": "NewtonMeterPerRadian", + "ConversionBaseUnit": "NewtonMeterPerRadian", "XmlDoc": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/RotationalStiffnessPerLength.json b/Common/UnitDefinitions/RotationalStiffnessPerLength.json index f4030876d7..ecf08768a0 100644 --- a/Common/UnitDefinitions/RotationalStiffnessPerLength.json +++ b/Common/UnitDefinitions/RotationalStiffnessPerLength.json @@ -1,6 +1,6 @@ { "Name": "RotationalStiffnessPerLength", - "BaseUnit": "NewtonMeterPerRadianPerMeter", + "ConversionBaseUnit": "NewtonMeterPerRadianPerMeter", "XmlDoc": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/Scalar.json b/Common/UnitDefinitions/Scalar.json index d9a8d6aa90..e18572f610 100644 --- a/Common/UnitDefinitions/Scalar.json +++ b/Common/UnitDefinitions/Scalar.json @@ -1,6 +1,6 @@ { "Name": "Scalar", - "BaseUnit": "Amount", + "ConversionBaseUnit": "Amount", "XmlDoc": "A way of representing a number of items.", "Units": [ { diff --git a/Common/UnitDefinitions/SolidAngle.json b/Common/UnitDefinitions/SolidAngle.json index 6f37c56698..129b827edf 100644 --- a/Common/UnitDefinitions/SolidAngle.json +++ b/Common/UnitDefinitions/SolidAngle.json @@ -1,6 +1,6 @@ { "Name": "SolidAngle", - "BaseUnit": "Steradian", + "ConversionBaseUnit": "Steradian", "XmlDoc": "In geometry, a solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Solid_angle", "Units": [ diff --git a/Common/UnitDefinitions/SpecificEnergy.json b/Common/UnitDefinitions/SpecificEnergy.json index d93d929737..8ee6f4a48e 100644 --- a/Common/UnitDefinitions/SpecificEnergy.json +++ b/Common/UnitDefinitions/SpecificEnergy.json @@ -1,6 +1,6 @@ { "Name": "SpecificEnergy", - "BaseUnit": "JoulePerKilogram", + "ConversionBaseUnit": "JoulePerKilogram", "XmlDoc": "The SpecificEnergy", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Specific_energy", "BaseDimensions": { diff --git a/Common/UnitDefinitions/SpecificEntropy.json b/Common/UnitDefinitions/SpecificEntropy.json index 81e11abffd..ba5daa613b 100644 --- a/Common/UnitDefinitions/SpecificEntropy.json +++ b/Common/UnitDefinitions/SpecificEntropy.json @@ -1,6 +1,6 @@ { "Name": "SpecificEntropy", - "BaseUnit": "JoulePerKilogramKelvin", + "ConversionBaseUnit": "JoulePerKilogramKelvin", "XmlDoc": "Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/SpecificFuelConsumption.json b/Common/UnitDefinitions/SpecificFuelConsumption.json index 3174720cc0..7dcc396a43 100644 --- a/Common/UnitDefinitions/SpecificFuelConsumption.json +++ b/Common/UnitDefinitions/SpecificFuelConsumption.json @@ -1,6 +1,6 @@ { "Name": "SpecificFuelConsumption", - "BaseUnit": "GramPerKiloNewtonSecond", + "ConversionBaseUnit": "GramPerKiloNewtonSecond", "XmlDoc": "SFC is the fuel efficiency of an engine design with respect to thrust output", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption", "Units": [ @@ -12,7 +12,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "lb/(lbfh)" ] + "Abbreviations": [ "lb/(lbf�h)" ] } ] }, @@ -24,7 +24,7 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "kg/(kgfh)" ] + "Abbreviations": [ "kg/(kgf�h)" ] } ] }, @@ -37,8 +37,8 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "g/(kNs)" ], - "AbbreviationsForPrefixes": { "Kilo": [ "kg/(kNs)" ] } + "Abbreviations": [ "g/(kN�s)" ], + "AbbreviationsForPrefixes": { "Kilo": [ "kg/(kN�s)" ] } } ] } diff --git a/Common/UnitDefinitions/SpecificVolume.json b/Common/UnitDefinitions/SpecificVolume.json index fbcc235a92..81963039b8 100644 --- a/Common/UnitDefinitions/SpecificVolume.json +++ b/Common/UnitDefinitions/SpecificVolume.json @@ -1,6 +1,6 @@ { "Name": "SpecificVolume", - "BaseUnit": "CubicMeterPerKilogram", + "ConversionBaseUnit": "CubicMeterPerKilogram", "XmlDoc": "In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well.", "BaseDimensions": { "L": 3, diff --git a/Common/UnitDefinitions/SpecificWeight.json b/Common/UnitDefinitions/SpecificWeight.json index 5ffecf2923..33924cd80b 100644 --- a/Common/UnitDefinitions/SpecificWeight.json +++ b/Common/UnitDefinitions/SpecificWeight.json @@ -1,6 +1,6 @@ { "Name": "SpecificWeight", - "BaseUnit": "NewtonPerCubicMeter", + "ConversionBaseUnit": "NewtonPerCubicMeter", "XmlDoc": "The SpecificWeight, or more precisely, the volumetric weight density, of a substance is its weight per unit volume.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Specificweight", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Speed.json b/Common/UnitDefinitions/Speed.json index c055010980..83c538ce1c 100644 --- a/Common/UnitDefinitions/Speed.json +++ b/Common/UnitDefinitions/Speed.json @@ -1,6 +1,6 @@ { "Name": "Speed", - "BaseUnit": "MeterPerSecond", + "ConversionBaseUnit": "MeterPerSecond", "XmlDoc": "In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/StandardVolumeFlow.json b/Common/UnitDefinitions/StandardVolumeFlow.json index bb214e2a09..963a987c0b 100644 --- a/Common/UnitDefinitions/StandardVolumeFlow.json +++ b/Common/UnitDefinitions/StandardVolumeFlow.json @@ -1,6 +1,6 @@ { "Name": "StandardVolumeFlow", - "BaseUnit": "StandardCubicMeterPerSecond", + "ConversionBaseUnit": "StandardCubicMeterPerSecond", "XmlDoc": "The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index 9b8422f891..1c68b69389 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -1,6 +1,6 @@ { "Name": "Temperature", - "BaseUnit": "Kelvin", + "ConversionBaseUnit": "Kelvin", "XmlDoc": "A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.", "GenerateArithmetic": false, "BaseDimensions": { diff --git a/Common/UnitDefinitions/TemperatureChangeRate.json b/Common/UnitDefinitions/TemperatureChangeRate.json index 0f4b70cde6..843030bdee 100644 --- a/Common/UnitDefinitions/TemperatureChangeRate.json +++ b/Common/UnitDefinitions/TemperatureChangeRate.json @@ -1,6 +1,6 @@ { "Name": "TemperatureChangeRate", - "BaseUnit": "DegreeCelsiusPerSecond", + "ConversionBaseUnit": "DegreeCelsiusPerSecond", "XmlDoc": "Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time).", "BaseDimensions": { "T": -1, diff --git a/Common/UnitDefinitions/TemperatureDelta.json b/Common/UnitDefinitions/TemperatureDelta.json index 764065c0ed..bfc135e944 100644 --- a/Common/UnitDefinitions/TemperatureDelta.json +++ b/Common/UnitDefinitions/TemperatureDelta.json @@ -1,6 +1,6 @@ { "Name": "TemperatureDelta", - "BaseUnit": "Kelvin", + "ConversionBaseUnit": "Kelvin", "XmlDoc": "Difference between two temperatures. The conversions are different than for Temperature.", "BaseDimensions": { "Θ": 1 diff --git a/Common/UnitDefinitions/ThermalConductivity.json b/Common/UnitDefinitions/ThermalConductivity.json index 89a5011fe7..0309c06c0d 100644 --- a/Common/UnitDefinitions/ThermalConductivity.json +++ b/Common/UnitDefinitions/ThermalConductivity.json @@ -1,6 +1,6 @@ { "Name": "ThermalConductivity", - "BaseUnit": "WattPerMeterKelvin", + "ConversionBaseUnit": "WattPerMeterKelvin", "XmlDoc": "Thermal conductivity is the property of a material to conduct heat.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thermal_Conductivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ThermalResistance.json b/Common/UnitDefinitions/ThermalResistance.json index 35d3f85d66..b829eaebc2 100644 --- a/Common/UnitDefinitions/ThermalResistance.json +++ b/Common/UnitDefinitions/ThermalResistance.json @@ -1,6 +1,6 @@ { "Name": "ThermalResistance", - "BaseUnit": "SquareMeterKelvinPerKilowatt", + "ConversionBaseUnit": "SquareMeterKelvinPerKilowatt", "XmlDoc": "Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.", "BaseDimensions": { "M": -1, diff --git a/Common/UnitDefinitions/Torque.json b/Common/UnitDefinitions/Torque.json index 6328f39ce1..6bf3f69f4b 100644 --- a/Common/UnitDefinitions/Torque.json +++ b/Common/UnitDefinitions/Torque.json @@ -1,6 +1,6 @@ { "Name": "Torque", - "BaseUnit": "NewtonMeter", + "ConversionBaseUnit": "NewtonMeter", "XmlDoc": "Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/TorquePerLength.json b/Common/UnitDefinitions/TorquePerLength.json index 19da6fc1cd..cfe3878644 100644 --- a/Common/UnitDefinitions/TorquePerLength.json +++ b/Common/UnitDefinitions/TorquePerLength.json @@ -1,6 +1,6 @@ { "Name": "TorquePerLength", - "BaseUnit": "NewtonMeterPerMeter", + "ConversionBaseUnit": "NewtonMeterPerMeter", "XmlDoc": "The magnitude of torque per unit length.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/Turbidity.json b/Common/UnitDefinitions/Turbidity.json index 6098ac3046..402109b9ee 100644 --- a/Common/UnitDefinitions/Turbidity.json +++ b/Common/UnitDefinitions/Turbidity.json @@ -1,6 +1,6 @@ { "Name": "Turbidity", - "BaseUnit": "NTU", + "ConversionBaseUnit": "NTU", "XmlDoc": "Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are generally invisible to the naked eye, similar to smoke in air. The measurement of turbidity is a key test of water quality.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Turbidity", "Units": [ diff --git a/Common/UnitDefinitions/VitaminA.json b/Common/UnitDefinitions/VitaminA.json index 42e78ce791..203f59c589 100644 --- a/Common/UnitDefinitions/VitaminA.json +++ b/Common/UnitDefinitions/VitaminA.json @@ -1,6 +1,6 @@ { "Name": "VitaminA", - "BaseUnit": "InternationalUnit", + "ConversionBaseUnit": "InternationalUnit", "XmlDoc": "Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.", "Units": [ { diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json index a6082eccde..aad8a93a43 100644 --- a/Common/UnitDefinitions/Volume.json +++ b/Common/UnitDefinitions/Volume.json @@ -1,6 +1,6 @@ { "Name": "Volume", - "BaseUnit": "CubicMeter", + "ConversionBaseUnit": "CubicMeter", "XmlDoc": "Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces.", "BaseDimensions": { "L": 3 diff --git a/Common/UnitDefinitions/VolumeConcentration.json b/Common/UnitDefinitions/VolumeConcentration.json index de56f8491f..fdc47dc7b4 100644 --- a/Common/UnitDefinitions/VolumeConcentration.json +++ b/Common/UnitDefinitions/VolumeConcentration.json @@ -1,6 +1,6 @@ { "Name": "VolumeConcentration", - "BaseUnit": "DecimalFraction", + "ConversionBaseUnit": "DecimalFraction", "XmlDoc": "The volume concentration (not to be confused with volume fraction) is defined as the volume of a constituent divided by the total volume of the mixture.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Concentration#Volume_concentration", "Units": [ diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json index 318c3d73eb..cd7d4dc4fc 100644 --- a/Common/UnitDefinitions/VolumeFlow.json +++ b/Common/UnitDefinitions/VolumeFlow.json @@ -1,6 +1,6 @@ { "Name": "VolumeFlow", - "BaseUnit": "CubicMeterPerSecond", + "ConversionBaseUnit": "CubicMeterPerSecond", "XmlDoc": "In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.", "BaseDimensions": { "L": 3, diff --git a/Common/UnitDefinitions/VolumePerLength.json b/Common/UnitDefinitions/VolumePerLength.json index 02b8e0e18b..f583254c43 100644 --- a/Common/UnitDefinitions/VolumePerLength.json +++ b/Common/UnitDefinitions/VolumePerLength.json @@ -1,6 +1,6 @@ { "Name": "VolumePerLength", - "BaseUnit": "CubicMeterPerMeter", + "ConversionBaseUnit": "CubicMeterPerMeter", "XmlDoc": "Volume, typically of fluid, that a container can hold within a unit of length.", "BaseDimensions": { "L": 2 diff --git a/Common/UnitDefinitions/VolumetricHeatCapacity.json b/Common/UnitDefinitions/VolumetricHeatCapacity.json index efe274e498..0ab9b8db62 100644 --- a/Common/UnitDefinitions/VolumetricHeatCapacity.json +++ b/Common/UnitDefinitions/VolumetricHeatCapacity.json @@ -1,6 +1,6 @@ { "Name": "VolumetricHeatCapacity", - "BaseUnit": "JoulePerCubicMeterKelvin", + "ConversionBaseUnit": "JoulePerCubicMeterKelvin", "XmlDoc": "The volumetric heat capacity is the amount of energy that must be added, in the form of heat, to one unit of volume of the material in order to cause an increase of one unit in its temperature.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Volumetric_heat_capacity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/WarpingMomentOfInertia.json b/Common/UnitDefinitions/WarpingMomentOfInertia.json index db9d247e86..c4dfd0c11b 100644 --- a/Common/UnitDefinitions/WarpingMomentOfInertia.json +++ b/Common/UnitDefinitions/WarpingMomentOfInertia.json @@ -1,6 +1,6 @@ { "Name": "WarpingMomentOfInertia", - "BaseUnit": "MeterToTheSixth", + "ConversionBaseUnit": "MeterToTheSixth", "XmlDoc": "A geometric property of an area that is used to determine the warping stress.", "BaseDimensions": { "L": 6 diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs index dc6440eb7e..5258cc7cac 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs @@ -60,21 +60,21 @@ public Acceleration(double value, AccelerationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AccelerationUnit BaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; + public static AccelerationUnit ConversionBaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; /// /// Represents the largest possible value of Duration /// - public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, BaseUnit); + public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, BaseUnit); + public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Acceleration Zero { get; } = new Acceleration(0, BaseUnit); + public static Acceleration Zero { get; } = new Acceleration(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 9eb6832d19..83cd813294 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -60,21 +60,21 @@ public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AmountOfSubstanceUnit BaseUnit { get; } = AmountOfSubstanceUnit.Mole; + public static AmountOfSubstanceUnit ConversionBaseUnit { get; } = AmountOfSubstanceUnit.Mole; /// /// Represents the largest possible value of Duration /// - public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, BaseUnit); + public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, BaseUnit); + public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, BaseUnit); + public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 50998b84fd..8af7867eca 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -60,21 +60,21 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AmplitudeRatioUnit BaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; + public static AmplitudeRatioUnit ConversionBaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; /// /// Represents the largest possible value of Duration /// - public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, BaseUnit); + public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, BaseUnit); + public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, BaseUnit); + public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs index 75262d8ee1..978ae8d319 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs @@ -60,21 +60,21 @@ public Angle(double value, AngleUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AngleUnit BaseUnit { get; } = AngleUnit.Degree; + public static AngleUnit ConversionBaseUnit { get; } = AngleUnit.Degree; /// /// Represents the largest possible value of Duration /// - public static Angle MaxValue { get; } = new Angle(double.MaxValue, BaseUnit); + public static Angle MaxValue { get; } = new Angle(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Angle MinValue { get; } = new Angle(double.MinValue, BaseUnit); + public static Angle MinValue { get; } = new Angle(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Angle Zero { get; } = new Angle(0, BaseUnit); + public static Angle Zero { get; } = new Angle(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs index 612c22331c..28a26812a7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -60,21 +60,21 @@ public ApparentEnergy(double value, ApparentEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ApparentEnergyUnit BaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; + public static ApparentEnergyUnit ConversionBaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; /// /// Represents the largest possible value of Duration /// - public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, BaseUnit); + public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, BaseUnit); + public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, BaseUnit); + public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs index a29629b7f0..fe871f440f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs @@ -60,21 +60,21 @@ public ApparentPower(double value, ApparentPowerUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ApparentPowerUnit BaseUnit { get; } = ApparentPowerUnit.Voltampere; + public static ApparentPowerUnit ConversionBaseUnit { get; } = ApparentPowerUnit.Voltampere; /// /// Represents the largest possible value of Duration /// - public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, BaseUnit); + public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, BaseUnit); + public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ApparentPower Zero { get; } = new ApparentPower(0, BaseUnit); + public static ApparentPower Zero { get; } = new ApparentPower(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs index 1433a2aa93..eda05cb22f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs @@ -60,21 +60,21 @@ public Area(double value, AreaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AreaUnit BaseUnit { get; } = AreaUnit.SquareMeter; + public static AreaUnit ConversionBaseUnit { get; } = AreaUnit.SquareMeter; /// /// Represents the largest possible value of Duration /// - public static Area MaxValue { get; } = new Area(double.MaxValue, BaseUnit); + public static Area MaxValue { get; } = new Area(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Area MinValue { get; } = new Area(double.MinValue, BaseUnit); + public static Area MinValue { get; } = new Area(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Area Zero { get; } = new Area(0, BaseUnit); + public static Area Zero { get; } = new Area(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index e3e80a9084..247ebc0457 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -60,21 +60,21 @@ public AreaDensity(double value, AreaDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AreaDensityUnit BaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; + public static AreaDensityUnit ConversionBaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, BaseUnit); + public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, BaseUnit); + public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AreaDensity Zero { get; } = new AreaDensity(0, BaseUnit); + public static AreaDensity Zero { get; } = new AreaDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index c273455fd4..d6602c07bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -60,21 +60,21 @@ public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AreaMomentOfInertiaUnit BaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; + public static AreaMomentOfInertiaUnit ConversionBaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; /// /// Represents the largest possible value of Duration /// - public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, BaseUnit); + public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, BaseUnit); + public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, BaseUnit); + public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs index ff2fc354d4..6f063bb6e3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs @@ -63,21 +63,21 @@ public BitRate(double value, BitRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static BitRateUnit BaseUnit { get; } = BitRateUnit.BitPerSecond; + public static BitRateUnit ConversionBaseUnit { get; } = BitRateUnit.BitPerSecond; /// /// Represents the largest possible value of Duration /// - public static BitRate MaxValue { get; } = new BitRate(79228162514264337593543950335d, BaseUnit); + public static BitRate MaxValue { get; } = new BitRate(79228162514264337593543950335d, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static BitRate MinValue { get; } = new BitRate(-79228162514264337593543950335d, BaseUnit); + public static BitRate MinValue { get; } = new BitRate(-79228162514264337593543950335d, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static BitRate Zero { get; } = new BitRate(0, BaseUnit); + public static BitRate Zero { get; } = new BitRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 60ba7a14f4..d418a889a1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -60,21 +60,21 @@ public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUn /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static BrakeSpecificFuelConsumptionUnit BaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; + public static BrakeSpecificFuelConsumptionUnit ConversionBaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; /// /// Represents the largest possible value of Duration /// - public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit); + public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit); + public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, BaseUnit); + public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs index 8403d8e2bc..5732eaddfe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs @@ -63,21 +63,21 @@ public Capacitance(double value, CapacitanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static CapacitanceUnit BaseUnit { get; } = CapacitanceUnit.Farad; + public static CapacitanceUnit ConversionBaseUnit { get; } = CapacitanceUnit.Farad; /// /// Represents the largest possible value of Duration /// - public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, BaseUnit); + public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, BaseUnit); + public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Capacitance Zero { get; } = new Capacitance(0, BaseUnit); + public static Capacitance Zero { get; } = new Capacitance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 629809f3b9..654fdacd28 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -60,21 +60,21 @@ public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansion /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static CoefficientOfThermalExpansionUnit BaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; + public static CoefficientOfThermalExpansionUnit ConversionBaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; /// /// Represents the largest possible value of Duration /// - public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit); + public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, BaseUnit); + public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, BaseUnit); + public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs index dc0c0f0c58..07e218b296 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs @@ -63,21 +63,21 @@ public Density(double value, DensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DensityUnit BaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; + public static DensityUnit ConversionBaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static Density MaxValue { get; } = new Density(double.MaxValue, BaseUnit); + public static Density MaxValue { get; } = new Density(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Density MinValue { get; } = new Density(double.MinValue, BaseUnit); + public static Density MinValue { get; } = new Density(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Density Zero { get; } = new Density(0, BaseUnit); + public static Density Zero { get; } = new Density(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs index f00d76c833..4604bb810a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs @@ -60,21 +60,21 @@ public Duration(double value, DurationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DurationUnit BaseUnit { get; } = DurationUnit.Second; + public static DurationUnit ConversionBaseUnit { get; } = DurationUnit.Second; /// /// Represents the largest possible value of Duration /// - public static Duration MaxValue { get; } = new Duration(double.MaxValue, BaseUnit); + public static Duration MaxValue { get; } = new Duration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Duration MinValue { get; } = new Duration(double.MinValue, BaseUnit); + public static Duration MinValue { get; } = new Duration(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Duration Zero { get; } = new Duration(0, BaseUnit); + public static Duration Zero { get; } = new Duration(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs index a4576107fe..a5dc5f995a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -63,21 +63,21 @@ public DynamicViscosity(double value, DynamicViscosityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DynamicViscosityUnit BaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; + public static DynamicViscosityUnit ConversionBaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; /// /// Represents the largest possible value of Duration /// - public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, BaseUnit); + public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, BaseUnit); + public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, BaseUnit); + public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 8756c91def..2544164f04 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -60,21 +60,21 @@ public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricAdmittanceUnit BaseUnit { get; } = ElectricAdmittanceUnit.Siemens; + public static ElectricAdmittanceUnit ConversionBaseUnit { get; } = ElectricAdmittanceUnit.Siemens; /// /// Represents the largest possible value of Duration /// - public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, BaseUnit); + public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, BaseUnit); + public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, BaseUnit); + public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs index 6358fe31dc..0bf3feb8cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -63,21 +63,21 @@ public ElectricCharge(double value, ElectricChargeUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricChargeUnit BaseUnit { get; } = ElectricChargeUnit.Coulomb; + public static ElectricChargeUnit ConversionBaseUnit { get; } = ElectricChargeUnit.Coulomb; /// /// Represents the largest possible value of Duration /// - public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, BaseUnit); + public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, BaseUnit); + public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCharge Zero { get; } = new ElectricCharge(0, BaseUnit); + public static ElectricCharge Zero { get; } = new ElectricCharge(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 7e5e070a36..b0b634509c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -63,21 +63,21 @@ public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricChargeDensityUnit BaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; + public static ElectricChargeDensityUnit ConversionBaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, BaseUnit); + public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, BaseUnit); + public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, BaseUnit); + public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs index e71d7a8db0..13d7df6934 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -63,21 +63,21 @@ public ElectricConductance(double value, ElectricConductanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricConductanceUnit BaseUnit { get; } = ElectricConductanceUnit.Siemens; + public static ElectricConductanceUnit ConversionBaseUnit { get; } = ElectricConductanceUnit.Siemens; /// /// Represents the largest possible value of Duration /// - public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, BaseUnit); + public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, BaseUnit); + public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricConductance Zero { get; } = new ElectricConductance(0, BaseUnit); + public static ElectricConductance Zero { get; } = new ElectricConductance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs index 857ae824f7..246e2e726b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -63,21 +63,21 @@ public ElectricConductivity(double value, ElectricConductivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricConductivityUnit BaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; + public static ElectricConductivityUnit ConversionBaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, BaseUnit); + public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, BaseUnit); + public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, BaseUnit); + public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs index 5e2aded212..5d0ea253cc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -60,21 +60,21 @@ public ElectricCurrent(double value, ElectricCurrentUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricCurrentUnit BaseUnit { get; } = ElectricCurrentUnit.Ampere; + public static ElectricCurrentUnit ConversionBaseUnit { get; } = ElectricCurrentUnit.Ampere; /// /// Represents the largest possible value of Duration /// - public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, BaseUnit); + public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, BaseUnit); + public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, BaseUnit); + public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index fb70b7a8c5..5181531e61 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -63,21 +63,21 @@ public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricCurrentDensityUnit BaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; + public static ElectricCurrentDensityUnit ConversionBaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, BaseUnit); + public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, BaseUnit); + public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, BaseUnit); + public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 476e0de0aa..b8d3a6ceb6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -60,21 +60,21 @@ public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricCurrentGradientUnit BaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; + public static ElectricCurrentGradientUnit ConversionBaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; /// /// Represents the largest possible value of Duration /// - public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, BaseUnit); + public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, BaseUnit); + public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, BaseUnit); + public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs index 542856d0d9..a5b395d4e6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs @@ -63,21 +63,21 @@ public ElectricField(double value, ElectricFieldUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricFieldUnit BaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; + public static ElectricFieldUnit ConversionBaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, BaseUnit); + public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, BaseUnit); + public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricField Zero { get; } = new ElectricField(0, BaseUnit); + public static ElectricField Zero { get; } = new ElectricField(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs index c2c6b8a0f5..207fc21a5c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -63,21 +63,21 @@ public ElectricInductance(double value, ElectricInductanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricInductanceUnit BaseUnit { get; } = ElectricInductanceUnit.Henry; + public static ElectricInductanceUnit ConversionBaseUnit { get; } = ElectricInductanceUnit.Henry; /// /// Represents the largest possible value of Duration /// - public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, BaseUnit); + public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, BaseUnit); + public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricInductance Zero { get; } = new ElectricInductance(0, BaseUnit); + public static ElectricInductance Zero { get; } = new ElectricInductance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs index d3a1896e86..02d544278d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -60,21 +60,21 @@ public ElectricPotential(double value, ElectricPotentialUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialUnit BaseUnit { get; } = ElectricPotentialUnit.Volt; + public static ElectricPotentialUnit ConversionBaseUnit { get; } = ElectricPotentialUnit.Volt; /// /// Represents the largest possible value of Duration /// - public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, BaseUnit); + public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, BaseUnit); + public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotential Zero { get; } = new ElectricPotential(0, BaseUnit); + public static ElectricPotential Zero { get; } = new ElectricPotential(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index a3bc3f2ad4..f71d975542 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -60,21 +60,21 @@ public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialAcUnit BaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; + public static ElectricPotentialAcUnit ConversionBaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; /// /// Represents the largest possible value of Duration /// - public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, BaseUnit); + public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, BaseUnit); + public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, BaseUnit); + public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 3da8868632..650aead496 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -60,21 +60,21 @@ public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialChangeRateUnit BaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; + public static ElectricPotentialChangeRateUnit ConversionBaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; /// /// Represents the largest possible value of Duration /// - public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, BaseUnit); + public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, BaseUnit); + public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, BaseUnit); + public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 72da488327..f7d74ae8e7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -60,21 +60,21 @@ public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialDcUnit BaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; + public static ElectricPotentialDcUnit ConversionBaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; /// /// Represents the largest possible value of Duration /// - public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, BaseUnit); + public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, BaseUnit); + public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, BaseUnit); + public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs index c45b3ccbe5..5224b4054c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -60,21 +60,21 @@ public ElectricResistance(double value, ElectricResistanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricResistanceUnit BaseUnit { get; } = ElectricResistanceUnit.Ohm; + public static ElectricResistanceUnit ConversionBaseUnit { get; } = ElectricResistanceUnit.Ohm; /// /// Represents the largest possible value of Duration /// - public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, BaseUnit); + public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, BaseUnit); + public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricResistance Zero { get; } = new ElectricResistance(0, BaseUnit); + public static ElectricResistance Zero { get; } = new ElectricResistance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs index 7963136182..229da70e2a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -63,21 +63,21 @@ public ElectricResistivity(double value, ElectricResistivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricResistivityUnit BaseUnit { get; } = ElectricResistivityUnit.OhmMeter; + public static ElectricResistivityUnit ConversionBaseUnit { get; } = ElectricResistivityUnit.OhmMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, BaseUnit); + public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, BaseUnit); + public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, BaseUnit); + public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 1feb4fc190..2a7d94e2a8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -63,21 +63,21 @@ public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUn /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricSurfaceChargeDensityUnit BaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; + public static ElectricSurfaceChargeDensityUnit ConversionBaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, BaseUnit); + public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, BaseUnit); + public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, BaseUnit); + public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs index 5cbe03d497..00c3f31d1d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs @@ -60,21 +60,21 @@ public Energy(double value, EnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static EnergyUnit BaseUnit { get; } = EnergyUnit.Joule; + public static EnergyUnit ConversionBaseUnit { get; } = EnergyUnit.Joule; /// /// Represents the largest possible value of Duration /// - public static Energy MaxValue { get; } = new Energy(double.MaxValue, BaseUnit); + public static Energy MaxValue { get; } = new Energy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Energy MinValue { get; } = new Energy(double.MinValue, BaseUnit); + public static Energy MinValue { get; } = new Energy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Energy Zero { get; } = new Energy(0, BaseUnit); + public static Energy Zero { get; } = new Energy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs index 27418a3c7e..b6b955b01e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs @@ -60,21 +60,21 @@ public Entropy(double value, EntropyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static EntropyUnit BaseUnit { get; } = EntropyUnit.JoulePerKelvin; + public static EntropyUnit ConversionBaseUnit { get; } = EntropyUnit.JoulePerKelvin; /// /// Represents the largest possible value of Duration /// - public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, BaseUnit); + public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Entropy MinValue { get; } = new Entropy(double.MinValue, BaseUnit); + public static Entropy MinValue { get; } = new Entropy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Entropy Zero { get; } = new Entropy(0, BaseUnit); + public static Entropy Zero { get; } = new Entropy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs index 04ecaf4d37..86edd91cc4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs @@ -60,21 +60,21 @@ public Force(double value, ForceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ForceUnit BaseUnit { get; } = ForceUnit.Newton; + public static ForceUnit ConversionBaseUnit { get; } = ForceUnit.Newton; /// /// Represents the largest possible value of Duration /// - public static Force MaxValue { get; } = new Force(double.MaxValue, BaseUnit); + public static Force MaxValue { get; } = new Force(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Force MinValue { get; } = new Force(double.MinValue, BaseUnit); + public static Force MinValue { get; } = new Force(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Force Zero { get; } = new Force(0, BaseUnit); + public static Force Zero { get; } = new Force(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs index d4bc1f5f6c..ad7924eda3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -60,21 +60,21 @@ public ForceChangeRate(double value, ForceChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ForceChangeRateUnit BaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; + public static ForceChangeRateUnit ConversionBaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; /// /// Represents the largest possible value of Duration /// - public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, BaseUnit); + public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, BaseUnit); + public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, BaseUnit); + public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs index 4e901f4b4b..b5b82363e3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -60,21 +60,21 @@ public ForcePerLength(double value, ForcePerLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ForcePerLengthUnit BaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; + public static ForcePerLengthUnit ConversionBaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; /// /// Represents the largest possible value of Duration /// - public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, BaseUnit); + public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, BaseUnit); + public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ForcePerLength Zero { get; } = new ForcePerLength(0, BaseUnit); + public static ForcePerLength Zero { get; } = new ForcePerLength(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs index 8e93966048..ce059beb35 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs @@ -60,21 +60,21 @@ public Frequency(double value, FrequencyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static FrequencyUnit BaseUnit { get; } = FrequencyUnit.Hertz; + public static FrequencyUnit ConversionBaseUnit { get; } = FrequencyUnit.Hertz; /// /// Represents the largest possible value of Duration /// - public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, BaseUnit); + public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Frequency MinValue { get; } = new Frequency(double.MinValue, BaseUnit); + public static Frequency MinValue { get; } = new Frequency(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Frequency Zero { get; } = new Frequency(0, BaseUnit); + public static Frequency Zero { get; } = new Frequency(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs index 2807584287..c7c6bc1715 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -63,21 +63,21 @@ public FuelEfficiency(double value, FuelEfficiencyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static FuelEfficiencyUnit BaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; + public static FuelEfficiencyUnit ConversionBaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; /// /// Represents the largest possible value of Duration /// - public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, BaseUnit); + public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, BaseUnit); + public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, BaseUnit); + public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs index 3d8641875b..3da199a07f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs @@ -60,21 +60,21 @@ public HeatFlux(double value, HeatFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static HeatFluxUnit BaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; + public static HeatFluxUnit ConversionBaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, BaseUnit); + public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, BaseUnit); + public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static HeatFlux Zero { get; } = new HeatFlux(0, BaseUnit); + public static HeatFlux Zero { get; } = new HeatFlux(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index df7ce8d19d..6bbb9a2b18 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -60,21 +60,21 @@ public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static HeatTransferCoefficientUnit BaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; + public static HeatTransferCoefficientUnit ConversionBaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; /// /// Represents the largest possible value of Duration /// - public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, BaseUnit); + public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, BaseUnit); + public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, BaseUnit); + public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs index dec0eefe31..6db51d810c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs @@ -63,21 +63,21 @@ public Illuminance(double value, IlluminanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static IlluminanceUnit BaseUnit { get; } = IlluminanceUnit.Lux; + public static IlluminanceUnit ConversionBaseUnit { get; } = IlluminanceUnit.Lux; /// /// Represents the largest possible value of Duration /// - public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, BaseUnit); + public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, BaseUnit); + public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Illuminance Zero { get; } = new Illuminance(0, BaseUnit); + public static Illuminance Zero { get; } = new Illuminance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs index f7c1bae25a..46ea07d2d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs @@ -60,21 +60,21 @@ public Information(double value, InformationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static InformationUnit BaseUnit { get; } = InformationUnit.Bit; + public static InformationUnit ConversionBaseUnit { get; } = InformationUnit.Bit; /// /// Represents the largest possible value of Duration /// - public static Information MaxValue { get; } = new Information(79228162514264337593543950335d, BaseUnit); + public static Information MaxValue { get; } = new Information(79228162514264337593543950335d, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Information MinValue { get; } = new Information(-79228162514264337593543950335d, BaseUnit); + public static Information MinValue { get; } = new Information(-79228162514264337593543950335d, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Information Zero { get; } = new Information(0, BaseUnit); + public static Information Zero { get; } = new Information(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs index 485557b649..757f34305b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs @@ -60,21 +60,21 @@ public Irradiance(double value, IrradianceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static IrradianceUnit BaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; + public static IrradianceUnit ConversionBaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, BaseUnit); + public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, BaseUnit); + public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Irradiance Zero { get; } = new Irradiance(0, BaseUnit); + public static Irradiance Zero { get; } = new Irradiance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs index 6592c201d4..341dd0b84e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs @@ -63,21 +63,21 @@ public Irradiation(double value, IrradiationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static IrradiationUnit BaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; + public static IrradiationUnit ConversionBaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, BaseUnit); + public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, BaseUnit); + public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Irradiation Zero { get; } = new Irradiation(0, BaseUnit); + public static Irradiation Zero { get; } = new Irradiation(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs index 6e71268e2a..3e0cc9fbde 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -63,21 +63,21 @@ public KinematicViscosity(double value, KinematicViscosityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static KinematicViscosityUnit BaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; + public static KinematicViscosityUnit ConversionBaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, BaseUnit); + public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, BaseUnit); + public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, BaseUnit); + public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs index a6f7ef5674..84399497a8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs @@ -60,21 +60,21 @@ public LapseRate(double value, LapseRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LapseRateUnit BaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; + public static LapseRateUnit ConversionBaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; /// /// Represents the largest possible value of Duration /// - public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, BaseUnit); + public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, BaseUnit); + public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LapseRate Zero { get; } = new LapseRate(0, BaseUnit); + public static LapseRate Zero { get; } = new LapseRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs index 6f88bf443d..1cfbb88659 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs @@ -60,21 +60,21 @@ public Length(double value, LengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LengthUnit BaseUnit { get; } = LengthUnit.Meter; + public static LengthUnit ConversionBaseUnit { get; } = LengthUnit.Meter; /// /// Represents the largest possible value of Duration /// - public static Length MaxValue { get; } = new Length(double.MaxValue, BaseUnit); + public static Length MaxValue { get; } = new Length(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Length MinValue { get; } = new Length(double.MinValue, BaseUnit); + public static Length MinValue { get; } = new Length(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Length Zero { get; } = new Length(0, BaseUnit); + public static Length Zero { get; } = new Length(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs index 8f6433b13f..57104afcda 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs @@ -60,21 +60,21 @@ public Level(double value, LevelUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LevelUnit BaseUnit { get; } = LevelUnit.Decibel; + public static LevelUnit ConversionBaseUnit { get; } = LevelUnit.Decibel; /// /// Represents the largest possible value of Duration /// - public static Level MaxValue { get; } = new Level(double.MaxValue, BaseUnit); + public static Level MaxValue { get; } = new Level(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Level MinValue { get; } = new Level(double.MinValue, BaseUnit); + public static Level MinValue { get; } = new Level(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Level Zero { get; } = new Level(0, BaseUnit); + public static Level Zero { get; } = new Level(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs index 3b7ffa5188..3945cc7439 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs @@ -63,21 +63,21 @@ public LinearDensity(double value, LinearDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LinearDensityUnit BaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; + public static LinearDensityUnit ConversionBaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; /// /// Represents the largest possible value of Duration /// - public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, BaseUnit); + public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, BaseUnit); + public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LinearDensity Zero { get; } = new LinearDensity(0, BaseUnit); + public static LinearDensity Zero { get; } = new LinearDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs index f29ab637aa..ef29a48c73 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -63,21 +63,21 @@ public LinearPowerDensity(double value, LinearPowerDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LinearPowerDensityUnit BaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; + public static LinearPowerDensityUnit ConversionBaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; /// /// Represents the largest possible value of Duration /// - public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, BaseUnit); + public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, BaseUnit); + public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, BaseUnit); + public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs index e400ef52e8..28f2d9f6ae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs @@ -63,21 +63,21 @@ public Luminosity(double value, LuminosityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LuminosityUnit BaseUnit { get; } = LuminosityUnit.Watt; + public static LuminosityUnit ConversionBaseUnit { get; } = LuminosityUnit.Watt; /// /// Represents the largest possible value of Duration /// - public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, BaseUnit); + public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, BaseUnit); + public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Luminosity Zero { get; } = new Luminosity(0, BaseUnit); + public static Luminosity Zero { get; } = new Luminosity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs index c7b1231437..934af77713 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -63,21 +63,21 @@ public LuminousFlux(double value, LuminousFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LuminousFluxUnit BaseUnit { get; } = LuminousFluxUnit.Lumen; + public static LuminousFluxUnit ConversionBaseUnit { get; } = LuminousFluxUnit.Lumen; /// /// Represents the largest possible value of Duration /// - public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, BaseUnit); + public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, BaseUnit); + public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LuminousFlux Zero { get; } = new LuminousFlux(0, BaseUnit); + public static LuminousFlux Zero { get; } = new LuminousFlux(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs index a058ebe49c..27f6ef0e59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -63,21 +63,21 @@ public LuminousIntensity(double value, LuminousIntensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LuminousIntensityUnit BaseUnit { get; } = LuminousIntensityUnit.Candela; + public static LuminousIntensityUnit ConversionBaseUnit { get; } = LuminousIntensityUnit.Candela; /// /// Represents the largest possible value of Duration /// - public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, BaseUnit); + public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, BaseUnit); + public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, BaseUnit); + public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs index 8d512557d6..b7bf7e0bb1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs @@ -63,21 +63,21 @@ public MagneticField(double value, MagneticFieldUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MagneticFieldUnit BaseUnit { get; } = MagneticFieldUnit.Tesla; + public static MagneticFieldUnit ConversionBaseUnit { get; } = MagneticFieldUnit.Tesla; /// /// Represents the largest possible value of Duration /// - public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, BaseUnit); + public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, BaseUnit); + public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MagneticField Zero { get; } = new MagneticField(0, BaseUnit); + public static MagneticField Zero { get; } = new MagneticField(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs index eb6957ae9e..5fcd893e9a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -63,21 +63,21 @@ public MagneticFlux(double value, MagneticFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MagneticFluxUnit BaseUnit { get; } = MagneticFluxUnit.Weber; + public static MagneticFluxUnit ConversionBaseUnit { get; } = MagneticFluxUnit.Weber; /// /// Represents the largest possible value of Duration /// - public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, BaseUnit); + public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, BaseUnit); + public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MagneticFlux Zero { get; } = new MagneticFlux(0, BaseUnit); + public static MagneticFlux Zero { get; } = new MagneticFlux(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs index d1b731691f..c90b582696 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs @@ -63,21 +63,21 @@ public Magnetization(double value, MagnetizationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MagnetizationUnit BaseUnit { get; } = MagnetizationUnit.AmperePerMeter; + public static MagnetizationUnit ConversionBaseUnit { get; } = MagnetizationUnit.AmperePerMeter; /// /// Represents the largest possible value of Duration /// - public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, BaseUnit); + public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, BaseUnit); + public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Magnetization Zero { get; } = new Magnetization(0, BaseUnit); + public static Magnetization Zero { get; } = new Magnetization(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs index 1df3d359d1..68a6614ed6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs @@ -60,21 +60,21 @@ public Mass(double value, MassUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassUnit BaseUnit { get; } = MassUnit.Kilogram; + public static MassUnit ConversionBaseUnit { get; } = MassUnit.Kilogram; /// /// Represents the largest possible value of Duration /// - public static Mass MaxValue { get; } = new Mass(double.MaxValue, BaseUnit); + public static Mass MaxValue { get; } = new Mass(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Mass MinValue { get; } = new Mass(double.MinValue, BaseUnit); + public static Mass MinValue { get; } = new Mass(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Mass Zero { get; } = new Mass(0, BaseUnit); + public static Mass Zero { get; } = new Mass(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs index 54416eb19b..628c783198 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs @@ -63,21 +63,21 @@ public MassConcentration(double value, MassConcentrationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassConcentrationUnit BaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; + public static MassConcentrationUnit ConversionBaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, BaseUnit); + public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, BaseUnit); + public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassConcentration Zero { get; } = new MassConcentration(0, BaseUnit); + public static MassConcentration Zero { get; } = new MassConcentration(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs index 4ef935431b..4758354f6d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs @@ -60,21 +60,21 @@ public MassFlow(double value, MassFlowUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassFlowUnit BaseUnit { get; } = MassFlowUnit.GramPerSecond; + public static MassFlowUnit ConversionBaseUnit { get; } = MassFlowUnit.GramPerSecond; /// /// Represents the largest possible value of Duration /// - public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, BaseUnit); + public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, BaseUnit); + public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassFlow Zero { get; } = new MassFlow(0, BaseUnit); + public static MassFlow Zero { get; } = new MassFlow(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs index d0aceaa85f..340360959f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs @@ -60,21 +60,21 @@ public MassFlux(double value, MassFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassFluxUnit BaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; + public static MassFluxUnit ConversionBaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, BaseUnit); + public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, BaseUnit); + public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassFlux Zero { get; } = new MassFlux(0, BaseUnit); + public static MassFlux Zero { get; } = new MassFlux(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs index c78426464c..ee835df31c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs @@ -63,21 +63,21 @@ public MassFraction(double value, MassFractionUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassFractionUnit BaseUnit { get; } = MassFractionUnit.DecimalFraction; + public static MassFractionUnit ConversionBaseUnit { get; } = MassFractionUnit.DecimalFraction; /// /// Represents the largest possible value of Duration /// - public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, BaseUnit); + public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, BaseUnit); + public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassFraction Zero { get; } = new MassFraction(0, BaseUnit); + public static MassFraction Zero { get; } = new MassFraction(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 40c820205a..d847a3c3f8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -60,21 +60,21 @@ public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassMomentOfInertiaUnit BaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; + public static MassMomentOfInertiaUnit ConversionBaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; /// /// Represents the largest possible value of Duration /// - public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, BaseUnit); + public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, BaseUnit); + public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, BaseUnit); + public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs index 17ea343848..ae113abe79 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -60,21 +60,21 @@ public MolarEnergy(double value, MolarEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarEnergyUnit BaseUnit { get; } = MolarEnergyUnit.JoulePerMole; + public static MolarEnergyUnit ConversionBaseUnit { get; } = MolarEnergyUnit.JoulePerMole; /// /// Represents the largest possible value of Duration /// - public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, BaseUnit); + public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, BaseUnit); + public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MolarEnergy Zero { get; } = new MolarEnergy(0, BaseUnit); + public static MolarEnergy Zero { get; } = new MolarEnergy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs index 74f6ecb750..1dd6bcfd14 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -60,21 +60,21 @@ public MolarEntropy(double value, MolarEntropyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarEntropyUnit BaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; + public static MolarEntropyUnit ConversionBaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; /// /// Represents the largest possible value of Duration /// - public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, BaseUnit); + public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, BaseUnit); + public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MolarEntropy Zero { get; } = new MolarEntropy(0, BaseUnit); + public static MolarEntropy Zero { get; } = new MolarEntropy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs index 136977d53a..068273ca73 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs @@ -60,21 +60,21 @@ public MolarMass(double value, MolarMassUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarMassUnit BaseUnit { get; } = MolarMassUnit.KilogramPerMole; + public static MolarMassUnit ConversionBaseUnit { get; } = MolarMassUnit.KilogramPerMole; /// /// Represents the largest possible value of Duration /// - public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, BaseUnit); + public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, BaseUnit); + public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MolarMass Zero { get; } = new MolarMass(0, BaseUnit); + public static MolarMass Zero { get; } = new MolarMass(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs index 2f4f9868ef..a0c6e30669 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs @@ -63,21 +63,21 @@ public Molarity(double value, MolarityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarityUnit BaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; + public static MolarityUnit ConversionBaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, BaseUnit); + public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Molarity MinValue { get; } = new Molarity(double.MinValue, BaseUnit); + public static Molarity MinValue { get; } = new Molarity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Molarity Zero { get; } = new Molarity(0, BaseUnit); + public static Molarity Zero { get; } = new Molarity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs index ce6def0ba1..695c7ed9f7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs @@ -63,21 +63,21 @@ public Permeability(double value, PermeabilityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PermeabilityUnit BaseUnit { get; } = PermeabilityUnit.HenryPerMeter; + public static PermeabilityUnit ConversionBaseUnit { get; } = PermeabilityUnit.HenryPerMeter; /// /// Represents the largest possible value of Duration /// - public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, BaseUnit); + public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Permeability MinValue { get; } = new Permeability(double.MinValue, BaseUnit); + public static Permeability MinValue { get; } = new Permeability(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Permeability Zero { get; } = new Permeability(0, BaseUnit); + public static Permeability Zero { get; } = new Permeability(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs index 2b93b1d8b0..98e014ec97 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs @@ -63,21 +63,21 @@ public Permittivity(double value, PermittivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PermittivityUnit BaseUnit { get; } = PermittivityUnit.FaradPerMeter; + public static PermittivityUnit ConversionBaseUnit { get; } = PermittivityUnit.FaradPerMeter; /// /// Represents the largest possible value of Duration /// - public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, BaseUnit); + public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, BaseUnit); + public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Permittivity Zero { get; } = new Permittivity(0, BaseUnit); + public static Permittivity Zero { get; } = new Permittivity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index c42445613e..880f0aae50 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -60,21 +60,21 @@ public Power(double value, PowerUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PowerUnit BaseUnit { get; } = PowerUnit.Watt; + public static PowerUnit ConversionBaseUnit { get; } = PowerUnit.Watt; /// /// Represents the largest possible value of Duration /// - public static Power MaxValue { get; } = new Power(79228162514264337593543950335d, BaseUnit); + public static Power MaxValue { get; } = new Power(79228162514264337593543950335d, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Power MinValue { get; } = new Power(-79228162514264337593543950335d, BaseUnit); + public static Power MinValue { get; } = new Power(-79228162514264337593543950335d, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Power Zero { get; } = new Power(0, BaseUnit); + public static Power Zero { get; } = new Power(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs index 6a82ffc0cd..24bab2e22c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs @@ -60,21 +60,21 @@ public PowerDensity(double value, PowerDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PowerDensityUnit BaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; + public static PowerDensityUnit ConversionBaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, BaseUnit); + public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, BaseUnit); + public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static PowerDensity Zero { get; } = new PowerDensity(0, BaseUnit); + public static PowerDensity Zero { get; } = new PowerDensity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs index 576ad5bc25..15ea9f7123 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs @@ -60,21 +60,21 @@ public PowerRatio(double value, PowerRatioUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PowerRatioUnit BaseUnit { get; } = PowerRatioUnit.DecibelWatt; + public static PowerRatioUnit ConversionBaseUnit { get; } = PowerRatioUnit.DecibelWatt; /// /// Represents the largest possible value of Duration /// - public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, BaseUnit); + public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, BaseUnit); + public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static PowerRatio Zero { get; } = new PowerRatio(0, BaseUnit); + public static PowerRatio Zero { get; } = new PowerRatio(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs index 77083dcc35..e52c6f4933 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs @@ -60,21 +60,21 @@ public Pressure(double value, PressureUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PressureUnit BaseUnit { get; } = PressureUnit.Pascal; + public static PressureUnit ConversionBaseUnit { get; } = PressureUnit.Pascal; /// /// Represents the largest possible value of Duration /// - public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, BaseUnit); + public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Pressure MinValue { get; } = new Pressure(double.MinValue, BaseUnit); + public static Pressure MinValue { get; } = new Pressure(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Pressure Zero { get; } = new Pressure(0, BaseUnit); + public static Pressure Zero { get; } = new Pressure(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs index 7d396c84d3..9f1a8e11ac 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -60,21 +60,21 @@ public PressureChangeRate(double value, PressureChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PressureChangeRateUnit BaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; + public static PressureChangeRateUnit ConversionBaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; /// /// Represents the largest possible value of Duration /// - public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, BaseUnit); + public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, BaseUnit); + public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, BaseUnit); + public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs index 4f6c208709..1c6de225d4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs @@ -60,21 +60,21 @@ public Ratio(double value, RatioUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RatioUnit BaseUnit { get; } = RatioUnit.DecimalFraction; + public static RatioUnit ConversionBaseUnit { get; } = RatioUnit.DecimalFraction; /// /// Represents the largest possible value of Duration /// - public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, BaseUnit); + public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Ratio MinValue { get; } = new Ratio(double.MinValue, BaseUnit); + public static Ratio MinValue { get; } = new Ratio(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Ratio Zero { get; } = new Ratio(0, BaseUnit); + public static Ratio Zero { get; } = new Ratio(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs index 998acbb4ee..7dd34071d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -60,21 +60,21 @@ public RatioChangeRate(double value, RatioChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RatioChangeRateUnit BaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; + public static RatioChangeRateUnit ConversionBaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; /// /// Represents the largest possible value of Duration /// - public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, BaseUnit); + public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, BaseUnit); + public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, BaseUnit); + public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs index e14b88f04b..c502de324f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -60,21 +60,21 @@ public ReactiveEnergy(double value, ReactiveEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReactiveEnergyUnit BaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; + public static ReactiveEnergyUnit ConversionBaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; /// /// Represents the largest possible value of Duration /// - public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, BaseUnit); + public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, BaseUnit); + public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, BaseUnit); + public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs index 770f5ebaf5..15d0aef13c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs @@ -60,21 +60,21 @@ public ReactivePower(double value, ReactivePowerUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReactivePowerUnit BaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; + public static ReactivePowerUnit ConversionBaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; /// /// Represents the largest possible value of Duration /// - public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, BaseUnit); + public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, BaseUnit); + public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReactivePower Zero { get; } = new ReactivePower(0, BaseUnit); + public static ReactivePower Zero { get; } = new ReactivePower(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs index 0941da4332..6e41a3d9c4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -63,21 +63,21 @@ public ReciprocalArea(double value, ReciprocalAreaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReciprocalAreaUnit BaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; + public static ReciprocalAreaUnit ConversionBaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; /// /// Represents the largest possible value of Duration /// - public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, BaseUnit); + public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, BaseUnit); + public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, BaseUnit); + public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs index 273c2e6e9f..29e70a2204 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -63,21 +63,21 @@ public ReciprocalLength(double value, ReciprocalLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReciprocalLengthUnit BaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; + public static ReciprocalLengthUnit ConversionBaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; /// /// Represents the largest possible value of Duration /// - public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, BaseUnit); + public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, BaseUnit); + public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, BaseUnit); + public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs index d788971841..9e7165e688 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -60,21 +60,21 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RelativeHumidityUnit BaseUnit { get; } = RelativeHumidityUnit.Percent; + public static RelativeHumidityUnit ConversionBaseUnit { get; } = RelativeHumidityUnit.Percent; /// /// Represents the largest possible value of Duration /// - public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, BaseUnit); + public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, BaseUnit); + public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, BaseUnit); + public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 9e51de985b..51c3bb2185 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -60,21 +60,21 @@ public RotationalAcceleration(double value, RotationalAccelerationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalAccelerationUnit BaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; + public static RotationalAccelerationUnit ConversionBaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; /// /// Represents the largest possible value of Duration /// - public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, BaseUnit); + public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, BaseUnit); + public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, BaseUnit); + public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs index 3b73371df6..53bc1f7834 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -60,21 +60,21 @@ public RotationalSpeed(double value, RotationalSpeedUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalSpeedUnit BaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; + public static RotationalSpeedUnit ConversionBaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; /// /// Represents the largest possible value of Duration /// - public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, BaseUnit); + public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, BaseUnit); + public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, BaseUnit); + public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs index a47c25f2a3..5d47807698 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -60,21 +60,21 @@ public RotationalStiffness(double value, RotationalStiffnessUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalStiffnessUnit BaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; + public static RotationalStiffnessUnit ConversionBaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; /// /// Represents the largest possible value of Duration /// - public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, BaseUnit); + public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, BaseUnit); + public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, BaseUnit); + public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 41c43cb7b5..6318f1b093 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -60,21 +60,21 @@ public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUn /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalStiffnessPerLengthUnit BaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; + public static RotationalStiffnessPerLengthUnit ConversionBaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; /// /// Represents the largest possible value of Duration /// - public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, BaseUnit); + public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, BaseUnit); + public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, BaseUnit); + public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs index 3e6c6fd5d5..d5722d9f19 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs @@ -60,21 +60,21 @@ public Scalar(double value, ScalarUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ScalarUnit BaseUnit { get; } = ScalarUnit.Amount; + public static ScalarUnit ConversionBaseUnit { get; } = ScalarUnit.Amount; /// /// Represents the largest possible value of Duration /// - public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, BaseUnit); + public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Scalar MinValue { get; } = new Scalar(double.MinValue, BaseUnit); + public static Scalar MinValue { get; } = new Scalar(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Scalar Zero { get; } = new Scalar(0, BaseUnit); + public static Scalar Zero { get; } = new Scalar(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs index 9c51f02470..6a4669a7ef 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs @@ -63,21 +63,21 @@ public SolidAngle(double value, SolidAngleUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SolidAngleUnit BaseUnit { get; } = SolidAngleUnit.Steradian; + public static SolidAngleUnit ConversionBaseUnit { get; } = SolidAngleUnit.Steradian; /// /// Represents the largest possible value of Duration /// - public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, BaseUnit); + public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, BaseUnit); + public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SolidAngle Zero { get; } = new SolidAngle(0, BaseUnit); + public static SolidAngle Zero { get; } = new SolidAngle(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs index 32fc74dcea..b35189239d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -63,21 +63,21 @@ public SpecificEnergy(double value, SpecificEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificEnergyUnit BaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; + public static SpecificEnergyUnit ConversionBaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; /// /// Represents the largest possible value of Duration /// - public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, BaseUnit); + public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, BaseUnit); + public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, BaseUnit); + public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs index 16bf4d39de..0d28530c70 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -60,21 +60,21 @@ public SpecificEntropy(double value, SpecificEntropyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificEntropyUnit BaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; + public static SpecificEntropyUnit ConversionBaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; /// /// Represents the largest possible value of Duration /// - public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, BaseUnit); + public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, BaseUnit); + public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, BaseUnit); + public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 133149d969..8771c02815 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -63,21 +63,21 @@ public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificFuelConsumptionUnit BaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; + public static SpecificFuelConsumptionUnit ConversionBaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; /// /// Represents the largest possible value of Duration /// - public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, BaseUnit); + public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, BaseUnit); + public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, BaseUnit); + public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs index 3efeaae43d..8a9dc3fa64 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -60,21 +60,21 @@ public SpecificVolume(double value, SpecificVolumeUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificVolumeUnit BaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; + public static SpecificVolumeUnit ConversionBaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; /// /// Represents the largest possible value of Duration /// - public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, BaseUnit); + public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, BaseUnit); + public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificVolume Zero { get; } = new SpecificVolume(0, BaseUnit); + public static SpecificVolume Zero { get; } = new SpecificVolume(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs index b78e420273..0da4b8ca99 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -63,21 +63,21 @@ public SpecificWeight(double value, SpecificWeightUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificWeightUnit BaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; + public static SpecificWeightUnit ConversionBaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, BaseUnit); + public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, BaseUnit); + public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificWeight Zero { get; } = new SpecificWeight(0, BaseUnit); + public static SpecificWeight Zero { get; } = new SpecificWeight(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs index 068d009a6f..b04f38867c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs @@ -60,21 +60,21 @@ public Speed(double value, SpeedUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpeedUnit BaseUnit { get; } = SpeedUnit.MeterPerSecond; + public static SpeedUnit ConversionBaseUnit { get; } = SpeedUnit.MeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static Speed MaxValue { get; } = new Speed(double.MaxValue, BaseUnit); + public static Speed MaxValue { get; } = new Speed(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Speed MinValue { get; } = new Speed(double.MinValue, BaseUnit); + public static Speed MinValue { get; } = new Speed(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Speed Zero { get; } = new Speed(0, BaseUnit); + public static Speed Zero { get; } = new Speed(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index d1382f3b60..a150803797 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -60,21 +60,21 @@ public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static StandardVolumeFlowUnit BaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; + public static StandardVolumeFlowUnit ConversionBaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, BaseUnit); + public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, BaseUnit); + public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, BaseUnit); + public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs index 8f8f51054f..d2f053c21b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs @@ -60,21 +60,21 @@ public Temperature(double value, TemperatureUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TemperatureUnit BaseUnit { get; } = TemperatureUnit.Kelvin; + public static TemperatureUnit ConversionBaseUnit { get; } = TemperatureUnit.Kelvin; /// /// Represents the largest possible value of Duration /// - public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, BaseUnit); + public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Temperature MinValue { get; } = new Temperature(double.MinValue, BaseUnit); + public static Temperature MinValue { get; } = new Temperature(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Temperature Zero { get; } = new Temperature(0, BaseUnit); + public static Temperature Zero { get; } = new Temperature(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 6d53336741..ddf0f6dfe1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -60,21 +60,21 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TemperatureChangeRateUnit BaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; + public static TemperatureChangeRateUnit ConversionBaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; /// /// Represents the largest possible value of Duration /// - public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, BaseUnit); + public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, BaseUnit); + public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, BaseUnit); + public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs index d7afb0cb62..d4028e1a17 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -60,21 +60,21 @@ public TemperatureDelta(double value, TemperatureDeltaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TemperatureDeltaUnit BaseUnit { get; } = TemperatureDeltaUnit.Kelvin; + public static TemperatureDeltaUnit ConversionBaseUnit { get; } = TemperatureDeltaUnit.Kelvin; /// /// Represents the largest possible value of Duration /// - public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, BaseUnit); + public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, BaseUnit); + public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, BaseUnit); + public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs index 15929a67a0..285dbc14f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -63,21 +63,21 @@ public ThermalConductivity(double value, ThermalConductivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ThermalConductivityUnit BaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; + public static ThermalConductivityUnit ConversionBaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; /// /// Represents the largest possible value of Duration /// - public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, BaseUnit); + public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, BaseUnit); + public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, BaseUnit); + public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs index ddd9050de6..af082eb12e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -60,21 +60,21 @@ public ThermalResistance(double value, ThermalResistanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ThermalResistanceUnit BaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; + public static ThermalResistanceUnit ConversionBaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; /// /// Represents the largest possible value of Duration /// - public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, BaseUnit); + public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, BaseUnit); + public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ThermalResistance Zero { get; } = new ThermalResistance(0, BaseUnit); + public static ThermalResistance Zero { get; } = new ThermalResistance(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs index 9b3f0d6dd8..ab38374058 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs @@ -60,21 +60,21 @@ public Torque(double value, TorqueUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TorqueUnit BaseUnit { get; } = TorqueUnit.NewtonMeter; + public static TorqueUnit ConversionBaseUnit { get; } = TorqueUnit.NewtonMeter; /// /// Represents the largest possible value of Duration /// - public static Torque MaxValue { get; } = new Torque(double.MaxValue, BaseUnit); + public static Torque MaxValue { get; } = new Torque(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Torque MinValue { get; } = new Torque(double.MinValue, BaseUnit); + public static Torque MinValue { get; } = new Torque(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Torque Zero { get; } = new Torque(0, BaseUnit); + public static Torque Zero { get; } = new Torque(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs index 5c095bb043..35bcd31239 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -60,21 +60,21 @@ public TorquePerLength(double value, TorquePerLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TorquePerLengthUnit BaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; + public static TorquePerLengthUnit ConversionBaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; /// /// Represents the largest possible value of Duration /// - public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, BaseUnit); + public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, BaseUnit); + public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static TorquePerLength Zero { get; } = new TorquePerLength(0, BaseUnit); + public static TorquePerLength Zero { get; } = new TorquePerLength(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs index 0af65166a0..2f8b295917 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs @@ -63,21 +63,21 @@ public Turbidity(double value, TurbidityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TurbidityUnit BaseUnit { get; } = TurbidityUnit.NTU; + public static TurbidityUnit ConversionBaseUnit { get; } = TurbidityUnit.NTU; /// /// Represents the largest possible value of Duration /// - public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, BaseUnit); + public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, BaseUnit); + public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Turbidity Zero { get; } = new Turbidity(0, BaseUnit); + public static Turbidity Zero { get; } = new Turbidity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs index ee3e993dce..5a54688502 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs @@ -60,21 +60,21 @@ public VitaminA(double value, VitaminAUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VitaminAUnit BaseUnit { get; } = VitaminAUnit.InternationalUnit; + public static VitaminAUnit ConversionBaseUnit { get; } = VitaminAUnit.InternationalUnit; /// /// Represents the largest possible value of Duration /// - public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, BaseUnit); + public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, BaseUnit); + public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VitaminA Zero { get; } = new VitaminA(0, BaseUnit); + public static VitaminA Zero { get; } = new VitaminA(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs index 17ba86b57b..d7fff94b05 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs @@ -60,21 +60,21 @@ public Volume(double value, VolumeUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumeUnit BaseUnit { get; } = VolumeUnit.CubicMeter; + public static VolumeUnit ConversionBaseUnit { get; } = VolumeUnit.CubicMeter; /// /// Represents the largest possible value of Duration /// - public static Volume MaxValue { get; } = new Volume(double.MaxValue, BaseUnit); + public static Volume MaxValue { get; } = new Volume(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Volume MinValue { get; } = new Volume(double.MinValue, BaseUnit); + public static Volume MinValue { get; } = new Volume(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Volume Zero { get; } = new Volume(0, BaseUnit); + public static Volume Zero { get; } = new Volume(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs index 84f16f4580..a710e75835 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -63,21 +63,21 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumeConcentrationUnit BaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; + public static VolumeConcentrationUnit ConversionBaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; /// /// Represents the largest possible value of Duration /// - public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, BaseUnit); + public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, BaseUnit); + public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, BaseUnit); + public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs index 2dfc1749e2..e8c4a36b6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -60,21 +60,21 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumeFlowUnit BaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; + public static VolumeFlowUnit ConversionBaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, BaseUnit); + public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, BaseUnit); + public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumeFlow Zero { get; } = new VolumeFlow(0, BaseUnit); + public static VolumeFlow Zero { get; } = new VolumeFlow(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs index 0c3a42ee6a..eeb73eebd0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -60,21 +60,21 @@ public VolumePerLength(double value, VolumePerLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumePerLengthUnit BaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; + public static VolumePerLengthUnit ConversionBaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; /// /// Represents the largest possible value of Duration /// - public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, BaseUnit); + public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, BaseUnit); + public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumePerLength Zero { get; } = new VolumePerLength(0, BaseUnit); + public static VolumePerLength Zero { get; } = new VolumePerLength(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index b43908c014..38b92d08a5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -63,21 +63,21 @@ public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumetricHeatCapacityUnit BaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; + public static VolumetricHeatCapacityUnit ConversionBaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; /// /// Represents the largest possible value of Duration /// - public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, BaseUnit); + public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, BaseUnit); + public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, BaseUnit); + public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index f3ede9fd35..e555d690bf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -60,21 +60,21 @@ public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static WarpingMomentOfInertiaUnit BaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; + public static WarpingMomentOfInertiaUnit ConversionBaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; /// /// Represents the largest possible value of Duration /// - public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, BaseUnit); + public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// - public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, BaseUnit); + public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, ConversionBaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, BaseUnit); + public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, ConversionBaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs index 2782da5ed8..0865ee9545 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs @@ -20,7 +20,7 @@ namespace UnitsNet.Serialization.JsonNet /// Assumptions by reflection code in the converter: /// * Unit classes are of type UnitsNet.Length etc. /// * Unit enums are of type UnitsNet.Units.LengthUnit etc. - /// * Unit class has a BaseUnit property returning the base unit, such as LengthUnit.Meter + /// * Unit class has a ConversionBaseUnit property returning the base unit, such as LengthUnit.Meter /// [Obsolete("Replaced by UnitsNetIQuantityJsonConverter and UnitsNetIComparableJsonConverter (if you need support for IComparable)")] public class UnitsNetJsonConverter : JsonConverter @@ -46,7 +46,7 @@ public override object ReadJson(JsonReader reader, Type objectType, object exist if (obj is Array values) { - // Create array with the requested type, such as `Length[]` or `Frequency[]` or multi-dimensional arrays like `Length[,]` or `Frequency[,,]` + // Create array with the requested type, such as `Length[]` or `Frequency[]` or multi-dimensional arrays like `Length[,]` or `Frequency[,,]` var arrayOfQuantities = Array.CreateInstance(objectType.GetElementType(), MultiDimensionalArrayHelpers.LastIndex(values)); // Fill array with parsed quantities @@ -157,8 +157,8 @@ public override void WriteJson(JsonWriter writer, object obj, JsonSerializer ser { results.SetValue((IQuantity)values.GetValue(ind), ind); ind = MultiDimensionalArrayHelpers.NextIndex(results, ind); - } - + } + serializer.Serialize(writer, results); } else if (obj is IQuantity quantity) diff --git a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs index 187ac024bc..77c38e6b42 100644 --- a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs +++ b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs @@ -137,12 +137,12 @@ public static void ComponentMassFromMassConcentrationAndSolutionVolume( } - [Fact(Skip = "No BaseUnit defined: see https://github.com/angularsen/UnitsNet/issues/651")] + [Fact(Skip = "No ConversionBaseUnit defined: see https://github.com/angularsen/UnitsNet/issues/651")] public void DefaultSIUnitIsKgPerCubicMeter() { var massConcentration = new MassConcentration(1, UnitSystem.SI); - Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, massConcentration.Unit); // MassConcentration.BaseUnit = KilogramPerCubicMeter + Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, massConcentration.Unit); // MassConcentration.ConversionBaseUnit = KilogramPerCubicMeter } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 8fdff341d5..06e461f680 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -254,7 +254,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Acceleration(value: 1, unit: Acceleration.BaseUnit); + var quantity = new Acceleration(value: 1, unit: Acceleration.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -334,7 +334,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Acceleration.FromMetersPerSecondSquared(1).ToBaseUnit(); - Assert.Equal(Acceleration.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Acceleration.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 9495e04c8f..0560af84c4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -262,7 +262,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.BaseUnit); + var quantity = new AmountOfSubstance(value: 1, unit: AmountOfSubstance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -346,7 +346,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = AmountOfSubstance.FromMoles(1).ToBaseUnit(); - Assert.Equal(AmountOfSubstance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(AmountOfSubstance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 24063f7fe9..ceb1025089 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatio.BaseUnit); + var quantity = new AmplitudeRatio(value: 1, unit: AmplitudeRatio.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = AmplitudeRatio.FromDecibelVolts(1).ToBaseUnit(); - Assert.Equal(AmplitudeRatio.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(AmplitudeRatio.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index b495603ee4..d95be2e7ce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -270,7 +270,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Angle(value: 1, unit: Angle.BaseUnit); + var quantity = new Angle(value: 1, unit: Angle.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -358,7 +358,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Angle.FromDegrees(1).ToBaseUnit(); - Assert.Equal(Angle.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Angle.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 6e94f37657..037e29abfc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ApparentEnergy(value: 1, unit: ApparentEnergy.BaseUnit); + var quantity = new ApparentEnergy(value: 1, unit: ApparentEnergy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ApparentEnergy.FromVoltampereHours(1).ToBaseUnit(); - Assert.Equal(ApparentEnergy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ApparentEnergy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 595427df3e..4af2a71f02 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ApparentPower(value: 1, unit: ApparentPower.BaseUnit); + var quantity = new ApparentPower(value: 1, unit: ApparentPower.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ApparentPower.FromVoltamperes(1).ToBaseUnit(); - Assert.Equal(ApparentPower.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ApparentPower.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index f109ab006d..7c7d618356 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new AreaDensity(value: 1, unit: AreaDensity.BaseUnit); + var quantity = new AreaDensity(value: 1, unit: AreaDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = AreaDensity.FromKilogramsPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(AreaDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(AreaDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index c885ab32f6..4fdb9ea777 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -190,7 +190,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.BaseUnit); + var quantity = new AreaMomentOfInertia(value: 1, unit: AreaMomentOfInertia.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -238,7 +238,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = AreaMomentOfInertia.FromMetersToTheFourth(1).ToBaseUnit(); - Assert.Equal(AreaMomentOfInertia.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(AreaMomentOfInertia.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 0eeb5c8c8c..3079a7652e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -254,7 +254,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Area(value: 1, unit: Area.BaseUnit); + var quantity = new Area(value: 1, unit: Area.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -334,7 +334,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Area.FromSquareMeters(1).ToBaseUnit(); - Assert.Equal(Area.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Area.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index dc91874b00..8f10e34206 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -325,7 +325,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new BitRate(value: 1, unit: BitRate.BaseUnit); + var quantity = new BitRate(value: 1, unit: BitRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -453,7 +453,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = BitRate.FromBitsPerSecond(1).ToBaseUnit(); - Assert.Equal(BitRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(BitRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index e7f822ff7f..32977d0814 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.BaseUnit); + var quantity = new BrakeSpecificFuelConsumption(value: 1, unit: BrakeSpecificFuelConsumption.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1).ToBaseUnit(); - Assert.Equal(BrakeSpecificFuelConsumption.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(BrakeSpecificFuelConsumption.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 644c0edda3..4f02bd8927 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -198,7 +198,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Capacitance(value: 1, unit: Capacitance.BaseUnit); + var quantity = new Capacitance(value: 1, unit: Capacitance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -250,7 +250,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Capacitance.FromFarads(1).ToBaseUnit(); - Assert.Equal(Capacitance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Capacitance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index a760f56fc7..053b44d363 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.BaseUnit); + var quantity = new CoefficientOfThermalExpansion(value: 1, unit: CoefficientOfThermalExpansion.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = CoefficientOfThermalExpansion.FromInverseKelvin(1).ToBaseUnit(); - Assert.Equal(CoefficientOfThermalExpansion.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(CoefficientOfThermalExpansion.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index f37285aba0..04a5e8d34f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -462,7 +462,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Density(value: 1, unit: Density.BaseUnit); + var quantity = new Density(value: 1, unit: Density.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -646,7 +646,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Density.FromKilogramsPerCubicMeter(1).ToBaseUnit(); - Assert.Equal(Density.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Density.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 546fe7ca64..c659e91b37 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -222,7 +222,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Duration(value: 1, unit: Duration.BaseUnit); + var quantity = new Duration(value: 1, unit: Duration.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -286,7 +286,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Duration.FromSeconds(1).ToBaseUnit(); - Assert.Equal(Duration.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Duration.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 47b7e6934f..2b2402ccf8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -222,7 +222,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.BaseUnit); + var quantity = new DynamicViscosity(value: 1, unit: DynamicViscosity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -286,7 +286,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1).ToBaseUnit(); - Assert.Equal(DynamicViscosity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(DynamicViscosity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index d855cedc5c..22094c3c56 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.BaseUnit); + var quantity = new ElectricAdmittance(value: 1, unit: ElectricAdmittance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricAdmittance.FromSiemens(1).ToBaseUnit(); - Assert.Equal(ElectricAdmittance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricAdmittance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index c714108b47..9149152525 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.BaseUnit); + var quantity = new ElectricChargeDensity(value: 1, unit: ElectricChargeDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricChargeDensity.FromCoulombsPerCubicMeter(1).ToBaseUnit(); - Assert.Equal(ElectricChargeDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricChargeDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index ba6b76acbb..0ef2602920 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -182,7 +182,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricCharge(value: 1, unit: ElectricCharge.BaseUnit); + var quantity = new ElectricCharge(value: 1, unit: ElectricCharge.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -226,7 +226,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricCharge.FromCoulombs(1).ToBaseUnit(); - Assert.Equal(ElectricCharge.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricCharge.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 3b348ba006..2bbfaa2c4c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricConductance(value: 1, unit: ElectricConductance.BaseUnit); + var quantity = new ElectricConductance(value: 1, unit: ElectricConductance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricConductance.FromSiemens(1).ToBaseUnit(); - Assert.Equal(ElectricConductance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricConductance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 30fe721b4a..a84d221861 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.BaseUnit); + var quantity = new ElectricConductivity(value: 1, unit: ElectricConductivity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricConductivity.FromSiemensPerMeter(1).ToBaseUnit(); - Assert.Equal(ElectricConductivity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricConductivity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 2b6a166eac..41f03986a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.BaseUnit); + var quantity = new ElectricCurrentDensity(value: 1, unit: ElectricCurrentDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricCurrentDensity.FromAmperesPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(ElectricCurrentDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricCurrentDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index ab24e643a2..2bf61801e3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.BaseUnit); + var quantity = new ElectricCurrentGradient(value: 1, unit: ElectricCurrentGradient.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricCurrentGradient.FromAmperesPerSecond(1).ToBaseUnit(); - Assert.Equal(ElectricCurrentGradient.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricCurrentGradient.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 633f32f1ff..90f641a8f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -206,7 +206,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.BaseUnit); + var quantity = new ElectricCurrent(value: 1, unit: ElectricCurrent.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -262,7 +262,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricCurrent.FromAmperes(1).ToBaseUnit(); - Assert.Equal(ElectricCurrent.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricCurrent.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 79f369eae9..54784a6ec2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricField(value: 1, unit: ElectricField.BaseUnit); + var quantity = new ElectricField(value: 1, unit: ElectricField.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricField.FromVoltsPerMeter(1).ToBaseUnit(); - Assert.Equal(ElectricField.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricField.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 4482b18fd5..9a28c5ce96 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricInductance(value: 1, unit: ElectricInductance.BaseUnit); + var quantity = new ElectricInductance(value: 1, unit: ElectricInductance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricInductance.FromHenries(1).ToBaseUnit(); - Assert.Equal(ElectricInductance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricInductance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index ddc23fa2c6..0accd69915 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -182,7 +182,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricPotentialAc(value: 1, unit: ElectricPotentialAc.BaseUnit); + var quantity = new ElectricPotentialAc(value: 1, unit: ElectricPotentialAc.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -226,7 +226,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricPotentialAc.FromVoltsAc(1).ToBaseUnit(); - Assert.Equal(ElectricPotentialAc.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricPotentialAc.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 987928a2cc..dd774a53e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -302,7 +302,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.BaseUnit); + var quantity = new ElectricPotentialChangeRate(value: 1, unit: ElectricPotentialChangeRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -406,7 +406,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricPotentialChangeRate.FromVoltsPerSeconds(1).ToBaseUnit(); - Assert.Equal(ElectricPotentialChangeRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricPotentialChangeRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 9028ea50e2..06b945f828 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -182,7 +182,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricPotentialDc(value: 1, unit: ElectricPotentialDc.BaseUnit); + var quantity = new ElectricPotentialDc(value: 1, unit: ElectricPotentialDc.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -226,7 +226,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricPotentialDc.FromVoltsDc(1).ToBaseUnit(); - Assert.Equal(ElectricPotentialDc.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricPotentialDc.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 5c519932bd..35d2a24654 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -182,7 +182,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricPotential(value: 1, unit: ElectricPotential.BaseUnit); + var quantity = new ElectricPotential(value: 1, unit: ElectricPotential.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -226,7 +226,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricPotential.FromVolts(1).ToBaseUnit(); - Assert.Equal(ElectricPotential.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricPotential.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 7a656c484d..356191455a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -190,7 +190,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricResistance(value: 1, unit: ElectricResistance.BaseUnit); + var quantity = new ElectricResistance(value: 1, unit: ElectricResistance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -238,7 +238,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricResistance.FromOhms(1).ToBaseUnit(); - Assert.Equal(ElectricResistance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricResistance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 6bdd2c7cd0..bd09c49092 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -254,7 +254,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.BaseUnit); + var quantity = new ElectricResistivity(value: 1, unit: ElectricResistivity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -334,7 +334,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricResistivity.FromOhmMeters(1).ToBaseUnit(); - Assert.Equal(ElectricResistivity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricResistivity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index efb9b9f710..21dad8dff5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.BaseUnit); + var quantity = new ElectricSurfaceChargeDensity(value: 1, unit: ElectricSurfaceChargeDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(ElectricSurfaceChargeDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ElectricSurfaceChargeDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 18f4ef6623..8d8b931539 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -430,7 +430,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Energy(value: 1, unit: Energy.BaseUnit); + var quantity = new Energy(value: 1, unit: Energy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -598,7 +598,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Energy.FromJoules(1).ToBaseUnit(); - Assert.Equal(Energy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Energy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 5e44a83900..5c79deddab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -198,7 +198,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Entropy(value: 1, unit: Entropy.BaseUnit); + var quantity = new Entropy(value: 1, unit: Entropy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -250,7 +250,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Entropy.FromJoulesPerKelvin(1).ToBaseUnit(); - Assert.Equal(Entropy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Entropy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index ebdfab01de..a416e4a841 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -262,7 +262,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.BaseUnit); + var quantity = new ForceChangeRate(value: 1, unit: ForceChangeRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -346,7 +346,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ForceChangeRate.FromNewtonsPerSecond(1).ToBaseUnit(); - Assert.Equal(ForceChangeRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ForceChangeRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 1ba699c782..9615dffe82 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -446,7 +446,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ForcePerLength(value: 1, unit: ForcePerLength.BaseUnit); + var quantity = new ForcePerLength(value: 1, unit: ForcePerLength.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -622,7 +622,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ForcePerLength.FromNewtonsPerMeter(1).ToBaseUnit(); - Assert.Equal(ForcePerLength.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ForcePerLength.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index e99f00c8e2..d0bd8f4e0e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -262,7 +262,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Force(value: 1, unit: Force.BaseUnit); + var quantity = new Force(value: 1, unit: Force.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -346,7 +346,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Force.FromNewtons(1).ToBaseUnit(); - Assert.Equal(Force.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Force.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 80d4ed8863..82e6dc7aca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -230,7 +230,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Frequency(value: 1, unit: Frequency.BaseUnit); + var quantity = new Frequency(value: 1, unit: Frequency.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -298,7 +298,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Frequency.FromHertz(1).ToBaseUnit(); - Assert.Equal(Frequency.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Frequency.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 1c989ea4b2..e69999fe06 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.BaseUnit); + var quantity = new FuelEfficiency(value: 1, unit: FuelEfficiency.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = FuelEfficiency.FromLitersPer100Kilometers(1).ToBaseUnit(); - Assert.Equal(FuelEfficiency.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(FuelEfficiency.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index ef5b021573..175bad85ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -286,7 +286,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new HeatFlux(value: 1, unit: HeatFlux.BaseUnit); + var quantity = new HeatFlux(value: 1, unit: HeatFlux.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -382,7 +382,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = HeatFlux.FromWattsPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(HeatFlux.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(HeatFlux.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index b0ed942d4c..561456fc12 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.BaseUnit); + var quantity = new HeatTransferCoefficient(value: 1, unit: HeatTransferCoefficient.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1).ToBaseUnit(); - Assert.Equal(HeatTransferCoefficient.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(HeatTransferCoefficient.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 5537fc12bd..5c5a1fe98b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Illuminance(value: 1, unit: Illuminance.BaseUnit); + var quantity = new Illuminance(value: 1, unit: Illuminance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Illuminance.FromLux(1).ToBaseUnit(); - Assert.Equal(Illuminance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Illuminance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index b362e00824..5dc0a62463 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -325,7 +325,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Information(value: 1, unit: Information.BaseUnit); + var quantity = new Information(value: 1, unit: Information.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -453,7 +453,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Information.FromBits(1).ToBaseUnit(); - Assert.Equal(Information.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Information.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 76e0cd7403..2d180555b9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -254,7 +254,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Irradiance(value: 1, unit: Irradiance.BaseUnit); + var quantity = new Irradiance(value: 1, unit: Irradiance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -334,7 +334,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Irradiance.FromWattsPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(Irradiance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Irradiance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index afdd0b60c3..7496a84e52 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -198,7 +198,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Irradiation(value: 1, unit: Irradiation.BaseUnit); + var quantity = new Irradiation(value: 1, unit: Irradiation.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -250,7 +250,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Irradiation.FromJoulesPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(Irradiation.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Irradiation.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 34e19f82df..69d28640a3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -214,7 +214,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.BaseUnit); + var quantity = new KinematicViscosity(value: 1, unit: KinematicViscosity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -274,7 +274,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = KinematicViscosity.FromSquareMetersPerSecond(1).ToBaseUnit(); - Assert.Equal(KinematicViscosity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(KinematicViscosity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 0012197a39..1223629d2e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new LapseRate(value: 1, unit: LapseRate.BaseUnit); + var quantity = new LapseRate(value: 1, unit: LapseRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = LapseRate.FromDegreesCelciusPerKilometer(1).ToBaseUnit(); - Assert.Equal(LapseRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(LapseRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 1cb7481f7c..5c128d9bac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -406,7 +406,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Length(value: 1, unit: Length.BaseUnit); + var quantity = new Length(value: 1, unit: Length.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -562,7 +562,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Length.FromMeters(1).ToBaseUnit(); - Assert.Equal(Length.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Length.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 3cc0e5f9bb..1251414373 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -158,7 +158,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Level(value: 1, unit: Level.BaseUnit); + var quantity = new Level(value: 1, unit: Level.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -190,7 +190,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Level.FromDecibels(1).ToBaseUnit(); - Assert.Equal(Level.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Level.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 55b42a0dcd..7ec3d9b9eb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -254,7 +254,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new LinearDensity(value: 1, unit: LinearDensity.BaseUnit); + var quantity = new LinearDensity(value: 1, unit: LinearDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -334,7 +334,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = LinearDensity.FromKilogramsPerMeter(1).ToBaseUnit(); - Assert.Equal(LinearDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(LinearDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index d6b7623329..eee6b3b55b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -342,7 +342,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.BaseUnit); + var quantity = new LinearPowerDensity(value: 1, unit: LinearPowerDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -466,7 +466,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = LinearPowerDensity.FromWattsPerMeter(1).ToBaseUnit(); - Assert.Equal(LinearPowerDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(LinearPowerDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index ef5509b976..0a4cdf22ba 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -254,7 +254,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Luminosity(value: 1, unit: Luminosity.BaseUnit); + var quantity = new Luminosity(value: 1, unit: Luminosity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -334,7 +334,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Luminosity.FromWatts(1).ToBaseUnit(); - Assert.Equal(Luminosity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Luminosity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 6ce9dae421..eccf6494ee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new LuminousFlux(value: 1, unit: LuminousFlux.BaseUnit); + var quantity = new LuminousFlux(value: 1, unit: LuminousFlux.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = LuminousFlux.FromLumens(1).ToBaseUnit(); - Assert.Equal(LuminousFlux.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(LuminousFlux.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 7aa01f9f41..a6db150311 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.BaseUnit); + var quantity = new LuminousIntensity(value: 1, unit: LuminousIntensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = LuminousIntensity.FromCandela(1).ToBaseUnit(); - Assert.Equal(LuminousIntensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(LuminousIntensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index fb0b6872b0..b1176db250 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -190,7 +190,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MagneticField(value: 1, unit: MagneticField.BaseUnit); + var quantity = new MagneticField(value: 1, unit: MagneticField.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -238,7 +238,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MagneticField.FromTeslas(1).ToBaseUnit(); - Assert.Equal(MagneticField.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MagneticField.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index ec2730dae4..57d5d41fad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MagneticFlux(value: 1, unit: MagneticFlux.BaseUnit); + var quantity = new MagneticFlux(value: 1, unit: MagneticFlux.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MagneticFlux.FromWebers(1).ToBaseUnit(); - Assert.Equal(MagneticFlux.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MagneticFlux.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index a1af95cb71..29ad33eeb6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Magnetization(value: 1, unit: Magnetization.BaseUnit); + var quantity = new Magnetization(value: 1, unit: Magnetization.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Magnetization.FromAmperesPerMeter(1).ToBaseUnit(); - Assert.Equal(Magnetization.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Magnetization.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 49c606599d..a524e456f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -534,7 +534,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MassConcentration(value: 1, unit: MassConcentration.BaseUnit); + var quantity = new MassConcentration(value: 1, unit: MassConcentration.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -754,7 +754,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MassConcentration.FromKilogramsPerCubicMeter(1).ToBaseUnit(); - Assert.Equal(MassConcentration.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MassConcentration.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 306ad7e5e6..054a3a434c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -406,7 +406,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MassFlow(value: 1, unit: MassFlow.BaseUnit); + var quantity = new MassFlow(value: 1, unit: MassFlow.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -562,7 +562,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MassFlow.FromGramsPerSecond(1).ToBaseUnit(); - Assert.Equal(MassFlow.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MassFlow.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 854af922ff..c184d551d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -238,7 +238,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MassFlux(value: 1, unit: MassFlux.BaseUnit); + var quantity = new MassFlux(value: 1, unit: MassFlux.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -310,7 +310,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MassFlux.FromKilogramsPerSecondPerSquareMeter(1).ToBaseUnit(); - Assert.Equal(MassFlux.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MassFlux.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 7644821a54..fe2b5e143b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -334,7 +334,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MassFraction(value: 1, unit: MassFraction.BaseUnit); + var quantity = new MassFraction(value: 1, unit: MassFraction.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -454,7 +454,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MassFraction.FromDecimalFractions(1).ToBaseUnit(); - Assert.Equal(MassFraction.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MassFraction.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index ff9b74d7df..e986bd3bcc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -366,7 +366,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.BaseUnit); + var quantity = new MassMomentOfInertia(value: 1, unit: MassMomentOfInertia.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -502,7 +502,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MassMomentOfInertia.FromKilogramSquareMeters(1).ToBaseUnit(); - Assert.Equal(MassMomentOfInertia.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MassMomentOfInertia.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 0d28d6724e..9879e07047 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -342,7 +342,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Mass(value: 1, unit: Mass.BaseUnit); + var quantity = new Mass(value: 1, unit: Mass.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -466,7 +466,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Mass.FromKilograms(1).ToBaseUnit(); - Assert.Equal(Mass.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Mass.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 2bcf7a5820..7a21b4a4d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MolarEnergy(value: 1, unit: MolarEnergy.BaseUnit); + var quantity = new MolarEnergy(value: 1, unit: MolarEnergy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MolarEnergy.FromJoulesPerMole(1).ToBaseUnit(); - Assert.Equal(MolarEnergy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MolarEnergy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 0a076aae5e..822e97b8e1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MolarEntropy(value: 1, unit: MolarEntropy.BaseUnit); + var quantity = new MolarEntropy(value: 1, unit: MolarEntropy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MolarEntropy.FromJoulesPerMoleKelvin(1).ToBaseUnit(); - Assert.Equal(MolarEntropy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MolarEntropy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 7df39a1cc9..25a9466cdb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -238,7 +238,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new MolarMass(value: 1, unit: MolarMass.BaseUnit); + var quantity = new MolarMass(value: 1, unit: MolarMass.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -310,7 +310,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = MolarMass.FromKilogramsPerMole(1).ToBaseUnit(); - Assert.Equal(MolarMass.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(MolarMass.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 5e77ce6c5d..3cfdc8742c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -206,7 +206,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Molarity(value: 1, unit: Molarity.BaseUnit); + var quantity = new Molarity(value: 1, unit: Molarity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -262,7 +262,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Molarity.FromMolesPerCubicMeter(1).ToBaseUnit(); - Assert.Equal(Molarity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Molarity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 2cd5d7c69e..58466eca6a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Permeability(value: 1, unit: Permeability.BaseUnit); + var quantity = new Permeability(value: 1, unit: Permeability.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Permeability.FromHenriesPerMeter(1).ToBaseUnit(); - Assert.Equal(Permeability.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Permeability.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index d42b94bb7b..8bcd23c09e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Permittivity(value: 1, unit: Permittivity.BaseUnit); + var quantity = new Permittivity(value: 1, unit: Permittivity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Permittivity.FromFaradsPerMeter(1).ToBaseUnit(); - Assert.Equal(Permittivity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Permittivity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index fe43ad30c0..65707d49d3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -494,7 +494,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new PowerDensity(value: 1, unit: PowerDensity.BaseUnit); + var quantity = new PowerDensity(value: 1, unit: PowerDensity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -694,7 +694,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = PowerDensity.FromWattsPerCubicMeter(1).ToBaseUnit(); - Assert.Equal(PowerDensity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(PowerDensity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 2468327188..afaeb495dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -158,7 +158,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new PowerRatio(value: 1, unit: PowerRatio.BaseUnit); + var quantity = new PowerRatio(value: 1, unit: PowerRatio.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -190,7 +190,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = PowerRatio.FromDecibelWatts(1).ToBaseUnit(); - Assert.Equal(PowerRatio.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(PowerRatio.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 234c3c9f09..24c9b3573b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -317,7 +317,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Power(value: 1, unit: Power.BaseUnit); + var quantity = new Power(value: 1, unit: Power.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -441,7 +441,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Power.FromWatts(1).ToBaseUnit(); - Assert.Equal(Power.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Power.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 1a0dbad637..4c52218912 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -246,7 +246,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.BaseUnit); + var quantity = new PressureChangeRate(value: 1, unit: PressureChangeRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -322,7 +322,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = PressureChangeRate.FromPascalsPerSecond(1).ToBaseUnit(); - Assert.Equal(PressureChangeRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(PressureChangeRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index cf421ce1ca..f0440ba02b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -494,7 +494,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Pressure(value: 1, unit: Pressure.BaseUnit); + var quantity = new Pressure(value: 1, unit: Pressure.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -694,7 +694,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Pressure.FromPascals(1).ToBaseUnit(); - Assert.Equal(Pressure.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Pressure.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index f6e2cd8ff6..932cbbf21c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -158,7 +158,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.BaseUnit); + var quantity = new RatioChangeRate(value: 1, unit: RatioChangeRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -190,7 +190,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = RatioChangeRate.FromDecimalFractionsPerSecond(1).ToBaseUnit(); - Assert.Equal(RatioChangeRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(RatioChangeRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 5f1c730275..19759a2559 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -190,7 +190,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Ratio(value: 1, unit: Ratio.BaseUnit); + var quantity = new Ratio(value: 1, unit: Ratio.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -238,7 +238,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Ratio.FromDecimalFractions(1).ToBaseUnit(); - Assert.Equal(Ratio.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Ratio.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index a5fb420a1b..b66c8de4b8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ReactiveEnergy(value: 1, unit: ReactiveEnergy.BaseUnit); + var quantity = new ReactiveEnergy(value: 1, unit: ReactiveEnergy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ReactiveEnergy.FromVoltampereReactiveHours(1).ToBaseUnit(); - Assert.Equal(ReactiveEnergy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ReactiveEnergy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 7d4cb80b6a..8a8c85efcb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ReactivePower(value: 1, unit: ReactivePower.BaseUnit); + var quantity = new ReactivePower(value: 1, unit: ReactivePower.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ReactivePower.FromVoltamperesReactive(1).ToBaseUnit(); - Assert.Equal(ReactivePower.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ReactivePower.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index b64695166c..671db86a16 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -230,7 +230,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.BaseUnit); + var quantity = new ReciprocalArea(value: 1, unit: ReciprocalArea.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -298,7 +298,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ReciprocalArea.FromInverseSquareMeters(1).ToBaseUnit(); - Assert.Equal(ReciprocalArea.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ReciprocalArea.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 682963c9ff..9015d143c2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -222,7 +222,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.BaseUnit); + var quantity = new ReciprocalLength(value: 1, unit: ReciprocalLength.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -286,7 +286,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ReciprocalLength.FromInverseMeters(1).ToBaseUnit(); - Assert.Equal(ReciprocalLength.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ReciprocalLength.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index a7ba21d25b..7a0c6fccf2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new RelativeHumidity(value: 1, unit: RelativeHumidity.BaseUnit); + var quantity = new RelativeHumidity(value: 1, unit: RelativeHumidity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = RelativeHumidity.FromPercent(1).ToBaseUnit(); - Assert.Equal(RelativeHumidity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(RelativeHumidity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 634a40430b..102a0cf80d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.BaseUnit); + var quantity = new RotationalAcceleration(value: 1, unit: RotationalAcceleration.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = RotationalAcceleration.FromRadiansPerSecondSquared(1).ToBaseUnit(); - Assert.Equal(RotationalAcceleration.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(RotationalAcceleration.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 93cc2fea10..faecba342b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -246,7 +246,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.BaseUnit); + var quantity = new RotationalSpeed(value: 1, unit: RotationalSpeed.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -322,7 +322,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = RotationalSpeed.FromRadiansPerSecond(1).ToBaseUnit(); - Assert.Equal(RotationalSpeed.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(RotationalSpeed.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index aae2ddea51..3acbe35835 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -182,7 +182,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.BaseUnit); + var quantity = new RotationalStiffnessPerLength(value: 1, unit: RotationalStiffnessPerLength.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -226,7 +226,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1).ToBaseUnit(); - Assert.Equal(RotationalStiffnessPerLength.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(RotationalStiffnessPerLength.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index b5d56b1897..111401e3f1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -406,7 +406,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.BaseUnit); + var quantity = new RotationalStiffness(value: 1, unit: RotationalStiffness.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -562,7 +562,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = RotationalStiffness.FromNewtonMetersPerRadian(1).ToBaseUnit(); - Assert.Equal(RotationalStiffness.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(RotationalStiffness.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index d01595760c..c5210cfca7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Scalar(value: 1, unit: Scalar.BaseUnit); + var quantity = new Scalar(value: 1, unit: Scalar.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Scalar.FromAmount(1).ToBaseUnit(); - Assert.Equal(Scalar.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Scalar.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 5c9b1a4ebb..49ee308d61 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new SolidAngle(value: 1, unit: SolidAngle.BaseUnit); + var quantity = new SolidAngle(value: 1, unit: SolidAngle.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = SolidAngle.FromSteradians(1).ToBaseUnit(); - Assert.Equal(SolidAngle.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(SolidAngle.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 4a59195ae3..1c4a22bc07 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -342,7 +342,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.BaseUnit); + var quantity = new SpecificEnergy(value: 1, unit: SpecificEnergy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -466,7 +466,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = SpecificEnergy.FromJoulesPerKilogram(1).ToBaseUnit(); - Assert.Equal(SpecificEnergy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(SpecificEnergy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index d46d26509b..a70d26d5f2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -214,7 +214,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.BaseUnit); + var quantity = new SpecificEntropy(value: 1, unit: SpecificEntropy.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -274,7 +274,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = SpecificEntropy.FromJoulesPerKilogramKelvin(1).ToBaseUnit(); - Assert.Equal(SpecificEntropy.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(SpecificEntropy.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index aa43b0b7fa..33567e2da1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -174,7 +174,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.BaseUnit); + var quantity = new SpecificFuelConsumption(value: 1, unit: SpecificFuelConsumption.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -214,7 +214,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1).ToBaseUnit(); - Assert.Equal(SpecificFuelConsumption.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(SpecificFuelConsumption.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 198913ba08..12bf303654 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -166,7 +166,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new SpecificVolume(value: 1, unit: SpecificVolume.BaseUnit); + var quantity = new SpecificVolume(value: 1, unit: SpecificVolume.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -202,7 +202,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = SpecificVolume.FromCubicMetersPerKilogram(1).ToBaseUnit(); - Assert.Equal(SpecificVolume.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(SpecificVolume.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 6c6288dcbb..3835cc3ece 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -278,7 +278,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new SpecificWeight(value: 1, unit: SpecificWeight.BaseUnit); + var quantity = new SpecificWeight(value: 1, unit: SpecificWeight.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -370,7 +370,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = SpecificWeight.FromNewtonsPerCubicMeter(1).ToBaseUnit(); - Assert.Equal(SpecificWeight.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(SpecificWeight.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index fb9fd1ea9d..a13ca24aeb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -398,7 +398,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Speed(value: 1, unit: Speed.BaseUnit); + var quantity = new Speed(value: 1, unit: Speed.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -550,7 +550,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Speed.FromMetersPerSecond(1).ToBaseUnit(); - Assert.Equal(Speed.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Speed.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index db667fcf5c..409c360642 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -214,7 +214,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.BaseUnit); + var quantity = new StandardVolumeFlow(value: 1, unit: StandardVolumeFlow.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -274,7 +274,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1).ToBaseUnit(); - Assert.Equal(StandardVolumeFlow.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(StandardVolumeFlow.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 3986719461..95e1fb0203 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -222,7 +222,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.BaseUnit); + var quantity = new TemperatureChangeRate(value: 1, unit: TemperatureChangeRate.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -286,7 +286,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1).ToBaseUnit(); - Assert.Equal(TemperatureChangeRate.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(TemperatureChangeRate.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index bd811703eb..1ff295e727 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -214,7 +214,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.BaseUnit); + var quantity = new TemperatureDelta(value: 1, unit: TemperatureDelta.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -274,7 +274,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = TemperatureDelta.FromKelvins(1).ToBaseUnit(); - Assert.Equal(TemperatureDelta.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(TemperatureDelta.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index d9cc05adff..50226cf4c8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -222,7 +222,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Temperature(value: 1, unit: Temperature.BaseUnit); + var quantity = new Temperature(value: 1, unit: Temperature.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -286,7 +286,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Temperature.FromKelvins(1).ToBaseUnit(); - Assert.Equal(Temperature.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Temperature.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 1d5122321a..09458d068f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -158,7 +158,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.BaseUnit); + var quantity = new ThermalConductivity(value: 1, unit: ThermalConductivity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -190,7 +190,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ThermalConductivity.FromWattsPerMeterKelvin(1).ToBaseUnit(); - Assert.Equal(ThermalConductivity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ThermalConductivity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 549eb82ea5..733f5b09b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -182,7 +182,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new ThermalResistance(value: 1, unit: ThermalResistance.BaseUnit); + var quantity = new ThermalResistance(value: 1, unit: ThermalResistance.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -226,7 +226,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1).ToBaseUnit(); - Assert.Equal(ThermalResistance.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(ThermalResistance.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 5bf790acfe..47760be662 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -310,7 +310,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new TorquePerLength(value: 1, unit: TorquePerLength.BaseUnit); + var quantity = new TorquePerLength(value: 1, unit: TorquePerLength.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -418,7 +418,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = TorquePerLength.FromNewtonMetersPerMeter(1).ToBaseUnit(); - Assert.Equal(TorquePerLength.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(TorquePerLength.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index d37ecfbad2..4aed3a6ff5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -318,7 +318,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Torque(value: 1, unit: Torque.BaseUnit); + var quantity = new Torque(value: 1, unit: Torque.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -430,7 +430,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Torque.FromNewtonMeters(1).ToBaseUnit(); - Assert.Equal(Torque.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Torque.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index f4b6eac73c..cd55be577d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Turbidity(value: 1, unit: Turbidity.BaseUnit); + var quantity = new Turbidity(value: 1, unit: Turbidity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Turbidity.FromNTU(1).ToBaseUnit(); - Assert.Equal(Turbidity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Turbidity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 8e774dac97..ce38c66001 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -150,7 +150,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new VitaminA(value: 1, unit: VitaminA.BaseUnit); + var quantity = new VitaminA(value: 1, unit: VitaminA.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -178,7 +178,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = VitaminA.FromInternationalUnits(1).ToBaseUnit(); - Assert.Equal(VitaminA.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(VitaminA.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 085e791a32..590de306e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -302,7 +302,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new VolumeConcentration(value: 1, unit: VolumeConcentration.BaseUnit); + var quantity = new VolumeConcentration(value: 1, unit: VolumeConcentration.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -406,7 +406,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = VolumeConcentration.FromDecimalFractions(1).ToBaseUnit(); - Assert.Equal(VolumeConcentration.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(VolumeConcentration.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index ec8d14783f..ade0c890e5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -590,7 +590,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new VolumeFlow(value: 1, unit: VolumeFlow.BaseUnit); + var quantity = new VolumeFlow(value: 1, unit: VolumeFlow.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -838,7 +838,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = VolumeFlow.FromCubicMetersPerSecond(1).ToBaseUnit(); - Assert.Equal(VolumeFlow.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(VolumeFlow.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index ce74461e4f..0b6f523eea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -198,7 +198,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new VolumePerLength(value: 1, unit: VolumePerLength.BaseUnit); + var quantity = new VolumePerLength(value: 1, unit: VolumePerLength.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -250,7 +250,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = VolumePerLength.FromCubicMetersPerMeter(1).ToBaseUnit(); - Assert.Equal(VolumePerLength.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(VolumePerLength.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 7012708187..c467920145 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -550,7 +550,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new Volume(value: 1, unit: Volume.BaseUnit); + var quantity = new Volume(value: 1, unit: Volume.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -778,7 +778,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = Volume.FromCubicMeters(1).ToBaseUnit(); - Assert.Equal(Volume.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(Volume.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 8abd390f15..8cc8dae8c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -214,7 +214,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.BaseUnit); + var quantity = new VolumetricHeatCapacity(value: 1, unit: VolumetricHeatCapacity.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -274,7 +274,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1).ToBaseUnit(); - Assert.Equal(VolumetricHeatCapacity.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(VolumetricHeatCapacity.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 6890a5115c..58a0e29930 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -190,7 +190,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() { - var quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.BaseUnit); + var quantity = new WarpingMomentOfInertia(value: 1, unit: WarpingMomentOfInertia.ConversionBaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -238,7 +238,7 @@ public void ToUnit() public void ToBaseUnit_ReturnsQuantityWithBaseUnit() { var quantityInBaseUnit = WarpingMomentOfInertia.FromMetersToTheSixth(1).ToBaseUnit(); - Assert.Equal(WarpingMomentOfInertia.BaseUnit, quantityInBaseUnit.Unit); + Assert.Equal(WarpingMomentOfInertia.ConversionBaseUnit, quantityInBaseUnit.Unit); } [Fact] diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index f3cbdea055..9d7a7ee445 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -34,7 +34,7 @@ public void Constructor_AssignsProperties() Assert.Equal(expectedBaseDimensions, info.BaseDimensions); // Obsolete members - Assert.Equal( expectedBaseUnit, info.BaseUnit ); + Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } @@ -62,7 +62,7 @@ public void Constructor_AssignsPropertiesForCustomQuantity() Assert.Equal(expectedBaseDimensions, info.BaseDimensions); // Obsolete members - Assert.Equal( expectedBaseUnit, info.BaseUnit ); + Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); Assert.Equal(new[] {nameof(HowMuchUnit.Some), nameof(HowMuchUnit.ATon), nameof(HowMuchUnit.AShitTon)}, info.UnitNames); } @@ -87,7 +87,7 @@ public void ObsoleteConstructor_AssignsProperties() Assert.Equal(expectedBaseDimensions, info.BaseDimensions); // Obsolete members - Assert.Equal( expectedBaseUnit, info.BaseUnit ); + Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } @@ -113,7 +113,7 @@ public void GenericsConstructor_AssignsProperties() // Obsolete members Assert.Equal(expectedQuantityType, info.QuantityType); - Assert.Equal( expectedBaseUnit, info.BaseUnit ); + Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } @@ -122,7 +122,7 @@ public void GenericsConstructor_AssignsProperties() public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions, QuantityType.Length)); + null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions, QuantityType.Length)); } [Fact] @@ -130,7 +130,7 @@ public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions, QuantityType.Length)); + null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions, QuantityType.Length)); } [Fact] @@ -146,7 +146,7 @@ public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions, QuantityType.Length)); } [Fact] @@ -154,7 +154,7 @@ public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions, QuantityType.Length)); } [Fact] @@ -162,7 +162,7 @@ public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null, QuantityType.Length)); } [Fact] @@ -170,14 +170,14 @@ public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null, QuantityType.Length)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void Constructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, typeof(LengthUnit), - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -185,7 +185,7 @@ public void Constructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() public void GenericsConstructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, - null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -201,7 +201,7 @@ public void Constructor2_GivenNullAsBaseUnit_ThrowsArgumentNullException() public void Constructor2_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, typeof(LengthUnit), - Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -209,7 +209,7 @@ public void Constructor2_GivenNullAsZero_ThrowsArgumentNullException() public void GenericsConstructor2_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, - Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -217,7 +217,7 @@ public void GenericsConstructor2_GivenNullAsZero_ThrowsArgumentNullException() public void Constructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, typeof(LengthUnit), - Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); } [Fact] @@ -225,7 +225,7 @@ public void Constructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullException() public void GenericsConstructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, - Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); } [Fact] diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index d25421a990..06e4e06b93 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -223,7 +223,7 @@ public void FromQuantityType_GivenLengthQuantityType_ReturnsLengthQuantity() Assert.Equal(0.0, fromQuantity.Value); Assert.Equal(QuantityType.Length, fromQuantity.Type); - Assert.Equal(Length.BaseUnit, fromQuantity.Unit); + Assert.Equal(Length.ConversionBaseUnit, fromQuantity.Unit); } } } diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index 022b82f6ba..fcec387af0 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -82,7 +82,7 @@ public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndI Assert.Equal(expectedJson, json); } - + [Fact] public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit() { @@ -124,7 +124,7 @@ public void DoubleBaseUnitQuantity_DeserializedFromValueAndNoUnit() var quantity = DeserializeObject(json); Assert.Equal(1.2, quantity.Value); - Assert.Equal(Mass.BaseUnit, quantity.Unit); + Assert.Equal(Mass.ConversionBaseUnit, quantity.Unit); } [Fact] @@ -135,9 +135,9 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() var quantity = DeserializeObject(json); Assert.Equal(0, quantity.Value); - Assert.Equal(Mass.BaseUnit, quantity.Unit); + Assert.Equal(Mass.ConversionBaseUnit, quantity.Unit); } - + [Fact] public void DecimalQuantity_DeserializedFromDecimalValueAndIntegerUnit() { @@ -179,10 +179,10 @@ public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit() var json = "{\"Value\":1.200}"; var quantity = DeserializeObject(json); - + Assert.Equal(1.200m, quantity.Value); Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); - Assert.Equal(Information.BaseUnit, quantity.Unit); + Assert.Equal(Information.ConversionBaseUnit, quantity.Unit); } [Fact] @@ -193,7 +193,7 @@ public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput() var quantity = DeserializeObject(json); Assert.Equal(0, quantity.Value); - Assert.Equal(Information.BaseUnit, quantity.Unit); + Assert.Equal(Information.ConversionBaseUnit, quantity.Unit); } [Fact] diff --git a/UnitsNet.Tests/UnitMathTests.cs b/UnitsNet.Tests/UnitMathTests.cs index 1951549863..64dd3827d7 100644 --- a/UnitsNet.Tests/UnitMathTests.cs +++ b/UnitsNet.Tests/UnitMathTests.cs @@ -276,7 +276,7 @@ public void SumOfEmptySourceReturnsZero() { var units = new Length[] { }; - Length sum = units.Sum(Length.BaseUnit); + Length sum = units.Sum(Length.ConversionBaseUnit); Assert.Equal(Length.Zero, sum); } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 129787880a..66a7126a44 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -71,7 +71,7 @@ static Acceleration() new UnitInfo(AccelerationUnit.NanometerPerSecondSquared, "NanometersPerSecondSquared", BaseUnits.Undefined), new UnitInfo(AccelerationUnit.StandardGravity, "StandardGravity", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Acceleration); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Acceleration); } /// @@ -121,19 +121,19 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// The base unit of Acceleration, which is MeterPerSecondSquared. All conversions go via this value. /// - public static AccelerationUnit BaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; + public static AccelerationUnit ConversionBaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; /// /// Represents the largest possible value of Acceleration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, BaseUnit); + public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Acceleration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, BaseUnit); + public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -149,7 +149,7 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecondSquared. /// - public static Acceleration Zero { get; } = new Acceleration(0, BaseUnit); + public static Acceleration Zero { get; } = new Acceleration(0, ConversionBaseUnit); #endregion @@ -163,7 +163,7 @@ public Acceleration(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AccelerationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -866,7 +866,7 @@ private double GetValueInBaseUnit() internal Acceleration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Acceleration(baseUnitValue, BaseUnit); + return new Acceleration(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AccelerationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index a4c975d355..17a1c70e5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -72,7 +72,7 @@ static AmountOfSubstance() new UnitInfo(AmountOfSubstanceUnit.NanopoundMole, "NanopoundMoles", BaseUnits.Undefined), new UnitInfo(AmountOfSubstanceUnit.PoundMole, "PoundMoles", new BaseUnits(amount: AmountOfSubstanceUnit.PoundMole)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AmountOfSubstance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AmountOfSubstance); } /// @@ -122,19 +122,19 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// The base unit of AmountOfSubstance, which is Mole. All conversions go via this value. /// - public static AmountOfSubstanceUnit BaseUnit { get; } = AmountOfSubstanceUnit.Mole; + public static AmountOfSubstanceUnit ConversionBaseUnit { get; } = AmountOfSubstanceUnit.Mole; /// /// Represents the largest possible value of AmountOfSubstance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, BaseUnit); + public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of AmountOfSubstance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, BaseUnit); + public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -150,7 +150,7 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Mole. /// - public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, BaseUnit); + public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, ConversionBaseUnit); #endregion @@ -164,7 +164,7 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AmountOfSubstanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -882,7 +882,7 @@ private double GetValueInBaseUnit() internal AmountOfSubstance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AmountOfSubstance(baseUnitValue, BaseUnit); + return new AmountOfSubstance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AmountOfSubstanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index f4478bfd0d..0b8d1d19d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -61,7 +61,7 @@ static AmplitudeRatio() new UnitInfo(AmplitudeRatioUnit.DecibelUnloaded, "DecibelsUnloaded", BaseUnits.Undefined), new UnitInfo(AmplitudeRatioUnit.DecibelVolt, "DecibelVolts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AmplitudeRatio); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AmplitudeRatio); } /// @@ -111,19 +111,19 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// The base unit of AmplitudeRatio, which is DecibelVolt. All conversions go via this value. /// - public static AmplitudeRatioUnit BaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; + public static AmplitudeRatioUnit ConversionBaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; /// /// Represents the largest possible value of AmplitudeRatio /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, BaseUnit); + public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of AmplitudeRatio /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, BaseUnit); + public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DecibelVolt. /// - public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, BaseUnit); + public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AmplitudeRatioUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -714,7 +714,7 @@ private double GetValueInBaseUnit() internal AmplitudeRatio ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AmplitudeRatio(baseUnitValue, BaseUnit); + return new AmplitudeRatio(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AmplitudeRatioUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 7025d49b06..3457a4b108 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -73,7 +73,7 @@ static Angle() new UnitInfo(AngleUnit.Revolution, "Revolutions", BaseUnits.Undefined), new UnitInfo(AngleUnit.Tilt, "Tilt", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Angle); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Angle); } /// @@ -123,19 +123,19 @@ public Angle(double value, UnitSystem unitSystem) /// /// The base unit of Angle, which is Degree. All conversions go via this value. /// - public static AngleUnit BaseUnit { get; } = AngleUnit.Degree; + public static AngleUnit ConversionBaseUnit { get; } = AngleUnit.Degree; /// /// Represents the largest possible value of Angle /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Angle MaxValue { get; } = new Angle(double.MaxValue, BaseUnit); + public static Angle MaxValue { get; } = new Angle(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Angle /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Angle MinValue { get; } = new Angle(double.MinValue, BaseUnit); + public static Angle MinValue { get; } = new Angle(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -151,7 +151,7 @@ public Angle(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Degree. /// - public static Angle Zero { get; } = new Angle(0, BaseUnit); + public static Angle Zero { get; } = new Angle(0, ConversionBaseUnit); #endregion @@ -165,7 +165,7 @@ public Angle(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AngleUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -898,7 +898,7 @@ private double GetValueInBaseUnit() internal Angle ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Angle(baseUnitValue, BaseUnit); + return new Angle(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AngleUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 5c8f074761..49c15c594f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -60,7 +60,7 @@ static ApparentEnergy() new UnitInfo(ApparentEnergyUnit.MegavoltampereHour, "MegavoltampereHours", BaseUnits.Undefined), new UnitInfo(ApparentEnergyUnit.VoltampereHour, "VoltampereHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ApparentEnergy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ApparentEnergy); } /// @@ -110,19 +110,19 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// The base unit of ApparentEnergy, which is VoltampereHour. All conversions go via this value. /// - public static ApparentEnergyUnit BaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; + public static ApparentEnergyUnit ConversionBaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; /// /// Represents the largest possible value of ApparentEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, BaseUnit); + public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ApparentEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, BaseUnit); + public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereHour. /// - public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, BaseUnit); + public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public ApparentEnergy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ApparentEnergyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal ApparentEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ApparentEnergy(baseUnitValue, BaseUnit); + return new ApparentEnergy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ApparentEnergyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 69009aed33..6182805bc7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -61,7 +61,7 @@ static ApparentPower() new UnitInfo(ApparentPowerUnit.Megavoltampere, "Megavoltamperes", BaseUnits.Undefined), new UnitInfo(ApparentPowerUnit.Voltampere, "Voltamperes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ApparentPower); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ApparentPower); } /// @@ -111,19 +111,19 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// The base unit of ApparentPower, which is Voltampere. All conversions go via this value. /// - public static ApparentPowerUnit BaseUnit { get; } = ApparentPowerUnit.Voltampere; + public static ApparentPowerUnit ConversionBaseUnit { get; } = ApparentPowerUnit.Voltampere; /// /// Represents the largest possible value of ApparentPower /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, BaseUnit); + public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ApparentPower /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, BaseUnit); + public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Voltampere. /// - public static ApparentPower Zero { get; } = new ApparentPower(0, BaseUnit); + public static ApparentPower Zero { get; } = new ApparentPower(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public ApparentPower(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ApparentPowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ApparentPowerUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -706,7 +706,7 @@ private double GetValueInBaseUnit() internal ApparentPower ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ApparentPower(baseUnitValue, BaseUnit); + return new ApparentPower(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ApparentPowerUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 0e03c9a519..0ed7a2bde2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -71,7 +71,7 @@ static Area() new UnitInfo(AreaUnit.SquareYard, "SquareYards", new BaseUnits(length: LengthUnit.Yard)), new UnitInfo(AreaUnit.UsSurveySquareFoot, "UsSurveySquareFeet", new BaseUnits(length: LengthUnit.UsSurveyFoot)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Area); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Area); } /// @@ -121,19 +121,19 @@ public Area(double value, UnitSystem unitSystem) /// /// The base unit of Area, which is SquareMeter. All conversions go via this value. /// - public static AreaUnit BaseUnit { get; } = AreaUnit.SquareMeter; + public static AreaUnit ConversionBaseUnit { get; } = AreaUnit.SquareMeter; /// /// Represents the largest possible value of Area /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Area MaxValue { get; } = new Area(double.MaxValue, BaseUnit); + public static Area MaxValue { get; } = new Area(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Area /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Area MinValue { get; } = new Area(double.MinValue, BaseUnit); + public static Area MinValue { get; } = new Area(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -149,7 +149,7 @@ public Area(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeter. /// - public static Area Zero { get; } = new Area(0, BaseUnit); + public static Area Zero { get; } = new Area(0, ConversionBaseUnit); #endregion @@ -163,7 +163,7 @@ public Area(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AreaUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -866,7 +866,7 @@ private double GetValueInBaseUnit() internal Area ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Area(baseUnitValue, BaseUnit); + return new Area(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AreaUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index e52b05bf88..b7351e72a7 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -58,7 +58,7 @@ static AreaDensity() new UnitInfo[] { new UnitInfo(AreaDensityUnit.KilogramPerSquareMeter, "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AreaDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AreaDensity); } /// @@ -108,19 +108,19 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// The base unit of AreaDensity, which is KilogramPerSquareMeter. All conversions go via this value. /// - public static AreaDensityUnit BaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; + public static AreaDensityUnit ConversionBaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; /// /// Represents the largest possible value of AreaDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, BaseUnit); + public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of AreaDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, BaseUnit); + public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -136,7 +136,7 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSquareMeter. /// - public static AreaDensity Zero { get; } = new AreaDensity(0, BaseUnit); + public static AreaDensity Zero { get; } = new AreaDensity(0, ConversionBaseUnit); #endregion @@ -150,7 +150,7 @@ public AreaDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AreaDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AreaDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -658,7 +658,7 @@ private double GetValueInBaseUnit() internal AreaDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AreaDensity(baseUnitValue, BaseUnit); + return new AreaDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AreaDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 35752e8a18..ac701f1ffe 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -63,7 +63,7 @@ static AreaMomentOfInertia() new UnitInfo(AreaMomentOfInertiaUnit.MeterToTheFourth, "MetersToTheFourth", new BaseUnits(length: LengthUnit.Meter)), new UnitInfo(AreaMomentOfInertiaUnit.MillimeterToTheFourth, "MillimetersToTheFourth", new BaseUnits(length: LengthUnit.Millimeter)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AreaMomentOfInertia); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AreaMomentOfInertia); } /// @@ -113,19 +113,19 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// The base unit of AreaMomentOfInertia, which is MeterToTheFourth. All conversions go via this value. /// - public static AreaMomentOfInertiaUnit BaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; + public static AreaMomentOfInertiaUnit ConversionBaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; /// /// Represents the largest possible value of AreaMomentOfInertia /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, BaseUnit); + public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of AreaMomentOfInertia /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, BaseUnit); + public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheFourth. /// - public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, BaseUnit); + public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public AreaMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public AreaMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -738,7 +738,7 @@ private double GetValueInBaseUnit() internal AreaMomentOfInertia ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new AreaMomentOfInertia(baseUnitValue, BaseUnit); + return new AreaMomentOfInertia(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(AreaMomentOfInertiaUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 8215bf3120..afc1d973af 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -86,7 +86,7 @@ static BitRate() new UnitInfo(BitRateUnit.TerabitPerSecond, "TerabitsPerSecond", BaseUnits.Undefined), new UnitInfo(BitRateUnit.TerabytePerSecond, "TerabytesPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.BitRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.BitRate); } /// @@ -136,19 +136,19 @@ public BitRate(decimal value, UnitSystem unitSystem) /// /// The base unit of BitRate, which is BitPerSecond. All conversions go via this value. /// - public static BitRateUnit BaseUnit { get; } = BitRateUnit.BitPerSecond; + public static BitRateUnit ConversionBaseUnit { get; } = BitRateUnit.BitPerSecond; /// /// Represents the largest possible value of BitRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BitRate MaxValue { get; } = new BitRate(decimal.MaxValue, BaseUnit); + public static BitRate MaxValue { get; } = new BitRate(decimal.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of BitRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BitRate MinValue { get; } = new BitRate(decimal.MinValue, BaseUnit); + public static BitRate MinValue { get; } = new BitRate(decimal.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -164,7 +164,7 @@ public BitRate(decimal value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit BitPerSecond. /// - public static BitRate Zero { get; } = new BitRate(0, BaseUnit); + public static BitRate Zero { get; } = new BitRate(0, ConversionBaseUnit); #endregion @@ -183,7 +183,7 @@ public BitRate(decimal value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public BitRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public BitRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1066,7 +1066,7 @@ private decimal GetValueInBaseUnit() internal BitRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new BitRate(baseUnitValue, BaseUnit); + return new BitRate(baseUnitValue, ConversionBaseUnit); } private decimal GetValueAs(BitRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 1db65ccd26..20a394b6ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -60,7 +60,7 @@ static BrakeSpecificFuelConsumption() new UnitInfo(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, "KilogramsPerJoule", BaseUnits.Undefined), new UnitInfo(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, "PoundsPerMechanicalHorsepowerHour", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.BrakeSpecificFuelConsumption); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.BrakeSpecificFuelConsumption); } /// @@ -110,19 +110,19 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The base unit of BrakeSpecificFuelConsumption, which is KilogramPerJoule. All conversions go via this value. /// - public static BrakeSpecificFuelConsumptionUnit BaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; + public static BrakeSpecificFuelConsumptionUnit ConversionBaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; /// /// Represents the largest possible value of BrakeSpecificFuelConsumption /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit); + public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of BrakeSpecificFuelConsumption /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit); + public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerJoule. /// - public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, BaseUnit); + public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public BrakeSpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public BrakeSpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal BrakeSpecificFuelConsumption ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new BrakeSpecificFuelConsumption(baseUnitValue, BaseUnit); + return new BrakeSpecificFuelConsumption(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index cc2bf58663..4d48f54340 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -67,7 +67,7 @@ static Capacitance() new UnitInfo(CapacitanceUnit.Nanofarad, "Nanofarads", BaseUnits.Undefined), new UnitInfo(CapacitanceUnit.Picofarad, "Picofarads", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Capacitance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Capacitance); } /// @@ -117,19 +117,19 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// The base unit of Capacitance, which is Farad. All conversions go via this value. /// - public static CapacitanceUnit BaseUnit { get; } = CapacitanceUnit.Farad; + public static CapacitanceUnit ConversionBaseUnit { get; } = CapacitanceUnit.Farad; /// /// Represents the largest possible value of Capacitance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, BaseUnit); + public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Capacitance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, BaseUnit); + public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -145,7 +145,7 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Farad. /// - public static Capacitance Zero { get; } = new Capacitance(0, BaseUnit); + public static Capacitance Zero { get; } = new Capacitance(0, ConversionBaseUnit); #endregion @@ -159,7 +159,7 @@ public Capacitance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public CapacitanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public CapacitanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -757,7 +757,7 @@ private double GetValueInBaseUnit() internal Capacitance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Capacitance(baseUnitValue, BaseUnit); + return new Capacitance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(CapacitanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index cae873cd13..b7ee800cac 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -60,7 +60,7 @@ static CoefficientOfThermalExpansion() new UnitInfo(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, "InverseDegreeFahrenheit", new BaseUnits(temperature: TemperatureUnit.DegreeFahrenheit)), new UnitInfo(CoefficientOfThermalExpansionUnit.InverseKelvin, "InverseKelvin", new BaseUnits(temperature: TemperatureUnit.Kelvin)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.CoefficientOfThermalExpansion); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.CoefficientOfThermalExpansion); } /// @@ -110,19 +110,19 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// The base unit of CoefficientOfThermalExpansion, which is InverseKelvin. All conversions go via this value. /// - public static CoefficientOfThermalExpansionUnit BaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; + public static CoefficientOfThermalExpansionUnit ConversionBaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; /// /// Represents the largest possible value of CoefficientOfThermalExpansion /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit); + public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of CoefficientOfThermalExpansion /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, BaseUnit); + public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseKelvin. /// - public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, BaseUnit); + public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public CoefficientOfThermalExpansionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public CoefficientOfThermalExpansionUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal CoefficientOfThermalExpansion ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new CoefficientOfThermalExpansion(baseUnitValue, BaseUnit); + return new CoefficientOfThermalExpansion(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(CoefficientOfThermalExpansionUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 11b60bd3d2..7e6f640db8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -100,7 +100,7 @@ static Density() new UnitInfo(DensityUnit.TonnePerCubicMeter, "TonnesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Tonne)), new UnitInfo(DensityUnit.TonnePerCubicMillimeter, "TonnesPerCubicMillimeter", new BaseUnits(length: LengthUnit.Millimeter, mass: MassUnit.Tonne)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Density); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Density); } /// @@ -150,19 +150,19 @@ public Density(double value, UnitSystem unitSystem) /// /// The base unit of Density, which is KilogramPerCubicMeter. All conversions go via this value. /// - public static DensityUnit BaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; + public static DensityUnit ConversionBaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; /// /// Represents the largest possible value of Density /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Density MaxValue { get; } = new Density(double.MaxValue, BaseUnit); + public static Density MaxValue { get; } = new Density(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Density /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Density MinValue { get; } = new Density(double.MinValue, BaseUnit); + public static Density MinValue { get; } = new Density(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -178,7 +178,7 @@ public Density(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. /// - public static Density Zero { get; } = new Density(0, BaseUnit); + public static Density Zero { get; } = new Density(0, ConversionBaseUnit); #endregion @@ -192,7 +192,7 @@ public Density(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public DensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public DensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1285,7 +1285,7 @@ private double GetValueInBaseUnit() internal Density ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Density(baseUnitValue, BaseUnit); + return new Density(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(DensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 770ac80d28..c10e60bb8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -67,7 +67,7 @@ static Duration() new UnitInfo(DurationUnit.Week, "Weeks", new BaseUnits(time: DurationUnit.Week)), new UnitInfo(DurationUnit.Year365, "Years365", new BaseUnits(time: DurationUnit.Year365)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Duration); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Duration); } /// @@ -117,19 +117,19 @@ public Duration(double value, UnitSystem unitSystem) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DurationUnit BaseUnit { get; } = DurationUnit.Second; + public static DurationUnit ConversionBaseUnit { get; } = DurationUnit.Second; /// /// Represents the largest possible value of Duration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Duration MaxValue { get; } = new Duration(double.MaxValue, BaseUnit); + public static Duration MaxValue { get; } = new Duration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Duration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Duration MinValue { get; } = new Duration(double.MinValue, BaseUnit); + public static Duration MinValue { get; } = new Duration(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -145,7 +145,7 @@ public Duration(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Duration Zero { get; } = new Duration(0, BaseUnit); + public static Duration Zero { get; } = new Duration(0, ConversionBaseUnit); #endregion @@ -159,7 +159,7 @@ public Duration(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public DurationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public DurationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -802,7 +802,7 @@ private double GetValueInBaseUnit() internal Duration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Duration(baseUnitValue, BaseUnit); + return new Duration(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(DurationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 54c0078e3b..32d553f479 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -70,7 +70,7 @@ static DynamicViscosity() new UnitInfo(DynamicViscosityUnit.PoundPerFootSecond, "PoundsPerFootSecond", BaseUnits.Undefined), new UnitInfo(DynamicViscosityUnit.Reyn, "Reyns", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.DynamicViscosity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.DynamicViscosity); } /// @@ -120,19 +120,19 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// The base unit of DynamicViscosity, which is NewtonSecondPerMeterSquared. All conversions go via this value. /// - public static DynamicViscosityUnit BaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; + public static DynamicViscosityUnit ConversionBaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; /// /// Represents the largest possible value of DynamicViscosity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, BaseUnit); + public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of DynamicViscosity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, BaseUnit); + public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -148,7 +148,7 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared. /// - public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, BaseUnit); + public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, ConversionBaseUnit); #endregion @@ -162,7 +162,7 @@ public DynamicViscosity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public DynamicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public DynamicViscosityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -805,7 +805,7 @@ private double GetValueInBaseUnit() internal DynamicViscosity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new DynamicViscosity(baseUnitValue, BaseUnit); + return new DynamicViscosity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(DynamicViscosityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 24a5702c8c..9d12fa4e40 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -61,7 +61,7 @@ static ElectricAdmittance() new UnitInfo(ElectricAdmittanceUnit.Nanosiemens, "Nanosiemens", BaseUnits.Undefined), new UnitInfo(ElectricAdmittanceUnit.Siemens, "Siemens", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricAdmittance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricAdmittance); } /// @@ -111,19 +111,19 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// The base unit of ElectricAdmittance, which is Siemens. All conversions go via this value. /// - public static ElectricAdmittanceUnit BaseUnit { get; } = ElectricAdmittanceUnit.Siemens; + public static ElectricAdmittanceUnit ConversionBaseUnit { get; } = ElectricAdmittanceUnit.Siemens; /// /// Represents the largest possible value of ElectricAdmittance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, BaseUnit); + public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricAdmittance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, BaseUnit); + public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. /// - public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, BaseUnit); + public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricAdmittanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricAdmittanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -706,7 +706,7 @@ private double GetValueInBaseUnit() internal ElectricAdmittance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricAdmittance(baseUnitValue, BaseUnit); + return new ElectricAdmittance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricAdmittanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index ab9d21afbb..b57657f453 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -65,7 +65,7 @@ static ElectricCharge() new UnitInfo(ElectricChargeUnit.MegaampereHour, "MegaampereHours", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.MilliampereHour, "MilliampereHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCharge); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCharge); } /// @@ -115,19 +115,19 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// The base unit of ElectricCharge, which is Coulomb. All conversions go via this value. /// - public static ElectricChargeUnit BaseUnit { get; } = ElectricChargeUnit.Coulomb; + public static ElectricChargeUnit ConversionBaseUnit { get; } = ElectricChargeUnit.Coulomb; /// /// Represents the largest possible value of ElectricCharge /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, BaseUnit); + public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricCharge /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, BaseUnit); + public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -143,7 +143,7 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Coulomb. /// - public static ElectricCharge Zero { get; } = new ElectricCharge(0, BaseUnit); + public static ElectricCharge Zero { get; } = new ElectricCharge(0, ConversionBaseUnit); #endregion @@ -157,7 +157,7 @@ public ElectricCharge(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricChargeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricChargeUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -725,7 +725,7 @@ private double GetValueInBaseUnit() internal ElectricCharge ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCharge(baseUnitValue, BaseUnit); + return new ElectricCharge(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricChargeUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 5be23b40c2..7e2c2b260e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -61,7 +61,7 @@ static ElectricChargeDensity() new UnitInfo[] { new UnitInfo(ElectricChargeDensityUnit.CoulombPerCubicMeter, "CoulombsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricChargeDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricChargeDensity); } /// @@ -111,19 +111,19 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// The base unit of ElectricChargeDensity, which is CoulombPerCubicMeter. All conversions go via this value. /// - public static ElectricChargeDensityUnit BaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; + public static ElectricChargeDensityUnit ConversionBaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; /// /// Represents the largest possible value of ElectricChargeDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, BaseUnit); + public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricChargeDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, BaseUnit); + public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerCubicMeter. /// - public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, BaseUnit); + public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricChargeDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal ElectricChargeDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricChargeDensity(baseUnitValue, BaseUnit); + return new ElectricChargeDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricChargeDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 2e3908e2bb..7889ce1975 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -63,7 +63,7 @@ static ElectricConductance() new UnitInfo(ElectricConductanceUnit.Millisiemens, "Millisiemens", BaseUnits.Undefined), new UnitInfo(ElectricConductanceUnit.Siemens, "Siemens", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductance); } /// @@ -113,19 +113,19 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// The base unit of ElectricConductance, which is Siemens. All conversions go via this value. /// - public static ElectricConductanceUnit BaseUnit { get; } = ElectricConductanceUnit.Siemens; + public static ElectricConductanceUnit ConversionBaseUnit { get; } = ElectricConductanceUnit.Siemens; /// /// Represents the largest possible value of ElectricConductance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, BaseUnit); + public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricConductance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, BaseUnit); + public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. /// - public static ElectricConductance Zero { get; } = new ElectricConductance(0, BaseUnit); + public static ElectricConductance Zero { get; } = new ElectricConductance(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public ElectricConductance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricConductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricConductanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -693,7 +693,7 @@ private double GetValueInBaseUnit() internal ElectricConductance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricConductance(baseUnitValue, BaseUnit); + return new ElectricConductance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricConductanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 510d8cf461..4971dba570 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -63,7 +63,7 @@ static ElectricConductivity() new UnitInfo(ElectricConductivityUnit.SiemensPerInch, "SiemensPerInch", BaseUnits.Undefined), new UnitInfo(ElectricConductivityUnit.SiemensPerMeter, "SiemensPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductivity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductivity); } /// @@ -113,19 +113,19 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// The base unit of ElectricConductivity, which is SiemensPerMeter. All conversions go via this value. /// - public static ElectricConductivityUnit BaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; + public static ElectricConductivityUnit ConversionBaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; /// /// Represents the largest possible value of ElectricConductivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, BaseUnit); + public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricConductivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, BaseUnit); + public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit SiemensPerMeter. /// - public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, BaseUnit); + public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public ElectricConductivity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricConductivityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -693,7 +693,7 @@ private double GetValueInBaseUnit() internal ElectricConductivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricConductivity(baseUnitValue, BaseUnit); + return new ElectricConductivity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricConductivityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index b799cadf1d..0bfc735436 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -65,7 +65,7 @@ static ElectricCurrent() new UnitInfo(ElectricCurrentUnit.Nanoampere, "Nanoamperes", BaseUnits.Undefined), new UnitInfo(ElectricCurrentUnit.Picoampere, "Picoamperes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrent); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrent); } /// @@ -115,19 +115,19 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// The base unit of ElectricCurrent, which is Ampere. All conversions go via this value. /// - public static ElectricCurrentUnit BaseUnit { get; } = ElectricCurrentUnit.Ampere; + public static ElectricCurrentUnit ConversionBaseUnit { get; } = ElectricCurrentUnit.Ampere; /// /// Represents the largest possible value of ElectricCurrent /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, BaseUnit); + public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricCurrent /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, BaseUnit); + public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -143,7 +143,7 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Ampere. /// - public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, BaseUnit); + public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, ConversionBaseUnit); #endregion @@ -157,7 +157,7 @@ public ElectricCurrent(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricCurrentUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricCurrentUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -770,7 +770,7 @@ private double GetValueInBaseUnit() internal ElectricCurrent ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCurrent(baseUnitValue, BaseUnit); + return new ElectricCurrent(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricCurrentUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 04728cb1e4..e52725594e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -63,7 +63,7 @@ static ElectricCurrentDensity() new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareInch, "AmperesPerSquareInch", new BaseUnits(length: LengthUnit.Inch, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareMeter, "AmperesPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentDensity); } /// @@ -113,19 +113,19 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// The base unit of ElectricCurrentDensity, which is AmperePerSquareMeter. All conversions go via this value. /// - public static ElectricCurrentDensityUnit BaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; + public static ElectricCurrentDensityUnit ConversionBaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; /// /// Represents the largest possible value of ElectricCurrentDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, BaseUnit); + public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricCurrentDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, BaseUnit); + public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSquareMeter. /// - public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, BaseUnit); + public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricCurrentDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricCurrentDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -693,7 +693,7 @@ private double GetValueInBaseUnit() internal ElectricCurrentDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCurrentDensity(baseUnitValue, BaseUnit); + return new ElectricCurrentDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricCurrentDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 4fec12a674..a1cf6314b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -61,7 +61,7 @@ static ElectricCurrentGradient() new UnitInfo(ElectricCurrentGradientUnit.AmperePerNanosecond, "AmperesPerNanosecond", new BaseUnits(time: DurationUnit.Nanosecond, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricCurrentGradientUnit.AmperePerSecond, "AmperesPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentGradient); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentGradient); } /// @@ -111,19 +111,19 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// The base unit of ElectricCurrentGradient, which is AmperePerSecond. All conversions go via this value. /// - public static ElectricCurrentGradientUnit BaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; + public static ElectricCurrentGradientUnit ConversionBaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; /// /// Represents the largest possible value of ElectricCurrentGradient /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, BaseUnit); + public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricCurrentGradient /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, BaseUnit); + public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSecond. /// - public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, BaseUnit); + public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricCurrentGradientUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricCurrentGradientUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -706,7 +706,7 @@ private double GetValueInBaseUnit() internal ElectricCurrentGradient ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricCurrentGradient(baseUnitValue, BaseUnit); + return new ElectricCurrentGradient(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricCurrentGradientUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 8f1dc443e9..bcde5e2616 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -61,7 +61,7 @@ static ElectricField() new UnitInfo[] { new UnitInfo(ElectricFieldUnit.VoltPerMeter, "VoltsPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricField); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricField); } /// @@ -111,19 +111,19 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// The base unit of ElectricField, which is VoltPerMeter. All conversions go via this value. /// - public static ElectricFieldUnit BaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; + public static ElectricFieldUnit ConversionBaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; /// /// Represents the largest possible value of ElectricField /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, BaseUnit); + public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricField /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, BaseUnit); + public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerMeter. /// - public static ElectricField Zero { get; } = new ElectricField(0, BaseUnit); + public static ElectricField Zero { get; } = new ElectricField(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public ElectricField(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricFieldUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal ElectricField ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricField(baseUnitValue, BaseUnit); + return new ElectricField(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricFieldUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index c033bd06d4..9cadf2f1eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -64,7 +64,7 @@ static ElectricInductance() new UnitInfo(ElectricInductanceUnit.Millihenry, "Millihenries", BaseUnits.Undefined), new UnitInfo(ElectricInductanceUnit.Nanohenry, "Nanohenries", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricInductance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricInductance); } /// @@ -114,19 +114,19 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// The base unit of ElectricInductance, which is Henry. All conversions go via this value. /// - public static ElectricInductanceUnit BaseUnit { get; } = ElectricInductanceUnit.Henry; + public static ElectricInductanceUnit ConversionBaseUnit { get; } = ElectricInductanceUnit.Henry; /// /// Represents the largest possible value of ElectricInductance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, BaseUnit); + public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricInductance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, BaseUnit); + public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -142,7 +142,7 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Henry. /// - public static ElectricInductance Zero { get; } = new ElectricInductance(0, BaseUnit); + public static ElectricInductance Zero { get; } = new ElectricInductance(0, ConversionBaseUnit); #endregion @@ -156,7 +156,7 @@ public ElectricInductance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricInductanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricInductanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -709,7 +709,7 @@ private double GetValueInBaseUnit() internal ElectricInductance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricInductance(baseUnitValue, BaseUnit); + return new ElectricInductance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricInductanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3afcdacee7..fc0c8c8e2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -62,7 +62,7 @@ static ElectricPotential() new UnitInfo(ElectricPotentialUnit.Millivolt, "Millivolts", BaseUnits.Undefined), new UnitInfo(ElectricPotentialUnit.Volt, "Volts", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotential); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotential); } /// @@ -112,19 +112,19 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// The base unit of ElectricPotential, which is Volt. All conversions go via this value. /// - public static ElectricPotentialUnit BaseUnit { get; } = ElectricPotentialUnit.Volt; + public static ElectricPotentialUnit ConversionBaseUnit { get; } = ElectricPotentialUnit.Volt; /// /// Represents the largest possible value of ElectricPotential /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, BaseUnit); + public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricPotential /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, BaseUnit); + public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -140,7 +140,7 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Volt. /// - public static ElectricPotential Zero { get; } = new ElectricPotential(0, BaseUnit); + public static ElectricPotential Zero { get; } = new ElectricPotential(0, ConversionBaseUnit); #endregion @@ -154,7 +154,7 @@ public ElectricPotential(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricPotentialUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricPotentialUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -722,7 +722,7 @@ private double GetValueInBaseUnit() internal ElectricPotential ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotential(baseUnitValue, BaseUnit); + return new ElectricPotential(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricPotentialUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 312b9f4968..5af9190065 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -62,7 +62,7 @@ static ElectricPotentialAc() new UnitInfo(ElectricPotentialAcUnit.MillivoltAc, "MillivoltsAc", BaseUnits.Undefined), new UnitInfo(ElectricPotentialAcUnit.VoltAc, "VoltsAc", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialAc); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialAc); } /// @@ -112,19 +112,19 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// The base unit of ElectricPotentialAc, which is VoltAc. All conversions go via this value. /// - public static ElectricPotentialAcUnit BaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; + public static ElectricPotentialAcUnit ConversionBaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; /// /// Represents the largest possible value of ElectricPotentialAc /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, BaseUnit); + public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricPotentialAc /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, BaseUnit); + public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -140,7 +140,7 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltAc. /// - public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, BaseUnit); + public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, ConversionBaseUnit); #endregion @@ -154,7 +154,7 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricPotentialAcUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricPotentialAcUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -722,7 +722,7 @@ private double GetValueInBaseUnit() internal ElectricPotentialAc ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotentialAc(baseUnitValue, BaseUnit); + return new ElectricPotentialAc(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricPotentialAcUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 703973f8d7..0ccbf03273 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -77,7 +77,7 @@ static ElectricPotentialChangeRate() new UnitInfo(ElectricPotentialChangeRateUnit.VoltPerMinute, "VoltsPerMinutes", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Minute, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricPotentialChangeRateUnit.VoltPerSecond, "VoltsPerSeconds", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialChangeRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialChangeRate); } /// @@ -127,19 +127,19 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// The base unit of ElectricPotentialChangeRate, which is VoltPerSecond. All conversions go via this value. /// - public static ElectricPotentialChangeRateUnit BaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; + public static ElectricPotentialChangeRateUnit ConversionBaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; /// /// Represents the largest possible value of ElectricPotentialChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, BaseUnit); + public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricPotentialChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, BaseUnit); + public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -155,7 +155,7 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerSecond. /// - public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, BaseUnit); + public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, ConversionBaseUnit); #endregion @@ -169,7 +169,7 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricPotentialChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricPotentialChangeRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -962,7 +962,7 @@ private double GetValueInBaseUnit() internal ElectricPotentialChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotentialChangeRate(baseUnitValue, BaseUnit); + return new ElectricPotentialChangeRate(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricPotentialChangeRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index f46630a1ec..79d7799ff4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -62,7 +62,7 @@ static ElectricPotentialDc() new UnitInfo(ElectricPotentialDcUnit.MillivoltDc, "MillivoltsDc", BaseUnits.Undefined), new UnitInfo(ElectricPotentialDcUnit.VoltDc, "VoltsDc", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialDc); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialDc); } /// @@ -112,19 +112,19 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// The base unit of ElectricPotentialDc, which is VoltDc. All conversions go via this value. /// - public static ElectricPotentialDcUnit BaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; + public static ElectricPotentialDcUnit ConversionBaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; /// /// Represents the largest possible value of ElectricPotentialDc /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, BaseUnit); + public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricPotentialDc /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, BaseUnit); + public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -140,7 +140,7 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltDc. /// - public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, BaseUnit); + public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, ConversionBaseUnit); #endregion @@ -154,7 +154,7 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricPotentialDcUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricPotentialDcUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -722,7 +722,7 @@ private double GetValueInBaseUnit() internal ElectricPotentialDc ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricPotentialDc(baseUnitValue, BaseUnit); + return new ElectricPotentialDc(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricPotentialDcUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 07f4137d6a..fd399ceaf6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -63,7 +63,7 @@ static ElectricResistance() new UnitInfo(ElectricResistanceUnit.Milliohm, "Milliohms", BaseUnits.Undefined), new UnitInfo(ElectricResistanceUnit.Ohm, "Ohms", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistance); } /// @@ -113,19 +113,19 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// The base unit of ElectricResistance, which is Ohm. All conversions go via this value. /// - public static ElectricResistanceUnit BaseUnit { get; } = ElectricResistanceUnit.Ohm; + public static ElectricResistanceUnit ConversionBaseUnit { get; } = ElectricResistanceUnit.Ohm; /// /// Represents the largest possible value of ElectricResistance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, BaseUnit); + public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricResistance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, BaseUnit); + public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Ohm. /// - public static ElectricResistance Zero { get; } = new ElectricResistance(0, BaseUnit); + public static ElectricResistance Zero { get; } = new ElectricResistance(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public ElectricResistance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricResistanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -738,7 +738,7 @@ private double GetValueInBaseUnit() internal ElectricResistance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricResistance(baseUnitValue, BaseUnit); + return new ElectricResistance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricResistanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index bb3c7e0ea5..bdd15e68c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -74,7 +74,7 @@ static ElectricResistivity() new UnitInfo(ElectricResistivityUnit.PicoohmCentimeter, "PicoohmsCentimeter", BaseUnits.Undefined), new UnitInfo(ElectricResistivityUnit.PicoohmMeter, "PicoohmMeters", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistivity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistivity); } /// @@ -124,19 +124,19 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// The base unit of ElectricResistivity, which is OhmMeter. All conversions go via this value. /// - public static ElectricResistivityUnit BaseUnit { get; } = ElectricResistivityUnit.OhmMeter; + public static ElectricResistivityUnit ConversionBaseUnit { get; } = ElectricResistivityUnit.OhmMeter; /// /// Represents the largest possible value of ElectricResistivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, BaseUnit); + public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricResistivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, BaseUnit); + public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -152,7 +152,7 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit OhmMeter. /// - public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, BaseUnit); + public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, ConversionBaseUnit); #endregion @@ -166,7 +166,7 @@ public ElectricResistivity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricResistivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricResistivityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -869,7 +869,7 @@ private double GetValueInBaseUnit() internal ElectricResistivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricResistivity(baseUnitValue, BaseUnit); + return new ElectricResistivity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricResistivityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 418979c96b..0795641d97 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -63,7 +63,7 @@ static ElectricSurfaceChargeDensity() new UnitInfo(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, "CoulombsPerSquareInch", new BaseUnits(length: LengthUnit.Inch, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, "CoulombsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricSurfaceChargeDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricSurfaceChargeDensity); } /// @@ -113,19 +113,19 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// The base unit of ElectricSurfaceChargeDensity, which is CoulombPerSquareMeter. All conversions go via this value. /// - public static ElectricSurfaceChargeDensityUnit BaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; + public static ElectricSurfaceChargeDensityUnit ConversionBaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; /// /// Represents the largest possible value of ElectricSurfaceChargeDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, BaseUnit); + public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ElectricSurfaceChargeDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, BaseUnit); + public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerSquareMeter. /// - public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, BaseUnit); + public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ElectricSurfaceChargeDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ElectricSurfaceChargeDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -693,7 +693,7 @@ private double GetValueInBaseUnit() internal ElectricSurfaceChargeDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ElectricSurfaceChargeDensity(baseUnitValue, BaseUnit); + return new ElectricSurfaceChargeDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index b19927be1e..485fad71d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -93,7 +93,7 @@ static Energy() new UnitInfo(EnergyUnit.WattDay, "WattDays", BaseUnits.Undefined), new UnitInfo(EnergyUnit.WattHour, "WattHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Energy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Energy); } /// @@ -143,19 +143,19 @@ public Energy(double value, UnitSystem unitSystem) /// /// The base unit of Energy, which is Joule. All conversions go via this value. /// - public static EnergyUnit BaseUnit { get; } = EnergyUnit.Joule; + public static EnergyUnit ConversionBaseUnit { get; } = EnergyUnit.Joule; /// /// Represents the largest possible value of Energy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Energy MaxValue { get; } = new Energy(double.MaxValue, BaseUnit); + public static Energy MaxValue { get; } = new Energy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Energy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Energy MinValue { get; } = new Energy(double.MinValue, BaseUnit); + public static Energy MinValue { get; } = new Energy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -171,7 +171,7 @@ public Energy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Joule. /// - public static Energy Zero { get; } = new Energy(0, BaseUnit); + public static Energy Zero { get; } = new Energy(0, ConversionBaseUnit); #endregion @@ -185,7 +185,7 @@ public Energy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public EnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public EnergyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1218,7 +1218,7 @@ private double GetValueInBaseUnit() internal Energy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Energy(baseUnitValue, BaseUnit); + return new Energy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(EnergyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index f1a32e356d..def9a8a314 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -64,7 +64,7 @@ static Entropy() new UnitInfo(EntropyUnit.KilojoulePerKelvin, "KilojoulesPerKelvin", BaseUnits.Undefined), new UnitInfo(EntropyUnit.MegajoulePerKelvin, "MegajoulesPerKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Entropy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Entropy); } /// @@ -114,19 +114,19 @@ public Entropy(double value, UnitSystem unitSystem) /// /// The base unit of Entropy, which is JoulePerKelvin. All conversions go via this value. /// - public static EntropyUnit BaseUnit { get; } = EntropyUnit.JoulePerKelvin; + public static EntropyUnit ConversionBaseUnit { get; } = EntropyUnit.JoulePerKelvin; /// /// Represents the largest possible value of Entropy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, BaseUnit); + public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Entropy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Entropy MinValue { get; } = new Entropy(double.MinValue, BaseUnit); + public static Entropy MinValue { get; } = new Entropy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -142,7 +142,7 @@ public Entropy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKelvin. /// - public static Entropy Zero { get; } = new Entropy(0, BaseUnit); + public static Entropy Zero { get; } = new Entropy(0, ConversionBaseUnit); #endregion @@ -156,7 +156,7 @@ public Entropy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public EntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public EntropyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -754,7 +754,7 @@ private double GetValueInBaseUnit() internal Entropy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Entropy(baseUnitValue, BaseUnit); + return new Entropy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(EntropyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 54d04e2e3c..36c6268d86 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -72,7 +72,7 @@ static Force() new UnitInfo(ForceUnit.ShortTonForce, "ShortTonsForce", BaseUnits.Undefined), new UnitInfo(ForceUnit.TonneForce, "TonnesForce", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Force); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Force); } /// @@ -122,19 +122,19 @@ public Force(double value, UnitSystem unitSystem) /// /// The base unit of Force, which is Newton. All conversions go via this value. /// - public static ForceUnit BaseUnit { get; } = ForceUnit.Newton; + public static ForceUnit ConversionBaseUnit { get; } = ForceUnit.Newton; /// /// Represents the largest possible value of Force /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Force MaxValue { get; } = new Force(double.MaxValue, BaseUnit); + public static Force MaxValue { get; } = new Force(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Force /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Force MinValue { get; } = new Force(double.MinValue, BaseUnit); + public static Force MinValue { get; } = new Force(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -150,7 +150,7 @@ public Force(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Newton. /// - public static Force Zero { get; } = new Force(0, BaseUnit); + public static Force Zero { get; } = new Force(0, ConversionBaseUnit); #endregion @@ -164,7 +164,7 @@ public Force(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ForceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ForceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -882,7 +882,7 @@ private double GetValueInBaseUnit() internal Force ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Force(baseUnitValue, BaseUnit); + return new Force(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ForceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 86d4c8bbc4..c179c0a94b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -72,7 +72,7 @@ static ForceChangeRate() new UnitInfo(ForceChangeRateUnit.PoundForcePerMinute, "PoundsForcePerMinute", BaseUnits.Undefined), new UnitInfo(ForceChangeRateUnit.PoundForcePerSecond, "PoundsForcePerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ForceChangeRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ForceChangeRate); } /// @@ -122,19 +122,19 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// The base unit of ForceChangeRate, which is NewtonPerSecond. All conversions go via this value. /// - public static ForceChangeRateUnit BaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; + public static ForceChangeRateUnit ConversionBaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; /// /// Represents the largest possible value of ForceChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, BaseUnit); + public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ForceChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, BaseUnit); + public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -150,7 +150,7 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerSecond. /// - public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, BaseUnit); + public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, ConversionBaseUnit); #endregion @@ -164,7 +164,7 @@ public ForceChangeRate(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ForceChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ForceChangeRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -882,7 +882,7 @@ private double GetValueInBaseUnit() internal ForceChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ForceChangeRate(baseUnitValue, BaseUnit); + return new ForceChangeRate(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ForceChangeRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 8160031d62..7a5546bab2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -95,7 +95,7 @@ static ForcePerLength() new UnitInfo(ForcePerLengthUnit.TonneForcePerMeter, "TonnesForcePerMeter", BaseUnits.Undefined), new UnitInfo(ForcePerLengthUnit.TonneForcePerMillimeter, "TonnesForcePerMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ForcePerLength); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ForcePerLength); } /// @@ -145,19 +145,19 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// The base unit of ForcePerLength, which is NewtonPerMeter. All conversions go via this value. /// - public static ForcePerLengthUnit BaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; + public static ForcePerLengthUnit ConversionBaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; /// /// Represents the largest possible value of ForcePerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, BaseUnit); + public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ForcePerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, BaseUnit); + public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -173,7 +173,7 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerMeter. /// - public static ForcePerLength Zero { get; } = new ForcePerLength(0, BaseUnit); + public static ForcePerLength Zero { get; } = new ForcePerLength(0, ConversionBaseUnit); #endregion @@ -187,7 +187,7 @@ public ForcePerLength(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ForcePerLengthUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1250,7 +1250,7 @@ private double GetValueInBaseUnit() internal ForcePerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ForcePerLength(baseUnitValue, BaseUnit); + return new ForcePerLength(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ForcePerLengthUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index b82b7682f2..ce12d0278f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -68,7 +68,7 @@ static Frequency() new UnitInfo(FrequencyUnit.RadianPerSecond, "RadiansPerSecond", BaseUnits.Undefined), new UnitInfo(FrequencyUnit.Terahertz, "Terahertz", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Frequency); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Frequency); } /// @@ -118,19 +118,19 @@ public Frequency(double value, UnitSystem unitSystem) /// /// The base unit of Frequency, which is Hertz. All conversions go via this value. /// - public static FrequencyUnit BaseUnit { get; } = FrequencyUnit.Hertz; + public static FrequencyUnit ConversionBaseUnit { get; } = FrequencyUnit.Hertz; /// /// Represents the largest possible value of Frequency /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, BaseUnit); + public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Frequency /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Frequency MinValue { get; } = new Frequency(double.MinValue, BaseUnit); + public static Frequency MinValue { get; } = new Frequency(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -146,7 +146,7 @@ public Frequency(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Hertz. /// - public static Frequency Zero { get; } = new Frequency(0, BaseUnit); + public static Frequency Zero { get; } = new Frequency(0, ConversionBaseUnit); #endregion @@ -160,7 +160,7 @@ public Frequency(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public FrequencyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public FrequencyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -818,7 +818,7 @@ private double GetValueInBaseUnit() internal Frequency ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Frequency(baseUnitValue, BaseUnit); + return new Frequency(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(FrequencyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index f00c7c8f37..048d9abb70 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -64,7 +64,7 @@ static FuelEfficiency() new UnitInfo(FuelEfficiencyUnit.MilePerUkGallon, "MilesPerUkGallon", BaseUnits.Undefined), new UnitInfo(FuelEfficiencyUnit.MilePerUsGallon, "MilesPerUsGallon", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.FuelEfficiency); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.FuelEfficiency); } /// @@ -114,19 +114,19 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// The base unit of FuelEfficiency, which is LiterPer100Kilometers. All conversions go via this value. /// - public static FuelEfficiencyUnit BaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; + public static FuelEfficiencyUnit ConversionBaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; /// /// Represents the largest possible value of FuelEfficiency /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, BaseUnit); + public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of FuelEfficiency /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, BaseUnit); + public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -142,7 +142,7 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit LiterPer100Kilometers. /// - public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, BaseUnit); + public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, ConversionBaseUnit); #endregion @@ -156,7 +156,7 @@ public FuelEfficiency(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public FuelEfficiencyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public FuelEfficiencyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -709,7 +709,7 @@ private double GetValueInBaseUnit() internal FuelEfficiency ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new FuelEfficiency(baseUnitValue, BaseUnit); + return new FuelEfficiency(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(FuelEfficiencyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 2139a34317..8282c9aeb4 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -75,7 +75,7 @@ static HeatFlux() new UnitInfo(HeatFluxUnit.WattPerSquareInch, "WattsPerSquareInch", BaseUnits.Undefined), new UnitInfo(HeatFluxUnit.WattPerSquareMeter, "WattsPerSquareMeter", new BaseUnits(mass: MassUnit.Kilogram, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.HeatFlux); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.HeatFlux); } /// @@ -125,19 +125,19 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// The base unit of HeatFlux, which is WattPerSquareMeter. All conversions go via this value. /// - public static HeatFluxUnit BaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; + public static HeatFluxUnit ConversionBaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; /// /// Represents the largest possible value of HeatFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, BaseUnit); + public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of HeatFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, BaseUnit); + public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -153,7 +153,7 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. /// - public static HeatFlux Zero { get; } = new HeatFlux(0, BaseUnit); + public static HeatFlux Zero { get; } = new HeatFlux(0, ConversionBaseUnit); #endregion @@ -167,7 +167,7 @@ public HeatFlux(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public HeatFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public HeatFluxUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -930,7 +930,7 @@ private double GetValueInBaseUnit() internal HeatFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new HeatFlux(baseUnitValue, BaseUnit); + return new HeatFlux(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(HeatFluxUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index a16bc127cb..501bd61cf9 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -60,7 +60,7 @@ static HeatTransferCoefficient() new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, "WattsPerSquareMeterCelsius", BaseUnits.Undefined), new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, "WattsPerSquareMeterKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.HeatTransferCoefficient); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.HeatTransferCoefficient); } /// @@ -110,19 +110,19 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// The base unit of HeatTransferCoefficient, which is WattPerSquareMeterKelvin. All conversions go via this value. /// - public static HeatTransferCoefficientUnit BaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; + public static HeatTransferCoefficientUnit ConversionBaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; /// /// Represents the largest possible value of HeatTransferCoefficient /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, BaseUnit); + public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of HeatTransferCoefficient /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, BaseUnit); + public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeterKelvin. /// - public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, BaseUnit); + public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public HeatTransferCoefficientUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public HeatTransferCoefficientUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal HeatTransferCoefficient ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new HeatTransferCoefficient(baseUnitValue, BaseUnit); + return new HeatTransferCoefficient(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(HeatTransferCoefficientUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index c3b01e15e0..a3cbe99325 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -64,7 +64,7 @@ static Illuminance() new UnitInfo(IlluminanceUnit.Megalux, "Megalux", BaseUnits.Undefined), new UnitInfo(IlluminanceUnit.Millilux, "Millilux", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Illuminance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Illuminance); } /// @@ -114,19 +114,19 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// The base unit of Illuminance, which is Lux. All conversions go via this value. /// - public static IlluminanceUnit BaseUnit { get; } = IlluminanceUnit.Lux; + public static IlluminanceUnit ConversionBaseUnit { get; } = IlluminanceUnit.Lux; /// /// Represents the largest possible value of Illuminance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, BaseUnit); + public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Illuminance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, BaseUnit); + public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -142,7 +142,7 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Lux. /// - public static Illuminance Zero { get; } = new Illuminance(0, BaseUnit); + public static Illuminance Zero { get; } = new Illuminance(0, ConversionBaseUnit); #endregion @@ -156,7 +156,7 @@ public Illuminance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public IlluminanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public IlluminanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -709,7 +709,7 @@ private double GetValueInBaseUnit() internal Illuminance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Illuminance(baseUnitValue, BaseUnit); + return new Illuminance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(IlluminanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index cf438f74c5..717ecd92be 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -83,7 +83,7 @@ static Information() new UnitInfo(InformationUnit.Terabit, "Terabits", BaseUnits.Undefined), new UnitInfo(InformationUnit.Terabyte, "Terabytes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Information); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Information); } /// @@ -133,19 +133,19 @@ public Information(decimal value, UnitSystem unitSystem) /// /// The base unit of Information, which is Bit. All conversions go via this value. /// - public static InformationUnit BaseUnit { get; } = InformationUnit.Bit; + public static InformationUnit ConversionBaseUnit { get; } = InformationUnit.Bit; /// /// Represents the largest possible value of Information /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Information MaxValue { get; } = new Information(decimal.MaxValue, BaseUnit); + public static Information MaxValue { get; } = new Information(decimal.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Information /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Information MinValue { get; } = new Information(decimal.MinValue, BaseUnit); + public static Information MinValue { get; } = new Information(decimal.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -161,7 +161,7 @@ public Information(decimal value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Bit. /// - public static Information Zero { get; } = new Information(0, BaseUnit); + public static Information Zero { get; } = new Information(0, ConversionBaseUnit); #endregion @@ -180,7 +180,7 @@ public Information(decimal value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public InformationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public InformationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1063,7 +1063,7 @@ private decimal GetValueInBaseUnit() internal Information ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Information(baseUnitValue, BaseUnit); + return new Information(baseUnitValue, ConversionBaseUnit); } private decimal GetValueAs(InformationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index ef2e4fae9a..dab2a379a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -71,7 +71,7 @@ static Irradiance() new UnitInfo(IrradianceUnit.WattPerSquareCentimeter, "WattsPerSquareCentimeter", BaseUnits.Undefined), new UnitInfo(IrradianceUnit.WattPerSquareMeter, "WattsPerSquareMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Irradiance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Irradiance); } /// @@ -121,19 +121,19 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// The base unit of Irradiance, which is WattPerSquareMeter. All conversions go via this value. /// - public static IrradianceUnit BaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; + public static IrradianceUnit ConversionBaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; /// /// Represents the largest possible value of Irradiance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, BaseUnit); + public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Irradiance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, BaseUnit); + public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -149,7 +149,7 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. /// - public static Irradiance Zero { get; } = new Irradiance(0, BaseUnit); + public static Irradiance Zero { get; } = new Irradiance(0, ConversionBaseUnit); #endregion @@ -163,7 +163,7 @@ public Irradiance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public IrradianceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public IrradianceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -866,7 +866,7 @@ private double GetValueInBaseUnit() internal Irradiance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Irradiance(baseUnitValue, BaseUnit); + return new Irradiance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(IrradianceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index a7a5eb6ad7..f402d6a503 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -67,7 +67,7 @@ static Irradiation() new UnitInfo(IrradiationUnit.MillijoulePerSquareCentimeter, "MillijoulesPerSquareCentimeter", BaseUnits.Undefined), new UnitInfo(IrradiationUnit.WattHourPerSquareMeter, "WattHoursPerSquareMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Irradiation); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Irradiation); } /// @@ -117,19 +117,19 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// The base unit of Irradiation, which is JoulePerSquareMeter. All conversions go via this value. /// - public static IrradiationUnit BaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; + public static IrradiationUnit ConversionBaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; /// /// Represents the largest possible value of Irradiation /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, BaseUnit); + public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Irradiation /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, BaseUnit); + public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -145,7 +145,7 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerSquareMeter. /// - public static Irradiation Zero { get; } = new Irradiation(0, BaseUnit); + public static Irradiation Zero { get; } = new Irradiation(0, ConversionBaseUnit); #endregion @@ -159,7 +159,7 @@ public Irradiation(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public IrradiationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public IrradiationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -757,7 +757,7 @@ private double GetValueInBaseUnit() internal Irradiation ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Irradiation(baseUnitValue, BaseUnit); + return new Irradiation(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(IrradiationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index e49c80cf31..be8664db8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -69,7 +69,7 @@ static KinematicViscosity() new UnitInfo(KinematicViscosityUnit.SquareMeterPerSecond, "SquareMetersPerSecond", BaseUnits.Undefined), new UnitInfo(KinematicViscosityUnit.Stokes, "Stokes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.KinematicViscosity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.KinematicViscosity); } /// @@ -119,19 +119,19 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// The base unit of KinematicViscosity, which is SquareMeterPerSecond. All conversions go via this value. /// - public static KinematicViscosityUnit BaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; + public static KinematicViscosityUnit ConversionBaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; /// /// Represents the largest possible value of KinematicViscosity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, BaseUnit); + public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of KinematicViscosity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, BaseUnit); + public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -147,7 +147,7 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterPerSecond. /// - public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, BaseUnit); + public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, ConversionBaseUnit); #endregion @@ -161,7 +161,7 @@ public KinematicViscosity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public KinematicViscosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public KinematicViscosityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -789,7 +789,7 @@ private double GetValueInBaseUnit() internal KinematicViscosity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new KinematicViscosity(baseUnitValue, BaseUnit); + return new KinematicViscosity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(KinematicViscosityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 56a9bebf13..7ec1eea564 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -58,7 +58,7 @@ static LapseRate() new UnitInfo[] { new UnitInfo(LapseRateUnit.DegreeCelsiusPerKilometer, "DegreesCelciusPerKilometer", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LapseRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LapseRate); } /// @@ -108,19 +108,19 @@ public LapseRate(double value, UnitSystem unitSystem) /// /// The base unit of LapseRate, which is DegreeCelsiusPerKilometer. All conversions go via this value. /// - public static LapseRateUnit BaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; + public static LapseRateUnit ConversionBaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; /// /// Represents the largest possible value of LapseRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, BaseUnit); + public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of LapseRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, BaseUnit); + public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -136,7 +136,7 @@ public LapseRate(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer. /// - public static LapseRate Zero { get; } = new LapseRate(0, BaseUnit); + public static LapseRate Zero { get; } = new LapseRate(0, ConversionBaseUnit); #endregion @@ -150,7 +150,7 @@ public LapseRate(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LapseRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LapseRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -658,7 +658,7 @@ private double GetValueInBaseUnit() internal LapseRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LapseRate(baseUnitValue, BaseUnit); + return new LapseRate(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LapseRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 1f624cab7c..4dbf22ce7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -90,7 +90,7 @@ static Length() new UnitInfo(LengthUnit.UsSurveyFoot, "UsSurveyFeet", new BaseUnits(length: LengthUnit.UsSurveyFoot)), new UnitInfo(LengthUnit.Yard, "Yards", new BaseUnits(length: LengthUnit.Yard)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Length); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Length); } /// @@ -140,19 +140,19 @@ public Length(double value, UnitSystem unitSystem) /// /// The base unit of Length, which is Meter. All conversions go via this value. /// - public static LengthUnit BaseUnit { get; } = LengthUnit.Meter; + public static LengthUnit ConversionBaseUnit { get; } = LengthUnit.Meter; /// /// Represents the largest possible value of Length /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Length MaxValue { get; } = new Length(double.MaxValue, BaseUnit); + public static Length MaxValue { get; } = new Length(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Length /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Length MinValue { get; } = new Length(double.MinValue, BaseUnit); + public static Length MinValue { get; } = new Length(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -168,7 +168,7 @@ public Length(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Meter. /// - public static Length Zero { get; } = new Length(0, BaseUnit); + public static Length Zero { get; } = new Length(0, ConversionBaseUnit); #endregion @@ -182,7 +182,7 @@ public Length(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LengthUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1170,7 +1170,7 @@ private double GetValueInBaseUnit() internal Length ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Length(baseUnitValue, BaseUnit); + return new Length(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LengthUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 41e28629dc..1ddb26a533 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -59,7 +59,7 @@ static Level() new UnitInfo(LevelUnit.Decibel, "Decibels", BaseUnits.Undefined), new UnitInfo(LevelUnit.Neper, "Nepers", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Level); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Level); } /// @@ -109,19 +109,19 @@ public Level(double value, UnitSystem unitSystem) /// /// The base unit of Level, which is Decibel. All conversions go via this value. /// - public static LevelUnit BaseUnit { get; } = LevelUnit.Decibel; + public static LevelUnit ConversionBaseUnit { get; } = LevelUnit.Decibel; /// /// Represents the largest possible value of Level /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Level MaxValue { get; } = new Level(double.MaxValue, BaseUnit); + public static Level MaxValue { get; } = new Level(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Level /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Level MinValue { get; } = new Level(double.MinValue, BaseUnit); + public static Level MinValue { get; } = new Level(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -137,7 +137,7 @@ public Level(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Decibel. /// - public static Level Zero { get; } = new Level(0, BaseUnit); + public static Level Zero { get; } = new Level(0, ConversionBaseUnit); #endregion @@ -151,7 +151,7 @@ public Level(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LevelUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LevelUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -682,7 +682,7 @@ private double GetValueInBaseUnit() internal Level ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Level(baseUnitValue, BaseUnit); + return new Level(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LevelUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 832fa889ee..5f97682ea7 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -74,7 +74,7 @@ static LinearDensity() new UnitInfo(LinearDensityUnit.PoundPerFoot, "PoundsPerFoot", BaseUnits.Undefined), new UnitInfo(LinearDensityUnit.PoundPerInch, "PoundsPerInch", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LinearDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LinearDensity); } /// @@ -124,19 +124,19 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// The base unit of LinearDensity, which is KilogramPerMeter. All conversions go via this value. /// - public static LinearDensityUnit BaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; + public static LinearDensityUnit ConversionBaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; /// /// Represents the largest possible value of LinearDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, BaseUnit); + public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of LinearDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, BaseUnit); + public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -152,7 +152,7 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMeter. /// - public static LinearDensity Zero { get; } = new LinearDensity(0, BaseUnit); + public static LinearDensity Zero { get; } = new LinearDensity(0, ConversionBaseUnit); #endregion @@ -166,7 +166,7 @@ public LinearDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LinearDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LinearDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -869,7 +869,7 @@ private double GetValueInBaseUnit() internal LinearDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LinearDensity(baseUnitValue, BaseUnit); + return new LinearDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LinearDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 913b09383b..6b69739dc4 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -85,7 +85,7 @@ static LinearPowerDensity() new UnitInfo(LinearPowerDensityUnit.WattPerMeter, "WattsPerMeter", BaseUnits.Undefined), new UnitInfo(LinearPowerDensityUnit.WattPerMillimeter, "WattsPerMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LinearPowerDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LinearPowerDensity); } /// @@ -135,19 +135,19 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// The base unit of LinearPowerDensity, which is WattPerMeter. All conversions go via this value. /// - public static LinearPowerDensityUnit BaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; + public static LinearPowerDensityUnit ConversionBaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; /// /// Represents the largest possible value of LinearPowerDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, BaseUnit); + public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of LinearPowerDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, BaseUnit); + public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -163,7 +163,7 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeter. /// - public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, BaseUnit); + public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, ConversionBaseUnit); #endregion @@ -177,7 +177,7 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LinearPowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LinearPowerDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1045,7 +1045,7 @@ private double GetValueInBaseUnit() internal LinearPowerDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LinearPowerDensity(baseUnitValue, BaseUnit); + return new LinearPowerDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LinearPowerDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 7448398ec7..873bf7d4e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -74,7 +74,7 @@ static Luminosity() new UnitInfo(LuminosityUnit.Terawatt, "Terawatts", BaseUnits.Undefined), new UnitInfo(LuminosityUnit.Watt, "Watts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Luminosity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Luminosity); } /// @@ -124,19 +124,19 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// The base unit of Luminosity, which is Watt. All conversions go via this value. /// - public static LuminosityUnit BaseUnit { get; } = LuminosityUnit.Watt; + public static LuminosityUnit ConversionBaseUnit { get; } = LuminosityUnit.Watt; /// /// Represents the largest possible value of Luminosity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, BaseUnit); + public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Luminosity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, BaseUnit); + public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -152,7 +152,7 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Watt. /// - public static Luminosity Zero { get; } = new Luminosity(0, BaseUnit); + public static Luminosity Zero { get; } = new Luminosity(0, ConversionBaseUnit); #endregion @@ -166,7 +166,7 @@ public Luminosity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LuminosityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LuminosityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -869,7 +869,7 @@ private double GetValueInBaseUnit() internal Luminosity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Luminosity(baseUnitValue, BaseUnit); + return new Luminosity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LuminosityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index c728d71999..28640f3969 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -61,7 +61,7 @@ static LuminousFlux() new UnitInfo[] { new UnitInfo(LuminousFluxUnit.Lumen, "Lumens", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LuminousFlux); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LuminousFlux); } /// @@ -111,19 +111,19 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// The base unit of LuminousFlux, which is Lumen. All conversions go via this value. /// - public static LuminousFluxUnit BaseUnit { get; } = LuminousFluxUnit.Lumen; + public static LuminousFluxUnit ConversionBaseUnit { get; } = LuminousFluxUnit.Lumen; /// /// Represents the largest possible value of LuminousFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, BaseUnit); + public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of LuminousFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, BaseUnit); + public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Lumen. /// - public static LuminousFlux Zero { get; } = new LuminousFlux(0, BaseUnit); + public static LuminousFlux Zero { get; } = new LuminousFlux(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public LuminousFlux(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LuminousFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LuminousFluxUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal LuminousFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LuminousFlux(baseUnitValue, BaseUnit); + return new LuminousFlux(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LuminousFluxUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index cf848bc96c..0c4e2043b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -61,7 +61,7 @@ static LuminousIntensity() new UnitInfo[] { new UnitInfo(LuminousIntensityUnit.Candela, "Candela", new BaseUnits(luminousIntensity: LuminousIntensityUnit.Candela)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LuminousIntensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LuminousIntensity); } /// @@ -111,19 +111,19 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// The base unit of LuminousIntensity, which is Candela. All conversions go via this value. /// - public static LuminousIntensityUnit BaseUnit { get; } = LuminousIntensityUnit.Candela; + public static LuminousIntensityUnit ConversionBaseUnit { get; } = LuminousIntensityUnit.Candela; /// /// Represents the largest possible value of LuminousIntensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, BaseUnit); + public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of LuminousIntensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, BaseUnit); + public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Candela. /// - public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, BaseUnit); + public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public LuminousIntensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public LuminousIntensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public LuminousIntensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal LuminousIntensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new LuminousIntensity(baseUnitValue, BaseUnit); + return new LuminousIntensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(LuminousIntensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index a5ee7c2a80..65f952761f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -66,7 +66,7 @@ static MagneticField() new UnitInfo(MagneticFieldUnit.Nanotesla, "Nanoteslas", BaseUnits.Undefined), new UnitInfo(MagneticFieldUnit.Tesla, "Teslas", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MagneticField); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MagneticField); } /// @@ -116,19 +116,19 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// The base unit of MagneticField, which is Tesla. All conversions go via this value. /// - public static MagneticFieldUnit BaseUnit { get; } = MagneticFieldUnit.Tesla; + public static MagneticFieldUnit ConversionBaseUnit { get; } = MagneticFieldUnit.Tesla; /// /// Represents the largest possible value of MagneticField /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, BaseUnit); + public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MagneticField /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, BaseUnit); + public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -144,7 +144,7 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Tesla. /// - public static MagneticField Zero { get; } = new MagneticField(0, BaseUnit); + public static MagneticField Zero { get; } = new MagneticField(0, ConversionBaseUnit); #endregion @@ -158,7 +158,7 @@ public MagneticField(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MagneticFieldUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MagneticFieldUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -741,7 +741,7 @@ private double GetValueInBaseUnit() internal MagneticField ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MagneticField(baseUnitValue, BaseUnit); + return new MagneticField(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MagneticFieldUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 8787207610..3406fc6c83 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -61,7 +61,7 @@ static MagneticFlux() new UnitInfo[] { new UnitInfo(MagneticFluxUnit.Weber, "Webers", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MagneticFlux); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MagneticFlux); } /// @@ -111,19 +111,19 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// The base unit of MagneticFlux, which is Weber. All conversions go via this value. /// - public static MagneticFluxUnit BaseUnit { get; } = MagneticFluxUnit.Weber; + public static MagneticFluxUnit ConversionBaseUnit { get; } = MagneticFluxUnit.Weber; /// /// Represents the largest possible value of MagneticFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, BaseUnit); + public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MagneticFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, BaseUnit); + public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Weber. /// - public static MagneticFlux Zero { get; } = new MagneticFlux(0, BaseUnit); + public static MagneticFlux Zero { get; } = new MagneticFlux(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public MagneticFlux(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MagneticFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MagneticFluxUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal MagneticFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MagneticFlux(baseUnitValue, BaseUnit); + return new MagneticFlux(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MagneticFluxUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index b5771cbab6..5ce1b918a5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -61,7 +61,7 @@ static Magnetization() new UnitInfo[] { new UnitInfo(MagnetizationUnit.AmperePerMeter, "AmperesPerMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Magnetization); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Magnetization); } /// @@ -111,19 +111,19 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// The base unit of Magnetization, which is AmperePerMeter. All conversions go via this value. /// - public static MagnetizationUnit BaseUnit { get; } = MagnetizationUnit.AmperePerMeter; + public static MagnetizationUnit ConversionBaseUnit { get; } = MagnetizationUnit.AmperePerMeter; /// /// Represents the largest possible value of Magnetization /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, BaseUnit); + public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Magnetization /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, BaseUnit); + public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerMeter. /// - public static Magnetization Zero { get; } = new Magnetization(0, BaseUnit); + public static Magnetization Zero { get; } = new Magnetization(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public Magnetization(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MagnetizationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MagnetizationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal Magnetization ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Magnetization(baseUnitValue, BaseUnit); + return new Magnetization(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MagnetizationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index a6928331a4..7f1ccc263e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -82,7 +82,7 @@ static Mass() new UnitInfo(MassUnit.Stone, "Stone", new BaseUnits(mass: MassUnit.Stone)), new UnitInfo(MassUnit.Tonne, "Tonnes", new BaseUnits(mass: MassUnit.Tonne)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Mass); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Mass); } /// @@ -132,19 +132,19 @@ public Mass(double value, UnitSystem unitSystem) /// /// The base unit of Mass, which is Kilogram. All conversions go via this value. /// - public static MassUnit BaseUnit { get; } = MassUnit.Kilogram; + public static MassUnit ConversionBaseUnit { get; } = MassUnit.Kilogram; /// /// Represents the largest possible value of Mass /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Mass MaxValue { get; } = new Mass(double.MaxValue, BaseUnit); + public static Mass MaxValue { get; } = new Mass(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Mass /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Mass MinValue { get; } = new Mass(double.MinValue, BaseUnit); + public static Mass MinValue { get; } = new Mass(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -160,7 +160,7 @@ public Mass(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Kilogram. /// - public static Mass Zero { get; } = new Mass(0, BaseUnit); + public static Mass Zero { get; } = new Mass(0, ConversionBaseUnit); #endregion @@ -174,7 +174,7 @@ public Mass(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MassUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MassUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1042,7 +1042,7 @@ private double GetValueInBaseUnit() internal Mass ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Mass(baseUnitValue, BaseUnit); + return new Mass(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MassUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 7f4d40bcca..f8397e0070 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -109,7 +109,7 @@ static MassConcentration() new UnitInfo(MassConcentrationUnit.TonnePerCubicMeter, "TonnesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Tonne)), new UnitInfo(MassConcentrationUnit.TonnePerCubicMillimeter, "TonnesPerCubicMillimeter", new BaseUnits(length: LengthUnit.Millimeter, mass: MassUnit.Tonne)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassConcentration); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassConcentration); } /// @@ -159,19 +159,19 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// The base unit of MassConcentration, which is KilogramPerCubicMeter. All conversions go via this value. /// - public static MassConcentrationUnit BaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; + public static MassConcentrationUnit ConversionBaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; /// /// Represents the largest possible value of MassConcentration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, BaseUnit); + public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MassConcentration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, BaseUnit); + public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -187,7 +187,7 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. /// - public static MassConcentration Zero { get; } = new MassConcentration(0, BaseUnit); + public static MassConcentration Zero { get; } = new MassConcentration(0, ConversionBaseUnit); #endregion @@ -201,7 +201,7 @@ public MassConcentration(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MassConcentrationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MassConcentrationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1429,7 +1429,7 @@ private double GetValueInBaseUnit() internal MassConcentration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassConcentration(baseUnitValue, BaseUnit); + return new MassConcentration(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MassConcentrationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 374bbfc3ea..e685e75330 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -90,7 +90,7 @@ static MassFlow() new UnitInfo(MassFlowUnit.TonnePerDay, "TonnesPerDay", BaseUnits.Undefined), new UnitInfo(MassFlowUnit.TonnePerHour, "TonnesPerHour", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassFlow); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassFlow); } /// @@ -140,19 +140,19 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// The base unit of MassFlow, which is GramPerSecond. All conversions go via this value. /// - public static MassFlowUnit BaseUnit { get; } = MassFlowUnit.GramPerSecond; + public static MassFlowUnit ConversionBaseUnit { get; } = MassFlowUnit.GramPerSecond; /// /// Represents the largest possible value of MassFlow /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, BaseUnit); + public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MassFlow /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, BaseUnit); + public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -168,7 +168,7 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit GramPerSecond. /// - public static MassFlow Zero { get; } = new MassFlow(0, BaseUnit); + public static MassFlow Zero { get; } = new MassFlow(0, ConversionBaseUnit); #endregion @@ -182,7 +182,7 @@ public MassFlow(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MassFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MassFlowUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1170,7 +1170,7 @@ private double GetValueInBaseUnit() internal MassFlow ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassFlow(baseUnitValue, BaseUnit); + return new MassFlow(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MassFlowUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 2751d6a4d8..b8d9631d52 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -69,7 +69,7 @@ static MassFlux() new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMeter, "KilogramsPerSecondPerSquareMeter", BaseUnits.Undefined), new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, "KilogramsPerSecondPerSquareMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassFlux); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassFlux); } /// @@ -119,19 +119,19 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// The base unit of MassFlux, which is KilogramPerSecondPerSquareMeter. All conversions go via this value. /// - public static MassFluxUnit BaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; + public static MassFluxUnit ConversionBaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; /// /// Represents the largest possible value of MassFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, BaseUnit); + public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MassFlux /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, BaseUnit); + public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -147,7 +147,7 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter. /// - public static MassFlux Zero { get; } = new MassFlux(0, BaseUnit); + public static MassFlux Zero { get; } = new MassFlux(0, ConversionBaseUnit); #endregion @@ -161,7 +161,7 @@ public MassFlux(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MassFluxUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MassFluxUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -834,7 +834,7 @@ private double GetValueInBaseUnit() internal MassFlux ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassFlux(baseUnitValue, BaseUnit); + return new MassFlux(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MassFluxUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 559f282e08..9eb6c3dfc9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -84,7 +84,7 @@ static MassFraction() new UnitInfo(MassFractionUnit.PartPerTrillion, "PartsPerTrillion", BaseUnits.Undefined), new UnitInfo(MassFractionUnit.Percent, "Percent", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassFraction); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassFraction); } /// @@ -134,19 +134,19 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// The base unit of MassFraction, which is DecimalFraction. All conversions go via this value. /// - public static MassFractionUnit BaseUnit { get; } = MassFractionUnit.DecimalFraction; + public static MassFractionUnit ConversionBaseUnit { get; } = MassFractionUnit.DecimalFraction; /// /// Represents the largest possible value of MassFraction /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, BaseUnit); + public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MassFraction /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, BaseUnit); + public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -162,7 +162,7 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. /// - public static MassFraction Zero { get; } = new MassFraction(0, BaseUnit); + public static MassFraction Zero { get; } = new MassFraction(0, ConversionBaseUnit); #endregion @@ -176,7 +176,7 @@ public MassFraction(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MassFractionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MassFractionUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1029,7 +1029,7 @@ private double GetValueInBaseUnit() internal MassFraction ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassFraction(baseUnitValue, BaseUnit); + return new MassFraction(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MassFractionUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 7332ab643b..f06c03fb23 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -85,7 +85,7 @@ static MassMomentOfInertia() new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMeter, "TonneSquareMeters", BaseUnits.Undefined), new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMilimeter, "TonneSquareMilimeters", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassMomentOfInertia); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassMomentOfInertia); } /// @@ -135,19 +135,19 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// The base unit of MassMomentOfInertia, which is KilogramSquareMeter. All conversions go via this value. /// - public static MassMomentOfInertiaUnit BaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; + public static MassMomentOfInertiaUnit ConversionBaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; /// /// Represents the largest possible value of MassMomentOfInertia /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, BaseUnit); + public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MassMomentOfInertia /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, BaseUnit); + public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -163,7 +163,7 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramSquareMeter. /// - public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, BaseUnit); + public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, ConversionBaseUnit); #endregion @@ -177,7 +177,7 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MassMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MassMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1090,7 +1090,7 @@ private double GetValueInBaseUnit() internal MassMomentOfInertia ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MassMomentOfInertia(baseUnitValue, BaseUnit); + return new MassMomentOfInertia(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MassMomentOfInertiaUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index fb0076783f..6fcce874e3 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -60,7 +60,7 @@ static MolarEnergy() new UnitInfo(MolarEnergyUnit.KilojoulePerMole, "KilojoulesPerMole", BaseUnits.Undefined), new UnitInfo(MolarEnergyUnit.MegajoulePerMole, "MegajoulesPerMole", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MolarEnergy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MolarEnergy); } /// @@ -110,19 +110,19 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// The base unit of MolarEnergy, which is JoulePerMole. All conversions go via this value. /// - public static MolarEnergyUnit BaseUnit { get; } = MolarEnergyUnit.JoulePerMole; + public static MolarEnergyUnit ConversionBaseUnit { get; } = MolarEnergyUnit.JoulePerMole; /// /// Represents the largest possible value of MolarEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, BaseUnit); + public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MolarEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, BaseUnit); + public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMole. /// - public static MolarEnergy Zero { get; } = new MolarEnergy(0, BaseUnit); + public static MolarEnergy Zero { get; } = new MolarEnergy(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public MolarEnergy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MolarEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MolarEnergyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal MolarEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MolarEnergy(baseUnitValue, BaseUnit); + return new MolarEnergy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MolarEnergyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index fd570688ef..1f9cce6133 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -60,7 +60,7 @@ static MolarEntropy() new UnitInfo(MolarEntropyUnit.KilojoulePerMoleKelvin, "KilojoulesPerMoleKelvin", BaseUnits.Undefined), new UnitInfo(MolarEntropyUnit.MegajoulePerMoleKelvin, "MegajoulesPerMoleKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MolarEntropy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MolarEntropy); } /// @@ -110,19 +110,19 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// The base unit of MolarEntropy, which is JoulePerMoleKelvin. All conversions go via this value. /// - public static MolarEntropyUnit BaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; + public static MolarEntropyUnit ConversionBaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; /// /// Represents the largest possible value of MolarEntropy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, BaseUnit); + public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MolarEntropy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, BaseUnit); + public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMoleKelvin. /// - public static MolarEntropy Zero { get; } = new MolarEntropy(0, BaseUnit); + public static MolarEntropy Zero { get; } = new MolarEntropy(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public MolarEntropy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MolarEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MolarEntropyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal MolarEntropy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MolarEntropy(baseUnitValue, BaseUnit); + return new MolarEntropy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MolarEntropyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 6b2f8efea1..dd1745680d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -69,7 +69,7 @@ static MolarMass() new UnitInfo(MolarMassUnit.NanogramPerMole, "NanogramsPerMole", BaseUnits.Undefined), new UnitInfo(MolarMassUnit.PoundPerMole, "PoundsPerMole", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MolarMass); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MolarMass); } /// @@ -119,19 +119,19 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// The base unit of MolarMass, which is KilogramPerMole. All conversions go via this value. /// - public static MolarMassUnit BaseUnit { get; } = MolarMassUnit.KilogramPerMole; + public static MolarMassUnit ConversionBaseUnit { get; } = MolarMassUnit.KilogramPerMole; /// /// Represents the largest possible value of MolarMass /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, BaseUnit); + public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of MolarMass /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, BaseUnit); + public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -147,7 +147,7 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMole. /// - public static MolarMass Zero { get; } = new MolarMass(0, BaseUnit); + public static MolarMass Zero { get; } = new MolarMass(0, ConversionBaseUnit); #endregion @@ -161,7 +161,7 @@ public MolarMass(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MolarMassUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MolarMassUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -834,7 +834,7 @@ private double GetValueInBaseUnit() internal MolarMass ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new MolarMass(baseUnitValue, BaseUnit); + return new MolarMass(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MolarMassUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index b6d2a4ceee..741aa1cc56 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -33,7 +33,7 @@ namespace UnitsNet { /// /// - /// Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. + /// Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. /// /// /// https://en.wikipedia.org/wiki/Molar_concentration @@ -68,7 +68,7 @@ static Molarity() new UnitInfo(MolarityUnit.NanomolesPerLiter, "NanomolesPerLiter", BaseUnits.Undefined), new UnitInfo(MolarityUnit.PicomolesPerLiter, "PicomolesPerLiter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Molarity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Molarity); } /// @@ -118,19 +118,19 @@ public Molarity(double value, UnitSystem unitSystem) /// /// The base unit of Molarity, which is MolesPerCubicMeter. All conversions go via this value. /// - public static MolarityUnit BaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; + public static MolarityUnit ConversionBaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; /// /// Represents the largest possible value of Molarity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, BaseUnit); + public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Molarity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Molarity MinValue { get; } = new Molarity(double.MinValue, BaseUnit); + public static Molarity MinValue { get; } = new Molarity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -146,7 +146,7 @@ public Molarity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit MolesPerCubicMeter. /// - public static Molarity Zero { get; } = new Molarity(0, BaseUnit); + public static Molarity Zero { get; } = new Molarity(0, ConversionBaseUnit); #endregion @@ -160,7 +160,7 @@ public Molarity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public MolarityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public MolarityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -773,7 +773,7 @@ private double GetValueInBaseUnit() internal Molarity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Molarity(baseUnitValue, BaseUnit); + return new Molarity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(MolarityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 7e286f2ce0..37ec853f81 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -61,7 +61,7 @@ static Permeability() new UnitInfo[] { new UnitInfo(PermeabilityUnit.HenryPerMeter, "HenriesPerMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Permeability); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Permeability); } /// @@ -111,19 +111,19 @@ public Permeability(double value, UnitSystem unitSystem) /// /// The base unit of Permeability, which is HenryPerMeter. All conversions go via this value. /// - public static PermeabilityUnit BaseUnit { get; } = PermeabilityUnit.HenryPerMeter; + public static PermeabilityUnit ConversionBaseUnit { get; } = PermeabilityUnit.HenryPerMeter; /// /// Represents the largest possible value of Permeability /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, BaseUnit); + public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Permeability /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permeability MinValue { get; } = new Permeability(double.MinValue, BaseUnit); + public static Permeability MinValue { get; } = new Permeability(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public Permeability(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit HenryPerMeter. /// - public static Permeability Zero { get; } = new Permeability(0, BaseUnit); + public static Permeability Zero { get; } = new Permeability(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public Permeability(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PermeabilityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PermeabilityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal Permeability ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Permeability(baseUnitValue, BaseUnit); + return new Permeability(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(PermeabilityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a3bbbd52d7..eb6f6a6688 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -61,7 +61,7 @@ static Permittivity() new UnitInfo[] { new UnitInfo(PermittivityUnit.FaradPerMeter, "FaradsPerMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Permittivity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Permittivity); } /// @@ -111,19 +111,19 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// The base unit of Permittivity, which is FaradPerMeter. All conversions go via this value. /// - public static PermittivityUnit BaseUnit { get; } = PermittivityUnit.FaradPerMeter; + public static PermittivityUnit ConversionBaseUnit { get; } = PermittivityUnit.FaradPerMeter; /// /// Represents the largest possible value of Permittivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, BaseUnit); + public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Permittivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, BaseUnit); + public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit FaradPerMeter. /// - public static Permittivity Zero { get; } = new Permittivity(0, BaseUnit); + public static Permittivity Zero { get; } = new Permittivity(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public Permittivity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PermittivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PermittivityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal Permittivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Permittivity(baseUnitValue, BaseUnit); + return new Permittivity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(PermittivityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 4469dc22cf..033462de4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -82,7 +82,7 @@ static Power() new UnitInfo(PowerUnit.Terawatt, "Terawatts", BaseUnits.Undefined), new UnitInfo(PowerUnit.Watt, "Watts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Power); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Power); } /// @@ -132,19 +132,19 @@ public Power(decimal value, UnitSystem unitSystem) /// /// The base unit of Power, which is Watt. All conversions go via this value. /// - public static PowerUnit BaseUnit { get; } = PowerUnit.Watt; + public static PowerUnit ConversionBaseUnit { get; } = PowerUnit.Watt; /// /// Represents the largest possible value of Power /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Power MaxValue { get; } = new Power(decimal.MaxValue, BaseUnit); + public static Power MaxValue { get; } = new Power(decimal.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Power /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Power MinValue { get; } = new Power(decimal.MinValue, BaseUnit); + public static Power MinValue { get; } = new Power(decimal.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -160,7 +160,7 @@ public Power(decimal value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Watt. /// - public static Power Zero { get; } = new Power(0, BaseUnit); + public static Power Zero { get; } = new Power(0, ConversionBaseUnit); #endregion @@ -179,7 +179,7 @@ public Power(decimal value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PowerUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1047,7 +1047,7 @@ private decimal GetValueInBaseUnit() internal Power ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Power(baseUnitValue, BaseUnit); + return new Power(baseUnitValue, ConversionBaseUnit); } private decimal GetValueAs(PowerUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index f8e40805da..1bd51d110b 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -101,7 +101,7 @@ static PowerDensity() new UnitInfo(PowerDensityUnit.WattPerCubicMeter, "WattsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second)), new UnitInfo(PowerDensityUnit.WattPerLiter, "WattsPerLiter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.PowerDensity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.PowerDensity); } /// @@ -151,19 +151,19 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// The base unit of PowerDensity, which is WattPerCubicMeter. All conversions go via this value. /// - public static PowerDensityUnit BaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; + public static PowerDensityUnit ConversionBaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; /// /// Represents the largest possible value of PowerDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, BaseUnit); + public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of PowerDensity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, BaseUnit); + public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -179,7 +179,7 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerCubicMeter. /// - public static PowerDensity Zero { get; } = new PowerDensity(0, BaseUnit); + public static PowerDensity Zero { get; } = new PowerDensity(0, ConversionBaseUnit); #endregion @@ -193,7 +193,7 @@ public PowerDensity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PowerDensityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PowerDensityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1346,7 +1346,7 @@ private double GetValueInBaseUnit() internal PowerDensity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new PowerDensity(baseUnitValue, BaseUnit); + return new PowerDensity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(PowerDensityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 5fc6c4963e..59ca99c83b 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -59,7 +59,7 @@ static PowerRatio() new UnitInfo(PowerRatioUnit.DecibelMilliwatt, "DecibelMilliwatts", BaseUnits.Undefined), new UnitInfo(PowerRatioUnit.DecibelWatt, "DecibelWatts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.PowerRatio); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.PowerRatio); } /// @@ -109,19 +109,19 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// The base unit of PowerRatio, which is DecibelWatt. All conversions go via this value. /// - public static PowerRatioUnit BaseUnit { get; } = PowerRatioUnit.DecibelWatt; + public static PowerRatioUnit ConversionBaseUnit { get; } = PowerRatioUnit.DecibelWatt; /// /// Represents the largest possible value of PowerRatio /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, BaseUnit); + public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of PowerRatio /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, BaseUnit); + public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -137,7 +137,7 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DecibelWatt. /// - public static PowerRatio Zero { get; } = new PowerRatio(0, BaseUnit); + public static PowerRatio Zero { get; } = new PowerRatio(0, ConversionBaseUnit); #endregion @@ -151,7 +151,7 @@ public PowerRatio(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PowerRatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PowerRatioUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -682,7 +682,7 @@ private double GetValueInBaseUnit() internal PowerRatio ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new PowerRatio(baseUnitValue, BaseUnit); + return new PowerRatio(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(PowerRatioUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 45115570f0..66bd6e98e3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -101,7 +101,7 @@ static Pressure() new UnitInfo(PressureUnit.TonneForcePerSquareMillimeter, "TonnesForcePerSquareMillimeter", BaseUnits.Undefined), new UnitInfo(PressureUnit.Torr, "Torrs", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Pressure); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Pressure); } /// @@ -151,19 +151,19 @@ public Pressure(double value, UnitSystem unitSystem) /// /// The base unit of Pressure, which is Pascal. All conversions go via this value. /// - public static PressureUnit BaseUnit { get; } = PressureUnit.Pascal; + public static PressureUnit ConversionBaseUnit { get; } = PressureUnit.Pascal; /// /// Represents the largest possible value of Pressure /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, BaseUnit); + public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Pressure /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Pressure MinValue { get; } = new Pressure(double.MinValue, BaseUnit); + public static Pressure MinValue { get; } = new Pressure(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -179,7 +179,7 @@ public Pressure(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Pascal. /// - public static Pressure Zero { get; } = new Pressure(0, BaseUnit); + public static Pressure Zero { get; } = new Pressure(0, ConversionBaseUnit); #endregion @@ -193,7 +193,7 @@ public Pressure(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PressureUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PressureUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1346,7 +1346,7 @@ private double GetValueInBaseUnit() internal Pressure ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Pressure(baseUnitValue, BaseUnit); + return new Pressure(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(PressureUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 429cfa2e77..8520f2ff9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -70,7 +70,7 @@ static PressureChangeRate() new UnitInfo(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, "PoundsForcePerSquareInchPerMinute", BaseUnits.Undefined), new UnitInfo(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, "PoundsForcePerSquareInchPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.PressureChangeRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.PressureChangeRate); } /// @@ -120,19 +120,19 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// The base unit of PressureChangeRate, which is PascalPerSecond. All conversions go via this value. /// - public static PressureChangeRateUnit BaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; + public static PressureChangeRateUnit ConversionBaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; /// /// Represents the largest possible value of PressureChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, BaseUnit); + public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of PressureChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, BaseUnit); + public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -148,7 +148,7 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit PascalPerSecond. /// - public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, BaseUnit); + public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, ConversionBaseUnit); #endregion @@ -162,7 +162,7 @@ public PressureChangeRate(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public PressureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public PressureChangeRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -850,7 +850,7 @@ private double GetValueInBaseUnit() internal PressureChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new PressureChangeRate(baseUnitValue, BaseUnit); + return new PressureChangeRate(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(PressureChangeRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 5c1504d069..43076a9d67 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -63,7 +63,7 @@ static Ratio() new UnitInfo(RatioUnit.PartPerTrillion, "PartsPerTrillion", BaseUnits.Undefined), new UnitInfo(RatioUnit.Percent, "Percent", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Ratio); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Ratio); } /// @@ -113,19 +113,19 @@ public Ratio(double value, UnitSystem unitSystem) /// /// The base unit of Ratio, which is DecimalFraction. All conversions go via this value. /// - public static RatioUnit BaseUnit { get; } = RatioUnit.DecimalFraction; + public static RatioUnit ConversionBaseUnit { get; } = RatioUnit.DecimalFraction; /// /// Represents the largest possible value of Ratio /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, BaseUnit); + public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Ratio /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Ratio MinValue { get; } = new Ratio(double.MinValue, BaseUnit); + public static Ratio MinValue { get; } = new Ratio(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public Ratio(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. /// - public static Ratio Zero { get; } = new Ratio(0, BaseUnit); + public static Ratio Zero { get; } = new Ratio(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public Ratio(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RatioUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RatioUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -738,7 +738,7 @@ private double GetValueInBaseUnit() internal Ratio ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Ratio(baseUnitValue, BaseUnit); + return new Ratio(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RatioUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 816dac5c6c..a9b6445b43 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -59,7 +59,7 @@ static RatioChangeRate() new UnitInfo(RatioChangeRateUnit.DecimalFractionPerSecond, "DecimalFractionsPerSecond", BaseUnits.Undefined), new UnitInfo(RatioChangeRateUnit.PercentPerSecond, "PercentsPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RatioChangeRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RatioChangeRate); } /// @@ -109,19 +109,19 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// The base unit of RatioChangeRate, which is DecimalFractionPerSecond. All conversions go via this value. /// - public static RatioChangeRateUnit BaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; + public static RatioChangeRateUnit ConversionBaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; /// /// Represents the largest possible value of RatioChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, BaseUnit); + public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of RatioChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, BaseUnit); + public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -137,7 +137,7 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFractionPerSecond. /// - public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, BaseUnit); + public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, ConversionBaseUnit); #endregion @@ -151,7 +151,7 @@ public RatioChangeRate(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RatioChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RatioChangeRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -674,7 +674,7 @@ private double GetValueInBaseUnit() internal RatioChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RatioChangeRate(baseUnitValue, BaseUnit); + return new RatioChangeRate(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RatioChangeRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 75b498f348..c8eec7a44b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -60,7 +60,7 @@ static ReactiveEnergy() new UnitInfo(ReactiveEnergyUnit.MegavoltampereReactiveHour, "MegavoltampereReactiveHours", BaseUnits.Undefined), new UnitInfo(ReactiveEnergyUnit.VoltampereReactiveHour, "VoltampereReactiveHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReactiveEnergy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReactiveEnergy); } /// @@ -110,19 +110,19 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// The base unit of ReactiveEnergy, which is VoltampereReactiveHour. All conversions go via this value. /// - public static ReactiveEnergyUnit BaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; + public static ReactiveEnergyUnit ConversionBaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; /// /// Represents the largest possible value of ReactiveEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, BaseUnit); + public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ReactiveEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, BaseUnit); + public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactiveHour. /// - public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, BaseUnit); + public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ReactiveEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ReactiveEnergyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal ReactiveEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ReactiveEnergy(baseUnitValue, BaseUnit); + return new ReactiveEnergy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ReactiveEnergyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 3f04f97883..b11e24d99a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -61,7 +61,7 @@ static ReactivePower() new UnitInfo(ReactivePowerUnit.MegavoltampereReactive, "MegavoltamperesReactive", BaseUnits.Undefined), new UnitInfo(ReactivePowerUnit.VoltampereReactive, "VoltamperesReactive", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReactivePower); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReactivePower); } /// @@ -111,19 +111,19 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// The base unit of ReactivePower, which is VoltampereReactive. All conversions go via this value. /// - public static ReactivePowerUnit BaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; + public static ReactivePowerUnit ConversionBaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; /// /// Represents the largest possible value of ReactivePower /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, BaseUnit); + public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ReactivePower /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, BaseUnit); + public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactive. /// - public static ReactivePower Zero { get; } = new ReactivePower(0, BaseUnit); + public static ReactivePower Zero { get; } = new ReactivePower(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public ReactivePower(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ReactivePowerUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ReactivePowerUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -706,7 +706,7 @@ private double GetValueInBaseUnit() internal ReactivePower ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ReactivePower(baseUnitValue, BaseUnit); + return new ReactivePower(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ReactivePowerUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 08965698c2..330e55e64c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -71,7 +71,7 @@ static ReciprocalArea() new UnitInfo(ReciprocalAreaUnit.InverseSquareYard, "InverseSquareYards", BaseUnits.Undefined), new UnitInfo(ReciprocalAreaUnit.InverseUsSurveySquareFoot, "InverseUsSurveySquareFeet", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalArea); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalArea); } /// @@ -121,19 +121,19 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// /// The base unit of ReciprocalArea, which is InverseSquareMeter. All conversions go via this value. /// - public static ReciprocalAreaUnit BaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; + public static ReciprocalAreaUnit ConversionBaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; /// /// Represents the largest possible value of ReciprocalArea /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, BaseUnit); + public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ReciprocalArea /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, BaseUnit); + public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -149,7 +149,7 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseSquareMeter. /// - public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, BaseUnit); + public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, ConversionBaseUnit); #endregion @@ -163,7 +163,7 @@ public ReciprocalArea(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ReciprocalAreaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ReciprocalAreaUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -821,7 +821,7 @@ private double GetValueInBaseUnit() internal ReciprocalArea ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ReciprocalArea(baseUnitValue, BaseUnit); + return new ReciprocalArea(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ReciprocalAreaUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index af768a8ef2..5a9c0d1c05 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -70,7 +70,7 @@ static ReciprocalLength() new UnitInfo(ReciprocalLengthUnit.InverseUsSurveyFoot, "InverseUsSurveyFeet", BaseUnits.Undefined), new UnitInfo(ReciprocalLengthUnit.InverseYard, "InverseYards", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalLength); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalLength); } /// @@ -120,19 +120,19 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// /// The base unit of ReciprocalLength, which is InverseMeter. All conversions go via this value. /// - public static ReciprocalLengthUnit BaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; + public static ReciprocalLengthUnit ConversionBaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; /// /// Represents the largest possible value of ReciprocalLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, BaseUnit); + public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ReciprocalLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, BaseUnit); + public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -148,7 +148,7 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseMeter. /// - public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, BaseUnit); + public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, ConversionBaseUnit); #endregion @@ -162,7 +162,7 @@ public ReciprocalLength(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ReciprocalLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ReciprocalLengthUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -805,7 +805,7 @@ private double GetValueInBaseUnit() internal ReciprocalLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ReciprocalLength(baseUnitValue, BaseUnit); + return new ReciprocalLength(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ReciprocalLengthUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 0b62365c85..8d1b1aa808 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -58,7 +58,7 @@ static RelativeHumidity() new UnitInfo[] { new UnitInfo(RelativeHumidityUnit.Percent, "Percent", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RelativeHumidity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RelativeHumidity); } /// @@ -108,19 +108,19 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// The base unit of RelativeHumidity, which is Percent. All conversions go via this value. /// - public static RelativeHumidityUnit BaseUnit { get; } = RelativeHumidityUnit.Percent; + public static RelativeHumidityUnit ConversionBaseUnit { get; } = RelativeHumidityUnit.Percent; /// /// Represents the largest possible value of RelativeHumidity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, BaseUnit); + public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of RelativeHumidity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, BaseUnit); + public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -136,7 +136,7 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Percent. /// - public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, BaseUnit); + public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, ConversionBaseUnit); #endregion @@ -150,7 +150,7 @@ public RelativeHumidity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RelativeHumidityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RelativeHumidityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -658,7 +658,7 @@ private double GetValueInBaseUnit() internal RelativeHumidity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RelativeHumidity(baseUnitValue, BaseUnit); + return new RelativeHumidity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RelativeHumidityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index de5d3df498..11e9a83bc1 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -61,7 +61,7 @@ static RotationalAcceleration() new UnitInfo(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, "RevolutionsPerMinutePerSecond", BaseUnits.Undefined), new UnitInfo(RotationalAccelerationUnit.RevolutionPerSecondSquared, "RevolutionsPerSecondSquared", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalAcceleration); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalAcceleration); } /// @@ -111,19 +111,19 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// The base unit of RotationalAcceleration, which is RadianPerSecondSquared. All conversions go via this value. /// - public static RotationalAccelerationUnit BaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; + public static RotationalAccelerationUnit ConversionBaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; /// /// Represents the largest possible value of RotationalAcceleration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, BaseUnit); + public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of RotationalAcceleration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, BaseUnit); + public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecondSquared. /// - public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, BaseUnit); + public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RotationalAccelerationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RotationalAccelerationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -706,7 +706,7 @@ private double GetValueInBaseUnit() internal RotationalAcceleration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalAcceleration(baseUnitValue, BaseUnit); + return new RotationalAcceleration(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RotationalAccelerationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index a34bd384df..889d489a15 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -70,7 +70,7 @@ static RotationalSpeed() new UnitInfo(RotationalSpeedUnit.RevolutionPerMinute, "RevolutionsPerMinute", BaseUnits.Undefined), new UnitInfo(RotationalSpeedUnit.RevolutionPerSecond, "RevolutionsPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalSpeed); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalSpeed); } /// @@ -120,19 +120,19 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// The base unit of RotationalSpeed, which is RadianPerSecond. All conversions go via this value. /// - public static RotationalSpeedUnit BaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; + public static RotationalSpeedUnit ConversionBaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; /// /// Represents the largest possible value of RotationalSpeed /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, BaseUnit); + public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of RotationalSpeed /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, BaseUnit); + public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -148,7 +148,7 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecond. /// - public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, BaseUnit); + public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, ConversionBaseUnit); #endregion @@ -162,7 +162,7 @@ public RotationalSpeed(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RotationalSpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RotationalSpeedUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -850,7 +850,7 @@ private double GetValueInBaseUnit() internal RotationalSpeed ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalSpeed(baseUnitValue, BaseUnit); + return new RotationalSpeed(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RotationalSpeedUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 2cb9ddb73b..d4e46efed9 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -90,7 +90,7 @@ static RotationalStiffness() new UnitInfo(RotationalStiffnessUnit.PoundForceFeetPerRadian, "PoundForceFeetPerRadian", BaseUnits.Undefined), new UnitInfo(RotationalStiffnessUnit.PoundForceFootPerDegrees, "PoundForceFeetPerDegrees", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffness); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffness); } /// @@ -140,19 +140,19 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// The base unit of RotationalStiffness, which is NewtonMeterPerRadian. All conversions go via this value. /// - public static RotationalStiffnessUnit BaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; + public static RotationalStiffnessUnit ConversionBaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; /// /// Represents the largest possible value of RotationalStiffness /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, BaseUnit); + public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of RotationalStiffness /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, BaseUnit); + public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -168,7 +168,7 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadian. /// - public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, BaseUnit); + public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, ConversionBaseUnit); #endregion @@ -182,7 +182,7 @@ public RotationalStiffness(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RotationalStiffnessUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RotationalStiffnessUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1170,7 +1170,7 @@ private double GetValueInBaseUnit() internal RotationalStiffness ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalStiffness(baseUnitValue, BaseUnit); + return new RotationalStiffness(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RotationalStiffnessUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 698c7c06b8..99681350bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -62,7 +62,7 @@ static RotationalStiffnessPerLength() new UnitInfo(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, "NewtonMetersPerRadianPerMeter", BaseUnits.Undefined), new UnitInfo(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, "PoundForceFeetPerDegreesPerFeet", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffnessPerLength); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffnessPerLength); } /// @@ -112,19 +112,19 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// The base unit of RotationalStiffnessPerLength, which is NewtonMeterPerRadianPerMeter. All conversions go via this value. /// - public static RotationalStiffnessPerLengthUnit BaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; + public static RotationalStiffnessPerLengthUnit ConversionBaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; /// /// Represents the largest possible value of RotationalStiffnessPerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, BaseUnit); + public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of RotationalStiffnessPerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, BaseUnit); + public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -140,7 +140,7 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter. /// - public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, BaseUnit); + public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, ConversionBaseUnit); #endregion @@ -154,7 +154,7 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public RotationalStiffnessPerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public RotationalStiffnessPerLengthUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -722,7 +722,7 @@ private double GetValueInBaseUnit() internal RotationalStiffnessPerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new RotationalStiffnessPerLength(baseUnitValue, BaseUnit); + return new RotationalStiffnessPerLength(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(RotationalStiffnessPerLengthUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 7e8c3dddd0..d9d8ac40f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -58,7 +58,7 @@ static Scalar() new UnitInfo[] { new UnitInfo(ScalarUnit.Amount, "Amount", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Scalar); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Scalar); } /// @@ -108,19 +108,19 @@ public Scalar(double value, UnitSystem unitSystem) /// /// The base unit of Scalar, which is Amount. All conversions go via this value. /// - public static ScalarUnit BaseUnit { get; } = ScalarUnit.Amount; + public static ScalarUnit ConversionBaseUnit { get; } = ScalarUnit.Amount; /// /// Represents the largest possible value of Scalar /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, BaseUnit); + public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Scalar /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Scalar MinValue { get; } = new Scalar(double.MinValue, BaseUnit); + public static Scalar MinValue { get; } = new Scalar(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -136,7 +136,7 @@ public Scalar(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Amount. /// - public static Scalar Zero { get; } = new Scalar(0, BaseUnit); + public static Scalar Zero { get; } = new Scalar(0, ConversionBaseUnit); #endregion @@ -150,7 +150,7 @@ public Scalar(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ScalarUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ScalarUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -658,7 +658,7 @@ private double GetValueInBaseUnit() internal Scalar ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Scalar(baseUnitValue, BaseUnit); + return new Scalar(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ScalarUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index bab23997a2..b126e7c836 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -61,7 +61,7 @@ static SolidAngle() new UnitInfo[] { new UnitInfo(SolidAngleUnit.Steradian, "Steradians", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SolidAngle); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SolidAngle); } /// @@ -111,19 +111,19 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// The base unit of SolidAngle, which is Steradian. All conversions go via this value. /// - public static SolidAngleUnit BaseUnit { get; } = SolidAngleUnit.Steradian; + public static SolidAngleUnit ConversionBaseUnit { get; } = SolidAngleUnit.Steradian; /// /// Represents the largest possible value of SolidAngle /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, BaseUnit); + public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of SolidAngle /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, BaseUnit); + public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Steradian. /// - public static SolidAngle Zero { get; } = new SolidAngle(0, BaseUnit); + public static SolidAngle Zero { get; } = new SolidAngle(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public SolidAngle(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SolidAngleUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SolidAngleUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal SolidAngle ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SolidAngle(baseUnitValue, BaseUnit); + return new SolidAngle(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SolidAngleUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index d812bc6db0..60aa66c515 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -85,7 +85,7 @@ static SpecificEnergy() new UnitInfo(SpecificEnergyUnit.WattDayPerTonne, "WattDaysPerTonne", BaseUnits.Undefined), new UnitInfo(SpecificEnergyUnit.WattHourPerKilogram, "WattHoursPerKilogram", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificEnergy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificEnergy); } /// @@ -135,19 +135,19 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// The base unit of SpecificEnergy, which is JoulePerKilogram. All conversions go via this value. /// - public static SpecificEnergyUnit BaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; + public static SpecificEnergyUnit ConversionBaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; /// /// Represents the largest possible value of SpecificEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, BaseUnit); + public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of SpecificEnergy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, BaseUnit); + public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -163,7 +163,7 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogram. /// - public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, BaseUnit); + public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, ConversionBaseUnit); #endregion @@ -177,7 +177,7 @@ public SpecificEnergy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SpecificEnergyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SpecificEnergyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1045,7 +1045,7 @@ private double GetValueInBaseUnit() internal SpecificEnergy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificEnergy(baseUnitValue, BaseUnit); + return new SpecificEnergy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SpecificEnergyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 94896490b8..bda82f5820 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -66,7 +66,7 @@ static SpecificEntropy() new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, "MegajoulesPerKilogramDegreeCelsius", BaseUnits.Undefined), new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramKelvin, "MegajoulesPerKilogramKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificEntropy); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificEntropy); } /// @@ -116,19 +116,19 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// The base unit of SpecificEntropy, which is JoulePerKilogramKelvin. All conversions go via this value. /// - public static SpecificEntropyUnit BaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; + public static SpecificEntropyUnit ConversionBaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; /// /// Represents the largest possible value of SpecificEntropy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, BaseUnit); + public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of SpecificEntropy /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, BaseUnit); + public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -144,7 +144,7 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogramKelvin. /// - public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, BaseUnit); + public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, ConversionBaseUnit); #endregion @@ -158,7 +158,7 @@ public SpecificEntropy(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SpecificEntropyUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SpecificEntropyUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -786,7 +786,7 @@ private double GetValueInBaseUnit() internal SpecificEntropy ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificEntropy(baseUnitValue, BaseUnit); + return new SpecificEntropy(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SpecificEntropyUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 861ac827c1..ce3fec6f51 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -64,7 +64,7 @@ static SpecificFuelConsumption() new UnitInfo(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, "KilogramsPerKiloNewtonSecond", BaseUnits.Undefined), new UnitInfo(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, "PoundsMassPerPoundForceHour", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificFuelConsumption); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificFuelConsumption); } /// @@ -114,19 +114,19 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The base unit of SpecificFuelConsumption, which is GramPerKiloNewtonSecond. All conversions go via this value. /// - public static SpecificFuelConsumptionUnit BaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; + public static SpecificFuelConsumptionUnit ConversionBaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; /// /// Represents the largest possible value of SpecificFuelConsumption /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, BaseUnit); + public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of SpecificFuelConsumption /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, BaseUnit); + public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -142,7 +142,7 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit GramPerKiloNewtonSecond. /// - public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, BaseUnit); + public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, ConversionBaseUnit); #endregion @@ -156,7 +156,7 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SpecificFuelConsumptionUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -709,7 +709,7 @@ private double GetValueInBaseUnit() internal SpecificFuelConsumption ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificFuelConsumption(baseUnitValue, BaseUnit); + return new SpecificFuelConsumption(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SpecificFuelConsumptionUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index a3ccc3ffa3..6c154efbee 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -60,7 +60,7 @@ static SpecificVolume() new UnitInfo(SpecificVolumeUnit.CubicMeterPerKilogram, "CubicMetersPerKilogram", BaseUnits.Undefined), new UnitInfo(SpecificVolumeUnit.MillicubicMeterPerKilogram, "MillicubicMetersPerKilogram", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificVolume); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificVolume); } /// @@ -110,19 +110,19 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// The base unit of SpecificVolume, which is CubicMeterPerKilogram. All conversions go via this value. /// - public static SpecificVolumeUnit BaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; + public static SpecificVolumeUnit ConversionBaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; /// /// Represents the largest possible value of SpecificVolume /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, BaseUnit); + public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of SpecificVolume /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, BaseUnit); + public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -138,7 +138,7 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerKilogram. /// - public static SpecificVolume Zero { get; } = new SpecificVolume(0, BaseUnit); + public static SpecificVolume Zero { get; } = new SpecificVolume(0, ConversionBaseUnit); #endregion @@ -152,7 +152,7 @@ public SpecificVolume(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SpecificVolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SpecificVolumeUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -690,7 +690,7 @@ private double GetValueInBaseUnit() internal SpecificVolume ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificVolume(baseUnitValue, BaseUnit); + return new SpecificVolume(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SpecificVolumeUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 26b6f3908d..664888a751 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -77,7 +77,7 @@ static SpecificWeight() new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMeter, "TonnesForcePerCubicMeter", BaseUnits.Undefined), new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMillimeter, "TonnesForcePerCubicMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificWeight); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificWeight); } /// @@ -127,19 +127,19 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// The base unit of SpecificWeight, which is NewtonPerCubicMeter. All conversions go via this value. /// - public static SpecificWeightUnit BaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; + public static SpecificWeightUnit ConversionBaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; /// /// Represents the largest possible value of SpecificWeight /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, BaseUnit); + public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of SpecificWeight /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, BaseUnit); + public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -155,7 +155,7 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerCubicMeter. /// - public static SpecificWeight Zero { get; } = new SpecificWeight(0, BaseUnit); + public static SpecificWeight Zero { get; } = new SpecificWeight(0, ConversionBaseUnit); #endregion @@ -169,7 +169,7 @@ public SpecificWeight(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SpecificWeightUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SpecificWeightUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -917,7 +917,7 @@ private double GetValueInBaseUnit() internal SpecificWeight ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new SpecificWeight(baseUnitValue, BaseUnit); + return new SpecificWeight(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SpecificWeightUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 908ae57e51..9d9f8f9634 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -89,7 +89,7 @@ static Speed() new UnitInfo(SpeedUnit.YardPerMinute, "YardsPerMinute", new BaseUnits(length: LengthUnit.Yard, time: DurationUnit.Minute)), new UnitInfo(SpeedUnit.YardPerSecond, "YardsPerSecond", new BaseUnits(length: LengthUnit.Yard, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Speed); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Speed); } /// @@ -139,19 +139,19 @@ public Speed(double value, UnitSystem unitSystem) /// /// The base unit of Speed, which is MeterPerSecond. All conversions go via this value. /// - public static SpeedUnit BaseUnit { get; } = SpeedUnit.MeterPerSecond; + public static SpeedUnit ConversionBaseUnit { get; } = SpeedUnit.MeterPerSecond; /// /// Represents the largest possible value of Speed /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Speed MaxValue { get; } = new Speed(double.MaxValue, BaseUnit); + public static Speed MaxValue { get; } = new Speed(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Speed /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Speed MinValue { get; } = new Speed(double.MinValue, BaseUnit); + public static Speed MinValue { get; } = new Speed(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -167,7 +167,7 @@ public Speed(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecond. /// - public static Speed Zero { get; } = new Speed(0, BaseUnit); + public static Speed Zero { get; } = new Speed(0, ConversionBaseUnit); #endregion @@ -181,7 +181,7 @@ public Speed(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public SpeedUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public SpeedUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1154,7 +1154,7 @@ private double GetValueInBaseUnit() internal Speed ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Speed(baseUnitValue, BaseUnit); + return new Speed(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(SpeedUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index e824e47951..0f7a635eaf 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -66,7 +66,7 @@ static StandardVolumeFlow() new UnitInfo(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, "StandardCubicMetersPerSecond", BaseUnits.Undefined), new UnitInfo(StandardVolumeFlowUnit.StandardLiterPerMinute, "StandardLitersPerMinute", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.StandardVolumeFlow); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.StandardVolumeFlow); } /// @@ -116,19 +116,19 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// /// The base unit of StandardVolumeFlow, which is StandardCubicMeterPerSecond. All conversions go via this value. /// - public static StandardVolumeFlowUnit BaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; + public static StandardVolumeFlowUnit ConversionBaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; /// /// Represents the largest possible value of StandardVolumeFlow /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, BaseUnit); + public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of StandardVolumeFlow /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, BaseUnit); + public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -144,7 +144,7 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit StandardCubicMeterPerSecond. /// - public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, BaseUnit); + public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, ConversionBaseUnit); #endregion @@ -158,7 +158,7 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public StandardVolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public StandardVolumeFlowUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -786,7 +786,7 @@ private double GetValueInBaseUnit() internal StandardVolumeFlow ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new StandardVolumeFlow(baseUnitValue, BaseUnit); + return new StandardVolumeFlow(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(StandardVolumeFlowUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 0535351faa..9e7bc59cb0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -67,7 +67,7 @@ static Temperature() new UnitInfo(TemperatureUnit.MillidegreeCelsius, "MillidegreesCelsius", new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)), new UnitInfo(TemperatureUnit.SolarTemperature, "SolarTemperatures", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Temperature); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Temperature); } /// @@ -117,19 +117,19 @@ public Temperature(double value, UnitSystem unitSystem) /// /// The base unit of Temperature, which is Kelvin. All conversions go via this value. /// - public static TemperatureUnit BaseUnit { get; } = TemperatureUnit.Kelvin; + public static TemperatureUnit ConversionBaseUnit { get; } = TemperatureUnit.Kelvin; /// /// Represents the largest possible value of Temperature /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, BaseUnit); + public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Temperature /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Temperature MinValue { get; } = new Temperature(double.MinValue, BaseUnit); + public static Temperature MinValue { get; } = new Temperature(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -145,7 +145,7 @@ public Temperature(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. /// - public static Temperature Zero { get; } = new Temperature(0, BaseUnit); + public static Temperature Zero { get; } = new Temperature(0, ConversionBaseUnit); #endregion @@ -159,7 +159,7 @@ public Temperature(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public TemperatureUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public TemperatureUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -756,7 +756,7 @@ private double GetValueInBaseUnit() internal Temperature ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Temperature(baseUnitValue, BaseUnit); + return new Temperature(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(TemperatureUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 3386e70e79..1aa9f26d55 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -67,7 +67,7 @@ static TemperatureChangeRate() new UnitInfo(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, "MillidegreesCelsiusPerSecond", BaseUnits.Undefined), new UnitInfo(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, "NanodegreesCelsiusPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TemperatureChangeRate); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.TemperatureChangeRate); } /// @@ -117,19 +117,19 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// The base unit of TemperatureChangeRate, which is DegreeCelsiusPerSecond. All conversions go via this value. /// - public static TemperatureChangeRateUnit BaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; + public static TemperatureChangeRateUnit ConversionBaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; /// /// Represents the largest possible value of TemperatureChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, BaseUnit); + public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of TemperatureChangeRate /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, BaseUnit); + public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -145,7 +145,7 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerSecond. /// - public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, BaseUnit); + public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, ConversionBaseUnit); #endregion @@ -159,7 +159,7 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public TemperatureChangeRateUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public TemperatureChangeRateUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -802,7 +802,7 @@ private double GetValueInBaseUnit() internal TemperatureChangeRate ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new TemperatureChangeRate(baseUnitValue, BaseUnit); + return new TemperatureChangeRate(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(TemperatureChangeRateUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 2da799ff92..0f9ba517b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -66,7 +66,7 @@ static TemperatureDelta() new UnitInfo(TemperatureDeltaUnit.Kelvin, "Kelvins", BaseUnits.Undefined), new UnitInfo(TemperatureDeltaUnit.MillidegreeCelsius, "MillidegreesCelsius", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TemperatureDelta); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.TemperatureDelta); } /// @@ -116,19 +116,19 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// The base unit of TemperatureDelta, which is Kelvin. All conversions go via this value. /// - public static TemperatureDeltaUnit BaseUnit { get; } = TemperatureDeltaUnit.Kelvin; + public static TemperatureDeltaUnit ConversionBaseUnit { get; } = TemperatureDeltaUnit.Kelvin; /// /// Represents the largest possible value of TemperatureDelta /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, BaseUnit); + public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of TemperatureDelta /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, BaseUnit); + public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -144,7 +144,7 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. /// - public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, BaseUnit); + public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, ConversionBaseUnit); #endregion @@ -158,7 +158,7 @@ public TemperatureDelta(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public TemperatureDeltaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public TemperatureDeltaUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -786,7 +786,7 @@ private double GetValueInBaseUnit() internal TemperatureDelta ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new TemperatureDelta(baseUnitValue, BaseUnit); + return new TemperatureDelta(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(TemperatureDeltaUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index a50d788c87..6e2fb29ecf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -62,7 +62,7 @@ static ThermalConductivity() new UnitInfo(ThermalConductivityUnit.BtuPerHourFootFahrenheit, "BtusPerHourFootFahrenheit", BaseUnits.Undefined), new UnitInfo(ThermalConductivityUnit.WattPerMeterKelvin, "WattsPerMeterKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ThermalConductivity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ThermalConductivity); } /// @@ -112,19 +112,19 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// The base unit of ThermalConductivity, which is WattPerMeterKelvin. All conversions go via this value. /// - public static ThermalConductivityUnit BaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; + public static ThermalConductivityUnit ConversionBaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; /// /// Represents the largest possible value of ThermalConductivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, BaseUnit); + public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ThermalConductivity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, BaseUnit); + public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -140,7 +140,7 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeterKelvin. /// - public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, BaseUnit); + public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, ConversionBaseUnit); #endregion @@ -154,7 +154,7 @@ public ThermalConductivity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ThermalConductivityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ThermalConductivityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -677,7 +677,7 @@ private double GetValueInBaseUnit() internal ThermalConductivity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ThermalConductivity(baseUnitValue, BaseUnit); + return new ThermalConductivity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ThermalConductivityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 7ae2314a4e..e66aff17f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -62,7 +62,7 @@ static ThermalResistance() new UnitInfo(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, "SquareMeterDegreesCelsiusPerWatt", BaseUnits.Undefined), new UnitInfo(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, "SquareMeterKelvinsPerKilowatt", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ThermalResistance); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ThermalResistance); } /// @@ -112,19 +112,19 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// The base unit of ThermalResistance, which is SquareMeterKelvinPerKilowatt. All conversions go via this value. /// - public static ThermalResistanceUnit BaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; + public static ThermalResistanceUnit ConversionBaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; /// /// Represents the largest possible value of ThermalResistance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, BaseUnit); + public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of ThermalResistance /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, BaseUnit); + public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -140,7 +140,7 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt. /// - public static ThermalResistance Zero { get; } = new ThermalResistance(0, BaseUnit); + public static ThermalResistance Zero { get; } = new ThermalResistance(0, ConversionBaseUnit); #endregion @@ -154,7 +154,7 @@ public ThermalResistance(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public ThermalResistanceUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public ThermalResistanceUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -722,7 +722,7 @@ private double GetValueInBaseUnit() internal ThermalResistance ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new ThermalResistance(baseUnitValue, BaseUnit); + return new ThermalResistance(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(ThermalResistanceUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 32bc8a54b7..583a4019c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -79,7 +79,7 @@ static Torque() new UnitInfo(TorqueUnit.TonneForceMeter, "TonneForceMeters", BaseUnits.Undefined), new UnitInfo(TorqueUnit.TonneForceMillimeter, "TonneForceMillimeters", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Torque); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Torque); } /// @@ -129,19 +129,19 @@ public Torque(double value, UnitSystem unitSystem) /// /// The base unit of Torque, which is NewtonMeter. All conversions go via this value. /// - public static TorqueUnit BaseUnit { get; } = TorqueUnit.NewtonMeter; + public static TorqueUnit ConversionBaseUnit { get; } = TorqueUnit.NewtonMeter; /// /// Represents the largest possible value of Torque /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Torque MaxValue { get; } = new Torque(double.MaxValue, BaseUnit); + public static Torque MaxValue { get; } = new Torque(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Torque /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Torque MinValue { get; } = new Torque(double.MinValue, BaseUnit); + public static Torque MinValue { get; } = new Torque(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -157,7 +157,7 @@ public Torque(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeter. /// - public static Torque Zero { get; } = new Torque(0, BaseUnit); + public static Torque Zero { get; } = new Torque(0, ConversionBaseUnit); #endregion @@ -171,7 +171,7 @@ public Torque(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public TorqueUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public TorqueUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -994,7 +994,7 @@ private double GetValueInBaseUnit() internal Torque ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Torque(baseUnitValue, BaseUnit); + return new Torque(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(TorqueUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 5fa9737c3d..7a63623438 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -78,7 +78,7 @@ static TorquePerLength() new UnitInfo(TorquePerLengthUnit.TonneForceMeterPerMeter, "TonneForceMetersPerMeter", BaseUnits.Undefined), new UnitInfo(TorquePerLengthUnit.TonneForceMillimeterPerMeter, "TonneForceMillimetersPerMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TorquePerLength); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.TorquePerLength); } /// @@ -128,19 +128,19 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// The base unit of TorquePerLength, which is NewtonMeterPerMeter. All conversions go via this value. /// - public static TorquePerLengthUnit BaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; + public static TorquePerLengthUnit ConversionBaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; /// /// Represents the largest possible value of TorquePerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, BaseUnit); + public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of TorquePerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, BaseUnit); + public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -156,7 +156,7 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerMeter. /// - public static TorquePerLength Zero { get; } = new TorquePerLength(0, BaseUnit); + public static TorquePerLength Zero { get; } = new TorquePerLength(0, ConversionBaseUnit); #endregion @@ -170,7 +170,7 @@ public TorquePerLength(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public TorquePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public TorquePerLengthUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -978,7 +978,7 @@ private double GetValueInBaseUnit() internal TorquePerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new TorquePerLength(baseUnitValue, BaseUnit); + return new TorquePerLength(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(TorquePerLengthUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 588fb8c5ed..162c557d4f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -61,7 +61,7 @@ static Turbidity() new UnitInfo[] { new UnitInfo(TurbidityUnit.NTU, "NTU", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Turbidity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Turbidity); } /// @@ -111,19 +111,19 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// The base unit of Turbidity, which is NTU. All conversions go via this value. /// - public static TurbidityUnit BaseUnit { get; } = TurbidityUnit.NTU; + public static TurbidityUnit ConversionBaseUnit { get; } = TurbidityUnit.NTU; /// /// Represents the largest possible value of Turbidity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, BaseUnit); + public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Turbidity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, BaseUnit); + public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -139,7 +139,7 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit NTU. /// - public static Turbidity Zero { get; } = new Turbidity(0, BaseUnit); + public static Turbidity Zero { get; } = new Turbidity(0, ConversionBaseUnit); #endregion @@ -153,7 +153,7 @@ public Turbidity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public TurbidityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public TurbidityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -661,7 +661,7 @@ private double GetValueInBaseUnit() internal Turbidity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Turbidity(baseUnitValue, BaseUnit); + return new Turbidity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(TurbidityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index fac84258d0..548b70aab7 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -58,7 +58,7 @@ static VitaminA() new UnitInfo[] { new UnitInfo(VitaminAUnit.InternationalUnit, "InternationalUnits", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VitaminA); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VitaminA); } /// @@ -108,19 +108,19 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// The base unit of VitaminA, which is InternationalUnit. All conversions go via this value. /// - public static VitaminAUnit BaseUnit { get; } = VitaminAUnit.InternationalUnit; + public static VitaminAUnit ConversionBaseUnit { get; } = VitaminAUnit.InternationalUnit; /// /// Represents the largest possible value of VitaminA /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, BaseUnit); + public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of VitaminA /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, BaseUnit); + public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -136,7 +136,7 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit InternationalUnit. /// - public static VitaminA Zero { get; } = new VitaminA(0, BaseUnit); + public static VitaminA Zero { get; } = new VitaminA(0, ConversionBaseUnit); #endregion @@ -150,7 +150,7 @@ public VitaminA(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public VitaminAUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public VitaminAUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -658,7 +658,7 @@ private double GetValueInBaseUnit() internal VitaminA ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VitaminA(baseUnitValue, BaseUnit); + return new VitaminA(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(VitaminAUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index dac8c7c81f..95271cbdbb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -108,7 +108,7 @@ static Volume() new UnitInfo(VolumeUnit.UsTablespoon, "UsTablespoons", BaseUnits.Undefined), new UnitInfo(VolumeUnit.UsTeaspoon, "UsTeaspoons", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Volume); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Volume); } /// @@ -158,19 +158,19 @@ public Volume(double value, UnitSystem unitSystem) /// /// The base unit of Volume, which is CubicMeter. All conversions go via this value. /// - public static VolumeUnit BaseUnit { get; } = VolumeUnit.CubicMeter; + public static VolumeUnit ConversionBaseUnit { get; } = VolumeUnit.CubicMeter; /// /// Represents the largest possible value of Volume /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Volume MaxValue { get; } = new Volume(double.MaxValue, BaseUnit); + public static Volume MaxValue { get; } = new Volume(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of Volume /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Volume MinValue { get; } = new Volume(double.MinValue, BaseUnit); + public static Volume MinValue { get; } = new Volume(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -186,7 +186,7 @@ public Volume(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeter. /// - public static Volume Zero { get; } = new Volume(0, BaseUnit); + public static Volume Zero { get; } = new Volume(0, ConversionBaseUnit); #endregion @@ -200,7 +200,7 @@ public Volume(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public VolumeUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public VolumeUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1458,7 +1458,7 @@ private double GetValueInBaseUnit() internal Volume ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new Volume(baseUnitValue, BaseUnit); + return new Volume(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(VolumeUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 76d63b69a1..0dc762a39e 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -80,7 +80,7 @@ static VolumeConcentration() new UnitInfo(VolumeConcentrationUnit.PicolitersPerLiter, "PicolitersPerLiter", BaseUnits.Undefined), new UnitInfo(VolumeConcentrationUnit.PicolitersPerMililiter, "PicolitersPerMililiter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumeConcentration); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumeConcentration); } /// @@ -130,19 +130,19 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// The base unit of VolumeConcentration, which is DecimalFraction. All conversions go via this value. /// - public static VolumeConcentrationUnit BaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; + public static VolumeConcentrationUnit ConversionBaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; /// /// Represents the largest possible value of VolumeConcentration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, BaseUnit); + public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of VolumeConcentration /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, BaseUnit); + public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -158,7 +158,7 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. /// - public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, BaseUnit); + public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, ConversionBaseUnit); #endregion @@ -172,7 +172,7 @@ public VolumeConcentration(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public VolumeConcentrationUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public VolumeConcentrationUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -965,7 +965,7 @@ private double GetValueInBaseUnit() internal VolumeConcentration ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumeConcentration(baseUnitValue, BaseUnit); + return new VolumeConcentration(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(VolumeConcentrationUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 7ebf98a4bd..c0db9d1afa 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -113,7 +113,7 @@ static VolumeFlow() new UnitInfo(VolumeFlowUnit.UsGallonPerMinute, "UsGallonsPerMinute", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.UsGallonPerSecond, "UsGallonsPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumeFlow); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumeFlow); } /// @@ -163,19 +163,19 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// The base unit of VolumeFlow, which is CubicMeterPerSecond. All conversions go via this value. /// - public static VolumeFlowUnit BaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; + public static VolumeFlowUnit ConversionBaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; /// /// Represents the largest possible value of VolumeFlow /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, BaseUnit); + public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of VolumeFlow /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, BaseUnit); + public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -191,7 +191,7 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerSecond. /// - public static VolumeFlow Zero { get; } = new VolumeFlow(0, BaseUnit); + public static VolumeFlow Zero { get; } = new VolumeFlow(0, ConversionBaseUnit); #endregion @@ -205,7 +205,7 @@ public VolumeFlow(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public VolumeFlowUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public VolumeFlowUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -1538,7 +1538,7 @@ private double GetValueInBaseUnit() internal VolumeFlow ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumeFlow(baseUnitValue, BaseUnit); + return new VolumeFlow(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(VolumeFlowUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 741f79165e..f5f331ffb8 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -64,7 +64,7 @@ static VolumePerLength() new UnitInfo(VolumePerLengthUnit.LiterPerMillimeter, "LitersPerMillimeter", BaseUnits.Undefined), new UnitInfo(VolumePerLengthUnit.OilBarrelPerFoot, "OilBarrelsPerFoot", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumePerLength); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumePerLength); } /// @@ -114,19 +114,19 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// The base unit of VolumePerLength, which is CubicMeterPerMeter. All conversions go via this value. /// - public static VolumePerLengthUnit BaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; + public static VolumePerLengthUnit ConversionBaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; /// /// Represents the largest possible value of VolumePerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, BaseUnit); + public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of VolumePerLength /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, BaseUnit); + public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -142,7 +142,7 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerMeter. /// - public static VolumePerLength Zero { get; } = new VolumePerLength(0, BaseUnit); + public static VolumePerLength Zero { get; } = new VolumePerLength(0, ConversionBaseUnit); #endregion @@ -156,7 +156,7 @@ public VolumePerLength(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public VolumePerLengthUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public VolumePerLengthUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -754,7 +754,7 @@ private double GetValueInBaseUnit() internal VolumePerLength ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumePerLength(baseUnitValue, BaseUnit); + return new VolumePerLength(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(VolumePerLengthUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index ca83ca00da..8bbd3df326 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -69,7 +69,7 @@ static VolumetricHeatCapacity() new UnitInfo(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, "MegajoulesPerCubicMeterDegreeCelsius", BaseUnits.Undefined), new UnitInfo(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, "MegajoulesPerCubicMeterKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumetricHeatCapacity); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumetricHeatCapacity); } /// @@ -119,19 +119,19 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// /// The base unit of VolumetricHeatCapacity, which is JoulePerCubicMeterKelvin. All conversions go via this value. /// - public static VolumetricHeatCapacityUnit BaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; + public static VolumetricHeatCapacityUnit ConversionBaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; /// /// Represents the largest possible value of VolumetricHeatCapacity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, BaseUnit); + public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of VolumetricHeatCapacity /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, BaseUnit); + public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -147,7 +147,7 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerCubicMeterKelvin. /// - public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, BaseUnit); + public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, ConversionBaseUnit); #endregion @@ -161,7 +161,7 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public VolumetricHeatCapacityUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public VolumetricHeatCapacityUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -789,7 +789,7 @@ private double GetValueInBaseUnit() internal VolumetricHeatCapacity ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new VolumetricHeatCapacity(baseUnitValue, BaseUnit); + return new VolumetricHeatCapacity(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(VolumetricHeatCapacityUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 6ae795df69..dd62fe3ff9 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -63,7 +63,7 @@ static WarpingMomentOfInertia() new UnitInfo(WarpingMomentOfInertiaUnit.MeterToTheSixth, "MetersToTheSixth", new BaseUnits(length: LengthUnit.Meter)), new UnitInfo(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, "MillimetersToTheSixth", new BaseUnits(length: LengthUnit.Millimeter)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.WarpingMomentOfInertia); + ConversionBaseUnit, Zero, BaseDimensions, QuantityType.WarpingMomentOfInertia); } /// @@ -113,19 +113,19 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// The base unit of WarpingMomentOfInertia, which is MeterToTheSixth. All conversions go via this value. /// - public static WarpingMomentOfInertiaUnit BaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; + public static WarpingMomentOfInertiaUnit ConversionBaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; /// /// Represents the largest possible value of WarpingMomentOfInertia /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, BaseUnit); + public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, ConversionBaseUnit); /// /// Represents the smallest possible value of WarpingMomentOfInertia /// [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, BaseUnit); + public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, ConversionBaseUnit); /// /// The of this quantity. @@ -141,7 +141,7 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheSixth. /// - public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, BaseUnit); + public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, ConversionBaseUnit); #endregion @@ -155,7 +155,7 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) Enum IQuantity.Unit => Unit; /// - public WarpingMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(BaseUnit); + public WarpingMomentOfInertiaUnit Unit => _unit.GetValueOrDefault(ConversionBaseUnit); /// public QuantityInfo QuantityInfo => Info; @@ -738,7 +738,7 @@ private double GetValueInBaseUnit() internal WarpingMomentOfInertia ToBaseUnit() { var baseUnitValue = GetValueInBaseUnit(); - return new WarpingMomentOfInertia(baseUnitValue, BaseUnit); + return new WarpingMomentOfInertia(baseUnitValue, ConversionBaseUnit); } private double GetValueAs(WarpingMomentOfInertiaUnit unit) diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 44f07e2aa5..3197988463 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -278,225 +278,225 @@ public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValu switch(quantityType) { case QuantityType.Acceleration: - return Acceleration.From(value, Acceleration.BaseUnit); + return Acceleration.From(value, Acceleration.ConversionBaseUnit); case QuantityType.AmountOfSubstance: - return AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit); + return AmountOfSubstance.From(value, AmountOfSubstance.ConversionBaseUnit); case QuantityType.AmplitudeRatio: - return AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit); + return AmplitudeRatio.From(value, AmplitudeRatio.ConversionBaseUnit); case QuantityType.Angle: - return Angle.From(value, Angle.BaseUnit); + return Angle.From(value, Angle.ConversionBaseUnit); case QuantityType.ApparentEnergy: - return ApparentEnergy.From(value, ApparentEnergy.BaseUnit); + return ApparentEnergy.From(value, ApparentEnergy.ConversionBaseUnit); case QuantityType.ApparentPower: - return ApparentPower.From(value, ApparentPower.BaseUnit); + return ApparentPower.From(value, ApparentPower.ConversionBaseUnit); case QuantityType.Area: - return Area.From(value, Area.BaseUnit); + return Area.From(value, Area.ConversionBaseUnit); case QuantityType.AreaDensity: - return AreaDensity.From(value, AreaDensity.BaseUnit); + return AreaDensity.From(value, AreaDensity.ConversionBaseUnit); case QuantityType.AreaMomentOfInertia: - return AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit); + return AreaMomentOfInertia.From(value, AreaMomentOfInertia.ConversionBaseUnit); case QuantityType.BitRate: - return BitRate.From(value, BitRate.BaseUnit); + return BitRate.From(value, BitRate.ConversionBaseUnit); case QuantityType.BrakeSpecificFuelConsumption: - return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit); + return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.ConversionBaseUnit); case QuantityType.Capacitance: - return Capacitance.From(value, Capacitance.BaseUnit); + return Capacitance.From(value, Capacitance.ConversionBaseUnit); case QuantityType.CoefficientOfThermalExpansion: - return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit); + return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.ConversionBaseUnit); case QuantityType.Density: - return Density.From(value, Density.BaseUnit); + return Density.From(value, Density.ConversionBaseUnit); case QuantityType.Duration: - return Duration.From(value, Duration.BaseUnit); + return Duration.From(value, Duration.ConversionBaseUnit); case QuantityType.DynamicViscosity: - return DynamicViscosity.From(value, DynamicViscosity.BaseUnit); + return DynamicViscosity.From(value, DynamicViscosity.ConversionBaseUnit); case QuantityType.ElectricAdmittance: - return ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit); + return ElectricAdmittance.From(value, ElectricAdmittance.ConversionBaseUnit); case QuantityType.ElectricCharge: - return ElectricCharge.From(value, ElectricCharge.BaseUnit); + return ElectricCharge.From(value, ElectricCharge.ConversionBaseUnit); case QuantityType.ElectricChargeDensity: - return ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit); + return ElectricChargeDensity.From(value, ElectricChargeDensity.ConversionBaseUnit); case QuantityType.ElectricConductance: - return ElectricConductance.From(value, ElectricConductance.BaseUnit); + return ElectricConductance.From(value, ElectricConductance.ConversionBaseUnit); case QuantityType.ElectricConductivity: - return ElectricConductivity.From(value, ElectricConductivity.BaseUnit); + return ElectricConductivity.From(value, ElectricConductivity.ConversionBaseUnit); case QuantityType.ElectricCurrent: - return ElectricCurrent.From(value, ElectricCurrent.BaseUnit); + return ElectricCurrent.From(value, ElectricCurrent.ConversionBaseUnit); case QuantityType.ElectricCurrentDensity: - return ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit); + return ElectricCurrentDensity.From(value, ElectricCurrentDensity.ConversionBaseUnit); case QuantityType.ElectricCurrentGradient: - return ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit); + return ElectricCurrentGradient.From(value, ElectricCurrentGradient.ConversionBaseUnit); case QuantityType.ElectricField: - return ElectricField.From(value, ElectricField.BaseUnit); + return ElectricField.From(value, ElectricField.ConversionBaseUnit); case QuantityType.ElectricInductance: - return ElectricInductance.From(value, ElectricInductance.BaseUnit); + return ElectricInductance.From(value, ElectricInductance.ConversionBaseUnit); case QuantityType.ElectricPotential: - return ElectricPotential.From(value, ElectricPotential.BaseUnit); + return ElectricPotential.From(value, ElectricPotential.ConversionBaseUnit); case QuantityType.ElectricPotentialAc: - return ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit); + return ElectricPotentialAc.From(value, ElectricPotentialAc.ConversionBaseUnit); case QuantityType.ElectricPotentialChangeRate: - return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit); + return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.ConversionBaseUnit); case QuantityType.ElectricPotentialDc: - return ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit); + return ElectricPotentialDc.From(value, ElectricPotentialDc.ConversionBaseUnit); case QuantityType.ElectricResistance: - return ElectricResistance.From(value, ElectricResistance.BaseUnit); + return ElectricResistance.From(value, ElectricResistance.ConversionBaseUnit); case QuantityType.ElectricResistivity: - return ElectricResistivity.From(value, ElectricResistivity.BaseUnit); + return ElectricResistivity.From(value, ElectricResistivity.ConversionBaseUnit); case QuantityType.ElectricSurfaceChargeDensity: - return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit); + return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.ConversionBaseUnit); case QuantityType.Energy: - return Energy.From(value, Energy.BaseUnit); + return Energy.From(value, Energy.ConversionBaseUnit); case QuantityType.Entropy: - return Entropy.From(value, Entropy.BaseUnit); + return Entropy.From(value, Entropy.ConversionBaseUnit); case QuantityType.Force: - return Force.From(value, Force.BaseUnit); + return Force.From(value, Force.ConversionBaseUnit); case QuantityType.ForceChangeRate: - return ForceChangeRate.From(value, ForceChangeRate.BaseUnit); + return ForceChangeRate.From(value, ForceChangeRate.ConversionBaseUnit); case QuantityType.ForcePerLength: - return ForcePerLength.From(value, ForcePerLength.BaseUnit); + return ForcePerLength.From(value, ForcePerLength.ConversionBaseUnit); case QuantityType.Frequency: - return Frequency.From(value, Frequency.BaseUnit); + return Frequency.From(value, Frequency.ConversionBaseUnit); case QuantityType.FuelEfficiency: - return FuelEfficiency.From(value, FuelEfficiency.BaseUnit); + return FuelEfficiency.From(value, FuelEfficiency.ConversionBaseUnit); case QuantityType.HeatFlux: - return HeatFlux.From(value, HeatFlux.BaseUnit); + return HeatFlux.From(value, HeatFlux.ConversionBaseUnit); case QuantityType.HeatTransferCoefficient: - return HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit); + return HeatTransferCoefficient.From(value, HeatTransferCoefficient.ConversionBaseUnit); case QuantityType.Illuminance: - return Illuminance.From(value, Illuminance.BaseUnit); + return Illuminance.From(value, Illuminance.ConversionBaseUnit); case QuantityType.Information: - return Information.From(value, Information.BaseUnit); + return Information.From(value, Information.ConversionBaseUnit); case QuantityType.Irradiance: - return Irradiance.From(value, Irradiance.BaseUnit); + return Irradiance.From(value, Irradiance.ConversionBaseUnit); case QuantityType.Irradiation: - return Irradiation.From(value, Irradiation.BaseUnit); + return Irradiation.From(value, Irradiation.ConversionBaseUnit); case QuantityType.KinematicViscosity: - return KinematicViscosity.From(value, KinematicViscosity.BaseUnit); + return KinematicViscosity.From(value, KinematicViscosity.ConversionBaseUnit); case QuantityType.LapseRate: - return LapseRate.From(value, LapseRate.BaseUnit); + return LapseRate.From(value, LapseRate.ConversionBaseUnit); case QuantityType.Length: - return Length.From(value, Length.BaseUnit); + return Length.From(value, Length.ConversionBaseUnit); case QuantityType.Level: - return Level.From(value, Level.BaseUnit); + return Level.From(value, Level.ConversionBaseUnit); case QuantityType.LinearDensity: - return LinearDensity.From(value, LinearDensity.BaseUnit); + return LinearDensity.From(value, LinearDensity.ConversionBaseUnit); case QuantityType.LinearPowerDensity: - return LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit); + return LinearPowerDensity.From(value, LinearPowerDensity.ConversionBaseUnit); case QuantityType.Luminosity: - return Luminosity.From(value, Luminosity.BaseUnit); + return Luminosity.From(value, Luminosity.ConversionBaseUnit); case QuantityType.LuminousFlux: - return LuminousFlux.From(value, LuminousFlux.BaseUnit); + return LuminousFlux.From(value, LuminousFlux.ConversionBaseUnit); case QuantityType.LuminousIntensity: - return LuminousIntensity.From(value, LuminousIntensity.BaseUnit); + return LuminousIntensity.From(value, LuminousIntensity.ConversionBaseUnit); case QuantityType.MagneticField: - return MagneticField.From(value, MagneticField.BaseUnit); + return MagneticField.From(value, MagneticField.ConversionBaseUnit); case QuantityType.MagneticFlux: - return MagneticFlux.From(value, MagneticFlux.BaseUnit); + return MagneticFlux.From(value, MagneticFlux.ConversionBaseUnit); case QuantityType.Magnetization: - return Magnetization.From(value, Magnetization.BaseUnit); + return Magnetization.From(value, Magnetization.ConversionBaseUnit); case QuantityType.Mass: - return Mass.From(value, Mass.BaseUnit); + return Mass.From(value, Mass.ConversionBaseUnit); case QuantityType.MassConcentration: - return MassConcentration.From(value, MassConcentration.BaseUnit); + return MassConcentration.From(value, MassConcentration.ConversionBaseUnit); case QuantityType.MassFlow: - return MassFlow.From(value, MassFlow.BaseUnit); + return MassFlow.From(value, MassFlow.ConversionBaseUnit); case QuantityType.MassFlux: - return MassFlux.From(value, MassFlux.BaseUnit); + return MassFlux.From(value, MassFlux.ConversionBaseUnit); case QuantityType.MassFraction: - return MassFraction.From(value, MassFraction.BaseUnit); + return MassFraction.From(value, MassFraction.ConversionBaseUnit); case QuantityType.MassMomentOfInertia: - return MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit); + return MassMomentOfInertia.From(value, MassMomentOfInertia.ConversionBaseUnit); case QuantityType.MolarEnergy: - return MolarEnergy.From(value, MolarEnergy.BaseUnit); + return MolarEnergy.From(value, MolarEnergy.ConversionBaseUnit); case QuantityType.MolarEntropy: - return MolarEntropy.From(value, MolarEntropy.BaseUnit); + return MolarEntropy.From(value, MolarEntropy.ConversionBaseUnit); case QuantityType.Molarity: - return Molarity.From(value, Molarity.BaseUnit); + return Molarity.From(value, Molarity.ConversionBaseUnit); case QuantityType.MolarMass: - return MolarMass.From(value, MolarMass.BaseUnit); + return MolarMass.From(value, MolarMass.ConversionBaseUnit); case QuantityType.Permeability: - return Permeability.From(value, Permeability.BaseUnit); + return Permeability.From(value, Permeability.ConversionBaseUnit); case QuantityType.Permittivity: - return Permittivity.From(value, Permittivity.BaseUnit); + return Permittivity.From(value, Permittivity.ConversionBaseUnit); case QuantityType.Power: - return Power.From(value, Power.BaseUnit); + return Power.From(value, Power.ConversionBaseUnit); case QuantityType.PowerDensity: - return PowerDensity.From(value, PowerDensity.BaseUnit); + return PowerDensity.From(value, PowerDensity.ConversionBaseUnit); case QuantityType.PowerRatio: - return PowerRatio.From(value, PowerRatio.BaseUnit); + return PowerRatio.From(value, PowerRatio.ConversionBaseUnit); case QuantityType.Pressure: - return Pressure.From(value, Pressure.BaseUnit); + return Pressure.From(value, Pressure.ConversionBaseUnit); case QuantityType.PressureChangeRate: - return PressureChangeRate.From(value, PressureChangeRate.BaseUnit); + return PressureChangeRate.From(value, PressureChangeRate.ConversionBaseUnit); case QuantityType.Ratio: - return Ratio.From(value, Ratio.BaseUnit); + return Ratio.From(value, Ratio.ConversionBaseUnit); case QuantityType.RatioChangeRate: - return RatioChangeRate.From(value, RatioChangeRate.BaseUnit); + return RatioChangeRate.From(value, RatioChangeRate.ConversionBaseUnit); case QuantityType.ReactiveEnergy: - return ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit); + return ReactiveEnergy.From(value, ReactiveEnergy.ConversionBaseUnit); case QuantityType.ReactivePower: - return ReactivePower.From(value, ReactivePower.BaseUnit); + return ReactivePower.From(value, ReactivePower.ConversionBaseUnit); case QuantityType.ReciprocalArea: - return ReciprocalArea.From(value, ReciprocalArea.BaseUnit); + return ReciprocalArea.From(value, ReciprocalArea.ConversionBaseUnit); case QuantityType.ReciprocalLength: - return ReciprocalLength.From(value, ReciprocalLength.BaseUnit); + return ReciprocalLength.From(value, ReciprocalLength.ConversionBaseUnit); case QuantityType.RelativeHumidity: - return RelativeHumidity.From(value, RelativeHumidity.BaseUnit); + return RelativeHumidity.From(value, RelativeHumidity.ConversionBaseUnit); case QuantityType.RotationalAcceleration: - return RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit); + return RotationalAcceleration.From(value, RotationalAcceleration.ConversionBaseUnit); case QuantityType.RotationalSpeed: - return RotationalSpeed.From(value, RotationalSpeed.BaseUnit); + return RotationalSpeed.From(value, RotationalSpeed.ConversionBaseUnit); case QuantityType.RotationalStiffness: - return RotationalStiffness.From(value, RotationalStiffness.BaseUnit); + return RotationalStiffness.From(value, RotationalStiffness.ConversionBaseUnit); case QuantityType.RotationalStiffnessPerLength: - return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit); + return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.ConversionBaseUnit); case QuantityType.Scalar: - return Scalar.From(value, Scalar.BaseUnit); + return Scalar.From(value, Scalar.ConversionBaseUnit); case QuantityType.SolidAngle: - return SolidAngle.From(value, SolidAngle.BaseUnit); + return SolidAngle.From(value, SolidAngle.ConversionBaseUnit); case QuantityType.SpecificEnergy: - return SpecificEnergy.From(value, SpecificEnergy.BaseUnit); + return SpecificEnergy.From(value, SpecificEnergy.ConversionBaseUnit); case QuantityType.SpecificEntropy: - return SpecificEntropy.From(value, SpecificEntropy.BaseUnit); + return SpecificEntropy.From(value, SpecificEntropy.ConversionBaseUnit); case QuantityType.SpecificFuelConsumption: - return SpecificFuelConsumption.From(value, SpecificFuelConsumption.BaseUnit); + return SpecificFuelConsumption.From(value, SpecificFuelConsumption.ConversionBaseUnit); case QuantityType.SpecificVolume: - return SpecificVolume.From(value, SpecificVolume.BaseUnit); + return SpecificVolume.From(value, SpecificVolume.ConversionBaseUnit); case QuantityType.SpecificWeight: - return SpecificWeight.From(value, SpecificWeight.BaseUnit); + return SpecificWeight.From(value, SpecificWeight.ConversionBaseUnit); case QuantityType.Speed: - return Speed.From(value, Speed.BaseUnit); + return Speed.From(value, Speed.ConversionBaseUnit); case QuantityType.StandardVolumeFlow: - return StandardVolumeFlow.From(value, StandardVolumeFlow.BaseUnit); + return StandardVolumeFlow.From(value, StandardVolumeFlow.ConversionBaseUnit); case QuantityType.Temperature: - return Temperature.From(value, Temperature.BaseUnit); + return Temperature.From(value, Temperature.ConversionBaseUnit); case QuantityType.TemperatureChangeRate: - return TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit); + return TemperatureChangeRate.From(value, TemperatureChangeRate.ConversionBaseUnit); case QuantityType.TemperatureDelta: - return TemperatureDelta.From(value, TemperatureDelta.BaseUnit); + return TemperatureDelta.From(value, TemperatureDelta.ConversionBaseUnit); case QuantityType.ThermalConductivity: - return ThermalConductivity.From(value, ThermalConductivity.BaseUnit); + return ThermalConductivity.From(value, ThermalConductivity.ConversionBaseUnit); case QuantityType.ThermalResistance: - return ThermalResistance.From(value, ThermalResistance.BaseUnit); + return ThermalResistance.From(value, ThermalResistance.ConversionBaseUnit); case QuantityType.Torque: - return Torque.From(value, Torque.BaseUnit); + return Torque.From(value, Torque.ConversionBaseUnit); case QuantityType.TorquePerLength: - return TorquePerLength.From(value, TorquePerLength.BaseUnit); + return TorquePerLength.From(value, TorquePerLength.ConversionBaseUnit); case QuantityType.Turbidity: - return Turbidity.From(value, Turbidity.BaseUnit); + return Turbidity.From(value, Turbidity.ConversionBaseUnit); case QuantityType.VitaminA: - return VitaminA.From(value, VitaminA.BaseUnit); + return VitaminA.From(value, VitaminA.ConversionBaseUnit); case QuantityType.Volume: - return Volume.From(value, Volume.BaseUnit); + return Volume.From(value, Volume.ConversionBaseUnit); case QuantityType.VolumeConcentration: - return VolumeConcentration.From(value, VolumeConcentration.BaseUnit); + return VolumeConcentration.From(value, VolumeConcentration.ConversionBaseUnit); case QuantityType.VolumeFlow: - return VolumeFlow.From(value, VolumeFlow.BaseUnit); + return VolumeFlow.From(value, VolumeFlow.ConversionBaseUnit); case QuantityType.VolumePerLength: - return VolumePerLength.From(value, VolumePerLength.BaseUnit); + return VolumePerLength.From(value, VolumePerLength.ConversionBaseUnit); case QuantityType.VolumetricHeatCapacity: - return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.BaseUnit); + return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.ConversionBaseUnit); case QuantityType.WarpingMomentOfInertia: - return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit); + return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.ConversionBaseUnit); default: throw new ArgumentException($"{quantityType} is not a supported quantity type."); } @@ -513,225 +513,225 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu switch(quantityInfo.Name) { case "Acceleration": - return Acceleration.From(value, Acceleration.BaseUnit); + return Acceleration.From(value, Acceleration.ConversionBaseUnit); case "AmountOfSubstance": - return AmountOfSubstance.From(value, AmountOfSubstance.BaseUnit); + return AmountOfSubstance.From(value, AmountOfSubstance.ConversionBaseUnit); case "AmplitudeRatio": - return AmplitudeRatio.From(value, AmplitudeRatio.BaseUnit); + return AmplitudeRatio.From(value, AmplitudeRatio.ConversionBaseUnit); case "Angle": - return Angle.From(value, Angle.BaseUnit); + return Angle.From(value, Angle.ConversionBaseUnit); case "ApparentEnergy": - return ApparentEnergy.From(value, ApparentEnergy.BaseUnit); + return ApparentEnergy.From(value, ApparentEnergy.ConversionBaseUnit); case "ApparentPower": - return ApparentPower.From(value, ApparentPower.BaseUnit); + return ApparentPower.From(value, ApparentPower.ConversionBaseUnit); case "Area": - return Area.From(value, Area.BaseUnit); + return Area.From(value, Area.ConversionBaseUnit); case "AreaDensity": - return AreaDensity.From(value, AreaDensity.BaseUnit); + return AreaDensity.From(value, AreaDensity.ConversionBaseUnit); case "AreaMomentOfInertia": - return AreaMomentOfInertia.From(value, AreaMomentOfInertia.BaseUnit); + return AreaMomentOfInertia.From(value, AreaMomentOfInertia.ConversionBaseUnit); case "BitRate": - return BitRate.From(value, BitRate.BaseUnit); + return BitRate.From(value, BitRate.ConversionBaseUnit); case "BrakeSpecificFuelConsumption": - return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.BaseUnit); + return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.ConversionBaseUnit); case "Capacitance": - return Capacitance.From(value, Capacitance.BaseUnit); + return Capacitance.From(value, Capacitance.ConversionBaseUnit); case "CoefficientOfThermalExpansion": - return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.BaseUnit); + return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.ConversionBaseUnit); case "Density": - return Density.From(value, Density.BaseUnit); + return Density.From(value, Density.ConversionBaseUnit); case "Duration": - return Duration.From(value, Duration.BaseUnit); + return Duration.From(value, Duration.ConversionBaseUnit); case "DynamicViscosity": - return DynamicViscosity.From(value, DynamicViscosity.BaseUnit); + return DynamicViscosity.From(value, DynamicViscosity.ConversionBaseUnit); case "ElectricAdmittance": - return ElectricAdmittance.From(value, ElectricAdmittance.BaseUnit); + return ElectricAdmittance.From(value, ElectricAdmittance.ConversionBaseUnit); case "ElectricCharge": - return ElectricCharge.From(value, ElectricCharge.BaseUnit); + return ElectricCharge.From(value, ElectricCharge.ConversionBaseUnit); case "ElectricChargeDensity": - return ElectricChargeDensity.From(value, ElectricChargeDensity.BaseUnit); + return ElectricChargeDensity.From(value, ElectricChargeDensity.ConversionBaseUnit); case "ElectricConductance": - return ElectricConductance.From(value, ElectricConductance.BaseUnit); + return ElectricConductance.From(value, ElectricConductance.ConversionBaseUnit); case "ElectricConductivity": - return ElectricConductivity.From(value, ElectricConductivity.BaseUnit); + return ElectricConductivity.From(value, ElectricConductivity.ConversionBaseUnit); case "ElectricCurrent": - return ElectricCurrent.From(value, ElectricCurrent.BaseUnit); + return ElectricCurrent.From(value, ElectricCurrent.ConversionBaseUnit); case "ElectricCurrentDensity": - return ElectricCurrentDensity.From(value, ElectricCurrentDensity.BaseUnit); + return ElectricCurrentDensity.From(value, ElectricCurrentDensity.ConversionBaseUnit); case "ElectricCurrentGradient": - return ElectricCurrentGradient.From(value, ElectricCurrentGradient.BaseUnit); + return ElectricCurrentGradient.From(value, ElectricCurrentGradient.ConversionBaseUnit); case "ElectricField": - return ElectricField.From(value, ElectricField.BaseUnit); + return ElectricField.From(value, ElectricField.ConversionBaseUnit); case "ElectricInductance": - return ElectricInductance.From(value, ElectricInductance.BaseUnit); + return ElectricInductance.From(value, ElectricInductance.ConversionBaseUnit); case "ElectricPotential": - return ElectricPotential.From(value, ElectricPotential.BaseUnit); + return ElectricPotential.From(value, ElectricPotential.ConversionBaseUnit); case "ElectricPotentialAc": - return ElectricPotentialAc.From(value, ElectricPotentialAc.BaseUnit); + return ElectricPotentialAc.From(value, ElectricPotentialAc.ConversionBaseUnit); case "ElectricPotentialChangeRate": - return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.BaseUnit); + return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.ConversionBaseUnit); case "ElectricPotentialDc": - return ElectricPotentialDc.From(value, ElectricPotentialDc.BaseUnit); + return ElectricPotentialDc.From(value, ElectricPotentialDc.ConversionBaseUnit); case "ElectricResistance": - return ElectricResistance.From(value, ElectricResistance.BaseUnit); + return ElectricResistance.From(value, ElectricResistance.ConversionBaseUnit); case "ElectricResistivity": - return ElectricResistivity.From(value, ElectricResistivity.BaseUnit); + return ElectricResistivity.From(value, ElectricResistivity.ConversionBaseUnit); case "ElectricSurfaceChargeDensity": - return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.BaseUnit); + return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.ConversionBaseUnit); case "Energy": - return Energy.From(value, Energy.BaseUnit); + return Energy.From(value, Energy.ConversionBaseUnit); case "Entropy": - return Entropy.From(value, Entropy.BaseUnit); + return Entropy.From(value, Entropy.ConversionBaseUnit); case "Force": - return Force.From(value, Force.BaseUnit); + return Force.From(value, Force.ConversionBaseUnit); case "ForceChangeRate": - return ForceChangeRate.From(value, ForceChangeRate.BaseUnit); + return ForceChangeRate.From(value, ForceChangeRate.ConversionBaseUnit); case "ForcePerLength": - return ForcePerLength.From(value, ForcePerLength.BaseUnit); + return ForcePerLength.From(value, ForcePerLength.ConversionBaseUnit); case "Frequency": - return Frequency.From(value, Frequency.BaseUnit); + return Frequency.From(value, Frequency.ConversionBaseUnit); case "FuelEfficiency": - return FuelEfficiency.From(value, FuelEfficiency.BaseUnit); + return FuelEfficiency.From(value, FuelEfficiency.ConversionBaseUnit); case "HeatFlux": - return HeatFlux.From(value, HeatFlux.BaseUnit); + return HeatFlux.From(value, HeatFlux.ConversionBaseUnit); case "HeatTransferCoefficient": - return HeatTransferCoefficient.From(value, HeatTransferCoefficient.BaseUnit); + return HeatTransferCoefficient.From(value, HeatTransferCoefficient.ConversionBaseUnit); case "Illuminance": - return Illuminance.From(value, Illuminance.BaseUnit); + return Illuminance.From(value, Illuminance.ConversionBaseUnit); case "Information": - return Information.From(value, Information.BaseUnit); + return Information.From(value, Information.ConversionBaseUnit); case "Irradiance": - return Irradiance.From(value, Irradiance.BaseUnit); + return Irradiance.From(value, Irradiance.ConversionBaseUnit); case "Irradiation": - return Irradiation.From(value, Irradiation.BaseUnit); + return Irradiation.From(value, Irradiation.ConversionBaseUnit); case "KinematicViscosity": - return KinematicViscosity.From(value, KinematicViscosity.BaseUnit); + return KinematicViscosity.From(value, KinematicViscosity.ConversionBaseUnit); case "LapseRate": - return LapseRate.From(value, LapseRate.BaseUnit); + return LapseRate.From(value, LapseRate.ConversionBaseUnit); case "Length": - return Length.From(value, Length.BaseUnit); + return Length.From(value, Length.ConversionBaseUnit); case "Level": - return Level.From(value, Level.BaseUnit); + return Level.From(value, Level.ConversionBaseUnit); case "LinearDensity": - return LinearDensity.From(value, LinearDensity.BaseUnit); + return LinearDensity.From(value, LinearDensity.ConversionBaseUnit); case "LinearPowerDensity": - return LinearPowerDensity.From(value, LinearPowerDensity.BaseUnit); + return LinearPowerDensity.From(value, LinearPowerDensity.ConversionBaseUnit); case "Luminosity": - return Luminosity.From(value, Luminosity.BaseUnit); + return Luminosity.From(value, Luminosity.ConversionBaseUnit); case "LuminousFlux": - return LuminousFlux.From(value, LuminousFlux.BaseUnit); + return LuminousFlux.From(value, LuminousFlux.ConversionBaseUnit); case "LuminousIntensity": - return LuminousIntensity.From(value, LuminousIntensity.BaseUnit); + return LuminousIntensity.From(value, LuminousIntensity.ConversionBaseUnit); case "MagneticField": - return MagneticField.From(value, MagneticField.BaseUnit); + return MagneticField.From(value, MagneticField.ConversionBaseUnit); case "MagneticFlux": - return MagneticFlux.From(value, MagneticFlux.BaseUnit); + return MagneticFlux.From(value, MagneticFlux.ConversionBaseUnit); case "Magnetization": - return Magnetization.From(value, Magnetization.BaseUnit); + return Magnetization.From(value, Magnetization.ConversionBaseUnit); case "Mass": - return Mass.From(value, Mass.BaseUnit); + return Mass.From(value, Mass.ConversionBaseUnit); case "MassConcentration": - return MassConcentration.From(value, MassConcentration.BaseUnit); + return MassConcentration.From(value, MassConcentration.ConversionBaseUnit); case "MassFlow": - return MassFlow.From(value, MassFlow.BaseUnit); + return MassFlow.From(value, MassFlow.ConversionBaseUnit); case "MassFlux": - return MassFlux.From(value, MassFlux.BaseUnit); + return MassFlux.From(value, MassFlux.ConversionBaseUnit); case "MassFraction": - return MassFraction.From(value, MassFraction.BaseUnit); + return MassFraction.From(value, MassFraction.ConversionBaseUnit); case "MassMomentOfInertia": - return MassMomentOfInertia.From(value, MassMomentOfInertia.BaseUnit); + return MassMomentOfInertia.From(value, MassMomentOfInertia.ConversionBaseUnit); case "MolarEnergy": - return MolarEnergy.From(value, MolarEnergy.BaseUnit); + return MolarEnergy.From(value, MolarEnergy.ConversionBaseUnit); case "MolarEntropy": - return MolarEntropy.From(value, MolarEntropy.BaseUnit); + return MolarEntropy.From(value, MolarEntropy.ConversionBaseUnit); case "Molarity": - return Molarity.From(value, Molarity.BaseUnit); + return Molarity.From(value, Molarity.ConversionBaseUnit); case "MolarMass": - return MolarMass.From(value, MolarMass.BaseUnit); + return MolarMass.From(value, MolarMass.ConversionBaseUnit); case "Permeability": - return Permeability.From(value, Permeability.BaseUnit); + return Permeability.From(value, Permeability.ConversionBaseUnit); case "Permittivity": - return Permittivity.From(value, Permittivity.BaseUnit); + return Permittivity.From(value, Permittivity.ConversionBaseUnit); case "Power": - return Power.From(value, Power.BaseUnit); + return Power.From(value, Power.ConversionBaseUnit); case "PowerDensity": - return PowerDensity.From(value, PowerDensity.BaseUnit); + return PowerDensity.From(value, PowerDensity.ConversionBaseUnit); case "PowerRatio": - return PowerRatio.From(value, PowerRatio.BaseUnit); + return PowerRatio.From(value, PowerRatio.ConversionBaseUnit); case "Pressure": - return Pressure.From(value, Pressure.BaseUnit); + return Pressure.From(value, Pressure.ConversionBaseUnit); case "PressureChangeRate": - return PressureChangeRate.From(value, PressureChangeRate.BaseUnit); + return PressureChangeRate.From(value, PressureChangeRate.ConversionBaseUnit); case "Ratio": - return Ratio.From(value, Ratio.BaseUnit); + return Ratio.From(value, Ratio.ConversionBaseUnit); case "RatioChangeRate": - return RatioChangeRate.From(value, RatioChangeRate.BaseUnit); + return RatioChangeRate.From(value, RatioChangeRate.ConversionBaseUnit); case "ReactiveEnergy": - return ReactiveEnergy.From(value, ReactiveEnergy.BaseUnit); + return ReactiveEnergy.From(value, ReactiveEnergy.ConversionBaseUnit); case "ReactivePower": - return ReactivePower.From(value, ReactivePower.BaseUnit); + return ReactivePower.From(value, ReactivePower.ConversionBaseUnit); case "ReciprocalArea": - return ReciprocalArea.From(value, ReciprocalArea.BaseUnit); + return ReciprocalArea.From(value, ReciprocalArea.ConversionBaseUnit); case "ReciprocalLength": - return ReciprocalLength.From(value, ReciprocalLength.BaseUnit); + return ReciprocalLength.From(value, ReciprocalLength.ConversionBaseUnit); case "RelativeHumidity": - return RelativeHumidity.From(value, RelativeHumidity.BaseUnit); + return RelativeHumidity.From(value, RelativeHumidity.ConversionBaseUnit); case "RotationalAcceleration": - return RotationalAcceleration.From(value, RotationalAcceleration.BaseUnit); + return RotationalAcceleration.From(value, RotationalAcceleration.ConversionBaseUnit); case "RotationalSpeed": - return RotationalSpeed.From(value, RotationalSpeed.BaseUnit); + return RotationalSpeed.From(value, RotationalSpeed.ConversionBaseUnit); case "RotationalStiffness": - return RotationalStiffness.From(value, RotationalStiffness.BaseUnit); + return RotationalStiffness.From(value, RotationalStiffness.ConversionBaseUnit); case "RotationalStiffnessPerLength": - return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.BaseUnit); + return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.ConversionBaseUnit); case "Scalar": - return Scalar.From(value, Scalar.BaseUnit); + return Scalar.From(value, Scalar.ConversionBaseUnit); case "SolidAngle": - return SolidAngle.From(value, SolidAngle.BaseUnit); + return SolidAngle.From(value, SolidAngle.ConversionBaseUnit); case "SpecificEnergy": - return SpecificEnergy.From(value, SpecificEnergy.BaseUnit); + return SpecificEnergy.From(value, SpecificEnergy.ConversionBaseUnit); case "SpecificEntropy": - return SpecificEntropy.From(value, SpecificEntropy.BaseUnit); + return SpecificEntropy.From(value, SpecificEntropy.ConversionBaseUnit); case "SpecificFuelConsumption": - return SpecificFuelConsumption.From(value, SpecificFuelConsumption.BaseUnit); + return SpecificFuelConsumption.From(value, SpecificFuelConsumption.ConversionBaseUnit); case "SpecificVolume": - return SpecificVolume.From(value, SpecificVolume.BaseUnit); + return SpecificVolume.From(value, SpecificVolume.ConversionBaseUnit); case "SpecificWeight": - return SpecificWeight.From(value, SpecificWeight.BaseUnit); + return SpecificWeight.From(value, SpecificWeight.ConversionBaseUnit); case "Speed": - return Speed.From(value, Speed.BaseUnit); + return Speed.From(value, Speed.ConversionBaseUnit); case "StandardVolumeFlow": - return StandardVolumeFlow.From(value, StandardVolumeFlow.BaseUnit); + return StandardVolumeFlow.From(value, StandardVolumeFlow.ConversionBaseUnit); case "Temperature": - return Temperature.From(value, Temperature.BaseUnit); + return Temperature.From(value, Temperature.ConversionBaseUnit); case "TemperatureChangeRate": - return TemperatureChangeRate.From(value, TemperatureChangeRate.BaseUnit); + return TemperatureChangeRate.From(value, TemperatureChangeRate.ConversionBaseUnit); case "TemperatureDelta": - return TemperatureDelta.From(value, TemperatureDelta.BaseUnit); + return TemperatureDelta.From(value, TemperatureDelta.ConversionBaseUnit); case "ThermalConductivity": - return ThermalConductivity.From(value, ThermalConductivity.BaseUnit); + return ThermalConductivity.From(value, ThermalConductivity.ConversionBaseUnit); case "ThermalResistance": - return ThermalResistance.From(value, ThermalResistance.BaseUnit); + return ThermalResistance.From(value, ThermalResistance.ConversionBaseUnit); case "Torque": - return Torque.From(value, Torque.BaseUnit); + return Torque.From(value, Torque.ConversionBaseUnit); case "TorquePerLength": - return TorquePerLength.From(value, TorquePerLength.BaseUnit); + return TorquePerLength.From(value, TorquePerLength.ConversionBaseUnit); case "Turbidity": - return Turbidity.From(value, Turbidity.BaseUnit); + return Turbidity.From(value, Turbidity.ConversionBaseUnit); case "VitaminA": - return VitaminA.From(value, VitaminA.BaseUnit); + return VitaminA.From(value, VitaminA.ConversionBaseUnit); case "Volume": - return Volume.From(value, Volume.BaseUnit); + return Volume.From(value, Volume.ConversionBaseUnit); case "VolumeConcentration": - return VolumeConcentration.From(value, VolumeConcentration.BaseUnit); + return VolumeConcentration.From(value, VolumeConcentration.ConversionBaseUnit); case "VolumeFlow": - return VolumeFlow.From(value, VolumeFlow.BaseUnit); + return VolumeFlow.From(value, VolumeFlow.ConversionBaseUnit); case "VolumePerLength": - return VolumePerLength.From(value, VolumePerLength.BaseUnit); + return VolumePerLength.From(value, VolumePerLength.ConversionBaseUnit); case "VolumetricHeatCapacity": - return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.BaseUnit); + return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.ConversionBaseUnit); case "WarpingMomentOfInertia": - return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.BaseUnit); + return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.ConversionBaseUnit); default: throw new ArgumentException($"{quantityInfo.Name} is not a supported quantity."); } diff --git a/UnitsNet/GeneratedCode/UnitConverter.g.cs b/UnitsNet/GeneratedCode/UnitConverter.g.cs index 88ecc635d7..0bf220153f 100644 --- a/UnitsNet/GeneratedCode/UnitConverter.g.cs +++ b/UnitsNet/GeneratedCode/UnitConverter.g.cs @@ -32,2548 +32,2548 @@ public sealed partial class UnitConverter /// The to register the default conversion functions in. public static void RegisterDefaultConversions(UnitConverter unitConverter) { - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.CentimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.CentimeterPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.CentimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.DecimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.DecimeterPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.DecimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.FootPerSecondSquared, q => q.ToUnit(AccelerationUnit.FootPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.FootPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.InchPerSecondSquared, q => q.ToUnit(AccelerationUnit.InchPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.InchPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KilometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.KilometerPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.KilometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KnotPerHour, q => q.ToUnit(AccelerationUnit.KnotPerHour)); - unitConverter.SetConversionFunction(AccelerationUnit.KnotPerHour, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KnotPerMinute, q => q.ToUnit(AccelerationUnit.KnotPerMinute)); - unitConverter.SetConversionFunction(AccelerationUnit.KnotPerMinute, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.KnotPerSecond, q => q.ToUnit(AccelerationUnit.KnotPerSecond)); - unitConverter.SetConversionFunction(AccelerationUnit.KnotPerSecond, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, Acceleration.BaseUnit, q => q); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.MicrometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.MicrometerPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.MicrometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.MillimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.MillimeterPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.MillimeterPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.MillistandardGravity, q => q.ToUnit(AccelerationUnit.MillistandardGravity)); - unitConverter.SetConversionFunction(AccelerationUnit.MillistandardGravity, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.NanometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.NanometerPerSecondSquared)); - unitConverter.SetConversionFunction(AccelerationUnit.NanometerPerSecondSquared, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Acceleration.BaseUnit, AccelerationUnit.StandardGravity, q => q.ToUnit(AccelerationUnit.StandardGravity)); - unitConverter.SetConversionFunction(AccelerationUnit.StandardGravity, Acceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Centimole, q => q.ToUnit(AmountOfSubstanceUnit.Centimole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Centimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.CentipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.CentipoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.CentipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Decimole, q => q.ToUnit(AmountOfSubstanceUnit.Decimole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Decimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.DecipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.DecipoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.DecipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Kilomole, q => q.ToUnit(AmountOfSubstanceUnit.Kilomole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Kilomole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.KilopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.KilopoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.KilopoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Megamole, q => q.ToUnit(AmountOfSubstanceUnit.Megamole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Megamole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Micromole, q => q.ToUnit(AmountOfSubstanceUnit.Micromole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Micromole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.MicropoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MicropoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.MicropoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Millimole, q => q.ToUnit(AmountOfSubstanceUnit.Millimole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Millimole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.MillipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MillipoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.MillipoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstance.BaseUnit, q => q); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.Nanomole, q => q.ToUnit(AmountOfSubstanceUnit.Nanomole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Nanomole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.NanopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.NanopoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.NanopoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmountOfSubstance.BaseUnit, AmountOfSubstanceUnit.PoundMole, q => q.ToUnit(AmountOfSubstanceUnit.PoundMole)); - unitConverter.SetConversionFunction(AmountOfSubstanceUnit.PoundMole, AmountOfSubstance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelMicrovolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt)); - unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelMillivolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMillivolt)); - unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelMillivolt, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatioUnit.DecibelUnloaded, q => q.ToUnit(AmplitudeRatioUnit.DecibelUnloaded)); - unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelUnloaded, AmplitudeRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AmplitudeRatio.BaseUnit, AmplitudeRatio.BaseUnit, q => q); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Arcminute, q => q.ToUnit(AngleUnit.Arcminute)); - unitConverter.SetConversionFunction(AngleUnit.Arcminute, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Arcsecond, q => q.ToUnit(AngleUnit.Arcsecond)); - unitConverter.SetConversionFunction(AngleUnit.Arcsecond, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Centiradian, q => q.ToUnit(AngleUnit.Centiradian)); - unitConverter.SetConversionFunction(AngleUnit.Centiradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Deciradian, q => q.ToUnit(AngleUnit.Deciradian)); - unitConverter.SetConversionFunction(AngleUnit.Deciradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, Angle.BaseUnit, q => q); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Gradian, q => q.ToUnit(AngleUnit.Gradian)); - unitConverter.SetConversionFunction(AngleUnit.Gradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Microdegree, q => q.ToUnit(AngleUnit.Microdegree)); - unitConverter.SetConversionFunction(AngleUnit.Microdegree, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Microradian, q => q.ToUnit(AngleUnit.Microradian)); - unitConverter.SetConversionFunction(AngleUnit.Microradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Millidegree, q => q.ToUnit(AngleUnit.Millidegree)); - unitConverter.SetConversionFunction(AngleUnit.Millidegree, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Milliradian, q => q.ToUnit(AngleUnit.Milliradian)); - unitConverter.SetConversionFunction(AngleUnit.Milliradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Nanodegree, q => q.ToUnit(AngleUnit.Nanodegree)); - unitConverter.SetConversionFunction(AngleUnit.Nanodegree, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Nanoradian, q => q.ToUnit(AngleUnit.Nanoradian)); - unitConverter.SetConversionFunction(AngleUnit.Nanoradian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.NatoMil, q => q.ToUnit(AngleUnit.NatoMil)); - unitConverter.SetConversionFunction(AngleUnit.NatoMil, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Radian, q => q.ToUnit(AngleUnit.Radian)); - unitConverter.SetConversionFunction(AngleUnit.Radian, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Revolution, q => q.ToUnit(AngleUnit.Revolution)); - unitConverter.SetConversionFunction(AngleUnit.Revolution, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Angle.BaseUnit, AngleUnit.Tilt, q => q.ToUnit(AngleUnit.Tilt)); - unitConverter.SetConversionFunction(AngleUnit.Tilt, Angle.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentEnergy.BaseUnit, ApparentEnergyUnit.KilovoltampereHour, q => q.ToUnit(ApparentEnergyUnit.KilovoltampereHour)); - unitConverter.SetConversionFunction(ApparentEnergyUnit.KilovoltampereHour, ApparentEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentEnergy.BaseUnit, ApparentEnergyUnit.MegavoltampereHour, q => q.ToUnit(ApparentEnergyUnit.MegavoltampereHour)); - unitConverter.SetConversionFunction(ApparentEnergyUnit.MegavoltampereHour, ApparentEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentEnergy.BaseUnit, ApparentEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPowerUnit.Gigavoltampere, q => q.ToUnit(ApparentPowerUnit.Gigavoltampere)); - unitConverter.SetConversionFunction(ApparentPowerUnit.Gigavoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPowerUnit.Kilovoltampere, q => q.ToUnit(ApparentPowerUnit.Kilovoltampere)); - unitConverter.SetConversionFunction(ApparentPowerUnit.Kilovoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPowerUnit.Megavoltampere, q => q.ToUnit(ApparentPowerUnit.Megavoltampere)); - unitConverter.SetConversionFunction(ApparentPowerUnit.Megavoltampere, ApparentPower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ApparentPower.BaseUnit, ApparentPower.BaseUnit, q => q); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.Acre, q => q.ToUnit(AreaUnit.Acre)); - unitConverter.SetConversionFunction(AreaUnit.Acre, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.Hectare, q => q.ToUnit(AreaUnit.Hectare)); - unitConverter.SetConversionFunction(AreaUnit.Hectare, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareCentimeter, q => q.ToUnit(AreaUnit.SquareCentimeter)); - unitConverter.SetConversionFunction(AreaUnit.SquareCentimeter, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareDecimeter, q => q.ToUnit(AreaUnit.SquareDecimeter)); - unitConverter.SetConversionFunction(AreaUnit.SquareDecimeter, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareFoot, q => q.ToUnit(AreaUnit.SquareFoot)); - unitConverter.SetConversionFunction(AreaUnit.SquareFoot, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareInch, q => q.ToUnit(AreaUnit.SquareInch)); - unitConverter.SetConversionFunction(AreaUnit.SquareInch, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareKilometer, q => q.ToUnit(AreaUnit.SquareKilometer)); - unitConverter.SetConversionFunction(AreaUnit.SquareKilometer, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, Area.BaseUnit, q => q); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareMicrometer, q => q.ToUnit(AreaUnit.SquareMicrometer)); - unitConverter.SetConversionFunction(AreaUnit.SquareMicrometer, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareMile, q => q.ToUnit(AreaUnit.SquareMile)); - unitConverter.SetConversionFunction(AreaUnit.SquareMile, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareMillimeter, q => q.ToUnit(AreaUnit.SquareMillimeter)); - unitConverter.SetConversionFunction(AreaUnit.SquareMillimeter, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareNauticalMile, q => q.ToUnit(AreaUnit.SquareNauticalMile)); - unitConverter.SetConversionFunction(AreaUnit.SquareNauticalMile, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.SquareYard, q => q.ToUnit(AreaUnit.SquareYard)); - unitConverter.SetConversionFunction(AreaUnit.SquareYard, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Area.BaseUnit, AreaUnit.UsSurveySquareFoot, q => q.ToUnit(AreaUnit.UsSurveySquareFoot)); - unitConverter.SetConversionFunction(AreaUnit.UsSurveySquareFoot, Area.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaDensity.BaseUnit, AreaDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.CentimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.CentimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.DecimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.DecimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.FootToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.FootToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.InchToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.InchToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertia.BaseUnit, q => q); - unitConverter.SetConversionFunction(AreaMomentOfInertia.BaseUnit, AreaMomentOfInertiaUnit.MillimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth)); - unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MillimeterToTheFourth, AreaMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.BytePerSecond, q => q.ToUnit(BitRateUnit.BytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.BytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExabitPerSecond, q => q.ToUnit(BitRateUnit.ExabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExabytePerSecond, q => q.ToUnit(BitRateUnit.ExabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExbibitPerSecond, q => q.ToUnit(BitRateUnit.ExbibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExbibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.ExbibytePerSecond, q => q.ToUnit(BitRateUnit.ExbibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.ExbibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GibibitPerSecond, q => q.ToUnit(BitRateUnit.GibibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GibibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GibibytePerSecond, q => q.ToUnit(BitRateUnit.GibibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GibibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GigabitPerSecond, q => q.ToUnit(BitRateUnit.GigabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GigabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.GigabytePerSecond, q => q.ToUnit(BitRateUnit.GigabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.GigabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KibibitPerSecond, q => q.ToUnit(BitRateUnit.KibibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KibibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KibibytePerSecond, q => q.ToUnit(BitRateUnit.KibibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KibibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KilobitPerSecond, q => q.ToUnit(BitRateUnit.KilobitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KilobitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.KilobytePerSecond, q => q.ToUnit(BitRateUnit.KilobytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.KilobytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MebibitPerSecond, q => q.ToUnit(BitRateUnit.MebibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MebibytePerSecond, q => q.ToUnit(BitRateUnit.MebibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MegabitPerSecond, q => q.ToUnit(BitRateUnit.MegabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MegabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.MegabytePerSecond, q => q.ToUnit(BitRateUnit.MegabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.MegabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PebibitPerSecond, q => q.ToUnit(BitRateUnit.PebibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PebibytePerSecond, q => q.ToUnit(BitRateUnit.PebibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PetabitPerSecond, q => q.ToUnit(BitRateUnit.PetabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PetabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.PetabytePerSecond, q => q.ToUnit(BitRateUnit.PetabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.PetabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TebibitPerSecond, q => q.ToUnit(BitRateUnit.TebibitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TebibitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TebibytePerSecond, q => q.ToUnit(BitRateUnit.TebibytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TebibytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TerabitPerSecond, q => q.ToUnit(BitRateUnit.TerabitPerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TerabitPerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BitRate.BaseUnit, BitRateUnit.TerabytePerSecond, q => q.ToUnit(BitRateUnit.TerabytePerSecond)); - unitConverter.SetConversionFunction(BitRateUnit.TerabytePerSecond, BitRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour)); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BrakeSpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumption.BaseUnit, q => q); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.BaseUnit, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); - unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BrakeSpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, Capacitance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Kilofarad, q => q.ToUnit(CapacitanceUnit.Kilofarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Kilofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Megafarad, q => q.ToUnit(CapacitanceUnit.Megafarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Megafarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Microfarad, q => q.ToUnit(CapacitanceUnit.Microfarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Microfarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Millifarad, q => q.ToUnit(CapacitanceUnit.Millifarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Millifarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Nanofarad, q => q.ToUnit(CapacitanceUnit.Nanofarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Nanofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Capacitance.BaseUnit, CapacitanceUnit.Picofarad, q => q.ToUnit(CapacitanceUnit.Picofarad)); - unitConverter.SetConversionFunction(CapacitanceUnit.Picofarad, Capacitance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius)); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, CoefficientOfThermalExpansion.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit)); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, CoefficientOfThermalExpansion.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.BaseUnit, CoefficientOfThermalExpansion.BaseUnit, q => q); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.CentigramPerDeciliter, q => q.ToUnit(DensityUnit.CentigramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.CentigramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.CentigramPerLiter, q => q.ToUnit(DensityUnit.CentigramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.CentigramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.CentigramPerMilliliter, q => q.ToUnit(DensityUnit.CentigramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.CentigramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.DecigramPerDeciliter, q => q.ToUnit(DensityUnit.DecigramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.DecigramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.DecigramPerLiter, q => q.ToUnit(DensityUnit.DecigramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.DecigramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.DecigramPerMilliliter, q => q.ToUnit(DensityUnit.DecigramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.DecigramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerCubicCentimeter, q => q.ToUnit(DensityUnit.GramPerCubicCentimeter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerCubicMeter, q => q.ToUnit(DensityUnit.GramPerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerCubicMillimeter, q => q.ToUnit(DensityUnit.GramPerCubicMillimeter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerDeciliter, q => q.ToUnit(DensityUnit.GramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerLiter, q => q.ToUnit(DensityUnit.GramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.GramPerMilliliter, q => q.ToUnit(DensityUnit.GramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.GramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilogramPerCubicCentimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicCentimeter)); - unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, Density.BaseUnit, q => q); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilogramPerCubicMillimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicMillimeter)); - unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilogramPerLiter, q => q.ToUnit(DensityUnit.KilogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.KilogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilopoundPerCubicFoot, q => q.ToUnit(DensityUnit.KilopoundPerCubicFoot)); - unitConverter.SetConversionFunction(DensityUnit.KilopoundPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.KilopoundPerCubicInch, q => q.ToUnit(DensityUnit.KilopoundPerCubicInch)); - unitConverter.SetConversionFunction(DensityUnit.KilopoundPerCubicInch, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerCubicMeter, q => q.ToUnit(DensityUnit.MicrogramPerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerDeciliter, q => q.ToUnit(DensityUnit.MicrogramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerLiter, q => q.ToUnit(DensityUnit.MicrogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MicrogramPerMilliliter, q => q.ToUnit(DensityUnit.MicrogramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.MicrogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerCubicMeter, q => q.ToUnit(DensityUnit.MilligramPerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerDeciliter, q => q.ToUnit(DensityUnit.MilligramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerLiter, q => q.ToUnit(DensityUnit.MilligramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.MilligramPerMilliliter, q => q.ToUnit(DensityUnit.MilligramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.MilligramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.NanogramPerDeciliter, q => q.ToUnit(DensityUnit.NanogramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.NanogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.NanogramPerLiter, q => q.ToUnit(DensityUnit.NanogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.NanogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.NanogramPerMilliliter, q => q.ToUnit(DensityUnit.NanogramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.NanogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PicogramPerDeciliter, q => q.ToUnit(DensityUnit.PicogramPerDeciliter)); - unitConverter.SetConversionFunction(DensityUnit.PicogramPerDeciliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PicogramPerLiter, q => q.ToUnit(DensityUnit.PicogramPerLiter)); - unitConverter.SetConversionFunction(DensityUnit.PicogramPerLiter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PicogramPerMilliliter, q => q.ToUnit(DensityUnit.PicogramPerMilliliter)); - unitConverter.SetConversionFunction(DensityUnit.PicogramPerMilliliter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerCubicFoot, q => q.ToUnit(DensityUnit.PoundPerCubicFoot)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerCubicInch, q => q.ToUnit(DensityUnit.PoundPerCubicInch)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerCubicInch, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerImperialGallon, q => q.ToUnit(DensityUnit.PoundPerImperialGallon)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerImperialGallon, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.PoundPerUSGallon, q => q.ToUnit(DensityUnit.PoundPerUSGallon)); - unitConverter.SetConversionFunction(DensityUnit.PoundPerUSGallon, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.SlugPerCubicFoot, q => q.ToUnit(DensityUnit.SlugPerCubicFoot)); - unitConverter.SetConversionFunction(DensityUnit.SlugPerCubicFoot, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.TonnePerCubicCentimeter, q => q.ToUnit(DensityUnit.TonnePerCubicCentimeter)); - unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicCentimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.TonnePerCubicMeter, q => q.ToUnit(DensityUnit.TonnePerCubicMeter)); - unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicMeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Density.BaseUnit, DensityUnit.TonnePerCubicMillimeter, q => q.ToUnit(DensityUnit.TonnePerCubicMillimeter)); - unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicMillimeter, Density.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Day, q => q.ToUnit(DurationUnit.Day)); - unitConverter.SetConversionFunction(DurationUnit.Day, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Hour, q => q.ToUnit(DurationUnit.Hour)); - unitConverter.SetConversionFunction(DurationUnit.Hour, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Microsecond, q => q.ToUnit(DurationUnit.Microsecond)); - unitConverter.SetConversionFunction(DurationUnit.Microsecond, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Millisecond, q => q.ToUnit(DurationUnit.Millisecond)); - unitConverter.SetConversionFunction(DurationUnit.Millisecond, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Minute, q => q.ToUnit(DurationUnit.Minute)); - unitConverter.SetConversionFunction(DurationUnit.Minute, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Month30, q => q.ToUnit(DurationUnit.Month30)); - unitConverter.SetConversionFunction(DurationUnit.Month30, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Nanosecond, q => q.ToUnit(DurationUnit.Nanosecond)); - unitConverter.SetConversionFunction(DurationUnit.Nanosecond, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, Duration.BaseUnit, q => q); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Week, q => q.ToUnit(DurationUnit.Week)); - unitConverter.SetConversionFunction(DurationUnit.Week, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Duration.BaseUnit, DurationUnit.Year365, q => q.ToUnit(DurationUnit.Year365)); - unitConverter.SetConversionFunction(DurationUnit.Year365, Duration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Centipoise, q => q.ToUnit(DynamicViscosityUnit.Centipoise)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.Centipoise, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.MicropascalSecond, q => q.ToUnit(DynamicViscosityUnit.MicropascalSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.MicropascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.MillipascalSecond, q => q.ToUnit(DynamicViscosityUnit.MillipascalSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.MillipascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosity.BaseUnit, q => q); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PascalSecond, q => q.ToUnit(DynamicViscosityUnit.PascalSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PascalSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Poise, q => q.ToUnit(DynamicViscosityUnit.Poise)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.Poise, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareFoot, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareFoot)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundForceSecondPerSquareFoot, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareInch, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareInch)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundForceSecondPerSquareInch, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.PoundPerFootSecond, q => q.ToUnit(DynamicViscosityUnit.PoundPerFootSecond)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundPerFootSecond, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(DynamicViscosity.BaseUnit, DynamicViscosityUnit.Reyn, q => q.ToUnit(DynamicViscosityUnit.Reyn)); - unitConverter.SetConversionFunction(DynamicViscosityUnit.Reyn, DynamicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Microsiemens, q => q.ToUnit(ElectricAdmittanceUnit.Microsiemens)); - unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Microsiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Millisiemens, q => q.ToUnit(ElectricAdmittanceUnit.Millisiemens)); - unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Millisiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittanceUnit.Nanosiemens, q => q.ToUnit(ElectricAdmittanceUnit.Nanosiemens)); - unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Nanosiemens, ElectricAdmittance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricAdmittance.BaseUnit, ElectricAdmittance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.AmpereHour, q => q.ToUnit(ElectricChargeUnit.AmpereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.AmpereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricCharge.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.KiloampereHour, q => q.ToUnit(ElectricChargeUnit.KiloampereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.KiloampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.MegaampereHour, q => q.ToUnit(ElectricChargeUnit.MegaampereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.MegaampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCharge.BaseUnit, ElectricChargeUnit.MilliampereHour, q => q.ToUnit(ElectricChargeUnit.MilliampereHour)); - unitConverter.SetConversionFunction(ElectricChargeUnit.MilliampereHour, ElectricCharge.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricChargeDensity.BaseUnit, ElectricChargeDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricConductance.BaseUnit, ElectricConductanceUnit.Microsiemens, q => q.ToUnit(ElectricConductanceUnit.Microsiemens)); - unitConverter.SetConversionFunction(ElectricConductanceUnit.Microsiemens, ElectricConductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductance.BaseUnit, ElectricConductanceUnit.Millisiemens, q => q.ToUnit(ElectricConductanceUnit.Millisiemens)); - unitConverter.SetConversionFunction(ElectricConductanceUnit.Millisiemens, ElectricConductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductance.BaseUnit, ElectricConductance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricConductivity.BaseUnit, ElectricConductivityUnit.SiemensPerFoot, q => q.ToUnit(ElectricConductivityUnit.SiemensPerFoot)); - unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerFoot, ElectricConductivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductivity.BaseUnit, ElectricConductivityUnit.SiemensPerInch, q => q.ToUnit(ElectricConductivityUnit.SiemensPerInch)); - unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerInch, ElectricConductivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricConductivity.BaseUnit, ElectricConductivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrent.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Centiampere, q => q.ToUnit(ElectricCurrentUnit.Centiampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Centiampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Kiloampere, q => q.ToUnit(ElectricCurrentUnit.Kiloampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Kiloampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Megaampere, q => q.ToUnit(ElectricCurrentUnit.Megaampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Megaampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Microampere, q => q.ToUnit(ElectricCurrentUnit.Microampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Microampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Milliampere, q => q.ToUnit(ElectricCurrentUnit.Milliampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Milliampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Nanoampere, q => q.ToUnit(ElectricCurrentUnit.Nanoampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Nanoampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrent.BaseUnit, ElectricCurrentUnit.Picoampere, q => q.ToUnit(ElectricCurrentUnit.Picoampere)); - unitConverter.SetConversionFunction(ElectricCurrentUnit.Picoampere, ElectricCurrent.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensityUnit.AmperePerSquareFoot, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot)); - unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareFoot, ElectricCurrentDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensityUnit.AmperePerSquareInch, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch)); - unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareInch, ElectricCurrentDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentDensity.BaseUnit, ElectricCurrentDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerMicrosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMicrosecond)); - unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerMicrosecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerMillisecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMillisecond)); - unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerMillisecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradientUnit.AmperePerNanosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerNanosecond)); - unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerNanosecond, ElectricCurrentGradient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricCurrentGradient.BaseUnit, ElectricCurrentGradient.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricField.BaseUnit, ElectricField.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductanceUnit.Microhenry, q => q.ToUnit(ElectricInductanceUnit.Microhenry)); - unitConverter.SetConversionFunction(ElectricInductanceUnit.Microhenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductanceUnit.Millihenry, q => q.ToUnit(ElectricInductanceUnit.Millihenry)); - unitConverter.SetConversionFunction(ElectricInductanceUnit.Millihenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricInductance.BaseUnit, ElectricInductanceUnit.Nanohenry, q => q.ToUnit(ElectricInductanceUnit.Nanohenry)); - unitConverter.SetConversionFunction(ElectricInductanceUnit.Nanohenry, ElectricInductance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Kilovolt, q => q.ToUnit(ElectricPotentialUnit.Kilovolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Kilovolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Megavolt, q => q.ToUnit(ElectricPotentialUnit.Megavolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Megavolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Microvolt, q => q.ToUnit(ElectricPotentialUnit.Microvolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Microvolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotentialUnit.Millivolt, q => q.ToUnit(ElectricPotentialUnit.Millivolt)); - unitConverter.SetConversionFunction(ElectricPotentialUnit.Millivolt, ElectricPotential.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotential.BaseUnit, ElectricPotential.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.KilovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.KilovoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.KilovoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MegavoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MegavoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MegavoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MicrovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MicrovoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MicrovoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAcUnit.MillivoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MillivoltAc)); - unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MillivoltAc, ElectricPotentialAc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialAc.BaseUnit, ElectricPotentialAc.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerSecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerSecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerHour)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerHour, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMicrosecond)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerMicrosecond, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRateUnit.VoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMinute)); - unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerMinute, ElectricPotentialChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialChangeRate.BaseUnit, ElectricPotentialChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.KilovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.KilovoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.KilovoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MegavoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MegavoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MegavoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MicrovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MicrovoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MicrovoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDcUnit.MillivoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MillivoltDc)); - unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MillivoltDc, ElectricPotentialDc.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricPotentialDc.BaseUnit, ElectricPotentialDc.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Gigaohm, q => q.ToUnit(ElectricResistanceUnit.Gigaohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Gigaohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Kiloohm, q => q.ToUnit(ElectricResistanceUnit.Kiloohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Kiloohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Megaohm, q => q.ToUnit(ElectricResistanceUnit.Megaohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Megaohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Microohm, q => q.ToUnit(ElectricResistanceUnit.Microohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Microohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistanceUnit.Milliohm, q => q.ToUnit(ElectricResistanceUnit.Milliohm)); - unitConverter.SetConversionFunction(ElectricResistanceUnit.Milliohm, ElectricResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistance.BaseUnit, ElectricResistance.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.KiloohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.KiloohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.KiloohmMeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.KiloohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MegaohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MegaohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MegaohmMeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MegaohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MicroohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MicroohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MicroohmMeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MicroohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MilliohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MilliohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.MilliohmMeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.MilliohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.NanoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.NanoohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.NanoohmMeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.NanoohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.OhmCentimeter, q => q.ToUnit(ElectricResistivityUnit.OhmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.PicoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmCentimeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.PicoohmCentimeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricResistivity.BaseUnit, ElectricResistivityUnit.PicoohmMeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmMeter)); - unitConverter.SetConversionFunction(ElectricResistivityUnit.PicoohmMeter, ElectricResistivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter)); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, ElectricSurfaceChargeDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch)); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, ElectricSurfaceChargeDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.BaseUnit, ElectricSurfaceChargeDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.BritishThermalUnit, q => q.ToUnit(EnergyUnit.BritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.BritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Calorie, q => q.ToUnit(EnergyUnit.Calorie)); - unitConverter.SetConversionFunction(EnergyUnit.Calorie, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.DecathermEc, q => q.ToUnit(EnergyUnit.DecathermEc)); - unitConverter.SetConversionFunction(EnergyUnit.DecathermEc, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.DecathermImperial, q => q.ToUnit(EnergyUnit.DecathermImperial)); - unitConverter.SetConversionFunction(EnergyUnit.DecathermImperial, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.DecathermUs, q => q.ToUnit(EnergyUnit.DecathermUs)); - unitConverter.SetConversionFunction(EnergyUnit.DecathermUs, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ElectronVolt, q => q.ToUnit(EnergyUnit.ElectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.ElectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Erg, q => q.ToUnit(EnergyUnit.Erg)); - unitConverter.SetConversionFunction(EnergyUnit.Erg, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.FootPound, q => q.ToUnit(EnergyUnit.FootPound)); - unitConverter.SetConversionFunction(EnergyUnit.FootPound, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigabritishThermalUnit, q => q.ToUnit(EnergyUnit.GigabritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.GigabritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigaelectronVolt, q => q.ToUnit(EnergyUnit.GigaelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.GigaelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Gigajoule, q => q.ToUnit(EnergyUnit.Gigajoule)); - unitConverter.SetConversionFunction(EnergyUnit.Gigajoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigawattDay, q => q.ToUnit(EnergyUnit.GigawattDay)); - unitConverter.SetConversionFunction(EnergyUnit.GigawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.GigawattHour, q => q.ToUnit(EnergyUnit.GigawattHour)); - unitConverter.SetConversionFunction(EnergyUnit.GigawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.HorsepowerHour, q => q.ToUnit(EnergyUnit.HorsepowerHour)); - unitConverter.SetConversionFunction(EnergyUnit.HorsepowerHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, Energy.BaseUnit, q => q); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KilobritishThermalUnit, q => q.ToUnit(EnergyUnit.KilobritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.KilobritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Kilocalorie, q => q.ToUnit(EnergyUnit.Kilocalorie)); - unitConverter.SetConversionFunction(EnergyUnit.Kilocalorie, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KiloelectronVolt, q => q.ToUnit(EnergyUnit.KiloelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.KiloelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Kilojoule, q => q.ToUnit(EnergyUnit.Kilojoule)); - unitConverter.SetConversionFunction(EnergyUnit.Kilojoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KilowattDay, q => q.ToUnit(EnergyUnit.KilowattDay)); - unitConverter.SetConversionFunction(EnergyUnit.KilowattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.KilowattHour, q => q.ToUnit(EnergyUnit.KilowattHour)); - unitConverter.SetConversionFunction(EnergyUnit.KilowattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegabritishThermalUnit, q => q.ToUnit(EnergyUnit.MegabritishThermalUnit)); - unitConverter.SetConversionFunction(EnergyUnit.MegabritishThermalUnit, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Megacalorie, q => q.ToUnit(EnergyUnit.Megacalorie)); - unitConverter.SetConversionFunction(EnergyUnit.Megacalorie, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegaelectronVolt, q => q.ToUnit(EnergyUnit.MegaelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.MegaelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Megajoule, q => q.ToUnit(EnergyUnit.Megajoule)); - unitConverter.SetConversionFunction(EnergyUnit.Megajoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegawattDay, q => q.ToUnit(EnergyUnit.MegawattDay)); - unitConverter.SetConversionFunction(EnergyUnit.MegawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.MegawattHour, q => q.ToUnit(EnergyUnit.MegawattHour)); - unitConverter.SetConversionFunction(EnergyUnit.MegawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.Millijoule, q => q.ToUnit(EnergyUnit.Millijoule)); - unitConverter.SetConversionFunction(EnergyUnit.Millijoule, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.TeraelectronVolt, q => q.ToUnit(EnergyUnit.TeraelectronVolt)); - unitConverter.SetConversionFunction(EnergyUnit.TeraelectronVolt, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.TerawattDay, q => q.ToUnit(EnergyUnit.TerawattDay)); - unitConverter.SetConversionFunction(EnergyUnit.TerawattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.TerawattHour, q => q.ToUnit(EnergyUnit.TerawattHour)); - unitConverter.SetConversionFunction(EnergyUnit.TerawattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ThermEc, q => q.ToUnit(EnergyUnit.ThermEc)); - unitConverter.SetConversionFunction(EnergyUnit.ThermEc, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ThermImperial, q => q.ToUnit(EnergyUnit.ThermImperial)); - unitConverter.SetConversionFunction(EnergyUnit.ThermImperial, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.ThermUs, q => q.ToUnit(EnergyUnit.ThermUs)); - unitConverter.SetConversionFunction(EnergyUnit.ThermUs, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.WattDay, q => q.ToUnit(EnergyUnit.WattDay)); - unitConverter.SetConversionFunction(EnergyUnit.WattDay, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Energy.BaseUnit, EnergyUnit.WattHour, q => q.ToUnit(EnergyUnit.WattHour)); - unitConverter.SetConversionFunction(EnergyUnit.WattHour, Energy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.CaloriePerKelvin, q => q.ToUnit(EntropyUnit.CaloriePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.CaloriePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.JoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.JoulePerDegreeCelsius)); - unitConverter.SetConversionFunction(EntropyUnit.JoulePerDegreeCelsius, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, Entropy.BaseUnit, q => q); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.KilocaloriePerKelvin, q => q.ToUnit(EntropyUnit.KilocaloriePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.KilocaloriePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.KilojoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.KilojoulePerDegreeCelsius)); - unitConverter.SetConversionFunction(EntropyUnit.KilojoulePerDegreeCelsius, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.KilojoulePerKelvin, q => q.ToUnit(EntropyUnit.KilojoulePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.KilojoulePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Entropy.BaseUnit, EntropyUnit.MegajoulePerKelvin, q => q.ToUnit(EntropyUnit.MegajoulePerKelvin)); - unitConverter.SetConversionFunction(EntropyUnit.MegajoulePerKelvin, Entropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Decanewton, q => q.ToUnit(ForceUnit.Decanewton)); - unitConverter.SetConversionFunction(ForceUnit.Decanewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Dyn, q => q.ToUnit(ForceUnit.Dyn)); - unitConverter.SetConversionFunction(ForceUnit.Dyn, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.KilogramForce, q => q.ToUnit(ForceUnit.KilogramForce)); - unitConverter.SetConversionFunction(ForceUnit.KilogramForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Kilonewton, q => q.ToUnit(ForceUnit.Kilonewton)); - unitConverter.SetConversionFunction(ForceUnit.Kilonewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.KiloPond, q => q.ToUnit(ForceUnit.KiloPond)); - unitConverter.SetConversionFunction(ForceUnit.KiloPond, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.KilopoundForce, q => q.ToUnit(ForceUnit.KilopoundForce)); - unitConverter.SetConversionFunction(ForceUnit.KilopoundForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Meganewton, q => q.ToUnit(ForceUnit.Meganewton)); - unitConverter.SetConversionFunction(ForceUnit.Meganewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Micronewton, q => q.ToUnit(ForceUnit.Micronewton)); - unitConverter.SetConversionFunction(ForceUnit.Micronewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Millinewton, q => q.ToUnit(ForceUnit.Millinewton)); - unitConverter.SetConversionFunction(ForceUnit.Millinewton, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, Force.BaseUnit, q => q); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.OunceForce, q => q.ToUnit(ForceUnit.OunceForce)); - unitConverter.SetConversionFunction(ForceUnit.OunceForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.Poundal, q => q.ToUnit(ForceUnit.Poundal)); - unitConverter.SetConversionFunction(ForceUnit.Poundal, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.PoundForce, q => q.ToUnit(ForceUnit.PoundForce)); - unitConverter.SetConversionFunction(ForceUnit.PoundForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.ShortTonForce, q => q.ToUnit(ForceUnit.ShortTonForce)); - unitConverter.SetConversionFunction(ForceUnit.ShortTonForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Force.BaseUnit, ForceUnit.TonneForce, q => q.ToUnit(ForceUnit.TonneForce)); - unitConverter.SetConversionFunction(ForceUnit.TonneForce, Force.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.CentinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.CentinewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.CentinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecanewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.DecanewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecanewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.DecanewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.DecinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecinewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.DecinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilonewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.KilonewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.KilonewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilopoundForcePerMinute, q => q.ToUnit(ForceChangeRateUnit.KilopoundForcePerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.KilopoundForcePerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.KilopoundForcePerSecond, q => q.ToUnit(ForceChangeRateUnit.KilopoundForcePerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.KilopoundForcePerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.MicronewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MicronewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.MillinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MillinewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.MillinewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.NanonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.NanonewtonPerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.NanonewtonPerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.NewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.NewtonPerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.PoundForcePerMinute, q => q.ToUnit(ForceChangeRateUnit.PoundForcePerMinute)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.PoundForcePerMinute, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForceChangeRate.BaseUnit, ForceChangeRateUnit.PoundForcePerSecond, q => q.ToUnit(ForceChangeRateUnit.PoundForcePerSecond)); - unitConverter.SetConversionFunction(ForceChangeRateUnit.PoundForcePerSecond, ForceChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.CentinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecanewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.DecinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilogramForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilopoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerFoot)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilopoundForcePerFoot, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.KilopoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerInch)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.KilopoundForcePerInch, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MeganewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MicronewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.MillinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NanonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.NewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerFoot)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerFoot, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerInch)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerInch, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.PoundForcePerYard, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerYard)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerYard, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerCentimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerCentimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerMeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ForcePerLength.BaseUnit, ForcePerLengthUnit.TonneForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMillimeter)); - unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerMillimeter, ForcePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.BeatPerMinute, q => q.ToUnit(FrequencyUnit.BeatPerMinute)); - unitConverter.SetConversionFunction(FrequencyUnit.BeatPerMinute, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.BUnit, q => q.ToUnit(FrequencyUnit.BUnit)); - unitConverter.SetConversionFunction(FrequencyUnit.BUnit, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.CyclePerHour, q => q.ToUnit(FrequencyUnit.CyclePerHour)); - unitConverter.SetConversionFunction(FrequencyUnit.CyclePerHour, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.CyclePerMinute, q => q.ToUnit(FrequencyUnit.CyclePerMinute)); - unitConverter.SetConversionFunction(FrequencyUnit.CyclePerMinute, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Gigahertz, q => q.ToUnit(FrequencyUnit.Gigahertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Gigahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, Frequency.BaseUnit, q => q); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Kilohertz, q => q.ToUnit(FrequencyUnit.Kilohertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Kilohertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Megahertz, q => q.ToUnit(FrequencyUnit.Megahertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Megahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.PerSecond, q => q.ToUnit(FrequencyUnit.PerSecond)); - unitConverter.SetConversionFunction(FrequencyUnit.PerSecond, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.RadianPerSecond, q => q.ToUnit(FrequencyUnit.RadianPerSecond)); - unitConverter.SetConversionFunction(FrequencyUnit.RadianPerSecond, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Frequency.BaseUnit, FrequencyUnit.Terahertz, q => q.ToUnit(FrequencyUnit.Terahertz)); - unitConverter.SetConversionFunction(FrequencyUnit.Terahertz, Frequency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.KilometerPerLiter, q => q.ToUnit(FuelEfficiencyUnit.KilometerPerLiter)); - unitConverter.SetConversionFunction(FuelEfficiencyUnit.KilometerPerLiter, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiency.BaseUnit, q => q); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.MilePerUkGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUkGallon)); - unitConverter.SetConversionFunction(FuelEfficiencyUnit.MilePerUkGallon, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(FuelEfficiency.BaseUnit, FuelEfficiencyUnit.MilePerUsGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUsGallon)); - unitConverter.SetConversionFunction(FuelEfficiencyUnit.MilePerUsGallon, FuelEfficiency.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerHourSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerHourSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerHourSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerMinuteSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerMinuteSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerMinuteSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerSecondSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerSecondSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.BtuPerSecondSquareInch, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareInch)); - unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerSecondSquareInch, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.CaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.CaloriePerSecondSquareCentimeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.CaloriePerSecondSquareCentimeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.CentiwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.CentiwattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.CentiwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.DeciwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.DeciwattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.DeciwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.KilocaloriePerHourSquareMeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerHourSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.KilocaloriePerHourSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.KilowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.KilowattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.KilowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.MicrowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MicrowattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.MicrowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.MilliwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MilliwattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.MilliwattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.NanowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.NanowattPerSquareMeter)); - unitConverter.SetConversionFunction(HeatFluxUnit.NanowattPerSquareMeter, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.PoundForcePerFootSecond, q => q.ToUnit(HeatFluxUnit.PoundForcePerFootSecond)); - unitConverter.SetConversionFunction(HeatFluxUnit.PoundForcePerFootSecond, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.PoundPerSecondCubed, q => q.ToUnit(HeatFluxUnit.PoundPerSecondCubed)); - unitConverter.SetConversionFunction(HeatFluxUnit.PoundPerSecondCubed, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.WattPerSquareFoot, q => q.ToUnit(HeatFluxUnit.WattPerSquareFoot)); - unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareFoot, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFluxUnit.WattPerSquareInch, q => q.ToUnit(HeatFluxUnit.WattPerSquareInch)); - unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareInch, HeatFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatFlux.BaseUnit, HeatFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, q => q.ToUnit(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit)); - unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, HeatTransferCoefficient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, q => q.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius)); - unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, HeatTransferCoefficient.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(HeatTransferCoefficient.BaseUnit, HeatTransferCoefficient.BaseUnit, q => q); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, IlluminanceUnit.Kilolux, q => q.ToUnit(IlluminanceUnit.Kilolux)); - unitConverter.SetConversionFunction(IlluminanceUnit.Kilolux, Illuminance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, Illuminance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, IlluminanceUnit.Megalux, q => q.ToUnit(IlluminanceUnit.Megalux)); - unitConverter.SetConversionFunction(IlluminanceUnit.Megalux, Illuminance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Illuminance.BaseUnit, IlluminanceUnit.Millilux, q => q.ToUnit(IlluminanceUnit.Millilux)); - unitConverter.SetConversionFunction(IlluminanceUnit.Millilux, Illuminance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, Information.BaseUnit, q => q); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Byte, q => q.ToUnit(InformationUnit.Byte)); - unitConverter.SetConversionFunction(InformationUnit.Byte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exabit, q => q.ToUnit(InformationUnit.Exabit)); - unitConverter.SetConversionFunction(InformationUnit.Exabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exabyte, q => q.ToUnit(InformationUnit.Exabyte)); - unitConverter.SetConversionFunction(InformationUnit.Exabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exbibit, q => q.ToUnit(InformationUnit.Exbibit)); - unitConverter.SetConversionFunction(InformationUnit.Exbibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Exbibyte, q => q.ToUnit(InformationUnit.Exbibyte)); - unitConverter.SetConversionFunction(InformationUnit.Exbibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gibibit, q => q.ToUnit(InformationUnit.Gibibit)); - unitConverter.SetConversionFunction(InformationUnit.Gibibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gibibyte, q => q.ToUnit(InformationUnit.Gibibyte)); - unitConverter.SetConversionFunction(InformationUnit.Gibibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gigabit, q => q.ToUnit(InformationUnit.Gigabit)); - unitConverter.SetConversionFunction(InformationUnit.Gigabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Gigabyte, q => q.ToUnit(InformationUnit.Gigabyte)); - unitConverter.SetConversionFunction(InformationUnit.Gigabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kibibit, q => q.ToUnit(InformationUnit.Kibibit)); - unitConverter.SetConversionFunction(InformationUnit.Kibibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kibibyte, q => q.ToUnit(InformationUnit.Kibibyte)); - unitConverter.SetConversionFunction(InformationUnit.Kibibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kilobit, q => q.ToUnit(InformationUnit.Kilobit)); - unitConverter.SetConversionFunction(InformationUnit.Kilobit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Kilobyte, q => q.ToUnit(InformationUnit.Kilobyte)); - unitConverter.SetConversionFunction(InformationUnit.Kilobyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Mebibit, q => q.ToUnit(InformationUnit.Mebibit)); - unitConverter.SetConversionFunction(InformationUnit.Mebibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Mebibyte, q => q.ToUnit(InformationUnit.Mebibyte)); - unitConverter.SetConversionFunction(InformationUnit.Mebibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Megabit, q => q.ToUnit(InformationUnit.Megabit)); - unitConverter.SetConversionFunction(InformationUnit.Megabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Megabyte, q => q.ToUnit(InformationUnit.Megabyte)); - unitConverter.SetConversionFunction(InformationUnit.Megabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Pebibit, q => q.ToUnit(InformationUnit.Pebibit)); - unitConverter.SetConversionFunction(InformationUnit.Pebibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Pebibyte, q => q.ToUnit(InformationUnit.Pebibyte)); - unitConverter.SetConversionFunction(InformationUnit.Pebibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Petabit, q => q.ToUnit(InformationUnit.Petabit)); - unitConverter.SetConversionFunction(InformationUnit.Petabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Petabyte, q => q.ToUnit(InformationUnit.Petabyte)); - unitConverter.SetConversionFunction(InformationUnit.Petabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Tebibit, q => q.ToUnit(InformationUnit.Tebibit)); - unitConverter.SetConversionFunction(InformationUnit.Tebibit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Tebibyte, q => q.ToUnit(InformationUnit.Tebibyte)); - unitConverter.SetConversionFunction(InformationUnit.Tebibyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Terabit, q => q.ToUnit(InformationUnit.Terabit)); - unitConverter.SetConversionFunction(InformationUnit.Terabit, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Information.BaseUnit, InformationUnit.Terabyte, q => q.ToUnit(InformationUnit.Terabyte)); - unitConverter.SetConversionFunction(InformationUnit.Terabyte, Information.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.KilowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.KilowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.KilowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.KilowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MegawattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MegawattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MegawattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MegawattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MicrowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MicrowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MicrowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MicrowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MilliwattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MilliwattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.MilliwattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.MilliwattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.NanowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.NanowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.NanowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.NanowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.PicowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.PicowattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.PicowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareMeter)); - unitConverter.SetConversionFunction(IrradianceUnit.PicowattPerSquareMeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, IrradianceUnit.WattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.WattPerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareCentimeter, Irradiance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiance.BaseUnit, Irradiance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.JoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareCentimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, Irradiation.BaseUnit, q => q); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.JoulePerSquareMillimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareMillimeter)); - unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMillimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.KilojoulePerSquareMeter, q => q.ToUnit(IrradiationUnit.KilojoulePerSquareMeter)); - unitConverter.SetConversionFunction(IrradiationUnit.KilojoulePerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.KilowattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.KilowattHourPerSquareMeter)); - unitConverter.SetConversionFunction(IrradiationUnit.KilowattHourPerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.MillijoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.MillijoulePerSquareCentimeter)); - unitConverter.SetConversionFunction(IrradiationUnit.MillijoulePerSquareCentimeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Irradiation.BaseUnit, IrradiationUnit.WattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.WattHourPerSquareMeter)); - unitConverter.SetConversionFunction(IrradiationUnit.WattHourPerSquareMeter, Irradiation.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Centistokes, q => q.ToUnit(KinematicViscosityUnit.Centistokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Centistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Decistokes, q => q.ToUnit(KinematicViscosityUnit.Decistokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Decistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Kilostokes, q => q.ToUnit(KinematicViscosityUnit.Kilostokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Kilostokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Microstokes, q => q.ToUnit(KinematicViscosityUnit.Microstokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Microstokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Millistokes, q => q.ToUnit(KinematicViscosityUnit.Millistokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Millistokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Nanostokes, q => q.ToUnit(KinematicViscosityUnit.Nanostokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Nanostokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.SquareFootPerSecond, q => q.ToUnit(KinematicViscosityUnit.SquareFootPerSecond)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.SquareFootPerSecond, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosity.BaseUnit, q => q); - unitConverter.SetConversionFunction(KinematicViscosity.BaseUnit, KinematicViscosityUnit.Stokes, q => q.ToUnit(KinematicViscosityUnit.Stokes)); - unitConverter.SetConversionFunction(KinematicViscosityUnit.Stokes, KinematicViscosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LapseRate.BaseUnit, LapseRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.AstronomicalUnit, q => q.ToUnit(LengthUnit.AstronomicalUnit)); - unitConverter.SetConversionFunction(LengthUnit.AstronomicalUnit, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Centimeter, q => q.ToUnit(LengthUnit.Centimeter)); - unitConverter.SetConversionFunction(LengthUnit.Centimeter, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Chain, q => q.ToUnit(LengthUnit.Chain)); - unitConverter.SetConversionFunction(LengthUnit.Chain, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Decimeter, q => q.ToUnit(LengthUnit.Decimeter)); - unitConverter.SetConversionFunction(LengthUnit.Decimeter, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.DtpPica, q => q.ToUnit(LengthUnit.DtpPica)); - unitConverter.SetConversionFunction(LengthUnit.DtpPica, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.DtpPoint, q => q.ToUnit(LengthUnit.DtpPoint)); - unitConverter.SetConversionFunction(LengthUnit.DtpPoint, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Fathom, q => q.ToUnit(LengthUnit.Fathom)); - unitConverter.SetConversionFunction(LengthUnit.Fathom, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Foot, q => q.ToUnit(LengthUnit.Foot)); - unitConverter.SetConversionFunction(LengthUnit.Foot, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Hand, q => q.ToUnit(LengthUnit.Hand)); - unitConverter.SetConversionFunction(LengthUnit.Hand, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Hectometer, q => q.ToUnit(LengthUnit.Hectometer)); - unitConverter.SetConversionFunction(LengthUnit.Hectometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Inch, q => q.ToUnit(LengthUnit.Inch)); - unitConverter.SetConversionFunction(LengthUnit.Inch, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.KilolightYear, q => q.ToUnit(LengthUnit.KilolightYear)); - unitConverter.SetConversionFunction(LengthUnit.KilolightYear, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Kilometer, q => q.ToUnit(LengthUnit.Kilometer)); - unitConverter.SetConversionFunction(LengthUnit.Kilometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Kiloparsec, q => q.ToUnit(LengthUnit.Kiloparsec)); - unitConverter.SetConversionFunction(LengthUnit.Kiloparsec, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.LightYear, q => q.ToUnit(LengthUnit.LightYear)); - unitConverter.SetConversionFunction(LengthUnit.LightYear, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.MegalightYear, q => q.ToUnit(LengthUnit.MegalightYear)); - unitConverter.SetConversionFunction(LengthUnit.MegalightYear, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Megaparsec, q => q.ToUnit(LengthUnit.Megaparsec)); - unitConverter.SetConversionFunction(LengthUnit.Megaparsec, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, Length.BaseUnit, q => q); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Microinch, q => q.ToUnit(LengthUnit.Microinch)); - unitConverter.SetConversionFunction(LengthUnit.Microinch, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Micrometer, q => q.ToUnit(LengthUnit.Micrometer)); - unitConverter.SetConversionFunction(LengthUnit.Micrometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Mil, q => q.ToUnit(LengthUnit.Mil)); - unitConverter.SetConversionFunction(LengthUnit.Mil, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Mile, q => q.ToUnit(LengthUnit.Mile)); - unitConverter.SetConversionFunction(LengthUnit.Mile, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Millimeter, q => q.ToUnit(LengthUnit.Millimeter)); - unitConverter.SetConversionFunction(LengthUnit.Millimeter, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Nanometer, q => q.ToUnit(LengthUnit.Nanometer)); - unitConverter.SetConversionFunction(LengthUnit.Nanometer, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.NauticalMile, q => q.ToUnit(LengthUnit.NauticalMile)); - unitConverter.SetConversionFunction(LengthUnit.NauticalMile, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Parsec, q => q.ToUnit(LengthUnit.Parsec)); - unitConverter.SetConversionFunction(LengthUnit.Parsec, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.PrinterPica, q => q.ToUnit(LengthUnit.PrinterPica)); - unitConverter.SetConversionFunction(LengthUnit.PrinterPica, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.PrinterPoint, q => q.ToUnit(LengthUnit.PrinterPoint)); - unitConverter.SetConversionFunction(LengthUnit.PrinterPoint, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Shackle, q => q.ToUnit(LengthUnit.Shackle)); - unitConverter.SetConversionFunction(LengthUnit.Shackle, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.SolarRadius, q => q.ToUnit(LengthUnit.SolarRadius)); - unitConverter.SetConversionFunction(LengthUnit.SolarRadius, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Twip, q => q.ToUnit(LengthUnit.Twip)); - unitConverter.SetConversionFunction(LengthUnit.Twip, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.UsSurveyFoot, q => q.ToUnit(LengthUnit.UsSurveyFoot)); - unitConverter.SetConversionFunction(LengthUnit.UsSurveyFoot, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Length.BaseUnit, LengthUnit.Yard, q => q.ToUnit(LengthUnit.Yard)); - unitConverter.SetConversionFunction(LengthUnit.Yard, Length.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Level.BaseUnit, Level.BaseUnit, q => q); - unitConverter.SetConversionFunction(Level.BaseUnit, LevelUnit.Neper, q => q.ToUnit(LevelUnit.Neper)); - unitConverter.SetConversionFunction(LevelUnit.Neper, Level.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.GramPerCentimeter, q => q.ToUnit(LinearDensityUnit.GramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.GramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.GramPerMeter, q => q.ToUnit(LinearDensityUnit.GramPerMeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.GramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.GramPerMillimeter, q => q.ToUnit(LinearDensityUnit.GramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.GramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.KilogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.KilogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerMeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MicrogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerCentimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerCentimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerMeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerMeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.MilligramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMillimeter)); - unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerMillimeter, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.PoundPerFoot, q => q.ToUnit(LinearDensityUnit.PoundPerFoot)); - unitConverter.SetConversionFunction(LinearDensityUnit.PoundPerFoot, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearDensity.BaseUnit, LinearDensityUnit.PoundPerInch, q => q.ToUnit(LinearDensityUnit.PoundPerInch)); - unitConverter.SetConversionFunction(LinearDensityUnit.PoundPerInch, LinearDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.GigawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerInch, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.KilowattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MegawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerMeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.MilliwattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerCentimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerCentimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.WattPerFoot)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerFoot, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerInch, q => q.ToUnit(LinearPowerDensityUnit.WattPerInch)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerInch, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(LinearPowerDensity.BaseUnit, LinearPowerDensityUnit.WattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerMillimeter)); - unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMillimeter, LinearPowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Decawatt, q => q.ToUnit(LuminosityUnit.Decawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Decawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Deciwatt, q => q.ToUnit(LuminosityUnit.Deciwatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Deciwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Femtowatt, q => q.ToUnit(LuminosityUnit.Femtowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Femtowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Gigawatt, q => q.ToUnit(LuminosityUnit.Gigawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Gigawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Kilowatt, q => q.ToUnit(LuminosityUnit.Kilowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Kilowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Megawatt, q => q.ToUnit(LuminosityUnit.Megawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Megawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Microwatt, q => q.ToUnit(LuminosityUnit.Microwatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Microwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Milliwatt, q => q.ToUnit(LuminosityUnit.Milliwatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Milliwatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Nanowatt, q => q.ToUnit(LuminosityUnit.Nanowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Nanowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Petawatt, q => q.ToUnit(LuminosityUnit.Petawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Petawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Picowatt, q => q.ToUnit(LuminosityUnit.Picowatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Picowatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.SolarLuminosity, q => q.ToUnit(LuminosityUnit.SolarLuminosity)); - unitConverter.SetConversionFunction(LuminosityUnit.SolarLuminosity, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, LuminosityUnit.Terawatt, q => q.ToUnit(LuminosityUnit.Terawatt)); - unitConverter.SetConversionFunction(LuminosityUnit.Terawatt, Luminosity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Luminosity.BaseUnit, Luminosity.BaseUnit, q => q); - unitConverter.SetConversionFunction(LuminousFlux.BaseUnit, LuminousFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(LuminousIntensity.BaseUnit, LuminousIntensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Gauss, q => q.ToUnit(MagneticFieldUnit.Gauss)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Gauss, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Microtesla, q => q.ToUnit(MagneticFieldUnit.Microtesla)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Microtesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Milligauss, q => q.ToUnit(MagneticFieldUnit.Milligauss)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Milligauss, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Millitesla, q => q.ToUnit(MagneticFieldUnit.Millitesla)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Millitesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticFieldUnit.Nanotesla, q => q.ToUnit(MagneticFieldUnit.Nanotesla)); - unitConverter.SetConversionFunction(MagneticFieldUnit.Nanotesla, MagneticField.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MagneticField.BaseUnit, MagneticField.BaseUnit, q => q); - unitConverter.SetConversionFunction(MagneticFlux.BaseUnit, MagneticFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(Magnetization.BaseUnit, Magnetization.BaseUnit, q => q); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Centigram, q => q.ToUnit(MassUnit.Centigram)); - unitConverter.SetConversionFunction(MassUnit.Centigram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Decagram, q => q.ToUnit(MassUnit.Decagram)); - unitConverter.SetConversionFunction(MassUnit.Decagram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Decigram, q => q.ToUnit(MassUnit.Decigram)); - unitConverter.SetConversionFunction(MassUnit.Decigram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.EarthMass, q => q.ToUnit(MassUnit.EarthMass)); - unitConverter.SetConversionFunction(MassUnit.EarthMass, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Grain, q => q.ToUnit(MassUnit.Grain)); - unitConverter.SetConversionFunction(MassUnit.Grain, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Gram, q => q.ToUnit(MassUnit.Gram)); - unitConverter.SetConversionFunction(MassUnit.Gram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Hectogram, q => q.ToUnit(MassUnit.Hectogram)); - unitConverter.SetConversionFunction(MassUnit.Hectogram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, Mass.BaseUnit, q => q); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Kilopound, q => q.ToUnit(MassUnit.Kilopound)); - unitConverter.SetConversionFunction(MassUnit.Kilopound, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Kilotonne, q => q.ToUnit(MassUnit.Kilotonne)); - unitConverter.SetConversionFunction(MassUnit.Kilotonne, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.LongHundredweight, q => q.ToUnit(MassUnit.LongHundredweight)); - unitConverter.SetConversionFunction(MassUnit.LongHundredweight, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.LongTon, q => q.ToUnit(MassUnit.LongTon)); - unitConverter.SetConversionFunction(MassUnit.LongTon, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Megapound, q => q.ToUnit(MassUnit.Megapound)); - unitConverter.SetConversionFunction(MassUnit.Megapound, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Megatonne, q => q.ToUnit(MassUnit.Megatonne)); - unitConverter.SetConversionFunction(MassUnit.Megatonne, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Microgram, q => q.ToUnit(MassUnit.Microgram)); - unitConverter.SetConversionFunction(MassUnit.Microgram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Milligram, q => q.ToUnit(MassUnit.Milligram)); - unitConverter.SetConversionFunction(MassUnit.Milligram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Nanogram, q => q.ToUnit(MassUnit.Nanogram)); - unitConverter.SetConversionFunction(MassUnit.Nanogram, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Ounce, q => q.ToUnit(MassUnit.Ounce)); - unitConverter.SetConversionFunction(MassUnit.Ounce, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Pound, q => q.ToUnit(MassUnit.Pound)); - unitConverter.SetConversionFunction(MassUnit.Pound, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.ShortHundredweight, q => q.ToUnit(MassUnit.ShortHundredweight)); - unitConverter.SetConversionFunction(MassUnit.ShortHundredweight, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.ShortTon, q => q.ToUnit(MassUnit.ShortTon)); - unitConverter.SetConversionFunction(MassUnit.ShortTon, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Slug, q => q.ToUnit(MassUnit.Slug)); - unitConverter.SetConversionFunction(MassUnit.Slug, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.SolarMass, q => q.ToUnit(MassUnit.SolarMass)); - unitConverter.SetConversionFunction(MassUnit.SolarMass, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Stone, q => q.ToUnit(MassUnit.Stone)); - unitConverter.SetConversionFunction(MassUnit.Stone, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Mass.BaseUnit, MassUnit.Tonne, q => q.ToUnit(MassUnit.Tonne)); - unitConverter.SetConversionFunction(MassUnit.Tonne, Mass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerLiter, q => q.ToUnit(MassConcentrationUnit.CentigramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.CentigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerLiter, q => q.ToUnit(MassConcentrationUnit.DecigramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.DecigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicCentimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMillimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.GramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerLiter, q => q.ToUnit(MassConcentrationUnit.GramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.GramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.GramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.GramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicCentimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentration.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicMillimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilogramPerLiter, q => q.ToUnit(MassConcentrationUnit.KilogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilopoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicFoot)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilopoundPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.KilopoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicInch)); - unitConverter.SetConversionFunction(MassConcentrationUnit.KilopoundPerCubicInch, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerLiter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MicrogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MilligramPerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerLiter, q => q.ToUnit(MassConcentrationUnit.MilligramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.MilligramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerLiter, q => q.ToUnit(MassConcentrationUnit.NanogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.NanogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.OuncePerImperialGallon, q => q.ToUnit(MassConcentrationUnit.OuncePerImperialGallon)); - unitConverter.SetConversionFunction(MassConcentrationUnit.OuncePerImperialGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.OuncePerUSGallon, q => q.ToUnit(MassConcentrationUnit.OuncePerUSGallon)); - unitConverter.SetConversionFunction(MassConcentrationUnit.OuncePerUSGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerDeciliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerDeciliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerLiter, q => q.ToUnit(MassConcentrationUnit.PicogramPerLiter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerLiter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMicroliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerMicroliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PicogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMilliliter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerMilliliter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicFoot)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicInch)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerCubicInch, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerImperialGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerImperialGallon)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerImperialGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.PoundPerUSGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerUSGallon)); - unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerUSGallon, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.SlugPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.SlugPerCubicFoot)); - unitConverter.SetConversionFunction(MassConcentrationUnit.SlugPerCubicFoot, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicCentimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicCentimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicMeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicMeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassConcentration.BaseUnit, MassConcentrationUnit.TonnePerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMillimeter)); - unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicMillimeter, MassConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.CentigramPerDay, q => q.ToUnit(MassFlowUnit.CentigramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.CentigramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.CentigramPerSecond, q => q.ToUnit(MassFlowUnit.CentigramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.CentigramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecagramPerDay, q => q.ToUnit(MassFlowUnit.DecagramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.DecagramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecagramPerSecond, q => q.ToUnit(MassFlowUnit.DecagramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.DecagramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecigramPerDay, q => q.ToUnit(MassFlowUnit.DecigramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.DecigramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.DecigramPerSecond, q => q.ToUnit(MassFlowUnit.DecigramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.DecigramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.GramPerDay, q => q.ToUnit(MassFlowUnit.GramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.GramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.GramPerHour, q => q.ToUnit(MassFlowUnit.GramPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.GramPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlow.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.HectogramPerDay, q => q.ToUnit(MassFlowUnit.HectogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.HectogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.HectogramPerSecond, q => q.ToUnit(MassFlowUnit.HectogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.HectogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerDay, q => q.ToUnit(MassFlowUnit.KilogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerHour, q => q.ToUnit(MassFlowUnit.KilogramPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerMinute, q => q.ToUnit(MassFlowUnit.KilogramPerMinute)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.KilogramPerSecond, q => q.ToUnit(MassFlowUnit.KilogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegagramPerDay, q => q.ToUnit(MassFlowUnit.MegagramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MegagramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerDay, q => q.ToUnit(MassFlowUnit.MegapoundPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerHour, q => q.ToUnit(MassFlowUnit.MegapoundPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerMinute, q => q.ToUnit(MassFlowUnit.MegapoundPerMinute)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MegapoundPerSecond, q => q.ToUnit(MassFlowUnit.MegapoundPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MicrogramPerDay, q => q.ToUnit(MassFlowUnit.MicrogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MicrogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MicrogramPerSecond, q => q.ToUnit(MassFlowUnit.MicrogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.MicrogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MilligramPerDay, q => q.ToUnit(MassFlowUnit.MilligramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.MilligramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.MilligramPerSecond, q => q.ToUnit(MassFlowUnit.MilligramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.MilligramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.NanogramPerDay, q => q.ToUnit(MassFlowUnit.NanogramPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.NanogramPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.NanogramPerSecond, q => q.ToUnit(MassFlowUnit.NanogramPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.NanogramPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerDay, q => q.ToUnit(MassFlowUnit.PoundPerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerHour, q => q.ToUnit(MassFlowUnit.PoundPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerMinute, q => q.ToUnit(MassFlowUnit.PoundPerMinute)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerMinute, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.PoundPerSecond, q => q.ToUnit(MassFlowUnit.PoundPerSecond)); - unitConverter.SetConversionFunction(MassFlowUnit.PoundPerSecond, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.ShortTonPerHour, q => q.ToUnit(MassFlowUnit.ShortTonPerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.ShortTonPerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.TonnePerDay, q => q.ToUnit(MassFlowUnit.TonnePerDay)); - unitConverter.SetConversionFunction(MassFlowUnit.TonnePerDay, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlow.BaseUnit, MassFlowUnit.TonnePerHour, q => q.ToUnit(MassFlowUnit.TonnePerHour)); - unitConverter.SetConversionFunction(MassFlowUnit.TonnePerHour, MassFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.GramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareMeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareCentimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareCentimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFlux.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassFlux.BaseUnit, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); - unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, MassFlux.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.CentigramPerGram, q => q.ToUnit(MassFractionUnit.CentigramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.CentigramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.CentigramPerKilogram, q => q.ToUnit(MassFractionUnit.CentigramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.CentigramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecagramPerGram, q => q.ToUnit(MassFractionUnit.DecagramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecagramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecagramPerKilogram, q => q.ToUnit(MassFractionUnit.DecagramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecagramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecigramPerGram, q => q.ToUnit(MassFractionUnit.DecigramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecigramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.DecigramPerKilogram, q => q.ToUnit(MassFractionUnit.DecigramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.DecigramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFraction.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.GramPerGram, q => q.ToUnit(MassFractionUnit.GramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.GramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.GramPerKilogram, q => q.ToUnit(MassFractionUnit.GramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.GramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.HectogramPerGram, q => q.ToUnit(MassFractionUnit.HectogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.HectogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.HectogramPerKilogram, q => q.ToUnit(MassFractionUnit.HectogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.HectogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.KilogramPerGram, q => q.ToUnit(MassFractionUnit.KilogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.KilogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.KilogramPerKilogram, q => q.ToUnit(MassFractionUnit.KilogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.KilogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MicrogramPerGram, q => q.ToUnit(MassFractionUnit.MicrogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.MicrogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MicrogramPerKilogram, q => q.ToUnit(MassFractionUnit.MicrogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.MicrogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MilligramPerGram, q => q.ToUnit(MassFractionUnit.MilligramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.MilligramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.MilligramPerKilogram, q => q.ToUnit(MassFractionUnit.MilligramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.MilligramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.NanogramPerGram, q => q.ToUnit(MassFractionUnit.NanogramPerGram)); - unitConverter.SetConversionFunction(MassFractionUnit.NanogramPerGram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.NanogramPerKilogram, q => q.ToUnit(MassFractionUnit.NanogramPerKilogram)); - unitConverter.SetConversionFunction(MassFractionUnit.NanogramPerKilogram, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerBillion, q => q.ToUnit(MassFractionUnit.PartPerBillion)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerBillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerMillion, q => q.ToUnit(MassFractionUnit.PartPerMillion)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerMillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerThousand, q => q.ToUnit(MassFractionUnit.PartPerThousand)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerThousand, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.PartPerTrillion, q => q.ToUnit(MassFractionUnit.PartPerTrillion)); - unitConverter.SetConversionFunction(MassFractionUnit.PartPerTrillion, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassFraction.BaseUnit, MassFractionUnit.Percent, q => q.ToUnit(MassFractionUnit.Percent)); - unitConverter.SetConversionFunction(MassFractionUnit.Percent, MassFraction.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.GramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMillimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertia.BaseUnit, q => q); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilogramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareMillimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMilimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMilimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.MilligramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMillimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareMillimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.PoundSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareFoot)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.PoundSquareFoot, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.PoundSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareInch)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.PoundSquareInch, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.SlugSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareFoot)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.SlugSquareFoot, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.SlugSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareInch)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.SlugSquareInch, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareCentimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareCentimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareDecimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareDecimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareMeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MassMomentOfInertia.BaseUnit, MassMomentOfInertiaUnit.TonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMilimeter)); - unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareMilimeter, MassMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEnergy.BaseUnit, MolarEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(MolarEnergy.BaseUnit, MolarEnergyUnit.KilojoulePerMole, q => q.ToUnit(MolarEnergyUnit.KilojoulePerMole)); - unitConverter.SetConversionFunction(MolarEnergyUnit.KilojoulePerMole, MolarEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEnergy.BaseUnit, MolarEnergyUnit.MegajoulePerMole, q => q.ToUnit(MolarEnergyUnit.MegajoulePerMole)); - unitConverter.SetConversionFunction(MolarEnergyUnit.MegajoulePerMole, MolarEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEntropy.BaseUnit, MolarEntropy.BaseUnit, q => q); - unitConverter.SetConversionFunction(MolarEntropy.BaseUnit, MolarEntropyUnit.KilojoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.KilojoulePerMoleKelvin)); - unitConverter.SetConversionFunction(MolarEntropyUnit.KilojoulePerMoleKelvin, MolarEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarEntropy.BaseUnit, MolarEntropyUnit.MegajoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.MegajoulePerMoleKelvin)); - unitConverter.SetConversionFunction(MolarEntropyUnit.MegajoulePerMoleKelvin, MolarEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.CentimolesPerLiter, q => q.ToUnit(MolarityUnit.CentimolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.CentimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.DecimolesPerLiter, q => q.ToUnit(MolarityUnit.DecimolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.DecimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.MicromolesPerLiter, q => q.ToUnit(MolarityUnit.MicromolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.MicromolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.MillimolesPerLiter, q => q.ToUnit(MolarityUnit.MillimolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.MillimolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, Molarity.BaseUnit, q => q); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.MolesPerLiter, q => q.ToUnit(MolarityUnit.MolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.MolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.NanomolesPerLiter, q => q.ToUnit(MolarityUnit.NanomolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.NanomolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Molarity.BaseUnit, MolarityUnit.PicomolesPerLiter, q => q.ToUnit(MolarityUnit.PicomolesPerLiter)); - unitConverter.SetConversionFunction(MolarityUnit.PicomolesPerLiter, Molarity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.CentigramPerMole, q => q.ToUnit(MolarMassUnit.CentigramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.CentigramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.DecagramPerMole, q => q.ToUnit(MolarMassUnit.DecagramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.DecagramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.DecigramPerMole, q => q.ToUnit(MolarMassUnit.DecigramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.DecigramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.GramPerMole, q => q.ToUnit(MolarMassUnit.GramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.GramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.HectogramPerMole, q => q.ToUnit(MolarMassUnit.HectogramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.HectogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMass.BaseUnit, q => q); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.KilopoundPerMole, q => q.ToUnit(MolarMassUnit.KilopoundPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.KilopoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.MegapoundPerMole, q => q.ToUnit(MolarMassUnit.MegapoundPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.MegapoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.MicrogramPerMole, q => q.ToUnit(MolarMassUnit.MicrogramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.MicrogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.MilligramPerMole, q => q.ToUnit(MolarMassUnit.MilligramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.MilligramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.NanogramPerMole, q => q.ToUnit(MolarMassUnit.NanogramPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.NanogramPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(MolarMass.BaseUnit, MolarMassUnit.PoundPerMole, q => q.ToUnit(MolarMassUnit.PoundPerMole)); - unitConverter.SetConversionFunction(MolarMassUnit.PoundPerMole, MolarMass.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Permeability.BaseUnit, Permeability.BaseUnit, q => q); - unitConverter.SetConversionFunction(Permittivity.BaseUnit, Permittivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.BoilerHorsepower, q => q.ToUnit(PowerUnit.BoilerHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.BritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.BritishThermalUnitPerHour)); - unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Decawatt, q => q.ToUnit(PowerUnit.Decawatt)); - unitConverter.SetConversionFunction(PowerUnit.Decawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Deciwatt, q => q.ToUnit(PowerUnit.Deciwatt)); - unitConverter.SetConversionFunction(PowerUnit.Deciwatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.ElectricalHorsepower, q => q.ToUnit(PowerUnit.ElectricalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Femtowatt, q => q.ToUnit(PowerUnit.Femtowatt)); - unitConverter.SetConversionFunction(PowerUnit.Femtowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.GigajoulePerHour, q => q.ToUnit(PowerUnit.GigajoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.GigajoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Gigawatt, q => q.ToUnit(PowerUnit.Gigawatt)); - unitConverter.SetConversionFunction(PowerUnit.Gigawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.HydraulicHorsepower, q => q.ToUnit(PowerUnit.HydraulicHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.JoulePerHour, q => q.ToUnit(PowerUnit.JoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.KilobritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.KilobritishThermalUnitPerHour)); - unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.KilojoulePerHour, q => q.ToUnit(PowerUnit.KilojoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Kilowatt, q => q.ToUnit(PowerUnit.Kilowatt)); - unitConverter.SetConversionFunction(PowerUnit.Kilowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MechanicalHorsepower, q => q.ToUnit(PowerUnit.MechanicalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MegajoulePerHour, q => q.ToUnit(PowerUnit.MegajoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Megawatt, q => q.ToUnit(PowerUnit.Megawatt)); - unitConverter.SetConversionFunction(PowerUnit.Megawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MetricHorsepower, q => q.ToUnit(PowerUnit.MetricHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Microwatt, q => q.ToUnit(PowerUnit.Microwatt)); - unitConverter.SetConversionFunction(PowerUnit.Microwatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.MillijoulePerHour, q => q.ToUnit(PowerUnit.MillijoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.MillijoulePerHour, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Milliwatt, q => q.ToUnit(PowerUnit.Milliwatt)); - unitConverter.SetConversionFunction(PowerUnit.Milliwatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Nanowatt, q => q.ToUnit(PowerUnit.Nanowatt)); - unitConverter.SetConversionFunction(PowerUnit.Nanowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Petawatt, q => q.ToUnit(PowerUnit.Petawatt)); - unitConverter.SetConversionFunction(PowerUnit.Petawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Picowatt, q => q.ToUnit(PowerUnit.Picowatt)); - unitConverter.SetConversionFunction(PowerUnit.Picowatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, PowerUnit.Terawatt, q => q.ToUnit(PowerUnit.Terawatt)); - unitConverter.SetConversionFunction(PowerUnit.Terawatt, Power.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Power.BaseUnit, Power.BaseUnit, q => q); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DecawattPerLiter, q => q.ToUnit(PowerDensityUnit.DecawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.DeciwattPerLiter, q => q.ToUnit(PowerDensityUnit.DeciwattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.GigawattPerLiter, q => q.ToUnit(PowerDensityUnit.GigawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.KilowattPerLiter, q => q.ToUnit(PowerDensityUnit.KilowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MegawattPerLiter, q => q.ToUnit(PowerDensityUnit.MegawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MicrowattPerLiter, q => q.ToUnit(PowerDensityUnit.MicrowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.MilliwattPerLiter, q => q.ToUnit(PowerDensityUnit.MilliwattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.NanowattPerLiter, q => q.ToUnit(PowerDensityUnit.NanowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.PicowattPerLiter, q => q.ToUnit(PowerDensityUnit.PicowattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicMeter)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicMeter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.TerawattPerLiter, q => q.ToUnit(PowerDensityUnit.TerawattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.WattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.WattPerCubicFoot)); - unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicFoot, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.WattPerCubicInch, q => q.ToUnit(PowerDensityUnit.WattPerCubicInch)); - unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicInch, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensity.BaseUnit, q => q); - unitConverter.SetConversionFunction(PowerDensity.BaseUnit, PowerDensityUnit.WattPerLiter, q => q.ToUnit(PowerDensityUnit.WattPerLiter)); - unitConverter.SetConversionFunction(PowerDensityUnit.WattPerLiter, PowerDensity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerRatio.BaseUnit, PowerRatioUnit.DecibelMilliwatt, q => q.ToUnit(PowerRatioUnit.DecibelMilliwatt)); - unitConverter.SetConversionFunction(PowerRatioUnit.DecibelMilliwatt, PowerRatio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PowerRatio.BaseUnit, PowerRatio.BaseUnit, q => q); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Atmosphere, q => q.ToUnit(PressureUnit.Atmosphere)); - unitConverter.SetConversionFunction(PressureUnit.Atmosphere, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Bar, q => q.ToUnit(PressureUnit.Bar)); - unitConverter.SetConversionFunction(PressureUnit.Bar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Centibar, q => q.ToUnit(PressureUnit.Centibar)); - unitConverter.SetConversionFunction(PressureUnit.Centibar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Decapascal, q => q.ToUnit(PressureUnit.Decapascal)); - unitConverter.SetConversionFunction(PressureUnit.Decapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Decibar, q => q.ToUnit(PressureUnit.Decibar)); - unitConverter.SetConversionFunction(PressureUnit.Decibar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.DynePerSquareCentimeter, q => q.ToUnit(PressureUnit.DynePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.DynePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.FootOfElevation, q => q.ToUnit(PressureUnit.FootOfElevation)); - unitConverter.SetConversionFunction(PressureUnit.FootOfElevation, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.FootOfHead, q => q.ToUnit(PressureUnit.FootOfHead)); - unitConverter.SetConversionFunction(PressureUnit.FootOfHead, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Gigapascal, q => q.ToUnit(PressureUnit.Gigapascal)); - unitConverter.SetConversionFunction(PressureUnit.Gigapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Hectopascal, q => q.ToUnit(PressureUnit.Hectopascal)); - unitConverter.SetConversionFunction(PressureUnit.Hectopascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.InchOfMercury, q => q.ToUnit(PressureUnit.InchOfMercury)); - unitConverter.SetConversionFunction(PressureUnit.InchOfMercury, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.InchOfWaterColumn, q => q.ToUnit(PressureUnit.InchOfWaterColumn)); - unitConverter.SetConversionFunction(PressureUnit.InchOfWaterColumn, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Kilobar, q => q.ToUnit(PressureUnit.Kilobar)); - unitConverter.SetConversionFunction(PressureUnit.Kilobar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareMeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilogramForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareMeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilonewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Kilopascal, q => q.ToUnit(PressureUnit.Kilopascal)); - unitConverter.SetConversionFunction(PressureUnit.Kilopascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilopoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareFoot)); - unitConverter.SetConversionFunction(PressureUnit.KilopoundForcePerSquareFoot, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.KilopoundForcePerSquareInch, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareInch)); - unitConverter.SetConversionFunction(PressureUnit.KilopoundForcePerSquareInch, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Megabar, q => q.ToUnit(PressureUnit.Megabar)); - unitConverter.SetConversionFunction(PressureUnit.Megabar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MeganewtonPerSquareMeter, q => q.ToUnit(PressureUnit.MeganewtonPerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.MeganewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Megapascal, q => q.ToUnit(PressureUnit.Megapascal)); - unitConverter.SetConversionFunction(PressureUnit.Megapascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MeterOfElevation, q => q.ToUnit(PressureUnit.MeterOfElevation)); - unitConverter.SetConversionFunction(PressureUnit.MeterOfElevation, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MeterOfHead, q => q.ToUnit(PressureUnit.MeterOfHead)); - unitConverter.SetConversionFunction(PressureUnit.MeterOfHead, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Microbar, q => q.ToUnit(PressureUnit.Microbar)); - unitConverter.SetConversionFunction(PressureUnit.Microbar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Micropascal, q => q.ToUnit(PressureUnit.Micropascal)); - unitConverter.SetConversionFunction(PressureUnit.Micropascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Millibar, q => q.ToUnit(PressureUnit.Millibar)); - unitConverter.SetConversionFunction(PressureUnit.Millibar, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.MillimeterOfMercury, q => q.ToUnit(PressureUnit.MillimeterOfMercury)); - unitConverter.SetConversionFunction(PressureUnit.MillimeterOfMercury, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Millipascal, q => q.ToUnit(PressureUnit.Millipascal)); - unitConverter.SetConversionFunction(PressureUnit.Millipascal, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.NewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.NewtonPerSquareMeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.NewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, Pressure.BaseUnit, q => q); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.PoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.PoundForcePerSquareFoot)); - unitConverter.SetConversionFunction(PressureUnit.PoundForcePerSquareFoot, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.PoundForcePerSquareInch, q => q.ToUnit(PressureUnit.PoundForcePerSquareInch)); - unitConverter.SetConversionFunction(PressureUnit.PoundForcePerSquareInch, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.PoundPerInchSecondSquared, q => q.ToUnit(PressureUnit.PoundPerInchSecondSquared)); - unitConverter.SetConversionFunction(PressureUnit.PoundPerInchSecondSquared, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TechnicalAtmosphere, q => q.ToUnit(PressureUnit.TechnicalAtmosphere)); - unitConverter.SetConversionFunction(PressureUnit.TechnicalAtmosphere, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareCentimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareMeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMeter)); - unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareMeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.TonneForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMillimeter)); - unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareMillimeter, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Pressure.BaseUnit, PressureUnit.Torr, q => q.ToUnit(PressureUnit.Torr)); - unitConverter.SetConversionFunction(PressureUnit.Torr, Pressure.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.AtmospherePerSecond, q => q.ToUnit(PressureChangeRateUnit.AtmospherePerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.AtmospherePerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopascalPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, q => q.ToUnit(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, q => q.ToUnit(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapascalPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, q => q.ToUnit(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, q => q.ToUnit(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.PascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.PascalPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, q => q.ToUnit(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(PressureChangeRate.BaseUnit, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, q => q.ToUnit(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond)); - unitConverter.SetConversionFunction(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, PressureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, Ratio.BaseUnit, q => q); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerBillion, q => q.ToUnit(RatioUnit.PartPerBillion)); - unitConverter.SetConversionFunction(RatioUnit.PartPerBillion, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerMillion, q => q.ToUnit(RatioUnit.PartPerMillion)); - unitConverter.SetConversionFunction(RatioUnit.PartPerMillion, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerThousand, q => q.ToUnit(RatioUnit.PartPerThousand)); - unitConverter.SetConversionFunction(RatioUnit.PartPerThousand, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.PartPerTrillion, q => q.ToUnit(RatioUnit.PartPerTrillion)); - unitConverter.SetConversionFunction(RatioUnit.PartPerTrillion, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Ratio.BaseUnit, RatioUnit.Percent, q => q.ToUnit(RatioUnit.Percent)); - unitConverter.SetConversionFunction(RatioUnit.Percent, Ratio.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RatioChangeRate.BaseUnit, RatioChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(RatioChangeRate.BaseUnit, RatioChangeRateUnit.PercentPerSecond, q => q.ToUnit(RatioChangeRateUnit.PercentPerSecond)); - unitConverter.SetConversionFunction(RatioChangeRateUnit.PercentPerSecond, RatioChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactiveEnergy.BaseUnit, ReactiveEnergyUnit.KilovoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour)); - unitConverter.SetConversionFunction(ReactiveEnergyUnit.KilovoltampereReactiveHour, ReactiveEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactiveEnergy.BaseUnit, ReactiveEnergyUnit.MegavoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.MegavoltampereReactiveHour)); - unitConverter.SetConversionFunction(ReactiveEnergyUnit.MegavoltampereReactiveHour, ReactiveEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactiveEnergy.BaseUnit, ReactiveEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePowerUnit.GigavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.GigavoltampereReactive)); - unitConverter.SetConversionFunction(ReactivePowerUnit.GigavoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePowerUnit.KilovoltampereReactive, q => q.ToUnit(ReactivePowerUnit.KilovoltampereReactive)); - unitConverter.SetConversionFunction(ReactivePowerUnit.KilovoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePowerUnit.MegavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.MegavoltampereReactive)); - unitConverter.SetConversionFunction(ReactivePowerUnit.MegavoltampereReactive, ReactivePower.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReactivePower.BaseUnit, ReactivePower.BaseUnit, q => q); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareCentimeter, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareCentimeter)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareCentimeter, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareDecimeter, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareDecimeter)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareDecimeter, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareFoot, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareFoot)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareFoot, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareInch, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareInch)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareInch, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareKilometer, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareKilometer)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareKilometer, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalArea.BaseUnit, q => q); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareMicrometer, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareMicrometer)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMicrometer, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareMile, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareMile)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMile, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareMillimeter, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareMillimeter)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMillimeter, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseSquareYard, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareYard)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareYard, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalArea.BaseUnit, ReciprocalAreaUnit.InverseUsSurveySquareFoot, q => q.ToUnit(ReciprocalAreaUnit.InverseUsSurveySquareFoot)); - unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseUsSurveySquareFoot, ReciprocalArea.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseCentimeter, q => q.ToUnit(ReciprocalLengthUnit.InverseCentimeter)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseCentimeter, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseFoot, q => q.ToUnit(ReciprocalLengthUnit.InverseFoot)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseFoot, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseInch, q => q.ToUnit(ReciprocalLengthUnit.InverseInch)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseInch, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseMicroinch, q => q.ToUnit(ReciprocalLengthUnit.InverseMicroinch)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMicroinch, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseMil, q => q.ToUnit(ReciprocalLengthUnit.InverseMil)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMil, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseMile, q => q.ToUnit(ReciprocalLengthUnit.InverseMile)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMile, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseMillimeter, q => q.ToUnit(ReciprocalLengthUnit.InverseMillimeter)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMillimeter, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseUsSurveyFoot, q => q.ToUnit(ReciprocalLengthUnit.InverseUsSurveyFoot)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseUsSurveyFoot, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ReciprocalLength.BaseUnit, ReciprocalLengthUnit.InverseYard, q => q.ToUnit(ReciprocalLengthUnit.InverseYard)); - unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseYard, ReciprocalLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RelativeHumidity.BaseUnit, RelativeHumidity.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.DegreePerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared)); - unitConverter.SetConversionFunction(RotationalAccelerationUnit.DegreePerSecondSquared, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAcceleration.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.RevolutionPerMinutePerSecond, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerMinutePerSecond)); - unitConverter.SetConversionFunction(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalAcceleration.BaseUnit, RotationalAccelerationUnit.RevolutionPerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerSecondSquared)); - unitConverter.SetConversionFunction(RotationalAccelerationUnit.RevolutionPerSecondSquared, RotationalAcceleration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.CentiradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.CentiradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.CentiradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DeciradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.DeciradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.DeciradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DegreePerMinute, q => q.ToUnit(RotationalSpeedUnit.DegreePerMinute)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.DegreePerMinute, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.DegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.DegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.DegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MicrodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MicrodegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MicroradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MicroradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MillidegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MillidegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MillidegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.MilliradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MilliradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.MilliradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.NanodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.NanodegreePerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.NanodegreePerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.NanoradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.NanoradianPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.NanoradianPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeed.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.RevolutionPerMinute, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerMinute)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.RevolutionPerMinute, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalSpeed.BaseUnit, RotationalSpeedUnit.RevolutionPerSecond, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerSecond)); - unitConverter.SetConversionFunction(RotationalSpeedUnit.RevolutionPerSecond, RotationalSpeed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.KilopoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.KilopoundForceFootPerDegrees)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilopoundForceFootPerDegrees, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffness.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerDegree)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMillimeterPerDegree, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMillimeterPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.PoundForceFeetPerRadian, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFeetPerRadian)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.PoundForceFeetPerRadian, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffness.BaseUnit, RotationalStiffnessUnit.PoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFootPerDegrees)); - unitConverter.SetConversionFunction(RotationalStiffnessUnit.PoundForceFootPerDegrees, RotationalStiffness.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(RotationalStiffnessPerLength.BaseUnit, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); - unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Scalar.BaseUnit, Scalar.BaseUnit, q => q); - unitConverter.SetConversionFunction(SolidAngle.BaseUnit, SolidAngle.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.BtuPerPound, q => q.ToUnit(SpecificEnergyUnit.BtuPerPound)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.BtuPerPound, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.CaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.CaloriePerGram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.CaloriePerGram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.GigawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergy.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilocaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.KilocaloriePerGram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilocaloriePerGram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilojoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilojoulePerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilojoulePerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.KilowattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegajoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegajoulePerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegajoulePerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.MegawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.TerawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattDayPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.WattDayPerShortTon)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerShortTon, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.WattDayPerTonne)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerTonne, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEnergy.BaseUnit, SpecificEnergyUnit.WattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattHourPerKilogram)); - unitConverter.SetConversionFunction(SpecificEnergyUnit.WattHourPerKilogram, SpecificEnergy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.BtuPerPoundFahrenheit, q => q.ToUnit(SpecificEntropyUnit.BtuPerPoundFahrenheit)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.BtuPerPoundFahrenheit, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.CaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.CaloriePerGramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.CaloriePerGramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropy.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilocaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilocaloriePerGramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.KilocaloriePerGramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.KilojoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.KilojoulePerKilogramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificEntropy.BaseUnit, SpecificEntropyUnit.MegajoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramKelvin)); - unitConverter.SetConversionFunction(SpecificEntropyUnit.MegajoulePerKilogramKelvin, SpecificEntropy.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificFuelConsumption.BaseUnit, SpecificFuelConsumption.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificFuelConsumption.BaseUnit, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, q => q.ToUnit(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour)); - unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, SpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificFuelConsumption.BaseUnit, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, q => q.ToUnit(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond)); - unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, SpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificFuelConsumption.BaseUnit, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, q => q.ToUnit(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour)); - unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, SpecificFuelConsumption.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificVolume.BaseUnit, SpecificVolumeUnit.CubicFootPerPound, q => q.ToUnit(SpecificVolumeUnit.CubicFootPerPound)); - unitConverter.SetConversionFunction(SpecificVolumeUnit.CubicFootPerPound, SpecificVolume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificVolume.BaseUnit, SpecificVolume.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificVolume.BaseUnit, SpecificVolumeUnit.MillicubicMeterPerKilogram, q => q.ToUnit(SpecificVolumeUnit.MillicubicMeterPerKilogram)); - unitConverter.SetConversionFunction(SpecificVolumeUnit.MillicubicMeterPerKilogram, SpecificVolume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilogramForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilonewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilopoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicFoot)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilopoundForcePerCubicFoot, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.KilopoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicInch)); - unitConverter.SetConversionFunction(SpecificWeightUnit.KilopoundForcePerCubicInch, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.MeganewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.MeganewtonPerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.MeganewtonPerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.NewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeight.BaseUnit, q => q); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.NewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.PoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicFoot)); - unitConverter.SetConversionFunction(SpecificWeightUnit.PoundForcePerCubicFoot, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.PoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicInch)); - unitConverter.SetConversionFunction(SpecificWeightUnit.PoundForcePerCubicInch, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicCentimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicCentimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicMeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(SpecificWeight.BaseUnit, SpecificWeightUnit.TonneForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMillimeter)); - unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicMillimeter, SpecificWeight.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.CentimeterPerHour, q => q.ToUnit(SpeedUnit.CentimeterPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.CentimeterPerMinute, q => q.ToUnit(SpeedUnit.CentimeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.CentimeterPerSecond, q => q.ToUnit(SpeedUnit.CentimeterPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.DecimeterPerMinute, q => q.ToUnit(SpeedUnit.DecimeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.DecimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.DecimeterPerSecond, q => q.ToUnit(SpeedUnit.DecimeterPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.DecimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.FootPerHour, q => q.ToUnit(SpeedUnit.FootPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.FootPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.FootPerMinute, q => q.ToUnit(SpeedUnit.FootPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.FootPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.FootPerSecond, q => q.ToUnit(SpeedUnit.FootPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.FootPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.InchPerHour, q => q.ToUnit(SpeedUnit.InchPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.InchPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.InchPerMinute, q => q.ToUnit(SpeedUnit.InchPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.InchPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.InchPerSecond, q => q.ToUnit(SpeedUnit.InchPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.InchPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.KilometerPerHour, q => q.ToUnit(SpeedUnit.KilometerPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.KilometerPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.KilometerPerMinute, q => q.ToUnit(SpeedUnit.KilometerPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.KilometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.KilometerPerSecond, q => q.ToUnit(SpeedUnit.KilometerPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.KilometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.Knot, q => q.ToUnit(SpeedUnit.Knot)); - unitConverter.SetConversionFunction(SpeedUnit.Knot, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MeterPerHour, q => q.ToUnit(SpeedUnit.MeterPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.MeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MeterPerMinute, q => q.ToUnit(SpeedUnit.MeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.MeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, Speed.BaseUnit, q => q); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MicrometerPerMinute, q => q.ToUnit(SpeedUnit.MicrometerPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.MicrometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MicrometerPerSecond, q => q.ToUnit(SpeedUnit.MicrometerPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.MicrometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MilePerHour, q => q.ToUnit(SpeedUnit.MilePerHour)); - unitConverter.SetConversionFunction(SpeedUnit.MilePerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MillimeterPerHour, q => q.ToUnit(SpeedUnit.MillimeterPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MillimeterPerMinute, q => q.ToUnit(SpeedUnit.MillimeterPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.MillimeterPerSecond, q => q.ToUnit(SpeedUnit.MillimeterPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.NanometerPerMinute, q => q.ToUnit(SpeedUnit.NanometerPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.NanometerPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.NanometerPerSecond, q => q.ToUnit(SpeedUnit.NanometerPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.NanometerPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerHour, q => q.ToUnit(SpeedUnit.UsSurveyFootPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerMinute, q => q.ToUnit(SpeedUnit.UsSurveyFootPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.UsSurveyFootPerSecond, q => q.ToUnit(SpeedUnit.UsSurveyFootPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.YardPerHour, q => q.ToUnit(SpeedUnit.YardPerHour)); - unitConverter.SetConversionFunction(SpeedUnit.YardPerHour, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.YardPerMinute, q => q.ToUnit(SpeedUnit.YardPerMinute)); - unitConverter.SetConversionFunction(SpeedUnit.YardPerMinute, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Speed.BaseUnit, SpeedUnit.YardPerSecond, q => q.ToUnit(SpeedUnit.YardPerSecond)); - unitConverter.SetConversionFunction(SpeedUnit.YardPerSecond, Speed.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicFootPerHour, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicFootPerHour)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicFootPerHour, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicFootPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicFootPerMinute)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicFootPerMinute, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicFootPerSecond, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicFootPerSecond)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicFootPerSecond, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicMeterPerDay, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicMeterPerDay)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerDay, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicMeterPerHour, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicMeterPerHour)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerHour, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardCubicMeterPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicMeterPerMinute)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerMinute, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlow.BaseUnit, q => q); - unitConverter.SetConversionFunction(StandardVolumeFlow.BaseUnit, StandardVolumeFlowUnit.StandardLiterPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardLiterPerMinute)); - unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardLiterPerMinute, StandardVolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeCelsius, q => q.ToUnit(TemperatureUnit.DegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeCelsius, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeDelisle, q => q.ToUnit(TemperatureUnit.DegreeDelisle)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeDelisle, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureUnit.DegreeFahrenheit)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeFahrenheit, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeNewton, q => q.ToUnit(TemperatureUnit.DegreeNewton)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeNewton, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeRankine, q => q.ToUnit(TemperatureUnit.DegreeRankine)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeRankine, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeReaumur, q => q.ToUnit(TemperatureUnit.DegreeReaumur)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeReaumur, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.DegreeRoemer, q => q.ToUnit(TemperatureUnit.DegreeRoemer)); - unitConverter.SetConversionFunction(TemperatureUnit.DegreeRoemer, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, Temperature.BaseUnit, q => q); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureUnit.MillidegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureUnit.MillidegreeCelsius, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Temperature.BaseUnit, TemperatureUnit.SolarTemperature, q => q.ToUnit(TemperatureUnit.SolarTemperature)); - unitConverter.SetConversionFunction(TemperatureUnit.SolarTemperature, Temperature.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.DegreeCelsiusPerMinute, q => q.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerMinute)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRate.BaseUnit, q => q); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureChangeRate.BaseUnit, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); - unitConverter.SetConversionFunction(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, TemperatureChangeRate.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.DegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeCelsius, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeDelisle, q => q.ToUnit(TemperatureDeltaUnit.DegreeDelisle)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeDelisle, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureDeltaUnit.DegreeFahrenheit)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeFahrenheit, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeNewton, q => q.ToUnit(TemperatureDeltaUnit.DegreeNewton)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeNewton, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeRankine, q => q.ToUnit(TemperatureDeltaUnit.DegreeRankine)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeRankine, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeReaumur, q => q.ToUnit(TemperatureDeltaUnit.DegreeReaumur)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeReaumur, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.DegreeRoemer, q => q.ToUnit(TemperatureDeltaUnit.DegreeRoemer)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeRoemer, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDelta.BaseUnit, q => q); - unitConverter.SetConversionFunction(TemperatureDelta.BaseUnit, TemperatureDeltaUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.MillidegreeCelsius)); - unitConverter.SetConversionFunction(TemperatureDeltaUnit.MillidegreeCelsius, TemperatureDelta.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalConductivity.BaseUnit, ThermalConductivityUnit.BtuPerHourFootFahrenheit, q => q.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit)); - unitConverter.SetConversionFunction(ThermalConductivityUnit.BtuPerHourFootFahrenheit, ThermalConductivity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalConductivity.BaseUnit, ThermalConductivity.BaseUnit, q => q); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, q => q.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt)); - unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, ThermalResistance.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(ThermalResistance.BaseUnit, ThermalResistance.BaseUnit, q => q); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilogramForceCentimeter, q => q.ToUnit(TorqueUnit.KilogramForceCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilogramForceCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilogramForceMeter, q => q.ToUnit(TorqueUnit.KilogramForceMeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilogramForceMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilogramForceMillimeter, q => q.ToUnit(TorqueUnit.KilogramForceMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilogramForceMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilonewtonCentimeter, q => q.ToUnit(TorqueUnit.KilonewtonCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilonewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilonewtonMeter, q => q.ToUnit(TorqueUnit.KilonewtonMeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilonewtonMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilonewtonMillimeter, q => q.ToUnit(TorqueUnit.KilonewtonMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.KilonewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilopoundForceFoot, q => q.ToUnit(TorqueUnit.KilopoundForceFoot)); - unitConverter.SetConversionFunction(TorqueUnit.KilopoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.KilopoundForceInch, q => q.ToUnit(TorqueUnit.KilopoundForceInch)); - unitConverter.SetConversionFunction(TorqueUnit.KilopoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MeganewtonCentimeter, q => q.ToUnit(TorqueUnit.MeganewtonCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.MeganewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MeganewtonMeter, q => q.ToUnit(TorqueUnit.MeganewtonMeter)); - unitConverter.SetConversionFunction(TorqueUnit.MeganewtonMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MeganewtonMillimeter, q => q.ToUnit(TorqueUnit.MeganewtonMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.MeganewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MegapoundForceFoot, q => q.ToUnit(TorqueUnit.MegapoundForceFoot)); - unitConverter.SetConversionFunction(TorqueUnit.MegapoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.MegapoundForceInch, q => q.ToUnit(TorqueUnit.MegapoundForceInch)); - unitConverter.SetConversionFunction(TorqueUnit.MegapoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.NewtonCentimeter, q => q.ToUnit(TorqueUnit.NewtonCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.NewtonCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, Torque.BaseUnit, q => q); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.NewtonMillimeter, q => q.ToUnit(TorqueUnit.NewtonMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.NewtonMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.PoundalFoot, q => q.ToUnit(TorqueUnit.PoundalFoot)); - unitConverter.SetConversionFunction(TorqueUnit.PoundalFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.PoundForceFoot, q => q.ToUnit(TorqueUnit.PoundForceFoot)); - unitConverter.SetConversionFunction(TorqueUnit.PoundForceFoot, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.PoundForceInch, q => q.ToUnit(TorqueUnit.PoundForceInch)); - unitConverter.SetConversionFunction(TorqueUnit.PoundForceInch, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.TonneForceCentimeter, q => q.ToUnit(TorqueUnit.TonneForceCentimeter)); - unitConverter.SetConversionFunction(TorqueUnit.TonneForceCentimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.TonneForceMeter, q => q.ToUnit(TorqueUnit.TonneForceMeter)); - unitConverter.SetConversionFunction(TorqueUnit.TonneForceMeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Torque.BaseUnit, TorqueUnit.TonneForceMillimeter, q => q.ToUnit(TorqueUnit.TonneForceMillimeter)); - unitConverter.SetConversionFunction(TorqueUnit.TonneForceMillimeter, Torque.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilogramForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilonewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilopoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.KilopoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MeganewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MegapoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.MegapoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.NewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.NewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.PoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceFootPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.PoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceInchPerFoot)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceCentimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(TorquePerLength.BaseUnit, TorquePerLengthUnit.TonneForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMillimeterPerMeter)); - unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Turbidity.BaseUnit, Turbidity.BaseUnit, q => q); - unitConverter.SetConversionFunction(VitaminA.BaseUnit, VitaminA.BaseUnit, q => q); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.AcreFoot, q => q.ToUnit(VolumeUnit.AcreFoot)); - unitConverter.SetConversionFunction(VolumeUnit.AcreFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.AuTablespoon, q => q.ToUnit(VolumeUnit.AuTablespoon)); - unitConverter.SetConversionFunction(VolumeUnit.AuTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.BoardFoot, q => q.ToUnit(VolumeUnit.BoardFoot)); - unitConverter.SetConversionFunction(VolumeUnit.BoardFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Centiliter, q => q.ToUnit(VolumeUnit.Centiliter)); - unitConverter.SetConversionFunction(VolumeUnit.Centiliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicCentimeter, q => q.ToUnit(VolumeUnit.CubicCentimeter)); - unitConverter.SetConversionFunction(VolumeUnit.CubicCentimeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicDecimeter, q => q.ToUnit(VolumeUnit.CubicDecimeter)); - unitConverter.SetConversionFunction(VolumeUnit.CubicDecimeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicFoot, q => q.ToUnit(VolumeUnit.CubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.CubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicHectometer, q => q.ToUnit(VolumeUnit.CubicHectometer)); - unitConverter.SetConversionFunction(VolumeUnit.CubicHectometer, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicInch, q => q.ToUnit(VolumeUnit.CubicInch)); - unitConverter.SetConversionFunction(VolumeUnit.CubicInch, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicKilometer, q => q.ToUnit(VolumeUnit.CubicKilometer)); - unitConverter.SetConversionFunction(VolumeUnit.CubicKilometer, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, Volume.BaseUnit, q => q); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicMicrometer, q => q.ToUnit(VolumeUnit.CubicMicrometer)); - unitConverter.SetConversionFunction(VolumeUnit.CubicMicrometer, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicMile, q => q.ToUnit(VolumeUnit.CubicMile)); - unitConverter.SetConversionFunction(VolumeUnit.CubicMile, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicMillimeter, q => q.ToUnit(VolumeUnit.CubicMillimeter)); - unitConverter.SetConversionFunction(VolumeUnit.CubicMillimeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.CubicYard, q => q.ToUnit(VolumeUnit.CubicYard)); - unitConverter.SetConversionFunction(VolumeUnit.CubicYard, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.DecausGallon, q => q.ToUnit(VolumeUnit.DecausGallon)); - unitConverter.SetConversionFunction(VolumeUnit.DecausGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Deciliter, q => q.ToUnit(VolumeUnit.Deciliter)); - unitConverter.SetConversionFunction(VolumeUnit.Deciliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.DeciusGallon, q => q.ToUnit(VolumeUnit.DeciusGallon)); - unitConverter.SetConversionFunction(VolumeUnit.DeciusGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.HectocubicFoot, q => q.ToUnit(VolumeUnit.HectocubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.HectocubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.HectocubicMeter, q => q.ToUnit(VolumeUnit.HectocubicMeter)); - unitConverter.SetConversionFunction(VolumeUnit.HectocubicMeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Hectoliter, q => q.ToUnit(VolumeUnit.Hectoliter)); - unitConverter.SetConversionFunction(VolumeUnit.Hectoliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.HectousGallon, q => q.ToUnit(VolumeUnit.HectousGallon)); - unitConverter.SetConversionFunction(VolumeUnit.HectousGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialBeerBarrel, q => q.ToUnit(VolumeUnit.ImperialBeerBarrel)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialBeerBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialGallon, q => q.ToUnit(VolumeUnit.ImperialGallon)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialOunce, q => q.ToUnit(VolumeUnit.ImperialOunce)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialOunce, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.ImperialPint, q => q.ToUnit(VolumeUnit.ImperialPint)); - unitConverter.SetConversionFunction(VolumeUnit.ImperialPint, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KilocubicFoot, q => q.ToUnit(VolumeUnit.KilocubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.KilocubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KilocubicMeter, q => q.ToUnit(VolumeUnit.KilocubicMeter)); - unitConverter.SetConversionFunction(VolumeUnit.KilocubicMeter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KiloimperialGallon, q => q.ToUnit(VolumeUnit.KiloimperialGallon)); - unitConverter.SetConversionFunction(VolumeUnit.KiloimperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Kiloliter, q => q.ToUnit(VolumeUnit.Kiloliter)); - unitConverter.SetConversionFunction(VolumeUnit.Kiloliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.KilousGallon, q => q.ToUnit(VolumeUnit.KilousGallon)); - unitConverter.SetConversionFunction(VolumeUnit.KilousGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Liter, q => q.ToUnit(VolumeUnit.Liter)); - unitConverter.SetConversionFunction(VolumeUnit.Liter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MegacubicFoot, q => q.ToUnit(VolumeUnit.MegacubicFoot)); - unitConverter.SetConversionFunction(VolumeUnit.MegacubicFoot, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MegaimperialGallon, q => q.ToUnit(VolumeUnit.MegaimperialGallon)); - unitConverter.SetConversionFunction(VolumeUnit.MegaimperialGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Megaliter, q => q.ToUnit(VolumeUnit.Megaliter)); - unitConverter.SetConversionFunction(VolumeUnit.Megaliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MegausGallon, q => q.ToUnit(VolumeUnit.MegausGallon)); - unitConverter.SetConversionFunction(VolumeUnit.MegausGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MetricCup, q => q.ToUnit(VolumeUnit.MetricCup)); - unitConverter.SetConversionFunction(VolumeUnit.MetricCup, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.MetricTeaspoon, q => q.ToUnit(VolumeUnit.MetricTeaspoon)); - unitConverter.SetConversionFunction(VolumeUnit.MetricTeaspoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Microliter, q => q.ToUnit(VolumeUnit.Microliter)); - unitConverter.SetConversionFunction(VolumeUnit.Microliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.Milliliter, q => q.ToUnit(VolumeUnit.Milliliter)); - unitConverter.SetConversionFunction(VolumeUnit.Milliliter, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.OilBarrel, q => q.ToUnit(VolumeUnit.OilBarrel)); - unitConverter.SetConversionFunction(VolumeUnit.OilBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UkTablespoon, q => q.ToUnit(VolumeUnit.UkTablespoon)); - unitConverter.SetConversionFunction(VolumeUnit.UkTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsBeerBarrel, q => q.ToUnit(VolumeUnit.UsBeerBarrel)); - unitConverter.SetConversionFunction(VolumeUnit.UsBeerBarrel, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsCustomaryCup, q => q.ToUnit(VolumeUnit.UsCustomaryCup)); - unitConverter.SetConversionFunction(VolumeUnit.UsCustomaryCup, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsGallon, q => q.ToUnit(VolumeUnit.UsGallon)); - unitConverter.SetConversionFunction(VolumeUnit.UsGallon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsLegalCup, q => q.ToUnit(VolumeUnit.UsLegalCup)); - unitConverter.SetConversionFunction(VolumeUnit.UsLegalCup, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsOunce, q => q.ToUnit(VolumeUnit.UsOunce)); - unitConverter.SetConversionFunction(VolumeUnit.UsOunce, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsPint, q => q.ToUnit(VolumeUnit.UsPint)); - unitConverter.SetConversionFunction(VolumeUnit.UsPint, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsQuart, q => q.ToUnit(VolumeUnit.UsQuart)); - unitConverter.SetConversionFunction(VolumeUnit.UsQuart, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsTablespoon, q => q.ToUnit(VolumeUnit.UsTablespoon)); - unitConverter.SetConversionFunction(VolumeUnit.UsTablespoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(Volume.BaseUnit, VolumeUnit.UsTeaspoon, q => q.ToUnit(VolumeUnit.UsTeaspoon)); - unitConverter.SetConversionFunction(VolumeUnit.UsTeaspoon, Volume.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.CentilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.CentilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.CentilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.CentilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.DecilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.DecilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentration.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.LitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.LitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.LitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.LitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MicrolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MicrolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MicrolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MicrolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MillilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MillilitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.MillilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.MillilitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.NanolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.NanolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.NanolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.NanolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerBillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerBillion)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerBillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerMillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerMillion)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerMillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerThousand, q => q.ToUnit(VolumeConcentrationUnit.PartPerThousand)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerThousand, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PartPerTrillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerTrillion)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerTrillion, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.Percent, q => q.ToUnit(VolumeConcentrationUnit.Percent)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.Percent, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PicolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerLiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PicolitersPerLiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeConcentration.BaseUnit, VolumeConcentrationUnit.PicolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerMililiter)); - unitConverter.SetConversionFunction(VolumeConcentrationUnit.PicolitersPerMililiter, VolumeConcentration.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerDay, q => q.ToUnit(VolumeFlowUnit.AcreFootPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerHour, q => q.ToUnit(VolumeFlowUnit.AcreFootPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerMinute, q => q.ToUnit(VolumeFlowUnit.AcreFootPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.AcreFootPerSecond, q => q.ToUnit(VolumeFlowUnit.AcreFootPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerDay, q => q.ToUnit(VolumeFlowUnit.CentiliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerMinute, q => q.ToUnit(VolumeFlowUnit.CentiliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CentiliterPerSecond, q => q.ToUnit(VolumeFlowUnit.CentiliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicCentimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicCentimeterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicCentimeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicDecimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicDecimeterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicDecimeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerHour, q => q.ToUnit(VolumeFlowUnit.CubicFootPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicFootPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicFootPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicFootPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerDay, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerHour, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlow.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicMillimeterPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicMillimeterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMillimeterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerDay, q => q.ToUnit(VolumeFlowUnit.CubicYardPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerHour, q => q.ToUnit(VolumeFlowUnit.CubicYardPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicYardPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.CubicYardPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicYardPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerDay, q => q.ToUnit(VolumeFlowUnit.DeciliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerMinute, q => q.ToUnit(VolumeFlowUnit.DeciliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.DeciliterPerSecond, q => q.ToUnit(VolumeFlowUnit.DeciliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerDay, q => q.ToUnit(VolumeFlowUnit.KiloliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerMinute, q => q.ToUnit(VolumeFlowUnit.KiloliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KiloliterPerSecond, q => q.ToUnit(VolumeFlowUnit.KiloliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.KilousGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.KilousGallonPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.KilousGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerDay, q => q.ToUnit(VolumeFlowUnit.LiterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerHour, q => q.ToUnit(VolumeFlowUnit.LiterPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerMinute, q => q.ToUnit(VolumeFlowUnit.LiterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.LiterPerSecond, q => q.ToUnit(VolumeFlowUnit.LiterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MegaliterPerDay, q => q.ToUnit(VolumeFlowUnit.MegaliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MegaliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MegaukGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.MegaukGallonPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MegaukGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerDay, q => q.ToUnit(VolumeFlowUnit.MicroliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MicroliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MicroliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MicroliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerDay, q => q.ToUnit(VolumeFlowUnit.MilliliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MilliliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MilliliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MilliliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.MillionUsGallonsPerDay, q => q.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonsPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerDay, q => q.ToUnit(VolumeFlowUnit.NanoliterPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerMinute, q => q.ToUnit(VolumeFlowUnit.NanoliterPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.NanoliterPerSecond, q => q.ToUnit(VolumeFlowUnit.NanoliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerDay, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerHour, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerMinute, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.OilBarrelPerSecond, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UkGallonPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UkGallonPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UkGallonPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UkGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UkGallonPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UsGallonPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerDay, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UsGallonPerHour)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerHour, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UsGallonPerMinute)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerMinute, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.BaseUnit, VolumeFlowUnit.UsGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UsGallonPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerSecond, VolumeFlow.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLength.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.CubicYardPerFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerFoot)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicYardPerFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.CubicYardPerUsSurveyFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerUsSurveyFoot)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerKilometer, q => q.ToUnit(VolumePerLengthUnit.LiterPerKilometer)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerKilometer, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerMeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMeter)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerMeter, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.LiterPerMillimeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMillimeter)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerMillimeter, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumePerLength.BaseUnit, VolumePerLengthUnit.OilBarrelPerFoot, q => q.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot)); - unitConverter.SetConversionFunction(VolumePerLengthUnit.OilBarrelPerFoot, VolumePerLength.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, q => q.ToUnit(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacity.BaseUnit, q => q); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, q => q.ToUnit(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumetricHeatCapacity.BaseUnit, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, q => q.ToUnit(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin)); - unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, VolumetricHeatCapacity.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.CentimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.CentimeterToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.CentimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.DecimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.DecimeterToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.DecimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.FootToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.FootToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.FootToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.InchToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.InchToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.InchToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertia.BaseUnit, q => q); - unitConverter.SetConversionFunction(WarpingMomentOfInertia.BaseUnit, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); - unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, WarpingMomentOfInertia.BaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.CentimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.CentimeterPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.CentimeterPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.DecimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.DecimeterPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.DecimeterPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.FootPerSecondSquared, q => q.ToUnit(AccelerationUnit.FootPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.FootPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.InchPerSecondSquared, q => q.ToUnit(AccelerationUnit.InchPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.InchPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.KilometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.KilometerPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.KilometerPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.KnotPerHour, q => q.ToUnit(AccelerationUnit.KnotPerHour)); + unitConverter.SetConversionFunction(AccelerationUnit.KnotPerHour, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.KnotPerMinute, q => q.ToUnit(AccelerationUnit.KnotPerMinute)); + unitConverter.SetConversionFunction(AccelerationUnit.KnotPerMinute, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.KnotPerSecond, q => q.ToUnit(AccelerationUnit.KnotPerSecond)); + unitConverter.SetConversionFunction(AccelerationUnit.KnotPerSecond, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, Acceleration.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.MicrometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.MicrometerPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.MicrometerPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.MillimeterPerSecondSquared, q => q.ToUnit(AccelerationUnit.MillimeterPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.MillimeterPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.MillistandardGravity, q => q.ToUnit(AccelerationUnit.MillistandardGravity)); + unitConverter.SetConversionFunction(AccelerationUnit.MillistandardGravity, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.NanometerPerSecondSquared, q => q.ToUnit(AccelerationUnit.NanometerPerSecondSquared)); + unitConverter.SetConversionFunction(AccelerationUnit.NanometerPerSecondSquared, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Acceleration.ConversionBaseUnit, AccelerationUnit.StandardGravity, q => q.ToUnit(AccelerationUnit.StandardGravity)); + unitConverter.SetConversionFunction(AccelerationUnit.StandardGravity, Acceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Centimole, q => q.ToUnit(AmountOfSubstanceUnit.Centimole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Centimole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.CentipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.CentipoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.CentipoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Decimole, q => q.ToUnit(AmountOfSubstanceUnit.Decimole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Decimole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.DecipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.DecipoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.DecipoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Kilomole, q => q.ToUnit(AmountOfSubstanceUnit.Kilomole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Kilomole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.KilopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.KilopoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.KilopoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Megamole, q => q.ToUnit(AmountOfSubstanceUnit.Megamole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Megamole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Micromole, q => q.ToUnit(AmountOfSubstanceUnit.Micromole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Micromole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.MicropoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MicropoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.MicropoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Millimole, q => q.ToUnit(AmountOfSubstanceUnit.Millimole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Millimole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.MillipoundMole, q => q.ToUnit(AmountOfSubstanceUnit.MillipoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.MillipoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.Nanomole, q => q.ToUnit(AmountOfSubstanceUnit.Nanomole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Nanomole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.NanopoundMole, q => q.ToUnit(AmountOfSubstanceUnit.NanopoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.NanopoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmountOfSubstance.ConversionBaseUnit, AmountOfSubstanceUnit.PoundMole, q => q.ToUnit(AmountOfSubstanceUnit.PoundMole)); + unitConverter.SetConversionFunction(AmountOfSubstanceUnit.PoundMole, AmountOfSubstance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmplitudeRatio.ConversionBaseUnit, AmplitudeRatioUnit.DecibelMicrovolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMicrovolt)); + unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelMicrovolt, AmplitudeRatio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmplitudeRatio.ConversionBaseUnit, AmplitudeRatioUnit.DecibelMillivolt, q => q.ToUnit(AmplitudeRatioUnit.DecibelMillivolt)); + unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelMillivolt, AmplitudeRatio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmplitudeRatio.ConversionBaseUnit, AmplitudeRatioUnit.DecibelUnloaded, q => q.ToUnit(AmplitudeRatioUnit.DecibelUnloaded)); + unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelUnloaded, AmplitudeRatio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AmplitudeRatio.ConversionBaseUnit, AmplitudeRatio.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Arcminute, q => q.ToUnit(AngleUnit.Arcminute)); + unitConverter.SetConversionFunction(AngleUnit.Arcminute, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Arcsecond, q => q.ToUnit(AngleUnit.Arcsecond)); + unitConverter.SetConversionFunction(AngleUnit.Arcsecond, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Centiradian, q => q.ToUnit(AngleUnit.Centiradian)); + unitConverter.SetConversionFunction(AngleUnit.Centiradian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Deciradian, q => q.ToUnit(AngleUnit.Deciradian)); + unitConverter.SetConversionFunction(AngleUnit.Deciradian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, Angle.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Gradian, q => q.ToUnit(AngleUnit.Gradian)); + unitConverter.SetConversionFunction(AngleUnit.Gradian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Microdegree, q => q.ToUnit(AngleUnit.Microdegree)); + unitConverter.SetConversionFunction(AngleUnit.Microdegree, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Microradian, q => q.ToUnit(AngleUnit.Microradian)); + unitConverter.SetConversionFunction(AngleUnit.Microradian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Millidegree, q => q.ToUnit(AngleUnit.Millidegree)); + unitConverter.SetConversionFunction(AngleUnit.Millidegree, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Milliradian, q => q.ToUnit(AngleUnit.Milliradian)); + unitConverter.SetConversionFunction(AngleUnit.Milliradian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Nanodegree, q => q.ToUnit(AngleUnit.Nanodegree)); + unitConverter.SetConversionFunction(AngleUnit.Nanodegree, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Nanoradian, q => q.ToUnit(AngleUnit.Nanoradian)); + unitConverter.SetConversionFunction(AngleUnit.Nanoradian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.NatoMil, q => q.ToUnit(AngleUnit.NatoMil)); + unitConverter.SetConversionFunction(AngleUnit.NatoMil, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Radian, q => q.ToUnit(AngleUnit.Radian)); + unitConverter.SetConversionFunction(AngleUnit.Radian, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Revolution, q => q.ToUnit(AngleUnit.Revolution)); + unitConverter.SetConversionFunction(AngleUnit.Revolution, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Angle.ConversionBaseUnit, AngleUnit.Tilt, q => q.ToUnit(AngleUnit.Tilt)); + unitConverter.SetConversionFunction(AngleUnit.Tilt, Angle.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ApparentEnergy.ConversionBaseUnit, ApparentEnergyUnit.KilovoltampereHour, q => q.ToUnit(ApparentEnergyUnit.KilovoltampereHour)); + unitConverter.SetConversionFunction(ApparentEnergyUnit.KilovoltampereHour, ApparentEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ApparentEnergy.ConversionBaseUnit, ApparentEnergyUnit.MegavoltampereHour, q => q.ToUnit(ApparentEnergyUnit.MegavoltampereHour)); + unitConverter.SetConversionFunction(ApparentEnergyUnit.MegavoltampereHour, ApparentEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ApparentEnergy.ConversionBaseUnit, ApparentEnergy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ApparentPower.ConversionBaseUnit, ApparentPowerUnit.Gigavoltampere, q => q.ToUnit(ApparentPowerUnit.Gigavoltampere)); + unitConverter.SetConversionFunction(ApparentPowerUnit.Gigavoltampere, ApparentPower.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ApparentPower.ConversionBaseUnit, ApparentPowerUnit.Kilovoltampere, q => q.ToUnit(ApparentPowerUnit.Kilovoltampere)); + unitConverter.SetConversionFunction(ApparentPowerUnit.Kilovoltampere, ApparentPower.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ApparentPower.ConversionBaseUnit, ApparentPowerUnit.Megavoltampere, q => q.ToUnit(ApparentPowerUnit.Megavoltampere)); + unitConverter.SetConversionFunction(ApparentPowerUnit.Megavoltampere, ApparentPower.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ApparentPower.ConversionBaseUnit, ApparentPower.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.Acre, q => q.ToUnit(AreaUnit.Acre)); + unitConverter.SetConversionFunction(AreaUnit.Acre, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.Hectare, q => q.ToUnit(AreaUnit.Hectare)); + unitConverter.SetConversionFunction(AreaUnit.Hectare, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareCentimeter, q => q.ToUnit(AreaUnit.SquareCentimeter)); + unitConverter.SetConversionFunction(AreaUnit.SquareCentimeter, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareDecimeter, q => q.ToUnit(AreaUnit.SquareDecimeter)); + unitConverter.SetConversionFunction(AreaUnit.SquareDecimeter, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareFoot, q => q.ToUnit(AreaUnit.SquareFoot)); + unitConverter.SetConversionFunction(AreaUnit.SquareFoot, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareInch, q => q.ToUnit(AreaUnit.SquareInch)); + unitConverter.SetConversionFunction(AreaUnit.SquareInch, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareKilometer, q => q.ToUnit(AreaUnit.SquareKilometer)); + unitConverter.SetConversionFunction(AreaUnit.SquareKilometer, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, Area.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareMicrometer, q => q.ToUnit(AreaUnit.SquareMicrometer)); + unitConverter.SetConversionFunction(AreaUnit.SquareMicrometer, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareMile, q => q.ToUnit(AreaUnit.SquareMile)); + unitConverter.SetConversionFunction(AreaUnit.SquareMile, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareMillimeter, q => q.ToUnit(AreaUnit.SquareMillimeter)); + unitConverter.SetConversionFunction(AreaUnit.SquareMillimeter, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareNauticalMile, q => q.ToUnit(AreaUnit.SquareNauticalMile)); + unitConverter.SetConversionFunction(AreaUnit.SquareNauticalMile, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.SquareYard, q => q.ToUnit(AreaUnit.SquareYard)); + unitConverter.SetConversionFunction(AreaUnit.SquareYard, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Area.ConversionBaseUnit, AreaUnit.UsSurveySquareFoot, q => q.ToUnit(AreaUnit.UsSurveySquareFoot)); + unitConverter.SetConversionFunction(AreaUnit.UsSurveySquareFoot, Area.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AreaDensity.ConversionBaseUnit, AreaDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(AreaMomentOfInertia.ConversionBaseUnit, AreaMomentOfInertiaUnit.CentimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.CentimeterToTheFourth)); + unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.CentimeterToTheFourth, AreaMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AreaMomentOfInertia.ConversionBaseUnit, AreaMomentOfInertiaUnit.DecimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.DecimeterToTheFourth)); + unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.DecimeterToTheFourth, AreaMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AreaMomentOfInertia.ConversionBaseUnit, AreaMomentOfInertiaUnit.FootToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.FootToTheFourth)); + unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.FootToTheFourth, AreaMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AreaMomentOfInertia.ConversionBaseUnit, AreaMomentOfInertiaUnit.InchToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.InchToTheFourth)); + unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.InchToTheFourth, AreaMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(AreaMomentOfInertia.ConversionBaseUnit, AreaMomentOfInertia.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(AreaMomentOfInertia.ConversionBaseUnit, AreaMomentOfInertiaUnit.MillimeterToTheFourth, q => q.ToUnit(AreaMomentOfInertiaUnit.MillimeterToTheFourth)); + unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MillimeterToTheFourth, AreaMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.BytePerSecond, q => q.ToUnit(BitRateUnit.BytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.BytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.ExabitPerSecond, q => q.ToUnit(BitRateUnit.ExabitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.ExabitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.ExabytePerSecond, q => q.ToUnit(BitRateUnit.ExabytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.ExabytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.ExbibitPerSecond, q => q.ToUnit(BitRateUnit.ExbibitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.ExbibitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.ExbibytePerSecond, q => q.ToUnit(BitRateUnit.ExbibytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.ExbibytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.GibibitPerSecond, q => q.ToUnit(BitRateUnit.GibibitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.GibibitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.GibibytePerSecond, q => q.ToUnit(BitRateUnit.GibibytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.GibibytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.GigabitPerSecond, q => q.ToUnit(BitRateUnit.GigabitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.GigabitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.GigabytePerSecond, q => q.ToUnit(BitRateUnit.GigabytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.GigabytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.KibibitPerSecond, q => q.ToUnit(BitRateUnit.KibibitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.KibibitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.KibibytePerSecond, q => q.ToUnit(BitRateUnit.KibibytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.KibibytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.KilobitPerSecond, q => q.ToUnit(BitRateUnit.KilobitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.KilobitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.KilobytePerSecond, q => q.ToUnit(BitRateUnit.KilobytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.KilobytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.MebibitPerSecond, q => q.ToUnit(BitRateUnit.MebibitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.MebibitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.MebibytePerSecond, q => q.ToUnit(BitRateUnit.MebibytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.MebibytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.MegabitPerSecond, q => q.ToUnit(BitRateUnit.MegabitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.MegabitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.MegabytePerSecond, q => q.ToUnit(BitRateUnit.MegabytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.MegabytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.PebibitPerSecond, q => q.ToUnit(BitRateUnit.PebibitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.PebibitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.PebibytePerSecond, q => q.ToUnit(BitRateUnit.PebibytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.PebibytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.PetabitPerSecond, q => q.ToUnit(BitRateUnit.PetabitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.PetabitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.PetabytePerSecond, q => q.ToUnit(BitRateUnit.PetabytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.PetabytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.TebibitPerSecond, q => q.ToUnit(BitRateUnit.TebibitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.TebibitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.TebibytePerSecond, q => q.ToUnit(BitRateUnit.TebibytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.TebibytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.TerabitPerSecond, q => q.ToUnit(BitRateUnit.TerabitPerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.TerabitPerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BitRate.ConversionBaseUnit, BitRateUnit.TerabytePerSecond, q => q.ToUnit(BitRateUnit.TerabytePerSecond)); + unitConverter.SetConversionFunction(BitRateUnit.TerabytePerSecond, BitRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.ConversionBaseUnit, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour)); + unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, BrakeSpecificFuelConsumption.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.ConversionBaseUnit, BrakeSpecificFuelConsumption.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(BrakeSpecificFuelConsumption.ConversionBaseUnit, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, q => q.ToUnit(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); + unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, BrakeSpecificFuelConsumption.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, Capacitance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, CapacitanceUnit.Kilofarad, q => q.ToUnit(CapacitanceUnit.Kilofarad)); + unitConverter.SetConversionFunction(CapacitanceUnit.Kilofarad, Capacitance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, CapacitanceUnit.Megafarad, q => q.ToUnit(CapacitanceUnit.Megafarad)); + unitConverter.SetConversionFunction(CapacitanceUnit.Megafarad, Capacitance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, CapacitanceUnit.Microfarad, q => q.ToUnit(CapacitanceUnit.Microfarad)); + unitConverter.SetConversionFunction(CapacitanceUnit.Microfarad, Capacitance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, CapacitanceUnit.Millifarad, q => q.ToUnit(CapacitanceUnit.Millifarad)); + unitConverter.SetConversionFunction(CapacitanceUnit.Millifarad, Capacitance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, CapacitanceUnit.Nanofarad, q => q.ToUnit(CapacitanceUnit.Nanofarad)); + unitConverter.SetConversionFunction(CapacitanceUnit.Nanofarad, Capacitance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Capacitance.ConversionBaseUnit, CapacitanceUnit.Picofarad, q => q.ToUnit(CapacitanceUnit.Picofarad)); + unitConverter.SetConversionFunction(CapacitanceUnit.Picofarad, Capacitance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.ConversionBaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius)); + unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, CoefficientOfThermalExpansion.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.ConversionBaseUnit, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, q => q.ToUnit(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit)); + unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, CoefficientOfThermalExpansion.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(CoefficientOfThermalExpansion.ConversionBaseUnit, CoefficientOfThermalExpansion.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.CentigramPerDeciliter, q => q.ToUnit(DensityUnit.CentigramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.CentigramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.CentigramPerLiter, q => q.ToUnit(DensityUnit.CentigramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.CentigramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.CentigramPerMilliliter, q => q.ToUnit(DensityUnit.CentigramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.CentigramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.DecigramPerDeciliter, q => q.ToUnit(DensityUnit.DecigramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.DecigramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.DecigramPerLiter, q => q.ToUnit(DensityUnit.DecigramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.DecigramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.DecigramPerMilliliter, q => q.ToUnit(DensityUnit.DecigramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.DecigramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.GramPerCubicCentimeter, q => q.ToUnit(DensityUnit.GramPerCubicCentimeter)); + unitConverter.SetConversionFunction(DensityUnit.GramPerCubicCentimeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.GramPerCubicMeter, q => q.ToUnit(DensityUnit.GramPerCubicMeter)); + unitConverter.SetConversionFunction(DensityUnit.GramPerCubicMeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.GramPerCubicMillimeter, q => q.ToUnit(DensityUnit.GramPerCubicMillimeter)); + unitConverter.SetConversionFunction(DensityUnit.GramPerCubicMillimeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.GramPerDeciliter, q => q.ToUnit(DensityUnit.GramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.GramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.GramPerLiter, q => q.ToUnit(DensityUnit.GramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.GramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.GramPerMilliliter, q => q.ToUnit(DensityUnit.GramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.GramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.KilogramPerCubicCentimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicCentimeter)); + unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicCentimeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, Density.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.KilogramPerCubicMillimeter, q => q.ToUnit(DensityUnit.KilogramPerCubicMillimeter)); + unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMillimeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.KilogramPerLiter, q => q.ToUnit(DensityUnit.KilogramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.KilogramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.KilopoundPerCubicFoot, q => q.ToUnit(DensityUnit.KilopoundPerCubicFoot)); + unitConverter.SetConversionFunction(DensityUnit.KilopoundPerCubicFoot, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.KilopoundPerCubicInch, q => q.ToUnit(DensityUnit.KilopoundPerCubicInch)); + unitConverter.SetConversionFunction(DensityUnit.KilopoundPerCubicInch, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MicrogramPerCubicMeter, q => q.ToUnit(DensityUnit.MicrogramPerCubicMeter)); + unitConverter.SetConversionFunction(DensityUnit.MicrogramPerCubicMeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MicrogramPerDeciliter, q => q.ToUnit(DensityUnit.MicrogramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.MicrogramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MicrogramPerLiter, q => q.ToUnit(DensityUnit.MicrogramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.MicrogramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MicrogramPerMilliliter, q => q.ToUnit(DensityUnit.MicrogramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.MicrogramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MilligramPerCubicMeter, q => q.ToUnit(DensityUnit.MilligramPerCubicMeter)); + unitConverter.SetConversionFunction(DensityUnit.MilligramPerCubicMeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MilligramPerDeciliter, q => q.ToUnit(DensityUnit.MilligramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.MilligramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MilligramPerLiter, q => q.ToUnit(DensityUnit.MilligramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.MilligramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.MilligramPerMilliliter, q => q.ToUnit(DensityUnit.MilligramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.MilligramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.NanogramPerDeciliter, q => q.ToUnit(DensityUnit.NanogramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.NanogramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.NanogramPerLiter, q => q.ToUnit(DensityUnit.NanogramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.NanogramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.NanogramPerMilliliter, q => q.ToUnit(DensityUnit.NanogramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.NanogramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PicogramPerDeciliter, q => q.ToUnit(DensityUnit.PicogramPerDeciliter)); + unitConverter.SetConversionFunction(DensityUnit.PicogramPerDeciliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PicogramPerLiter, q => q.ToUnit(DensityUnit.PicogramPerLiter)); + unitConverter.SetConversionFunction(DensityUnit.PicogramPerLiter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PicogramPerMilliliter, q => q.ToUnit(DensityUnit.PicogramPerMilliliter)); + unitConverter.SetConversionFunction(DensityUnit.PicogramPerMilliliter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PoundPerCubicFoot, q => q.ToUnit(DensityUnit.PoundPerCubicFoot)); + unitConverter.SetConversionFunction(DensityUnit.PoundPerCubicFoot, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PoundPerCubicInch, q => q.ToUnit(DensityUnit.PoundPerCubicInch)); + unitConverter.SetConversionFunction(DensityUnit.PoundPerCubicInch, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PoundPerImperialGallon, q => q.ToUnit(DensityUnit.PoundPerImperialGallon)); + unitConverter.SetConversionFunction(DensityUnit.PoundPerImperialGallon, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.PoundPerUSGallon, q => q.ToUnit(DensityUnit.PoundPerUSGallon)); + unitConverter.SetConversionFunction(DensityUnit.PoundPerUSGallon, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.SlugPerCubicFoot, q => q.ToUnit(DensityUnit.SlugPerCubicFoot)); + unitConverter.SetConversionFunction(DensityUnit.SlugPerCubicFoot, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.TonnePerCubicCentimeter, q => q.ToUnit(DensityUnit.TonnePerCubicCentimeter)); + unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicCentimeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.TonnePerCubicMeter, q => q.ToUnit(DensityUnit.TonnePerCubicMeter)); + unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicMeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Density.ConversionBaseUnit, DensityUnit.TonnePerCubicMillimeter, q => q.ToUnit(DensityUnit.TonnePerCubicMillimeter)); + unitConverter.SetConversionFunction(DensityUnit.TonnePerCubicMillimeter, Density.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Day, q => q.ToUnit(DurationUnit.Day)); + unitConverter.SetConversionFunction(DurationUnit.Day, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Hour, q => q.ToUnit(DurationUnit.Hour)); + unitConverter.SetConversionFunction(DurationUnit.Hour, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Microsecond, q => q.ToUnit(DurationUnit.Microsecond)); + unitConverter.SetConversionFunction(DurationUnit.Microsecond, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Millisecond, q => q.ToUnit(DurationUnit.Millisecond)); + unitConverter.SetConversionFunction(DurationUnit.Millisecond, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Minute, q => q.ToUnit(DurationUnit.Minute)); + unitConverter.SetConversionFunction(DurationUnit.Minute, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Month30, q => q.ToUnit(DurationUnit.Month30)); + unitConverter.SetConversionFunction(DurationUnit.Month30, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Nanosecond, q => q.ToUnit(DurationUnit.Nanosecond)); + unitConverter.SetConversionFunction(DurationUnit.Nanosecond, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, Duration.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Week, q => q.ToUnit(DurationUnit.Week)); + unitConverter.SetConversionFunction(DurationUnit.Week, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Duration.ConversionBaseUnit, DurationUnit.Year365, q => q.ToUnit(DurationUnit.Year365)); + unitConverter.SetConversionFunction(DurationUnit.Year365, Duration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.Centipoise, q => q.ToUnit(DynamicViscosityUnit.Centipoise)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.Centipoise, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.MicropascalSecond, q => q.ToUnit(DynamicViscosityUnit.MicropascalSecond)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.MicropascalSecond, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.MillipascalSecond, q => q.ToUnit(DynamicViscosityUnit.MillipascalSecond)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.MillipascalSecond, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.PascalSecond, q => q.ToUnit(DynamicViscosityUnit.PascalSecond)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.PascalSecond, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.Poise, q => q.ToUnit(DynamicViscosityUnit.Poise)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.Poise, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareFoot, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareFoot)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundForceSecondPerSquareFoot, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.PoundForceSecondPerSquareInch, q => q.ToUnit(DynamicViscosityUnit.PoundForceSecondPerSquareInch)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundForceSecondPerSquareInch, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.PoundPerFootSecond, q => q.ToUnit(DynamicViscosityUnit.PoundPerFootSecond)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.PoundPerFootSecond, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(DynamicViscosity.ConversionBaseUnit, DynamicViscosityUnit.Reyn, q => q.ToUnit(DynamicViscosityUnit.Reyn)); + unitConverter.SetConversionFunction(DynamicViscosityUnit.Reyn, DynamicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricAdmittance.ConversionBaseUnit, ElectricAdmittanceUnit.Microsiemens, q => q.ToUnit(ElectricAdmittanceUnit.Microsiemens)); + unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Microsiemens, ElectricAdmittance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricAdmittance.ConversionBaseUnit, ElectricAdmittanceUnit.Millisiemens, q => q.ToUnit(ElectricAdmittanceUnit.Millisiemens)); + unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Millisiemens, ElectricAdmittance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricAdmittance.ConversionBaseUnit, ElectricAdmittanceUnit.Nanosiemens, q => q.ToUnit(ElectricAdmittanceUnit.Nanosiemens)); + unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Nanosiemens, ElectricAdmittance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricAdmittance.ConversionBaseUnit, ElectricAdmittance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricCharge.ConversionBaseUnit, ElectricChargeUnit.AmpereHour, q => q.ToUnit(ElectricChargeUnit.AmpereHour)); + unitConverter.SetConversionFunction(ElectricChargeUnit.AmpereHour, ElectricCharge.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCharge.ConversionBaseUnit, ElectricCharge.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricCharge.ConversionBaseUnit, ElectricChargeUnit.KiloampereHour, q => q.ToUnit(ElectricChargeUnit.KiloampereHour)); + unitConverter.SetConversionFunction(ElectricChargeUnit.KiloampereHour, ElectricCharge.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCharge.ConversionBaseUnit, ElectricChargeUnit.MegaampereHour, q => q.ToUnit(ElectricChargeUnit.MegaampereHour)); + unitConverter.SetConversionFunction(ElectricChargeUnit.MegaampereHour, ElectricCharge.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCharge.ConversionBaseUnit, ElectricChargeUnit.MilliampereHour, q => q.ToUnit(ElectricChargeUnit.MilliampereHour)); + unitConverter.SetConversionFunction(ElectricChargeUnit.MilliampereHour, ElectricCharge.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricChargeDensity.ConversionBaseUnit, ElectricChargeDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricConductance.ConversionBaseUnit, ElectricConductanceUnit.Microsiemens, q => q.ToUnit(ElectricConductanceUnit.Microsiemens)); + unitConverter.SetConversionFunction(ElectricConductanceUnit.Microsiemens, ElectricConductance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricConductance.ConversionBaseUnit, ElectricConductanceUnit.Millisiemens, q => q.ToUnit(ElectricConductanceUnit.Millisiemens)); + unitConverter.SetConversionFunction(ElectricConductanceUnit.Millisiemens, ElectricConductance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricConductance.ConversionBaseUnit, ElectricConductance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricConductivity.ConversionBaseUnit, ElectricConductivityUnit.SiemensPerFoot, q => q.ToUnit(ElectricConductivityUnit.SiemensPerFoot)); + unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerFoot, ElectricConductivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricConductivity.ConversionBaseUnit, ElectricConductivityUnit.SiemensPerInch, q => q.ToUnit(ElectricConductivityUnit.SiemensPerInch)); + unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerInch, ElectricConductivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricConductivity.ConversionBaseUnit, ElectricConductivity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrent.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Centiampere, q => q.ToUnit(ElectricCurrentUnit.Centiampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Centiampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Kiloampere, q => q.ToUnit(ElectricCurrentUnit.Kiloampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Kiloampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Megaampere, q => q.ToUnit(ElectricCurrentUnit.Megaampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Megaampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Microampere, q => q.ToUnit(ElectricCurrentUnit.Microampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Microampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Milliampere, q => q.ToUnit(ElectricCurrentUnit.Milliampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Milliampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Nanoampere, q => q.ToUnit(ElectricCurrentUnit.Nanoampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Nanoampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrent.ConversionBaseUnit, ElectricCurrentUnit.Picoampere, q => q.ToUnit(ElectricCurrentUnit.Picoampere)); + unitConverter.SetConversionFunction(ElectricCurrentUnit.Picoampere, ElectricCurrent.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrentDensity.ConversionBaseUnit, ElectricCurrentDensityUnit.AmperePerSquareFoot, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareFoot)); + unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareFoot, ElectricCurrentDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrentDensity.ConversionBaseUnit, ElectricCurrentDensityUnit.AmperePerSquareInch, q => q.ToUnit(ElectricCurrentDensityUnit.AmperePerSquareInch)); + unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareInch, ElectricCurrentDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrentDensity.ConversionBaseUnit, ElectricCurrentDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricCurrentGradient.ConversionBaseUnit, ElectricCurrentGradientUnit.AmperePerMicrosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMicrosecond)); + unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerMicrosecond, ElectricCurrentGradient.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrentGradient.ConversionBaseUnit, ElectricCurrentGradientUnit.AmperePerMillisecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerMillisecond)); + unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerMillisecond, ElectricCurrentGradient.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrentGradient.ConversionBaseUnit, ElectricCurrentGradientUnit.AmperePerNanosecond, q => q.ToUnit(ElectricCurrentGradientUnit.AmperePerNanosecond)); + unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerNanosecond, ElectricCurrentGradient.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricCurrentGradient.ConversionBaseUnit, ElectricCurrentGradient.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricField.ConversionBaseUnit, ElectricField.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricInductance.ConversionBaseUnit, ElectricInductance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricInductance.ConversionBaseUnit, ElectricInductanceUnit.Microhenry, q => q.ToUnit(ElectricInductanceUnit.Microhenry)); + unitConverter.SetConversionFunction(ElectricInductanceUnit.Microhenry, ElectricInductance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricInductance.ConversionBaseUnit, ElectricInductanceUnit.Millihenry, q => q.ToUnit(ElectricInductanceUnit.Millihenry)); + unitConverter.SetConversionFunction(ElectricInductanceUnit.Millihenry, ElectricInductance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricInductance.ConversionBaseUnit, ElectricInductanceUnit.Nanohenry, q => q.ToUnit(ElectricInductanceUnit.Nanohenry)); + unitConverter.SetConversionFunction(ElectricInductanceUnit.Nanohenry, ElectricInductance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotential.ConversionBaseUnit, ElectricPotentialUnit.Kilovolt, q => q.ToUnit(ElectricPotentialUnit.Kilovolt)); + unitConverter.SetConversionFunction(ElectricPotentialUnit.Kilovolt, ElectricPotential.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotential.ConversionBaseUnit, ElectricPotentialUnit.Megavolt, q => q.ToUnit(ElectricPotentialUnit.Megavolt)); + unitConverter.SetConversionFunction(ElectricPotentialUnit.Megavolt, ElectricPotential.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotential.ConversionBaseUnit, ElectricPotentialUnit.Microvolt, q => q.ToUnit(ElectricPotentialUnit.Microvolt)); + unitConverter.SetConversionFunction(ElectricPotentialUnit.Microvolt, ElectricPotential.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotential.ConversionBaseUnit, ElectricPotentialUnit.Millivolt, q => q.ToUnit(ElectricPotentialUnit.Millivolt)); + unitConverter.SetConversionFunction(ElectricPotentialUnit.Millivolt, ElectricPotential.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotential.ConversionBaseUnit, ElectricPotential.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricPotentialAc.ConversionBaseUnit, ElectricPotentialAcUnit.KilovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.KilovoltAc)); + unitConverter.SetConversionFunction(ElectricPotentialAcUnit.KilovoltAc, ElectricPotentialAc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialAc.ConversionBaseUnit, ElectricPotentialAcUnit.MegavoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MegavoltAc)); + unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MegavoltAc, ElectricPotentialAc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialAc.ConversionBaseUnit, ElectricPotentialAcUnit.MicrovoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MicrovoltAc)); + unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MicrovoltAc, ElectricPotentialAc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialAc.ConversionBaseUnit, ElectricPotentialAcUnit.MillivoltAc, q => q.ToUnit(ElectricPotentialAcUnit.MillivoltAc)); + unitConverter.SetConversionFunction(ElectricPotentialAcUnit.MillivoltAc, ElectricPotentialAc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialAc.ConversionBaseUnit, ElectricPotentialAc.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerHour)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerHour, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerMinute)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerMinute, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.KilovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.KilovoltPerSecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.KilovoltPerSecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerHour)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerHour, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerMinute)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerMinute, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MegavoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MegavoltPerSecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MegavoltPerSecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerHour)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerHour, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerMinute)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerMinute, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MicrovoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MicrovoltPerSecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MicrovoltPerSecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerHour)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerHour, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerMinute)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerMinute, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.MillivoltPerSecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.MillivoltPerSecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.MillivoltPerSecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.VoltPerHour, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerHour)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerHour, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.VoltPerMicrosecond, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMicrosecond)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerMicrosecond, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRateUnit.VoltPerMinute, q => q.ToUnit(ElectricPotentialChangeRateUnit.VoltPerMinute)); + unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerMinute, ElectricPotentialChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialChangeRate.ConversionBaseUnit, ElectricPotentialChangeRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricPotentialDc.ConversionBaseUnit, ElectricPotentialDcUnit.KilovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.KilovoltDc)); + unitConverter.SetConversionFunction(ElectricPotentialDcUnit.KilovoltDc, ElectricPotentialDc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialDc.ConversionBaseUnit, ElectricPotentialDcUnit.MegavoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MegavoltDc)); + unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MegavoltDc, ElectricPotentialDc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialDc.ConversionBaseUnit, ElectricPotentialDcUnit.MicrovoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MicrovoltDc)); + unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MicrovoltDc, ElectricPotentialDc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialDc.ConversionBaseUnit, ElectricPotentialDcUnit.MillivoltDc, q => q.ToUnit(ElectricPotentialDcUnit.MillivoltDc)); + unitConverter.SetConversionFunction(ElectricPotentialDcUnit.MillivoltDc, ElectricPotentialDc.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricPotentialDc.ConversionBaseUnit, ElectricPotentialDc.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricResistance.ConversionBaseUnit, ElectricResistanceUnit.Gigaohm, q => q.ToUnit(ElectricResistanceUnit.Gigaohm)); + unitConverter.SetConversionFunction(ElectricResistanceUnit.Gigaohm, ElectricResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistance.ConversionBaseUnit, ElectricResistanceUnit.Kiloohm, q => q.ToUnit(ElectricResistanceUnit.Kiloohm)); + unitConverter.SetConversionFunction(ElectricResistanceUnit.Kiloohm, ElectricResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistance.ConversionBaseUnit, ElectricResistanceUnit.Megaohm, q => q.ToUnit(ElectricResistanceUnit.Megaohm)); + unitConverter.SetConversionFunction(ElectricResistanceUnit.Megaohm, ElectricResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistance.ConversionBaseUnit, ElectricResistanceUnit.Microohm, q => q.ToUnit(ElectricResistanceUnit.Microohm)); + unitConverter.SetConversionFunction(ElectricResistanceUnit.Microohm, ElectricResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistance.ConversionBaseUnit, ElectricResistanceUnit.Milliohm, q => q.ToUnit(ElectricResistanceUnit.Milliohm)); + unitConverter.SetConversionFunction(ElectricResistanceUnit.Milliohm, ElectricResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistance.ConversionBaseUnit, ElectricResistance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.KiloohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.KiloohmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.KiloohmMeter, q => q.ToUnit(ElectricResistivityUnit.KiloohmMeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.KiloohmMeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.MegaohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.MegaohmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.MegaohmMeter, q => q.ToUnit(ElectricResistivityUnit.MegaohmMeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.MegaohmMeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.MicroohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.MicroohmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.MicroohmMeter, q => q.ToUnit(ElectricResistivityUnit.MicroohmMeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.MicroohmMeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.MilliohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.MilliohmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.MilliohmMeter, q => q.ToUnit(ElectricResistivityUnit.MilliohmMeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.MilliohmMeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.NanoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.NanoohmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.NanoohmMeter, q => q.ToUnit(ElectricResistivityUnit.NanoohmMeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.NanoohmMeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.OhmCentimeter, q => q.ToUnit(ElectricResistivityUnit.OhmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.PicoohmCentimeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmCentimeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.PicoohmCentimeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricResistivity.ConversionBaseUnit, ElectricResistivityUnit.PicoohmMeter, q => q.ToUnit(ElectricResistivityUnit.PicoohmMeter)); + unitConverter.SetConversionFunction(ElectricResistivityUnit.PicoohmMeter, ElectricResistivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.ConversionBaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter)); + unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, ElectricSurfaceChargeDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.ConversionBaseUnit, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, q => q.ToUnit(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch)); + unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, ElectricSurfaceChargeDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ElectricSurfaceChargeDensity.ConversionBaseUnit, ElectricSurfaceChargeDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.BritishThermalUnit, q => q.ToUnit(EnergyUnit.BritishThermalUnit)); + unitConverter.SetConversionFunction(EnergyUnit.BritishThermalUnit, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Calorie, q => q.ToUnit(EnergyUnit.Calorie)); + unitConverter.SetConversionFunction(EnergyUnit.Calorie, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.DecathermEc, q => q.ToUnit(EnergyUnit.DecathermEc)); + unitConverter.SetConversionFunction(EnergyUnit.DecathermEc, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.DecathermImperial, q => q.ToUnit(EnergyUnit.DecathermImperial)); + unitConverter.SetConversionFunction(EnergyUnit.DecathermImperial, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.DecathermUs, q => q.ToUnit(EnergyUnit.DecathermUs)); + unitConverter.SetConversionFunction(EnergyUnit.DecathermUs, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.ElectronVolt, q => q.ToUnit(EnergyUnit.ElectronVolt)); + unitConverter.SetConversionFunction(EnergyUnit.ElectronVolt, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Erg, q => q.ToUnit(EnergyUnit.Erg)); + unitConverter.SetConversionFunction(EnergyUnit.Erg, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.FootPound, q => q.ToUnit(EnergyUnit.FootPound)); + unitConverter.SetConversionFunction(EnergyUnit.FootPound, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.GigabritishThermalUnit, q => q.ToUnit(EnergyUnit.GigabritishThermalUnit)); + unitConverter.SetConversionFunction(EnergyUnit.GigabritishThermalUnit, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.GigaelectronVolt, q => q.ToUnit(EnergyUnit.GigaelectronVolt)); + unitConverter.SetConversionFunction(EnergyUnit.GigaelectronVolt, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Gigajoule, q => q.ToUnit(EnergyUnit.Gigajoule)); + unitConverter.SetConversionFunction(EnergyUnit.Gigajoule, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.GigawattDay, q => q.ToUnit(EnergyUnit.GigawattDay)); + unitConverter.SetConversionFunction(EnergyUnit.GigawattDay, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.GigawattHour, q => q.ToUnit(EnergyUnit.GigawattHour)); + unitConverter.SetConversionFunction(EnergyUnit.GigawattHour, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.HorsepowerHour, q => q.ToUnit(EnergyUnit.HorsepowerHour)); + unitConverter.SetConversionFunction(EnergyUnit.HorsepowerHour, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, Energy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.KilobritishThermalUnit, q => q.ToUnit(EnergyUnit.KilobritishThermalUnit)); + unitConverter.SetConversionFunction(EnergyUnit.KilobritishThermalUnit, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Kilocalorie, q => q.ToUnit(EnergyUnit.Kilocalorie)); + unitConverter.SetConversionFunction(EnergyUnit.Kilocalorie, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.KiloelectronVolt, q => q.ToUnit(EnergyUnit.KiloelectronVolt)); + unitConverter.SetConversionFunction(EnergyUnit.KiloelectronVolt, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Kilojoule, q => q.ToUnit(EnergyUnit.Kilojoule)); + unitConverter.SetConversionFunction(EnergyUnit.Kilojoule, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.KilowattDay, q => q.ToUnit(EnergyUnit.KilowattDay)); + unitConverter.SetConversionFunction(EnergyUnit.KilowattDay, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.KilowattHour, q => q.ToUnit(EnergyUnit.KilowattHour)); + unitConverter.SetConversionFunction(EnergyUnit.KilowattHour, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.MegabritishThermalUnit, q => q.ToUnit(EnergyUnit.MegabritishThermalUnit)); + unitConverter.SetConversionFunction(EnergyUnit.MegabritishThermalUnit, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Megacalorie, q => q.ToUnit(EnergyUnit.Megacalorie)); + unitConverter.SetConversionFunction(EnergyUnit.Megacalorie, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.MegaelectronVolt, q => q.ToUnit(EnergyUnit.MegaelectronVolt)); + unitConverter.SetConversionFunction(EnergyUnit.MegaelectronVolt, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Megajoule, q => q.ToUnit(EnergyUnit.Megajoule)); + unitConverter.SetConversionFunction(EnergyUnit.Megajoule, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.MegawattDay, q => q.ToUnit(EnergyUnit.MegawattDay)); + unitConverter.SetConversionFunction(EnergyUnit.MegawattDay, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.MegawattHour, q => q.ToUnit(EnergyUnit.MegawattHour)); + unitConverter.SetConversionFunction(EnergyUnit.MegawattHour, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.Millijoule, q => q.ToUnit(EnergyUnit.Millijoule)); + unitConverter.SetConversionFunction(EnergyUnit.Millijoule, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.TeraelectronVolt, q => q.ToUnit(EnergyUnit.TeraelectronVolt)); + unitConverter.SetConversionFunction(EnergyUnit.TeraelectronVolt, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.TerawattDay, q => q.ToUnit(EnergyUnit.TerawattDay)); + unitConverter.SetConversionFunction(EnergyUnit.TerawattDay, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.TerawattHour, q => q.ToUnit(EnergyUnit.TerawattHour)); + unitConverter.SetConversionFunction(EnergyUnit.TerawattHour, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.ThermEc, q => q.ToUnit(EnergyUnit.ThermEc)); + unitConverter.SetConversionFunction(EnergyUnit.ThermEc, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.ThermImperial, q => q.ToUnit(EnergyUnit.ThermImperial)); + unitConverter.SetConversionFunction(EnergyUnit.ThermImperial, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.ThermUs, q => q.ToUnit(EnergyUnit.ThermUs)); + unitConverter.SetConversionFunction(EnergyUnit.ThermUs, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.WattDay, q => q.ToUnit(EnergyUnit.WattDay)); + unitConverter.SetConversionFunction(EnergyUnit.WattDay, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Energy.ConversionBaseUnit, EnergyUnit.WattHour, q => q.ToUnit(EnergyUnit.WattHour)); + unitConverter.SetConversionFunction(EnergyUnit.WattHour, Energy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, EntropyUnit.CaloriePerKelvin, q => q.ToUnit(EntropyUnit.CaloriePerKelvin)); + unitConverter.SetConversionFunction(EntropyUnit.CaloriePerKelvin, Entropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, EntropyUnit.JoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.JoulePerDegreeCelsius)); + unitConverter.SetConversionFunction(EntropyUnit.JoulePerDegreeCelsius, Entropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, Entropy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, EntropyUnit.KilocaloriePerKelvin, q => q.ToUnit(EntropyUnit.KilocaloriePerKelvin)); + unitConverter.SetConversionFunction(EntropyUnit.KilocaloriePerKelvin, Entropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, EntropyUnit.KilojoulePerDegreeCelsius, q => q.ToUnit(EntropyUnit.KilojoulePerDegreeCelsius)); + unitConverter.SetConversionFunction(EntropyUnit.KilojoulePerDegreeCelsius, Entropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, EntropyUnit.KilojoulePerKelvin, q => q.ToUnit(EntropyUnit.KilojoulePerKelvin)); + unitConverter.SetConversionFunction(EntropyUnit.KilojoulePerKelvin, Entropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Entropy.ConversionBaseUnit, EntropyUnit.MegajoulePerKelvin, q => q.ToUnit(EntropyUnit.MegajoulePerKelvin)); + unitConverter.SetConversionFunction(EntropyUnit.MegajoulePerKelvin, Entropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Decanewton, q => q.ToUnit(ForceUnit.Decanewton)); + unitConverter.SetConversionFunction(ForceUnit.Decanewton, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Dyn, q => q.ToUnit(ForceUnit.Dyn)); + unitConverter.SetConversionFunction(ForceUnit.Dyn, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.KilogramForce, q => q.ToUnit(ForceUnit.KilogramForce)); + unitConverter.SetConversionFunction(ForceUnit.KilogramForce, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Kilonewton, q => q.ToUnit(ForceUnit.Kilonewton)); + unitConverter.SetConversionFunction(ForceUnit.Kilonewton, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.KiloPond, q => q.ToUnit(ForceUnit.KiloPond)); + unitConverter.SetConversionFunction(ForceUnit.KiloPond, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.KilopoundForce, q => q.ToUnit(ForceUnit.KilopoundForce)); + unitConverter.SetConversionFunction(ForceUnit.KilopoundForce, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Meganewton, q => q.ToUnit(ForceUnit.Meganewton)); + unitConverter.SetConversionFunction(ForceUnit.Meganewton, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Micronewton, q => q.ToUnit(ForceUnit.Micronewton)); + unitConverter.SetConversionFunction(ForceUnit.Micronewton, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Millinewton, q => q.ToUnit(ForceUnit.Millinewton)); + unitConverter.SetConversionFunction(ForceUnit.Millinewton, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, Force.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.OunceForce, q => q.ToUnit(ForceUnit.OunceForce)); + unitConverter.SetConversionFunction(ForceUnit.OunceForce, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.Poundal, q => q.ToUnit(ForceUnit.Poundal)); + unitConverter.SetConversionFunction(ForceUnit.Poundal, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.PoundForce, q => q.ToUnit(ForceUnit.PoundForce)); + unitConverter.SetConversionFunction(ForceUnit.PoundForce, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.ShortTonForce, q => q.ToUnit(ForceUnit.ShortTonForce)); + unitConverter.SetConversionFunction(ForceUnit.ShortTonForce, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Force.ConversionBaseUnit, ForceUnit.TonneForce, q => q.ToUnit(ForceUnit.TonneForce)); + unitConverter.SetConversionFunction(ForceUnit.TonneForce, Force.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.CentinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.CentinewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.CentinewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.DecanewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerMinute)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.DecanewtonPerMinute, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.DecanewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecanewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.DecanewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.DecinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.DecinewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.DecinewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.KilonewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerMinute)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.KilonewtonPerMinute, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.KilonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.KilonewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.KilonewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.KilopoundForcePerMinute, q => q.ToUnit(ForceChangeRateUnit.KilopoundForcePerMinute)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.KilopoundForcePerMinute, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.KilopoundForcePerSecond, q => q.ToUnit(ForceChangeRateUnit.KilopoundForcePerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.KilopoundForcePerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.MicronewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MicronewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.MicronewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.MillinewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.MillinewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.MillinewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.NanonewtonPerSecond, q => q.ToUnit(ForceChangeRateUnit.NanonewtonPerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.NanonewtonPerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.NewtonPerMinute, q => q.ToUnit(ForceChangeRateUnit.NewtonPerMinute)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerMinute, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.PoundForcePerMinute, q => q.ToUnit(ForceChangeRateUnit.PoundForcePerMinute)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.PoundForcePerMinute, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForceChangeRate.ConversionBaseUnit, ForceChangeRateUnit.PoundForcePerSecond, q => q.ToUnit(ForceChangeRateUnit.PoundForcePerSecond)); + unitConverter.SetConversionFunction(ForceChangeRateUnit.PoundForcePerSecond, ForceChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.CentinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.CentinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.CentinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.CentinewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.CentinewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.DecanewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.DecanewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.DecanewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecanewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.DecanewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.DecinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.DecinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.DecinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.DecinewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.DecinewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilogramForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilogramForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilogramForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilogramForcePerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilogramForcePerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.KilonewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilonewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilopoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerFoot)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilopoundForcePerFoot, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.KilopoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.KilopoundForcePerInch)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.KilopoundForcePerInch, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MeganewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MeganewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MeganewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MeganewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MeganewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MicronewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MicronewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MicronewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MicronewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MicronewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MillinewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MillinewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.MillinewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.MillinewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.MillinewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.NanonewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.NanonewtonPerMeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.NanonewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NanonewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.NanonewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.NewtonPerCentimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLength.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.NewtonPerMillimeter, q => q.ToUnit(ForcePerLengthUnit.NewtonPerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.PoundForcePerFoot, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerFoot)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerFoot, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.PoundForcePerInch, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerInch)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerInch, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.PoundForcePerYard, q => q.ToUnit(ForcePerLengthUnit.PoundForcePerYard)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.PoundForcePerYard, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.TonneForcePerCentimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerCentimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerCentimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.TonneForcePerMeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerMeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ForcePerLength.ConversionBaseUnit, ForcePerLengthUnit.TonneForcePerMillimeter, q => q.ToUnit(ForcePerLengthUnit.TonneForcePerMillimeter)); + unitConverter.SetConversionFunction(ForcePerLengthUnit.TonneForcePerMillimeter, ForcePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.BeatPerMinute, q => q.ToUnit(FrequencyUnit.BeatPerMinute)); + unitConverter.SetConversionFunction(FrequencyUnit.BeatPerMinute, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.BUnit, q => q.ToUnit(FrequencyUnit.BUnit)); + unitConverter.SetConversionFunction(FrequencyUnit.BUnit, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.CyclePerHour, q => q.ToUnit(FrequencyUnit.CyclePerHour)); + unitConverter.SetConversionFunction(FrequencyUnit.CyclePerHour, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.CyclePerMinute, q => q.ToUnit(FrequencyUnit.CyclePerMinute)); + unitConverter.SetConversionFunction(FrequencyUnit.CyclePerMinute, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.Gigahertz, q => q.ToUnit(FrequencyUnit.Gigahertz)); + unitConverter.SetConversionFunction(FrequencyUnit.Gigahertz, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, Frequency.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.Kilohertz, q => q.ToUnit(FrequencyUnit.Kilohertz)); + unitConverter.SetConversionFunction(FrequencyUnit.Kilohertz, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.Megahertz, q => q.ToUnit(FrequencyUnit.Megahertz)); + unitConverter.SetConversionFunction(FrequencyUnit.Megahertz, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.PerSecond, q => q.ToUnit(FrequencyUnit.PerSecond)); + unitConverter.SetConversionFunction(FrequencyUnit.PerSecond, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.RadianPerSecond, q => q.ToUnit(FrequencyUnit.RadianPerSecond)); + unitConverter.SetConversionFunction(FrequencyUnit.RadianPerSecond, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Frequency.ConversionBaseUnit, FrequencyUnit.Terahertz, q => q.ToUnit(FrequencyUnit.Terahertz)); + unitConverter.SetConversionFunction(FrequencyUnit.Terahertz, Frequency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(FuelEfficiency.ConversionBaseUnit, FuelEfficiencyUnit.KilometerPerLiter, q => q.ToUnit(FuelEfficiencyUnit.KilometerPerLiter)); + unitConverter.SetConversionFunction(FuelEfficiencyUnit.KilometerPerLiter, FuelEfficiency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(FuelEfficiency.ConversionBaseUnit, FuelEfficiency.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(FuelEfficiency.ConversionBaseUnit, FuelEfficiencyUnit.MilePerUkGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUkGallon)); + unitConverter.SetConversionFunction(FuelEfficiencyUnit.MilePerUkGallon, FuelEfficiency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(FuelEfficiency.ConversionBaseUnit, FuelEfficiencyUnit.MilePerUsGallon, q => q.ToUnit(FuelEfficiencyUnit.MilePerUsGallon)); + unitConverter.SetConversionFunction(FuelEfficiencyUnit.MilePerUsGallon, FuelEfficiency.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.BtuPerHourSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerHourSquareFoot)); + unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerHourSquareFoot, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.BtuPerMinuteSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerMinuteSquareFoot)); + unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerMinuteSquareFoot, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.BtuPerSecondSquareFoot, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareFoot)); + unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerSecondSquareFoot, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.BtuPerSecondSquareInch, q => q.ToUnit(HeatFluxUnit.BtuPerSecondSquareInch)); + unitConverter.SetConversionFunction(HeatFluxUnit.BtuPerSecondSquareInch, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.CaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.CaloriePerSecondSquareCentimeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.CaloriePerSecondSquareCentimeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.CentiwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.CentiwattPerSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.CentiwattPerSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.DeciwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.DeciwattPerSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.DeciwattPerSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.KilocaloriePerHourSquareMeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerHourSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.KilocaloriePerHourSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, q => q.ToUnit(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.KilowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.KilowattPerSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.KilowattPerSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.MicrowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MicrowattPerSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.MicrowattPerSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.MilliwattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.MilliwattPerSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.MilliwattPerSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.NanowattPerSquareMeter, q => q.ToUnit(HeatFluxUnit.NanowattPerSquareMeter)); + unitConverter.SetConversionFunction(HeatFluxUnit.NanowattPerSquareMeter, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.PoundForcePerFootSecond, q => q.ToUnit(HeatFluxUnit.PoundForcePerFootSecond)); + unitConverter.SetConversionFunction(HeatFluxUnit.PoundForcePerFootSecond, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.PoundPerSecondCubed, q => q.ToUnit(HeatFluxUnit.PoundPerSecondCubed)); + unitConverter.SetConversionFunction(HeatFluxUnit.PoundPerSecondCubed, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.WattPerSquareFoot, q => q.ToUnit(HeatFluxUnit.WattPerSquareFoot)); + unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareFoot, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFluxUnit.WattPerSquareInch, q => q.ToUnit(HeatFluxUnit.WattPerSquareInch)); + unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareInch, HeatFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatFlux.ConversionBaseUnit, HeatFlux.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(HeatTransferCoefficient.ConversionBaseUnit, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, q => q.ToUnit(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit)); + unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, HeatTransferCoefficient.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatTransferCoefficient.ConversionBaseUnit, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, q => q.ToUnit(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius)); + unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, HeatTransferCoefficient.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(HeatTransferCoefficient.ConversionBaseUnit, HeatTransferCoefficient.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Illuminance.ConversionBaseUnit, IlluminanceUnit.Kilolux, q => q.ToUnit(IlluminanceUnit.Kilolux)); + unitConverter.SetConversionFunction(IlluminanceUnit.Kilolux, Illuminance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Illuminance.ConversionBaseUnit, Illuminance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Illuminance.ConversionBaseUnit, IlluminanceUnit.Megalux, q => q.ToUnit(IlluminanceUnit.Megalux)); + unitConverter.SetConversionFunction(IlluminanceUnit.Megalux, Illuminance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Illuminance.ConversionBaseUnit, IlluminanceUnit.Millilux, q => q.ToUnit(IlluminanceUnit.Millilux)); + unitConverter.SetConversionFunction(IlluminanceUnit.Millilux, Illuminance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, Information.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Byte, q => q.ToUnit(InformationUnit.Byte)); + unitConverter.SetConversionFunction(InformationUnit.Byte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Exabit, q => q.ToUnit(InformationUnit.Exabit)); + unitConverter.SetConversionFunction(InformationUnit.Exabit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Exabyte, q => q.ToUnit(InformationUnit.Exabyte)); + unitConverter.SetConversionFunction(InformationUnit.Exabyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Exbibit, q => q.ToUnit(InformationUnit.Exbibit)); + unitConverter.SetConversionFunction(InformationUnit.Exbibit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Exbibyte, q => q.ToUnit(InformationUnit.Exbibyte)); + unitConverter.SetConversionFunction(InformationUnit.Exbibyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Gibibit, q => q.ToUnit(InformationUnit.Gibibit)); + unitConverter.SetConversionFunction(InformationUnit.Gibibit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Gibibyte, q => q.ToUnit(InformationUnit.Gibibyte)); + unitConverter.SetConversionFunction(InformationUnit.Gibibyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Gigabit, q => q.ToUnit(InformationUnit.Gigabit)); + unitConverter.SetConversionFunction(InformationUnit.Gigabit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Gigabyte, q => q.ToUnit(InformationUnit.Gigabyte)); + unitConverter.SetConversionFunction(InformationUnit.Gigabyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Kibibit, q => q.ToUnit(InformationUnit.Kibibit)); + unitConverter.SetConversionFunction(InformationUnit.Kibibit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Kibibyte, q => q.ToUnit(InformationUnit.Kibibyte)); + unitConverter.SetConversionFunction(InformationUnit.Kibibyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Kilobit, q => q.ToUnit(InformationUnit.Kilobit)); + unitConverter.SetConversionFunction(InformationUnit.Kilobit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Kilobyte, q => q.ToUnit(InformationUnit.Kilobyte)); + unitConverter.SetConversionFunction(InformationUnit.Kilobyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Mebibit, q => q.ToUnit(InformationUnit.Mebibit)); + unitConverter.SetConversionFunction(InformationUnit.Mebibit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Mebibyte, q => q.ToUnit(InformationUnit.Mebibyte)); + unitConverter.SetConversionFunction(InformationUnit.Mebibyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Megabit, q => q.ToUnit(InformationUnit.Megabit)); + unitConverter.SetConversionFunction(InformationUnit.Megabit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Megabyte, q => q.ToUnit(InformationUnit.Megabyte)); + unitConverter.SetConversionFunction(InformationUnit.Megabyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Pebibit, q => q.ToUnit(InformationUnit.Pebibit)); + unitConverter.SetConversionFunction(InformationUnit.Pebibit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Pebibyte, q => q.ToUnit(InformationUnit.Pebibyte)); + unitConverter.SetConversionFunction(InformationUnit.Pebibyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Petabit, q => q.ToUnit(InformationUnit.Petabit)); + unitConverter.SetConversionFunction(InformationUnit.Petabit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Petabyte, q => q.ToUnit(InformationUnit.Petabyte)); + unitConverter.SetConversionFunction(InformationUnit.Petabyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Tebibit, q => q.ToUnit(InformationUnit.Tebibit)); + unitConverter.SetConversionFunction(InformationUnit.Tebibit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Tebibyte, q => q.ToUnit(InformationUnit.Tebibyte)); + unitConverter.SetConversionFunction(InformationUnit.Tebibyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Terabit, q => q.ToUnit(InformationUnit.Terabit)); + unitConverter.SetConversionFunction(InformationUnit.Terabit, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Information.ConversionBaseUnit, InformationUnit.Terabyte, q => q.ToUnit(InformationUnit.Terabyte)); + unitConverter.SetConversionFunction(InformationUnit.Terabyte, Information.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.KilowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.KilowattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.KilowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.KilowattPerSquareMeter)); + unitConverter.SetConversionFunction(IrradianceUnit.KilowattPerSquareMeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.MegawattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.MegawattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.MegawattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MegawattPerSquareMeter)); + unitConverter.SetConversionFunction(IrradianceUnit.MegawattPerSquareMeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.MicrowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.MicrowattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.MicrowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MicrowattPerSquareMeter)); + unitConverter.SetConversionFunction(IrradianceUnit.MicrowattPerSquareMeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.MilliwattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.MilliwattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.MilliwattPerSquareMeter, q => q.ToUnit(IrradianceUnit.MilliwattPerSquareMeter)); + unitConverter.SetConversionFunction(IrradianceUnit.MilliwattPerSquareMeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.NanowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.NanowattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.NanowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.NanowattPerSquareMeter)); + unitConverter.SetConversionFunction(IrradianceUnit.NanowattPerSquareMeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.PicowattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.PicowattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.PicowattPerSquareMeter, q => q.ToUnit(IrradianceUnit.PicowattPerSquareMeter)); + unitConverter.SetConversionFunction(IrradianceUnit.PicowattPerSquareMeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, IrradianceUnit.WattPerSquareCentimeter, q => q.ToUnit(IrradianceUnit.WattPerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareCentimeter, Irradiance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiance.ConversionBaseUnit, Irradiance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, IrradiationUnit.JoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareCentimeter, Irradiation.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, Irradiation.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, IrradiationUnit.JoulePerSquareMillimeter, q => q.ToUnit(IrradiationUnit.JoulePerSquareMillimeter)); + unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMillimeter, Irradiation.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, IrradiationUnit.KilojoulePerSquareMeter, q => q.ToUnit(IrradiationUnit.KilojoulePerSquareMeter)); + unitConverter.SetConversionFunction(IrradiationUnit.KilojoulePerSquareMeter, Irradiation.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, IrradiationUnit.KilowattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.KilowattHourPerSquareMeter)); + unitConverter.SetConversionFunction(IrradiationUnit.KilowattHourPerSquareMeter, Irradiation.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, IrradiationUnit.MillijoulePerSquareCentimeter, q => q.ToUnit(IrradiationUnit.MillijoulePerSquareCentimeter)); + unitConverter.SetConversionFunction(IrradiationUnit.MillijoulePerSquareCentimeter, Irradiation.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Irradiation.ConversionBaseUnit, IrradiationUnit.WattHourPerSquareMeter, q => q.ToUnit(IrradiationUnit.WattHourPerSquareMeter)); + unitConverter.SetConversionFunction(IrradiationUnit.WattHourPerSquareMeter, Irradiation.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Centistokes, q => q.ToUnit(KinematicViscosityUnit.Centistokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Centistokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Decistokes, q => q.ToUnit(KinematicViscosityUnit.Decistokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Decistokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Kilostokes, q => q.ToUnit(KinematicViscosityUnit.Kilostokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Kilostokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Microstokes, q => q.ToUnit(KinematicViscosityUnit.Microstokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Microstokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Millistokes, q => q.ToUnit(KinematicViscosityUnit.Millistokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Millistokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Nanostokes, q => q.ToUnit(KinematicViscosityUnit.Nanostokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Nanostokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.SquareFootPerSecond, q => q.ToUnit(KinematicViscosityUnit.SquareFootPerSecond)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.SquareFootPerSecond, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(KinematicViscosity.ConversionBaseUnit, KinematicViscosityUnit.Stokes, q => q.ToUnit(KinematicViscosityUnit.Stokes)); + unitConverter.SetConversionFunction(KinematicViscosityUnit.Stokes, KinematicViscosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LapseRate.ConversionBaseUnit, LapseRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.AstronomicalUnit, q => q.ToUnit(LengthUnit.AstronomicalUnit)); + unitConverter.SetConversionFunction(LengthUnit.AstronomicalUnit, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Centimeter, q => q.ToUnit(LengthUnit.Centimeter)); + unitConverter.SetConversionFunction(LengthUnit.Centimeter, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Chain, q => q.ToUnit(LengthUnit.Chain)); + unitConverter.SetConversionFunction(LengthUnit.Chain, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Decimeter, q => q.ToUnit(LengthUnit.Decimeter)); + unitConverter.SetConversionFunction(LengthUnit.Decimeter, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.DtpPica, q => q.ToUnit(LengthUnit.DtpPica)); + unitConverter.SetConversionFunction(LengthUnit.DtpPica, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.DtpPoint, q => q.ToUnit(LengthUnit.DtpPoint)); + unitConverter.SetConversionFunction(LengthUnit.DtpPoint, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Fathom, q => q.ToUnit(LengthUnit.Fathom)); + unitConverter.SetConversionFunction(LengthUnit.Fathom, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Foot, q => q.ToUnit(LengthUnit.Foot)); + unitConverter.SetConversionFunction(LengthUnit.Foot, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Hand, q => q.ToUnit(LengthUnit.Hand)); + unitConverter.SetConversionFunction(LengthUnit.Hand, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Hectometer, q => q.ToUnit(LengthUnit.Hectometer)); + unitConverter.SetConversionFunction(LengthUnit.Hectometer, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Inch, q => q.ToUnit(LengthUnit.Inch)); + unitConverter.SetConversionFunction(LengthUnit.Inch, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.KilolightYear, q => q.ToUnit(LengthUnit.KilolightYear)); + unitConverter.SetConversionFunction(LengthUnit.KilolightYear, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Kilometer, q => q.ToUnit(LengthUnit.Kilometer)); + unitConverter.SetConversionFunction(LengthUnit.Kilometer, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Kiloparsec, q => q.ToUnit(LengthUnit.Kiloparsec)); + unitConverter.SetConversionFunction(LengthUnit.Kiloparsec, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.LightYear, q => q.ToUnit(LengthUnit.LightYear)); + unitConverter.SetConversionFunction(LengthUnit.LightYear, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.MegalightYear, q => q.ToUnit(LengthUnit.MegalightYear)); + unitConverter.SetConversionFunction(LengthUnit.MegalightYear, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Megaparsec, q => q.ToUnit(LengthUnit.Megaparsec)); + unitConverter.SetConversionFunction(LengthUnit.Megaparsec, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, Length.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Microinch, q => q.ToUnit(LengthUnit.Microinch)); + unitConverter.SetConversionFunction(LengthUnit.Microinch, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Micrometer, q => q.ToUnit(LengthUnit.Micrometer)); + unitConverter.SetConversionFunction(LengthUnit.Micrometer, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Mil, q => q.ToUnit(LengthUnit.Mil)); + unitConverter.SetConversionFunction(LengthUnit.Mil, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Mile, q => q.ToUnit(LengthUnit.Mile)); + unitConverter.SetConversionFunction(LengthUnit.Mile, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Millimeter, q => q.ToUnit(LengthUnit.Millimeter)); + unitConverter.SetConversionFunction(LengthUnit.Millimeter, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Nanometer, q => q.ToUnit(LengthUnit.Nanometer)); + unitConverter.SetConversionFunction(LengthUnit.Nanometer, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.NauticalMile, q => q.ToUnit(LengthUnit.NauticalMile)); + unitConverter.SetConversionFunction(LengthUnit.NauticalMile, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Parsec, q => q.ToUnit(LengthUnit.Parsec)); + unitConverter.SetConversionFunction(LengthUnit.Parsec, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.PrinterPica, q => q.ToUnit(LengthUnit.PrinterPica)); + unitConverter.SetConversionFunction(LengthUnit.PrinterPica, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.PrinterPoint, q => q.ToUnit(LengthUnit.PrinterPoint)); + unitConverter.SetConversionFunction(LengthUnit.PrinterPoint, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Shackle, q => q.ToUnit(LengthUnit.Shackle)); + unitConverter.SetConversionFunction(LengthUnit.Shackle, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.SolarRadius, q => q.ToUnit(LengthUnit.SolarRadius)); + unitConverter.SetConversionFunction(LengthUnit.SolarRadius, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Twip, q => q.ToUnit(LengthUnit.Twip)); + unitConverter.SetConversionFunction(LengthUnit.Twip, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.UsSurveyFoot, q => q.ToUnit(LengthUnit.UsSurveyFoot)); + unitConverter.SetConversionFunction(LengthUnit.UsSurveyFoot, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Length.ConversionBaseUnit, LengthUnit.Yard, q => q.ToUnit(LengthUnit.Yard)); + unitConverter.SetConversionFunction(LengthUnit.Yard, Length.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Level.ConversionBaseUnit, Level.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Level.ConversionBaseUnit, LevelUnit.Neper, q => q.ToUnit(LevelUnit.Neper)); + unitConverter.SetConversionFunction(LevelUnit.Neper, Level.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.GramPerCentimeter, q => q.ToUnit(LinearDensityUnit.GramPerCentimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.GramPerCentimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.GramPerMeter, q => q.ToUnit(LinearDensityUnit.GramPerMeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.GramPerMeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.GramPerMillimeter, q => q.ToUnit(LinearDensityUnit.GramPerMillimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.GramPerMillimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.KilogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerCentimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerCentimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.KilogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.KilogramPerMillimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMillimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.MicrogramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerCentimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerCentimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.MicrogramPerMeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerMeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.MicrogramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MicrogramPerMillimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.MicrogramPerMillimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.MilligramPerCentimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerCentimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerCentimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.MilligramPerMeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerMeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.MilligramPerMillimeter, q => q.ToUnit(LinearDensityUnit.MilligramPerMillimeter)); + unitConverter.SetConversionFunction(LinearDensityUnit.MilligramPerMillimeter, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.PoundPerFoot, q => q.ToUnit(LinearDensityUnit.PoundPerFoot)); + unitConverter.SetConversionFunction(LinearDensityUnit.PoundPerFoot, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearDensity.ConversionBaseUnit, LinearDensityUnit.PoundPerInch, q => q.ToUnit(LinearDensityUnit.PoundPerInch)); + unitConverter.SetConversionFunction(LinearDensityUnit.PoundPerInch, LinearDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.GigawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerCentimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerCentimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.GigawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerFoot)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerFoot, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.GigawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerInch)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerInch, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.GigawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerMeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.GigawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.GigawattPerMillimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.GigawattPerMillimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.KilowattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerCentimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerCentimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.KilowattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerFoot)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerFoot, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.KilowattPerInch, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerInch)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerInch, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.KilowattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerMeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.KilowattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.KilowattPerMillimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.KilowattPerMillimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MegawattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerCentimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerCentimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MegawattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerFoot)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerFoot, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MegawattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerInch)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerInch, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MegawattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerMeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MegawattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MegawattPerMillimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MegawattPerMillimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MilliwattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerCentimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerCentimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MilliwattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerFoot)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerFoot, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MilliwattPerInch, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerInch)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerInch, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MilliwattPerMeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerMeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.MilliwattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.MilliwattPerMillimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.MilliwattPerMillimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.WattPerCentimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerCentimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerCentimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.WattPerFoot, q => q.ToUnit(LinearPowerDensityUnit.WattPerFoot)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerFoot, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.WattPerInch, q => q.ToUnit(LinearPowerDensityUnit.WattPerInch)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerInch, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(LinearPowerDensity.ConversionBaseUnit, LinearPowerDensityUnit.WattPerMillimeter, q => q.ToUnit(LinearPowerDensityUnit.WattPerMillimeter)); + unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMillimeter, LinearPowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Decawatt, q => q.ToUnit(LuminosityUnit.Decawatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Decawatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Deciwatt, q => q.ToUnit(LuminosityUnit.Deciwatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Deciwatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Femtowatt, q => q.ToUnit(LuminosityUnit.Femtowatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Femtowatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Gigawatt, q => q.ToUnit(LuminosityUnit.Gigawatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Gigawatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Kilowatt, q => q.ToUnit(LuminosityUnit.Kilowatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Kilowatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Megawatt, q => q.ToUnit(LuminosityUnit.Megawatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Megawatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Microwatt, q => q.ToUnit(LuminosityUnit.Microwatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Microwatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Milliwatt, q => q.ToUnit(LuminosityUnit.Milliwatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Milliwatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Nanowatt, q => q.ToUnit(LuminosityUnit.Nanowatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Nanowatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Petawatt, q => q.ToUnit(LuminosityUnit.Petawatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Petawatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Picowatt, q => q.ToUnit(LuminosityUnit.Picowatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Picowatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.SolarLuminosity, q => q.ToUnit(LuminosityUnit.SolarLuminosity)); + unitConverter.SetConversionFunction(LuminosityUnit.SolarLuminosity, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, LuminosityUnit.Terawatt, q => q.ToUnit(LuminosityUnit.Terawatt)); + unitConverter.SetConversionFunction(LuminosityUnit.Terawatt, Luminosity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Luminosity.ConversionBaseUnit, Luminosity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(LuminousFlux.ConversionBaseUnit, LuminousFlux.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(LuminousIntensity.ConversionBaseUnit, LuminousIntensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MagneticField.ConversionBaseUnit, MagneticFieldUnit.Gauss, q => q.ToUnit(MagneticFieldUnit.Gauss)); + unitConverter.SetConversionFunction(MagneticFieldUnit.Gauss, MagneticField.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MagneticField.ConversionBaseUnit, MagneticFieldUnit.Microtesla, q => q.ToUnit(MagneticFieldUnit.Microtesla)); + unitConverter.SetConversionFunction(MagneticFieldUnit.Microtesla, MagneticField.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MagneticField.ConversionBaseUnit, MagneticFieldUnit.Milligauss, q => q.ToUnit(MagneticFieldUnit.Milligauss)); + unitConverter.SetConversionFunction(MagneticFieldUnit.Milligauss, MagneticField.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MagneticField.ConversionBaseUnit, MagneticFieldUnit.Millitesla, q => q.ToUnit(MagneticFieldUnit.Millitesla)); + unitConverter.SetConversionFunction(MagneticFieldUnit.Millitesla, MagneticField.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MagneticField.ConversionBaseUnit, MagneticFieldUnit.Nanotesla, q => q.ToUnit(MagneticFieldUnit.Nanotesla)); + unitConverter.SetConversionFunction(MagneticFieldUnit.Nanotesla, MagneticField.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MagneticField.ConversionBaseUnit, MagneticField.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MagneticFlux.ConversionBaseUnit, MagneticFlux.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Magnetization.ConversionBaseUnit, Magnetization.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Centigram, q => q.ToUnit(MassUnit.Centigram)); + unitConverter.SetConversionFunction(MassUnit.Centigram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Decagram, q => q.ToUnit(MassUnit.Decagram)); + unitConverter.SetConversionFunction(MassUnit.Decagram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Decigram, q => q.ToUnit(MassUnit.Decigram)); + unitConverter.SetConversionFunction(MassUnit.Decigram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.EarthMass, q => q.ToUnit(MassUnit.EarthMass)); + unitConverter.SetConversionFunction(MassUnit.EarthMass, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Grain, q => q.ToUnit(MassUnit.Grain)); + unitConverter.SetConversionFunction(MassUnit.Grain, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Gram, q => q.ToUnit(MassUnit.Gram)); + unitConverter.SetConversionFunction(MassUnit.Gram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Hectogram, q => q.ToUnit(MassUnit.Hectogram)); + unitConverter.SetConversionFunction(MassUnit.Hectogram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, Mass.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Kilopound, q => q.ToUnit(MassUnit.Kilopound)); + unitConverter.SetConversionFunction(MassUnit.Kilopound, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Kilotonne, q => q.ToUnit(MassUnit.Kilotonne)); + unitConverter.SetConversionFunction(MassUnit.Kilotonne, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.LongHundredweight, q => q.ToUnit(MassUnit.LongHundredweight)); + unitConverter.SetConversionFunction(MassUnit.LongHundredweight, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.LongTon, q => q.ToUnit(MassUnit.LongTon)); + unitConverter.SetConversionFunction(MassUnit.LongTon, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Megapound, q => q.ToUnit(MassUnit.Megapound)); + unitConverter.SetConversionFunction(MassUnit.Megapound, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Megatonne, q => q.ToUnit(MassUnit.Megatonne)); + unitConverter.SetConversionFunction(MassUnit.Megatonne, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Microgram, q => q.ToUnit(MassUnit.Microgram)); + unitConverter.SetConversionFunction(MassUnit.Microgram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Milligram, q => q.ToUnit(MassUnit.Milligram)); + unitConverter.SetConversionFunction(MassUnit.Milligram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Nanogram, q => q.ToUnit(MassUnit.Nanogram)); + unitConverter.SetConversionFunction(MassUnit.Nanogram, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Ounce, q => q.ToUnit(MassUnit.Ounce)); + unitConverter.SetConversionFunction(MassUnit.Ounce, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Pound, q => q.ToUnit(MassUnit.Pound)); + unitConverter.SetConversionFunction(MassUnit.Pound, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.ShortHundredweight, q => q.ToUnit(MassUnit.ShortHundredweight)); + unitConverter.SetConversionFunction(MassUnit.ShortHundredweight, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.ShortTon, q => q.ToUnit(MassUnit.ShortTon)); + unitConverter.SetConversionFunction(MassUnit.ShortTon, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Slug, q => q.ToUnit(MassUnit.Slug)); + unitConverter.SetConversionFunction(MassUnit.Slug, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.SolarMass, q => q.ToUnit(MassUnit.SolarMass)); + unitConverter.SetConversionFunction(MassUnit.SolarMass, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Stone, q => q.ToUnit(MassUnit.Stone)); + unitConverter.SetConversionFunction(MassUnit.Stone, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Mass.ConversionBaseUnit, MassUnit.Tonne, q => q.ToUnit(MassUnit.Tonne)); + unitConverter.SetConversionFunction(MassUnit.Tonne, Mass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.CentigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.CentigramPerLiter, q => q.ToUnit(MassConcentrationUnit.CentigramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.CentigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.CentigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.CentigramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.CentigramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.DecigramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.DecigramPerLiter, q => q.ToUnit(MassConcentrationUnit.DecigramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.DecigramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.DecigramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.DecigramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.DecigramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicCentimeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicCentimeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicMeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.GramPerCubicMillimeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerCubicMillimeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.GramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerLiter, q => q.ToUnit(MassConcentrationUnit.GramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.GramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.GramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.GramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.GramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.KilogramPerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicCentimeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicCentimeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentration.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.KilogramPerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.KilogramPerCubicMillimeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMillimeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.KilogramPerLiter, q => q.ToUnit(MassConcentrationUnit.KilogramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.KilopoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicFoot)); + unitConverter.SetConversionFunction(MassConcentrationUnit.KilopoundPerCubicFoot, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.KilopoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.KilopoundPerCubicInch)); + unitConverter.SetConversionFunction(MassConcentrationUnit.KilopoundPerCubicInch, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MicrogramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerCubicMeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerCubicMeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MicrogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MicrogramPerLiter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MicrogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MicrogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MicrogramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MicrogramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MilligramPerCubicMeter, q => q.ToUnit(MassConcentrationUnit.MilligramPerCubicMeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerCubicMeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MilligramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MilligramPerLiter, q => q.ToUnit(MassConcentrationUnit.MilligramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MilligramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.MilligramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.MilligramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.MilligramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.NanogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.NanogramPerLiter, q => q.ToUnit(MassConcentrationUnit.NanogramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.NanogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.NanogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.NanogramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.NanogramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.OuncePerImperialGallon, q => q.ToUnit(MassConcentrationUnit.OuncePerImperialGallon)); + unitConverter.SetConversionFunction(MassConcentrationUnit.OuncePerImperialGallon, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.OuncePerUSGallon, q => q.ToUnit(MassConcentrationUnit.OuncePerUSGallon)); + unitConverter.SetConversionFunction(MassConcentrationUnit.OuncePerUSGallon, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PicogramPerDeciliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerDeciliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerDeciliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PicogramPerLiter, q => q.ToUnit(MassConcentrationUnit.PicogramPerLiter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerLiter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PicogramPerMicroliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMicroliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerMicroliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PicogramPerMilliliter, q => q.ToUnit(MassConcentrationUnit.PicogramPerMilliliter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PicogramPerMilliliter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PoundPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicFoot)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerCubicFoot, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PoundPerCubicInch, q => q.ToUnit(MassConcentrationUnit.PoundPerCubicInch)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerCubicInch, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PoundPerImperialGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerImperialGallon)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerImperialGallon, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.PoundPerUSGallon, q => q.ToUnit(MassConcentrationUnit.PoundPerUSGallon)); + unitConverter.SetConversionFunction(MassConcentrationUnit.PoundPerUSGallon, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.SlugPerCubicFoot, q => q.ToUnit(MassConcentrationUnit.SlugPerCubicFoot)); + unitConverter.SetConversionFunction(MassConcentrationUnit.SlugPerCubicFoot, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.TonnePerCubicCentimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicCentimeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicCentimeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.TonnePerCubicMeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicMeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassConcentration.ConversionBaseUnit, MassConcentrationUnit.TonnePerCubicMillimeter, q => q.ToUnit(MassConcentrationUnit.TonnePerCubicMillimeter)); + unitConverter.SetConversionFunction(MassConcentrationUnit.TonnePerCubicMillimeter, MassConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.CentigramPerDay, q => q.ToUnit(MassFlowUnit.CentigramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.CentigramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.CentigramPerSecond, q => q.ToUnit(MassFlowUnit.CentigramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.CentigramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.DecagramPerDay, q => q.ToUnit(MassFlowUnit.DecagramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.DecagramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.DecagramPerSecond, q => q.ToUnit(MassFlowUnit.DecagramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.DecagramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.DecigramPerDay, q => q.ToUnit(MassFlowUnit.DecigramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.DecigramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.DecigramPerSecond, q => q.ToUnit(MassFlowUnit.DecigramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.DecigramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.GramPerDay, q => q.ToUnit(MassFlowUnit.GramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.GramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.GramPerHour, q => q.ToUnit(MassFlowUnit.GramPerHour)); + unitConverter.SetConversionFunction(MassFlowUnit.GramPerHour, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlow.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.HectogramPerDay, q => q.ToUnit(MassFlowUnit.HectogramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.HectogramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.HectogramPerSecond, q => q.ToUnit(MassFlowUnit.HectogramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.HectogramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.KilogramPerDay, q => q.ToUnit(MassFlowUnit.KilogramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.KilogramPerHour, q => q.ToUnit(MassFlowUnit.KilogramPerHour)); + unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerHour, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.KilogramPerMinute, q => q.ToUnit(MassFlowUnit.KilogramPerMinute)); + unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerMinute, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.KilogramPerSecond, q => q.ToUnit(MassFlowUnit.KilogramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.KilogramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MegagramPerDay, q => q.ToUnit(MassFlowUnit.MegagramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.MegagramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MegapoundPerDay, q => q.ToUnit(MassFlowUnit.MegapoundPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MegapoundPerHour, q => q.ToUnit(MassFlowUnit.MegapoundPerHour)); + unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerHour, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MegapoundPerMinute, q => q.ToUnit(MassFlowUnit.MegapoundPerMinute)); + unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerMinute, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MegapoundPerSecond, q => q.ToUnit(MassFlowUnit.MegapoundPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.MegapoundPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MicrogramPerDay, q => q.ToUnit(MassFlowUnit.MicrogramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.MicrogramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MicrogramPerSecond, q => q.ToUnit(MassFlowUnit.MicrogramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.MicrogramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MilligramPerDay, q => q.ToUnit(MassFlowUnit.MilligramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.MilligramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.MilligramPerSecond, q => q.ToUnit(MassFlowUnit.MilligramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.MilligramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.NanogramPerDay, q => q.ToUnit(MassFlowUnit.NanogramPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.NanogramPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.NanogramPerSecond, q => q.ToUnit(MassFlowUnit.NanogramPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.NanogramPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.PoundPerDay, q => q.ToUnit(MassFlowUnit.PoundPerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.PoundPerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.PoundPerHour, q => q.ToUnit(MassFlowUnit.PoundPerHour)); + unitConverter.SetConversionFunction(MassFlowUnit.PoundPerHour, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.PoundPerMinute, q => q.ToUnit(MassFlowUnit.PoundPerMinute)); + unitConverter.SetConversionFunction(MassFlowUnit.PoundPerMinute, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.PoundPerSecond, q => q.ToUnit(MassFlowUnit.PoundPerSecond)); + unitConverter.SetConversionFunction(MassFlowUnit.PoundPerSecond, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.ShortTonPerHour, q => q.ToUnit(MassFlowUnit.ShortTonPerHour)); + unitConverter.SetConversionFunction(MassFlowUnit.ShortTonPerHour, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.TonnePerDay, q => q.ToUnit(MassFlowUnit.TonnePerDay)); + unitConverter.SetConversionFunction(MassFlowUnit.TonnePerDay, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlow.ConversionBaseUnit, MassFlowUnit.TonnePerHour, q => q.ToUnit(MassFlowUnit.TonnePerHour)); + unitConverter.SetConversionFunction(MassFlowUnit.TonnePerHour, MassFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.GramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareCentimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareCentimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.GramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMeter)); + unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareMeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.GramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerHourPerSquareMillimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.GramPerHourPerSquareMillimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.GramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareCentimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareCentimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.GramPerSecondPerSquareMeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMeter)); + unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareMeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.GramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.GramPerSecondPerSquareMillimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.GramPerSecondPerSquareMillimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.KilogramPerHourPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareCentimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareCentimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.KilogramPerHourPerSquareMeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMeter)); + unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareMeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.KilogramPerHourPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerHourPerSquareMillimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerHourPerSquareMillimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.KilogramPerSecondPerSquareCentimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareCentimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareCentimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFlux.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MassFlux.ConversionBaseUnit, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, q => q.ToUnit(MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); + unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, MassFlux.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.CentigramPerGram, q => q.ToUnit(MassFractionUnit.CentigramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.CentigramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.CentigramPerKilogram, q => q.ToUnit(MassFractionUnit.CentigramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.CentigramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.DecagramPerGram, q => q.ToUnit(MassFractionUnit.DecagramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.DecagramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.DecagramPerKilogram, q => q.ToUnit(MassFractionUnit.DecagramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.DecagramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.DecigramPerGram, q => q.ToUnit(MassFractionUnit.DecigramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.DecigramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.DecigramPerKilogram, q => q.ToUnit(MassFractionUnit.DecigramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.DecigramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFraction.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.GramPerGram, q => q.ToUnit(MassFractionUnit.GramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.GramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.GramPerKilogram, q => q.ToUnit(MassFractionUnit.GramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.GramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.HectogramPerGram, q => q.ToUnit(MassFractionUnit.HectogramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.HectogramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.HectogramPerKilogram, q => q.ToUnit(MassFractionUnit.HectogramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.HectogramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.KilogramPerGram, q => q.ToUnit(MassFractionUnit.KilogramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.KilogramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.KilogramPerKilogram, q => q.ToUnit(MassFractionUnit.KilogramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.KilogramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.MicrogramPerGram, q => q.ToUnit(MassFractionUnit.MicrogramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.MicrogramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.MicrogramPerKilogram, q => q.ToUnit(MassFractionUnit.MicrogramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.MicrogramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.MilligramPerGram, q => q.ToUnit(MassFractionUnit.MilligramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.MilligramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.MilligramPerKilogram, q => q.ToUnit(MassFractionUnit.MilligramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.MilligramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.NanogramPerGram, q => q.ToUnit(MassFractionUnit.NanogramPerGram)); + unitConverter.SetConversionFunction(MassFractionUnit.NanogramPerGram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.NanogramPerKilogram, q => q.ToUnit(MassFractionUnit.NanogramPerKilogram)); + unitConverter.SetConversionFunction(MassFractionUnit.NanogramPerKilogram, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.PartPerBillion, q => q.ToUnit(MassFractionUnit.PartPerBillion)); + unitConverter.SetConversionFunction(MassFractionUnit.PartPerBillion, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.PartPerMillion, q => q.ToUnit(MassFractionUnit.PartPerMillion)); + unitConverter.SetConversionFunction(MassFractionUnit.PartPerMillion, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.PartPerThousand, q => q.ToUnit(MassFractionUnit.PartPerThousand)); + unitConverter.SetConversionFunction(MassFractionUnit.PartPerThousand, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.PartPerTrillion, q => q.ToUnit(MassFractionUnit.PartPerTrillion)); + unitConverter.SetConversionFunction(MassFractionUnit.PartPerTrillion, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassFraction.ConversionBaseUnit, MassFractionUnit.Percent, q => q.ToUnit(MassFractionUnit.Percent)); + unitConverter.SetConversionFunction(MassFractionUnit.Percent, MassFraction.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.GramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareCentimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareCentimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.GramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareDecimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareDecimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.GramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareMeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.GramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.GramSquareMillimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.GramSquareMillimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilogramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareCentimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareCentimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilogramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareDecimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareDecimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertia.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilogramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilogramSquareMillimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMillimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilotonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareCentimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareCentimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilotonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareDecimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareDecimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareMeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.KilotonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.KilotonneSquareMilimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilotonneSquareMilimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MegatonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareCentimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareCentimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MegatonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareDecimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareDecimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareMeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MegatonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MegatonneSquareMilimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MegatonneSquareMilimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MilligramSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareCentimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareCentimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MilligramSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareDecimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareDecimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MilligramSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareMeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.MilligramSquareMillimeter, q => q.ToUnit(MassMomentOfInertiaUnit.MilligramSquareMillimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.MilligramSquareMillimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.PoundSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareFoot)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.PoundSquareFoot, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.PoundSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.PoundSquareInch)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.PoundSquareInch, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.SlugSquareFoot, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareFoot)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.SlugSquareFoot, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.SlugSquareInch, q => q.ToUnit(MassMomentOfInertiaUnit.SlugSquareInch)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.SlugSquareInch, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.TonneSquareCentimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareCentimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareCentimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.TonneSquareDecimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareDecimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareDecimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.TonneSquareMeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareMeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MassMomentOfInertia.ConversionBaseUnit, MassMomentOfInertiaUnit.TonneSquareMilimeter, q => q.ToUnit(MassMomentOfInertiaUnit.TonneSquareMilimeter)); + unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.TonneSquareMilimeter, MassMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarEnergy.ConversionBaseUnit, MolarEnergy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MolarEnergy.ConversionBaseUnit, MolarEnergyUnit.KilojoulePerMole, q => q.ToUnit(MolarEnergyUnit.KilojoulePerMole)); + unitConverter.SetConversionFunction(MolarEnergyUnit.KilojoulePerMole, MolarEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarEnergy.ConversionBaseUnit, MolarEnergyUnit.MegajoulePerMole, q => q.ToUnit(MolarEnergyUnit.MegajoulePerMole)); + unitConverter.SetConversionFunction(MolarEnergyUnit.MegajoulePerMole, MolarEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarEntropy.ConversionBaseUnit, MolarEntropy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MolarEntropy.ConversionBaseUnit, MolarEntropyUnit.KilojoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.KilojoulePerMoleKelvin)); + unitConverter.SetConversionFunction(MolarEntropyUnit.KilojoulePerMoleKelvin, MolarEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarEntropy.ConversionBaseUnit, MolarEntropyUnit.MegajoulePerMoleKelvin, q => q.ToUnit(MolarEntropyUnit.MegajoulePerMoleKelvin)); + unitConverter.SetConversionFunction(MolarEntropyUnit.MegajoulePerMoleKelvin, MolarEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.CentimolesPerLiter, q => q.ToUnit(MolarityUnit.CentimolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.CentimolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.DecimolesPerLiter, q => q.ToUnit(MolarityUnit.DecimolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.DecimolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.MicromolesPerLiter, q => q.ToUnit(MolarityUnit.MicromolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.MicromolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.MillimolesPerLiter, q => q.ToUnit(MolarityUnit.MillimolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.MillimolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, Molarity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.MolesPerLiter, q => q.ToUnit(MolarityUnit.MolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.MolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.NanomolesPerLiter, q => q.ToUnit(MolarityUnit.NanomolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.NanomolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Molarity.ConversionBaseUnit, MolarityUnit.PicomolesPerLiter, q => q.ToUnit(MolarityUnit.PicomolesPerLiter)); + unitConverter.SetConversionFunction(MolarityUnit.PicomolesPerLiter, Molarity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.CentigramPerMole, q => q.ToUnit(MolarMassUnit.CentigramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.CentigramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.DecagramPerMole, q => q.ToUnit(MolarMassUnit.DecagramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.DecagramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.DecigramPerMole, q => q.ToUnit(MolarMassUnit.DecigramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.DecigramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.GramPerMole, q => q.ToUnit(MolarMassUnit.GramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.GramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.HectogramPerMole, q => q.ToUnit(MolarMassUnit.HectogramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.HectogramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMass.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.KilopoundPerMole, q => q.ToUnit(MolarMassUnit.KilopoundPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.KilopoundPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.MegapoundPerMole, q => q.ToUnit(MolarMassUnit.MegapoundPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.MegapoundPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.MicrogramPerMole, q => q.ToUnit(MolarMassUnit.MicrogramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.MicrogramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.MilligramPerMole, q => q.ToUnit(MolarMassUnit.MilligramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.MilligramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.NanogramPerMole, q => q.ToUnit(MolarMassUnit.NanogramPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.NanogramPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(MolarMass.ConversionBaseUnit, MolarMassUnit.PoundPerMole, q => q.ToUnit(MolarMassUnit.PoundPerMole)); + unitConverter.SetConversionFunction(MolarMassUnit.PoundPerMole, MolarMass.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Permeability.ConversionBaseUnit, Permeability.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Permittivity.ConversionBaseUnit, Permittivity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.BoilerHorsepower, q => q.ToUnit(PowerUnit.BoilerHorsepower)); + unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.BritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.BritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Decawatt, q => q.ToUnit(PowerUnit.Decawatt)); + unitConverter.SetConversionFunction(PowerUnit.Decawatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Deciwatt, q => q.ToUnit(PowerUnit.Deciwatt)); + unitConverter.SetConversionFunction(PowerUnit.Deciwatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.ElectricalHorsepower, q => q.ToUnit(PowerUnit.ElectricalHorsepower)); + unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Femtowatt, q => q.ToUnit(PowerUnit.Femtowatt)); + unitConverter.SetConversionFunction(PowerUnit.Femtowatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.GigajoulePerHour, q => q.ToUnit(PowerUnit.GigajoulePerHour)); + unitConverter.SetConversionFunction(PowerUnit.GigajoulePerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Gigawatt, q => q.ToUnit(PowerUnit.Gigawatt)); + unitConverter.SetConversionFunction(PowerUnit.Gigawatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.HydraulicHorsepower, q => q.ToUnit(PowerUnit.HydraulicHorsepower)); + unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.JoulePerHour, q => q.ToUnit(PowerUnit.JoulePerHour)); + unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.KilobritishThermalUnitPerHour, q => q.ToUnit(PowerUnit.KilobritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.KilojoulePerHour, q => q.ToUnit(PowerUnit.KilojoulePerHour)); + unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Kilowatt, q => q.ToUnit(PowerUnit.Kilowatt)); + unitConverter.SetConversionFunction(PowerUnit.Kilowatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.MechanicalHorsepower, q => q.ToUnit(PowerUnit.MechanicalHorsepower)); + unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.MegajoulePerHour, q => q.ToUnit(PowerUnit.MegajoulePerHour)); + unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Megawatt, q => q.ToUnit(PowerUnit.Megawatt)); + unitConverter.SetConversionFunction(PowerUnit.Megawatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.MetricHorsepower, q => q.ToUnit(PowerUnit.MetricHorsepower)); + unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Microwatt, q => q.ToUnit(PowerUnit.Microwatt)); + unitConverter.SetConversionFunction(PowerUnit.Microwatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.MillijoulePerHour, q => q.ToUnit(PowerUnit.MillijoulePerHour)); + unitConverter.SetConversionFunction(PowerUnit.MillijoulePerHour, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Milliwatt, q => q.ToUnit(PowerUnit.Milliwatt)); + unitConverter.SetConversionFunction(PowerUnit.Milliwatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Nanowatt, q => q.ToUnit(PowerUnit.Nanowatt)); + unitConverter.SetConversionFunction(PowerUnit.Nanowatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Petawatt, q => q.ToUnit(PowerUnit.Petawatt)); + unitConverter.SetConversionFunction(PowerUnit.Petawatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Picowatt, q => q.ToUnit(PowerUnit.Picowatt)); + unitConverter.SetConversionFunction(PowerUnit.Picowatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, PowerUnit.Terawatt, q => q.ToUnit(PowerUnit.Terawatt)); + unitConverter.SetConversionFunction(PowerUnit.Terawatt, Power.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Power.ConversionBaseUnit, Power.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DecawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DecawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DecawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DecawattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DecawattPerLiter, q => q.ToUnit(PowerDensityUnit.DecawattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.DecawattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DeciwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DeciwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DeciwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.DeciwattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.DeciwattPerLiter, q => q.ToUnit(PowerDensityUnit.DeciwattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.DeciwattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.GigawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.GigawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.GigawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.GigawattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.GigawattPerLiter, q => q.ToUnit(PowerDensityUnit.GigawattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.GigawattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.KilowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.KilowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.KilowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.KilowattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.KilowattPerLiter, q => q.ToUnit(PowerDensityUnit.KilowattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.KilowattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MegawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MegawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MegawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MegawattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MegawattPerLiter, q => q.ToUnit(PowerDensityUnit.MegawattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.MegawattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MicrowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MicrowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MicrowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MicrowattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MicrowattPerLiter, q => q.ToUnit(PowerDensityUnit.MicrowattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.MicrowattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MilliwattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MilliwattPerCubicInch, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MilliwattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.MilliwattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.MilliwattPerLiter, q => q.ToUnit(PowerDensityUnit.MilliwattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.MilliwattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.NanowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.NanowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.NanowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.NanowattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.NanowattPerLiter, q => q.ToUnit(PowerDensityUnit.NanowattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.NanowattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.PicowattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.PicowattPerCubicInch, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.PicowattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.PicowattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.PicowattPerLiter, q => q.ToUnit(PowerDensityUnit.PicowattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.PicowattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.TerawattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.TerawattPerCubicInch, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.TerawattPerCubicMeter, q => q.ToUnit(PowerDensityUnit.TerawattPerCubicMeter)); + unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerCubicMeter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.TerawattPerLiter, q => q.ToUnit(PowerDensityUnit.TerawattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.TerawattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.WattPerCubicFoot, q => q.ToUnit(PowerDensityUnit.WattPerCubicFoot)); + unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicFoot, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.WattPerCubicInch, q => q.ToUnit(PowerDensityUnit.WattPerCubicInch)); + unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicInch, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(PowerDensity.ConversionBaseUnit, PowerDensityUnit.WattPerLiter, q => q.ToUnit(PowerDensityUnit.WattPerLiter)); + unitConverter.SetConversionFunction(PowerDensityUnit.WattPerLiter, PowerDensity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerRatio.ConversionBaseUnit, PowerRatioUnit.DecibelMilliwatt, q => q.ToUnit(PowerRatioUnit.DecibelMilliwatt)); + unitConverter.SetConversionFunction(PowerRatioUnit.DecibelMilliwatt, PowerRatio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PowerRatio.ConversionBaseUnit, PowerRatio.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Atmosphere, q => q.ToUnit(PressureUnit.Atmosphere)); + unitConverter.SetConversionFunction(PressureUnit.Atmosphere, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Bar, q => q.ToUnit(PressureUnit.Bar)); + unitConverter.SetConversionFunction(PressureUnit.Bar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Centibar, q => q.ToUnit(PressureUnit.Centibar)); + unitConverter.SetConversionFunction(PressureUnit.Centibar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Decapascal, q => q.ToUnit(PressureUnit.Decapascal)); + unitConverter.SetConversionFunction(PressureUnit.Decapascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Decibar, q => q.ToUnit(PressureUnit.Decibar)); + unitConverter.SetConversionFunction(PressureUnit.Decibar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.DynePerSquareCentimeter, q => q.ToUnit(PressureUnit.DynePerSquareCentimeter)); + unitConverter.SetConversionFunction(PressureUnit.DynePerSquareCentimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.FootOfElevation, q => q.ToUnit(PressureUnit.FootOfElevation)); + unitConverter.SetConversionFunction(PressureUnit.FootOfElevation, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.FootOfHead, q => q.ToUnit(PressureUnit.FootOfHead)); + unitConverter.SetConversionFunction(PressureUnit.FootOfHead, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Gigapascal, q => q.ToUnit(PressureUnit.Gigapascal)); + unitConverter.SetConversionFunction(PressureUnit.Gigapascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Hectopascal, q => q.ToUnit(PressureUnit.Hectopascal)); + unitConverter.SetConversionFunction(PressureUnit.Hectopascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.InchOfMercury, q => q.ToUnit(PressureUnit.InchOfMercury)); + unitConverter.SetConversionFunction(PressureUnit.InchOfMercury, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.InchOfWaterColumn, q => q.ToUnit(PressureUnit.InchOfWaterColumn)); + unitConverter.SetConversionFunction(PressureUnit.InchOfWaterColumn, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Kilobar, q => q.ToUnit(PressureUnit.Kilobar)); + unitConverter.SetConversionFunction(PressureUnit.Kilobar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilogramForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareCentimeter)); + unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareCentimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilogramForcePerSquareMeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMeter)); + unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareMeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilogramForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.KilogramForcePerSquareMillimeter)); + unitConverter.SetConversionFunction(PressureUnit.KilogramForcePerSquareMillimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilonewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareCentimeter)); + unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareCentimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilonewtonPerSquareMeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMeter)); + unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareMeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilonewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.KilonewtonPerSquareMillimeter)); + unitConverter.SetConversionFunction(PressureUnit.KilonewtonPerSquareMillimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Kilopascal, q => q.ToUnit(PressureUnit.Kilopascal)); + unitConverter.SetConversionFunction(PressureUnit.Kilopascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilopoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareFoot)); + unitConverter.SetConversionFunction(PressureUnit.KilopoundForcePerSquareFoot, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.KilopoundForcePerSquareInch, q => q.ToUnit(PressureUnit.KilopoundForcePerSquareInch)); + unitConverter.SetConversionFunction(PressureUnit.KilopoundForcePerSquareInch, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Megabar, q => q.ToUnit(PressureUnit.Megabar)); + unitConverter.SetConversionFunction(PressureUnit.Megabar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.MeganewtonPerSquareMeter, q => q.ToUnit(PressureUnit.MeganewtonPerSquareMeter)); + unitConverter.SetConversionFunction(PressureUnit.MeganewtonPerSquareMeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Megapascal, q => q.ToUnit(PressureUnit.Megapascal)); + unitConverter.SetConversionFunction(PressureUnit.Megapascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.MeterOfElevation, q => q.ToUnit(PressureUnit.MeterOfElevation)); + unitConverter.SetConversionFunction(PressureUnit.MeterOfElevation, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.MeterOfHead, q => q.ToUnit(PressureUnit.MeterOfHead)); + unitConverter.SetConversionFunction(PressureUnit.MeterOfHead, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Microbar, q => q.ToUnit(PressureUnit.Microbar)); + unitConverter.SetConversionFunction(PressureUnit.Microbar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Micropascal, q => q.ToUnit(PressureUnit.Micropascal)); + unitConverter.SetConversionFunction(PressureUnit.Micropascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Millibar, q => q.ToUnit(PressureUnit.Millibar)); + unitConverter.SetConversionFunction(PressureUnit.Millibar, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.MillimeterOfMercury, q => q.ToUnit(PressureUnit.MillimeterOfMercury)); + unitConverter.SetConversionFunction(PressureUnit.MillimeterOfMercury, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Millipascal, q => q.ToUnit(PressureUnit.Millipascal)); + unitConverter.SetConversionFunction(PressureUnit.Millipascal, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.NewtonPerSquareCentimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareCentimeter)); + unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareCentimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.NewtonPerSquareMeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMeter)); + unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareMeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.NewtonPerSquareMillimeter, q => q.ToUnit(PressureUnit.NewtonPerSquareMillimeter)); + unitConverter.SetConversionFunction(PressureUnit.NewtonPerSquareMillimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, Pressure.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.PoundForcePerSquareFoot, q => q.ToUnit(PressureUnit.PoundForcePerSquareFoot)); + unitConverter.SetConversionFunction(PressureUnit.PoundForcePerSquareFoot, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.PoundForcePerSquareInch, q => q.ToUnit(PressureUnit.PoundForcePerSquareInch)); + unitConverter.SetConversionFunction(PressureUnit.PoundForcePerSquareInch, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.PoundPerInchSecondSquared, q => q.ToUnit(PressureUnit.PoundPerInchSecondSquared)); + unitConverter.SetConversionFunction(PressureUnit.PoundPerInchSecondSquared, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.TechnicalAtmosphere, q => q.ToUnit(PressureUnit.TechnicalAtmosphere)); + unitConverter.SetConversionFunction(PressureUnit.TechnicalAtmosphere, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.TonneForcePerSquareCentimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareCentimeter)); + unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareCentimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.TonneForcePerSquareMeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMeter)); + unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareMeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.TonneForcePerSquareMillimeter, q => q.ToUnit(PressureUnit.TonneForcePerSquareMillimeter)); + unitConverter.SetConversionFunction(PressureUnit.TonneForcePerSquareMillimeter, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Pressure.ConversionBaseUnit, PressureUnit.Torr, q => q.ToUnit(PressureUnit.Torr)); + unitConverter.SetConversionFunction(PressureUnit.Torr, Pressure.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.AtmospherePerSecond, q => q.ToUnit(PressureChangeRateUnit.AtmospherePerSecond)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.AtmospherePerSecond, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.KilopascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerMinute)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopascalPerMinute, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.KilopascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.KilopascalPerSecond)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopascalPerSecond, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, q => q.ToUnit(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, q => q.ToUnit(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.MegapascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerMinute)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapascalPerMinute, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.MegapascalPerSecond, q => q.ToUnit(PressureChangeRateUnit.MegapascalPerSecond)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapascalPerSecond, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, q => q.ToUnit(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, q => q.ToUnit(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.PascalPerMinute, q => q.ToUnit(PressureChangeRateUnit.PascalPerMinute)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerMinute, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, q => q.ToUnit(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(PressureChangeRate.ConversionBaseUnit, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, q => q.ToUnit(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond)); + unitConverter.SetConversionFunction(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, PressureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Ratio.ConversionBaseUnit, Ratio.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Ratio.ConversionBaseUnit, RatioUnit.PartPerBillion, q => q.ToUnit(RatioUnit.PartPerBillion)); + unitConverter.SetConversionFunction(RatioUnit.PartPerBillion, Ratio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Ratio.ConversionBaseUnit, RatioUnit.PartPerMillion, q => q.ToUnit(RatioUnit.PartPerMillion)); + unitConverter.SetConversionFunction(RatioUnit.PartPerMillion, Ratio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Ratio.ConversionBaseUnit, RatioUnit.PartPerThousand, q => q.ToUnit(RatioUnit.PartPerThousand)); + unitConverter.SetConversionFunction(RatioUnit.PartPerThousand, Ratio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Ratio.ConversionBaseUnit, RatioUnit.PartPerTrillion, q => q.ToUnit(RatioUnit.PartPerTrillion)); + unitConverter.SetConversionFunction(RatioUnit.PartPerTrillion, Ratio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Ratio.ConversionBaseUnit, RatioUnit.Percent, q => q.ToUnit(RatioUnit.Percent)); + unitConverter.SetConversionFunction(RatioUnit.Percent, Ratio.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RatioChangeRate.ConversionBaseUnit, RatioChangeRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(RatioChangeRate.ConversionBaseUnit, RatioChangeRateUnit.PercentPerSecond, q => q.ToUnit(RatioChangeRateUnit.PercentPerSecond)); + unitConverter.SetConversionFunction(RatioChangeRateUnit.PercentPerSecond, RatioChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReactiveEnergy.ConversionBaseUnit, ReactiveEnergyUnit.KilovoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.KilovoltampereReactiveHour)); + unitConverter.SetConversionFunction(ReactiveEnergyUnit.KilovoltampereReactiveHour, ReactiveEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReactiveEnergy.ConversionBaseUnit, ReactiveEnergyUnit.MegavoltampereReactiveHour, q => q.ToUnit(ReactiveEnergyUnit.MegavoltampereReactiveHour)); + unitConverter.SetConversionFunction(ReactiveEnergyUnit.MegavoltampereReactiveHour, ReactiveEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReactiveEnergy.ConversionBaseUnit, ReactiveEnergy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ReactivePower.ConversionBaseUnit, ReactivePowerUnit.GigavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.GigavoltampereReactive)); + unitConverter.SetConversionFunction(ReactivePowerUnit.GigavoltampereReactive, ReactivePower.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReactivePower.ConversionBaseUnit, ReactivePowerUnit.KilovoltampereReactive, q => q.ToUnit(ReactivePowerUnit.KilovoltampereReactive)); + unitConverter.SetConversionFunction(ReactivePowerUnit.KilovoltampereReactive, ReactivePower.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReactivePower.ConversionBaseUnit, ReactivePowerUnit.MegavoltampereReactive, q => q.ToUnit(ReactivePowerUnit.MegavoltampereReactive)); + unitConverter.SetConversionFunction(ReactivePowerUnit.MegavoltampereReactive, ReactivePower.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReactivePower.ConversionBaseUnit, ReactivePower.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareCentimeter, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareCentimeter)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareCentimeter, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareDecimeter, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareDecimeter)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareDecimeter, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareFoot, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareFoot)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareFoot, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareInch, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareInch)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareInch, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareKilometer, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareKilometer)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareKilometer, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalArea.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareMicrometer, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareMicrometer)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMicrometer, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareMile, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareMile)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMile, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareMillimeter, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareMillimeter)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMillimeter, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseSquareYard, q => q.ToUnit(ReciprocalAreaUnit.InverseSquareYard)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareYard, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalArea.ConversionBaseUnit, ReciprocalAreaUnit.InverseUsSurveySquareFoot, q => q.ToUnit(ReciprocalAreaUnit.InverseUsSurveySquareFoot)); + unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseUsSurveySquareFoot, ReciprocalArea.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseCentimeter, q => q.ToUnit(ReciprocalLengthUnit.InverseCentimeter)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseCentimeter, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseFoot, q => q.ToUnit(ReciprocalLengthUnit.InverseFoot)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseFoot, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseInch, q => q.ToUnit(ReciprocalLengthUnit.InverseInch)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseInch, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLength.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseMicroinch, q => q.ToUnit(ReciprocalLengthUnit.InverseMicroinch)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMicroinch, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseMil, q => q.ToUnit(ReciprocalLengthUnit.InverseMil)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMil, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseMile, q => q.ToUnit(ReciprocalLengthUnit.InverseMile)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMile, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseMillimeter, q => q.ToUnit(ReciprocalLengthUnit.InverseMillimeter)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMillimeter, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseUsSurveyFoot, q => q.ToUnit(ReciprocalLengthUnit.InverseUsSurveyFoot)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseUsSurveyFoot, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ReciprocalLength.ConversionBaseUnit, ReciprocalLengthUnit.InverseYard, q => q.ToUnit(ReciprocalLengthUnit.InverseYard)); + unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseYard, ReciprocalLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RelativeHumidity.ConversionBaseUnit, RelativeHumidity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(RotationalAcceleration.ConversionBaseUnit, RotationalAccelerationUnit.DegreePerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.DegreePerSecondSquared)); + unitConverter.SetConversionFunction(RotationalAccelerationUnit.DegreePerSecondSquared, RotationalAcceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalAcceleration.ConversionBaseUnit, RotationalAcceleration.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(RotationalAcceleration.ConversionBaseUnit, RotationalAccelerationUnit.RevolutionPerMinutePerSecond, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerMinutePerSecond)); + unitConverter.SetConversionFunction(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, RotationalAcceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalAcceleration.ConversionBaseUnit, RotationalAccelerationUnit.RevolutionPerSecondSquared, q => q.ToUnit(RotationalAccelerationUnit.RevolutionPerSecondSquared)); + unitConverter.SetConversionFunction(RotationalAccelerationUnit.RevolutionPerSecondSquared, RotationalAcceleration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.CentiradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.CentiradianPerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.CentiradianPerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.DeciradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.DeciradianPerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.DeciradianPerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.DegreePerMinute, q => q.ToUnit(RotationalSpeedUnit.DegreePerMinute)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.DegreePerMinute, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.DegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.DegreePerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.DegreePerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.MicrodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MicrodegreePerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.MicrodegreePerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.MicroradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MicroradianPerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.MicroradianPerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.MillidegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.MillidegreePerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.MillidegreePerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.MilliradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.MilliradianPerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.MilliradianPerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.NanodegreePerSecond, q => q.ToUnit(RotationalSpeedUnit.NanodegreePerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.NanodegreePerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.NanoradianPerSecond, q => q.ToUnit(RotationalSpeedUnit.NanoradianPerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.NanoradianPerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeed.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.RevolutionPerMinute, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerMinute)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.RevolutionPerMinute, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalSpeed.ConversionBaseUnit, RotationalSpeedUnit.RevolutionPerSecond, q => q.ToUnit(RotationalSpeedUnit.RevolutionPerSecond)); + unitConverter.SetConversionFunction(RotationalSpeedUnit.RevolutionPerSecond, RotationalSpeed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.CentinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.DecanewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.DecinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.KilonewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.KilopoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.KilopoundForceFootPerDegrees)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.KilopoundForceFootPerDegrees, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MeganewtonMeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MicronewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MillinewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.NanonewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.NewtonMeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffness.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerDegree, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerDegree)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMillimeterPerDegree, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.NewtonMillimeterPerRadian, q => q.ToUnit(RotationalStiffnessUnit.NewtonMillimeterPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMillimeterPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.PoundForceFeetPerRadian, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFeetPerRadian)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.PoundForceFeetPerRadian, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffness.ConversionBaseUnit, RotationalStiffnessUnit.PoundForceFootPerDegrees, q => q.ToUnit(RotationalStiffnessUnit.PoundForceFootPerDegrees)); + unitConverter.SetConversionFunction(RotationalStiffnessUnit.PoundForceFootPerDegrees, RotationalStiffness.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffnessPerLength.ConversionBaseUnit, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter)); + unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffnessPerLength.ConversionBaseUnit, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot)); + unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffnessPerLength.ConversionBaseUnit, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, q => q.ToUnit(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter)); + unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, RotationalStiffnessPerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(RotationalStiffnessPerLength.ConversionBaseUnit, RotationalStiffnessPerLength.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(RotationalStiffnessPerLength.ConversionBaseUnit, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, q => q.ToUnit(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); + unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, RotationalStiffnessPerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Scalar.ConversionBaseUnit, Scalar.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SolidAngle.ConversionBaseUnit, SolidAngle.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.BtuPerPound, q => q.ToUnit(SpecificEnergyUnit.BtuPerPound)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.BtuPerPound, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.CaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.CaloriePerGram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.CaloriePerGram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.GigawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.GigawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerShortTon)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerShortTon, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.GigawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.GigawattDayPerTonne)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattDayPerTonne, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.GigawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.GigawattHourPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.GigawattHourPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.KilocaloriePerGram, q => q.ToUnit(SpecificEnergyUnit.KilocaloriePerGram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.KilocaloriePerGram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.KilojoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilojoulePerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.KilojoulePerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.KilowattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.KilowattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerShortTon)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerShortTon, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.KilowattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.KilowattDayPerTonne)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattDayPerTonne, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.KilowattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.KilowattHourPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.KilowattHourPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.MegajoulePerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegajoulePerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.MegajoulePerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.MegawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.MegawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerShortTon)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerShortTon, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.MegawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.MegawattDayPerTonne)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattDayPerTonne, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.MegawattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.MegawattHourPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.MegawattHourPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.TerawattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.TerawattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerShortTon)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerShortTon, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.TerawattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.TerawattDayPerTonne)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.TerawattDayPerTonne, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.WattDayPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattDayPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.WattDayPerShortTon, q => q.ToUnit(SpecificEnergyUnit.WattDayPerShortTon)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerShortTon, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.WattDayPerTonne, q => q.ToUnit(SpecificEnergyUnit.WattDayPerTonne)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.WattDayPerTonne, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEnergy.ConversionBaseUnit, SpecificEnergyUnit.WattHourPerKilogram, q => q.ToUnit(SpecificEnergyUnit.WattHourPerKilogram)); + unitConverter.SetConversionFunction(SpecificEnergyUnit.WattHourPerKilogram, SpecificEnergy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.BtuPerPoundFahrenheit, q => q.ToUnit(SpecificEntropyUnit.BtuPerPoundFahrenheit)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.BtuPerPoundFahrenheit, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.CaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.CaloriePerGramKelvin)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.CaloriePerGramKelvin, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropy.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.KilocaloriePerGramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilocaloriePerGramKelvin)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.KilocaloriePerGramKelvin, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.KilojoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.KilojoulePerKilogramKelvin)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.KilojoulePerKilogramKelvin, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificEntropy.ConversionBaseUnit, SpecificEntropyUnit.MegajoulePerKilogramKelvin, q => q.ToUnit(SpecificEntropyUnit.MegajoulePerKilogramKelvin)); + unitConverter.SetConversionFunction(SpecificEntropyUnit.MegajoulePerKilogramKelvin, SpecificEntropy.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificFuelConsumption.ConversionBaseUnit, SpecificFuelConsumption.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SpecificFuelConsumption.ConversionBaseUnit, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, q => q.ToUnit(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour)); + unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, SpecificFuelConsumption.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificFuelConsumption.ConversionBaseUnit, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, q => q.ToUnit(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond)); + unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, SpecificFuelConsumption.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificFuelConsumption.ConversionBaseUnit, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, q => q.ToUnit(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour)); + unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, SpecificFuelConsumption.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificVolume.ConversionBaseUnit, SpecificVolumeUnit.CubicFootPerPound, q => q.ToUnit(SpecificVolumeUnit.CubicFootPerPound)); + unitConverter.SetConversionFunction(SpecificVolumeUnit.CubicFootPerPound, SpecificVolume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificVolume.ConversionBaseUnit, SpecificVolume.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SpecificVolume.ConversionBaseUnit, SpecificVolumeUnit.MillicubicMeterPerKilogram, q => q.ToUnit(SpecificVolumeUnit.MillicubicMeterPerKilogram)); + unitConverter.SetConversionFunction(SpecificVolumeUnit.MillicubicMeterPerKilogram, SpecificVolume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilogramForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicCentimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicCentimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilogramForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicMeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilogramForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilogramForcePerCubicMillimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilogramForcePerCubicMillimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilonewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicCentimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicCentimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilonewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicMeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilonewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.KilonewtonPerCubicMillimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilonewtonPerCubicMillimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilopoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicFoot)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilopoundForcePerCubicFoot, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.KilopoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.KilopoundForcePerCubicInch)); + unitConverter.SetConversionFunction(SpecificWeightUnit.KilopoundForcePerCubicInch, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.MeganewtonPerCubicMeter, q => q.ToUnit(SpecificWeightUnit.MeganewtonPerCubicMeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.MeganewtonPerCubicMeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.NewtonPerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicCentimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicCentimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeight.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.NewtonPerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.NewtonPerCubicMillimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMillimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.PoundForcePerCubicFoot, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicFoot)); + unitConverter.SetConversionFunction(SpecificWeightUnit.PoundForcePerCubicFoot, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.PoundForcePerCubicInch, q => q.ToUnit(SpecificWeightUnit.PoundForcePerCubicInch)); + unitConverter.SetConversionFunction(SpecificWeightUnit.PoundForcePerCubicInch, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.TonneForcePerCubicCentimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicCentimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicCentimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.TonneForcePerCubicMeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicMeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(SpecificWeight.ConversionBaseUnit, SpecificWeightUnit.TonneForcePerCubicMillimeter, q => q.ToUnit(SpecificWeightUnit.TonneForcePerCubicMillimeter)); + unitConverter.SetConversionFunction(SpecificWeightUnit.TonneForcePerCubicMillimeter, SpecificWeight.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.CentimeterPerHour, q => q.ToUnit(SpeedUnit.CentimeterPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.CentimeterPerMinute, q => q.ToUnit(SpeedUnit.CentimeterPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.CentimeterPerSecond, q => q.ToUnit(SpeedUnit.CentimeterPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.CentimeterPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.DecimeterPerMinute, q => q.ToUnit(SpeedUnit.DecimeterPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.DecimeterPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.DecimeterPerSecond, q => q.ToUnit(SpeedUnit.DecimeterPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.DecimeterPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.FootPerHour, q => q.ToUnit(SpeedUnit.FootPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.FootPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.FootPerMinute, q => q.ToUnit(SpeedUnit.FootPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.FootPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.FootPerSecond, q => q.ToUnit(SpeedUnit.FootPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.FootPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.InchPerHour, q => q.ToUnit(SpeedUnit.InchPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.InchPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.InchPerMinute, q => q.ToUnit(SpeedUnit.InchPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.InchPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.InchPerSecond, q => q.ToUnit(SpeedUnit.InchPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.InchPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.KilometerPerHour, q => q.ToUnit(SpeedUnit.KilometerPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.KilometerPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.KilometerPerMinute, q => q.ToUnit(SpeedUnit.KilometerPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.KilometerPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.KilometerPerSecond, q => q.ToUnit(SpeedUnit.KilometerPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.KilometerPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.Knot, q => q.ToUnit(SpeedUnit.Knot)); + unitConverter.SetConversionFunction(SpeedUnit.Knot, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MeterPerHour, q => q.ToUnit(SpeedUnit.MeterPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.MeterPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MeterPerMinute, q => q.ToUnit(SpeedUnit.MeterPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.MeterPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, Speed.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MicrometerPerMinute, q => q.ToUnit(SpeedUnit.MicrometerPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.MicrometerPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MicrometerPerSecond, q => q.ToUnit(SpeedUnit.MicrometerPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.MicrometerPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MilePerHour, q => q.ToUnit(SpeedUnit.MilePerHour)); + unitConverter.SetConversionFunction(SpeedUnit.MilePerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MillimeterPerHour, q => q.ToUnit(SpeedUnit.MillimeterPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MillimeterPerMinute, q => q.ToUnit(SpeedUnit.MillimeterPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.MillimeterPerSecond, q => q.ToUnit(SpeedUnit.MillimeterPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.MillimeterPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.NanometerPerMinute, q => q.ToUnit(SpeedUnit.NanometerPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.NanometerPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.NanometerPerSecond, q => q.ToUnit(SpeedUnit.NanometerPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.NanometerPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.UsSurveyFootPerHour, q => q.ToUnit(SpeedUnit.UsSurveyFootPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.UsSurveyFootPerMinute, q => q.ToUnit(SpeedUnit.UsSurveyFootPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.UsSurveyFootPerSecond, q => q.ToUnit(SpeedUnit.UsSurveyFootPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.UsSurveyFootPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.YardPerHour, q => q.ToUnit(SpeedUnit.YardPerHour)); + unitConverter.SetConversionFunction(SpeedUnit.YardPerHour, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.YardPerMinute, q => q.ToUnit(SpeedUnit.YardPerMinute)); + unitConverter.SetConversionFunction(SpeedUnit.YardPerMinute, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Speed.ConversionBaseUnit, SpeedUnit.YardPerSecond, q => q.ToUnit(SpeedUnit.YardPerSecond)); + unitConverter.SetConversionFunction(SpeedUnit.YardPerSecond, Speed.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicFootPerHour, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicFootPerHour)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicFootPerHour, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicFootPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicFootPerMinute)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicFootPerMinute, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicFootPerSecond, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicFootPerSecond)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicFootPerSecond, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicMeterPerDay, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicMeterPerDay)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerDay, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicMeterPerHour, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicMeterPerHour)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerHour, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardCubicMeterPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardCubicMeterPerMinute)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerMinute, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlow.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(StandardVolumeFlow.ConversionBaseUnit, StandardVolumeFlowUnit.StandardLiterPerMinute, q => q.ToUnit(StandardVolumeFlowUnit.StandardLiterPerMinute)); + unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardLiterPerMinute, StandardVolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeCelsius, q => q.ToUnit(TemperatureUnit.DegreeCelsius)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeCelsius, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeDelisle, q => q.ToUnit(TemperatureUnit.DegreeDelisle)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeDelisle, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureUnit.DegreeFahrenheit)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeFahrenheit, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeNewton, q => q.ToUnit(TemperatureUnit.DegreeNewton)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeNewton, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeRankine, q => q.ToUnit(TemperatureUnit.DegreeRankine)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeRankine, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeReaumur, q => q.ToUnit(TemperatureUnit.DegreeReaumur)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeReaumur, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.DegreeRoemer, q => q.ToUnit(TemperatureUnit.DegreeRoemer)); + unitConverter.SetConversionFunction(TemperatureUnit.DegreeRoemer, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, Temperature.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureUnit.MillidegreeCelsius)); + unitConverter.SetConversionFunction(TemperatureUnit.MillidegreeCelsius, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Temperature.ConversionBaseUnit, TemperatureUnit.SolarTemperature, q => q.ToUnit(TemperatureUnit.SolarTemperature)); + unitConverter.SetConversionFunction(TemperatureUnit.SolarTemperature, Temperature.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.DegreeCelsiusPerMinute, q => q.ToUnit(TemperatureChangeRateUnit.DegreeCelsiusPerMinute)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerMinute, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRate.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureChangeRate.ConversionBaseUnit, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, q => q.ToUnit(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); + unitConverter.SetConversionFunction(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, TemperatureChangeRate.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.DegreeCelsius)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeCelsius, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeDelisle, q => q.ToUnit(TemperatureDeltaUnit.DegreeDelisle)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeDelisle, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeFahrenheit, q => q.ToUnit(TemperatureDeltaUnit.DegreeFahrenheit)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeFahrenheit, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeNewton, q => q.ToUnit(TemperatureDeltaUnit.DegreeNewton)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeNewton, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeRankine, q => q.ToUnit(TemperatureDeltaUnit.DegreeRankine)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeRankine, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeReaumur, q => q.ToUnit(TemperatureDeltaUnit.DegreeReaumur)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeReaumur, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.DegreeRoemer, q => q.ToUnit(TemperatureDeltaUnit.DegreeRoemer)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.DegreeRoemer, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDelta.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(TemperatureDelta.ConversionBaseUnit, TemperatureDeltaUnit.MillidegreeCelsius, q => q.ToUnit(TemperatureDeltaUnit.MillidegreeCelsius)); + unitConverter.SetConversionFunction(TemperatureDeltaUnit.MillidegreeCelsius, TemperatureDelta.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ThermalConductivity.ConversionBaseUnit, ThermalConductivityUnit.BtuPerHourFootFahrenheit, q => q.ToUnit(ThermalConductivityUnit.BtuPerHourFootFahrenheit)); + unitConverter.SetConversionFunction(ThermalConductivityUnit.BtuPerHourFootFahrenheit, ThermalConductivity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ThermalConductivity.ConversionBaseUnit, ThermalConductivity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(ThermalResistance.ConversionBaseUnit, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, q => q.ToUnit(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu)); + unitConverter.SetConversionFunction(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu, ThermalResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ThermalResistance.ConversionBaseUnit, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie)); + unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie, ThermalResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ThermalResistance.ConversionBaseUnit, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt)); + unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, ThermalResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ThermalResistance.ConversionBaseUnit, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, q => q.ToUnit(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt)); + unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, ThermalResistance.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(ThermalResistance.ConversionBaseUnit, ThermalResistance.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilogramForceCentimeter, q => q.ToUnit(TorqueUnit.KilogramForceCentimeter)); + unitConverter.SetConversionFunction(TorqueUnit.KilogramForceCentimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilogramForceMeter, q => q.ToUnit(TorqueUnit.KilogramForceMeter)); + unitConverter.SetConversionFunction(TorqueUnit.KilogramForceMeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilogramForceMillimeter, q => q.ToUnit(TorqueUnit.KilogramForceMillimeter)); + unitConverter.SetConversionFunction(TorqueUnit.KilogramForceMillimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilonewtonCentimeter, q => q.ToUnit(TorqueUnit.KilonewtonCentimeter)); + unitConverter.SetConversionFunction(TorqueUnit.KilonewtonCentimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilonewtonMeter, q => q.ToUnit(TorqueUnit.KilonewtonMeter)); + unitConverter.SetConversionFunction(TorqueUnit.KilonewtonMeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilonewtonMillimeter, q => q.ToUnit(TorqueUnit.KilonewtonMillimeter)); + unitConverter.SetConversionFunction(TorqueUnit.KilonewtonMillimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilopoundForceFoot, q => q.ToUnit(TorqueUnit.KilopoundForceFoot)); + unitConverter.SetConversionFunction(TorqueUnit.KilopoundForceFoot, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.KilopoundForceInch, q => q.ToUnit(TorqueUnit.KilopoundForceInch)); + unitConverter.SetConversionFunction(TorqueUnit.KilopoundForceInch, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.MeganewtonCentimeter, q => q.ToUnit(TorqueUnit.MeganewtonCentimeter)); + unitConverter.SetConversionFunction(TorqueUnit.MeganewtonCentimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.MeganewtonMeter, q => q.ToUnit(TorqueUnit.MeganewtonMeter)); + unitConverter.SetConversionFunction(TorqueUnit.MeganewtonMeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.MeganewtonMillimeter, q => q.ToUnit(TorqueUnit.MeganewtonMillimeter)); + unitConverter.SetConversionFunction(TorqueUnit.MeganewtonMillimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.MegapoundForceFoot, q => q.ToUnit(TorqueUnit.MegapoundForceFoot)); + unitConverter.SetConversionFunction(TorqueUnit.MegapoundForceFoot, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.MegapoundForceInch, q => q.ToUnit(TorqueUnit.MegapoundForceInch)); + unitConverter.SetConversionFunction(TorqueUnit.MegapoundForceInch, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.NewtonCentimeter, q => q.ToUnit(TorqueUnit.NewtonCentimeter)); + unitConverter.SetConversionFunction(TorqueUnit.NewtonCentimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, Torque.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.NewtonMillimeter, q => q.ToUnit(TorqueUnit.NewtonMillimeter)); + unitConverter.SetConversionFunction(TorqueUnit.NewtonMillimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.PoundalFoot, q => q.ToUnit(TorqueUnit.PoundalFoot)); + unitConverter.SetConversionFunction(TorqueUnit.PoundalFoot, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.PoundForceFoot, q => q.ToUnit(TorqueUnit.PoundForceFoot)); + unitConverter.SetConversionFunction(TorqueUnit.PoundForceFoot, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.PoundForceInch, q => q.ToUnit(TorqueUnit.PoundForceInch)); + unitConverter.SetConversionFunction(TorqueUnit.PoundForceInch, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.TonneForceCentimeter, q => q.ToUnit(TorqueUnit.TonneForceCentimeter)); + unitConverter.SetConversionFunction(TorqueUnit.TonneForceCentimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.TonneForceMeter, q => q.ToUnit(TorqueUnit.TonneForceMeter)); + unitConverter.SetConversionFunction(TorqueUnit.TonneForceMeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Torque.ConversionBaseUnit, TorqueUnit.TonneForceMillimeter, q => q.ToUnit(TorqueUnit.TonneForceMillimeter)); + unitConverter.SetConversionFunction(TorqueUnit.TonneForceMillimeter, Torque.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilogramForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceCentimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceCentimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilogramForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilogramForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilogramForceMillimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilogramForceMillimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilonewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonCentimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonCentimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilonewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilonewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.KilonewtonMillimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilonewtonMillimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilopoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceFootPerFoot)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceFootPerFoot, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.KilopoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.KilopoundForceInchPerFoot)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.KilopoundForceInchPerFoot, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.MeganewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonCentimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonCentimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.MeganewtonMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.MeganewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.MeganewtonMillimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.MeganewtonMillimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.MegapoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceFootPerFoot)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceFootPerFoot, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.MegapoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.MegapoundForceInchPerFoot)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.MegapoundForceInchPerFoot, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.NewtonCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonCentimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonCentimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLength.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.NewtonMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.NewtonMillimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMillimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.PoundForceFootPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceFootPerFoot)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceFootPerFoot, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.PoundForceInchPerFoot, q => q.ToUnit(TorquePerLengthUnit.PoundForceInchPerFoot)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.PoundForceInchPerFoot, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.TonneForceCentimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceCentimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceCentimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.TonneForceMeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(TorquePerLength.ConversionBaseUnit, TorquePerLengthUnit.TonneForceMillimeterPerMeter, q => q.ToUnit(TorquePerLengthUnit.TonneForceMillimeterPerMeter)); + unitConverter.SetConversionFunction(TorquePerLengthUnit.TonneForceMillimeterPerMeter, TorquePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Turbidity.ConversionBaseUnit, Turbidity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(VitaminA.ConversionBaseUnit, VitaminA.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.AcreFoot, q => q.ToUnit(VolumeUnit.AcreFoot)); + unitConverter.SetConversionFunction(VolumeUnit.AcreFoot, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.AuTablespoon, q => q.ToUnit(VolumeUnit.AuTablespoon)); + unitConverter.SetConversionFunction(VolumeUnit.AuTablespoon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.BoardFoot, q => q.ToUnit(VolumeUnit.BoardFoot)); + unitConverter.SetConversionFunction(VolumeUnit.BoardFoot, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Centiliter, q => q.ToUnit(VolumeUnit.Centiliter)); + unitConverter.SetConversionFunction(VolumeUnit.Centiliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicCentimeter, q => q.ToUnit(VolumeUnit.CubicCentimeter)); + unitConverter.SetConversionFunction(VolumeUnit.CubicCentimeter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicDecimeter, q => q.ToUnit(VolumeUnit.CubicDecimeter)); + unitConverter.SetConversionFunction(VolumeUnit.CubicDecimeter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicFoot, q => q.ToUnit(VolumeUnit.CubicFoot)); + unitConverter.SetConversionFunction(VolumeUnit.CubicFoot, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicHectometer, q => q.ToUnit(VolumeUnit.CubicHectometer)); + unitConverter.SetConversionFunction(VolumeUnit.CubicHectometer, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicInch, q => q.ToUnit(VolumeUnit.CubicInch)); + unitConverter.SetConversionFunction(VolumeUnit.CubicInch, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicKilometer, q => q.ToUnit(VolumeUnit.CubicKilometer)); + unitConverter.SetConversionFunction(VolumeUnit.CubicKilometer, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, Volume.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicMicrometer, q => q.ToUnit(VolumeUnit.CubicMicrometer)); + unitConverter.SetConversionFunction(VolumeUnit.CubicMicrometer, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicMile, q => q.ToUnit(VolumeUnit.CubicMile)); + unitConverter.SetConversionFunction(VolumeUnit.CubicMile, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicMillimeter, q => q.ToUnit(VolumeUnit.CubicMillimeter)); + unitConverter.SetConversionFunction(VolumeUnit.CubicMillimeter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.CubicYard, q => q.ToUnit(VolumeUnit.CubicYard)); + unitConverter.SetConversionFunction(VolumeUnit.CubicYard, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.DecausGallon, q => q.ToUnit(VolumeUnit.DecausGallon)); + unitConverter.SetConversionFunction(VolumeUnit.DecausGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Deciliter, q => q.ToUnit(VolumeUnit.Deciliter)); + unitConverter.SetConversionFunction(VolumeUnit.Deciliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.DeciusGallon, q => q.ToUnit(VolumeUnit.DeciusGallon)); + unitConverter.SetConversionFunction(VolumeUnit.DeciusGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.HectocubicFoot, q => q.ToUnit(VolumeUnit.HectocubicFoot)); + unitConverter.SetConversionFunction(VolumeUnit.HectocubicFoot, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.HectocubicMeter, q => q.ToUnit(VolumeUnit.HectocubicMeter)); + unitConverter.SetConversionFunction(VolumeUnit.HectocubicMeter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Hectoliter, q => q.ToUnit(VolumeUnit.Hectoliter)); + unitConverter.SetConversionFunction(VolumeUnit.Hectoliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.HectousGallon, q => q.ToUnit(VolumeUnit.HectousGallon)); + unitConverter.SetConversionFunction(VolumeUnit.HectousGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.ImperialBeerBarrel, q => q.ToUnit(VolumeUnit.ImperialBeerBarrel)); + unitConverter.SetConversionFunction(VolumeUnit.ImperialBeerBarrel, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.ImperialGallon, q => q.ToUnit(VolumeUnit.ImperialGallon)); + unitConverter.SetConversionFunction(VolumeUnit.ImperialGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.ImperialOunce, q => q.ToUnit(VolumeUnit.ImperialOunce)); + unitConverter.SetConversionFunction(VolumeUnit.ImperialOunce, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.ImperialPint, q => q.ToUnit(VolumeUnit.ImperialPint)); + unitConverter.SetConversionFunction(VolumeUnit.ImperialPint, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.KilocubicFoot, q => q.ToUnit(VolumeUnit.KilocubicFoot)); + unitConverter.SetConversionFunction(VolumeUnit.KilocubicFoot, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.KilocubicMeter, q => q.ToUnit(VolumeUnit.KilocubicMeter)); + unitConverter.SetConversionFunction(VolumeUnit.KilocubicMeter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.KiloimperialGallon, q => q.ToUnit(VolumeUnit.KiloimperialGallon)); + unitConverter.SetConversionFunction(VolumeUnit.KiloimperialGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Kiloliter, q => q.ToUnit(VolumeUnit.Kiloliter)); + unitConverter.SetConversionFunction(VolumeUnit.Kiloliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.KilousGallon, q => q.ToUnit(VolumeUnit.KilousGallon)); + unitConverter.SetConversionFunction(VolumeUnit.KilousGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Liter, q => q.ToUnit(VolumeUnit.Liter)); + unitConverter.SetConversionFunction(VolumeUnit.Liter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.MegacubicFoot, q => q.ToUnit(VolumeUnit.MegacubicFoot)); + unitConverter.SetConversionFunction(VolumeUnit.MegacubicFoot, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.MegaimperialGallon, q => q.ToUnit(VolumeUnit.MegaimperialGallon)); + unitConverter.SetConversionFunction(VolumeUnit.MegaimperialGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Megaliter, q => q.ToUnit(VolumeUnit.Megaliter)); + unitConverter.SetConversionFunction(VolumeUnit.Megaliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.MegausGallon, q => q.ToUnit(VolumeUnit.MegausGallon)); + unitConverter.SetConversionFunction(VolumeUnit.MegausGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.MetricCup, q => q.ToUnit(VolumeUnit.MetricCup)); + unitConverter.SetConversionFunction(VolumeUnit.MetricCup, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.MetricTeaspoon, q => q.ToUnit(VolumeUnit.MetricTeaspoon)); + unitConverter.SetConversionFunction(VolumeUnit.MetricTeaspoon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Microliter, q => q.ToUnit(VolumeUnit.Microliter)); + unitConverter.SetConversionFunction(VolumeUnit.Microliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.Milliliter, q => q.ToUnit(VolumeUnit.Milliliter)); + unitConverter.SetConversionFunction(VolumeUnit.Milliliter, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.OilBarrel, q => q.ToUnit(VolumeUnit.OilBarrel)); + unitConverter.SetConversionFunction(VolumeUnit.OilBarrel, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UkTablespoon, q => q.ToUnit(VolumeUnit.UkTablespoon)); + unitConverter.SetConversionFunction(VolumeUnit.UkTablespoon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsBeerBarrel, q => q.ToUnit(VolumeUnit.UsBeerBarrel)); + unitConverter.SetConversionFunction(VolumeUnit.UsBeerBarrel, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsCustomaryCup, q => q.ToUnit(VolumeUnit.UsCustomaryCup)); + unitConverter.SetConversionFunction(VolumeUnit.UsCustomaryCup, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsGallon, q => q.ToUnit(VolumeUnit.UsGallon)); + unitConverter.SetConversionFunction(VolumeUnit.UsGallon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsLegalCup, q => q.ToUnit(VolumeUnit.UsLegalCup)); + unitConverter.SetConversionFunction(VolumeUnit.UsLegalCup, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsOunce, q => q.ToUnit(VolumeUnit.UsOunce)); + unitConverter.SetConversionFunction(VolumeUnit.UsOunce, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsPint, q => q.ToUnit(VolumeUnit.UsPint)); + unitConverter.SetConversionFunction(VolumeUnit.UsPint, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsQuart, q => q.ToUnit(VolumeUnit.UsQuart)); + unitConverter.SetConversionFunction(VolumeUnit.UsQuart, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsTablespoon, q => q.ToUnit(VolumeUnit.UsTablespoon)); + unitConverter.SetConversionFunction(VolumeUnit.UsTablespoon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(Volume.ConversionBaseUnit, VolumeUnit.UsTeaspoon, q => q.ToUnit(VolumeUnit.UsTeaspoon)); + unitConverter.SetConversionFunction(VolumeUnit.UsTeaspoon, Volume.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.CentilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.CentilitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.CentilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.CentilitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.CentilitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.DecilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecilitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.DecilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.DecilitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecilitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentration.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.LitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.LitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.LitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.LitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.LitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.MicrolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.MicrolitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.MicrolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MicrolitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.MicrolitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.MillilitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.MillilitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.MillilitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.MillilitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.MillilitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.NanolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.NanolitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.NanolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.NanolitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.NanolitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.PartPerBillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerBillion)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerBillion, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.PartPerMillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerMillion)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerMillion, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.PartPerThousand, q => q.ToUnit(VolumeConcentrationUnit.PartPerThousand)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerThousand, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.PartPerTrillion, q => q.ToUnit(VolumeConcentrationUnit.PartPerTrillion)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.PartPerTrillion, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.Percent, q => q.ToUnit(VolumeConcentrationUnit.Percent)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.Percent, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.PicolitersPerLiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerLiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.PicolitersPerLiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeConcentration.ConversionBaseUnit, VolumeConcentrationUnit.PicolitersPerMililiter, q => q.ToUnit(VolumeConcentrationUnit.PicolitersPerMililiter)); + unitConverter.SetConversionFunction(VolumeConcentrationUnit.PicolitersPerMililiter, VolumeConcentration.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.AcreFootPerDay, q => q.ToUnit(VolumeFlowUnit.AcreFootPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.AcreFootPerHour, q => q.ToUnit(VolumeFlowUnit.AcreFootPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.AcreFootPerMinute, q => q.ToUnit(VolumeFlowUnit.AcreFootPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.AcreFootPerSecond, q => q.ToUnit(VolumeFlowUnit.AcreFootPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.AcreFootPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CentiliterPerDay, q => q.ToUnit(VolumeFlowUnit.CentiliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CentiliterPerMinute, q => q.ToUnit(VolumeFlowUnit.CentiliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CentiliterPerSecond, q => q.ToUnit(VolumeFlowUnit.CentiliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CentiliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicCentimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicCentimeterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicCentimeterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicDecimeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicDecimeterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicDecimeterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicFootPerHour, q => q.ToUnit(VolumeFlowUnit.CubicFootPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicFootPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicFootPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicFootPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicFootPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicFootPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicMeterPerDay, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicMeterPerHour, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicMeterPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicMeterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlow.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicMillimeterPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicMillimeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMillimeterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicYardPerDay, q => q.ToUnit(VolumeFlowUnit.CubicYardPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicYardPerHour, q => q.ToUnit(VolumeFlowUnit.CubicYardPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicYardPerMinute, q => q.ToUnit(VolumeFlowUnit.CubicYardPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.CubicYardPerSecond, q => q.ToUnit(VolumeFlowUnit.CubicYardPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicYardPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.DeciliterPerDay, q => q.ToUnit(VolumeFlowUnit.DeciliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.DeciliterPerMinute, q => q.ToUnit(VolumeFlowUnit.DeciliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.DeciliterPerSecond, q => q.ToUnit(VolumeFlowUnit.DeciliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.DeciliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.KiloliterPerDay, q => q.ToUnit(VolumeFlowUnit.KiloliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.KiloliterPerMinute, q => q.ToUnit(VolumeFlowUnit.KiloliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.KiloliterPerSecond, q => q.ToUnit(VolumeFlowUnit.KiloliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.KiloliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.KilousGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.KilousGallonPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.KilousGallonPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.LiterPerDay, q => q.ToUnit(VolumeFlowUnit.LiterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.LiterPerHour, q => q.ToUnit(VolumeFlowUnit.LiterPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.LiterPerMinute, q => q.ToUnit(VolumeFlowUnit.LiterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.LiterPerSecond, q => q.ToUnit(VolumeFlowUnit.LiterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.LiterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MegaliterPerDay, q => q.ToUnit(VolumeFlowUnit.MegaliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MegaliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MegaukGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.MegaukGallonPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MegaukGallonPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MicroliterPerDay, q => q.ToUnit(VolumeFlowUnit.MicroliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MicroliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MicroliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MicroliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MicroliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MicroliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MilliliterPerDay, q => q.ToUnit(VolumeFlowUnit.MilliliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MilliliterPerMinute, q => q.ToUnit(VolumeFlowUnit.MilliliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MilliliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MilliliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MillionUsGallonsPerDay, q => q.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonsPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.NanoliterPerDay, q => q.ToUnit(VolumeFlowUnit.NanoliterPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.NanoliterPerMinute, q => q.ToUnit(VolumeFlowUnit.NanoliterPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.NanoliterPerSecond, q => q.ToUnit(VolumeFlowUnit.NanoliterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.OilBarrelPerDay, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.OilBarrelPerHour, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.OilBarrelPerMinute, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.OilBarrelPerSecond, q => q.ToUnit(VolumeFlowUnit.OilBarrelPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.OilBarrelPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UkGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UkGallonPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UkGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UkGallonPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UkGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UkGallonPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UkGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UkGallonPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UkGallonPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UsGallonPerDay, q => q.ToUnit(VolumeFlowUnit.UsGallonPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UsGallonPerHour, q => q.ToUnit(VolumeFlowUnit.UsGallonPerHour)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerHour, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UsGallonPerMinute, q => q.ToUnit(VolumeFlowUnit.UsGallonPerMinute)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.UsGallonPerSecond, q => q.ToUnit(VolumeFlowUnit.UsGallonPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.UsGallonPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLength.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLengthUnit.CubicYardPerFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerFoot)); + unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicYardPerFoot, VolumePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLengthUnit.CubicYardPerUsSurveyFoot, q => q.ToUnit(VolumePerLengthUnit.CubicYardPerUsSurveyFoot)); + unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicYardPerUsSurveyFoot, VolumePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLengthUnit.LiterPerKilometer, q => q.ToUnit(VolumePerLengthUnit.LiterPerKilometer)); + unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerKilometer, VolumePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLengthUnit.LiterPerMeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMeter)); + unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerMeter, VolumePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLengthUnit.LiterPerMillimeter, q => q.ToUnit(VolumePerLengthUnit.LiterPerMillimeter)); + unitConverter.SetConversionFunction(VolumePerLengthUnit.LiterPerMillimeter, VolumePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumePerLength.ConversionBaseUnit, VolumePerLengthUnit.OilBarrelPerFoot, q => q.ToUnit(VolumePerLengthUnit.OilBarrelPerFoot)); + unitConverter.SetConversionFunction(VolumePerLengthUnit.OilBarrelPerFoot, VolumePerLength.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, q => q.ToUnit(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacity.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, q => q.ToUnit(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, q => q.ToUnit(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumetricHeatCapacity.ConversionBaseUnit, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, q => q.ToUnit(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin)); + unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, VolumetricHeatCapacity.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(WarpingMomentOfInertia.ConversionBaseUnit, WarpingMomentOfInertiaUnit.CentimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.CentimeterToTheSixth)); + unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.CentimeterToTheSixth, WarpingMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(WarpingMomentOfInertia.ConversionBaseUnit, WarpingMomentOfInertiaUnit.DecimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.DecimeterToTheSixth)); + unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.DecimeterToTheSixth, WarpingMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(WarpingMomentOfInertia.ConversionBaseUnit, WarpingMomentOfInertiaUnit.FootToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.FootToTheSixth)); + unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.FootToTheSixth, WarpingMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(WarpingMomentOfInertia.ConversionBaseUnit, WarpingMomentOfInertiaUnit.InchToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.InchToTheSixth)); + unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.InchToTheSixth, WarpingMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(WarpingMomentOfInertia.ConversionBaseUnit, WarpingMomentOfInertia.ConversionBaseUnit, q => q); + unitConverter.SetConversionFunction(WarpingMomentOfInertia.ConversionBaseUnit, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, q => q.ToUnit(WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); + unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, WarpingMomentOfInertia.ConversionBaseUnit, q => q.ToBaseUnit()); } } } diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 9146fe083a..3d30f9b6b2 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -46,7 +46,7 @@ public interface IQuantity : IFormattable double As(UnitSystem unitSystem); /// - /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. + /// The unit this quantity was constructed with -or- ConversionBaseUnit if default ctor was used. /// Enum Unit { get; } diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index 974edca7a9..8a36283334 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -77,7 +77,7 @@ public QuantityInfo([NotNull] string name, Type unitType, [NotNull] UnitInfo[] u // Obsolete members UnitNames = UnitInfos.Select( unitInfo => unitInfo.Name ).ToArray(); Units = UnitInfos.Select( unitInfo => unitInfo.Value ).ToArray(); - BaseUnit = BaseUnitInfo.Value; + ConversionBaseUnit = BaseUnitInfo.Value; QuantityType = quantityType; } @@ -119,7 +119,7 @@ public QuantityInfo([NotNull] string name, Type unitType, [NotNull] UnitInfo[] u /// The base unit for the quantity, such as . /// [Obsolete("This property is deprecated and will be removed at a future release. Please use the BaseUnitInfo property.")] - public Enum BaseUnit { get; } + public Enum ConversionBaseUnit { get; } /// /// Zero value of quantity, such as . @@ -213,7 +213,7 @@ public QuantityInfo(string name, UnitInfo[] unitInfos, TUnit baseUnit, IQ // Obsolete members Units = UnitInfos.Select(unitInfo => unitInfo.Value).ToArray(); - BaseUnit = BaseUnitInfo.Value; + ConversionBaseUnit = BaseUnitInfo.Value; } /// @@ -226,9 +226,9 @@ public QuantityInfo(string name, UnitInfo[] unitInfos, TUnit baseUnit, IQ /// public new UnitInfo BaseUnitInfo { get; } - /// + /// [Obsolete("This property is deprecated and will be removed at a future release. Please use the BaseUnitInfo property.")] - public new TUnit BaseUnit { get; } + public new TUnit ConversionBaseUnit { get; } /// public new IQuantity Zero { get; } diff --git a/UnitsNet/Scripts/Include-GenerateUnitConverterDefaultSourceCode.ps1 b/UnitsNet/Scripts/Include-GenerateUnitConverterDefaultSourceCode.ps1 deleted file mode 100644 index a501d34500..0000000000 --- a/UnitsNet/Scripts/Include-GenerateUnitConverterDefaultSourceCode.ps1 +++ /dev/null @@ -1,52 +0,0 @@ -function GenerateUnitConverterDefaultSourceCode($quantities) -{ -@" -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using UnitsNet.Units; - -// ReSharper disable RedundantCommaInArrayInitializer -// ReSharper disable once CheckNamespace - -namespace UnitsNet -{ - public sealed partial class UnitConverter - { - /// - /// Registers the default conversion functions in the given instance. - /// - /// The to register the default conversion functions in. - public static void RegisterDefaultConversions(UnitConverter unitConverter) - { -"@; -foreach ($quantity in $quantities) -{ - $quantityName = $quantity.Name; - $unitEnumName = "$quantityName" + "Unit"; - - foreach ($unit in $quantity.Units) - { - $enumValue = $unit.SingularName; - - if( $quantity.BaseUnit -eq $enumValue ) - { -@" - unitConverter.SetConversionFunction<$quantityName>($quantityName.BaseUnit, $quantityName.BaseUnit, q => q); -"@; - } - else - { -@" - unitConverter.SetConversionFunction<$quantityName>($quantityName.BaseUnit, $unitEnumName.$enumValue, q => q.ToUnit($unitEnumName.$enumValue)); - unitConverter.SetConversionFunction<$quantityName>($unitEnumName.$enumValue, $quantityName.BaseUnit, q => q.ToBaseUnit()); -"@; - } - } -} -@" - } - } -} -"@; -} From b5e02691ea9f618030881f88f2da0caef28179c2 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:09:21 +0100 Subject: [PATCH 09/66] Fix deploying nugets on release/support branches --- appveyor.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 731a9d66b2..7793c940b9 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -70,15 +70,15 @@ artifacts: - path: 'Artifacts\NuGet\*.nupkg' # find all NuGet packages recursively - path: Artifacts\Coverage -deploy: -- provider: NuGet - api_key: - secure: wUADhxnlTxLj2ge4k459gEuu6tLtVBD1lN2MacpH1glEvA2LKyM2QbJYKlNTu6vg - on: - branch: master - -- provider: NuGet - api_key: - secure: wUADhxnlTxLj2ge4k459gEuu6tLtVBD1lN2MacpH1glEvA2LKyM2QbJYKlNTu6vg - on: - branch: release/* +for: + - + branches: + only: + - master + - /release\/.+/ + - /support\/.+/ + + deploy: + - provider: NuGet + api_key: + secure: wUADhxnlTxLj2ge4k459gEuu6tLtVBD1lN2MacpH1glEvA2LKyM2QbJYKlNTu6vg From 35d383eeea3b5711a45daccf3149938720e169a8 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:10:36 +0100 Subject: [PATCH 10/66] Whitespace fixes --- CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs | 2 -- CodeGen/Generators/NanoFrameworkGenerator.cs | 3 +-- .../UnitsNetGen/NumberExtensionsTestClassGenerator.cs | 1 - .../Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs | 3 --- README.md | 5 ----- .../GeneratedCode/Quantities/Acceleration.g.cs | 4 +--- .../GeneratedCode/Quantities/AmountOfSubstance.g.cs | 4 +--- .../GeneratedCode/Quantities/AmplitudeRatio.g.cs | 4 +--- .../GeneratedCode/Quantities/Angle.g.cs | 4 +--- .../GeneratedCode/Quantities/ApparentEnergy.g.cs | 4 +--- .../GeneratedCode/Quantities/ApparentPower.g.cs | 4 +--- .../GeneratedCode/Quantities/Area.g.cs | 4 +--- .../GeneratedCode/Quantities/AreaDensity.g.cs | 4 +--- .../GeneratedCode/Quantities/AreaMomentOfInertia.g.cs | 4 +--- .../GeneratedCode/Quantities/BitRate.g.cs | 4 +--- .../Quantities/BrakeSpecificFuelConsumption.g.cs | 4 +--- .../GeneratedCode/Quantities/Capacitance.g.cs | 4 +--- .../Quantities/CoefficientOfThermalExpansion.g.cs | 4 +--- .../GeneratedCode/Quantities/Density.g.cs | 4 +--- .../GeneratedCode/Quantities/Duration.g.cs | 4 +--- .../GeneratedCode/Quantities/DynamicViscosity.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricAdmittance.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricCharge.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricChargeDensity.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricConductance.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricConductivity.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricCurrent.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricCurrentDensity.g.cs | 4 +--- .../Quantities/ElectricCurrentGradient.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricField.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricInductance.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricPotential.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricPotentialAc.g.cs | 4 +--- .../Quantities/ElectricPotentialChangeRate.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricPotentialDc.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricResistance.g.cs | 4 +--- .../GeneratedCode/Quantities/ElectricResistivity.g.cs | 4 +--- .../Quantities/ElectricSurfaceChargeDensity.g.cs | 4 +--- .../GeneratedCode/Quantities/Energy.g.cs | 4 +--- .../GeneratedCode/Quantities/Entropy.g.cs | 4 +--- .../GeneratedCode/Quantities/Force.g.cs | 4 +--- .../GeneratedCode/Quantities/ForceChangeRate.g.cs | 4 +--- .../GeneratedCode/Quantities/ForcePerLength.g.cs | 4 +--- .../GeneratedCode/Quantities/Frequency.g.cs | 4 +--- .../GeneratedCode/Quantities/FuelEfficiency.g.cs | 4 +--- .../GeneratedCode/Quantities/HeatFlux.g.cs | 4 +--- .../Quantities/HeatTransferCoefficient.g.cs | 4 +--- .../GeneratedCode/Quantities/Illuminance.g.cs | 4 +--- .../GeneratedCode/Quantities/Information.g.cs | 4 +--- .../GeneratedCode/Quantities/Irradiance.g.cs | 4 +--- .../GeneratedCode/Quantities/Irradiation.g.cs | 4 +--- .../GeneratedCode/Quantities/KinematicViscosity.g.cs | 4 +--- .../GeneratedCode/Quantities/LapseRate.g.cs | 4 +--- .../GeneratedCode/Quantities/Length.g.cs | 4 +--- .../GeneratedCode/Quantities/Level.g.cs | 4 +--- .../GeneratedCode/Quantities/LinearDensity.g.cs | 4 +--- .../GeneratedCode/Quantities/LinearPowerDensity.g.cs | 4 +--- .../GeneratedCode/Quantities/Luminosity.g.cs | 4 +--- .../GeneratedCode/Quantities/LuminousFlux.g.cs | 4 +--- .../GeneratedCode/Quantities/LuminousIntensity.g.cs | 4 +--- .../GeneratedCode/Quantities/MagneticField.g.cs | 4 +--- .../GeneratedCode/Quantities/MagneticFlux.g.cs | 4 +--- .../GeneratedCode/Quantities/Magnetization.g.cs | 4 +--- .../GeneratedCode/Quantities/Mass.g.cs | 4 +--- .../GeneratedCode/Quantities/MassConcentration.g.cs | 4 +--- .../GeneratedCode/Quantities/MassFlow.g.cs | 4 +--- .../GeneratedCode/Quantities/MassFlux.g.cs | 4 +--- .../GeneratedCode/Quantities/MassFraction.g.cs | 4 +--- .../GeneratedCode/Quantities/MassMomentOfInertia.g.cs | 4 +--- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 4 +--- .../GeneratedCode/Quantities/MolarEntropy.g.cs | 4 +--- .../GeneratedCode/Quantities/MolarMass.g.cs | 4 +--- .../GeneratedCode/Quantities/Molarity.g.cs | 4 +--- .../GeneratedCode/Quantities/Permeability.g.cs | 4 +--- .../GeneratedCode/Quantities/Permittivity.g.cs | 4 +--- .../GeneratedCode/Quantities/Power.g.cs | 4 +--- .../GeneratedCode/Quantities/PowerDensity.g.cs | 4 +--- .../GeneratedCode/Quantities/PowerRatio.g.cs | 4 +--- .../GeneratedCode/Quantities/Pressure.g.cs | 4 +--- .../GeneratedCode/Quantities/PressureChangeRate.g.cs | 4 +--- .../GeneratedCode/Quantities/Ratio.g.cs | 4 +--- .../GeneratedCode/Quantities/RatioChangeRate.g.cs | 4 +--- .../GeneratedCode/Quantities/ReactiveEnergy.g.cs | 4 +--- .../GeneratedCode/Quantities/ReactivePower.g.cs | 4 +--- .../GeneratedCode/Quantities/ReciprocalArea.g.cs | 4 +--- .../GeneratedCode/Quantities/ReciprocalLength.g.cs | 4 +--- .../GeneratedCode/Quantities/RelativeHumidity.g.cs | 4 +--- .../GeneratedCode/Quantities/RotationalAcceleration.g.cs | 4 +--- .../GeneratedCode/Quantities/RotationalSpeed.g.cs | 4 +--- .../GeneratedCode/Quantities/RotationalStiffness.g.cs | 4 +--- .../Quantities/RotationalStiffnessPerLength.g.cs | 4 +--- .../GeneratedCode/Quantities/Scalar.g.cs | 4 +--- .../GeneratedCode/Quantities/SolidAngle.g.cs | 4 +--- .../GeneratedCode/Quantities/SpecificEnergy.g.cs | 4 +--- .../GeneratedCode/Quantities/SpecificEntropy.g.cs | 4 +--- .../Quantities/SpecificFuelConsumption.g.cs | 4 +--- .../GeneratedCode/Quantities/SpecificVolume.g.cs | 4 +--- .../GeneratedCode/Quantities/SpecificWeight.g.cs | 4 +--- .../GeneratedCode/Quantities/Speed.g.cs | 4 +--- .../GeneratedCode/Quantities/StandardVolumeFlow.g.cs | 4 +--- .../GeneratedCode/Quantities/Temperature.g.cs | 4 +--- .../GeneratedCode/Quantities/TemperatureChangeRate.g.cs | 4 +--- .../GeneratedCode/Quantities/TemperatureDelta.g.cs | 4 +--- .../GeneratedCode/Quantities/ThermalConductivity.g.cs | 4 +--- .../GeneratedCode/Quantities/ThermalResistance.g.cs | 4 +--- .../GeneratedCode/Quantities/Torque.g.cs | 4 +--- .../GeneratedCode/Quantities/TorquePerLength.g.cs | 4 +--- .../GeneratedCode/Quantities/Turbidity.g.cs | 4 +--- .../GeneratedCode/Quantities/VitaminA.g.cs | 4 +--- .../GeneratedCode/Quantities/Volume.g.cs | 4 +--- .../GeneratedCode/Quantities/VolumeConcentration.g.cs | 4 +--- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 4 +--- .../GeneratedCode/Quantities/VolumePerLength.g.cs | 4 +--- .../GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs | 4 +--- .../GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs | 4 +--- .../UnitsNetBaseJsonConverterTest.cs | 2 -- UnitsNet.Tests/CustomCode/ElectricResistanceTests.cs | 1 - UnitsNet.Tests/CustomCode/MassConcentrationTests.cs | 1 - UnitsNet.Tests/CustomCode/MassFlowTests.cs | 1 - UnitsNet.Tests/CustomCode/MassFluxTests.cs | 1 - UnitsNet.Tests/CustomCode/ReciprocalAreaTests.cs | 1 - UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs | 1 - UnitsNet.Tests/CustomCode/TemperatureTests.cs | 2 -- .../GeneratedCode/TestsBase/AccelerationTestsBase.g.cs | 3 --- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/AngleTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs | 3 --- .../TestsBase/AreaMomentOfInertiaTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/AreaTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/BitRateTestsBase.g.cs | 3 --- .../TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs | 3 --- .../CoefficientOfThermalExpansionTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/DensityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/DurationTestsBase.g.cs | 3 --- .../TestsBase/DynamicViscosityTestsBase.g.cs | 3 --- .../TestsBase/ElectricAdmittanceTestsBase.g.cs | 3 --- .../TestsBase/ElectricChargeDensityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs | 3 --- .../TestsBase/ElectricConductanceTestsBase.g.cs | 3 --- .../TestsBase/ElectricConductivityTestsBase.g.cs | 3 --- .../TestsBase/ElectricCurrentDensityTestsBase.g.cs | 3 --- .../TestsBase/ElectricCurrentGradientTestsBase.g.cs | 3 --- .../TestsBase/ElectricCurrentTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs | 3 --- .../TestsBase/ElectricInductanceTestsBase.g.cs | 3 --- .../TestsBase/ElectricPotentialAcTestsBase.g.cs | 3 --- .../TestsBase/ElectricPotentialChangeRateTestsBase.g.cs | 3 --- .../TestsBase/ElectricPotentialDcTestsBase.g.cs | 3 --- .../TestsBase/ElectricPotentialTestsBase.g.cs | 3 --- .../TestsBase/ElectricResistanceTestsBase.g.cs | 3 --- .../TestsBase/ElectricResistivityTestsBase.g.cs | 3 --- .../TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/EnergyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/EntropyTestsBase.g.cs | 3 --- .../TestsBase/ForceChangeRateTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ForceTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/FrequencyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs | 3 --- .../TestsBase/HeatTransferCoefficientTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/InformationTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/IrradianceTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/IrradiationTestsBase.g.cs | 3 --- .../TestsBase/KinematicViscosityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/LapseRateTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/LengthTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/LevelTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs | 3 --- .../TestsBase/LinearPowerDensityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/LuminosityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs | 3 --- .../TestsBase/LuminousIntensityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs | 3 --- .../TestsBase/MassConcentrationTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MassFlowTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MassFluxTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MassFractionTestsBase.g.cs | 3 --- .../TestsBase/MassMomentOfInertiaTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MassTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MolarMassTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/MolarityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/PermittivityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/PowerTestsBase.g.cs | 3 --- .../TestsBase/PressureChangeRateTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/PressureTestsBase.g.cs | 3 --- .../TestsBase/RatioChangeRateTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/RatioTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs | 3 --- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 3 --- .../TestsBase/RelativeHumidityTestsBase.g.cs | 3 --- .../TestsBase/RotationalAccelerationTestsBase.g.cs | 3 --- .../TestsBase/RotationalSpeedTestsBase.g.cs | 3 --- .../TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs | 3 --- .../TestsBase/RotationalStiffnessTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/ScalarTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs | 3 --- .../TestsBase/SpecificEntropyTestsBase.g.cs | 3 --- .../TestsBase/SpecificFuelConsumptionTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/SpeedTestsBase.g.cs | 3 --- .../TestsBase/StandardVolumeFlowTestsBase.g.cs | 3 --- .../TestsBase/TemperatureChangeRateTestsBase.g.cs | 3 --- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/TemperatureTestsBase.g.cs | 3 --- .../TestsBase/ThermalConductivityTestsBase.g.cs | 3 --- .../TestsBase/ThermalResistanceTestsBase.g.cs | 3 --- .../TestsBase/TorquePerLengthTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/TorqueTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/TurbidityTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/VitaminATestsBase.g.cs | 3 --- .../TestsBase/VolumeConcentrationTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs | 3 --- .../TestsBase/VolumePerLengthTestsBase.g.cs | 3 --- .../GeneratedCode/TestsBase/VolumeTestsBase.g.cs | 3 --- .../TestsBase/VolumetricHeatCapacityTestsBase.g.cs | 3 --- .../TestsBase/WarpingMomentOfInertiaTestsBase.g.cs | 3 --- UnitsNet.Tests/QuantityInfoTest.cs | 1 - .../CustomCode/Quantities/AmountOfSubstance.extra.cs | 9 ++++----- .../CustomCode/Quantities/MassConcentration.extra.cs | 5 ++--- UnitsNet/CustomCode/Quantities/Temperature.extra.cs | 1 - .../CustomCode/Quantities/VolumeConcentration.extra.cs | 5 ++--- UnitsNet/GeneratedCode/Quantities/Molarity.g.cs | 2 +- 239 files changed, 120 insertions(+), 697 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 9e214485f6..4982d93680 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -191,12 +191,10 @@ private void GenerateConversionMethods() /// A Duration with the specified unit. public {_quantity.Name} ToUnit({_unitEnumName} unit) {{ - var convertedValue = GetValueAs(unit); return new {_quantity.Name}(convertedValue, unit); }} - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/CodeGen/Generators/NanoFrameworkGenerator.cs b/CodeGen/Generators/NanoFrameworkGenerator.cs index 79fd51a35c..aee22c9a2e 100644 --- a/CodeGen/Generators/NanoFrameworkGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGenerator.cs @@ -333,8 +333,7 @@ private static string GeneratePackageConfigFile( "); - - if (NanoFrameworkGenerator.ProjectsRequiringMath.Contains(quantityName)) + if (ProjectsRequiringMath.Contains(quantityName)) { writer.WL($@" "); diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs index c7cb27ec06..eba484b31e 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs @@ -16,7 +16,6 @@ public NumberExtensionsTestClassGenerator(Quantity quantity) _quantityName = quantity.Name; } - public override string Generate() { Writer.WL(GeneratedFileHeader); diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index d292a6d908..0d03528d46 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -121,7 +121,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Writer.WL($@" Assert.Equal({_baseUnitFullName}, quantity.Unit); }} - "); if (_quantity.ValueType == "double") Writer.WL($@" [Fact] @@ -523,7 +522,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal(""0.1235{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s4"", culture)); }} - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() {{ @@ -545,7 +543,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, ""g""), quantity.ToString(null, ""g"")); }} - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() {{ diff --git a/README.md b/README.md index d044960b2a..cc49212b62 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,6 @@ Add strongly typed quantities to your code and get merrily on with your life. No more magic constants found on Stack Overflow, no more second-guessing the unit of parameters and variables. - ### Overview * [How to install](#how-to-install) @@ -36,7 +35,6 @@ Run the following command in the [Package Manager Console](http://docs.nuget.org ![Install-Package UnitsNet](https://raw.githubusercontent.com/angularsen/UnitsNet/master/Docs/Images/install_package_unitsnet.png "Install-Package UnitsNet") - #### Build Targets * .NET Standard 2.0 @@ -257,7 +255,6 @@ Console.WriteLine(Convert(HowMuchUnit.Tons)); // 10 tns ![image](https://user-images.githubusercontent.com/787816/34920961-9b697004-f97b-11e7-9e9a-51ff7142969b.png) - This example shows how you can create a dynamic unit converter, where the user selects the quantity to convert, such as `Temperature`, then selects to convert from `DegreeCelsius` to `DegreeFahrenheit` and types in a numeric value for how many degrees Celsius to convert. The quantity list box contains `QuantityType` values such as `QuantityType.Length` and the two unit list boxes contain `Enum` values, such as `LengthUnit.Meter`. @@ -309,7 +306,6 @@ The tests accept an error up to 1E-5 for most units added so far. Exceptions inc For more details, see [Precision](https://github.com/angularsen/UnitsNet/wiki/Precision). - ### Serialization * `UnitsNet.Serialization.JsonNet` ([nuget](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet), [src](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet), [tests](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet.Tests)) for JSON.NET @@ -345,7 +341,6 @@ We cannot guarantee backwards compatibility, although we will strive to do that The base unit of any unit should be treated as volatile as we have changed this several times in the history of this library already. Either to reduce precision errors of common units or to simplify code generation. An example is Mass, where the base unit was first Kilogram as this is the SI unit of mass, but in order to use powershell scripts to generate milligrams, nanograms etc. it was easier to choose Gram as the base unit of Mass. - ### Want To Contribute? This project is still early and many units and conversions are not yet covered. If you are missing something, please help by contributing or [ask for it](https://github.com/angularsen/UnitsNet/issues) by creating an issue. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs index 5258cc7cac..24fba27aff 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs @@ -255,7 +255,7 @@ public static Acceleration From(double value, AccelerationUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AccelerationUnit unit) => GetValueAs(unit); + public double As(AccelerationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -263,12 +263,10 @@ public static Acceleration From(double value, AccelerationUnit fromUnit) /// A Duration with the specified unit. public Acceleration ToUnit(AccelerationUnit unit) { - var convertedValue = GetValueAs(unit); return new Acceleration(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 83cd813294..e8d5316bbe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -266,7 +266,7 @@ public static AmountOfSubstance From(double value, AmountOfSubstanceUnit fromUni /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmountOfSubstanceUnit unit) => GetValueAs(unit); + public double As(AmountOfSubstanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -274,12 +274,10 @@ public static AmountOfSubstance From(double value, AmountOfSubstanceUnit fromUni /// A Duration with the specified unit. public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit) { - var convertedValue = GetValueAs(unit); return new AmountOfSubstance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 8af7867eca..542157716d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -145,7 +145,7 @@ public static AmplitudeRatio From(double value, AmplitudeRatioUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmplitudeRatioUnit unit) => GetValueAs(unit); + public double As(AmplitudeRatioUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static AmplitudeRatio From(double value, AmplitudeRatioUnit fromUnit) /// A Duration with the specified unit. public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit) { - var convertedValue = GetValueAs(unit); return new AmplitudeRatio(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs index 978ae8d319..5f424d72b9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs @@ -277,7 +277,7 @@ public static Angle From(double value, AngleUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AngleUnit unit) => GetValueAs(unit); + public double As(AngleUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -285,12 +285,10 @@ public static Angle From(double value, AngleUnit fromUnit) /// A Duration with the specified unit. public Angle ToUnit(AngleUnit unit) { - var convertedValue = GetValueAs(unit); return new Angle(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs index 28a26812a7..83876b1d1f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -134,7 +134,7 @@ public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentEnergyUnit unit) => GetValueAs(unit); + public double As(ApparentEnergyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static ApparentEnergy From(double value, ApparentEnergyUnit fromUnit) /// A Duration with the specified unit. public ApparentEnergy ToUnit(ApparentEnergyUnit unit) { - var convertedValue = GetValueAs(unit); return new ApparentEnergy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs index fe871f440f..d0c726813c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs @@ -145,7 +145,7 @@ public static ApparentPower From(double value, ApparentPowerUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentPowerUnit unit) => GetValueAs(unit); + public double As(ApparentPowerUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static ApparentPower From(double value, ApparentPowerUnit fromUnit) /// A Duration with the specified unit. public ApparentPower ToUnit(ApparentPowerUnit unit) { - var convertedValue = GetValueAs(unit); return new ApparentPower(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs index eda05cb22f..1b7ff64e3e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs @@ -255,7 +255,7 @@ public static Area From(double value, AreaUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaUnit unit) => GetValueAs(unit); + public double As(AreaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -263,12 +263,10 @@ public static Area From(double value, AreaUnit fromUnit) /// A Duration with the specified unit. public Area ToUnit(AreaUnit unit) { - var convertedValue = GetValueAs(unit); return new Area(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index 247ebc0457..c46ad04edf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -112,7 +112,7 @@ public static AreaDensity From(double value, AreaDensityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaDensityUnit unit) => GetValueAs(unit); + public double As(AreaDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -120,12 +120,10 @@ public static AreaDensity From(double value, AreaDensityUnit fromUnit) /// A Duration with the specified unit. public AreaDensity ToUnit(AreaDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new AreaDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index d6602c07bd..2a20928c79 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -167,7 +167,7 @@ public static AreaMomentOfInertia From(double value, AreaMomentOfInertiaUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaMomentOfInertiaUnit unit) => GetValueAs(unit); + public double As(AreaMomentOfInertiaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -175,12 +175,10 @@ public static AreaMomentOfInertia From(double value, AreaMomentOfInertiaUnit fro /// A Duration with the specified unit. public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit) { - var convertedValue = GetValueAs(unit); return new AreaMomentOfInertia(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs index 6f063bb6e3..e28a03eff5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs @@ -390,7 +390,7 @@ public static BitRate From(double value, BitRateUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BitRateUnit unit) => GetValueAs(unit); + public double As(BitRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -398,12 +398,10 @@ public static BitRate From(double value, BitRateUnit fromUnit) /// A Duration with the specified unit. public BitRate ToUnit(BitRateUnit unit) { - var convertedValue = GetValueAs(unit); return new BitRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index d418a889a1..e0ccfe50ed 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -134,7 +134,7 @@ public static BrakeSpecificFuelConsumption From(double value, BrakeSpecificFuelC /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BrakeSpecificFuelConsumptionUnit unit) => GetValueAs(unit); + public double As(BrakeSpecificFuelConsumptionUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static BrakeSpecificFuelConsumption From(double value, BrakeSpecificFuelC /// A Duration with the specified unit. public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit) { - var convertedValue = GetValueAs(unit); return new BrakeSpecificFuelConsumption(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs index 5732eaddfe..ba329c5e57 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs @@ -181,7 +181,7 @@ public static Capacitance From(double value, CapacitanceUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CapacitanceUnit unit) => GetValueAs(unit); + public double As(CapacitanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -189,12 +189,10 @@ public static Capacitance From(double value, CapacitanceUnit fromUnit) /// A Duration with the specified unit. public Capacitance ToUnit(CapacitanceUnit unit) { - var convertedValue = GetValueAs(unit); return new Capacitance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 654fdacd28..a4f787f3b8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -134,7 +134,7 @@ public static CoefficientOfThermalExpansion From(double value, CoefficientOfTher /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CoefficientOfThermalExpansionUnit unit) => GetValueAs(unit); + public double As(CoefficientOfThermalExpansionUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static CoefficientOfThermalExpansion From(double value, CoefficientOfTher /// A Duration with the specified unit. public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit unit) { - var convertedValue = GetValueAs(unit); return new CoefficientOfThermalExpansion(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs index 07e218b296..8fc942a6c0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs @@ -544,7 +544,7 @@ public static Density From(double value, DensityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DensityUnit unit) => GetValueAs(unit); + public double As(DensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -552,12 +552,10 @@ public static Density From(double value, DensityUnit fromUnit) /// A Duration with the specified unit. public Density ToUnit(DensityUnit unit) { - var convertedValue = GetValueAs(unit); return new Density(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs index 4604bb810a..a0babef352 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs @@ -211,7 +211,7 @@ public static Duration From(double value, DurationUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DurationUnit unit) => GetValueAs(unit); + public double As(DurationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -219,12 +219,10 @@ public static Duration From(double value, DurationUnit fromUnit) /// A Duration with the specified unit. public Duration ToUnit(DurationUnit unit) { - var convertedValue = GetValueAs(unit); return new Duration(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs index a5dc5f995a..1f23e8cb52 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -214,7 +214,7 @@ public static DynamicViscosity From(double value, DynamicViscosityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DynamicViscosityUnit unit) => GetValueAs(unit); + public double As(DynamicViscosityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -222,12 +222,10 @@ public static DynamicViscosity From(double value, DynamicViscosityUnit fromUnit) /// A Duration with the specified unit. public DynamicViscosity ToUnit(DynamicViscosityUnit unit) { - var convertedValue = GetValueAs(unit); return new DynamicViscosity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 2544164f04..bf81230351 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -145,7 +145,7 @@ public static ElectricAdmittance From(double value, ElectricAdmittanceUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricAdmittanceUnit unit) => GetValueAs(unit); + public double As(ElectricAdmittanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static ElectricAdmittance From(double value, ElectricAdmittanceUnit fromU /// A Duration with the specified unit. public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricAdmittance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs index 0bf3feb8cd..5964b55fb4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -159,7 +159,7 @@ public static ElectricCharge From(double value, ElectricChargeUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeUnit unit) => GetValueAs(unit); + public double As(ElectricChargeUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -167,12 +167,10 @@ public static ElectricCharge From(double value, ElectricChargeUnit fromUnit) /// A Duration with the specified unit. public ElectricCharge ToUnit(ElectricChargeUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricCharge(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index b0b634509c..1adb4bf3e7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -115,7 +115,7 @@ public static ElectricChargeDensity From(double value, ElectricChargeDensityUnit /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeDensityUnit unit) => GetValueAs(unit); + public double As(ElectricChargeDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static ElectricChargeDensity From(double value, ElectricChargeDensityUnit /// A Duration with the specified unit. public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricChargeDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs index 13d7df6934..fdadeb0eac 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -137,7 +137,7 @@ public static ElectricConductance From(double value, ElectricConductanceUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductanceUnit unit) => GetValueAs(unit); + public double As(ElectricConductanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -145,12 +145,10 @@ public static ElectricConductance From(double value, ElectricConductanceUnit fro /// A Duration with the specified unit. public ElectricConductance ToUnit(ElectricConductanceUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricConductance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs index 246e2e726b..7561614880 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -137,7 +137,7 @@ public static ElectricConductivity From(double value, ElectricConductivityUnit f /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductivityUnit unit) => GetValueAs(unit); + public double As(ElectricConductivityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -145,12 +145,10 @@ public static ElectricConductivity From(double value, ElectricConductivityUnit f /// A Duration with the specified unit. public ElectricConductivity ToUnit(ElectricConductivityUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricConductivity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs index 5d0ea253cc..ae17ce22e3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -189,7 +189,7 @@ public static ElectricCurrent From(double value, ElectricCurrentUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentUnit unit) => GetValueAs(unit); + public double As(ElectricCurrentUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -197,12 +197,10 @@ public static ElectricCurrent From(double value, ElectricCurrentUnit fromUnit) /// A Duration with the specified unit. public ElectricCurrent ToUnit(ElectricCurrentUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricCurrent(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 5181531e61..efceeb3627 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -137,7 +137,7 @@ public static ElectricCurrentDensity From(double value, ElectricCurrentDensityUn /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentDensityUnit unit) => GetValueAs(unit); + public double As(ElectricCurrentDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -145,12 +145,10 @@ public static ElectricCurrentDensity From(double value, ElectricCurrentDensityUn /// A Duration with the specified unit. public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricCurrentDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index b8d3a6ceb6..4817effa45 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -145,7 +145,7 @@ public static ElectricCurrentGradient From(double value, ElectricCurrentGradient /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentGradientUnit unit) => GetValueAs(unit); + public double As(ElectricCurrentGradientUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static ElectricCurrentGradient From(double value, ElectricCurrentGradient /// A Duration with the specified unit. public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricCurrentGradient(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs index a5b395d4e6..ea62a800f6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs @@ -115,7 +115,7 @@ public static ElectricField From(double value, ElectricFieldUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricFieldUnit unit) => GetValueAs(unit); + public double As(ElectricFieldUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static ElectricField From(double value, ElectricFieldUnit fromUnit) /// A Duration with the specified unit. public ElectricField ToUnit(ElectricFieldUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricField(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs index 207fc21a5c..1afd8ccb9b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -148,7 +148,7 @@ public static ElectricInductance From(double value, ElectricInductanceUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricInductanceUnit unit) => GetValueAs(unit); + public double As(ElectricInductanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -156,12 +156,10 @@ public static ElectricInductance From(double value, ElectricInductanceUnit fromU /// A Duration with the specified unit. public ElectricInductance ToUnit(ElectricInductanceUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricInductance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs index 02d544278d..84698afc08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -156,7 +156,7 @@ public static ElectricPotential From(double value, ElectricPotentialUnit fromUni /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialUnit unit) => GetValueAs(unit); + public double As(ElectricPotentialUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -164,12 +164,10 @@ public static ElectricPotential From(double value, ElectricPotentialUnit fromUni /// A Duration with the specified unit. public ElectricPotential ToUnit(ElectricPotentialUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricPotential(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index f71d975542..02b62ae184 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -156,7 +156,7 @@ public static ElectricPotentialAc From(double value, ElectricPotentialAcUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialAcUnit unit) => GetValueAs(unit); + public double As(ElectricPotentialAcUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -164,12 +164,10 @@ public static ElectricPotentialAc From(double value, ElectricPotentialAcUnit fro /// A Duration with the specified unit. public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricPotentialAc(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 650aead496..b33ffc6718 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -321,7 +321,7 @@ public static ElectricPotentialChangeRate From(double value, ElectricPotentialCh /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialChangeRateUnit unit) => GetValueAs(unit); + public double As(ElectricPotentialChangeRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -329,12 +329,10 @@ public static ElectricPotentialChangeRate From(double value, ElectricPotentialCh /// A Duration with the specified unit. public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricPotentialChangeRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index f7d74ae8e7..de59867ffa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -156,7 +156,7 @@ public static ElectricPotentialDc From(double value, ElectricPotentialDcUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialDcUnit unit) => GetValueAs(unit); + public double As(ElectricPotentialDcUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -164,12 +164,10 @@ public static ElectricPotentialDc From(double value, ElectricPotentialDcUnit fro /// A Duration with the specified unit. public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricPotentialDc(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs index 5224b4054c..dd207ee46d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -167,7 +167,7 @@ public static ElectricResistance From(double value, ElectricResistanceUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistanceUnit unit) => GetValueAs(unit); + public double As(ElectricResistanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -175,12 +175,10 @@ public static ElectricResistance From(double value, ElectricResistanceUnit fromU /// A Duration with the specified unit. public ElectricResistance ToUnit(ElectricResistanceUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricResistance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs index 229da70e2a..f4201a8793 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -258,7 +258,7 @@ public static ElectricResistivity From(double value, ElectricResistivityUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistivityUnit unit) => GetValueAs(unit); + public double As(ElectricResistivityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -266,12 +266,10 @@ public static ElectricResistivity From(double value, ElectricResistivityUnit fro /// A Duration with the specified unit. public ElectricResistivity ToUnit(ElectricResistivityUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricResistivity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 2a7d94e2a8..d45dcfc057 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -137,7 +137,7 @@ public static ElectricSurfaceChargeDensity From(double value, ElectricSurfaceCha /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricSurfaceChargeDensityUnit unit) => GetValueAs(unit); + public double As(ElectricSurfaceChargeDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -145,12 +145,10 @@ public static ElectricSurfaceChargeDensity From(double value, ElectricSurfaceCha /// A Duration with the specified unit. public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new ElectricSurfaceChargeDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs index 00c3f31d1d..fa5e992b62 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs @@ -497,7 +497,7 @@ public static Energy From(double value, EnergyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EnergyUnit unit) => GetValueAs(unit); + public double As(EnergyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -505,12 +505,10 @@ public static Energy From(double value, EnergyUnit fromUnit) /// A Duration with the specified unit. public Energy ToUnit(EnergyUnit unit) { - var convertedValue = GetValueAs(unit); return new Energy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs index b6b955b01e..40938ece69 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs @@ -178,7 +178,7 @@ public static Entropy From(double value, EntropyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EntropyUnit unit) => GetValueAs(unit); + public double As(EntropyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -186,12 +186,10 @@ public static Entropy From(double value, EntropyUnit fromUnit) /// A Duration with the specified unit. public Entropy ToUnit(EntropyUnit unit) { - var convertedValue = GetValueAs(unit); return new Entropy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs index 86edd91cc4..054d12fcee 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs @@ -266,7 +266,7 @@ public static Force From(double value, ForceUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceUnit unit) => GetValueAs(unit); + public double As(ForceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -274,12 +274,10 @@ public static Force From(double value, ForceUnit fromUnit) /// A Duration with the specified unit. public Force ToUnit(ForceUnit unit) { - var convertedValue = GetValueAs(unit); return new Force(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs index ad7924eda3..2d312ca7b6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -266,7 +266,7 @@ public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceChangeRateUnit unit) => GetValueAs(unit); + public double As(ForceChangeRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -274,12 +274,10 @@ public static ForceChangeRate From(double value, ForceChangeRateUnit fromUnit) /// A Duration with the specified unit. public ForceChangeRate ToUnit(ForceChangeRateUnit unit) { - var convertedValue = GetValueAs(unit); return new ForceChangeRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs index b5b82363e3..cde6bcd3dc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -519,7 +519,7 @@ public static ForcePerLength From(double value, ForcePerLengthUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForcePerLengthUnit unit) => GetValueAs(unit); + public double As(ForcePerLengthUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -527,12 +527,10 @@ public static ForcePerLength From(double value, ForcePerLengthUnit fromUnit) /// A Duration with the specified unit. public ForcePerLength ToUnit(ForcePerLengthUnit unit) { - var convertedValue = GetValueAs(unit); return new ForcePerLength(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs index ce059beb35..2195a7452f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs @@ -222,7 +222,7 @@ public static Frequency From(double value, FrequencyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FrequencyUnit unit) => GetValueAs(unit); + public double As(FrequencyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -230,12 +230,10 @@ public static Frequency From(double value, FrequencyUnit fromUnit) /// A Duration with the specified unit. public Frequency ToUnit(FrequencyUnit unit) { - var convertedValue = GetValueAs(unit); return new Frequency(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs index c7c6bc1715..9028d058a3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -148,7 +148,7 @@ public static FuelEfficiency From(double value, FuelEfficiencyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FuelEfficiencyUnit unit) => GetValueAs(unit); + public double As(FuelEfficiencyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -156,12 +156,10 @@ public static FuelEfficiency From(double value, FuelEfficiencyUnit fromUnit) /// A Duration with the specified unit. public FuelEfficiency ToUnit(FuelEfficiencyUnit unit) { - var convertedValue = GetValueAs(unit); return new FuelEfficiency(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs index 3da199a07f..b4ef29ee9a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs @@ -299,7 +299,7 @@ public static HeatFlux From(double value, HeatFluxUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatFluxUnit unit) => GetValueAs(unit); + public double As(HeatFluxUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -307,12 +307,10 @@ public static HeatFlux From(double value, HeatFluxUnit fromUnit) /// A Duration with the specified unit. public HeatFlux ToUnit(HeatFluxUnit unit) { - var convertedValue = GetValueAs(unit); return new HeatFlux(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 6bbb9a2b18..6ab4488345 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -134,7 +134,7 @@ public static HeatTransferCoefficient From(double value, HeatTransferCoefficient /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatTransferCoefficientUnit unit) => GetValueAs(unit); + public double As(HeatTransferCoefficientUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static HeatTransferCoefficient From(double value, HeatTransferCoefficient /// A Duration with the specified unit. public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit) { - var convertedValue = GetValueAs(unit); return new HeatTransferCoefficient(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs index 6db51d810c..7913154465 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs @@ -148,7 +148,7 @@ public static Illuminance From(double value, IlluminanceUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IlluminanceUnit unit) => GetValueAs(unit); + public double As(IlluminanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -156,12 +156,10 @@ public static Illuminance From(double value, IlluminanceUnit fromUnit) /// A Duration with the specified unit. public Illuminance ToUnit(IlluminanceUnit unit) { - var convertedValue = GetValueAs(unit); return new Illuminance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs index 46ea07d2d6..d1c6d38a14 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs @@ -387,7 +387,7 @@ public static Information From(double value, InformationUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(InformationUnit unit) => GetValueAs(unit); + public double As(InformationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -395,12 +395,10 @@ public static Information From(double value, InformationUnit fromUnit) /// A Duration with the specified unit. public Information ToUnit(InformationUnit unit) { - var convertedValue = GetValueAs(unit); return new Information(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs index 757f34305b..66f49b34e7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs @@ -255,7 +255,7 @@ public static Irradiance From(double value, IrradianceUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradianceUnit unit) => GetValueAs(unit); + public double As(IrradianceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -263,12 +263,10 @@ public static Irradiance From(double value, IrradianceUnit fromUnit) /// A Duration with the specified unit. public Irradiance ToUnit(IrradianceUnit unit) { - var convertedValue = GetValueAs(unit); return new Irradiance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs index 341dd0b84e..1b12772832 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs @@ -181,7 +181,7 @@ public static Irradiation From(double value, IrradiationUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradiationUnit unit) => GetValueAs(unit); + public double As(IrradiationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -189,12 +189,10 @@ public static Irradiation From(double value, IrradiationUnit fromUnit) /// A Duration with the specified unit. public Irradiation ToUnit(IrradiationUnit unit) { - var convertedValue = GetValueAs(unit); return new Irradiation(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs index 3e0cc9fbde..ad6c311057 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -203,7 +203,7 @@ public static KinematicViscosity From(double value, KinematicViscosityUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(KinematicViscosityUnit unit) => GetValueAs(unit); + public double As(KinematicViscosityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -211,12 +211,10 @@ public static KinematicViscosity From(double value, KinematicViscosityUnit fromU /// A Duration with the specified unit. public KinematicViscosity ToUnit(KinematicViscosityUnit unit) { - var convertedValue = GetValueAs(unit); return new KinematicViscosity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs index 84399497a8..361a1cbf25 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs @@ -112,7 +112,7 @@ public static LapseRate From(double value, LapseRateUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LapseRateUnit unit) => GetValueAs(unit); + public double As(LapseRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -120,12 +120,10 @@ public static LapseRate From(double value, LapseRateUnit fromUnit) /// A Duration with the specified unit. public LapseRate ToUnit(LapseRateUnit unit) { - var convertedValue = GetValueAs(unit); return new LapseRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs index 1cfbb88659..e64e698fe3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs @@ -464,7 +464,7 @@ public static Length From(double value, LengthUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LengthUnit unit) => GetValueAs(unit); + public double As(LengthUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -472,12 +472,10 @@ public static Length From(double value, LengthUnit fromUnit) /// A Duration with the specified unit. public Length ToUnit(LengthUnit unit) { - var convertedValue = GetValueAs(unit); return new Length(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs index 57104afcda..7e08980ca1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs @@ -123,7 +123,7 @@ public static Level From(double value, LevelUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LevelUnit unit) => GetValueAs(unit); + public double As(LevelUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -131,12 +131,10 @@ public static Level From(double value, LevelUnit fromUnit) /// A Duration with the specified unit. public Level ToUnit(LevelUnit unit) { - var convertedValue = GetValueAs(unit); return new Level(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs index 3945cc7439..badd92703a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs @@ -258,7 +258,7 @@ public static LinearDensity From(double value, LinearDensityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearDensityUnit unit) => GetValueAs(unit); + public double As(LinearDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -266,12 +266,10 @@ public static LinearDensity From(double value, LinearDensityUnit fromUnit) /// A Duration with the specified unit. public LinearDensity ToUnit(LinearDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new LinearDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs index ef29a48c73..f07158d33d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -379,7 +379,7 @@ public static LinearPowerDensity From(double value, LinearPowerDensityUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearPowerDensityUnit unit) => GetValueAs(unit); + public double As(LinearPowerDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -387,12 +387,10 @@ public static LinearPowerDensity From(double value, LinearPowerDensityUnit fromU /// A Duration with the specified unit. public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new LinearPowerDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs index 28f2d9f6ae..db5f5bf32e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs @@ -258,7 +258,7 @@ public static Luminosity From(double value, LuminosityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminosityUnit unit) => GetValueAs(unit); + public double As(LuminosityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -266,12 +266,10 @@ public static Luminosity From(double value, LuminosityUnit fromUnit) /// A Duration with the specified unit. public Luminosity ToUnit(LuminosityUnit unit) { - var convertedValue = GetValueAs(unit); return new Luminosity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs index 934af77713..5fb05e4cc1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -115,7 +115,7 @@ public static LuminousFlux From(double value, LuminousFluxUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousFluxUnit unit) => GetValueAs(unit); + public double As(LuminousFluxUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static LuminousFlux From(double value, LuminousFluxUnit fromUnit) /// A Duration with the specified unit. public LuminousFlux ToUnit(LuminousFluxUnit unit) { - var convertedValue = GetValueAs(unit); return new LuminousFlux(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs index 27f6ef0e59..113e45474c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -115,7 +115,7 @@ public static LuminousIntensity From(double value, LuminousIntensityUnit fromUni /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousIntensityUnit unit) => GetValueAs(unit); + public double As(LuminousIntensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static LuminousIntensity From(double value, LuminousIntensityUnit fromUni /// A Duration with the specified unit. public LuminousIntensity ToUnit(LuminousIntensityUnit unit) { - var convertedValue = GetValueAs(unit); return new LuminousIntensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs index b7bf7e0bb1..e9bf740bd5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs @@ -170,7 +170,7 @@ public static MagneticField From(double value, MagneticFieldUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFieldUnit unit) => GetValueAs(unit); + public double As(MagneticFieldUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -178,12 +178,10 @@ public static MagneticField From(double value, MagneticFieldUnit fromUnit) /// A Duration with the specified unit. public MagneticField ToUnit(MagneticFieldUnit unit) { - var convertedValue = GetValueAs(unit); return new MagneticField(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs index 5fcd893e9a..32e41056ed 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -115,7 +115,7 @@ public static MagneticFlux From(double value, MagneticFluxUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFluxUnit unit) => GetValueAs(unit); + public double As(MagneticFluxUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static MagneticFlux From(double value, MagneticFluxUnit fromUnit) /// A Duration with the specified unit. public MagneticFlux ToUnit(MagneticFluxUnit unit) { - var convertedValue = GetValueAs(unit); return new MagneticFlux(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs index c90b582696..a25126cc42 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs @@ -115,7 +115,7 @@ public static Magnetization From(double value, MagnetizationUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagnetizationUnit unit) => GetValueAs(unit); + public double As(MagnetizationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static Magnetization From(double value, MagnetizationUnit fromUnit) /// A Duration with the specified unit. public Magnetization ToUnit(MagnetizationUnit unit) { - var convertedValue = GetValueAs(unit); return new Magnetization(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs index 68a6614ed6..ebcf4e7a0c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs @@ -376,7 +376,7 @@ public static Mass From(double value, MassUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassUnit unit) => GetValueAs(unit); + public double As(MassUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -384,12 +384,10 @@ public static Mass From(double value, MassUnit fromUnit) /// A Duration with the specified unit. public Mass ToUnit(MassUnit unit) { - var convertedValue = GetValueAs(unit); return new Mass(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs index 628c783198..5fd6903a0e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs @@ -643,7 +643,7 @@ public static MassConcentration From(double value, MassConcentrationUnit fromUni /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassConcentrationUnit unit) => GetValueAs(unit); + public double As(MassConcentrationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -651,12 +651,10 @@ public static MassConcentration From(double value, MassConcentrationUnit fromUni /// A Duration with the specified unit. public MassConcentration ToUnit(MassConcentrationUnit unit) { - var convertedValue = GetValueAs(unit); return new MassConcentration(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs index 4758354f6d..be0d7a8a8b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs @@ -464,7 +464,7 @@ public static MassFlow From(double value, MassFlowUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFlowUnit unit) => GetValueAs(unit); + public double As(MassFlowUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -472,12 +472,10 @@ public static MassFlow From(double value, MassFlowUnit fromUnit) /// A Duration with the specified unit. public MassFlow ToUnit(MassFlowUnit unit) { - var convertedValue = GetValueAs(unit); return new MassFlow(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs index 340360959f..b22220235b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs @@ -233,7 +233,7 @@ public static MassFlux From(double value, MassFluxUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFluxUnit unit) => GetValueAs(unit); + public double As(MassFluxUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -241,12 +241,10 @@ public static MassFlux From(double value, MassFluxUnit fromUnit) /// A Duration with the specified unit. public MassFlux ToUnit(MassFluxUnit unit) { - var convertedValue = GetValueAs(unit); return new MassFlux(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs index ee835df31c..2044ac2ee3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs @@ -368,7 +368,7 @@ public static MassFraction From(double value, MassFractionUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFractionUnit unit) => GetValueAs(unit); + public double As(MassFractionUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -376,12 +376,10 @@ public static MassFraction From(double value, MassFractionUnit fromUnit) /// A Duration with the specified unit. public MassFraction ToUnit(MassFractionUnit unit) { - var convertedValue = GetValueAs(unit); return new MassFraction(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index d847a3c3f8..69dc6dd481 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -409,7 +409,7 @@ public static MassMomentOfInertia From(double value, MassMomentOfInertiaUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassMomentOfInertiaUnit unit) => GetValueAs(unit); + public double As(MassMomentOfInertiaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -417,12 +417,10 @@ public static MassMomentOfInertia From(double value, MassMomentOfInertiaUnit fro /// A Duration with the specified unit. public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit) { - var convertedValue = GetValueAs(unit); return new MassMomentOfInertia(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs index ae113abe79..fc159b70c1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -134,7 +134,7 @@ public static MolarEnergy From(double value, MolarEnergyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEnergyUnit unit) => GetValueAs(unit); + public double As(MolarEnergyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static MolarEnergy From(double value, MolarEnergyUnit fromUnit) /// A Duration with the specified unit. public MolarEnergy ToUnit(MolarEnergyUnit unit) { - var convertedValue = GetValueAs(unit); return new MolarEnergy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs index 1dd6bcfd14..8b08c53f6a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -134,7 +134,7 @@ public static MolarEntropy From(double value, MolarEntropyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEntropyUnit unit) => GetValueAs(unit); + public double As(MolarEntropyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static MolarEntropy From(double value, MolarEntropyUnit fromUnit) /// A Duration with the specified unit. public MolarEntropy ToUnit(MolarEntropyUnit unit) { - var convertedValue = GetValueAs(unit); return new MolarEntropy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs index 068273ca73..771ee65e2d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs @@ -233,7 +233,7 @@ public static MolarMass From(double value, MolarMassUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarMassUnit unit) => GetValueAs(unit); + public double As(MolarMassUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -241,12 +241,10 @@ public static MolarMass From(double value, MolarMassUnit fromUnit) /// A Duration with the specified unit. public MolarMass ToUnit(MolarMassUnit unit) { - var convertedValue = GetValueAs(unit); return new MolarMass(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs index a0c6e30669..9f3dd7caee 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs @@ -192,7 +192,7 @@ public static Molarity From(double value, MolarityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarityUnit unit) => GetValueAs(unit); + public double As(MolarityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -200,12 +200,10 @@ public static Molarity From(double value, MolarityUnit fromUnit) /// A Duration with the specified unit. public Molarity ToUnit(MolarityUnit unit) { - var convertedValue = GetValueAs(unit); return new Molarity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs index 695c7ed9f7..df87d75cb5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs @@ -115,7 +115,7 @@ public static Permeability From(double value, PermeabilityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermeabilityUnit unit) => GetValueAs(unit); + public double As(PermeabilityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static Permeability From(double value, PermeabilityUnit fromUnit) /// A Duration with the specified unit. public Permeability ToUnit(PermeabilityUnit unit) { - var convertedValue = GetValueAs(unit); return new Permeability(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs index 98e014ec97..fbc4d428f9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs @@ -115,7 +115,7 @@ public static Permittivity From(double value, PermittivityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermittivityUnit unit) => GetValueAs(unit); + public double As(PermittivityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static Permittivity From(double value, PermittivityUnit fromUnit) /// A Duration with the specified unit. public Permittivity ToUnit(PermittivityUnit unit) { - var convertedValue = GetValueAs(unit); return new Permittivity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index 880f0aae50..b41950408d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -376,7 +376,7 @@ public static Power From(double value, PowerUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerUnit unit) => GetValueAs(unit); + public double As(PowerUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -384,12 +384,10 @@ public static Power From(double value, PowerUnit fromUnit) /// A Duration with the specified unit. public Power ToUnit(PowerUnit unit) { - var convertedValue = GetValueAs(unit); return new Power(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs index 24bab2e22c..708f3986cf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs @@ -585,7 +585,7 @@ public static PowerDensity From(double value, PowerDensityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerDensityUnit unit) => GetValueAs(unit); + public double As(PowerDensityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -593,12 +593,10 @@ public static PowerDensity From(double value, PowerDensityUnit fromUnit) /// A Duration with the specified unit. public PowerDensity ToUnit(PowerDensityUnit unit) { - var convertedValue = GetValueAs(unit); return new PowerDensity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs index 15ea9f7123..2f58ed1c0f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs @@ -123,7 +123,7 @@ public static PowerRatio From(double value, PowerRatioUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerRatioUnit unit) => GetValueAs(unit); + public double As(PowerRatioUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -131,12 +131,10 @@ public static PowerRatio From(double value, PowerRatioUnit fromUnit) /// A Duration with the specified unit. public PowerRatio ToUnit(PowerRatioUnit unit) { - var convertedValue = GetValueAs(unit); return new PowerRatio(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs index e52c6f4933..633b12c352 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs @@ -585,7 +585,7 @@ public static Pressure From(double value, PressureUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureUnit unit) => GetValueAs(unit); + public double As(PressureUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -593,12 +593,10 @@ public static Pressure From(double value, PressureUnit fromUnit) /// A Duration with the specified unit. public Pressure ToUnit(PressureUnit unit) { - var convertedValue = GetValueAs(unit); return new Pressure(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs index 9f1a8e11ac..f7023d5d26 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -244,7 +244,7 @@ public static PressureChangeRate From(double value, PressureChangeRateUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureChangeRateUnit unit) => GetValueAs(unit); + public double As(PressureChangeRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -252,12 +252,10 @@ public static PressureChangeRate From(double value, PressureChangeRateUnit fromU /// A Duration with the specified unit. public PressureChangeRate ToUnit(PressureChangeRateUnit unit) { - var convertedValue = GetValueAs(unit); return new PressureChangeRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs index 1c6de225d4..b50c2c3dec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs @@ -167,7 +167,7 @@ public static Ratio From(double value, RatioUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioUnit unit) => GetValueAs(unit); + public double As(RatioUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -175,12 +175,10 @@ public static Ratio From(double value, RatioUnit fromUnit) /// A Duration with the specified unit. public Ratio ToUnit(RatioUnit unit) { - var convertedValue = GetValueAs(unit); return new Ratio(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs index 7dd34071d9..dad2208e98 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -123,7 +123,7 @@ public static RatioChangeRate From(double value, RatioChangeRateUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioChangeRateUnit unit) => GetValueAs(unit); + public double As(RatioChangeRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -131,12 +131,10 @@ public static RatioChangeRate From(double value, RatioChangeRateUnit fromUnit) /// A Duration with the specified unit. public RatioChangeRate ToUnit(RatioChangeRateUnit unit) { - var convertedValue = GetValueAs(unit); return new RatioChangeRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs index c502de324f..3b39ca6765 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -134,7 +134,7 @@ public static ReactiveEnergy From(double value, ReactiveEnergyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactiveEnergyUnit unit) => GetValueAs(unit); + public double As(ReactiveEnergyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static ReactiveEnergy From(double value, ReactiveEnergyUnit fromUnit) /// A Duration with the specified unit. public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit) { - var convertedValue = GetValueAs(unit); return new ReactiveEnergy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs index 15d0aef13c..9806533a22 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs @@ -145,7 +145,7 @@ public static ReactivePower From(double value, ReactivePowerUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactivePowerUnit unit) => GetValueAs(unit); + public double As(ReactivePowerUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static ReactivePower From(double value, ReactivePowerUnit fromUnit) /// A Duration with the specified unit. public ReactivePower ToUnit(ReactivePowerUnit unit) { - var convertedValue = GetValueAs(unit); return new ReactivePower(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs index 6e41a3d9c4..4f6f5e81b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -225,7 +225,7 @@ public static ReciprocalArea From(double value, ReciprocalAreaUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReciprocalAreaUnit unit) => GetValueAs(unit); + public double As(ReciprocalAreaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -233,12 +233,10 @@ public static ReciprocalArea From(double value, ReciprocalAreaUnit fromUnit) /// A Duration with the specified unit. public ReciprocalArea ToUnit(ReciprocalAreaUnit unit) { - var convertedValue = GetValueAs(unit); return new ReciprocalArea(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs index 29e70a2204..fdad8374d7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -214,7 +214,7 @@ public static ReciprocalLength From(double value, ReciprocalLengthUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReciprocalLengthUnit unit) => GetValueAs(unit); + public double As(ReciprocalLengthUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -222,12 +222,10 @@ public static ReciprocalLength From(double value, ReciprocalLengthUnit fromUnit) /// A Duration with the specified unit. public ReciprocalLength ToUnit(ReciprocalLengthUnit unit) { - var convertedValue = GetValueAs(unit); return new ReciprocalLength(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs index 9e7165e688..b88f20b22e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -112,7 +112,7 @@ public static RelativeHumidity From(double value, RelativeHumidityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RelativeHumidityUnit unit) => GetValueAs(unit); + public double As(RelativeHumidityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -120,12 +120,10 @@ public static RelativeHumidity From(double value, RelativeHumidityUnit fromUnit) /// A Duration with the specified unit. public RelativeHumidity ToUnit(RelativeHumidityUnit unit) { - var convertedValue = GetValueAs(unit); return new RelativeHumidity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 51c3bb2185..6220115730 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -145,7 +145,7 @@ public static RotationalAcceleration From(double value, RotationalAccelerationUn /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalAccelerationUnit unit) => GetValueAs(unit); + public double As(RotationalAccelerationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static RotationalAcceleration From(double value, RotationalAccelerationUn /// A Duration with the specified unit. public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit) { - var convertedValue = GetValueAs(unit); return new RotationalAcceleration(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs index 53bc1f7834..103ca82edb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -244,7 +244,7 @@ public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalSpeedUnit unit) => GetValueAs(unit); + public double As(RotationalSpeedUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -252,12 +252,10 @@ public static RotationalSpeed From(double value, RotationalSpeedUnit fromUnit) /// A Duration with the specified unit. public RotationalSpeed ToUnit(RotationalSpeedUnit unit) { - var convertedValue = GetValueAs(unit); return new RotationalSpeed(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs index 5d47807698..9fb984fd5b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -464,7 +464,7 @@ public static RotationalStiffness From(double value, RotationalStiffnessUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessUnit unit) => GetValueAs(unit); + public double As(RotationalStiffnessUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -472,12 +472,10 @@ public static RotationalStiffness From(double value, RotationalStiffnessUnit fro /// A Duration with the specified unit. public RotationalStiffness ToUnit(RotationalStiffnessUnit unit) { - var convertedValue = GetValueAs(unit); return new RotationalStiffness(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 6318f1b093..a0c9bd6d60 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -156,7 +156,7 @@ public static RotationalStiffnessPerLength From(double value, RotationalStiffnes /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessPerLengthUnit unit) => GetValueAs(unit); + public double As(RotationalStiffnessPerLengthUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -164,12 +164,10 @@ public static RotationalStiffnessPerLength From(double value, RotationalStiffnes /// A Duration with the specified unit. public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit) { - var convertedValue = GetValueAs(unit); return new RotationalStiffnessPerLength(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs index d5722d9f19..dff884f280 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs @@ -112,7 +112,7 @@ public static Scalar From(double value, ScalarUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ScalarUnit unit) => GetValueAs(unit); + public double As(ScalarUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -120,12 +120,10 @@ public static Scalar From(double value, ScalarUnit fromUnit) /// A Duration with the specified unit. public Scalar ToUnit(ScalarUnit unit) { - var convertedValue = GetValueAs(unit); return new Scalar(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs index 6a4669a7ef..4f26b53b3b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs @@ -115,7 +115,7 @@ public static SolidAngle From(double value, SolidAngleUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SolidAngleUnit unit) => GetValueAs(unit); + public double As(SolidAngleUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static SolidAngle From(double value, SolidAngleUnit fromUnit) /// A Duration with the specified unit. public SolidAngle ToUnit(SolidAngleUnit unit) { - var convertedValue = GetValueAs(unit); return new SolidAngle(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs index b35189239d..7de56dcb7e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -379,7 +379,7 @@ public static SpecificEnergy From(double value, SpecificEnergyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEnergyUnit unit) => GetValueAs(unit); + public double As(SpecificEnergyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -387,12 +387,10 @@ public static SpecificEnergy From(double value, SpecificEnergyUnit fromUnit) /// A Duration with the specified unit. public SpecificEnergy ToUnit(SpecificEnergyUnit unit) { - var convertedValue = GetValueAs(unit); return new SpecificEnergy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs index 0d28530c70..8a41ecd236 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -200,7 +200,7 @@ public static SpecificEntropy From(double value, SpecificEntropyUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEntropyUnit unit) => GetValueAs(unit); + public double As(SpecificEntropyUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -208,12 +208,10 @@ public static SpecificEntropy From(double value, SpecificEntropyUnit fromUnit) /// A Duration with the specified unit. public SpecificEntropy ToUnit(SpecificEntropyUnit unit) { - var convertedValue = GetValueAs(unit); return new SpecificEntropy(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 8771c02815..44955da03b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -148,7 +148,7 @@ public static SpecificFuelConsumption From(double value, SpecificFuelConsumption /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificFuelConsumptionUnit unit) => GetValueAs(unit); + public double As(SpecificFuelConsumptionUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -156,12 +156,10 @@ public static SpecificFuelConsumption From(double value, SpecificFuelConsumption /// A Duration with the specified unit. public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit) { - var convertedValue = GetValueAs(unit); return new SpecificFuelConsumption(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs index 8a9dc3fa64..33dbbac149 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -134,7 +134,7 @@ public static SpecificVolume From(double value, SpecificVolumeUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificVolumeUnit unit) => GetValueAs(unit); + public double As(SpecificVolumeUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -142,12 +142,10 @@ public static SpecificVolume From(double value, SpecificVolumeUnit fromUnit) /// A Duration with the specified unit. public SpecificVolume ToUnit(SpecificVolumeUnit unit) { - var convertedValue = GetValueAs(unit); return new SpecificVolume(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs index 0da4b8ca99..4a22c775bf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -291,7 +291,7 @@ public static SpecificWeight From(double value, SpecificWeightUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificWeightUnit unit) => GetValueAs(unit); + public double As(SpecificWeightUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -299,12 +299,10 @@ public static SpecificWeight From(double value, SpecificWeightUnit fromUnit) /// A Duration with the specified unit. public SpecificWeight ToUnit(SpecificWeightUnit unit) { - var convertedValue = GetValueAs(unit); return new SpecificWeight(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs index b04f38867c..37f45f13d2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs @@ -453,7 +453,7 @@ public static Speed From(double value, SpeedUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpeedUnit unit) => GetValueAs(unit); + public double As(SpeedUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -461,12 +461,10 @@ public static Speed From(double value, SpeedUnit fromUnit) /// A Duration with the specified unit. public Speed ToUnit(SpeedUnit unit) { - var convertedValue = GetValueAs(unit); return new Speed(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index a150803797..bdc7a9d536 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -200,7 +200,7 @@ public static StandardVolumeFlow From(double value, StandardVolumeFlowUnit fromU /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(StandardVolumeFlowUnit unit) => GetValueAs(unit); + public double As(StandardVolumeFlowUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -208,12 +208,10 @@ public static StandardVolumeFlow From(double value, StandardVolumeFlowUnit fromU /// A Duration with the specified unit. public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit) { - var convertedValue = GetValueAs(unit); return new StandardVolumeFlow(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs index d2f053c21b..267721e761 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs @@ -211,7 +211,7 @@ public static Temperature From(double value, TemperatureUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureUnit unit) => GetValueAs(unit); + public double As(TemperatureUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -219,12 +219,10 @@ public static Temperature From(double value, TemperatureUnit fromUnit) /// A Duration with the specified unit. public Temperature ToUnit(TemperatureUnit unit) { - var convertedValue = GetValueAs(unit); return new Temperature(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index ddf0f6dfe1..fb1652b96b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -211,7 +211,7 @@ public static TemperatureChangeRate From(double value, TemperatureChangeRateUnit /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureChangeRateUnit unit) => GetValueAs(unit); + public double As(TemperatureChangeRateUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -219,12 +219,10 @@ public static TemperatureChangeRate From(double value, TemperatureChangeRateUnit /// A Duration with the specified unit. public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit) { - var convertedValue = GetValueAs(unit); return new TemperatureChangeRate(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs index d4028e1a17..74b6b7a7f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -200,7 +200,7 @@ public static TemperatureDelta From(double value, TemperatureDeltaUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureDeltaUnit unit) => GetValueAs(unit); + public double As(TemperatureDeltaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -208,12 +208,10 @@ public static TemperatureDelta From(double value, TemperatureDeltaUnit fromUnit) /// A Duration with the specified unit. public TemperatureDelta ToUnit(TemperatureDeltaUnit unit) { - var convertedValue = GetValueAs(unit); return new TemperatureDelta(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs index 285dbc14f2..a485c0ece0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -126,7 +126,7 @@ public static ThermalConductivity From(double value, ThermalConductivityUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalConductivityUnit unit) => GetValueAs(unit); + public double As(ThermalConductivityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -134,12 +134,10 @@ public static ThermalConductivity From(double value, ThermalConductivityUnit fro /// A Duration with the specified unit. public ThermalConductivity ToUnit(ThermalConductivityUnit unit) { - var convertedValue = GetValueAs(unit); return new ThermalConductivity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs index af082eb12e..9b9aa7894e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -156,7 +156,7 @@ public static ThermalResistance From(double value, ThermalResistanceUnit fromUni /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalResistanceUnit unit) => GetValueAs(unit); + public double As(ThermalResistanceUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -164,12 +164,10 @@ public static ThermalResistance From(double value, ThermalResistanceUnit fromUni /// A Duration with the specified unit. public ThermalResistance ToUnit(ThermalResistanceUnit unit) { - var convertedValue = GetValueAs(unit); return new ThermalResistance(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs index ab38374058..5578a04cdd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs @@ -343,7 +343,7 @@ public static Torque From(double value, TorqueUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorqueUnit unit) => GetValueAs(unit); + public double As(TorqueUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -351,12 +351,10 @@ public static Torque From(double value, TorqueUnit fromUnit) /// A Duration with the specified unit. public Torque ToUnit(TorqueUnit unit) { - var convertedValue = GetValueAs(unit); return new Torque(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs index 35bcd31239..07100acd54 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -332,7 +332,7 @@ public static TorquePerLength From(double value, TorquePerLengthUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorquePerLengthUnit unit) => GetValueAs(unit); + public double As(TorquePerLengthUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -340,12 +340,10 @@ public static TorquePerLength From(double value, TorquePerLengthUnit fromUnit) /// A Duration with the specified unit. public TorquePerLength ToUnit(TorquePerLengthUnit unit) { - var convertedValue = GetValueAs(unit); return new TorquePerLength(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs index 2f8b295917..cf832215b5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs @@ -115,7 +115,7 @@ public static Turbidity From(double value, TurbidityUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TurbidityUnit unit) => GetValueAs(unit); + public double As(TurbidityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -123,12 +123,10 @@ public static Turbidity From(double value, TurbidityUnit fromUnit) /// A Duration with the specified unit. public Turbidity ToUnit(TurbidityUnit unit) { - var convertedValue = GetValueAs(unit); return new Turbidity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs index 5a54688502..4cd3af8af2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs @@ -112,7 +112,7 @@ public static VitaminA From(double value, VitaminAUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VitaminAUnit unit) => GetValueAs(unit); + public double As(VitaminAUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -120,12 +120,10 @@ public static VitaminA From(double value, VitaminAUnit fromUnit) /// A Duration with the specified unit. public VitaminA ToUnit(VitaminAUnit unit) { - var convertedValue = GetValueAs(unit); return new VitaminA(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs index d7fff94b05..da42a43274 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs @@ -662,7 +662,7 @@ public static Volume From(double value, VolumeUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeUnit unit) => GetValueAs(unit); + public double As(VolumeUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -670,12 +670,10 @@ public static Volume From(double value, VolumeUnit fromUnit) /// A Duration with the specified unit. public Volume ToUnit(VolumeUnit unit) { - var convertedValue = GetValueAs(unit); return new Volume(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs index a710e75835..6c68dd64ed 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -324,7 +324,7 @@ public static VolumeConcentration From(double value, VolumeConcentrationUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeConcentrationUnit unit) => GetValueAs(unit); + public double As(VolumeConcentrationUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -332,12 +332,10 @@ public static VolumeConcentration From(double value, VolumeConcentrationUnit fro /// A Duration with the specified unit. public VolumeConcentration ToUnit(VolumeConcentrationUnit unit) { - var convertedValue = GetValueAs(unit); return new VolumeConcentration(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs index e8c4a36b6e..7fffcfd6c4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -717,7 +717,7 @@ public static VolumeFlow From(double value, VolumeFlowUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowUnit unit) => GetValueAs(unit); + public double As(VolumeFlowUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -725,12 +725,10 @@ public static VolumeFlow From(double value, VolumeFlowUnit fromUnit) /// A Duration with the specified unit. public VolumeFlow ToUnit(VolumeFlowUnit unit) { - var convertedValue = GetValueAs(unit); return new VolumeFlow(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs index eeb73eebd0..36dd77870f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -178,7 +178,7 @@ public static VolumePerLength From(double value, VolumePerLengthUnit fromUnit) /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumePerLengthUnit unit) => GetValueAs(unit); + public double As(VolumePerLengthUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -186,12 +186,10 @@ public static VolumePerLength From(double value, VolumePerLengthUnit fromUnit) /// A Duration with the specified unit. public VolumePerLength ToUnit(VolumePerLengthUnit unit) { - var convertedValue = GetValueAs(unit); return new VolumePerLength(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 38b92d08a5..6444462d88 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -203,7 +203,7 @@ public static VolumetricHeatCapacity From(double value, VolumetricHeatCapacityUn /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumetricHeatCapacityUnit unit) => GetValueAs(unit); + public double As(VolumetricHeatCapacityUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -211,12 +211,10 @@ public static VolumetricHeatCapacity From(double value, VolumetricHeatCapacityUn /// A Duration with the specified unit. public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit) { - var convertedValue = GetValueAs(unit); return new VolumetricHeatCapacity(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index e555d690bf..4634701b08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -167,7 +167,7 @@ public static WarpingMomentOfInertia From(double value, WarpingMomentOfInertiaUn /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(WarpingMomentOfInertiaUnit unit) => GetValueAs(unit); + public double As(WarpingMomentOfInertiaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -175,12 +175,10 @@ public static WarpingMomentOfInertia From(double value, WarpingMomentOfInertiaUn /// A Duration with the specified unit. public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit) { - var convertedValue = GetValueAs(unit); return new WarpingMomentOfInertia(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index 2e88dc6d9e..2c2acc6444 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -157,7 +157,6 @@ public void UnitsNetBaseJsonConverter_ReadValueUnit_returns_null_when_value_type Assert.Null(result); } - [Fact] public void UnitsNetBaseJsonConverter_ReadDoubleValueUnit_works_with_empty_token() { @@ -210,7 +209,6 @@ public void UnitsNetBaseJsonConverter_ReadValueUnit_works_case_insensitive( {valueTypePropertyName, "decimal"} }; - var result = _sut.Test_ReadDecimalValueUnit(token); Assert.NotNull(result); diff --git a/UnitsNet.Tests/CustomCode/ElectricResistanceTests.cs b/UnitsNet.Tests/CustomCode/ElectricResistanceTests.cs index d970c4fb33..de64c8bdcd 100644 --- a/UnitsNet.Tests/CustomCode/ElectricResistanceTests.cs +++ b/UnitsNet.Tests/CustomCode/ElectricResistanceTests.cs @@ -20,7 +20,6 @@ public class ElectricResistanceTests : ElectricResistanceTestsBase protected override double GigaohmsInOneOhm => 1e-9; - [Theory] [InlineData(1, 1, 1)] [InlineData(0, int.MaxValue, 0)] diff --git a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs index 77c38e6b42..baecac921c 100644 --- a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs +++ b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs @@ -136,7 +136,6 @@ public static void ComponentMassFromMassConcentrationAndSolutionVolume( AssertEx.EqualTolerance(expectedMassValue, massComponent.As(expectedMassUnit), tolerance); } - [Fact(Skip = "No ConversionBaseUnit defined: see https://github.com/angularsen/UnitsNet/issues/651")] public void DefaultSIUnitIsKgPerCubicMeter() { diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index e59fa41f18..9d7cb97f2d 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -76,7 +76,6 @@ public class MassFlowTests : MassFlowTestsBase protected override double GramsPerHourInOneGramPerSecond => 3600; - [Fact] public void DurationTimesMassFlowEqualsMass() { diff --git a/UnitsNet.Tests/CustomCode/MassFluxTests.cs b/UnitsNet.Tests/CustomCode/MassFluxTests.cs index 99be1f8e51..2fe8cea5e5 100644 --- a/UnitsNet.Tests/CustomCode/MassFluxTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFluxTests.cs @@ -43,7 +43,6 @@ public class MassFluxTests : MassFluxTestsBase protected override double KilogramsPerHourPerSquareCentimeterInOneKilogramPerSecondPerSquareMeter => 3.6E-1; protected override double KilogramsPerHourPerSquareMillimeterInOneKilogramPerSecondPerSquareMeter => 3.6E-3; - [Fact] public void MassFluxDividedBySpeedEqualsDensity() { diff --git a/UnitsNet.Tests/CustomCode/ReciprocalAreaTests.cs b/UnitsNet.Tests/CustomCode/ReciprocalAreaTests.cs index dcb1625f6e..f73da0cbb3 100644 --- a/UnitsNet.Tests/CustomCode/ReciprocalAreaTests.cs +++ b/UnitsNet.Tests/CustomCode/ReciprocalAreaTests.cs @@ -33,7 +33,6 @@ public class ReciprocalAreaTests : ReciprocalAreaTestsBase protected override double InverseSquareMillimetersInOneInverseSquareMeter => 1E-6; protected override double InverseSquareMicrometersInOneInverseSquareMeter => 1E-12; - protected override double InverseSquareMilesInOneInverseSquareMeter => 2.59E6; protected override double InverseSquareYardsInOneInverseSquareMeter => 0.836127; protected override double InverseSquareFeetInOneInverseSquareMeter => 0.092903; diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index d0e073042e..08c35bb877 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -40,7 +40,6 @@ public class SpecificEnergyTests : SpecificEnergyTestsBase protected override double GigawattDaysPerTonneInOneJoulePerKilogram => 1.15740741E-11; protected override double TerawattDaysPerTonneInOneJoulePerKilogram => 1.15740741E-14; - [Fact] public void MassTimesSpecificEnergyEqualsEnergy() { diff --git a/UnitsNet.Tests/CustomCode/TemperatureTests.cs b/UnitsNet.Tests/CustomCode/TemperatureTests.cs index 441ce154ae..406ee33953 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureTests.cs @@ -121,8 +121,6 @@ public void TemperatureMinusTemperatureDeltaEqualsTemperature(Temperature temper new object[] { Temperature.FromDegreesFahrenheit(-10), TemperatureDelta.FromDegreesFahrenheit(20), Temperature.FromDegreesFahrenheit(10) } }; - - [Theory] [MemberData(nameof(TemperaturePlusTemperatureDeltaEqualsTemperatureData))] public void TemperaturePlusTemperatureDeltaEqualsTemperature(Temperature temperature, TemperatureDelta delta, Temperature expected) diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 06e461f680..35a886b084 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -83,7 +83,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AccelerationUnit.MeterPerSecondSquared, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -584,7 +583,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -606,7 +604,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 0560af84c4..d8d365115d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -85,7 +85,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AmountOfSubstanceUnit.Mole, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -599,7 +598,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -621,7 +619,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index ceb1025089..95c5ee2155 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AmplitudeRatioUnit.DecibelVolt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -438,7 +437,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -460,7 +458,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index d95be2e7ce..c74a769b38 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -87,7 +87,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AngleUnit.Degree, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -614,7 +613,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 °", new Angle(0.123456, AngleUnit.Degree).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -636,7 +634,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 037e29abfc..4f9f07dc3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ApparentEnergyUnit.VoltampereHour, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 4af2a71f02..8bedfd8165 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ApparentPowerUnit.Voltampere, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 7c7d618356..998a00095d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 4fdb9ea777..3916204e43 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -67,7 +67,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -464,7 +463,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -486,7 +484,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 3079a7652e..f93f6f7319 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -83,7 +83,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaUnit.SquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -584,7 +583,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -606,7 +604,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 8f10e34206..49b7f2470b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -108,7 +108,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(BitRateUnit.BitPerSecond, quantity.Unit); } - [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() { @@ -739,7 +738,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -761,7 +759,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 32977d0814..7e785ea94f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 4f02bd8927..d038eece7f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -69,7 +69,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CapacitanceUnit.Farad, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -479,7 +478,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -501,7 +499,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 053b44d363..50224b8760 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CoefficientOfThermalExpansionUnit.InverseKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 04a5e8d34f..9322299e1d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -135,7 +135,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DensityUnit.KilogramPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -974,7 +973,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -996,7 +994,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index c659e91b37..3cd57ef9fb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -75,7 +75,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DurationUnit.Second, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -524,7 +523,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 s", new Duration(0.123456, DurationUnit.Second).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -546,7 +544,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 2b2402ccf8..b4294a8f87 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -75,7 +75,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -524,7 +523,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -546,7 +544,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 22094c3c56..38a4b9caf5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricAdmittanceUnit.Siemens, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 9149152525..c414a76f7e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 0ef2602920..4e1c772c46 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -65,7 +65,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricChargeUnit.Coulomb, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -449,7 +448,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -471,7 +469,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 2bbfaa2c4c..2a7baedd05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricConductanceUnit.Siemens, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index a84d221861..b57e9b36f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 41f03986a9..32c5469419 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 2bf61801e3..b60cae463b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 90f641a8f0..7cf78bddf3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -71,7 +71,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentUnit.Ampere, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -494,7 +493,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -516,7 +514,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 54784a6ec2..7366fa1cf6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricFieldUnit.VoltPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 9a28c5ce96..0c701743fc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricInductanceUnit.Henry, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 0accd69915..afc609ff7d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -65,7 +65,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialAcUnit.VoltAc, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -449,7 +448,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -471,7 +469,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index dd774a53e4..b5c06c45dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -95,7 +95,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -674,7 +673,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -696,7 +694,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 06b945f828..e79ad28efb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -65,7 +65,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialDcUnit.VoltDc, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -449,7 +448,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -471,7 +469,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 35d2a24654..ee075378fc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -65,7 +65,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialUnit.Volt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -449,7 +448,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -471,7 +469,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 356191455a..77d7ec6fe4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -67,7 +67,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricResistanceUnit.Ohm, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -464,7 +463,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -486,7 +484,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index bd09c49092..0519de8918 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -83,7 +83,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricResistivityUnit.OhmMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -584,7 +583,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -606,7 +604,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 21dad8dff5..4365c15823 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 8d8b931539..545a13bb92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -127,7 +127,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EnergyUnit.Joule, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -914,7 +913,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -936,7 +934,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 5c79deddab..ad26d0b9a5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -69,7 +69,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EntropyUnit.JoulePerKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -479,7 +478,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -501,7 +499,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index a416e4a841..fdd27d7e29 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -85,7 +85,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForceChangeRateUnit.NewtonPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -599,7 +598,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -621,7 +619,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 9615dffe82..48b5fafb4a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -131,7 +131,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForcePerLengthUnit.NewtonPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -944,7 +943,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -966,7 +964,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index d0bd8f4e0e..1574d1b2bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -85,7 +85,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForceUnit.Newton, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -599,7 +598,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N", new Force(0.123456, ForceUnit.Newton).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -621,7 +619,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 82e6dc7aca..ccb9d4dc0f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -77,7 +77,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(FrequencyUnit.Hertz, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -539,7 +538,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -561,7 +559,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index e69999fe06..5c518405f1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(FuelEfficiencyUnit.LiterPer100Kilometers, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 175bad85ac..c3a97fae06 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -91,7 +91,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(HeatFluxUnit.WattPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -644,7 +643,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -666,7 +664,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 561456fc12..409fb5fd34 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 5c5a1fe98b..0a306d3cd9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IlluminanceUnit.Lux, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 5dc0a62463..8548e2b43c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -108,7 +108,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(InformationUnit.Bit, quantity.Unit); } - [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() { @@ -739,7 +738,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 b", new Information(0.123456m, InformationUnit.Bit).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -761,7 +759,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 2d180555b9..6df33a5a3d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -83,7 +83,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IrradianceUnit.WattPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -584,7 +583,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -606,7 +604,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 7496a84e52..5e8f5a514d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -69,7 +69,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IrradiationUnit.JoulePerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -479,7 +478,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -501,7 +499,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 69d28640a3..5c97add6c4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -73,7 +73,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(KinematicViscosityUnit.SquareMeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -509,7 +508,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -531,7 +529,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 1223629d2e..d8c9f83390 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LapseRateUnit.DegreeCelsiusPerKilometer, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 5c128d9bac..e23dfd1eb3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -121,7 +121,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LengthUnit.Meter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -869,7 +868,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m", new Length(0.123456, LengthUnit.Meter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -891,7 +889,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 1251414373..9ed78ebb27 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -59,7 +59,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LevelUnit.Decibel, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -408,7 +407,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -430,7 +428,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 7ec3d9b9eb..b07a7e6465 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -83,7 +83,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LinearDensityUnit.KilogramPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -584,7 +583,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -606,7 +604,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index eee6b3b55b..2491a7e15d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -105,7 +105,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LinearPowerDensityUnit.WattPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -749,7 +748,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -771,7 +769,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 0a4cdf22ba..71525e5d13 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -83,7 +83,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminosityUnit.Watt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -584,7 +583,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -606,7 +604,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index eccf6494ee..8cc5261154 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminousFluxUnit.Lumen, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index a6db150311..cf6bc83333 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminousIntensityUnit.Candela, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index b1176db250..dbca0efac8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -67,7 +67,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagneticFieldUnit.Tesla, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -464,7 +463,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -486,7 +484,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 57d5d41fad..411b6ded21 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagneticFluxUnit.Weber, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 29ad33eeb6..e8cc0f2bce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagnetizationUnit.AmperePerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index a524e456f0..5755241c3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -153,7 +153,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -1109,7 +1108,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -1131,7 +1129,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 054a3a434c..4491048764 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -121,7 +121,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFlowUnit.GramPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -869,7 +868,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -891,7 +889,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index c184d551d4..a96b8a408d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -79,7 +79,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -554,7 +553,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -576,7 +574,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index fe2b5e143b..ea06017014 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -103,7 +103,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFractionUnit.DecimalFraction, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -734,7 +733,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -756,7 +754,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index e986bd3bcc..62fa009938 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -111,7 +111,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -794,7 +793,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -816,7 +814,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 9879e07047..025f826bb4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -105,7 +105,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassUnit.Kilogram, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -749,7 +748,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -771,7 +769,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 7a21b4a4d0..8935b53a9b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarEnergyUnit.JoulePerMole, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 822e97b8e1..77dc2f71d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarEntropyUnit.JoulePerMoleKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 25a9466cdb..b04a22c7dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -79,7 +79,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarMassUnit.KilogramPerMole, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -554,7 +553,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -576,7 +574,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 3cfdc8742c..5e01104704 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -71,7 +71,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarityUnit.MolesPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -494,7 +493,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -516,7 +514,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 58466eca6a..a902f6257a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PermeabilityUnit.HenryPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 8bcd23c09e..87d1d38b77 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PermittivityUnit.FaradPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 65707d49d3..95794b111a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -143,7 +143,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerDensityUnit.WattPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -1034,7 +1033,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -1056,7 +1054,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index afaeb495dc..8e069d768b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -59,7 +59,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerRatioUnit.DecibelWatt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -408,7 +407,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -430,7 +428,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 24c9b3573b..d5a6e58346 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -106,7 +106,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerUnit.Watt, quantity.Unit); } - [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() { @@ -724,7 +723,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W", new Power(0.123456m, PowerUnit.Watt).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -746,7 +744,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 4c52218912..09465835f6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -81,7 +81,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PressureChangeRateUnit.PascalPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -569,7 +568,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -591,7 +589,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index f0440ba02b..efc6145fab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -143,7 +143,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PressureUnit.Pascal, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -1034,7 +1033,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -1056,7 +1054,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 932cbbf21c..77a61bb0cd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -59,7 +59,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RatioChangeRateUnit.DecimalFractionPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -404,7 +403,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -426,7 +424,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 19759a2559..3e18bcceb8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -67,7 +67,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RatioUnit.DecimalFraction, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -464,7 +463,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -486,7 +484,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index b66c8de4b8..204d7f3302 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReactiveEnergyUnit.VoltampereReactiveHour, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 8a8c85efcb..7a6d3fc2fb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReactivePowerUnit.VoltampereReactive, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 671db86a16..1858cc7860 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -77,7 +77,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReciprocalAreaUnit.InverseSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -539,7 +538,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -561,7 +559,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 9015d143c2..8d7dbd1677 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -75,7 +75,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReciprocalLengthUnit.InverseMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -524,7 +523,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -546,7 +544,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 7a0c6fccf2..6193dd0d6e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RelativeHumidityUnit.Percent, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 102a0cf80d..e1ff01e076 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalAccelerationUnit.RadianPerSecondSquared, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index faecba342b..3e8504afeb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -81,7 +81,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalSpeedUnit.RadianPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -569,7 +568,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -591,7 +589,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 3acbe35835..a08db85f25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -65,7 +65,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -449,7 +448,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -471,7 +469,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 111401e3f1..5fcde15e57 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -121,7 +121,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerRadian, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -869,7 +868,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -891,7 +889,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index c5210cfca7..a8a1a060b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ScalarUnit.Amount, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new Scalar(0.123456, ScalarUnit.Amount).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 49ee308d61..dbd7e17b3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SolidAngleUnit.Steradian, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 1c4a22bc07..615f786990 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -105,7 +105,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificEnergyUnit.JoulePerKilogram, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -749,7 +748,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -771,7 +769,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index a70d26d5f2..d00513a611 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -73,7 +73,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificEntropyUnit.JoulePerKilogramKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -509,7 +508,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -531,7 +529,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 33567e2da1..f3bf294e56 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -63,7 +63,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -434,7 +433,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -456,7 +454,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 12bf303654..30b7e5c268 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -61,7 +61,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificVolumeUnit.CubicMeterPerKilogram, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -419,7 +418,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -441,7 +439,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 3835cc3ece..44117da3d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -89,7 +89,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificWeightUnit.NewtonPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -629,7 +628,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -651,7 +649,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index a13ca24aeb..a204c47d3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -119,7 +119,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpeedUnit.MeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -854,7 +853,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -876,7 +874,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 409c360642..f4ff5a1ba9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -73,7 +73,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -509,7 +508,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -531,7 +529,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 95e1fb0203..25150bf902 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -75,7 +75,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -524,7 +523,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -546,7 +544,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 1ff295e727..3aa28b183a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -73,7 +73,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureDeltaUnit.Kelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -509,7 +508,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -531,7 +529,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 50226cf4c8..de2a5619dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -75,7 +75,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureUnit.Kelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -512,7 +511,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -534,7 +532,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 09458d068f..a514166f0f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -59,7 +59,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ThermalConductivityUnit.WattPerMeterKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -404,7 +403,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -426,7 +424,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 733f5b09b6..f44c4851b1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -65,7 +65,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -449,7 +448,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -471,7 +469,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 47760be662..619acfd4bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -97,7 +97,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -689,7 +688,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -711,7 +709,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 4aed3a6ff5..6225980f1a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -99,7 +99,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TorqueUnit.NewtonMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -704,7 +703,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -726,7 +724,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index cd55be577d..490d143756 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TurbidityUnit.NTU, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index ce38c66001..baa11123f1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -57,7 +57,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VitaminAUnit.InternationalUnit, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -389,7 +388,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -411,7 +409,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 590de306e2..aac241b2c3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -95,7 +95,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeConcentrationUnit.DecimalFraction, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -674,7 +673,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -696,7 +694,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index ade0c890e5..63a1c929a5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -167,7 +167,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeFlowUnit.CubicMeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -1214,7 +1213,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -1236,7 +1234,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 0b6f523eea..12e1bb4c46 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -69,7 +69,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -479,7 +478,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -501,7 +499,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index c467920145..f9c85f451f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -157,7 +157,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeUnit.CubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -1139,7 +1138,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -1161,7 +1159,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 8cc8dae8c0..5426d482cd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -73,7 +73,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -509,7 +508,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -531,7 +529,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 58a0e29930..16b5dfcb9f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -67,7 +67,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(WarpingMomentOfInertiaUnit.MeterToTheSixth, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -464,7 +463,6 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s4", culture)); } - [Fact] public void ToString_NullFormat_ThrowsArgumentNullException() { @@ -486,7 +484,6 @@ public void ToString_NullProvider_EqualsCurrentUICulture() Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index 9d7a7ee445..963ef6e15b 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -91,7 +91,6 @@ public void ObsoleteConstructor_AssignsProperties() Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } - [Fact] public void GenericsConstructor_AssignsProperties() { diff --git a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs index 30693f48eb..5d486417ec 100644 --- a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs @@ -10,9 +10,9 @@ namespace UnitsNet public partial struct AmountOfSubstance { /// - /// The Avogadro constant is the number of constituent particles, usually molecules, - /// atoms or ions that are contained in the amount of substance given by one mole. It is the proportionality factor that relates - /// the molar mass of a substance to the mass of a sample, is designated with the symbol NA or L[1], and has the value + /// The Avogadro constant is the number of constituent particles, usually molecules, + /// atoms or ions that are contained in the amount of substance given by one mole. It is the proportionality factor that relates + /// the molar mass of a substance to the mass of a sample, is designated with the symbol NA or L[1], and has the value /// 6.02214076e23 mol−1 in the International System of Units (SI). /// /// @@ -34,13 +34,12 @@ public double NumberOfParticles() return AvogadroConstant * moles; } - /// Get from and a given . public static AmountOfSubstance FromMass(Mass mass, MolarMass molarMass) { return mass / molarMass; } - + /// Get from for a given . public static Mass operator *(AmountOfSubstance amountOfSubstance, MolarMass molarMass) { diff --git a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs index edce6c4ee2..5caabbd03d 100644 --- a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs @@ -26,7 +26,6 @@ public VolumeConcentration ToVolumeConcentration(Density componentDensity) return this / componentDensity; } - #region Static Methods /// @@ -48,7 +47,7 @@ public static MassConcentration FromVolumeConcentration(VolumeConcentration volu #endregion #region Operators - + /// Get from times . public static Mass operator *(MassConcentration density, Volume volume) { @@ -60,7 +59,7 @@ public static MassConcentration FromVolumeConcentration(VolumeConcentration volu { return Mass.FromKilograms(density.KilogramsPerCubicMeter * volume.CubicMeters); } - + /// Get from divided by the component's . public static Molarity operator /(MassConcentration massConcentration, MolarMass componentMass) { diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index cfce09a948..4556009fc6 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -64,7 +64,6 @@ public Temperature Multiply(double factor, TemperatureUnit unit) return From(resultInUnit, unit); } - /// /// Divide temperature by a in a given . /// diff --git a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs index e90942cfd1..fed1b0ca30 100644 --- a/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/VolumeConcentration.extra.cs @@ -46,7 +46,6 @@ public static VolumeConcentration FromMolarity(Molarity molarity, Density compon return molarity * componentMolarMass / componentDensity; } - #endregion #region Operators @@ -56,13 +55,13 @@ public static VolumeConcentration FromMolarity(Molarity molarity, Density compon { return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); } - + /// Get from times the component . public static MassConcentration operator *(Density componentDensity, VolumeConcentration volumeConcentration) { return MassConcentration.FromKilogramsPerCubicMeter(volumeConcentration.DecimalFractions * componentDensity.KilogramsPerCubicMeter); } - + #endregion } diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 741aa1cc56..cec2eae382 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -33,7 +33,7 @@ namespace UnitsNet { /// /// - /// Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. + /// Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. /// /// /// https://en.wikipedia.org/wiki/Molar_concentration From 7d699a73f978b5618d5200335e4475e32139f229 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:26:50 +0100 Subject: [PATCH 11/66] Add README to nuget --- UnitsNet/UnitsNet.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index aaabf86f20..6bbfc8e7e1 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -15,6 +15,7 @@ MIT false unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable + README.md @@ -65,6 +66,7 @@ + From 916b375c755fb2844650ecb42c4b3d83f2c22243 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:28:10 +0100 Subject: [PATCH 12/66] Rename TargetFrameworks to TargetFramework --- .../UnitsNet.NumberExtensions.Tests.csproj | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 2 +- .../UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj | 2 +- .../UnitsNet.Serialization.JsonNet.Tests.csproj | 2 +- .../UnitsNet.Serialization.JsonNet.csproj | 4 ++-- UnitsNet.Tests/UnitsNet.Tests.csproj | 2 +- UnitsNet/UnitsNet.csproj | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index 49e8cbc0ad..88d88da220 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -1,7 +1,7 @@ - net5.0 + net5.0 UnitsNet.NumberExtensions.Tests latest true diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index f7700dbc74..02f256fa8d 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -22,7 +22,7 @@ latest enable UnitsNet - netstandard2.0 + netstandard2.0 diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj index 97ed26f8b9..a04b39be97 100644 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj @@ -1,7 +1,7 @@  - net5.0 + net5.0 UnitsNet.Serialization.JsonNet.CompatibilityTests latest true diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj index 05eb397a50..7d4d55d5fc 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net5.0 UnitsNet.Serialization.JsonNet.Tests latest true diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index c790ec5e8e..095fe3facd 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -1,4 +1,4 @@ - + UnitsNet.Serialization.JsonNet @@ -23,7 +23,7 @@ 5.0.0.0 latest UnitsNet.Serialization.JsonNet - netstandard2.0 + netstandard2.0 diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index 11e56a9173..2b22e5ffa1 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net5.0 UnitsNet.Tests latest true diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 6bbfc8e7e1..0dfc48c769 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -24,7 +24,7 @@ latest enable UnitsNet - netstandard2.0 + netstandard2.0 From 6ec95f1b1b623dfd525ba0268b349d1ab21c2b7f Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:28:38 +0100 Subject: [PATCH 13/66] Remove System.ValueTuple ref for net40 target --- UnitsNet/UnitsNet.csproj | 5 ----- 1 file changed, 5 deletions(-) diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 0dfc48c769..7b4518efaf 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -48,11 +48,6 @@ - - - - - From 8cfc0262ec7cfae954d19b17a3ef258458926840 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 22:34:46 +0100 Subject: [PATCH 14/66] Remove TypeWrapper No longer needed after dropping net40 target --- .../UnitsNetGen/StaticQuantityGenerator.cs | 1 - UnitsNet/CustomCode/Quantity.cs | 3 +- UnitsNet/CustomCode/UnitAbbreviationsCache.cs | 3 +- UnitsNet/GeneratedCode/Quantity.g.cs | 1 - .../ReflectionBridgeExtensions.cs | 84 ------------------- UnitsNet/QuantityInfo.cs | 4 +- UnitsNet/UnitsNet.csproj | 2 +- 7 files changed, 4 insertions(+), 94 deletions(-) delete mode 100644 UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 050975208d..b14dda8fe5 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -19,7 +19,6 @@ public override string Generate() using System; using System.Globalization; using JetBrains.Annotations; -using UnitsNet.InternalHelpers; using UnitsNet.Units; using System.Collections.Generic; diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs index 838d4d9cb1..5de7fedbcd 100644 --- a/UnitsNet/CustomCode/Quantity.cs +++ b/UnitsNet/CustomCode/Quantity.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -using UnitsNet.InternalHelpers; namespace UnitsNet { @@ -102,7 +101,7 @@ public static bool TryFrom(double value, Enum unit, out IQuantity? quantity) /// Type must be of type UnitsNet.IQuantity -or- Type is not a known quantity type. public static IQuantity Parse(IFormatProvider? formatProvider, Type quantityType, string quantityString) { - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + if (!typeof(IQuantity).IsAssignableFrom(quantityType)) throw new ArgumentException($"Type {quantityType} must be of type UnitsNet.IQuantity."); if (TryParse(formatProvider, quantityType, quantityString, out IQuantity? quantity)) diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index a0b52ff101..f701cc7a83 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -6,7 +6,6 @@ using System.Globalization; using System.Linq; using JetBrains.Annotations; -using UnitsNet.InternalHelpers; using UnitsNet.Units; using UnitTypeToLookup = System.Collections.Generic.Dictionary; @@ -163,7 +162,7 @@ public void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatPr private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider formatProvider, bool setAsDefault, [NotNull] params string[] abbreviations) { - if (!unitType.Wrap().IsEnum) + if (!unitType.IsEnum) throw new ArgumentException("Must be an enum type.", nameof(unitType)); if (abbreviations == null) diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 3197988463..0838e74a2e 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -20,7 +20,6 @@ using System; using System.Globalization; using JetBrains.Annotations; -using UnitsNet.InternalHelpers; using UnitsNet.Units; using System.Collections.Generic; diff --git a/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs b/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs deleted file mode 100644 index 7fa3efac3b..0000000000 --- a/UnitsNet/InternalHelpers/ReflectionBridgeExtensions.cs +++ /dev/null @@ -1,84 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Collections.Generic; -using System.Reflection; -#if NET40 || NET35 || NET20 || SILVERLIGHT -using UniformTypeInfo = System.Type; -#else -using UniformTypeInfo = System.Reflection.TypeInfo; -#endif - -// Based on -// https://github.com/StefH/ReflectionBridge/blob/c1e34e57fe3fc93507e83d5cebc1677396645397/ReflectionBridge/src/ReflectionBridge/Extensions/ReflectionBridgeExtensions.cs -// MIT license -namespace UnitsNet.InternalHelpers -{ - internal struct TypeWrapper - { - private readonly Type _type; - - public TypeWrapper(Type type) - { - _type = type; - } - - internal Assembly Assembly => _type.ToUniformType().Assembly; - internal bool IsEnum => _type.ToUniformType().IsEnum; - internal bool IsClass => _type.ToUniformType().IsClass; - internal bool IsAssignableFrom(Type other) => _type.ToUniformType().IsAssignableFrom(other.ToUniformType()); - internal bool IsValueType => _type.ToUniformType().IsValueType; - - internal PropertyInfo GetProperty(string name) - { -#if NET40 || NET35 || NET20 || SILVERLIGHT - return _type.GetProperty(name); -#else - return _type.GetTypeInfo().GetDeclaredProperty(name); -#endif - } - - internal IEnumerable GetDeclaredMethods() - { - UniformTypeInfo? t = _type.ToUniformType(); - while (t != null) - { -#if NET40 || NET35 || NET20 || SILVERLIGHT - foreach (MethodInfo m in t.GetMethods()) -#else - foreach (MethodInfo m in t.DeclaredMethods) -#endif - yield return m; - - t = t.BaseType?.ToUniformType(); - } - } - } - - internal static class ReflectionBridgeExtensions - { - /// - /// Wrap the type to make it .NET agnostic using Type for old targets and the newer TypeInfo for newer targets. - /// - public static TypeWrapper Wrap(this Type type) - { - return new TypeWrapper(type); - } - - /// - /// Returns the type or type info object depending on compile target, such as TypeInfo for .NET 4.5+ and Type for .NET - /// 4.0 and older. - /// The APIs of these two objects are similar, but obtaining them is slightly different. - /// The idea is to get fewer #if pragma statements in the code. - /// - public static UniformTypeInfo ToUniformType(this Type type) - { -#if NET40 || NET35 || NET20 || SILVERLIGHT - return type; -#else - return type.GetTypeInfo(); -#endif - } - } -} diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index 8a36283334..ec07f3fda4 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Linq; using JetBrains.Annotations; -using UnitsNet.InternalHelpers; using UnitsNet.Units; namespace UnitsNet @@ -24,10 +23,9 @@ public class QuantityInfo private static readonly string UnitEnumNamespace = typeof(LengthUnit).Namespace; private static readonly Dictionary UnitEnumTypes = typeof(Length) - .Wrap() .Assembly .GetExportedTypes() - .Where(t => t.Wrap().IsEnum && t.Namespace == UnitEnumNamespace && t.Name.EndsWith("Unit")) + .Where(t => t.IsEnum && t.Namespace == UnitEnumNamespace && t.Name.EndsWith("Unit")) .ToDictionary(t => t.Name, t => t); /// diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 7b4518efaf..652d70274e 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -61,7 +61,7 @@ - + From ae3bf03a485394f9d3429169705ec97739fe0566 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 23:17:03 +0100 Subject: [PATCH 15/66] =?UTF-8?q?=F0=9F=94=A5=20Replace=20JetBrains.Annota?= =?UTF-8?q?tions=20with=20#nullable=20enable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Generators/UnitsNetGen/QuantityGenerator.cs | 3 +-- .../UnitsNetGen/StaticQuantityGenerator.cs | 3 +-- UnitsNet.Benchmark/UnitsNet.Benchmark.csproj | 2 +- .../UnitsNet.NumberExtensions.Tests.csproj | 2 +- .../UnitsNet.Serialization.JsonNet.csproj | 2 +- .../UnitsNetBaseJsonConverter.cs | 11 +++++------ UnitsNet.Tests/DummyIQuantity.cs | 14 ++++++-------- UnitsNet/CustomCode/Quantities/Length.extra.cs | 3 +-- UnitsNet/CustomCode/Quantities/Mass.extra.cs | 1 - UnitsNet/CustomCode/QuantityParser.cs | 11 +++++------ UnitsNet/CustomCode/UnitAbbreviationsCache.cs | 17 +++-------------- UnitsNet/CustomCode/UnitParser.cs | 9 +-------- .../GeneratedCode/Quantities/Acceleration.g.cs | 3 +-- .../Quantities/AmountOfSubstance.g.cs | 3 +-- .../Quantities/AmplitudeRatio.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 3 +-- .../Quantities/ApparentEnergy.g.cs | 3 +-- .../GeneratedCode/Quantities/ApparentPower.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 3 +-- .../GeneratedCode/Quantities/AreaDensity.g.cs | 3 +-- .../Quantities/AreaMomentOfInertia.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/BitRate.g.cs | 3 +-- .../BrakeSpecificFuelConsumption.g.cs | 3 +-- .../GeneratedCode/Quantities/Capacitance.g.cs | 3 +-- .../CoefficientOfThermalExpansion.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Density.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Duration.g.cs | 3 +-- .../Quantities/DynamicViscosity.g.cs | 3 +-- .../Quantities/ElectricAdmittance.g.cs | 3 +-- .../Quantities/ElectricCharge.g.cs | 3 +-- .../Quantities/ElectricChargeDensity.g.cs | 3 +-- .../Quantities/ElectricConductance.g.cs | 3 +-- .../Quantities/ElectricConductivity.g.cs | 3 +-- .../Quantities/ElectricCurrent.g.cs | 3 +-- .../Quantities/ElectricCurrentDensity.g.cs | 3 +-- .../Quantities/ElectricCurrentGradient.g.cs | 3 +-- .../GeneratedCode/Quantities/ElectricField.g.cs | 3 +-- .../Quantities/ElectricInductance.g.cs | 3 +-- .../Quantities/ElectricPotential.g.cs | 3 +-- .../Quantities/ElectricPotentialAc.g.cs | 3 +-- .../Quantities/ElectricPotentialChangeRate.g.cs | 3 +-- .../Quantities/ElectricPotentialDc.g.cs | 3 +-- .../Quantities/ElectricResistance.g.cs | 3 +-- .../Quantities/ElectricResistivity.g.cs | 3 +-- .../ElectricSurfaceChargeDensity.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Entropy.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 3 +-- .../Quantities/ForceChangeRate.g.cs | 3 +-- .../Quantities/ForcePerLength.g.cs | 3 +-- .../GeneratedCode/Quantities/Frequency.g.cs | 3 +-- .../Quantities/FuelEfficiency.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs | 3 +-- .../Quantities/HeatTransferCoefficient.g.cs | 3 +-- .../GeneratedCode/Quantities/Illuminance.g.cs | 3 +-- .../GeneratedCode/Quantities/Information.g.cs | 3 +-- .../GeneratedCode/Quantities/Irradiance.g.cs | 3 +-- .../GeneratedCode/Quantities/Irradiation.g.cs | 3 +-- .../Quantities/KinematicViscosity.g.cs | 3 +-- .../GeneratedCode/Quantities/LapseRate.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 3 +-- .../GeneratedCode/Quantities/LinearDensity.g.cs | 3 +-- .../Quantities/LinearPowerDensity.g.cs | 3 +-- .../GeneratedCode/Quantities/Luminosity.g.cs | 3 +-- .../GeneratedCode/Quantities/LuminousFlux.g.cs | 3 +-- .../Quantities/LuminousIntensity.g.cs | 3 +-- .../GeneratedCode/Quantities/MagneticField.g.cs | 3 +-- .../GeneratedCode/Quantities/MagneticFlux.g.cs | 3 +-- .../GeneratedCode/Quantities/Magnetization.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 3 +-- .../Quantities/MassConcentration.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs | 3 +-- .../GeneratedCode/Quantities/MassFraction.g.cs | 3 +-- .../Quantities/MassMomentOfInertia.g.cs | 3 +-- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 3 +-- .../GeneratedCode/Quantities/MolarEntropy.g.cs | 3 +-- .../GeneratedCode/Quantities/MolarMass.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Molarity.g.cs | 3 +-- .../GeneratedCode/Quantities/Permeability.g.cs | 3 +-- .../GeneratedCode/Quantities/Permittivity.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 3 +-- .../GeneratedCode/Quantities/PowerDensity.g.cs | 3 +-- .../GeneratedCode/Quantities/PowerRatio.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Pressure.g.cs | 3 +-- .../Quantities/PressureChangeRate.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 3 +-- .../Quantities/RatioChangeRate.g.cs | 3 +-- .../Quantities/ReactiveEnergy.g.cs | 3 +-- .../GeneratedCode/Quantities/ReactivePower.g.cs | 3 +-- .../Quantities/ReciprocalArea.g.cs | 3 +-- .../Quantities/ReciprocalLength.g.cs | 3 +-- .../Quantities/RelativeHumidity.g.cs | 3 +-- .../Quantities/RotationalAcceleration.g.cs | 3 +-- .../Quantities/RotationalSpeed.g.cs | 3 +-- .../Quantities/RotationalStiffness.g.cs | 3 +-- .../RotationalStiffnessPerLength.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 3 +-- .../GeneratedCode/Quantities/SolidAngle.g.cs | 3 +-- .../Quantities/SpecificEnergy.g.cs | 3 +-- .../Quantities/SpecificEntropy.g.cs | 3 +-- .../Quantities/SpecificFuelConsumption.g.cs | 3 +-- .../Quantities/SpecificVolume.g.cs | 3 +-- .../Quantities/SpecificWeight.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 3 +-- .../Quantities/StandardVolumeFlow.g.cs | 3 +-- .../GeneratedCode/Quantities/Temperature.g.cs | 3 +-- .../Quantities/TemperatureChangeRate.g.cs | 3 +-- .../Quantities/TemperatureDelta.g.cs | 3 +-- .../Quantities/ThermalConductivity.g.cs | 3 +-- .../Quantities/ThermalResistance.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 3 +-- .../Quantities/TorquePerLength.g.cs | 3 +-- .../GeneratedCode/Quantities/Turbidity.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 3 +-- .../Quantities/VolumeConcentration.g.cs | 3 +-- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 3 +-- .../Quantities/VolumePerLength.g.cs | 3 +-- .../Quantities/VolumetricHeatCapacity.g.cs | 3 +-- .../Quantities/WarpingMomentOfInertia.g.cs | 3 +-- UnitsNet/GeneratedCode/Quantity.g.cs | 3 +-- UnitsNet/IQuantity.cs | 3 +-- UnitsNet/InternalHelpers/Guard.cs | 3 +-- UnitsNet/QuantityInfo.cs | 5 ++--- UnitsNet/QuantityValue.cs | 1 + UnitsNet/UnitConverter.cs | 2 -- UnitsNet/UnitInfo.cs | 3 +-- UnitsNet/UnitsNet.csproj | 1 - 130 files changed, 143 insertions(+), 286 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 394502da1d..1b2c270d82 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -48,7 +48,6 @@ public override string Generate() using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1008,7 +1007,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete(""This method is deprecated and will be removed at a future release. Please use string.Format()."")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) {{ if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index b14dda8fe5..0d40cb3a8c 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -18,7 +18,6 @@ public override string Generate() Writer.WL(@" using System; using System.Globalization; -using JetBrains.Annotations; using UnitsNet.Units; using System.Collections.Generic; @@ -144,7 +143,7 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, { quantity = default(IQuantity); - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + if (!typeof(IQuantity).IsAssignableFrom(quantityType)) return false; var parser = QuantityParser.Default; diff --git a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj index 9e41c5274b..aeb489e9f0 100644 --- a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj +++ b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj @@ -3,7 +3,7 @@ Exe net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472 4.0.0.0 - 4.0.0.0 + 4.0.0.0 UnitsNet.Benchmark UnitsNet.Benchmark UnitsNet diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index 88d88da220..721e0d145f 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -4,6 +4,7 @@ net5.0 UnitsNet.NumberExtensions.Tests latest + enable true @@ -23,7 +24,6 @@ - diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 095fe3facd..f90225a933 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -22,6 +22,7 @@ 5.0.0.0 latest + enable UnitsNet.Serialization.JsonNet netstandard2.0 @@ -42,7 +43,6 @@ - diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index f73416c2ea..d47a7ddad7 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Concurrent; using System.Globalization; using System.Linq; -using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -150,7 +149,7 @@ private Enum GetUnit(string unit) throw ex; } } - + var unitValue = (Enum) Enum.Parse(unitEnumType, unitEnumValue); // Ex: MassUnit.Kilogram return unitValue; } @@ -251,13 +250,13 @@ protected class ValueUnit /// MassUnit.Pound /// InformationUnit.Kilobyte [JsonProperty(Order = 1)] - public string Unit { get; [UsedImplicitly] set; } + public string Unit { get; set; } = null!; /// /// The value. /// [JsonProperty(Order = 2)] - public double Value { get; [UsedImplicitly] set; } + public double Value { get; set; } } /// @@ -273,13 +272,13 @@ protected sealed class ExtendedValueUnit : ValueUnit /// The value as a string. /// [JsonProperty(Order = 3)] - public string ValueString { get; [UsedImplicitly] set; } + public string? ValueString { get; set; } /// /// The type of the value, e.g. "decimal". /// [JsonProperty(Order = 4)] - public string ValueType { get; [UsedImplicitly] set; } + public string? ValueType { get; set; } } } } diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index 04f97a7ea2..bd60bbe67f 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -1,7 +1,5 @@ -using System; -using System.Collections.Generic; -using System.Text; -using JetBrains.Annotations; +#nullable enable +using System; namespace UnitsNet.Tests { @@ -27,22 +25,22 @@ public double As(UnitSystem unitSystem) throw new NotImplementedException(); } - public string ToString([CanBeNull] IFormatProvider provider) + public string ToString(IFormatProvider? provider) { throw new NotImplementedException(); } - public string ToString([CanBeNull] IFormatProvider provider, int significantDigitsAfterRadix) + public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) { throw new NotImplementedException(); } - public string ToString([CanBeNull] IFormatProvider provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { throw new NotImplementedException(); } - public string ToString(string format, IFormatProvider formatProvider) + public string ToString(string? format, IFormatProvider? formatProvider) { throw new NotImplementedException(); } diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index 1d7c8922c0..09efb49596 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -5,7 +5,6 @@ using System.Globalization; using System.Text.RegularExpressions; using System.Threading; -using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet @@ -59,7 +58,7 @@ public static Length FromFeetInches(double feet, double inches) /// /// Optionally specify the culture format numbers and localize unit abbreviations. Defaults to thread's culture. /// Parsed length. - public static Length ParseFeetInches([NotNull] string str, IFormatProvider? formatProvider = null) + public static Length ParseFeetInches(string str, IFormatProvider? formatProvider = null) { if (str == null) throw new ArgumentNullException(nameof(str)); if (!TryParseFeetInches(str, out Length result, formatProvider)) diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index b28c958182..adab6a5216 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -4,7 +4,6 @@ using System; using System.Threading; using System.Globalization; -using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index a0054f5779..aa17c1e4d9 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -7,7 +7,6 @@ using System.Globalization; using System.Linq; using System.Text.RegularExpressions; -using JetBrains.Annotations; // ReSharper disable once CheckNamespace namespace UnitsNet @@ -41,9 +40,9 @@ static QuantityParser() } [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal TQuantity Parse([NotNull] string str, + internal TQuantity Parse(string str, IFormatProvider? formatProvider, - [NotNull] QuantityFromDelegate fromDelegate) + QuantityFromDelegate fromDelegate) where TQuantity : IQuantity where TUnitType : Enum { @@ -72,7 +71,7 @@ internal TQuantity Parse([NotNull] string str, [SuppressMessage("ReSharper", "UseStringInterpolation")] internal bool TryParse(string? str, IFormatProvider? formatProvider, - [NotNull] QuantityFromDelegate fromDelegate, + QuantityFromDelegate fromDelegate, out TQuantity result) where TQuantity : struct, IQuantity where TUnitType : struct, Enum @@ -101,9 +100,9 @@ internal bool TryParse(string? str, /// Workaround for C# not allowing to pass on 'out' param from type Length to IQuantity, even though the are compatible. /// [SuppressMessage("ReSharper", "UseStringInterpolation")] - internal bool TryParse([NotNull] string str, + internal bool TryParse(string str, IFormatProvider? formatProvider, - [NotNull] QuantityFromDelegate fromDelegate, + QuantityFromDelegate fromDelegate, out IQuantity? result) where TQuantity : struct, IQuantity where TUnitType : struct, Enum diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index f701cc7a83..318ca23aae 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -using JetBrains.Annotations; using UnitsNet.Units; using UnitTypeToLookup = System.Collections.Generic.Dictionary; @@ -69,7 +68,6 @@ private void LoadGeneratedAbbreviations() /// The unit enum value. /// Unit abbreviations to add. /// The type of unit enum. - [PublicAPI] public void MapUnitToAbbreviation(TUnitType unit, params string[] abbreviations) where TUnitType : Enum { MapUnitToAbbreviation(typeof(TUnitType), Convert.ToInt32(unit), CultureInfo.CurrentUICulture, abbreviations); @@ -97,7 +95,6 @@ public void MapUnitToDefaultAbbreviation(TUnitType unit, string abbre /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations to add. /// The type of unit enum. - [PublicAPI] public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider formatProvider, params string[] abbreviations) where TUnitType : Enum { // Assuming TUnitType is an enum, this conversion is safe. Seems not possible to enforce this today. @@ -118,7 +115,6 @@ public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider for /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviation to add as default. /// The type of unit enum. - [PublicAPI] public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvider formatProvider, string abbreviation) where TUnitType : Enum { // Assuming TUnitType is an enum, this conversion is safe. Seems not possible to enforce this today. @@ -139,8 +135,7 @@ public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvi /// The unit enum value. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations to add. - [PublicAPI] - public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, [NotNull] params string[] abbreviations) + public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, params string[] abbreviations) { PerformAbbreviationMapping(unitType, unitValue, formatProvider, false, abbreviations); } @@ -154,13 +149,12 @@ public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider /// The unit enum value. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviation to add as default. - [PublicAPI] - public void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, [NotNull] string abbreviation) + public void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, string abbreviation) { PerformAbbreviationMapping(unitType, unitValue, formatProvider, true, abbreviation); } - private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider formatProvider, bool setAsDefault, [NotNull] params string[] abbreviations) + private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider formatProvider, bool setAsDefault, params string[] abbreviations) { if (!unitType.IsEnum) throw new ArgumentException("Must be an enum type.", nameof(unitType)); @@ -190,7 +184,6 @@ private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatPro /// The format provider to use for lookup. Defaults to if null. /// The type of unit enum. /// The default unit abbreviation string. - [PublicAPI] public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider? formatProvider = null) where TUnitType : Enum { var unitType = typeof(TUnitType); @@ -224,7 +217,6 @@ public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider? /// The unit enum value. /// The format provider to use for lookup. Defaults to if null. /// The default unit abbreviation string. - [PublicAPI] public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider = null) { if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) @@ -254,7 +246,6 @@ public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvid /// Enum value for unit. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations associated with unit. - [PublicAPI] public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider? formatProvider = null) where TUnitType : Enum { return GetUnitAbbreviations(typeof(TUnitType), Convert.ToInt32(unit), formatProvider); @@ -267,7 +258,6 @@ public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider? /// Enum value for unit. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations associated with unit. - [PublicAPI] public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvider? formatProvider = null) { formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; @@ -288,7 +278,6 @@ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvid /// Enum type for unit. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations associated with unit. - [PublicAPI] public string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider? formatProvider = null) { formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs index 2becb1fd4d..07e0a9f845 100644 --- a/UnitsNet/CustomCode/UnitParser.cs +++ b/UnitsNet/CustomCode/UnitParser.cs @@ -4,7 +4,6 @@ using System; using System.Globalization; using System.Linq; -using JetBrains.Annotations; using UnitsNet.Units; // ReSharper disable once CheckNamespace @@ -47,7 +46,6 @@ static UnitParser() /// The format provider to use for lookup. Defaults to if null. /// /// - [PublicAPI] public TUnitType Parse(string unitAbbreviation, IFormatProvider? formatProvider = null) where TUnitType : Enum { return (TUnitType)Parse(unitAbbreviation, typeof(TUnitType), formatProvider); @@ -66,8 +64,7 @@ public TUnitType Parse(string unitAbbreviation, IFormatProvider? form /// Unit enum value, such as . /// No units match the abbreviation. /// More than one unit matches the abbreviation. - [PublicAPI] - public Enum Parse([NotNull] string unitAbbreviation, Type unitType, IFormatProvider? formatProvider = null) + public Enum Parse(string unitAbbreviation, Type unitType, IFormatProvider? formatProvider = null) { if (unitAbbreviation == null) throw new ArgumentNullException(nameof(unitAbbreviation)); unitAbbreviation = unitAbbreviation.Trim(); @@ -138,7 +135,6 @@ internal static string NormalizeUnitString(string unitAbbreviation) /// The unit enum value as out result. /// Type of unit enum. /// True if successful. - [PublicAPI] public bool TryParse(string unitAbbreviation, out TUnitType unit) where TUnitType : struct, Enum { return TryParse(unitAbbreviation, null, out unit); @@ -152,7 +148,6 @@ public bool TryParse(string unitAbbreviation, out TUnitType unit) whe /// The unit enum value as out result. /// Type of unit enum. /// True if successful. - [PublicAPI] public bool TryParse(string? unitAbbreviation, IFormatProvider? formatProvider, out TUnitType unit) where TUnitType : struct, Enum { unit = default; @@ -171,7 +166,6 @@ public bool TryParse(string? unitAbbreviation, IFormatProvider? forma /// Type of unit enum. /// The unit enum value as out result. /// True if successful. - [PublicAPI] public bool TryParse(string unitAbbreviation, Type unitType, out Enum? unit) { return TryParse(unitAbbreviation, unitType, null, out unit); @@ -185,7 +179,6 @@ public bool TryParse(string unitAbbreviation, Type unitType, out Enum? unit) /// The format provider to use for lookup. Defaults to if null. /// The unit enum value as out result. /// True if successful. - [PublicAPI] public bool TryParse(string? unitAbbreviation, Type unitType, IFormatProvider? formatProvider, out Enum? unit) { if (unitAbbreviation == null) diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 66a7126a44..f332af5eed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -942,7 +941,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 17a1c70e5e..47c45d7471 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -959,7 +958,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 0b8d1d19d1..f822d6a34f 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -780,7 +779,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 3457a4b108..0db185bd07 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -976,7 +975,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 49c15c594f..83a67cf3e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 6182805bc7..82e8a25b8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -772,7 +771,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 0ed7a2bde2..34533ade51 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -942,7 +941,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index b7351e72a7..bf2661bfda 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -721,7 +720,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index ac701f1ffe..84395f99ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -806,7 +805,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index afc1d973af..1eae835a28 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1154,7 +1153,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 20a394b6ab..f127d02221 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 4d48f54340..528c66ccde 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -826,7 +825,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index b7ee800cac..0e686eeff5 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 7e6f640db8..70b39f3f13 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1387,7 +1386,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index c10e60bb8a..d96bac6e4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -874,7 +873,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 32d553f479..1c59bf9032 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -877,7 +876,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 9d12fa4e40..6d4a3bed45 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -772,7 +771,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index b57657f453..f9e8322338 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -792,7 +791,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 7e2c2b260e..8d1cf9ab62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 7889ce1975..025a53d252 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -758,7 +757,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 4971dba570..8fa33f43e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -758,7 +757,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 0bfc735436..523c8e180b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -840,7 +839,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index e52725594e..46659c9f61 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -758,7 +757,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index a1cf6314b3..81929beb4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -772,7 +771,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index bcde5e2616..2ee4350268 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 9cadf2f1eb..132893a5b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -775,7 +774,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index fc0c8c8e2d..34b3e2b94e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -789,7 +788,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 5af9190065..ecb0ccda6f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -789,7 +788,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 0ccbf03273..b824f18c4d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1044,7 +1043,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 79d7799ff4..89908ae98e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -789,7 +788,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index fd399ceaf6..87cc892108 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -806,7 +805,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index bdd15e68c6..ff90a867c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -945,7 +944,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 0795641d97..21caea1829 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -758,7 +757,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 485fad71d9..1a61ed8cdb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1316,7 +1315,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index def9a8a314..784cc8326a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -823,7 +822,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 36c6268d86..75785057d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -959,7 +958,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index c179c0a94b..1be80e0b95 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -959,7 +958,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 7a5546bab2..120fbef58a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1350,7 +1349,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index ce12d0278f..de0f148873 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -891,7 +890,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 048d9abb70..68843d7f8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -775,7 +774,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 8282c9aeb4..32b212bd5b 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1010,7 +1009,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 501bd61cf9..4f3385c7d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index a3cbe99325..98c318beaf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -775,7 +774,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 717ecd92be..29058e6ce8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1151,7 +1150,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index dab2a379a2..23fa842bb3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -942,7 +941,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index f402d6a503..50d6dbf240 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -826,7 +825,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index be8664db8c..19745a6374 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -860,7 +859,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 7ec1eea564..b53fd11642 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -721,7 +720,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 4dbf22ce7a..73487a133f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1265,7 +1264,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 1ddb26a533..103dfbad8f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -746,7 +745,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 5f97682ea7..730ad86f70 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -945,7 +944,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 6b69739dc4..27d22715b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1132,7 +1131,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 873bf7d4e7..1e3ce7c664 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -945,7 +944,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 28640f3969..46bc89d193 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 0c4e2043b6..ee9a507ac1 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 65f952761f..d794831228 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -809,7 +808,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 3406fc6c83..0bd872cb36 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 5ce1b918a5..3218711d19 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 7f1ccc263e..e6563824f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1129,7 +1128,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index f8397e0070..17154b31aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1540,7 +1539,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index e685e75330..fee47b8f72 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1265,7 +1264,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index b8d9631d52..2fe9667d05 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -908,7 +907,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 9eb6c3dfc9..f70142fd28 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1115,7 +1114,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index f06c03fb23..269f53e444 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1180,7 +1179,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 6fcce874e3..d0f32df103 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 1f9cce6133..3f3641bc44 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index dd1745680d..adeaf45cab 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -908,7 +907,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index cec2eae382..eee20660a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -843,7 +842,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 37ec853f81..d015317453 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index eb6f6a6688..a7df3dea12 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 033462de4e..c10a10cf86 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1134,7 +1133,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 1bd51d110b..5f2eeffbe9 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1452,7 +1451,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 59ca99c83b..547aebf9a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -746,7 +745,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 66bd6e98e3..723ab378e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1452,7 +1451,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 8520f2ff9f..ef536ff205 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -925,7 +924,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 43076a9d67..c54fed1861 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -806,7 +805,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index a9b6445b43..b1743f69f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -738,7 +737,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index c8eec7a44b..7157c78f28 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index b11e24d99a..3ee79fd0fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -772,7 +771,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 330e55e64c..5b00deba83 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -894,7 +893,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 5a9c0d1c05..f97ba8bceb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -877,7 +876,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 8d1b1aa808..d180fc99fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -721,7 +720,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 11e9a83bc1..c18eaa0b69 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -772,7 +771,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 889d489a15..d8db45ccc0 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -925,7 +924,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index d4e46efed9..d1496a5884 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1265,7 +1264,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 99681350bf..a04cf7fe2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -789,7 +788,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index d9d8ac40f7..33bdc099ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -721,7 +720,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index b126e7c836..683555beaa 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 60aa66c515..ea3fcb9714 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1132,7 +1131,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index bda82f5820..5dcbbce1dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -857,7 +856,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index ce3fec6f51..408634af93 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -775,7 +774,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 6c154efbee..f83fe3c8ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -755,7 +754,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 664888a751..e3d22bc4f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -996,7 +995,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 9d9f8f9634..f1e6f27c3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1248,7 +1247,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 0f7a635eaf..e6ee811dd9 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -857,7 +856,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 9e7bc59cb0..43d8c9dde9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -828,7 +827,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 1aa9f26d55..ad844059d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -874,7 +873,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 0f9ba517b3..9be7fce222 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -857,7 +856,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 6e2fb29ecf..54a1585e00 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -741,7 +740,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index e66aff17f8..949fa04124 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -789,7 +788,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 583a4019c2..3438421947 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1078,7 +1077,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 7a63623438..c0e5dd2a80 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1061,7 +1060,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 162c557d4f..1301a87ad2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -724,7 +723,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 548b70aab7..84ba139b5b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -721,7 +720,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 95271cbdbb..c39a600480 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1571,7 +1570,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 0dc762a39e..9ca177d547 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1047,7 +1046,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index c0db9d1afa..11bbb8c3dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -1656,7 +1655,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index f5f331ffb8..232cf7c1cb 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -823,7 +822,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 8bbd3df326..cde2effd7f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -860,7 +859,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index dd62fe3ff9..5e276f81a3 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -806,7 +805,7 @@ public string ToString(IFormatProvider? provider, int significantDigitsAfterRadi /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) + public string ToString(IFormatProvider? provider, string format, params object[] args) { if (format == null) throw new ArgumentNullException(nameof(format)); if (args == null) throw new ArgumentNullException(nameof(args)); diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 0838e74a2e..c2d2b17713 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -19,7 +19,6 @@ using System; using System.Globalization; -using JetBrains.Annotations; using UnitsNet.Units; using System.Collections.Generic; @@ -1097,7 +1096,7 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, { quantity = default(IQuantity); - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + if (!typeof(IQuantity).IsAssignableFrom(quantityType)) return false; var parser = QuantityParser.Default; diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 3d30f9b6b2..546051d0da 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -3,7 +3,6 @@ using System; using System.Globalization; -using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet @@ -94,7 +93,7 @@ public interface IQuantity : IFormattable /// String representation. /// Format to use for localization and number formatting. Defaults to if null. [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args); + string ToString(IFormatProvider? provider, string format, params object[] args); } /// diff --git a/UnitsNet/InternalHelpers/Guard.cs b/UnitsNet/InternalHelpers/Guard.cs index 0c4f48ce27..c43210d088 100644 --- a/UnitsNet/InternalHelpers/Guard.cs +++ b/UnitsNet/InternalHelpers/Guard.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using JetBrains.Annotations; namespace UnitsNet.InternalHelpers { @@ -19,7 +18,7 @@ internal static class Guard /// Name of parameter in calling method. /// The given if valid. /// If is invalid. - internal static double EnsureValidNumber(double value, [InvokerParameterName] string paramName) + internal static double EnsureValidNumber(double value, string paramName) { if (double.IsNaN(value)) throw new ArgumentException("NaN is not a valid number.", paramName); if (double.IsInfinity(value)) throw new ArgumentException("PositiveInfinity or NegativeInfinity is not a valid number.", paramName); diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index ec07f3fda4..d9fd96cb03 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Linq; -using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet @@ -39,7 +38,7 @@ public class QuantityInfo /// Quantity type can not be undefined. /// If units -or- baseUnit -or- zero -or- baseDimensions is null. [Obsolete("QuantityType will be removed in the future. Use QuantityInfo(string, UnitInfo[], Enum, IQuantity, BaseDimensions) instead.")] - public QuantityInfo(QuantityType quantityType, [NotNull] UnitInfo[] unitInfos, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions) + public QuantityInfo(QuantityType quantityType, UnitInfo[] unitInfos, Enum baseUnit, IQuantity zero, BaseDimensions baseDimensions) : this(quantityType.ToString(), UnitEnumTypes[$"{quantityType}Unit"], unitInfos, baseUnit, zero, baseDimensions, quantityType) { } @@ -56,7 +55,7 @@ public QuantityInfo(QuantityType quantityType, [NotNull] UnitInfo[] unitInfos, [ /// The the quantity type. Defaults to Undefined. /// Quantity type can not be undefined. /// If units -or- baseUnit -or- zero -or- baseDimensions is null. - public QuantityInfo([NotNull] string name, Type unitType, [NotNull] UnitInfo[] unitInfos, [NotNull] Enum baseUnit, [NotNull] IQuantity zero, [NotNull] BaseDimensions baseDimensions, + public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseUnit, IQuantity zero, BaseDimensions baseDimensions, QuantityType quantityType = QuantityType.Undefined) { if(baseUnit == null) throw new ArgumentNullException(nameof(baseUnit)); diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index 6e6bd88430..98cb83b493 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -1,6 +1,7 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + using UnitsNet.InternalHelpers; namespace UnitsNet diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 09f55f3255..9715098136 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -5,7 +5,6 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; -using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet @@ -31,7 +30,6 @@ public delegate TQuantity ConversionFunction(TQuantity inputValue) /// /// Convert between units of a quantity, such as converting from meters to centimeters of a given length. /// - [PublicAPI] public sealed partial class UnitConverter { /// diff --git a/UnitsNet/UnitInfo.cs b/UnitsNet/UnitInfo.cs index eea329a9a8..7fc673ea87 100644 --- a/UnitsNet/UnitInfo.cs +++ b/UnitsNet/UnitInfo.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using JetBrains.Annotations; using UnitsNet.Units; namespace UnitsNet @@ -24,7 +23,7 @@ public class UnitInfo /// The enum value for this class, for example . /// The plural name of the unit, such as "Centimeters". /// The for this unit. - public UnitInfo([NotNull] Enum value, [NotNull] string pluralName, [NotNull] BaseUnits baseUnits) + public UnitInfo(Enum value, string pluralName, BaseUnits baseUnits) { Value = value ?? throw new ArgumentNullException(nameof(value)); Name = value.ToString(); diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 652d70274e..5d2563f779 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -44,7 +44,6 @@ - From 826d39295e857c90140ccae5bb613b956c97f7db Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 23:17:15 +0100 Subject: [PATCH 16/66] json: Fix nullable issues --- .../UnitsNetBaseJsonConverterTest.cs | 8 --- .../Internal/MultiDimensionalArrayHelpers.cs | 12 ++-- .../UnitsNetBaseJsonConverter.cs | 16 ++--- .../UnitsNetIComparableJsonConverter.cs | 15 +++-- .../UnitsNetIQuantityJsonConverter.cs | 16 +++-- .../UnitsNetJsonConverter.cs | 59 +++++++++---------- 6 files changed, 57 insertions(+), 69 deletions(-) diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index 2c2acc6444..9aa3d59239 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -58,14 +58,6 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected() } - [Fact] - public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_with_NULL_value() - { - var result = _sut.Test_ConvertValueUnit(); - - Assert.Null(result); - } - [Fact] public void UnitsNetBaseJsonConverter_ConvertValueUnit_throws_UnitsNetException_when_unit_does_not_exist() { diff --git a/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs b/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs index 5a675067c7..ff8c4aa5b9 100644 --- a/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs +++ b/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs @@ -1,7 +1,5 @@ using System; -using System.Collections.Generic; using System.Linq; -using System.Text; namespace UnitsNet.Serialization.JsonNet.Internal { @@ -10,7 +8,7 @@ namespace UnitsNet.Serialization.JsonNet.Internal /// Helper class for working with and manipulating multi-dimension arrays based on their generic index. /// internal static class MultiDimensionalArrayHelpers - { + { /// /// Returns a new array of same Rank and Length as but with each element converted to @@ -42,7 +40,7 @@ public static Array ConvertArrayElements(Array array) /// 1D integer array specifying the location of the first element in the multidimensional array public static int[] FirstIndex(Array array) { - return Enumerable.Range(0, array.Rank).Select(x => array.GetLowerBound(x)).ToArray(); + return Enumerable.Range(0, array.Rank).Select(array.GetLowerBound).ToArray(); } /// @@ -62,12 +60,12 @@ public static int[] LastIndex(Array array) /// /// Returns the 'next' index after the specified multidimensional /// - /// The 'next' index is determined by first looping through all elements in the first dimension of the array, then moving on to the next dimension and repeating + /// The 'next' index is determined by first looping through all elements in the first dimension of the array, then moving on to the next dimension and repeating /// /// /// /// Returns the index location of the next element in after as a 1D array of integers. If there is no next index, returns null - public static int[] NextIndex(Array array, int[] index) + public static int[]? NextIndex(Array array, int[] index) { for (var i = 0; i < index.Length; i++) { @@ -83,7 +81,7 @@ public static int[] NextIndex(Array array, int[] index) } } return null; - } + } } } diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index d47a7ddad7..86c7cefc8e 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -17,7 +17,7 @@ namespace UnitsNet.Serialization.JsonNet /// The type being converted. Should either be or public abstract class UnitsNetBaseJsonConverter : JsonConverter { - private ConcurrentDictionary _registeredTypes = new(); + private readonly ConcurrentDictionary _registeredTypes = new(); /// /// Register custom types so that the converter can instantiate these quantities. @@ -45,7 +45,7 @@ public void RegisterCustomType(Type quantity, Type unit) /// /// The JSON data to read from /// A - protected ValueUnit ReadValueUnit(JToken jsonToken) + protected ValueUnit? ReadValueUnit(JToken jsonToken) { if (!jsonToken.HasValues) { @@ -96,9 +96,9 @@ protected ValueUnit ReadValueUnit(JToken jsonToken) /// An IQuantity protected IQuantity ConvertValueUnit(ValueUnit valueUnit) { - if (string.IsNullOrWhiteSpace(valueUnit?.Unit)) + if (string.IsNullOrWhiteSpace(valueUnit.Unit)) { - return null; + throw new NotSupportedException("Unit must be specified."); } var unit = GetUnit(valueUnit.Unit); @@ -111,14 +111,14 @@ protected IQuantity ConvertValueUnit(ValueUnit valueUnit) return valueUnit switch { - ExtendedValueUnit {ValueType: "decimal"} extendedValueUnit => Quantity.From(decimal.Parse(extendedValueUnit.ValueString, CultureInfo.InvariantCulture), unit), + ExtendedValueUnit {ValueType: "decimal", ValueString: {}} extendedValueUnit => Quantity.From(decimal.Parse(extendedValueUnit.ValueString, CultureInfo.InvariantCulture), unit), _ => Quantity.From(valueUnit.Value, unit) }; } - private (Type Quantity, Type Unit) GetRegisteredType(string unit) + private (Type? Quantity, Type? Unit) GetRegisteredType(string unit) { - (var unitEnumTypeName, var _) = SplitUnitString(unit); + var (unitEnumTypeName, _) = SplitUnitString(unit); if (_registeredTypes.TryGetValue(unitEnumTypeName, out var registeredType)) { return registeredType; @@ -129,7 +129,7 @@ protected IQuantity ConvertValueUnit(ValueUnit valueUnit) private Enum GetUnit(string unit) { - (var unitEnumTypeName, var unitEnumValue) = SplitUnitString(unit); + var (unitEnumTypeName, unitEnumValue) = SplitUnitString(unit); // First try to find the name in the list of registered types. var unitEnumType = GetRegisteredType(unit).Unit; diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetIComparableJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetIComparableJsonConverter.cs index 66a3b57415..1e9cc3c174 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetIComparableJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetIComparableJsonConverter.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -16,7 +15,7 @@ namespace UnitsNet.Serialization.JsonNet /// Should only be used when UnitsNet types are assigned to properties of type IComparable. /// Requires TypeNameHandling on to be set to something other than so that it outputs $type when serializing. /// - public sealed class UnitsNetIComparableJsonConverter : UnitsNetBaseJsonConverter + public sealed class UnitsNetIComparableJsonConverter : UnitsNetBaseJsonConverter { /// /// Indicates if this JsonConverter is capable of writing JSON @@ -34,7 +33,7 @@ public sealed class UnitsNetIComparableJsonConverter : UnitsNetBaseJsonConverter /// Because this converter should only be used in combination with the , the WriteJson method of that converter will always be used /// to serialize an IComparable in the context of UnitsNet. /// JsonNet is capable of serializing any IComparable implementation. - public override void WriteJson(JsonWriter writer, IComparable value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, IComparable? value, JsonSerializer serializer) { throw new NotImplementedException("Serialization of IComparable is handled by default serialization"); } @@ -48,15 +47,15 @@ public override void WriteJson(JsonWriter writer, IComparable value, JsonSeriali /// Indicates if there is an existing value that should be updated (which is ignored) /// The JsonSerializer to use for deserialization /// A deserialized IComparable - public override IComparable ReadJson([NotNull] JsonReader reader, Type objectType, IComparable existingValue, bool hasExistingValue, - [NotNull] JsonSerializer serializer) + public override IComparable? ReadJson(JsonReader reader, Type objectType, IComparable? existingValue, bool hasExistingValue, + JsonSerializer serializer) { reader = reader ?? throw new ArgumentNullException(nameof(reader)); serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); if (reader.TokenType == JsonToken.Null) { - return null; + return existingValue; } var localSerializer = CreateLocalSerializer(serializer, this); @@ -66,7 +65,7 @@ public override IComparable ReadJson([NotNull] JsonReader reader, Type objectTyp // If objectType is not IComparable but a type that implements IComparable, deserialize directly as this type instead. if (objectType != typeof(IComparable)) { - return token.ToObject(objectType, localSerializer) as IComparable; + return (IComparable)token.ToObject(objectType, localSerializer)!; } var valueUnit = ReadValueUnit(token); @@ -76,7 +75,7 @@ public override IComparable ReadJson([NotNull] JsonReader reader, Type objectTyp return token.ToObject(localSerializer); } - return ConvertValueUnit(valueUnit) as IComparable; + return (IComparable)ConvertValueUnit(valueUnit); } } } diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetIQuantityJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetIQuantityJsonConverter.cs index 4f258040f3..a7ca91baac 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetIQuantityJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetIQuantityJsonConverter.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -13,7 +12,7 @@ namespace UnitsNet.Serialization.JsonNet /// JSON.net converter for IQuantity types (e.g. all units in UnitsNet) /// Use this converter to serialize and deserialize UnitsNet types to and from JSON /// - public sealed class UnitsNetIQuantityJsonConverter : UnitsNetBaseJsonConverter + public sealed class UnitsNetIQuantityJsonConverter : UnitsNetBaseJsonConverter { /// /// Writes the JSON representation of the object. @@ -21,7 +20,7 @@ public sealed class UnitsNetIQuantityJsonConverter : UnitsNetBaseJsonConverterThe to write to. /// The value to write. /// The calling serializer. - public override void WriteJson([NotNull] JsonWriter writer, IQuantity value, [NotNull] JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, IQuantity? value, JsonSerializer serializer) { writer = writer ?? throw new ArgumentNullException(nameof(writer)); serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); @@ -49,21 +48,26 @@ public override void WriteJson([NotNull] JsonWriter writer, IQuantity value, [No /// The object value. /// /// Unable to parse value and unit from JSON. - public override IQuantity ReadJson([NotNull] JsonReader reader, Type objectType, IQuantity existingValue, bool hasExistingValue, - [NotNull] JsonSerializer serializer) + public override IQuantity? ReadJson(JsonReader reader, Type objectType, IQuantity? existingValue, bool hasExistingValue, + JsonSerializer serializer) { reader = reader ?? throw new ArgumentNullException(nameof(reader)); serializer = serializer ?? throw new ArgumentNullException(nameof(serializer)); if (reader.TokenType == JsonToken.Null) { - return null; + return existingValue; } var token = JToken.Load(reader); var valueUnit = ReadValueUnit(token); + if (valueUnit == null) + { + return token.ToObject(serializer); + } + return ConvertValueUnit(valueUnit); } } diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs index 0865ee9545..d51ba4f294 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs @@ -3,7 +3,6 @@ using System; using System.Linq; -using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using UnitsNet.Serialization.JsonNet.Internal; @@ -36,25 +35,23 @@ public class UnitsNetJsonConverter : JsonConverter /// The object value. /// /// Unable to parse value and unit from JSON. - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { if (reader.ValueType != null) return reader.Value; - object obj = TryDeserializeIComparable(reader, serializer); + object? obj = TryDeserializeIComparable(reader, serializer); if (obj is Array values) { // Create array with the requested type, such as `Length[]` or `Frequency[]` or multi-dimensional arrays like `Length[,]` or `Frequency[,,]` - var arrayOfQuantities = Array.CreateInstance(objectType.GetElementType(), MultiDimensionalArrayHelpers.LastIndex(values)); + var elementType = objectType.GetElementType() ?? throw new NotSupportedException($"GetElementType() returned null for type {objectType}."); + var arrayOfQuantities = Array.CreateInstance(elementType, MultiDimensionalArrayHelpers.LastIndex(values)); // Fill array with parsed quantities int[] index = MultiDimensionalArrayHelpers.FirstIndex(values); - while (index != null) - { - arrayOfQuantities.SetValue(values.GetValue(index), index); - } + arrayOfQuantities.SetValue(values.GetValue(index), index); return arrayOfQuantities; } @@ -78,12 +75,13 @@ private static IQuantity ParseValueUnit(ValueUnit vu) string unitEnumTypeAssemblyQualifiedName = "UnitsNet.Units." + unitEnumTypeName + ",UnitsNet"; // -- see http://stackoverflow.com/a/6465096/1256096 for details - Type unitEnumType = Type.GetType(unitEnumTypeAssemblyQualifiedName); + Type? unitEnumType = Type.GetType(unitEnumTypeAssemblyQualifiedName); if (unitEnumType == null) { - var ex = new UnitsNetException("Unable to find enum type."); - ex.Data["type"] = unitEnumTypeAssemblyQualifiedName; - throw ex; + throw new UnitsNetException("Unable to find enum type.") + { + Data = { ["type"] = unitEnumTypeAssemblyQualifiedName } + }; } double value = vu.Value; @@ -92,13 +90,13 @@ private static IQuantity ParseValueUnit(ValueUnit vu) return Quantity.From(value, unitValue); } - private static object TryDeserializeIComparable(JsonReader reader, JsonSerializer serializer) + private static object? TryDeserializeIComparable(JsonReader reader, JsonSerializer serializer) { JToken token = JToken.Load(reader); if (token is JArray) { - object[] results = token.Children().Select(item => TryDeserializeIComparable(item, serializer)).ToArray(); + object?[] results = token.Children().Select(item => TryDeserializeIComparable(item, serializer)).ToArray(); return results; } else @@ -107,24 +105,17 @@ private static object TryDeserializeIComparable(JsonReader reader, JsonSerialize } } - private static object TryDeserializeIComparable(JToken token, JsonSerializer serializer) + private static object? TryDeserializeIComparable(JToken token, JsonSerializer serializer) { - if (!token.HasValues || token[nameof(ValueUnit.Unit)] == null || token[nameof(ValueUnit.Value)] == null) - { - var localSerializer = new JsonSerializer - { - TypeNameHandling = serializer.TypeNameHandling, - }; - return token.ToObject(localSerializer); - } - else + JToken? unitToken = token[nameof(ValueUnit.Unit)]; + JToken? valueToken = token[nameof(ValueUnit.Value)]; + if (unitToken != null && valueToken != null) { - return new ValueUnit - { - Unit = token[nameof(ValueUnit.Unit)].ToString(), - Value = token[nameof(ValueUnit.Value)].ToObject() - }; + return new ValueUnit { Unit = unitToken.ToString(), Value = valueToken.ToObject() }; } + + var localSerializer = new JsonSerializer { TypeNameHandling = serializer.TypeNameHandling, }; + return token.ToObject(localSerializer); } /// @@ -134,7 +125,7 @@ private static object TryDeserializeIComparable(JToken token, JsonSerializer ser /// The value to write. /// The calling serializer. /// Can't serialize 'null' value. - public override void WriteJson(JsonWriter writer, object obj, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object? obj, JsonSerializer serializer) { // ValueUnit should be written as usual (but read in a custom way) if (obj is ValueUnit valueUnit) @@ -165,6 +156,10 @@ public override void WriteJson(JsonWriter writer, object obj, JsonSerializer ser { serializer.Serialize(writer, ToValueUnit(quantity)); } + else if (obj is null) + { + serializer.Serialize(writer, null); + } else { throw new NotSupportedException($"Unsupported type: {obj.GetType()}"); @@ -195,8 +190,8 @@ private static ValueUnit ToValueUnit(IQuantity value) /// private class ValueUnit { - public string Unit { get; [UsedImplicitly] set; } - public double Value { get; [UsedImplicitly] set; } + public string Unit { get; set; } = null!; + public double Value { get; set; } } #region Can Convert From 1bd9cc8fc42f334ec6a4cc7c60f92f2acd3f7caa Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 23:18:23 +0100 Subject: [PATCH 17/66] Rename json field XmlDoc to XmlDocSummary --- CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs | 2 +- CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs | 2 +- CodeGen/JsonTypes/Quantity.cs | 2 +- Common/UnitDefinitions/Acceleration.json | 2 +- Common/UnitDefinitions/AmountOfSubstance.json | 2 +- Common/UnitDefinitions/AmplitudeRatio.json | 2 +- Common/UnitDefinitions/Angle.json | 2 +- Common/UnitDefinitions/ApparentEnergy.json | 2 +- Common/UnitDefinitions/ApparentPower.json | 2 +- Common/UnitDefinitions/Area.json | 2 +- Common/UnitDefinitions/AreaDensity.json | 2 +- Common/UnitDefinitions/AreaMomentOfInertia.json | 2 +- Common/UnitDefinitions/BitRate.json | 2 +- Common/UnitDefinitions/BrakeSpecificFuelConsumption.json | 2 +- Common/UnitDefinitions/Capacitance.json | 2 +- Common/UnitDefinitions/CoefficientOfThermalExpansion.json | 2 +- Common/UnitDefinitions/Density.json | 2 +- Common/UnitDefinitions/Duration.json | 2 +- Common/UnitDefinitions/DynamicViscosity.json | 2 +- Common/UnitDefinitions/ElectricAdmittance.json | 2 +- Common/UnitDefinitions/ElectricCharge.json | 2 +- Common/UnitDefinitions/ElectricChargeDensity.json | 2 +- Common/UnitDefinitions/ElectricConductance.json | 2 +- Common/UnitDefinitions/ElectricConductivity.json | 2 +- Common/UnitDefinitions/ElectricCurrent.json | 2 +- Common/UnitDefinitions/ElectricCurrentDensity.json | 2 +- Common/UnitDefinitions/ElectricCurrentGradient.json | 2 +- Common/UnitDefinitions/ElectricField.json | 2 +- Common/UnitDefinitions/ElectricInductance.json | 2 +- Common/UnitDefinitions/ElectricPotential.json | 2 +- Common/UnitDefinitions/ElectricPotentialAc.json | 2 +- Common/UnitDefinitions/ElectricPotentialChangeRate.json | 2 +- Common/UnitDefinitions/ElectricPotentialDc.json | 2 +- Common/UnitDefinitions/ElectricResistance.json | 2 +- Common/UnitDefinitions/ElectricResistivity.json | 2 +- Common/UnitDefinitions/ElectricSurfaceChargeDensity.json | 2 +- Common/UnitDefinitions/Energy.json | 2 +- Common/UnitDefinitions/Entropy.json | 2 +- Common/UnitDefinitions/Force.json | 2 +- Common/UnitDefinitions/ForceChangeRate.json | 2 +- Common/UnitDefinitions/ForcePerLength.json | 2 +- Common/UnitDefinitions/Frequency.json | 2 +- Common/UnitDefinitions/FuelEfficiency.json | 2 +- Common/UnitDefinitions/HeatFlux.json | 2 +- Common/UnitDefinitions/HeatTransferCoefficient.json | 2 +- Common/UnitDefinitions/Illuminance.json | 2 +- Common/UnitDefinitions/Information.json | 2 +- Common/UnitDefinitions/Irradiance.json | 2 +- Common/UnitDefinitions/Irradiation.json | 2 +- Common/UnitDefinitions/KinematicViscosity.json | 2 +- Common/UnitDefinitions/LapseRate.json | 2 +- Common/UnitDefinitions/Length.json | 2 +- Common/UnitDefinitions/Level.json | 2 +- Common/UnitDefinitions/LinearDensity.json | 2 +- Common/UnitDefinitions/LinearPowerDensity.json | 2 +- Common/UnitDefinitions/Luminosity.json | 2 +- Common/UnitDefinitions/LuminousFlux.json | 2 +- Common/UnitDefinitions/LuminousIntensity.json | 2 +- Common/UnitDefinitions/MagneticField.json | 2 +- Common/UnitDefinitions/MagneticFlux.json | 2 +- Common/UnitDefinitions/Magnetization.json | 2 +- Common/UnitDefinitions/Mass.json | 2 +- Common/UnitDefinitions/MassConcentration.json | 2 +- Common/UnitDefinitions/MassFlow.json | 2 +- Common/UnitDefinitions/MassFlux.json | 2 +- Common/UnitDefinitions/MassFraction.json | 2 +- Common/UnitDefinitions/MassMomentOfInertia.json | 2 +- Common/UnitDefinitions/MolarEnergy.json | 2 +- Common/UnitDefinitions/MolarEntropy.json | 2 +- Common/UnitDefinitions/MolarMass.json | 2 +- Common/UnitDefinitions/Molarity.json | 2 +- Common/UnitDefinitions/Permeability.json | 2 +- Common/UnitDefinitions/Permittivity.json | 2 +- Common/UnitDefinitions/Power.json | 2 +- Common/UnitDefinitions/PowerDensity.json | 2 +- Common/UnitDefinitions/PowerRatio.json | 2 +- Common/UnitDefinitions/Pressure.json | 2 +- Common/UnitDefinitions/PressureChangeRate.json | 2 +- Common/UnitDefinitions/Ratio.json | 2 +- Common/UnitDefinitions/RatioChangeRate.json | 2 +- Common/UnitDefinitions/ReactiveEnergy.json | 2 +- Common/UnitDefinitions/ReactivePower.json | 2 +- Common/UnitDefinitions/ReciprocalArea.json | 2 +- Common/UnitDefinitions/ReciprocalLength.json | 2 +- Common/UnitDefinitions/RelativeHumidity.json | 2 +- Common/UnitDefinitions/RotationalAcceleration.json | 2 +- Common/UnitDefinitions/RotationalSpeed.json | 2 +- Common/UnitDefinitions/RotationalStiffness.json | 2 +- Common/UnitDefinitions/RotationalStiffnessPerLength.json | 2 +- Common/UnitDefinitions/Scalar.json | 2 +- Common/UnitDefinitions/SolidAngle.json | 2 +- Common/UnitDefinitions/SpecificEnergy.json | 2 +- Common/UnitDefinitions/SpecificEntropy.json | 2 +- Common/UnitDefinitions/SpecificFuelConsumption.json | 2 +- Common/UnitDefinitions/SpecificVolume.json | 2 +- Common/UnitDefinitions/SpecificWeight.json | 2 +- Common/UnitDefinitions/Speed.json | 2 +- Common/UnitDefinitions/StandardVolumeFlow.json | 2 +- Common/UnitDefinitions/Temperature.json | 2 +- Common/UnitDefinitions/TemperatureChangeRate.json | 2 +- Common/UnitDefinitions/TemperatureDelta.json | 2 +- Common/UnitDefinitions/ThermalConductivity.json | 2 +- Common/UnitDefinitions/ThermalResistance.json | 2 +- Common/UnitDefinitions/Torque.json | 2 +- Common/UnitDefinitions/TorquePerLength.json | 2 +- Common/UnitDefinitions/Turbidity.json | 2 +- Common/UnitDefinitions/VitaminA.json | 2 +- Common/UnitDefinitions/Volume.json | 2 +- Common/UnitDefinitions/VolumeConcentration.json | 2 +- Common/UnitDefinitions/VolumeFlow.json | 2 +- Common/UnitDefinitions/VolumePerLength.json | 2 +- Common/UnitDefinitions/VolumetricHeatCapacity.json | 2 +- Common/UnitDefinitions/WarpingMomentOfInertia.json | 2 +- 113 files changed, 113 insertions(+), 113 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 4982d93680..12b12368b4 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -30,7 +30,7 @@ namespace UnitsNet Writer.WL($@" /// /// - /// {_quantity.XmlDoc} + /// {_quantity.XmlDocSummary} /// "); Writer.WLCondition(_quantity.XmlDocRemarks.HasText(), $@" diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 1b2c270d82..1ed7302dd7 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -61,7 +61,7 @@ namespace UnitsNet Writer.WL($@" /// /// - /// {_quantity.XmlDoc} + /// {_quantity.XmlDocSummary} /// "); Writer.WLCondition(_quantity.XmlDocRemarks.HasText(), $@" diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index 884afd60e2..4534af2eb7 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -20,7 +20,7 @@ internal class Quantity public string Name; public Unit[] Units = Array.Empty(); public string XmlDocRemarks; - public string XmlDoc; // TODO Rename to XmlDocSummary + public string XmlDocSummary; public string ObsoleteText; // 0649 Field is never assigned to diff --git a/Common/UnitDefinitions/Acceleration.json b/Common/UnitDefinitions/Acceleration.json index db4627d2d6..f50487e981 100644 --- a/Common/UnitDefinitions/Acceleration.json +++ b/Common/UnitDefinitions/Acceleration.json @@ -1,7 +1,7 @@ { "Name": "Acceleration", "ConversionBaseUnit": "MeterPerSecondSquared", - "XmlDoc": "Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration.", + "XmlDocSummary": "Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration.", "BaseDimensions": { "L": 1, "T": -2 diff --git a/Common/UnitDefinitions/AmountOfSubstance.json b/Common/UnitDefinitions/AmountOfSubstance.json index d90a962f71..6619474bb5 100644 --- a/Common/UnitDefinitions/AmountOfSubstance.json +++ b/Common/UnitDefinitions/AmountOfSubstance.json @@ -1,7 +1,7 @@ { "Name": "AmountOfSubstance", "ConversionBaseUnit": "Mole", - "XmlDoc": "Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals.", + "XmlDocSummary": "Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals.", "BaseDimensions": { "N": 1 }, diff --git a/Common/UnitDefinitions/AmplitudeRatio.json b/Common/UnitDefinitions/AmplitudeRatio.json index 23c8942e47..7fcaa0d8e9 100644 --- a/Common/UnitDefinitions/AmplitudeRatio.json +++ b/Common/UnitDefinitions/AmplitudeRatio.json @@ -3,7 +3,7 @@ "ConversionBaseUnit": "DecibelVolt", "Logarithmic": "True", "LogarithmicScalingFactor": "2", - "XmlDoc": "The strength of a signal expressed in decibels (dB) relative to one volt RMS.", + "XmlDocSummary": "The strength of a signal expressed in decibels (dB) relative to one volt RMS.", "Units": [ { "SingularName": "DecibelVolt", diff --git a/Common/UnitDefinitions/Angle.json b/Common/UnitDefinitions/Angle.json index 2adf55ad66..57bd0c2f0b 100644 --- a/Common/UnitDefinitions/Angle.json +++ b/Common/UnitDefinitions/Angle.json @@ -1,7 +1,7 @@ { "Name": "Angle", "ConversionBaseUnit": "Degree", - "XmlDoc": "In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.", + "XmlDocSummary": "In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.", "Units": [ { "SingularName": "Radian", diff --git a/Common/UnitDefinitions/ApparentEnergy.json b/Common/UnitDefinitions/ApparentEnergy.json index 2a0e048864..4494816c2f 100644 --- a/Common/UnitDefinitions/ApparentEnergy.json +++ b/Common/UnitDefinitions/ApparentEnergy.json @@ -1,7 +1,7 @@ { "Name": "ApparentEnergy", "ConversionBaseUnit": "VoltampereHour", - "XmlDoc": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.", + "XmlDocSummary": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/ApparentPower.json b/Common/UnitDefinitions/ApparentPower.json index 4d1e224f10..a611dc935b 100644 --- a/Common/UnitDefinitions/ApparentPower.json +++ b/Common/UnitDefinitions/ApparentPower.json @@ -1,7 +1,7 @@ { "Name": "ApparentPower", "ConversionBaseUnit": "Voltampere", - "XmlDoc": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.", + "XmlDocSummary": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/Area.json b/Common/UnitDefinitions/Area.json index 365352b412..cf150329ab 100644 --- a/Common/UnitDefinitions/Area.json +++ b/Common/UnitDefinitions/Area.json @@ -1,7 +1,7 @@ { "Name": "Area", "ConversionBaseUnit": "SquareMeter", - "XmlDoc": "Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept).", + "XmlDocSummary": "Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept).", "BaseDimensions": { "L": 2 }, diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index 18c748d875..87524e09c9 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -1,7 +1,7 @@ { "Name": "AreaDensity", "ConversionBaseUnit": "KilogramPerSquareMeter", - "XmlDoc": "The area density of a two-dimensional object is calculated as the mass per unit area.", + "XmlDocSummary": "The area density of a two-dimensional object is calculated as the mass per unit area.", "BaseDimensions": { "L": -2, "M": 1 diff --git a/Common/UnitDefinitions/AreaMomentOfInertia.json b/Common/UnitDefinitions/AreaMomentOfInertia.json index b780a45854..28e9080cc8 100644 --- a/Common/UnitDefinitions/AreaMomentOfInertia.json +++ b/Common/UnitDefinitions/AreaMomentOfInertia.json @@ -1,7 +1,7 @@ { "Name": "AreaMomentOfInertia", "ConversionBaseUnit": "MeterToTheFourth", - "XmlDoc": "A geometric property of an area that reflects how its points are distributed with regard to an axis.", + "XmlDocSummary": "A geometric property of an area that reflects how its points are distributed with regard to an axis.", "BaseDimensions": { "L": 4 }, diff --git a/Common/UnitDefinitions/BitRate.json b/Common/UnitDefinitions/BitRate.json index d1a8741587..bb3ddf14f2 100644 --- a/Common/UnitDefinitions/BitRate.json +++ b/Common/UnitDefinitions/BitRate.json @@ -2,7 +2,7 @@ "Name": "BitRate", "ConversionBaseUnit": "BitPerSecond", "ValueType": "decimal", - "XmlDoc": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.", + "XmlDocSummary": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate", "BaseDimensions": { "T": -1 }, "Units": [ diff --git a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json index c6d3130457..37ef52e093 100644 --- a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json +++ b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json @@ -1,7 +1,7 @@ { "Name": "BrakeSpecificFuelConsumption", "ConversionBaseUnit": "KilogramPerJoule", - "XmlDoc": "Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.", + "XmlDocSummary": "Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.", "BaseDimensions": { "L": -2, "T": 2 diff --git a/Common/UnitDefinitions/Capacitance.json b/Common/UnitDefinitions/Capacitance.json index 16068b00df..87ad7082f0 100644 --- a/Common/UnitDefinitions/Capacitance.json +++ b/Common/UnitDefinitions/Capacitance.json @@ -1,7 +1,7 @@ { "Name": "Capacitance", "ConversionBaseUnit": "Farad", - "XmlDoc": "Capacitance is the ability of a body to store an electric charge.", + "XmlDocSummary": "Capacitance is the ability of a body to store an electric charge.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Capacitance", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json index 1c3630b9c6..a7c26f8008 100644 --- a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json +++ b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json @@ -1,7 +1,7 @@ { "Name": "CoefficientOfThermalExpansion", "ConversionBaseUnit": "InverseKelvin", - "XmlDoc": "A unit that represents a fractional change in size in response to a change in temperature.", + "XmlDocSummary": "A unit that represents a fractional change in size in response to a change in temperature.", "BaseDimensions": { "Θ": -1 }, diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json index a8bed90a85..66ac279f20 100644 --- a/Common/UnitDefinitions/Density.json +++ b/Common/UnitDefinitions/Density.json @@ -1,7 +1,7 @@ { "Name": "Density", "ConversionBaseUnit": "KilogramPerCubicMeter", - "XmlDoc": "The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume.", + "XmlDocSummary": "The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Density", "BaseDimensions": { "L": -3, diff --git a/Common/UnitDefinitions/Duration.json b/Common/UnitDefinitions/Duration.json index ee7a2f81ca..fb53ed56cf 100644 --- a/Common/UnitDefinitions/Duration.json +++ b/Common/UnitDefinitions/Duration.json @@ -1,7 +1,7 @@ { "Name": "Duration", "ConversionBaseUnit": "Second", - "XmlDoc": "Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them.", + "XmlDocSummary": "Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them.", "BaseDimensions": { "T": 1 }, diff --git a/Common/UnitDefinitions/DynamicViscosity.json b/Common/UnitDefinitions/DynamicViscosity.json index c14e04f7b4..ab13130f49 100644 --- a/Common/UnitDefinitions/DynamicViscosity.json +++ b/Common/UnitDefinitions/DynamicViscosity.json @@ -1,7 +1,7 @@ { "Name": "DynamicViscosity", "ConversionBaseUnit": "NewtonSecondPerMeterSquared", - "XmlDoc": "The dynamic (shear) viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds", + "XmlDocSummary": "The dynamic (shear) viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/ElectricAdmittance.json b/Common/UnitDefinitions/ElectricAdmittance.json index bf07ea62e1..37a30884af 100644 --- a/Common/UnitDefinitions/ElectricAdmittance.json +++ b/Common/UnitDefinitions/ElectricAdmittance.json @@ -1,7 +1,7 @@ { "Name": "ElectricAdmittance", "ConversionBaseUnit": "Siemens", - "XmlDoc": "Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S).", + "XmlDocSummary": "Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S).", "BaseDimensions": { "L": -2, "M": -1, diff --git a/Common/UnitDefinitions/ElectricCharge.json b/Common/UnitDefinitions/ElectricCharge.json index 54a00b15c2..249e8c2286 100644 --- a/Common/UnitDefinitions/ElectricCharge.json +++ b/Common/UnitDefinitions/ElectricCharge.json @@ -1,7 +1,7 @@ { "Name": "ElectricCharge", "ConversionBaseUnit": "Coulomb", - "XmlDoc": "Electric charge is the physical property of matter that causes it to experience a force when placed in an electromagnetic field.", + "XmlDocSummary": "Electric charge is the physical property of matter that causes it to experience a force when placed in an electromagnetic field.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_charge", "BaseDimensions": { "T": 1, diff --git a/Common/UnitDefinitions/ElectricChargeDensity.json b/Common/UnitDefinitions/ElectricChargeDensity.json index 1742e046f7..0ccb841d3a 100644 --- a/Common/UnitDefinitions/ElectricChargeDensity.json +++ b/Common/UnitDefinitions/ElectricChargeDensity.json @@ -1,7 +1,7 @@ { "Name": "ElectricChargeDensity", "ConversionBaseUnit": "CoulombPerCubicMeter", - "XmlDoc": "In electromagnetism, charge density is a measure of the amount of electric charge per volume.", + "XmlDocSummary": "In electromagnetism, charge density is a measure of the amount of electric charge per volume.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Charge_density", "BaseDimensions": { "L": -3, diff --git a/Common/UnitDefinitions/ElectricConductance.json b/Common/UnitDefinitions/ElectricConductance.json index 16ec1b6911..7290e67157 100644 --- a/Common/UnitDefinitions/ElectricConductance.json +++ b/Common/UnitDefinitions/ElectricConductance.json @@ -1,7 +1,7 @@ { "Name": "ElectricConductance", "ConversionBaseUnit": "Siemens", - "XmlDoc": "The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor.", + "XmlDocSummary": "The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/ElectricConductivity.json b/Common/UnitDefinitions/ElectricConductivity.json index d1a49af29d..b4f0f5f262 100644 --- a/Common/UnitDefinitions/ElectricConductivity.json +++ b/Common/UnitDefinitions/ElectricConductivity.json @@ -1,7 +1,7 @@ { "Name": "ElectricConductivity", "ConversionBaseUnit": "SiemensPerMeter", - "XmlDoc": "Electrical conductivity or specific conductance is the reciprocal of electrical resistivity, and measures a material's ability to conduct an electric current.", + "XmlDocSummary": "Electrical conductivity or specific conductance is the reciprocal of electrical resistivity, and measures a material's ability to conduct an electric current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity", "BaseDimensions": { "L": -3, diff --git a/Common/UnitDefinitions/ElectricCurrent.json b/Common/UnitDefinitions/ElectricCurrent.json index 0d41c4fcc9..a1dd6b71e9 100644 --- a/Common/UnitDefinitions/ElectricCurrent.json +++ b/Common/UnitDefinitions/ElectricCurrent.json @@ -1,7 +1,7 @@ { "Name": "ElectricCurrent", "ConversionBaseUnit": "Ampere", - "XmlDoc": "An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma.", + "XmlDocSummary": "An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma.", "BaseDimensions": { "I": 1 }, diff --git a/Common/UnitDefinitions/ElectricCurrentDensity.json b/Common/UnitDefinitions/ElectricCurrentDensity.json index 2d6638e9ca..e3826f9c81 100644 --- a/Common/UnitDefinitions/ElectricCurrentDensity.json +++ b/Common/UnitDefinitions/ElectricCurrentDensity.json @@ -1,7 +1,7 @@ { "Name": "ElectricCurrentDensity", "ConversionBaseUnit": "AmperePerSquareMeter", - "XmlDoc": "In electromagnetism, current density is the electric current per unit area of cross section.", + "XmlDocSummary": "In electromagnetism, current density is the electric current per unit area of cross section.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Current_density", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/ElectricCurrentGradient.json b/Common/UnitDefinitions/ElectricCurrentGradient.json index 8d5281a601..599ba2cf6a 100644 --- a/Common/UnitDefinitions/ElectricCurrentGradient.json +++ b/Common/UnitDefinitions/ElectricCurrentGradient.json @@ -1,7 +1,7 @@ { "Name": "ElectricCurrentGradient", "ConversionBaseUnit": "AmperePerSecond", - "XmlDoc": "In electromagnetism, the current gradient describes how the current changes in time.", + "XmlDocSummary": "In electromagnetism, the current gradient describes how the current changes in time.", "BaseDimensions": { "T": -1, "I": 1 diff --git a/Common/UnitDefinitions/ElectricField.json b/Common/UnitDefinitions/ElectricField.json index 9e3284c025..757d065fdf 100644 --- a/Common/UnitDefinitions/ElectricField.json +++ b/Common/UnitDefinitions/ElectricField.json @@ -1,7 +1,7 @@ { "Name": "ElectricField", "ConversionBaseUnit": "VoltPerMeter", - "XmlDoc": "An electric field is a force field that surrounds electric charges that attracts or repels other electric charges.", + "XmlDocSummary": "An electric field is a force field that surrounds electric charges that attracts or repels other electric charges.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_field", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/ElectricInductance.json b/Common/UnitDefinitions/ElectricInductance.json index 1b8e943fea..d4c6fac94d 100644 --- a/Common/UnitDefinitions/ElectricInductance.json +++ b/Common/UnitDefinitions/ElectricInductance.json @@ -1,7 +1,7 @@ { "Name": "ElectricInductance", "ConversionBaseUnit": "Henry", - "XmlDoc": "Inductance is a property of an electrical conductor which opposes a change in current.", + "XmlDocSummary": "Inductance is a property of an electrical conductor which opposes a change in current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inductance", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricPotential.json b/Common/UnitDefinitions/ElectricPotential.json index ed0c8466e4..cb35f1140b 100644 --- a/Common/UnitDefinitions/ElectricPotential.json +++ b/Common/UnitDefinitions/ElectricPotential.json @@ -1,7 +1,7 @@ { "Name": "ElectricPotential", "ConversionBaseUnit": "Volt", - "XmlDoc": "In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.", + "XmlDocSummary": "In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/ElectricPotentialAc.json b/Common/UnitDefinitions/ElectricPotentialAc.json index 642a5af934..21fea93861 100644 --- a/Common/UnitDefinitions/ElectricPotentialAc.json +++ b/Common/UnitDefinitions/ElectricPotentialAc.json @@ -1,7 +1,7 @@ { "Name": "ElectricPotentialAc", "ConversionBaseUnit": "VoltAc", - "XmlDoc": "The Electric Potential of a system known to use Alternating Current.", + "XmlDocSummary": "The Electric Potential of a system known to use Alternating Current.", "Units": [ { "SingularName": "VoltAc", diff --git a/Common/UnitDefinitions/ElectricPotentialChangeRate.json b/Common/UnitDefinitions/ElectricPotentialChangeRate.json index 775804e042..743026a403 100644 --- a/Common/UnitDefinitions/ElectricPotentialChangeRate.json +++ b/Common/UnitDefinitions/ElectricPotentialChangeRate.json @@ -1,7 +1,7 @@ { "Name": "ElectricPotentialChangeRate", "ConversionBaseUnit": "VoltPerSecond", - "XmlDoc": "ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time).", + "XmlDocSummary": "ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time).", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/ElectricPotentialDc.json b/Common/UnitDefinitions/ElectricPotentialDc.json index c8c6591118..6eee1e7f08 100644 --- a/Common/UnitDefinitions/ElectricPotentialDc.json +++ b/Common/UnitDefinitions/ElectricPotentialDc.json @@ -1,7 +1,7 @@ { "Name": "ElectricPotentialDc", "ConversionBaseUnit": "VoltDc", - "XmlDoc": "The Electric Potential of a system known to use Direct Current.", + "XmlDocSummary": "The Electric Potential of a system known to use Direct Current.", "Units": [ { "SingularName": "VoltDc", diff --git a/Common/UnitDefinitions/ElectricResistance.json b/Common/UnitDefinitions/ElectricResistance.json index b51f9e9fc1..00cd794802 100644 --- a/Common/UnitDefinitions/ElectricResistance.json +++ b/Common/UnitDefinitions/ElectricResistance.json @@ -1,7 +1,7 @@ { "Name": "ElectricResistance", "ConversionBaseUnit": "Ohm", - "XmlDoc": "The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.", + "XmlDocSummary": "The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/ElectricResistivity.json b/Common/UnitDefinitions/ElectricResistivity.json index 41624faf93..0bf07a492a 100644 --- a/Common/UnitDefinitions/ElectricResistivity.json +++ b/Common/UnitDefinitions/ElectricResistivity.json @@ -1,7 +1,7 @@ { "Name": "ElectricResistivity", "ConversionBaseUnit": "OhmMeter", - "XmlDoc": "Electrical resistivity (also known as resistivity, specific electrical resistance, or volume resistivity) is a fundamental property that quantifies how strongly a given material opposes the flow of electric current.", + "XmlDocSummary": "Electrical resistivity (also known as resistivity, specific electrical resistance, or volume resistivity) is a fundamental property that quantifies how strongly a given material opposes the flow of electric current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity", "BaseDimensions": { "L": 3, diff --git a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json index 305a1811ac..422e829f25 100644 --- a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json +++ b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json @@ -1,7 +1,7 @@ { "Name": "ElectricSurfaceChargeDensity", "ConversionBaseUnit": "CoulombPerSquareMeter", - "XmlDoc": "In electromagnetism, surface charge density is a measure of the amount of electric charge per surface area.", + "XmlDocSummary": "In electromagnetism, surface charge density is a measure of the amount of electric charge per surface area.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Charge_density", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/Energy.json b/Common/UnitDefinitions/Energy.json index 1c5602c3ae..d60d387d5f 100644 --- a/Common/UnitDefinitions/Energy.json +++ b/Common/UnitDefinitions/Energy.json @@ -1,7 +1,7 @@ { "Name": "Energy", "ConversionBaseUnit": "Joule", - "XmlDoc": "The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used.", + "XmlDocSummary": "The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/Entropy.json b/Common/UnitDefinitions/Entropy.json index 770b896ee9..91a5e8dac3 100644 --- a/Common/UnitDefinitions/Entropy.json +++ b/Common/UnitDefinitions/Entropy.json @@ -1,7 +1,7 @@ { "Name": "Entropy", "ConversionBaseUnit": "JoulePerKelvin", - "XmlDoc": "Entropy is an important concept in the branch of science known as thermodynamics. The idea of \"irreversibility\" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units", + "XmlDocSummary": "Entropy is an important concept in the branch of science known as thermodynamics. The idea of \"irreversibility\" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/Force.json b/Common/UnitDefinitions/Force.json index d50a8febc7..955793e61c 100644 --- a/Common/UnitDefinitions/Force.json +++ b/Common/UnitDefinitions/Force.json @@ -1,7 +1,7 @@ { "Name": "Force", "ConversionBaseUnit": "Newton", - "XmlDoc": "In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F.", + "XmlDocSummary": "In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F.", "BaseDimensions": { "L": 1, "M": 1, diff --git a/Common/UnitDefinitions/ForceChangeRate.json b/Common/UnitDefinitions/ForceChangeRate.json index 5f02e5b533..b11ce1fda1 100644 --- a/Common/UnitDefinitions/ForceChangeRate.json +++ b/Common/UnitDefinitions/ForceChangeRate.json @@ -1,7 +1,7 @@ { "Name": "ForceChangeRate", "ConversionBaseUnit": "NewtonPerSecond", - "XmlDoc": "Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time).", + "XmlDocSummary": "Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time).", "BaseDimensions": { "L": 1, "M": 1, diff --git a/Common/UnitDefinitions/ForcePerLength.json b/Common/UnitDefinitions/ForcePerLength.json index 2e8aed1b91..ddf6a5cd26 100644 --- a/Common/UnitDefinitions/ForcePerLength.json +++ b/Common/UnitDefinitions/ForcePerLength.json @@ -1,7 +1,7 @@ { "Name": "ForcePerLength", "ConversionBaseUnit": "NewtonPerMeter", - "XmlDoc": "The magnitude of force per unit length.", + "XmlDocSummary": "The magnitude of force per unit length.", "BaseDimensions": { "M": 1, "T": -2 diff --git a/Common/UnitDefinitions/Frequency.json b/Common/UnitDefinitions/Frequency.json index b5ebcb545d..232bf4b329 100644 --- a/Common/UnitDefinitions/Frequency.json +++ b/Common/UnitDefinitions/Frequency.json @@ -1,7 +1,7 @@ { "Name": "Frequency", "ConversionBaseUnit": "Hertz", - "XmlDoc": "The number of occurrences of a repeating event per unit time.", + "XmlDocSummary": "The number of occurrences of a repeating event per unit time.", "BaseDimensions": { "T": -1 }, diff --git a/Common/UnitDefinitions/FuelEfficiency.json b/Common/UnitDefinitions/FuelEfficiency.json index 81e30d4106..405630f068 100644 --- a/Common/UnitDefinitions/FuelEfficiency.json +++ b/Common/UnitDefinitions/FuelEfficiency.json @@ -1,7 +1,7 @@ { "Name": "FuelEfficiency", "ConversionBaseUnit": "LiterPer100Kilometers", - "XmlDoc": "Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as \"fuel consumption\" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).", + "XmlDocSummary": "Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as \"fuel consumption\" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fuel_efficiency", "Units": [{ "SingularName": "LiterPer100Kilometers", diff --git a/Common/UnitDefinitions/HeatFlux.json b/Common/UnitDefinitions/HeatFlux.json index a3c573ce8e..439cec7fb4 100644 --- a/Common/UnitDefinitions/HeatFlux.json +++ b/Common/UnitDefinitions/HeatFlux.json @@ -1,7 +1,7 @@ { "Name": "HeatFlux", "ConversionBaseUnit": "WattPerSquareMeter", - "XmlDoc": "Heat flux is the flow of energy per unit of area per unit of time", + "XmlDocSummary": "Heat flux is the flow of energy per unit of area per unit of time", "BaseDimensions": { "M": 1, "T": -3 diff --git a/Common/UnitDefinitions/HeatTransferCoefficient.json b/Common/UnitDefinitions/HeatTransferCoefficient.json index c904d3bfc6..24118ca7eb 100644 --- a/Common/UnitDefinitions/HeatTransferCoefficient.json +++ b/Common/UnitDefinitions/HeatTransferCoefficient.json @@ -1,7 +1,7 @@ { "Name": "HeatTransferCoefficient", "ConversionBaseUnit": "WattPerSquareMeterKelvin", - "XmlDoc": "The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT)", + "XmlDocSummary": "The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT)", "BaseDimensions": { "M": 1, "T": -3, diff --git a/Common/UnitDefinitions/Illuminance.json b/Common/UnitDefinitions/Illuminance.json index ac931d6092..f8d80912e9 100644 --- a/Common/UnitDefinitions/Illuminance.json +++ b/Common/UnitDefinitions/Illuminance.json @@ -1,7 +1,7 @@ { "Name": "Illuminance", "ConversionBaseUnit": "Lux", - "XmlDoc": "In photometry, illuminance is the total luminous flux incident on a surface, per unit area.", + "XmlDocSummary": "In photometry, illuminance is the total luminous flux incident on a surface, per unit area.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Illuminance", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/Information.json b/Common/UnitDefinitions/Information.json index 3646353415..074088a971 100644 --- a/Common/UnitDefinitions/Information.json +++ b/Common/UnitDefinitions/Information.json @@ -2,7 +2,7 @@ "Name": "Information", "ConversionBaseUnit": "Bit", "ValueType": "decimal", - "XmlDoc": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.", + "XmlDocSummary": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.", "Units": [ { "SingularName": "Byte", diff --git a/Common/UnitDefinitions/Irradiance.json b/Common/UnitDefinitions/Irradiance.json index a1dee85b1e..88f51d186c 100644 --- a/Common/UnitDefinitions/Irradiance.json +++ b/Common/UnitDefinitions/Irradiance.json @@ -1,7 +1,7 @@ { "Name": "Irradiance", "ConversionBaseUnit": "WattPerSquareMeter", - "XmlDoc": "Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface.", + "XmlDocSummary": "Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface.", "BaseDimensions": { "M": 1, "T": -3 diff --git a/Common/UnitDefinitions/Irradiation.json b/Common/UnitDefinitions/Irradiation.json index 07e33181e8..8a0b6a7cc9 100644 --- a/Common/UnitDefinitions/Irradiation.json +++ b/Common/UnitDefinitions/Irradiation.json @@ -1,7 +1,7 @@ { "Name": "Irradiation", "ConversionBaseUnit": "JoulePerSquareMeter", - "XmlDoc": "Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources.", + "XmlDocSummary": "Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Irradiation", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/KinematicViscosity.json b/Common/UnitDefinitions/KinematicViscosity.json index 85df2707f5..cc571c7bda 100644 --- a/Common/UnitDefinitions/KinematicViscosity.json +++ b/Common/UnitDefinitions/KinematicViscosity.json @@ -1,7 +1,7 @@ { "Name": "KinematicViscosity", "ConversionBaseUnit": "SquareMeterPerSecond", - "XmlDoc": "The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress.", + "XmlDocSummary": "The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Viscosity", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/LapseRate.json b/Common/UnitDefinitions/LapseRate.json index c55cbb2e8f..6fd432ab4a 100644 --- a/Common/UnitDefinitions/LapseRate.json +++ b/Common/UnitDefinitions/LapseRate.json @@ -1,7 +1,7 @@ { "Name": "LapseRate", "ConversionBaseUnit": "DegreeCelsiusPerKilometer", - "XmlDoc": "Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude.", + "XmlDocSummary": "Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude.", "BaseDimensions": { "L": -1, "Θ": 1 diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json index 3a533a2f1a..1d0de3f298 100644 --- a/Common/UnitDefinitions/Length.json +++ b/Common/UnitDefinitions/Length.json @@ -1,7 +1,7 @@ { "Name": "Length", "ConversionBaseUnit": "Meter", - "XmlDoc": "Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units.", + "XmlDocSummary": "Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units.", "BaseDimensions": { "L": 1 }, diff --git a/Common/UnitDefinitions/Level.json b/Common/UnitDefinitions/Level.json index c5e7cfba60..8091eb421c 100644 --- a/Common/UnitDefinitions/Level.json +++ b/Common/UnitDefinitions/Level.json @@ -3,7 +3,7 @@ "ConversionBaseUnit": "Decibel", "Logarithmic": "True", "LogarithmicScalingFactor": "1", - "XmlDoc": "Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units.", + "XmlDocSummary": "Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units.", "Units": [ { "SingularName": "Decibel", diff --git a/Common/UnitDefinitions/LinearDensity.json b/Common/UnitDefinitions/LinearDensity.json index 87b6176508..c4caefc8b6 100644 --- a/Common/UnitDefinitions/LinearDensity.json +++ b/Common/UnitDefinitions/LinearDensity.json @@ -1,7 +1,7 @@ { "Name": "LinearDensity", "ConversionBaseUnit": "KilogramPerMeter", - "XmlDoc": "The Linear Density, or more precisely, the linear mass density, of a substance is its mass per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", + "XmlDocSummary": "The Linear Density, or more precisely, the linear mass density, of a substance is its mass per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Linear_density", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/LinearPowerDensity.json b/Common/UnitDefinitions/LinearPowerDensity.json index 81b374fd39..f9fe68c480 100644 --- a/Common/UnitDefinitions/LinearPowerDensity.json +++ b/Common/UnitDefinitions/LinearPowerDensity.json @@ -1,7 +1,7 @@ { "Name": "LinearPowerDensity", "ConversionBaseUnit": "WattPerMeter", - "XmlDoc": "The Linear Power Density of a substance is its power per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", + "XmlDocSummary": "The Linear Power Density of a substance is its power per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Linear_density", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Luminosity.json b/Common/UnitDefinitions/Luminosity.json index 1f949e02ea..f4e5834f05 100644 --- a/Common/UnitDefinitions/Luminosity.json +++ b/Common/UnitDefinitions/Luminosity.json @@ -1,7 +1,7 @@ { "Name": "Luminosity", "ConversionBaseUnit": "Watt", - "XmlDoc": "Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object.", + "XmlDocSummary": "Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/LuminousFlux.json b/Common/UnitDefinitions/LuminousFlux.json index 9676c42d6e..f1c3071efb 100644 --- a/Common/UnitDefinitions/LuminousFlux.json +++ b/Common/UnitDefinitions/LuminousFlux.json @@ -1,7 +1,7 @@ { "Name": "LuminousFlux", "ConversionBaseUnit": "Lumen", - "XmlDoc": "In photometry, luminous flux or luminous power is the measure of the perceived power of light.", + "XmlDocSummary": "In photometry, luminous flux or luminous power is the measure of the perceived power of light.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminous_flux", "BaseDimensions": { "J": 1 diff --git a/Common/UnitDefinitions/LuminousIntensity.json b/Common/UnitDefinitions/LuminousIntensity.json index 5f0bca8b87..65e007e9e6 100644 --- a/Common/UnitDefinitions/LuminousIntensity.json +++ b/Common/UnitDefinitions/LuminousIntensity.json @@ -1,7 +1,7 @@ { "Name": "LuminousIntensity", "ConversionBaseUnit": "Candela", - "XmlDoc": "In photometry, luminous intensity is a measure of the wavelength-weighted power emitted by a light source in a particular direction per unit solid angle, based on the luminosity function, a standardized model of the sensitivity of the human eye.", + "XmlDocSummary": "In photometry, luminous intensity is a measure of the wavelength-weighted power emitted by a light source in a particular direction per unit solid angle, based on the luminosity function, a standardized model of the sensitivity of the human eye.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminous_intensity", "BaseDimensions": { "J": 1 diff --git a/Common/UnitDefinitions/MagneticField.json b/Common/UnitDefinitions/MagneticField.json index 6e72a0c517..5f72f0f116 100644 --- a/Common/UnitDefinitions/MagneticField.json +++ b/Common/UnitDefinitions/MagneticField.json @@ -1,7 +1,7 @@ { "Name": "MagneticField", "ConversionBaseUnit": "Tesla", - "XmlDoc": "A magnetic field is a force field that is created by moving electric charges (electric currents) and magnetic dipoles, and exerts a force on other nearby moving charges and magnetic dipoles.", + "XmlDocSummary": "A magnetic field is a force field that is created by moving electric charges (electric currents) and magnetic dipoles, and exerts a force on other nearby moving charges and magnetic dipoles.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetic_field", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/MagneticFlux.json b/Common/UnitDefinitions/MagneticFlux.json index 9b2f348306..3e11c34eb7 100644 --- a/Common/UnitDefinitions/MagneticFlux.json +++ b/Common/UnitDefinitions/MagneticFlux.json @@ -1,7 +1,7 @@ { "Name": "MagneticFlux", "ConversionBaseUnit": "Weber", - "XmlDoc": "In physics, specifically electromagnetism, the magnetic flux through a surface is the surface integral of the normal component of the magnetic field B passing through that surface.", + "XmlDocSummary": "In physics, specifically electromagnetism, the magnetic flux through a surface is the surface integral of the normal component of the magnetic field B passing through that surface.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetic_flux", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Magnetization.json b/Common/UnitDefinitions/Magnetization.json index 287cab25ba..69cea51618 100644 --- a/Common/UnitDefinitions/Magnetization.json +++ b/Common/UnitDefinitions/Magnetization.json @@ -1,7 +1,7 @@ { "Name": "Magnetization", "ConversionBaseUnit": "AmperePerMeter", - "XmlDoc": "In classical electromagnetism, magnetization is the vector field that expresses the density of permanent or induced magnetic dipole moments in a magnetic material.", + "XmlDocSummary": "In classical electromagnetism, magnetization is the vector field that expresses the density of permanent or induced magnetic dipole moments in a magnetic material.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetization", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/Mass.json b/Common/UnitDefinitions/Mass.json index e9d0066a73..0529e0d880 100644 --- a/Common/UnitDefinitions/Mass.json +++ b/Common/UnitDefinitions/Mass.json @@ -1,7 +1,7 @@ { "Name": "Mass", "ConversionBaseUnit": "Kilogram", - "XmlDoc": "In physics, mass (from Greek μᾶζα \"barley cake, lump [of dough]\") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg).", + "XmlDocSummary": "In physics, mass (from Greek μᾶζα \"barley cake, lump [of dough]\") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg).", "BaseDimensions": { "M": 1 }, diff --git a/Common/UnitDefinitions/MassConcentration.json b/Common/UnitDefinitions/MassConcentration.json index 03a525a120..2b50d72a17 100644 --- a/Common/UnitDefinitions/MassConcentration.json +++ b/Common/UnitDefinitions/MassConcentration.json @@ -1,7 +1,7 @@ { "Name": "MassConcentration", "ConversionBaseUnit": "KilogramPerCubicMeter", - "XmlDoc": "In chemistry, the mass concentration ρi (or γi) is defined as the mass of a constituent mi divided by the volume of the mixture V", + "XmlDocSummary": "In chemistry, the mass concentration ρi (or γi) is defined as the mass of a constituent mi divided by the volume of the mixture V", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Mass_concentration_(chemistry)", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/MassFlow.json b/Common/UnitDefinitions/MassFlow.json index aff587dd6b..4c5a0ff33c 100644 --- a/Common/UnitDefinitions/MassFlow.json +++ b/Common/UnitDefinitions/MassFlow.json @@ -1,7 +1,7 @@ { "Name": "MassFlow", "ConversionBaseUnit": "GramPerSecond", - "XmlDoc": "Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time).", + "XmlDocSummary": "Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time).", "BaseDimensions": { "M": 1, "T": -1 diff --git a/Common/UnitDefinitions/MassFlux.json b/Common/UnitDefinitions/MassFlux.json index be7fb9911a..6443eec441 100644 --- a/Common/UnitDefinitions/MassFlux.json +++ b/Common/UnitDefinitions/MassFlux.json @@ -1,7 +1,7 @@ { "Name": "MassFlux", "ConversionBaseUnit": "KilogramPerSecondPerSquareMeter", - "XmlDoc": "Mass flux is the mass flow rate per unit area.", + "XmlDocSummary": "Mass flux is the mass flow rate per unit area.", "BaseDimensions": { "L": -2, "M": 1, diff --git a/Common/UnitDefinitions/MassFraction.json b/Common/UnitDefinitions/MassFraction.json index 720e9efd4f..cb2f2a1180 100644 --- a/Common/UnitDefinitions/MassFraction.json +++ b/Common/UnitDefinitions/MassFraction.json @@ -1,7 +1,7 @@ { "Name": "MassFraction", "ConversionBaseUnit": "DecimalFraction", - "XmlDoc": "The mass fraction is defined as the mass of a constituent divided by the total mass of the mixture.", + "XmlDocSummary": "The mass fraction is defined as the mass of a constituent divided by the total mass of the mixture.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Mass_fraction_(chemistry)", "Units": [ { diff --git a/Common/UnitDefinitions/MassMomentOfInertia.json b/Common/UnitDefinitions/MassMomentOfInertia.json index 57f4699e3e..3fd613d07b 100644 --- a/Common/UnitDefinitions/MassMomentOfInertia.json +++ b/Common/UnitDefinitions/MassMomentOfInertia.json @@ -1,7 +1,7 @@ { "Name": "MassMomentOfInertia", "ConversionBaseUnit": "KilogramSquareMeter", - "XmlDoc": "A property of body reflects how its mass is distributed with regard to an axis.", + "XmlDocSummary": "A property of body reflects how its mass is distributed with regard to an axis.", "BaseDimensions": { "L": 2, "M": 1 diff --git a/Common/UnitDefinitions/MolarEnergy.json b/Common/UnitDefinitions/MolarEnergy.json index 88dcaa0de9..81dc5547dd 100644 --- a/Common/UnitDefinitions/MolarEnergy.json +++ b/Common/UnitDefinitions/MolarEnergy.json @@ -1,7 +1,7 @@ { "Name": "MolarEnergy", "ConversionBaseUnit": "JoulePerMole", - "XmlDoc": "Molar energy is the amount of energy stored in 1 mole of a substance.", + "XmlDocSummary": "Molar energy is the amount of energy stored in 1 mole of a substance.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/MolarEntropy.json b/Common/UnitDefinitions/MolarEntropy.json index 5a2d7ff1ef..6883c89652 100644 --- a/Common/UnitDefinitions/MolarEntropy.json +++ b/Common/UnitDefinitions/MolarEntropy.json @@ -1,7 +1,7 @@ { "Name": "MolarEntropy", "ConversionBaseUnit": "JoulePerMoleKelvin", - "XmlDoc": "Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.", + "XmlDocSummary": "Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/MolarMass.json b/Common/UnitDefinitions/MolarMass.json index 6105c7b2dc..69e15f99be 100644 --- a/Common/UnitDefinitions/MolarMass.json +++ b/Common/UnitDefinitions/MolarMass.json @@ -1,7 +1,7 @@ { "Name": "MolarMass", "ConversionBaseUnit": "KilogramPerMole", - "XmlDoc": "In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance.", + "XmlDocSummary": "In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance.", "BaseDimensions": { "M": 1, "N": -1 diff --git a/Common/UnitDefinitions/Molarity.json b/Common/UnitDefinitions/Molarity.json index 9ca7d6b912..cfb0163520 100644 --- a/Common/UnitDefinitions/Molarity.json +++ b/Common/UnitDefinitions/Molarity.json @@ -1,7 +1,7 @@ { "Name": "Molarity", "ConversionBaseUnit": "MolesPerCubicMeter", - "XmlDoc": "Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. ", + "XmlDocSummary": "Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. ", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Molar_concentration", "BaseDimensions": { "L": -3, diff --git a/Common/UnitDefinitions/Permeability.json b/Common/UnitDefinitions/Permeability.json index 793c5416fd..a0117ff339 100644 --- a/Common/UnitDefinitions/Permeability.json +++ b/Common/UnitDefinitions/Permeability.json @@ -1,7 +1,7 @@ { "Name": "Permeability", "ConversionBaseUnit": "HenryPerMeter", - "XmlDoc": "In electromagnetism, permeability is the measure of the ability of a material to support the formation of a magnetic field within itself.", + "XmlDocSummary": "In electromagnetism, permeability is the measure of the ability of a material to support the formation of a magnetic field within itself.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Permeability_(electromagnetism)", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/Permittivity.json b/Common/UnitDefinitions/Permittivity.json index f65c5b8930..2fec0230e1 100644 --- a/Common/UnitDefinitions/Permittivity.json +++ b/Common/UnitDefinitions/Permittivity.json @@ -1,7 +1,7 @@ { "Name": "Permittivity", "ConversionBaseUnit": "FaradPerMeter", - "XmlDoc": "In electromagnetism, permittivity is the measure of resistance that is encountered when forming an electric field in a particular medium.", + "XmlDocSummary": "In electromagnetism, permittivity is the measure of resistance that is encountered when forming an electric field in a particular medium.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Permittivity", "BaseDimensions": { "L": -3, diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index a8763a1c71..9f7fc6c603 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -2,7 +2,7 @@ "Name": "Power", "ConversionBaseUnit": "Watt", "ValueType": "decimal", - "XmlDoc": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.", + "XmlDocSummary": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/PowerDensity.json b/Common/UnitDefinitions/PowerDensity.json index 6315002766..2b26e51500 100644 --- a/Common/UnitDefinitions/PowerDensity.json +++ b/Common/UnitDefinitions/PowerDensity.json @@ -1,7 +1,7 @@ { "Name": "PowerDensity", "ConversionBaseUnit": "WattPerCubicMeter", - "XmlDoc": "The amount of power in a volume.", + "XmlDocSummary": "The amount of power in a volume.", "BaseDimensions": { "L": -1, "M": 1, diff --git a/Common/UnitDefinitions/PowerRatio.json b/Common/UnitDefinitions/PowerRatio.json index f57d0e23b8..2a4641f918 100644 --- a/Common/UnitDefinitions/PowerRatio.json +++ b/Common/UnitDefinitions/PowerRatio.json @@ -3,7 +3,7 @@ "ConversionBaseUnit": "DecibelWatt", "Logarithmic": "True", "LogarithmicScalingFactor": "1", - "XmlDoc": "The strength of a signal expressed in decibels (dB) relative to one watt.", + "XmlDocSummary": "The strength of a signal expressed in decibels (dB) relative to one watt.", "Units": [ { "SingularName": "DecibelWatt", diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json index 53b973b356..c31673ad4f 100644 --- a/Common/UnitDefinitions/Pressure.json +++ b/Common/UnitDefinitions/Pressure.json @@ -1,7 +1,7 @@ { "Name": "Pressure", "ConversionBaseUnit": "Pascal", - "XmlDoc": "Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa).", + "XmlDocSummary": "Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa).", "BaseDimensions": { "L": -1, "M": 1, diff --git a/Common/UnitDefinitions/PressureChangeRate.json b/Common/UnitDefinitions/PressureChangeRate.json index 3f183fb0ec..cbef9be403 100644 --- a/Common/UnitDefinitions/PressureChangeRate.json +++ b/Common/UnitDefinitions/PressureChangeRate.json @@ -1,7 +1,7 @@ { "Name": "PressureChangeRate", "ConversionBaseUnit": "PascalPerSecond", - "XmlDoc": "Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time).", + "XmlDocSummary": "Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time).", "BaseDimensions": { "L": -1, "M": 1, diff --git a/Common/UnitDefinitions/Ratio.json b/Common/UnitDefinitions/Ratio.json index 83cf9b4e8f..548044a920 100644 --- a/Common/UnitDefinitions/Ratio.json +++ b/Common/UnitDefinitions/Ratio.json @@ -1,7 +1,7 @@ { "Name": "Ratio", "ConversionBaseUnit": "DecimalFraction", - "XmlDoc": "In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as \"a to b\" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).", + "XmlDocSummary": "In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as \"a to b\" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).", "Units": [ { "SingularName": "DecimalFraction", diff --git a/Common/UnitDefinitions/RatioChangeRate.json b/Common/UnitDefinitions/RatioChangeRate.json index 77b6a49760..c37fe82566 100644 --- a/Common/UnitDefinitions/RatioChangeRate.json +++ b/Common/UnitDefinitions/RatioChangeRate.json @@ -1,7 +1,7 @@ { "Name": "RatioChangeRate", "ConversionBaseUnit": "DecimalFractionPerSecond", - "XmlDoc": "The change in ratio per unit of time.", + "XmlDocSummary": "The change in ratio per unit of time.", "BaseDimensions": { "T": -1 }, "Units": [ { diff --git a/Common/UnitDefinitions/ReactiveEnergy.json b/Common/UnitDefinitions/ReactiveEnergy.json index 4a510e6425..74c172119f 100644 --- a/Common/UnitDefinitions/ReactiveEnergy.json +++ b/Common/UnitDefinitions/ReactiveEnergy.json @@ -1,7 +1,7 @@ { "Name": "ReactiveEnergy", "ConversionBaseUnit": "VoltampereReactiveHour", - "XmlDoc": "The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.", + "XmlDocSummary": "The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/ReactivePower.json b/Common/UnitDefinitions/ReactivePower.json index 762a287ca3..226221fbf7 100644 --- a/Common/UnitDefinitions/ReactivePower.json +++ b/Common/UnitDefinitions/ReactivePower.json @@ -1,7 +1,7 @@ { "Name": "ReactivePower", "ConversionBaseUnit": "VoltampereReactive", - "XmlDoc": "Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.", + "XmlDocSummary": "Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/ReciprocalArea.json b/Common/UnitDefinitions/ReciprocalArea.json index 5eb4d597d1..7f57b72fef 100644 --- a/Common/UnitDefinitions/ReciprocalArea.json +++ b/Common/UnitDefinitions/ReciprocalArea.json @@ -1,7 +1,7 @@ { "Name": "ReciprocalArea", "ConversionBaseUnit": "InverseSquareMeter", - "XmlDoc": "Reciprocal area (Inverse-square) quantity is used to specify a physical quantity inversely proportional to the square of the distance.", + "XmlDocSummary": "Reciprocal area (Inverse-square) quantity is used to specify a physical quantity inversely proportional to the square of the distance.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inverse-square_law", "BaseDimensions": { "L": -2 diff --git a/Common/UnitDefinitions/ReciprocalLength.json b/Common/UnitDefinitions/ReciprocalLength.json index 605ce11a38..f874549b7f 100644 --- a/Common/UnitDefinitions/ReciprocalLength.json +++ b/Common/UnitDefinitions/ReciprocalLength.json @@ -1,7 +1,7 @@ { "Name": "ReciprocalLength", "ConversionBaseUnit": "InverseMeter", - "XmlDoc": "Reciprocal (Inverse) Length is used in various fields of science and mathematics. It is defined as the inverse value of a length unit.", + "XmlDocSummary": "Reciprocal (Inverse) Length is used in various fields of science and mathematics. It is defined as the inverse value of a length unit.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Reciprocal_length", "BaseDimensions": { "L": -1 diff --git a/Common/UnitDefinitions/RelativeHumidity.json b/Common/UnitDefinitions/RelativeHumidity.json index a94db549a3..b8c09b66f9 100644 --- a/Common/UnitDefinitions/RelativeHumidity.json +++ b/Common/UnitDefinitions/RelativeHumidity.json @@ -1,7 +1,7 @@ { "Name": "RelativeHumidity", "ConversionBaseUnit": "Percent", - "XmlDoc": "Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature.", + "XmlDocSummary": "Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature.", "Units": [ { "SingularName": "Percent", diff --git a/Common/UnitDefinitions/RotationalAcceleration.json b/Common/UnitDefinitions/RotationalAcceleration.json index 47f694531a..a7bd752b73 100644 --- a/Common/UnitDefinitions/RotationalAcceleration.json +++ b/Common/UnitDefinitions/RotationalAcceleration.json @@ -1,7 +1,7 @@ { "Name": "RotationalAcceleration", "ConversionBaseUnit": "RadianPerSecondSquared", - "XmlDoc": "Angular acceleration is the rate of change of rotational speed.", + "XmlDocSummary": "Angular acceleration is the rate of change of rotational speed.", "BaseDimensions": { "T": -2 }, diff --git a/Common/UnitDefinitions/RotationalSpeed.json b/Common/UnitDefinitions/RotationalSpeed.json index 0ac3e3acf6..4bb8f18b0c 100644 --- a/Common/UnitDefinitions/RotationalSpeed.json +++ b/Common/UnitDefinitions/RotationalSpeed.json @@ -1,7 +1,7 @@ { "Name": "RotationalSpeed", "ConversionBaseUnit": "RadianPerSecond", - "XmlDoc": "Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter \"omega\").", + "XmlDocSummary": "Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter \"omega\").", "BaseDimensions": { "T": -1 }, diff --git a/Common/UnitDefinitions/RotationalStiffness.json b/Common/UnitDefinitions/RotationalStiffness.json index 08aa3f079f..b50f6eefd0 100644 --- a/Common/UnitDefinitions/RotationalStiffness.json +++ b/Common/UnitDefinitions/RotationalStiffness.json @@ -1,7 +1,7 @@ { "Name": "RotationalStiffness", "ConversionBaseUnit": "NewtonMeterPerRadian", - "XmlDoc": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", + "XmlDocSummary": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/RotationalStiffnessPerLength.json b/Common/UnitDefinitions/RotationalStiffnessPerLength.json index ecf08768a0..0ad8f70db9 100644 --- a/Common/UnitDefinitions/RotationalStiffnessPerLength.json +++ b/Common/UnitDefinitions/RotationalStiffnessPerLength.json @@ -1,7 +1,7 @@ { "Name": "RotationalStiffnessPerLength", "ConversionBaseUnit": "NewtonMeterPerRadianPerMeter", - "XmlDoc": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", + "XmlDocSummary": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", "BaseDimensions": { "L": 1, "M": 1, diff --git a/Common/UnitDefinitions/Scalar.json b/Common/UnitDefinitions/Scalar.json index e18572f610..fc72e1cd37 100644 --- a/Common/UnitDefinitions/Scalar.json +++ b/Common/UnitDefinitions/Scalar.json @@ -1,7 +1,7 @@ { "Name": "Scalar", "ConversionBaseUnit": "Amount", - "XmlDoc": "A way of representing a number of items.", + "XmlDocSummary": "A way of representing a number of items.", "Units": [ { "SingularName": "Amount", diff --git a/Common/UnitDefinitions/SolidAngle.json b/Common/UnitDefinitions/SolidAngle.json index 129b827edf..9b25fe7b8c 100644 --- a/Common/UnitDefinitions/SolidAngle.json +++ b/Common/UnitDefinitions/SolidAngle.json @@ -1,7 +1,7 @@ { "Name": "SolidAngle", "ConversionBaseUnit": "Steradian", - "XmlDoc": "In geometry, a solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point.", + "XmlDocSummary": "In geometry, a solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Solid_angle", "Units": [ { diff --git a/Common/UnitDefinitions/SpecificEnergy.json b/Common/UnitDefinitions/SpecificEnergy.json index 8ee6f4a48e..77555b7d07 100644 --- a/Common/UnitDefinitions/SpecificEnergy.json +++ b/Common/UnitDefinitions/SpecificEnergy.json @@ -1,7 +1,7 @@ { "Name": "SpecificEnergy", "ConversionBaseUnit": "JoulePerKilogram", - "XmlDoc": "The SpecificEnergy", + "XmlDocSummary": "The SpecificEnergy", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Specific_energy", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/SpecificEntropy.json b/Common/UnitDefinitions/SpecificEntropy.json index ba5daa613b..0b69126fc7 100644 --- a/Common/UnitDefinitions/SpecificEntropy.json +++ b/Common/UnitDefinitions/SpecificEntropy.json @@ -1,7 +1,7 @@ { "Name": "SpecificEntropy", "ConversionBaseUnit": "JoulePerKilogramKelvin", - "XmlDoc": "Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass.", + "XmlDocSummary": "Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass.", "BaseDimensions": { "L": 2, "T": -2, diff --git a/Common/UnitDefinitions/SpecificFuelConsumption.json b/Common/UnitDefinitions/SpecificFuelConsumption.json index 7dcc396a43..0b2f6b5ce1 100644 --- a/Common/UnitDefinitions/SpecificFuelConsumption.json +++ b/Common/UnitDefinitions/SpecificFuelConsumption.json @@ -1,7 +1,7 @@ { "Name": "SpecificFuelConsumption", "ConversionBaseUnit": "GramPerKiloNewtonSecond", - "XmlDoc": "SFC is the fuel efficiency of an engine design with respect to thrust output", + "XmlDocSummary": "SFC is the fuel efficiency of an engine design with respect to thrust output", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption", "Units": [ { diff --git a/Common/UnitDefinitions/SpecificVolume.json b/Common/UnitDefinitions/SpecificVolume.json index 81963039b8..73e2f0793e 100644 --- a/Common/UnitDefinitions/SpecificVolume.json +++ b/Common/UnitDefinitions/SpecificVolume.json @@ -1,7 +1,7 @@ { "Name": "SpecificVolume", "ConversionBaseUnit": "CubicMeterPerKilogram", - "XmlDoc": "In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well.", + "XmlDocSummary": "In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well.", "BaseDimensions": { "L": 3, "M": -1 diff --git a/Common/UnitDefinitions/SpecificWeight.json b/Common/UnitDefinitions/SpecificWeight.json index 33924cd80b..750025c2df 100644 --- a/Common/UnitDefinitions/SpecificWeight.json +++ b/Common/UnitDefinitions/SpecificWeight.json @@ -1,7 +1,7 @@ { "Name": "SpecificWeight", "ConversionBaseUnit": "NewtonPerCubicMeter", - "XmlDoc": "The SpecificWeight, or more precisely, the volumetric weight density, of a substance is its weight per unit volume.", + "XmlDocSummary": "The SpecificWeight, or more precisely, the volumetric weight density, of a substance is its weight per unit volume.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Specificweight", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/Speed.json b/Common/UnitDefinitions/Speed.json index 83c538ce1c..90fccd5389 100644 --- a/Common/UnitDefinitions/Speed.json +++ b/Common/UnitDefinitions/Speed.json @@ -1,7 +1,7 @@ { "Name": "Speed", "ConversionBaseUnit": "MeterPerSecond", - "XmlDoc": "In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero.", + "XmlDocSummary": "In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero.", "BaseDimensions": { "L": 1, "T": -1 diff --git a/Common/UnitDefinitions/StandardVolumeFlow.json b/Common/UnitDefinitions/StandardVolumeFlow.json index 963a987c0b..1b456ce838 100644 --- a/Common/UnitDefinitions/StandardVolumeFlow.json +++ b/Common/UnitDefinitions/StandardVolumeFlow.json @@ -1,7 +1,7 @@ { "Name": "StandardVolumeFlow", "ConversionBaseUnit": "StandardCubicMeterPerSecond", - "XmlDoc": "The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions.", + "XmlDocSummary": "The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions.", "BaseDimensions": { "M": 1, "T": -1 diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index 1c68b69389..1259fea41e 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -1,7 +1,7 @@ { "Name": "Temperature", "ConversionBaseUnit": "Kelvin", - "XmlDoc": "A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.", + "XmlDocSummary": "A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.", "GenerateArithmetic": false, "BaseDimensions": { "Θ": 1 diff --git a/Common/UnitDefinitions/TemperatureChangeRate.json b/Common/UnitDefinitions/TemperatureChangeRate.json index 843030bdee..0023cbd605 100644 --- a/Common/UnitDefinitions/TemperatureChangeRate.json +++ b/Common/UnitDefinitions/TemperatureChangeRate.json @@ -1,7 +1,7 @@ { "Name": "TemperatureChangeRate", "ConversionBaseUnit": "DegreeCelsiusPerSecond", - "XmlDoc": "Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time).", + "XmlDocSummary": "Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time).", "BaseDimensions": { "T": -1, "Θ": 1 diff --git a/Common/UnitDefinitions/TemperatureDelta.json b/Common/UnitDefinitions/TemperatureDelta.json index bfc135e944..ef8930a335 100644 --- a/Common/UnitDefinitions/TemperatureDelta.json +++ b/Common/UnitDefinitions/TemperatureDelta.json @@ -1,7 +1,7 @@ { "Name": "TemperatureDelta", "ConversionBaseUnit": "Kelvin", - "XmlDoc": "Difference between two temperatures. The conversions are different than for Temperature.", + "XmlDocSummary": "Difference between two temperatures. The conversions are different than for Temperature.", "BaseDimensions": { "Θ": 1 }, diff --git a/Common/UnitDefinitions/ThermalConductivity.json b/Common/UnitDefinitions/ThermalConductivity.json index 0309c06c0d..d20c4dab62 100644 --- a/Common/UnitDefinitions/ThermalConductivity.json +++ b/Common/UnitDefinitions/ThermalConductivity.json @@ -1,7 +1,7 @@ { "Name": "ThermalConductivity", "ConversionBaseUnit": "WattPerMeterKelvin", - "XmlDoc": "Thermal conductivity is the property of a material to conduct heat.", + "XmlDocSummary": "Thermal conductivity is the property of a material to conduct heat.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thermal_Conductivity", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/ThermalResistance.json b/Common/UnitDefinitions/ThermalResistance.json index b829eaebc2..d662a658be 100644 --- a/Common/UnitDefinitions/ThermalResistance.json +++ b/Common/UnitDefinitions/ThermalResistance.json @@ -1,7 +1,7 @@ { "Name": "ThermalResistance", "ConversionBaseUnit": "SquareMeterKelvinPerKilowatt", - "XmlDoc": "Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.", + "XmlDocSummary": "Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.", "BaseDimensions": { "M": -1, "T": 3, diff --git a/Common/UnitDefinitions/Torque.json b/Common/UnitDefinitions/Torque.json index 6bf3f69f4b..e55f443480 100644 --- a/Common/UnitDefinitions/Torque.json +++ b/Common/UnitDefinitions/Torque.json @@ -1,7 +1,7 @@ { "Name": "Torque", "ConversionBaseUnit": "NewtonMeter", - "XmlDoc": "Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt.", + "XmlDocSummary": "Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt.", "BaseDimensions": { "L": 2, "M": 1, diff --git a/Common/UnitDefinitions/TorquePerLength.json b/Common/UnitDefinitions/TorquePerLength.json index cfe3878644..5f4f3b984b 100644 --- a/Common/UnitDefinitions/TorquePerLength.json +++ b/Common/UnitDefinitions/TorquePerLength.json @@ -1,7 +1,7 @@ { "Name": "TorquePerLength", "ConversionBaseUnit": "NewtonMeterPerMeter", - "XmlDoc": "The magnitude of torque per unit length.", + "XmlDocSummary": "The magnitude of torque per unit length.", "BaseDimensions": { "L": 1, "M": 1, diff --git a/Common/UnitDefinitions/Turbidity.json b/Common/UnitDefinitions/Turbidity.json index 402109b9ee..c4e6978932 100644 --- a/Common/UnitDefinitions/Turbidity.json +++ b/Common/UnitDefinitions/Turbidity.json @@ -1,7 +1,7 @@ { "Name": "Turbidity", "ConversionBaseUnit": "NTU", - "XmlDoc": "Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are generally invisible to the naked eye, similar to smoke in air. The measurement of turbidity is a key test of water quality.", + "XmlDocSummary": "Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are generally invisible to the naked eye, similar to smoke in air. The measurement of turbidity is a key test of water quality.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Turbidity", "Units": [ { diff --git a/Common/UnitDefinitions/VitaminA.json b/Common/UnitDefinitions/VitaminA.json index 203f59c589..6b414412f3 100644 --- a/Common/UnitDefinitions/VitaminA.json +++ b/Common/UnitDefinitions/VitaminA.json @@ -1,7 +1,7 @@ { "Name": "VitaminA", "ConversionBaseUnit": "InternationalUnit", - "XmlDoc": "Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.", + "XmlDocSummary": "Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.", "Units": [ { "SingularName": "InternationalUnit", diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json index aad8a93a43..4f1c2be266 100644 --- a/Common/UnitDefinitions/Volume.json +++ b/Common/UnitDefinitions/Volume.json @@ -1,7 +1,7 @@ { "Name": "Volume", "ConversionBaseUnit": "CubicMeter", - "XmlDoc": "Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces.", + "XmlDocSummary": "Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces.", "BaseDimensions": { "L": 3 }, diff --git a/Common/UnitDefinitions/VolumeConcentration.json b/Common/UnitDefinitions/VolumeConcentration.json index fdc47dc7b4..df47186ee0 100644 --- a/Common/UnitDefinitions/VolumeConcentration.json +++ b/Common/UnitDefinitions/VolumeConcentration.json @@ -1,7 +1,7 @@ { "Name": "VolumeConcentration", "ConversionBaseUnit": "DecimalFraction", - "XmlDoc": "The volume concentration (not to be confused with volume fraction) is defined as the volume of a constituent divided by the total volume of the mixture.", + "XmlDocSummary": "The volume concentration (not to be confused with volume fraction) is defined as the volume of a constituent divided by the total volume of the mixture.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Concentration#Volume_concentration", "Units": [ { diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json index cd7d4dc4fc..a100c54afa 100644 --- a/Common/UnitDefinitions/VolumeFlow.json +++ b/Common/UnitDefinitions/VolumeFlow.json @@ -1,7 +1,7 @@ { "Name": "VolumeFlow", "ConversionBaseUnit": "CubicMeterPerSecond", - "XmlDoc": "In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.", + "XmlDocSummary": "In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.", "BaseDimensions": { "L": 3, "T": -1 diff --git a/Common/UnitDefinitions/VolumePerLength.json b/Common/UnitDefinitions/VolumePerLength.json index f583254c43..2db9ecd778 100644 --- a/Common/UnitDefinitions/VolumePerLength.json +++ b/Common/UnitDefinitions/VolumePerLength.json @@ -1,7 +1,7 @@ { "Name": "VolumePerLength", "ConversionBaseUnit": "CubicMeterPerMeter", - "XmlDoc": "Volume, typically of fluid, that a container can hold within a unit of length.", + "XmlDocSummary": "Volume, typically of fluid, that a container can hold within a unit of length.", "BaseDimensions": { "L": 2 }, diff --git a/Common/UnitDefinitions/VolumetricHeatCapacity.json b/Common/UnitDefinitions/VolumetricHeatCapacity.json index 0ab9b8db62..75741205dd 100644 --- a/Common/UnitDefinitions/VolumetricHeatCapacity.json +++ b/Common/UnitDefinitions/VolumetricHeatCapacity.json @@ -1,7 +1,7 @@ { "Name": "VolumetricHeatCapacity", "ConversionBaseUnit": "JoulePerCubicMeterKelvin", - "XmlDoc": "The volumetric heat capacity is the amount of energy that must be added, in the form of heat, to one unit of volume of the material in order to cause an increase of one unit in its temperature.", + "XmlDocSummary": "The volumetric heat capacity is the amount of energy that must be added, in the form of heat, to one unit of volume of the material in order to cause an increase of one unit in its temperature.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Volumetric_heat_capacity", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/WarpingMomentOfInertia.json b/Common/UnitDefinitions/WarpingMomentOfInertia.json index c4dfd0c11b..21f18ea1d8 100644 --- a/Common/UnitDefinitions/WarpingMomentOfInertia.json +++ b/Common/UnitDefinitions/WarpingMomentOfInertia.json @@ -1,7 +1,7 @@ { "Name": "WarpingMomentOfInertia", "ConversionBaseUnit": "MeterToTheSixth", - "XmlDoc": "A geometric property of an area that is used to determine the warping stress.", + "XmlDocSummary": "A geometric property of an area that is used to determine the warping stress.", "BaseDimensions": { "L": 6 }, From 6c4f4d99196bc48d33b3da82fdc222036d9285b3 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 23:38:18 +0100 Subject: [PATCH 18/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20QuantityType=20en?= =?UTF-8?q?um?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../IQuantityTestClassGenerator.cs | 10 - .../UnitsNetGen/QuantityGenerator.cs | 15 +- .../UnitsNetGen/QuantityTypeGenerator.cs | 43 --- .../UnitsNetGen/StaticQuantityGenerator.cs | 35 -- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 8 - CodeGen/Generators/UnitsNetGenerator.cs | 8 - CodeGen/Program.cs | 9 +- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 3 +- UnitsNet.Tests/DummyIQuantity.cs | 2 - .../GeneratedCode/IQuantityTests.g.cs | 117 ------ .../TestsBase/AccelerationTestsBase.g.cs | 8 - .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 8 - .../TestsBase/AmplitudeRatioTestsBase.g.cs | 8 - .../TestsBase/AngleTestsBase.g.cs | 8 - .../TestsBase/ApparentEnergyTestsBase.g.cs | 8 - .../TestsBase/ApparentPowerTestsBase.g.cs | 8 - .../TestsBase/AreaDensityTestsBase.g.cs | 8 - .../AreaMomentOfInertiaTestsBase.g.cs | 8 - .../TestsBase/AreaTestsBase.g.cs | 8 - .../TestsBase/BitRateTestsBase.g.cs | 8 - ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 8 - .../TestsBase/CapacitanceTestsBase.g.cs | 8 - ...oefficientOfThermalExpansionTestsBase.g.cs | 8 - .../TestsBase/DensityTestsBase.g.cs | 8 - .../TestsBase/DurationTestsBase.g.cs | 8 - .../TestsBase/DynamicViscosityTestsBase.g.cs | 8 - .../ElectricAdmittanceTestsBase.g.cs | 8 - .../ElectricChargeDensityTestsBase.g.cs | 8 - .../TestsBase/ElectricChargeTestsBase.g.cs | 8 - .../ElectricConductanceTestsBase.g.cs | 8 - .../ElectricConductivityTestsBase.g.cs | 8 - .../ElectricCurrentDensityTestsBase.g.cs | 8 - .../ElectricCurrentGradientTestsBase.g.cs | 8 - .../TestsBase/ElectricCurrentTestsBase.g.cs | 8 - .../TestsBase/ElectricFieldTestsBase.g.cs | 8 - .../ElectricInductanceTestsBase.g.cs | 8 - .../ElectricPotentialAcTestsBase.g.cs | 8 - .../ElectricPotentialChangeRateTestsBase.g.cs | 8 - .../ElectricPotentialDcTestsBase.g.cs | 8 - .../TestsBase/ElectricPotentialTestsBase.g.cs | 8 - .../ElectricResistanceTestsBase.g.cs | 8 - .../ElectricResistivityTestsBase.g.cs | 8 - ...ElectricSurfaceChargeDensityTestsBase.g.cs | 8 - .../TestsBase/EnergyTestsBase.g.cs | 8 - .../TestsBase/EntropyTestsBase.g.cs | 8 - .../TestsBase/ForceChangeRateTestsBase.g.cs | 8 - .../TestsBase/ForcePerLengthTestsBase.g.cs | 8 - .../TestsBase/ForceTestsBase.g.cs | 8 - .../TestsBase/FrequencyTestsBase.g.cs | 8 - .../TestsBase/FuelEfficiencyTestsBase.g.cs | 8 - .../TestsBase/HeatFluxTestsBase.g.cs | 8 - .../HeatTransferCoefficientTestsBase.g.cs | 8 - .../TestsBase/IlluminanceTestsBase.g.cs | 8 - .../TestsBase/InformationTestsBase.g.cs | 8 - .../TestsBase/IrradianceTestsBase.g.cs | 8 - .../TestsBase/IrradiationTestsBase.g.cs | 8 - .../KinematicViscosityTestsBase.g.cs | 8 - .../TestsBase/LapseRateTestsBase.g.cs | 8 - .../TestsBase/LengthTestsBase.g.cs | 8 - .../TestsBase/LevelTestsBase.g.cs | 8 - .../TestsBase/LinearDensityTestsBase.g.cs | 8 - .../LinearPowerDensityTestsBase.g.cs | 8 - .../TestsBase/LuminosityTestsBase.g.cs | 8 - .../TestsBase/LuminousFluxTestsBase.g.cs | 8 - .../TestsBase/LuminousIntensityTestsBase.g.cs | 8 - .../TestsBase/MagneticFieldTestsBase.g.cs | 8 - .../TestsBase/MagneticFluxTestsBase.g.cs | 8 - .../TestsBase/MagnetizationTestsBase.g.cs | 8 - .../TestsBase/MassConcentrationTestsBase.g.cs | 8 - .../TestsBase/MassFlowTestsBase.g.cs | 8 - .../TestsBase/MassFluxTestsBase.g.cs | 8 - .../TestsBase/MassFractionTestsBase.g.cs | 8 - .../MassMomentOfInertiaTestsBase.g.cs | 8 - .../TestsBase/MassTestsBase.g.cs | 8 - .../TestsBase/MolarEnergyTestsBase.g.cs | 8 - .../TestsBase/MolarEntropyTestsBase.g.cs | 8 - .../TestsBase/MolarMassTestsBase.g.cs | 8 - .../TestsBase/MolarityTestsBase.g.cs | 8 - .../TestsBase/PermeabilityTestsBase.g.cs | 8 - .../TestsBase/PermittivityTestsBase.g.cs | 8 - .../TestsBase/PowerDensityTestsBase.g.cs | 8 - .../TestsBase/PowerRatioTestsBase.g.cs | 8 - .../TestsBase/PowerTestsBase.g.cs | 8 - .../PressureChangeRateTestsBase.g.cs | 8 - .../TestsBase/PressureTestsBase.g.cs | 8 - .../TestsBase/RatioChangeRateTestsBase.g.cs | 8 - .../TestsBase/RatioTestsBase.g.cs | 8 - .../TestsBase/ReactiveEnergyTestsBase.g.cs | 8 - .../TestsBase/ReactivePowerTestsBase.g.cs | 8 - .../TestsBase/ReciprocalAreaTestsBase.g.cs | 8 - .../TestsBase/ReciprocalLengthTestsBase.g.cs | 8 - .../TestsBase/RelativeHumidityTestsBase.g.cs | 8 - .../RotationalAccelerationTestsBase.g.cs | 8 - .../TestsBase/RotationalSpeedTestsBase.g.cs | 8 - ...RotationalStiffnessPerLengthTestsBase.g.cs | 8 - .../RotationalStiffnessTestsBase.g.cs | 8 - .../TestsBase/ScalarTestsBase.g.cs | 8 - .../TestsBase/SolidAngleTestsBase.g.cs | 8 - .../TestsBase/SpecificEnergyTestsBase.g.cs | 8 - .../TestsBase/SpecificEntropyTestsBase.g.cs | 8 - .../SpecificFuelConsumptionTestsBase.g.cs | 8 - .../TestsBase/SpecificVolumeTestsBase.g.cs | 8 - .../TestsBase/SpecificWeightTestsBase.g.cs | 8 - .../TestsBase/SpeedTestsBase.g.cs | 8 - .../StandardVolumeFlowTestsBase.g.cs | 8 - .../TemperatureChangeRateTestsBase.g.cs | 8 - .../TestsBase/TemperatureDeltaTestsBase.g.cs | 8 - .../TestsBase/TemperatureTestsBase.g.cs | 8 - .../ThermalConductivityTestsBase.g.cs | 8 - .../TestsBase/ThermalResistanceTestsBase.g.cs | 8 - .../TestsBase/TorquePerLengthTestsBase.g.cs | 8 - .../TestsBase/TorqueTestsBase.g.cs | 8 - .../TestsBase/TurbidityTestsBase.g.cs | 8 - .../TestsBase/VitaminATestsBase.g.cs | 8 - .../VolumeConcentrationTestsBase.g.cs | 8 - .../TestsBase/VolumeFlowTestsBase.g.cs | 8 - .../TestsBase/VolumePerLengthTestsBase.g.cs | 8 - .../TestsBase/VolumeTestsBase.g.cs | 8 - .../VolumetricHeatCapacityTestsBase.g.cs | 8 - .../WarpingMomentOfInertiaTestsBase.g.cs | 8 - UnitsNet.Tests/QuantityIConvertibleTests.cs | 4 - UnitsNet.Tests/QuantityInfoTest.cs | 87 ++--- UnitsNet.Tests/QuantityTest.cs | 41 +- UnitsNet/CustomCode/Quantity.cs | 18 - .../Quantities/Acceleration.g.cs | 15 +- .../Quantities/AmountOfSubstance.g.cs | 15 +- .../Quantities/AmplitudeRatio.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 15 +- .../Quantities/ApparentEnergy.g.cs | 15 +- .../Quantities/ApparentPower.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 15 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 15 +- .../Quantities/AreaMomentOfInertia.g.cs | 15 +- .../GeneratedCode/Quantities/BitRate.g.cs | 15 +- .../BrakeSpecificFuelConsumption.g.cs | 15 +- .../GeneratedCode/Quantities/Capacitance.g.cs | 15 +- .../CoefficientOfThermalExpansion.g.cs | 15 +- .../GeneratedCode/Quantities/Density.g.cs | 15 +- .../GeneratedCode/Quantities/Duration.g.cs | 15 +- .../Quantities/DynamicViscosity.g.cs | 15 +- .../Quantities/ElectricAdmittance.g.cs | 15 +- .../Quantities/ElectricCharge.g.cs | 15 +- .../Quantities/ElectricChargeDensity.g.cs | 15 +- .../Quantities/ElectricConductance.g.cs | 15 +- .../Quantities/ElectricConductivity.g.cs | 15 +- .../Quantities/ElectricCurrent.g.cs | 15 +- .../Quantities/ElectricCurrentDensity.g.cs | 15 +- .../Quantities/ElectricCurrentGradient.g.cs | 15 +- .../Quantities/ElectricField.g.cs | 15 +- .../Quantities/ElectricInductance.g.cs | 15 +- .../Quantities/ElectricPotential.g.cs | 15 +- .../Quantities/ElectricPotentialAc.g.cs | 15 +- .../ElectricPotentialChangeRate.g.cs | 15 +- .../Quantities/ElectricPotentialDc.g.cs | 15 +- .../Quantities/ElectricResistance.g.cs | 15 +- .../Quantities/ElectricResistivity.g.cs | 15 +- .../ElectricSurfaceChargeDensity.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 15 +- .../GeneratedCode/Quantities/Entropy.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 15 +- .../Quantities/ForceChangeRate.g.cs | 15 +- .../Quantities/ForcePerLength.g.cs | 15 +- .../GeneratedCode/Quantities/Frequency.g.cs | 15 +- .../Quantities/FuelEfficiency.g.cs | 15 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 15 +- .../Quantities/HeatTransferCoefficient.g.cs | 15 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 15 +- .../GeneratedCode/Quantities/Information.g.cs | 15 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 15 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 15 +- .../Quantities/KinematicViscosity.g.cs | 15 +- .../GeneratedCode/Quantities/LapseRate.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 15 +- .../Quantities/LinearDensity.g.cs | 15 +- .../Quantities/LinearPowerDensity.g.cs | 15 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 15 +- .../Quantities/LuminousFlux.g.cs | 15 +- .../Quantities/LuminousIntensity.g.cs | 15 +- .../Quantities/MagneticField.g.cs | 15 +- .../Quantities/MagneticFlux.g.cs | 15 +- .../Quantities/Magnetization.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 15 +- .../Quantities/MassConcentration.g.cs | 15 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 15 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 15 +- .../Quantities/MassFraction.g.cs | 15 +- .../Quantities/MassMomentOfInertia.g.cs | 15 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 15 +- .../Quantities/MolarEntropy.g.cs | 15 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 15 +- .../GeneratedCode/Quantities/Molarity.g.cs | 15 +- .../Quantities/Permeability.g.cs | 15 +- .../Quantities/Permittivity.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 15 +- .../Quantities/PowerDensity.g.cs | 15 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 15 +- .../GeneratedCode/Quantities/Pressure.g.cs | 15 +- .../Quantities/PressureChangeRate.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 15 +- .../Quantities/RatioChangeRate.g.cs | 15 +- .../Quantities/ReactiveEnergy.g.cs | 15 +- .../Quantities/ReactivePower.g.cs | 15 +- .../Quantities/ReciprocalArea.g.cs | 15 +- .../Quantities/ReciprocalLength.g.cs | 15 +- .../Quantities/RelativeHumidity.g.cs | 15 +- .../Quantities/RotationalAcceleration.g.cs | 15 +- .../Quantities/RotationalSpeed.g.cs | 15 +- .../Quantities/RotationalStiffness.g.cs | 15 +- .../RotationalStiffnessPerLength.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 15 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 15 +- .../Quantities/SpecificEnergy.g.cs | 15 +- .../Quantities/SpecificEntropy.g.cs | 15 +- .../Quantities/SpecificFuelConsumption.g.cs | 15 +- .../Quantities/SpecificVolume.g.cs | 15 +- .../Quantities/SpecificWeight.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 15 +- .../Quantities/StandardVolumeFlow.g.cs | 15 +- .../GeneratedCode/Quantities/Temperature.g.cs | 15 +- .../Quantities/TemperatureChangeRate.g.cs | 15 +- .../Quantities/TemperatureDelta.g.cs | 15 +- .../Quantities/ThermalConductivity.g.cs | 15 +- .../Quantities/ThermalResistance.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 15 +- .../Quantities/TorquePerLength.g.cs | 15 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 15 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 15 +- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 15 +- .../Quantities/VolumeConcentration.g.cs | 15 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 15 +- .../Quantities/VolumePerLength.g.cs | 15 +- .../Quantities/VolumetricHeatCapacity.g.cs | 15 +- .../Quantities/WarpingMomentOfInertia.g.cs | 15 +- UnitsNet/GeneratedCode/Quantity.g.cs | 352 ------------------ UnitsNet/GeneratedCode/QuantityType.g.cs | 147 -------- UnitsNet/IQuantity.cs | 6 - UnitsNet/QuantityInfo.cs | 47 +-- UnitsNet/UnitConverter.cs | 15 +- 239 files changed, 157 insertions(+), 3340 deletions(-) delete mode 100644 CodeGen/Generators/UnitsNetGen/QuantityTypeGenerator.cs delete mode 100644 UnitsNet/GeneratedCode/QuantityType.g.cs diff --git a/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs index 6577988301..6c5c6f2f78 100644 --- a/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs @@ -62,16 +62,6 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Writer.WL($@" }} - [Fact] - public void Type_EqualsStaticQuantityTypeProperty() - {{ - void Assertion(QuantityType expected, IQuantity quantity) => Assert.Equal(expected, quantity.Type); -"); - foreach (var quantity in _quantities) Writer.WL($@" - Assertion({quantity.Name}.QuantityType, {quantity.Name}.Zero);"); - Writer.WL($@" - }} - [Fact] public void Dimensions_IsSameAsStaticBaseDimensions() {{ diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 1ed7302dd7..75d17e48ea 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -159,7 +159,7 @@ private void GenerateStaticConstructor() Writer.WL($@" }}, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.{_quantity.Name}); + ConversionBaseUnit, Zero, BaseDimensions); }} "); } @@ -245,12 +245,6 @@ private void GenerateStaticProperties() [Obsolete(""MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848."")] public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_valueType}.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete(""QuantityType will be removed in the future. Use Info property instead."")] - public static QuantityType QuantityType {{ get; }} = QuantityType.{_quantity.Name}; - /// /// All units of measurement for the {_quantity.Name} quantity. /// @@ -299,11 +293,6 @@ private void GenerateProperties() /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => {_quantity.Name}.QuantityType; - /// /// The of this quantity. /// @@ -1122,8 +1111,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof({_unitEnumName})) return Unit; - else if(conversionType == typeof(QuantityType)) - return {_quantity.Name}.QuantityType; else if(conversionType == typeof(QuantityInfo)) return {_quantity.Name}.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityTypeGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityTypeGenerator.cs deleted file mode 100644 index 72c1bbccef..0000000000 --- a/CodeGen/Generators/UnitsNetGen/QuantityTypeGenerator.cs +++ /dev/null @@ -1,43 +0,0 @@ -using CodeGen.JsonTypes; - -namespace CodeGen.Generators.UnitsNetGen -{ - internal class QuantityTypeGenerator : GeneratorBase - { - private readonly Quantity[] _quantities; - - public QuantityTypeGenerator(Quantity[] quantities) - { - _quantities = quantities; - } - - public override string Generate() - { - Writer.WL(GeneratedFileHeader); - Writer.WL(@" -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - /// - /// Lists all generated quantities with the same name as the quantity struct type, - /// such as Length, Mass, Force etc. - /// This is useful for populating options in the UI, such as creating a generic conversion - /// tool with inputValue, quantityName, fromUnit and toUnit selectors. - /// - public enum QuantityType - { -// Missing XML comment for public type or member -#pragma warning disable CS1591 - Undefined = 0,"); - foreach (var quantity in _quantities) - Writer.WL($@" - {quantity.Name},"); - Writer.WL(@" -// Missing XML comment for public type or member -#pragma warning restore CS1591 - } -}"); - return Writer.ToString(); - } - } -} diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 0d40cb3a8c..eb0db61b94 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -41,41 +41,6 @@ public static partial class Quantity Writer.WL(@" }; - // Used by the QuantityInfo .ctor to map a name to a QuantityType. Will be removed when QuantityType - // will be removed. - internal static readonly IDictionary QuantityTypeByName = new Dictionary - {"); - foreach (var quantity in _quantities) - Writer.WL($@" - {{ ""{quantity.Name}"", QuantityType.{quantity.Name} }},"); - Writer.WL(@" - }; - - /// - /// Dynamically constructs a quantity of the given with the value in the quantity's base units. - /// - /// The of the quantity to create. - /// The value to construct the quantity with. - /// The created quantity. - [Obsolete(""QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead."")] - public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) - { - switch(quantityType) - {"); - foreach (var quantity in _quantities) - { - var quantityName = quantity.Name; - Writer.WL($@" - case QuantityType.{quantityName}: - return {quantityName}.From(value, {quantityName}.ConversionBaseUnit);"); - } - - Writer.WL(@" - default: - throw new ArgumentException($""{quantityType} is not a supported quantity type.""); - } - } - /// /// Dynamically constructs a quantity of the given with the value in the quantity's base units. /// diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 0d03528d46..ba76ac5783 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -167,7 +167,6 @@ public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() Assert.Equal({_quantity.Name}.Zero, quantityInfo.Zero); Assert.Equal(""{_quantity.Name}"", quantityInfo.Name); - Assert.Equal(QuantityType.{_quantity.Name}, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues<{_unitEnumName}>().Except(new[] {{{_unitEnumName}.Undefined}}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -662,13 +661,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof({_unitEnumName}))); }} - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal(QuantityType.{_quantity.Name}, Convert.ChangeType(quantity, typeof(QuantityType))); - }} - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() {{ diff --git a/CodeGen/Generators/UnitsNetGenerator.cs b/CodeGen/Generators/UnitsNetGenerator.cs index 8f6465b9cb..6c58c0ec38 100644 --- a/CodeGen/Generators/UnitsNetGenerator.cs +++ b/CodeGen/Generators/UnitsNetGenerator.cs @@ -67,7 +67,6 @@ public static void Generate(string rootDir, Quantity[] quantities) Log.Information(""); GenerateIQuantityTests(quantities, $"{testProjectDir}/GeneratedCode/IQuantityTests.g.cs"); GenerateUnitAbbreviationsCache(quantities, $"{outputDir}/UnitAbbreviationsCache.g.cs"); - GenerateQuantityType(quantities, $"{outputDir}/QuantityType.g.cs"); GenerateStaticQuantity(quantities, $"{outputDir}/Quantity.g.cs"); GenerateUnitConverter(quantities, $"{outputDir}/UnitConverter.g.cs"); @@ -130,13 +129,6 @@ private static void GenerateUnitAbbreviationsCache(Quantity[] quantities, string Log.Information("✅ UnitAbbreviationsCache.g.cs"); } - private static void GenerateQuantityType(Quantity[] quantities, string filePath) - { - var content = new QuantityTypeGenerator(quantities).Generate(); - File.WriteAllText(filePath, content); - Log.Information("✅ QuantityType.g.cs"); - } - private static void GenerateStaticQuantity(Quantity[] quantities, string filePath) { var content = new StaticQuantityGenerator(quantities).Generate(); diff --git a/CodeGen/Program.cs b/CodeGen/Program.cs index c51a9d7cf7..7007a58297 100644 --- a/CodeGen/Program.cs +++ b/CodeGen/Program.cs @@ -19,20 +19,17 @@ internal class Program /// Quantity types (Length, Mass, ...) /// /// - /// UnitsNet.QuantityType enum type (QuantityType.Length, QuantityType.Mass, ...) + /// Unit enum types (LengthUnit, MassUnit, ...) /// /// - /// UnitsNet.Quantity type + /// UnitsNet.Quantity class. /// /// - /// UnitsNet.UnitAbbreviationsCache + /// UnitsNet.UnitAbbreviationsCache class. /// /// /// Test stubs for testing conversion functions of all units, to be fleshed out by a human later /// - /// - /// Unit enum types (LengthUnit, MassUnit, ...) - /// /// /// /// diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index d41f0dcfab..91e3f77949 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -23,10 +23,9 @@ public HowMuch(double value, HowMuchUnit unit) private static readonly HowMuch Zero = new HowMuch(0, HowMuchUnit.Some); - public QuantityType Type => QuantityType.Undefined; public BaseDimensions Dimensions => BaseDimensions.Dimensionless; - public QuantityInfo QuantityInfo => new QuantityInfo( + public QuantityInfo QuantityInfo => new( nameof(HowMuch), typeof(HowMuchUnit), new UnitInfo[] diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index bd60bbe67f..ca10677cb0 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -5,8 +5,6 @@ namespace UnitsNet.Tests { internal class DummyIQuantity : IQuantity { - public QuantityType Type => throw new NotImplementedException(); - public BaseDimensions Dimensions => throw new NotImplementedException(); public QuantityInfo QuantityInfo => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index a135be39b0..9edd18f72f 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -263,123 +263,6 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Assertion(WarpingMomentOfInertia.Info, WarpingMomentOfInertia.Zero); } - [Fact] - public void Type_EqualsStaticQuantityTypeProperty() - { - void Assertion(QuantityType expected, IQuantity quantity) => Assert.Equal(expected, quantity.Type); - - Assertion(Acceleration.QuantityType, Acceleration.Zero); - Assertion(AmountOfSubstance.QuantityType, AmountOfSubstance.Zero); - Assertion(AmplitudeRatio.QuantityType, AmplitudeRatio.Zero); - Assertion(Angle.QuantityType, Angle.Zero); - Assertion(ApparentEnergy.QuantityType, ApparentEnergy.Zero); - Assertion(ApparentPower.QuantityType, ApparentPower.Zero); - Assertion(Area.QuantityType, Area.Zero); - Assertion(AreaDensity.QuantityType, AreaDensity.Zero); - Assertion(AreaMomentOfInertia.QuantityType, AreaMomentOfInertia.Zero); - Assertion(BitRate.QuantityType, BitRate.Zero); - Assertion(BrakeSpecificFuelConsumption.QuantityType, BrakeSpecificFuelConsumption.Zero); - Assertion(Capacitance.QuantityType, Capacitance.Zero); - Assertion(CoefficientOfThermalExpansion.QuantityType, CoefficientOfThermalExpansion.Zero); - Assertion(Density.QuantityType, Density.Zero); - Assertion(Duration.QuantityType, Duration.Zero); - Assertion(DynamicViscosity.QuantityType, DynamicViscosity.Zero); - Assertion(ElectricAdmittance.QuantityType, ElectricAdmittance.Zero); - Assertion(ElectricCharge.QuantityType, ElectricCharge.Zero); - Assertion(ElectricChargeDensity.QuantityType, ElectricChargeDensity.Zero); - Assertion(ElectricConductance.QuantityType, ElectricConductance.Zero); - Assertion(ElectricConductivity.QuantityType, ElectricConductivity.Zero); - Assertion(ElectricCurrent.QuantityType, ElectricCurrent.Zero); - Assertion(ElectricCurrentDensity.QuantityType, ElectricCurrentDensity.Zero); - Assertion(ElectricCurrentGradient.QuantityType, ElectricCurrentGradient.Zero); - Assertion(ElectricField.QuantityType, ElectricField.Zero); - Assertion(ElectricInductance.QuantityType, ElectricInductance.Zero); - Assertion(ElectricPotential.QuantityType, ElectricPotential.Zero); - Assertion(ElectricPotentialAc.QuantityType, ElectricPotentialAc.Zero); - Assertion(ElectricPotentialChangeRate.QuantityType, ElectricPotentialChangeRate.Zero); - Assertion(ElectricPotentialDc.QuantityType, ElectricPotentialDc.Zero); - Assertion(ElectricResistance.QuantityType, ElectricResistance.Zero); - Assertion(ElectricResistivity.QuantityType, ElectricResistivity.Zero); - Assertion(ElectricSurfaceChargeDensity.QuantityType, ElectricSurfaceChargeDensity.Zero); - Assertion(Energy.QuantityType, Energy.Zero); - Assertion(Entropy.QuantityType, Entropy.Zero); - Assertion(Force.QuantityType, Force.Zero); - Assertion(ForceChangeRate.QuantityType, ForceChangeRate.Zero); - Assertion(ForcePerLength.QuantityType, ForcePerLength.Zero); - Assertion(Frequency.QuantityType, Frequency.Zero); - Assertion(FuelEfficiency.QuantityType, FuelEfficiency.Zero); - Assertion(HeatFlux.QuantityType, HeatFlux.Zero); - Assertion(HeatTransferCoefficient.QuantityType, HeatTransferCoefficient.Zero); - Assertion(Illuminance.QuantityType, Illuminance.Zero); - Assertion(Information.QuantityType, Information.Zero); - Assertion(Irradiance.QuantityType, Irradiance.Zero); - Assertion(Irradiation.QuantityType, Irradiation.Zero); - Assertion(KinematicViscosity.QuantityType, KinematicViscosity.Zero); - Assertion(LapseRate.QuantityType, LapseRate.Zero); - Assertion(Length.QuantityType, Length.Zero); - Assertion(Level.QuantityType, Level.Zero); - Assertion(LinearDensity.QuantityType, LinearDensity.Zero); - Assertion(LinearPowerDensity.QuantityType, LinearPowerDensity.Zero); - Assertion(Luminosity.QuantityType, Luminosity.Zero); - Assertion(LuminousFlux.QuantityType, LuminousFlux.Zero); - Assertion(LuminousIntensity.QuantityType, LuminousIntensity.Zero); - Assertion(MagneticField.QuantityType, MagneticField.Zero); - Assertion(MagneticFlux.QuantityType, MagneticFlux.Zero); - Assertion(Magnetization.QuantityType, Magnetization.Zero); - Assertion(Mass.QuantityType, Mass.Zero); - Assertion(MassConcentration.QuantityType, MassConcentration.Zero); - Assertion(MassFlow.QuantityType, MassFlow.Zero); - Assertion(MassFlux.QuantityType, MassFlux.Zero); - Assertion(MassFraction.QuantityType, MassFraction.Zero); - Assertion(MassMomentOfInertia.QuantityType, MassMomentOfInertia.Zero); - Assertion(MolarEnergy.QuantityType, MolarEnergy.Zero); - Assertion(MolarEntropy.QuantityType, MolarEntropy.Zero); - Assertion(Molarity.QuantityType, Molarity.Zero); - Assertion(MolarMass.QuantityType, MolarMass.Zero); - Assertion(Permeability.QuantityType, Permeability.Zero); - Assertion(Permittivity.QuantityType, Permittivity.Zero); - Assertion(Power.QuantityType, Power.Zero); - Assertion(PowerDensity.QuantityType, PowerDensity.Zero); - Assertion(PowerRatio.QuantityType, PowerRatio.Zero); - Assertion(Pressure.QuantityType, Pressure.Zero); - Assertion(PressureChangeRate.QuantityType, PressureChangeRate.Zero); - Assertion(Ratio.QuantityType, Ratio.Zero); - Assertion(RatioChangeRate.QuantityType, RatioChangeRate.Zero); - Assertion(ReactiveEnergy.QuantityType, ReactiveEnergy.Zero); - Assertion(ReactivePower.QuantityType, ReactivePower.Zero); - Assertion(ReciprocalArea.QuantityType, ReciprocalArea.Zero); - Assertion(ReciprocalLength.QuantityType, ReciprocalLength.Zero); - Assertion(RelativeHumidity.QuantityType, RelativeHumidity.Zero); - Assertion(RotationalAcceleration.QuantityType, RotationalAcceleration.Zero); - Assertion(RotationalSpeed.QuantityType, RotationalSpeed.Zero); - Assertion(RotationalStiffness.QuantityType, RotationalStiffness.Zero); - Assertion(RotationalStiffnessPerLength.QuantityType, RotationalStiffnessPerLength.Zero); - Assertion(Scalar.QuantityType, Scalar.Zero); - Assertion(SolidAngle.QuantityType, SolidAngle.Zero); - Assertion(SpecificEnergy.QuantityType, SpecificEnergy.Zero); - Assertion(SpecificEntropy.QuantityType, SpecificEntropy.Zero); - Assertion(SpecificFuelConsumption.QuantityType, SpecificFuelConsumption.Zero); - Assertion(SpecificVolume.QuantityType, SpecificVolume.Zero); - Assertion(SpecificWeight.QuantityType, SpecificWeight.Zero); - Assertion(Speed.QuantityType, Speed.Zero); - Assertion(StandardVolumeFlow.QuantityType, StandardVolumeFlow.Zero); - Assertion(Temperature.QuantityType, Temperature.Zero); - Assertion(TemperatureChangeRate.QuantityType, TemperatureChangeRate.Zero); - Assertion(TemperatureDelta.QuantityType, TemperatureDelta.Zero); - Assertion(ThermalConductivity.QuantityType, ThermalConductivity.Zero); - Assertion(ThermalResistance.QuantityType, ThermalResistance.Zero); - Assertion(Torque.QuantityType, Torque.Zero); - Assertion(TorquePerLength.QuantityType, TorquePerLength.Zero); - Assertion(Turbidity.QuantityType, Turbidity.Zero); - Assertion(VitaminA.QuantityType, VitaminA.Zero); - Assertion(Volume.QuantityType, Volume.Zero); - Assertion(VolumeConcentration.QuantityType, VolumeConcentration.Zero); - Assertion(VolumeFlow.QuantityType, VolumeFlow.Zero); - Assertion(VolumePerLength.QuantityType, VolumePerLength.Zero); - Assertion(VolumetricHeatCapacity.QuantityType, VolumetricHeatCapacity.Zero); - Assertion(WarpingMomentOfInertia.QuantityType, WarpingMomentOfInertia.Zero); - } - [Fact] public void Dimensions_IsSameAsStaticBaseDimensions() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 35a886b084..e4a851f0b4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -126,7 +126,6 @@ public void Acceleration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Acceleration.Zero, quantityInfo.Zero); Assert.Equal("Acceleration", quantityInfo.Name); - Assert.Equal(QuantityType.Acceleration, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AccelerationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -723,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AccelerationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(QuantityType.Acceleration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index d8d365115d..99a3f9af9a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -128,7 +128,6 @@ public void AmountOfSubstance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(AmountOfSubstance.Zero, quantityInfo.Zero); Assert.Equal("AmountOfSubstance", quantityInfo.Name); - Assert.Equal(QuantityType.AmountOfSubstance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AmountOfSubstanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -738,13 +737,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AmountOfSubstanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(QuantityType.AmountOfSubstance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 95c5ee2155..8ec1ac34a3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -106,7 +106,6 @@ public void AmplitudeRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(AmplitudeRatio.Zero, quantityInfo.Zero); Assert.Equal("AmplitudeRatio", quantityInfo.Name); - Assert.Equal(QuantityType.AmplitudeRatio, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AmplitudeRatioUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -577,13 +576,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AmplitudeRatioUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(QuantityType.AmplitudeRatio, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index c74a769b38..d87269badb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -130,7 +130,6 @@ public void Angle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Angle.Zero, quantityInfo.Zero); Assert.Equal("Angle", quantityInfo.Name); - Assert.Equal(QuantityType.Angle, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AngleUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -753,13 +752,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AngleUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal(QuantityType.Angle, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 4f9f07dc3c..6ffd292207 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -104,7 +104,6 @@ public void ApparentEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ApparentEnergy.Zero, quantityInfo.Zero); Assert.Equal("ApparentEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.ApparentEnergy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ApparentEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ApparentEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(QuantityType.ApparentEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 8bedfd8165..49fe978c2c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -106,7 +106,6 @@ public void ApparentPower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ApparentPower.Zero, quantityInfo.Zero); Assert.Equal("ApparentPower", quantityInfo.Name); - Assert.Equal(QuantityType.ApparentPower, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ApparentPowerUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ApparentPowerUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(QuantityType.ApparentPower, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 998a00095d..69c83958fe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -100,7 +100,6 @@ public void AreaDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(AreaDensity.Zero, quantityInfo.Zero); Assert.Equal("AreaDensity", quantityInfo.Name); - Assert.Equal(QuantityType.AreaDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AreaDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(QuantityType.AreaDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 3916204e43..e9a5fef2ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -110,7 +110,6 @@ public void AreaMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(AreaMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("AreaMomentOfInertia", quantityInfo.Name); - Assert.Equal(QuantityType.AreaMomentOfInertia, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AreaMomentOfInertiaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -603,13 +602,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaMomentOfInertiaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(QuantityType.AreaMomentOfInertia, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index f93f6f7319..4930cf8da9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -126,7 +126,6 @@ public void Area_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Area.Zero, quantityInfo.Zero); Assert.Equal("Area", quantityInfo.Name); - Assert.Equal(QuantityType.Area, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {AreaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -723,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(QuantityType.Area, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 49b7f2470b..2c0afd0ef2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -138,7 +138,6 @@ public void BitRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(BitRate.Zero, quantityInfo.Zero); Assert.Equal("BitRate", quantityInfo.Name); - Assert.Equal(QuantityType.BitRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {BitRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -878,13 +877,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(BitRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(QuantityType.BitRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 7e785ea94f..d540ce0eac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -104,7 +104,6 @@ public void BrakeSpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(BrakeSpecificFuelConsumption.Zero, quantityInfo.Zero); Assert.Equal("BrakeSpecificFuelConsumption", quantityInfo.Name); - Assert.Equal(QuantityType.BrakeSpecificFuelConsumption, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {BrakeSpecificFuelConsumptionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(BrakeSpecificFuelConsumptionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(QuantityType.BrakeSpecificFuelConsumption, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index d038eece7f..a8ac663a2d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -112,7 +112,6 @@ public void Capacitance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Capacitance.Zero, quantityInfo.Zero); Assert.Equal("Capacitance", quantityInfo.Name); - Assert.Equal(QuantityType.Capacitance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {CapacitanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -618,13 +617,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(CapacitanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(QuantityType.Capacitance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 50224b8760..43111755b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -104,7 +104,6 @@ public void CoefficientOfThermalExpansion_QuantityInfo_ReturnsQuantityInfoDescri Assert.Equal(CoefficientOfThermalExpansion.Zero, quantityInfo.Zero); Assert.Equal("CoefficientOfThermalExpansion", quantityInfo.Name); - Assert.Equal(QuantityType.CoefficientOfThermalExpansion, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {CoefficientOfThermalExpansionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(CoefficientOfThermalExpansionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(QuantityType.CoefficientOfThermalExpansion, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 9322299e1d..b905a164ad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -178,7 +178,6 @@ public void Density_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Density.Zero, quantityInfo.Zero); Assert.Equal("Density", quantityInfo.Name); - Assert.Equal(QuantityType.Density, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {DensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1113,13 +1112,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(QuantityType.Density, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 3cd57ef9fb..22895561bd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -118,7 +118,6 @@ public void Duration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Duration.Zero, quantityInfo.Zero); Assert.Equal("Duration", quantityInfo.Name); - Assert.Equal(QuantityType.Duration, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {DurationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -663,13 +662,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DurationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal(QuantityType.Duration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index b4294a8f87..936eeec688 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -118,7 +118,6 @@ public void DynamicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(DynamicViscosity.Zero, quantityInfo.Zero); Assert.Equal("DynamicViscosity", quantityInfo.Name); - Assert.Equal(QuantityType.DynamicViscosity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {DynamicViscosityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -663,13 +662,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DynamicViscosityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(QuantityType.DynamicViscosity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 38a4b9caf5..65427b5b76 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -106,7 +106,6 @@ public void ElectricAdmittance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricAdmittance.Zero, quantityInfo.Zero); Assert.Equal("ElectricAdmittance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricAdmittance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricAdmittanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricAdmittanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(QuantityType.ElectricAdmittance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index c414a76f7e..7507293eb8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -100,7 +100,6 @@ public void ElectricChargeDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuan Assert.Equal(ElectricChargeDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricChargeDensity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricChargeDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricChargeDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(QuantityType.ElectricChargeDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 4e1c772c46..312548fa3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -108,7 +108,6 @@ public void ElectricCharge_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricCharge.Zero, quantityInfo.Zero); Assert.Equal("ElectricCharge", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCharge, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -588,13 +587,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricChargeUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(QuantityType.ElectricCharge, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 2a7baedd05..b9eaeff67e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -104,7 +104,6 @@ public void ElectricConductance_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricConductance.Zero, quantityInfo.Zero); Assert.Equal("ElectricConductance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricConductance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricConductanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(QuantityType.ElectricConductance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index b57e9b36f7..414bbd4493 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -104,7 +104,6 @@ public void ElectricConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuant Assert.Equal(ElectricConductivity.Zero, quantityInfo.Zero); Assert.Equal("ElectricConductivity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricConductivity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricConductivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(QuantityType.ElectricConductivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 32c5469419..060a7ae629 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -104,7 +104,6 @@ public void ElectricCurrentDensity_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(ElectricCurrentDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrentDensity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCurrentDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(QuantityType.ElectricCurrentDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index b60cae463b..fb47ca10cb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -106,7 +106,6 @@ public void ElectricCurrentGradient_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(ElectricCurrentGradient.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrentGradient", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCurrentGradient, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentGradientUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentGradientUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(QuantityType.ElectricCurrentGradient, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 7cf78bddf3..ff63cbeaf9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -114,7 +114,6 @@ public void ElectricCurrent_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricCurrent.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrent", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCurrent, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -633,13 +632,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(QuantityType.ElectricCurrent, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 7366fa1cf6..5f4cab7d98 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -100,7 +100,6 @@ public void ElectricField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricField.Zero, quantityInfo.Zero); Assert.Equal("ElectricField", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricField, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricFieldUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricFieldUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(QuantityType.ElectricField, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 0c701743fc..a87ca5f4d6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -106,7 +106,6 @@ public void ElectricInductance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricInductance.Zero, quantityInfo.Zero); Assert.Equal("ElectricInductance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricInductance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricInductanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricInductanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(QuantityType.ElectricInductance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index afc609ff7d..ad72cc88c4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -108,7 +108,6 @@ public void ElectricPotentialAc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricPotentialAc.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialAc", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotentialAc, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialAcUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -588,13 +587,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialAcUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(QuantityType.ElectricPotentialAc, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index b5c06c45dd..1e8b767242 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -138,7 +138,6 @@ public void ElectricPotentialChangeRate_QuantityInfo_ReturnsQuantityInfoDescribi Assert.Equal(ElectricPotentialChangeRate.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotentialChangeRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -813,13 +812,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(QuantityType.ElectricPotentialChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index e79ad28efb..1ca6103428 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -108,7 +108,6 @@ public void ElectricPotentialDc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricPotentialDc.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialDc", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotentialDc, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialDcUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -588,13 +587,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialDcUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(QuantityType.ElectricPotentialDc, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index ee075378fc..caa4749e79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -108,7 +108,6 @@ public void ElectricPotential_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(ElectricPotential.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotential", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotential, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -588,13 +587,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(QuantityType.ElectricPotential, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 77d7ec6fe4..d091cc3d9c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -110,7 +110,6 @@ public void ElectricResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricResistance.Zero, quantityInfo.Zero); Assert.Equal("ElectricResistance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricResistance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -603,13 +602,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricResistanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(QuantityType.ElectricResistance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 0519de8918..086a91d116 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -126,7 +126,6 @@ public void ElectricResistivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricResistivity.Zero, quantityInfo.Zero); Assert.Equal("ElectricResistivity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricResistivity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -723,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricResistivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(QuantityType.ElectricResistivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 4365c15823..aa4dd8f559 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -104,7 +104,6 @@ public void ElectricSurfaceChargeDensity_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(ElectricSurfaceChargeDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricSurfaceChargeDensity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricSurfaceChargeDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ElectricSurfaceChargeDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricSurfaceChargeDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(QuantityType.ElectricSurfaceChargeDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 545a13bb92..50f5da7d74 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -170,7 +170,6 @@ public void Energy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Energy.Zero, quantityInfo.Zero); Assert.Equal("Energy", quantityInfo.Name); - Assert.Equal(QuantityType.Energy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {EnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1053,13 +1052,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(EnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Energy.FromJoules(1.0); - Assert.Equal(QuantityType.Energy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index ad26d0b9a5..42d3e37bf4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -112,7 +112,6 @@ public void Entropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Entropy.Zero, quantityInfo.Zero); Assert.Equal("Entropy", quantityInfo.Name); - Assert.Equal(QuantityType.Entropy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {EntropyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -618,13 +617,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(EntropyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(QuantityType.Entropy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index fdd27d7e29..7a12cbb0e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -128,7 +128,6 @@ public void ForceChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ForceChangeRate.Zero, quantityInfo.Zero); Assert.Equal("ForceChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.ForceChangeRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ForceChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -738,13 +737,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ForceChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(QuantityType.ForceChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 48b5fafb4a..5da01598f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -174,7 +174,6 @@ public void ForcePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ForcePerLength.Zero, quantityInfo.Zero); Assert.Equal("ForcePerLength", quantityInfo.Name); - Assert.Equal(QuantityType.ForcePerLength, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ForcePerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1083,13 +1082,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ForcePerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(QuantityType.ForcePerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 1574d1b2bc..f5268a6a03 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -128,7 +128,6 @@ public void Force_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Force.Zero, quantityInfo.Zero); Assert.Equal("Force", quantityInfo.Name); - Assert.Equal(QuantityType.Force, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ForceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -738,13 +737,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ForceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Force.FromNewtons(1.0); - Assert.Equal(QuantityType.Force, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index ccb9d4dc0f..670981cb1d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -120,7 +120,6 @@ public void Frequency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Frequency.Zero, quantityInfo.Zero); Assert.Equal("Frequency", quantityInfo.Name); - Assert.Equal(QuantityType.Frequency, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {FrequencyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -678,13 +677,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(FrequencyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal(QuantityType.Frequency, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 5c518405f1..f68b3e3009 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -106,7 +106,6 @@ public void FuelEfficiency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(FuelEfficiency.Zero, quantityInfo.Zero); Assert.Equal("FuelEfficiency", quantityInfo.Name); - Assert.Equal(QuantityType.FuelEfficiency, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {FuelEfficiencyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(FuelEfficiencyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(QuantityType.FuelEfficiency, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index c3a97fae06..b91749a674 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -134,7 +134,6 @@ public void HeatFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(HeatFlux.Zero, quantityInfo.Zero); Assert.Equal("HeatFlux", quantityInfo.Name); - Assert.Equal(QuantityType.HeatFlux, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {HeatFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -783,13 +782,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(HeatFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(QuantityType.HeatFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 409fb5fd34..733f1a36a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -104,7 +104,6 @@ public void HeatTransferCoefficient_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(HeatTransferCoefficient.Zero, quantityInfo.Zero); Assert.Equal("HeatTransferCoefficient", quantityInfo.Name); - Assert.Equal(QuantityType.HeatTransferCoefficient, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {HeatTransferCoefficientUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(HeatTransferCoefficientUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(QuantityType.HeatTransferCoefficient, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 0a306d3cd9..881b7dd457 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -106,7 +106,6 @@ public void Illuminance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Illuminance.Zero, quantityInfo.Zero); Assert.Equal("Illuminance", quantityInfo.Name); - Assert.Equal(QuantityType.Illuminance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {IlluminanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(IlluminanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal(QuantityType.Illuminance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 8548e2b43c..93444f880b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -138,7 +138,6 @@ public void Information_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Information.Zero, quantityInfo.Zero); Assert.Equal("Information", quantityInfo.Name); - Assert.Equal(QuantityType.Information, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {InformationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -878,13 +877,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(InformationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Information.FromBits(1.0); - Assert.Equal(QuantityType.Information, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 6df33a5a3d..294194e9e5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -126,7 +126,6 @@ public void Irradiance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Irradiance.Zero, quantityInfo.Zero); Assert.Equal("Irradiance", quantityInfo.Name); - Assert.Equal(QuantityType.Irradiance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {IrradianceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -723,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(IrradianceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(QuantityType.Irradiance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 5e8f5a514d..c6da8cbdae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -112,7 +112,6 @@ public void Irradiation_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Irradiation.Zero, quantityInfo.Zero); Assert.Equal("Irradiation", quantityInfo.Name); - Assert.Equal(QuantityType.Irradiation, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {IrradiationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -618,13 +617,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(IrradiationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(QuantityType.Irradiation, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 5c97add6c4..eef75fbbdd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -116,7 +116,6 @@ public void KinematicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(KinematicViscosity.Zero, quantityInfo.Zero); Assert.Equal("KinematicViscosity", quantityInfo.Name); - Assert.Equal(QuantityType.KinematicViscosity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {KinematicViscosityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -648,13 +647,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(KinematicViscosityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(QuantityType.KinematicViscosity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index d8c9f83390..017199a1b9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -100,7 +100,6 @@ public void LapseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LapseRate.Zero, quantityInfo.Zero); Assert.Equal("LapseRate", quantityInfo.Name); - Assert.Equal(QuantityType.LapseRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LapseRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LapseRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(QuantityType.LapseRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index e23dfd1eb3..763679f72e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -164,7 +164,6 @@ public void Length_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Length.Zero, quantityInfo.Zero); Assert.Equal("Length", quantityInfo.Name); - Assert.Equal(QuantityType.Length, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1008,13 +1007,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Length.FromMeters(1.0); - Assert.Equal(QuantityType.Length, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 9ed78ebb27..2ebc42c6d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -102,7 +102,6 @@ public void Level_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Level.Zero, quantityInfo.Zero); Assert.Equal("Level", quantityInfo.Name); - Assert.Equal(QuantityType.Level, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LevelUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -547,13 +546,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LevelUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Level.FromDecibels(1.0); - Assert.Equal(QuantityType.Level, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index b07a7e6465..087253455e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -126,7 +126,6 @@ public void LinearDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LinearDensity.Zero, quantityInfo.Zero); Assert.Equal("LinearDensity", quantityInfo.Name); - Assert.Equal(QuantityType.LinearDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LinearDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -723,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LinearDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(QuantityType.LinearDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 2491a7e15d..4bc90b7955 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -148,7 +148,6 @@ public void LinearPowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(LinearPowerDensity.Zero, quantityInfo.Zero); Assert.Equal("LinearPowerDensity", quantityInfo.Name); - Assert.Equal(QuantityType.LinearPowerDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LinearPowerDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -888,13 +887,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LinearPowerDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(QuantityType.LinearPowerDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 71525e5d13..dd33c33fc6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -126,7 +126,6 @@ public void Luminosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Luminosity.Zero, quantityInfo.Zero); Assert.Equal("Luminosity", quantityInfo.Name); - Assert.Equal(QuantityType.Luminosity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LuminosityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -723,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminosityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(QuantityType.Luminosity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 8cc5261154..93e0ff14f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -100,7 +100,6 @@ public void LuminousFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LuminousFlux.Zero, quantityInfo.Zero); Assert.Equal("LuminousFlux", quantityInfo.Name); - Assert.Equal(QuantityType.LuminousFlux, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LuminousFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminousFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(QuantityType.LuminousFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index cf6bc83333..df03ad16c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -100,7 +100,6 @@ public void LuminousIntensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(LuminousIntensity.Zero, quantityInfo.Zero); Assert.Equal("LuminousIntensity", quantityInfo.Name); - Assert.Equal(QuantityType.LuminousIntensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {LuminousIntensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminousIntensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(QuantityType.LuminousIntensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index dbca0efac8..583a8babc5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -110,7 +110,6 @@ public void MagneticField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MagneticField.Zero, quantityInfo.Zero); Assert.Equal("MagneticField", quantityInfo.Name); - Assert.Equal(QuantityType.MagneticField, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFieldUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -603,13 +602,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagneticFieldUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(QuantityType.MagneticField, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 411b6ded21..64ba398f7b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -100,7 +100,6 @@ public void MagneticFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MagneticFlux.Zero, quantityInfo.Zero); Assert.Equal("MagneticFlux", quantityInfo.Name); - Assert.Equal(QuantityType.MagneticFlux, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagneticFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(QuantityType.MagneticFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index e8cc0f2bce..14c4af2617 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -100,7 +100,6 @@ public void Magnetization_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Magnetization.Zero, quantityInfo.Zero); Assert.Equal("Magnetization", quantityInfo.Name); - Assert.Equal(QuantityType.Magnetization, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MagnetizationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagnetizationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(QuantityType.Magnetization, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 5755241c3e..6597abb2a7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -196,7 +196,6 @@ public void MassConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(MassConcentration.Zero, quantityInfo.Zero); Assert.Equal("MassConcentration", quantityInfo.Name); - Assert.Equal(QuantityType.MassConcentration, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MassConcentrationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1248,13 +1247,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassConcentrationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(QuantityType.MassConcentration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 4491048764..a4e238e2ef 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -164,7 +164,6 @@ public void MassFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFlow.Zero, quantityInfo.Zero); Assert.Equal("MassFlow", quantityInfo.Name); - Assert.Equal(QuantityType.MassFlow, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MassFlowUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1008,13 +1007,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassFlowUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(QuantityType.MassFlow, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index a96b8a408d..111ccef9a7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -122,7 +122,6 @@ public void MassFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFlux.Zero, quantityInfo.Zero); Assert.Equal("MassFlux", quantityInfo.Name); - Assert.Equal(QuantityType.MassFlux, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MassFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -693,13 +692,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(QuantityType.MassFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index ea06017014..014e771320 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -146,7 +146,6 @@ public void MassFraction_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFraction.Zero, quantityInfo.Zero); Assert.Equal("MassFraction", quantityInfo.Name); - Assert.Equal(QuantityType.MassFraction, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MassFractionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -873,13 +872,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassFractionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(QuantityType.MassFraction, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 62fa009938..21caaab511 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -154,7 +154,6 @@ public void MassMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(MassMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("MassMomentOfInertia", quantityInfo.Name); - Assert.Equal(QuantityType.MassMomentOfInertia, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MassMomentOfInertiaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -933,13 +932,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassMomentOfInertiaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(QuantityType.MassMomentOfInertia, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 025f826bb4..30e8e25f69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -148,7 +148,6 @@ public void Mass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Mass.Zero, quantityInfo.Zero); Assert.Equal("Mass", quantityInfo.Name); - Assert.Equal(QuantityType.Mass, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MassUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -888,13 +887,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal(QuantityType.Mass, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 8935b53a9b..5ee3825a25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -104,7 +104,6 @@ public void MolarEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarEnergy.Zero, quantityInfo.Zero); Assert.Equal("MolarEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.MolarEnergy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MolarEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(QuantityType.MolarEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 77dc2f71d9..cb6958a896 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -104,7 +104,6 @@ public void MolarEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarEntropy.Zero, quantityInfo.Zero); Assert.Equal("MolarEntropy", quantityInfo.Name); - Assert.Equal(QuantityType.MolarEntropy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MolarEntropyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarEntropyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(QuantityType.MolarEntropy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index b04a22c7dd..76ecf76f8c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -122,7 +122,6 @@ public void MolarMass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarMass.Zero, quantityInfo.Zero); Assert.Equal("MolarMass", quantityInfo.Name); - Assert.Equal(QuantityType.MolarMass, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MolarMassUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -693,13 +692,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarMassUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(QuantityType.MolarMass, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 5e01104704..ec96bf5af6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -114,7 +114,6 @@ public void Molarity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Molarity.Zero, quantityInfo.Zero); Assert.Equal("Molarity", quantityInfo.Name); - Assert.Equal(QuantityType.Molarity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {MolarityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -633,13 +632,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(QuantityType.Molarity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index a902f6257a..f523787d21 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -100,7 +100,6 @@ public void Permeability_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Permeability.Zero, quantityInfo.Zero); Assert.Equal("Permeability", quantityInfo.Name); - Assert.Equal(QuantityType.Permeability, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PermeabilityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PermeabilityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(QuantityType.Permeability, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 87d1d38b77..628dbcaab9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -100,7 +100,6 @@ public void Permittivity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Permittivity.Zero, quantityInfo.Zero); Assert.Equal("Permittivity", quantityInfo.Name); - Assert.Equal(QuantityType.Permittivity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PermittivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PermittivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(QuantityType.Permittivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 95794b111a..77fa028f57 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -186,7 +186,6 @@ public void PowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(PowerDensity.Zero, quantityInfo.Zero); Assert.Equal("PowerDensity", quantityInfo.Name); - Assert.Equal(QuantityType.PowerDensity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PowerDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1173,13 +1172,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(QuantityType.PowerDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 8e069d768b..6e92da0627 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -102,7 +102,6 @@ public void PowerRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(PowerRatio.Zero, quantityInfo.Zero); Assert.Equal("PowerRatio", quantityInfo.Name); - Assert.Equal(QuantityType.PowerRatio, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PowerRatioUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -547,13 +546,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerRatioUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(QuantityType.PowerRatio, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index d5a6e58346..376d3bf385 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -136,7 +136,6 @@ public void Power_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Power.Zero, quantityInfo.Zero); Assert.Equal("Power", quantityInfo.Name); - Assert.Equal(QuantityType.Power, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PowerUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -863,13 +862,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Power.FromWatts(1.0); - Assert.Equal(QuantityType.Power, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 09465835f6..0eb488f05c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -124,7 +124,6 @@ public void PressureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(PressureChangeRate.Zero, quantityInfo.Zero); Assert.Equal("PressureChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.PressureChangeRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PressureChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -708,13 +707,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PressureChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(QuantityType.PressureChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index efc6145fab..27203ef3e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -186,7 +186,6 @@ public void Pressure_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Pressure.Zero, quantityInfo.Zero); Assert.Equal("Pressure", quantityInfo.Name); - Assert.Equal(QuantityType.Pressure, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {PressureUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1173,13 +1172,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PressureUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal(QuantityType.Pressure, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 77a61bb0cd..3aed7ed457 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -102,7 +102,6 @@ public void RatioChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(RatioChangeRate.Zero, quantityInfo.Zero); Assert.Equal("RatioChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.RatioChangeRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RatioChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -543,13 +542,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RatioChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(QuantityType.RatioChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 3e18bcceb8..5525631d39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -110,7 +110,6 @@ public void Ratio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Ratio.Zero, quantityInfo.Zero); Assert.Equal("Ratio", quantityInfo.Name); - Assert.Equal(QuantityType.Ratio, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RatioUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -603,13 +602,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RatioUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(QuantityType.Ratio, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 204d7f3302..9b40d939d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -104,7 +104,6 @@ public void ReactiveEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReactiveEnergy.Zero, quantityInfo.Zero); Assert.Equal("ReactiveEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.ReactiveEnergy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ReactiveEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReactiveEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(QuantityType.ReactiveEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 7a6d3fc2fb..1f8f68a1ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -106,7 +106,6 @@ public void ReactivePower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReactivePower.Zero, quantityInfo.Zero); Assert.Equal("ReactivePower", quantityInfo.Name); - Assert.Equal(QuantityType.ReactivePower, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ReactivePowerUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReactivePowerUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(QuantityType.ReactivePower, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 1858cc7860..6cdabc0366 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -120,7 +120,6 @@ public void ReciprocalArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReciprocalArea.Zero, quantityInfo.Zero); Assert.Equal("ReciprocalArea", quantityInfo.Name); - Assert.Equal(QuantityType.ReciprocalArea, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalAreaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -678,13 +677,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReciprocalAreaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(QuantityType.ReciprocalArea, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 8d7dbd1677..78615a705e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -118,7 +118,6 @@ public void ReciprocalLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(ReciprocalLength.Zero, quantityInfo.Zero); Assert.Equal("ReciprocalLength", quantityInfo.Name); - Assert.Equal(QuantityType.ReciprocalLength, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -663,13 +662,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReciprocalLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(QuantityType.ReciprocalLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 6193dd0d6e..f0af4d4e71 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -100,7 +100,6 @@ public void RelativeHumidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(RelativeHumidity.Zero, quantityInfo.Zero); Assert.Equal("RelativeHumidity", quantityInfo.Name); - Assert.Equal(QuantityType.RelativeHumidity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RelativeHumidityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RelativeHumidityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(QuantityType.RelativeHumidity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index e1ff01e076..2abe4526a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -106,7 +106,6 @@ public void RotationalAcceleration_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(RotationalAcceleration.Zero, quantityInfo.Zero); Assert.Equal("RotationalAcceleration", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalAcceleration, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RotationalAccelerationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalAccelerationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(QuantityType.RotationalAcceleration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 3e8504afeb..3ad29e76d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -124,7 +124,6 @@ public void RotationalSpeed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(RotationalSpeed.Zero, quantityInfo.Zero); Assert.Equal("RotationalSpeed", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalSpeed, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RotationalSpeedUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -708,13 +707,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalSpeedUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(QuantityType.RotationalSpeed, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index a08db85f25..c5ceb3308b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -108,7 +108,6 @@ public void RotationalStiffnessPerLength_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(RotationalStiffnessPerLength.Zero, quantityInfo.Zero); Assert.Equal("RotationalStiffnessPerLength", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalStiffnessPerLength, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessPerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -588,13 +587,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalStiffnessPerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(QuantityType.RotationalStiffnessPerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 5fcde15e57..19645921ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -164,7 +164,6 @@ public void RotationalStiffness_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(RotationalStiffness.Zero, quantityInfo.Zero); Assert.Equal("RotationalStiffness", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalStiffness, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1008,13 +1007,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalStiffnessUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(QuantityType.RotationalStiffness, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index a8a1a060b7..cca987ee20 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -100,7 +100,6 @@ public void Scalar_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Scalar.Zero, quantityInfo.Zero); Assert.Equal("Scalar", quantityInfo.Name); - Assert.Equal(QuantityType.Scalar, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ScalarUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ScalarUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal(QuantityType.Scalar, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index dbd7e17b3c..60f1c3b1a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -100,7 +100,6 @@ public void SolidAngle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SolidAngle.Zero, quantityInfo.Zero); Assert.Equal("SolidAngle", quantityInfo.Name); - Assert.Equal(QuantityType.SolidAngle, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SolidAngleUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SolidAngleUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(QuantityType.SolidAngle, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 615f786990..2ecacd2d2b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -148,7 +148,6 @@ public void SpecificEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificEnergy.Zero, quantityInfo.Zero); Assert.Equal("SpecificEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificEnergy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -888,13 +887,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(QuantityType.SpecificEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index d00513a611..7ac5369551 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -116,7 +116,6 @@ public void SpecificEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificEntropy.Zero, quantityInfo.Zero); Assert.Equal("SpecificEntropy", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificEntropy, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEntropyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -648,13 +647,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificEntropyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(QuantityType.SpecificEntropy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index f3bf294e56..3fbf631da0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -106,7 +106,6 @@ public void SpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(SpecificFuelConsumption.Zero, quantityInfo.Zero); Assert.Equal("SpecificFuelConsumption", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificFuelConsumption, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SpecificFuelConsumptionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -573,13 +572,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificFuelConsumptionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(QuantityType.SpecificFuelConsumption, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 30b7e5c268..2415359dbf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -104,7 +104,6 @@ public void SpecificVolume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificVolume.Zero, quantityInfo.Zero); Assert.Equal("SpecificVolume", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificVolume, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SpecificVolumeUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -558,13 +557,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificVolumeUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(QuantityType.SpecificVolume, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 44117da3d9..99445dd042 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -132,7 +132,6 @@ public void SpecificWeight_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificWeight.Zero, quantityInfo.Zero); Assert.Equal("SpecificWeight", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificWeight, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SpecificWeightUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -768,13 +767,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificWeightUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(QuantityType.SpecificWeight, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index a204c47d3e..5137cd6b66 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -162,7 +162,6 @@ public void Speed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Speed.Zero, quantityInfo.Zero); Assert.Equal("Speed", quantityInfo.Name); - Assert.Equal(QuantityType.Speed, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {SpeedUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -993,13 +992,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpeedUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(QuantityType.Speed, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index f4ff5a1ba9..992854a00b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -116,7 +116,6 @@ public void StandardVolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(StandardVolumeFlow.Zero, quantityInfo.Zero); Assert.Equal("StandardVolumeFlow", quantityInfo.Name); - Assert.Equal(QuantityType.StandardVolumeFlow, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {StandardVolumeFlowUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -648,13 +647,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(StandardVolumeFlowUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(QuantityType.StandardVolumeFlow, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 25150bf902..c924304cf4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -118,7 +118,6 @@ public void TemperatureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuan Assert.Equal(TemperatureChangeRate.Zero, quantityInfo.Zero); Assert.Equal("TemperatureChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.TemperatureChangeRate, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -663,13 +662,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(QuantityType.TemperatureChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 3aa28b183a..98eed1a3a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -116,7 +116,6 @@ public void TemperatureDelta_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(TemperatureDelta.Zero, quantityInfo.Zero); Assert.Equal("TemperatureDelta", quantityInfo.Name); - Assert.Equal(QuantityType.TemperatureDelta, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureDeltaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -648,13 +647,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureDeltaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(QuantityType.TemperatureDelta, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index de2a5619dd..3d0446d109 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -118,7 +118,6 @@ public void Temperature_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Temperature.Zero, quantityInfo.Zero); Assert.Equal("Temperature", quantityInfo.Name); - Assert.Equal(QuantityType.Temperature, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -651,13 +650,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(QuantityType.Temperature, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index a514166f0f..ad67d32ff0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -102,7 +102,6 @@ public void ThermalConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ThermalConductivity.Zero, quantityInfo.Zero); Assert.Equal("ThermalConductivity", quantityInfo.Name); - Assert.Equal(QuantityType.ThermalConductivity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ThermalConductivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -543,13 +542,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ThermalConductivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(QuantityType.ThermalConductivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index f44c4851b1..48bafa9d79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -108,7 +108,6 @@ public void ThermalResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(ThermalResistance.Zero, quantityInfo.Zero); Assert.Equal("ThermalResistance", quantityInfo.Name); - Assert.Equal(QuantityType.ThermalResistance, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {ThermalResistanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -588,13 +587,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ThermalResistanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(QuantityType.ThermalResistance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 619acfd4bb..bdedcba996 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -140,7 +140,6 @@ public void TorquePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(TorquePerLength.Zero, quantityInfo.Zero); Assert.Equal("TorquePerLength", quantityInfo.Name); - Assert.Equal(QuantityType.TorquePerLength, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {TorquePerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -828,13 +827,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TorquePerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(QuantityType.TorquePerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 6225980f1a..a5661da2c6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -142,7 +142,6 @@ public void Torque_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Torque.Zero, quantityInfo.Zero); Assert.Equal("Torque", quantityInfo.Name); - Assert.Equal(QuantityType.Torque, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {TorqueUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -843,13 +842,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TorqueUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(QuantityType.Torque, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 490d143756..506a822a98 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -100,7 +100,6 @@ public void Turbidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Turbidity.Zero, quantityInfo.Zero); Assert.Equal("Turbidity", quantityInfo.Name); - Assert.Equal(QuantityType.Turbidity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {TurbidityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TurbidityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(QuantityType.Turbidity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index baa11123f1..4b1dc163b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -100,7 +100,6 @@ public void VitaminA_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VitaminA.Zero, quantityInfo.Zero); Assert.Equal("VitaminA", quantityInfo.Name); - Assert.Equal(QuantityType.VitaminA, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {VitaminAUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -528,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VitaminAUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(QuantityType.VitaminA, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index aac241b2c3..772bccc999 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -138,7 +138,6 @@ public void VolumeConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(VolumeConcentration.Zero, quantityInfo.Zero); Assert.Equal("VolumeConcentration", quantityInfo.Name); - Assert.Equal(QuantityType.VolumeConcentration, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {VolumeConcentrationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -813,13 +812,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeConcentrationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(QuantityType.VolumeConcentration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 63a1c929a5..605d0de51c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -210,7 +210,6 @@ public void VolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VolumeFlow.Zero, quantityInfo.Zero); Assert.Equal("VolumeFlow", quantityInfo.Name); - Assert.Equal(QuantityType.VolumeFlow, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {VolumeFlowUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1353,13 +1352,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeFlowUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(QuantityType.VolumeFlow, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 12e1bb4c46..66146411fa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -112,7 +112,6 @@ public void VolumePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VolumePerLength.Zero, quantityInfo.Zero); Assert.Equal("VolumePerLength", quantityInfo.Name); - Assert.Equal(QuantityType.VolumePerLength, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {VolumePerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -618,13 +617,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumePerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(QuantityType.VolumePerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index f9c85f451f..99f6250514 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -200,7 +200,6 @@ public void Volume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Volume.Zero, quantityInfo.Zero); Assert.Equal("Volume", quantityInfo.Name); - Assert.Equal(QuantityType.Volume, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {VolumeUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -1278,13 +1277,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(QuantityType.Volume, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 5426d482cd..ceab50186e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -116,7 +116,6 @@ public void VolumetricHeatCapacity_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(VolumetricHeatCapacity.Zero, quantityInfo.Zero); Assert.Equal("VolumetricHeatCapacity", quantityInfo.Name); - Assert.Equal(QuantityType.VolumetricHeatCapacity, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {VolumetricHeatCapacityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -648,13 +647,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumetricHeatCapacityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(QuantityType.VolumetricHeatCapacity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 16b5dfcb9f..941c004dd2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -110,7 +110,6 @@ public void WarpingMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(WarpingMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("WarpingMomentOfInertia", quantityInfo.Name); - Assert.Equal(QuantityType.WarpingMomentOfInertia, quantityInfo.QuantityType); var units = EnumUtils.GetEnumValues().Except(new[] {WarpingMomentOfInertiaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); @@ -603,13 +602,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(WarpingMomentOfInertiaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(QuantityType.WarpingMomentOfInertia, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/QuantityIConvertibleTests.cs b/UnitsNet.Tests/QuantityIConvertibleTests.cs index 5c5f7983a5..b514a657a9 100644 --- a/UnitsNet.Tests/QuantityIConvertibleTests.cs +++ b/UnitsNet.Tests/QuantityIConvertibleTests.cs @@ -141,10 +141,6 @@ public void ToTypeTest() Assert.Throws(() => lengthAsIConvertible.ToType(typeof(DurationUnit), null)); Assert.Throws(() => Convert.ChangeType(length, typeof(DurationUnit))); - // QuantityType - Assert.Equal(Length.QuantityType, lengthAsIConvertible.ToType(typeof(QuantityType), null)); - Assert.Equal(Length.QuantityType, Convert.ChangeType(length, typeof(QuantityType))); - // QuantityInfo Assert.Equal(Length.Info, lengthAsIConvertible.ToType(typeof(QuantityInfo), null)); Assert.Equal(Length.Info, Convert.ChangeType(length, typeof(QuantityInfo))); diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index 963ef6e15b..719c927002 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -3,7 +3,6 @@ using System; using System.Diagnostics.CodeAnalysis; -using System.Linq; using UnitsNet.Tests.CustomQuantities; using UnitsNet.Units; using Xunit; @@ -16,21 +15,19 @@ public class QuantityInfoTest public void Constructor_AssignsProperties() { var expectedZero = Length.FromCentimeters(10); - var expectedUnitInfos = new UnitInfo[]{ - new UnitInfo(LengthUnit.Centimeter, "Centimeters", new BaseUnits(LengthUnit.Centimeter)), - new UnitInfo(LengthUnit.Kilometer, "Kilometers", new BaseUnits(LengthUnit.Kilometer)) + UnitInfo[] expectedUnitInfos = { + new(LengthUnit.Centimeter, "Centimeters", new BaseUnits(LengthUnit.Centimeter)), + new(LengthUnit.Kilometer, "Kilometers", new BaseUnits(LengthUnit.Kilometer)) }; var expectedBaseUnit = LengthUnit.Centimeter; - var expectedQuantityType = QuantityType.Length; var expectedBaseDimensions = Length.BaseDimensions; var info = new QuantityInfo(nameof(Length), typeof(LengthUnit), expectedUnitInfos, - expectedBaseUnit, expectedZero, expectedBaseDimensions, QuantityType.Length); + expectedBaseUnit, expectedZero, expectedBaseDimensions); Assert.Equal(expectedZero, info.Zero); Assert.Equal("Length", info.Name); Assert.Equal(expectedUnitInfos, info.UnitInfos); - Assert.Equal(expectedQuantityType, info.QuantityType); Assert.Equal(expectedBaseDimensions, info.BaseDimensions); // Obsolete members @@ -42,14 +39,12 @@ public void Constructor_AssignsProperties() public void Constructor_AssignsPropertiesForCustomQuantity() { var expectedZero = new HowMuch(10, HowMuchUnit.Some); - var expectedUnitInfos = new UnitInfo[] - { - new UnitInfo(HowMuchUnit.Some, "Some", BaseUnits.Undefined), - new UnitInfo(HowMuchUnit.ATon, "Tons", BaseUnits.Undefined), - new UnitInfo(HowMuchUnit.AShitTon, "ShitTons", BaseUnits.Undefined) + UnitInfo[] expectedUnitInfos = { + new(HowMuchUnit.Some, "Some", BaseUnits.Undefined), + new(HowMuchUnit.ATon, "Tons", BaseUnits.Undefined), + new(HowMuchUnit.AShitTon, "ShitTons", BaseUnits.Undefined) }; var expectedBaseUnit = HowMuchUnit.Some; - var expectedQuantityType = QuantityType.Undefined; var expectedBaseDimensions = BaseDimensions.Dimensionless; var info = new QuantityInfo(nameof(HowMuch), typeof(HowMuchUnit), expectedUnitInfos, @@ -58,7 +53,6 @@ public void Constructor_AssignsPropertiesForCustomQuantity() Assert.Equal(expectedZero, info.Zero); Assert.Equal(nameof(HowMuch), info.Name); Assert.Equal(expectedUnitInfos, info.UnitInfos); - Assert.Equal(expectedQuantityType, info.QuantityType); Assert.Equal(expectedBaseDimensions, info.BaseDimensions); // Obsolete members @@ -66,52 +60,24 @@ public void Constructor_AssignsPropertiesForCustomQuantity() Assert.Equal(new[] {nameof(HowMuchUnit.Some), nameof(HowMuchUnit.ATon), nameof(HowMuchUnit.AShitTon)}, info.UnitNames); } - [Fact] - public void ObsoleteConstructor_AssignsProperties() - { - var expectedZero = Length.FromCentimeters(10); - var expectedUnitInfos = new UnitInfo[]{ - new UnitInfo(LengthUnit.Centimeter, "Centimeters", new BaseUnits(LengthUnit.Centimeter)), - new UnitInfo(LengthUnit.Kilometer, "Kilometers", new BaseUnits(LengthUnit.Kilometer)) - }; - var expectedBaseUnit = LengthUnit.Centimeter; - var expectedQuantityType = QuantityType.Length; - var expectedBaseDimensions = Length.BaseDimensions; - - var info = new QuantityInfo(QuantityType.Length, expectedUnitInfos, expectedBaseUnit, expectedZero, expectedBaseDimensions); - - Assert.Equal(expectedZero, info.Zero); - Assert.Equal("Length", info.Name); - Assert.Equal(expectedUnitInfos, info.UnitInfos); - Assert.Equal(expectedQuantityType, info.QuantityType); - Assert.Equal(expectedBaseDimensions, info.BaseDimensions); - - // Obsolete members - Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); - Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); - } - [Fact] public void GenericsConstructor_AssignsProperties() { var expectedZero = Length.FromCentimeters(10); - var expectedUnitInfos = new UnitInfo[]{ - new UnitInfo(LengthUnit.Centimeter, "Centimeters", new BaseUnits(LengthUnit.Centimeter)), - new UnitInfo(LengthUnit.Kilometer,"Kilometers", new BaseUnits(LengthUnit.Kilometer)) + UnitInfo[] expectedUnitInfos = { + new(LengthUnit.Centimeter, "Centimeters", new BaseUnits(LengthUnit.Centimeter)), + new(LengthUnit.Kilometer,"Kilometers", new BaseUnits(LengthUnit.Kilometer)) }; var expectedBaseUnit = LengthUnit.Centimeter; - var expectedQuantityType = QuantityType.Length; var expectedBaseDimensions = Length.BaseDimensions; - var info = new QuantityInfo(nameof(Length), expectedUnitInfos, - expectedBaseUnit, expectedZero, expectedBaseDimensions, expectedQuantityType); + var info = new QuantityInfo(nameof(Length), expectedUnitInfos, expectedBaseUnit, expectedZero, expectedBaseDimensions); Assert.Equal(expectedZero, info.Zero); Assert.Equal("Length", info.Name); Assert.Equal(expectedUnitInfos, info.UnitInfos); Assert.Equal(expectedBaseDimensions, info.BaseDimensions); // Obsolete members - Assert.Equal(expectedQuantityType, info.QuantityType); Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } @@ -121,7 +87,7 @@ public void GenericsConstructor_AssignsProperties() public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions, QuantityType.Length)); + null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -129,7 +95,7 @@ public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions, QuantityType.Length)); + null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -137,7 +103,7 @@ public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, null, Length.Zero, Length.BaseDimensions, QuantityType.Length)); + Length.Info.UnitInfos, null, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -145,7 +111,7 @@ public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -153,7 +119,7 @@ public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -161,7 +127,7 @@ public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); } [Fact] @@ -169,7 +135,7 @@ public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null, QuantityType.Length)); + Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] @@ -246,9 +212,10 @@ public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperat var baseUnits = new BaseUnits(LengthUnit.Meter); var quantityInfo = new QuantityInfo(Length.Info.Name, - new UnitInfo[]{ - new UnitInfo(LengthUnit.Meter, "Meters", baseUnits), - new UnitInfo(LengthUnit.Foot, "Feet", baseUnits) }, + new UnitInfo[] { + new(LengthUnit.Meter, "Meters", baseUnits), + new(LengthUnit.Foot, "Feet", baseUnits) + }, LengthUnit.Meter, Length.Zero, Length.BaseDimensions); Assert.Throws(() => quantityInfo.GetUnitInfoFor(baseUnits)); @@ -257,7 +224,7 @@ public void GetUnitInfoFor_GivenBaseUnitsWithMultipleMatches_ThrowsInvalidOperat [Fact] public void GetUnitInfosFor_GivenNullAsBaseUnits_ThrowsArgumentNullException() { - Assert.Throws(() => Length.Info.GetUnitInfosFor(null)); + Assert.Throws(() => Length.Info.GetUnitInfosFor(null!)); } [Fact] @@ -282,9 +249,9 @@ public void GetUnitInfosFor_GivenBaseUnitsWithMultipleMatches_ReturnsMultipleMat var baseUnits = new BaseUnits(LengthUnit.Meter); var quantityInfo = new QuantityInfo(Length.Info.Name, - new UnitInfo[]{ - new UnitInfo(LengthUnit.Meter, "Meters", baseUnits), - new UnitInfo(LengthUnit.Foot, "Feet", baseUnits) }, + new UnitInfo[] { + new(LengthUnit.Meter, "Meters", baseUnits), + new(LengthUnit.Foot, "Feet", baseUnits) }, LengthUnit.Meter, Length.Zero, Length.BaseDimensions); var result = quantityInfo.GetUnitInfosFor(baseUnits); diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 06e4e06b93..3b6807e06b 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -43,15 +43,15 @@ public void From_GivenValueAndUnit_ReturnsQuantity() } [Fact] - public void GetInfo_GivenLength_ReturnsQuantityInfoForLength() + public void ByName_GivenLength_ReturnsQuantityInfoForLength() { var knownLengthUnits = new Enum[] { LengthUnit.Meter, LengthUnit.Centimeter, LengthUnit.Kilometer }; var knownLengthUnitNames = new[] { "Meter", "Centimeter", "Kilometer" }; var lengthUnitCount = Enum.GetValues(typeof(LengthUnit)).Length - 1; // Exclude LengthUnit.Undefined - QuantityInfo quantityInfo = Quantity.GetInfo(QuantityType.Length); + QuantityInfo quantityInfo = Quantity.ByName["Length"]; Assert.Equal("Length", quantityInfo.Name); - Assert.Equal(QuantityType.Length, quantityInfo.QuantityType); + Assert.Same(Length.Info, quantityInfo.Name); // Obsolete members Assert.Superset(knownLengthUnitNames.ToHashSet(), quantityInfo.UnitNames.ToHashSet()); Assert.Superset(knownLengthUnits.ToHashSet(), quantityInfo.Units.ToHashSet()); @@ -63,16 +63,16 @@ public void GetInfo_GivenLength_ReturnsQuantityInfoForLength() } [Fact] - public void GetInfo_GivenMass_ReturnsQuantityInfoForMass() + public void ByName_GivenMass_ReturnsQuantityInfoForMass() { var knownMassUnits = new Enum[] { MassUnit.Kilogram, MassUnit.Gram, MassUnit.Tonne }; var knownMassUnitNames = new[] { "Kilogram", "Gram", "Tonne" }; var massUnitCount = Enum.GetValues(typeof(MassUnit)).Length - 1; // Exclude MassUnit.Undefined - QuantityInfo quantityInfo = Quantity.GetInfo(QuantityType.Mass); + QuantityInfo quantityInfo = Quantity.ByName["Mass"]; Assert.Equal("Mass", quantityInfo.Name); + Assert.Same(Mass.Info, quantityInfo.Name); // Obsolete members - Assert.Equal(QuantityType.Mass, quantityInfo.QuantityType); Assert.Superset(knownMassUnitNames.ToHashSet(), quantityInfo.UnitNames.ToHashSet()); Assert.Superset(knownMassUnits.ToHashSet(), quantityInfo.Units.ToHashSet()); Assert.Equal(massUnitCount, quantityInfo.UnitNames.Length); @@ -85,12 +85,7 @@ public void GetInfo_GivenMass_ReturnsQuantityInfoForMass() [Fact] public void Infos_ReturnsKnownQuantityInfoObjects() { - var knownQuantityInfos = new[] - { - Quantity.GetInfo(QuantityType.Length), - Quantity.GetInfo(QuantityType.Force), - Quantity.GetInfo(QuantityType.Mass) - }; + QuantityInfo[] knownQuantityInfos = { Length.Info, Force.Info, Mass.Info }; var infos = Quantity.Infos; Assert.Superset(knownQuantityInfos.ToHashSet(), infos.ToHashSet()); @@ -203,27 +198,5 @@ public void Types_ReturnsKnownQuantityTypes() Assert.Superset(knownQuantities.ToHashSet(), types.ToHashSet()); } - - [Fact] - public void FromQuantityType_GivenUndefinedQuantityType_ThrowsArgumentException() - { - Assert.Throws(() => Quantity.FromQuantityType(QuantityType.Undefined, 0.0)); - } - - [Fact] - public void FromQuantityType_GivenInvalidQuantityType_ThrowsArgumentException() - { - Assert.Throws(() => Quantity.FromQuantityType((QuantityType)(-1), 0.0)); - } - - [Fact] - public void FromQuantityType_GivenLengthQuantityType_ReturnsLengthQuantity() - { - var fromQuantity = Quantity.FromQuantityType(QuantityType.Length, 0.0); - - Assert.Equal(0.0, fromQuantity.Value); - Assert.Equal(QuantityType.Length, fromQuantity.Type); - Assert.Equal(Length.ConversionBaseUnit, fromQuantity.Unit); - } } } diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs index 5de7fedbcd..da44bcfde9 100644 --- a/UnitsNet/CustomCode/Quantity.cs +++ b/UnitsNet/CustomCode/Quantity.cs @@ -13,7 +13,6 @@ public partial class Quantity static Quantity() { ICollection quantityInfos = ByName.Values; - Types = Enum.GetValues(typeof(QuantityType)).Cast().Except(new[] { QuantityType.Undefined }).ToArray(); Names = quantityInfos.Select(qt => qt.Name).ToArray(); InfosLazy = new Lazy(() => quantityInfos @@ -31,12 +30,6 @@ static Quantity() }); } - /// - /// All enum values of , such as and . - /// - [Obsolete("QuantityType will be removed in the future. Use Infos property instead.")] - public static QuantityType[] Types { get; } - /// /// All enum value names of , such as "Length" and "Mass". /// @@ -114,17 +107,6 @@ public static IQuantity Parse(IFormatProvider? formatProvider, Type quantityType public static bool TryParse(Type quantityType, string quantityString, out IQuantity? quantity) => TryParse(null, quantityType, quantityString, out quantity); - /// - /// Get information about the given quantity type. - /// - /// The quantity type enum value. - /// Information about the quantity and its units. - [Obsolete("QuantityType will be removed in the future.")] - public static QuantityInfo GetInfo(QuantityType quantityType) - { - return Infos.First(qi => qi.QuantityType == quantityType); - } - /// /// Get a list of quantities that has the given base dimensions. /// diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index f332af5eed..6c228e6f3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -70,7 +70,7 @@ static Acceleration() new UnitInfo(AccelerationUnit.NanometerPerSecondSquared, "NanometersPerSecondSquared", BaseUnits.Undefined), new UnitInfo(AccelerationUnit.StandardGravity, "StandardGravity", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Acceleration); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -134,12 +134,6 @@ public Acceleration(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Acceleration; - /// /// All units of measurement for the Acceleration quantity. /// @@ -170,11 +164,6 @@ public Acceleration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Acceleration.QuantityType; - /// /// The of this quantity. /// @@ -1051,8 +1040,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AccelerationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Acceleration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Acceleration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 47c45d7471..49eb24c5ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -71,7 +71,7 @@ static AmountOfSubstance() new UnitInfo(AmountOfSubstanceUnit.NanopoundMole, "NanopoundMoles", BaseUnits.Undefined), new UnitInfo(AmountOfSubstanceUnit.PoundMole, "PoundMoles", new BaseUnits(amount: AmountOfSubstanceUnit.PoundMole)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AmountOfSubstance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -135,12 +135,6 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.AmountOfSubstance; - /// /// All units of measurement for the AmountOfSubstance quantity. /// @@ -171,11 +165,6 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => AmountOfSubstance.QuantityType; - /// /// The of this quantity. /// @@ -1068,8 +1057,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AmountOfSubstanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AmountOfSubstance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AmountOfSubstance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index f822d6a34f..f681673404 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -60,7 +60,7 @@ static AmplitudeRatio() new UnitInfo(AmplitudeRatioUnit.DecibelUnloaded, "DecibelsUnloaded", BaseUnits.Undefined), new UnitInfo(AmplitudeRatioUnit.DecibelVolt, "DecibelVolts", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AmplitudeRatio); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.AmplitudeRatio; - /// /// All units of measurement for the AmplitudeRatio quantity. /// @@ -160,11 +154,6 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => AmplitudeRatio.QuantityType; - /// /// The of this quantity. /// @@ -889,8 +878,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AmplitudeRatioUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AmplitudeRatio.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AmplitudeRatio.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 0db185bd07..54b9740139 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -72,7 +72,7 @@ static Angle() new UnitInfo(AngleUnit.Revolution, "Revolutions", BaseUnits.Undefined), new UnitInfo(AngleUnit.Tilt, "Tilt", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Angle); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -136,12 +136,6 @@ public Angle(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Angle MinValue { get; } = new Angle(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Angle; - /// /// All units of measurement for the Angle quantity. /// @@ -172,11 +166,6 @@ public Angle(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Angle.QuantityType; - /// /// The of this quantity. /// @@ -1085,8 +1074,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AngleUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Angle.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Angle.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 83a67cf3e0..6eb19413be 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -59,7 +59,7 @@ static ApparentEnergy() new UnitInfo(ApparentEnergyUnit.MegavoltampereHour, "MegavoltampereHours", BaseUnits.Undefined), new UnitInfo(ApparentEnergyUnit.VoltampereHour, "VoltampereHours", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ApparentEnergy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public ApparentEnergy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ApparentEnergy; - /// /// All units of measurement for the ApparentEnergy quantity. /// @@ -159,11 +153,6 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ApparentEnergy.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ApparentEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ApparentEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ApparentEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 82e8a25b8a..b0808f9735 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -60,7 +60,7 @@ static ApparentPower() new UnitInfo(ApparentPowerUnit.Megavoltampere, "Megavoltamperes", BaseUnits.Undefined), new UnitInfo(ApparentPowerUnit.Voltampere, "Voltamperes", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ApparentPower); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public ApparentPower(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ApparentPower; - /// /// All units of measurement for the ApparentPower quantity. /// @@ -160,11 +154,6 @@ public ApparentPower(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ApparentPower.QuantityType; - /// /// The of this quantity. /// @@ -881,8 +870,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ApparentPowerUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ApparentPower.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ApparentPower.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 34533ade51..1df64259f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -70,7 +70,7 @@ static Area() new UnitInfo(AreaUnit.SquareYard, "SquareYards", new BaseUnits(length: LengthUnit.Yard)), new UnitInfo(AreaUnit.UsSurveySquareFoot, "UsSurveySquareFeet", new BaseUnits(length: LengthUnit.UsSurveyFoot)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Area); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -134,12 +134,6 @@ public Area(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Area MinValue { get; } = new Area(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Area; - /// /// All units of measurement for the Area quantity. /// @@ -170,11 +164,6 @@ public Area(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Area.QuantityType; - /// /// The of this quantity. /// @@ -1051,8 +1040,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AreaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Area.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Area.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index bf2661bfda..377cb6dcf8 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -57,7 +57,7 @@ static AreaDensity() new UnitInfo[] { new UnitInfo(AreaDensityUnit.KilogramPerSquareMeter, "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AreaDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -121,12 +121,6 @@ public AreaDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.AreaDensity; - /// /// All units of measurement for the AreaDensity quantity. /// @@ -157,11 +151,6 @@ public AreaDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => AreaDensity.QuantityType; - /// /// The of this quantity. /// @@ -830,8 +819,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AreaDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AreaDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AreaDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 84395f99ea..05bf3f6f81 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -62,7 +62,7 @@ static AreaMomentOfInertia() new UnitInfo(AreaMomentOfInertiaUnit.MeterToTheFourth, "MetersToTheFourth", new BaseUnits(length: LengthUnit.Meter)), new UnitInfo(AreaMomentOfInertiaUnit.MillimeterToTheFourth, "MillimetersToTheFourth", new BaseUnits(length: LengthUnit.Millimeter)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.AreaMomentOfInertia); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.AreaMomentOfInertia; - /// /// All units of measurement for the AreaMomentOfInertia quantity. /// @@ -162,11 +156,6 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => AreaMomentOfInertia.QuantityType; - /// /// The of this quantity. /// @@ -915,8 +904,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AreaMomentOfInertiaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AreaMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AreaMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 1eae835a28..4bc458f27c 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -85,7 +85,7 @@ static BitRate() new UnitInfo(BitRateUnit.TerabitPerSecond, "TerabitsPerSecond", BaseUnits.Undefined), new UnitInfo(BitRateUnit.TerabytePerSecond, "TerabytesPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.BitRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -149,12 +149,6 @@ public BitRate(decimal value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static BitRate MinValue { get; } = new BitRate(decimal.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.BitRate; - /// /// All units of measurement for the BitRate quantity. /// @@ -190,11 +184,6 @@ public BitRate(decimal value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => BitRate.QuantityType; - /// /// The of this quantity. /// @@ -1263,8 +1252,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(BitRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return BitRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return BitRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index f127d02221..c61a75f3a0 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -59,7 +59,7 @@ static BrakeSpecificFuelConsumption() new UnitInfo(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, "KilogramsPerJoule", BaseUnits.Undefined), new UnitInfo(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, "PoundsPerMechanicalHorsepowerHour", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.BrakeSpecificFuelConsumption); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.BrakeSpecificFuelConsumption; - /// /// All units of measurement for the BrakeSpecificFuelConsumption quantity. /// @@ -159,11 +153,6 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => BrakeSpecificFuelConsumption.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(BrakeSpecificFuelConsumptionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return BrakeSpecificFuelConsumption.QuantityType; else if(conversionType == typeof(QuantityInfo)) return BrakeSpecificFuelConsumption.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 528c66ccde..57370ce801 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -66,7 +66,7 @@ static Capacitance() new UnitInfo(CapacitanceUnit.Nanofarad, "Nanofarads", BaseUnits.Undefined), new UnitInfo(CapacitanceUnit.Picofarad, "Picofarads", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Capacitance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -130,12 +130,6 @@ public Capacitance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Capacitance; - /// /// All units of measurement for the Capacitance quantity. /// @@ -166,11 +160,6 @@ public Capacitance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Capacitance.QuantityType; - /// /// The of this quantity. /// @@ -935,8 +924,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(CapacitanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Capacitance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Capacitance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 0e686eeff5..f8d7899350 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -59,7 +59,7 @@ static CoefficientOfThermalExpansion() new UnitInfo(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, "InverseDegreeFahrenheit", new BaseUnits(temperature: TemperatureUnit.DegreeFahrenheit)), new UnitInfo(CoefficientOfThermalExpansionUnit.InverseKelvin, "InverseKelvin", new BaseUnits(temperature: TemperatureUnit.Kelvin)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.CoefficientOfThermalExpansion); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.CoefficientOfThermalExpansion; - /// /// All units of measurement for the CoefficientOfThermalExpansion quantity. /// @@ -159,11 +153,6 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => CoefficientOfThermalExpansion.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(CoefficientOfThermalExpansionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return CoefficientOfThermalExpansion.QuantityType; else if(conversionType == typeof(QuantityInfo)) return CoefficientOfThermalExpansion.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 70b39f3f13..2735994c0e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -99,7 +99,7 @@ static Density() new UnitInfo(DensityUnit.TonnePerCubicMeter, "TonnesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Tonne)), new UnitInfo(DensityUnit.TonnePerCubicMillimeter, "TonnesPerCubicMillimeter", new BaseUnits(length: LengthUnit.Millimeter, mass: MassUnit.Tonne)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Density); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -163,12 +163,6 @@ public Density(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Density MinValue { get; } = new Density(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Density; - /// /// All units of measurement for the Density quantity. /// @@ -199,11 +193,6 @@ public Density(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Density.QuantityType; - /// /// The of this quantity. /// @@ -1496,8 +1485,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(DensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Density.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Density.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index d96bac6e4a..3630845b9e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -66,7 +66,7 @@ static Duration() new UnitInfo(DurationUnit.Week, "Weeks", new BaseUnits(time: DurationUnit.Week)), new UnitInfo(DurationUnit.Year365, "Years365", new BaseUnits(time: DurationUnit.Year365)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Duration); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -130,12 +130,6 @@ public Duration(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Duration MinValue { get; } = new Duration(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Duration; - /// /// All units of measurement for the Duration quantity. /// @@ -166,11 +160,6 @@ public Duration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Duration.QuantityType; - /// /// The of this quantity. /// @@ -983,8 +972,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(DurationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Duration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Duration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 1c59bf9032..1dce91357e 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -69,7 +69,7 @@ static DynamicViscosity() new UnitInfo(DynamicViscosityUnit.PoundPerFootSecond, "PoundsPerFootSecond", BaseUnits.Undefined), new UnitInfo(DynamicViscosityUnit.Reyn, "Reyns", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.DynamicViscosity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -133,12 +133,6 @@ public DynamicViscosity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.DynamicViscosity; - /// /// All units of measurement for the DynamicViscosity quantity. /// @@ -169,11 +163,6 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => DynamicViscosity.QuantityType; - /// /// The of this quantity. /// @@ -986,8 +975,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(DynamicViscosityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return DynamicViscosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return DynamicViscosity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 6d4a3bed45..22940a65d8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -60,7 +60,7 @@ static ElectricAdmittance() new UnitInfo(ElectricAdmittanceUnit.Nanosiemens, "Nanosiemens", BaseUnits.Undefined), new UnitInfo(ElectricAdmittanceUnit.Siemens, "Siemens", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricAdmittance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricAdmittance; - /// /// All units of measurement for the ElectricAdmittance quantity. /// @@ -160,11 +154,6 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricAdmittance.QuantityType; - /// /// The of this quantity. /// @@ -881,8 +870,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricAdmittanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricAdmittance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricAdmittance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index f9e8322338..2c76c8244b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -64,7 +64,7 @@ static ElectricCharge() new UnitInfo(ElectricChargeUnit.MegaampereHour, "MegaampereHours", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.MilliampereHour, "MilliampereHours", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCharge); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -128,12 +128,6 @@ public ElectricCharge(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricCharge; - /// /// All units of measurement for the ElectricCharge quantity. /// @@ -164,11 +158,6 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCharge.QuantityType; - /// /// The of this quantity. /// @@ -901,8 +890,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricChargeUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCharge.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCharge.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 8d1cf9ab62..d842e21b6f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -60,7 +60,7 @@ static ElectricChargeDensity() new UnitInfo[] { new UnitInfo(ElectricChargeDensityUnit.CoulombPerCubicMeter, "CoulombsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricChargeDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricChargeDensity; - /// /// All units of measurement for the ElectricChargeDensity quantity. /// @@ -160,11 +154,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricChargeDensity.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricChargeDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricChargeDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricChargeDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 025a53d252..7b4b4cd136 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -62,7 +62,7 @@ static ElectricConductance() new UnitInfo(ElectricConductanceUnit.Millisiemens, "Millisiemens", BaseUnits.Undefined), new UnitInfo(ElectricConductanceUnit.Siemens, "Siemens", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public ElectricConductance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricConductance; - /// /// All units of measurement for the ElectricConductance quantity. /// @@ -162,11 +156,6 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricConductance.QuantityType; - /// /// The of this quantity. /// @@ -867,8 +856,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricConductanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricConductance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricConductance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 8fa33f43e8..b5f7b23437 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -62,7 +62,7 @@ static ElectricConductivity() new UnitInfo(ElectricConductivityUnit.SiemensPerInch, "SiemensPerInch", BaseUnits.Undefined), new UnitInfo(ElectricConductivityUnit.SiemensPerMeter, "SiemensPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductivity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public ElectricConductivity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricConductivity; - /// /// All units of measurement for the ElectricConductivity quantity. /// @@ -162,11 +156,6 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricConductivity.QuantityType; - /// /// The of this quantity. /// @@ -867,8 +856,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricConductivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricConductivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricConductivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 523c8e180b..cefa2e07d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -64,7 +64,7 @@ static ElectricCurrent() new UnitInfo(ElectricCurrentUnit.Nanoampere, "Nanoamperes", BaseUnits.Undefined), new UnitInfo(ElectricCurrentUnit.Picoampere, "Picoamperes", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrent); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -128,12 +128,6 @@ public ElectricCurrent(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrent; - /// /// All units of measurement for the ElectricCurrent quantity. /// @@ -164,11 +158,6 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCurrent.QuantityType; - /// /// The of this quantity. /// @@ -949,8 +938,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricCurrentUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCurrent.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCurrent.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 46659c9f61..64e067d65f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -62,7 +62,7 @@ static ElectricCurrentDensity() new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareInch, "AmperesPerSquareInch", new BaseUnits(length: LengthUnit.Inch, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareMeter, "AmperesPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrentDensity; - /// /// All units of measurement for the ElectricCurrentDensity quantity. /// @@ -162,11 +156,6 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCurrentDensity.QuantityType; - /// /// The of this quantity. /// @@ -867,8 +856,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricCurrentDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCurrentDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCurrentDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 81929beb4a..f317d5cf44 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -60,7 +60,7 @@ static ElectricCurrentGradient() new UnitInfo(ElectricCurrentGradientUnit.AmperePerNanosecond, "AmperesPerNanosecond", new BaseUnits(time: DurationUnit.Nanosecond, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricCurrentGradientUnit.AmperePerSecond, "AmperesPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentGradient); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricCurrentGradient; - /// /// All units of measurement for the ElectricCurrentGradient quantity. /// @@ -160,11 +154,6 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricCurrentGradient.QuantityType; - /// /// The of this quantity. /// @@ -881,8 +870,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricCurrentGradientUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCurrentGradient.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCurrentGradient.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 2ee4350268..e982c06306 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -60,7 +60,7 @@ static ElectricField() new UnitInfo[] { new UnitInfo(ElectricFieldUnit.VoltPerMeter, "VoltsPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricField); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public ElectricField(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricField; - /// /// All units of measurement for the ElectricField quantity. /// @@ -160,11 +154,6 @@ public ElectricField(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricField.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricFieldUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricField.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricField.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 132893a5b2..36d3c62a31 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -63,7 +63,7 @@ static ElectricInductance() new UnitInfo(ElectricInductanceUnit.Millihenry, "Millihenries", BaseUnits.Undefined), new UnitInfo(ElectricInductanceUnit.Nanohenry, "Nanohenries", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricInductance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -127,12 +127,6 @@ public ElectricInductance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricInductance; - /// /// All units of measurement for the ElectricInductance quantity. /// @@ -163,11 +157,6 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricInductance.QuantityType; - /// /// The of this quantity. /// @@ -884,8 +873,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricInductanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricInductance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricInductance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 34b3e2b94e..5272f87f64 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -61,7 +61,7 @@ static ElectricPotential() new UnitInfo(ElectricPotentialUnit.Millivolt, "Millivolts", BaseUnits.Undefined), new UnitInfo(ElectricPotentialUnit.Volt, "Volts", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotential); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -125,12 +125,6 @@ public ElectricPotential(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotential; - /// /// All units of measurement for the ElectricPotential quantity. /// @@ -161,11 +155,6 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotential.QuantityType; - /// /// The of this quantity. /// @@ -898,8 +887,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotential.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotential.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index ecb0ccda6f..8b21fed4ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -61,7 +61,7 @@ static ElectricPotentialAc() new UnitInfo(ElectricPotentialAcUnit.MillivoltAc, "MillivoltsAc", BaseUnits.Undefined), new UnitInfo(ElectricPotentialAcUnit.VoltAc, "VoltsAc", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialAc); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -125,12 +125,6 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialAc; - /// /// All units of measurement for the ElectricPotentialAc quantity. /// @@ -161,11 +155,6 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotentialAc.QuantityType; - /// /// The of this quantity. /// @@ -898,8 +887,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialAcUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotentialAc.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotentialAc.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index b824f18c4d..b8d26d52d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -76,7 +76,7 @@ static ElectricPotentialChangeRate() new UnitInfo(ElectricPotentialChangeRateUnit.VoltPerMinute, "VoltsPerMinutes", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Minute, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricPotentialChangeRateUnit.VoltPerSecond, "VoltsPerSeconds", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialChangeRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -140,12 +140,6 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialChangeRate; - /// /// All units of measurement for the ElectricPotentialChangeRate quantity. /// @@ -176,11 +170,6 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotentialChangeRate.QuantityType; - /// /// The of this quantity. /// @@ -1153,8 +1142,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotentialChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotentialChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 89908ae98e..d99cbca13d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -61,7 +61,7 @@ static ElectricPotentialDc() new UnitInfo(ElectricPotentialDcUnit.MillivoltDc, "MillivoltsDc", BaseUnits.Undefined), new UnitInfo(ElectricPotentialDcUnit.VoltDc, "VoltsDc", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialDc); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -125,12 +125,6 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricPotentialDc; - /// /// All units of measurement for the ElectricPotentialDc quantity. /// @@ -161,11 +155,6 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricPotentialDc.QuantityType; - /// /// The of this quantity. /// @@ -898,8 +887,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialDcUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotentialDc.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotentialDc.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 87cc892108..de83f98590 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -62,7 +62,7 @@ static ElectricResistance() new UnitInfo(ElectricResistanceUnit.Milliohm, "Milliohms", BaseUnits.Undefined), new UnitInfo(ElectricResistanceUnit.Ohm, "Ohms", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public ElectricResistance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricResistance; - /// /// All units of measurement for the ElectricResistance quantity. /// @@ -162,11 +156,6 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricResistance.QuantityType; - /// /// The of this quantity. /// @@ -915,8 +904,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricResistanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricResistance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricResistance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index ff90a867c8..1be903d4f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -73,7 +73,7 @@ static ElectricResistivity() new UnitInfo(ElectricResistivityUnit.PicoohmCentimeter, "PicoohmsCentimeter", BaseUnits.Undefined), new UnitInfo(ElectricResistivityUnit.PicoohmMeter, "PicoohmMeters", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistivity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -137,12 +137,6 @@ public ElectricResistivity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricResistivity; - /// /// All units of measurement for the ElectricResistivity quantity. /// @@ -173,11 +167,6 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricResistivity.QuantityType; - /// /// The of this quantity. /// @@ -1054,8 +1043,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricResistivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricResistivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricResistivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 21caea1829..d0b612d5de 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -62,7 +62,7 @@ static ElectricSurfaceChargeDensity() new UnitInfo(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, "CoulombsPerSquareInch", new BaseUnits(length: LengthUnit.Inch, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, "CoulombsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ElectricSurfaceChargeDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ElectricSurfaceChargeDensity; - /// /// All units of measurement for the ElectricSurfaceChargeDensity quantity. /// @@ -162,11 +156,6 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ElectricSurfaceChargeDensity.QuantityType; - /// /// The of this quantity. /// @@ -867,8 +856,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricSurfaceChargeDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricSurfaceChargeDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricSurfaceChargeDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 1a61ed8cdb..0c8851fab2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -92,7 +92,7 @@ static Energy() new UnitInfo(EnergyUnit.WattDay, "WattDays", BaseUnits.Undefined), new UnitInfo(EnergyUnit.WattHour, "WattHours", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Energy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -156,12 +156,6 @@ public Energy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Energy MinValue { get; } = new Energy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Energy; - /// /// All units of measurement for the Energy quantity. /// @@ -192,11 +186,6 @@ public Energy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Energy.QuantityType; - /// /// The of this quantity. /// @@ -1425,8 +1414,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(EnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Energy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Energy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 784cc8326a..23d52fcf63 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -63,7 +63,7 @@ static Entropy() new UnitInfo(EntropyUnit.KilojoulePerKelvin, "KilojoulesPerKelvin", BaseUnits.Undefined), new UnitInfo(EntropyUnit.MegajoulePerKelvin, "MegajoulesPerKelvin", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Entropy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -127,12 +127,6 @@ public Entropy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Entropy MinValue { get; } = new Entropy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Entropy; - /// /// All units of measurement for the Entropy quantity. /// @@ -163,11 +157,6 @@ public Entropy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Entropy.QuantityType; - /// /// The of this quantity. /// @@ -932,8 +921,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(EntropyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Entropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Entropy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 75785057d7..3f781bc20a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -71,7 +71,7 @@ static Force() new UnitInfo(ForceUnit.ShortTonForce, "ShortTonsForce", BaseUnits.Undefined), new UnitInfo(ForceUnit.TonneForce, "TonnesForce", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Force); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -135,12 +135,6 @@ public Force(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Force MinValue { get; } = new Force(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Force; - /// /// All units of measurement for the Force quantity. /// @@ -171,11 +165,6 @@ public Force(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Force.QuantityType; - /// /// The of this quantity. /// @@ -1068,8 +1057,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ForceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Force.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Force.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 1be80e0b95..7df7ed7389 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -71,7 +71,7 @@ static ForceChangeRate() new UnitInfo(ForceChangeRateUnit.PoundForcePerMinute, "PoundsForcePerMinute", BaseUnits.Undefined), new UnitInfo(ForceChangeRateUnit.PoundForcePerSecond, "PoundsForcePerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ForceChangeRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -135,12 +135,6 @@ public ForceChangeRate(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ForceChangeRate; - /// /// All units of measurement for the ForceChangeRate quantity. /// @@ -171,11 +165,6 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ForceChangeRate.QuantityType; - /// /// The of this quantity. /// @@ -1068,8 +1057,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ForceChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ForceChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ForceChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 120fbef58a..1deb899115 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -94,7 +94,7 @@ static ForcePerLength() new UnitInfo(ForcePerLengthUnit.TonneForcePerMeter, "TonnesForcePerMeter", BaseUnits.Undefined), new UnitInfo(ForcePerLengthUnit.TonneForcePerMillimeter, "TonnesForcePerMillimeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ForcePerLength); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -158,12 +158,6 @@ public ForcePerLength(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ForcePerLength; - /// /// All units of measurement for the ForcePerLength quantity. /// @@ -194,11 +188,6 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ForcePerLength.QuantityType; - /// /// The of this quantity. /// @@ -1459,8 +1448,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ForcePerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ForcePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ForcePerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index de0f148873..696bbd145d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -67,7 +67,7 @@ static Frequency() new UnitInfo(FrequencyUnit.RadianPerSecond, "RadiansPerSecond", BaseUnits.Undefined), new UnitInfo(FrequencyUnit.Terahertz, "Terahertz", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Frequency); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -131,12 +131,6 @@ public Frequency(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Frequency MinValue { get; } = new Frequency(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Frequency; - /// /// All units of measurement for the Frequency quantity. /// @@ -167,11 +161,6 @@ public Frequency(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Frequency.QuantityType; - /// /// The of this quantity. /// @@ -1000,8 +989,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(FrequencyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Frequency.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Frequency.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 68843d7f8a..2d92357c77 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -63,7 +63,7 @@ static FuelEfficiency() new UnitInfo(FuelEfficiencyUnit.MilePerUkGallon, "MilesPerUkGallon", BaseUnits.Undefined), new UnitInfo(FuelEfficiencyUnit.MilePerUsGallon, "MilesPerUsGallon", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.FuelEfficiency); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -127,12 +127,6 @@ public FuelEfficiency(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.FuelEfficiency; - /// /// All units of measurement for the FuelEfficiency quantity. /// @@ -163,11 +157,6 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => FuelEfficiency.QuantityType; - /// /// The of this quantity. /// @@ -884,8 +873,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(FuelEfficiencyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return FuelEfficiency.QuantityType; else if(conversionType == typeof(QuantityInfo)) return FuelEfficiency.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 32b212bd5b..9095a143a3 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -74,7 +74,7 @@ static HeatFlux() new UnitInfo(HeatFluxUnit.WattPerSquareInch, "WattsPerSquareInch", BaseUnits.Undefined), new UnitInfo(HeatFluxUnit.WattPerSquareMeter, "WattsPerSquareMeter", new BaseUnits(mass: MassUnit.Kilogram, time: DurationUnit.Second)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.HeatFlux); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -138,12 +138,6 @@ public HeatFlux(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.HeatFlux; - /// /// All units of measurement for the HeatFlux quantity. /// @@ -174,11 +168,6 @@ public HeatFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => HeatFlux.QuantityType; - /// /// The of this quantity. /// @@ -1119,8 +1108,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(HeatFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return HeatFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return HeatFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 4f3385c7d5..fb9dade625 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -59,7 +59,7 @@ static HeatTransferCoefficient() new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, "WattsPerSquareMeterCelsius", BaseUnits.Undefined), new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, "WattsPerSquareMeterKelvin", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.HeatTransferCoefficient); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.HeatTransferCoefficient; - /// /// All units of measurement for the HeatTransferCoefficient quantity. /// @@ -159,11 +153,6 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => HeatTransferCoefficient.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(HeatTransferCoefficientUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return HeatTransferCoefficient.QuantityType; else if(conversionType == typeof(QuantityInfo)) return HeatTransferCoefficient.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 98c318beaf..19f5c85343 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -63,7 +63,7 @@ static Illuminance() new UnitInfo(IlluminanceUnit.Megalux, "Megalux", BaseUnits.Undefined), new UnitInfo(IlluminanceUnit.Millilux, "Millilux", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Illuminance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -127,12 +127,6 @@ public Illuminance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Illuminance; - /// /// All units of measurement for the Illuminance quantity. /// @@ -163,11 +157,6 @@ public Illuminance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Illuminance.QuantityType; - /// /// The of this quantity. /// @@ -884,8 +873,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(IlluminanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Illuminance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Illuminance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 29058e6ce8..21f5ee75a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -82,7 +82,7 @@ static Information() new UnitInfo(InformationUnit.Terabit, "Terabits", BaseUnits.Undefined), new UnitInfo(InformationUnit.Terabyte, "Terabytes", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Information); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -146,12 +146,6 @@ public Information(decimal value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Information MinValue { get; } = new Information(decimal.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Information; - /// /// All units of measurement for the Information quantity. /// @@ -187,11 +181,6 @@ public Information(decimal value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Information.QuantityType; - /// /// The of this quantity. /// @@ -1260,8 +1249,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(InformationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Information.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Information.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 23fa842bb3..67b1cccd96 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -70,7 +70,7 @@ static Irradiance() new UnitInfo(IrradianceUnit.WattPerSquareCentimeter, "WattsPerSquareCentimeter", BaseUnits.Undefined), new UnitInfo(IrradianceUnit.WattPerSquareMeter, "WattsPerSquareMeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Irradiance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -134,12 +134,6 @@ public Irradiance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Irradiance; - /// /// All units of measurement for the Irradiance quantity. /// @@ -170,11 +164,6 @@ public Irradiance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Irradiance.QuantityType; - /// /// The of this quantity. /// @@ -1051,8 +1040,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(IrradianceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Irradiance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Irradiance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 50d6dbf240..622868f081 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -66,7 +66,7 @@ static Irradiation() new UnitInfo(IrradiationUnit.MillijoulePerSquareCentimeter, "MillijoulesPerSquareCentimeter", BaseUnits.Undefined), new UnitInfo(IrradiationUnit.WattHourPerSquareMeter, "WattHoursPerSquareMeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Irradiation); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -130,12 +130,6 @@ public Irradiation(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Irradiation; - /// /// All units of measurement for the Irradiation quantity. /// @@ -166,11 +160,6 @@ public Irradiation(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Irradiation.QuantityType; - /// /// The of this quantity. /// @@ -935,8 +924,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(IrradiationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Irradiation.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Irradiation.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 19745a6374..308b1e615c 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -68,7 +68,7 @@ static KinematicViscosity() new UnitInfo(KinematicViscosityUnit.SquareMeterPerSecond, "SquareMetersPerSecond", BaseUnits.Undefined), new UnitInfo(KinematicViscosityUnit.Stokes, "Stokes", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.KinematicViscosity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -132,12 +132,6 @@ public KinematicViscosity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.KinematicViscosity; - /// /// All units of measurement for the KinematicViscosity quantity. /// @@ -168,11 +162,6 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => KinematicViscosity.QuantityType; - /// /// The of this quantity. /// @@ -969,8 +958,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(KinematicViscosityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return KinematicViscosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return KinematicViscosity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index b53fd11642..6a78e3fb82 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -57,7 +57,7 @@ static LapseRate() new UnitInfo[] { new UnitInfo(LapseRateUnit.DegreeCelsiusPerKilometer, "DegreesCelciusPerKilometer", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LapseRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -121,12 +121,6 @@ public LapseRate(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.LapseRate; - /// /// All units of measurement for the LapseRate quantity. /// @@ -157,11 +151,6 @@ public LapseRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => LapseRate.QuantityType; - /// /// The of this quantity. /// @@ -830,8 +819,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LapseRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LapseRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LapseRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 73487a133f..f328ab22ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -89,7 +89,7 @@ static Length() new UnitInfo(LengthUnit.UsSurveyFoot, "UsSurveyFeet", new BaseUnits(length: LengthUnit.UsSurveyFoot)), new UnitInfo(LengthUnit.Yard, "Yards", new BaseUnits(length: LengthUnit.Yard)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Length); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -153,12 +153,6 @@ public Length(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Length MinValue { get; } = new Length(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Length; - /// /// All units of measurement for the Length quantity. /// @@ -189,11 +183,6 @@ public Length(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Length.QuantityType; - /// /// The of this quantity. /// @@ -1374,8 +1363,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Length.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Length.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 103dfbad8f..958e9fde58 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -58,7 +58,7 @@ static Level() new UnitInfo(LevelUnit.Decibel, "Decibels", BaseUnits.Undefined), new UnitInfo(LevelUnit.Neper, "Nepers", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Level); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -122,12 +122,6 @@ public Level(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Level MinValue { get; } = new Level(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Level; - /// /// All units of measurement for the Level quantity. /// @@ -158,11 +152,6 @@ public Level(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Level.QuantityType; - /// /// The of this quantity. /// @@ -855,8 +844,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LevelUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Level.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Level.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 730ad86f70..af54ca335e 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -73,7 +73,7 @@ static LinearDensity() new UnitInfo(LinearDensityUnit.PoundPerFoot, "PoundsPerFoot", BaseUnits.Undefined), new UnitInfo(LinearDensityUnit.PoundPerInch, "PoundsPerInch", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LinearDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -137,12 +137,6 @@ public LinearDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.LinearDensity; - /// /// All units of measurement for the LinearDensity quantity. /// @@ -173,11 +167,6 @@ public LinearDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => LinearDensity.QuantityType; - /// /// The of this quantity. /// @@ -1054,8 +1043,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LinearDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LinearDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LinearDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 27d22715b6..819e7e4932 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -84,7 +84,7 @@ static LinearPowerDensity() new UnitInfo(LinearPowerDensityUnit.WattPerMeter, "WattsPerMeter", BaseUnits.Undefined), new UnitInfo(LinearPowerDensityUnit.WattPerMillimeter, "WattsPerMillimeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LinearPowerDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -148,12 +148,6 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.LinearPowerDensity; - /// /// All units of measurement for the LinearPowerDensity quantity. /// @@ -184,11 +178,6 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => LinearPowerDensity.QuantityType; - /// /// The of this quantity. /// @@ -1241,8 +1230,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LinearPowerDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LinearPowerDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LinearPowerDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 1e3ce7c664..848d9099d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -73,7 +73,7 @@ static Luminosity() new UnitInfo(LuminosityUnit.Terawatt, "Terawatts", BaseUnits.Undefined), new UnitInfo(LuminosityUnit.Watt, "Watts", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Luminosity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -137,12 +137,6 @@ public Luminosity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Luminosity; - /// /// All units of measurement for the Luminosity quantity. /// @@ -173,11 +167,6 @@ public Luminosity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Luminosity.QuantityType; - /// /// The of this quantity. /// @@ -1054,8 +1043,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LuminosityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Luminosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Luminosity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 46bc89d193..ab99cd168d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -60,7 +60,7 @@ static LuminousFlux() new UnitInfo[] { new UnitInfo(LuminousFluxUnit.Lumen, "Lumens", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LuminousFlux); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.LuminousFlux; - /// /// All units of measurement for the LuminousFlux quantity. /// @@ -160,11 +154,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => LuminousFlux.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LuminousFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LuminousFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LuminousFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index ee9a507ac1..015111d2d7 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -60,7 +60,7 @@ static LuminousIntensity() new UnitInfo[] { new UnitInfo(LuminousIntensityUnit.Candela, "Candela", new BaseUnits(luminousIntensity: LuminousIntensityUnit.Candela)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.LuminousIntensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.LuminousIntensity; - /// /// All units of measurement for the LuminousIntensity quantity. /// @@ -160,11 +154,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => LuminousIntensity.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LuminousIntensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LuminousIntensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LuminousIntensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index d794831228..58621ec89b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -65,7 +65,7 @@ static MagneticField() new UnitInfo(MagneticFieldUnit.Nanotesla, "Nanoteslas", BaseUnits.Undefined), new UnitInfo(MagneticFieldUnit.Tesla, "Teslas", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MagneticField); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -129,12 +129,6 @@ public MagneticField(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MagneticField; - /// /// All units of measurement for the MagneticField quantity. /// @@ -165,11 +159,6 @@ public MagneticField(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MagneticField.QuantityType; - /// /// The of this quantity. /// @@ -918,8 +907,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MagneticFieldUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MagneticField.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MagneticField.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 0bd872cb36..b075a1e27f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -60,7 +60,7 @@ static MagneticFlux() new UnitInfo[] { new UnitInfo(MagneticFluxUnit.Weber, "Webers", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MagneticFlux); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MagneticFlux; - /// /// All units of measurement for the MagneticFlux quantity. /// @@ -160,11 +154,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MagneticFlux.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MagneticFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MagneticFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MagneticFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 3218711d19..a955b3f65f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -60,7 +60,7 @@ static Magnetization() new UnitInfo[] { new UnitInfo(MagnetizationUnit.AmperePerMeter, "AmperesPerMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Magnetization); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public Magnetization(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Magnetization; - /// /// All units of measurement for the Magnetization quantity. /// @@ -160,11 +154,6 @@ public Magnetization(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Magnetization.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MagnetizationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Magnetization.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Magnetization.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index e6563824f4..0873c1a4b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -81,7 +81,7 @@ static Mass() new UnitInfo(MassUnit.Stone, "Stone", new BaseUnits(mass: MassUnit.Stone)), new UnitInfo(MassUnit.Tonne, "Tonnes", new BaseUnits(mass: MassUnit.Tonne)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Mass); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -145,12 +145,6 @@ public Mass(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Mass MinValue { get; } = new Mass(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Mass; - /// /// All units of measurement for the Mass quantity. /// @@ -181,11 +175,6 @@ public Mass(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Mass.QuantityType; - /// /// The of this quantity. /// @@ -1238,8 +1227,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Mass.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Mass.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 17154b31aa..c20d1e09c9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -108,7 +108,7 @@ static MassConcentration() new UnitInfo(MassConcentrationUnit.TonnePerCubicMeter, "TonnesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Tonne)), new UnitInfo(MassConcentrationUnit.TonnePerCubicMillimeter, "TonnesPerCubicMillimeter", new BaseUnits(length: LengthUnit.Millimeter, mass: MassUnit.Tonne)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassConcentration); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -172,12 +172,6 @@ public MassConcentration(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MassConcentration; - /// /// All units of measurement for the MassConcentration quantity. /// @@ -208,11 +202,6 @@ public MassConcentration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MassConcentration.QuantityType; - /// /// The of this quantity. /// @@ -1649,8 +1638,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassConcentrationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassConcentration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassConcentration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index fee47b8f72..7fa8858797 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -89,7 +89,7 @@ static MassFlow() new UnitInfo(MassFlowUnit.TonnePerDay, "TonnesPerDay", BaseUnits.Undefined), new UnitInfo(MassFlowUnit.TonnePerHour, "TonnesPerHour", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassFlow); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -153,12 +153,6 @@ public MassFlow(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MassFlow; - /// /// All units of measurement for the MassFlow quantity. /// @@ -189,11 +183,6 @@ public MassFlow(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MassFlow.QuantityType; - /// /// The of this quantity. /// @@ -1374,8 +1363,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassFlowUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassFlow.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 2fe9667d05..d4124d3f78 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -68,7 +68,7 @@ static MassFlux() new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMeter, "KilogramsPerSecondPerSquareMeter", BaseUnits.Undefined), new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, "KilogramsPerSecondPerSquareMillimeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassFlux); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -132,12 +132,6 @@ public MassFlux(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MassFlux; - /// /// All units of measurement for the MassFlux quantity. /// @@ -168,11 +162,6 @@ public MassFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MassFlux.QuantityType; - /// /// The of this quantity. /// @@ -1017,8 +1006,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index f70142fd28..d81dfed06b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -83,7 +83,7 @@ static MassFraction() new UnitInfo(MassFractionUnit.PartPerTrillion, "PartsPerTrillion", BaseUnits.Undefined), new UnitInfo(MassFractionUnit.Percent, "Percent", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassFraction); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -147,12 +147,6 @@ public MassFraction(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MassFraction; - /// /// All units of measurement for the MassFraction quantity. /// @@ -183,11 +177,6 @@ public MassFraction(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MassFraction.QuantityType; - /// /// The of this quantity. /// @@ -1224,8 +1213,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassFractionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassFraction.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassFraction.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 269f53e444..526b0f3cb0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -84,7 +84,7 @@ static MassMomentOfInertia() new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMeter, "TonneSquareMeters", BaseUnits.Undefined), new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMilimeter, "TonneSquareMilimeters", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MassMomentOfInertia); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -148,12 +148,6 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MassMomentOfInertia; - /// /// All units of measurement for the MassMomentOfInertia quantity. /// @@ -184,11 +178,6 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MassMomentOfInertia.QuantityType; - /// /// The of this quantity. /// @@ -1289,8 +1278,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassMomentOfInertiaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index d0f32df103..51b4b0c41b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -59,7 +59,7 @@ static MolarEnergy() new UnitInfo(MolarEnergyUnit.KilojoulePerMole, "KilojoulesPerMole", BaseUnits.Undefined), new UnitInfo(MolarEnergyUnit.MegajoulePerMole, "MegajoulesPerMole", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MolarEnergy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public MolarEnergy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MolarEnergy; - /// /// All units of measurement for the MolarEnergy quantity. /// @@ -159,11 +153,6 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MolarEnergy.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MolarEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MolarEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 3f3641bc44..3725b9da9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -59,7 +59,7 @@ static MolarEntropy() new UnitInfo(MolarEntropyUnit.KilojoulePerMoleKelvin, "KilojoulesPerMoleKelvin", BaseUnits.Undefined), new UnitInfo(MolarEntropyUnit.MegajoulePerMoleKelvin, "MegajoulesPerMoleKelvin", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MolarEntropy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public MolarEntropy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MolarEntropy; - /// /// All units of measurement for the MolarEntropy quantity. /// @@ -159,11 +153,6 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MolarEntropy.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarEntropyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MolarEntropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MolarEntropy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index adeaf45cab..1fc9c12970 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -68,7 +68,7 @@ static MolarMass() new UnitInfo(MolarMassUnit.NanogramPerMole, "NanogramsPerMole", BaseUnits.Undefined), new UnitInfo(MolarMassUnit.PoundPerMole, "PoundsPerMole", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.MolarMass); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -132,12 +132,6 @@ public MolarMass(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.MolarMass; - /// /// All units of measurement for the MolarMass quantity. /// @@ -168,11 +162,6 @@ public MolarMass(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => MolarMass.QuantityType; - /// /// The of this quantity. /// @@ -1017,8 +1006,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarMassUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MolarMass.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MolarMass.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index eee20660a6..1dad094b5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -67,7 +67,7 @@ static Molarity() new UnitInfo(MolarityUnit.NanomolesPerLiter, "NanomolesPerLiter", BaseUnits.Undefined), new UnitInfo(MolarityUnit.PicomolesPerLiter, "PicomolesPerLiter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Molarity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -131,12 +131,6 @@ public Molarity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Molarity MinValue { get; } = new Molarity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Molarity; - /// /// All units of measurement for the Molarity quantity. /// @@ -167,11 +161,6 @@ public Molarity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Molarity.QuantityType; - /// /// The of this quantity. /// @@ -952,8 +941,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Molarity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Molarity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index d015317453..faf0a1ea2f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -60,7 +60,7 @@ static Permeability() new UnitInfo[] { new UnitInfo(PermeabilityUnit.HenryPerMeter, "HenriesPerMeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Permeability); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public Permeability(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Permeability MinValue { get; } = new Permeability(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Permeability; - /// /// All units of measurement for the Permeability quantity. /// @@ -160,11 +154,6 @@ public Permeability(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Permeability.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PermeabilityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Permeability.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Permeability.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a7df3dea12..3fa6da8405 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -60,7 +60,7 @@ static Permittivity() new UnitInfo[] { new UnitInfo(PermittivityUnit.FaradPerMeter, "FaradsPerMeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Permittivity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public Permittivity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Permittivity; - /// /// All units of measurement for the Permittivity quantity. /// @@ -160,11 +154,6 @@ public Permittivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Permittivity.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PermittivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Permittivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Permittivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index c10a10cf86..ed3eabcd22 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -81,7 +81,7 @@ static Power() new UnitInfo(PowerUnit.Terawatt, "Terawatts", BaseUnits.Undefined), new UnitInfo(PowerUnit.Watt, "Watts", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Power); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -145,12 +145,6 @@ public Power(decimal value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Power MinValue { get; } = new Power(decimal.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Power; - /// /// All units of measurement for the Power quantity. /// @@ -186,11 +180,6 @@ public Power(decimal value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Power.QuantityType; - /// /// The of this quantity. /// @@ -1243,8 +1232,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PowerUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Power.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Power.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 5f2eeffbe9..4cfcedb9d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -100,7 +100,7 @@ static PowerDensity() new UnitInfo(PowerDensityUnit.WattPerCubicMeter, "WattsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second)), new UnitInfo(PowerDensityUnit.WattPerLiter, "WattsPerLiter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.PowerDensity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -164,12 +164,6 @@ public PowerDensity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.PowerDensity; - /// /// All units of measurement for the PowerDensity quantity. /// @@ -200,11 +194,6 @@ public PowerDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => PowerDensity.QuantityType; - /// /// The of this quantity. /// @@ -1561,8 +1550,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PowerDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return PowerDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return PowerDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 547aebf9a6..793c89fbc7 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -58,7 +58,7 @@ static PowerRatio() new UnitInfo(PowerRatioUnit.DecibelMilliwatt, "DecibelMilliwatts", BaseUnits.Undefined), new UnitInfo(PowerRatioUnit.DecibelWatt, "DecibelWatts", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.PowerRatio); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -122,12 +122,6 @@ public PowerRatio(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.PowerRatio; - /// /// All units of measurement for the PowerRatio quantity. /// @@ -158,11 +152,6 @@ public PowerRatio(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => PowerRatio.QuantityType; - /// /// The of this quantity. /// @@ -855,8 +844,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PowerRatioUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return PowerRatio.QuantityType; else if(conversionType == typeof(QuantityInfo)) return PowerRatio.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 723ab378e9..bd09108ce8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -100,7 +100,7 @@ static Pressure() new UnitInfo(PressureUnit.TonneForcePerSquareMillimeter, "TonnesForcePerSquareMillimeter", BaseUnits.Undefined), new UnitInfo(PressureUnit.Torr, "Torrs", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Pressure); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -164,12 +164,6 @@ public Pressure(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Pressure MinValue { get; } = new Pressure(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Pressure; - /// /// All units of measurement for the Pressure quantity. /// @@ -200,11 +194,6 @@ public Pressure(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Pressure.QuantityType; - /// /// The of this quantity. /// @@ -1561,8 +1550,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PressureUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Pressure.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Pressure.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index ef536ff205..31ca12a2b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -69,7 +69,7 @@ static PressureChangeRate() new UnitInfo(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, "PoundsForcePerSquareInchPerMinute", BaseUnits.Undefined), new UnitInfo(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, "PoundsForcePerSquareInchPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.PressureChangeRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -133,12 +133,6 @@ public PressureChangeRate(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.PressureChangeRate; - /// /// All units of measurement for the PressureChangeRate quantity. /// @@ -169,11 +163,6 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => PressureChangeRate.QuantityType; - /// /// The of this quantity. /// @@ -1034,8 +1023,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PressureChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return PressureChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return PressureChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index c54fed1861..a3692f89cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -62,7 +62,7 @@ static Ratio() new UnitInfo(RatioUnit.PartPerTrillion, "PartsPerTrillion", BaseUnits.Undefined), new UnitInfo(RatioUnit.Percent, "Percent", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Ratio); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public Ratio(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Ratio MinValue { get; } = new Ratio(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Ratio; - /// /// All units of measurement for the Ratio quantity. /// @@ -162,11 +156,6 @@ public Ratio(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Ratio.QuantityType; - /// /// The of this quantity. /// @@ -915,8 +904,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RatioUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Ratio.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Ratio.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index b1743f69f2..b8e9f12459 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -58,7 +58,7 @@ static RatioChangeRate() new UnitInfo(RatioChangeRateUnit.DecimalFractionPerSecond, "DecimalFractionsPerSecond", BaseUnits.Undefined), new UnitInfo(RatioChangeRateUnit.PercentPerSecond, "PercentsPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RatioChangeRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -122,12 +122,6 @@ public RatioChangeRate(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.RatioChangeRate; - /// /// All units of measurement for the RatioChangeRate quantity. /// @@ -158,11 +152,6 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => RatioChangeRate.QuantityType; - /// /// The of this quantity. /// @@ -847,8 +836,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RatioChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RatioChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RatioChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 7157c78f28..324156dba8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -59,7 +59,7 @@ static ReactiveEnergy() new UnitInfo(ReactiveEnergyUnit.MegavoltampereReactiveHour, "MegavoltampereReactiveHours", BaseUnits.Undefined), new UnitInfo(ReactiveEnergyUnit.VoltampereReactiveHour, "VoltampereReactiveHours", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReactiveEnergy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ReactiveEnergy; - /// /// All units of measurement for the ReactiveEnergy quantity. /// @@ -159,11 +153,6 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ReactiveEnergy.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReactiveEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReactiveEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReactiveEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 3ee79fd0fe..274c554d16 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -60,7 +60,7 @@ static ReactivePower() new UnitInfo(ReactivePowerUnit.MegavoltampereReactive, "MegavoltamperesReactive", BaseUnits.Undefined), new UnitInfo(ReactivePowerUnit.VoltampereReactive, "VoltamperesReactive", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReactivePower); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public ReactivePower(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ReactivePower; - /// /// All units of measurement for the ReactivePower quantity. /// @@ -160,11 +154,6 @@ public ReactivePower(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ReactivePower.QuantityType; - /// /// The of this quantity. /// @@ -881,8 +870,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReactivePowerUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReactivePower.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReactivePower.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 5b00deba83..3c471ee4ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -70,7 +70,7 @@ static ReciprocalArea() new UnitInfo(ReciprocalAreaUnit.InverseSquareYard, "InverseSquareYards", BaseUnits.Undefined), new UnitInfo(ReciprocalAreaUnit.InverseUsSurveySquareFoot, "InverseUsSurveySquareFeet", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalArea); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -134,12 +134,6 @@ public ReciprocalArea(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ReciprocalArea; - /// /// All units of measurement for the ReciprocalArea quantity. /// @@ -170,11 +164,6 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ReciprocalArea.QuantityType; - /// /// The of this quantity. /// @@ -1003,8 +992,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReciprocalAreaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReciprocalArea.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReciprocalArea.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index f97ba8bceb..c98ca524e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -69,7 +69,7 @@ static ReciprocalLength() new UnitInfo(ReciprocalLengthUnit.InverseUsSurveyFoot, "InverseUsSurveyFeet", BaseUnits.Undefined), new UnitInfo(ReciprocalLengthUnit.InverseYard, "InverseYards", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalLength); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -133,12 +133,6 @@ public ReciprocalLength(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ReciprocalLength; - /// /// All units of measurement for the ReciprocalLength quantity. /// @@ -169,11 +163,6 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ReciprocalLength.QuantityType; - /// /// The of this quantity. /// @@ -986,8 +975,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReciprocalLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReciprocalLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReciprocalLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index d180fc99fc..4d69fc2be8 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -57,7 +57,7 @@ static RelativeHumidity() new UnitInfo[] { new UnitInfo(RelativeHumidityUnit.Percent, "Percent", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RelativeHumidity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -121,12 +121,6 @@ public RelativeHumidity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.RelativeHumidity; - /// /// All units of measurement for the RelativeHumidity quantity. /// @@ -157,11 +151,6 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => RelativeHumidity.QuantityType; - /// /// The of this quantity. /// @@ -830,8 +819,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RelativeHumidityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RelativeHumidity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RelativeHumidity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index c18eaa0b69..2af81fe71d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -60,7 +60,7 @@ static RotationalAcceleration() new UnitInfo(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, "RevolutionsPerMinutePerSecond", BaseUnits.Undefined), new UnitInfo(RotationalAccelerationUnit.RevolutionPerSecondSquared, "RevolutionsPerSecondSquared", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalAcceleration); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.RotationalAcceleration; - /// /// All units of measurement for the RotationalAcceleration quantity. /// @@ -160,11 +154,6 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalAcceleration.QuantityType; - /// /// The of this quantity. /// @@ -881,8 +870,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalAccelerationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalAcceleration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalAcceleration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index d8db45ccc0..3ac652035f 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -69,7 +69,7 @@ static RotationalSpeed() new UnitInfo(RotationalSpeedUnit.RevolutionPerMinute, "RevolutionsPerMinute", BaseUnits.Undefined), new UnitInfo(RotationalSpeedUnit.RevolutionPerSecond, "RevolutionsPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalSpeed); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -133,12 +133,6 @@ public RotationalSpeed(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.RotationalSpeed; - /// /// All units of measurement for the RotationalSpeed quantity. /// @@ -169,11 +163,6 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalSpeed.QuantityType; - /// /// The of this quantity. /// @@ -1034,8 +1023,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalSpeedUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalSpeed.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalSpeed.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index d1496a5884..aa4aaa44e3 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -89,7 +89,7 @@ static RotationalStiffness() new UnitInfo(RotationalStiffnessUnit.PoundForceFeetPerRadian, "PoundForceFeetPerRadian", BaseUnits.Undefined), new UnitInfo(RotationalStiffnessUnit.PoundForceFootPerDegrees, "PoundForceFeetPerDegrees", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffness); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -153,12 +153,6 @@ public RotationalStiffness(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.RotationalStiffness; - /// /// All units of measurement for the RotationalStiffness quantity. /// @@ -189,11 +183,6 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalStiffness.QuantityType; - /// /// The of this quantity. /// @@ -1374,8 +1363,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalStiffnessUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalStiffness.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalStiffness.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index a04cf7fe2d..41dddd51b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -61,7 +61,7 @@ static RotationalStiffnessPerLength() new UnitInfo(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, "NewtonMetersPerRadianPerMeter", BaseUnits.Undefined), new UnitInfo(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, "PoundForceFeetPerDegreesPerFeet", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffnessPerLength); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -125,12 +125,6 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.RotationalStiffnessPerLength; - /// /// All units of measurement for the RotationalStiffnessPerLength quantity. /// @@ -161,11 +155,6 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => RotationalStiffnessPerLength.QuantityType; - /// /// The of this quantity. /// @@ -898,8 +887,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalStiffnessPerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalStiffnessPerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalStiffnessPerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 33bdc099ec..d3700bfded 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -57,7 +57,7 @@ static Scalar() new UnitInfo[] { new UnitInfo(ScalarUnit.Amount, "Amount", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Scalar); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -121,12 +121,6 @@ public Scalar(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Scalar MinValue { get; } = new Scalar(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Scalar; - /// /// All units of measurement for the Scalar quantity. /// @@ -157,11 +151,6 @@ public Scalar(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Scalar.QuantityType; - /// /// The of this quantity. /// @@ -830,8 +819,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ScalarUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Scalar.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Scalar.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 683555beaa..00a30ddfb0 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -60,7 +60,7 @@ static SolidAngle() new UnitInfo[] { new UnitInfo(SolidAngleUnit.Steradian, "Steradians", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SolidAngle); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public SolidAngle(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.SolidAngle; - /// /// All units of measurement for the SolidAngle quantity. /// @@ -160,11 +154,6 @@ public SolidAngle(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => SolidAngle.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SolidAngleUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SolidAngle.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SolidAngle.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index ea3fcb9714..8714ae99fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -84,7 +84,7 @@ static SpecificEnergy() new UnitInfo(SpecificEnergyUnit.WattDayPerTonne, "WattDaysPerTonne", BaseUnits.Undefined), new UnitInfo(SpecificEnergyUnit.WattHourPerKilogram, "WattHoursPerKilogram", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificEnergy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -148,12 +148,6 @@ public SpecificEnergy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.SpecificEnergy; - /// /// All units of measurement for the SpecificEnergy quantity. /// @@ -184,11 +178,6 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificEnergy.QuantityType; - /// /// The of this quantity. /// @@ -1241,8 +1230,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 5dcbbce1dd..38db174727 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -65,7 +65,7 @@ static SpecificEntropy() new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, "MegajoulesPerKilogramDegreeCelsius", BaseUnits.Undefined), new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramKelvin, "MegajoulesPerKilogramKelvin", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificEntropy); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -129,12 +129,6 @@ public SpecificEntropy(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.SpecificEntropy; - /// /// All units of measurement for the SpecificEntropy quantity. /// @@ -165,11 +159,6 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificEntropy.QuantityType; - /// /// The of this quantity. /// @@ -966,8 +955,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificEntropyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificEntropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificEntropy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 408634af93..18ffe2f694 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -63,7 +63,7 @@ static SpecificFuelConsumption() new UnitInfo(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, "KilogramsPerKiloNewtonSecond", BaseUnits.Undefined), new UnitInfo(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, "PoundsMassPerPoundForceHour", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificFuelConsumption); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -127,12 +127,6 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.SpecificFuelConsumption; - /// /// All units of measurement for the SpecificFuelConsumption quantity. /// @@ -163,11 +157,6 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificFuelConsumption.QuantityType; - /// /// The of this quantity. /// @@ -884,8 +873,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificFuelConsumptionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificFuelConsumption.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificFuelConsumption.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index f83fe3c8ec..915e8ee3fd 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -59,7 +59,7 @@ static SpecificVolume() new UnitInfo(SpecificVolumeUnit.CubicMeterPerKilogram, "CubicMetersPerKilogram", BaseUnits.Undefined), new UnitInfo(SpecificVolumeUnit.MillicubicMeterPerKilogram, "MillicubicMetersPerKilogram", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificVolume); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -123,12 +123,6 @@ public SpecificVolume(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.SpecificVolume; - /// /// All units of measurement for the SpecificVolume quantity. /// @@ -159,11 +153,6 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificVolume.QuantityType; - /// /// The of this quantity. /// @@ -864,8 +853,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificVolumeUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificVolume.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificVolume.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index e3d22bc4f5..70648945a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -76,7 +76,7 @@ static SpecificWeight() new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMeter, "TonnesForcePerCubicMeter", BaseUnits.Undefined), new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMillimeter, "TonnesForcePerCubicMillimeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.SpecificWeight); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -140,12 +140,6 @@ public SpecificWeight(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.SpecificWeight; - /// /// All units of measurement for the SpecificWeight quantity. /// @@ -176,11 +170,6 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => SpecificWeight.QuantityType; - /// /// The of this quantity. /// @@ -1105,8 +1094,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificWeightUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificWeight.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificWeight.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index f1e6f27c3a..2cd4fd55b8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -88,7 +88,7 @@ static Speed() new UnitInfo(SpeedUnit.YardPerMinute, "YardsPerMinute", new BaseUnits(length: LengthUnit.Yard, time: DurationUnit.Minute)), new UnitInfo(SpeedUnit.YardPerSecond, "YardsPerSecond", new BaseUnits(length: LengthUnit.Yard, time: DurationUnit.Second)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Speed); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -152,12 +152,6 @@ public Speed(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Speed MinValue { get; } = new Speed(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Speed; - /// /// All units of measurement for the Speed quantity. /// @@ -188,11 +182,6 @@ public Speed(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Speed.QuantityType; - /// /// The of this quantity. /// @@ -1357,8 +1346,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpeedUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Speed.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Speed.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index e6ee811dd9..ad60e95c7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -65,7 +65,7 @@ static StandardVolumeFlow() new UnitInfo(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, "StandardCubicMetersPerSecond", BaseUnits.Undefined), new UnitInfo(StandardVolumeFlowUnit.StandardLiterPerMinute, "StandardLitersPerMinute", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.StandardVolumeFlow); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -129,12 +129,6 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.StandardVolumeFlow; - /// /// All units of measurement for the StandardVolumeFlow quantity. /// @@ -165,11 +159,6 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => StandardVolumeFlow.QuantityType; - /// /// The of this quantity. /// @@ -966,8 +955,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(StandardVolumeFlowUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return StandardVolumeFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) return StandardVolumeFlow.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 43d8c9dde9..a037fae4aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -66,7 +66,7 @@ static Temperature() new UnitInfo(TemperatureUnit.MillidegreeCelsius, "MillidegreesCelsius", new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)), new UnitInfo(TemperatureUnit.SolarTemperature, "SolarTemperatures", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Temperature); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -130,12 +130,6 @@ public Temperature(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Temperature MinValue { get; } = new Temperature(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Temperature; - /// /// All units of measurement for the Temperature quantity. /// @@ -166,11 +160,6 @@ public Temperature(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Temperature.QuantityType; - /// /// The of this quantity. /// @@ -937,8 +926,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Temperature.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Temperature.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index ad844059d7..3dc465eb0c 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -66,7 +66,7 @@ static TemperatureChangeRate() new UnitInfo(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, "MillidegreesCelsiusPerSecond", BaseUnits.Undefined), new UnitInfo(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, "NanodegreesCelsiusPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.TemperatureChangeRate); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -130,12 +130,6 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.TemperatureChangeRate; - /// /// All units of measurement for the TemperatureChangeRate quantity. /// @@ -166,11 +160,6 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => TemperatureChangeRate.QuantityType; - /// /// The of this quantity. /// @@ -983,8 +972,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TemperatureChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TemperatureChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 9be7fce222..5c473b2fb1 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -65,7 +65,7 @@ static TemperatureDelta() new UnitInfo(TemperatureDeltaUnit.Kelvin, "Kelvins", BaseUnits.Undefined), new UnitInfo(TemperatureDeltaUnit.MillidegreeCelsius, "MillidegreesCelsius", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.TemperatureDelta); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -129,12 +129,6 @@ public TemperatureDelta(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.TemperatureDelta; - /// /// All units of measurement for the TemperatureDelta quantity. /// @@ -165,11 +159,6 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => TemperatureDelta.QuantityType; - /// /// The of this quantity. /// @@ -966,8 +955,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureDeltaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TemperatureDelta.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TemperatureDelta.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 54a1585e00..4738a98ce2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -61,7 +61,7 @@ static ThermalConductivity() new UnitInfo(ThermalConductivityUnit.BtuPerHourFootFahrenheit, "BtusPerHourFootFahrenheit", BaseUnits.Undefined), new UnitInfo(ThermalConductivityUnit.WattPerMeterKelvin, "WattsPerMeterKelvin", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ThermalConductivity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -125,12 +125,6 @@ public ThermalConductivity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ThermalConductivity; - /// /// All units of measurement for the ThermalConductivity quantity. /// @@ -161,11 +155,6 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ThermalConductivity.QuantityType; - /// /// The of this quantity. /// @@ -850,8 +839,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ThermalConductivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ThermalConductivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ThermalConductivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 949fa04124..45f54efccd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -61,7 +61,7 @@ static ThermalResistance() new UnitInfo(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, "SquareMeterDegreesCelsiusPerWatt", BaseUnits.Undefined), new UnitInfo(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, "SquareMeterKelvinsPerKilowatt", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.ThermalResistance); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -125,12 +125,6 @@ public ThermalResistance(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.ThermalResistance; - /// /// All units of measurement for the ThermalResistance quantity. /// @@ -161,11 +155,6 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => ThermalResistance.QuantityType; - /// /// The of this quantity. /// @@ -898,8 +887,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ThermalResistanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ThermalResistance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ThermalResistance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 3438421947..13cf55e5ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -78,7 +78,7 @@ static Torque() new UnitInfo(TorqueUnit.TonneForceMeter, "TonneForceMeters", BaseUnits.Undefined), new UnitInfo(TorqueUnit.TonneForceMillimeter, "TonneForceMillimeters", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Torque); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -142,12 +142,6 @@ public Torque(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Torque MinValue { get; } = new Torque(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Torque; - /// /// All units of measurement for the Torque quantity. /// @@ -178,11 +172,6 @@ public Torque(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Torque.QuantityType; - /// /// The of this quantity. /// @@ -1187,8 +1176,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TorqueUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Torque.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Torque.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index c0e5dd2a80..60e726d36a 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -77,7 +77,7 @@ static TorquePerLength() new UnitInfo(TorquePerLengthUnit.TonneForceMeterPerMeter, "TonneForceMetersPerMeter", BaseUnits.Undefined), new UnitInfo(TorquePerLengthUnit.TonneForceMillimeterPerMeter, "TonneForceMillimetersPerMeter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.TorquePerLength); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -141,12 +141,6 @@ public TorquePerLength(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.TorquePerLength; - /// /// All units of measurement for the TorquePerLength quantity. /// @@ -177,11 +171,6 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => TorquePerLength.QuantityType; - /// /// The of this quantity. /// @@ -1170,8 +1159,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TorquePerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TorquePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TorquePerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 1301a87ad2..2931ac18f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -60,7 +60,7 @@ static Turbidity() new UnitInfo[] { new UnitInfo(TurbidityUnit.NTU, "NTU", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Turbidity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -124,12 +124,6 @@ public Turbidity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Turbidity; - /// /// All units of measurement for the Turbidity quantity. /// @@ -160,11 +154,6 @@ public Turbidity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Turbidity.QuantityType; - /// /// The of this quantity. /// @@ -833,8 +822,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TurbidityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Turbidity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Turbidity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 84ba139b5b..27b919d201 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -57,7 +57,7 @@ static VitaminA() new UnitInfo[] { new UnitInfo(VitaminAUnit.InternationalUnit, "InternationalUnits", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VitaminA); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -121,12 +121,6 @@ public VitaminA(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.VitaminA; - /// /// All units of measurement for the VitaminA quantity. /// @@ -157,11 +151,6 @@ public VitaminA(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => VitaminA.QuantityType; - /// /// The of this quantity. /// @@ -830,8 +819,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VitaminAUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VitaminA.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VitaminA.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index c39a600480..719c3a7036 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -107,7 +107,7 @@ static Volume() new UnitInfo(VolumeUnit.UsTablespoon, "UsTablespoons", BaseUnits.Undefined), new UnitInfo(VolumeUnit.UsTeaspoon, "UsTeaspoons", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.Volume); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -171,12 +171,6 @@ public Volume(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static Volume MinValue { get; } = new Volume(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.Volume; - /// /// All units of measurement for the Volume quantity. /// @@ -207,11 +201,6 @@ public Volume(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => Volume.QuantityType; - /// /// The of this quantity. /// @@ -1680,8 +1669,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Volume.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Volume.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 9ca177d547..82af9e404d 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -79,7 +79,7 @@ static VolumeConcentration() new UnitInfo(VolumeConcentrationUnit.PicolitersPerLiter, "PicolitersPerLiter", BaseUnits.Undefined), new UnitInfo(VolumeConcentrationUnit.PicolitersPerMililiter, "PicolitersPerMililiter", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumeConcentration); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -143,12 +143,6 @@ public VolumeConcentration(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.VolumeConcentration; - /// /// All units of measurement for the VolumeConcentration quantity. /// @@ -179,11 +173,6 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => VolumeConcentration.QuantityType; - /// /// The of this quantity. /// @@ -1156,8 +1145,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeConcentrationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumeConcentration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumeConcentration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 11bbb8c3dc..4c27f39b92 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -112,7 +112,7 @@ static VolumeFlow() new UnitInfo(VolumeFlowUnit.UsGallonPerMinute, "UsGallonsPerMinute", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.UsGallonPerSecond, "UsGallonsPerSecond", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumeFlow); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -176,12 +176,6 @@ public VolumeFlow(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.VolumeFlow; - /// /// All units of measurement for the VolumeFlow quantity. /// @@ -212,11 +206,6 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => VolumeFlow.QuantityType; - /// /// The of this quantity. /// @@ -1765,8 +1754,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeFlowUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumeFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumeFlow.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 232cf7c1cb..3fdcd7248e 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -63,7 +63,7 @@ static VolumePerLength() new UnitInfo(VolumePerLengthUnit.LiterPerMillimeter, "LitersPerMillimeter", BaseUnits.Undefined), new UnitInfo(VolumePerLengthUnit.OilBarrelPerFoot, "OilBarrelsPerFoot", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumePerLength); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -127,12 +127,6 @@ public VolumePerLength(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.VolumePerLength; - /// /// All units of measurement for the VolumePerLength quantity. /// @@ -163,11 +157,6 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => VolumePerLength.QuantityType; - /// /// The of this quantity. /// @@ -932,8 +921,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumePerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumePerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index cde2effd7f..2811f02c7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -68,7 +68,7 @@ static VolumetricHeatCapacity() new UnitInfo(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, "MegajoulesPerCubicMeterDegreeCelsius", BaseUnits.Undefined), new UnitInfo(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, "MegajoulesPerCubicMeterKelvin", BaseUnits.Undefined), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.VolumetricHeatCapacity); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -132,12 +132,6 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.VolumetricHeatCapacity; - /// /// All units of measurement for the VolumetricHeatCapacity quantity. /// @@ -168,11 +162,6 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => VolumetricHeatCapacity.QuantityType; - /// /// The of this quantity. /// @@ -969,8 +958,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumetricHeatCapacityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumetricHeatCapacity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumetricHeatCapacity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 5e276f81a3..1f23846805 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -62,7 +62,7 @@ static WarpingMomentOfInertia() new UnitInfo(WarpingMomentOfInertiaUnit.MeterToTheSixth, "MetersToTheSixth", new BaseUnits(length: LengthUnit.Meter)), new UnitInfo(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, "MillimetersToTheSixth", new BaseUnits(length: LengthUnit.Millimeter)), }, - ConversionBaseUnit, Zero, BaseDimensions, QuantityType.WarpingMomentOfInertia); + ConversionBaseUnit, Zero, BaseDimensions); } /// @@ -126,12 +126,6 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, ConversionBaseUnit); - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use Info property instead.")] - public static QuantityType QuantityType { get; } = QuantityType.WarpingMomentOfInertia; - /// /// All units of measurement for the WarpingMomentOfInertia quantity. /// @@ -162,11 +156,6 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - public QuantityType Type => WarpingMomentOfInertia.QuantityType; - /// /// The of this quantity. /// @@ -915,8 +904,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(WarpingMomentOfInertiaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return WarpingMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) return WarpingMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index c2d2b17713..85d081c726 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -148,358 +148,6 @@ public static partial class Quantity { "WarpingMomentOfInertia", WarpingMomentOfInertia.Info }, }; - // Used by the QuantityInfo .ctor to map a name to a QuantityType. Will be removed when QuantityType - // will be removed. - internal static readonly IDictionary QuantityTypeByName = new Dictionary - { - { "Acceleration", QuantityType.Acceleration }, - { "AmountOfSubstance", QuantityType.AmountOfSubstance }, - { "AmplitudeRatio", QuantityType.AmplitudeRatio }, - { "Angle", QuantityType.Angle }, - { "ApparentEnergy", QuantityType.ApparentEnergy }, - { "ApparentPower", QuantityType.ApparentPower }, - { "Area", QuantityType.Area }, - { "AreaDensity", QuantityType.AreaDensity }, - { "AreaMomentOfInertia", QuantityType.AreaMomentOfInertia }, - { "BitRate", QuantityType.BitRate }, - { "BrakeSpecificFuelConsumption", QuantityType.BrakeSpecificFuelConsumption }, - { "Capacitance", QuantityType.Capacitance }, - { "CoefficientOfThermalExpansion", QuantityType.CoefficientOfThermalExpansion }, - { "Density", QuantityType.Density }, - { "Duration", QuantityType.Duration }, - { "DynamicViscosity", QuantityType.DynamicViscosity }, - { "ElectricAdmittance", QuantityType.ElectricAdmittance }, - { "ElectricCharge", QuantityType.ElectricCharge }, - { "ElectricChargeDensity", QuantityType.ElectricChargeDensity }, - { "ElectricConductance", QuantityType.ElectricConductance }, - { "ElectricConductivity", QuantityType.ElectricConductivity }, - { "ElectricCurrent", QuantityType.ElectricCurrent }, - { "ElectricCurrentDensity", QuantityType.ElectricCurrentDensity }, - { "ElectricCurrentGradient", QuantityType.ElectricCurrentGradient }, - { "ElectricField", QuantityType.ElectricField }, - { "ElectricInductance", QuantityType.ElectricInductance }, - { "ElectricPotential", QuantityType.ElectricPotential }, - { "ElectricPotentialAc", QuantityType.ElectricPotentialAc }, - { "ElectricPotentialChangeRate", QuantityType.ElectricPotentialChangeRate }, - { "ElectricPotentialDc", QuantityType.ElectricPotentialDc }, - { "ElectricResistance", QuantityType.ElectricResistance }, - { "ElectricResistivity", QuantityType.ElectricResistivity }, - { "ElectricSurfaceChargeDensity", QuantityType.ElectricSurfaceChargeDensity }, - { "Energy", QuantityType.Energy }, - { "Entropy", QuantityType.Entropy }, - { "Force", QuantityType.Force }, - { "ForceChangeRate", QuantityType.ForceChangeRate }, - { "ForcePerLength", QuantityType.ForcePerLength }, - { "Frequency", QuantityType.Frequency }, - { "FuelEfficiency", QuantityType.FuelEfficiency }, - { "HeatFlux", QuantityType.HeatFlux }, - { "HeatTransferCoefficient", QuantityType.HeatTransferCoefficient }, - { "Illuminance", QuantityType.Illuminance }, - { "Information", QuantityType.Information }, - { "Irradiance", QuantityType.Irradiance }, - { "Irradiation", QuantityType.Irradiation }, - { "KinematicViscosity", QuantityType.KinematicViscosity }, - { "LapseRate", QuantityType.LapseRate }, - { "Length", QuantityType.Length }, - { "Level", QuantityType.Level }, - { "LinearDensity", QuantityType.LinearDensity }, - { "LinearPowerDensity", QuantityType.LinearPowerDensity }, - { "Luminosity", QuantityType.Luminosity }, - { "LuminousFlux", QuantityType.LuminousFlux }, - { "LuminousIntensity", QuantityType.LuminousIntensity }, - { "MagneticField", QuantityType.MagneticField }, - { "MagneticFlux", QuantityType.MagneticFlux }, - { "Magnetization", QuantityType.Magnetization }, - { "Mass", QuantityType.Mass }, - { "MassConcentration", QuantityType.MassConcentration }, - { "MassFlow", QuantityType.MassFlow }, - { "MassFlux", QuantityType.MassFlux }, - { "MassFraction", QuantityType.MassFraction }, - { "MassMomentOfInertia", QuantityType.MassMomentOfInertia }, - { "MolarEnergy", QuantityType.MolarEnergy }, - { "MolarEntropy", QuantityType.MolarEntropy }, - { "Molarity", QuantityType.Molarity }, - { "MolarMass", QuantityType.MolarMass }, - { "Permeability", QuantityType.Permeability }, - { "Permittivity", QuantityType.Permittivity }, - { "Power", QuantityType.Power }, - { "PowerDensity", QuantityType.PowerDensity }, - { "PowerRatio", QuantityType.PowerRatio }, - { "Pressure", QuantityType.Pressure }, - { "PressureChangeRate", QuantityType.PressureChangeRate }, - { "Ratio", QuantityType.Ratio }, - { "RatioChangeRate", QuantityType.RatioChangeRate }, - { "ReactiveEnergy", QuantityType.ReactiveEnergy }, - { "ReactivePower", QuantityType.ReactivePower }, - { "ReciprocalArea", QuantityType.ReciprocalArea }, - { "ReciprocalLength", QuantityType.ReciprocalLength }, - { "RelativeHumidity", QuantityType.RelativeHumidity }, - { "RotationalAcceleration", QuantityType.RotationalAcceleration }, - { "RotationalSpeed", QuantityType.RotationalSpeed }, - { "RotationalStiffness", QuantityType.RotationalStiffness }, - { "RotationalStiffnessPerLength", QuantityType.RotationalStiffnessPerLength }, - { "Scalar", QuantityType.Scalar }, - { "SolidAngle", QuantityType.SolidAngle }, - { "SpecificEnergy", QuantityType.SpecificEnergy }, - { "SpecificEntropy", QuantityType.SpecificEntropy }, - { "SpecificFuelConsumption", QuantityType.SpecificFuelConsumption }, - { "SpecificVolume", QuantityType.SpecificVolume }, - { "SpecificWeight", QuantityType.SpecificWeight }, - { "Speed", QuantityType.Speed }, - { "StandardVolumeFlow", QuantityType.StandardVolumeFlow }, - { "Temperature", QuantityType.Temperature }, - { "TemperatureChangeRate", QuantityType.TemperatureChangeRate }, - { "TemperatureDelta", QuantityType.TemperatureDelta }, - { "ThermalConductivity", QuantityType.ThermalConductivity }, - { "ThermalResistance", QuantityType.ThermalResistance }, - { "Torque", QuantityType.Torque }, - { "TorquePerLength", QuantityType.TorquePerLength }, - { "Turbidity", QuantityType.Turbidity }, - { "VitaminA", QuantityType.VitaminA }, - { "Volume", QuantityType.Volume }, - { "VolumeConcentration", QuantityType.VolumeConcentration }, - { "VolumeFlow", QuantityType.VolumeFlow }, - { "VolumePerLength", QuantityType.VolumePerLength }, - { "VolumetricHeatCapacity", QuantityType.VolumetricHeatCapacity }, - { "WarpingMomentOfInertia", QuantityType.WarpingMomentOfInertia }, - }; - - /// - /// Dynamically constructs a quantity of the given with the value in the quantity's base units. - /// - /// The of the quantity to create. - /// The value to construct the quantity with. - /// The created quantity. - [Obsolete("QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead.")] - public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) - { - switch(quantityType) - { - case QuantityType.Acceleration: - return Acceleration.From(value, Acceleration.ConversionBaseUnit); - case QuantityType.AmountOfSubstance: - return AmountOfSubstance.From(value, AmountOfSubstance.ConversionBaseUnit); - case QuantityType.AmplitudeRatio: - return AmplitudeRatio.From(value, AmplitudeRatio.ConversionBaseUnit); - case QuantityType.Angle: - return Angle.From(value, Angle.ConversionBaseUnit); - case QuantityType.ApparentEnergy: - return ApparentEnergy.From(value, ApparentEnergy.ConversionBaseUnit); - case QuantityType.ApparentPower: - return ApparentPower.From(value, ApparentPower.ConversionBaseUnit); - case QuantityType.Area: - return Area.From(value, Area.ConversionBaseUnit); - case QuantityType.AreaDensity: - return AreaDensity.From(value, AreaDensity.ConversionBaseUnit); - case QuantityType.AreaMomentOfInertia: - return AreaMomentOfInertia.From(value, AreaMomentOfInertia.ConversionBaseUnit); - case QuantityType.BitRate: - return BitRate.From(value, BitRate.ConversionBaseUnit); - case QuantityType.BrakeSpecificFuelConsumption: - return BrakeSpecificFuelConsumption.From(value, BrakeSpecificFuelConsumption.ConversionBaseUnit); - case QuantityType.Capacitance: - return Capacitance.From(value, Capacitance.ConversionBaseUnit); - case QuantityType.CoefficientOfThermalExpansion: - return CoefficientOfThermalExpansion.From(value, CoefficientOfThermalExpansion.ConversionBaseUnit); - case QuantityType.Density: - return Density.From(value, Density.ConversionBaseUnit); - case QuantityType.Duration: - return Duration.From(value, Duration.ConversionBaseUnit); - case QuantityType.DynamicViscosity: - return DynamicViscosity.From(value, DynamicViscosity.ConversionBaseUnit); - case QuantityType.ElectricAdmittance: - return ElectricAdmittance.From(value, ElectricAdmittance.ConversionBaseUnit); - case QuantityType.ElectricCharge: - return ElectricCharge.From(value, ElectricCharge.ConversionBaseUnit); - case QuantityType.ElectricChargeDensity: - return ElectricChargeDensity.From(value, ElectricChargeDensity.ConversionBaseUnit); - case QuantityType.ElectricConductance: - return ElectricConductance.From(value, ElectricConductance.ConversionBaseUnit); - case QuantityType.ElectricConductivity: - return ElectricConductivity.From(value, ElectricConductivity.ConversionBaseUnit); - case QuantityType.ElectricCurrent: - return ElectricCurrent.From(value, ElectricCurrent.ConversionBaseUnit); - case QuantityType.ElectricCurrentDensity: - return ElectricCurrentDensity.From(value, ElectricCurrentDensity.ConversionBaseUnit); - case QuantityType.ElectricCurrentGradient: - return ElectricCurrentGradient.From(value, ElectricCurrentGradient.ConversionBaseUnit); - case QuantityType.ElectricField: - return ElectricField.From(value, ElectricField.ConversionBaseUnit); - case QuantityType.ElectricInductance: - return ElectricInductance.From(value, ElectricInductance.ConversionBaseUnit); - case QuantityType.ElectricPotential: - return ElectricPotential.From(value, ElectricPotential.ConversionBaseUnit); - case QuantityType.ElectricPotentialAc: - return ElectricPotentialAc.From(value, ElectricPotentialAc.ConversionBaseUnit); - case QuantityType.ElectricPotentialChangeRate: - return ElectricPotentialChangeRate.From(value, ElectricPotentialChangeRate.ConversionBaseUnit); - case QuantityType.ElectricPotentialDc: - return ElectricPotentialDc.From(value, ElectricPotentialDc.ConversionBaseUnit); - case QuantityType.ElectricResistance: - return ElectricResistance.From(value, ElectricResistance.ConversionBaseUnit); - case QuantityType.ElectricResistivity: - return ElectricResistivity.From(value, ElectricResistivity.ConversionBaseUnit); - case QuantityType.ElectricSurfaceChargeDensity: - return ElectricSurfaceChargeDensity.From(value, ElectricSurfaceChargeDensity.ConversionBaseUnit); - case QuantityType.Energy: - return Energy.From(value, Energy.ConversionBaseUnit); - case QuantityType.Entropy: - return Entropy.From(value, Entropy.ConversionBaseUnit); - case QuantityType.Force: - return Force.From(value, Force.ConversionBaseUnit); - case QuantityType.ForceChangeRate: - return ForceChangeRate.From(value, ForceChangeRate.ConversionBaseUnit); - case QuantityType.ForcePerLength: - return ForcePerLength.From(value, ForcePerLength.ConversionBaseUnit); - case QuantityType.Frequency: - return Frequency.From(value, Frequency.ConversionBaseUnit); - case QuantityType.FuelEfficiency: - return FuelEfficiency.From(value, FuelEfficiency.ConversionBaseUnit); - case QuantityType.HeatFlux: - return HeatFlux.From(value, HeatFlux.ConversionBaseUnit); - case QuantityType.HeatTransferCoefficient: - return HeatTransferCoefficient.From(value, HeatTransferCoefficient.ConversionBaseUnit); - case QuantityType.Illuminance: - return Illuminance.From(value, Illuminance.ConversionBaseUnit); - case QuantityType.Information: - return Information.From(value, Information.ConversionBaseUnit); - case QuantityType.Irradiance: - return Irradiance.From(value, Irradiance.ConversionBaseUnit); - case QuantityType.Irradiation: - return Irradiation.From(value, Irradiation.ConversionBaseUnit); - case QuantityType.KinematicViscosity: - return KinematicViscosity.From(value, KinematicViscosity.ConversionBaseUnit); - case QuantityType.LapseRate: - return LapseRate.From(value, LapseRate.ConversionBaseUnit); - case QuantityType.Length: - return Length.From(value, Length.ConversionBaseUnit); - case QuantityType.Level: - return Level.From(value, Level.ConversionBaseUnit); - case QuantityType.LinearDensity: - return LinearDensity.From(value, LinearDensity.ConversionBaseUnit); - case QuantityType.LinearPowerDensity: - return LinearPowerDensity.From(value, LinearPowerDensity.ConversionBaseUnit); - case QuantityType.Luminosity: - return Luminosity.From(value, Luminosity.ConversionBaseUnit); - case QuantityType.LuminousFlux: - return LuminousFlux.From(value, LuminousFlux.ConversionBaseUnit); - case QuantityType.LuminousIntensity: - return LuminousIntensity.From(value, LuminousIntensity.ConversionBaseUnit); - case QuantityType.MagneticField: - return MagneticField.From(value, MagneticField.ConversionBaseUnit); - case QuantityType.MagneticFlux: - return MagneticFlux.From(value, MagneticFlux.ConversionBaseUnit); - case QuantityType.Magnetization: - return Magnetization.From(value, Magnetization.ConversionBaseUnit); - case QuantityType.Mass: - return Mass.From(value, Mass.ConversionBaseUnit); - case QuantityType.MassConcentration: - return MassConcentration.From(value, MassConcentration.ConversionBaseUnit); - case QuantityType.MassFlow: - return MassFlow.From(value, MassFlow.ConversionBaseUnit); - case QuantityType.MassFlux: - return MassFlux.From(value, MassFlux.ConversionBaseUnit); - case QuantityType.MassFraction: - return MassFraction.From(value, MassFraction.ConversionBaseUnit); - case QuantityType.MassMomentOfInertia: - return MassMomentOfInertia.From(value, MassMomentOfInertia.ConversionBaseUnit); - case QuantityType.MolarEnergy: - return MolarEnergy.From(value, MolarEnergy.ConversionBaseUnit); - case QuantityType.MolarEntropy: - return MolarEntropy.From(value, MolarEntropy.ConversionBaseUnit); - case QuantityType.Molarity: - return Molarity.From(value, Molarity.ConversionBaseUnit); - case QuantityType.MolarMass: - return MolarMass.From(value, MolarMass.ConversionBaseUnit); - case QuantityType.Permeability: - return Permeability.From(value, Permeability.ConversionBaseUnit); - case QuantityType.Permittivity: - return Permittivity.From(value, Permittivity.ConversionBaseUnit); - case QuantityType.Power: - return Power.From(value, Power.ConversionBaseUnit); - case QuantityType.PowerDensity: - return PowerDensity.From(value, PowerDensity.ConversionBaseUnit); - case QuantityType.PowerRatio: - return PowerRatio.From(value, PowerRatio.ConversionBaseUnit); - case QuantityType.Pressure: - return Pressure.From(value, Pressure.ConversionBaseUnit); - case QuantityType.PressureChangeRate: - return PressureChangeRate.From(value, PressureChangeRate.ConversionBaseUnit); - case QuantityType.Ratio: - return Ratio.From(value, Ratio.ConversionBaseUnit); - case QuantityType.RatioChangeRate: - return RatioChangeRate.From(value, RatioChangeRate.ConversionBaseUnit); - case QuantityType.ReactiveEnergy: - return ReactiveEnergy.From(value, ReactiveEnergy.ConversionBaseUnit); - case QuantityType.ReactivePower: - return ReactivePower.From(value, ReactivePower.ConversionBaseUnit); - case QuantityType.ReciprocalArea: - return ReciprocalArea.From(value, ReciprocalArea.ConversionBaseUnit); - case QuantityType.ReciprocalLength: - return ReciprocalLength.From(value, ReciprocalLength.ConversionBaseUnit); - case QuantityType.RelativeHumidity: - return RelativeHumidity.From(value, RelativeHumidity.ConversionBaseUnit); - case QuantityType.RotationalAcceleration: - return RotationalAcceleration.From(value, RotationalAcceleration.ConversionBaseUnit); - case QuantityType.RotationalSpeed: - return RotationalSpeed.From(value, RotationalSpeed.ConversionBaseUnit); - case QuantityType.RotationalStiffness: - return RotationalStiffness.From(value, RotationalStiffness.ConversionBaseUnit); - case QuantityType.RotationalStiffnessPerLength: - return RotationalStiffnessPerLength.From(value, RotationalStiffnessPerLength.ConversionBaseUnit); - case QuantityType.Scalar: - return Scalar.From(value, Scalar.ConversionBaseUnit); - case QuantityType.SolidAngle: - return SolidAngle.From(value, SolidAngle.ConversionBaseUnit); - case QuantityType.SpecificEnergy: - return SpecificEnergy.From(value, SpecificEnergy.ConversionBaseUnit); - case QuantityType.SpecificEntropy: - return SpecificEntropy.From(value, SpecificEntropy.ConversionBaseUnit); - case QuantityType.SpecificFuelConsumption: - return SpecificFuelConsumption.From(value, SpecificFuelConsumption.ConversionBaseUnit); - case QuantityType.SpecificVolume: - return SpecificVolume.From(value, SpecificVolume.ConversionBaseUnit); - case QuantityType.SpecificWeight: - return SpecificWeight.From(value, SpecificWeight.ConversionBaseUnit); - case QuantityType.Speed: - return Speed.From(value, Speed.ConversionBaseUnit); - case QuantityType.StandardVolumeFlow: - return StandardVolumeFlow.From(value, StandardVolumeFlow.ConversionBaseUnit); - case QuantityType.Temperature: - return Temperature.From(value, Temperature.ConversionBaseUnit); - case QuantityType.TemperatureChangeRate: - return TemperatureChangeRate.From(value, TemperatureChangeRate.ConversionBaseUnit); - case QuantityType.TemperatureDelta: - return TemperatureDelta.From(value, TemperatureDelta.ConversionBaseUnit); - case QuantityType.ThermalConductivity: - return ThermalConductivity.From(value, ThermalConductivity.ConversionBaseUnit); - case QuantityType.ThermalResistance: - return ThermalResistance.From(value, ThermalResistance.ConversionBaseUnit); - case QuantityType.Torque: - return Torque.From(value, Torque.ConversionBaseUnit); - case QuantityType.TorquePerLength: - return TorquePerLength.From(value, TorquePerLength.ConversionBaseUnit); - case QuantityType.Turbidity: - return Turbidity.From(value, Turbidity.ConversionBaseUnit); - case QuantityType.VitaminA: - return VitaminA.From(value, VitaminA.ConversionBaseUnit); - case QuantityType.Volume: - return Volume.From(value, Volume.ConversionBaseUnit); - case QuantityType.VolumeConcentration: - return VolumeConcentration.From(value, VolumeConcentration.ConversionBaseUnit); - case QuantityType.VolumeFlow: - return VolumeFlow.From(value, VolumeFlow.ConversionBaseUnit); - case QuantityType.VolumePerLength: - return VolumePerLength.From(value, VolumePerLength.ConversionBaseUnit); - case QuantityType.VolumetricHeatCapacity: - return VolumetricHeatCapacity.From(value, VolumetricHeatCapacity.ConversionBaseUnit); - case QuantityType.WarpingMomentOfInertia: - return WarpingMomentOfInertia.From(value, WarpingMomentOfInertia.ConversionBaseUnit); - default: - throw new ArgumentException($"{quantityType} is not a supported quantity type."); - } - } - /// /// Dynamically constructs a quantity of the given with the value in the quantity's base units. /// diff --git a/UnitsNet/GeneratedCode/QuantityType.g.cs b/UnitsNet/GeneratedCode/QuantityType.g.cs deleted file mode 100644 index f9f36fdc40..0000000000 --- a/UnitsNet/GeneratedCode/QuantityType.g.cs +++ /dev/null @@ -1,147 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by \generate-code.bat. -// -// Changes to this file will be lost when the code is regenerated. -// The build server regenerates the code before each build and a pre-build -// step will regenerate the code on each local build. -// -// See https://github.com/angularsen/UnitsNet/wiki/Adding-a-New-Unit for how to add or edit units. -// -// Add CustomCode\Quantities\MyQuantity.extra.cs files to add code to generated quantities. -// Add UnitDefinitions\MyQuantity.json and run generate-code.bat to generate new units or quantities. -// -// -//------------------------------------------------------------------------------ - -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - /// - /// Lists all generated quantities with the same name as the quantity struct type, - /// such as Length, Mass, Force etc. - /// This is useful for populating options in the UI, such as creating a generic conversion - /// tool with inputValue, quantityName, fromUnit and toUnit selectors. - /// - public enum QuantityType - { -// Missing XML comment for public type or member -#pragma warning disable CS1591 - Undefined = 0, - Acceleration, - AmountOfSubstance, - AmplitudeRatio, - Angle, - ApparentEnergy, - ApparentPower, - Area, - AreaDensity, - AreaMomentOfInertia, - BitRate, - BrakeSpecificFuelConsumption, - Capacitance, - CoefficientOfThermalExpansion, - Density, - Duration, - DynamicViscosity, - ElectricAdmittance, - ElectricCharge, - ElectricChargeDensity, - ElectricConductance, - ElectricConductivity, - ElectricCurrent, - ElectricCurrentDensity, - ElectricCurrentGradient, - ElectricField, - ElectricInductance, - ElectricPotential, - ElectricPotentialAc, - ElectricPotentialChangeRate, - ElectricPotentialDc, - ElectricResistance, - ElectricResistivity, - ElectricSurfaceChargeDensity, - Energy, - Entropy, - Force, - ForceChangeRate, - ForcePerLength, - Frequency, - FuelEfficiency, - HeatFlux, - HeatTransferCoefficient, - Illuminance, - Information, - Irradiance, - Irradiation, - KinematicViscosity, - LapseRate, - Length, - Level, - LinearDensity, - LinearPowerDensity, - Luminosity, - LuminousFlux, - LuminousIntensity, - MagneticField, - MagneticFlux, - Magnetization, - Mass, - MassConcentration, - MassFlow, - MassFlux, - MassFraction, - MassMomentOfInertia, - MolarEnergy, - MolarEntropy, - Molarity, - MolarMass, - Permeability, - Permittivity, - Power, - PowerDensity, - PowerRatio, - Pressure, - PressureChangeRate, - Ratio, - RatioChangeRate, - ReactiveEnergy, - ReactivePower, - ReciprocalArea, - ReciprocalLength, - RelativeHumidity, - RotationalAcceleration, - RotationalSpeed, - RotationalStiffness, - RotationalStiffnessPerLength, - Scalar, - SolidAngle, - SpecificEnergy, - SpecificEntropy, - SpecificFuelConsumption, - SpecificVolume, - SpecificWeight, - Speed, - StandardVolumeFlow, - Temperature, - TemperatureChangeRate, - TemperatureDelta, - ThermalConductivity, - ThermalResistance, - Torque, - TorquePerLength, - Turbidity, - VitaminA, - Volume, - VolumeConcentration, - VolumeFlow, - VolumePerLength, - VolumetricHeatCapacity, - WarpingMomentOfInertia, -// Missing XML comment for public type or member -#pragma warning restore CS1591 - } -} diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 546051d0da..d19bb68366 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -12,12 +12,6 @@ namespace UnitsNet /// public interface IQuantity : IFormattable { - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use QuantityInfo instead.")] - QuantityType Type { get; } - /// /// The of this quantity. /// diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index d9fd96cb03..0c70c1114d 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -19,30 +19,6 @@ namespace UnitsNet /// public class QuantityInfo { - private static readonly string UnitEnumNamespace = typeof(LengthUnit).Namespace; - - private static readonly Dictionary UnitEnumTypes = typeof(Length) - .Assembly - .GetExportedTypes() - .Where(t => t.IsEnum && t.Namespace == UnitEnumNamespace && t.Name.EndsWith("Unit")) - .ToDictionary(t => t.Name, t => t); - - /// - /// Constructs an instance. - /// - /// The quantity enum value. - /// The information about the units for this quantity. - /// The base unit enum value. - /// The zero quantity. - /// The base dimensions of the quantity. - /// Quantity type can not be undefined. - /// If units -or- baseUnit -or- zero -or- baseDimensions is null. - [Obsolete("QuantityType will be removed in the future. Use QuantityInfo(string, UnitInfo[], Enum, IQuantity, BaseDimensions) instead.")] - public QuantityInfo(QuantityType quantityType, UnitInfo[] unitInfos, Enum baseUnit, IQuantity zero, BaseDimensions baseDimensions) - : this(quantityType.ToString(), UnitEnumTypes[$"{quantityType}Unit"], unitInfos, baseUnit, zero, baseDimensions, quantityType) - { - } - /// /// Constructs an instance. /// @@ -52,11 +28,9 @@ public QuantityInfo(QuantityType quantityType, UnitInfo[] unitInfos, Enum baseUn /// The base unit enum value. /// The zero quantity. /// The base dimensions of the quantity. - /// The the quantity type. Defaults to Undefined. /// Quantity type can not be undefined. /// If units -or- baseUnit -or- zero -or- baseDimensions is null. - public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseUnit, IQuantity zero, BaseDimensions baseDimensions, - QuantityType quantityType = QuantityType.Undefined) + public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseUnit, IQuantity zero, BaseDimensions baseDimensions) { if(baseUnit == null) throw new ArgumentNullException(nameof(baseUnit)); @@ -75,7 +49,6 @@ public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseU UnitNames = UnitInfos.Select( unitInfo => unitInfo.Name ).ToArray(); Units = UnitInfos.Select( unitInfo => unitInfo.Value ).ToArray(); ConversionBaseUnit = BaseUnitInfo.Value; - QuantityType = quantityType; } /// @@ -83,12 +56,6 @@ public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseU /// public string Name { get; } - /// - /// Quantity type, such as or . - /// - [Obsolete("QuantityType will be removed in the future. Use QuantityInfo instead.")] - public QuantityType QuantityType { get; } - /// /// The units for this quantity. /// @@ -191,17 +158,9 @@ public IEnumerable GetUnitInfosFor(BaseUnits baseUnits) public class QuantityInfo : QuantityInfo where TUnit : Enum { - /// - [Obsolete("QuantityType will be removed in the future. Use QuantityInfo(QuantityType, string, UnitInfo{TUnit}[], TUnit, IQuantity{TUnit}, BaseDimensions) instead.")] - public QuantityInfo(QuantityType quantityType, UnitInfo[] unitInfos, TUnit baseUnit, IQuantity zero, BaseDimensions baseDimensions) - : this(quantityType.ToString(), unitInfos, baseUnit, zero, baseDimensions, quantityType) - { - } - /// - public QuantityInfo(string name, UnitInfo[] unitInfos, TUnit baseUnit, IQuantity zero, BaseDimensions baseDimensions, - QuantityType quantityType = QuantityType.Undefined) - : base(name, typeof(TUnit), unitInfos.ToArray(), baseUnit, zero, baseDimensions, quantityType) + public QuantityInfo(string name, UnitInfo[] unitInfos, TUnit baseUnit, IQuantity zero, BaseDimensions baseDimensions) + : base(name, typeof(TUnit), unitInfos.ToArray(), baseUnit, zero, baseDimensions) { Zero = zero; UnitInfos = unitInfos ?? throw new ArgumentNullException(nameof(unitInfos)); diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 9715098136..069557583c 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -278,8 +278,7 @@ public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum /// convert from. /// /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. + /// Name of quantity, such as "Length" and "Mass". for all quantities. /// /// /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as @@ -328,8 +327,7 @@ public static double ConvertByName(QuantityValue fromValue, string quantityName, /// convert from. /// /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. + /// Name of quantity, such as "Length" and "Mass". for all quantities. /// /// /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as @@ -403,8 +401,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant /// convert from. /// /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. + /// Name of quantity, such as "Length" and "Mass". for all quantities. /// /// /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as @@ -449,8 +446,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant /// convert from. /// /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. + /// Name of quantity, such as "Length" and "Mass". for all quantities. /// /// /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as @@ -481,8 +477,7 @@ public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quan /// convert from. /// /// - /// Name of quantity, such as "Length" and "Mass". for all - /// values. + /// Name of quantity, such as "Length" and "Mass". for all quantities. /// /// /// Name of unit, such as "Meter" or "Centimeter" if "Length" was passed as From 245460bfe6bffdf3fed3e0064c0386a2dc544afe Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Mon, 1 Nov 2021 23:43:40 +0100 Subject: [PATCH 19/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20IQuantity.Units?= =?UTF-8?q?=20and=20.UnitNames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 4 --- .../TestsBase/AccelerationTestsBase.g.cs | 4 --- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 4 --- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 4 --- .../TestsBase/AngleTestsBase.g.cs | 4 --- .../TestsBase/ApparentEnergyTestsBase.g.cs | 4 --- .../TestsBase/ApparentPowerTestsBase.g.cs | 4 --- .../TestsBase/AreaDensityTestsBase.g.cs | 4 --- .../AreaMomentOfInertiaTestsBase.g.cs | 4 --- .../TestsBase/AreaTestsBase.g.cs | 4 --- .../TestsBase/BitRateTestsBase.g.cs | 4 --- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 4 --- .../TestsBase/CapacitanceTestsBase.g.cs | 4 --- ...oefficientOfThermalExpansionTestsBase.g.cs | 4 --- .../TestsBase/DensityTestsBase.g.cs | 4 --- .../TestsBase/DurationTestsBase.g.cs | 4 --- .../TestsBase/DynamicViscosityTestsBase.g.cs | 4 --- .../ElectricAdmittanceTestsBase.g.cs | 4 --- .../ElectricChargeDensityTestsBase.g.cs | 4 --- .../TestsBase/ElectricChargeTestsBase.g.cs | 4 --- .../ElectricConductanceTestsBase.g.cs | 4 --- .../ElectricConductivityTestsBase.g.cs | 4 --- .../ElectricCurrentDensityTestsBase.g.cs | 4 --- .../ElectricCurrentGradientTestsBase.g.cs | 4 --- .../TestsBase/ElectricCurrentTestsBase.g.cs | 4 --- .../TestsBase/ElectricFieldTestsBase.g.cs | 4 --- .../ElectricInductanceTestsBase.g.cs | 4 --- .../ElectricPotentialAcTestsBase.g.cs | 4 --- .../ElectricPotentialChangeRateTestsBase.g.cs | 4 --- .../ElectricPotentialDcTestsBase.g.cs | 4 --- .../TestsBase/ElectricPotentialTestsBase.g.cs | 4 --- .../ElectricResistanceTestsBase.g.cs | 4 --- .../ElectricResistivityTestsBase.g.cs | 4 --- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 4 --- .../TestsBase/EnergyTestsBase.g.cs | 4 --- .../TestsBase/EntropyTestsBase.g.cs | 4 --- .../TestsBase/ForceChangeRateTestsBase.g.cs | 4 --- .../TestsBase/ForcePerLengthTestsBase.g.cs | 4 --- .../TestsBase/ForceTestsBase.g.cs | 4 --- .../TestsBase/FrequencyTestsBase.g.cs | 4 --- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 4 --- .../TestsBase/HeatFluxTestsBase.g.cs | 4 --- .../HeatTransferCoefficientTestsBase.g.cs | 4 --- .../TestsBase/IlluminanceTestsBase.g.cs | 4 --- .../TestsBase/InformationTestsBase.g.cs | 4 --- .../TestsBase/IrradianceTestsBase.g.cs | 4 --- .../TestsBase/IrradiationTestsBase.g.cs | 4 --- .../KinematicViscosityTestsBase.g.cs | 4 --- .../TestsBase/LapseRateTestsBase.g.cs | 4 --- .../TestsBase/LengthTestsBase.g.cs | 4 --- .../TestsBase/LevelTestsBase.g.cs | 4 --- .../TestsBase/LinearDensityTestsBase.g.cs | 4 --- .../LinearPowerDensityTestsBase.g.cs | 4 --- .../TestsBase/LuminosityTestsBase.g.cs | 4 --- .../TestsBase/LuminousFluxTestsBase.g.cs | 4 --- .../TestsBase/LuminousIntensityTestsBase.g.cs | 4 --- .../TestsBase/MagneticFieldTestsBase.g.cs | 4 --- .../TestsBase/MagneticFluxTestsBase.g.cs | 4 --- .../TestsBase/MagnetizationTestsBase.g.cs | 4 --- .../TestsBase/MassConcentrationTestsBase.g.cs | 4 --- .../TestsBase/MassFlowTestsBase.g.cs | 4 --- .../TestsBase/MassFluxTestsBase.g.cs | 4 --- .../TestsBase/MassFractionTestsBase.g.cs | 4 --- .../MassMomentOfInertiaTestsBase.g.cs | 4 --- .../TestsBase/MassTestsBase.g.cs | 4 --- .../TestsBase/MolarEnergyTestsBase.g.cs | 4 --- .../TestsBase/MolarEntropyTestsBase.g.cs | 4 --- .../TestsBase/MolarMassTestsBase.g.cs | 4 --- .../TestsBase/MolarityTestsBase.g.cs | 4 --- .../TestsBase/PermeabilityTestsBase.g.cs | 4 --- .../TestsBase/PermittivityTestsBase.g.cs | 4 --- .../TestsBase/PowerDensityTestsBase.g.cs | 4 --- .../TestsBase/PowerRatioTestsBase.g.cs | 4 --- .../TestsBase/PowerTestsBase.g.cs | 4 --- .../PressureChangeRateTestsBase.g.cs | 4 --- .../TestsBase/PressureTestsBase.g.cs | 4 --- .../TestsBase/RatioChangeRateTestsBase.g.cs | 4 --- .../TestsBase/RatioTestsBase.g.cs | 4 --- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 4 --- .../TestsBase/ReactivePowerTestsBase.g.cs | 4 --- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 4 --- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 4 --- .../TestsBase/RelativeHumidityTestsBase.g.cs | 4 --- .../RotationalAccelerationTestsBase.g.cs | 4 --- .../TestsBase/RotationalSpeedTestsBase.g.cs | 4 --- ...RotationalStiffnessPerLengthTestsBase.g.cs | 4 --- .../RotationalStiffnessTestsBase.g.cs | 4 --- .../TestsBase/ScalarTestsBase.g.cs | 4 --- .../TestsBase/SolidAngleTestsBase.g.cs | 4 --- .../TestsBase/SpecificEnergyTestsBase.g.cs | 4 --- .../TestsBase/SpecificEntropyTestsBase.g.cs | 4 --- .../SpecificFuelConsumptionTestsBase.g.cs | 4 --- .../TestsBase/SpecificVolumeTestsBase.g.cs | 4 --- .../TestsBase/SpecificWeightTestsBase.g.cs | 4 --- .../TestsBase/SpeedTestsBase.g.cs | 4 --- .../StandardVolumeFlowTestsBase.g.cs | 4 --- .../TemperatureChangeRateTestsBase.g.cs | 4 --- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 4 --- .../TestsBase/TemperatureTestsBase.g.cs | 4 --- .../ThermalConductivityTestsBase.g.cs | 4 --- .../TestsBase/ThermalResistanceTestsBase.g.cs | 4 --- .../TestsBase/TorquePerLengthTestsBase.g.cs | 4 --- .../TestsBase/TorqueTestsBase.g.cs | 4 --- .../TestsBase/TurbidityTestsBase.g.cs | 4 --- .../TestsBase/VitaminATestsBase.g.cs | 4 --- .../VolumeConcentrationTestsBase.g.cs | 4 --- .../TestsBase/VolumeFlowTestsBase.g.cs | 4 --- .../TestsBase/VolumePerLengthTestsBase.g.cs | 4 --- .../TestsBase/VolumeTestsBase.g.cs | 4 --- .../VolumetricHeatCapacityTestsBase.g.cs | 4 --- .../WarpingMomentOfInertiaTestsBase.g.cs | 4 --- UnitsNet.Tests/QuantityInfoTest.cs | 12 ------- UnitsNet.Tests/QuantityTest.cs | 24 ------------- UnitsNet/QuantityInfo.cs | 36 ------------------- 114 files changed, 516 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index ba76ac5783..39ad4ce5e8 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -170,10 +170,6 @@ public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() var units = EnumUtils.GetEnumValues<{_unitEnumName}>().Except(new[] {{{_unitEnumName}.Undefined}}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); }} [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index e4a851f0b4..fc7280dca0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -129,10 +129,6 @@ public void Acceleration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {AccelerationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 99a3f9af9a..af3236f364 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -131,10 +131,6 @@ public void AmountOfSubstance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity var units = EnumUtils.GetEnumValues().Except(new[] {AmountOfSubstanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 8ec1ac34a3..08c70ed5db 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -109,10 +109,6 @@ public void AmplitudeRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {AmplitudeRatioUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index d87269badb..29eedf4ddd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -133,10 +133,6 @@ public void Angle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {AngleUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 6ffd292207..75b85cffe1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -107,10 +107,6 @@ public void ApparentEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ApparentEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 49fe978c2c..3776c80d92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -109,10 +109,6 @@ public void ApparentPower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ApparentPowerUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 69c83958fe..0057a1229a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -103,10 +103,6 @@ public void AreaDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {AreaDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index e9a5fef2ca..d91c815442 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -113,10 +113,6 @@ public void AreaMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {AreaMomentOfInertiaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 4930cf8da9..c2ebd9b8e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -129,10 +129,6 @@ public void Area_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {AreaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 2c0afd0ef2..f1f81615f5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -141,10 +141,6 @@ public void BitRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {BitRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index d540ce0eac..765014dc66 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -107,10 +107,6 @@ public void BrakeSpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescrib var units = EnumUtils.GetEnumValues().Except(new[] {BrakeSpecificFuelConsumptionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index a8ac663a2d..297e49f301 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -115,10 +115,6 @@ public void Capacitance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {CapacitanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 43111755b7..d329a95f13 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -107,10 +107,6 @@ public void CoefficientOfThermalExpansion_QuantityInfo_ReturnsQuantityInfoDescri var units = EnumUtils.GetEnumValues().Except(new[] {CoefficientOfThermalExpansionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index b905a164ad..38629c6c54 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -181,10 +181,6 @@ public void Density_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {DensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 22895561bd..0e8bbcb5e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -121,10 +121,6 @@ public void Duration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {DurationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 936eeec688..77eed0299f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -121,10 +121,6 @@ public void DynamicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( var units = EnumUtils.GetEnumValues().Except(new[] {DynamicViscosityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 65427b5b76..7c8a58bf23 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -109,10 +109,6 @@ public void ElectricAdmittance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {ElectricAdmittanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 7507293eb8..839013f337 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -103,10 +103,6 @@ public void ElectricChargeDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuan var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 312548fa3e..7ad3626bfc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -111,10 +111,6 @@ public void ElectricCharge_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index b9eaeff67e..027e5d0ef6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -107,10 +107,6 @@ public void ElectricConductance_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 414bbd4493..42dba0cd92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -107,10 +107,6 @@ public void ElectricConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuant var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 060a7ae629..05e79c2dc5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -107,10 +107,6 @@ public void ElectricCurrentDensity_QuantityInfo_ReturnsQuantityInfoDescribingQua var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index fb47ca10cb..89315e95a5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -109,10 +109,6 @@ public void ElectricCurrentGradient_QuantityInfo_ReturnsQuantityInfoDescribingQu var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentGradientUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index ff63cbeaf9..9988854013 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -117,10 +117,6 @@ public void ElectricCurrent_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 5f4cab7d98..d074423c24 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -103,10 +103,6 @@ public void ElectricField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ElectricFieldUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index a87ca5f4d6..fd533cc716 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -109,10 +109,6 @@ public void ElectricInductance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {ElectricInductanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index ad72cc88c4..1f01ede974 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -111,10 +111,6 @@ public void ElectricPotentialAc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialAcUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 1e8b767242..cc6cf45b2b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -141,10 +141,6 @@ public void ElectricPotentialChangeRate_QuantityInfo_ReturnsQuantityInfoDescribi var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 1ca6103428..586c08fd61 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -111,10 +111,6 @@ public void ElectricPotentialDc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialDcUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index caa4749e79..b65983c626 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -111,10 +111,6 @@ public void ElectricPotential_QuantityInfo_ReturnsQuantityInfoDescribingQuantity var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index d091cc3d9c..1c1bbe7782 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -113,10 +113,6 @@ public void ElectricResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 086a91d116..f090b02b1e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -129,10 +129,6 @@ public void ElectricResistivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index aa4dd8f559..48f4a87664 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -107,10 +107,6 @@ public void ElectricSurfaceChargeDensity_QuantityInfo_ReturnsQuantityInfoDescrib var units = EnumUtils.GetEnumValues().Except(new[] {ElectricSurfaceChargeDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 50f5da7d74..ee3b77473c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -173,10 +173,6 @@ public void Energy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {EnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 42d3e37bf4..3602402663 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -115,10 +115,6 @@ public void Entropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {EntropyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 7a12cbb0e4..879d1597c7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -131,10 +131,6 @@ public void ForceChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ForceChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 5da01598f8..3f6f7b2fe4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -177,10 +177,6 @@ public void ForcePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ForcePerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index f5268a6a03..aa52a70cb5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -131,10 +131,6 @@ public void Force_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ForceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 670981cb1d..8f3f7dd060 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -123,10 +123,6 @@ public void Frequency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {FrequencyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index f68b3e3009..070a13ac17 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -109,10 +109,6 @@ public void FuelEfficiency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {FuelEfficiencyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index b91749a674..b9782540c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -137,10 +137,6 @@ public void HeatFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {HeatFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 733f1a36a6..a47591fbee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -107,10 +107,6 @@ public void HeatTransferCoefficient_QuantityInfo_ReturnsQuantityInfoDescribingQu var units = EnumUtils.GetEnumValues().Except(new[] {HeatTransferCoefficientUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 881b7dd457..2019628632 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -109,10 +109,6 @@ public void Illuminance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {IlluminanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 93444f880b..d8af813a79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -141,10 +141,6 @@ public void Information_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {InformationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 294194e9e5..b26f71b7b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -129,10 +129,6 @@ public void Irradiance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {IrradianceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index c6da8cbdae..28e791cbd4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -115,10 +115,6 @@ public void Irradiation_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {IrradiationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index eef75fbbdd..12c0b2b9e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -119,10 +119,6 @@ public void KinematicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {KinematicViscosityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 017199a1b9..9b45fb831f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -103,10 +103,6 @@ public void LapseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {LapseRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 763679f72e..2259dac807 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -167,10 +167,6 @@ public void Length_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {LengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 2ebc42c6d1..282156b608 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -105,10 +105,6 @@ public void Level_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {LevelUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 087253455e..4ec8965641 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -129,10 +129,6 @@ public void LinearDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {LinearDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 4bc90b7955..bb277d84a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -151,10 +151,6 @@ public void LinearPowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {LinearPowerDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index dd33c33fc6..9dc6bc45a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -129,10 +129,6 @@ public void Luminosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {LuminosityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 93e0ff14f8..98f2e4eb29 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -103,10 +103,6 @@ public void LuminousFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {LuminousFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index df03ad16c0..7d1fd10a74 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -103,10 +103,6 @@ public void LuminousIntensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity var units = EnumUtils.GetEnumValues().Except(new[] {LuminousIntensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 583a8babc5..79e3ec59c5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -113,10 +113,6 @@ public void MagneticField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFieldUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 64ba398f7b..114d51a3af 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -103,10 +103,6 @@ public void MagneticFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 14c4af2617..5624542aee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -103,10 +103,6 @@ public void Magnetization_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MagnetizationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 6597abb2a7..c77ca6493f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -199,10 +199,6 @@ public void MassConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity var units = EnumUtils.GetEnumValues().Except(new[] {MassConcentrationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index a4e238e2ef..69e9b6373f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -167,10 +167,6 @@ public void MassFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MassFlowUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 111ccef9a7..78740e43ec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -125,10 +125,6 @@ public void MassFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MassFluxUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 014e771320..824329f958 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -149,10 +149,6 @@ public void MassFraction_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MassFractionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 21caaab511..003a0969a6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -157,10 +157,6 @@ public void MassMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {MassMomentOfInertiaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 30e8e25f69..5ef9da9318 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -151,10 +151,6 @@ public void Mass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MassUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 5ee3825a25..7470c588f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -107,10 +107,6 @@ public void MolarEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MolarEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index cb6958a896..94224482a0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -107,10 +107,6 @@ public void MolarEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MolarEntropyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 76ecf76f8c..f12e266275 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -125,10 +125,6 @@ public void MolarMass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MolarMassUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index ec96bf5af6..32fd869928 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -117,10 +117,6 @@ public void Molarity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {MolarityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index f523787d21..b74761f202 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -103,10 +103,6 @@ public void Permeability_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {PermeabilityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 628dbcaab9..7a7f4558d3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -103,10 +103,6 @@ public void Permittivity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {PermittivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 77fa028f57..4a85cb7e8f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -189,10 +189,6 @@ public void PowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {PowerDensityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 6e92da0627..39bc6da04b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -105,10 +105,6 @@ public void PowerRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {PowerRatioUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 376d3bf385..6b892e621b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -139,10 +139,6 @@ public void Power_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {PowerUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 0eb488f05c..63218f597c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -127,10 +127,6 @@ public void PressureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {PressureChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 27203ef3e8..31e25a1177 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -189,10 +189,6 @@ public void Pressure_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {PressureUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 3aed7ed457..9b130d7f2f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -105,10 +105,6 @@ public void RatioChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {RatioChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 5525631d39..5b1b39beb3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -113,10 +113,6 @@ public void Ratio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {RatioUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 9b40d939d2..49ffecf81c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -107,10 +107,6 @@ public void ReactiveEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ReactiveEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 1f8f68a1ac..ffd88e403b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -109,10 +109,6 @@ public void ReactivePower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ReactivePowerUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 6cdabc0366..7cc2e2e96d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -123,10 +123,6 @@ public void ReciprocalArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalAreaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 78615a705e..a017e73fd0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -121,10 +121,6 @@ public void ReciprocalLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index f0af4d4e71..e53a0c6950 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -103,10 +103,6 @@ public void RelativeHumidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( var units = EnumUtils.GetEnumValues().Except(new[] {RelativeHumidityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 2abe4526a6..0d92d40b7d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -109,10 +109,6 @@ public void RotationalAcceleration_QuantityInfo_ReturnsQuantityInfoDescribingQua var units = EnumUtils.GetEnumValues().Except(new[] {RotationalAccelerationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 3ad29e76d1..07829e7b4c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -127,10 +127,6 @@ public void RotationalSpeed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {RotationalSpeedUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index c5ceb3308b..edda3cb83f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -111,10 +111,6 @@ public void RotationalStiffnessPerLength_QuantityInfo_ReturnsQuantityInfoDescrib var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessPerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 19645921ca..998559d2e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -167,10 +167,6 @@ public void RotationalStiffness_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index cca987ee20..776b02ab7e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -103,10 +103,6 @@ public void Scalar_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {ScalarUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 60f1c3b1a9..6c3ad74af0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -103,10 +103,6 @@ public void SolidAngle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {SolidAngleUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 2ecacd2d2b..1782410f10 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -151,10 +151,6 @@ public void SpecificEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEnergyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 7ac5369551..e6adaccba8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -119,10 +119,6 @@ public void SpecificEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEntropyUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 3fbf631da0..69d1466b62 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -109,10 +109,6 @@ public void SpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescribingQu var units = EnumUtils.GetEnumValues().Except(new[] {SpecificFuelConsumptionUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 2415359dbf..b27d6f9444 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -107,10 +107,6 @@ public void SpecificVolume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {SpecificVolumeUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 99445dd042..73bfdf2582 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -135,10 +135,6 @@ public void SpecificWeight_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {SpecificWeightUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 5137cd6b66..c2a020dc7f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -165,10 +165,6 @@ public void Speed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {SpeedUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 992854a00b..fcdd7de773 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -119,10 +119,6 @@ public void StandardVolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantit var units = EnumUtils.GetEnumValues().Except(new[] {StandardVolumeFlowUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index c924304cf4..8581fc13a4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -121,10 +121,6 @@ public void TemperatureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuan var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureChangeRateUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 98eed1a3a6..343bfb216b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -119,10 +119,6 @@ public void TemperatureDelta_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureDeltaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 3d0446d109..433e00866b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -121,10 +121,6 @@ public void Temperature_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index ad67d32ff0..b1f08883bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -105,10 +105,6 @@ public void ThermalConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {ThermalConductivityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 48bafa9d79..14200f924a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -111,10 +111,6 @@ public void ThermalResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity var units = EnumUtils.GetEnumValues().Except(new[] {ThermalResistanceUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index bdedcba996..11ea0c65d3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -143,10 +143,6 @@ public void TorquePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {TorquePerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index a5661da2c6..8346b7e599 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -145,10 +145,6 @@ public void Torque_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {TorqueUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 506a822a98..fbd48bb9f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -103,10 +103,6 @@ public void Turbidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {TurbidityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 4b1dc163b5..05b124620d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -103,10 +103,6 @@ public void VitaminA_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {VitaminAUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 772bccc999..21770de6e5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -141,10 +141,6 @@ public void VolumeConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuanti var units = EnumUtils.GetEnumValues().Except(new[] {VolumeConcentrationUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 605d0de51c..f438755e4c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -213,10 +213,6 @@ public void VolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {VolumeFlowUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 66146411fa..6b688a72a8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -115,10 +115,6 @@ public void VolumePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {VolumePerLengthUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 99f6250514..23f0dac504 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -203,10 +203,6 @@ public void Volume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() var units = EnumUtils.GetEnumValues().Except(new[] {VolumeUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index ceab50186e..8aa7798217 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -119,10 +119,6 @@ public void VolumetricHeatCapacity_QuantityInfo_ReturnsQuantityInfoDescribingQua var units = EnumUtils.GetEnumValues().Except(new[] {VolumetricHeatCapacityUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 941c004dd2..b205d4630f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -113,10 +113,6 @@ public void WarpingMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQua var units = EnumUtils.GetEnumValues().Except(new[] {WarpingMomentOfInertiaUnit.Undefined}).ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index 719c927002..cff89598a6 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -29,10 +29,6 @@ public void Constructor_AssignsProperties() Assert.Equal("Length", info.Name); Assert.Equal(expectedUnitInfos, info.UnitInfos); Assert.Equal(expectedBaseDimensions, info.BaseDimensions); - - // Obsolete members - Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); - Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } [Fact] @@ -54,10 +50,6 @@ public void Constructor_AssignsPropertiesForCustomQuantity() Assert.Equal(nameof(HowMuch), info.Name); Assert.Equal(expectedUnitInfos, info.UnitInfos); Assert.Equal(expectedBaseDimensions, info.BaseDimensions); - - // Obsolete members - Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); - Assert.Equal(new[] {nameof(HowMuchUnit.Some), nameof(HowMuchUnit.ATon), nameof(HowMuchUnit.AShitTon)}, info.UnitNames); } [Fact] @@ -76,10 +68,6 @@ public void GenericsConstructor_AssignsProperties() Assert.Equal("Length", info.Name); Assert.Equal(expectedUnitInfos, info.UnitInfos); Assert.Equal(expectedBaseDimensions, info.BaseDimensions); - - // Obsolete members - Assert.Equal( expectedBaseUnit, info.ConversionBaseUnit ); - Assert.Equal( new[] { "Centimeter", "Kilometer" }, info.UnitNames ); } [Fact] diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 3b6807e06b..82bd29a1d1 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -45,41 +45,17 @@ public void From_GivenValueAndUnit_ReturnsQuantity() [Fact] public void ByName_GivenLength_ReturnsQuantityInfoForLength() { - var knownLengthUnits = new Enum[] { LengthUnit.Meter, LengthUnit.Centimeter, LengthUnit.Kilometer }; - var knownLengthUnitNames = new[] { "Meter", "Centimeter", "Kilometer" }; - var lengthUnitCount = Enum.GetValues(typeof(LengthUnit)).Length - 1; // Exclude LengthUnit.Undefined - QuantityInfo quantityInfo = Quantity.ByName["Length"]; Assert.Equal("Length", quantityInfo.Name); Assert.Same(Length.Info, quantityInfo.Name); - // Obsolete members - Assert.Superset(knownLengthUnitNames.ToHashSet(), quantityInfo.UnitNames.ToHashSet()); - Assert.Superset(knownLengthUnits.ToHashSet(), quantityInfo.Units.ToHashSet()); - Assert.Equal(lengthUnitCount, quantityInfo.UnitNames.Length); - Assert.Equal(lengthUnitCount, quantityInfo.Units.Length); - Assert.Equal(typeof(LengthUnit), quantityInfo.UnitType); - Assert.Equal(typeof(Length), quantityInfo.ValueType); - Assert.Equal(Length.Zero, quantityInfo.Zero); } [Fact] public void ByName_GivenMass_ReturnsQuantityInfoForMass() { - var knownMassUnits = new Enum[] { MassUnit.Kilogram, MassUnit.Gram, MassUnit.Tonne }; - var knownMassUnitNames = new[] { "Kilogram", "Gram", "Tonne" }; - var massUnitCount = Enum.GetValues(typeof(MassUnit)).Length - 1; // Exclude MassUnit.Undefined - QuantityInfo quantityInfo = Quantity.ByName["Mass"]; Assert.Equal("Mass", quantityInfo.Name); Assert.Same(Mass.Info, quantityInfo.Name); - // Obsolete members - Assert.Superset(knownMassUnitNames.ToHashSet(), quantityInfo.UnitNames.ToHashSet()); - Assert.Superset(knownMassUnits.ToHashSet(), quantityInfo.Units.ToHashSet()); - Assert.Equal(massUnitCount, quantityInfo.UnitNames.Length); - Assert.Equal(massUnitCount, quantityInfo.Units.Length); - Assert.Equal(typeof(MassUnit), quantityInfo.UnitType); - Assert.Equal(typeof(Mass), quantityInfo.ValueType); - Assert.Equal(Mass.Zero, quantityInfo.Zero); } [Fact] diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index 0c70c1114d..0de49d6a22 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -44,11 +44,6 @@ public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseU Zero = zero ?? throw new ArgumentNullException(nameof(zero)); ValueType = zero.GetType(); BaseDimensions = baseDimensions ?? throw new ArgumentNullException(nameof(baseDimensions)); - - // Obsolete members - UnitNames = UnitInfos.Select( unitInfo => unitInfo.Name ).ToArray(); - Units = UnitInfos.Select( unitInfo => unitInfo.Value ).ToArray(); - ConversionBaseUnit = BaseUnitInfo.Value; } /// @@ -61,30 +56,11 @@ public QuantityInfo(string name, Type unitType, UnitInfo[] unitInfos, Enum baseU /// public UnitInfo[] UnitInfos { get; } - /// - /// All unit names for the quantity, such as ["Centimeter", "Decimeter", "Meter", ...]. - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the UnitInfos property.")] - public string[] UnitNames { get; } - - /// - /// All unit enum values for the quantity, such as [, - /// , , ...]. - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the UnitInfos property.")] - public Enum[] Units { get; } - /// /// The base unit of this quantity. /// public UnitInfo BaseUnitInfo { get; } - /// - /// The base unit for the quantity, such as . - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the BaseUnitInfo property.")] - public Enum ConversionBaseUnit { get; } - /// /// Zero value of quantity, such as . /// @@ -166,26 +142,14 @@ public QuantityInfo(string name, UnitInfo[] unitInfos, TUnit baseUnit, IQ UnitInfos = unitInfos ?? throw new ArgumentNullException(nameof(unitInfos)); BaseUnitInfo = UnitInfos.First(unitInfo => unitInfo.Value.Equals(baseUnit)); UnitType = baseUnit; - - // Obsolete members - Units = UnitInfos.Select(unitInfo => unitInfo.Value).ToArray(); - ConversionBaseUnit = BaseUnitInfo.Value; } /// public new UnitInfo[] UnitInfos { get; } - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the UnitInfos property.")] - public new TUnit[] Units { get; } - /// public new UnitInfo BaseUnitInfo { get; } - /// - [Obsolete("This property is deprecated and will be removed at a future release. Please use the BaseUnitInfo property.")] - public new TUnit ConversionBaseUnit { get; } - /// public new IQuantity Zero { get; } From dcca62a6701cbdca5f8452629ff536170f5f4ce3 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 00:08:55 +0100 Subject: [PATCH 20/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20obsolete=20method?= =?UTF-8?q?s=20in=20quantity=20classes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MinValue - MaxValue - ToString overloads --- .../UnitsNetGen/QuantityGenerator.cs | 48 +------------------ .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 25 +++++----- .../UnitsNetJsonDeserializationTests.cs | 29 +++++------ UnitsNet.Tests/CustomCode/InformationTests.cs | 13 ----- UnitsNet.Tests/CustomCode/LengthTests.cs | 12 ----- .../TestsBase/AccelerationTestsBase.g.cs | 25 +++++----- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 25 +++++----- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 25 +++++----- .../TestsBase/AngleTestsBase.g.cs | 25 +++++----- .../TestsBase/ApparentEnergyTestsBase.g.cs | 25 +++++----- .../TestsBase/ApparentPowerTestsBase.g.cs | 25 +++++----- .../TestsBase/AreaDensityTestsBase.g.cs | 25 +++++----- .../AreaMomentOfInertiaTestsBase.g.cs | 25 +++++----- .../TestsBase/AreaTestsBase.g.cs | 25 +++++----- .../TestsBase/BitRateTestsBase.g.cs | 25 +++++----- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 25 +++++----- .../TestsBase/CapacitanceTestsBase.g.cs | 25 +++++----- ...oefficientOfThermalExpansionTestsBase.g.cs | 25 +++++----- .../TestsBase/DensityTestsBase.g.cs | 25 +++++----- .../TestsBase/DurationTestsBase.g.cs | 25 +++++----- .../TestsBase/DynamicViscosityTestsBase.g.cs | 25 +++++----- .../ElectricAdmittanceTestsBase.g.cs | 25 +++++----- .../ElectricChargeDensityTestsBase.g.cs | 25 +++++----- .../TestsBase/ElectricChargeTestsBase.g.cs | 25 +++++----- .../ElectricConductanceTestsBase.g.cs | 25 +++++----- .../ElectricConductivityTestsBase.g.cs | 25 +++++----- .../ElectricCurrentDensityTestsBase.g.cs | 25 +++++----- .../ElectricCurrentGradientTestsBase.g.cs | 25 +++++----- .../TestsBase/ElectricCurrentTestsBase.g.cs | 25 +++++----- .../TestsBase/ElectricFieldTestsBase.g.cs | 25 +++++----- .../ElectricInductanceTestsBase.g.cs | 25 +++++----- .../ElectricPotentialAcTestsBase.g.cs | 25 +++++----- .../ElectricPotentialChangeRateTestsBase.g.cs | 25 +++++----- .../ElectricPotentialDcTestsBase.g.cs | 25 +++++----- .../TestsBase/ElectricPotentialTestsBase.g.cs | 25 +++++----- .../ElectricResistanceTestsBase.g.cs | 25 +++++----- .../ElectricResistivityTestsBase.g.cs | 25 +++++----- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 25 +++++----- .../TestsBase/EnergyTestsBase.g.cs | 25 +++++----- .../TestsBase/EntropyTestsBase.g.cs | 25 +++++----- .../TestsBase/ForceChangeRateTestsBase.g.cs | 25 +++++----- .../TestsBase/ForcePerLengthTestsBase.g.cs | 25 +++++----- .../TestsBase/ForceTestsBase.g.cs | 25 +++++----- .../TestsBase/FrequencyTestsBase.g.cs | 25 +++++----- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 25 +++++----- .../TestsBase/HeatFluxTestsBase.g.cs | 25 +++++----- .../HeatTransferCoefficientTestsBase.g.cs | 25 +++++----- .../TestsBase/IlluminanceTestsBase.g.cs | 25 +++++----- .../TestsBase/InformationTestsBase.g.cs | 25 +++++----- .../TestsBase/IrradianceTestsBase.g.cs | 25 +++++----- .../TestsBase/IrradiationTestsBase.g.cs | 25 +++++----- .../KinematicViscosityTestsBase.g.cs | 25 +++++----- .../TestsBase/LapseRateTestsBase.g.cs | 25 +++++----- .../TestsBase/LengthTestsBase.g.cs | 25 +++++----- .../TestsBase/LevelTestsBase.g.cs | 25 +++++----- .../TestsBase/LinearDensityTestsBase.g.cs | 25 +++++----- .../LinearPowerDensityTestsBase.g.cs | 25 +++++----- .../TestsBase/LuminosityTestsBase.g.cs | 25 +++++----- .../TestsBase/LuminousFluxTestsBase.g.cs | 25 +++++----- .../TestsBase/LuminousIntensityTestsBase.g.cs | 25 +++++----- .../TestsBase/MagneticFieldTestsBase.g.cs | 25 +++++----- .../TestsBase/MagneticFluxTestsBase.g.cs | 25 +++++----- .../TestsBase/MagnetizationTestsBase.g.cs | 25 +++++----- .../TestsBase/MassConcentrationTestsBase.g.cs | 25 +++++----- .../TestsBase/MassFlowTestsBase.g.cs | 25 +++++----- .../TestsBase/MassFluxTestsBase.g.cs | 25 +++++----- .../TestsBase/MassFractionTestsBase.g.cs | 25 +++++----- .../MassMomentOfInertiaTestsBase.g.cs | 25 +++++----- .../TestsBase/MassTestsBase.g.cs | 25 +++++----- .../TestsBase/MolarEnergyTestsBase.g.cs | 25 +++++----- .../TestsBase/MolarEntropyTestsBase.g.cs | 25 +++++----- .../TestsBase/MolarMassTestsBase.g.cs | 25 +++++----- .../TestsBase/MolarityTestsBase.g.cs | 25 +++++----- .../TestsBase/PermeabilityTestsBase.g.cs | 25 +++++----- .../TestsBase/PermittivityTestsBase.g.cs | 25 +++++----- .../TestsBase/PowerDensityTestsBase.g.cs | 25 +++++----- .../TestsBase/PowerRatioTestsBase.g.cs | 25 +++++----- .../TestsBase/PowerTestsBase.g.cs | 25 +++++----- .../PressureChangeRateTestsBase.g.cs | 25 +++++----- .../TestsBase/PressureTestsBase.g.cs | 25 +++++----- .../TestsBase/RatioChangeRateTestsBase.g.cs | 25 +++++----- .../TestsBase/RatioTestsBase.g.cs | 25 +++++----- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 25 +++++----- .../TestsBase/ReactivePowerTestsBase.g.cs | 25 +++++----- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 25 +++++----- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 25 +++++----- .../TestsBase/RelativeHumidityTestsBase.g.cs | 25 +++++----- .../RotationalAccelerationTestsBase.g.cs | 25 +++++----- .../TestsBase/RotationalSpeedTestsBase.g.cs | 25 +++++----- ...RotationalStiffnessPerLengthTestsBase.g.cs | 25 +++++----- .../RotationalStiffnessTestsBase.g.cs | 25 +++++----- .../TestsBase/ScalarTestsBase.g.cs | 25 +++++----- .../TestsBase/SolidAngleTestsBase.g.cs | 25 +++++----- .../TestsBase/SpecificEnergyTestsBase.g.cs | 25 +++++----- .../TestsBase/SpecificEntropyTestsBase.g.cs | 25 +++++----- .../SpecificFuelConsumptionTestsBase.g.cs | 25 +++++----- .../TestsBase/SpecificVolumeTestsBase.g.cs | 25 +++++----- .../TestsBase/SpecificWeightTestsBase.g.cs | 25 +++++----- .../TestsBase/SpeedTestsBase.g.cs | 25 +++++----- .../StandardVolumeFlowTestsBase.g.cs | 25 +++++----- .../TemperatureChangeRateTestsBase.g.cs | 25 +++++----- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 25 +++++----- .../TestsBase/TemperatureTestsBase.g.cs | 25 +++++----- .../ThermalConductivityTestsBase.g.cs | 25 +++++----- .../TestsBase/ThermalResistanceTestsBase.g.cs | 25 +++++----- .../TestsBase/TorquePerLengthTestsBase.g.cs | 25 +++++----- .../TestsBase/TorqueTestsBase.g.cs | 25 +++++----- .../TestsBase/TurbidityTestsBase.g.cs | 25 +++++----- .../TestsBase/VitaminATestsBase.g.cs | 25 +++++----- .../VolumeConcentrationTestsBase.g.cs | 25 +++++----- .../TestsBase/VolumeFlowTestsBase.g.cs | 25 +++++----- .../TestsBase/VolumePerLengthTestsBase.g.cs | 25 +++++----- .../TestsBase/VolumeTestsBase.g.cs | 25 +++++----- .../VolumetricHeatCapacityTestsBase.g.cs | 25 +++++----- .../WarpingMomentOfInertiaTestsBase.g.cs | 25 +++++----- UnitsNet.Tests/QuantityTest.cs | 4 +- .../Quantities/Acceleration.g.cs | 46 ------------------ .../Quantities/AmountOfSubstance.g.cs | 46 ------------------ .../Quantities/AmplitudeRatio.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 46 ------------------ .../Quantities/ApparentEnergy.g.cs | 46 ------------------ .../Quantities/ApparentPower.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Area.g.cs | 46 ------------------ .../GeneratedCode/Quantities/AreaDensity.g.cs | 46 ------------------ .../Quantities/AreaMomentOfInertia.g.cs | 46 ------------------ .../GeneratedCode/Quantities/BitRate.g.cs | 46 ------------------ .../BrakeSpecificFuelConsumption.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Capacitance.g.cs | 46 ------------------ .../CoefficientOfThermalExpansion.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Density.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Duration.g.cs | 46 ------------------ .../Quantities/DynamicViscosity.g.cs | 46 ------------------ .../Quantities/ElectricAdmittance.g.cs | 46 ------------------ .../Quantities/ElectricCharge.g.cs | 46 ------------------ .../Quantities/ElectricChargeDensity.g.cs | 46 ------------------ .../Quantities/ElectricConductance.g.cs | 46 ------------------ .../Quantities/ElectricConductivity.g.cs | 46 ------------------ .../Quantities/ElectricCurrent.g.cs | 46 ------------------ .../Quantities/ElectricCurrentDensity.g.cs | 46 ------------------ .../Quantities/ElectricCurrentGradient.g.cs | 46 ------------------ .../Quantities/ElectricField.g.cs | 46 ------------------ .../Quantities/ElectricInductance.g.cs | 46 ------------------ .../Quantities/ElectricPotential.g.cs | 46 ------------------ .../Quantities/ElectricPotentialAc.g.cs | 46 ------------------ .../ElectricPotentialChangeRate.g.cs | 46 ------------------ .../Quantities/ElectricPotentialDc.g.cs | 46 ------------------ .../Quantities/ElectricResistance.g.cs | 46 ------------------ .../Quantities/ElectricResistivity.g.cs | 46 ------------------ .../ElectricSurfaceChargeDensity.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Entropy.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Force.g.cs | 46 ------------------ .../Quantities/ForceChangeRate.g.cs | 46 ------------------ .../Quantities/ForcePerLength.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Frequency.g.cs | 46 ------------------ .../Quantities/FuelEfficiency.g.cs | 46 ------------------ .../GeneratedCode/Quantities/HeatFlux.g.cs | 46 ------------------ .../Quantities/HeatTransferCoefficient.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Illuminance.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Information.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Irradiance.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Irradiation.g.cs | 46 ------------------ .../Quantities/KinematicViscosity.g.cs | 46 ------------------ .../GeneratedCode/Quantities/LapseRate.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Length.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Level.g.cs | 46 ------------------ .../Quantities/LinearDensity.g.cs | 46 ------------------ .../Quantities/LinearPowerDensity.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Luminosity.g.cs | 46 ------------------ .../Quantities/LuminousFlux.g.cs | 46 ------------------ .../Quantities/LuminousIntensity.g.cs | 46 ------------------ .../Quantities/MagneticField.g.cs | 46 ------------------ .../Quantities/MagneticFlux.g.cs | 46 ------------------ .../Quantities/Magnetization.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 46 ------------------ .../Quantities/MassConcentration.g.cs | 46 ------------------ .../GeneratedCode/Quantities/MassFlow.g.cs | 46 ------------------ .../GeneratedCode/Quantities/MassFlux.g.cs | 46 ------------------ .../Quantities/MassFraction.g.cs | 46 ------------------ .../Quantities/MassMomentOfInertia.g.cs | 46 ------------------ .../GeneratedCode/Quantities/MolarEnergy.g.cs | 46 ------------------ .../Quantities/MolarEntropy.g.cs | 46 ------------------ .../GeneratedCode/Quantities/MolarMass.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Molarity.g.cs | 46 ------------------ .../Quantities/Permeability.g.cs | 46 ------------------ .../Quantities/Permittivity.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Power.g.cs | 46 ------------------ .../Quantities/PowerDensity.g.cs | 46 ------------------ .../GeneratedCode/Quantities/PowerRatio.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Pressure.g.cs | 46 ------------------ .../Quantities/PressureChangeRate.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 46 ------------------ .../Quantities/RatioChangeRate.g.cs | 46 ------------------ .../Quantities/ReactiveEnergy.g.cs | 46 ------------------ .../Quantities/ReactivePower.g.cs | 46 ------------------ .../Quantities/ReciprocalArea.g.cs | 46 ------------------ .../Quantities/ReciprocalLength.g.cs | 46 ------------------ .../Quantities/RelativeHumidity.g.cs | 46 ------------------ .../Quantities/RotationalAcceleration.g.cs | 46 ------------------ .../Quantities/RotationalSpeed.g.cs | 46 ------------------ .../Quantities/RotationalStiffness.g.cs | 46 ------------------ .../RotationalStiffnessPerLength.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 46 ------------------ .../GeneratedCode/Quantities/SolidAngle.g.cs | 46 ------------------ .../Quantities/SpecificEnergy.g.cs | 46 ------------------ .../Quantities/SpecificEntropy.g.cs | 46 ------------------ .../Quantities/SpecificFuelConsumption.g.cs | 46 ------------------ .../Quantities/SpecificVolume.g.cs | 46 ------------------ .../Quantities/SpecificWeight.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 46 ------------------ .../Quantities/StandardVolumeFlow.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Temperature.g.cs | 46 ------------------ .../Quantities/TemperatureChangeRate.g.cs | 46 ------------------ .../Quantities/TemperatureDelta.g.cs | 46 ------------------ .../Quantities/ThermalConductivity.g.cs | 46 ------------------ .../Quantities/ThermalResistance.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 46 ------------------ .../Quantities/TorquePerLength.g.cs | 46 ------------------ .../GeneratedCode/Quantities/Turbidity.g.cs | 46 ------------------ .../GeneratedCode/Quantities/VitaminA.g.cs | 46 ------------------ UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 46 ------------------ .../Quantities/VolumeConcentration.g.cs | 46 ------------------ .../GeneratedCode/Quantities/VolumeFlow.g.cs | 46 ------------------ .../Quantities/VolumePerLength.g.cs | 46 ------------------ .../Quantities/VolumetricHeatCapacity.g.cs | 46 ------------------ .../Quantities/WarpingMomentOfInertia.g.cs | 46 ------------------ UnitsNet/IQuantity.cs | 19 -------- 227 files changed, 1457 insertions(+), 6503 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 75d17e48ea..1482176c9f 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -233,18 +233,6 @@ private void GenerateStaticProperties() /// public static {_unitEnumName} ConversionBaseUnit {{ get; }} = {_unitEnumName}.{_quantity.ConversionBaseUnit}; - /// - /// Represents the largest possible value of {_quantity.Name} - /// - [Obsolete(""MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848."")] - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_valueType}.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of {_quantity.Name} - /// - [Obsolete(""MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848."")] - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_valueType}.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the {_quantity.Name} quantity. /// @@ -974,40 +962,6 @@ public string ToString(IFormatProvider? provider) return ToString(""g"", provider); }} - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@""This method is deprecated and will be removed at a future release. Please use ToString(""""s2"""") or ToString(""""s2"""", provider) where 2 is an example of the number passed to significantDigitsAfterRadix."")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - {{ - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - }} - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: ""{{0:0.##}} {{1}} for value and unit abbreviation respectively."" - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(""This method is deprecated and will be removed at a future release. Please use string.Format()."")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - {{ - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - }} - /// /// /// Gets the string representation of this instance in the specified format string using . @@ -1138,7 +1092,7 @@ ulong IConvertible.ToUInt64(IFormatProvider provider) } /// - internal static string? GetObsoleteAttributeOrNull(Quantity quantity) => GetObsoleteAttributeOrNull(quantity.ObsoleteText); + private static string? GetObsoleteAttributeOrNull(Quantity quantity) => GetObsoleteAttributeOrNull(quantity.ObsoleteText); /// internal static string? GetObsoleteAttributeOrNull(Unit unit) => GetObsoleteAttributeOrNull(unit.ObsoleteText); diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 39ad4ce5e8..b0add6c90e 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -517,25 +517,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal(""0.1235{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s4"", culture)); }} - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData(""en-US"")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - }} + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Throws(() => quantity.ToString(null, ""g"", null)); + Assert.Equal(quantity.ToString(""g"", formatProvider), quantity.ToString(null, formatProvider)); }} - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData(""g"")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, ""g""), quantity.ToString(null, ""g"")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); }} [Fact] diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs index f789666e18..7a3f331ce4 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonDeserializationTests.cs @@ -1,8 +1,10 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using System; using Newtonsoft.Json; using UnitsNet.Serialization.JsonNet.Tests.Infrastructure; +using UnitsNet.Units; using Xunit; namespace UnitsNet.Serialization.JsonNet.Tests @@ -10,9 +12,9 @@ namespace UnitsNet.Serialization.JsonNet.Tests public sealed class UnitsNetJsonDeserializationTests : UnitsNetJsonBaseTest { [Fact] - public void Information_CanDeserializeVeryLargeValues() + public void Information_CanDeserializeLargeValue() { - var original = Information.FromExabytes(1E+9); + var original = new Information(decimal.MaxValue, InformationUnit.Exbibyte); var json = SerializeObject(original); var deserialized = DeserializeObject(json); @@ -20,9 +22,10 @@ public void Information_CanDeserializeVeryLargeValues() } [Fact] - public void Information_CanDeserializeMaxValue() + public void Information_CanDeserializeSmallValue() { - var original = Information.MaxValue; + decimal decimalEpsilon = (decimal)(1 / Math.Pow(10, 28)); + var original = new Information(decimalEpsilon, InformationUnit.Bit); var json = SerializeObject(original); var deserialized = DeserializeObject(json); @@ -30,19 +33,9 @@ public void Information_CanDeserializeMaxValue() } [Fact] - public void Information_CanDeserializeMinValue() + public void Length_CanDeserializeLargeValue() { - var original = Information.MinValue; - var json = SerializeObject(original); - var deserialized = DeserializeObject(json); - - Assert.Equal(original, deserialized); - } - - [Fact] - public void Length_CanDeserializeMaxValue() - { - var original = Length.MaxValue; + var original = new Length(double.MaxValue, LengthUnit.MegalightYear); var json = SerializeObject(original); var deserialized = DeserializeObject(json); @@ -50,9 +43,9 @@ public void Length_CanDeserializeMaxValue() } [Fact] - public void Length_CanDeserializeMinValue() + public void Length_CanDeserializeSmallValue() { - var original = Length.MinValue; + var original = new Length(double.Epsilon, LengthUnit.Nanometer); var json = SerializeObject(original); var deserialized = DeserializeObject(json); diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs index a65933ef4b..dc0dbfd879 100644 --- a/UnitsNet.Tests/CustomCode/InformationTests.cs +++ b/UnitsNet.Tests/CustomCode/InformationTests.cs @@ -61,23 +61,10 @@ public class InformationTests : InformationTestsBase protected override double TerabytesInOneBit => 0.125d*1e-12d; -// ReSharper disable once InconsistentNaming [Fact] public void OneKBHas1000Bytes() { Assert.Equal(1000, Information.FromKilobytes(1).Bytes); } - - [Fact] - public void MaxValueIsCorrectForUnitWithBaseTypeDecimal() - { - Assert.Equal((double) decimal.MaxValue, Information.MaxValue.Bits); - } - - [Fact] - public void MinValueIsCorrectForUnitWithBaseTypeDecimal() - { - Assert.Equal((double) decimal.MinValue, Information.MinValue.Bits); - } } } diff --git a/UnitsNet.Tests/CustomCode/LengthTests.cs b/UnitsNet.Tests/CustomCode/LengthTests.cs index cf340ecf0f..46b3b5c172 100644 --- a/UnitsNet.Tests/CustomCode/LengthTests.cs +++ b/UnitsNet.Tests/CustomCode/LengthTests.cs @@ -148,18 +148,6 @@ public void ToStringReturnsCorrectNumberAndUnitWithCentimeterAsDefualtUnit() Assert.Equal("2 cm", valueString); } - [Fact] - public void MaxValueIsCorrectForUnitWithBaseTypeDouble() - { - Assert.Equal(double.MaxValue, Length.MaxValue.Meters); - } - - [Fact] - public void MinValueIsCorrectForUnitWithBaseTypeDouble() - { - Assert.Equal(double.MinValue, Length.MinValue.Meters); - } - [Fact] public void NegativeLengthToStonePoundsReturnsCorrectValues() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index fc7280dca0..785d7fcd78 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -578,25 +578,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index af3236f364..1e55b712d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -593,25 +593,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 08c70ed5db..85756bfe05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -432,25 +432,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 29eedf4ddd..4c7d20b2b4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -608,25 +608,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 °", new Angle(0.123456, AngleUnit.Degree).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Angle.FromDegrees(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Angle.FromDegrees(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Angle.FromDegrees(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 75b85cffe1..41c449540f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 3776c80d92..a820b50e63 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 0057a1229a..ac43f40d9b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index d91c815442..b2051230df 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -458,25 +458,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index c2ebd9b8e0..20e3949732 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -578,25 +578,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Area.FromSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Area.FromSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index f1f81615f5..939f4e3bc5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -733,25 +733,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 765014dc66..08e94d548e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 297e49f301..3d1af028f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -473,25 +473,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Capacitance.FromFarads(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Capacitance.FromFarads(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index d329a95f13..0eb864e00c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 38629c6c54..3abfc1710a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -968,25 +968,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 0e8bbcb5e2..439dc745f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -518,25 +518,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 s", new Duration(0.123456, DurationUnit.Second).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Duration.FromSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Duration.FromSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 77eed0299f..846e7e3c7a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -518,25 +518,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 7c8a58bf23..d2e9826106 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 839013f337..36bbff3e78 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 7ad3626bfc..1b59ca70cd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -443,25 +443,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 027e5d0ef6..7ae1c31a27 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 42dba0cd92..84721aa76f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 05e79c2dc5..1fe5894a6a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 89315e95a5..8b9bdf9d2c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 9988854013..44b4e52759 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -488,25 +488,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index d074423c24..7ee40a5ca5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index fd533cc716..3fd960b1ba 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 1f01ede974..6d6f4a2c45 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -443,25 +443,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index cc6cf45b2b..94f5c21041 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -668,25 +668,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 586c08fd61..7b8f47878d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -443,25 +443,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index b65983c626..513c92b312 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -443,25 +443,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 1c1bbe7782..3d4bd25db1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -458,25 +458,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index f090b02b1e..80568a95d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -578,25 +578,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 48f4a87664..3e6305db87 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index ee3b77473c..aa5e5dc369 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -908,25 +908,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Energy.FromJoules(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Energy.FromJoules(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Energy.FromJoules(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 3602402663..c0f05da54c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -473,25 +473,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 879d1597c7..70fc828bf3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -593,25 +593,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 3f6f7b2fe4..253d0b0fee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -938,25 +938,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index aa52a70cb5..fb766bfbf9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -593,25 +593,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N", new Force(0.123456, ForceUnit.Newton).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Force.FromNewtons(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Force.FromNewtons(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Force.FromNewtons(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 8f3f7dd060..da3f6fb796 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -533,25 +533,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Frequency.FromHertz(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Frequency.FromHertz(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 070a13ac17..93e4f93326 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index b9782540c0..d4d28657e3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -638,25 +638,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index a47591fbee..49d12ad2b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 2019628632..c785c41c56 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Illuminance.FromLux(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Illuminance.FromLux(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index d8af813a79..3224cbc885 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -733,25 +733,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 b", new Information(0.123456m, InformationUnit.Bit).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Information.FromBits(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Information.FromBits(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Information.FromBits(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index b26f71b7b2..f8a22db31b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -578,25 +578,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 28e791cbd4..aef1602c48 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -473,25 +473,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 12c0b2b9e7..2ccac0ef36 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -503,25 +503,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 9b45fb831f..10cf24b231 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 2259dac807..78106ebec9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -863,25 +863,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m", new Length(0.123456, LengthUnit.Meter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Length.FromMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Length.FromMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Length.FromMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 282156b608..5e76d2d6f6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -402,25 +402,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Level.FromDecibels(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Level.FromDecibels(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Level.FromDecibels(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 4ec8965641..1b9dbe2f65 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -578,25 +578,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index bb277d84a6..f3a6d4b1c4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -743,25 +743,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 9dc6bc45a1..c2332cf734 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -578,25 +578,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Luminosity.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Luminosity.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 98f2e4eb29..c1ace699e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 7d1fd10a74..951a888f8c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 79e3ec59c5..efe8a3f49e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -458,25 +458,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MagneticField.FromTeslas(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 114d51a3af..fc18de119c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 5624542aee..c75b066faf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index c77ca6493f..89dc1516bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -1103,25 +1103,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 69e9b6373f..c533cb888f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -863,25 +863,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 78740e43ec..271bf17c9e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -548,25 +548,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 824329f958..5965c840af 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -728,25 +728,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 003a0969a6..373e2144a2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -788,25 +788,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 5ef9da9318..739c240a7d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -743,25 +743,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Mass.FromKilograms(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Mass.FromKilograms(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 7470c588f9..874800b4fb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 94224482a0..7c35ede5f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index f12e266275..51721566b3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -548,25 +548,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 32fd869928..83b3cfe8c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -488,25 +488,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index b74761f202..12f9166f05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 7a7f4558d3..d933af45b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 4a85cb7e8f..bad58879a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -1028,25 +1028,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 39bc6da04b..16d4b63087 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -402,25 +402,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 6b892e621b..3b32aa4b3b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -718,25 +718,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W", new Power(0.123456m, PowerUnit.Watt).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Power.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Power.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Power.FromWatts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 63218f597c..c640cee461 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -563,25 +563,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 31e25a1177..f84c1a7b9a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -1028,25 +1028,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Pressure.FromPascals(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Pressure.FromPascals(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 9b130d7f2f..b21a1b97ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -398,25 +398,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 5b1b39beb3..8609416e57 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -458,25 +458,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 49ffecf81c..38d1231226 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index ffd88e403b..4a019734ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 7cc2e2e96d..02d1499565 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -533,25 +533,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index a017e73fd0..1812cb860a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -518,25 +518,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index e53a0c6950..fc9864128a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 0d92d40b7d..92919d264d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 07829e7b4c..7e9725c885 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -563,25 +563,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index edda3cb83f..d4dd9164e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -443,25 +443,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 998559d2e8..3a5d7285d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -863,25 +863,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 776b02ab7e..210bd6997d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new Scalar(0.123456, ScalarUnit.Amount).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Scalar.FromAmount(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Scalar.FromAmount(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 6c3ad74af0..70759b2b4a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 1782410f10..53233324b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -743,25 +743,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index e6adaccba8..2f9b2057c3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -503,25 +503,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 69d1466b62..70a65d0cec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -428,25 +428,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index b27d6f9444..7514a63b05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -413,25 +413,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 73bfdf2582..b7d52b475c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -623,25 +623,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index c2a020dc7f..9ca11ca2be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -848,25 +848,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index fcdd7de773..dabbf55413 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -503,25 +503,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 8581fc13a4..940f6bb351 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -518,25 +518,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 343bfb216b..e4c8850880 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -503,25 +503,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 433e00866b..ec973e4061 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -506,25 +506,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Temperature.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Temperature.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index b1f08883bc..730effa3c8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -398,25 +398,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 14200f924a..d8a9e3c25c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -443,25 +443,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 11ea0c65d3..c1377310d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -683,25 +683,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 8346b7e599..1a3655b5db 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -698,25 +698,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index fbd48bb9f7..5e60dbfe9f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Turbidity.FromNTU(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Turbidity.FromNTU(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 05b124620d..badabc07a4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -383,25 +383,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 21770de6e5..6c0a7a35fb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -668,25 +668,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index f438755e4c..5680b07a0d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -1208,25 +1208,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 6b688a72a8..08b6c027b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -473,25 +473,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 23f0dac504..fb1f562150 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -1133,25 +1133,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Volume.FromCubicMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 8aa7798217..297abef5e3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -503,25 +503,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index b205d4630f..d523ad9be2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -458,25 +458,26 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s4", culture)); } - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentUICulture(string format) { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 82bd29a1d1..129e288835 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -47,7 +47,7 @@ public void ByName_GivenLength_ReturnsQuantityInfoForLength() { QuantityInfo quantityInfo = Quantity.ByName["Length"]; Assert.Equal("Length", quantityInfo.Name); - Assert.Same(Length.Info, quantityInfo.Name); + Assert.Same(Length.Info, quantityInfo); } [Fact] @@ -55,7 +55,7 @@ public void ByName_GivenMass_ReturnsQuantityInfoForMass() { QuantityInfo quantityInfo = Quantity.ByName["Mass"]; Assert.Equal("Mass", quantityInfo.Name); - Assert.Same(Mass.Info, quantityInfo.Name); + Assert.Same(Mass.Info, quantityInfo); } [Fact] diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 6c228e6f3d..7cfc7fee2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -122,18 +122,6 @@ public Acceleration(double value, UnitSystem unitSystem) /// public static AccelerationUnit ConversionBaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; - /// - /// Represents the largest possible value of Acceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Acceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Acceleration quantity. /// @@ -908,40 +896,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 49eb24c5ba..57ec963dcf 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -123,18 +123,6 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// public static AmountOfSubstanceUnit ConversionBaseUnit { get; } = AmountOfSubstanceUnit.Mole; - /// - /// Represents the largest possible value of AmountOfSubstance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of AmountOfSubstance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the AmountOfSubstance quantity. /// @@ -925,40 +913,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index f681673404..71cedf32c0 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -112,18 +112,6 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// public static AmplitudeRatioUnit ConversionBaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; - /// - /// Represents the largest possible value of AmplitudeRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of AmplitudeRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the AmplitudeRatio quantity. /// @@ -746,40 +734,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 54b9740139..168a677fe6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -124,18 +124,6 @@ public Angle(double value, UnitSystem unitSystem) /// public static AngleUnit ConversionBaseUnit { get; } = AngleUnit.Degree; - /// - /// Represents the largest possible value of Angle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Angle MaxValue { get; } = new Angle(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Angle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Angle MinValue { get; } = new Angle(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Angle quantity. /// @@ -942,40 +930,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 6eb19413be..e039aea5da 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -111,18 +111,6 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// public static ApparentEnergyUnit ConversionBaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; - /// - /// Represents the largest possible value of ApparentEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ApparentEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ApparentEnergy quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index b0808f9735..25ccf76d26 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -112,18 +112,6 @@ public ApparentPower(double value, UnitSystem unitSystem) /// public static ApparentPowerUnit ConversionBaseUnit { get; } = ApparentPowerUnit.Voltampere; - /// - /// Represents the largest possible value of ApparentPower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ApparentPower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ApparentPower quantity. /// @@ -738,40 +726,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 1df64259f9..f0e7d9dd2f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -122,18 +122,6 @@ public Area(double value, UnitSystem unitSystem) /// public static AreaUnit ConversionBaseUnit { get; } = AreaUnit.SquareMeter; - /// - /// Represents the largest possible value of Area - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Area MaxValue { get; } = new Area(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Area - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Area MinValue { get; } = new Area(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Area quantity. /// @@ -908,40 +896,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 377cb6dcf8..7e481b11cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -109,18 +109,6 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public static AreaDensityUnit ConversionBaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; - /// - /// Represents the largest possible value of AreaDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of AreaDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the AreaDensity quantity. /// @@ -687,40 +675,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 05bf3f6f81..15b5fddc60 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -114,18 +114,6 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// public static AreaMomentOfInertiaUnit ConversionBaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; - /// - /// Represents the largest possible value of AreaMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of AreaMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the AreaMomentOfInertia quantity. /// @@ -772,40 +760,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 4bc458f27c..be61335338 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -137,18 +137,6 @@ public BitRate(decimal value, UnitSystem unitSystem) /// public static BitRateUnit ConversionBaseUnit { get; } = BitRateUnit.BitPerSecond; - /// - /// Represents the largest possible value of BitRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BitRate MaxValue { get; } = new BitRate(decimal.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of BitRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BitRate MinValue { get; } = new BitRate(decimal.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the BitRate quantity. /// @@ -1120,40 +1108,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index c61a75f3a0..4de5c6d691 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -111,18 +111,6 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// public static BrakeSpecificFuelConsumptionUnit ConversionBaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; - /// - /// Represents the largest possible value of BrakeSpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of BrakeSpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the BrakeSpecificFuelConsumption quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 57370ce801..c573f46ca6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -118,18 +118,6 @@ public Capacitance(double value, UnitSystem unitSystem) /// public static CapacitanceUnit ConversionBaseUnit { get; } = CapacitanceUnit.Farad; - /// - /// Represents the largest possible value of Capacitance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Capacitance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Capacitance quantity. /// @@ -792,40 +780,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index f8d7899350..4fab9691ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -111,18 +111,6 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// public static CoefficientOfThermalExpansionUnit ConversionBaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; - /// - /// Represents the largest possible value of CoefficientOfThermalExpansion - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of CoefficientOfThermalExpansion - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the CoefficientOfThermalExpansion quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 2735994c0e..b3d62099c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -151,18 +151,6 @@ public Density(double value, UnitSystem unitSystem) /// public static DensityUnit ConversionBaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; - /// - /// Represents the largest possible value of Density - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Density MaxValue { get; } = new Density(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Density - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Density MinValue { get; } = new Density(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Density quantity. /// @@ -1353,40 +1341,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 3630845b9e..2222adbece 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -118,18 +118,6 @@ public Duration(double value, UnitSystem unitSystem) /// public static DurationUnit ConversionBaseUnit { get; } = DurationUnit.Second; - /// - /// Represents the largest possible value of Duration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Duration MaxValue { get; } = new Duration(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Duration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Duration MinValue { get; } = new Duration(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Duration quantity. /// @@ -840,40 +828,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 1dce91357e..a5c112e0db 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -121,18 +121,6 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// public static DynamicViscosityUnit ConversionBaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; - /// - /// Represents the largest possible value of DynamicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of DynamicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the DynamicViscosity quantity. /// @@ -843,40 +831,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 22940a65d8..bbaab5fa72 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -112,18 +112,6 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// public static ElectricAdmittanceUnit ConversionBaseUnit { get; } = ElectricAdmittanceUnit.Siemens; - /// - /// Represents the largest possible value of ElectricAdmittance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricAdmittance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricAdmittance quantity. /// @@ -738,40 +726,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 2c76c8244b..c8ac40b86b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -116,18 +116,6 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// public static ElectricChargeUnit ConversionBaseUnit { get; } = ElectricChargeUnit.Coulomb; - /// - /// Represents the largest possible value of ElectricCharge - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricCharge - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricCharge quantity. /// @@ -758,40 +746,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index d842e21b6f..13905cac40 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -112,18 +112,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// public static ElectricChargeDensityUnit ConversionBaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; - /// - /// Represents the largest possible value of ElectricChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricChargeDensity quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 7b4b4cd136..250a46af61 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -114,18 +114,6 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// public static ElectricConductanceUnit ConversionBaseUnit { get; } = ElectricConductanceUnit.Siemens; - /// - /// Represents the largest possible value of ElectricConductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricConductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricConductance quantity. /// @@ -724,40 +712,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index b5f7b23437..04ceacc1e3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -114,18 +114,6 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// public static ElectricConductivityUnit ConversionBaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; - /// - /// Represents the largest possible value of ElectricConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricConductivity quantity. /// @@ -724,40 +712,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index cefa2e07d4..b46691e1e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -116,18 +116,6 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// public static ElectricCurrentUnit ConversionBaseUnit { get; } = ElectricCurrentUnit.Ampere; - /// - /// Represents the largest possible value of ElectricCurrent - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricCurrent - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricCurrent quantity. /// @@ -806,40 +794,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 64e067d65f..40b737bd77 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -114,18 +114,6 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// public static ElectricCurrentDensityUnit ConversionBaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; - /// - /// Represents the largest possible value of ElectricCurrentDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricCurrentDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricCurrentDensity quantity. /// @@ -724,40 +712,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index f317d5cf44..76ee5c5d55 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -112,18 +112,6 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// public static ElectricCurrentGradientUnit ConversionBaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; - /// - /// Represents the largest possible value of ElectricCurrentGradient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricCurrentGradient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricCurrentGradient quantity. /// @@ -738,40 +726,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index e982c06306..a0b4cb7aae 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -112,18 +112,6 @@ public ElectricField(double value, UnitSystem unitSystem) /// public static ElectricFieldUnit ConversionBaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; - /// - /// Represents the largest possible value of ElectricField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricField quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 36d3c62a31..3039ebb532 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -115,18 +115,6 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// public static ElectricInductanceUnit ConversionBaseUnit { get; } = ElectricInductanceUnit.Henry; - /// - /// Represents the largest possible value of ElectricInductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricInductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricInductance quantity. /// @@ -741,40 +729,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 5272f87f64..7344bd581d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -113,18 +113,6 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// public static ElectricPotentialUnit ConversionBaseUnit { get; } = ElectricPotentialUnit.Volt; - /// - /// Represents the largest possible value of ElectricPotential - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotential - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricPotential quantity. /// @@ -755,40 +743,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 8b21fed4ed..ef01f507ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -113,18 +113,6 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// public static ElectricPotentialAcUnit ConversionBaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; - /// - /// Represents the largest possible value of ElectricPotentialAc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotentialAc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricPotentialAc quantity. /// @@ -755,40 +743,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index b8d26d52d5..7d0e9a27c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -128,18 +128,6 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// public static ElectricPotentialChangeRateUnit ConversionBaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; - /// - /// Represents the largest possible value of ElectricPotentialChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotentialChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricPotentialChangeRate quantity. /// @@ -1010,40 +998,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index d99cbca13d..d69888140d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -113,18 +113,6 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// public static ElectricPotentialDcUnit ConversionBaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; - /// - /// Represents the largest possible value of ElectricPotentialDc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricPotentialDc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricPotentialDc quantity. /// @@ -755,40 +743,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index de83f98590..59add3c0aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -114,18 +114,6 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// public static ElectricResistanceUnit ConversionBaseUnit { get; } = ElectricResistanceUnit.Ohm; - /// - /// Represents the largest possible value of ElectricResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricResistance quantity. /// @@ -772,40 +760,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 1be903d4f9..79b22e9784 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -125,18 +125,6 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// public static ElectricResistivityUnit ConversionBaseUnit { get; } = ElectricResistivityUnit.OhmMeter; - /// - /// Represents the largest possible value of ElectricResistivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricResistivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricResistivity quantity. /// @@ -911,40 +899,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index d0b612d5de..9d5f8ada1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -114,18 +114,6 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// public static ElectricSurfaceChargeDensityUnit ConversionBaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; - /// - /// Represents the largest possible value of ElectricSurfaceChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ElectricSurfaceChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ElectricSurfaceChargeDensity quantity. /// @@ -724,40 +712,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 0c8851fab2..462097d530 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -144,18 +144,6 @@ public Energy(double value, UnitSystem unitSystem) /// public static EnergyUnit ConversionBaseUnit { get; } = EnergyUnit.Joule; - /// - /// Represents the largest possible value of Energy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Energy MaxValue { get; } = new Energy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Energy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Energy MinValue { get; } = new Energy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Energy quantity. /// @@ -1282,40 +1270,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 23d52fcf63..417979791d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -115,18 +115,6 @@ public Entropy(double value, UnitSystem unitSystem) /// public static EntropyUnit ConversionBaseUnit { get; } = EntropyUnit.JoulePerKelvin; - /// - /// Represents the largest possible value of Entropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Entropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Entropy MinValue { get; } = new Entropy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Entropy quantity. /// @@ -789,40 +777,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 3f781bc20a..41ee454cf4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -123,18 +123,6 @@ public Force(double value, UnitSystem unitSystem) /// public static ForceUnit ConversionBaseUnit { get; } = ForceUnit.Newton; - /// - /// Represents the largest possible value of Force - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Force MaxValue { get; } = new Force(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Force - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Force MinValue { get; } = new Force(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Force quantity. /// @@ -925,40 +913,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 7df7ed7389..699bb8c30f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -123,18 +123,6 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// public static ForceChangeRateUnit ConversionBaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; - /// - /// Represents the largest possible value of ForceChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ForceChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ForceChangeRate quantity. /// @@ -925,40 +913,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 1deb899115..b18b63198a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -146,18 +146,6 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// public static ForcePerLengthUnit ConversionBaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; - /// - /// Represents the largest possible value of ForcePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ForcePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ForcePerLength quantity. /// @@ -1316,40 +1304,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 696bbd145d..07d0e7b347 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -119,18 +119,6 @@ public Frequency(double value, UnitSystem unitSystem) /// public static FrequencyUnit ConversionBaseUnit { get; } = FrequencyUnit.Hertz; - /// - /// Represents the largest possible value of Frequency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Frequency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Frequency MinValue { get; } = new Frequency(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Frequency quantity. /// @@ -857,40 +845,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 2d92357c77..a024464310 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -115,18 +115,6 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// public static FuelEfficiencyUnit ConversionBaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; - /// - /// Represents the largest possible value of FuelEfficiency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of FuelEfficiency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the FuelEfficiency quantity. /// @@ -741,40 +729,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 9095a143a3..fb71bd7a5c 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -126,18 +126,6 @@ public HeatFlux(double value, UnitSystem unitSystem) /// public static HeatFluxUnit ConversionBaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; - /// - /// Represents the largest possible value of HeatFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of HeatFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the HeatFlux quantity. /// @@ -976,40 +964,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index fb9dade625..6f27a4a90b 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -111,18 +111,6 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// public static HeatTransferCoefficientUnit ConversionBaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; - /// - /// Represents the largest possible value of HeatTransferCoefficient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of HeatTransferCoefficient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the HeatTransferCoefficient quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 19f5c85343..90e5d79d98 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -115,18 +115,6 @@ public Illuminance(double value, UnitSystem unitSystem) /// public static IlluminanceUnit ConversionBaseUnit { get; } = IlluminanceUnit.Lux; - /// - /// Represents the largest possible value of Illuminance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Illuminance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Illuminance quantity. /// @@ -741,40 +729,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 21f5ee75a2..79a014ac96 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -134,18 +134,6 @@ public Information(decimal value, UnitSystem unitSystem) /// public static InformationUnit ConversionBaseUnit { get; } = InformationUnit.Bit; - /// - /// Represents the largest possible value of Information - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Information MaxValue { get; } = new Information(decimal.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Information - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Information MinValue { get; } = new Information(decimal.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Information quantity. /// @@ -1117,40 +1105,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 67b1cccd96..ab24151d25 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -122,18 +122,6 @@ public Irradiance(double value, UnitSystem unitSystem) /// public static IrradianceUnit ConversionBaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; - /// - /// Represents the largest possible value of Irradiance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Irradiance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Irradiance quantity. /// @@ -908,40 +896,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 622868f081..309296a386 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -118,18 +118,6 @@ public Irradiation(double value, UnitSystem unitSystem) /// public static IrradiationUnit ConversionBaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; - /// - /// Represents the largest possible value of Irradiation - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Irradiation - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Irradiation quantity. /// @@ -792,40 +780,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 308b1e615c..1019ec6a9a 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -120,18 +120,6 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// public static KinematicViscosityUnit ConversionBaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; - /// - /// Represents the largest possible value of KinematicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of KinematicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the KinematicViscosity quantity. /// @@ -826,40 +814,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 6a78e3fb82..2f3b21f4ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -109,18 +109,6 @@ public LapseRate(double value, UnitSystem unitSystem) /// public static LapseRateUnit ConversionBaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; - /// - /// Represents the largest possible value of LapseRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of LapseRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the LapseRate quantity. /// @@ -687,40 +675,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index f328ab22ed..cb2548da43 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -141,18 +141,6 @@ public Length(double value, UnitSystem unitSystem) /// public static LengthUnit ConversionBaseUnit { get; } = LengthUnit.Meter; - /// - /// Represents the largest possible value of Length - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Length MaxValue { get; } = new Length(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Length - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Length MinValue { get; } = new Length(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Length quantity. /// @@ -1231,40 +1219,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 958e9fde58..54739274e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -110,18 +110,6 @@ public Level(double value, UnitSystem unitSystem) /// public static LevelUnit ConversionBaseUnit { get; } = LevelUnit.Decibel; - /// - /// Represents the largest possible value of Level - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Level MaxValue { get; } = new Level(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Level - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Level MinValue { get; } = new Level(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Level quantity. /// @@ -712,40 +700,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index af54ca335e..455ea0e52d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -125,18 +125,6 @@ public LinearDensity(double value, UnitSystem unitSystem) /// public static LinearDensityUnit ConversionBaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; - /// - /// Represents the largest possible value of LinearDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of LinearDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the LinearDensity quantity. /// @@ -911,40 +899,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 819e7e4932..7ac344bdcf 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -136,18 +136,6 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// public static LinearPowerDensityUnit ConversionBaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; - /// - /// Represents the largest possible value of LinearPowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of LinearPowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the LinearPowerDensity quantity. /// @@ -1098,40 +1086,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 848d9099d0..d5fe855983 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -125,18 +125,6 @@ public Luminosity(double value, UnitSystem unitSystem) /// public static LuminosityUnit ConversionBaseUnit { get; } = LuminosityUnit.Watt; - /// - /// Represents the largest possible value of Luminosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Luminosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Luminosity quantity. /// @@ -911,40 +899,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index ab99cd168d..486f8f5f1a 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -112,18 +112,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// public static LuminousFluxUnit ConversionBaseUnit { get; } = LuminousFluxUnit.Lumen; - /// - /// Represents the largest possible value of LuminousFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of LuminousFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the LuminousFlux quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 015111d2d7..82a4d2fc24 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -112,18 +112,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// public static LuminousIntensityUnit ConversionBaseUnit { get; } = LuminousIntensityUnit.Candela; - /// - /// Represents the largest possible value of LuminousIntensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of LuminousIntensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the LuminousIntensity quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 58621ec89b..00a32fb36f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -117,18 +117,6 @@ public MagneticField(double value, UnitSystem unitSystem) /// public static MagneticFieldUnit ConversionBaseUnit { get; } = MagneticFieldUnit.Tesla; - /// - /// Represents the largest possible value of MagneticField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MagneticField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MagneticField quantity. /// @@ -775,40 +763,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index b075a1e27f..bf1f8a6bb4 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -112,18 +112,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// public static MagneticFluxUnit ConversionBaseUnit { get; } = MagneticFluxUnit.Weber; - /// - /// Represents the largest possible value of MagneticFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MagneticFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MagneticFlux quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index a955b3f65f..2d38e009c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -112,18 +112,6 @@ public Magnetization(double value, UnitSystem unitSystem) /// public static MagnetizationUnit ConversionBaseUnit { get; } = MagnetizationUnit.AmperePerMeter; - /// - /// Represents the largest possible value of Magnetization - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Magnetization - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Magnetization quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 0873c1a4b8..104e912d42 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -133,18 +133,6 @@ public Mass(double value, UnitSystem unitSystem) /// public static MassUnit ConversionBaseUnit { get; } = MassUnit.Kilogram; - /// - /// Represents the largest possible value of Mass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Mass MaxValue { get; } = new Mass(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Mass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Mass MinValue { get; } = new Mass(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Mass quantity. /// @@ -1095,40 +1083,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index c20d1e09c9..2b03ebae71 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -160,18 +160,6 @@ public MassConcentration(double value, UnitSystem unitSystem) /// public static MassConcentrationUnit ConversionBaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; - /// - /// Represents the largest possible value of MassConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MassConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MassConcentration quantity. /// @@ -1506,40 +1494,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 7fa8858797..eed63e6499 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -141,18 +141,6 @@ public MassFlow(double value, UnitSystem unitSystem) /// public static MassFlowUnit ConversionBaseUnit { get; } = MassFlowUnit.GramPerSecond; - /// - /// Represents the largest possible value of MassFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MassFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MassFlow quantity. /// @@ -1231,40 +1219,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index d4124d3f78..2ed309f8fd 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -120,18 +120,6 @@ public MassFlux(double value, UnitSystem unitSystem) /// public static MassFluxUnit ConversionBaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; - /// - /// Represents the largest possible value of MassFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MassFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MassFlux quantity. /// @@ -874,40 +862,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index d81dfed06b..332e9c675c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -135,18 +135,6 @@ public MassFraction(double value, UnitSystem unitSystem) /// public static MassFractionUnit ConversionBaseUnit { get; } = MassFractionUnit.DecimalFraction; - /// - /// Represents the largest possible value of MassFraction - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MassFraction - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MassFraction quantity. /// @@ -1081,40 +1069,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 526b0f3cb0..6765e45ef0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -136,18 +136,6 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// public static MassMomentOfInertiaUnit ConversionBaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; - /// - /// Represents the largest possible value of MassMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MassMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MassMomentOfInertia quantity. /// @@ -1146,40 +1134,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 51b4b0c41b..385f077e48 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -111,18 +111,6 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// public static MolarEnergyUnit ConversionBaseUnit { get; } = MolarEnergyUnit.JoulePerMole; - /// - /// Represents the largest possible value of MolarEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MolarEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MolarEnergy quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 3725b9da9f..7727cac3a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -111,18 +111,6 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// public static MolarEntropyUnit ConversionBaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; - /// - /// Represents the largest possible value of MolarEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MolarEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MolarEntropy quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 1fc9c12970..58880a66e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -120,18 +120,6 @@ public MolarMass(double value, UnitSystem unitSystem) /// public static MolarMassUnit ConversionBaseUnit { get; } = MolarMassUnit.KilogramPerMole; - /// - /// Represents the largest possible value of MolarMass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of MolarMass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the MolarMass quantity. /// @@ -874,40 +862,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 1dad094b5a..ebc4fe2150 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -119,18 +119,6 @@ public Molarity(double value, UnitSystem unitSystem) /// public static MolarityUnit ConversionBaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; - /// - /// Represents the largest possible value of Molarity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Molarity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Molarity MinValue { get; } = new Molarity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Molarity quantity. /// @@ -809,40 +797,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index faf0a1ea2f..e3b48fb1ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -112,18 +112,6 @@ public Permeability(double value, UnitSystem unitSystem) /// public static PermeabilityUnit ConversionBaseUnit { get; } = PermeabilityUnit.HenryPerMeter; - /// - /// Represents the largest possible value of Permeability - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Permeability - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permeability MinValue { get; } = new Permeability(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Permeability quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 3fa6da8405..eaf83812e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -112,18 +112,6 @@ public Permittivity(double value, UnitSystem unitSystem) /// public static PermittivityUnit ConversionBaseUnit { get; } = PermittivityUnit.FaradPerMeter; - /// - /// Represents the largest possible value of Permittivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Permittivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Permittivity quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index ed3eabcd22..7fb13b7b4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -133,18 +133,6 @@ public Power(decimal value, UnitSystem unitSystem) /// public static PowerUnit ConversionBaseUnit { get; } = PowerUnit.Watt; - /// - /// Represents the largest possible value of Power - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Power MaxValue { get; } = new Power(decimal.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Power - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Power MinValue { get; } = new Power(decimal.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Power quantity. /// @@ -1100,40 +1088,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 4cfcedb9d5..8889e8c8ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -152,18 +152,6 @@ public PowerDensity(double value, UnitSystem unitSystem) /// public static PowerDensityUnit ConversionBaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; - /// - /// Represents the largest possible value of PowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of PowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the PowerDensity quantity. /// @@ -1418,40 +1406,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 793c89fbc7..3cf66c2188 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -110,18 +110,6 @@ public PowerRatio(double value, UnitSystem unitSystem) /// public static PowerRatioUnit ConversionBaseUnit { get; } = PowerRatioUnit.DecibelWatt; - /// - /// Represents the largest possible value of PowerRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of PowerRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the PowerRatio quantity. /// @@ -712,40 +700,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index bd09108ce8..8c63de053a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -152,18 +152,6 @@ public Pressure(double value, UnitSystem unitSystem) /// public static PressureUnit ConversionBaseUnit { get; } = PressureUnit.Pascal; - /// - /// Represents the largest possible value of Pressure - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Pressure - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Pressure MinValue { get; } = new Pressure(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Pressure quantity. /// @@ -1418,40 +1406,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 31ca12a2b4..9ce6958f01 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -121,18 +121,6 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// public static PressureChangeRateUnit ConversionBaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; - /// - /// Represents the largest possible value of PressureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of PressureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the PressureChangeRate quantity. /// @@ -891,40 +879,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index a3692f89cc..9a2fc380af 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -114,18 +114,6 @@ public Ratio(double value, UnitSystem unitSystem) /// public static RatioUnit ConversionBaseUnit { get; } = RatioUnit.DecimalFraction; - /// - /// Represents the largest possible value of Ratio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Ratio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Ratio MinValue { get; } = new Ratio(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Ratio quantity. /// @@ -772,40 +760,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index b8e9f12459..73d6984cbb 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -110,18 +110,6 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// public static RatioChangeRateUnit ConversionBaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; - /// - /// Represents the largest possible value of RatioChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of RatioChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the RatioChangeRate quantity. /// @@ -704,40 +692,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 324156dba8..ba8314b336 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -111,18 +111,6 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// public static ReactiveEnergyUnit ConversionBaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; - /// - /// Represents the largest possible value of ReactiveEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ReactiveEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ReactiveEnergy quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 274c554d16..133986f128 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -112,18 +112,6 @@ public ReactivePower(double value, UnitSystem unitSystem) /// public static ReactivePowerUnit ConversionBaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; - /// - /// Represents the largest possible value of ReactivePower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ReactivePower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ReactivePower quantity. /// @@ -738,40 +726,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 3c471ee4ed..1952669116 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -122,18 +122,6 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// public static ReciprocalAreaUnit ConversionBaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; - /// - /// Represents the largest possible value of ReciprocalArea - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ReciprocalArea - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ReciprocalArea quantity. /// @@ -860,40 +848,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index c98ca524e2..7824664c8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -121,18 +121,6 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// public static ReciprocalLengthUnit ConversionBaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; - /// - /// Represents the largest possible value of ReciprocalLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ReciprocalLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ReciprocalLength quantity. /// @@ -843,40 +831,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 4d69fc2be8..8df2922d6e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -109,18 +109,6 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// public static RelativeHumidityUnit ConversionBaseUnit { get; } = RelativeHumidityUnit.Percent; - /// - /// Represents the largest possible value of RelativeHumidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of RelativeHumidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the RelativeHumidity quantity. /// @@ -687,40 +675,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 2af81fe71d..cee1f0ab27 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -112,18 +112,6 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// public static RotationalAccelerationUnit ConversionBaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; - /// - /// Represents the largest possible value of RotationalAcceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of RotationalAcceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the RotationalAcceleration quantity. /// @@ -738,40 +726,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 3ac652035f..bbfcc3bc99 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -121,18 +121,6 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// public static RotationalSpeedUnit ConversionBaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; - /// - /// Represents the largest possible value of RotationalSpeed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of RotationalSpeed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the RotationalSpeed quantity. /// @@ -891,40 +879,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index aa4aaa44e3..69463076d6 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -141,18 +141,6 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// public static RotationalStiffnessUnit ConversionBaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; - /// - /// Represents the largest possible value of RotationalStiffness - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of RotationalStiffness - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the RotationalStiffness quantity. /// @@ -1231,40 +1219,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 41dddd51b2..741eaf8cdf 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -113,18 +113,6 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// public static RotationalStiffnessPerLengthUnit ConversionBaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; - /// - /// Represents the largest possible value of RotationalStiffnessPerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of RotationalStiffnessPerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the RotationalStiffnessPerLength quantity. /// @@ -755,40 +743,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index d3700bfded..ccb04e35f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -109,18 +109,6 @@ public Scalar(double value, UnitSystem unitSystem) /// public static ScalarUnit ConversionBaseUnit { get; } = ScalarUnit.Amount; - /// - /// Represents the largest possible value of Scalar - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Scalar - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Scalar MinValue { get; } = new Scalar(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Scalar quantity. /// @@ -687,40 +675,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 00a30ddfb0..59c2e93460 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -112,18 +112,6 @@ public SolidAngle(double value, UnitSystem unitSystem) /// public static SolidAngleUnit ConversionBaseUnit { get; } = SolidAngleUnit.Steradian; - /// - /// Represents the largest possible value of SolidAngle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of SolidAngle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the SolidAngle quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 8714ae99fc..1c0431aaa4 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -136,18 +136,6 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// public static SpecificEnergyUnit ConversionBaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; - /// - /// Represents the largest possible value of SpecificEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of SpecificEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the SpecificEnergy quantity. /// @@ -1098,40 +1086,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 38db174727..45488f057d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -117,18 +117,6 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// public static SpecificEntropyUnit ConversionBaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; - /// - /// Represents the largest possible value of SpecificEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of SpecificEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the SpecificEntropy quantity. /// @@ -823,40 +811,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 18ffe2f694..342a3d2445 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -115,18 +115,6 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// public static SpecificFuelConsumptionUnit ConversionBaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; - /// - /// Represents the largest possible value of SpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of SpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the SpecificFuelConsumption quantity. /// @@ -741,40 +729,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 915e8ee3fd..a398af10d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -111,18 +111,6 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// public static SpecificVolumeUnit ConversionBaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; - /// - /// Represents the largest possible value of SpecificVolume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of SpecificVolume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the SpecificVolume quantity. /// @@ -721,40 +709,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 70648945a6..bf29901ef9 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -128,18 +128,6 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// public static SpecificWeightUnit ConversionBaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; - /// - /// Represents the largest possible value of SpecificWeight - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of SpecificWeight - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the SpecificWeight quantity. /// @@ -962,40 +950,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 2cd4fd55b8..526a46d875 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -140,18 +140,6 @@ public Speed(double value, UnitSystem unitSystem) /// public static SpeedUnit ConversionBaseUnit { get; } = SpeedUnit.MeterPerSecond; - /// - /// Represents the largest possible value of Speed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Speed MaxValue { get; } = new Speed(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Speed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Speed MinValue { get; } = new Speed(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Speed quantity. /// @@ -1214,40 +1202,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index ad60e95c7b..4d32fd8295 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -117,18 +117,6 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// public static StandardVolumeFlowUnit ConversionBaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; - /// - /// Represents the largest possible value of StandardVolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of StandardVolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the StandardVolumeFlow quantity. /// @@ -823,40 +811,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index a037fae4aa..3dfe18d15e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -118,18 +118,6 @@ public Temperature(double value, UnitSystem unitSystem) /// public static TemperatureUnit ConversionBaseUnit { get; } = TemperatureUnit.Kelvin; - /// - /// Represents the largest possible value of Temperature - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Temperature - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Temperature MinValue { get; } = new Temperature(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Temperature quantity. /// @@ -794,40 +782,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 3dc465eb0c..951fd7590e 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -118,18 +118,6 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// public static TemperatureChangeRateUnit ConversionBaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; - /// - /// Represents the largest possible value of TemperatureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of TemperatureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the TemperatureChangeRate quantity. /// @@ -840,40 +828,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 5c473b2fb1..72c0d1ae50 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -117,18 +117,6 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// public static TemperatureDeltaUnit ConversionBaseUnit { get; } = TemperatureDeltaUnit.Kelvin; - /// - /// Represents the largest possible value of TemperatureDelta - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of TemperatureDelta - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the TemperatureDelta quantity. /// @@ -823,40 +811,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 4738a98ce2..e84d3ff1c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -113,18 +113,6 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// public static ThermalConductivityUnit ConversionBaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; - /// - /// Represents the largest possible value of ThermalConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ThermalConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ThermalConductivity quantity. /// @@ -707,40 +695,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 45f54efccd..da8e427a49 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -113,18 +113,6 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// public static ThermalResistanceUnit ConversionBaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; - /// - /// Represents the largest possible value of ThermalResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of ThermalResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the ThermalResistance quantity. /// @@ -755,40 +743,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 13cf55e5ed..093953a4b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -130,18 +130,6 @@ public Torque(double value, UnitSystem unitSystem) /// public static TorqueUnit ConversionBaseUnit { get; } = TorqueUnit.NewtonMeter; - /// - /// Represents the largest possible value of Torque - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Torque MaxValue { get; } = new Torque(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Torque - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Torque MinValue { get; } = new Torque(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Torque quantity. /// @@ -1044,40 +1032,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 60e726d36a..7d5f2b1764 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -129,18 +129,6 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// public static TorquePerLengthUnit ConversionBaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; - /// - /// Represents the largest possible value of TorquePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of TorquePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the TorquePerLength quantity. /// @@ -1027,40 +1015,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 2931ac18f0..dc81095700 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -112,18 +112,6 @@ public Turbidity(double value, UnitSystem unitSystem) /// public static TurbidityUnit ConversionBaseUnit { get; } = TurbidityUnit.NTU; - /// - /// Represents the largest possible value of Turbidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Turbidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Turbidity quantity. /// @@ -690,40 +678,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 27b919d201..e4f3b5ee6c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -109,18 +109,6 @@ public VitaminA(double value, UnitSystem unitSystem) /// public static VitaminAUnit ConversionBaseUnit { get; } = VitaminAUnit.InternationalUnit; - /// - /// Represents the largest possible value of VitaminA - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of VitaminA - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the VitaminA quantity. /// @@ -687,40 +675,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 719c3a7036..6265fb8806 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -159,18 +159,6 @@ public Volume(double value, UnitSystem unitSystem) /// public static VolumeUnit ConversionBaseUnit { get; } = VolumeUnit.CubicMeter; - /// - /// Represents the largest possible value of Volume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Volume MaxValue { get; } = new Volume(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of Volume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Volume MinValue { get; } = new Volume(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the Volume quantity. /// @@ -1537,40 +1525,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 82af9e404d..69ecaab423 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -131,18 +131,6 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// public static VolumeConcentrationUnit ConversionBaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; - /// - /// Represents the largest possible value of VolumeConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of VolumeConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the VolumeConcentration quantity. /// @@ -1013,40 +1001,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 4c27f39b92..0a8608e307 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -164,18 +164,6 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// public static VolumeFlowUnit ConversionBaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; - /// - /// Represents the largest possible value of VolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of VolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the VolumeFlow quantity. /// @@ -1622,40 +1610,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 3fdcd7248e..c4369aceba 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -115,18 +115,6 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// public static VolumePerLengthUnit ConversionBaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; - /// - /// Represents the largest possible value of VolumePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of VolumePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the VolumePerLength quantity. /// @@ -789,40 +777,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 2811f02c7d..2ee69e6aa7 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -120,18 +120,6 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// public static VolumetricHeatCapacityUnit ConversionBaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; - /// - /// Represents the largest possible value of VolumetricHeatCapacity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of VolumetricHeatCapacity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the VolumetricHeatCapacity quantity. /// @@ -826,40 +814,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 1f23846805..adab894eed 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -114,18 +114,6 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// public static WarpingMomentOfInertiaUnit ConversionBaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; - /// - /// Represents the largest possible value of WarpingMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, ConversionBaseUnit); - - /// - /// Represents the smallest possible value of WarpingMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, ConversionBaseUnit); - /// /// All units of measurement for the WarpingMomentOfInertia quantity. /// @@ -772,40 +760,6 @@ public string ToString(IFormatProvider? provider) return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// /// Gets the string representation of this instance in the specified format string using . diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index d19bb68366..6bf0a34182 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -69,25 +69,6 @@ public interface IQuantity : IFormattable /// String representation. /// Format to use for localization and number formatting. Defaults to if null. string ToString(IFormatProvider? provider); - - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - string ToString(IFormatProvider? provider, int significantDigitsAfterRadix); - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implictly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - string ToString(IFormatProvider? provider, string format, params object[] args); } /// From d096b6d7f4e5fb1ccf4693a8a73489b5a09d67a2 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 00:21:22 +0100 Subject: [PATCH 21/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20GlobalConfigurati?= =?UTF-8?q?on?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UnitsNet/CustomCode/GlobalConfiguration.cs | 28 ---------------------- 1 file changed, 28 deletions(-) delete mode 100644 UnitsNet/CustomCode/GlobalConfiguration.cs diff --git a/UnitsNet/CustomCode/GlobalConfiguration.cs b/UnitsNet/CustomCode/GlobalConfiguration.cs deleted file mode 100644 index 746e98dc65..0000000000 --- a/UnitsNet/CustomCode/GlobalConfiguration.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Globalization; -using System.Threading; - -// ReSharper disable once CheckNamespace -namespace UnitsNet -{ - /// - /// Global configuration for culture, used as default culture in methods like and - /// . - /// - [Obsolete("The only property DefaultCulture is now deprecated. Manipulate Thread.CurrentThread.CurrentUICulture instead.")] - public static class GlobalConfiguration - { - /// - /// Wrapper for . - /// - [Obsolete("Manipulate Thread.CurrentThread.CurrentUICulture instead, this property will be removed.")] - public static IFormatProvider DefaultCulture - { - get => Thread.CurrentThread.CurrentUICulture; - set => Thread.CurrentThread.CurrentUICulture = (CultureInfo) value; - } - } -} From 6dd046de6fe7c5b6d0d1bf08ba42ece59099fa2e Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 00:22:10 +0100 Subject: [PATCH 22/66] =?UTF-8?q?=F0=9F=94=A5=20json:=20Remove=20UnitsNetJ?= =?UTF-8?q?sonConverter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Internal/MultiDimensionalArrayHelpers.cs | 87 ------- .../Internal/ReflectionHelper.cs | 43 ---- .../UnitsNet.Serialization.JsonNet.csproj | 2 +- .../UnitsNetJsonConverter.cs | 241 ------------------ 4 files changed, 1 insertion(+), 372 deletions(-) delete mode 100644 UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs delete mode 100644 UnitsNet.Serialization.JsonNet/Internal/ReflectionHelper.cs delete mode 100644 UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs diff --git a/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs b/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs deleted file mode 100644 index ff8c4aa5b9..0000000000 --- a/UnitsNet.Serialization.JsonNet/Internal/MultiDimensionalArrayHelpers.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Linq; - -namespace UnitsNet.Serialization.JsonNet.Internal -{ - - /// - /// Helper class for working with and manipulating multi-dimension arrays based on their generic index. - /// - internal static class MultiDimensionalArrayHelpers - { - - /// - /// Returns a new array of same Rank and Length as but with each element converted to - /// - /// - /// - /// - public static Array ConvertArrayElements(Array array) - { - var ret = Array.CreateInstance(typeof(TResult), LastIndex(array)); - var ind = FirstIndex(array); - - while (ind != null) - { - ret.SetValue((TResult)array.GetValue(ind), ind); - ind = NextIndex(array, ind); - } - return ret; - } - - /// - /// Returns the index for the 'first' element in a multidimensional array. - /// - /// 'First' is defined as the for each rank of the - /// - /// E.g., for a zero-based 5x5x5 array this method would return [0, 0, 0]. - /// - /// - /// 1D integer array specifying the location of the first element in the multidimensional array - public static int[] FirstIndex(Array array) - { - return Enumerable.Range(0, array.Rank).Select(array.GetLowerBound).ToArray(); - } - - /// - /// Returns the index for the 'last' element in a multidimensional array. - /// - /// 'Last' is defined as the for each rank of the - /// - /// E.g., for a zero-based 5x5x5 array this method would return [4, 4, 4]. - /// - /// - /// 1D integer array specifying the location of the last element in the multidimensional array - public static int[] LastIndex(Array array) - { - return Enumerable.Range(0, array.Rank).Select(x => array.GetUpperBound(x) + 1).ToArray(); - } - - /// - /// Returns the 'next' index after the specified multidimensional - /// - /// The 'next' index is determined by first looping through all elements in the first dimension of the array, then moving on to the next dimension and repeating - /// - /// - /// - /// Returns the index location of the next element in after as a 1D array of integers. If there is no next index, returns null - public static int[]? NextIndex(Array array, int[] index) - { - for (var i = 0; i < index.Length; i++) - { - index[i] += 1; - - if (index[i] <= array.GetUpperBound(i)) - { - return index; - } - else - { - index[i] = array.GetLowerBound(i); - } - } - return null; - } - - } -} diff --git a/UnitsNet.Serialization.JsonNet/Internal/ReflectionHelper.cs b/UnitsNet.Serialization.JsonNet/Internal/ReflectionHelper.cs deleted file mode 100644 index c38435e291..0000000000 --- a/UnitsNet.Serialization.JsonNet/Internal/ReflectionHelper.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Reflection; - -namespace UnitsNet.Serialization.JsonNet.Internal -{ - /// - /// Helper for dealing with reflection, abstracting API differences between old and new .NET framework. - /// - [Obsolete("The JsonConverter(s) for UnitsNet no longer relies on reflection")] - internal static class ReflectionHelper - { - [Obsolete("The JsonConverter(s) for UnitsNet no longer relies on reflection")] - internal static PropertyInfo GetProperty(this Type type, string name) - { -#if (NET40 || NET35 || NET20 || SILVERLIGHT) - return type.GetProperty(name); - -#else - return type.GetTypeInfo().GetDeclaredProperty(name); -#endif - } - - [Obsolete("The JsonConverter(s) for UnitsNet no longer relies on reflection")] - internal static IEnumerable GetDeclaredMethods(this Type someType) - { - Type t = someType; - while (t != null) - { -#if (NET40 || NET35 || NET20 || SILVERLIGHT) - foreach (var m in t.GetMethods()) - yield return m; - t = t.BaseType; -#else - TypeInfo ti = t.GetTypeInfo(); - foreach (MethodInfo m in ti.DeclaredMethods) - yield return m; - t = ti.BaseType; -#endif - } - } - } -} diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index f90225a933..4d8966bf0d 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -54,7 +54,7 @@ - + diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs deleted file mode 100644 index d51ba4f294..0000000000 --- a/UnitsNet.Serialization.JsonNet/UnitsNetJsonConverter.cs +++ /dev/null @@ -1,241 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using System.Linq; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using UnitsNet.Serialization.JsonNet.Internal; - -namespace UnitsNet.Serialization.JsonNet -{ - /// - /// - /// A JSON.net for converting to/from JSON and Units.NET - /// units like and . - /// - /// - /// Relies on reflection and the type names and namespaces as of 3.x.x of Units.NET. - /// Assumptions by reflection code in the converter: - /// * Unit classes are of type UnitsNet.Length etc. - /// * Unit enums are of type UnitsNet.Units.LengthUnit etc. - /// * Unit class has a ConversionBaseUnit property returning the base unit, such as LengthUnit.Meter - /// - [Obsolete("Replaced by UnitsNetIQuantityJsonConverter and UnitsNetIComparableJsonConverter (if you need support for IComparable)")] - public class UnitsNetJsonConverter : JsonConverter - { - /// - /// Reads the JSON representation of the object. - /// - /// The to read from. - /// Type of the object. - /// The existing value of object being read. - /// The calling serializer. - /// - /// The object value. - /// - /// Unable to parse value and unit from JSON. - public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, - JsonSerializer serializer) - { - if (reader.ValueType != null) - return reader.Value; - - object? obj = TryDeserializeIComparable(reader, serializer); - if (obj is Array values) - { - - // Create array with the requested type, such as `Length[]` or `Frequency[]` or multi-dimensional arrays like `Length[,]` or `Frequency[,,]` - var elementType = objectType.GetElementType() ?? throw new NotSupportedException($"GetElementType() returned null for type {objectType}."); - var arrayOfQuantities = Array.CreateInstance(elementType, MultiDimensionalArrayHelpers.LastIndex(values)); - - // Fill array with parsed quantities - int[] index = MultiDimensionalArrayHelpers.FirstIndex(values); - arrayOfQuantities.SetValue(values.GetValue(index), index); - - return arrayOfQuantities; - } - else if (obj is ValueUnit valueUnit) - { - return ParseValueUnit(valueUnit); - } - else - { - return obj; - } - } - - private static IQuantity ParseValueUnit(ValueUnit vu) - { - // "MassUnit.Kilogram" => "MassUnit" and "Kilogram" - string unitEnumTypeName = vu.Unit.Split('.')[0]; - string unitEnumValue = vu.Unit.Split('.')[1]; - - // "UnitsNet.Units.MassUnit,UnitsNet" - string unitEnumTypeAssemblyQualifiedName = "UnitsNet.Units." + unitEnumTypeName + ",UnitsNet"; - - // -- see http://stackoverflow.com/a/6465096/1256096 for details - Type? unitEnumType = Type.GetType(unitEnumTypeAssemblyQualifiedName); - if (unitEnumType == null) - { - throw new UnitsNetException("Unable to find enum type.") - { - Data = { ["type"] = unitEnumTypeAssemblyQualifiedName } - }; - } - - double value = vu.Value; - Enum unitValue = (Enum)Enum.Parse(unitEnumType, unitEnumValue); // Ex: MassUnit.Kilogram - - return Quantity.From(value, unitValue); - } - - private static object? TryDeserializeIComparable(JsonReader reader, JsonSerializer serializer) - { - JToken token = JToken.Load(reader); - - if (token is JArray) - { - object?[] results = token.Children().Select(item => TryDeserializeIComparable(item, serializer)).ToArray(); - return results; - } - else - { - return TryDeserializeIComparable(token, serializer); - } - } - - private static object? TryDeserializeIComparable(JToken token, JsonSerializer serializer) - { - JToken? unitToken = token[nameof(ValueUnit.Unit)]; - JToken? valueToken = token[nameof(ValueUnit.Value)]; - if (unitToken != null && valueToken != null) - { - return new ValueUnit { Unit = unitToken.ToString(), Value = valueToken.ToObject() }; - } - - var localSerializer = new JsonSerializer { TypeNameHandling = serializer.TypeNameHandling, }; - return token.ToObject(localSerializer); - } - - /// - /// Writes the JSON representation of the object. - /// - /// The to write to. - /// The value to write. - /// The calling serializer. - /// Can't serialize 'null' value. - public override void WriteJson(JsonWriter writer, object? obj, JsonSerializer serializer) - { - // ValueUnit should be written as usual (but read in a custom way) - if (obj is ValueUnit valueUnit) - { - var localSerializer = new JsonSerializer - { - TypeNameHandling = serializer.TypeNameHandling, - }; - - var t = JToken.FromObject(valueUnit, localSerializer); - t.WriteTo(writer); - } - else if (obj is Array values) - { - - var results = Array.CreateInstance(typeof(ValueUnit), MultiDimensionalArrayHelpers.LastIndex(values)); - var ind = MultiDimensionalArrayHelpers.FirstIndex(values); - - while (ind != null) - { - results.SetValue((IQuantity)values.GetValue(ind), ind); - ind = MultiDimensionalArrayHelpers.NextIndex(results, ind); - } - - serializer.Serialize(writer, results); - } - else if (obj is IQuantity quantity) - { - serializer.Serialize(writer, ToValueUnit(quantity)); - } - else if (obj is null) - { - serializer.Serialize(writer, null); - } - else - { - throw new NotSupportedException($"Unsupported type: {obj.GetType()}"); - } - } - - private static ValueUnit ToValueUnit(IQuantity value) - { - return new ValueUnit - { - // See ValueUnit about precision loss for quantities using decimal type. - Value = value.Value, - Unit = $"{value.QuantityInfo.UnitType.Name}.{value.Unit}" - }; - } - - /// - /// A structure used to serialize/deserialize Units.NET unit instances. - /// - /// - /// Quantities may use decimal, long or double as base value type and this might result - /// in a loss of precision when serializing/deserializing to decimal. - /// Decimal is the highest precision type available in .NET, but has a smaller - /// range than double. - /// - /// Json: Support decimal precision #503 - /// https://github.com/angularsen/UnitsNet/issues/503 - /// - private class ValueUnit - { - public string Unit { get; set; } = null!; - public double Value { get; set; } - } - - #region Can Convert - - /// - /// Determines whether this instance can convert the specified object type. - /// - /// Type of the object. - /// - public override bool CanConvert(Type objectType) - { - if (IsNullable(objectType)) - return CanConvertNullable(objectType); - - return objectType.Namespace != null && - (objectType.Namespace.Equals(nameof(UnitsNet)) || - objectType == typeof(ValueUnit) || - // All unit types implement IComparable - objectType == typeof(IComparable)); - } - - /// - /// Determines whether the specified object type is actually a type. - /// - /// Type of the object. - /// true if the object type is nullable; otherwise false. - private static bool IsNullable(Type objectType) - { - return Nullable.GetUnderlyingType(objectType) != null; - } - - /// - /// Determines whether this instance can convert the specified nullable object type. - /// - /// Type of the object. - /// true if the object type is a nullable container for a UnitsNet type; otherwise false. - protected virtual bool CanConvertNullable(Type objectType) - { - // Need to look at the FullName in order to determine if the nullable type contains a UnitsNet type. - // For example: FullName = 'System.Nullable`1[[UnitsNet.Frequency, UnitsNet, Version=3.19.0.0, Culture=neutral, PublicKeyToken=null]]' - return objectType.FullName != null && objectType.FullName.Contains(nameof(UnitsNet) + "."); - } - - #endregion - - } -} From 1e6a82322c3a1b6e348c1ff5f0ce96da628560b9 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 00:24:36 +0100 Subject: [PATCH 23/66] =?UTF-8?q?=F0=9F=94=A5=20QuantityNotFoundException?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- UnitsNet/QuantityNotFoundException.cs | 30 --------------------------- 1 file changed, 30 deletions(-) delete mode 100644 UnitsNet/QuantityNotFoundException.cs diff --git a/UnitsNet/QuantityNotFoundException.cs b/UnitsNet/QuantityNotFoundException.cs deleted file mode 100644 index 78ce500b9e..0000000000 --- a/UnitsNet/QuantityNotFoundException.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; - -namespace UnitsNet -{ - /// - /// Quantity type was not found. This is typically thrown for dynamic conversions, - /// such as . - /// - [Obsolete("")] - public class QuantityNotFoundException : UnitsNetException - { - /// - public QuantityNotFoundException() - { - } - - /// - public QuantityNotFoundException(string message) : base(message) - { - } - - /// - public QuantityNotFoundException(string message, Exception innerException) : base(message, innerException) - { - } - } -} From 51fff339305dc9f5ad7fb5e115fe73b837f99ab6 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 00:25:14 +0100 Subject: [PATCH 24/66] =?UTF-8?q?=F0=9F=94=A5=20Molarity=20ctor=20and=20op?= =?UTF-8?q?erator=20overloads?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CustomCode/Quantities/Density.extra.cs | 33 --------------- .../CustomCode/Quantities/Molarity.extra.cs | 41 ++----------------- 2 files changed, 3 insertions(+), 71 deletions(-) diff --git a/UnitsNet/CustomCode/Quantities/Density.extra.cs b/UnitsNet/CustomCode/Quantities/Density.extra.cs index d20459ed7b..d0bc88d758 100644 --- a/UnitsNet/CustomCode/Quantities/Density.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Density.extra.cs @@ -8,31 +8,6 @@ namespace UnitsNet { public partial struct Density { - /// - /// Gets from this . - /// - /// - /// - [Obsolete("This method is deprecated in favor of MassConcentration.ToMolarity(MolarMass).")] - public Molarity ToMolarity(Mass molecularWeight) - { - return Molarity.FromMolesPerCubicMeter(KilogramsPerCubicMeter / molecularWeight.Kilograms); - } - - #region Static Methods - - /// - /// Get from . - /// - /// - [Obsolete("This method is deprecated in favor of MassConcentration.FromMolarity(Molarity, MolarMass).")] - public static Density FromMolarity(Molarity molarity, Mass molecularWeight) - { - return new Density(molarity.MolesPerCubicMeter * molecularWeight.Kilograms, DensityUnit.KilogramPerCubicMeter); - } - - #endregion - /// Get from times . public static Mass operator *(Density density, Volume volume) { @@ -63,14 +38,6 @@ public static Density FromMolarity(Molarity molarity, Mass molecularWeight) return new SpecificWeight(density.KilogramsPerCubicMeter * acceleration.MetersPerSecondSquared, SpecificWeightUnit.NewtonPerCubicMeter); } - /// Get from divided by . - /// - [Obsolete("This operator is deprecated in favor of MassConcentration.op_Division(MassConcentration, MolarMass).")] - public static Molarity operator /(Density density, Mass molecularWeight) - { - return new Molarity(density.KilogramsPerCubicMeter / molecularWeight.Kilograms, MolarityUnit.MolesPerCubicMeter); - } - /// Get from times . public static LinearDensity operator *(Density density, Area area) { diff --git a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs index 53af6eeb15..8d6079c9e4 100644 --- a/UnitsNet/CustomCode/Quantities/Molarity.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Molarity.extra.cs @@ -1,40 +1,16 @@ -using System; -using UnitsNet.Units; +using UnitsNet.Units; namespace UnitsNet { public partial struct Molarity { - /// - /// Construct from divided by . - /// - /// - [Obsolete("This constructor will be removed in favor of operator overload MassConcentration.op_Division(MassConcentration,MolarMass).")] - public Molarity(Density density, Mass molecularWeight) - : this() - { - _value = density.KilogramsPerCubicMeter / molecularWeight.Kilograms; - _unit = MolarityUnit.MolesPerCubicMeter; - } - - /// - /// Get a from this . - /// - /// - /// - [Obsolete("This method will be removed in favor of ToMassConcentration(MolarMass)")] - public Density ToDensity(Mass molecularWeight) - { - return Density.FromKilogramsPerCubicMeter(MolesPerCubicMeter * molecularWeight.Kilograms); - } - /// /// Get a from this . /// /// - public MassConcentration ToMassConcentration(MolarMass molecularWeight) + public MassConcentration ToMassConcentration(MolarMass molecularWeight) { - return this * molecularWeight; + return this * molecularWeight; } /// @@ -49,17 +25,6 @@ public VolumeConcentration ToVolumeConcentration(Density componentDensity, Molar #region Static Methods - /// - /// Get from . - /// - /// - /// - [Obsolete("Use MassConcentration / MolarMass operator overload instead.")] - public static Molarity FromDensity(Density density, Mass molecularWeight) - { - return density / molecularWeight; - } - /// /// Get from and known component and . /// From 9577dd3e9142340fdce1a6710dc9af5a5ed25753 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 00:54:16 +0100 Subject: [PATCH 25/66] Misc R# code fixes --- CodeGen/Generators/GeneratorBase.cs | 5 +- .../NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../NanoFrameworkGen/ProjectGenerator.cs | 2 +- .../NanoFrameworkGen/PropertyGenerator.cs | 2 +- .../NanoFrameworkGen/QuantityGenerator.cs | 2 +- .../NanoFrameworkGen/SolutionGenerator.cs | 2 +- .../NanoFrameworkGen/UnitTypeGenerator.cs | 2 +- .../IQuantityTestClassGenerator.cs | 2 +- .../UnitsNetGen/NumberExtensionsGenerator.cs | 2 +- .../NumberExtensionsTestClassGenerator.cs | 4 +- .../UnitsNetGen/QuantityGenerator.cs | 2 +- .../UnitsNetGen/StaticQuantityGenerator.cs | 2 +- .../UnitAbbreviationsCacheGenerator.cs | 2 +- .../UnitsNetGen/UnitConverterGenerator.cs | 2 +- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 2 +- .../UnitsNetGen/UnitTestStubGenerator.cs | 2 +- .../UnitsNetGen/UnitTypeGenerator.cs | 2 +- CodeGen/Program.cs | 5 +- UnitsNet.Benchmark/Program.cs | 28 ++-- .../UnitsNetJsonConverterTests.cs | 2 +- .../UnitsNetIQuantityJsonConverterTest.cs | 3 +- .../UnitsNetJsonSerializationTests.cs | 2 +- UnitsNet.Tests/BaseUnitsTests.cs | 60 ++++----- UnitsNet.Tests/CustomCode/PressureTests.cs | 2 +- .../CustomCode/TemperatureChangeRateTests.cs | 2 +- UnitsNet.Tests/DummyIQuantity.cs | 10 -- UnitsNet.Tests/QuantityIConvertibleTests.cs | 124 +++++++++--------- UnitsNet.Tests/QuantityTest.cs | 2 +- UnitsNet.Tests/QuantityTypeConverterTest.cs | 54 ++++---- UnitsNet.Tests/UnitSystemTests.cs | 3 - UnitsNet/BaseDimensions.cs | 36 +++-- UnitsNet/BaseUnits.cs | 20 +-- .../Quantities/AreaMomentOfInertia.extra.cs | 2 - .../CustomCode/Quantities/Density.extra.cs | 1 - .../Quantities/MassConcentration.extra.cs | 2 - .../Quantities/SpecificWeight.extra.cs | 6 +- UnitsNet/CustomCode/QuantityParser.cs | 22 +--- UnitsNet/CustomCode/UnitAbbreviationsCache.cs | 84 +++++++----- UnitsNet/CustomCode/UnitParser.cs | 2 +- .../CustomCode/UnitValueAbbreviationLookup.cs | 31 ++--- .../CustomCode/Wrappers/ReferencePressure.cs | 3 +- UnitsNet/QuantityInfo.cs | 2 +- UnitsNet/QuantityTypeConverter.cs | 15 +-- UnitsNet/UnitConverter.cs | 10 +- 44 files changed, 267 insertions(+), 305 deletions(-) diff --git a/CodeGen/Generators/GeneratorBase.cs b/CodeGen/Generators/GeneratorBase.cs index 53c9a23f7f..8488e5baae 100644 --- a/CodeGen/Generators/GeneratorBase.cs +++ b/CodeGen/Generators/GeneratorBase.cs @@ -7,10 +7,9 @@ namespace CodeGen.Generators { internal abstract class GeneratorBase { - protected readonly MyTextWriter Writer = new MyTextWriter(); - public abstract string Generate(); + protected readonly MyTextWriter Writer = new(); - public const string GeneratedFileHeader = @"//------------------------------------------------------------------------------ + protected const string GeneratedFileHeader = @"//------------------------------------------------------------------------------ // // This code was generated by \generate-code.bat. // diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index b691996b2a..a4a5d3db4c 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -19,7 +19,7 @@ public NuspecGenerator( _mathNuGetVersion = mathNuGetVersion; } - public override string Generate() + public string Generate() { Writer.WL($@" diff --git a/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs index a6ac6851b6..aa0ac982c4 100644 --- a/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs @@ -14,7 +14,7 @@ public ProjectGenerator(Quantity quantity, NanoFrameworkVersions versions) _versions = versions; } - public override string Generate() + public string Generate() { Writer.WL($@" diff --git a/CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs index f046e72ca2..1d235b79ac 100644 --- a/CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/PropertyGenerator.cs @@ -13,7 +13,7 @@ public PropertyGenerator(string version) _version = version; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.W($@"using System.Reflection; diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 12b12368b4..d6615e3fc8 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -17,7 +17,7 @@ public QuantityGenerator(Quantity quantity) _unitEnumName = $"{quantity.Name}Unit"; } - public override string Generate() + public string Generate() { // Auto generated header Writer.WL(GeneratedFileHeader); diff --git a/CodeGen/Generators/NanoFrameworkGen/SolutionGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/SolutionGenerator.cs index 8f30f4cb94..1b8384288d 100644 --- a/CodeGen/Generators/NanoFrameworkGen/SolutionGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/SolutionGenerator.cs @@ -15,7 +15,7 @@ public SolutionGenerator(Quantity[] quantities) _quantities = quantities; } - public override string Generate() + public string Generate() { StringBuilder sb = new(); Writer.WL($@"Microsoft Visual Studio Solution File, Format Version 12.00 diff --git a/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs index 5c962eca63..0b56ff1898 100644 --- a/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs @@ -15,7 +15,7 @@ public UnitTypeGenerator(Quantity quantity) _unitEnumName = $"{quantity.Name}Unit"; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL($@" diff --git a/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs index 6c5c6f2f78..d331fc52c6 100644 --- a/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/IQuantityTestClassGenerator.cs @@ -18,7 +18,7 @@ public IQuantityTestClassGenerator(Quantity[] quantities) _quantities = quantities; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL($@" diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs index bfc73f0433..00a49b8c83 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsGenerator.cs @@ -17,7 +17,7 @@ public NumberExtensionsGenerator(Quantity quantity) _quantityName = quantity.Name; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); diff --git a/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs index eba484b31e..6b23ebd294 100644 --- a/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/NumberExtensionsTestClassGenerator.cs @@ -16,7 +16,7 @@ public NumberExtensionsTestClassGenerator(Quantity quantity) _quantityName = quantity.Name; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); @@ -47,7 +47,7 @@ public class NumberTo{_quantityName}ExtensionsTests return Writer.ToString(); } - private string GetObsoleteAttributeOrNull(string obsoleteText) => + private static string? GetObsoleteAttributeOrNull(string obsoleteText) => string.IsNullOrWhiteSpace(obsoleteText) ? null : $"[System.Obsolete({obsoleteText})]"; diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 1482176c9f..f514e0de55 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -40,7 +40,7 @@ public QuantityGenerator(Quantity quantity) } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL(@" diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index eb0db61b94..021d8e765b 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -12,7 +12,7 @@ public StaticQuantityGenerator(Quantity[] quantities) _quantities = quantities; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL(@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitAbbreviationsCacheGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitAbbreviationsCacheGenerator.cs index 26189a0172..c2d1acc2f3 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitAbbreviationsCacheGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitAbbreviationsCacheGenerator.cs @@ -12,7 +12,7 @@ public UnitAbbreviationsCacheGenerator(Quantity[] quantities) _quantities = quantities; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL(@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs index 83de92800a..00b8cc4412 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitConverterGenerator.cs @@ -15,7 +15,7 @@ public UnitConverterGenerator(Quantity[] quantities) _quantities = quantities; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL($@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index b0add6c90e..2259ae8a22 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -69,7 +69,7 @@ private static string GetEnglishAbbreviation(Unit unit) return string.IsNullOrEmpty(unitAbbreviation) ? "" : $" {unitAbbreviation}"; } - public override string Generate() + public string Generate() { var baseUnitVariableName = _baseUnit.SingularName.ToLowerInvariant(); diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestStubGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestStubGenerator.cs index 3580502e0b..e736652684 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestStubGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestStubGenerator.cs @@ -11,7 +11,7 @@ public UnitTestStubGenerator(Quantity quantity) _quantity = quantity; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL($@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs index eaf6220511..595a82e110 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs @@ -14,7 +14,7 @@ public UnitTypeGenerator(Quantity quantity) _unitEnumName = $"{quantity.Name}Unit"; } - public override string Generate() + public string Generate() { Writer.WL(GeneratedFileHeader); Writer.WL($@" diff --git a/CodeGen/Program.cs b/CodeGen/Program.cs index 7007a58297..cbbeba143f 100644 --- a/CodeGen/Program.cs +++ b/CodeGen/Program.cs @@ -9,7 +9,10 @@ namespace CodeGen { - internal class Program + /// + /// Code generator for Units.NET. + /// + public class Program { /// /// Code generator for Units.NET. diff --git a/UnitsNet.Benchmark/Program.cs b/UnitsNet.Benchmark/Program.cs index f2b551b342..25d32af6e7 100644 --- a/UnitsNet.Benchmark/Program.cs +++ b/UnitsNet.Benchmark/Program.cs @@ -7,8 +7,8 @@ namespace UnitsNet.Benchmark [MemoryDiagnoser] public class UnitsNetBenchmarks { - private Length length = Length.FromMeters(3.0); - private IQuantity lengthIQuantity = Length.FromMeters(3.0); + private Length _length = Length.FromMeters(3.0); + private readonly IQuantity _lengthIQuantity = Length.FromMeters(3.0); [Benchmark] [BenchmarkCategory("Construction")] @@ -24,27 +24,27 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Transformation")] - public double ToProperty() => length.Centimeters; + public double ToProperty() => _length.Centimeters; [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double As() => length.As(LengthUnit.Centimeter); + public double As() => _length.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double As_SI() => length.As(UnitSystem.SI); + public double As_SI() => _length.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] - public Length ToUnit() => length.ToUnit(LengthUnit.Centimeter); + public Length ToUnit() => _length.ToUnit(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] - public Length ToUnit_SI() => length.ToUnit(UnitSystem.SI); + public Length ToUnit_SI() => _length.ToUnit(UnitSystem.SI); [Benchmark] [BenchmarkCategory("ToString")] - public string ToStringTest() => length.ToString(); + public string ToStringTest() => _length.ToString(); [Benchmark] [BenchmarkCategory("Parsing")] @@ -52,11 +52,11 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Parsing")] - public bool TryParseValid() => Length.TryParse("3.0 m", out var l); + public bool TryParseValid() => Length.TryParse("3.0 m", out _); [Benchmark] [BenchmarkCategory("Parsing")] - public bool TryParseInvalid() => Length.TryParse("3.0 zoom", out var l); + public bool TryParseInvalid() => Length.TryParse("3.0 zoom", out _); [Benchmark] [BenchmarkCategory("Construction")] @@ -64,19 +64,19 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double IQuantity_As() => lengthIQuantity.As(LengthUnit.Centimeter); + public double IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double IQuantity_As_SI() => lengthIQuantity.As(UnitSystem.SI); + public double IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] - public IQuantity IQuantity_ToUnit() => lengthIQuantity.ToUnit(LengthUnit.Centimeter); + public IQuantity IQuantity_ToUnit() => _lengthIQuantity.ToUnit(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("ToString")] - public string IQuantity_ToStringTest() => lengthIQuantity.ToString(); + public string IQuantity_ToStringTest() => _lengthIQuantity.ToString(); } class Program diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs index 3a71fbc5fe..6775d8769d 100644 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs @@ -142,7 +142,7 @@ public void ArrayValue_ExpectJsonArray() [Fact(Skip = "Not supported in older versions of serialization")] public void EmptyArrayValue_ExpectJsonArray() { - Frequency[] testObj = new Frequency[0]; + Frequency[] testObj = { }; string expectedJson = "[]"; diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs index 56341bce15..ea87af940d 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using System.Collections; using System.Collections.Generic; using System.IO; using System.Text; @@ -13,7 +12,7 @@ namespace UnitsNet.Serialization.JsonNet.Tests { public sealed class UnitsNetIQuantityJsonConverterTest { - private UnitsNetIQuantityJsonConverter _sut; + private readonly UnitsNetIQuantityJsonConverter _sut; public UnitsNetIQuantityJsonConverterTest() { diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs index ecad2cf236..8d8d6b2e35 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetJsonSerializationTests.cs @@ -155,7 +155,7 @@ public void MultiDimArrayValue_ExpectJsonArray() [Fact] public void EmptyArrayValue_ExpectJsonArray() { - Frequency[] testObj = new Frequency[0]; + Frequency[] testObj = { }; string expectedJson = "[]"; diff --git a/UnitsNet.Tests/BaseUnitsTests.cs b/UnitsNet.Tests/BaseUnitsTests.cs index 3954e61b93..4056bac59a 100644 --- a/UnitsNet.Tests/BaseUnitsTests.cs +++ b/UnitsNet.Tests/BaseUnitsTests.cs @@ -9,13 +9,13 @@ namespace UnitsNet.Tests { public class BaseUnitsTests { - private static BaseUnits siBaseUnits = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, + private static readonly BaseUnits SIBaseUnits = new(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela); - private static BaseUnits siBaseUnitsCopy = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, + private static readonly BaseUnits SIBaseUnitsCopy = new(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela); - private static BaseUnits nonSiBaseUnits = new BaseUnits(LengthUnit.Foot, MassUnit.Pound, DurationUnit.Second, + private static readonly BaseUnits NonSiBaseUnits = new(LengthUnit.Foot, MassUnit.Pound, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.DegreeFahrenheit, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela); [Fact] @@ -36,36 +36,36 @@ public void ConstructorSetsUnitsProperly() [Fact] public void EqualsObjectIsImplementedCorrectly() { - Assert.True(siBaseUnits.Equals((object)siBaseUnitsCopy)); - Assert.False(siBaseUnits.Equals((object)nonSiBaseUnits)); + Assert.True(SIBaseUnits.Equals((object)SIBaseUnitsCopy)); + Assert.False(SIBaseUnits.Equals((object)NonSiBaseUnits)); - Assert.False(siBaseUnits.Equals("Some object.")); - Assert.False(siBaseUnits.Equals((IFormatProvider)null)); + Assert.False(SIBaseUnits.Equals("Some object.")); + Assert.False(SIBaseUnits.Equals(((IFormatProvider)null)!)); } [Fact] public void EqualsBaseUnitsIsImplementedCorrectly() { - Assert.True(siBaseUnits.Equals(siBaseUnitsCopy)); - Assert.True(siBaseUnitsCopy.Equals(siBaseUnits)); + Assert.True(SIBaseUnits.Equals(SIBaseUnitsCopy)); + Assert.True(SIBaseUnitsCopy.Equals(SIBaseUnits)); - Assert.False(siBaseUnits.Equals(nonSiBaseUnits)); - Assert.False(nonSiBaseUnits.Equals(siBaseUnits)); + Assert.False(SIBaseUnits.Equals(NonSiBaseUnits)); + Assert.False(NonSiBaseUnits.Equals(SIBaseUnits)); - Assert.False(siBaseUnits.Equals(null)); + Assert.False(SIBaseUnits.Equals(null!)); } [Fact] public void EqualityOperatorIsImplementedCorrectly() { - Assert.True(siBaseUnits == siBaseUnitsCopy); - Assert.True(siBaseUnitsCopy == siBaseUnits); + Assert.True(SIBaseUnits == SIBaseUnitsCopy); + Assert.True(SIBaseUnitsCopy == SIBaseUnits); - Assert.False(siBaseUnits == nonSiBaseUnits); - Assert.False(nonSiBaseUnits == siBaseUnits); + Assert.False(SIBaseUnits == NonSiBaseUnits); + Assert.False(NonSiBaseUnits == SIBaseUnits); - Assert.False(siBaseUnits == null); - Assert.False(null == siBaseUnits); + Assert.False(SIBaseUnits == null); + Assert.False(null == SIBaseUnits); BaseUnits nullBaseUnits1 = null; BaseUnits nullBaseUnits2 = null; @@ -76,14 +76,14 @@ public void EqualityOperatorIsImplementedCorrectly() [Fact] public void InequalityOperatorIsImplementedCorrectly() { - Assert.False(siBaseUnits != siBaseUnitsCopy); - Assert.False(siBaseUnitsCopy != siBaseUnits); + Assert.False(SIBaseUnits != SIBaseUnitsCopy); + Assert.False(SIBaseUnitsCopy != SIBaseUnits); - Assert.True(siBaseUnits != nonSiBaseUnits); - Assert.True(nonSiBaseUnits != siBaseUnits); + Assert.True(SIBaseUnits != NonSiBaseUnits); + Assert.True(NonSiBaseUnits != SIBaseUnits); - Assert.True(siBaseUnits != null); - Assert.True(null != siBaseUnits); + Assert.True(SIBaseUnits != null); + Assert.True(null != SIBaseUnits); BaseUnits nullBaseUnits1 = null; BaseUnits nullBaseUnits2 = null; @@ -112,20 +112,20 @@ public void UndefinedIsSubsetOfUndefined() [Fact] public void IsSubsetOfReturnsFalseWithNull() { - Assert.False(siBaseUnits.IsSubsetOf(null)); + Assert.False(SIBaseUnits.IsSubsetOf(null!)); } [Fact] public void ExistsInWorksCorrectly() { - Assert.False(BaseUnits.Undefined.IsSubsetOf(siBaseUnits)); - Assert.False(siBaseUnits.IsSubsetOf(BaseUnits.Undefined)); + Assert.False(BaseUnits.Undefined.IsSubsetOf(SIBaseUnits)); + Assert.False(SIBaseUnits.IsSubsetOf(BaseUnits.Undefined)); var meterBaseUnits = new BaseUnits(LengthUnit.Meter); - Assert.True(meterBaseUnits.IsSubsetOf(siBaseUnits)); + Assert.True(meterBaseUnits.IsSubsetOf(SIBaseUnits)); // Not all units in siBaseUnits will exist in meterBaseUnits - Assert.False(siBaseUnits.IsSubsetOf(meterBaseUnits)); + Assert.False(SIBaseUnits.IsSubsetOf(meterBaseUnits)); } [Fact] @@ -144,7 +144,7 @@ public void IsFullyDefined_TrueIfAllBaseUnitDefined() ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela).IsFullyDefined); } - + [Fact] public void IsFullyDefined_FalseIfAnyBaseUnitIsUndefined() { diff --git a/UnitsNet.Tests/CustomCode/PressureTests.cs b/UnitsNet.Tests/CustomCode/PressureTests.cs index ef560dda04..2f66605a9f 100644 --- a/UnitsNet.Tests/CustomCode/PressureTests.cs +++ b/UnitsNet.Tests/CustomCode/PressureTests.cs @@ -3,7 +3,7 @@ using System; using UnitsNet.CustomCode.Units; -using UnitsNet.CustomCode.Wrappers; +using UnitsNet.Wrappers; using Xunit; namespace UnitsNet.Tests.CustomCode diff --git a/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs b/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs index bc3ea93e2d..9a4b07a973 100644 --- a/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs +++ b/UnitsNet.Tests/CustomCode/TemperatureChangeRateTests.cs @@ -24,6 +24,6 @@ public class TemperatureChangeRateTests : TemperatureChangeRateTestsBase protected override double NanodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond => 1E9; - protected override double DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond => 60; + protected override double DegreesCelsiusPerMinuteInOneDegreeCelsiusPerSecond => 60; } } diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index ca10677cb0..11fd05118f 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -28,16 +28,6 @@ public string ToString(IFormatProvider? provider) throw new NotImplementedException(); } - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - throw new NotImplementedException(); - } - - public string ToString(IFormatProvider? provider, string format, params object[] args) - { - throw new NotImplementedException(); - } - public string ToString(string? format, IFormatProvider? formatProvider) { throw new NotImplementedException(); diff --git a/UnitsNet.Tests/QuantityIConvertibleTests.cs b/UnitsNet.Tests/QuantityIConvertibleTests.cs index b514a657a9..23bcf4f588 100644 --- a/UnitsNet.Tests/QuantityIConvertibleTests.cs +++ b/UnitsNet.Tests/QuantityIConvertibleTests.cs @@ -7,174 +7,174 @@ namespace UnitsNet.Tests { public class QuantityIConvertibleTests { - private static Length length = Length.FromMeters(3.0); - private static IConvertible lengthAsIConvertible = Length.FromMeters(3.0); + private static Length _length = Length.FromMeters(3.0); + private static readonly IConvertible LengthAsIConvertible = Length.FromMeters(3.0); [Fact] public void GetTypeCodeTest() { - Assert.Equal(TypeCode.Object, lengthAsIConvertible.GetTypeCode()); - Assert.Equal(TypeCode.Object, Convert.GetTypeCode(length)); + Assert.Equal(TypeCode.Object, LengthAsIConvertible.GetTypeCode()); + Assert.Equal(TypeCode.Object, Convert.GetTypeCode(_length)); } [Fact] public void ToBooleanTest() { - Assert.Throws(() => lengthAsIConvertible.ToBoolean(null)); - Assert.Throws(() => Convert.ToBoolean(length)); - Assert.Throws(() => Convert.ChangeType(length, typeof(bool))); + Assert.Throws(() => LengthAsIConvertible.ToBoolean(null)); + Assert.Throws(() => Convert.ToBoolean(_length)); + Assert.Throws(() => Convert.ChangeType(_length, typeof(bool))); } [Fact] public void ToByteTest() { byte expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToByte(null)); - Assert.Equal(expected, Convert.ToByte(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(byte))); + Assert.Equal(expected, LengthAsIConvertible.ToByte(null)); + Assert.Equal(expected, Convert.ToByte(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(byte))); } [Fact] public void ToCharTest() { - Assert.Throws(() => lengthAsIConvertible.ToChar(null)); - Assert.Throws(() => Convert.ToChar(length)); - Assert.Throws(() => Convert.ChangeType(length, typeof(char))); + Assert.Throws(() => LengthAsIConvertible.ToChar(null)); + Assert.Throws(() => Convert.ToChar(_length)); + Assert.Throws(() => Convert.ChangeType(_length, typeof(char))); } [Fact] public void ToDateTimeTest() { - Assert.Throws(() => lengthAsIConvertible.ToDateTime(null)); - Assert.Throws(() => Convert.ToDateTime(length)); - Assert.Throws(() => Convert.ChangeType(length, typeof(DateTime))); + Assert.Throws(() => LengthAsIConvertible.ToDateTime(null)); + Assert.Throws(() => Convert.ToDateTime(_length)); + Assert.Throws(() => Convert.ChangeType(_length, typeof(DateTime))); } [Fact] public void ToDecimalTest() { decimal expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToDecimal(null)); - Assert.Equal(expected, Convert.ToDecimal(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(decimal))); + Assert.Equal(expected, LengthAsIConvertible.ToDecimal(null)); + Assert.Equal(expected, Convert.ToDecimal(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(decimal))); } [Fact] public void ToDoubleTest() { double expected = 3.0; - Assert.Equal(expected, lengthAsIConvertible.ToDouble(null)); - Assert.Equal(expected, Convert.ToDouble(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(double))); + Assert.Equal(expected, LengthAsIConvertible.ToDouble(null)); + Assert.Equal(expected, Convert.ToDouble(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(double))); } [Fact] public void ToInt16Test() { short expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToInt16(null)); - Assert.Equal(expected, Convert.ToInt16(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(short))); + Assert.Equal(expected, LengthAsIConvertible.ToInt16(null)); + Assert.Equal(expected, Convert.ToInt16(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(short))); } [Fact] public void ToInt32Test() { int expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToInt32(null)); - Assert.Equal(expected, Convert.ToInt32(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(int))); + Assert.Equal(expected, LengthAsIConvertible.ToInt32(null)); + Assert.Equal(expected, Convert.ToInt32(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(int))); } [Fact] public void ToInt64Test() { long expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToInt64(null)); - Assert.Equal(expected, Convert.ToInt64(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(long))); + Assert.Equal(expected, LengthAsIConvertible.ToInt64(null)); + Assert.Equal(expected, Convert.ToInt64(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(long))); } [Fact] public void ToSByteTest() { sbyte expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToSByte(null)); - Assert.Equal(expected, Convert.ToSByte(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(sbyte))); + Assert.Equal(expected, LengthAsIConvertible.ToSByte(null)); + Assert.Equal(expected, Convert.ToSByte(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(sbyte))); } [Fact] public void ToSingleTest() { float expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToSingle(null)); - Assert.Equal(expected, Convert.ToSingle(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(float))); + Assert.Equal(expected, LengthAsIConvertible.ToSingle(null)); + Assert.Equal(expected, Convert.ToSingle(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(float))); } [Fact] public void ToStringTest() { - string expected = length.ToString(CultureInfo.CurrentUICulture); - Assert.Equal(expected, lengthAsIConvertible.ToString(CultureInfo.CurrentUICulture)); - Assert.Equal(expected, Convert.ToString(length, CultureInfo.CurrentUICulture)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(string), CultureInfo.CurrentUICulture)); + string expected = _length.ToString(CultureInfo.CurrentUICulture); + Assert.Equal(expected, LengthAsIConvertible.ToString(CultureInfo.CurrentUICulture)); + Assert.Equal(expected, Convert.ToString(_length, CultureInfo.CurrentUICulture)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(string), CultureInfo.CurrentUICulture)); } [Fact] public void ToTypeTest() { // Same quantity type - Assert.Equal(length, lengthAsIConvertible.ToType(typeof(Length), null)); - Assert.Equal(length, Convert.ChangeType(length, typeof(Length))); + Assert.Equal(_length, LengthAsIConvertible.ToType(typeof(Length), null)); + Assert.Equal(_length, Convert.ChangeType(_length, typeof(Length))); // Same unit type - Assert.Equal(length.Unit, lengthAsIConvertible.ToType(typeof(LengthUnit), null)); - Assert.Equal(length.Unit, Convert.ChangeType(length, typeof(LengthUnit))); + Assert.Equal(_length.Unit, LengthAsIConvertible.ToType(typeof(LengthUnit), null)); + Assert.Equal(_length.Unit, Convert.ChangeType(_length, typeof(LengthUnit))); // Different type - Assert.Throws(() => lengthAsIConvertible.ToType(typeof(Duration), null)); - Assert.Throws(() => Convert.ChangeType(length, typeof(Duration))); + Assert.Throws(() => LengthAsIConvertible.ToType(typeof(Duration), null)); + Assert.Throws(() => Convert.ChangeType(_length, typeof(Duration))); // Different unit type - Assert.Throws(() => lengthAsIConvertible.ToType(typeof(DurationUnit), null)); - Assert.Throws(() => Convert.ChangeType(length, typeof(DurationUnit))); + Assert.Throws(() => LengthAsIConvertible.ToType(typeof(DurationUnit), null)); + Assert.Throws(() => Convert.ChangeType(_length, typeof(DurationUnit))); // QuantityInfo - Assert.Equal(Length.Info, lengthAsIConvertible.ToType(typeof(QuantityInfo), null)); - Assert.Equal(Length.Info, Convert.ChangeType(length, typeof(QuantityInfo))); + Assert.Equal(Length.Info, LengthAsIConvertible.ToType(typeof(QuantityInfo), null)); + Assert.Equal(Length.Info, Convert.ChangeType(_length, typeof(QuantityInfo))); // BaseDimensions - Assert.Equal(Length.BaseDimensions, lengthAsIConvertible.ToType(typeof(BaseDimensions), null)); - Assert.Equal(Length.BaseDimensions, Convert.ChangeType(length, typeof(BaseDimensions))); + Assert.Equal(Length.BaseDimensions, LengthAsIConvertible.ToType(typeof(BaseDimensions), null)); + Assert.Equal(Length.BaseDimensions, Convert.ChangeType(_length, typeof(BaseDimensions))); } [Fact] public void ToUInt16Test() { ushort expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToUInt16(null)); - Assert.Equal(expected, Convert.ToUInt16(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(ushort))); + Assert.Equal(expected, LengthAsIConvertible.ToUInt16(null)); + Assert.Equal(expected, Convert.ToUInt16(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(ushort))); } [Fact] public void ToUInt32Test() { uint expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToUInt32(null)); - Assert.Equal(expected, Convert.ToUInt32(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(uint))); + Assert.Equal(expected, LengthAsIConvertible.ToUInt32(null)); + Assert.Equal(expected, Convert.ToUInt32(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(uint))); } [Fact] public void ToUInt64Test() { ulong expected = 3; - Assert.Equal(expected, lengthAsIConvertible.ToUInt64(null)); - Assert.Equal(expected, Convert.ToUInt64(length)); - Assert.Equal(expected, Convert.ChangeType(length, typeof(ulong))); + Assert.Equal(expected, LengthAsIConvertible.ToUInt64(null)); + Assert.Equal(expected, Convert.ToUInt64(_length)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(ulong))); } } } diff --git a/UnitsNet.Tests/QuantityTest.cs b/UnitsNet.Tests/QuantityTest.cs index 129e288835..b0885167a1 100644 --- a/UnitsNet.Tests/QuantityTest.cs +++ b/UnitsNet.Tests/QuantityTest.cs @@ -96,7 +96,7 @@ public void GetUnitInfo_ThrowsKeyNotFoundExceptionIfNotFound() [Fact] public void TryGetUnitInfo_ReturnsFalseIfNotFound() { - bool found = Quantity.TryGetUnitInfo(ConsoleColor.Red, out UnitInfo unitInfo); + bool found = Quantity.TryGetUnitInfo(ConsoleColor.Red, out _); Assert.False(found); } diff --git a/UnitsNet.Tests/QuantityTypeConverterTest.cs b/UnitsNet.Tests/QuantityTypeConverterTest.cs index 6d1b587aed..60b2d32762 100644 --- a/UnitsNet.Tests/QuantityTypeConverterTest.cs +++ b/UnitsNet.Tests/QuantityTypeConverterTest.cs @@ -35,7 +35,7 @@ static QuantityTypeConverterTest() /// /// Is used for tests that are culture dependent /// - private static CultureInfo culture = CultureInfo.GetCultureInfo("en-US"); + private static readonly CultureInfo Culture = CultureInfo.GetCultureInfo("en-US"); [Theory] [InlineData(typeof(string), true)] @@ -77,7 +77,7 @@ public void ConvertFrom_GivenQuantityStringAndContextWithNoAttributes_ReturnsQua var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - var convertedValue = (Length)converter.ConvertFrom(context, culture, str); + var convertedValue = (Length)converter.ConvertFrom(context, Culture, str); Assert.Equal(expectedValue, convertedValue.Value); Assert.Equal(expectedUnit, convertedValue.Unit); @@ -96,7 +96,7 @@ public void ConvertFrom_GivenQuantityStringAndContextWithDefaultUnitAttribute_Re new DefaultUnitAttribute(Units.LengthUnit.Centimeter) }); - var convertedValue = (Length)converter.ConvertFrom(context, culture, str); + var convertedValue = (Length)converter.ConvertFrom(context, Culture, str); Assert.Equal(expectedValue, convertedValue.Value); Assert.Equal(expectedUnit, convertedValue.Unit); @@ -116,7 +116,7 @@ public void ConvertFrom_GivenQuantityStringAndContextWithDefaultUnitAndConvertTo new ConvertToUnitAttribute(Units.LengthUnit.Meter) }); - var convertedValue = (Length)converter.ConvertFrom(context, culture, str); + var convertedValue = (Length)converter.ConvertFrom(context, Culture, str); Assert.Equal(expectedValue, convertedValue.Value); Assert.Equal(expectedUnit, convertedValue.Unit); @@ -128,7 +128,7 @@ public void ConvertFrom_GivenEmptyString_ThrowsNotSupportedException() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Throws(() => converter.ConvertFrom(context, culture, "")); + Assert.Throws(() => converter.ConvertFrom(context, Culture, "")); } [Fact] @@ -137,7 +137,7 @@ public void ConvertFrom_GivenWrongQuantity_ThrowsArgumentException() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Throws(() => converter.ConvertFrom(context, culture, "1m^2")); + Assert.Throws(() => converter.ConvertFrom(context, Culture, "1m^2")); } [Theory] @@ -147,7 +147,6 @@ public void ConvertFrom_GivenWrongQuantity_ThrowsArgumentException() public void ConvertTo_GivenWrongType_ThrowsNotSupportedException(Type value) { var converter = new QuantityTypeConverter(); - ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); Length length = Length.FromMeters(1); Assert.Throws(() => converter.ConvertTo(length, value)); @@ -157,7 +156,6 @@ public void ConvertTo_GivenWrongType_ThrowsNotSupportedException(Type value) public void ConvertTo_GivenStringType_ReturnsQuantityString() { var converter = new QuantityTypeConverter(); - ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); Length length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(length, typeof(string)); @@ -172,7 +170,7 @@ public void ConvertTo_GivenSomeQuantityAndContextWithNoAttributes_ReturnsQuantit ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); Length length = Length.FromMeters(1); - string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); + string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); Assert.Equal("1 m", convertedQuantity); } @@ -184,7 +182,7 @@ public void ConvertTo_GivenSomeQuantityAndContextWithoutProperty_ReturnsQuantity ITypeDescriptorContext context = new TypeDescriptorContext(); Length length = Length.FromMeters(1); - string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); + string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); Assert.Equal("1 m", convertedQuantity); } @@ -199,7 +197,7 @@ public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUn }); Length length = Length.FromMeters(1); - string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); + string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); Assert.Equal("10 dm", convertedQuantity); } @@ -214,7 +212,7 @@ public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUn }); Length length = Length.FromMeters(1); - string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); + string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); Assert.Equal("10", convertedQuantity); } @@ -229,7 +227,7 @@ public void ConvertTo_TestDisplayAsFormattingWithoutDefinedUnit_ReturnsQuantityS }); Length length = Length.FromMeters(1); - string convertedQuantity = (string)converter.ConvertTo(context, culture, length, typeof(string)); + string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); Assert.Equal("1", convertedQuantity); } @@ -245,7 +243,7 @@ public void ConvertTo_GivenSomeQuantityAndContextWithDisplayAsUnitAttributes_Ret Length length = Length.FromMeters(1); string convertedQuantityDefaultCulture = (string)converter.ConvertTo(length, typeof(string)); - string convertedQuantitySpecificCulture = (string)converter.ConvertTo(context, culture, length, typeof(string)); + string convertedQuantitySpecificCulture = (string)converter.ConvertTo(context, Culture, length, typeof(string)); Assert.Equal("1 m", convertedQuantityDefaultCulture); Assert.Equal("10 dm", convertedQuantitySpecificCulture); @@ -260,7 +258,7 @@ public void ConvertFrom_GivenDefaultUnitAttributeWithWrongUnitType_ThrowsArgumen new DefaultUnitAttribute(Units.VolumeUnit.CubicMeter) }); - Assert.Throws(() => converter.ConvertFrom(context, culture, "1")); + Assert.Throws(() => converter.ConvertFrom(context, Culture, "1")); } [Fact] @@ -269,8 +267,8 @@ public void ConvertFrom_GivenStringWithPower_1() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, culture, "1m")); - Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, culture, "1m^1")); + Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, Culture, "1m")); + Assert.Equal(Length.FromMeters(1), converter.ConvertFrom(context, Culture, "1m^1")); } [Fact] @@ -279,8 +277,8 @@ public void ConvertFrom_GivenStringWithPower_2() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, culture, "1m²")); - Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, culture, "1m^2")); + Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, Culture, "1m²")); + Assert.Equal(Area.FromSquareMeters(1), converter.ConvertFrom(context, Culture, "1m^2")); } [Fact] @@ -289,8 +287,8 @@ public void ConvertFrom_GivenStringWithPower_3() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, culture, "1m³")); - Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, culture, "1m^3")); + Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, Culture, "1m³")); + Assert.Equal(Volume.FromCubicMeters(1), converter.ConvertFrom(context, Culture, "1m^3")); } [Fact] @@ -299,8 +297,8 @@ public void ConvertFrom_GivenStringWithPower_4() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, culture, "1m⁴")); - Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, culture, "1m^4")); + Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, Culture, "1m⁴")); + Assert.Equal(AreaMomentOfInertia.FromMetersToTheFourth(1), converter.ConvertFrom(context, Culture, "1m^4")); } [Fact] @@ -309,8 +307,8 @@ public void ConvertFrom_GivenStringWithPower_minus1() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, culture, "1K⁻¹")); - Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, culture, "1K^-1")); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, Culture, "1K⁻¹")); + Assert.Equal(CoefficientOfThermalExpansion.FromInverseKelvin(1), converter.ConvertFrom(context, Culture, "1K^-1")); } [Fact] @@ -319,9 +317,9 @@ public void ConvertFrom_GivenStringWithPower_minus2() var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { }); - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg·s⁻¹·m⁻²")); - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg·s^-1·m^-2")); - Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, culture, "1kg*s^-1*m^-2")); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, Culture, "1kg·s⁻¹·m⁻²")); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, Culture, "1kg·s^-1·m^-2")); + Assert.Equal(MassFlux.FromKilogramsPerSecondPerSquareMeter(1), converter.ConvertFrom(context, Culture, "1kg*s^-1*m^-2")); } } } diff --git a/UnitsNet.Tests/UnitSystemTests.cs b/UnitsNet.Tests/UnitSystemTests.cs index b0da0923ca..a1463f5cb7 100644 --- a/UnitsNet.Tests/UnitSystemTests.cs +++ b/UnitsNet.Tests/UnitSystemTests.cs @@ -138,9 +138,6 @@ public void InequalityOperatorIsImplementedCorrectly() [Fact] public void SIUnitSystemHasCorrectBaseUnits() { - var siBaseUnits = new BaseUnits(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, - ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela); - Assert.Equal(LengthUnit.Meter, UnitSystem.SI.BaseUnits.Length); Assert.Equal(MassUnit.Kilogram, UnitSystem.SI.BaseUnits.Mass); Assert.Equal(DurationUnit.Second, UnitSystem.SI.BaseUnits.Time); diff --git a/UnitsNet/BaseDimensions.cs b/UnitsNet/BaseDimensions.cs index 1b2f8c70ff..92a1fc1b3e 100644 --- a/UnitsNet/BaseDimensions.cs +++ b/UnitsNet/BaseDimensions.cs @@ -30,7 +30,7 @@ public BaseDimensions(int length, int mass, int time, int current, int temperatu /// True if the dimensions represent a base quantity, otherwise false. public bool IsBaseQuantity() { - var dimensionsArray = new int[]{Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity}; + var dimensionsArray = new[] { Length, Mass, Time, Current, Temperature, Amount, LuminousIntensity }; bool onlyOneEqualsOne = dimensionsArray.Where(dimension => dimension == 1).Take(2).Count() == 1; return onlyOneEqualsOne; } @@ -54,20 +54,18 @@ public bool IsDimensionless() } /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { - if(obj is null || !(obj is BaseDimensions)) + if (obj is not BaseDimensions other) return false; - var other = (BaseDimensions)obj; - return Length == other.Length && - Mass == other.Mass && - Time == other.Time && - Current == other.Current && - Temperature == other.Temperature && - Amount == other.Amount && - LuminousIntensity == other.LuminousIntensity; + Mass == other.Mass && + Time == other.Time && + Current == other.Current && + Temperature == other.Temperature && + Amount == other.Amount && + LuminousIntensity == other.LuminousIntensity; } /// @@ -122,9 +120,9 @@ public BaseDimensions Divide(BaseDimensions right) /// Left. /// Right. /// True if equal. - public static bool operator ==(BaseDimensions left, BaseDimensions right) + public static bool operator ==(BaseDimensions? left, BaseDimensions? right) { - return left is null ? right is null : left.Equals(right); + return left?.Equals(right!) ?? right is null; } /// @@ -146,10 +144,8 @@ public BaseDimensions Divide(BaseDimensions right) /// Resulting dimensions. public static BaseDimensions operator *(BaseDimensions left, BaseDimensions right) { - if(left is null) - throw new ArgumentNullException(nameof(left)); - else if(right is null) - throw new ArgumentNullException(nameof(right)); + if (left is null) throw new ArgumentNullException(nameof(left)); + if (right is null) throw new ArgumentNullException(nameof(right)); return left.Multiply(right); } @@ -162,10 +158,8 @@ public BaseDimensions Divide(BaseDimensions right) /// Resulting dimensions. public static BaseDimensions operator /(BaseDimensions left, BaseDimensions right) { - if(left is null) - throw new ArgumentNullException(nameof(left)); - else if(right is null) - throw new ArgumentNullException(nameof(right)); + if (left is null) throw new ArgumentNullException(nameof(left)); + if (right is null) throw new ArgumentNullException(nameof(right)); return left.Divide(right); } diff --git a/UnitsNet/BaseUnits.cs b/UnitsNet/BaseUnits.cs index cfcf559eb1..03f192edc3 100644 --- a/UnitsNet/BaseUnits.cs +++ b/UnitsNet/BaseUnits.cs @@ -57,12 +57,9 @@ public BaseUnits( } /// - public override bool Equals(object obj) + public override bool Equals(object? obj) { - if(obj is null || !(obj is BaseUnits)) - return false; - - return Equals((BaseUnits)obj); + return obj is BaseUnits other && Equals(other); } /// @@ -70,9 +67,9 @@ public override bool Equals(object obj) /// /// The other instance to check if equal to. /// True if equal, otherwise false. - public bool Equals(BaseUnits other) + public bool Equals(BaseUnits? other) { - if(other is null) + if (other is null) return false; return Length == other.Length && @@ -93,11 +90,8 @@ public bool Equals(BaseUnits other) /// True if the base units are a subset of other, otherwise false. public bool IsSubsetOf(BaseUnits other) { - if(other is null) - return false; - // If all base units are undefined, can only be a subset of another where all base units are undefined. - if(Equals(Undefined)) + if (Equals(Undefined)) return other.Equals(Undefined); return (Length == LengthUnit.Undefined || Length == other.Length) && @@ -122,9 +116,9 @@ public override int GetHashCode() /// The right instance. /// True if equal, otherwise false. /// - public static bool operator ==(BaseUnits left, BaseUnits right) + public static bool operator ==(BaseUnits? left, BaseUnits? right) { - return left is null ? right is null : left.Equals(right); + return left?.Equals(right!) ?? right is null; } /// diff --git a/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs b/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs index 6afa77213e..2d254b9c17 100644 --- a/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AreaMomentOfInertia.extra.cs @@ -1,8 +1,6 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. -using System; - namespace UnitsNet { public partial struct AreaMomentOfInertia diff --git a/UnitsNet/CustomCode/Quantities/Density.extra.cs b/UnitsNet/CustomCode/Quantities/Density.extra.cs index d0bc88d758..fd036dc519 100644 --- a/UnitsNet/CustomCode/Quantities/Density.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Density.extra.cs @@ -1,7 +1,6 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. -using System; using UnitsNet.Units; namespace UnitsNet diff --git a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs index 5caabbd03d..3e02c6e53d 100644 --- a/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassConcentration.extra.cs @@ -1,8 +1,6 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. -using UnitsNet.Units; - namespace UnitsNet { public partial struct MassConcentration diff --git a/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs index 85f4f8bae1..0a6bd6e6d9 100644 --- a/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs +++ b/UnitsNet/CustomCode/Quantities/SpecificWeight.extra.cs @@ -10,7 +10,7 @@ public partial struct SpecificWeight /// Get from times . public static Pressure operator *(SpecificWeight specificWeight, Length length) { - return new Pressure(specificWeight.NewtonsPerCubicMeter * length.Meters, UnitsNet.Units.PressureUnit.Pascal); + return new Pressure(specificWeight.NewtonsPerCubicMeter * length.Meters, PressureUnit.Pascal); } /// Get from times . @@ -28,13 +28,13 @@ public partial struct SpecificWeight /// Get from divided by . public static Acceleration operator /(SpecificWeight specificWeight, Density density) { - return new Acceleration(specificWeight.NewtonsPerCubicMeter / density.KilogramsPerCubicMeter, UnitsNet.Units.AccelerationUnit.MeterPerSecondSquared); + return new Acceleration(specificWeight.NewtonsPerCubicMeter / density.KilogramsPerCubicMeter, AccelerationUnit.MeterPerSecondSquared); } /// Get from divided by . public static Density operator /(SpecificWeight specific, Acceleration acceleration) { - return new Density(specific.NewtonsPerCubicMeter / acceleration.MetersPerSecondSquared, UnitsNet.Units.DensityUnit.KilogramPerCubicMeter); + return new Density(specific.NewtonsPerCubicMeter / acceleration.MetersPerSecondSquared, DensityUnit.KilogramPerCubicMeter); } } } diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index aa17c1e4d9..7ed646080f 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -28,7 +28,7 @@ internal class QuantityParser public static QuantityParser Default { get; } - public QuantityParser(UnitAbbreviationsCache unitAbbreviationsCache) + public QuantityParser(UnitAbbreviationsCache? unitAbbreviationsCache) { _unitAbbreviationsCache = unitAbbreviationsCache ?? UnitAbbreviationsCache.Default; _unitParser = new UnitParser(_unitAbbreviationsCache); @@ -49,13 +49,6 @@ internal TQuantity Parse(string str, if (str == null) throw new ArgumentNullException(nameof(str)); str = str.Trim(); - var numFormat = formatProvider != null - ? (NumberFormatInfo) formatProvider.GetFormat(typeof(NumberFormatInfo)) - : NumberFormatInfo.CurrentInfo; - - if (numFormat == null) - throw new InvalidOperationException($"No number format was found for the given format provider: {formatProvider}"); - var regex = CreateRegexForQuantity(formatProvider); if (!TryExtractValueAndUnit(regex, str, out var valueString, out var unitString)) @@ -81,19 +74,10 @@ internal bool TryParse(string? str, if(string.IsNullOrWhiteSpace(str)) return false; str = str!.Trim(); - var numFormat = formatProvider != null - ? (NumberFormatInfo) formatProvider.GetFormat(typeof(NumberFormatInfo)) - : NumberFormatInfo.CurrentInfo; - - if(numFormat == null) - return false; - var regex = CreateRegexForQuantity(formatProvider); - if (!TryExtractValueAndUnit(regex, str, out var valueString, out var unitString)) - return false; - - return TryParseWithRegex(valueString, unitString, fromDelegate, formatProvider, out result); + return TryExtractValueAndUnit(regex, str, out var valueString, out var unitString) && + TryParseWithRegex(valueString, unitString, fromDelegate, formatProvider, out result); } /// diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index 318ca23aae..b3396b4f5a 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -29,7 +29,7 @@ public sealed partial class UnitAbbreviationsCache /// culture, but no translation is defined, so we return the US English definition as a last resort. If it's not /// defined there either, an exception is thrown. /// - private static readonly CultureInfo FallbackCulture = new CultureInfo("en-US"); + private static readonly CultureInfo FallbackCulture = new("en-US"); /// /// The static instance used internally for ToString() and Parse() of quantities and units. @@ -95,7 +95,7 @@ public void MapUnitToDefaultAbbreviation(TUnitType unit, string abbre /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations to add. /// The type of unit enum. - public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider formatProvider, params string[] abbreviations) where TUnitType : Enum + public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider? formatProvider, params string[] abbreviations) where TUnitType : Enum { // Assuming TUnitType is an enum, this conversion is safe. Seems not possible to enforce this today. // Src: http://stackoverflow.com/questions/908543/how-to-convert-from-system-enum-to-base-integer @@ -115,7 +115,7 @@ public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider for /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviation to add as default. /// The type of unit enum. - public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvider formatProvider, string abbreviation) where TUnitType : Enum + public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvider? formatProvider, string abbreviation) where TUnitType : Enum { // Assuming TUnitType is an enum, this conversion is safe. Seems not possible to enforce this today. // Src: http://stackoverflow.com/questions/908543/how-to-convert-from-system-enum-to-base-integer @@ -135,7 +135,7 @@ public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvi /// The unit enum value. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations to add. - public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, params string[] abbreviations) + public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider, params string[] abbreviations) { PerformAbbreviationMapping(unitType, unitValue, formatProvider, false, abbreviations); } @@ -149,12 +149,12 @@ public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider /// The unit enum value. /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviation to add as default. - public void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider formatProvider, string abbreviation) + public void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider, string abbreviation) { PerformAbbreviationMapping(unitType, unitValue, formatProvider, true, abbreviation); } - private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider formatProvider, bool setAsDefault, params string[] abbreviations) + private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatProvider? formatProvider, bool setAsDefault, params string[] abbreviations) { if (!unitType.IsEnum) throw new ArgumentException("Must be an enum type.", nameof(unitType)); @@ -162,7 +162,7 @@ private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatPro if (abbreviations == null) throw new ArgumentNullException(nameof(abbreviations)); - formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; + formatProvider ??= CultureInfo.CurrentUICulture; if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) quantitiesForProvider = _lookupsForCulture[formatProvider] = new UnitTypeToLookup(); @@ -190,19 +190,17 @@ public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider? if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unit, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}"); + return !Equals(formatProvider, FallbackCulture) + ? GetDefaultAbbreviation(unit, FallbackCulture) + : throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}"); } var abbreviations = lookup!.GetAbbreviationsForUnit(unit); if(abbreviations.Count == 0) { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unit, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}"); + return !Equals(formatProvider, FallbackCulture) + ? GetDefaultAbbreviation(unit, FallbackCulture) + : throw new NotImplementedException($"No abbreviation is specified for {unitType.Name}.{unit}"); } return abbreviations.First(); @@ -221,19 +219,17 @@ public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvid { if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unitType, unitValue, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}."); + return !Equals(formatProvider, FallbackCulture) + ? GetDefaultAbbreviation(unitType, unitValue, FallbackCulture) + : throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}."); } var abbreviations = lookup!.GetAbbreviationsForUnit(unitValue); if(abbreviations.Count == 0) { - if(formatProvider != FallbackCulture) - return GetDefaultAbbreviation(unitType, unitValue, FallbackCulture); - else - throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}."); + return !Equals(formatProvider, FallbackCulture) + ? GetDefaultAbbreviation(unitType, unitValue, FallbackCulture) + : throw new NotImplementedException($"No abbreviation is specified for {unitType.Name} with numeric value {unitValue}."); } return abbreviations.First(); @@ -262,12 +258,20 @@ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvid { formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; - if(!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) - return formatProvider != FallbackCulture ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) : new string[] { }; + if (!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) + { + return !Equals(formatProvider, FallbackCulture) + ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) + : new string[] { }; + } var abbreviations = lookup!.GetAbbreviationsForUnit(unitValue); - if(abbreviations.Count == 0) - return formatProvider != FallbackCulture ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) : new string[] { }; + if (abbreviations.Count == 0) + { + return !Equals(formatProvider, FallbackCulture) + ? GetUnitAbbreviations(unitType, unitValue, FallbackCulture) + : new string[] { }; + } return abbreviations.ToArray(); } @@ -280,10 +284,14 @@ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvid /// Unit abbreviations associated with unit. public string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider? formatProvider = null) { - formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; + formatProvider ??= CultureInfo.CurrentUICulture; - if(!TryGetUnitValueAbbreviationLookup(unitEnumType, formatProvider, out var lookup)) - return formatProvider != FallbackCulture ? GetAllUnitAbbreviationsForQuantity(unitEnumType, FallbackCulture) : new string[] { }; + if (!TryGetUnitValueAbbreviationLookup(unitEnumType, formatProvider, out var lookup)) + { + return !Equals(formatProvider, FallbackCulture) + ? GetAllUnitAbbreviationsForQuantity(unitEnumType, FallbackCulture) + : new string[] { }; + } return lookup!.GetAllUnitAbbreviationsForQuantity(); } @@ -292,13 +300,19 @@ internal bool TryGetUnitValueAbbreviationLookup(Type unitType, IFormatProvider? { unitToAbbreviations = null; - formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; + formatProvider ??= CultureInfo.CurrentUICulture; - if(!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) - return formatProvider != FallbackCulture ? TryGetUnitValueAbbreviationLookup(unitType, FallbackCulture, out unitToAbbreviations) : false; + if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) + { + return !Equals(formatProvider, FallbackCulture) && + TryGetUnitValueAbbreviationLookup(unitType, FallbackCulture, out unitToAbbreviations); + } - if(!quantitiesForProvider.TryGetValue(unitType, out unitToAbbreviations)) - return formatProvider != FallbackCulture ? TryGetUnitValueAbbreviationLookup(unitType, FallbackCulture, out unitToAbbreviations) : false; + if (!quantitiesForProvider.TryGetValue(unitType, out unitToAbbreviations)) + { + return !Equals(formatProvider, FallbackCulture) && + TryGetUnitValueAbbreviationLookup(unitType, FallbackCulture, out unitToAbbreviations); + } return true; } diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs index 07e0a9f845..cce1e1d14c 100644 --- a/UnitsNet/CustomCode/UnitParser.cs +++ b/UnitsNet/CustomCode/UnitParser.cs @@ -28,7 +28,7 @@ public sealed class UnitParser /// Create a parser using the given unit abbreviations cache. /// /// - public UnitParser(UnitAbbreviationsCache unitAbbreviationsCache) + public UnitParser(UnitAbbreviationsCache? unitAbbreviationsCache) { _unitAbbreviationsCache = unitAbbreviationsCache ?? UnitAbbreviationsCache.Default; } diff --git a/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs b/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs index a82d3f7faf..96d21a32a0 100644 --- a/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs +++ b/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs @@ -12,27 +12,24 @@ namespace UnitsNet { internal class UnitValueAbbreviationLookup { - private readonly UnitToAbbreviationMap unitToAbbreviationMap = new UnitToAbbreviationMap(); - private readonly AbbreviationToUnitMap abbreviationToUnitMap = new AbbreviationToUnitMap(); - private readonly AbbreviationToUnitMap lowerCaseAbbreviationToUnitMap = new AbbreviationToUnitMap(); + private readonly UnitToAbbreviationMap _unitToAbbreviationMap = new(); + private readonly AbbreviationToUnitMap _abbreviationToUnitMap = new(); + private readonly AbbreviationToUnitMap _lowerCaseAbbreviationToUnitMap = new(); internal string[] GetAllUnitAbbreviationsForQuantity() { - return unitToAbbreviationMap.Values.SelectMany((abbreviations) => - { - return abbreviations; - } ).Distinct().ToArray(); + return _unitToAbbreviationMap.Values.SelectMany(abbreviations => abbreviations).Distinct().ToArray(); } - internal List GetAbbreviationsForUnit(UnitType unit) where UnitType : Enum + internal List GetAbbreviationsForUnit(TUnitType unit) where TUnitType : Enum { return GetAbbreviationsForUnit(Convert.ToInt32(unit)); } internal List GetAbbreviationsForUnit(int unit) { - if(!unitToAbbreviationMap.TryGetValue(unit, out var abbreviations)) - unitToAbbreviationMap[unit] = abbreviations = new List(); + if(!_unitToAbbreviationMap.TryGetValue(unit, out var abbreviations)) + _unitToAbbreviationMap[unit] = abbreviations = new List(); return abbreviations.Distinct().ToList(); } @@ -41,7 +38,7 @@ internal List GetUnitsForAbbreviation(string abbreviation, bool ignoreCase) { var lowerCaseAbbreviation = abbreviation.ToLower(); var key = ignoreCase ? lowerCaseAbbreviation : abbreviation; - var map = ignoreCase ? lowerCaseAbbreviationToUnitMap : abbreviationToUnitMap; + var map = ignoreCase ? _lowerCaseAbbreviationToUnitMap : _abbreviationToUnitMap; if(!map.TryGetValue(key, out List units)) map[key] = units = new List(); @@ -53,14 +50,14 @@ internal void Add(int unit, string abbreviation, bool setAsDefault = false) { var lowerCaseAbbreviation = abbreviation.ToLower(); - if(!unitToAbbreviationMap.TryGetValue(unit, out var abbreviationsForUnit)) - abbreviationsForUnit = unitToAbbreviationMap[unit] = new List(); + if(!_unitToAbbreviationMap.TryGetValue(unit, out var abbreviationsForUnit)) + abbreviationsForUnit = _unitToAbbreviationMap[unit] = new List(); - if(!abbreviationToUnitMap.TryGetValue(abbreviation, out var unitsForAbbreviation)) - abbreviationToUnitMap[abbreviation] = unitsForAbbreviation = new List(); + if(!_abbreviationToUnitMap.TryGetValue(abbreviation, out var unitsForAbbreviation)) + _abbreviationToUnitMap[abbreviation] = unitsForAbbreviation = new List(); - if(!lowerCaseAbbreviationToUnitMap.TryGetValue(lowerCaseAbbreviation, out var unitsForLowerCaseAbbreviation)) - lowerCaseAbbreviationToUnitMap[lowerCaseAbbreviation] = unitsForLowerCaseAbbreviation = new List(); + if(!_lowerCaseAbbreviationToUnitMap.TryGetValue(lowerCaseAbbreviation, out var unitsForLowerCaseAbbreviation)) + _lowerCaseAbbreviationToUnitMap[lowerCaseAbbreviation] = unitsForLowerCaseAbbreviation = new List(); unitsForLowerCaseAbbreviation.Remove(unit); unitsForLowerCaseAbbreviation.Add(unit); diff --git a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs index c11d4a34c9..16aa38ee17 100644 --- a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs +++ b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs @@ -2,12 +2,11 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using System.Collections.Generic; using System.Linq; using UnitsNet.CustomCode.Units; using UnitsNet.Units; -namespace UnitsNet.CustomCode.Wrappers +namespace UnitsNet.Wrappers { /// /// Pressure tied to a real-world reference, allowing conversion between references. diff --git a/UnitsNet/QuantityInfo.cs b/UnitsNet/QuantityInfo.cs index 0de49d6a22..5524ccf5eb 100644 --- a/UnitsNet/QuantityInfo.cs +++ b/UnitsNet/QuantityInfo.cs @@ -120,7 +120,7 @@ public IEnumerable GetUnitInfosFor(BaseUnits baseUnits) if(baseUnits is null) throw new ArgumentNullException(nameof(baseUnits)); - return UnitInfos.Where((unitInfo) => unitInfo.BaseUnits.IsSubsetOf(baseUnits)); + return UnitInfos.Where(unitInfo => unitInfo.BaseUnits.IsSubsetOf(baseUnits)); } } diff --git a/UnitsNet/QuantityTypeConverter.cs b/UnitsNet/QuantityTypeConverter.cs index dbbe2865ae..bed4ef40b3 100644 --- a/UnitsNet/QuantityTypeConverter.cs +++ b/UnitsNet/QuantityTypeConverter.cs @@ -10,7 +10,7 @@ namespace UnitsNet /// /// Is the base class for all attributes that are related to /// - [AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = true)] + [AttributeUsage(AttributeTargets.Property)] public abstract class UnitAttributeBase : Attribute { /// @@ -167,7 +167,7 @@ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceT /// An object. /// The conversion cannot be performed. /// Unit value is not a know unit enum type. - public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + public override object? ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object? value) { if (value is string stringValue && !string.IsNullOrEmpty(stringValue)) { @@ -184,7 +184,7 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c quantity = Quantity.Parse(culture, typeof(TQuantity), stringValue); } - if( quantity != null ) + if( quantity != null) { ConvertToUnitAttribute? convertToUnit = GetAttribute(context); if (convertToUnit != null && convertToUnit.UnitType != null) @@ -214,16 +214,15 @@ public override bool CanConvertTo(ITypeDescriptorContext context, Type destinati /// The to convert the parameter to. /// The parameter is null. /// The conversion cannot be performed. - public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + public override object? ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object? value, Type destinationType) { DisplayAsUnitAttribute? displayAsUnit = GetAttribute(context); if (value is IQuantity qvalue && destinationType == typeof(string) && displayAsUnit != null) { - if (displayAsUnit.UnitType != null) - return qvalue.ToUnit(displayAsUnit.UnitType).ToString(displayAsUnit.Format, culture); - else - return qvalue.ToString(displayAsUnit.Format, culture); + return displayAsUnit.UnitType != null + ? qvalue.ToUnit(displayAsUnit.UnitType).ToString(displayAsUnit.Format, culture) + : qvalue.ToString(displayAsUnit.Format, culture); } return base.ConvertTo(context, culture, value, destinationType); diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 069557583c..43a5b4bd1d 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -424,7 +424,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); - var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture); + var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture!); var fromUnit = UnitParser.Default.Parse(fromUnitAbbrev, unitType!, cultureInfo); // ex: ("m", LengthUnit) => LengthUnit.Meter var fromQuantity = Quantity.From(fromValue, fromUnit); @@ -499,7 +499,7 @@ public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quan if (!TryGetUnitType(quantityName, out Type? unitType)) return false; - var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture); + var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture!); if (!UnitParser.Default.TryParse(fromUnitAbbrev, unitType!, cultureInfo, out Enum? fromUnit)) // ex: ("m", LengthUnit) => LengthUnit.Meter return false; @@ -525,8 +525,8 @@ private static bool TryParseUnit(Type unitType, string unitName, out Enum? unitV { unitValue = null; var eNames = Enum.GetNames(unitType); - unitName = eNames.FirstOrDefault(x => x.Equals(unitName, StringComparison.OrdinalIgnoreCase)); - if (unitName == null) + var matchedUnitName = eNames.FirstOrDefault(x => x.Equals(unitName, StringComparison.OrdinalIgnoreCase)); + if (matchedUnitName == null) return false; unitValue = (Enum) Enum.Parse(unitType, unitName); @@ -535,7 +535,7 @@ private static bool TryParseUnit(Type unitType, string unitName, out Enum? unitV private static bool TryGetUnitType(string quantityName, out Type? unitType) { - var quantityInfo = Quantity.Infos.FirstOrDefault((info) => info.Name.Equals(quantityName, StringComparison.OrdinalIgnoreCase)); + var quantityInfo = Quantity.Infos.FirstOrDefault(info => info.Name.Equals(quantityName, StringComparison.OrdinalIgnoreCase)); unitType = quantityInfo?.UnitType; return quantityInfo != null; From c5c1227b5a12593a149ab6b205006b6d21fe6cf8 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:08:11 +0100 Subject: [PATCH 26/66] Fix spelling --- UnitsNet/CustomCode/QuantityParser.cs | 2 +- UnitsNet/QuantityTypeConverter.cs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/UnitsNet/CustomCode/QuantityParser.cs b/UnitsNet/CustomCode/QuantityParser.cs index 7ed646080f..b5f4ecb012 100644 --- a/UnitsNet/CustomCode/QuantityParser.cs +++ b/UnitsNet/CustomCode/QuantityParser.cs @@ -170,7 +170,7 @@ private static bool TryExtractValueAndUnit(Regex regex, string str, out string? // the regex coming in contains all allowed units as strings. // That means if the unit in str is not formatted right // the regex.Match will ether put str or string.empty into Groups[0] and Groups[1] - // Therefor a mismatch can be detected by comparing the values of this two groups. + // Therefore a mismatch can be detected by comparing the values of this two groups. if (match.Groups[0].Value == match.Groups[1].Value) { str = UnitParser.NormalizeUnitString(str); diff --git a/UnitsNet/QuantityTypeConverter.cs b/UnitsNet/QuantityTypeConverter.cs index bed4ef40b3..b8cb632fc6 100644 --- a/UnitsNet/QuantityTypeConverter.cs +++ b/UnitsNet/QuantityTypeConverter.cs @@ -58,7 +58,7 @@ public ConvertToUnitAttribute(object unitType) : base(unitType) { } public class DisplayAsUnitAttribute : DefaultUnitAttribute { /// - /// The formating used when the quantity is converted to string. See + /// The formatting used when the quantity is converted to string. See /// public string Format { get; set; } @@ -66,7 +66,7 @@ public class DisplayAsUnitAttribute : DefaultUnitAttribute /// Initializes a new instance of the class. /// /// The unit the quantity should be displayed in - /// Formating string + /// Formatting string public DisplayAsUnitAttribute(object unitType, string format = "") : base(unitType) { Format = format; @@ -76,7 +76,7 @@ public DisplayAsUnitAttribute(object unitType, string format = "") : base(unitTy /// /// /// Converts between IQuantity and string. - /// Implements a TypeConverter for IQuantitys. This allows eg the PropertyGrid to read and write properties of type IQuantity. + /// Implements a TypeConverter for IQuantities. This allows eg the PropertyGrid to read and write properties of type IQuantity. /// /// For basic understanding of TypeConverters consult the .NET documentation. /// @@ -107,7 +107,7 @@ public DisplayAsUnitAttribute(object unitType, string format = "") : base(unitTy /// Units.Length Length { get; set; } /// /// - /// + /// /// [DisplayAsUnit(UnitsNet.Units.LengthUnit.Meter, "g")] /// [TypeConverter(typeof(UnitsNetTypeConverter{Length}))] /// Units.Length Length { get; set; } From 2cf619a9204bb03fa2acfb7d0a1b800d06c4e1aa Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:08:21 +0100 Subject: [PATCH 27/66] Fix argex --- UnitsNet/CustomCode/Wrappers/ReferencePressure.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs index 16aa38ee17..8f57e91038 100644 --- a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs +++ b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs @@ -164,7 +164,7 @@ private double AsBaseReference() { if (Pressure.Value < 0) { - throw new ArgumentOutOfRangeException("Absolute pressure cannot be less than zero."); + throw new ArgumentOutOfRangeException(nameof(Pressure), "Absolute pressure cannot be less than zero."); } return Pressure.Value; @@ -173,7 +173,7 @@ private double AsBaseReference() { if (Pressure.Value * -1 > AtmosphericPressure.ToUnit(Pressure.Unit).Value) { - throw new ArgumentOutOfRangeException("Absolute pressure cannot be less than zero."); + throw new ArgumentOutOfRangeException(nameof(Pressure), "Absolute pressure cannot be less than zero."); } return AtmosphericPressure.ToUnit(Pressure.Unit).Value + Pressure.Value; @@ -182,7 +182,7 @@ private double AsBaseReference() { if (Pressure.Value > AtmosphericPressure.ToUnit(Pressure.Unit).Value) { - throw new ArgumentOutOfRangeException("Absolute pressure cannot be less than zero."); + throw new ArgumentOutOfRangeException(nameof(Pressure), "Absolute pressure cannot be less than zero."); } return AtmosphericPressure.ToUnit(Pressure.Unit).Value - Pressure.Value; From 6187c630a149da799b2cb63101c606b4940ebd12 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:08:55 +0100 Subject: [PATCH 28/66] UnitsNet: 5.0.0-alpha002 --- CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.AmountOfSubstance.nuspec | 2 +- .../UnitsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- .../UnitsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- .../ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../BitRate/UnitsNet.NanoFramework.BitRate.nuspec | 2 +- ...UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- ...nitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec | 2 +- .../Density/UnitsNet.NanoFramework.Density.nuspec | 2 +- .../Duration/UnitsNet.NanoFramework.Duration.nuspec | 2 +- .../UnitsNet.NanoFramework.DynamicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricAdmittance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCharge.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec | 2 +- .../ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricInductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotential.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialAc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialDc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistivity.nuspec | 2 +- ...UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../Entropy/UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- .../UnitsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../Frequency/UnitsNet.NanoFramework.Frequency.nuspec | 2 +- .../UnitsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec | 2 +- .../Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../Information/UnitsNet.NanoFramework.Information.nuspec | 2 +- .../Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- .../UnitsNet.NanoFramework.KinematicViscosity.nuspec | 2 +- .../LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec | 2 +- .../GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- .../LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- .../LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.LuminousIntensity.nuspec | 2 +- .../MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec | 2 +- .../MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- .../Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- .../UnitsNet.NanoFramework.MassConcentration.nuspec | 2 +- .../MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- .../MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- .../UnitsNet.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- .../MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../Molarity/UnitsNet.NanoFramework.Molarity.nuspec | 2 +- .../Permeability/UnitsNet.NanoFramework.Permeability.nuspec | 2 +- .../Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- .../PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../Pressure/UnitsNet.NanoFramework.Pressure.nuspec | 2 +- .../UnitsNet.NanoFramework.PressureChangeRate.nuspec | 2 +- .../GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- .../UnitsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- .../ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalLength.nuspec | 2 +- .../UnitsNet.NanoFramework.RelativeHumidity.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalAcceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffness.nuspec | 2 +- ...UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec | 2 +- .../GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificVolume.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- .../UnitsNet.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../Temperature/UnitsNet.NanoFramework.Temperature.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureDelta.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalResistance.nuspec | 2 +- .../GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec | 2 +- .../UnitsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeConcentration.nuspec | 2 +- .../VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec | 2 +- .../UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 4 ++-- UnitsNet/UnitsNet.csproj | 4 ++-- 113 files changed, 115 insertions(+), 115 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index a4a5d3db4c..0b7ea34bf8 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index a1fc09b17e..f7d9253ef2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Acceleration - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index 27f55a4389..ac1027660d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmountOfSubstance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index 9890947de6..de366d669c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmplitudeRatio - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index 1b307d7806..87d9d7236a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Angle - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 57fb50ecf7..96c4e8d824 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentEnergy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index fc3f56884c..64b10a0de0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentPower - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index 893177ed95..e3774bbcc0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Area - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index 263c0ce38c..4525af0acc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index df09f8b6b5..ac462ca796 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index 32e641ab7d..ff6f61b38a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BitRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 1c9925d23d..092101b916 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index 264be727e6..fe261ba3a2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Capacitance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index fc5339f5c0..4b1539a2da 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 51ed8c8f00..dfc4ae0be6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Density - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index e1b03f92d6..b8d90fb8c4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Duration - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 37ea9ca5e2..7d9020b066 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.DynamicViscosity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index 87c05156f2..a77755412a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricAdmittance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index 5618a9ea33..4fc686b1a7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCharge - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index adf680aafd..f5b19585c1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 440e565c56..df04c0360f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index cb78038f55..08a06f2bca 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductivity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 4b2b1d2428..f6c45307f9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrent - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index 8a79ad5fb4..b99bb79cba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index e39c260527..e07c02d152 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index 4efdf55afe..4903591df1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricField - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index a40ef906ca..d96e1953fe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricInductance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index 03e25ef962..e3bd87dda4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotential - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index 7e01617230..bdc19790a8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index f64a29e26e..55ea98f760 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index ca8eb157e9..9fea934fbb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 0e766fa393..334f71cfff 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index 134d5d6aa4..d5f3428e1d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistivity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index 5f04ac542b..3f8c7473b1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index 6f5a7d8413..b3fe684942 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Energy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 0c44aa9a17..53f519a2f5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Entropy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index c4b1b885fb..73b710870c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Force - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index 16f16eda02..050748b012 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForceChangeRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index 7c8980d7b2..f7b775ea56 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForcePerLength - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 755cf865f6..f3aa921395 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Frequency - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index 390524d587..6a578fc12c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.FuelEfficiency - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index b646d2db9d..41fbbef660 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatFlux - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index fdf1dd77c7..933a5c923d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index d77213cb1e..a17b3a41c7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Illuminance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index f35f5309c5..2324273f05 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Information - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index f382bfe5ba..775239f2b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index 3ea11e97f9..639acd2797 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiation - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index 869441fb02..f7b58e78d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.KinematicViscosity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index e5c2e29f44..4a3fbd1920 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LapseRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index 5b3b62b2ee..70d30cf6d5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Length - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index 7db084922d..d3ca70f6c0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Level - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index e4b8fc6204..46f149720d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index 29144a71a0..284fb0829a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearPowerDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index 778709e74a..c360fa7028 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Luminosity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 8cf132e9c2..fd607134ef 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousFlux - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index e46f8aaff9..653cf06117 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousIntensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index 5aaaaf70cb..23bc5d972f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticField - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 79bafea313..11194e3f37 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticFlux - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index eb3442b01e..61bed4419a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Magnetization - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index ada47b667e..e12e10e53a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Mass - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index 0b6d256e12..156fff358e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassConcentration - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 4a90ce8aae..2f430d5a08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlow - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index 3f3620a2e1..ee305b5f48 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlux - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 69b4d6ea6e..07888a431a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFraction - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index 475e49a5b4..a6ff1c4898 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index b97ed6a39a..fee894aefe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEnergy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index f633a24cff..09ab812a1c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEntropy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index d836f05002..f51f24bfb9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarMass - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 381dab84b6..7d6e1f465c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Molarity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 36575873cc..03272579cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permeability - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index 1374e8d844..b00e46ccb9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permittivity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index 0fb715cd32..7c57f73c7c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Power - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index c0182f5b7f..868db4af8d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerDensity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index c23bff0bde..5e62215e22 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerRatio - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 798c80cd81..c80f938546 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Pressure - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index e96ddabe4c..6bfcd7ef01 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PressureChangeRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index f2d44af979..bc0ccb4f77 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Ratio - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index 866a89cbe0..db90c9b009 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RatioChangeRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index efdc430029..1bf772170c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactiveEnergy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 2e4cea472a..3c0ff8b71f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactivePower - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index cf1e00c789..f8dc39ce17 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalArea - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 3c7b023ad3..6f49048d04 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalLength - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index c83f5fa97d..e2aa4fad35 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RelativeHumidity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index c2a6b4ce42..229ab64dc7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalAcceleration - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index a39490a45e..1ed95ee7b9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalSpeed - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index eeb43b46ea..3d3f8b56df 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffness - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index 978693b764..4a09b0279a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index a497fcbeb8..654e5a9812 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Scalar - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 45b7b2be00..45801bf390 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SolidAngle - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 1e0cd08f55..7156966615 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEnergy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index ebfcbef793..187c4b7548 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEntropy - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index a4629c50cb..65b8033832 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index e88e60cbeb..c3a68b4ddc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificVolume - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 05897da007..849e120343 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificWeight - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index 5f5bf0fee1..9c90bb3205 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Speed - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 488abbad58..4b9e9f2758 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index 44759b1152..50dada662f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Temperature - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 5414a15dd6..2e02c4253b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 4c87e7f173..366756a5b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureDelta - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index c50c773ff9..17c757848b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalConductivity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index eeceae37a2..df4d033caa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalResistance - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 983d17496a..55a929536a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Torque - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index a9633cf230..17ad374feb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TorquePerLength - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index cea033c1d3..721033aa27 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Turbidity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index 1b8dbbd95e..d9f2ce15a5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VitaminA - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index 05b0c463bd..91356993c0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Volume - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index e2091d4f67..554478a88a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeConcentration - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index 172d75c2d5..865fbdeed9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlow - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index d9da46988e..c7b2f59a03 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumePerLength - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 65ea3bd290..86fcc2acae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 29043b6d43..95347ffed1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 5.0.0-alpha001 + 5.0.0-alpha002 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index 02f256fa8d..bd98669f40 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -1,8 +1,8 @@ - + UnitsNet.NumberExtensions - 5.0.0-alpha001 + 5.0.0-alpha002 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 5d2563f779..dcca56e4c4 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -1,8 +1,8 @@ - + UnitsNet - 5.0.0-alpha001 + 5.0.0-alpha002 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. From fdbb778dee700d50e958c31217aa204e6ea2ac12 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:09:00 +0100 Subject: [PATCH 29/66] JsonNet: 5.0.0-alpha002 --- .../UnitsNet.Serialization.JsonNet.csproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 4d8966bf0d..18cf4add59 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -1,8 +1,8 @@ - + UnitsNet.Serialization.JsonNet - 5.0.0-alpha001 + 5.0.0-alpha002 Andreas Gullberg Larsen Units.NET Serialization with Json.NET A helper library for serializing and deserializing types in Units.NET using Json.NET. From f3c7e2559319b88219413348c0a27864ad0d306a Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:17:31 +0100 Subject: [PATCH 30/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20IEquatable=20a?= =?UTF-8?q?nd=20equality=20operators/methods?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid floating point rounding issues, uses should use Equals() methods instead. --- .../UnitsNetGen/QuantityGenerator.cs | 33 +------------- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 43 ------------------- .../TestsBase/AccelerationTestsBase.g.cs | 43 ------------------- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 43 ------------------- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 43 ------------------- .../TestsBase/AngleTestsBase.g.cs | 43 ------------------- .../TestsBase/ApparentEnergyTestsBase.g.cs | 43 ------------------- .../TestsBase/ApparentPowerTestsBase.g.cs | 43 ------------------- .../TestsBase/AreaDensityTestsBase.g.cs | 43 ------------------- .../AreaMomentOfInertiaTestsBase.g.cs | 43 ------------------- .../TestsBase/AreaTestsBase.g.cs | 43 ------------------- .../TestsBase/BitRateTestsBase.g.cs | 43 ------------------- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 43 ------------------- .../TestsBase/CapacitanceTestsBase.g.cs | 43 ------------------- ...oefficientOfThermalExpansionTestsBase.g.cs | 43 ------------------- .../TestsBase/DensityTestsBase.g.cs | 43 ------------------- .../TestsBase/DurationTestsBase.g.cs | 43 ------------------- .../TestsBase/DynamicViscosityTestsBase.g.cs | 43 ------------------- .../ElectricAdmittanceTestsBase.g.cs | 43 ------------------- .../ElectricChargeDensityTestsBase.g.cs | 43 ------------------- .../TestsBase/ElectricChargeTestsBase.g.cs | 43 ------------------- .../ElectricConductanceTestsBase.g.cs | 43 ------------------- .../ElectricConductivityTestsBase.g.cs | 43 ------------------- .../ElectricCurrentDensityTestsBase.g.cs | 43 ------------------- .../ElectricCurrentGradientTestsBase.g.cs | 43 ------------------- .../TestsBase/ElectricCurrentTestsBase.g.cs | 43 ------------------- .../TestsBase/ElectricFieldTestsBase.g.cs | 43 ------------------- .../ElectricInductanceTestsBase.g.cs | 43 ------------------- .../ElectricPotentialAcTestsBase.g.cs | 43 ------------------- .../ElectricPotentialChangeRateTestsBase.g.cs | 43 ------------------- .../ElectricPotentialDcTestsBase.g.cs | 43 ------------------- .../TestsBase/ElectricPotentialTestsBase.g.cs | 43 ------------------- .../ElectricResistanceTestsBase.g.cs | 43 ------------------- .../ElectricResistivityTestsBase.g.cs | 43 ------------------- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 43 ------------------- .../TestsBase/EnergyTestsBase.g.cs | 43 ------------------- .../TestsBase/EntropyTestsBase.g.cs | 43 ------------------- .../TestsBase/ForceChangeRateTestsBase.g.cs | 43 ------------------- .../TestsBase/ForcePerLengthTestsBase.g.cs | 43 ------------------- .../TestsBase/ForceTestsBase.g.cs | 43 ------------------- .../TestsBase/FrequencyTestsBase.g.cs | 43 ------------------- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 43 ------------------- .../TestsBase/HeatFluxTestsBase.g.cs | 43 ------------------- .../HeatTransferCoefficientTestsBase.g.cs | 43 ------------------- .../TestsBase/IlluminanceTestsBase.g.cs | 43 ------------------- .../TestsBase/InformationTestsBase.g.cs | 43 ------------------- .../TestsBase/IrradianceTestsBase.g.cs | 43 ------------------- .../TestsBase/IrradiationTestsBase.g.cs | 43 ------------------- .../KinematicViscosityTestsBase.g.cs | 43 ------------------- .../TestsBase/LapseRateTestsBase.g.cs | 43 ------------------- .../TestsBase/LengthTestsBase.g.cs | 43 ------------------- .../TestsBase/LevelTestsBase.g.cs | 43 ------------------- .../TestsBase/LinearDensityTestsBase.g.cs | 43 ------------------- .../LinearPowerDensityTestsBase.g.cs | 43 ------------------- .../TestsBase/LuminosityTestsBase.g.cs | 43 ------------------- .../TestsBase/LuminousFluxTestsBase.g.cs | 43 ------------------- .../TestsBase/LuminousIntensityTestsBase.g.cs | 43 ------------------- .../TestsBase/MagneticFieldTestsBase.g.cs | 43 ------------------- .../TestsBase/MagneticFluxTestsBase.g.cs | 43 ------------------- .../TestsBase/MagnetizationTestsBase.g.cs | 43 ------------------- .../TestsBase/MassConcentrationTestsBase.g.cs | 43 ------------------- .../TestsBase/MassFlowTestsBase.g.cs | 43 ------------------- .../TestsBase/MassFluxTestsBase.g.cs | 43 ------------------- .../TestsBase/MassFractionTestsBase.g.cs | 43 ------------------- .../MassMomentOfInertiaTestsBase.g.cs | 43 ------------------- .../TestsBase/MassTestsBase.g.cs | 43 ------------------- .../TestsBase/MolarEnergyTestsBase.g.cs | 43 ------------------- .../TestsBase/MolarEntropyTestsBase.g.cs | 43 ------------------- .../TestsBase/MolarMassTestsBase.g.cs | 43 ------------------- .../TestsBase/MolarityTestsBase.g.cs | 43 ------------------- .../TestsBase/PermeabilityTestsBase.g.cs | 43 ------------------- .../TestsBase/PermittivityTestsBase.g.cs | 43 ------------------- .../TestsBase/PowerDensityTestsBase.g.cs | 43 ------------------- .../TestsBase/PowerRatioTestsBase.g.cs | 43 ------------------- .../TestsBase/PowerTestsBase.g.cs | 43 ------------------- .../PressureChangeRateTestsBase.g.cs | 43 ------------------- .../TestsBase/PressureTestsBase.g.cs | 43 ------------------- .../TestsBase/RatioChangeRateTestsBase.g.cs | 43 ------------------- .../TestsBase/RatioTestsBase.g.cs | 43 ------------------- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 43 ------------------- .../TestsBase/ReactivePowerTestsBase.g.cs | 43 ------------------- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 43 ------------------- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 43 ------------------- .../TestsBase/RelativeHumidityTestsBase.g.cs | 43 ------------------- .../RotationalAccelerationTestsBase.g.cs | 43 ------------------- .../TestsBase/RotationalSpeedTestsBase.g.cs | 43 ------------------- ...RotationalStiffnessPerLengthTestsBase.g.cs | 43 ------------------- .../RotationalStiffnessTestsBase.g.cs | 43 ------------------- .../TestsBase/ScalarTestsBase.g.cs | 43 ------------------- .../TestsBase/SolidAngleTestsBase.g.cs | 43 ------------------- .../TestsBase/SpecificEnergyTestsBase.g.cs | 43 ------------------- .../TestsBase/SpecificEntropyTestsBase.g.cs | 43 ------------------- .../SpecificFuelConsumptionTestsBase.g.cs | 43 ------------------- .../TestsBase/SpecificVolumeTestsBase.g.cs | 43 ------------------- .../TestsBase/SpecificWeightTestsBase.g.cs | 43 ------------------- .../TestsBase/SpeedTestsBase.g.cs | 43 ------------------- .../StandardVolumeFlowTestsBase.g.cs | 43 ------------------- .../TemperatureChangeRateTestsBase.g.cs | 43 ------------------- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 43 ------------------- .../TestsBase/TemperatureTestsBase.g.cs | 43 ------------------- .../ThermalConductivityTestsBase.g.cs | 43 ------------------- .../TestsBase/ThermalResistanceTestsBase.g.cs | 43 ------------------- .../TestsBase/TorquePerLengthTestsBase.g.cs | 43 ------------------- .../TestsBase/TorqueTestsBase.g.cs | 43 ------------------- .../TestsBase/TurbidityTestsBase.g.cs | 43 ------------------- .../TestsBase/VitaminATestsBase.g.cs | 43 ------------------- .../VolumeConcentrationTestsBase.g.cs | 43 ------------------- .../TestsBase/VolumeFlowTestsBase.g.cs | 43 ------------------- .../TestsBase/VolumePerLengthTestsBase.g.cs | 43 ------------------- .../TestsBase/VolumeTestsBase.g.cs | 43 ------------------- .../VolumetricHeatCapacityTestsBase.g.cs | 43 ------------------- .../WarpingMomentOfInertiaTestsBase.g.cs | 43 ------------------- .../Quantities/Acceleration.g.cs | 33 +------------- .../Quantities/AmountOfSubstance.g.cs | 33 +------------- .../Quantities/AmplitudeRatio.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 33 +------------- .../Quantities/ApparentEnergy.g.cs | 33 +------------- .../Quantities/ApparentPower.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 33 +------------- .../GeneratedCode/Quantities/AreaDensity.g.cs | 33 +------------- .../Quantities/AreaMomentOfInertia.g.cs | 33 +------------- .../GeneratedCode/Quantities/BitRate.g.cs | 33 +------------- .../BrakeSpecificFuelConsumption.g.cs | 33 +------------- .../GeneratedCode/Quantities/Capacitance.g.cs | 33 +------------- .../CoefficientOfThermalExpansion.g.cs | 33 +------------- .../GeneratedCode/Quantities/Density.g.cs | 33 +------------- .../GeneratedCode/Quantities/Duration.g.cs | 33 +------------- .../Quantities/DynamicViscosity.g.cs | 33 +------------- .../Quantities/ElectricAdmittance.g.cs | 33 +------------- .../Quantities/ElectricCharge.g.cs | 33 +------------- .../Quantities/ElectricChargeDensity.g.cs | 33 +------------- .../Quantities/ElectricConductance.g.cs | 33 +------------- .../Quantities/ElectricConductivity.g.cs | 33 +------------- .../Quantities/ElectricCurrent.g.cs | 33 +------------- .../Quantities/ElectricCurrentDensity.g.cs | 33 +------------- .../Quantities/ElectricCurrentGradient.g.cs | 33 +------------- .../Quantities/ElectricField.g.cs | 33 +------------- .../Quantities/ElectricInductance.g.cs | 33 +------------- .../Quantities/ElectricPotential.g.cs | 33 +------------- .../Quantities/ElectricPotentialAc.g.cs | 33 +------------- .../ElectricPotentialChangeRate.g.cs | 33 +------------- .../Quantities/ElectricPotentialDc.g.cs | 33 +------------- .../Quantities/ElectricResistance.g.cs | 33 +------------- .../Quantities/ElectricResistivity.g.cs | 33 +------------- .../ElectricSurfaceChargeDensity.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 33 +------------- .../GeneratedCode/Quantities/Entropy.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 33 +------------- .../Quantities/ForceChangeRate.g.cs | 33 +------------- .../Quantities/ForcePerLength.g.cs | 33 +------------- .../GeneratedCode/Quantities/Frequency.g.cs | 33 +------------- .../Quantities/FuelEfficiency.g.cs | 33 +------------- .../GeneratedCode/Quantities/HeatFlux.g.cs | 33 +------------- .../Quantities/HeatTransferCoefficient.g.cs | 33 +------------- .../GeneratedCode/Quantities/Illuminance.g.cs | 33 +------------- .../GeneratedCode/Quantities/Information.g.cs | 33 +------------- .../GeneratedCode/Quantities/Irradiance.g.cs | 33 +------------- .../GeneratedCode/Quantities/Irradiation.g.cs | 33 +------------- .../Quantities/KinematicViscosity.g.cs | 33 +------------- .../GeneratedCode/Quantities/LapseRate.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 33 +------------- .../Quantities/LinearDensity.g.cs | 33 +------------- .../Quantities/LinearPowerDensity.g.cs | 33 +------------- .../GeneratedCode/Quantities/Luminosity.g.cs | 33 +------------- .../Quantities/LuminousFlux.g.cs | 33 +------------- .../Quantities/LuminousIntensity.g.cs | 33 +------------- .../Quantities/MagneticField.g.cs | 33 +------------- .../Quantities/MagneticFlux.g.cs | 33 +------------- .../Quantities/Magnetization.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 33 +------------- .../Quantities/MassConcentration.g.cs | 33 +------------- .../GeneratedCode/Quantities/MassFlow.g.cs | 33 +------------- .../GeneratedCode/Quantities/MassFlux.g.cs | 33 +------------- .../Quantities/MassFraction.g.cs | 33 +------------- .../Quantities/MassMomentOfInertia.g.cs | 33 +------------- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 33 +------------- .../Quantities/MolarEntropy.g.cs | 33 +------------- .../GeneratedCode/Quantities/MolarMass.g.cs | 33 +------------- .../GeneratedCode/Quantities/Molarity.g.cs | 33 +------------- .../Quantities/Permeability.g.cs | 33 +------------- .../Quantities/Permittivity.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 33 +------------- .../Quantities/PowerDensity.g.cs | 33 +------------- .../GeneratedCode/Quantities/PowerRatio.g.cs | 33 +------------- .../GeneratedCode/Quantities/Pressure.g.cs | 33 +------------- .../Quantities/PressureChangeRate.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 33 +------------- .../Quantities/RatioChangeRate.g.cs | 33 +------------- .../Quantities/ReactiveEnergy.g.cs | 33 +------------- .../Quantities/ReactivePower.g.cs | 33 +------------- .../Quantities/ReciprocalArea.g.cs | 33 +------------- .../Quantities/ReciprocalLength.g.cs | 33 +------------- .../Quantities/RelativeHumidity.g.cs | 33 +------------- .../Quantities/RotationalAcceleration.g.cs | 33 +------------- .../Quantities/RotationalSpeed.g.cs | 33 +------------- .../Quantities/RotationalStiffness.g.cs | 33 +------------- .../RotationalStiffnessPerLength.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 33 +------------- .../GeneratedCode/Quantities/SolidAngle.g.cs | 33 +------------- .../Quantities/SpecificEnergy.g.cs | 33 +------------- .../Quantities/SpecificEntropy.g.cs | 33 +------------- .../Quantities/SpecificFuelConsumption.g.cs | 33 +------------- .../Quantities/SpecificVolume.g.cs | 33 +------------- .../Quantities/SpecificWeight.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 33 +------------- .../Quantities/StandardVolumeFlow.g.cs | 33 +------------- .../GeneratedCode/Quantities/Temperature.g.cs | 33 +------------- .../Quantities/TemperatureChangeRate.g.cs | 33 +------------- .../Quantities/TemperatureDelta.g.cs | 33 +------------- .../Quantities/ThermalConductivity.g.cs | 33 +------------- .../Quantities/ThermalResistance.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 33 +------------- .../Quantities/TorquePerLength.g.cs | 33 +------------- .../GeneratedCode/Quantities/Turbidity.g.cs | 33 +------------- .../GeneratedCode/Quantities/VitaminA.g.cs | 33 +------------- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 33 +------------- .../Quantities/VolumeConcentration.g.cs | 33 +------------- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 33 +------------- .../Quantities/VolumePerLength.g.cs | 33 +------------- .../Quantities/VolumetricHeatCapacity.g.cs | 33 +------------- .../Quantities/WarpingMomentOfInertia.g.cs | 33 +------------- 222 files changed, 111 insertions(+), 8325 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index f514e0de55..3c39933687 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -77,7 +77,7 @@ public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); Writer.W("IDecimalQuantity, "); } - Writer.WL($"IEquatable<{_quantity.Name}>, IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); + Writer.WL($"IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); Writer.WL($@" {{ /// @@ -684,20 +684,6 @@ private void GenerateEqualityAndComparison() return left.Value > right.GetValueAs(left.Unit); }} - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) - {{ - return left.Equals(right); - }} - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) - {{ - return !(left == right); - }} - /// public int CompareTo(object obj) {{ @@ -713,23 +699,6 @@ public int CompareTo({_quantity.Name} other) return _value.CompareTo(other.GetValueAs(this.Unit)); }} - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - {{ - if(obj is null || !(obj is {_quantity.Name} obj{_quantity.Name})) - return false; - - return Equals(obj{_quantity.Name}); - }} - - /// - /// Consider using for safely comparing floating point values. - public bool Equals({_quantity.Name} other) - {{ - return _value.Equals(other.GetValueAs(this.Unit)); - }} - /// /// /// Compare equality to another {_quantity.Name} within the given absolute or relative tolerance. diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 2259ae8a22..6928bfc736 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -359,49 +359,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => {baseUnitVariableName}.CompareTo(null)); }} - [Fact] - public void EqualityOperators() - {{ - var a = {_quantity.Name}.From{_baseUnit.PluralName}(1); - var b = {_quantity.Name}.From{_baseUnit.PluralName}(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - }} - - [Fact] - public void Equals_SameType_IsImplemented() - {{ - var a = {_quantity.Name}.From{_baseUnit.PluralName}(1); - var b = {_quantity.Name}.From{_baseUnit.PluralName}(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - }} - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - {{ - object a = {_quantity.Name}.From{_baseUnit.PluralName}(1); - object b = {_quantity.Name}.From{_baseUnit.PluralName}(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - }} - [Fact] public void Equals_RelativeTolerance_IsImplemented() {{ diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 785d7fcd78..48b78e3959 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -404,49 +404,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => meterpersecondsquared.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Acceleration.FromMetersPerSecondSquared(1); - var b = Acceleration.FromMetersPerSecondSquared(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Acceleration.FromMetersPerSecondSquared(1); - var b = Acceleration.FromMetersPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Acceleration.FromMetersPerSecondSquared(1); - object b = Acceleration.FromMetersPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 1e55b712d2..6df945f8a4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -417,49 +417,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => mole.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AmountOfSubstance.FromMoles(1); - var b = AmountOfSubstance.FromMoles(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AmountOfSubstance.FromMoles(1); - var b = AmountOfSubstance.FromMoles(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AmountOfSubstance.FromMoles(1); - object b = AmountOfSubstance.FromMoles(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 85756bfe05..d756cc753f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -278,49 +278,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decibelvolt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AmplitudeRatio.FromDecibelVolts(1); - var b = AmplitudeRatio.FromDecibelVolts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AmplitudeRatio.FromDecibelVolts(1); - var b = AmplitudeRatio.FromDecibelVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AmplitudeRatio.FromDecibelVolts(1); - object b = AmplitudeRatio.FromDecibelVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 4c7d20b2b4..7f1cea4263 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -430,49 +430,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => degree.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Angle.FromDegrees(1); - var b = Angle.FromDegrees(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Angle.FromDegrees(1); - var b = Angle.FromDegrees(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Angle.FromDegrees(1); - object b = Angle.FromDegrees(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 41c449540f..d568bf6438 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltamperehour.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ApparentEnergy.FromVoltampereHours(1); - var b = ApparentEnergy.FromVoltampereHours(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ApparentEnergy.FromVoltampereHours(1); - var b = ApparentEnergy.FromVoltampereHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ApparentEnergy.FromVoltampereHours(1); - object b = ApparentEnergy.FromVoltampereHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index a820b50e63..9f147d9abf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltampere.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ApparentPower.FromVoltamperes(1); - var b = ApparentPower.FromVoltamperes(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ApparentPower.FromVoltamperes(1); - var b = ApparentPower.FromVoltamperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ApparentPower.FromVoltamperes(1); - object b = ApparentPower.FromVoltamperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index ac43f40d9b..2f0c2b3c3d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AreaDensity.FromKilogramsPerSquareMeter(1); - var b = AreaDensity.FromKilogramsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AreaDensity.FromKilogramsPerSquareMeter(1); - var b = AreaDensity.FromKilogramsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AreaDensity.FromKilogramsPerSquareMeter(1); - object b = AreaDensity.FromKilogramsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index b2051230df..5f1477116d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -300,49 +300,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => metertothefourth.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AreaMomentOfInertia.FromMetersToTheFourth(1); - var b = AreaMomentOfInertia.FromMetersToTheFourth(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AreaMomentOfInertia.FromMetersToTheFourth(1); - var b = AreaMomentOfInertia.FromMetersToTheFourth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AreaMomentOfInertia.FromMetersToTheFourth(1); - object b = AreaMomentOfInertia.FromMetersToTheFourth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 20e3949732..6d55b7b8a2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -404,49 +404,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => squaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Area.FromSquareMeters(1); - var b = Area.FromSquareMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Area.FromSquareMeters(1); - var b = Area.FromSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Area.FromSquareMeters(1); - object b = Area.FromSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 939f4e3bc5..ea52ebe637 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -535,49 +535,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => bitpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = BitRate.FromBitsPerSecond(1); - var b = BitRate.FromBitsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = BitRate.FromBitsPerSecond(1); - var b = BitRate.FromBitsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = BitRate.FromBitsPerSecond(1); - object b = BitRate.FromBitsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 08e94d548e..fd5bddda09 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogramperjoule.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - object b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 3d1af028f9..3825bd5774 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -313,49 +313,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => farad.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Capacitance.FromFarads(1); - var b = Capacitance.FromFarads(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Capacitance.FromFarads(1); - var b = Capacitance.FromFarads(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Capacitance.FromFarads(1); - object b = Capacitance.FromFarads(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 0eb864e00c..0bcf0aed97 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => inversekelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - object b = CoefficientOfThermalExpansion.FromInverseKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 3abfc1710a..b4757fb314 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -742,49 +742,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Density.FromKilogramsPerCubicMeter(1); - var b = Density.FromKilogramsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Density.FromKilogramsPerCubicMeter(1); - var b = Density.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Density.FromKilogramsPerCubicMeter(1); - object b = Density.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 439dc745f9..2e19791280 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -352,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => second.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Duration.FromSeconds(1); - var b = Duration.FromSeconds(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Duration.FromSeconds(1); - var b = Duration.FromSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Duration.FromSeconds(1); - object b = Duration.FromSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 846e7e3c7a..79f3183d5f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -352,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonsecondpermetersquared.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - object b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index d2e9826106..48b29f1876 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => siemens.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricAdmittance.FromSiemens(1); - var b = ElectricAdmittance.FromSiemens(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricAdmittance.FromSiemens(1); - var b = ElectricAdmittance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricAdmittance.FromSiemens(1); - object b = ElectricAdmittance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 36bbff3e78..0e489d95f2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => coulombpercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - object b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 1b59ca70cd..1140295d07 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -287,49 +287,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => coulomb.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCharge.FromCoulombs(1); - var b = ElectricCharge.FromCoulombs(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCharge.FromCoulombs(1); - var b = ElectricCharge.FromCoulombs(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCharge.FromCoulombs(1); - object b = ElectricCharge.FromCoulombs(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 7ae1c31a27..56cdd7c9a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => siemens.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricConductance.FromSiemens(1); - var b = ElectricConductance.FromSiemens(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricConductance.FromSiemens(1); - var b = ElectricConductance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricConductance.FromSiemens(1); - object b = ElectricConductance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 84721aa76f..c7971356b1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => siemenspermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricConductivity.FromSiemensPerMeter(1); - var b = ElectricConductivity.FromSiemensPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricConductivity.FromSiemensPerMeter(1); - var b = ElectricConductivity.FromSiemensPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricConductivity.FromSiemensPerMeter(1); - object b = ElectricConductivity.FromSiemensPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 1fe5894a6a..8f1fccadfa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amperepersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - object b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 8b9bdf9d2c..251f13af39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amperepersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCurrentGradient.FromAmperesPerSecond(1); - var b = ElectricCurrentGradient.FromAmperesPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCurrentGradient.FromAmperesPerSecond(1); - var b = ElectricCurrentGradient.FromAmperesPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCurrentGradient.FromAmperesPerSecond(1); - object b = ElectricCurrentGradient.FromAmperesPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 44b4e52759..2f7f17d7ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -326,49 +326,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ampere.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCurrent.FromAmperes(1); - var b = ElectricCurrent.FromAmperes(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCurrent.FromAmperes(1); - var b = ElectricCurrent.FromAmperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCurrent.FromAmperes(1); - object b = ElectricCurrent.FromAmperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 7ee40a5ca5..de4a676b29 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricField.FromVoltsPerMeter(1); - var b = ElectricField.FromVoltsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricField.FromVoltsPerMeter(1); - var b = ElectricField.FromVoltsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricField.FromVoltsPerMeter(1); - object b = ElectricField.FromVoltsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 3fd960b1ba..528ca520a2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => henry.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricInductance.FromHenries(1); - var b = ElectricInductance.FromHenries(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricInductance.FromHenries(1); - var b = ElectricInductance.FromHenries(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricInductance.FromHenries(1); - object b = ElectricInductance.FromHenries(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 6d6f4a2c45..e15c685fa0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -287,49 +287,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltac.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotentialAc.FromVoltsAc(1); - var b = ElectricPotentialAc.FromVoltsAc(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotentialAc.FromVoltsAc(1); - var b = ElectricPotentialAc.FromVoltsAc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotentialAc.FromVoltsAc(1); - object b = ElectricPotentialAc.FromVoltsAc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 94f5c21041..87b7fe70bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -482,49 +482,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - object b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 7b8f47878d..0d80b8d232 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -287,49 +287,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltdc.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotentialDc.FromVoltsDc(1); - var b = ElectricPotentialDc.FromVoltsDc(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotentialDc.FromVoltsDc(1); - var b = ElectricPotentialDc.FromVoltsDc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotentialDc.FromVoltsDc(1); - object b = ElectricPotentialDc.FromVoltsDc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 513c92b312..fe849d9823 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -287,49 +287,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => volt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotential.FromVolts(1); - var b = ElectricPotential.FromVolts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotential.FromVolts(1); - var b = ElectricPotential.FromVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotential.FromVolts(1); - object b = ElectricPotential.FromVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 3d4bd25db1..e8300e92ec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -300,49 +300,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ohm.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricResistance.FromOhms(1); - var b = ElectricResistance.FromOhms(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricResistance.FromOhms(1); - var b = ElectricResistance.FromOhms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricResistance.FromOhms(1); - object b = ElectricResistance.FromOhms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 80568a95d5..ef08e81da7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -404,49 +404,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ohmmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricResistivity.FromOhmMeters(1); - var b = ElectricResistivity.FromOhmMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricResistivity.FromOhmMeters(1); - var b = ElectricResistivity.FromOhmMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricResistivity.FromOhmMeters(1); - object b = ElectricResistivity.FromOhmMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 3e6305db87..2159a541b3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => coulombpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - object b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index aa5e5dc369..d446a0a1da 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -690,49 +690,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joule.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Energy.FromJoules(1); - var b = Energy.FromJoules(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Energy.FromJoules(1); - var b = Energy.FromJoules(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Energy.FromJoules(1); - object b = Energy.FromJoules(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index c0f05da54c..487b4e943e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -313,49 +313,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => jouleperkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Entropy.FromJoulesPerKelvin(1); - var b = Entropy.FromJoulesPerKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Entropy.FromJoulesPerKelvin(1); - var b = Entropy.FromJoulesPerKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Entropy.FromJoulesPerKelvin(1); - object b = Entropy.FromJoulesPerKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 70fc828bf3..a43c2272b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -417,49 +417,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ForceChangeRate.FromNewtonsPerSecond(1); - var b = ForceChangeRate.FromNewtonsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ForceChangeRate.FromNewtonsPerSecond(1); - var b = ForceChangeRate.FromNewtonsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ForceChangeRate.FromNewtonsPerSecond(1); - object b = ForceChangeRate.FromNewtonsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 253d0b0fee..c7358a7082 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -716,49 +716,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ForcePerLength.FromNewtonsPerMeter(1); - var b = ForcePerLength.FromNewtonsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ForcePerLength.FromNewtonsPerMeter(1); - var b = ForcePerLength.FromNewtonsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ForcePerLength.FromNewtonsPerMeter(1); - object b = ForcePerLength.FromNewtonsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index fb766bfbf9..b3c6d10044 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -417,49 +417,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newton.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Force.FromNewtons(1); - var b = Force.FromNewtons(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Force.FromNewtons(1); - var b = Force.FromNewtons(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Force.FromNewtons(1); - object b = Force.FromNewtons(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index da3f6fb796..a8dfbe8022 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -365,49 +365,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => hertz.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Frequency.FromHertz(1); - var b = Frequency.FromHertz(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Frequency.FromHertz(1); - var b = Frequency.FromHertz(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Frequency.FromHertz(1); - object b = Frequency.FromHertz(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 93e4f93326..6e63eb304b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => literper100kilometers.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = FuelEfficiency.FromLitersPer100Kilometers(1); - var b = FuelEfficiency.FromLitersPer100Kilometers(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = FuelEfficiency.FromLitersPer100Kilometers(1); - var b = FuelEfficiency.FromLitersPer100Kilometers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = FuelEfficiency.FromLitersPer100Kilometers(1); - object b = FuelEfficiency.FromLitersPer100Kilometers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index d4d28657e3..01a87cb0d8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -456,49 +456,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = HeatFlux.FromWattsPerSquareMeter(1); - var b = HeatFlux.FromWattsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = HeatFlux.FromWattsPerSquareMeter(1); - var b = HeatFlux.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = HeatFlux.FromWattsPerSquareMeter(1); - object b = HeatFlux.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 49d12ad2b5..ac1120c94c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpersquaremeterkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - object b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index c785c41c56..b663e98a58 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => lux.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Illuminance.FromLux(1); - var b = Illuminance.FromLux(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Illuminance.FromLux(1); - var b = Illuminance.FromLux(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Illuminance.FromLux(1); - object b = Illuminance.FromLux(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 3224cbc885..e27dc816ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -535,49 +535,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => bit.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Information.FromBits(1); - var b = Information.FromBits(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Information.FromBits(1); - var b = Information.FromBits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Information.FromBits(1); - object b = Information.FromBits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index f8a22db31b..69795c7d5a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -404,49 +404,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Irradiance.FromWattsPerSquareMeter(1); - var b = Irradiance.FromWattsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Irradiance.FromWattsPerSquareMeter(1); - var b = Irradiance.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Irradiance.FromWattsPerSquareMeter(1); - object b = Irradiance.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index aef1602c48..deb5995971 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -313,49 +313,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Irradiation.FromJoulesPerSquareMeter(1); - var b = Irradiation.FromJoulesPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Irradiation.FromJoulesPerSquareMeter(1); - var b = Irradiation.FromJoulesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Irradiation.FromJoulesPerSquareMeter(1); - object b = Irradiation.FromJoulesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 2ccac0ef36..2d34f909bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -339,49 +339,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => squaremeterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = KinematicViscosity.FromSquareMetersPerSecond(1); - var b = KinematicViscosity.FromSquareMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = KinematicViscosity.FromSquareMetersPerSecond(1); - var b = KinematicViscosity.FromSquareMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = KinematicViscosity.FromSquareMetersPerSecond(1); - object b = KinematicViscosity.FromSquareMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 10cf24b231..50d3ee9d03 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => degreecelsiusperkilometer.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LapseRate.FromDegreesCelciusPerKilometer(1); - var b = LapseRate.FromDegreesCelciusPerKilometer(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LapseRate.FromDegreesCelciusPerKilometer(1); - var b = LapseRate.FromDegreesCelciusPerKilometer(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LapseRate.FromDegreesCelciusPerKilometer(1); - object b = LapseRate.FromDegreesCelciusPerKilometer(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 78106ebec9..27a14e0e69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -651,49 +651,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => meter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Length.FromMeters(1); - var b = Length.FromMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Length.FromMeters(1); - var b = Length.FromMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Length.FromMeters(1); - object b = Length.FromMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 5e76d2d6f6..ad671cfe25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -252,49 +252,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decibel.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Level.FromDecibels(1); - var b = Level.FromDecibels(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Level.FromDecibels(1); - var b = Level.FromDecibels(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Level.FromDecibels(1); - object b = Level.FromDecibels(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 1b9dbe2f65..ba441f0104 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -404,49 +404,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LinearDensity.FromKilogramsPerMeter(1); - var b = LinearDensity.FromKilogramsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LinearDensity.FromKilogramsPerMeter(1); - var b = LinearDensity.FromKilogramsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LinearDensity.FromKilogramsPerMeter(1); - object b = LinearDensity.FromKilogramsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index f3a6d4b1c4..0e7b07daef 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -547,49 +547,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LinearPowerDensity.FromWattsPerMeter(1); - var b = LinearPowerDensity.FromWattsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LinearPowerDensity.FromWattsPerMeter(1); - var b = LinearPowerDensity.FromWattsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LinearPowerDensity.FromWattsPerMeter(1); - object b = LinearPowerDensity.FromWattsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index c2332cf734..731253227a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -404,49 +404,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => watt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Luminosity.FromWatts(1); - var b = Luminosity.FromWatts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Luminosity.FromWatts(1); - var b = Luminosity.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Luminosity.FromWatts(1); - object b = Luminosity.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index c1ace699e7..5ebb12ec7a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => lumen.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LuminousFlux.FromLumens(1); - var b = LuminousFlux.FromLumens(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LuminousFlux.FromLumens(1); - var b = LuminousFlux.FromLumens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LuminousFlux.FromLumens(1); - object b = LuminousFlux.FromLumens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 951a888f8c..e13f70b337 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => candela.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LuminousIntensity.FromCandela(1); - var b = LuminousIntensity.FromCandela(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LuminousIntensity.FromCandela(1); - var b = LuminousIntensity.FromCandela(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LuminousIntensity.FromCandela(1); - object b = LuminousIntensity.FromCandela(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index efe8a3f49e..55ceca0294 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -300,49 +300,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => tesla.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MagneticField.FromTeslas(1); - var b = MagneticField.FromTeslas(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MagneticField.FromTeslas(1); - var b = MagneticField.FromTeslas(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MagneticField.FromTeslas(1); - object b = MagneticField.FromTeslas(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index fc18de119c..767693890e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => weber.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MagneticFlux.FromWebers(1); - var b = MagneticFlux.FromWebers(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MagneticFlux.FromWebers(1); - var b = MagneticFlux.FromWebers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MagneticFlux.FromWebers(1); - object b = MagneticFlux.FromWebers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index c75b066faf..d2a4e6b2ba 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amperepermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Magnetization.FromAmperesPerMeter(1); - var b = Magnetization.FromAmperesPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Magnetization.FromAmperesPerMeter(1); - var b = Magnetization.FromAmperesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Magnetization.FromAmperesPerMeter(1); - object b = Magnetization.FromAmperesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 89dc1516bc..4dc30fca0a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -859,49 +859,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassConcentration.FromKilogramsPerCubicMeter(1); - var b = MassConcentration.FromKilogramsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassConcentration.FromKilogramsPerCubicMeter(1); - var b = MassConcentration.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassConcentration.FromKilogramsPerCubicMeter(1); - object b = MassConcentration.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index c533cb888f..a50c205acd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -651,49 +651,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => grampersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassFlow.FromGramsPerSecond(1); - var b = MassFlow.FromGramsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassFlow.FromGramsPerSecond(1); - var b = MassFlow.FromGramsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassFlow.FromGramsPerSecond(1); - object b = MassFlow.FromGramsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 271bf17c9e..9b1dc96b6a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -378,49 +378,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampersecondpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - object b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 5965c840af..42eeed544a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -534,49 +534,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfraction.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassFraction.FromDecimalFractions(1); - var b = MassFraction.FromDecimalFractions(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassFraction.FromDecimalFractions(1); - var b = MassFraction.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassFraction.FromDecimalFractions(1); - object b = MassFraction.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 373e2144a2..14adde23fc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -586,49 +586,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogramsquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassMomentOfInertia.FromKilogramSquareMeters(1); - var b = MassMomentOfInertia.FromKilogramSquareMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassMomentOfInertia.FromKilogramSquareMeters(1); - var b = MassMomentOfInertia.FromKilogramSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassMomentOfInertia.FromKilogramSquareMeters(1); - object b = MassMomentOfInertia.FromKilogramSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 739c240a7d..4b4a911cc9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -547,49 +547,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogram.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Mass.FromKilograms(1); - var b = Mass.FromKilograms(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Mass.FromKilograms(1); - var b = Mass.FromKilograms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Mass.FromKilograms(1); - object b = Mass.FromKilograms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 874800b4fb..7449e96ab6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepermole.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MolarEnergy.FromJoulesPerMole(1); - var b = MolarEnergy.FromJoulesPerMole(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MolarEnergy.FromJoulesPerMole(1); - var b = MolarEnergy.FromJoulesPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MolarEnergy.FromJoulesPerMole(1); - object b = MolarEnergy.FromJoulesPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 7c35ede5f0..060f90e168 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepermolekelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MolarEntropy.FromJoulesPerMoleKelvin(1); - var b = MolarEntropy.FromJoulesPerMoleKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MolarEntropy.FromJoulesPerMoleKelvin(1); - var b = MolarEntropy.FromJoulesPerMoleKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MolarEntropy.FromJoulesPerMoleKelvin(1); - object b = MolarEntropy.FromJoulesPerMoleKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 51721566b3..2383f5f79d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -378,49 +378,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampermole.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MolarMass.FromKilogramsPerMole(1); - var b = MolarMass.FromKilogramsPerMole(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MolarMass.FromKilogramsPerMole(1); - var b = MolarMass.FromKilogramsPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MolarMass.FromKilogramsPerMole(1); - object b = MolarMass.FromKilogramsPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 83b3cfe8c0..8ac39b8759 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -326,49 +326,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => molespercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Molarity.FromMolesPerCubicMeter(1); - var b = Molarity.FromMolesPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Molarity.FromMolesPerCubicMeter(1); - var b = Molarity.FromMolesPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Molarity.FromMolesPerCubicMeter(1); - object b = Molarity.FromMolesPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 12f9166f05..513bc00bfd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => henrypermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Permeability.FromHenriesPerMeter(1); - var b = Permeability.FromHenriesPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Permeability.FromHenriesPerMeter(1); - var b = Permeability.FromHenriesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Permeability.FromHenriesPerMeter(1); - object b = Permeability.FromHenriesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index d933af45b7..b07e39312a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => faradpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Permittivity.FromFaradsPerMeter(1); - var b = Permittivity.FromFaradsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Permittivity.FromFaradsPerMeter(1); - var b = Permittivity.FromFaradsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Permittivity.FromFaradsPerMeter(1); - object b = Permittivity.FromFaradsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index bad58879a1..f287889fe5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -794,49 +794,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = PowerDensity.FromWattsPerCubicMeter(1); - var b = PowerDensity.FromWattsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = PowerDensity.FromWattsPerCubicMeter(1); - var b = PowerDensity.FromWattsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = PowerDensity.FromWattsPerCubicMeter(1); - object b = PowerDensity.FromWattsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 16d4b63087..a9daee8c66 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -252,49 +252,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decibelwatt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = PowerRatio.FromDecibelWatts(1); - var b = PowerRatio.FromDecibelWatts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = PowerRatio.FromDecibelWatts(1); - var b = PowerRatio.FromDecibelWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = PowerRatio.FromDecibelWatts(1); - object b = PowerRatio.FromDecibelWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 3b32aa4b3b..e75b82c7ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -522,49 +522,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => watt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Power.FromWatts(1); - var b = Power.FromWatts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Power.FromWatts(1); - var b = Power.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Power.FromWatts(1); - object b = Power.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index c640cee461..b5659483e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -391,49 +391,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => pascalpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = PressureChangeRate.FromPascalsPerSecond(1); - var b = PressureChangeRate.FromPascalsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = PressureChangeRate.FromPascalsPerSecond(1); - var b = PressureChangeRate.FromPascalsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = PressureChangeRate.FromPascalsPerSecond(1); - object b = PressureChangeRate.FromPascalsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index f84c1a7b9a..eeccb43baa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -794,49 +794,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => pascal.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Pressure.FromPascals(1); - var b = Pressure.FromPascals(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Pressure.FromPascals(1); - var b = Pressure.FromPascals(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Pressure.FromPascals(1); - object b = Pressure.FromPascals(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index b21a1b97ca..51b803091f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -248,49 +248,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfractionpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - object b = RatioChangeRate.FromDecimalFractionsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 8609416e57..8a0ffaaa7e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -300,49 +300,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfraction.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Ratio.FromDecimalFractions(1); - var b = Ratio.FromDecimalFractions(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Ratio.FromDecimalFractions(1); - var b = Ratio.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Ratio.FromDecimalFractions(1); - object b = Ratio.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 38d1231226..98371bc5bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltamperereactivehour.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReactiveEnergy.FromVoltampereReactiveHours(1); - var b = ReactiveEnergy.FromVoltampereReactiveHours(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReactiveEnergy.FromVoltampereReactiveHours(1); - var b = ReactiveEnergy.FromVoltampereReactiveHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReactiveEnergy.FromVoltampereReactiveHours(1); - object b = ReactiveEnergy.FromVoltampereReactiveHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 4a019734ea..a1f09b13a8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltamperereactive.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReactivePower.FromVoltamperesReactive(1); - var b = ReactivePower.FromVoltamperesReactive(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReactivePower.FromVoltamperesReactive(1); - var b = ReactivePower.FromVoltamperesReactive(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReactivePower.FromVoltamperesReactive(1); - object b = ReactivePower.FromVoltamperesReactive(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 02d1499565..8dc57c85ad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -365,49 +365,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => inversesquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReciprocalArea.FromInverseSquareMeters(1); - var b = ReciprocalArea.FromInverseSquareMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReciprocalArea.FromInverseSquareMeters(1); - var b = ReciprocalArea.FromInverseSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReciprocalArea.FromInverseSquareMeters(1); - object b = ReciprocalArea.FromInverseSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 1812cb860a..3404678d35 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -352,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => inversemeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReciprocalLength.FromInverseMeters(1); - var b = ReciprocalLength.FromInverseMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReciprocalLength.FromInverseMeters(1); - var b = ReciprocalLength.FromInverseMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReciprocalLength.FromInverseMeters(1); - object b = ReciprocalLength.FromInverseMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index fc9864128a..94a6fb0f62 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => percent.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RelativeHumidity.FromPercent(1); - var b = RelativeHumidity.FromPercent(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RelativeHumidity.FromPercent(1); - var b = RelativeHumidity.FromPercent(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RelativeHumidity.FromPercent(1); - object b = RelativeHumidity.FromPercent(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 92919d264d..be96d05c8e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => radianpersecondsquared.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - object b = RotationalAcceleration.FromRadiansPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 7e9725c885..08157997fb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -391,49 +391,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => radianpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalSpeed.FromRadiansPerSecond(1); - var b = RotationalSpeed.FromRadiansPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalSpeed.FromRadiansPerSecond(1); - var b = RotationalSpeed.FromRadiansPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalSpeed.FromRadiansPerSecond(1); - object b = RotationalSpeed.FromRadiansPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index d4dd9164e2..b6b830f860 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -287,49 +287,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeterperradianpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - object b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 3a5d7285d5..e52a0856f6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -651,49 +651,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeterperradian.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalStiffness.FromNewtonMetersPerRadian(1); - var b = RotationalStiffness.FromNewtonMetersPerRadian(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalStiffness.FromNewtonMetersPerRadian(1); - var b = RotationalStiffness.FromNewtonMetersPerRadian(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalStiffness.FromNewtonMetersPerRadian(1); - object b = RotationalStiffness.FromNewtonMetersPerRadian(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 210bd6997d..6f672bdfbc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amount.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Scalar.FromAmount(1); - var b = Scalar.FromAmount(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Scalar.FromAmount(1); - var b = Scalar.FromAmount(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Scalar.FromAmount(1); - object b = Scalar.FromAmount(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 70759b2b4a..41addc5b3c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => steradian.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SolidAngle.FromSteradians(1); - var b = SolidAngle.FromSteradians(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SolidAngle.FromSteradians(1); - var b = SolidAngle.FromSteradians(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SolidAngle.FromSteradians(1); - object b = SolidAngle.FromSteradians(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 53233324b7..90b0f09844 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -547,49 +547,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => jouleperkilogram.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificEnergy.FromJoulesPerKilogram(1); - var b = SpecificEnergy.FromJoulesPerKilogram(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificEnergy.FromJoulesPerKilogram(1); - var b = SpecificEnergy.FromJoulesPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificEnergy.FromJoulesPerKilogram(1); - object b = SpecificEnergy.FromJoulesPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 2f9b2057c3..a7f4d8dbfb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -339,49 +339,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => jouleperkilogramkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - object b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 70a65d0cec..a18827b0e1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -274,49 +274,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => gramperkilonewtonsecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1); - var b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1); - var b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1); - object b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 7514a63b05..a1c093c63d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -261,49 +261,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterperkilogram.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificVolume.FromCubicMetersPerKilogram(1); - var b = SpecificVolume.FromCubicMetersPerKilogram(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificVolume.FromCubicMetersPerKilogram(1); - var b = SpecificVolume.FromCubicMetersPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificVolume.FromCubicMetersPerKilogram(1); - object b = SpecificVolume.FromCubicMetersPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index b7d52b475c..3999b3ad24 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -443,49 +443,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonpercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificWeight.FromNewtonsPerCubicMeter(1); - var b = SpecificWeight.FromNewtonsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificWeight.FromNewtonsPerCubicMeter(1); - var b = SpecificWeight.FromNewtonsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificWeight.FromNewtonsPerCubicMeter(1); - object b = SpecificWeight.FromNewtonsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 9ca11ca2be..fd6f5179ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -638,49 +638,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => meterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Speed.FromMetersPerSecond(1); - var b = Speed.FromMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Speed.FromMetersPerSecond(1); - var b = Speed.FromMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Speed.FromMetersPerSecond(1); - object b = Speed.FromMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index dabbf55413..59e6bbff3a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -339,49 +339,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => standardcubicmeterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - var b = StandardVolumeFlow.FromStandardCubicMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - var b = StandardVolumeFlow.FromStandardCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - object b = StandardVolumeFlow.FromStandardCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 940f6bb351..42ec2fc80f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -352,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => degreecelsiuspersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - object b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index e4c8850880..efd558506d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -339,49 +339,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TemperatureDelta.FromKelvins(1); - var b = TemperatureDelta.FromKelvins(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TemperatureDelta.FromKelvins(1); - var b = TemperatureDelta.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TemperatureDelta.FromKelvins(1); - object b = TemperatureDelta.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index ec973e4061..f558e9e51e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -340,49 +340,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Temperature.FromKelvins(1); - var b = Temperature.FromKelvins(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Temperature.FromKelvins(1); - var b = Temperature.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Temperature.FromKelvins(1); - object b = Temperature.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 730effa3c8..4a93dc82d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -248,49 +248,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpermeterkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ThermalConductivity.FromWattsPerMeterKelvin(1); - var b = ThermalConductivity.FromWattsPerMeterKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ThermalConductivity.FromWattsPerMeterKelvin(1); - var b = ThermalConductivity.FromWattsPerMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ThermalConductivity.FromWattsPerMeterKelvin(1); - object b = ThermalConductivity.FromWattsPerMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index d8a9e3c25c..37103e822e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -287,49 +287,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => squaremeterkelvinperkilowatt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - object b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index c1377310d1..401ffcbfd7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -495,49 +495,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeterpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TorquePerLength.FromNewtonMetersPerMeter(1); - var b = TorquePerLength.FromNewtonMetersPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TorquePerLength.FromNewtonMetersPerMeter(1); - var b = TorquePerLength.FromNewtonMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TorquePerLength.FromNewtonMetersPerMeter(1); - object b = TorquePerLength.FromNewtonMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 1a3655b5db..45cea4af1c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -508,49 +508,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Torque.FromNewtonMeters(1); - var b = Torque.FromNewtonMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Torque.FromNewtonMeters(1); - var b = Torque.FromNewtonMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Torque.FromNewtonMeters(1); - object b = Torque.FromNewtonMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 5e60dbfe9f..474bbf295d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ntu.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Turbidity.FromNTU(1); - var b = Turbidity.FromNTU(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Turbidity.FromNTU(1); - var b = Turbidity.FromNTU(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Turbidity.FromNTU(1); - object b = Turbidity.FromNTU(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index badabc07a4..2505949dee 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -235,49 +235,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => internationalunit.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VitaminA.FromInternationalUnits(1); - var b = VitaminA.FromInternationalUnits(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VitaminA.FromInternationalUnits(1); - var b = VitaminA.FromInternationalUnits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VitaminA.FromInternationalUnits(1); - object b = VitaminA.FromInternationalUnits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 6c0a7a35fb..f4025417ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -482,49 +482,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfraction.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumeConcentration.FromDecimalFractions(1); - var b = VolumeConcentration.FromDecimalFractions(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumeConcentration.FromDecimalFractions(1); - var b = VolumeConcentration.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumeConcentration.FromDecimalFractions(1); - object b = VolumeConcentration.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 5680b07a0d..9a6a363063 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -950,49 +950,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumeFlow.FromCubicMetersPerSecond(1); - var b = VolumeFlow.FromCubicMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumeFlow.FromCubicMetersPerSecond(1); - var b = VolumeFlow.FromCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumeFlow.FromCubicMetersPerSecond(1); - object b = VolumeFlow.FromCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 08b6c027b2..718c2ecd71 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -313,49 +313,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumePerLength.FromCubicMetersPerMeter(1); - var b = VolumePerLength.FromCubicMetersPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumePerLength.FromCubicMetersPerMeter(1); - var b = VolumePerLength.FromCubicMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumePerLength.FromCubicMetersPerMeter(1); - object b = VolumePerLength.FromCubicMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index fb1f562150..d2e52c0871 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -885,49 +885,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Volume.FromCubicMeters(1); - var b = Volume.FromCubicMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Volume.FromCubicMeters(1); - var b = Volume.FromCubicMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Volume.FromCubicMeters(1); - object b = Volume.FromCubicMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 297abef5e3..6f391a97dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -339,49 +339,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepercubicmeterkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - var b = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - var b = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - object b = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index d523ad9be2..1dd7d407d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -300,49 +300,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => metertothesixth.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - object b = WarpingMomentOfInertia.FromMetersToTheSixth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 7cfc7fee2c..4cf7669aee 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. /// [DataContract] - public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Acceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -616,20 +616,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Acceleration left, Acceleration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Acceleration left, Acceleration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -645,23 +631,6 @@ public int CompareTo(Acceleration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Acceleration objAcceleration)) - return false; - - return Equals(objAcceleration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Acceleration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Acceleration within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 57ec963dcf..4817b1c6cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. /// [DataContract] - public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmountOfSubstance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -631,20 +631,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -660,23 +646,6 @@ public int CompareTo(AmountOfSubstance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) - return false; - - return Equals(objAmountOfSubstance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmountOfSubstance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 71cedf32c0..abd0f5404d 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. /// [DataContract] - public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmplitudeRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -474,20 +474,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -503,23 +489,6 @@ public int CompareTo(AmplitudeRatio other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) - return false; - - return Equals(objAmplitudeRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmplitudeRatio other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 168a677fe6..4b31f648e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. /// [DataContract] - public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Angle : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -646,20 +646,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Angle left, Angle right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Angle left, Angle right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -675,23 +661,6 @@ public int CompareTo(Angle other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Angle objAngle)) - return false; - - return Equals(objAngle); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Angle other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Angle within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index e039aea5da..fab3927c45 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. /// [DataContract] - public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentEnergy left, ApparentEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentEnergy left, ApparentEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(ApparentEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ApparentEnergy objApparentEnergy)) - return false; - - return Equals(objApparentEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ApparentEnergy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 25ccf76d26..d5946b9b40 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. /// [DataContract] - public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentPower : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -466,20 +466,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentPower left, ApparentPower right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentPower left, ApparentPower right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,23 +481,6 @@ public int CompareTo(ApparentPower other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ApparentPower objApparentPower)) - return false; - - return Equals(objApparentPower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentPower other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ApparentPower within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index f0e7d9dd2f..dc2c8b8c54 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). /// [DataContract] - public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Area : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -616,20 +616,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Area left, Area right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Area left, Area right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -645,23 +631,6 @@ public int CompareTo(Area other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Area objArea)) - return false; - - return Equals(objArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Area other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Area within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 7e481b11cf..08676f9b24 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The area density of a two-dimensional object is calculated as the mass per unit area. /// [DataContract] - public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -421,20 +421,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaDensity left, AreaDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaDensity left, AreaDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -450,23 +436,6 @@ public int CompareTo(AreaDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AreaDensity objAreaDensity)) - return false; - - return Equals(objAreaDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AreaDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 15b5fddc60..8988e0ea3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A geometric property of an area that reflects how its points are distributed with regard to an axis. /// [DataContract] - public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -496,20 +496,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -525,23 +511,6 @@ public int CompareTo(AreaMomentOfInertia other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) - return false; - - return Equals(objAreaMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaMomentOfInertia other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index be61335338..0145f75d03 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Bit_rate /// [DataContract] - public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BitRate : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -804,20 +804,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BitRate left, BitRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BitRate left, BitRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -833,23 +819,6 @@ public int CompareTo(BitRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is BitRate objBitRate)) - return false; - - return Equals(objBitRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(BitRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another BitRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 4de5c6d691..d629a6d0c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. /// [DataContract] - public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BrakeSpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(BrakeSpecificFuelConsumption other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) - return false; - - return Equals(objBrakeSpecificFuelConsumption); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(BrakeSpecificFuelConsumption other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another BrakeSpecificFuelConsumption within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index c573f46ca6..2b679df00b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Capacitance /// [DataContract] - public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Capacitance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -514,20 +514,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Capacitance left, Capacitance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Capacitance left, Capacitance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -543,23 +529,6 @@ public int CompareTo(Capacitance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Capacitance objCapacitance)) - return false; - - return Equals(objCapacitance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Capacitance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Capacitance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 4fab9691ba..6ed9d5bb01 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A unit that represents a fractional change in size in response to a change in temperature. /// [DataContract] - public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct CoefficientOfThermalExpansion : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(CoefficientOfThermalExpansion other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) - return false; - - return Equals(objCoefficientOfThermalExpansion); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(CoefficientOfThermalExpansion other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another CoefficientOfThermalExpansion within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index b3d62099c1..2eba18042d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Density /// [DataContract] - public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Density : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -1009,20 +1009,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Density left, Density right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Density left, Density right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1038,23 +1024,6 @@ public int CompareTo(Density other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Density objDensity)) - return false; - - return Equals(objDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Density other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Density within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 2222adbece..552a0af9cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. /// [DataContract] - public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Duration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -556,20 +556,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Duration left, Duration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Duration left, Duration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -585,23 +571,6 @@ public int CompareTo(Duration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Duration objDuration)) - return false; - - return Equals(objDuration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Duration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Duration within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index a5c112e0db..1a473fb753 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity /// [DataContract] - public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct DynamicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -559,20 +559,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(DynamicViscosity left, DynamicViscosity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(DynamicViscosity left, DynamicViscosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -588,23 +574,6 @@ public int CompareTo(DynamicViscosity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is DynamicViscosity objDynamicViscosity)) - return false; - - return Equals(objDynamicViscosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(DynamicViscosity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another DynamicViscosity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index bbaab5fa72..8da7483e95 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). /// [DataContract] - public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricAdmittance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -466,20 +466,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,23 +481,6 @@ public int CompareTo(ElectricAdmittance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) - return false; - - return Equals(objElectricAdmittance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricAdmittance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricAdmittance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index c8ac40b86b..7ff03984f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_charge /// [DataContract] - public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCharge : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -484,20 +484,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCharge left, ElectricCharge right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCharge left, ElectricCharge right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -513,23 +499,6 @@ public int CompareTo(ElectricCharge other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCharge objElectricCharge)) - return false; - - return Equals(objElectricCharge); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCharge other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCharge within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 13905cac40..98c63cdd7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(ElectricChargeDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) - return false; - - return Equals(objElectricChargeDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricChargeDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricChargeDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 250a46af61..b8fc5e194b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance /// [DataContract] - public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -454,20 +454,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductance left, ElectricConductance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductance left, ElectricConductance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -483,23 +469,6 @@ public int CompareTo(ElectricConductance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricConductance objElectricConductance)) - return false; - - return Equals(objElectricConductance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricConductance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 04ceacc1e3..401c08a2bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -454,20 +454,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductivity left, ElectricConductivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductivity left, ElectricConductivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -483,23 +469,6 @@ public int CompareTo(ElectricConductivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricConductivity objElectricConductivity)) - return false; - - return Equals(objElectricConductivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricConductivity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index b46691e1e9..083134c22e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. /// [DataContract] - public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrent : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -526,20 +526,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrent left, ElectricCurrent right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrent left, ElectricCurrent right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -555,23 +541,6 @@ public int CompareTo(ElectricCurrent other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrent objElectricCurrent)) - return false; - - return Equals(objElectricCurrent); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrent other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCurrent within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 40b737bd77..95f6b63a91 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Current_density /// [DataContract] - public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -454,20 +454,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -483,23 +469,6 @@ public int CompareTo(ElectricCurrentDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) - return false; - - return Equals(objElectricCurrentDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCurrentDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 76ee5c5d55..dae6d42e34 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In electromagnetism, the current gradient describes how the current changes in time. /// [DataContract] - public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -466,20 +466,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,23 +481,6 @@ public int CompareTo(ElectricCurrentGradient other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) - return false; - - return Equals(objElectricCurrentGradient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentGradient other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCurrentGradient within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index a0b4cb7aae..ffbae6bd46 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_field /// [DataContract] - public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricField : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricField left, ElectricField right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricField left, ElectricField right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(ElectricField other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricField objElectricField)) - return false; - - return Equals(objElectricField); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricField other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricField within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 3039ebb532..1807c84eca 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inductance /// [DataContract] - public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricInductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -469,20 +469,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricInductance left, ElectricInductance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricInductance left, ElectricInductance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -498,23 +484,6 @@ public int CompareTo(ElectricInductance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricInductance objElectricInductance)) - return false; - - return Equals(objElectricInductance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricInductance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricInductance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 7344bd581d..b9dcb6de63 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. /// [DataContract] - public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotential : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -481,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotential left, ElectricPotential right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotential left, ElectricPotential right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -510,23 +496,6 @@ public int CompareTo(ElectricPotential other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotential objElectricPotential)) - return false; - - return Equals(objElectricPotential); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotential other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotential within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index ef01f507ba..b338331dac 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The Electric Potential of a system known to use Alternating Current. /// [DataContract] - public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialAc : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -481,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -510,23 +496,6 @@ public int CompareTo(ElectricPotentialAc other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) - return false; - - return Equals(objElectricPotentialAc); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialAc other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotentialAc within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 7d0e9a27c2..32236cf3ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). /// [DataContract] - public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -706,20 +706,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -735,23 +721,6 @@ public int CompareTo(ElectricPotentialChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) - return false; - - return Equals(objElectricPotentialChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotentialChangeRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index d69888140d..34ba2e57ba 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The Electric Potential of a system known to use Direct Current. /// [DataContract] - public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialDc : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -481,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -510,23 +496,6 @@ public int CompareTo(ElectricPotentialDc other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) - return false; - - return Equals(objElectricPotentialDc); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialDc other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotentialDc within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 59add3c0aa..d38168a582 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. /// [DataContract] - public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -496,20 +496,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistance left, ElectricResistance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistance left, ElectricResistance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -525,23 +511,6 @@ public int CompareTo(ElectricResistance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricResistance objElectricResistance)) - return false; - - return Equals(objElectricResistance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricResistance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 79b22e9784..e6ff4a0d6a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -619,20 +619,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistivity left, ElectricResistivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistivity left, ElectricResistivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -648,23 +634,6 @@ public int CompareTo(ElectricResistivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricResistivity objElectricResistivity)) - return false; - - return Equals(objElectricResistivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricResistivity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 9d5f8ada1e..a9ebb08d7d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricSurfaceChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -454,20 +454,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -483,23 +469,6 @@ public int CompareTo(ElectricSurfaceChargeDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) - return false; - - return Equals(objElectricSurfaceChargeDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricSurfaceChargeDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricSurfaceChargeDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 462097d530..b6320a6c03 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. /// [DataContract] - public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Energy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -946,20 +946,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Energy left, Energy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Energy left, Energy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -975,23 +961,6 @@ public int CompareTo(Energy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Energy objEnergy)) - return false; - - return Equals(objEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Energy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Energy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 417979791d..6c505ed4aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units /// [DataContract] - public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Entropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -511,20 +511,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Entropy left, Entropy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Entropy left, Entropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -540,23 +526,6 @@ public int CompareTo(Entropy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Entropy objEntropy)) - return false; - - return Equals(objEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Entropy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Entropy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 41ee454cf4..22bde314f0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. /// [DataContract] - public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Force : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -631,20 +631,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Force left, Force right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Force left, Force right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -660,23 +646,6 @@ public int CompareTo(Force other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Force objForce)) - return false; - - return Equals(objForce); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Force other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Force within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 699bb8c30f..70de0f89be 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). /// [DataContract] - public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForceChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -631,20 +631,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForceChangeRate left, ForceChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForceChangeRate left, ForceChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -660,23 +646,6 @@ public int CompareTo(ForceChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ForceChangeRate objForceChangeRate)) - return false; - - return Equals(objForceChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForceChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ForceChangeRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index b18b63198a..f51ae7e407 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The magnitude of force per unit length. /// [DataContract] - public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForcePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -976,20 +976,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForcePerLength left, ForcePerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForcePerLength left, ForcePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1005,23 +991,6 @@ public int CompareTo(ForcePerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ForcePerLength objForcePerLength)) - return false; - - return Equals(objForcePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForcePerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ForcePerLength within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 07d0e7b347..ee20a59776 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The number of occurrences of a repeating event per unit time. /// [DataContract] - public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Frequency : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -571,20 +571,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Frequency left, Frequency right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Frequency left, Frequency right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -600,23 +586,6 @@ public int CompareTo(Frequency other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Frequency objFrequency)) - return false; - - return Equals(objFrequency); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Frequency other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Frequency within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index a024464310..b1f6bc1ff1 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Fuel_efficiency /// [DataContract] - public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct FuelEfficiency : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -469,20 +469,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(FuelEfficiency left, FuelEfficiency right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(FuelEfficiency left, FuelEfficiency right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -498,23 +484,6 @@ public int CompareTo(FuelEfficiency other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is FuelEfficiency objFuelEfficiency)) - return false; - - return Equals(objFuelEfficiency); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(FuelEfficiency other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another FuelEfficiency within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index fb71bd7a5c..0fc224be8f 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Heat flux is the flow of energy per unit of area per unit of time /// [DataContract] - public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -676,20 +676,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatFlux left, HeatFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatFlux left, HeatFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -705,23 +691,6 @@ public int CompareTo(HeatFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is HeatFlux objHeatFlux)) - return false; - - return Equals(objHeatFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another HeatFlux within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 6f27a4a90b..30287b7a69 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) /// [DataContract] - public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatTransferCoefficient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(HeatTransferCoefficient other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) - return false; - - return Equals(objHeatTransferCoefficient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatTransferCoefficient other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another HeatTransferCoefficient within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 90e5d79d98..7d9e3b5411 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Illuminance /// [DataContract] - public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Illuminance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -469,20 +469,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Illuminance left, Illuminance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Illuminance left, Illuminance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -498,23 +484,6 @@ public int CompareTo(Illuminance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Illuminance objIlluminance)) - return false; - - return Equals(objIlluminance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Illuminance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Illuminance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 79a014ac96..c3c9d8e7c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. /// [DataContract] - public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Information : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -801,20 +801,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Information left, Information right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Information left, Information right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -830,23 +816,6 @@ public int CompareTo(Information other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Information objInformation)) - return false; - - return Equals(objInformation); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Information other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Information within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index ab24151d25..9e54df430a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. /// [DataContract] - public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -616,20 +616,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiance left, Irradiance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiance left, Irradiance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -645,23 +631,6 @@ public int CompareTo(Irradiance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Irradiance objIrradiance)) - return false; - - return Equals(objIrradiance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Irradiance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 309296a386..b767a82648 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Irradiation /// [DataContract] - public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiation : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -514,20 +514,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiation left, Irradiation right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiation left, Irradiation right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -543,23 +529,6 @@ public int CompareTo(Irradiation other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Irradiation objIrradiation)) - return false; - - return Equals(objIrradiation); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiation other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Irradiation within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 1019ec6a9a..461d4b30be 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Viscosity /// [DataContract] - public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct KinematicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -544,20 +544,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(KinematicViscosity left, KinematicViscosity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(KinematicViscosity left, KinematicViscosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -573,23 +559,6 @@ public int CompareTo(KinematicViscosity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is KinematicViscosity objKinematicViscosity)) - return false; - - return Equals(objKinematicViscosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(KinematicViscosity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another KinematicViscosity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 2f3b21f4ba..d9014c6a68 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude. /// [DataContract] - public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LapseRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -421,20 +421,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LapseRate left, LapseRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LapseRate left, LapseRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -450,23 +436,6 @@ public int CompareTo(LapseRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LapseRate objLapseRate)) - return false; - - return Equals(objLapseRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LapseRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LapseRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index cb2548da43..0d520d132f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. /// [DataContract] - public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Length : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -901,20 +901,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Length left, Length right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Length left, Length right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -930,23 +916,6 @@ public int CompareTo(Length other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Length objLength)) - return false; - - return Equals(objLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Length other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Length within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 54739274e4..dde9e64bfd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. /// [DataContract] - public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Level : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -444,20 +444,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Level left, Level right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Level left, Level right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -473,23 +459,6 @@ public int CompareTo(Level other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Level objLevel)) - return false; - - return Equals(objLevel); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Level other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Level within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 455ea0e52d..49b0c4ab6f 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -619,20 +619,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearDensity left, LinearDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearDensity left, LinearDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -648,23 +634,6 @@ public int CompareTo(LinearDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LinearDensity objLinearDensity)) - return false; - - return Equals(objLinearDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LinearDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 7ac344bdcf..c000a43216 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearPowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -784,20 +784,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -813,23 +799,6 @@ public int CompareTo(LinearPowerDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) - return false; - - return Equals(objLinearPowerDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearPowerDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LinearPowerDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index d5fe855983..f8e5e51c4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminosity /// [DataContract] - public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Luminosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -619,20 +619,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Luminosity left, Luminosity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Luminosity left, Luminosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -648,23 +634,6 @@ public int CompareTo(Luminosity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Luminosity objLuminosity)) - return false; - - return Equals(objLuminosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Luminosity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Luminosity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 486f8f5f1a..8a9fc756df 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_flux /// [DataContract] - public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousFlux left, LuminousFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousFlux left, LuminousFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(LuminousFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LuminousFlux objLuminousFlux)) - return false; - - return Equals(objLuminousFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LuminousFlux within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 82a4d2fc24..d47ec9da54 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_intensity /// [DataContract] - public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousIntensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousIntensity left, LuminousIntensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousIntensity left, LuminousIntensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(LuminousIntensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LuminousIntensity objLuminousIntensity)) - return false; - - return Equals(objLuminousIntensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousIntensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LuminousIntensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 00a32fb36f..d44f209794 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_field /// [DataContract] - public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticField : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -499,20 +499,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticField left, MagneticField right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticField left, MagneticField right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -528,23 +514,6 @@ public int CompareTo(MagneticField other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MagneticField objMagneticField)) - return false; - - return Equals(objMagneticField); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticField other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MagneticField within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index bf1f8a6bb4..0b0326fd95 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_flux /// [DataContract] - public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticFlux left, MagneticFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticFlux left, MagneticFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(MagneticFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MagneticFlux objMagneticFlux)) - return false; - - return Equals(objMagneticFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MagneticFlux within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 2d38e009c4..5a4be0fba2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetization /// [DataContract] - public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Magnetization : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Magnetization left, Magnetization right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Magnetization left, Magnetization right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(Magnetization other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Magnetization objMagnetization)) - return false; - - return Equals(objMagnetization); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Magnetization other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Magnetization within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 104e912d42..ac27f16599 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). /// [DataContract] - public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Mass : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -781,20 +781,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Mass left, Mass right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Mass left, Mass right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -810,23 +796,6 @@ public int CompareTo(Mass other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Mass objMass)) - return false; - - return Equals(objMass); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Mass other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Mass within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 2b03ebae71..632b14de38 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) /// [DataContract] - public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -1144,20 +1144,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassConcentration left, MassConcentration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassConcentration left, MassConcentration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1173,23 +1159,6 @@ public int CompareTo(MassConcentration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassConcentration objMassConcentration)) - return false; - - return Equals(objMassConcentration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassConcentration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassConcentration within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index eed63e6499..d7609a3487 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). /// [DataContract] - public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -901,20 +901,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlow left, MassFlow right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlow left, MassFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -930,23 +916,6 @@ public int CompareTo(MassFlow other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFlow objMassFlow)) - return false; - - return Equals(objMassFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlow other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassFlow within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 2ed309f8fd..1a297392bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Mass flux is the mass flow rate per unit area. /// [DataContract] - public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -586,20 +586,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlux left, MassFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlux left, MassFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -615,23 +601,6 @@ public int CompareTo(MassFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFlux objMassFlux)) - return false; - - return Equals(objMassFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassFlux within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 332e9c675c..9334406a91 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) /// [DataContract] - public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFraction : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -769,20 +769,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFraction left, MassFraction right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFraction left, MassFraction right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -798,23 +784,6 @@ public int CompareTo(MassFraction other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFraction objMassFraction)) - return false; - - return Equals(objMassFraction); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFraction other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassFraction within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 6765e45ef0..84a62383f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A property of body reflects how its mass is distributed with regard to an axis. /// [DataContract] - public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -826,20 +826,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -855,23 +841,6 @@ public int CompareTo(MassMomentOfInertia other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) - return false; - - return Equals(objMassMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassMomentOfInertia other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassMomentOfInertia within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 385f077e48..cc87c5b14c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Molar energy is the amount of energy stored in 1 mole of a substance. /// [DataContract] - public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEnergy left, MolarEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEnergy left, MolarEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(MolarEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarEnergy objMolarEnergy)) - return false; - - return Equals(objMolarEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MolarEnergy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 7727cac3a1..4db75c4f9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// [DataContract] - public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEntropy left, MolarEntropy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEntropy left, MolarEntropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(MolarEntropy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarEntropy objMolarEntropy)) - return false; - - return Equals(objMolarEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEntropy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MolarEntropy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 58880a66e8..ebcf76fc23 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. /// [DataContract] - public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarMass : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -586,20 +586,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarMass left, MolarMass right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarMass left, MolarMass right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -615,23 +601,6 @@ public int CompareTo(MolarMass other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarMass objMolarMass)) - return false; - - return Equals(objMolarMass); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarMass other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MolarMass within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index ebc4fe2150..7c31fceca1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Molar_concentration /// [DataContract] - public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Molarity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -529,20 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Molarity left, Molarity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Molarity left, Molarity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -558,23 +544,6 @@ public int CompareTo(Molarity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Molarity objMolarity)) - return false; - - return Equals(objMolarity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Molarity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Molarity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index e3b48fb1ad..2263fdb8cb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) /// [DataContract] - public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permeability : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permeability left, Permeability right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permeability left, Permeability right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(Permeability other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Permeability objPermeability)) - return false; - - return Equals(objPermeability); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permeability other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Permeability within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index eaf83812e8..f0e0291f0c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permittivity /// [DataContract] - public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permittivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permittivity left, Permittivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permittivity left, Permittivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(Permittivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Permittivity objPermittivity)) - return false; - - return Equals(objPermittivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permittivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Permittivity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 7fb13b7b4c..a369415538 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. /// [DataContract] - public partial struct Power : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Power : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -786,20 +786,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Power left, Power right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Power left, Power right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -815,23 +801,6 @@ public int CompareTo(Power other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Power objPower)) - return false; - - return Equals(objPower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Power other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Power within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 8889e8c8ea..881f4b9dd9 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The amount of power in a volume. /// [DataContract] - public partial struct PowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -1066,20 +1066,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerDensity left, PowerDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerDensity left, PowerDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1095,23 +1081,6 @@ public int CompareTo(PowerDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is PowerDensity objPowerDensity)) - return false; - - return Equals(objPowerDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another PowerDensity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 3cf66c2188..35f3ccb654 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one watt. /// [DataContract] - public partial struct PowerRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -444,20 +444,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerRatio left, PowerRatio right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerRatio left, PowerRatio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -473,23 +459,6 @@ public int CompareTo(PowerRatio other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is PowerRatio objPowerRatio)) - return false; - - return Equals(objPowerRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerRatio other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another PowerRatio within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 8c63de053a..c558b69c06 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). /// [DataContract] - public partial struct Pressure : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Pressure : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -1066,20 +1066,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Pressure left, Pressure right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Pressure left, Pressure right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1095,23 +1081,6 @@ public int CompareTo(Pressure other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Pressure objPressure)) - return false; - - return Equals(objPressure); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Pressure other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Pressure within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 9ce6958f01..de2bbe0c8d 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). /// [DataContract] - public partial struct PressureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PressureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -601,20 +601,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PressureChangeRate left, PressureChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PressureChangeRate left, PressureChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -630,23 +616,6 @@ public int CompareTo(PressureChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is PressureChangeRate objPressureChangeRate)) - return false; - - return Equals(objPressureChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PressureChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another PressureChangeRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 9a2fc380af..c80752fcdf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). /// [DataContract] - public partial struct Ratio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Ratio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -496,20 +496,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Ratio left, Ratio right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Ratio left, Ratio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -525,23 +511,6 @@ public int CompareTo(Ratio other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Ratio objRatio)) - return false; - - return Equals(objRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Ratio other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Ratio within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 73d6984cbb..278edd1419 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The change in ratio per unit of time. /// [DataContract] - public partial struct RatioChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RatioChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -436,20 +436,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RatioChangeRate left, RatioChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RatioChangeRate left, RatioChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -465,23 +451,6 @@ public int CompareTo(RatioChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RatioChangeRate objRatioChangeRate)) - return false; - - return Equals(objRatioChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RatioChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RatioChangeRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index ba8314b336..20696902ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. /// [DataContract] - public partial struct ReactiveEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactiveEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(ReactiveEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) - return false; - - return Equals(objReactiveEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactiveEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReactiveEnergy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 133986f128..a6c5e8eb21 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. /// [DataContract] - public partial struct ReactivePower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactivePower : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -466,20 +466,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactivePower left, ReactivePower right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactivePower left, ReactivePower right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,23 +481,6 @@ public int CompareTo(ReactivePower other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReactivePower objReactivePower)) - return false; - - return Equals(objReactivePower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactivePower other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReactivePower within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 1952669116..f36e585421 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inverse-square_law /// [DataContract] - public partial struct ReciprocalArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -574,20 +574,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReciprocalArea left, ReciprocalArea right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReciprocalArea left, ReciprocalArea right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -603,23 +589,6 @@ public int CompareTo(ReciprocalArea other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReciprocalArea objReciprocalArea)) - return false; - - return Equals(objReciprocalArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReciprocalArea other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReciprocalArea within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 7824664c8c..b33dd46cdf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Reciprocal_length /// [DataContract] - public partial struct ReciprocalLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -559,20 +559,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReciprocalLength left, ReciprocalLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReciprocalLength left, ReciprocalLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -588,23 +574,6 @@ public int CompareTo(ReciprocalLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReciprocalLength objReciprocalLength)) - return false; - - return Equals(objReciprocalLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReciprocalLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReciprocalLength within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 8df2922d6e..5817cc979d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. /// [DataContract] - public partial struct RelativeHumidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RelativeHumidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -421,20 +421,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RelativeHumidity left, RelativeHumidity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RelativeHumidity left, RelativeHumidity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -450,23 +436,6 @@ public int CompareTo(RelativeHumidity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RelativeHumidity objRelativeHumidity)) - return false; - - return Equals(objRelativeHumidity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RelativeHumidity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RelativeHumidity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index cee1f0ab27..35912a4c5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Angular acceleration is the rate of change of rotational speed. /// [DataContract] - public partial struct RotationalAcceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalAcceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -466,20 +466,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,23 +481,6 @@ public int CompareTo(RotationalAcceleration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) - return false; - - return Equals(objRotationalAcceleration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalAcceleration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalAcceleration within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index bbfcc3bc99..159720c28a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). /// [DataContract] - public partial struct RotationalSpeed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalSpeed : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -601,20 +601,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalSpeed left, RotationalSpeed right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalSpeed left, RotationalSpeed right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -630,23 +616,6 @@ public int CompareTo(RotationalSpeed other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalSpeed objRotationalSpeed)) - return false; - - return Equals(objRotationalSpeed); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalSpeed other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalSpeed within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 69463076d6..d79ba26ff2 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffness : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffness : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -901,20 +901,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffness left, RotationalStiffness right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffness left, RotationalStiffness right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -930,23 +916,6 @@ public int CompareTo(RotationalStiffness other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalStiffness objRotationalStiffness)) - return false; - - return Equals(objRotationalStiffness); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffness other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalStiffness within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 741eaf8cdf..16964951c0 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffnessPerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffnessPerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -481,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -510,23 +496,6 @@ public int CompareTo(RotationalStiffnessPerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) - return false; - - return Equals(objRotationalStiffnessPerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffnessPerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalStiffnessPerLength within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index ccb04e35f9..751e23a7d1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A way of representing a number of items. /// [DataContract] - public partial struct Scalar : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Scalar : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -421,20 +421,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Scalar left, Scalar right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Scalar left, Scalar right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -450,23 +436,6 @@ public int CompareTo(Scalar other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Scalar objScalar)) - return false; - - return Equals(objScalar); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Scalar other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Scalar within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 59c2e93460..899e4cc908 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Solid_angle /// [DataContract] - public partial struct SolidAngle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SolidAngle : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SolidAngle left, SolidAngle right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SolidAngle left, SolidAngle right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(SolidAngle other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SolidAngle objSolidAngle)) - return false; - - return Equals(objSolidAngle); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SolidAngle other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SolidAngle within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 1c0431aaa4..7be5e9d433 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Specific_energy /// [DataContract] - public partial struct SpecificEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -784,20 +784,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEnergy left, SpecificEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEnergy left, SpecificEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -813,23 +799,6 @@ public int CompareTo(SpecificEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificEnergy objSpecificEnergy)) - return false; - - return Equals(objSpecificEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificEnergy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 45488f057d..e2c13f0038 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. /// [DataContract] - public partial struct SpecificEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -541,20 +541,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEntropy left, SpecificEntropy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEntropy left, SpecificEntropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +556,6 @@ public int CompareTo(SpecificEntropy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificEntropy objSpecificEntropy)) - return false; - - return Equals(objSpecificEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEntropy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificEntropy within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 342a3d2445..78d40f2948 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption /// [DataContract] - public partial struct SpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -469,20 +469,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificFuelConsumption left, SpecificFuelConsumption right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificFuelConsumption left, SpecificFuelConsumption right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -498,23 +484,6 @@ public int CompareTo(SpecificFuelConsumption other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificFuelConsumption objSpecificFuelConsumption)) - return false; - - return Equals(objSpecificFuelConsumption); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificFuelConsumption other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificFuelConsumption within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index a398af10d3..7805b02fce 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. /// [DataContract] - public partial struct SpecificVolume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificVolume : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -451,20 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificVolume left, SpecificVolume right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificVolume left, SpecificVolume right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -480,23 +466,6 @@ public int CompareTo(SpecificVolume other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificVolume objSpecificVolume)) - return false; - - return Equals(objSpecificVolume); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificVolume other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificVolume within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index bf29901ef9..969e1bdae7 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Specificweight /// [DataContract] - public partial struct SpecificWeight : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificWeight : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -664,20 +664,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificWeight left, SpecificWeight right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificWeight left, SpecificWeight right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -693,23 +679,6 @@ public int CompareTo(SpecificWeight other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificWeight objSpecificWeight)) - return false; - - return Equals(objSpecificWeight); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificWeight other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificWeight within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 526a46d875..7974b6d834 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. /// [DataContract] - public partial struct Speed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Speed : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -886,20 +886,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Speed left, Speed right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Speed left, Speed right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -915,23 +901,6 @@ public int CompareTo(Speed other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Speed objSpeed)) - return false; - - return Equals(objSpeed); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Speed other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Speed within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 4d32fd8295..0aaf0ffc99 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions. /// [DataContract] - public partial struct StandardVolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct StandardVolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -541,20 +541,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(StandardVolumeFlow left, StandardVolumeFlow right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(StandardVolumeFlow left, StandardVolumeFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +556,6 @@ public int CompareTo(StandardVolumeFlow other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is StandardVolumeFlow objStandardVolumeFlow)) - return false; - - return Equals(objStandardVolumeFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(StandardVolumeFlow other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another StandardVolumeFlow within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 3dfe18d15e..199efee3b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. /// [DataContract] - public partial struct Temperature : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Temperature : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -510,20 +510,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Temperature left, Temperature right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Temperature left, Temperature right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -539,23 +525,6 @@ public int CompareTo(Temperature other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Temperature objTemperature)) - return false; - - return Equals(objTemperature); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Temperature other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Temperature within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 951fd7590e..896718766b 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). /// [DataContract] - public partial struct TemperatureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -556,20 +556,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -585,23 +571,6 @@ public int CompareTo(TemperatureChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) - return false; - - return Equals(objTemperatureChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TemperatureChangeRate within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 72c0d1ae50..54ffc9d7ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Difference between two temperatures. The conversions are different than for Temperature. /// [DataContract] - public partial struct TemperatureDelta : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureDelta : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -541,20 +541,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureDelta left, TemperatureDelta right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureDelta left, TemperatureDelta right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +556,6 @@ public int CompareTo(TemperatureDelta other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureDelta objTemperatureDelta)) - return false; - - return Equals(objTemperatureDelta); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureDelta other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TemperatureDelta within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index e84d3ff1c7..a424b53255 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thermal_Conductivity /// [DataContract] - public partial struct ThermalConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -439,20 +439,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalConductivity left, ThermalConductivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalConductivity left, ThermalConductivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -468,23 +454,6 @@ public int CompareTo(ThermalConductivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ThermalConductivity objThermalConductivity)) - return false; - - return Equals(objThermalConductivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalConductivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ThermalConductivity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index da8e427a49..5cb5699bdb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. /// [DataContract] - public partial struct ThermalResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -481,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalResistance left, ThermalResistance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalResistance left, ThermalResistance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -510,23 +496,6 @@ public int CompareTo(ThermalResistance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ThermalResistance objThermalResistance)) - return false; - - return Equals(objThermalResistance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalResistance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ThermalResistance within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 093953a4b0..7f2f474c37 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. /// [DataContract] - public partial struct Torque : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Torque : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -736,20 +736,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Torque left, Torque right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Torque left, Torque right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -765,23 +751,6 @@ public int CompareTo(Torque other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Torque objTorque)) - return false; - - return Equals(objTorque); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Torque other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Torque within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 7d5f2b1764..13530acaf2 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// The magnitude of torque per unit length. /// [DataContract] - public partial struct TorquePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TorquePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -721,20 +721,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TorquePerLength left, TorquePerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TorquePerLength left, TorquePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -750,23 +736,6 @@ public int CompareTo(TorquePerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TorquePerLength objTorquePerLength)) - return false; - - return Equals(objTorquePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TorquePerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TorquePerLength within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index dc81095700..1af3f4e89c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Turbidity /// [DataContract] - public partial struct Turbidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Turbidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -424,20 +424,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Turbidity left, Turbidity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Turbidity left, Turbidity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -453,23 +439,6 @@ public int CompareTo(Turbidity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Turbidity objTurbidity)) - return false; - - return Equals(objTurbidity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Turbidity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Turbidity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index e4f3b5ee6c..6fc9609e17 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. /// [DataContract] - public partial struct VitaminA : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VitaminA : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -421,20 +421,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VitaminA left, VitaminA right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VitaminA left, VitaminA right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -450,23 +436,6 @@ public int CompareTo(VitaminA other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VitaminA objVitaminA)) - return false; - - return Equals(objVitaminA); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VitaminA other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VitaminA within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 6265fb8806..7062fca5e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. /// [DataContract] - public partial struct Volume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Volume : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -1171,20 +1171,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Volume left, Volume right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Volume left, Volume right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1200,23 +1186,6 @@ public int CompareTo(Volume other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Volume objVolume)) - return false; - - return Equals(objVolume); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Volume other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Volume within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 69ecaab423..df66989d05 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration /// [DataContract] - public partial struct VolumeConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -709,20 +709,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeConcentration left, VolumeConcentration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeConcentration left, VolumeConcentration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -738,23 +724,6 @@ public int CompareTo(VolumeConcentration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeConcentration objVolumeConcentration)) - return false; - - return Equals(objVolumeConcentration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeConcentration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumeConcentration within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 0a8608e307..fe14d36952 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. /// [DataContract] - public partial struct VolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -1246,20 +1246,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeFlow left, VolumeFlow right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeFlow left, VolumeFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1275,23 +1261,6 @@ public int CompareTo(VolumeFlow other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeFlow objVolumeFlow)) - return false; - - return Equals(objVolumeFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeFlow other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumeFlow within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index c4369aceba..bd0dea99e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// Volume, typically of fluid, that a container can hold within a unit of length. /// [DataContract] - public partial struct VolumePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -511,20 +511,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumePerLength left, VolumePerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumePerLength left, VolumePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -540,23 +526,6 @@ public int CompareTo(VolumePerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumePerLength objVolumePerLength)) - return false; - - return Equals(objVolumePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumePerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumePerLength within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 2ee69e6aa7..19525dabe2 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -38,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Volumetric_heat_capacity /// [DataContract] - public partial struct VolumetricHeatCapacity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumetricHeatCapacity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -544,20 +544,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumetricHeatCapacity left, VolumetricHeatCapacity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumetricHeatCapacity left, VolumetricHeatCapacity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -573,23 +559,6 @@ public int CompareTo(VolumetricHeatCapacity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumetricHeatCapacity objVolumetricHeatCapacity)) - return false; - - return Equals(objVolumetricHeatCapacity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumetricHeatCapacity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumetricHeatCapacity within the given absolute or relative tolerance. diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index adab894eed..7ee0cac165 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -35,7 +35,7 @@ namespace UnitsNet /// A geometric property of an area that is used to determine the warping stress. /// [DataContract] - public partial struct WarpingMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct WarpingMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -496,20 +496,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -525,23 +511,6 @@ public int CompareTo(WarpingMomentOfInertia other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) - return false; - - return Equals(objWarpingMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(WarpingMomentOfInertia other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another WarpingMomentOfInertia within the given absolute or relative tolerance. From 64afc5967c6cd7b5b793a94e740dae4bd8036230 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:22:25 +0100 Subject: [PATCH 31/66] Fix tests --- UnitsNet.Tests/BaseUnitsTests.cs | 2 +- UnitsNet/BaseUnits.cs | 2 ++ UnitsNet/UnitConverter.cs | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/UnitsNet.Tests/BaseUnitsTests.cs b/UnitsNet.Tests/BaseUnitsTests.cs index 4056bac59a..f50580c387 100644 --- a/UnitsNet.Tests/BaseUnitsTests.cs +++ b/UnitsNet.Tests/BaseUnitsTests.cs @@ -112,7 +112,7 @@ public void UndefinedIsSubsetOfUndefined() [Fact] public void IsSubsetOfReturnsFalseWithNull() { - Assert.False(SIBaseUnits.IsSubsetOf(null!)); + Assert.Throws(() => SIBaseUnits.IsSubsetOf(null!)); } [Fact] diff --git a/UnitsNet/BaseUnits.cs b/UnitsNet/BaseUnits.cs index 03f192edc3..61d08b761f 100644 --- a/UnitsNet/BaseUnits.cs +++ b/UnitsNet/BaseUnits.cs @@ -90,6 +90,8 @@ public bool Equals(BaseUnits? other) /// True if the base units are a subset of other, otherwise false. public bool IsSubsetOf(BaseUnits other) { + if (other == null) throw new ArgumentNullException(nameof(other)); + // If all base units are undefined, can only be a subset of another where all base units are undefined. if (Equals(Undefined)) return other.Equals(Undefined); diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 43a5b4bd1d..a5cec6e144 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -529,7 +529,7 @@ private static bool TryParseUnit(Type unitType, string unitName, out Enum? unitV if (matchedUnitName == null) return false; - unitValue = (Enum) Enum.Parse(unitType, unitName); + unitValue = (Enum) Enum.Parse(unitType, matchedUnitName); return true; } From ba903bc478cb5c1d20dd3d065d9520c0b66ce760 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 01:27:35 +0100 Subject: [PATCH 32/66] Fix singular name VolumeFlow.MillionUsGallonsPerDay --- Common/UnitDefinitions/VolumeFlow.json | 2 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 8 ++++---- .../GeneratedCode/Units/VolumeFlowUnit.g.cs | 2 +- .../TestsBase/VolumeFlowTestsBase.g.cs | 16 ++++++++-------- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 10 +++++----- .../GeneratedCode/UnitAbbreviationsCache.g.cs | 2 +- UnitsNet/GeneratedCode/UnitConverter.g.cs | 4 ++-- UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs | 2 +- 8 files changed, 23 insertions(+), 23 deletions(-) diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json index a100c54afa..2c6b299055 100644 --- a/Common/UnitDefinitions/VolumeFlow.json +++ b/Common/UnitDefinitions/VolumeFlow.json @@ -152,7 +152,7 @@ ] }, { - "SingularName": "MillionUsGallonsPerDay", + "SingularName": "MillionUsGallonPerDay", "PluralName": "MillionUsGallonsPerDay", "FromUnitToBaseFunc": "x/22.824465227", "FromBaseToUnitFunc": "x*22.824465227", diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs index 7fffcfd6c4..61dec59cf5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -280,7 +280,7 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// /// Get VolumeFlow in MillionUsGallonsPerDay. /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay); + public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); /// /// Get VolumeFlow in NanolitersPerDay. @@ -605,7 +605,7 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// Get VolumeFlow from MillionUsGallonsPerDay. /// /// If value is NaN or Infinity. - public static VolumeFlow FromMillionUsGallonsPerDay(double millionusgallonsperday) => new VolumeFlow(millionusgallonsperday, VolumeFlowUnit.MillionUsGallonsPerDay); + public static VolumeFlow FromMillionUsGallonsPerDay(double millionusgallonsperday) => new VolumeFlow(millionusgallonsperday, VolumeFlowUnit.MillionUsGallonPerDay); /// /// Get VolumeFlow from NanolitersPerDay. @@ -778,7 +778,7 @@ private double GetValueInBaseUnit() case VolumeFlowUnit.MilliliterPerDay: return (_value/86400000) * 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.MillionUsGallonPerDay: return _value/22.824465227; case VolumeFlowUnit.NanoliterPerDay: return (_value/86400000) * 1e-9d; case VolumeFlowUnit.NanoliterPerMinute: return (_value/60000.00000) * 1e-9d; case VolumeFlowUnit.NanoliterPerSecond: return (_value/1000) * 1e-9d; @@ -848,7 +848,7 @@ private double GetValueAs(VolumeFlowUnit unit) case VolumeFlowUnit.MilliliterPerDay: return (baseUnitValue*86400000) / 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.MillionUsGallonPerDay: return baseUnitValue*22.824465227; case VolumeFlowUnit.NanoliterPerDay: return (baseUnitValue*86400000) / 1e-9d; case VolumeFlowUnit.NanoliterPerMinute: return (baseUnitValue*60000.00000) / 1e-9d; case VolumeFlowUnit.NanoliterPerSecond: return (baseUnitValue*1000) / 1e-9d; diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs index f4333f63ec..f801690542 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs @@ -66,7 +66,7 @@ public enum VolumeFlowUnit MilliliterPerDay, MilliliterPerMinute, MilliliterPerSecond, - MillionUsGallonsPerDay, + MillionUsGallonPerDay, NanoliterPerDay, NanoliterPerMinute, NanoliterPerSecond, diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 9a6a363063..be93743135 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -440,9 +440,9 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() AssertEx.EqualTolerance(1, quantity39.MillilitersPerSecond, MillilitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.MilliliterPerSecond, quantity39.Unit); - var quantity40 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonsPerDay); + var quantity40 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonPerDay); AssertEx.EqualTolerance(1, quantity40.MillionUsGallonsPerDay, MillionUsGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MillionUsGallonsPerDay, quantity40.Unit); + Assert.Equal(VolumeFlowUnit.MillionUsGallonPerDay, quantity40.Unit); var quantity41 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerDay); AssertEx.EqualTolerance(1, quantity41.NanolitersPerDay, NanolitersPerDayTolerance); @@ -563,7 +563,7 @@ public void As() AssertEx.EqualTolerance(MillilitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MilliliterPerDay), MillilitersPerDayTolerance); AssertEx.EqualTolerance(MillilitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MilliliterPerMinute), MillilitersPerMinuteTolerance); AssertEx.EqualTolerance(MillilitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MilliliterPerSecond), MillilitersPerSecondTolerance); - AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MillionUsGallonsPerDay), MillionUsGallonsPerDayTolerance); + AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MillionUsGallonPerDay), MillionUsGallonsPerDayTolerance); AssertEx.EqualTolerance(NanolitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.NanoliterPerDay), NanolitersPerDayTolerance); AssertEx.EqualTolerance(NanolitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.NanoliterPerMinute), NanolitersPerMinuteTolerance); AssertEx.EqualTolerance(NanolitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.NanoliterPerSecond), NanolitersPerSecondTolerance); @@ -763,9 +763,9 @@ public void ToUnit() AssertEx.EqualTolerance(MillilitersPerSecondInOneCubicMeterPerSecond, (double)milliliterpersecondQuantity.Value, MillilitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.MilliliterPerSecond, milliliterpersecondQuantity.Unit); - var millionusgallonsperdayQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay); - AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, (double)millionusgallonsperdayQuantity.Value, MillionUsGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MillionUsGallonsPerDay, millionusgallonsperdayQuantity.Unit); + var millionusgallonperdayQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.MillionUsGallonPerDay); + AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, (double)millionusgallonperdayQuantity.Value, MillionUsGallonsPerDayTolerance); + Assert.Equal(VolumeFlowUnit.MillionUsGallonPerDay, millionusgallonperdayQuantity.Unit); var nanoliterperdayQuantity = cubicmeterpersecond.ToUnit(VolumeFlowUnit.NanoliterPerDay); AssertEx.EqualTolerance(NanolitersPerDayInOneCubicMeterPerSecond, (double)nanoliterperdayQuantity.Value, NanolitersPerDayTolerance); @@ -1050,7 +1050,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 ml/day", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerDay).ToString()); Assert.Equal("1 mL/min", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerMinute).ToString()); Assert.Equal("1 mL/s", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerSecond).ToString()); - Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonsPerDay).ToString()); + Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonPerDay).ToString()); Assert.Equal("1 nl/day", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerDay).ToString()); Assert.Equal("1 nL/min", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerMinute).ToString()); Assert.Equal("1 nL/s", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerSecond).ToString()); @@ -1119,7 +1119,7 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 ml/day", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerDay).ToString(swedishCulture)); Assert.Equal("1 mL/min", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerMinute).ToString(swedishCulture)); Assert.Equal("1 mL/s", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerSecond).ToString(swedishCulture)); - Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonsPerDay).ToString(swedishCulture)); + Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonPerDay).ToString(swedishCulture)); Assert.Equal("1 nl/day", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerDay).ToString(swedishCulture)); Assert.Equal("1 nL/min", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerMinute).ToString(swedishCulture)); Assert.Equal("1 nL/s", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerSecond).ToString(swedishCulture)); diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index fe14d36952..aa5193c9d2 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -95,7 +95,7 @@ static VolumeFlow() new UnitInfo(VolumeFlowUnit.MilliliterPerDay, "MillilitersPerDay", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.MilliliterPerMinute, "MillilitersPerMinute", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.MilliliterPerSecond, "MillilitersPerSecond", BaseUnits.Undefined), - new UnitInfo(VolumeFlowUnit.MillionUsGallonsPerDay, "MillionUsGallonsPerDay", BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MillionUsGallonPerDay, "MillionUsGallonsPerDay", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.NanoliterPerDay, "NanolitersPerDay", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.NanoliterPerMinute, "NanolitersPerMinute", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.NanoliterPerSecond, "NanolitersPerSecond", BaseUnits.Undefined), @@ -406,7 +406,7 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// Get VolumeFlow in MillionUsGallonsPerDay. /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay); + public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); /// /// Get VolumeFlow in NanolitersPerDay. @@ -879,7 +879,7 @@ public static VolumeFlow FromMillilitersPerSecond(QuantityValue millilitersperse public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday) { double value = (double) millionusgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonsPerDay); + return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonPerDay); } /// /// Get VolumeFlow from NanolitersPerDay. @@ -1454,7 +1454,7 @@ private double GetValueInBaseUnit() case VolumeFlowUnit.MilliliterPerDay: return (_value/86400000) * 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.MillionUsGallonPerDay: return _value/22.824465227; case VolumeFlowUnit.NanoliterPerDay: return (_value/86400000) * 1e-9d; case VolumeFlowUnit.NanoliterPerMinute: return (_value/60000.00000) * 1e-9d; case VolumeFlowUnit.NanoliterPerSecond: return (_value/1000) * 1e-9d; @@ -1535,7 +1535,7 @@ private double GetValueAs(VolumeFlowUnit unit) case VolumeFlowUnit.MilliliterPerDay: return (baseUnitValue*86400000) / 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.MillionUsGallonPerDay: return baseUnitValue*22.824465227; case VolumeFlowUnit.NanoliterPerDay: return (baseUnitValue*86400000) / 1e-9d; case VolumeFlowUnit.NanoliterPerMinute: return (baseUnitValue*60000.00000) / 1e-9d; case VolumeFlowUnit.NanoliterPerSecond: return (baseUnitValue*1000) / 1e-9d; diff --git a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs index a93fe609de..5e7ff16484 100644 --- a/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs +++ b/UnitsNet/GeneratedCode/UnitAbbreviationsCache.g.cs @@ -1677,7 +1677,7 @@ private static readonly (string CultureName, Type UnitType, int UnitValue, strin ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerMinute, new string[]{"мл/мин"}), ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerSecond, new string[]{"mL/s", "mLPS"}), ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MilliliterPerSecond, new string[]{"мл/c"}), - ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MillionUsGallonsPerDay, new string[]{"MGD"}), + ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.MillionUsGallonPerDay, new string[]{"MGD"}), ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerDay, new string[]{"nl/day", "nL/d", "nLPD"}), ("en-US", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerMinute, new string[]{"nL/min", "nLPM"}), ("ru-RU", typeof(VolumeFlowUnit), (int)VolumeFlowUnit.NanoliterPerMinute, new string[]{"нл/мин"}), diff --git a/UnitsNet/GeneratedCode/UnitConverter.g.cs b/UnitsNet/GeneratedCode/UnitConverter.g.cs index 0bf220153f..7adacb79ee 100644 --- a/UnitsNet/GeneratedCode/UnitConverter.g.cs +++ b/UnitsNet/GeneratedCode/UnitConverter.g.cs @@ -2501,8 +2501,8 @@ public static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerMinute, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MilliliterPerSecond, q => q.ToUnit(VolumeFlowUnit.MilliliterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerSecond, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); - unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MillionUsGallonsPerDay, q => q.ToUnit(VolumeFlowUnit.MillionUsGallonsPerDay)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonsPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); + unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.MillionUsGallonPerDay, q => q.ToUnit(VolumeFlowUnit.MillionUsGallonPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.NanoliterPerDay, q => q.ToUnit(VolumeFlowUnit.NanoliterPerDay)); unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerDay, VolumeFlow.ConversionBaseUnit, q => q.ToBaseUnit()); unitConverter.SetConversionFunction(VolumeFlow.ConversionBaseUnit, VolumeFlowUnit.NanoliterPerMinute, q => q.ToUnit(VolumeFlowUnit.NanoliterPerMinute)); diff --git a/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs index f4333f63ec..f801690542 100644 --- a/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs @@ -66,7 +66,7 @@ public enum VolumeFlowUnit MilliliterPerDay, MilliliterPerMinute, MilliliterPerSecond, - MillionUsGallonsPerDay, + MillionUsGallonPerDay, NanoliterPerDay, NanoliterPerMinute, NanoliterPerSecond, From 57676089d9e08b9b7ad5a58d78956604223f6aca Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 2 Nov 2021 22:38:47 +0100 Subject: [PATCH 33/66] Remove UnitsNet.WindowsRuntimeComponent.sln --- UnitsNet.WindowsRuntimeComponent.sln | 42 ---------------------------- 1 file changed, 42 deletions(-) delete mode 100644 UnitsNet.WindowsRuntimeComponent.sln diff --git a/UnitsNet.WindowsRuntimeComponent.sln b/UnitsNet.WindowsRuntimeComponent.sln deleted file mode 100644 index 4b394489cc..0000000000 --- a/UnitsNet.WindowsRuntimeComponent.sln +++ /dev/null @@ -1,42 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27004.2002 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitsNet.WindowsRuntimeComponent", "UnitsNet.WindowsRuntimeComponent\UnitsNet.WindowsRuntimeComponent.csproj", "{2DA428CA-BFE1-43FA-86D2-7CB42289D596}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|Any CPU.Build.0 = Debug|Any CPU - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|ARM.ActiveCfg = Debug|ARM - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|ARM.Build.0 = Debug|ARM - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x64.ActiveCfg = Debug|x64 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x64.Build.0 = Debug|x64 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x86.ActiveCfg = Debug|x86 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Debug|x86.Build.0 = Debug|x86 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|Any CPU.ActiveCfg = Release|Any CPU - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|Any CPU.Build.0 = Release|Any CPU - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|ARM.ActiveCfg = Release|ARM - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|ARM.Build.0 = Release|ARM - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x64.ActiveCfg = Release|x64 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x64.Build.0 = Release|x64 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x86.ActiveCfg = Release|x86 - {2DA428CA-BFE1-43FA-86D2-7CB42289D596}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F00A533B-6E8A-4169-9018-F9D6232A7E3C} - EndGlobalSection -EndGlobal From bdcea55f40a796d00fdc24482b1a057039fc7f2b Mon Sep 17 00:00:00 2001 From: Patrick Grawehr Date: Sat, 13 Nov 2021 22:55:16 +0100 Subject: [PATCH 34/66] Use CurrentCulture rather than CurrentUICulture (#986) Co-authored-by: Tristan Milnthorp --- .../UnitsNetGen/QuantityGenerator.cs | 20 ++++++------- .../UnitsNetGen/StaticQuantityGenerator.cs | 2 +- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 16 +++++----- README.md | 7 +++-- UnitsNet.Tests/CustomCode/StonePoundsTests.cs | 2 +- .../TestsBase/AccelerationTestsBase.g.cs | 16 +++++----- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 16 +++++----- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 16 +++++----- .../TestsBase/AngleTestsBase.g.cs | 16 +++++----- .../TestsBase/ApparentEnergyTestsBase.g.cs | 16 +++++----- .../TestsBase/ApparentPowerTestsBase.g.cs | 16 +++++----- .../TestsBase/AreaDensityTestsBase.g.cs | 16 +++++----- .../AreaMomentOfInertiaTestsBase.g.cs | 16 +++++----- .../TestsBase/AreaTestsBase.g.cs | 16 +++++----- .../TestsBase/BitRateTestsBase.g.cs | 16 +++++----- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 16 +++++----- .../TestsBase/CapacitanceTestsBase.g.cs | 16 +++++----- ...oefficientOfThermalExpansionTestsBase.g.cs | 16 +++++----- .../TestsBase/DensityTestsBase.g.cs | 16 +++++----- .../TestsBase/DurationTestsBase.g.cs | 16 +++++----- .../TestsBase/DynamicViscosityTestsBase.g.cs | 16 +++++----- .../ElectricAdmittanceTestsBase.g.cs | 16 +++++----- .../ElectricChargeDensityTestsBase.g.cs | 16 +++++----- .../TestsBase/ElectricChargeTestsBase.g.cs | 16 +++++----- .../ElectricConductanceTestsBase.g.cs | 16 +++++----- .../ElectricConductivityTestsBase.g.cs | 16 +++++----- .../ElectricCurrentDensityTestsBase.g.cs | 16 +++++----- .../ElectricCurrentGradientTestsBase.g.cs | 16 +++++----- .../TestsBase/ElectricCurrentTestsBase.g.cs | 16 +++++----- .../TestsBase/ElectricFieldTestsBase.g.cs | 16 +++++----- .../ElectricInductanceTestsBase.g.cs | 16 +++++----- .../ElectricPotentialAcTestsBase.g.cs | 16 +++++----- .../ElectricPotentialChangeRateTestsBase.g.cs | 16 +++++----- .../ElectricPotentialDcTestsBase.g.cs | 16 +++++----- .../TestsBase/ElectricPotentialTestsBase.g.cs | 16 +++++----- .../ElectricResistanceTestsBase.g.cs | 16 +++++----- .../ElectricResistivityTestsBase.g.cs | 16 +++++----- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 16 +++++----- .../TestsBase/EnergyTestsBase.g.cs | 16 +++++----- .../TestsBase/EntropyTestsBase.g.cs | 16 +++++----- .../TestsBase/ForceChangeRateTestsBase.g.cs | 16 +++++----- .../TestsBase/ForcePerLengthTestsBase.g.cs | 16 +++++----- .../TestsBase/ForceTestsBase.g.cs | 16 +++++----- .../TestsBase/FrequencyTestsBase.g.cs | 16 +++++----- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 16 +++++----- .../TestsBase/HeatFluxTestsBase.g.cs | 16 +++++----- .../HeatTransferCoefficientTestsBase.g.cs | 16 +++++----- .../TestsBase/IlluminanceTestsBase.g.cs | 16 +++++----- .../TestsBase/InformationTestsBase.g.cs | 16 +++++----- .../TestsBase/IrradianceTestsBase.g.cs | 16 +++++----- .../TestsBase/IrradiationTestsBase.g.cs | 16 +++++----- .../KinematicViscosityTestsBase.g.cs | 16 +++++----- .../TestsBase/LapseRateTestsBase.g.cs | 16 +++++----- .../TestsBase/LengthTestsBase.g.cs | 16 +++++----- .../TestsBase/LevelTestsBase.g.cs | 16 +++++----- .../TestsBase/LinearDensityTestsBase.g.cs | 16 +++++----- .../LinearPowerDensityTestsBase.g.cs | 16 +++++----- .../TestsBase/LuminosityTestsBase.g.cs | 16 +++++----- .../TestsBase/LuminousFluxTestsBase.g.cs | 16 +++++----- .../TestsBase/LuminousIntensityTestsBase.g.cs | 16 +++++----- .../TestsBase/MagneticFieldTestsBase.g.cs | 16 +++++----- .../TestsBase/MagneticFluxTestsBase.g.cs | 16 +++++----- .../TestsBase/MagnetizationTestsBase.g.cs | 16 +++++----- .../TestsBase/MassConcentrationTestsBase.g.cs | 16 +++++----- .../TestsBase/MassFlowTestsBase.g.cs | 16 +++++----- .../TestsBase/MassFluxTestsBase.g.cs | 16 +++++----- .../TestsBase/MassFractionTestsBase.g.cs | 16 +++++----- .../MassMomentOfInertiaTestsBase.g.cs | 16 +++++----- .../TestsBase/MassTestsBase.g.cs | 16 +++++----- .../TestsBase/MolarEnergyTestsBase.g.cs | 16 +++++----- .../TestsBase/MolarEntropyTestsBase.g.cs | 16 +++++----- .../TestsBase/MolarMassTestsBase.g.cs | 16 +++++----- .../TestsBase/MolarityTestsBase.g.cs | 16 +++++----- .../TestsBase/PermeabilityTestsBase.g.cs | 16 +++++----- .../TestsBase/PermittivityTestsBase.g.cs | 16 +++++----- .../TestsBase/PowerDensityTestsBase.g.cs | 16 +++++----- .../TestsBase/PowerRatioTestsBase.g.cs | 16 +++++----- .../TestsBase/PowerTestsBase.g.cs | 16 +++++----- .../PressureChangeRateTestsBase.g.cs | 16 +++++----- .../TestsBase/PressureTestsBase.g.cs | 16 +++++----- .../TestsBase/RatioChangeRateTestsBase.g.cs | 16 +++++----- .../TestsBase/RatioTestsBase.g.cs | 16 +++++----- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 16 +++++----- .../TestsBase/ReactivePowerTestsBase.g.cs | 16 +++++----- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 16 +++++----- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 16 +++++----- .../TestsBase/RelativeHumidityTestsBase.g.cs | 16 +++++----- .../RotationalAccelerationTestsBase.g.cs | 16 +++++----- .../TestsBase/RotationalSpeedTestsBase.g.cs | 16 +++++----- ...RotationalStiffnessPerLengthTestsBase.g.cs | 16 +++++----- .../RotationalStiffnessTestsBase.g.cs | 16 +++++----- .../TestsBase/ScalarTestsBase.g.cs | 16 +++++----- .../TestsBase/SolidAngleTestsBase.g.cs | 16 +++++----- .../TestsBase/SpecificEnergyTestsBase.g.cs | 16 +++++----- .../TestsBase/SpecificEntropyTestsBase.g.cs | 16 +++++----- .../SpecificFuelConsumptionTestsBase.g.cs | 16 +++++----- .../TestsBase/SpecificVolumeTestsBase.g.cs | 16 +++++----- .../TestsBase/SpecificWeightTestsBase.g.cs | 16 +++++----- .../TestsBase/SpeedTestsBase.g.cs | 16 +++++----- .../StandardVolumeFlowTestsBase.g.cs | 16 +++++----- .../TemperatureChangeRateTestsBase.g.cs | 16 +++++----- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 16 +++++----- .../TestsBase/TemperatureTestsBase.g.cs | 16 +++++----- .../ThermalConductivityTestsBase.g.cs | 16 +++++----- .../TestsBase/ThermalResistanceTestsBase.g.cs | 16 +++++----- .../TestsBase/TorquePerLengthTestsBase.g.cs | 16 +++++----- .../TestsBase/TorqueTestsBase.g.cs | 16 +++++----- .../TestsBase/TurbidityTestsBase.g.cs | 16 +++++----- .../TestsBase/VitaminATestsBase.g.cs | 16 +++++----- .../VolumeConcentrationTestsBase.g.cs | 16 +++++----- .../TestsBase/VolumeFlowTestsBase.g.cs | 16 +++++----- .../TestsBase/VolumePerLengthTestsBase.g.cs | 16 +++++----- .../TestsBase/VolumeTestsBase.g.cs | 16 +++++----- .../VolumetricHeatCapacityTestsBase.g.cs | 16 +++++----- .../WarpingMomentOfInertiaTestsBase.g.cs | 16 +++++----- UnitsNet.Tests/QuantityFormatterTests.cs | 14 +++++++-- UnitsNet.Tests/QuantityIConvertibleTests.cs | 8 ++--- UnitsNet.Tests/QuantityIFormattableTests.cs | 2 +- UnitsNet.Tests/QuantityTests.ToString.cs | 6 ++-- UnitsNet.Tests/UnitAbbreviationsCacheTests.cs | 6 ++-- .../CustomCode/Quantities/Length.extra.cs | 4 +-- UnitsNet/CustomCode/Quantities/Mass.extra.cs | 4 +-- UnitsNet/CustomCode/Quantity.cs | 2 +- UnitsNet/CustomCode/UnitAbbreviationsCache.cs | 30 +++++++++---------- UnitsNet/CustomCode/UnitParser.cs | 8 ++--- .../Quantities/Acceleration.g.cs | 20 ++++++------- .../Quantities/AmountOfSubstance.g.cs | 20 ++++++------- .../Quantities/AmplitudeRatio.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 20 ++++++------- .../Quantities/ApparentEnergy.g.cs | 20 ++++++------- .../Quantities/ApparentPower.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/AreaDensity.g.cs | 20 ++++++------- .../Quantities/AreaMomentOfInertia.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/BitRate.g.cs | 20 ++++++------- .../BrakeSpecificFuelConsumption.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Capacitance.g.cs | 20 ++++++------- .../CoefficientOfThermalExpansion.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Density.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Duration.g.cs | 20 ++++++------- .../Quantities/DynamicViscosity.g.cs | 20 ++++++------- .../Quantities/ElectricAdmittance.g.cs | 20 ++++++------- .../Quantities/ElectricCharge.g.cs | 20 ++++++------- .../Quantities/ElectricChargeDensity.g.cs | 20 ++++++------- .../Quantities/ElectricConductance.g.cs | 20 ++++++------- .../Quantities/ElectricConductivity.g.cs | 20 ++++++------- .../Quantities/ElectricCurrent.g.cs | 20 ++++++------- .../Quantities/ElectricCurrentDensity.g.cs | 20 ++++++------- .../Quantities/ElectricCurrentGradient.g.cs | 20 ++++++------- .../Quantities/ElectricField.g.cs | 20 ++++++------- .../Quantities/ElectricInductance.g.cs | 20 ++++++------- .../Quantities/ElectricPotential.g.cs | 20 ++++++------- .../Quantities/ElectricPotentialAc.g.cs | 20 ++++++------- .../ElectricPotentialChangeRate.g.cs | 20 ++++++------- .../Quantities/ElectricPotentialDc.g.cs | 20 ++++++------- .../Quantities/ElectricResistance.g.cs | 20 ++++++------- .../Quantities/ElectricResistivity.g.cs | 20 ++++++------- .../ElectricSurfaceChargeDensity.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Entropy.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 20 ++++++------- .../Quantities/ForceChangeRate.g.cs | 20 ++++++------- .../Quantities/ForcePerLength.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Frequency.g.cs | 20 ++++++------- .../Quantities/FuelEfficiency.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/HeatFlux.g.cs | 20 ++++++------- .../Quantities/HeatTransferCoefficient.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Illuminance.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Information.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Irradiance.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Irradiation.g.cs | 20 ++++++------- .../Quantities/KinematicViscosity.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/LapseRate.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 20 ++++++------- .../Quantities/LinearDensity.g.cs | 20 ++++++------- .../Quantities/LinearPowerDensity.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Luminosity.g.cs | 20 ++++++------- .../Quantities/LuminousFlux.g.cs | 20 ++++++------- .../Quantities/LuminousIntensity.g.cs | 20 ++++++------- .../Quantities/MagneticField.g.cs | 20 ++++++------- .../Quantities/MagneticFlux.g.cs | 20 ++++++------- .../Quantities/Magnetization.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 20 ++++++------- .../Quantities/MassConcentration.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/MassFlow.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/MassFlux.g.cs | 20 ++++++------- .../Quantities/MassFraction.g.cs | 20 ++++++------- .../Quantities/MassMomentOfInertia.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 20 ++++++------- .../Quantities/MolarEntropy.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/MolarMass.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Molarity.g.cs | 20 ++++++------- .../Quantities/Permeability.g.cs | 20 ++++++------- .../Quantities/Permittivity.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 20 ++++++------- .../Quantities/PowerDensity.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/PowerRatio.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Pressure.g.cs | 20 ++++++------- .../Quantities/PressureChangeRate.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 20 ++++++------- .../Quantities/RatioChangeRate.g.cs | 20 ++++++------- .../Quantities/ReactiveEnergy.g.cs | 20 ++++++------- .../Quantities/ReactivePower.g.cs | 20 ++++++------- .../Quantities/ReciprocalArea.g.cs | 20 ++++++------- .../Quantities/ReciprocalLength.g.cs | 20 ++++++------- .../Quantities/RelativeHumidity.g.cs | 20 ++++++------- .../Quantities/RotationalAcceleration.g.cs | 20 ++++++------- .../Quantities/RotationalSpeed.g.cs | 20 ++++++------- .../Quantities/RotationalStiffness.g.cs | 20 ++++++------- .../RotationalStiffnessPerLength.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/SolidAngle.g.cs | 20 ++++++------- .../Quantities/SpecificEnergy.g.cs | 20 ++++++------- .../Quantities/SpecificEntropy.g.cs | 20 ++++++------- .../Quantities/SpecificFuelConsumption.g.cs | 20 ++++++------- .../Quantities/SpecificVolume.g.cs | 20 ++++++------- .../Quantities/SpecificWeight.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 20 ++++++------- .../Quantities/StandardVolumeFlow.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Temperature.g.cs | 20 ++++++------- .../Quantities/TemperatureChangeRate.g.cs | 20 ++++++------- .../Quantities/TemperatureDelta.g.cs | 20 ++++++------- .../Quantities/ThermalConductivity.g.cs | 20 ++++++------- .../Quantities/ThermalResistance.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 20 ++++++------- .../Quantities/TorquePerLength.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/Turbidity.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/VitaminA.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 20 ++++++------- .../Quantities/VolumeConcentration.g.cs | 20 ++++++------- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 20 ++++++------- .../Quantities/VolumePerLength.g.cs | 20 ++++++------- .../Quantities/VolumetricHeatCapacity.g.cs | 20 ++++++------- .../Quantities/WarpingMomentOfInertia.g.cs | 20 ++++++------- UnitsNet/GeneratedCode/Quantity.g.cs | 2 +- UnitsNet/IQuantity.cs | 2 +- UnitsNet/QuantityFormatter.cs | 7 +++-- UnitsNet/UnitConverter.cs | 4 +-- 239 files changed, 2058 insertions(+), 2048 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 3c39933687..50f05679a1 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -334,7 +334,7 @@ public static string GetAbbreviation({_unitEnumName} unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation({_unitEnumName} unit, IFormatProvider? provider) {{ return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -437,7 +437,7 @@ private void GenerateStaticParseMethods() /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static {_quantity.Name} Parse(string str, IFormatProvider? provider) {{ return QuantityParser.Default.Parse<{_quantity.Name}, {_unitEnumName}>( @@ -468,7 +468,7 @@ public static bool TryParse(string? str, out {_quantity.Name} result) /// /// Length.Parse(""5.5 m"", new CultureInfo(""en-US"")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out {_quantity.Name} result) {{ return QuantityParser.Default.TryParse<{_quantity.Name}, {_unitEnumName}>( @@ -496,7 +496,7 @@ public static bool TryParse(string? str, IFormatProvider? provider, out {_quanti /// Parse a unit string. /// /// String to parse. Typically in the form: {{number}} {{unit}} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit(""m"", new CultureInfo(""en-US"")); /// @@ -522,7 +522,7 @@ public static bool TryParseUnit(string str, out {_unitEnumName} unit) /// /// Length.TryParseUnit(""m"", new CultureInfo(""en-US"")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out {_unitEnumName} unit) {{ return UnitParser.Default.TryParse<{_unitEnumName}>(str, provider, out unit); @@ -925,7 +925,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) {{ return ToString(""g"", provider); @@ -933,21 +933,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) {{ - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); }} /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) {{ diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 021d8e765b..2374cb83b3 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -99,7 +99,7 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quanti /// /// Try to dynamically parse a quantity string representation. /// - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Type of quantity, such as . /// Quantity string representation, such as ""1.5 kg"". Must be compatible with given quantity type. /// The resulting quantity if successful, otherwise default. diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 6928bfc736..fe007b5ec2 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -416,8 +416,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() {{ - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(""en-US""); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(""en-US""); try {{"); foreach (var unit in _quantity.Units) { @@ -428,7 +428,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() }} finally {{ - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; }} }} @@ -449,10 +449,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() {{ - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try {{ - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal(""0.1{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s1"")); Assert.Equal(""0.12{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s2"")); Assert.Equal(""0.123{_baseUnitEnglishAbbreviation}"", new {_quantity.Name}(0.123456{_numberSuffix}, {_baseUnitFullName}).ToString(""s3"")); @@ -460,7 +460,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul }} finally {{ - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; }} }} @@ -490,10 +490,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData(""g"")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); }} [Fact] diff --git a/README.md b/README.md index cc49212b62..84c2cadf90 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ RotationalSpeed r = Angle.FromDegrees(90) / TimeSpan.FromSeconds(2); ### Culture and Localization -The culture for abbreviations defaults to Thread.CurrentUICulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are: +The culture for abbreviations defaults to Thread.CurrentCulture and falls back to US English if not defined. Thread.CurrentCulture affects number formatting unless a custom culture is specified. The relevant methods are: * ToString() * GetAbbreviation() @@ -93,8 +93,9 @@ var usEnglish = new CultureInfo("en-US"); var russian = new CultureInfo("ru-RU"); var oneKg = Mass.FromKilograms(1); -// ToString() uses CurrentUICulture for abbreviation language and CurrentCulture for number formatting -Thread.CurrentThread.CurrentUICulture = russian; +// ToString() uses CurrentCulture for abbreviation language number formatting. This is consistent with the behavior of the .NET Framework, +// where DateTime.ToString() uses CurrentCulture for the whole string, likely because mixing an english date format with a russian month name might be confusing. +Thread.CurrentThread.CurrentCulture = russian; string kgRu = oneKg.ToString(); // "1 кг" // ToString() with specific culture and custom string format pattern diff --git a/UnitsNet.Tests/CustomCode/StonePoundsTests.cs b/UnitsNet.Tests/CustomCode/StonePoundsTests.cs index 76803c88d6..1191f3dc50 100644 --- a/UnitsNet.Tests/CustomCode/StonePoundsTests.cs +++ b/UnitsNet.Tests/CustomCode/StonePoundsTests.cs @@ -35,7 +35,7 @@ public void StonePoundsToString_FormatsNumberInDefaultCulture() { Mass m = Mass.FromStonePounds(3500, 1); StonePounds stonePounds = m.StonePounds; - string numberInCurrentCulture = 3500.ToString("n0", CultureInfo.CurrentUICulture); // Varies between machines, can't hard code it + string numberInCurrentCulture = 3500.ToString("n0", CultureInfo.CurrentCulture); // Varies between machines, can't hard code it Assert.Equal($"{numberInCurrentCulture} st 1 lb", stonePounds.ToString()); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 48b78e3959..1b6ebf73f5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -461,8 +461,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm/s²", new Acceleration(1, AccelerationUnit.CentimeterPerSecondSquared).ToString()); Assert.Equal("1 dm/s²", new Acceleration(1, AccelerationUnit.DecimeterPerSecondSquared).ToString()); @@ -481,7 +481,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -510,10 +510,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s1")); Assert.Equal("0.12 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s2")); Assert.Equal("0.123 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s3")); @@ -521,7 +521,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -551,10 +551,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 6df945f8a4..8155ff8eff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -474,8 +474,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cmol", new AmountOfSubstance(1, AmountOfSubstanceUnit.Centimole).ToString()); Assert.Equal("1 clbmol", new AmountOfSubstance(1, AmountOfSubstanceUnit.CentipoundMole).ToString()); @@ -495,7 +495,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -525,10 +525,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s1")); Assert.Equal("0.12 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s2")); Assert.Equal("0.123 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s3")); @@ -536,7 +536,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -566,10 +566,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index d756cc753f..029a660a52 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -335,8 +335,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 dBµV", new AmplitudeRatio(1, AmplitudeRatioUnit.DecibelMicrovolt).ToString()); Assert.Equal("1 dBmV", new AmplitudeRatio(1, AmplitudeRatioUnit.DecibelMillivolt).ToString()); @@ -345,7 +345,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -364,10 +364,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s1")); Assert.Equal("0.12 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s2")); Assert.Equal("0.123 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s3")); @@ -375,7 +375,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -405,10 +405,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 7f1cea4263..d8fa56abaf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -487,8 +487,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 '", new Angle(1, AngleUnit.Arcminute).ToString()); Assert.Equal("1 ″", new Angle(1, AngleUnit.Arcsecond).ToString()); @@ -509,7 +509,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -540,10 +540,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 °", new Angle(0.123456, AngleUnit.Degree).ToString("s1")); Assert.Equal("0.12 °", new Angle(0.123456, AngleUnit.Degree).ToString("s2")); Assert.Equal("0.123 °", new Angle(0.123456, AngleUnit.Degree).ToString("s3")); @@ -551,7 +551,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -581,10 +581,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Angle.FromDegrees(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index d568bf6438..3bf958cb62 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kVAh", new ApparentEnergy(1, ApparentEnergyUnit.KilovoltampereHour).ToString()); Assert.Equal("1 MVAh", new ApparentEnergy(1, ApparentEnergyUnit.MegavoltampereHour).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s1")); Assert.Equal("0.12 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s2")); Assert.Equal("0.123 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 9f147d9abf..672fa5e4e1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 GVA", new ApparentPower(1, ApparentPowerUnit.Gigavoltampere).ToString()); Assert.Equal("1 kVA", new ApparentPower(1, ApparentPowerUnit.Kilovoltampere).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s1")); Assert.Equal("0.12 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s2")); Assert.Equal("0.123 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 2f0c2b3c3d..cecd3658ca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s1")); Assert.Equal("0.12 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s2")); Assert.Equal("0.123 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 5f1477116d..9f2d412306 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -357,8 +357,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁴", new AreaMomentOfInertia(1, AreaMomentOfInertiaUnit.CentimeterToTheFourth).ToString()); Assert.Equal("1 dm⁴", new AreaMomentOfInertia(1, AreaMomentOfInertiaUnit.DecimeterToTheFourth).ToString()); @@ -369,7 +369,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -390,10 +390,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s1")); Assert.Equal("0.12 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s2")); Assert.Equal("0.123 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s3")); @@ -401,7 +401,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -431,10 +431,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 6d55b7b8a2..f80c5c4f56 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -461,8 +461,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ac", new Area(1, AreaUnit.Acre).ToString()); Assert.Equal("1 ha", new Area(1, AreaUnit.Hectare).ToString()); @@ -481,7 +481,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -510,10 +510,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s1")); Assert.Equal("0.12 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s2")); Assert.Equal("0.123 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s3")); @@ -521,7 +521,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -551,10 +551,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index ea52ebe637..6b887b6091 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -592,8 +592,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 bit/s", new BitRate(1, BitRateUnit.BitPerSecond).ToString()); Assert.Equal("1 B/s", new BitRate(1, BitRateUnit.BytePerSecond).ToString()); @@ -624,7 +624,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -665,10 +665,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s1")); Assert.Equal("0.12 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s2")); Assert.Equal("0.123 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s3")); @@ -676,7 +676,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -706,10 +706,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index fd5bddda09..b3e13df8f5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g/kWh", new BrakeSpecificFuelConsumption(1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour).ToString()); Assert.Equal("1 kg/J", new BrakeSpecificFuelConsumption(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s1")); Assert.Equal("0.12 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s2")); Assert.Equal("0.123 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 3825bd5774..39f605fc99 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -370,8 +370,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 F", new Capacitance(1, CapacitanceUnit.Farad).ToString()); Assert.Equal("1 kF", new Capacitance(1, CapacitanceUnit.Kilofarad).ToString()); @@ -383,7 +383,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -405,10 +405,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s1")); Assert.Equal("0.12 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s2")); Assert.Equal("0.123 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s3")); @@ -416,7 +416,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -446,10 +446,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 0bcf0aed97..cbcd63edfb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 °C⁻¹", new CoefficientOfThermalExpansion(1, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius).ToString()); Assert.Equal("1 °F⁻¹", new CoefficientOfThermalExpansion(1, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s1")); Assert.Equal("0.12 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s2")); Assert.Equal("0.123 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index b4757fb314..5efb74f49d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -799,8 +799,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/dl", new Density(1, DensityUnit.CentigramPerDeciliter).ToString()); Assert.Equal("1 cg/L", new Density(1, DensityUnit.CentigramPerLiter).ToString()); @@ -845,7 +845,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -900,10 +900,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s1")); Assert.Equal("0.12 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s2")); Assert.Equal("0.123 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s3")); @@ -911,7 +911,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -941,10 +941,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 2e19791280..c5382bd6c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -409,8 +409,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 d", new Duration(1, DurationUnit.Day).ToString()); Assert.Equal("1 h", new Duration(1, DurationUnit.Hour).ToString()); @@ -425,7 +425,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -450,10 +450,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 s", new Duration(0.123456, DurationUnit.Second).ToString("s1")); Assert.Equal("0.12 s", new Duration(0.123456, DurationUnit.Second).ToString("s2")); Assert.Equal("0.123 s", new Duration(0.123456, DurationUnit.Second).ToString("s3")); @@ -461,7 +461,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -491,10 +491,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 79f3183d5f..b07e089b4b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -409,8 +409,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cP", new DynamicViscosity(1, DynamicViscosityUnit.Centipoise).ToString()); Assert.Equal("1 µPa·s", new DynamicViscosity(1, DynamicViscosityUnit.MicropascalSecond).ToString()); @@ -425,7 +425,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -450,10 +450,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s1")); Assert.Equal("0.12 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s2")); Assert.Equal("0.123 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s3")); @@ -461,7 +461,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -491,10 +491,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 48b29f1876..af17d29c73 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 µS", new ElectricAdmittance(1, ElectricAdmittanceUnit.Microsiemens).ToString()); Assert.Equal("1 mS", new ElectricAdmittance(1, ElectricAdmittanceUnit.Millisiemens).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s1")); Assert.Equal("0.12 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s2")); Assert.Equal("0.123 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 0e489d95f2..421022d475 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 C/m³", new ElectricChargeDensity(1, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s1")); Assert.Equal("0.12 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s2")); Assert.Equal("0.123 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 1140295d07..ff3b204d3a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -344,8 +344,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A-h", new ElectricCharge(1, ElectricChargeUnit.AmpereHour).ToString()); Assert.Equal("1 C", new ElectricCharge(1, ElectricChargeUnit.Coulomb).ToString()); @@ -355,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -375,10 +375,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s1")); Assert.Equal("0.12 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s2")); Assert.Equal("0.123 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s3")); @@ -386,7 +386,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -416,10 +416,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 56cdd7c9a9..3a7e1e06bf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 µS", new ElectricConductance(1, ElectricConductanceUnit.Microsiemens).ToString()); Assert.Equal("1 mS", new ElectricConductance(1, ElectricConductanceUnit.Millisiemens).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s1")); Assert.Equal("0.12 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s2")); Assert.Equal("0.123 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index c7971356b1..db59e86483 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 S/ft", new ElectricConductivity(1, ElectricConductivityUnit.SiemensPerFoot).ToString()); Assert.Equal("1 S/in", new ElectricConductivity(1, ElectricConductivityUnit.SiemensPerInch).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s1")); Assert.Equal("0.12 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s2")); Assert.Equal("0.123 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 8f1fccadfa..408373cacb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A/ft²", new ElectricCurrentDensity(1, ElectricCurrentDensityUnit.AmperePerSquareFoot).ToString()); Assert.Equal("1 A/in²", new ElectricCurrentDensity(1, ElectricCurrentDensityUnit.AmperePerSquareInch).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s1")); Assert.Equal("0.12 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s2")); Assert.Equal("0.123 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 251f13af39..4a0a019201 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A/μs", new ElectricCurrentGradient(1, ElectricCurrentGradientUnit.AmperePerMicrosecond).ToString()); Assert.Equal("1 A/ms", new ElectricCurrentGradient(1, ElectricCurrentGradientUnit.AmperePerMillisecond).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s1")); Assert.Equal("0.12 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s2")); Assert.Equal("0.123 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 2f7f17d7ea..84a10e1fc3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -383,8 +383,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A", new ElectricCurrent(1, ElectricCurrentUnit.Ampere).ToString()); Assert.Equal("1 cA", new ElectricCurrent(1, ElectricCurrentUnit.Centiampere).ToString()); @@ -397,7 +397,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -420,10 +420,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s1")); Assert.Equal("0.12 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s2")); Assert.Equal("0.123 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s3")); @@ -431,7 +431,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -461,10 +461,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index de4a676b29..1c907d731d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 V/m", new ElectricField(1, ElectricFieldUnit.VoltPerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s1")); Assert.Equal("0.12 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s2")); Assert.Equal("0.123 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 528ca520a2..a4949c4dcd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 H", new ElectricInductance(1, ElectricInductanceUnit.Henry).ToString()); Assert.Equal("1 µH", new ElectricInductance(1, ElectricInductanceUnit.Microhenry).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s1")); Assert.Equal("0.12 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s2")); Assert.Equal("0.123 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index e15c685fa0..9cde8f7717 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -344,8 +344,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kVac", new ElectricPotentialAc(1, ElectricPotentialAcUnit.KilovoltAc).ToString()); Assert.Equal("1 MVac", new ElectricPotentialAc(1, ElectricPotentialAcUnit.MegavoltAc).ToString()); @@ -355,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -375,10 +375,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s1")); Assert.Equal("0.12 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s2")); Assert.Equal("0.123 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s3")); @@ -386,7 +386,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -416,10 +416,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 87b7fe70bb..ca697d9b43 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -539,8 +539,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kV/h", new ElectricPotentialChangeRate(1, ElectricPotentialChangeRateUnit.KilovoltPerHour).ToString()); Assert.Equal("1 kV/μs", new ElectricPotentialChangeRate(1, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond).ToString()); @@ -565,7 +565,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -600,10 +600,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s1")); Assert.Equal("0.12 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s2")); Assert.Equal("0.123 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s3")); @@ -611,7 +611,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -641,10 +641,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 0d80b8d232..11427db37a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -344,8 +344,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kVdc", new ElectricPotentialDc(1, ElectricPotentialDcUnit.KilovoltDc).ToString()); Assert.Equal("1 MVdc", new ElectricPotentialDc(1, ElectricPotentialDcUnit.MegavoltDc).ToString()); @@ -355,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -375,10 +375,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s1")); Assert.Equal("0.12 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s2")); Assert.Equal("0.123 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s3")); @@ -386,7 +386,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -416,10 +416,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index fe849d9823..bdb6a4f024 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -344,8 +344,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kV", new ElectricPotential(1, ElectricPotentialUnit.Kilovolt).ToString()); Assert.Equal("1 MV", new ElectricPotential(1, ElectricPotentialUnit.Megavolt).ToString()); @@ -355,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -375,10 +375,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s1")); Assert.Equal("0.12 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s2")); Assert.Equal("0.123 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s3")); @@ -386,7 +386,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -416,10 +416,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index e8300e92ec..84e501a996 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -357,8 +357,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 GΩ", new ElectricResistance(1, ElectricResistanceUnit.Gigaohm).ToString()); Assert.Equal("1 kΩ", new ElectricResistance(1, ElectricResistanceUnit.Kiloohm).ToString()); @@ -369,7 +369,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -390,10 +390,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s1")); Assert.Equal("0.12 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s2")); Assert.Equal("0.123 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s3")); @@ -401,7 +401,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -431,10 +431,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index ef08e81da7..5321cf1baf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -461,8 +461,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kΩ·cm", new ElectricResistivity(1, ElectricResistivityUnit.KiloohmCentimeter).ToString()); Assert.Equal("1 kΩ·m", new ElectricResistivity(1, ElectricResistivityUnit.KiloohmMeter).ToString()); @@ -481,7 +481,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -510,10 +510,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s1")); Assert.Equal("0.12 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s2")); Assert.Equal("0.123 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s3")); @@ -521,7 +521,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -551,10 +551,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 2159a541b3..ea39314e0f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 C/cm²", new ElectricSurfaceChargeDensity(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter).ToString()); Assert.Equal("1 C/in²", new ElectricSurfaceChargeDensity(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s1")); Assert.Equal("0.12 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s2")); Assert.Equal("0.123 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index d446a0a1da..38e9640a94 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -747,8 +747,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU", new Energy(1, EnergyUnit.BritishThermalUnit).ToString()); Assert.Equal("1 cal", new Energy(1, EnergyUnit.Calorie).ToString()); @@ -789,7 +789,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -840,10 +840,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s1")); Assert.Equal("0.12 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s2")); Assert.Equal("0.123 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s3")); @@ -851,7 +851,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -881,10 +881,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Energy.FromJoules(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 487b4e943e..711284e90e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -370,8 +370,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cal/K", new Entropy(1, EntropyUnit.CaloriePerKelvin).ToString()); Assert.Equal("1 J/C", new Entropy(1, EntropyUnit.JoulePerDegreeCelsius).ToString()); @@ -383,7 +383,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -405,10 +405,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s1")); Assert.Equal("0.12 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s2")); Assert.Equal("0.123 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s3")); @@ -416,7 +416,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -446,10 +446,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index a43c2272b7..faa6b8341b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -474,8 +474,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cN/s", new ForceChangeRate(1, ForceChangeRateUnit.CentinewtonPerSecond).ToString()); Assert.Equal("1 daN/min", new ForceChangeRate(1, ForceChangeRateUnit.DecanewtonPerMinute).ToString()); @@ -495,7 +495,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -525,10 +525,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s1")); Assert.Equal("0.12 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s2")); Assert.Equal("0.123 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s3")); @@ -536,7 +536,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -566,10 +566,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index c7358a7082..5875bb78d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -773,8 +773,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cN/cm", new ForcePerLength(1, ForcePerLengthUnit.CentinewtonPerCentimeter).ToString()); Assert.Equal("1 cN/m", new ForcePerLength(1, ForcePerLengthUnit.CentinewtonPerMeter).ToString()); @@ -817,7 +817,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -870,10 +870,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s1")); Assert.Equal("0.12 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s2")); Assert.Equal("0.123 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s3")); @@ -881,7 +881,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -911,10 +911,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index b3c6d10044..9dfd20416f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -474,8 +474,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 daN", new Force(1, ForceUnit.Decanewton).ToString()); Assert.Equal("1 dyn", new Force(1, ForceUnit.Dyn).ToString()); @@ -495,7 +495,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -525,10 +525,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N", new Force(0.123456, ForceUnit.Newton).ToString("s1")); Assert.Equal("0.12 N", new Force(0.123456, ForceUnit.Newton).ToString("s2")); Assert.Equal("0.123 N", new Force(0.123456, ForceUnit.Newton).ToString("s3")); @@ -536,7 +536,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -566,10 +566,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Force.FromNewtons(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index a8dfbe8022..af81a2acd5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -422,8 +422,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 bpm", new Frequency(1, FrequencyUnit.BeatPerMinute).ToString()); Assert.Equal("1 B Units", new Frequency(1, FrequencyUnit.BUnit).ToString()); @@ -439,7 +439,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -465,10 +465,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s1")); Assert.Equal("0.12 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s2")); Assert.Equal("0.123 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s3")); @@ -476,7 +476,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -506,10 +506,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 6e63eb304b..468bfc0dcf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 km/L", new FuelEfficiency(1, FuelEfficiencyUnit.KilometerPerLiter).ToString()); Assert.Equal("1 L/100km", new FuelEfficiency(1, FuelEfficiencyUnit.LiterPer100Kilometers).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s1")); Assert.Equal("0.12 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s2")); Assert.Equal("0.123 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 01a87cb0d8..71d0062f6e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -513,8 +513,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/h·ft²", new HeatFlux(1, HeatFluxUnit.BtuPerHourSquareFoot).ToString()); Assert.Equal("1 BTU/min·ft²", new HeatFlux(1, HeatFluxUnit.BtuPerMinuteSquareFoot).ToString()); @@ -537,7 +537,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -570,10 +570,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s1")); Assert.Equal("0.12 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s2")); Assert.Equal("0.123 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s3")); @@ -581,7 +581,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -611,10 +611,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index ac1120c94c..a891c07e90 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Btu/ft²·hr·°F", new HeatTransferCoefficient(1, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit).ToString()); Assert.Equal("1 W/m²·°C", new HeatTransferCoefficient(1, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s1")); Assert.Equal("0.12 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s2")); Assert.Equal("0.123 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index b663e98a58..e0ccfe7254 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 klx", new Illuminance(1, IlluminanceUnit.Kilolux).ToString()); Assert.Equal("1 lx", new Illuminance(1, IlluminanceUnit.Lux).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s1")); Assert.Equal("0.12 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s2")); Assert.Equal("0.123 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index e27dc816ea..1733094f88 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -592,8 +592,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 b", new Information(1, InformationUnit.Bit).ToString()); Assert.Equal("1 B", new Information(1, InformationUnit.Byte).ToString()); @@ -624,7 +624,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -665,10 +665,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 b", new Information(0.123456m, InformationUnit.Bit).ToString("s1")); Assert.Equal("0.12 b", new Information(0.123456m, InformationUnit.Bit).ToString("s2")); Assert.Equal("0.123 b", new Information(0.123456m, InformationUnit.Bit).ToString("s3")); @@ -676,7 +676,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -706,10 +706,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Information.FromBits(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 69795c7d5a..707f9f85cc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -461,8 +461,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kW/cm²", new Irradiance(1, IrradianceUnit.KilowattPerSquareCentimeter).ToString()); Assert.Equal("1 kW/m²", new Irradiance(1, IrradianceUnit.KilowattPerSquareMeter).ToString()); @@ -481,7 +481,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -510,10 +510,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s1")); Assert.Equal("0.12 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s2")); Assert.Equal("0.123 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s3")); @@ -521,7 +521,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -551,10 +551,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index deb5995971..5023608e99 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -370,8 +370,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 J/cm²", new Irradiation(1, IrradiationUnit.JoulePerSquareCentimeter).ToString()); Assert.Equal("1 J/m²", new Irradiation(1, IrradiationUnit.JoulePerSquareMeter).ToString()); @@ -383,7 +383,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -405,10 +405,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s1")); Assert.Equal("0.12 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s2")); Assert.Equal("0.123 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s3")); @@ -416,7 +416,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -446,10 +446,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 2d34f909bc..9c5d16b941 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -396,8 +396,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cSt", new KinematicViscosity(1, KinematicViscosityUnit.Centistokes).ToString()); Assert.Equal("1 dSt", new KinematicViscosity(1, KinematicViscosityUnit.Decistokes).ToString()); @@ -411,7 +411,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -435,10 +435,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s1")); Assert.Equal("0.12 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s2")); Assert.Equal("0.123 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s3")); @@ -446,7 +446,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,10 +476,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 50d3ee9d03..0547485dd6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ∆°C/km", new LapseRate(1, LapseRateUnit.DegreeCelsiusPerKilometer).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s1")); Assert.Equal("0.12 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s2")); Assert.Equal("0.123 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 27a14e0e69..70be45e183 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -708,8 +708,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 au", new Length(1, LengthUnit.AstronomicalUnit).ToString()); Assert.Equal("1 cm", new Length(1, LengthUnit.Centimeter).ToString()); @@ -747,7 +747,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -795,10 +795,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m", new Length(0.123456, LengthUnit.Meter).ToString("s1")); Assert.Equal("0.12 m", new Length(0.123456, LengthUnit.Meter).ToString("s2")); Assert.Equal("0.123 m", new Length(0.123456, LengthUnit.Meter).ToString("s3")); @@ -806,7 +806,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -836,10 +836,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Length.FromMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index ad671cfe25..9e8fc5c024 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -309,15 +309,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 dB", new Level(1, LevelUnit.Decibel).ToString()); Assert.Equal("1 Np", new Level(1, LevelUnit.Neper).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -334,10 +334,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s1")); Assert.Equal("0.12 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s2")); Assert.Equal("0.123 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s3")); @@ -345,7 +345,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -375,10 +375,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Level.FromDecibels(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index ba441f0104..c1bc525fe3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -461,8 +461,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g/cm", new LinearDensity(1, LinearDensityUnit.GramPerCentimeter).ToString()); Assert.Equal("1 g/m", new LinearDensity(1, LinearDensityUnit.GramPerMeter).ToString()); @@ -481,7 +481,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -510,10 +510,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s1")); Assert.Equal("0.12 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s2")); Assert.Equal("0.123 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s3")); @@ -521,7 +521,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -551,10 +551,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 0e7b07daef..19170d5fbb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -604,8 +604,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 GW/cm", new LinearPowerDensity(1, LinearPowerDensityUnit.GigawattPerCentimeter).ToString()); Assert.Equal("1 GW/ft", new LinearPowerDensity(1, LinearPowerDensityUnit.GigawattPerFoot).ToString()); @@ -635,7 +635,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -675,10 +675,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s1")); Assert.Equal("0.12 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s2")); Assert.Equal("0.123 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s3")); @@ -686,7 +686,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -716,10 +716,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 731253227a..54fbec51ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -461,8 +461,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 daW", new Luminosity(1, LuminosityUnit.Decawatt).ToString()); Assert.Equal("1 dW", new Luminosity(1, LuminosityUnit.Deciwatt).ToString()); @@ -481,7 +481,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -510,10 +510,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s1")); Assert.Equal("0.12 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s2")); Assert.Equal("0.123 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s3")); @@ -521,7 +521,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -551,10 +551,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 5ebb12ec7a..1a74dec784 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 lm", new LuminousFlux(1, LuminousFluxUnit.Lumen).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s1")); Assert.Equal("0.12 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s2")); Assert.Equal("0.123 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index e13f70b337..da9f2c8f4e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cd", new LuminousIntensity(1, LuminousIntensityUnit.Candela).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s1")); Assert.Equal("0.12 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s2")); Assert.Equal("0.123 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 55ceca0294..16ed475c5d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -357,8 +357,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 G", new MagneticField(1, MagneticFieldUnit.Gauss).ToString()); Assert.Equal("1 µT", new MagneticField(1, MagneticFieldUnit.Microtesla).ToString()); @@ -369,7 +369,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -390,10 +390,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s1")); Assert.Equal("0.12 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s2")); Assert.Equal("0.123 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s3")); @@ -401,7 +401,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -431,10 +431,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 767693890e..ec8ddfb7e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Wb", new MagneticFlux(1, MagneticFluxUnit.Weber).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s1")); Assert.Equal("0.12 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s2")); Assert.Equal("0.123 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index d2a4e6b2ba..b26a15e9ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A/m", new Magnetization(1, MagnetizationUnit.AmperePerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s1")); Assert.Equal("0.12 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s2")); Assert.Equal("0.123 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 4dc30fca0a..aae29e2b4f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -916,8 +916,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/dL", new MassConcentration(1, MassConcentrationUnit.CentigramPerDeciliter).ToString()); Assert.Equal("1 cg/L", new MassConcentration(1, MassConcentrationUnit.CentigramPerLiter).ToString()); @@ -971,7 +971,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1035,10 +1035,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s1")); Assert.Equal("0.12 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s2")); Assert.Equal("0.123 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s3")); @@ -1046,7 +1046,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1076,10 +1076,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index a50c205acd..5525ce02f4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -708,8 +708,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/d", new MassFlow(1, MassFlowUnit.CentigramPerDay).ToString()); Assert.Equal("1 cg/s", new MassFlow(1, MassFlowUnit.CentigramPerSecond).ToString()); @@ -747,7 +747,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -795,10 +795,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s1")); Assert.Equal("0.12 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s2")); Assert.Equal("0.123 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s3")); @@ -806,7 +806,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -836,10 +836,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 9b1dc96b6a..c714d53afe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -435,8 +435,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g·h⁻¹·cm⁻²", new MassFlux(1, MassFluxUnit.GramPerHourPerSquareCentimeter).ToString()); Assert.Equal("1 g·h⁻¹·m⁻²", new MassFlux(1, MassFluxUnit.GramPerHourPerSquareMeter).ToString()); @@ -453,7 +453,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -480,10 +480,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s1")); Assert.Equal("0.12 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s2")); Assert.Equal("0.123 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s3")); @@ -491,7 +491,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -521,10 +521,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 42eeed544a..a55be4828b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -591,8 +591,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/g", new MassFraction(1, MassFractionUnit.CentigramPerGram).ToString()); Assert.Equal("1 cg/kg", new MassFraction(1, MassFractionUnit.CentigramPerKilogram).ToString()); @@ -621,7 +621,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -660,10 +660,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s1")); Assert.Equal("0.12", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s2")); Assert.Equal("0.123", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s3")); @@ -671,7 +671,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -701,10 +701,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 14adde23fc..46c9980368 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -643,8 +643,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g·cm²", new MassMomentOfInertia(1, MassMomentOfInertiaUnit.GramSquareCentimeter).ToString()); Assert.Equal("1 g·dm²", new MassMomentOfInertia(1, MassMomentOfInertiaUnit.GramSquareDecimeter).ToString()); @@ -677,7 +677,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -720,10 +720,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s1")); Assert.Equal("0.12 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s2")); Assert.Equal("0.123 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s3")); @@ -731,7 +731,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -761,10 +761,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 4b4a911cc9..7733cb647a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -604,8 +604,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg", new Mass(1, MassUnit.Centigram).ToString()); Assert.Equal("1 dag", new Mass(1, MassUnit.Decagram).ToString()); @@ -635,7 +635,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -675,10 +675,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s1")); Assert.Equal("0.12 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s2")); Assert.Equal("0.123 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s3")); @@ -686,7 +686,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -716,10 +716,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 7449e96ab6..17dc5979f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 J/mol", new MolarEnergy(1, MolarEnergyUnit.JoulePerMole).ToString()); Assert.Equal("1 kJ/mol", new MolarEnergy(1, MolarEnergyUnit.KilojoulePerMole).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s1")); Assert.Equal("0.12 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s2")); Assert.Equal("0.123 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 060f90e168..8c8850d5be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 J/(mol*K)", new MolarEntropy(1, MolarEntropyUnit.JoulePerMoleKelvin).ToString()); Assert.Equal("1 kJ/(mol*K)", new MolarEntropy(1, MolarEntropyUnit.KilojoulePerMoleKelvin).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s1")); Assert.Equal("0.12 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s2")); Assert.Equal("0.123 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 2383f5f79d..eb7c97bb69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -435,8 +435,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/mol", new MolarMass(1, MolarMassUnit.CentigramPerMole).ToString()); Assert.Equal("1 dag/mol", new MolarMass(1, MolarMassUnit.DecagramPerMole).ToString()); @@ -453,7 +453,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -480,10 +480,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s1")); Assert.Equal("0.12 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s2")); Assert.Equal("0.123 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s3")); @@ -491,7 +491,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -521,10 +521,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 8ac39b8759..152f62104c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -383,8 +383,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cmol/L", new Molarity(1, MolarityUnit.CentimolesPerLiter).ToString()); Assert.Equal("1 dmol/L", new Molarity(1, MolarityUnit.DecimolesPerLiter).ToString()); @@ -397,7 +397,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -420,10 +420,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s1")); Assert.Equal("0.12 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s2")); Assert.Equal("0.123 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s3")); @@ -431,7 +431,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -461,10 +461,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 513bc00bfd..731cadc6a0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 H/m", new Permeability(1, PermeabilityUnit.HenryPerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s1")); Assert.Equal("0.12 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s2")); Assert.Equal("0.123 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index b07e39312a..5f2bea4f41 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 F/m", new Permittivity(1, PermittivityUnit.FaradPerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s1")); Assert.Equal("0.12 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s2")); Assert.Equal("0.123 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index f287889fe5..46503289e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -851,8 +851,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 daW/ft³", new PowerDensity(1, PowerDensityUnit.DecawattPerCubicFoot).ToString()); Assert.Equal("1 daW/in³", new PowerDensity(1, PowerDensityUnit.DecawattPerCubicInch).ToString()); @@ -901,7 +901,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -960,10 +960,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s1")); Assert.Equal("0.12 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s2")); Assert.Equal("0.123 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s3")); @@ -971,7 +971,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1001,10 +1001,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index a9daee8c66..f7817f52b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -309,15 +309,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 dBmW", new PowerRatio(1, PowerRatioUnit.DecibelMilliwatt).ToString()); Assert.Equal("1 dBW", new PowerRatio(1, PowerRatioUnit.DecibelWatt).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -334,10 +334,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s1")); Assert.Equal("0.12 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s2")); Assert.Equal("0.123 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s3")); @@ -345,7 +345,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -375,10 +375,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index e75b82c7ae..22cd9e08f6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -579,8 +579,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 hp(S)", new Power(1, PowerUnit.BoilerHorsepower).ToString()); Assert.Equal("1 Btu/h", new Power(1, PowerUnit.BritishThermalUnitPerHour).ToString()); @@ -610,7 +610,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -650,10 +650,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W", new Power(0.123456m, PowerUnit.Watt).ToString("s1")); Assert.Equal("0.12 W", new Power(0.123456m, PowerUnit.Watt).ToString("s2")); Assert.Equal("0.123 W", new Power(0.123456m, PowerUnit.Watt).ToString("s3")); @@ -661,7 +661,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -691,10 +691,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Power.FromWatts(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index b5659483e4..87ea64ef9f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -448,8 +448,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 atm/s", new PressureChangeRate(1, PressureChangeRateUnit.AtmospherePerSecond).ToString()); Assert.Equal("1 kPa/min", new PressureChangeRate(1, PressureChangeRateUnit.KilopascalPerMinute).ToString()); @@ -467,7 +467,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -495,10 +495,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s1")); Assert.Equal("0.12 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s2")); Assert.Equal("0.123 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s3")); @@ -506,7 +506,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -536,10 +536,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index eeccb43baa..cc7d8b733e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -851,8 +851,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 atm", new Pressure(1, PressureUnit.Atmosphere).ToString()); Assert.Equal("1 bar", new Pressure(1, PressureUnit.Bar).ToString()); @@ -901,7 +901,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -960,10 +960,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s1")); Assert.Equal("0.12 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s2")); Assert.Equal("0.123 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s3")); @@ -971,7 +971,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1001,10 +1001,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 51b803091f..e5a8d75f97 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -305,15 +305,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 /s", new RatioChangeRate(1, RatioChangeRateUnit.DecimalFractionPerSecond).ToString()); Assert.Equal("1 %/s", new RatioChangeRate(1, RatioChangeRateUnit.PercentPerSecond).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -330,10 +330,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s1")); Assert.Equal("0.12 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s2")); Assert.Equal("0.123 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s3")); @@ -341,7 +341,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -371,10 +371,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 8a0ffaaa7e..84c33e88b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -357,8 +357,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1", new Ratio(1, RatioUnit.DecimalFraction).ToString()); Assert.Equal("1 ppb", new Ratio(1, RatioUnit.PartPerBillion).ToString()); @@ -369,7 +369,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -390,10 +390,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s1")); Assert.Equal("0.12", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s2")); Assert.Equal("0.123", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s3")); @@ -401,7 +401,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -431,10 +431,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 98371bc5bc..94b91dfae0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kvarh", new ReactiveEnergy(1, ReactiveEnergyUnit.KilovoltampereReactiveHour).ToString()); Assert.Equal("1 Mvarh", new ReactiveEnergy(1, ReactiveEnergyUnit.MegavoltampereReactiveHour).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s1")); Assert.Equal("0.12 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s2")); Assert.Equal("0.123 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index a1f09b13a8..5464222e57 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Gvar", new ReactivePower(1, ReactivePowerUnit.GigavoltampereReactive).ToString()); Assert.Equal("1 kvar", new ReactivePower(1, ReactivePowerUnit.KilovoltampereReactive).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s1")); Assert.Equal("0.12 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s2")); Assert.Equal("0.123 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 8dc57c85ad..0fabdbb37f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -422,8 +422,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁻²", new ReciprocalArea(1, ReciprocalAreaUnit.InverseSquareCentimeter).ToString()); Assert.Equal("1 dm⁻²", new ReciprocalArea(1, ReciprocalAreaUnit.InverseSquareDecimeter).ToString()); @@ -439,7 +439,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -465,10 +465,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s1")); Assert.Equal("0.12 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s2")); Assert.Equal("0.123 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s3")); @@ -476,7 +476,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -506,10 +506,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 3404678d35..62b9b78790 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -409,8 +409,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁻¹", new ReciprocalLength(1, ReciprocalLengthUnit.InverseCentimeter).ToString()); Assert.Equal("1 ft⁻¹", new ReciprocalLength(1, ReciprocalLengthUnit.InverseFoot).ToString()); @@ -425,7 +425,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -450,10 +450,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s1")); Assert.Equal("0.12 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s2")); Assert.Equal("0.123 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s3")); @@ -461,7 +461,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -491,10 +491,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 94a6fb0f62..8a12a4c70d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 %RH", new RelativeHumidity(1, RelativeHumidityUnit.Percent).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s1")); Assert.Equal("0.12 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s2")); Assert.Equal("0.123 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index be96d05c8e..fb226a255b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 °/s²", new RotationalAcceleration(1, RotationalAccelerationUnit.DegreePerSecondSquared).ToString()); Assert.Equal("1 rad/s²", new RotationalAcceleration(1, RotationalAccelerationUnit.RadianPerSecondSquared).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s1")); Assert.Equal("0.12 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s2")); Assert.Equal("0.123 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 08157997fb..84c1bd4e8b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -448,8 +448,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 crad/s", new RotationalSpeed(1, RotationalSpeedUnit.CentiradianPerSecond).ToString()); Assert.Equal("1 drad/s", new RotationalSpeed(1, RotationalSpeedUnit.DeciradianPerSecond).ToString()); @@ -467,7 +467,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -495,10 +495,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s1")); Assert.Equal("0.12 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s2")); Assert.Equal("0.123 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s3")); @@ -506,7 +506,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -536,10 +536,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index b6b830f860..35e7db379d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -344,8 +344,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kN·m/rad/m", new RotationalStiffnessPerLength(1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter).ToString()); Assert.Equal("1 kipf·ft/°/ft", new RotationalStiffnessPerLength(1, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot).ToString()); @@ -355,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -375,10 +375,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s1")); Assert.Equal("0.12 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s2")); Assert.Equal("0.123 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s3")); @@ -386,7 +386,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -416,10 +416,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index e52a0856f6..912e63f77e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -708,8 +708,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cN·m/deg", new RotationalStiffness(1, RotationalStiffnessUnit.CentinewtonMeterPerDegree).ToString()); Assert.Equal("1 cN·mm/deg", new RotationalStiffness(1, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree).ToString()); @@ -747,7 +747,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -795,10 +795,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s1")); Assert.Equal("0.12 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s2")); Assert.Equal("0.123 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s3")); @@ -806,7 +806,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -836,10 +836,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 6f672bdfbc..bf9ba33eeb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1", new Scalar(1, ScalarUnit.Amount).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new Scalar(0.123456, ScalarUnit.Amount).ToString("s1")); Assert.Equal("0.12", new Scalar(0.123456, ScalarUnit.Amount).ToString("s2")); Assert.Equal("0.123", new Scalar(0.123456, ScalarUnit.Amount).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 41addc5b3c..b65e7b2a4f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 sr", new SolidAngle(1, SolidAngleUnit.Steradian).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s1")); Assert.Equal("0.12 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s2")); Assert.Equal("0.123 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 90b0f09844..9a0e0d5f05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -604,8 +604,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 btu/lb", new SpecificEnergy(1, SpecificEnergyUnit.BtuPerPound).ToString()); Assert.Equal("1 cal/g", new SpecificEnergy(1, SpecificEnergyUnit.CaloriePerGram).ToString()); @@ -635,7 +635,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -675,10 +675,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s1")); Assert.Equal("0.12 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s2")); Assert.Equal("0.123 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s3")); @@ -686,7 +686,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -716,10 +716,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index a7f4d8dbfb..65481090e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -396,8 +396,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/lb·°F", new SpecificEntropy(1, SpecificEntropyUnit.BtuPerPoundFahrenheit).ToString()); Assert.Equal("1 cal/g.K", new SpecificEntropy(1, SpecificEntropyUnit.CaloriePerGramKelvin).ToString()); @@ -411,7 +411,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -435,10 +435,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s1")); Assert.Equal("0.12 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s2")); Assert.Equal("0.123 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s3")); @@ -446,7 +446,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,10 +476,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index a18827b0e1..466865ad45 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -331,8 +331,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g/(kN�s)", new SpecificFuelConsumption(1, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString()); Assert.Equal("1 kg/(kgf�h)", new SpecificFuelConsumption(1, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour).ToString()); @@ -341,7 +341,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -360,10 +360,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s1")); Assert.Equal("0.12 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s2")); Assert.Equal("0.123 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s3")); @@ -371,7 +371,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -401,10 +401,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index a1c093c63d..42bb9b2d09 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -318,8 +318,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ft³/lb", new SpecificVolume(1, SpecificVolumeUnit.CubicFootPerPound).ToString()); Assert.Equal("1 m³/kg", new SpecificVolume(1, SpecificVolumeUnit.CubicMeterPerKilogram).ToString()); @@ -327,7 +327,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -345,10 +345,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s1")); Assert.Equal("0.12 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s2")); Assert.Equal("0.123 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s3")); @@ -356,7 +356,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -386,10 +386,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 3999b3ad24..9c54526bfa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -500,8 +500,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kgf/cm³", new SpecificWeight(1, SpecificWeightUnit.KilogramForcePerCubicCentimeter).ToString()); Assert.Equal("1 kgf/m³", new SpecificWeight(1, SpecificWeightUnit.KilogramForcePerCubicMeter).ToString()); @@ -523,7 +523,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -555,10 +555,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s1")); Assert.Equal("0.12 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s2")); Assert.Equal("0.123 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s3")); @@ -566,7 +566,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -596,10 +596,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index fd6f5179ca..badb0e3dfe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -695,8 +695,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm/h", new Speed(1, SpeedUnit.CentimeterPerHour).ToString()); Assert.Equal("1 cm/min", new Speed(1, SpeedUnit.CentimeterPerMinute).ToString()); @@ -733,7 +733,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -780,10 +780,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s1")); Assert.Equal("0.12 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s2")); Assert.Equal("0.123 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s3")); @@ -791,7 +791,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -821,10 +821,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 59e6bbff3a..3e9dd9ce9a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -396,8 +396,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 sccm", new StandardVolumeFlow(1, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute).ToString()); Assert.Equal("1 scfh", new StandardVolumeFlow(1, StandardVolumeFlowUnit.StandardCubicFootPerHour).ToString()); @@ -411,7 +411,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -435,10 +435,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s1")); Assert.Equal("0.12 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s2")); Assert.Equal("0.123 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s3")); @@ -446,7 +446,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,10 +476,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 42ec2fc80f..d0142ec5d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -409,8 +409,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 c°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond).ToString()); Assert.Equal("1 da°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond).ToString()); @@ -425,7 +425,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -450,10 +450,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s1")); Assert.Equal("0.12 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s2")); Assert.Equal("0.123 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s3")); @@ -461,7 +461,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -491,10 +491,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index efd558506d..7e727b5d53 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -396,8 +396,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ∆°C", new TemperatureDelta(1, TemperatureDeltaUnit.DegreeCelsius).ToString()); Assert.Equal("1 ∆°De", new TemperatureDelta(1, TemperatureDeltaUnit.DegreeDelisle).ToString()); @@ -411,7 +411,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -435,10 +435,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s1")); Assert.Equal("0.12 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s2")); Assert.Equal("0.123 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s3")); @@ -446,7 +446,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,10 +476,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index f558e9e51e..24c065a159 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -397,8 +397,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 °C", new Temperature(1, TemperatureUnit.DegreeCelsius).ToString()); Assert.Equal("1 °De", new Temperature(1, TemperatureUnit.DegreeDelisle).ToString()); @@ -413,7 +413,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +438,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s1")); Assert.Equal("0.12 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s2")); Assert.Equal("0.123 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s3")); @@ -449,7 +449,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -479,10 +479,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 4a93dc82d4..c09c444f10 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -305,15 +305,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/h·ft·°F", new ThermalConductivity(1, ThermalConductivityUnit.BtuPerHourFootFahrenheit).ToString()); Assert.Equal("1 W/m·K", new ThermalConductivity(1, ThermalConductivityUnit.WattPerMeterKelvin).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -330,10 +330,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s1")); Assert.Equal("0.12 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s2")); Assert.Equal("0.123 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s3")); @@ -341,7 +341,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -371,10 +371,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 37103e822e..f9b088d081 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -344,8 +344,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Hrft²°F/Btu", new ThermalResistance(1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu).ToString()); Assert.Equal("1 cm²Hr°C/kcal", new ThermalResistance(1, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie).ToString()); @@ -355,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -375,10 +375,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s1")); Assert.Equal("0.12 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s2")); Assert.Equal("0.123 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s3")); @@ -386,7 +386,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -416,10 +416,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 401ffcbfd7..8201166b49 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -552,8 +552,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kgf·cm/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter).ToString()); Assert.Equal("1 kgf·m/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceMeterPerMeter).ToString()); @@ -579,7 +579,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -615,10 +615,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s1")); Assert.Equal("0.12 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s2")); Assert.Equal("0.123 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s3")); @@ -626,7 +626,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -656,10 +656,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 45cea4af1c..a6a91a44d8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -565,8 +565,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kgf·cm", new Torque(1, TorqueUnit.KilogramForceCentimeter).ToString()); Assert.Equal("1 kgf·m", new Torque(1, TorqueUnit.KilogramForceMeter).ToString()); @@ -593,7 +593,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -630,10 +630,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s1")); Assert.Equal("0.12 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s2")); Assert.Equal("0.123 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s3")); @@ -641,7 +641,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -671,10 +671,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 474bbf295d..75b1af7686 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 NTU", new Turbidity(1, TurbidityUnit.NTU).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s1")); Assert.Equal("0.12 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s2")); Assert.Equal("0.123 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 2505949dee..032d274ded 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -292,14 +292,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 IU", new VitaminA(1, VitaminAUnit.InternationalUnit).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -315,10 +315,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s1")); Assert.Equal("0.12 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s2")); Assert.Equal("0.123 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s3")); @@ -326,7 +326,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -356,10 +356,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index f4025417ea..8b9a1ae06c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -539,8 +539,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cL/L", new VolumeConcentration(1, VolumeConcentrationUnit.CentilitersPerLiter).ToString()); Assert.Equal("1 cL/mL", new VolumeConcentration(1, VolumeConcentrationUnit.CentilitersPerMililiter).ToString()); @@ -565,7 +565,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -600,10 +600,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s1")); Assert.Equal("0.12", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s2")); Assert.Equal("0.123", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s3")); @@ -611,7 +611,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -641,10 +641,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index be93743135..9ad6d05ebd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -1007,8 +1007,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 af/d", new VolumeFlow(1, VolumeFlowUnit.AcreFootPerDay).ToString()); Assert.Equal("1 af/h", new VolumeFlow(1, VolumeFlowUnit.AcreFootPerHour).ToString()); @@ -1069,7 +1069,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1140,10 +1140,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s1")); Assert.Equal("0.12 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s2")); Assert.Equal("0.123 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s3")); @@ -1151,7 +1151,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1181,10 +1181,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 718c2ecd71..9eff21be27 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -370,8 +370,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 m³/m", new VolumePerLength(1, VolumePerLengthUnit.CubicMeterPerMeter).ToString()); Assert.Equal("1 yd³/ft", new VolumePerLength(1, VolumePerLengthUnit.CubicYardPerFoot).ToString()); @@ -383,7 +383,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -405,10 +405,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s1")); Assert.Equal("0.12 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s2")); Assert.Equal("0.123 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s3")); @@ -416,7 +416,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -446,10 +446,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index d2e52c0871..55e7de73ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -942,8 +942,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ac-ft", new Volume(1, VolumeUnit.AcreFoot).ToString()); Assert.Equal("1", new Volume(1, VolumeUnit.AuTablespoon).ToString()); @@ -999,7 +999,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1065,10 +1065,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s1")); Assert.Equal("0.12 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s2")); Assert.Equal("0.123 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s3")); @@ -1076,7 +1076,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1106,10 +1106,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 6f391a97dd..6ec9034c39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -396,8 +396,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/ft³·°F", new VolumetricHeatCapacity(1, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit).ToString()); Assert.Equal("1 cal/cm³·°C", new VolumetricHeatCapacity(1, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius).ToString()); @@ -411,7 +411,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -435,10 +435,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s1")); Assert.Equal("0.12 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s2")); Assert.Equal("0.123 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s3")); @@ -446,7 +446,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,10 +476,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 1dd7d407d5..3fc3a5c095 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -357,8 +357,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁶", new WarpingMomentOfInertia(1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth).ToString()); Assert.Equal("1 dm⁶", new WarpingMomentOfInertia(1, WarpingMomentOfInertiaUnit.DecimeterToTheSixth).ToString()); @@ -369,7 +369,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -390,10 +390,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s1")); Assert.Equal("0.12 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s2")); Assert.Equal("0.123 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s3")); @@ -401,7 +401,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -431,10 +431,10 @@ public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) [Theory] [InlineData(null)] [InlineData("g")] - public void ToString_NullProvider_EqualsCurrentUICulture(string format) + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(quantity.ToString(format, CultureInfo.CurrentUICulture), quantity.ToString(format, null)); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } [Fact] diff --git a/UnitsNet.Tests/QuantityFormatterTests.cs b/UnitsNet.Tests/QuantityFormatterTests.cs index 1a4d2315eb..eab7fe8d29 100644 --- a/UnitsNet.Tests/QuantityFormatterTests.cs +++ b/UnitsNet.Tests/QuantityFormatterTests.cs @@ -109,10 +109,20 @@ public static void StandardNumericFormatStrings_Equals_ValueWithFormatStringAndA { var length = Length.FromMeters(123456789.987654321); - var expected = string.Format(CultureInfo.CurrentUICulture, $"{{0:{format}}} {{1:a}}", length.Value, length); + var expected = string.Format(CultureInfo.CurrentCulture, $"{{0:{format}}} {{1:a}}", length.Value, length); Assert.Equal(expected, QuantityFormatter.Format(length, format)); } + [Fact] + public static void StandardNumericFormatStringsAsPartOfLongerFormatStringsWork() + { + var length = Length.FromMeters(123.321); + + var expected = "The distance is 123.3 m"; + var actual = string.Format(CultureInfo.InvariantCulture, $"The distance is {length:F1}"); + Assert.Equal(expected, actual); + } + [Theory] [InlineData("000")] [InlineData("0.00")] @@ -133,7 +143,7 @@ public static void CustomNumericFormatStrings_Equals_ValueWithFormatStringAndAbb { var length = Length.FromMeters(123456789.987654321); - var expected = string.Format(CultureInfo.CurrentUICulture, $"{{0:{format}}} {{1:a}}", length.Value, length); + var expected = string.Format(CultureInfo.CurrentCulture, $"{{0:{format}}} {{1:a}}", length.Value, length); Assert.Equal(expected, QuantityFormatter.Format(length, format)); } } diff --git a/UnitsNet.Tests/QuantityIConvertibleTests.cs b/UnitsNet.Tests/QuantityIConvertibleTests.cs index 23bcf4f588..a5949444c9 100644 --- a/UnitsNet.Tests/QuantityIConvertibleTests.cs +++ b/UnitsNet.Tests/QuantityIConvertibleTests.cs @@ -116,10 +116,10 @@ public void ToSingleTest() [Fact] public void ToStringTest() { - string expected = _length.ToString(CultureInfo.CurrentUICulture); - Assert.Equal(expected, LengthAsIConvertible.ToString(CultureInfo.CurrentUICulture)); - Assert.Equal(expected, Convert.ToString(_length, CultureInfo.CurrentUICulture)); - Assert.Equal(expected, Convert.ChangeType(_length, typeof(string), CultureInfo.CurrentUICulture)); + string expected = _length.ToString(CultureInfo.CurrentCulture); + Assert.Equal(expected, LengthAsIConvertible.ToString(CultureInfo.CurrentCulture)); + Assert.Equal(expected, Convert.ToString(_length, CultureInfo.CurrentCulture)); + Assert.Equal(expected, Convert.ChangeType(_length, typeof(string), CultureInfo.CurrentCulture)); } [Fact] diff --git a/UnitsNet.Tests/QuantityIFormattableTests.cs b/UnitsNet.Tests/QuantityIFormattableTests.cs index 059b5b22e2..18e670e644 100644 --- a/UnitsNet.Tests/QuantityIFormattableTests.cs +++ b/UnitsNet.Tests/QuantityIFormattableTests.cs @@ -43,7 +43,7 @@ public void AFormatWithInvalidIndexThrowsFormatException() [Fact] public void VFormatEqualsValueToString() { - Assert.Equal(length.Value.ToString(CultureInfo.CurrentUICulture), length.ToString("v")); + Assert.Equal(length.Value.ToString(CultureInfo.CurrentCulture), length.ToString("v")); } [Fact] diff --git a/UnitsNet.Tests/QuantityTests.ToString.cs b/UnitsNet.Tests/QuantityTests.ToString.cs index 06794a8273..f778a6c5c4 100644 --- a/UnitsNet.Tests/QuantityTests.ToString.cs +++ b/UnitsNet.Tests/QuantityTests.ToString.cs @@ -31,17 +31,17 @@ public void ReturnsTheOriginalValueAndUnit() [Fact] public void FormatsNumberUsingGivenCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString((IFormatProvider)null)); Assert.Equal("0.05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString(CultureInfo.InvariantCulture)); Assert.Equal("0,05 m", Length.FromCentimeters(5).ToUnit(LengthUnit.Meter).ToString(new CultureInfo("nb-NO"))); } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } } diff --git a/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs b/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs index c12c78ea76..238e857dd3 100644 --- a/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs +++ b/UnitsNet.Tests/UnitAbbreviationsCacheTests.cs @@ -222,15 +222,14 @@ public void GetDefaultAbbreviationThrowsNotImplementedExceptionIfNoneExist() public void GetDefaultAbbreviationFallsBackToUsEnglishCulture() { var oldCurrentCulture = CultureInfo.CurrentCulture; - var oldCurrentUICulture = CultureInfo.CurrentUICulture; try { // CurrentCulture affects number formatting, such as comma or dot as decimal separator. - // CurrentUICulture affects localization, in this case the abbreviation. + // CurrentCulture affects localization, in this case the abbreviation. // Zulu (South Africa) var zuluCulture = new CultureInfo("zu-ZA"); - CultureInfo.CurrentCulture = CultureInfo.CurrentUICulture = zuluCulture; + CultureInfo.CurrentCulture = zuluCulture; var abbreviationsCache = new UnitAbbreviationsCache(); abbreviationsCache.MapUnitToAbbreviation(CustomUnit.Unit1, AmericanCulture, "US english abbreviation for Unit1"); @@ -244,7 +243,6 @@ public void GetDefaultAbbreviationFallsBackToUsEnglishCulture() finally { CultureInfo.CurrentCulture = oldCurrentCulture; - CultureInfo.CurrentUICulture = oldCurrentUICulture; } } diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index 09efb49596..c668ca5724 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -222,11 +222,11 @@ public override string ToString() /// Length.FromFeetInches(3,2).FeetInches.ToString() outputs: "3 ft 2 in" /// /// Optional culture to format number and localize unit abbreviations. - /// If null, defaults to . + /// If null, defaults to . /// public string ToString(IFormatProvider? cultureInfo) { - cultureInfo = cultureInfo ?? CultureInfo.CurrentUICulture; + cultureInfo = cultureInfo ?? CultureInfo.CurrentCulture; var footUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(LengthUnit.Foot, cultureInfo); var inchUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(LengthUnit.Inch, cultureInfo); diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index adab6a5216..3b8f101e7e 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -126,11 +126,11 @@ public override string ToString() /// Mass.FromStonePounds(3,2).StonePounds.ToString() outputs: "3 st 2 lb" /// /// Optional culture to format number and localize unit abbreviations. - /// If null, defaults to . + /// If null, defaults to . /// public string ToString(IFormatProvider? cultureInfo) { - cultureInfo = cultureInfo ?? CultureInfo.CurrentUICulture; + cultureInfo = cultureInfo ?? CultureInfo.CurrentCulture; var stoneUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(MassUnit.Stone, cultureInfo); var poundUnit = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(MassUnit.Pound, cultureInfo); diff --git a/UnitsNet/CustomCode/Quantity.cs b/UnitsNet/CustomCode/Quantity.cs index da44bcfde9..0f0511b5bb 100644 --- a/UnitsNet/CustomCode/Quantity.cs +++ b/UnitsNet/CustomCode/Quantity.cs @@ -87,7 +87,7 @@ public static bool TryFrom(double value, Enum unit, out IQuantity? quantity) /// /// Dynamically parse a quantity string representation. /// - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Type of quantity, such as . /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. /// The parsed quantity. diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index b3396b4f5a..907fcd87fb 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -70,7 +70,7 @@ private void LoadGeneratedAbbreviations() /// The type of unit enum. public void MapUnitToAbbreviation(TUnitType unit, params string[] abbreviations) where TUnitType : Enum { - MapUnitToAbbreviation(typeof(TUnitType), Convert.ToInt32(unit), CultureInfo.CurrentUICulture, abbreviations); + MapUnitToAbbreviation(typeof(TUnitType), Convert.ToInt32(unit), CultureInfo.CurrentCulture, abbreviations); } /// @@ -83,7 +83,7 @@ public void MapUnitToAbbreviation(TUnitType unit, params string[] abb /// The type of unit enum. public void MapUnitToDefaultAbbreviation(TUnitType unit, string abbreviation) where TUnitType : Enum { - MapUnitToDefaultAbbreviation(typeof(TUnitType), Convert.ToInt32(unit), CultureInfo.CurrentUICulture, abbreviation); + MapUnitToDefaultAbbreviation(typeof(TUnitType), Convert.ToInt32(unit), CultureInfo.CurrentCulture, abbreviation); } /// @@ -92,7 +92,7 @@ public void MapUnitToDefaultAbbreviation(TUnitType unit, string abbre /// in order to or on them later. /// /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations to add. /// The type of unit enum. public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider? formatProvider, params string[] abbreviations) where TUnitType : Enum @@ -112,7 +112,7 @@ public void MapUnitToAbbreviation(TUnitType unit, IFormatProvider? fo /// in order to or on them later. /// /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviation to add as default. /// The type of unit enum. public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvider? formatProvider, string abbreviation) where TUnitType : Enum @@ -133,7 +133,7 @@ public void MapUnitToDefaultAbbreviation(TUnitType unit, IFormatProvi /// /// The unit enum type. /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations to add. public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider, params string[] abbreviations) { @@ -147,7 +147,7 @@ public void MapUnitToAbbreviation(Type unitType, int unitValue, IFormatProvider? /// /// The unit enum type. /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviation to add as default. public void MapUnitToDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider, string abbreviation) { @@ -162,7 +162,7 @@ private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatPro if (abbreviations == null) throw new ArgumentNullException(nameof(abbreviations)); - formatProvider ??= CultureInfo.CurrentUICulture; + formatProvider = formatProvider ?? CultureInfo.CurrentCulture; if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) quantitiesForProvider = _lookupsForCulture[formatProvider] = new UnitTypeToLookup(); @@ -181,7 +181,7 @@ private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatPro /// Example: GetDefaultAbbreviation<LengthUnit>(LengthUnit.Kilometer) => "km" /// /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// The type of unit enum. /// The default unit abbreviation string. public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider? formatProvider = null) where TUnitType : Enum @@ -213,7 +213,7 @@ public string GetDefaultAbbreviation(TUnitType unit, IFormatProvider? /// /// The unit enum type. /// The unit enum value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// The default unit abbreviation string. public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvider? formatProvider = null) { @@ -240,7 +240,7 @@ public string GetDefaultAbbreviation(Type unitType, int unitValue, IFormatProvid /// /// Enum type for units. /// Enum value for unit. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations associated with unit. public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider? formatProvider = null) where TUnitType : Enum { @@ -252,11 +252,11 @@ public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider? /// /// Enum type for unit. /// Enum value for unit. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations associated with unit. public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvider? formatProvider = null) { - formatProvider = formatProvider ?? CultureInfo.CurrentUICulture; + formatProvider = formatProvider ?? CultureInfo.CurrentCulture; if (!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) { @@ -280,11 +280,11 @@ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvid /// Get all abbreviations for all units of a quantity. /// /// Enum type for unit. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit abbreviations associated with unit. public string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider? formatProvider = null) { - formatProvider ??= CultureInfo.CurrentUICulture; + formatProvider = formatProvider ?? CultureInfo.CurrentCulture; if (!TryGetUnitValueAbbreviationLookup(unitEnumType, formatProvider, out var lookup)) { @@ -300,7 +300,7 @@ internal bool TryGetUnitValueAbbreviationLookup(Type unitType, IFormatProvider? { unitToAbbreviations = null; - formatProvider ??= CultureInfo.CurrentUICulture; + formatProvider = formatProvider ?? CultureInfo.CurrentCulture; if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) { diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs index cce1e1d14c..7677eae796 100644 --- a/UnitsNet/CustomCode/UnitParser.cs +++ b/UnitsNet/CustomCode/UnitParser.cs @@ -43,7 +43,7 @@ static UnitParser() /// Example: Parse<LengthUnit>("km") => LengthUnit.Kilometer /// /// - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// /// public TUnitType Parse(string unitAbbreviation, IFormatProvider? formatProvider = null) where TUnitType : Enum @@ -60,7 +60,7 @@ public TUnitType Parse(string unitAbbreviation, IFormatProvider? form /// respectively. /// /// Unit enum type, such as and . - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Unit enum value, such as . /// No units match the abbreviation. /// More than one unit matches the abbreviation. @@ -144,7 +144,7 @@ public bool TryParse(string unitAbbreviation, out TUnitType unit) whe /// Try to parse a unit abbreviation. /// /// The string value. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// The unit enum value as out result. /// Type of unit enum. /// True if successful. @@ -176,7 +176,7 @@ public bool TryParse(string unitAbbreviation, Type unitType, out Enum? unit) /// /// The string value. /// Type of unit enum. - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// The unit enum value as out result. /// True if successful. public bool TryParse(string? unitAbbreviation, Type unitType, IFormatProvider? formatProvider, out Enum? unit) diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 4cf7669aee..97a70387c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -250,7 +250,7 @@ public static string GetAbbreviation(AccelerationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -451,7 +451,7 @@ public static Acceleration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Acceleration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -482,7 +482,7 @@ public static bool TryParse(string? str, out Acceleration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Acceleration result) { return QuantityParser.Default.TryParse( @@ -510,7 +510,7 @@ public static AccelerationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -536,7 +536,7 @@ public static bool TryParseUnit(string str, out AccelerationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AccelerationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -859,7 +859,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -867,21 +867,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 4817b1c6cc..9890bc0981 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -256,7 +256,7 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -466,7 +466,7 @@ public static AmountOfSubstance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AmountOfSubstance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -497,7 +497,7 @@ public static bool TryParse(string? str, out AmountOfSubstance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AmountOfSubstance result) { return QuantityParser.Default.TryParse( @@ -525,7 +525,7 @@ public static AmountOfSubstanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -551,7 +551,7 @@ public static bool TryParseUnit(string str, out AmountOfSubstanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AmountOfSubstanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -876,7 +876,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -884,21 +884,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index abd0f5404d..3f9097e645 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -190,7 +190,7 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -301,7 +301,7 @@ public static AmplitudeRatio Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AmplitudeRatio Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -332,7 +332,7 @@ public static bool TryParse(string? str, out AmplitudeRatio result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AmplitudeRatio result) { return QuantityParser.Default.TryParse( @@ -360,7 +360,7 @@ public static AmplitudeRatioUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -386,7 +386,7 @@ public static bool TryParseUnit(string str, out AmplitudeRatioUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AmplitudeRatioUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -697,7 +697,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -705,21 +705,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 4b31f648e0..90d782401e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -262,7 +262,7 @@ public static string GetAbbreviation(AngleUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -481,7 +481,7 @@ public static Angle Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Angle Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -512,7 +512,7 @@ public static bool TryParse(string? str, out Angle result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Angle result) { return QuantityParser.Default.TryParse( @@ -540,7 +540,7 @@ public static AngleUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -566,7 +566,7 @@ public static bool TryParseUnit(string str, out AngleUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AngleUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -893,7 +893,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -901,21 +901,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index fab3927c45..af34e41f09 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(ApparentEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static ApparentEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ApparentEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out ApparentEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ApparentEnergy result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static ApparentEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out ApparentEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ApparentEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index d5946b9b40..00704d3077 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -190,7 +190,7 @@ public static string GetAbbreviation(ApparentPowerUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -301,7 +301,7 @@ public static ApparentPower Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ApparentPower Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -332,7 +332,7 @@ public static bool TryParse(string? str, out ApparentPower result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ApparentPower result) { return QuantityParser.Default.TryParse( @@ -360,7 +360,7 @@ public static ApparentPowerUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -386,7 +386,7 @@ public static bool TryParseUnit(string str, out ApparentPowerUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ApparentPowerUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -689,7 +689,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -697,21 +697,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index dc2c8b8c54..8726105ac7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -250,7 +250,7 @@ public static string GetAbbreviation(AreaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -451,7 +451,7 @@ public static Area Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Area Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -482,7 +482,7 @@ public static bool TryParse(string? str, out Area result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Area result) { return QuantityParser.Default.TryParse( @@ -510,7 +510,7 @@ public static AreaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -536,7 +536,7 @@ public static bool TryParseUnit(string str, out AreaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -859,7 +859,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -867,21 +867,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 08676f9b24..df417da1e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -172,7 +172,7 @@ public static string GetAbbreviation(AreaDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -256,7 +256,7 @@ public static AreaDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AreaDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -287,7 +287,7 @@ public static bool TryParse(string? str, out AreaDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AreaDensity result) { return QuantityParser.Default.TryParse( @@ -315,7 +315,7 @@ public static AreaDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -341,7 +341,7 @@ public static bool TryParseUnit(string str, out AreaDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -638,7 +638,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -646,21 +646,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 8988e0ea3f..f709471cfa 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -202,7 +202,7 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -331,7 +331,7 @@ public static AreaMomentOfInertia Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AreaMomentOfInertia Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -362,7 +362,7 @@ public static bool TryParse(string? str, out AreaMomentOfInertia result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AreaMomentOfInertia result) { return QuantityParser.Default.TryParse( @@ -390,7 +390,7 @@ public static AreaMomentOfInertiaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -416,7 +416,7 @@ public static bool TryParseUnit(string str, out AreaMomentOfInertiaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaMomentOfInertiaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -723,7 +723,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -731,21 +731,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 0145f75d03..c5960ed0b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -330,7 +330,7 @@ public static string GetAbbreviation(BitRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -639,7 +639,7 @@ public static BitRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static BitRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -670,7 +670,7 @@ public static bool TryParse(string? str, out BitRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out BitRate result) { return QuantityParser.Default.TryParse( @@ -698,7 +698,7 @@ public static BitRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -724,7 +724,7 @@ public static bool TryParseUnit(string str, out BitRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1071,7 +1071,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1079,21 +1079,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index d629a6d0c8..8c6945d91c 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static BrakeSpecificFuelConsumption Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static BrakeSpecificFuelConsumption Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out BrakeSpecificFuelConsumption result /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out BrakeSpecificFuelConsumption result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out BrakeSpecificFuelConsumptionUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out BrakeSpecificFuelConsumptionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 2b679df00b..a8bce3fea6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -211,7 +211,7 @@ public static string GetAbbreviation(CapacitanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -349,7 +349,7 @@ public static Capacitance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Capacitance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -380,7 +380,7 @@ public static bool TryParse(string? str, out Capacitance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Capacitance result) { return QuantityParser.Default.TryParse( @@ -408,7 +408,7 @@ public static CapacitanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -434,7 +434,7 @@ public static bool TryParseUnit(string str, out CapacitanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out CapacitanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -743,7 +743,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -751,21 +751,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 6ed9d5bb01..462f9b5a2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static CoefficientOfThermalExpansion Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static CoefficientOfThermalExpansion Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out CoefficientOfThermalExpansion resul /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out CoefficientOfThermalExpansion result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static CoefficientOfThermalExpansionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out CoefficientOfThermalExpansionUni /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out CoefficientOfThermalExpansionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 2eba18042d..15297d870d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -409,7 +409,7 @@ public static string GetAbbreviation(DensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -844,7 +844,7 @@ public static Density Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Density Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -875,7 +875,7 @@ public static bool TryParse(string? str, out Density result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Density result) { return QuantityParser.Default.TryParse( @@ -903,7 +903,7 @@ public static DensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -929,7 +929,7 @@ public static bool TryParseUnit(string str, out DensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out DensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1304,7 +1304,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1312,21 +1312,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 552a0af9cc..c84c7bb4d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -226,7 +226,7 @@ public static string GetAbbreviation(DurationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -391,7 +391,7 @@ public static Duration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Duration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -422,7 +422,7 @@ public static bool TryParse(string? str, out Duration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Duration result) { return QuantityParser.Default.TryParse( @@ -450,7 +450,7 @@ public static DurationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -476,7 +476,7 @@ public static bool TryParseUnit(string str, out DurationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out DurationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -791,7 +791,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -799,21 +799,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 1a473fb753..50da1af660 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -229,7 +229,7 @@ public static string GetAbbreviation(DynamicViscosityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -394,7 +394,7 @@ public static DynamicViscosity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static DynamicViscosity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -425,7 +425,7 @@ public static bool TryParse(string? str, out DynamicViscosity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out DynamicViscosity result) { return QuantityParser.Default.TryParse( @@ -453,7 +453,7 @@ public static DynamicViscosityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -479,7 +479,7 @@ public static bool TryParseUnit(string str, out DynamicViscosityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out DynamicViscosityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -794,7 +794,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -802,21 +802,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 8da7483e95..e8778623b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -190,7 +190,7 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -301,7 +301,7 @@ public static ElectricAdmittance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricAdmittance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -332,7 +332,7 @@ public static bool TryParse(string? str, out ElectricAdmittance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricAdmittance result) { return QuantityParser.Default.TryParse( @@ -360,7 +360,7 @@ public static ElectricAdmittanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -386,7 +386,7 @@ public static bool TryParseUnit(string str, out ElectricAdmittanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricAdmittanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -689,7 +689,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -697,21 +697,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 7ff03984f0..f353ec9463 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -199,7 +199,7 @@ public static string GetAbbreviation(ElectricChargeUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -319,7 +319,7 @@ public static ElectricCharge Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCharge Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -350,7 +350,7 @@ public static bool TryParse(string? str, out ElectricCharge result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCharge result) { return QuantityParser.Default.TryParse( @@ -378,7 +378,7 @@ public static ElectricChargeUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -404,7 +404,7 @@ public static bool TryParseUnit(string str, out ElectricChargeUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricChargeUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -709,7 +709,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -717,21 +717,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 98c63cdd7d..46a401a30f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static ElectricChargeDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricChargeDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out ElectricChargeDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricChargeDensity result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static ElectricChargeDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out ElectricChargeDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricChargeDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index b8fc5e194b..e4b9c97be1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -187,7 +187,7 @@ public static string GetAbbreviation(ElectricConductanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -289,7 +289,7 @@ public static ElectricConductance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricConductance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -320,7 +320,7 @@ public static bool TryParse(string? str, out ElectricConductance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductance result) { return QuantityParser.Default.TryParse( @@ -348,7 +348,7 @@ public static ElectricConductanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -374,7 +374,7 @@ public static bool TryParseUnit(string str, out ElectricConductanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -675,7 +675,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -683,21 +683,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 401c08a2bd..05d6597879 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -187,7 +187,7 @@ public static string GetAbbreviation(ElectricConductivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -289,7 +289,7 @@ public static ElectricConductivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricConductivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -320,7 +320,7 @@ public static bool TryParse(string? str, out ElectricConductivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductivity result) { return QuantityParser.Default.TryParse( @@ -348,7 +348,7 @@ public static ElectricConductivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -374,7 +374,7 @@ public static bool TryParseUnit(string str, out ElectricConductivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -675,7 +675,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -683,21 +683,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 083134c22e..79168272f3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -214,7 +214,7 @@ public static string GetAbbreviation(ElectricCurrentUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -361,7 +361,7 @@ public static ElectricCurrent Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCurrent Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -392,7 +392,7 @@ public static bool TryParse(string? str, out ElectricCurrent result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrent result) { return QuantityParser.Default.TryParse( @@ -420,7 +420,7 @@ public static ElectricCurrentUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -446,7 +446,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -757,7 +757,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -765,21 +765,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 95f6b63a91..3f19fdd22b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -187,7 +187,7 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -289,7 +289,7 @@ public static ElectricCurrentDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCurrentDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -320,7 +320,7 @@ public static bool TryParse(string? str, out ElectricCurrentDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentDensity result) { return QuantityParser.Default.TryParse( @@ -348,7 +348,7 @@ public static ElectricCurrentDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -374,7 +374,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -675,7 +675,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -683,21 +683,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index dae6d42e34..bfcd86362f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -190,7 +190,7 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -301,7 +301,7 @@ public static ElectricCurrentGradient Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCurrentGradient Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -332,7 +332,7 @@ public static bool TryParse(string? str, out ElectricCurrentGradient result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentGradient result) { return QuantityParser.Default.TryParse( @@ -360,7 +360,7 @@ public static ElectricCurrentGradientUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -386,7 +386,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentGradientUnit unit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentGradientUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -689,7 +689,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -697,21 +697,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index ffbae6bd46..9790fff6cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(ElectricFieldUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static ElectricField Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricField Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out ElectricField result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricField result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static ElectricFieldUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out ElectricFieldUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricFieldUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 1807c84eca..f91f2c6d0e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -193,7 +193,7 @@ public static string GetAbbreviation(ElectricInductanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -304,7 +304,7 @@ public static ElectricInductance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricInductance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -335,7 +335,7 @@ public static bool TryParse(string? str, out ElectricInductance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricInductance result) { return QuantityParser.Default.TryParse( @@ -363,7 +363,7 @@ public static ElectricInductanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -389,7 +389,7 @@ public static bool TryParseUnit(string str, out ElectricInductanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricInductanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -692,7 +692,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -700,21 +700,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index b9dcb6de63..b85de59b90 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -196,7 +196,7 @@ public static string GetAbbreviation(ElectricPotentialUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -316,7 +316,7 @@ public static ElectricPotential Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotential Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -347,7 +347,7 @@ public static bool TryParse(string? str, out ElectricPotential result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotential result) { return QuantityParser.Default.TryParse( @@ -375,7 +375,7 @@ public static ElectricPotentialUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -401,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -706,7 +706,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -714,21 +714,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index b338331dac..38d9c099e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -196,7 +196,7 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -316,7 +316,7 @@ public static ElectricPotentialAc Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotentialAc Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -347,7 +347,7 @@ public static bool TryParse(string? str, out ElectricPotentialAc result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialAc result) { return QuantityParser.Default.TryParse( @@ -375,7 +375,7 @@ public static ElectricPotentialAcUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -401,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialAcUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialAcUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -706,7 +706,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -714,21 +714,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 32236cf3ad..d47ba88419 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -286,7 +286,7 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -541,7 +541,7 @@ public static ElectricPotentialChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotentialChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -572,7 +572,7 @@ public static bool TryParse(string? str, out ElectricPotentialChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialChangeRate result) { return QuantityParser.Default.TryParse( @@ -600,7 +600,7 @@ public static ElectricPotentialChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -626,7 +626,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialChangeRateUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -961,7 +961,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -969,21 +969,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 34ba2e57ba..abef170f68 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -196,7 +196,7 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -316,7 +316,7 @@ public static ElectricPotentialDc Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotentialDc Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -347,7 +347,7 @@ public static bool TryParse(string? str, out ElectricPotentialDc result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialDc result) { return QuantityParser.Default.TryParse( @@ -375,7 +375,7 @@ public static ElectricPotentialDcUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -401,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialDcUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialDcUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -706,7 +706,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -714,21 +714,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index d38168a582..c4a6b3c4b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -202,7 +202,7 @@ public static string GetAbbreviation(ElectricResistanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -331,7 +331,7 @@ public static ElectricResistance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricResistance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -362,7 +362,7 @@ public static bool TryParse(string? str, out ElectricResistance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistance result) { return QuantityParser.Default.TryParse( @@ -390,7 +390,7 @@ public static ElectricResistanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -416,7 +416,7 @@ public static bool TryParseUnit(string str, out ElectricResistanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricResistanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -723,7 +723,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -731,21 +731,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index e6ff4a0d6a..d86e867757 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -253,7 +253,7 @@ public static string GetAbbreviation(ElectricResistivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -454,7 +454,7 @@ public static ElectricResistivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricResistivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -485,7 +485,7 @@ public static bool TryParse(string? str, out ElectricResistivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistivity result) { return QuantityParser.Default.TryParse( @@ -513,7 +513,7 @@ public static ElectricResistivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -539,7 +539,7 @@ public static bool TryParseUnit(string str, out ElectricResistivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricResistivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -862,7 +862,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -870,21 +870,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index a9ebb08d7d..c26ff1436b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -187,7 +187,7 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -289,7 +289,7 @@ public static ElectricSurfaceChargeDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricSurfaceChargeDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -320,7 +320,7 @@ public static bool TryParse(string? str, out ElectricSurfaceChargeDensity result /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricSurfaceChargeDensity result) { return QuantityParser.Default.TryParse( @@ -348,7 +348,7 @@ public static ElectricSurfaceChargeDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -374,7 +374,7 @@ public static bool TryParseUnit(string str, out ElectricSurfaceChargeDensityUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricSurfaceChargeDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -675,7 +675,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -683,21 +683,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index b6320a6c03..92887675fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -382,7 +382,7 @@ public static string GetAbbreviation(EnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -781,7 +781,7 @@ public static Energy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Energy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -812,7 +812,7 @@ public static bool TryParse(string? str, out Energy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Energy result) { return QuantityParser.Default.TryParse( @@ -840,7 +840,7 @@ public static EnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -866,7 +866,7 @@ public static bool TryParseUnit(string str, out EnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out EnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1233,7 +1233,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1241,21 +1241,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 6c505ed4aa..13fa637270 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -208,7 +208,7 @@ public static string GetAbbreviation(EntropyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -346,7 +346,7 @@ public static Entropy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Entropy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -377,7 +377,7 @@ public static bool TryParse(string? str, out Entropy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Entropy result) { return QuantityParser.Default.TryParse( @@ -405,7 +405,7 @@ public static EntropyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -431,7 +431,7 @@ public static bool TryParseUnit(string str, out EntropyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out EntropyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -740,7 +740,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -748,21 +748,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 22bde314f0..a5a67f7e93 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -256,7 +256,7 @@ public static string GetAbbreviation(ForceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -466,7 +466,7 @@ public static Force Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Force Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -497,7 +497,7 @@ public static bool TryParse(string? str, out Force result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Force result) { return QuantityParser.Default.TryParse( @@ -525,7 +525,7 @@ public static ForceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -551,7 +551,7 @@ public static bool TryParseUnit(string str, out ForceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ForceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -876,7 +876,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -884,21 +884,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 70de0f89be..47d360eb4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -256,7 +256,7 @@ public static string GetAbbreviation(ForceChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -466,7 +466,7 @@ public static ForceChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ForceChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -497,7 +497,7 @@ public static bool TryParse(string? str, out ForceChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ForceChangeRate result) { return QuantityParser.Default.TryParse( @@ -525,7 +525,7 @@ public static ForceChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -551,7 +551,7 @@ public static bool TryParseUnit(string str, out ForceChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ForceChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -876,7 +876,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -884,21 +884,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index f51ae7e407..b06632f34d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -394,7 +394,7 @@ public static string GetAbbreviation(ForcePerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -811,7 +811,7 @@ public static ForcePerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ForcePerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -842,7 +842,7 @@ public static bool TryParse(string? str, out ForcePerLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ForcePerLength result) { return QuantityParser.Default.TryParse( @@ -870,7 +870,7 @@ public static ForcePerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -896,7 +896,7 @@ public static bool TryParseUnit(string str, out ForcePerLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ForcePerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1267,7 +1267,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1275,21 +1275,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index ee20a59776..0c5fdff5d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -232,7 +232,7 @@ public static string GetAbbreviation(FrequencyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -406,7 +406,7 @@ public static Frequency Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Frequency Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -437,7 +437,7 @@ public static bool TryParse(string? str, out Frequency result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Frequency result) { return QuantityParser.Default.TryParse( @@ -465,7 +465,7 @@ public static FrequencyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -491,7 +491,7 @@ public static bool TryParseUnit(string str, out FrequencyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out FrequencyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -808,7 +808,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -816,21 +816,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index b1f6bc1ff1..c6363b09fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -193,7 +193,7 @@ public static string GetAbbreviation(FuelEfficiencyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(FuelEfficiencyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -304,7 +304,7 @@ public static FuelEfficiency Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static FuelEfficiency Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -335,7 +335,7 @@ public static bool TryParse(string? str, out FuelEfficiency result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out FuelEfficiency result) { return QuantityParser.Default.TryParse( @@ -363,7 +363,7 @@ public static FuelEfficiencyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -389,7 +389,7 @@ public static bool TryParseUnit(string str, out FuelEfficiencyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelEfficiencyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -692,7 +692,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -700,21 +700,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 0fc224be8f..e32423863b 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -274,7 +274,7 @@ public static string GetAbbreviation(HeatFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(HeatFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -511,7 +511,7 @@ public static HeatFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static HeatFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -542,7 +542,7 @@ public static bool TryParse(string? str, out HeatFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out HeatFlux result) { return QuantityParser.Default.TryParse( @@ -570,7 +570,7 @@ public static HeatFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -596,7 +596,7 @@ public static bool TryParseUnit(string str, out HeatFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -927,7 +927,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -935,21 +935,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 30287b7a69..3740a28047 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(HeatTransferCoefficientUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(HeatTransferCoefficientUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static HeatTransferCoefficient Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static HeatTransferCoefficient Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out HeatTransferCoefficient result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out HeatTransferCoefficient result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static HeatTransferCoefficientUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out HeatTransferCoefficientUnit unit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatTransferCoefficientUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 7d9e3b5411..930e98dda5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -193,7 +193,7 @@ public static string GetAbbreviation(IlluminanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(IlluminanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -304,7 +304,7 @@ public static Illuminance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Illuminance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -335,7 +335,7 @@ public static bool TryParse(string? str, out Illuminance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Illuminance result) { return QuantityParser.Default.TryParse( @@ -363,7 +363,7 @@ public static IlluminanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -389,7 +389,7 @@ public static bool TryParseUnit(string str, out IlluminanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out IlluminanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -692,7 +692,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -700,21 +700,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index c3c9d8e7c8..9399dc0f41 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -327,7 +327,7 @@ public static string GetAbbreviation(InformationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(InformationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -636,7 +636,7 @@ public static Information Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Information Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -667,7 +667,7 @@ public static bool TryParse(string? str, out Information result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Information result) { return QuantityParser.Default.TryParse( @@ -695,7 +695,7 @@ public static InformationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -721,7 +721,7 @@ public static bool TryParseUnit(string str, out InformationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out InformationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1068,7 +1068,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1076,21 +1076,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 9e54df430a..b7cc9cfab6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -250,7 +250,7 @@ public static string GetAbbreviation(IrradianceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(IrradianceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -451,7 +451,7 @@ public static Irradiance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Irradiance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -482,7 +482,7 @@ public static bool TryParse(string? str, out Irradiance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Irradiance result) { return QuantityParser.Default.TryParse( @@ -510,7 +510,7 @@ public static IrradianceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -536,7 +536,7 @@ public static bool TryParseUnit(string str, out IrradianceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out IrradianceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -859,7 +859,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -867,21 +867,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index b767a82648..ce54e68df0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -211,7 +211,7 @@ public static string GetAbbreviation(IrradiationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(IrradiationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -349,7 +349,7 @@ public static Irradiation Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Irradiation Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -380,7 +380,7 @@ public static bool TryParse(string? str, out Irradiation result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Irradiation result) { return QuantityParser.Default.TryParse( @@ -408,7 +408,7 @@ public static IrradiationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -434,7 +434,7 @@ public static bool TryParseUnit(string str, out IrradiationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out IrradiationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -743,7 +743,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -751,21 +751,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 461d4b30be..ff5ce17908 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -223,7 +223,7 @@ public static string GetAbbreviation(KinematicViscosityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(KinematicViscosityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -379,7 +379,7 @@ public static KinematicViscosity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static KinematicViscosity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -410,7 +410,7 @@ public static bool TryParse(string? str, out KinematicViscosity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out KinematicViscosity result) { return QuantityParser.Default.TryParse( @@ -438,7 +438,7 @@ public static KinematicViscosityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -464,7 +464,7 @@ public static bool TryParseUnit(string str, out KinematicViscosityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out KinematicViscosityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -777,7 +777,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -785,21 +785,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index d9014c6a68..cfa6517177 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -172,7 +172,7 @@ public static string GetAbbreviation(LapseRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LapseRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -256,7 +256,7 @@ public static LapseRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LapseRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -287,7 +287,7 @@ public static bool TryParse(string? str, out LapseRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LapseRate result) { return QuantityParser.Default.TryParse( @@ -315,7 +315,7 @@ public static LapseRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -341,7 +341,7 @@ public static bool TryParseUnit(string str, out LapseRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LapseRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -638,7 +638,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -646,21 +646,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 0d520d132f..a2d49b9039 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -364,7 +364,7 @@ public static string GetAbbreviation(LengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -736,7 +736,7 @@ public static Length Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Length Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -767,7 +767,7 @@ public static bool TryParse(string? str, out Length result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Length result) { return QuantityParser.Default.TryParse( @@ -795,7 +795,7 @@ public static LengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -821,7 +821,7 @@ public static bool TryParseUnit(string str, out LengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1182,7 +1182,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1190,21 +1190,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index dde9e64bfd..b74d165689 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -178,7 +178,7 @@ public static string GetAbbreviation(LevelUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LevelUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -271,7 +271,7 @@ public static Level Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Level Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -302,7 +302,7 @@ public static bool TryParse(string? str, out Level result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Level result) { return QuantityParser.Default.TryParse( @@ -330,7 +330,7 @@ public static LevelUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -356,7 +356,7 @@ public static bool TryParseUnit(string str, out LevelUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LevelUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -663,7 +663,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -671,21 +671,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 49b0c4ab6f..e6419b21e0 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -253,7 +253,7 @@ public static string GetAbbreviation(LinearDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LinearDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -454,7 +454,7 @@ public static LinearDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LinearDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -485,7 +485,7 @@ public static bool TryParse(string? str, out LinearDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LinearDensity result) { return QuantityParser.Default.TryParse( @@ -513,7 +513,7 @@ public static LinearDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -539,7 +539,7 @@ public static bool TryParseUnit(string str, out LinearDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LinearDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -862,7 +862,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -870,21 +870,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index c000a43216..7cf6a255dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -319,7 +319,7 @@ public static string GetAbbreviation(LinearPowerDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LinearPowerDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -619,7 +619,7 @@ public static LinearPowerDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LinearPowerDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -650,7 +650,7 @@ public static bool TryParse(string? str, out LinearPowerDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LinearPowerDensity result) { return QuantityParser.Default.TryParse( @@ -678,7 +678,7 @@ public static LinearPowerDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -704,7 +704,7 @@ public static bool TryParseUnit(string str, out LinearPowerDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LinearPowerDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1049,7 +1049,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1057,21 +1057,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index f8e5e51c4a..156af02864 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -253,7 +253,7 @@ public static string GetAbbreviation(LuminosityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LuminosityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -454,7 +454,7 @@ public static Luminosity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Luminosity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -485,7 +485,7 @@ public static bool TryParse(string? str, out Luminosity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Luminosity result) { return QuantityParser.Default.TryParse( @@ -513,7 +513,7 @@ public static LuminosityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -539,7 +539,7 @@ public static bool TryParseUnit(string str, out LuminosityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LuminosityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -862,7 +862,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -870,21 +870,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 8a9fc756df..3cda60672f 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(LuminousFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LuminousFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static LuminousFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LuminousFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out LuminousFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LuminousFlux result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static LuminousFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out LuminousFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LuminousFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index d47ec9da54..a6e45285b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(LuminousIntensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LuminousIntensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static LuminousIntensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LuminousIntensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out LuminousIntensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LuminousIntensity result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static LuminousIntensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out LuminousIntensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LuminousIntensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index d44f209794..a52dfe861d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -205,7 +205,7 @@ public static string GetAbbreviation(MagneticFieldUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MagneticFieldUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -334,7 +334,7 @@ public static MagneticField Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MagneticField Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -365,7 +365,7 @@ public static bool TryParse(string? str, out MagneticField result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MagneticField result) { return QuantityParser.Default.TryParse( @@ -393,7 +393,7 @@ public static MagneticFieldUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -419,7 +419,7 @@ public static bool TryParseUnit(string str, out MagneticFieldUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MagneticFieldUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -726,7 +726,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -734,21 +734,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 0b0326fd95..c7a0dea6a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(MagneticFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MagneticFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static MagneticFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MagneticFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out MagneticFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MagneticFlux result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static MagneticFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out MagneticFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MagneticFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 5a4be0fba2..905204d465 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(MagnetizationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MagnetizationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static Magnetization Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Magnetization Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out Magnetization result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Magnetization result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static MagnetizationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out MagnetizationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MagnetizationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index ac27f16599..116ec458f6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -316,7 +316,7 @@ public static string GetAbbreviation(MassUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -616,7 +616,7 @@ public static Mass Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Mass Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -647,7 +647,7 @@ public static bool TryParse(string? str, out Mass result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Mass result) { return QuantityParser.Default.TryParse( @@ -675,7 +675,7 @@ public static MassUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -701,7 +701,7 @@ public static bool TryParseUnit(string str, out MassUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1046,7 +1046,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1054,21 +1054,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 632b14de38..7131eac808 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -463,7 +463,7 @@ public static string GetAbbreviation(MassConcentrationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassConcentrationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -979,7 +979,7 @@ public static MassConcentration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassConcentration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1010,7 +1010,7 @@ public static bool TryParse(string? str, out MassConcentration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassConcentration result) { return QuantityParser.Default.TryParse( @@ -1038,7 +1038,7 @@ public static MassConcentrationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1064,7 +1064,7 @@ public static bool TryParseUnit(string str, out MassConcentrationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassConcentrationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1457,7 +1457,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1465,21 +1465,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index d7609a3487..523ddac416 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -364,7 +364,7 @@ public static string GetAbbreviation(MassFlowUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassFlowUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -736,7 +736,7 @@ public static MassFlow Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassFlow Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -767,7 +767,7 @@ public static bool TryParse(string? str, out MassFlow result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassFlow result) { return QuantityParser.Default.TryParse( @@ -795,7 +795,7 @@ public static MassFlowUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -821,7 +821,7 @@ public static bool TryParseUnit(string str, out MassFlowUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassFlowUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1182,7 +1182,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1190,21 +1190,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 1a297392bd..ce56bbf12c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -238,7 +238,7 @@ public static string GetAbbreviation(MassFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -421,7 +421,7 @@ public static MassFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -452,7 +452,7 @@ public static bool TryParse(string? str, out MassFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassFlux result) { return QuantityParser.Default.TryParse( @@ -480,7 +480,7 @@ public static MassFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -506,7 +506,7 @@ public static bool TryParseUnit(string str, out MassFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -825,7 +825,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -833,21 +833,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 9334406a91..21a503ca61 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -313,7 +313,7 @@ public static string GetAbbreviation(MassFractionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassFractionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -604,7 +604,7 @@ public static MassFraction Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassFraction Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -635,7 +635,7 @@ public static bool TryParse(string? str, out MassFraction result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassFraction result) { return QuantityParser.Default.TryParse( @@ -663,7 +663,7 @@ public static MassFractionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -689,7 +689,7 @@ public static bool TryParseUnit(string str, out MassFractionUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassFractionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1032,7 +1032,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1040,21 +1040,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 84a62383f2..48c655db4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -334,7 +334,7 @@ public static string GetAbbreviation(MassMomentOfInertiaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassMomentOfInertiaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -661,7 +661,7 @@ public static MassMomentOfInertia Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassMomentOfInertia Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -692,7 +692,7 @@ public static bool TryParse(string? str, out MassMomentOfInertia result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassMomentOfInertia result) { return QuantityParser.Default.TryParse( @@ -720,7 +720,7 @@ public static MassMomentOfInertiaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -746,7 +746,7 @@ public static bool TryParseUnit(string str, out MassMomentOfInertiaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassMomentOfInertiaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1097,7 +1097,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1105,21 +1105,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index cc87c5b14c..61e0bedd83 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(MolarEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static MolarEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MolarEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out MolarEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MolarEnergy result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static MolarEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out MolarEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 4db75c4f9f..dafec903b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(MolarEntropyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarEntropyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static MolarEntropy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MolarEntropy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out MolarEntropy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MolarEntropy result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static MolarEntropyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out MolarEntropyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarEntropyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index ebcf76fc23..0ba3fa3517 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -238,7 +238,7 @@ public static string GetAbbreviation(MolarMassUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarMassUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -421,7 +421,7 @@ public static MolarMass Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MolarMass Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -452,7 +452,7 @@ public static bool TryParse(string? str, out MolarMass result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MolarMass result) { return QuantityParser.Default.TryParse( @@ -480,7 +480,7 @@ public static MolarMassUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -506,7 +506,7 @@ public static bool TryParseUnit(string str, out MolarMassUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarMassUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -825,7 +825,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -833,21 +833,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 7c31fceca1..645c298cc5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -217,7 +217,7 @@ public static string GetAbbreviation(MolarityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -364,7 +364,7 @@ public static Molarity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Molarity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -395,7 +395,7 @@ public static bool TryParse(string? str, out Molarity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Molarity result) { return QuantityParser.Default.TryParse( @@ -423,7 +423,7 @@ public static MolarityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -449,7 +449,7 @@ public static bool TryParseUnit(string str, out MolarityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -760,7 +760,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -768,21 +768,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 2263fdb8cb..91d63953e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(PermeabilityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PermeabilityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static Permeability Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Permeability Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out Permeability result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Permeability result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static PermeabilityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out PermeabilityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PermeabilityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index f0e0291f0c..85eae6b36f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(PermittivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PermittivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static Permittivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Permittivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out Permittivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Permittivity result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static PermittivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out PermittivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PermittivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index a369415538..191e08e6f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -321,7 +321,7 @@ public static string GetAbbreviation(PowerUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -621,7 +621,7 @@ public static Power Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Power Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -652,7 +652,7 @@ public static bool TryParse(string? str, out Power result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Power result) { return QuantityParser.Default.TryParse( @@ -680,7 +680,7 @@ public static PowerUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -706,7 +706,7 @@ public static bool TryParseUnit(string str, out PowerUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PowerUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1051,7 +1051,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1059,21 +1059,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 881f4b9dd9..2751d895f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -430,7 +430,7 @@ public static string GetAbbreviation(PowerDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PowerDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -901,7 +901,7 @@ public static PowerDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static PowerDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -932,7 +932,7 @@ public static bool TryParse(string? str, out PowerDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out PowerDensity result) { return QuantityParser.Default.TryParse( @@ -960,7 +960,7 @@ public static PowerDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -986,7 +986,7 @@ public static bool TryParseUnit(string str, out PowerDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PowerDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1369,7 +1369,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1377,21 +1377,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 35f3ccb654..85efb4de93 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -178,7 +178,7 @@ public static string GetAbbreviation(PowerRatioUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PowerRatioUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -271,7 +271,7 @@ public static PowerRatio Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static PowerRatio Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -302,7 +302,7 @@ public static bool TryParse(string? str, out PowerRatio result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out PowerRatio result) { return QuantityParser.Default.TryParse( @@ -330,7 +330,7 @@ public static PowerRatioUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -356,7 +356,7 @@ public static bool TryParseUnit(string str, out PowerRatioUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PowerRatioUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -663,7 +663,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -671,21 +671,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index c558b69c06..9caa5e9dea 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -430,7 +430,7 @@ public static string GetAbbreviation(PressureUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PressureUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -901,7 +901,7 @@ public static Pressure Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Pressure Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -932,7 +932,7 @@ public static bool TryParse(string? str, out Pressure result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Pressure result) { return QuantityParser.Default.TryParse( @@ -960,7 +960,7 @@ public static PressureUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -986,7 +986,7 @@ public static bool TryParseUnit(string str, out PressureUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PressureUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1369,7 +1369,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1377,21 +1377,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index de2bbe0c8d..c4f102ab69 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -244,7 +244,7 @@ public static string GetAbbreviation(PressureChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PressureChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -436,7 +436,7 @@ public static PressureChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static PressureChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -467,7 +467,7 @@ public static bool TryParse(string? str, out PressureChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out PressureChangeRate result) { return QuantityParser.Default.TryParse( @@ -495,7 +495,7 @@ public static PressureChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -521,7 +521,7 @@ public static bool TryParseUnit(string str, out PressureChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PressureChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -842,7 +842,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -850,21 +850,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index c80752fcdf..ff6b2f08d9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -202,7 +202,7 @@ public static string GetAbbreviation(RatioUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RatioUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -331,7 +331,7 @@ public static Ratio Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Ratio Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -362,7 +362,7 @@ public static bool TryParse(string? str, out Ratio result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Ratio result) { return QuantityParser.Default.TryParse( @@ -390,7 +390,7 @@ public static RatioUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -416,7 +416,7 @@ public static bool TryParseUnit(string str, out RatioUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RatioUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -723,7 +723,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -731,21 +731,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 278edd1419..1f6a07f1c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -178,7 +178,7 @@ public static string GetAbbreviation(RatioChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RatioChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -271,7 +271,7 @@ public static RatioChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RatioChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -302,7 +302,7 @@ public static bool TryParse(string? str, out RatioChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RatioChangeRate result) { return QuantityParser.Default.TryParse( @@ -330,7 +330,7 @@ public static RatioChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -356,7 +356,7 @@ public static bool TryParseUnit(string str, out RatioChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RatioChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -655,7 +655,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -663,21 +663,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 20696902ca..2cdd915e14 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(ReactiveEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReactiveEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static ReactiveEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReactiveEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out ReactiveEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReactiveEnergy result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static ReactiveEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out ReactiveEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReactiveEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index a6c5e8eb21..cce28dc18b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -190,7 +190,7 @@ public static string GetAbbreviation(ReactivePowerUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReactivePowerUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -301,7 +301,7 @@ public static ReactivePower Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReactivePower Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -332,7 +332,7 @@ public static bool TryParse(string? str, out ReactivePower result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReactivePower result) { return QuantityParser.Default.TryParse( @@ -360,7 +360,7 @@ public static ReactivePowerUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -386,7 +386,7 @@ public static bool TryParseUnit(string str, out ReactivePowerUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReactivePowerUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -689,7 +689,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -697,21 +697,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index f36e585421..65163bdf19 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -235,7 +235,7 @@ public static string GetAbbreviation(ReciprocalAreaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReciprocalAreaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -409,7 +409,7 @@ public static ReciprocalArea Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReciprocalArea Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -440,7 +440,7 @@ public static bool TryParse(string? str, out ReciprocalArea result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReciprocalArea result) { return QuantityParser.Default.TryParse( @@ -468,7 +468,7 @@ public static ReciprocalAreaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -494,7 +494,7 @@ public static bool TryParseUnit(string str, out ReciprocalAreaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReciprocalAreaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -811,7 +811,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -819,21 +819,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index b33dd46cdf..9563e8560e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -229,7 +229,7 @@ public static string GetAbbreviation(ReciprocalLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReciprocalLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -394,7 +394,7 @@ public static ReciprocalLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReciprocalLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -425,7 +425,7 @@ public static bool TryParse(string? str, out ReciprocalLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReciprocalLength result) { return QuantityParser.Default.TryParse( @@ -453,7 +453,7 @@ public static ReciprocalLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -479,7 +479,7 @@ public static bool TryParseUnit(string str, out ReciprocalLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReciprocalLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -794,7 +794,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -802,21 +802,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 5817cc979d..a4ce4bf2c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -172,7 +172,7 @@ public static string GetAbbreviation(RelativeHumidityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RelativeHumidityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -256,7 +256,7 @@ public static RelativeHumidity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RelativeHumidity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -287,7 +287,7 @@ public static bool TryParse(string? str, out RelativeHumidity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RelativeHumidity result) { return QuantityParser.Default.TryParse( @@ -315,7 +315,7 @@ public static RelativeHumidityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -341,7 +341,7 @@ public static bool TryParseUnit(string str, out RelativeHumidityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RelativeHumidityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -638,7 +638,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -646,21 +646,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 35912a4c5e..a0004f3135 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -190,7 +190,7 @@ public static string GetAbbreviation(RotationalAccelerationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalAccelerationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -301,7 +301,7 @@ public static RotationalAcceleration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalAcceleration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -332,7 +332,7 @@ public static bool TryParse(string? str, out RotationalAcceleration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalAcceleration result) { return QuantityParser.Default.TryParse( @@ -360,7 +360,7 @@ public static RotationalAccelerationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -386,7 +386,7 @@ public static bool TryParseUnit(string str, out RotationalAccelerationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalAccelerationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -689,7 +689,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -697,21 +697,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 159720c28a..95fa563e2a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -244,7 +244,7 @@ public static string GetAbbreviation(RotationalSpeedUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalSpeedUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -436,7 +436,7 @@ public static RotationalSpeed Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalSpeed Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -467,7 +467,7 @@ public static bool TryParse(string? str, out RotationalSpeed result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalSpeed result) { return QuantityParser.Default.TryParse( @@ -495,7 +495,7 @@ public static RotationalSpeedUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -521,7 +521,7 @@ public static bool TryParseUnit(string str, out RotationalSpeedUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalSpeedUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -842,7 +842,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -850,21 +850,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index d79ba26ff2..c2d240a9ee 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -364,7 +364,7 @@ public static string GetAbbreviation(RotationalStiffnessUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalStiffnessUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -736,7 +736,7 @@ public static RotationalStiffness Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalStiffness Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -767,7 +767,7 @@ public static bool TryParse(string? str, out RotationalStiffness result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffness result) { return QuantityParser.Default.TryParse( @@ -795,7 +795,7 @@ public static RotationalStiffnessUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -821,7 +821,7 @@ public static bool TryParseUnit(string str, out RotationalStiffnessUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalStiffnessUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1182,7 +1182,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1190,21 +1190,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 16964951c0..91d4ad145a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -196,7 +196,7 @@ public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -316,7 +316,7 @@ public static RotationalStiffnessPerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalStiffnessPerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -347,7 +347,7 @@ public static bool TryParse(string? str, out RotationalStiffnessPerLength result /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffnessPerLength result) { return QuantityParser.Default.TryParse( @@ -375,7 +375,7 @@ public static RotationalStiffnessPerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -401,7 +401,7 @@ public static bool TryParseUnit(string str, out RotationalStiffnessPerLengthUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalStiffnessPerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -706,7 +706,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -714,21 +714,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 751e23a7d1..8c1c50aad8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -172,7 +172,7 @@ public static string GetAbbreviation(ScalarUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ScalarUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -256,7 +256,7 @@ public static Scalar Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Scalar Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -287,7 +287,7 @@ public static bool TryParse(string? str, out Scalar result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Scalar result) { return QuantityParser.Default.TryParse( @@ -315,7 +315,7 @@ public static ScalarUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -341,7 +341,7 @@ public static bool TryParseUnit(string str, out ScalarUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ScalarUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -638,7 +638,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -646,21 +646,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 899e4cc908..d4cb24750b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(SolidAngleUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SolidAngleUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static SolidAngle Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SolidAngle Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out SolidAngle result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SolidAngle result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static SolidAngleUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out SolidAngleUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SolidAngleUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 7be5e9d433..f60095d963 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -319,7 +319,7 @@ public static string GetAbbreviation(SpecificEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -619,7 +619,7 @@ public static SpecificEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -650,7 +650,7 @@ public static bool TryParse(string? str, out SpecificEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEnergy result) { return QuantityParser.Default.TryParse( @@ -678,7 +678,7 @@ public static SpecificEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -704,7 +704,7 @@ public static bool TryParseUnit(string str, out SpecificEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1049,7 +1049,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1057,21 +1057,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index e2c13f0038..2b800d1fee 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -220,7 +220,7 @@ public static string GetAbbreviation(SpecificEntropyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificEntropyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +376,7 @@ public static SpecificEntropy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificEntropy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +407,7 @@ public static bool TryParse(string? str, out SpecificEntropy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEntropy result) { return QuantityParser.Default.TryParse( @@ -435,7 +435,7 @@ public static SpecificEntropyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +461,7 @@ public static bool TryParseUnit(string str, out SpecificEntropyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificEntropyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -774,7 +774,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -782,21 +782,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 78d40f2948..d466faab28 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -193,7 +193,7 @@ public static string GetAbbreviation(SpecificFuelConsumptionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificFuelConsumptionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -304,7 +304,7 @@ public static SpecificFuelConsumption Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificFuelConsumption Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -335,7 +335,7 @@ public static bool TryParse(string? str, out SpecificFuelConsumption result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificFuelConsumption result) { return QuantityParser.Default.TryParse( @@ -363,7 +363,7 @@ public static SpecificFuelConsumptionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -389,7 +389,7 @@ public static bool TryParseUnit(string str, out SpecificFuelConsumptionUnit unit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificFuelConsumptionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -692,7 +692,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -700,21 +700,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 7805b02fce..ad2f50a3f6 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -184,7 +184,7 @@ public static string GetAbbreviation(SpecificVolumeUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificVolumeUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -286,7 +286,7 @@ public static SpecificVolume Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificVolume Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -317,7 +317,7 @@ public static bool TryParse(string? str, out SpecificVolume result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificVolume result) { return QuantityParser.Default.TryParse( @@ -345,7 +345,7 @@ public static SpecificVolumeUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -371,7 +371,7 @@ public static bool TryParseUnit(string str, out SpecificVolumeUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificVolumeUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -672,7 +672,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -680,21 +680,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 969e1bdae7..7404c07abc 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -271,7 +271,7 @@ public static string GetAbbreviation(SpecificWeightUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificWeightUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -499,7 +499,7 @@ public static SpecificWeight Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificWeight Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -530,7 +530,7 @@ public static bool TryParse(string? str, out SpecificWeight result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificWeight result) { return QuantityParser.Default.TryParse( @@ -558,7 +558,7 @@ public static SpecificWeightUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -584,7 +584,7 @@ public static bool TryParseUnit(string str, out SpecificWeightUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificWeightUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -913,7 +913,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -921,21 +921,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 7974b6d834..0d23c8bab9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -358,7 +358,7 @@ public static string GetAbbreviation(SpeedUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpeedUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -721,7 +721,7 @@ public static Speed Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Speed Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -752,7 +752,7 @@ public static bool TryParse(string? str, out Speed result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Speed result) { return QuantityParser.Default.TryParse( @@ -780,7 +780,7 @@ public static SpeedUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -806,7 +806,7 @@ public static bool TryParseUnit(string str, out SpeedUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpeedUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1165,7 +1165,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1173,21 +1173,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 0aaf0ffc99..0e11056e34 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -220,7 +220,7 @@ public static string GetAbbreviation(StandardVolumeFlowUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(StandardVolumeFlowUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +376,7 @@ public static StandardVolumeFlow Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static StandardVolumeFlow Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +407,7 @@ public static bool TryParse(string? str, out StandardVolumeFlow result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out StandardVolumeFlow result) { return QuantityParser.Default.TryParse( @@ -435,7 +435,7 @@ public static StandardVolumeFlowUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +461,7 @@ public static bool TryParseUnit(string str, out StandardVolumeFlowUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out StandardVolumeFlowUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -774,7 +774,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -782,21 +782,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 199efee3b2..c8d429dbf3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -226,7 +226,7 @@ public static string GetAbbreviation(TemperatureUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -391,7 +391,7 @@ public static Temperature Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Temperature Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -422,7 +422,7 @@ public static bool TryParse(string? str, out Temperature result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Temperature result) { return QuantityParser.Default.TryParse( @@ -450,7 +450,7 @@ public static TemperatureUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -476,7 +476,7 @@ public static bool TryParseUnit(string str, out TemperatureUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -745,7 +745,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -753,21 +753,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 896718766b..e459a5b3d6 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -226,7 +226,7 @@ public static string GetAbbreviation(TemperatureChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -391,7 +391,7 @@ public static TemperatureChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TemperatureChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -422,7 +422,7 @@ public static bool TryParse(string? str, out TemperatureChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureChangeRate result) { return QuantityParser.Default.TryParse( @@ -450,7 +450,7 @@ public static TemperatureChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -476,7 +476,7 @@ public static bool TryParseUnit(string str, out TemperatureChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -791,7 +791,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -799,21 +799,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 54ffc9d7ae..f29646d81c 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -220,7 +220,7 @@ public static string GetAbbreviation(TemperatureDeltaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureDeltaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +376,7 @@ public static TemperatureDelta Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TemperatureDelta Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +407,7 @@ public static bool TryParse(string? str, out TemperatureDelta result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureDelta result) { return QuantityParser.Default.TryParse( @@ -435,7 +435,7 @@ public static TemperatureDeltaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +461,7 @@ public static bool TryParseUnit(string str, out TemperatureDeltaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureDeltaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -774,7 +774,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -782,21 +782,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index a424b53255..4fee01d256 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -181,7 +181,7 @@ public static string GetAbbreviation(ThermalConductivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ThermalConductivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -274,7 +274,7 @@ public static ThermalConductivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ThermalConductivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -305,7 +305,7 @@ public static bool TryParse(string? str, out ThermalConductivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ThermalConductivity result) { return QuantityParser.Default.TryParse( @@ -333,7 +333,7 @@ public static ThermalConductivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -359,7 +359,7 @@ public static bool TryParseUnit(string str, out ThermalConductivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ThermalConductivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -658,7 +658,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -666,21 +666,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 5cb5699bdb..0def34e49d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -196,7 +196,7 @@ public static string GetAbbreviation(ThermalResistanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ThermalResistanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -316,7 +316,7 @@ public static ThermalResistance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ThermalResistance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -347,7 +347,7 @@ public static bool TryParse(string? str, out ThermalResistance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ThermalResistance result) { return QuantityParser.Default.TryParse( @@ -375,7 +375,7 @@ public static ThermalResistanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -401,7 +401,7 @@ public static bool TryParseUnit(string str, out ThermalResistanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ThermalResistanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -706,7 +706,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -714,21 +714,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 7f2f474c37..b6f3d949b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -298,7 +298,7 @@ public static string GetAbbreviation(TorqueUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TorqueUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -571,7 +571,7 @@ public static Torque Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Torque Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -602,7 +602,7 @@ public static bool TryParse(string? str, out Torque result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Torque result) { return QuantityParser.Default.TryParse( @@ -630,7 +630,7 @@ public static TorqueUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -656,7 +656,7 @@ public static bool TryParseUnit(string str, out TorqueUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TorqueUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -995,7 +995,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1003,21 +1003,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 13530acaf2..8bd8b8616d 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -292,7 +292,7 @@ public static string GetAbbreviation(TorquePerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TorquePerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -556,7 +556,7 @@ public static TorquePerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TorquePerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -587,7 +587,7 @@ public static bool TryParse(string? str, out TorquePerLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TorquePerLength result) { return QuantityParser.Default.TryParse( @@ -615,7 +615,7 @@ public static TorquePerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -641,7 +641,7 @@ public static bool TryParseUnit(string str, out TorquePerLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TorquePerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -978,7 +978,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -986,21 +986,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 1af3f4e89c..8330b681a1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -175,7 +175,7 @@ public static string GetAbbreviation(TurbidityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TurbidityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -259,7 +259,7 @@ public static Turbidity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Turbidity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -290,7 +290,7 @@ public static bool TryParse(string? str, out Turbidity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Turbidity result) { return QuantityParser.Default.TryParse( @@ -318,7 +318,7 @@ public static TurbidityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -344,7 +344,7 @@ public static bool TryParseUnit(string str, out TurbidityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TurbidityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -641,7 +641,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -649,21 +649,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 6fc9609e17..0870735155 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -172,7 +172,7 @@ public static string GetAbbreviation(VitaminAUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VitaminAUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -256,7 +256,7 @@ public static VitaminA Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VitaminA Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -287,7 +287,7 @@ public static bool TryParse(string? str, out VitaminA result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VitaminA result) { return QuantityParser.Default.TryParse( @@ -315,7 +315,7 @@ public static VitaminAUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -341,7 +341,7 @@ public static bool TryParseUnit(string str, out VitaminAUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VitaminAUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -638,7 +638,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -646,21 +646,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 7062fca5e2..0e4dcf26b4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -472,7 +472,7 @@ public static string GetAbbreviation(VolumeUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1006,7 +1006,7 @@ public static Volume Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Volume Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1037,7 +1037,7 @@ public static bool TryParse(string? str, out Volume result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Volume result) { return QuantityParser.Default.TryParse( @@ -1065,7 +1065,7 @@ public static VolumeUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1091,7 +1091,7 @@ public static bool TryParseUnit(string str, out VolumeUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1488,7 +1488,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1496,21 +1496,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index df66989d05..bd18c9e62e 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -289,7 +289,7 @@ public static string GetAbbreviation(VolumeConcentrationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeConcentrationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -544,7 +544,7 @@ public static VolumeConcentration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumeConcentration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -575,7 +575,7 @@ public static bool TryParse(string? str, out VolumeConcentration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumeConcentration result) { return QuantityParser.Default.TryParse( @@ -603,7 +603,7 @@ public static VolumeConcentrationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -629,7 +629,7 @@ public static bool TryParseUnit(string str, out VolumeConcentrationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeConcentrationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -964,7 +964,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -972,21 +972,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index aa5193c9d2..745fc3c32b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -502,7 +502,7 @@ public static string GetAbbreviation(VolumeFlowUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeFlowUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1081,7 +1081,7 @@ public static VolumeFlow Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumeFlow Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1112,7 +1112,7 @@ public static bool TryParse(string? str, out VolumeFlow result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumeFlow result) { return QuantityParser.Default.TryParse( @@ -1140,7 +1140,7 @@ public static VolumeFlowUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1166,7 +1166,7 @@ public static bool TryParseUnit(string str, out VolumeFlowUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeFlowUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1573,7 +1573,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -1581,21 +1581,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index bd0dea99e9..226f76ddc9 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -208,7 +208,7 @@ public static string GetAbbreviation(VolumePerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumePerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -346,7 +346,7 @@ public static VolumePerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumePerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -377,7 +377,7 @@ public static bool TryParse(string? str, out VolumePerLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumePerLength result) { return QuantityParser.Default.TryParse( @@ -405,7 +405,7 @@ public static VolumePerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -431,7 +431,7 @@ public static bool TryParseUnit(string str, out VolumePerLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumePerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -740,7 +740,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -748,21 +748,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 19525dabe2..9b9a4b0271 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -223,7 +223,7 @@ public static string GetAbbreviation(VolumetricHeatCapacityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumetricHeatCapacityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -379,7 +379,7 @@ public static VolumetricHeatCapacity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumetricHeatCapacity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -410,7 +410,7 @@ public static bool TryParse(string? str, out VolumetricHeatCapacity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumetricHeatCapacity result) { return QuantityParser.Default.TryParse( @@ -438,7 +438,7 @@ public static VolumetricHeatCapacityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -464,7 +464,7 @@ public static bool TryParseUnit(string str, out VolumetricHeatCapacityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumetricHeatCapacityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -777,7 +777,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -785,21 +785,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 7ee0cac165..4e472711f3 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -202,7 +202,7 @@ public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -331,7 +331,7 @@ public static WarpingMomentOfInertia Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static WarpingMomentOfInertia Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -362,7 +362,7 @@ public static bool TryParse(string? str, out WarpingMomentOfInertia result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out WarpingMomentOfInertia result) { return QuantityParser.Default.TryParse( @@ -390,7 +390,7 @@ public static WarpingMomentOfInertiaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -416,7 +416,7 @@ public static bool TryParseUnit(string str, out WarpingMomentOfInertiaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out WarpingMomentOfInertiaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -723,7 +723,7 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); @@ -731,21 +731,21 @@ public string ToString(IFormatProvider? provider) /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 85d081c726..31c9c7581d 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -735,7 +735,7 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quanti /// /// Try to dynamically parse a quantity string representation. /// - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Type of quantity, such as . /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. /// The resulting quantity if successful, otherwise default. diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 6bf0a34182..41a39e2848 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -67,7 +67,7 @@ public interface IQuantity : IFormattable /// Gets the string representation of value and unit. Uses two significant digits after radix. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. string ToString(IFormatProvider? provider); } diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index 87de29d1fa..4cbcbe5aee 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -69,7 +69,7 @@ public class QuantityFormatter public static string Format(IQuantity quantity, string format) where TUnitType : Enum { - return Format(quantity, format, CultureInfo.CurrentUICulture); + return Format(quantity, format, CultureInfo.CurrentCulture); } /// @@ -79,7 +79,7 @@ public static string Format(IQuantity quantity, string for /// The quantity to format. /// The format string. /// The format provider to use for localization and number formatting. Defaults to - /// if null. + /// if null. /// /// The valid format strings are as follows: /// @@ -125,13 +125,14 @@ public static string Format(IQuantity quantity, string for public static string Format(IQuantity quantity, string format, IFormatProvider? formatProvider) where TUnitType : Enum { + formatProvider = formatProvider ?? CultureInfo.CurrentCulture; return FormatUntrimmed(quantity, format, formatProvider).TrimEnd(); } private static string FormatUntrimmed(IQuantity quantity, string format, IFormatProvider? formatProvider) where TUnitType : Enum { - formatProvider ??= CultureInfo.CurrentUICulture; + formatProvider ??= CultureInfo.CurrentCulture; if(string.IsNullOrWhiteSpace(format)) format = "g"; diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index a5cec6e144..e096b7db67 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -424,7 +424,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); - var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture!); + var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentCulture : new CultureInfo(culture!); var fromUnit = UnitParser.Default.Parse(fromUnitAbbrev, unitType!, cultureInfo); // ex: ("m", LengthUnit) => LengthUnit.Meter var fromQuantity = Quantity.From(fromValue, fromUnit); @@ -499,7 +499,7 @@ public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quan if (!TryGetUnitType(quantityName, out Type? unitType)) return false; - var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentUICulture : new CultureInfo(culture!); + var cultureInfo = string.IsNullOrWhiteSpace(culture) ? CultureInfo.CurrentCulture : new CultureInfo(culture!); if (!UnitParser.Default.TryParse(fromUnitAbbrev, unitType!, cultureInfo, out Enum? fromUnit)) // ex: ("m", LengthUnit) => LengthUnit.Meter return false; From a1069effa764bbfbe825e32e2ad8e65354293ab0 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:19:06 +0100 Subject: [PATCH 35/66] Upgrade samples - Upgrade WPF from .NET 4.7.1 to 4.8 - Upgrade console from netcoreapp2.1 to net6.0 - Rename WpfMVVMSample to MvvmSample.Wpf - Use VS2022 or latests prerelease of msbuild to build net6.0 target --- .../ConsoleApp-NetCore.csproj | 17 ---- Samples/ConsoleApp-NetCore/Program.cs | 14 ---- .../MvvmSample.Wpf.sln} | 2 +- .../MvvmSample.Wpf}/App.config | 0 .../MvvmSample.Wpf}/App.xaml | 0 .../MvvmSample.Wpf}/App.xaml.cs | 0 .../Converters/EnumBindingSource.cs | 0 .../Converters/UnitToStringConverter.cs | 0 .../MvvmSample.Wpf}/MainWindow.xaml | 0 .../MvvmSample.Wpf}/MainWindow.xaml.cs | 0 .../MvvmSample.Wpf}/MainWindowViewModel.cs | 0 .../MvvmSample.Wpf/MvvmSample.Wpf.csproj} | 4 +- .../Properties/AssemblyInfo.cs | 4 +- .../Properties/Resources.Designer.cs | 2 +- .../MvvmSample.Wpf}/Properties/Resources.resx | 0 .../Properties/Settings.Designer.cs | 0 .../Properties/Settings.settings | 0 .../Settings/SettingsManager.cs | 0 .../MvvmSample.Wpf}/packages.config | 0 .../Readme.md | 0 .../build.bat | 0 Samples/Samples.sln | 78 +++++-------------- Samples/UnitConverter.Console/Program.cs | 6 ++ .../UnitConverter.Console.csproj | 14 ++++ .../UnitConverter.Wpf.csproj | 2 +- Samples/WpfMVVMSample/build.bat | 12 --- Samples/build.bat | 14 +--- Samples/msbuild.cmd | 10 +++ 28 files changed, 57 insertions(+), 122 deletions(-) delete mode 100644 Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj delete mode 100644 Samples/ConsoleApp-NetCore/Program.cs rename Samples/{WpfMVVMSample/WpfMVVMSample.sln => MvvmSample.Wpf/MvvmSample.Wpf.sln} (86%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/App.config (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/App.xaml (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/App.xaml.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Converters/EnumBindingSource.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Converters/UnitToStringConverter.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/MainWindow.xaml (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/MainWindow.xaml.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/MainWindowViewModel.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample/WpfMVVMSample.csproj => MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj} (98%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Properties/AssemblyInfo.cs (96%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Properties/Resources.Designer.cs (95%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Properties/Resources.resx (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Properties/Settings.Designer.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Properties/Settings.settings (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/Settings/SettingsManager.cs (100%) rename Samples/{WpfMVVMSample/WpfMVVMSample => MvvmSample.Wpf/MvvmSample.Wpf}/packages.config (100%) rename Samples/{WpfMVVMSample => MvvmSample.Wpf}/Readme.md (100%) rename Samples/{ConsoleApp-NetCore => MvvmSample.Wpf}/build.bat (100%) create mode 100644 Samples/UnitConverter.Console/Program.cs create mode 100644 Samples/UnitConverter.Console/UnitConverter.Console.csproj delete mode 100644 Samples/WpfMVVMSample/build.bat create mode 100644 Samples/msbuild.cmd diff --git a/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj b/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj deleted file mode 100644 index 4c6194f3df..0000000000 --- a/Samples/ConsoleApp-NetCore/ConsoleApp-NetCore.csproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - netcoreapp2.1 - Exe - ConsoleApp1.Program - - - - - - - - - - - diff --git a/Samples/ConsoleApp-NetCore/Program.cs b/Samples/ConsoleApp-NetCore/Program.cs deleted file mode 100644 index 4d4141d683..0000000000 --- a/Samples/ConsoleApp-NetCore/Program.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using UnitsNet; - -namespace ConsoleApp1 -{ - public class Program - { - public static void Main(string[] args) - { - Console.WriteLine("Length: " + Length.FromMeters(1)); - Console.ReadKey(true); - } - } -} diff --git a/Samples/WpfMVVMSample/WpfMVVMSample.sln b/Samples/MvvmSample.Wpf/MvvmSample.Wpf.sln similarity index 86% rename from Samples/WpfMVVMSample/WpfMVVMSample.sln rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf.sln index f6924a3728..d609483970 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample.sln +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2010 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfMVVMSample", "WpfMVVMSample\WpfMVVMSample.csproj", "{B72F9215-70FF-4155-89BC-9A02CC550447}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmSample.Wpf", "MvvmSample.Wpf\MvvmSample.Wpf.csproj", "{B72F9215-70FF-4155-89BC-9A02CC550447}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/App.config b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.config similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/App.config rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.config diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/App.xaml b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/App.xaml rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/App.xaml.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/App.xaml.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/App.xaml.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Converters/EnumBindingSource.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/EnumBindingSource.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/Converters/EnumBindingSource.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/EnumBindingSource.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/Converters/UnitToStringConverter.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Converters/UnitToStringConverter.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/MainWindow.xaml b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/MainWindow.xaml rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/MainWindow.xaml.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/MainWindow.xaml.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindow.xaml.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/MainWindowViewModel.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/MainWindowViewModel.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/MainWindowViewModel.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/WpfMVVMSample.csproj b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj similarity index 98% rename from Samples/WpfMVVMSample/WpfMVVMSample/WpfMVVMSample.csproj rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj index 4a1e7de4c5..d5edab10a6 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample/WpfMVVMSample.csproj +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/MvvmSample.Wpf.csproj @@ -7,8 +7,8 @@ {B72F9215-70FF-4155-89BC-9A02CC550447} WinExe WpfMVVMSample - WpfMVVMSample - v4.7.1 + MvvmSample.Wpf + v4.8 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/AssemblyInfo.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/AssemblyInfo.cs similarity index 96% rename from Samples/WpfMVVMSample/WpfMVVMSample/Properties/AssemblyInfo.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/AssemblyInfo.cs index 814762f31f..61146f9a9c 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/AssemblyInfo.cs +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/AssemblyInfo.cs @@ -7,11 +7,11 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -[assembly: AssemblyTitle("WpfMVVMSample")] +[assembly: AssemblyTitle("MvvmSample.Wpf")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("WpfMVVMSample")] +[assembly: AssemblyProduct("MvvmSample.Wpf")] [assembly: AssemblyCopyright("Copyright © 2017")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/Resources.Designer.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Resources.Designer.cs similarity index 95% rename from Samples/WpfMVVMSample/WpfMVVMSample/Properties/Resources.Designer.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Resources.Designer.cs index 08f38a53e5..b95ae2d722 100644 --- a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/Resources.Designer.cs +++ b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Resources.Designer.cs @@ -39,7 +39,7 @@ internal Resources() { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WpfMVVMSample.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("MvvmSample.Wpf.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/Resources.resx b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Resources.resx similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/Properties/Resources.resx rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Resources.resx diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/Settings.Designer.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Settings.Designer.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/Properties/Settings.Designer.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Settings.Designer.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Properties/Settings.settings b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Settings.settings similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/Properties/Settings.settings rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Properties/Settings.settings diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/Settings/SettingsManager.cs b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/Settings/SettingsManager.cs similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/Settings/SettingsManager.cs rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/Settings/SettingsManager.cs diff --git a/Samples/WpfMVVMSample/WpfMVVMSample/packages.config b/Samples/MvvmSample.Wpf/MvvmSample.Wpf/packages.config similarity index 100% rename from Samples/WpfMVVMSample/WpfMVVMSample/packages.config rename to Samples/MvvmSample.Wpf/MvvmSample.Wpf/packages.config diff --git a/Samples/WpfMVVMSample/Readme.md b/Samples/MvvmSample.Wpf/Readme.md similarity index 100% rename from Samples/WpfMVVMSample/Readme.md rename to Samples/MvvmSample.Wpf/Readme.md diff --git a/Samples/ConsoleApp-NetCore/build.bat b/Samples/MvvmSample.Wpf/build.bat similarity index 100% rename from Samples/ConsoleApp-NetCore/build.bat rename to Samples/MvvmSample.Wpf/build.bat diff --git a/Samples/Samples.sln b/Samples/Samples.sln index e125d7998a..2101631750 100644 --- a/Samples/Samples.sln +++ b/Samples/Samples.sln @@ -3,15 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 15 VisualStudioVersion = 15.0.27130.2020 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleApp-NetCore", "ConsoleApp-NetCore\ConsoleApp-NetCore.csproj", "{955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitConverter.Wpf", "UnitConverter.Wpf\UnitConverter.Wpf\UnitConverter.Wpf.csproj", "{D04EE35D-496A-4C83-A369-09B9B2BEAEEC}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfMVVMSample", "WpfMVVMSample\WpfMVVMSample\WpfMVVMSample.csproj", "{B72F9215-70FF-4155-89BC-9A02CC550447}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleConversionDemo.UWP.CSharp", "SimpleConversionDemo.UWP.CSharp\SimpleConversionDemo.UWP.CSharp.csproj", "{76255CC9-A854-441F-AF5C-2606509D3C5E}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MvvmSample.Wpf", "MvvmSample.Wpf\MvvmSample.Wpf\MvvmSample.Wpf.csproj", "{B72F9215-70FF-4155-89BC-9A02CC550447}" EndProject -Project("{262852C6-CD72-467D-83FE-5EEB1973A190}") = "SimpleConversionDemo.UWP.WinJS", "SimpleConversionDemo.UWP.WinJS\SimpleConversionDemo.UWP.WinJS.jsproj", "{F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitConverter.Console", "UnitConverter.Console\UnitConverter.Console.csproj", "{B3141011-CEF2-46DE-B3DD-7FECD0D6108C}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -25,20 +21,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|ARM.ActiveCfg = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x64.ActiveCfg = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x64.Build.0 = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x86.ActiveCfg = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Debug|x86.Build.0 = Debug|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|Any CPU.Build.0 = Release|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|ARM.ActiveCfg = Release|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x64.ActiveCfg = Release|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x64.Build.0 = Release|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x86.ActiveCfg = Release|Any CPU - {955A6CBF-C4E3-4C55-85C8-613E2CA4CCD7}.Release|x86.Build.0 = Release|Any CPU {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|Any CPU.Build.0 = Debug|Any CPU {D04EE35D-496A-4C83-A369-09B9B2BEAEEC}.Debug|ARM.ActiveCfg = Debug|Any CPU @@ -67,46 +49,22 @@ Global {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x64.Build.0 = Release|Any CPU {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x86.ActiveCfg = Release|Any CPU {B72F9215-70FF-4155-89BC-9A02CC550447}.Release|x86.Build.0 = Release|Any CPU - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|Any CPU.ActiveCfg = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|Any CPU.Build.0 = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|Any CPU.Deploy.0 = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.ActiveCfg = Debug|ARM - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.Build.0 = Debug|ARM - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|ARM.Deploy.0 = Debug|ARM - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x64.ActiveCfg = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.ActiveCfg = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.Build.0 = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Debug|x86.Deploy.0 = Debug|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|Any CPU.ActiveCfg = Release|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|Any CPU.Build.0 = Release|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|Any CPU.Deploy.0 = Release|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.ActiveCfg = Release|ARM - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.Build.0 = Release|ARM - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|ARM.Deploy.0 = Release|ARM - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x64.ActiveCfg = Release|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.ActiveCfg = Release|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.Build.0 = Release|x86 - {76255CC9-A854-441F-AF5C-2606509D3C5E}.Release|x86.Deploy.0 = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|Any CPU.ActiveCfg = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|Any CPU.Build.0 = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|Any CPU.Deploy.0 = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.ActiveCfg = Debug|ARM - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.Build.0 = Debug|ARM - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|ARM.Deploy.0 = Debug|ARM - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x64.ActiveCfg = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.ActiveCfg = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.Build.0 = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Debug|x86.Deploy.0 = Debug|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|Any CPU.ActiveCfg = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|Any CPU.Build.0 = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|Any CPU.Deploy.0 = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.ActiveCfg = Release|ARM - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.Build.0 = Release|ARM - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|ARM.Deploy.0 = Release|ARM - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x64.ActiveCfg = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.ActiveCfg = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.Build.0 = Release|x86 - {F5B26152-A64B-42A8-8F19-D2EAFB94CBD1}.Release|x86.Deploy.0 = Release|x86 + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|ARM.ActiveCfg = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|ARM.Build.0 = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|x64.ActiveCfg = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|x64.Build.0 = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|x86.ActiveCfg = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Debug|x86.Build.0 = Debug|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|Any CPU.Build.0 = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|ARM.ActiveCfg = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|ARM.Build.0 = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|x64.ActiveCfg = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|x64.Build.0 = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|x86.ActiveCfg = Release|Any CPU + {B3141011-CEF2-46DE-B3DD-7FECD0D6108C}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Samples/UnitConverter.Console/Program.cs b/Samples/UnitConverter.Console/Program.cs new file mode 100644 index 0000000000..7ba55aef09 --- /dev/null +++ b/Samples/UnitConverter.Console/Program.cs @@ -0,0 +1,6 @@ +using UnitsNet; +using static System.Console; +using static UnitsNet.Units.LengthUnit; + +WriteLine(Length.FromMeters(1).ToUnit(Centimeter)); // 100 cm +WriteLine(Length.Parse("100 cm").ToUnit(Meter)); // 1 m diff --git a/Samples/UnitConverter.Console/UnitConverter.Console.csproj b/Samples/UnitConverter.Console/UnitConverter.Console.csproj new file mode 100644 index 0000000000..82db681c45 --- /dev/null +++ b/Samples/UnitConverter.Console/UnitConverter.Console.csproj @@ -0,0 +1,14 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + diff --git a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj index 84df691425..29262603d0 100644 --- a/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj +++ b/Samples/UnitConverter.Wpf/UnitConverter.Wpf/UnitConverter.Wpf.csproj @@ -8,7 +8,7 @@ WinExe UnitsNet.Samples.UnitConverter.Wpf UnitConverter.Wpf - v4.7.1 + v4.8 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 diff --git a/Samples/WpfMVVMSample/build.bat b/Samples/WpfMVVMSample/build.bat deleted file mode 100644 index 266afed369..0000000000 --- a/Samples/WpfMVVMSample/build.bat +++ /dev/null @@ -1,12 +0,0 @@ -@echo off - -set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" - -for /f "usebackq tokens=*" %%i in (`%vswhere% -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do ( - set InstallDir=%%i -) - -if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" ( - "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" /t:restore %* - "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" %* -) \ No newline at end of file diff --git a/Samples/build.bat b/Samples/build.bat index e18b95c1fd..7b24eaf4ac 100644 --- a/Samples/build.bat +++ b/Samples/build.bat @@ -1,13 +1,3 @@ @echo off - -set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" - -for /f "usebackq tokens=*" %%i in (`%vswhere% -latest -products * -requires Microsoft.Component.MSBuild -property installationPath`) do ( - set InstallDir=%%i -) - -echo %vswhere% - -if exist "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" ( - "%InstallDir%\MSBuild\15.0\Bin\MSBuild.exe" -verbosity:minimal %* -) \ No newline at end of file +setlocal enabledelayedexpansion +msbuild . \ No newline at end of file diff --git a/Samples/msbuild.cmd b/Samples/msbuild.cmd new file mode 100644 index 0000000000..bc17df2242 --- /dev/null +++ b/Samples/msbuild.cmd @@ -0,0 +1,10 @@ +@echo off +setlocal enabledelayedexpansion + +set vswhere="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" + +for /f "usebackq tokens=*" %%i in (`%vswhere% -latest -prerelease -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do ( + echo "%%i" + "%%i" %* + exit /b !errorlevel! +) \ No newline at end of file From 17db45fea4be0ee2439b2e058b2f3ac08d344cde Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:37:47 +0100 Subject: [PATCH 36/66] appveyor: Use VS2022 image to support net6.0 --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7793c940b9..7377b6425d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ version: '{build}' -image: Visual Studio 2019 +image: Visual Studio 2022 # Don't build PR commits twice skip_branch_with_pr: true From 40893db91f843caa7364dc5eae802eae0a3d59dd Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:38:14 +0100 Subject: [PATCH 37/66] appveyor: skip_branch_with_pr: false The release branch does not get built, probably because of open draft PR. --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 7377b6425d..fef8b093d1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ version: '{build}' image: Visual Studio 2022 # Don't build PR commits twice -skip_branch_with_pr: true +skip_branch_with_pr: false # Don't build tags, avoid duplicate builds on master when bumping version skip_tags: true From ad2ebba9ee3342563d1171f81052686fe8d33a45 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:39:07 +0100 Subject: [PATCH 38/66] UnitsNet: 5.0.0-alpha003 --- CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.AmountOfSubstance.nuspec | 2 +- .../AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- .../ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- .../ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec | 2 +- .../UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- .../UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec | 2 +- .../GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec | 2 +- .../Duration/UnitsNet.NanoFramework.Duration.nuspec | 2 +- .../UnitsNet.NanoFramework.DynamicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricAdmittance.nuspec | 2 +- .../ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec | 2 +- .../ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricInductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotential.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialAc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialDc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- .../UnitsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- .../ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../Frequency/UnitsNet.NanoFramework.Frequency.nuspec | 2 +- .../FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec | 2 +- .../Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../Information/UnitsNet.NanoFramework.Information.nuspec | 2 +- .../Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- .../UnitsNet.NanoFramework.KinematicViscosity.nuspec | 2 +- .../LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec | 2 +- .../GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- .../LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- .../LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.LuminousIntensity.nuspec | 2 +- .../MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec | 2 +- .../MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- .../Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- .../UnitsNet.NanoFramework.MassConcentration.nuspec | 2 +- .../MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- .../MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- .../UnitsNet.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- .../MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../Molarity/UnitsNet.NanoFramework.Molarity.nuspec | 2 +- .../Permeability/UnitsNet.NanoFramework.Permeability.nuspec | 2 +- .../Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- .../PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../Pressure/UnitsNet.NanoFramework.Pressure.nuspec | 2 +- .../UnitsNet.NanoFramework.PressureChangeRate.nuspec | 2 +- .../GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- .../UnitsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- .../ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- .../ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec | 2 +- .../ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalLength.nuspec | 2 +- .../UnitsNet.NanoFramework.RelativeHumidity.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalAcceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffness.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec | 2 +- .../GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- .../SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec | 2 +- .../SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec | 2 +- .../SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- .../UnitsNet.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../Temperature/UnitsNet.NanoFramework.Temperature.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureDelta.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalResistance.nuspec | 2 +- .../GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec | 2 +- .../UnitsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeConcentration.nuspec | 2 +- .../VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec | 2 +- .../UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 2 +- UnitsNet/UnitsNet.csproj | 2 +- 113 files changed, 113 insertions(+), 113 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index 0b7ea34bf8..9a145ee43d 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index f7d9253ef2..0b9835ac14 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Acceleration - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index ac1027660d..e6f55f13ab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmountOfSubstance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index de366d669c..ddbef2bea3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmplitudeRatio - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index 87d9d7236a..ed309a08e4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Angle - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 96c4e8d824..a033aa0bc1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentEnergy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index 64b10a0de0..bdfe75a286 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentPower - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index e3774bbcc0..f899403a86 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Area - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index 4525af0acc..acde105e35 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index ac462ca796..ded4243f57 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index ff6f61b38a..dc1135b045 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BitRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 092101b916..78d24276ed 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index fe261ba3a2..1a32797d44 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Capacitance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index 4b1539a2da..c898ec5d9a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index dfc4ae0be6..42000362ae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Density - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index b8d90fb8c4..47e2d4b40c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Duration - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 7d9020b066..87f25887ce 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.DynamicViscosity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index a77755412a..03e7ad3290 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricAdmittance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index 4fc686b1a7..b5dfc4f4e9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCharge - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index f5b19585c1..c0d62746fc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index df04c0360f..3e7cd89e67 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index 08a06f2bca..eed284504d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductivity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index f6c45307f9..77f4544b62 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrent - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index b99bb79cba..8837c5003f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index e07c02d152..dbbd150c11 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index 4903591df1..5f28dfb95a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricField - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index d96e1953fe..948e2e0ef6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricInductance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index e3bd87dda4..9bb7728c83 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotential - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index bdc19790a8..35389cd8db 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 55ea98f760..38747159b6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index 9fea934fbb..dfe017ffaf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 334f71cfff..a5d9db22c3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index d5f3428e1d..e057577492 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistivity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index 3f8c7473b1..e607563132 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index b3fe684942..06cd6bb28f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Energy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 53f519a2f5..9db45d1069 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Entropy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index 73b710870c..edd9a3a462 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Force - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index 050748b012..b588e6de2c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForceChangeRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index f7b775ea56..b295121900 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForcePerLength - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index f3aa921395..6fda5475ae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Frequency - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index 6a578fc12c..1093232877 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.FuelEfficiency - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index 41fbbef660..2dfd4e9458 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatFlux - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index 933a5c923d..d78e5fba45 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index a17b3a41c7..2e82948d0b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Illuminance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index 2324273f05..ab46f059b1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Information - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index 775239f2b0..485ad55410 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index 639acd2797..771c93435d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiation - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index f7b58e78d6..4af2b0296a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.KinematicViscosity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index 4a3fbd1920..0410e079d5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LapseRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index 70d30cf6d5..2c6e6f10f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Length - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index d3ca70f6c0..d60e33ff6c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Level - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index 46f149720d..76c24de746 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index 284fb0829a..113ce7d4da 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearPowerDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index c360fa7028..e06ac1b85e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Luminosity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index fd607134ef..8aeabdc864 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousFlux - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index 653cf06117..7650c77e07 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousIntensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index 23bc5d972f..3221eefd8e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticField - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 11194e3f37..c48a53fd9d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticFlux - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index 61bed4419a..925969d978 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Magnetization - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index e12e10e53a..3e181e08ab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Mass - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index 156fff358e..a63d0dcaf8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassConcentration - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 2f430d5a08..854ed4d095 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlow - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index ee305b5f48..f3215d573b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlux - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 07888a431a..a244cfcfbc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFraction - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index a6ff1c4898..002f744311 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index fee894aefe..a0793057d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEnergy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index 09ab812a1c..6ef93fa055 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEntropy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index f51f24bfb9..185c225cd1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarMass - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 7d6e1f465c..90105db26b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Molarity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 03272579cd..c06b557a93 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permeability - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index b00e46ccb9..309e9d42ef 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permittivity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index 7c57f73c7c..ccadfa2044 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Power - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 868db4af8d..23c938ddab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerDensity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index 5e62215e22..18a7d3fbb9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerRatio - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index c80f938546..245541ddf4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Pressure - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index 6bfcd7ef01..d768538458 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PressureChangeRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index bc0ccb4f77..6c4b20b5e9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Ratio - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index db90c9b009..b40933a6c2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RatioChangeRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index 1bf772170c..ad46b7b1f0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactiveEnergy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 3c0ff8b71f..4eb803531a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactivePower - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index f8dc39ce17..1290ce7df4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalArea - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 6f49048d04..e886a67dd3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalLength - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index e2aa4fad35..d5a7d116eb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RelativeHumidity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index 229ab64dc7..c17f3a5aab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalAcceleration - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index 1ed95ee7b9..8a1bc126f4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalSpeed - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 3d3f8b56df..7e6f09861e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffness - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index 4a09b0279a..9769c9b93c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index 654e5a9812..9f2896e6b7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Scalar - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 45801bf390..001eb8ed44 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SolidAngle - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 7156966615..2dcf9d548e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEnergy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index 187c4b7548..49c2e0e323 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEntropy - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 65b8033832..d5dcc278cc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index c3a68b4ddc..42f8fdbcd1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificVolume - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 849e120343..4cfbcfeb5b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificWeight - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index 9c90bb3205..ef2db2ee9d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Speed - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 4b9e9f2758..10092b6e10 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index 50dada662f..870f5b206f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Temperature - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 2e02c4253b..4a342fd5d5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 366756a5b0..58f63f369a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureDelta - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index 17c757848b..6d1b194e63 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalConductivity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index df4d033caa..b9fc4a2c1c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalResistance - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 55a929536a..9d9ea70a28 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Torque - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index 17ad374feb..321faabafe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TorquePerLength - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 721033aa27..41c4b8beaf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Turbidity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index d9f2ce15a5..9c911082c5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VitaminA - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index 91356993c0..f90f43a0df 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Volume - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index 554478a88a..cf43fbdd1f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeConcentration - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index 865fbdeed9..fba8c8c6d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlow - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index c7b2f59a03..70dafffb56 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumePerLength - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 86fcc2acae..0a6ca1ba1f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 95347ffed1..0008c32898 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 5.0.0-alpha002 + 5.0.0-alpha003 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index bd98669f40..d540ab0efb 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -2,7 +2,7 @@ UnitsNet.NumberExtensions - 5.0.0-alpha002 + 5.0.0-alpha003 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index dcca56e4c4..c6dd1f26d2 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -2,7 +2,7 @@ UnitsNet - 5.0.0-alpha002 + 5.0.0-alpha003 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. From b17494ae82b22c97385d2e790a2de4eb29ad6334 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:49:55 +0100 Subject: [PATCH 39/66] Upgrade nugets --- CodeGen/CodeGen.csproj | 4 ++-- UnitsNet.Benchmark/UnitsNet.Benchmark.csproj | 4 ++-- .../UnitsNet.NumberExtensions.Tests.csproj | 7 +++++-- ...tsNet.Serialization.JsonNet.CompatibilityTests.csproj | 9 ++++++--- .../UnitsNet.Serialization.JsonNet.Tests.csproj | 7 +++++-- .../UnitsNet.Serialization.JsonNet.csproj | 4 ++-- UnitsNet.Tests/UnitsNet.Tests.csproj | 9 ++++++--- UnitsNet/UnitsNet.csproj | 2 +- 8 files changed, 29 insertions(+), 17 deletions(-) diff --git a/CodeGen/CodeGen.csproj b/CodeGen/CodeGen.csproj index 56fbbe39b8..728ec19e25 100644 --- a/CodeGen/CodeGen.csproj +++ b/CodeGen/CodeGen.csproj @@ -11,9 +11,9 @@ - + - + diff --git a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj index aeb489e9f0..c162a553db 100644 --- a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj +++ b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj @@ -10,8 +10,8 @@ - - + + all diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index 721e0d145f..9bf36ee5d1 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -24,9 +24,12 @@ - + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj index a04b39be97..e870fab409 100644 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj @@ -15,10 +15,13 @@ - - + + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj index 7d4d55d5fc..8454bed3f0 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj @@ -14,9 +14,12 @@ - + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 18cf4add59..3e062331f1 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -43,8 +43,8 @@ - - + + diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index 2b22e5ffa1..84b34f1a63 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -23,10 +23,13 @@ - - + + - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index c6dd1f26d2..29efb2b7ae 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -44,7 +44,7 @@ - + From 3ea84eedf04086dc2bf6d29cb97b82a0fc533b5f Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:50:34 +0100 Subject: [PATCH 40/66] benchmark: Add net6.0, remove netcore2.1, 3.1 and net4.7.2 --- UnitsNet.Benchmark/UnitsNet.Benchmark.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj index c162a553db..e8c458bfcf 100644 --- a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj +++ b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj @@ -1,7 +1,7 @@  Exe - net5.0;netcoreapp3.1;netcoreapp2.1;net48;net472 + net6.0;net5.0;net48 4.0.0.0 4.0.0.0 UnitsNet.Benchmark From d96bec6ecc1c6e23086eb5c46c1ca57b5ba86dc1 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sat, 13 Nov 2021 23:50:41 +0100 Subject: [PATCH 41/66] Fix nullable warnings --- .../UnitsNetBaseJsonConverter.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index 86c7cefc8e..2e804182c7 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -71,7 +71,10 @@ public void RegisterCustomType(Type quantity, Type unit) return null; } - return new ValueUnit {Unit = unit.Value(), Value = value.Value()}; + return new ValueUnit { + Unit = unit.Value() ?? throw new InvalidOperationException("Unit was not a string."), + Value = value.Value() + }; } if (valueType.Type != JTokenType.String) @@ -81,7 +84,7 @@ public void RegisterCustomType(Type quantity, Type unit) return new ExtendedValueUnit { - Unit = unit.Value(), + Unit = unit.Value() ?? throw new InvalidOperationException("Unit was not a string."), Value = value.Value(), ValueType = valueType.Value(), ValueString = valueString?.Value() From 721287dfab1539bb4abb2a5821e549b007badb79 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 14 Nov 2021 00:04:23 +0100 Subject: [PATCH 42/66] Remove "s" and "v" string formats Fixes #797 --- UnitsNet.Tests/QuantityIFormattableTests.cs | 19 ---------------- UnitsNet.Tests/QuantityTypeConverterTest.cs | 12 +++++------ UnitsNet/QuantityFormatter.cs | 24 ++++----------------- 3 files changed, 10 insertions(+), 45 deletions(-) diff --git a/UnitsNet.Tests/QuantityIFormattableTests.cs b/UnitsNet.Tests/QuantityIFormattableTests.cs index 18e670e644..e6ebbfcad0 100644 --- a/UnitsNet.Tests/QuantityIFormattableTests.cs +++ b/UnitsNet.Tests/QuantityIFormattableTests.cs @@ -40,31 +40,12 @@ public void AFormatWithInvalidIndexThrowsFormatException() Assert.Throws(() => length.ToString("a100")); } - [Fact] - public void VFormatEqualsValueToString() - { - Assert.Equal(length.Value.ToString(CultureInfo.CurrentCulture), length.ToString("v")); - } - [Fact] public void QFormatEqualsQuantityName() { Assert.Equal(Length.Info.Name, length.ToString("q")); } - [Theory] - [InlineData("s", "1 ft")] - [InlineData("s1", "1.2 ft")] - [InlineData("s2", "1.23 ft")] - [InlineData("s3", "1.235 ft")] - [InlineData("s4", "1.2346 ft")] - [InlineData("s5", "1.23457 ft")] - [InlineData("s6", "1.234568 ft")] - public void SFormatEqualsSignificantDigits(string sFormatString, string expected) - { - Assert.Equal(expected, length.ToString(sFormatString, NumberFormatInfo.InvariantInfo)); - } - [Fact] public void UFormatEqualsUnitToString() { diff --git a/UnitsNet.Tests/QuantityTypeConverterTest.cs b/UnitsNet.Tests/QuantityTypeConverterTest.cs index 60b2d32762..96f8782148 100644 --- a/UnitsNet.Tests/QuantityTypeConverterTest.cs +++ b/UnitsNet.Tests/QuantityTypeConverterTest.cs @@ -203,33 +203,33 @@ public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUn } [Fact] - public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUnitFormatAsValueOnly() + public void ConvertTo_TestDisplayAsFormatting_ReturnsQuantityStringWithDisplayUnitFormat() { var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { - new DisplayAsUnitAttribute(Units.LengthUnit.Decimeter, "v") + new DisplayAsUnitAttribute(Units.LengthUnit.Decimeter, "f2") }); Length length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); - Assert.Equal("10", convertedQuantity); + Assert.Equal("10.00 dm", convertedQuantity); } [Fact] - public void ConvertTo_TestDisplayAsFormattingWithoutDefinedUnit_ReturnsQuantityStringWithQuantityUnitAndFormattedAsValueOnly() + public void ConvertTo_TestDisplayAsFormattingWithoutDefinedUnit_ReturnsQuantityStringWithNumericFormat() { var converter = new QuantityTypeConverter(); ITypeDescriptorContext context = new TypeDescriptorContext("SomeMemberName", new Attribute[] { - new DisplayAsUnitAttribute(null, "v") + new DisplayAsUnitAttribute(null, "f2") }); Length length = Length.FromMeters(1); string convertedQuantity = (string)converter.ConvertTo(context, Culture, length, typeof(string)); - Assert.Equal("1", convertedQuantity); + Assert.Equal("1.00 m", convertedQuantity); } [Fact] diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index 4cbcbe5aee..154d5660bc 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -29,8 +29,9 @@ public class QuantityFormatter /// /// /// A standard numeric format string. - /// Any of the standard numeric format for except for "G" or "g". + /// Any of the standard numeric format for , except for "G" or "g", which have a special implementation. /// "C" or "c", "E" or "e", "F" or "f", "N" or "n", "P" or "p", "R" or "r" are all accepted. + /// See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#standard-format-specifiers. /// /// /// @@ -47,10 +48,6 @@ public class QuantityFormatter /// A will be thrown if the requested abbreviation index does not exist. /// /// - /// "V" or "v". - /// The string representation of using the default ToString method. - /// - /// /// "U" or "u". /// The enum name of , such as "Meter". /// @@ -58,11 +55,6 @@ public class QuantityFormatter /// "Q" or "q". /// The quantity name, such as "Length". /// - /// - /// "S1", "S2", ..., "Sn" or "s1", "s2", ..., "sn". - /// The value with n significant digits after the radix followed by the unit abbreviation. For example, - /// "s4" would return "1.2345 m" if is 1.2345678. Trailing zeros are omitted. - /// /// /// /// The string representation. @@ -85,8 +77,9 @@ public static string Format(IQuantity quantity, string for /// /// /// A standard numeric format string. - /// Any of the standard numeric format for except for "G" or "g". + /// Any of the standard numeric format for , except for "G" or "g", which have a special implementation. /// "C" or "c", "E" or "e", "F" or "f", "N" or "n", "P" or "p", "R" or "r" are all accepted. + /// See https://docs.microsoft.com/en-us/dotnet/standard/base-types/standard-numeric-format-strings#standard-format-specifiers. /// /// /// @@ -103,10 +96,6 @@ public static string Format(IQuantity quantity, string for /// A will be thrown if the requested abbreviation index does not exist. /// /// - /// "V" or "v". - /// The string representation of using the default ToString method. - /// - /// /// "U" or "u". /// The enum name of , such as "Meter". /// @@ -114,11 +103,6 @@ public static string Format(IQuantity quantity, string for /// "Q" or "q". /// The quantity name, such as "Length". /// - /// - /// "S1", "S2", ..., "Sn" or "s1", "s2", ..., "sn". - /// The value with n significant digits after the radix followed by the unit abbreviation. For example, - /// "s4" would return "1.2345 m" if is 1.2345678. Trailing zeros are omitted. - /// /// /// /// The string representation. From 58650693d7348e9e91b8e5c054c54460d445df36 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 14 Nov 2021 00:18:06 +0100 Subject: [PATCH 43/66] Remove Undefined unit value Fixes #983 --- .../NanoFrameworkGen/UnitTypeGenerator.cs | 5 +---- .../Generators/UnitsNetGen/QuantityGenerator.cs | 8 ++------ .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 17 +---------------- .../Generators/UnitsNetGen/UnitTypeGenerator.cs | 4 +--- .../GeneratedCode/Units/AccelerationUnit.g.cs | 1 - .../Units/AmountOfSubstanceUnit.g.cs | 1 - .../GeneratedCode/Units/AmplitudeRatioUnit.g.cs | 1 - .../GeneratedCode/Units/AngleUnit.g.cs | 1 - .../GeneratedCode/Units/ApparentEnergyUnit.g.cs | 1 - .../GeneratedCode/Units/ApparentPowerUnit.g.cs | 1 - .../GeneratedCode/Units/AreaDensityUnit.g.cs | 1 - .../Units/AreaMomentOfInertiaUnit.g.cs | 1 - .../GeneratedCode/Units/AreaUnit.g.cs | 1 - .../GeneratedCode/Units/BitRateUnit.g.cs | 1 - .../Units/BrakeSpecificFuelConsumptionUnit.g.cs | 1 - .../GeneratedCode/Units/CapacitanceUnit.g.cs | 1 - .../CoefficientOfThermalExpansionUnit.g.cs | 1 - .../GeneratedCode/Units/DensityUnit.g.cs | 1 - .../GeneratedCode/Units/DurationUnit.g.cs | 1 - .../Units/DynamicViscosityUnit.g.cs | 1 - .../Units/ElectricAdmittanceUnit.g.cs | 1 - .../Units/ElectricChargeDensityUnit.g.cs | 1 - .../GeneratedCode/Units/ElectricChargeUnit.g.cs | 1 - .../Units/ElectricConductanceUnit.g.cs | 1 - .../Units/ElectricConductivityUnit.g.cs | 1 - .../Units/ElectricCurrentDensityUnit.g.cs | 1 - .../Units/ElectricCurrentGradientUnit.g.cs | 1 - .../Units/ElectricCurrentUnit.g.cs | 1 - .../GeneratedCode/Units/ElectricFieldUnit.g.cs | 1 - .../Units/ElectricInductanceUnit.g.cs | 1 - .../Units/ElectricPotentialAcUnit.g.cs | 1 - .../Units/ElectricPotentialChangeRateUnit.g.cs | 1 - .../Units/ElectricPotentialDcUnit.g.cs | 1 - .../Units/ElectricPotentialUnit.g.cs | 1 - .../Units/ElectricResistanceUnit.g.cs | 1 - .../Units/ElectricResistivityUnit.g.cs | 1 - .../Units/ElectricSurfaceChargeDensityUnit.g.cs | 1 - .../GeneratedCode/Units/EnergyUnit.g.cs | 1 - .../GeneratedCode/Units/EntropyUnit.g.cs | 1 - .../Units/ForceChangeRateUnit.g.cs | 1 - .../GeneratedCode/Units/ForcePerLengthUnit.g.cs | 1 - .../GeneratedCode/Units/ForceUnit.g.cs | 1 - .../GeneratedCode/Units/FrequencyUnit.g.cs | 1 - .../GeneratedCode/Units/FuelEfficiencyUnit.g.cs | 1 - .../GeneratedCode/Units/HeatFluxUnit.g.cs | 1 - .../Units/HeatTransferCoefficientUnit.g.cs | 1 - .../GeneratedCode/Units/IlluminanceUnit.g.cs | 1 - .../GeneratedCode/Units/InformationUnit.g.cs | 1 - .../GeneratedCode/Units/IrradianceUnit.g.cs | 1 - .../GeneratedCode/Units/IrradiationUnit.g.cs | 1 - .../Units/KinematicViscosityUnit.g.cs | 1 - .../GeneratedCode/Units/LapseRateUnit.g.cs | 1 - .../GeneratedCode/Units/LengthUnit.g.cs | 1 - .../GeneratedCode/Units/LevelUnit.g.cs | 1 - .../GeneratedCode/Units/LinearDensityUnit.g.cs | 1 - .../Units/LinearPowerDensityUnit.g.cs | 1 - .../GeneratedCode/Units/LuminosityUnit.g.cs | 1 - .../GeneratedCode/Units/LuminousFluxUnit.g.cs | 1 - .../Units/LuminousIntensityUnit.g.cs | 1 - .../GeneratedCode/Units/MagneticFieldUnit.g.cs | 1 - .../GeneratedCode/Units/MagneticFluxUnit.g.cs | 1 - .../GeneratedCode/Units/MagnetizationUnit.g.cs | 1 - .../Units/MassConcentrationUnit.g.cs | 1 - .../GeneratedCode/Units/MassFlowUnit.g.cs | 1 - .../GeneratedCode/Units/MassFluxUnit.g.cs | 1 - .../GeneratedCode/Units/MassFractionUnit.g.cs | 1 - .../Units/MassMomentOfInertiaUnit.g.cs | 1 - .../GeneratedCode/Units/MassUnit.g.cs | 1 - .../GeneratedCode/Units/MolarEnergyUnit.g.cs | 1 - .../GeneratedCode/Units/MolarEntropyUnit.g.cs | 1 - .../GeneratedCode/Units/MolarMassUnit.g.cs | 1 - .../GeneratedCode/Units/MolarityUnit.g.cs | 1 - .../GeneratedCode/Units/PermeabilityUnit.g.cs | 1 - .../GeneratedCode/Units/PermittivityUnit.g.cs | 1 - .../GeneratedCode/Units/PowerDensityUnit.g.cs | 1 - .../GeneratedCode/Units/PowerRatioUnit.g.cs | 1 - .../GeneratedCode/Units/PowerUnit.g.cs | 1 - .../Units/PressureChangeRateUnit.g.cs | 1 - .../GeneratedCode/Units/PressureUnit.g.cs | 1 - .../Units/RatioChangeRateUnit.g.cs | 1 - .../GeneratedCode/Units/RatioUnit.g.cs | 1 - .../GeneratedCode/Units/ReactiveEnergyUnit.g.cs | 1 - .../GeneratedCode/Units/ReactivePowerUnit.g.cs | 1 - .../GeneratedCode/Units/ReciprocalAreaUnit.g.cs | 1 - .../Units/ReciprocalLengthUnit.g.cs | 1 - .../Units/RelativeHumidityUnit.g.cs | 1 - .../Units/RotationalAccelerationUnit.g.cs | 1 - .../Units/RotationalSpeedUnit.g.cs | 1 - .../Units/RotationalStiffnessPerLengthUnit.g.cs | 1 - .../Units/RotationalStiffnessUnit.g.cs | 1 - .../GeneratedCode/Units/ScalarUnit.g.cs | 1 - .../GeneratedCode/Units/SolidAngleUnit.g.cs | 1 - .../GeneratedCode/Units/SpecificEnergyUnit.g.cs | 1 - .../Units/SpecificEntropyUnit.g.cs | 1 - .../Units/SpecificFuelConsumptionUnit.g.cs | 1 - .../GeneratedCode/Units/SpecificVolumeUnit.g.cs | 1 - .../GeneratedCode/Units/SpecificWeightUnit.g.cs | 1 - .../GeneratedCode/Units/SpeedUnit.g.cs | 1 - .../Units/StandardVolumeFlowUnit.g.cs | 1 - .../Units/TemperatureChangeRateUnit.g.cs | 1 - .../Units/TemperatureDeltaUnit.g.cs | 1 - .../GeneratedCode/Units/TemperatureUnit.g.cs | 1 - .../Units/ThermalConductivityUnit.g.cs | 1 - .../Units/ThermalResistanceUnit.g.cs | 1 - .../Units/TorquePerLengthUnit.g.cs | 1 - .../GeneratedCode/Units/TorqueUnit.g.cs | 1 - .../GeneratedCode/Units/TurbidityUnit.g.cs | 1 - .../GeneratedCode/Units/VitaminAUnit.g.cs | 1 - .../Units/VolumeConcentrationUnit.g.cs | 1 - .../GeneratedCode/Units/VolumeFlowUnit.g.cs | 1 - .../Units/VolumePerLengthUnit.g.cs | 1 - .../GeneratedCode/Units/VolumeUnit.g.cs | 1 - .../Units/VolumetricHeatCapacityUnit.g.cs | 1 - .../Units/WarpingMomentOfInertiaUnit.g.cs | 1 - .../TestsBase/AccelerationTestsBase.g.cs | 17 +---------------- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 17 +---------------- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/AngleTestsBase.g.cs | 17 +---------------- .../TestsBase/ApparentEnergyTestsBase.g.cs | 17 +---------------- .../TestsBase/ApparentPowerTestsBase.g.cs | 17 +---------------- .../TestsBase/AreaDensityTestsBase.g.cs | 17 +---------------- .../TestsBase/AreaMomentOfInertiaTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/AreaTestsBase.g.cs | 17 +---------------- .../TestsBase/BitRateTestsBase.g.cs | 17 +---------------- .../BrakeSpecificFuelConsumptionTestsBase.g.cs | 17 +---------------- .../TestsBase/CapacitanceTestsBase.g.cs | 17 +---------------- .../CoefficientOfThermalExpansionTestsBase.g.cs | 17 +---------------- .../TestsBase/DensityTestsBase.g.cs | 17 +---------------- .../TestsBase/DurationTestsBase.g.cs | 17 +---------------- .../TestsBase/DynamicViscosityTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricAdmittanceTestsBase.g.cs | 17 +---------------- .../ElectricChargeDensityTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricChargeTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricConductanceTestsBase.g.cs | 17 +---------------- .../ElectricConductivityTestsBase.g.cs | 17 +---------------- .../ElectricCurrentDensityTestsBase.g.cs | 17 +---------------- .../ElectricCurrentGradientTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricCurrentTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricFieldTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricInductanceTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricPotentialAcTestsBase.g.cs | 17 +---------------- .../ElectricPotentialChangeRateTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricPotentialDcTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricPotentialTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricResistanceTestsBase.g.cs | 17 +---------------- .../TestsBase/ElectricResistivityTestsBase.g.cs | 17 +---------------- .../ElectricSurfaceChargeDensityTestsBase.g.cs | 17 +---------------- .../TestsBase/EnergyTestsBase.g.cs | 17 +---------------- .../TestsBase/EntropyTestsBase.g.cs | 17 +---------------- .../TestsBase/ForceChangeRateTestsBase.g.cs | 17 +---------------- .../TestsBase/ForcePerLengthTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/ForceTestsBase.g.cs | 17 +---------------- .../TestsBase/FrequencyTestsBase.g.cs | 17 +---------------- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 17 +---------------- .../TestsBase/HeatFluxTestsBase.g.cs | 17 +---------------- .../HeatTransferCoefficientTestsBase.g.cs | 17 +---------------- .../TestsBase/IlluminanceTestsBase.g.cs | 17 +---------------- .../TestsBase/InformationTestsBase.g.cs | 17 +---------------- .../TestsBase/IrradianceTestsBase.g.cs | 17 +---------------- .../TestsBase/IrradiationTestsBase.g.cs | 17 +---------------- .../TestsBase/KinematicViscosityTestsBase.g.cs | 17 +---------------- .../TestsBase/LapseRateTestsBase.g.cs | 17 +---------------- .../TestsBase/LengthTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/LevelTestsBase.g.cs | 17 +---------------- .../TestsBase/LinearDensityTestsBase.g.cs | 17 +---------------- .../TestsBase/LinearPowerDensityTestsBase.g.cs | 17 +---------------- .../TestsBase/LuminosityTestsBase.g.cs | 17 +---------------- .../TestsBase/LuminousFluxTestsBase.g.cs | 17 +---------------- .../TestsBase/LuminousIntensityTestsBase.g.cs | 17 +---------------- .../TestsBase/MagneticFieldTestsBase.g.cs | 17 +---------------- .../TestsBase/MagneticFluxTestsBase.g.cs | 17 +---------------- .../TestsBase/MagnetizationTestsBase.g.cs | 17 +---------------- .../TestsBase/MassConcentrationTestsBase.g.cs | 17 +---------------- .../TestsBase/MassFlowTestsBase.g.cs | 17 +---------------- .../TestsBase/MassFluxTestsBase.g.cs | 17 +---------------- .../TestsBase/MassFractionTestsBase.g.cs | 17 +---------------- .../TestsBase/MassMomentOfInertiaTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/MassTestsBase.g.cs | 17 +---------------- .../TestsBase/MolarEnergyTestsBase.g.cs | 17 +---------------- .../TestsBase/MolarEntropyTestsBase.g.cs | 17 +---------------- .../TestsBase/MolarMassTestsBase.g.cs | 17 +---------------- .../TestsBase/MolarityTestsBase.g.cs | 17 +---------------- .../TestsBase/PermeabilityTestsBase.g.cs | 17 +---------------- .../TestsBase/PermittivityTestsBase.g.cs | 17 +---------------- .../TestsBase/PowerDensityTestsBase.g.cs | 17 +---------------- .../TestsBase/PowerRatioTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/PowerTestsBase.g.cs | 17 +---------------- .../TestsBase/PressureChangeRateTestsBase.g.cs | 17 +---------------- .../TestsBase/PressureTestsBase.g.cs | 17 +---------------- .../TestsBase/RatioChangeRateTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/RatioTestsBase.g.cs | 17 +---------------- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 17 +---------------- .../TestsBase/ReactivePowerTestsBase.g.cs | 17 +---------------- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 17 +---------------- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 17 +---------------- .../TestsBase/RelativeHumidityTestsBase.g.cs | 17 +---------------- .../RotationalAccelerationTestsBase.g.cs | 17 +---------------- .../TestsBase/RotationalSpeedTestsBase.g.cs | 17 +---------------- .../RotationalStiffnessPerLengthTestsBase.g.cs | 17 +---------------- .../TestsBase/RotationalStiffnessTestsBase.g.cs | 17 +---------------- .../TestsBase/ScalarTestsBase.g.cs | 17 +---------------- .../TestsBase/SolidAngleTestsBase.g.cs | 17 +---------------- .../TestsBase/SpecificEnergyTestsBase.g.cs | 17 +---------------- .../TestsBase/SpecificEntropyTestsBase.g.cs | 17 +---------------- .../SpecificFuelConsumptionTestsBase.g.cs | 17 +---------------- .../TestsBase/SpecificVolumeTestsBase.g.cs | 17 +---------------- .../TestsBase/SpecificWeightTestsBase.g.cs | 17 +---------------- .../GeneratedCode/TestsBase/SpeedTestsBase.g.cs | 17 +---------------- .../TestsBase/StandardVolumeFlowTestsBase.g.cs | 17 +---------------- .../TemperatureChangeRateTestsBase.g.cs | 17 +---------------- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 17 +---------------- .../TestsBase/TemperatureTestsBase.g.cs | 17 +---------------- .../TestsBase/ThermalConductivityTestsBase.g.cs | 17 +---------------- .../TestsBase/ThermalResistanceTestsBase.g.cs | 17 +---------------- .../TestsBase/TorquePerLengthTestsBase.g.cs | 17 +---------------- .../TestsBase/TorqueTestsBase.g.cs | 17 +---------------- .../TestsBase/TurbidityTestsBase.g.cs | 17 +---------------- .../TestsBase/VitaminATestsBase.g.cs | 17 +---------------- .../TestsBase/VolumeConcentrationTestsBase.g.cs | 17 +---------------- .../TestsBase/VolumeFlowTestsBase.g.cs | 17 +---------------- .../TestsBase/VolumePerLengthTestsBase.g.cs | 17 +---------------- .../TestsBase/VolumeTestsBase.g.cs | 17 +---------------- .../VolumetricHeatCapacityTestsBase.g.cs | 17 +---------------- .../WarpingMomentOfInertiaTestsBase.g.cs | 17 +---------------- .../GeneratedCode/Quantities/Acceleration.g.cs | 5 +---- .../Quantities/AmountOfSubstance.g.cs | 5 +---- .../Quantities/AmplitudeRatio.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 5 +---- .../Quantities/ApparentEnergy.g.cs | 5 +---- .../GeneratedCode/Quantities/ApparentPower.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 5 +---- .../GeneratedCode/Quantities/AreaDensity.g.cs | 5 +---- .../Quantities/AreaMomentOfInertia.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/BitRate.g.cs | 5 +---- .../BrakeSpecificFuelConsumption.g.cs | 5 +---- .../GeneratedCode/Quantities/Capacitance.g.cs | 5 +---- .../CoefficientOfThermalExpansion.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Density.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Duration.g.cs | 5 +---- .../Quantities/DynamicViscosity.g.cs | 5 +---- .../Quantities/ElectricAdmittance.g.cs | 5 +---- .../Quantities/ElectricCharge.g.cs | 5 +---- .../Quantities/ElectricChargeDensity.g.cs | 5 +---- .../Quantities/ElectricConductance.g.cs | 5 +---- .../Quantities/ElectricConductivity.g.cs | 5 +---- .../Quantities/ElectricCurrent.g.cs | 5 +---- .../Quantities/ElectricCurrentDensity.g.cs | 5 +---- .../Quantities/ElectricCurrentGradient.g.cs | 5 +---- .../GeneratedCode/Quantities/ElectricField.g.cs | 5 +---- .../Quantities/ElectricInductance.g.cs | 5 +---- .../Quantities/ElectricPotential.g.cs | 5 +---- .../Quantities/ElectricPotentialAc.g.cs | 5 +---- .../Quantities/ElectricPotentialChangeRate.g.cs | 5 +---- .../Quantities/ElectricPotentialDc.g.cs | 5 +---- .../Quantities/ElectricResistance.g.cs | 5 +---- .../Quantities/ElectricResistivity.g.cs | 5 +---- .../ElectricSurfaceChargeDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Entropy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 5 +---- .../Quantities/ForceChangeRate.g.cs | 5 +---- .../Quantities/ForcePerLength.g.cs | 5 +---- .../GeneratedCode/Quantities/Frequency.g.cs | 5 +---- .../Quantities/FuelEfficiency.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs | 5 +---- .../Quantities/HeatTransferCoefficient.g.cs | 5 +---- .../GeneratedCode/Quantities/Illuminance.g.cs | 5 +---- .../GeneratedCode/Quantities/Information.g.cs | 5 +---- .../GeneratedCode/Quantities/Irradiance.g.cs | 5 +---- .../GeneratedCode/Quantities/Irradiation.g.cs | 5 +---- .../Quantities/KinematicViscosity.g.cs | 5 +---- .../GeneratedCode/Quantities/LapseRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 5 +---- .../GeneratedCode/Quantities/LinearDensity.g.cs | 5 +---- .../Quantities/LinearPowerDensity.g.cs | 5 +---- .../GeneratedCode/Quantities/Luminosity.g.cs | 5 +---- .../GeneratedCode/Quantities/LuminousFlux.g.cs | 5 +---- .../Quantities/LuminousIntensity.g.cs | 5 +---- .../GeneratedCode/Quantities/MagneticField.g.cs | 5 +---- .../GeneratedCode/Quantities/MagneticFlux.g.cs | 5 +---- .../GeneratedCode/Quantities/Magnetization.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 5 +---- .../Quantities/MassConcentration.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs | 5 +---- .../GeneratedCode/Quantities/MassFraction.g.cs | 5 +---- .../Quantities/MassMomentOfInertia.g.cs | 5 +---- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 5 +---- .../GeneratedCode/Quantities/MolarEntropy.g.cs | 5 +---- .../GeneratedCode/Quantities/MolarMass.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Molarity.g.cs | 5 +---- .../GeneratedCode/Quantities/Permeability.g.cs | 5 +---- .../GeneratedCode/Quantities/Permittivity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 5 +---- .../GeneratedCode/Quantities/PowerDensity.g.cs | 5 +---- .../GeneratedCode/Quantities/PowerRatio.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Pressure.g.cs | 5 +---- .../Quantities/PressureChangeRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 5 +---- .../Quantities/RatioChangeRate.g.cs | 5 +---- .../Quantities/ReactiveEnergy.g.cs | 5 +---- .../GeneratedCode/Quantities/ReactivePower.g.cs | 5 +---- .../Quantities/ReciprocalArea.g.cs | 5 +---- .../Quantities/ReciprocalLength.g.cs | 5 +---- .../Quantities/RelativeHumidity.g.cs | 5 +---- .../Quantities/RotationalAcceleration.g.cs | 5 +---- .../Quantities/RotationalSpeed.g.cs | 5 +---- .../Quantities/RotationalStiffness.g.cs | 5 +---- .../RotationalStiffnessPerLength.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 5 +---- .../GeneratedCode/Quantities/SolidAngle.g.cs | 5 +---- .../Quantities/SpecificEnergy.g.cs | 5 +---- .../Quantities/SpecificEntropy.g.cs | 5 +---- .../Quantities/SpecificFuelConsumption.g.cs | 5 +---- .../Quantities/SpecificVolume.g.cs | 5 +---- .../Quantities/SpecificWeight.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 5 +---- .../Quantities/StandardVolumeFlow.g.cs | 5 +---- .../GeneratedCode/Quantities/Temperature.g.cs | 5 +---- .../Quantities/TemperatureChangeRate.g.cs | 5 +---- .../Quantities/TemperatureDelta.g.cs | 5 +---- .../Quantities/ThermalConductivity.g.cs | 5 +---- .../Quantities/ThermalResistance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 5 +---- .../Quantities/TorquePerLength.g.cs | 5 +---- .../GeneratedCode/Quantities/Turbidity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 5 +---- .../Quantities/VolumeConcentration.g.cs | 5 +---- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 5 +---- .../Quantities/VolumePerLength.g.cs | 5 +---- .../Quantities/VolumetricHeatCapacity.g.cs | 5 +---- .../Quantities/WarpingMomentOfInertia.g.cs | 5 +---- .../GeneratedCode/Units/AccelerationUnit.g.cs | 1 - .../Units/AmountOfSubstanceUnit.g.cs | 1 - .../GeneratedCode/Units/AmplitudeRatioUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/AngleUnit.g.cs | 1 - .../GeneratedCode/Units/ApparentEnergyUnit.g.cs | 1 - .../GeneratedCode/Units/ApparentPowerUnit.g.cs | 1 - .../GeneratedCode/Units/AreaDensityUnit.g.cs | 1 - .../Units/AreaMomentOfInertiaUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/AreaUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/BitRateUnit.g.cs | 1 - .../Units/BrakeSpecificFuelConsumptionUnit.g.cs | 1 - .../GeneratedCode/Units/CapacitanceUnit.g.cs | 1 - .../CoefficientOfThermalExpansionUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/DensityUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/DurationUnit.g.cs | 1 - .../Units/DynamicViscosityUnit.g.cs | 1 - .../Units/ElectricAdmittanceUnit.g.cs | 1 - .../Units/ElectricChargeDensityUnit.g.cs | 1 - .../GeneratedCode/Units/ElectricChargeUnit.g.cs | 1 - .../Units/ElectricConductanceUnit.g.cs | 1 - .../Units/ElectricConductivityUnit.g.cs | 1 - .../Units/ElectricCurrentDensityUnit.g.cs | 1 - .../Units/ElectricCurrentGradientUnit.g.cs | 1 - .../Units/ElectricCurrentUnit.g.cs | 1 - .../GeneratedCode/Units/ElectricFieldUnit.g.cs | 1 - .../Units/ElectricInductanceUnit.g.cs | 1 - .../Units/ElectricPotentialAcUnit.g.cs | 1 - .../Units/ElectricPotentialChangeRateUnit.g.cs | 1 - .../Units/ElectricPotentialDcUnit.g.cs | 1 - .../Units/ElectricPotentialUnit.g.cs | 1 - .../Units/ElectricResistanceUnit.g.cs | 1 - .../Units/ElectricResistivityUnit.g.cs | 1 - .../Units/ElectricSurfaceChargeDensityUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs | 1 - .../Units/ForceChangeRateUnit.g.cs | 1 - .../GeneratedCode/Units/ForcePerLengthUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/ForceUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/FrequencyUnit.g.cs | 1 - .../GeneratedCode/Units/FuelEfficiencyUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/HeatFluxUnit.g.cs | 1 - .../Units/HeatTransferCoefficientUnit.g.cs | 1 - .../GeneratedCode/Units/IlluminanceUnit.g.cs | 1 - .../GeneratedCode/Units/InformationUnit.g.cs | 1 - .../GeneratedCode/Units/IrradianceUnit.g.cs | 1 - .../GeneratedCode/Units/IrradiationUnit.g.cs | 1 - .../Units/KinematicViscosityUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/LengthUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/LevelUnit.g.cs | 1 - .../GeneratedCode/Units/LinearDensityUnit.g.cs | 1 - .../Units/LinearPowerDensityUnit.g.cs | 1 - .../GeneratedCode/Units/LuminosityUnit.g.cs | 1 - .../GeneratedCode/Units/LuminousFluxUnit.g.cs | 1 - .../Units/LuminousIntensityUnit.g.cs | 1 - .../GeneratedCode/Units/MagneticFieldUnit.g.cs | 1 - .../GeneratedCode/Units/MagneticFluxUnit.g.cs | 1 - .../GeneratedCode/Units/MagnetizationUnit.g.cs | 1 - .../Units/MassConcentrationUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/MassFlowUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/MassFluxUnit.g.cs | 1 - .../GeneratedCode/Units/MassFractionUnit.g.cs | 1 - .../Units/MassMomentOfInertiaUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/MassUnit.g.cs | 1 - .../GeneratedCode/Units/MolarEnergyUnit.g.cs | 1 - .../GeneratedCode/Units/MolarEntropyUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/MolarMassUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/MolarityUnit.g.cs | 1 - .../GeneratedCode/Units/PermeabilityUnit.g.cs | 1 - .../GeneratedCode/Units/PermittivityUnit.g.cs | 1 - .../GeneratedCode/Units/PowerDensityUnit.g.cs | 1 - .../GeneratedCode/Units/PowerRatioUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/PowerUnit.g.cs | 1 - .../Units/PressureChangeRateUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/PressureUnit.g.cs | 1 - .../Units/RatioChangeRateUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/RatioUnit.g.cs | 1 - .../GeneratedCode/Units/ReactiveEnergyUnit.g.cs | 1 - .../GeneratedCode/Units/ReactivePowerUnit.g.cs | 1 - .../GeneratedCode/Units/ReciprocalAreaUnit.g.cs | 1 - .../Units/ReciprocalLengthUnit.g.cs | 1 - .../Units/RelativeHumidityUnit.g.cs | 1 - .../Units/RotationalAccelerationUnit.g.cs | 1 - .../Units/RotationalSpeedUnit.g.cs | 1 - .../Units/RotationalStiffnessPerLengthUnit.g.cs | 1 - .../Units/RotationalStiffnessUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/ScalarUnit.g.cs | 1 - .../GeneratedCode/Units/SolidAngleUnit.g.cs | 1 - .../GeneratedCode/Units/SpecificEnergyUnit.g.cs | 1 - .../Units/SpecificEntropyUnit.g.cs | 1 - .../Units/SpecificFuelConsumptionUnit.g.cs | 1 - .../GeneratedCode/Units/SpecificVolumeUnit.g.cs | 1 - .../GeneratedCode/Units/SpecificWeightUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/SpeedUnit.g.cs | 1 - .../Units/StandardVolumeFlowUnit.g.cs | 1 - .../Units/TemperatureChangeRateUnit.g.cs | 1 - .../Units/TemperatureDeltaUnit.g.cs | 1 - .../GeneratedCode/Units/TemperatureUnit.g.cs | 1 - .../Units/ThermalConductivityUnit.g.cs | 1 - .../Units/ThermalResistanceUnit.g.cs | 1 - .../Units/TorquePerLengthUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/TurbidityUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/VitaminAUnit.g.cs | 1 - .../Units/VolumeConcentrationUnit.g.cs | 1 - .../GeneratedCode/Units/VolumeFlowUnit.g.cs | 1 - .../Units/VolumePerLengthUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs | 1 - .../Units/VolumetricHeatCapacityUnit.g.cs | 1 - .../Units/WarpingMomentOfInertiaUnit.g.cs | 1 - 444 files changed, 225 insertions(+), 2449 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs index 0b56ff1898..d9247410bd 100644 --- a/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/UnitTypeGenerator.cs @@ -2,7 +2,6 @@ using CodeGen.JsonTypes; namespace CodeGen.Generators.NanoFrameworkGen - { internal class UnitTypeGenerator : GeneratorBase { @@ -26,9 +25,7 @@ namespace UnitsNet.Units #pragma warning disable 1591 public enum {_unitEnumName} - {{ - Undefined = 0,"); - + {{"); foreach (var unit in _quantity.Units) { if (unit.XmlDocSummary.HasText()) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index 50f05679a1..ab3827e552 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -174,11 +174,7 @@ private void GenerateInstanceConstructors() /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) - {{ - if(unit == {_unitEnumName}.Undefined) - throw new ArgumentException(""The quantity can not be created with an undefined unit."", nameof(unit)); -"); - + {{"); Writer.WL(_quantity.ValueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" @@ -236,7 +232,7 @@ private void GenerateStaticProperties() /// /// All units of measurement for the {_quantity.Name} quantity. /// - public static {_unitEnumName}[] Units {{ get; }} = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().Except(new {_unitEnumName}[]{{ {_unitEnumName}.Undefined }}).ToArray(); + public static {_unitEnumName}[] Units {{ get; }} = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.ConversionBaseUnit}. diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index fe007b5ec2..8b705a2114 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -105,12 +105,6 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase protected virtual double {unit.PluralName}Tolerance {{ get {{ return 1e-5; }} }}"); Writer.WL($@" // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - {{ - Assert.Throws(() => new {_quantity.Name}(({_quantity.ValueType})0.0, {_unitEnumName}.Undefined)); - }} - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() {{ @@ -168,7 +162,7 @@ public void Ctor_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() Assert.Equal({_quantity.Name}.Zero, quantityInfo.Zero); Assert.Equal(""{_quantity.Name}"", quantityInfo.Name); - var units = EnumUtils.GetEnumValues<{_unitEnumName}>().Except(new[] {{{_unitEnumName}.Undefined}}).ToArray(); + var units = EnumUtils.GetEnumValues<{_unitEnumName}>().ToArray(); var unitNames = units.Select(x => x.ToString()); }} @@ -388,21 +382,12 @@ public void EqualsReturnsFalseOnNull() Assert.False({baseUnitVariableName}.Equals(null)); }} - [Fact] - public void UnitsDoesNotContainUndefined() - {{ - Assert.DoesNotContain({_unitEnumName}.Undefined, {_quantity.Name}.Units); - }} - [Fact] public void HasAtLeastOneAbbreviationSpecified() {{ var units = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>(); foreach(var unit in units) {{ - if(unit == {_unitEnumName}.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); }} }} diff --git a/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs index 595a82e110..bf7eba8fcc 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTypeGenerator.cs @@ -25,9 +25,7 @@ namespace UnitsNet.Units #pragma warning disable 1591 public enum {_unitEnumName} - {{ - Undefined = 0,"); - + {{"); foreach (var unit in _quantity.Units) { if (unit.XmlDocSummary.HasText()) diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AccelerationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AccelerationUnit.g.cs index 149fda76fb..d2c2b8f7f4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AccelerationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AccelerationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AccelerationUnit { - Undefined = 0, CentimeterPerSecondSquared, DecimeterPerSecondSquared, FootPerSecondSquared, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs index ebd46a97d7..b2501da043 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AmountOfSubstanceUnit { - Undefined = 0, Centimole, CentipoundMole, Decimole, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AmplitudeRatioUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AmplitudeRatioUnit.g.cs index b7bb6ae224..cebbd5313e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AmplitudeRatioUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AmplitudeRatioUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AmplitudeRatioUnit { - Undefined = 0, DecibelMicrovolt, DecibelMillivolt, DecibelUnloaded, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AngleUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AngleUnit.g.cs index b61f169b80..6dffab599d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AngleUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AngleUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AngleUnit { - Undefined = 0, Arcminute, Arcsecond, Centiradian, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentEnergyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentEnergyUnit.g.cs index e7b4f42ee4..f271723e09 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentEnergyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ApparentEnergyUnit { - Undefined = 0, KilovoltampereHour, MegavoltampereHour, VoltampereHour, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentPowerUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentPowerUnit.g.cs index cd5563c699..791a8bac4b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentPowerUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ApparentPowerUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ApparentPowerUnit { - Undefined = 0, Gigavoltampere, Kilovoltampere, Megavoltampere, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs index 84924b7cf3..a37dd1c1a7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AreaDensityUnit { - Undefined = 0, KilogramPerSquareMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs index 3ca2fc3574..96cfb1072c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AreaMomentOfInertiaUnit { - Undefined = 0, CentimeterToTheFourth, DecimeterToTheFourth, FootToTheFourth, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaUnit.g.cs index 2db395608c..0bec95b55e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/AreaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/AreaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AreaUnit { - Undefined = 0, Acre, Hectare, SquareCentimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/BitRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/BitRateUnit.g.cs index e6328d9e65..69affbf6d1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/BitRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/BitRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum BitRateUnit { - Undefined = 0, BitPerSecond, BytePerSecond, ExabitPerSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs index bb10b001c3..2ec8d05234 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum BrakeSpecificFuelConsumptionUnit { - Undefined = 0, GramPerKiloWattHour, KilogramPerJoule, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/CapacitanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/CapacitanceUnit.g.cs index 9b6a538fb9..feaa108dab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/CapacitanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/CapacitanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum CapacitanceUnit { - Undefined = 0, Farad, Kilofarad, Megafarad, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs index 9db9fa9d0d..76316e54bc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum CoefficientOfThermalExpansionUnit { - Undefined = 0, InverseDegreeCelsius, InverseDegreeFahrenheit, InverseKelvin, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/DensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/DensityUnit.g.cs index 94f3fd7948..83405122c8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/DensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/DensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum DensityUnit { - Undefined = 0, CentigramPerDeciliter, CentigramPerLiter, CentigramPerMilliliter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/DurationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/DurationUnit.g.cs index 63af8ab3f0..148dd2a9b5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/DurationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/DurationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum DurationUnit { - Undefined = 0, Day, Hour, Microsecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/DynamicViscosityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/DynamicViscosityUnit.g.cs index a0d6fc8e13..fa920a2d2f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/DynamicViscosityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/DynamicViscosityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum DynamicViscosityUnit { - Undefined = 0, Centipoise, MicropascalSecond, MillipascalSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs index 21e8f4edfa..f6c3afcc4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricAdmittanceUnit { - Undefined = 0, Microsiemens, Millisiemens, Nanosiemens, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs index 8797383f4a..24bc7adb18 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricChargeDensityUnit { - Undefined = 0, CoulombPerCubicMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs index 65c4b8b58d..7d775c82a3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricChargeUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricChargeUnit { - Undefined = 0, AmpereHour, Coulomb, KiloampereHour, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductanceUnit.g.cs index 5b852833d7..d87748356e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricConductanceUnit { - Undefined = 0, Microsiemens, Millisiemens, Siemens, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductivityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductivityUnit.g.cs index 6afee546c8..1c1f2ffc4b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductivityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricConductivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricConductivityUnit { - Undefined = 0, SiemensPerFoot, SiemensPerInch, SiemensPerMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs index 9a0a8c9715..438ab45542 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricCurrentDensityUnit { - Undefined = 0, AmperePerSquareFoot, AmperePerSquareInch, AmperePerSquareMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs index ec7e9f0e02..3f58821e0e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricCurrentGradientUnit { - Undefined = 0, AmperePerMicrosecond, AmperePerMillisecond, AmperePerNanosecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentUnit.g.cs index a2b690d5c4..73df60e25d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricCurrentUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricCurrentUnit { - Undefined = 0, Ampere, Centiampere, Kiloampere, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricFieldUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricFieldUnit.g.cs index c3710d6ad6..acd3de7d8c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricFieldUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricFieldUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricFieldUnit { - Undefined = 0, VoltPerMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricInductanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricInductanceUnit.g.cs index 1cac8bbe3c..8e9db523e9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricInductanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricInductanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricInductanceUnit { - Undefined = 0, Henry, Microhenry, Millihenry, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs index 87ba58a573..6b44b3f3cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialAcUnit { - Undefined = 0, KilovoltAc, MegavoltAc, MicrovoltAc, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs index d77a1dd97b..c2764850a7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialChangeRateUnit { - Undefined = 0, KilovoltPerHour, KilovoltPerMicrosecond, KilovoltPerMinute, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs index 8743571009..98e8b5b40f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialDcUnit { - Undefined = 0, KilovoltDc, MegavoltDc, MicrovoltDc, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialUnit.g.cs index a50136ad6b..436e7c740a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricPotentialUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialUnit { - Undefined = 0, Kilovolt, Megavolt, Microvolt, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistanceUnit.g.cs index e0cdbd4632..c7e9de7756 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricResistanceUnit { - Undefined = 0, Gigaohm, Kiloohm, Megaohm, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistivityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistivityUnit.g.cs index cb6360eda3..8d198d3983 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistivityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricResistivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricResistivityUnit { - Undefined = 0, KiloohmCentimeter, KiloohmMeter, MegaohmCentimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs index 1e96388035..ce5be9b6fb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricSurfaceChargeDensityUnit { - Undefined = 0, CoulombPerSquareCentimeter, CoulombPerSquareInch, CoulombPerSquareMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/EnergyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/EnergyUnit.g.cs index f0fb9bb49d..ccbf4d9d0b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/EnergyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/EnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum EnergyUnit { - Undefined = 0, BritishThermalUnit, Calorie, DecathermEc, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/EntropyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/EntropyUnit.g.cs index 527b5b7f3c..8f4a0f622e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/EntropyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/EntropyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum EntropyUnit { - Undefined = 0, CaloriePerKelvin, JoulePerDegreeCelsius, JoulePerKelvin, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ForceChangeRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ForceChangeRateUnit.g.cs index 872ff7774c..990af24d02 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ForceChangeRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ForceChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ForceChangeRateUnit { - Undefined = 0, CentinewtonPerSecond, DecanewtonPerMinute, DecanewtonPerSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ForcePerLengthUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ForcePerLengthUnit.g.cs index e5f004605f..b29b199249 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ForcePerLengthUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ForcePerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ForcePerLengthUnit { - Undefined = 0, CentinewtonPerCentimeter, CentinewtonPerMeter, CentinewtonPerMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ForceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ForceUnit.g.cs index b3124108bd..de87d0edc0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ForceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ForceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ForceUnit { - Undefined = 0, Decanewton, Dyn, KilogramForce, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/FrequencyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/FrequencyUnit.g.cs index fd5c104061..6db6d05233 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/FrequencyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/FrequencyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum FrequencyUnit { - Undefined = 0, BeatPerMinute, BUnit, CyclePerHour, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/FuelEfficiencyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/FuelEfficiencyUnit.g.cs index 7dbfd0ab36..f2046a9aaf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/FuelEfficiencyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/FuelEfficiencyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum FuelEfficiencyUnit { - Undefined = 0, KilometerPerLiter, LiterPer100Kilometers, MilePerUkGallon, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/HeatFluxUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/HeatFluxUnit.g.cs index bc76552e32..85bd6051b5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/HeatFluxUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/HeatFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum HeatFluxUnit { - Undefined = 0, BtuPerHourSquareFoot, BtuPerMinuteSquareFoot, BtuPerSecondSquareFoot, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs index 6494d31478..68eb7e0656 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum HeatTransferCoefficientUnit { - Undefined = 0, BtuPerSquareFootDegreeFahrenheit, WattPerSquareMeterCelsius, WattPerSquareMeterKelvin, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/IlluminanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/IlluminanceUnit.g.cs index 3584e96825..8d187efb2a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/IlluminanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/IlluminanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum IlluminanceUnit { - Undefined = 0, Kilolux, Lux, Megalux, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/InformationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/InformationUnit.g.cs index 2986de4b20..a6e00fdfd4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/InformationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/InformationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum InformationUnit { - Undefined = 0, Bit, Byte, Exabit, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/IrradianceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/IrradianceUnit.g.cs index 285e771afa..204dddebf5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/IrradianceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/IrradianceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum IrradianceUnit { - Undefined = 0, KilowattPerSquareCentimeter, KilowattPerSquareMeter, MegawattPerSquareCentimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs index 1a13e8d425..2ce58066fc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/IrradiationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum IrradiationUnit { - Undefined = 0, JoulePerSquareCentimeter, JoulePerSquareMeter, JoulePerSquareMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/KinematicViscosityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/KinematicViscosityUnit.g.cs index af0c4a0e22..4bdb8e1759 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/KinematicViscosityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/KinematicViscosityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum KinematicViscosityUnit { - Undefined = 0, Centistokes, Decistokes, Kilostokes, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LapseRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LapseRateUnit.g.cs index 0db5758f3e..41f5b8bbe4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LapseRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LapseRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LapseRateUnit { - Undefined = 0, DegreeCelsiusPerKilometer, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LengthUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LengthUnit.g.cs index d2987f8ad4..c3e48b2d94 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LengthUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LengthUnit { - Undefined = 0, /// /// One Astronomical Unit is the distance from the solar system Star, the sun, to planet Earth. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LevelUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LevelUnit.g.cs index d1cd5c65ed..1ec66cdc70 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LevelUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LevelUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LevelUnit { - Undefined = 0, Decibel, Neper, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LinearDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LinearDensityUnit.g.cs index 70a4f47764..cff6234413 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LinearDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LinearDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LinearDensityUnit { - Undefined = 0, GramPerCentimeter, GramPerMeter, GramPerMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LinearPowerDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LinearPowerDensityUnit.g.cs index 0f744effb5..0eacaf457f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LinearPowerDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LinearPowerDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LinearPowerDensityUnit { - Undefined = 0, GigawattPerCentimeter, GigawattPerFoot, GigawattPerInch, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LuminosityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LuminosityUnit.g.cs index 309e51093d..8c08810b72 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LuminosityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LuminosityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LuminosityUnit { - Undefined = 0, Decawatt, Deciwatt, Femtowatt, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousFluxUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousFluxUnit.g.cs index 7d3122939f..77ebbc99e1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousFluxUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LuminousFluxUnit { - Undefined = 0, Lumen, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousIntensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousIntensityUnit.g.cs index 16feeb4596..796be6f002 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousIntensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/LuminousIntensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LuminousIntensityUnit { - Undefined = 0, Candela, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFieldUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFieldUnit.g.cs index 5ce5acdc3f..c86ae72bf0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFieldUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFieldUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MagneticFieldUnit { - Undefined = 0, Gauss, Microtesla, Milligauss, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFluxUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFluxUnit.g.cs index 241a0fc57b..3429bbbd15 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFluxUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MagneticFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MagneticFluxUnit { - Undefined = 0, Weber, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MagnetizationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MagnetizationUnit.g.cs index 96438162e4..600764abff 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MagnetizationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MagnetizationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MagnetizationUnit { - Undefined = 0, AmperePerMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MassConcentrationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MassConcentrationUnit.g.cs index 75513af502..501dbffc36 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MassConcentrationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MassConcentrationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassConcentrationUnit { - Undefined = 0, CentigramPerDeciliter, CentigramPerLiter, CentigramPerMicroliter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MassFlowUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MassFlowUnit.g.cs index acf8b9cba6..1288782e40 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MassFlowUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MassFlowUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassFlowUnit { - Undefined = 0, CentigramPerDay, CentigramPerSecond, DecagramPerDay, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MassFluxUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MassFluxUnit.g.cs index 2723abf13a..8eb72cbb51 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MassFluxUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MassFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassFluxUnit { - Undefined = 0, GramPerHourPerSquareCentimeter, GramPerHourPerSquareMeter, GramPerHourPerSquareMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MassFractionUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MassFractionUnit.g.cs index 8151a08dfd..bcad070f95 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MassFractionUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MassFractionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassFractionUnit { - Undefined = 0, CentigramPerGram, CentigramPerKilogram, DecagramPerGram, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs index 972b52d375..44042eba4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassMomentOfInertiaUnit { - Undefined = 0, GramSquareCentimeter, GramSquareDecimeter, GramSquareMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MassUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MassUnit.g.cs index 37a441d742..02ef7a2f78 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MassUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MassUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassUnit { - Undefined = 0, Centigram, Decagram, Decigram, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEnergyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEnergyUnit.g.cs index cd0ba80e11..988b8203ec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEnergyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarEnergyUnit { - Undefined = 0, JoulePerMole, KilojoulePerMole, MegajoulePerMole, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEntropyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEntropyUnit.g.cs index edd5decabe..2102e52d4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEntropyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarEntropyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarEntropyUnit { - Undefined = 0, JoulePerMoleKelvin, KilojoulePerMoleKelvin, MegajoulePerMoleKelvin, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarMassUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarMassUnit.g.cs index 2e955277a5..8fd58c4fce 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarMassUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarMassUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarMassUnit { - Undefined = 0, CentigramPerMole, DecagramPerMole, DecigramPerMole, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarityUnit.g.cs index 854a8969e0..4bae6e2bf4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/MolarityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/MolarityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarityUnit { - Undefined = 0, CentimolesPerLiter, DecimolesPerLiter, MicromolesPerLiter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PermeabilityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PermeabilityUnit.g.cs index 9d236dbc9c..df63a1b08d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PermeabilityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PermeabilityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PermeabilityUnit { - Undefined = 0, HenryPerMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PermittivityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PermittivityUnit.g.cs index 02caf933de..00938d92b6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PermittivityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PermittivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PermittivityUnit { - Undefined = 0, FaradPerMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PowerDensityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PowerDensityUnit.g.cs index 10946ecb5b..ffda44acc7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PowerDensityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PowerDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PowerDensityUnit { - Undefined = 0, DecawattPerCubicFoot, DecawattPerCubicInch, DecawattPerCubicMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PowerRatioUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PowerRatioUnit.g.cs index e4a29c66ed..cb75bef85e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PowerRatioUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PowerRatioUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PowerRatioUnit { - Undefined = 0, DecibelMilliwatt, DecibelWatt, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PowerUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PowerUnit.g.cs index 43701759dc..5631baba5a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PowerUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PowerUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PowerUnit { - Undefined = 0, BoilerHorsepower, BritishThermalUnitPerHour, Decawatt, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PressureChangeRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PressureChangeRateUnit.g.cs index 60fe8b12a9..321b81de30 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PressureChangeRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PressureChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PressureChangeRateUnit { - Undefined = 0, AtmospherePerSecond, KilopascalPerMinute, KilopascalPerSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/PressureUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/PressureUnit.g.cs index 19dc745d2f..044ee33d3c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/PressureUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/PressureUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PressureUnit { - Undefined = 0, Atmosphere, Bar, Centibar, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RatioChangeRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RatioChangeRateUnit.g.cs index bcde32166e..a43cd4b250 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RatioChangeRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RatioChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RatioChangeRateUnit { - Undefined = 0, DecimalFractionPerSecond, PercentPerSecond, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RatioUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RatioUnit.g.cs index c4d62326dc..be13f76760 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RatioUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RatioUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RatioUnit { - Undefined = 0, DecimalFraction, PartPerBillion, PartPerMillion, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ReactiveEnergyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ReactiveEnergyUnit.g.cs index 9c5e12ddb0..863003f8ec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ReactiveEnergyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ReactiveEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReactiveEnergyUnit { - Undefined = 0, KilovoltampereReactiveHour, MegavoltampereReactiveHour, VoltampereReactiveHour, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ReactivePowerUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ReactivePowerUnit.g.cs index 6dcb0a2687..ae28daaec3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ReactivePowerUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ReactivePowerUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReactivePowerUnit { - Undefined = 0, GigavoltampereReactive, KilovoltampereReactive, MegavoltampereReactive, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalAreaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalAreaUnit.g.cs index 822c6e03eb..122fd72e55 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalAreaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalAreaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReciprocalAreaUnit { - Undefined = 0, InverseSquareCentimeter, InverseSquareDecimeter, InverseSquareFoot, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalLengthUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalLengthUnit.g.cs index 166f08af87..2346e35c76 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalLengthUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ReciprocalLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReciprocalLengthUnit { - Undefined = 0, InverseCentimeter, InverseFoot, InverseInch, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RelativeHumidityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RelativeHumidityUnit.g.cs index d1ff2b1726..522ab7449b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RelativeHumidityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RelativeHumidityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RelativeHumidityUnit { - Undefined = 0, Percent, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalAccelerationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalAccelerationUnit.g.cs index e207d6c1ae..acc0acf6f6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalAccelerationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalAccelerationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalAccelerationUnit { - Undefined = 0, DegreePerSecondSquared, RadianPerSecondSquared, RevolutionPerMinutePerSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalSpeedUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalSpeedUnit.g.cs index 93b644ac7c..d5c3290737 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalSpeedUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalSpeedUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalSpeedUnit { - Undefined = 0, CentiradianPerSecond, DeciradianPerSecond, DegreePerMinute, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs index 479001f79c..a1e8777e2f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalStiffnessPerLengthUnit { - Undefined = 0, KilonewtonMeterPerRadianPerMeter, KilopoundForceFootPerDegreesPerFoot, MeganewtonMeterPerRadianPerMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessUnit.g.cs index 1ca970ecb1..99dfef7ae9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/RotationalStiffnessUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalStiffnessUnit { - Undefined = 0, CentinewtonMeterPerDegree, CentinewtonMillimeterPerDegree, CentinewtonMillimeterPerRadian, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ScalarUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ScalarUnit.g.cs index 3b0891f314..0ba35b11d5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ScalarUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ScalarUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ScalarUnit { - Undefined = 0, Amount, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SolidAngleUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SolidAngleUnit.g.cs index 1fa9137298..dcdd777eae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SolidAngleUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SolidAngleUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SolidAngleUnit { - Undefined = 0, Steradian, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEnergyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEnergyUnit.g.cs index 3c59f4a00f..02cc18028b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEnergyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificEnergyUnit { - Undefined = 0, BtuPerPound, CaloriePerGram, GigawattDayPerKilogram, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEntropyUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEntropyUnit.g.cs index 744c7608bf..f8611c6bb9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEntropyUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificEntropyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificEntropyUnit { - Undefined = 0, BtuPerPoundFahrenheit, CaloriePerGramKelvin, JoulePerKilogramDegreeCelsius, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs index f83628860d..c462612789 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificFuelConsumptionUnit { - Undefined = 0, GramPerKiloNewtonSecond, KilogramPerKilogramForceHour, KilogramPerKiloNewtonSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificVolumeUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificVolumeUnit.g.cs index 64f2e15212..d1066753fe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificVolumeUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificVolumeUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificVolumeUnit { - Undefined = 0, CubicFootPerPound, CubicMeterPerKilogram, MillicubicMeterPerKilogram, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificWeightUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificWeightUnit.g.cs index 21c71caacf..da2b36b6b4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificWeightUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SpecificWeightUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificWeightUnit { - Undefined = 0, KilogramForcePerCubicCentimeter, KilogramForcePerCubicMeter, KilogramForcePerCubicMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/SpeedUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/SpeedUnit.g.cs index 77335fd679..fdd5854520 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/SpeedUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/SpeedUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpeedUnit { - Undefined = 0, CentimeterPerHour, CentimeterPerMinute, CentimeterPerSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs index 86f6e5d486..65ee3bd72b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum StandardVolumeFlowUnit { - Undefined = 0, StandardCubicCentimeterPerMinute, StandardCubicFootPerHour, StandardCubicFootPerMinute, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs index 1170aab72f..dc87b5b284 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureChangeRateUnit { - Undefined = 0, CentidegreeCelsiusPerSecond, DecadegreeCelsiusPerSecond, DecidegreeCelsiusPerSecond, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureDeltaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureDeltaUnit.g.cs index 7fded81179..2b1b219672 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureDeltaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureDeltaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureDeltaUnit { - Undefined = 0, DegreeCelsius, DegreeDelisle, DegreeFahrenheit, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureUnit.g.cs index 9fef394aec..dcca0a9ba9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureUnit { - Undefined = 0, DegreeCelsius, DegreeDelisle, DegreeFahrenheit, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalConductivityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalConductivityUnit.g.cs index b57d36aa6e..1cf78e2034 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalConductivityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalConductivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ThermalConductivityUnit { - Undefined = 0, BtuPerHourFootFahrenheit, WattPerMeterKelvin, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalResistanceUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalResistanceUnit.g.cs index 643e5ba89f..5ca71e2a83 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalResistanceUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/ThermalResistanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ThermalResistanceUnit { - Undefined = 0, HourSquareFeetDegreeFahrenheitPerBtu, SquareCentimeterHourDegreeCelsiusPerKilocalorie, SquareCentimeterKelvinPerWatt, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TorquePerLengthUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TorquePerLengthUnit.g.cs index f400c141d5..5338332165 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TorquePerLengthUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TorquePerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TorquePerLengthUnit { - Undefined = 0, KilogramForceCentimeterPerMeter, KilogramForceMeterPerMeter, KilogramForceMillimeterPerMeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs index b8f52ad98e..7d73a74e8d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TorqueUnit { - Undefined = 0, KilogramForceCentimeter, KilogramForceMeter, KilogramForceMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TurbidityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TurbidityUnit.g.cs index 8e9c870a04..51be9ce794 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TurbidityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TurbidityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TurbidityUnit { - Undefined = 0, NTU, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VitaminAUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VitaminAUnit.g.cs index 566de16722..29a33a74f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VitaminAUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VitaminAUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VitaminAUnit { - Undefined = 0, InternationalUnit, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeConcentrationUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeConcentrationUnit.g.cs index 5fa899ebe4..6be8480466 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeConcentrationUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeConcentrationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeConcentrationUnit { - Undefined = 0, CentilitersPerLiter, CentilitersPerMililiter, DecilitersPerLiter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs index f801690542..e213e441f1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeFlowUnit { - Undefined = 0, AcreFootPerDay, AcreFootPerHour, AcreFootPerMinute, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumePerLengthUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumePerLengthUnit.g.cs index 9fe06e5e68..059507a461 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumePerLengthUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumePerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumePerLengthUnit { - Undefined = 0, CubicMeterPerMeter, CubicYardPerFoot, CubicYardPerUsSurveyFoot, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs index 2f659cf5d4..c32808ad1e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeUnit { - Undefined = 0, AcreFoot, AuTablespoon, BoardFoot, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs index 2f18602337..fda6345525 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumetricHeatCapacityUnit { - Undefined = 0, BtuPerCubicFootDegreeFahrenheit, CaloriePerCubicCentimeterDegreeCelsius, JoulePerCubicMeterDegreeCelsius, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs index a7e6d93c2e..64d2dc6cb8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum WarpingMomentOfInertiaUnit { - Undefined = 0, CentimeterToTheSixth, DecimeterToTheSixth, FootToTheSixth, diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 1b6ebf73f5..e39aabf742 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -69,12 +69,6 @@ public abstract partial class AccelerationTestsBase : QuantityTestsBase protected virtual double StandardGravityTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Acceleration((double)0.0, AccelerationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -127,7 +121,7 @@ public void Acceleration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Acceleration.Zero, quantityInfo.Zero); Assert.Equal("Acceleration", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AccelerationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -433,21 +427,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(meterpersecondsquared.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AccelerationUnit.Undefined, Acceleration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AccelerationUnit)).Cast(); foreach(var unit in units) { - if(unit == AccelerationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 8155ff8eff..11b7283de8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -71,12 +71,6 @@ public abstract partial class AmountOfSubstanceTestsBase : QuantityTestsBase protected virtual double PoundMolesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AmountOfSubstance((double)0.0, AmountOfSubstanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -129,7 +123,7 @@ public void AmountOfSubstance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(AmountOfSubstance.Zero, quantityInfo.Zero); Assert.Equal("AmountOfSubstance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AmountOfSubstanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -446,21 +440,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(mole.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AmountOfSubstanceUnit.Undefined, AmountOfSubstance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast(); foreach(var unit in units) { - if(unit == AmountOfSubstanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 029a660a52..4d363ed234 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class AmplitudeRatioTestsBase : QuantityTestsBase protected virtual double DecibelVoltsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AmplitudeRatio((double)0.0, AmplitudeRatioUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void AmplitudeRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(AmplitudeRatio.Zero, quantityInfo.Zero); Assert.Equal("AmplitudeRatio", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AmplitudeRatioUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -307,21 +301,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibelvolt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AmplitudeRatioUnit.Undefined, AmplitudeRatio.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast(); foreach(var unit in units) { - if(unit == AmplitudeRatioUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index d8fa56abaf..d6cb37ea6a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -73,12 +73,6 @@ public abstract partial class AngleTestsBase : QuantityTestsBase protected virtual double TiltTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Angle((double)0.0, AngleUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -131,7 +125,7 @@ public void Angle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Angle.Zero, quantityInfo.Zero); Assert.Equal("Angle", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AngleUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -459,21 +453,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(degree.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AngleUnit.Undefined, Angle.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AngleUnit)).Cast(); foreach(var unit in units) { - if(unit == AngleUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 3bf958cb62..683f3b2f36 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class ApparentEnergyTestsBase : QuantityTestsBase protected virtual double VoltampereHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ApparentEnergy((double)0.0, ApparentEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void ApparentEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ApparentEnergy.Zero, quantityInfo.Zero); Assert.Equal("ApparentEnergy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ApparentEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltamperehour.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ApparentEnergyUnit.Undefined, ApparentEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == ApparentEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 672fa5e4e1..382a3473b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class ApparentPowerTestsBase : QuantityTestsBase protected virtual double VoltamperesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ApparentPower((double)0.0, ApparentPowerUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void ApparentPower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ApparentPower.Zero, quantityInfo.Zero); Assert.Equal("ApparentPower", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ApparentPowerUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltampere.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ApparentPowerUnit.Undefined, ApparentPower.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ApparentPowerUnit)).Cast(); foreach(var unit in units) { - if(unit == ApparentPowerUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index cecd3658ca..5cd3ece679 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AreaDensity((double)0.0, AreaDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void AreaDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(AreaDensity.Zero, quantityInfo.Zero); Assert.Equal("AreaDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AreaDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AreaDensityUnit.Undefined, AreaDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AreaDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == AreaDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 9f2d412306..19a80abb56 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -53,12 +53,6 @@ public abstract partial class AreaMomentOfInertiaTestsBase : QuantityTestsBase protected virtual double MillimetersToTheFourthTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AreaMomentOfInertia((double)0.0, AreaMomentOfInertiaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -111,7 +105,7 @@ public void AreaMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(AreaMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("AreaMomentOfInertia", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AreaMomentOfInertiaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -329,21 +323,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(metertothefourth.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AreaMomentOfInertiaUnit.Undefined, AreaMomentOfInertia.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast(); foreach(var unit in units) { - if(unit == AreaMomentOfInertiaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index f80c5c4f56..39c590b108 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -69,12 +69,6 @@ public abstract partial class AreaTestsBase : QuantityTestsBase protected virtual double UsSurveySquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Area((double)0.0, AreaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -127,7 +121,7 @@ public void Area_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Area.Zero, quantityInfo.Zero); Assert.Equal("Area", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {AreaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -433,21 +427,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(squaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AreaUnit.Undefined, Area.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AreaUnit)).Cast(); foreach(var unit in units) { - if(unit == AreaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 6b887b6091..9e9f07d930 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -93,12 +93,6 @@ public abstract partial class BitRateTestsBase : QuantityTestsBase protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new BitRate((decimal)0.0, BitRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -139,7 +133,7 @@ public void BitRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(BitRate.Zero, quantityInfo.Zero); Assert.Equal("BitRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {BitRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -564,21 +558,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(bitpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(BitRateUnit.Undefined, BitRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(BitRateUnit)).Cast(); foreach(var unit in units) { - if(unit == BitRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index b3e13df8f5..d606088598 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class BrakeSpecificFuelConsumptionTestsBase : QuantityTe protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new BrakeSpecificFuelConsumption((double)0.0, BrakeSpecificFuelConsumptionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void BrakeSpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(BrakeSpecificFuelConsumption.Zero, quantityInfo.Zero); Assert.Equal("BrakeSpecificFuelConsumption", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {BrakeSpecificFuelConsumptionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogramperjoule.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(BrakeSpecificFuelConsumptionUnit.Undefined, BrakeSpecificFuelConsumption.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast(); foreach(var unit in units) { - if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 39f605fc99..4e25574cb7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -55,12 +55,6 @@ public abstract partial class CapacitanceTestsBase : QuantityTestsBase protected virtual double PicofaradsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Capacitance((double)0.0, CapacitanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -113,7 +107,7 @@ public void Capacitance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Capacitance.Zero, quantityInfo.Zero); Assert.Equal("Capacitance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {CapacitanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -342,21 +336,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(farad.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(CapacitanceUnit.Undefined, Capacitance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(CapacitanceUnit)).Cast(); foreach(var unit in units) { - if(unit == CapacitanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index cbcd63edfb..e10692ea79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class CoefficientOfThermalExpansionTestsBase : QuantityT protected virtual double InverseKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new CoefficientOfThermalExpansion((double)0.0, CoefficientOfThermalExpansionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void CoefficientOfThermalExpansion_QuantityInfo_ReturnsQuantityInfoDescri Assert.Equal(CoefficientOfThermalExpansion.Zero, quantityInfo.Zero); Assert.Equal("CoefficientOfThermalExpansion", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {CoefficientOfThermalExpansionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(inversekelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(CoefficientOfThermalExpansionUnit.Undefined, CoefficientOfThermalExpansion.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast(); foreach(var unit in units) { - if(unit == CoefficientOfThermalExpansionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 5efb74f49d..077e32ec2e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -121,12 +121,6 @@ public abstract partial class DensityTestsBase : QuantityTestsBase protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Density((double)0.0, DensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -179,7 +173,7 @@ public void Density_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Density.Zero, quantityInfo.Zero); Assert.Equal("Density", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {DensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -771,21 +765,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(DensityUnit.Undefined, Density.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(DensityUnit)).Cast(); foreach(var unit in units) { - if(unit == DensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index c5382bd6c0..a444634f0f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -61,12 +61,6 @@ public abstract partial class DurationTestsBase : QuantityTestsBase protected virtual double Years365Tolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Duration((double)0.0, DurationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -119,7 +113,7 @@ public void Duration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Duration.Zero, quantityInfo.Zero); Assert.Equal("Duration", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {DurationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -381,21 +375,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(second.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(DurationUnit.Undefined, Duration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(DurationUnit)).Cast(); foreach(var unit in units) { - if(unit == DurationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index b07e089b4b..08e4d65658 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -61,12 +61,6 @@ public abstract partial class DynamicViscosityTestsBase : QuantityTestsBase protected virtual double ReynsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new DynamicViscosity((double)0.0, DynamicViscosityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -119,7 +113,7 @@ public void DynamicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(DynamicViscosity.Zero, quantityInfo.Zero); Assert.Equal("DynamicViscosity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {DynamicViscosityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -381,21 +375,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonsecondpermetersquared.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(DynamicViscosityUnit.Undefined, DynamicViscosity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast(); foreach(var unit in units) { - if(unit == DynamicViscosityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index af17d29c73..b5a24e5676 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class ElectricAdmittanceTestsBase : QuantityTestsBase protected virtual double SiemensTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricAdmittance((double)0.0, ElectricAdmittanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void ElectricAdmittance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricAdmittance.Zero, quantityInfo.Zero); Assert.Equal("ElectricAdmittance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricAdmittanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(siemens.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricAdmittanceUnit.Undefined, ElectricAdmittance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricAdmittanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 421022d475..3ac3125669 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class ElectricChargeDensityTestsBase : QuantityTestsBase protected virtual double CoulombsPerCubicMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricChargeDensity((double)0.0, ElectricChargeDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void ElectricChargeDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuan Assert.Equal(ElectricChargeDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricChargeDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(coulombpercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricChargeDensityUnit.Undefined, ElectricChargeDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricChargeDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index ff3b204d3a..86a21d5100 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -51,12 +51,6 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase protected virtual double MilliampereHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCharge((double)0.0, ElectricChargeUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -109,7 +103,7 @@ public void ElectricCharge_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricCharge.Zero, quantityInfo.Zero); Assert.Equal("ElectricCharge", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -316,21 +310,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(coulomb.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricChargeUnit.Undefined, ElectricCharge.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricChargeUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricChargeUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 3a7e1e06bf..1dcaa71006 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class ElectricConductanceTestsBase : QuantityTestsBase protected virtual double SiemensTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricConductance((double)0.0, ElectricConductanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void ElectricConductance_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricConductance.Zero, quantityInfo.Zero); Assert.Equal("ElectricConductance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(siemens.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricConductanceUnit.Undefined, ElectricConductance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricConductanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index db59e86483..3b4595138d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class ElectricConductivityTestsBase : QuantityTestsBase protected virtual double SiemensPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricConductivity((double)0.0, ElectricConductivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void ElectricConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuant Assert.Equal(ElectricConductivity.Zero, quantityInfo.Zero); Assert.Equal("ElectricConductivity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(siemenspermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricConductivityUnit.Undefined, ElectricConductivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricConductivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 408373cacb..5bc631e4d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class ElectricCurrentDensityTestsBase : QuantityTestsBas protected virtual double AmperesPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCurrentDensity((double)0.0, ElectricCurrentDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void ElectricCurrentDensity_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(ElectricCurrentDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrentDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amperepersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricCurrentDensityUnit.Undefined, ElectricCurrentDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricCurrentDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 4a0a019201..1c0dc29c3d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class ElectricCurrentGradientTestsBase : QuantityTestsBa protected virtual double AmperesPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCurrentGradient((double)0.0, ElectricCurrentGradientUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void ElectricCurrentGradient_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(ElectricCurrentGradient.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrentGradient", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentGradientUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amperepersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricCurrentGradientUnit.Undefined, ElectricCurrentGradient.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricCurrentGradientUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 84a10e1fc3..d4dfe734eb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -57,12 +57,6 @@ public abstract partial class ElectricCurrentTestsBase : QuantityTestsBase protected virtual double PicoamperesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCurrent((double)0.0, ElectricCurrentUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -115,7 +109,7 @@ public void ElectricCurrent_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricCurrent.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrent", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -355,21 +349,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ampere.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricCurrentUnit.Undefined, ElectricCurrent.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricCurrentUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 1c907d731d..0aa023b990 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class ElectricFieldTestsBase : QuantityTestsBase protected virtual double VoltsPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricField((double)0.0, ElectricFieldUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void ElectricField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricField.Zero, quantityInfo.Zero); Assert.Equal("ElectricField", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricFieldUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricFieldUnit.Undefined, ElectricField.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricFieldUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricFieldUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index a4949c4dcd..031de1f445 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class ElectricInductanceTestsBase : QuantityTestsBase protected virtual double NanohenriesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricInductance((double)0.0, ElectricInductanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void ElectricInductance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricInductance.Zero, quantityInfo.Zero); Assert.Equal("ElectricInductance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricInductanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(henry.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricInductanceUnit.Undefined, ElectricInductance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricInductanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 9cde8f7717..9748573ee2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -51,12 +51,6 @@ public abstract partial class ElectricPotentialAcTestsBase : QuantityTestsBase protected virtual double VoltsAcTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotentialAc((double)0.0, ElectricPotentialAcUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -109,7 +103,7 @@ public void ElectricPotentialAc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricPotentialAc.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialAc", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialAcUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -316,21 +310,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltac.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialAcUnit.Undefined, ElectricPotentialAc.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialAcUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index ca697d9b43..68d9c5f16e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -81,12 +81,6 @@ public abstract partial class ElectricPotentialChangeRateTestsBase : QuantityTes protected virtual double VoltsPerSecondsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotentialChangeRate((double)0.0, ElectricPotentialChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -139,7 +133,7 @@ public void ElectricPotentialChangeRate_QuantityInfo_ReturnsQuantityInfoDescribi Assert.Equal(ElectricPotentialChangeRate.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialChangeRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -511,21 +505,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialChangeRateUnit.Undefined, ElectricPotentialChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index 11427db37a..aebc94450e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -51,12 +51,6 @@ public abstract partial class ElectricPotentialDcTestsBase : QuantityTestsBase protected virtual double VoltsDcTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotentialDc((double)0.0, ElectricPotentialDcUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -109,7 +103,7 @@ public void ElectricPotentialDc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricPotentialDc.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialDc", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialDcUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -316,21 +310,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltdc.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialDcUnit.Undefined, ElectricPotentialDc.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialDcUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index bdb6a4f024..a3bb36ec3d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -51,12 +51,6 @@ public abstract partial class ElectricPotentialTestsBase : QuantityTestsBase protected virtual double VoltsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotential((double)0.0, ElectricPotentialUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -109,7 +103,7 @@ public void ElectricPotential_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(ElectricPotential.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotential", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -316,21 +310,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(volt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialUnit.Undefined, ElectricPotential.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 84e501a996..389db6c0b0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -53,12 +53,6 @@ public abstract partial class ElectricResistanceTestsBase : QuantityTestsBase protected virtual double OhmsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricResistance((double)0.0, ElectricResistanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -111,7 +105,7 @@ public void ElectricResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricResistance.Zero, quantityInfo.Zero); Assert.Equal("ElectricResistance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -329,21 +323,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ohm.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricResistanceUnit.Undefined, ElectricResistance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricResistanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 5321cf1baf..a81d1b6e7f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -69,12 +69,6 @@ public abstract partial class ElectricResistivityTestsBase : QuantityTestsBase protected virtual double PicoohmMetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricResistivity((double)0.0, ElectricResistivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -127,7 +121,7 @@ public void ElectricResistivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricResistivity.Zero, quantityInfo.Zero); Assert.Equal("ElectricResistivity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -433,21 +427,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ohmmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricResistivityUnit.Undefined, ElectricResistivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricResistivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index ea39314e0f..febc4ba405 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class ElectricSurfaceChargeDensityTestsBase : QuantityTe protected virtual double CoulombsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricSurfaceChargeDensity((double)0.0, ElectricSurfaceChargeDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void ElectricSurfaceChargeDensity_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(ElectricSurfaceChargeDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricSurfaceChargeDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricSurfaceChargeDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(coulombpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricSurfaceChargeDensityUnit.Undefined, ElectricSurfaceChargeDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricSurfaceChargeDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 38e9640a94..51d5f589b8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -113,12 +113,6 @@ public abstract partial class EnergyTestsBase : QuantityTestsBase protected virtual double WattHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Energy((double)0.0, EnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -171,7 +165,7 @@ public void Energy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Energy.Zero, quantityInfo.Zero); Assert.Equal("Energy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {EnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -719,21 +713,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joule.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(EnergyUnit.Undefined, Energy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(EnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == EnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 711284e90e..8c2f084179 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -55,12 +55,6 @@ public abstract partial class EntropyTestsBase : QuantityTestsBase protected virtual double MegajoulesPerKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Entropy((double)0.0, EntropyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -113,7 +107,7 @@ public void Entropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Entropy.Zero, quantityInfo.Zero); Assert.Equal("Entropy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {EntropyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -342,21 +336,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(jouleperkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(EntropyUnit.Undefined, Entropy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(EntropyUnit)).Cast(); foreach(var unit in units) { - if(unit == EntropyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index faa6b8341b..a2eaf59b8a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -71,12 +71,6 @@ public abstract partial class ForceChangeRateTestsBase : QuantityTestsBase protected virtual double PoundsForcePerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ForceChangeRate((double)0.0, ForceChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -129,7 +123,7 @@ public void ForceChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ForceChangeRate.Zero, quantityInfo.Zero); Assert.Equal("ForceChangeRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ForceChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -446,21 +440,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ForceChangeRateUnit.Undefined, ForceChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == ForceChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 5875bb78d2..7d7c23ba1f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -117,12 +117,6 @@ public abstract partial class ForcePerLengthTestsBase : QuantityTestsBase protected virtual double TonnesForcePerMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ForcePerLength((double)0.0, ForcePerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -175,7 +169,7 @@ public void ForcePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ForcePerLength.Zero, quantityInfo.Zero); Assert.Equal("ForcePerLength", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ForcePerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -745,21 +739,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ForcePerLengthUnit.Undefined, ForcePerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == ForcePerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 9dfd20416f..9068f13d9a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -71,12 +71,6 @@ public abstract partial class ForceTestsBase : QuantityTestsBase protected virtual double TonnesForceTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Force((double)0.0, ForceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -129,7 +123,7 @@ public void Force_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Force.Zero, quantityInfo.Zero); Assert.Equal("Force", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ForceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -446,21 +440,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newton.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ForceUnit.Undefined, Force.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ForceUnit)).Cast(); foreach(var unit in units) { - if(unit == ForceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index af81a2acd5..a549b32c23 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -63,12 +63,6 @@ public abstract partial class FrequencyTestsBase : QuantityTestsBase protected virtual double TerahertzTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Frequency((double)0.0, FrequencyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -121,7 +115,7 @@ public void Frequency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Frequency.Zero, quantityInfo.Zero); Assert.Equal("Frequency", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {FrequencyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -394,21 +388,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(hertz.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(FrequencyUnit.Undefined, Frequency.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(FrequencyUnit)).Cast(); foreach(var unit in units) { - if(unit == FrequencyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 468bfc0dcf..a804b99abb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class FuelEfficiencyTestsBase : QuantityTestsBase protected virtual double MilesPerUsGallonTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new FuelEfficiency((double)0.0, FuelEfficiencyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void FuelEfficiency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(FuelEfficiency.Zero, quantityInfo.Zero); Assert.Equal("FuelEfficiency", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {FuelEfficiencyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(literper100kilometers.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(FuelEfficiencyUnit.Undefined, FuelEfficiency.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast(); foreach(var unit in units) { - if(unit == FuelEfficiencyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 71d0062f6e..450f126334 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -77,12 +77,6 @@ public abstract partial class HeatFluxTestsBase : QuantityTestsBase protected virtual double WattsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new HeatFlux((double)0.0, HeatFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -135,7 +129,7 @@ public void HeatFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(HeatFlux.Zero, quantityInfo.Zero); Assert.Equal("HeatFlux", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {HeatFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -485,21 +479,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(HeatFluxUnit.Undefined, HeatFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(HeatFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == HeatFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index a891c07e90..fa860ff626 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class HeatTransferCoefficientTestsBase : QuantityTestsBa protected virtual double WattsPerSquareMeterKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new HeatTransferCoefficient((double)0.0, HeatTransferCoefficientUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void HeatTransferCoefficient_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(HeatTransferCoefficient.Zero, quantityInfo.Zero); Assert.Equal("HeatTransferCoefficient", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {HeatTransferCoefficientUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpersquaremeterkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(HeatTransferCoefficientUnit.Undefined, HeatTransferCoefficient.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast(); foreach(var unit in units) { - if(unit == HeatTransferCoefficientUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index e0ccfe7254..7960d07d09 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class IlluminanceTestsBase : QuantityTestsBase protected virtual double MilliluxTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Illuminance((double)0.0, IlluminanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void Illuminance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Illuminance.Zero, quantityInfo.Zero); Assert.Equal("Illuminance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {IlluminanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(lux.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(IlluminanceUnit.Undefined, Illuminance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(IlluminanceUnit)).Cast(); foreach(var unit in units) { - if(unit == IlluminanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 1733094f88..4a365bc177 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -93,12 +93,6 @@ public abstract partial class InformationTestsBase : QuantityTestsBase protected virtual double TerabytesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Information((decimal)0.0, InformationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -139,7 +133,7 @@ public void Information_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Information.Zero, quantityInfo.Zero); Assert.Equal("Information", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {InformationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -564,21 +558,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(bit.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(InformationUnit.Undefined, Information.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(InformationUnit)).Cast(); foreach(var unit in units) { - if(unit == InformationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 707f9f85cc..4e1f41489e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -69,12 +69,6 @@ public abstract partial class IrradianceTestsBase : QuantityTestsBase protected virtual double WattsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Irradiance((double)0.0, IrradianceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -127,7 +121,7 @@ public void Irradiance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Irradiance.Zero, quantityInfo.Zero); Assert.Equal("Irradiance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {IrradianceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -433,21 +427,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(IrradianceUnit.Undefined, Irradiance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(IrradianceUnit)).Cast(); foreach(var unit in units) { - if(unit == IrradianceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 5023608e99..9a9b9e209a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -55,12 +55,6 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase protected virtual double WattHoursPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Irradiation((double)0.0, IrradiationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -113,7 +107,7 @@ public void Irradiation_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Irradiation.Zero, quantityInfo.Zero); Assert.Equal("Irradiation", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {IrradiationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -342,21 +336,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(IrradiationUnit.Undefined, Irradiation.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(IrradiationUnit)).Cast(); foreach(var unit in units) { - if(unit == IrradiationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 9c5d16b941..aaf65659ab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -59,12 +59,6 @@ public abstract partial class KinematicViscosityTestsBase : QuantityTestsBase protected virtual double StokesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new KinematicViscosity((double)0.0, KinematicViscosityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -117,7 +111,7 @@ public void KinematicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(KinematicViscosity.Zero, quantityInfo.Zero); Assert.Equal("KinematicViscosity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {KinematicViscosityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -368,21 +362,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(squaremeterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(KinematicViscosityUnit.Undefined, KinematicViscosity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast(); foreach(var unit in units) { - if(unit == KinematicViscosityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 0547485dd6..3e956283ce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class LapseRateTestsBase : QuantityTestsBase protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LapseRate((double)0.0, LapseRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void LapseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LapseRate.Zero, quantityInfo.Zero); Assert.Equal("LapseRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LapseRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(degreecelsiusperkilometer.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LapseRateUnit.Undefined, LapseRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LapseRateUnit)).Cast(); foreach(var unit in units) { - if(unit == LapseRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 70be45e183..c80f5ba361 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -107,12 +107,6 @@ public abstract partial class LengthTestsBase : QuantityTestsBase protected virtual double YardsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Length((double)0.0, LengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -165,7 +159,7 @@ public void Length_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Length.Zero, quantityInfo.Zero); Assert.Equal("Length", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -680,21 +674,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(meter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LengthUnit.Undefined, Length.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LengthUnit)).Cast(); foreach(var unit in units) { - if(unit == LengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 9e8fc5c024..284798fc6f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -45,12 +45,6 @@ public abstract partial class LevelTestsBase : QuantityTestsBase protected virtual double NepersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Level((double)0.0, LevelUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -103,7 +97,7 @@ public void Level_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Level.Zero, quantityInfo.Zero); Assert.Equal("Level", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LevelUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -281,21 +275,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibel.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LevelUnit.Undefined, Level.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LevelUnit)).Cast(); foreach(var unit in units) { - if(unit == LevelUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index c1bc525fe3..f701f6657b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -69,12 +69,6 @@ public abstract partial class LinearDensityTestsBase : QuantityTestsBase protected virtual double PoundsPerInchTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LinearDensity((double)0.0, LinearDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -127,7 +121,7 @@ public void LinearDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LinearDensity.Zero, quantityInfo.Zero); Assert.Equal("LinearDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LinearDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -433,21 +427,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LinearDensityUnit.Undefined, LinearDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LinearDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == LinearDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 19170d5fbb..1f0b617d67 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -91,12 +91,6 @@ public abstract partial class LinearPowerDensityTestsBase : QuantityTestsBase protected virtual double WattsPerMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LinearPowerDensity((double)0.0, LinearPowerDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -149,7 +143,7 @@ public void LinearPowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(LinearPowerDensity.Zero, quantityInfo.Zero); Assert.Equal("LinearPowerDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LinearPowerDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -576,21 +570,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LinearPowerDensityUnit.Undefined, LinearPowerDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == LinearPowerDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 54fbec51ae..5b0c19490f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -69,12 +69,6 @@ public abstract partial class LuminosityTestsBase : QuantityTestsBase protected virtual double WattsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Luminosity((double)0.0, LuminosityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -127,7 +121,7 @@ public void Luminosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Luminosity.Zero, quantityInfo.Zero); Assert.Equal("Luminosity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LuminosityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -433,21 +427,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(watt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LuminosityUnit.Undefined, Luminosity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LuminosityUnit)).Cast(); foreach(var unit in units) { - if(unit == LuminosityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 1a74dec784..1a8d2c2e91 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class LuminousFluxTestsBase : QuantityTestsBase protected virtual double LumensTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LuminousFlux((double)0.0, LuminousFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void LuminousFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LuminousFlux.Zero, quantityInfo.Zero); Assert.Equal("LuminousFlux", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LuminousFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(lumen.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LuminousFluxUnit.Undefined, LuminousFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LuminousFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == LuminousFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index da9f2c8f4e..9a95a877c7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class LuminousIntensityTestsBase : QuantityTestsBase protected virtual double CandelaTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LuminousIntensity((double)0.0, LuminousIntensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void LuminousIntensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(LuminousIntensity.Zero, quantityInfo.Zero); Assert.Equal("LuminousIntensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {LuminousIntensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(candela.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LuminousIntensityUnit.Undefined, LuminousIntensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast(); foreach(var unit in units) { - if(unit == LuminousIntensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 16ed475c5d..9a81b2facd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -53,12 +53,6 @@ public abstract partial class MagneticFieldTestsBase : QuantityTestsBase protected virtual double TeslasTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MagneticField((double)0.0, MagneticFieldUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -111,7 +105,7 @@ public void MagneticField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MagneticField.Zero, quantityInfo.Zero); Assert.Equal("MagneticField", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFieldUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -329,21 +323,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(tesla.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MagneticFieldUnit.Undefined, MagneticField.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MagneticFieldUnit)).Cast(); foreach(var unit in units) { - if(unit == MagneticFieldUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index ec8ddfb7e7..2f48f4d77b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class MagneticFluxTestsBase : QuantityTestsBase protected virtual double WebersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MagneticFlux((double)0.0, MagneticFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void MagneticFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MagneticFlux.Zero, quantityInfo.Zero); Assert.Equal("MagneticFlux", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(weber.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MagneticFluxUnit.Undefined, MagneticFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MagneticFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == MagneticFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index b26a15e9ac..3e6a29e224 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class MagnetizationTestsBase : QuantityTestsBase protected virtual double AmperesPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Magnetization((double)0.0, MagnetizationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void Magnetization_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Magnetization.Zero, quantityInfo.Zero); Assert.Equal("Magnetization", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MagnetizationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amperepermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MagnetizationUnit.Undefined, Magnetization.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MagnetizationUnit)).Cast(); foreach(var unit in units) { - if(unit == MagnetizationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index aae29e2b4f..9c90e23d23 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -139,12 +139,6 @@ public abstract partial class MassConcentrationTestsBase : QuantityTestsBase protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassConcentration((double)0.0, MassConcentrationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -197,7 +191,7 @@ public void MassConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(MassConcentration.Zero, quantityInfo.Zero); Assert.Equal("MassConcentration", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MassConcentrationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -888,21 +882,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassConcentrationUnit.Undefined, MassConcentration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassConcentrationUnit)).Cast(); foreach(var unit in units) { - if(unit == MassConcentrationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 5525ce02f4..8b072767b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -107,12 +107,6 @@ public abstract partial class MassFlowTestsBase : QuantityTestsBase protected virtual double TonnesPerHourTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassFlow((double)0.0, MassFlowUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -165,7 +159,7 @@ public void MassFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFlow.Zero, quantityInfo.Zero); Assert.Equal("MassFlow", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MassFlowUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -680,21 +674,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(grampersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassFlowUnit.Undefined, MassFlow.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassFlowUnit)).Cast(); foreach(var unit in units) { - if(unit == MassFlowUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index c714d53afe..f8e52b51e6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -65,12 +65,6 @@ public abstract partial class MassFluxTestsBase : QuantityTestsBase protected virtual double KilogramsPerSecondPerSquareMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassFlux((double)0.0, MassFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -123,7 +117,7 @@ public void MassFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFlux.Zero, quantityInfo.Zero); Assert.Equal("MassFlux", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MassFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -407,21 +401,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampersecondpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassFluxUnit.Undefined, MassFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == MassFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index a55be4828b..75a04e6d0e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -89,12 +89,6 @@ public abstract partial class MassFractionTestsBase : QuantityTestsBase protected virtual double PercentTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassFraction((double)0.0, MassFractionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -147,7 +141,7 @@ public void MassFraction_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFraction.Zero, quantityInfo.Zero); Assert.Equal("MassFraction", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MassFractionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -563,21 +557,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassFractionUnit.Undefined, MassFraction.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassFractionUnit)).Cast(); foreach(var unit in units) { - if(unit == MassFractionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 46c9980368..bd6644ab28 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -97,12 +97,6 @@ public abstract partial class MassMomentOfInertiaTestsBase : QuantityTestsBase protected virtual double TonneSquareMilimetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassMomentOfInertia((double)0.0, MassMomentOfInertiaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -155,7 +149,7 @@ public void MassMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(MassMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("MassMomentOfInertia", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MassMomentOfInertiaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -615,21 +609,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogramsquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassMomentOfInertiaUnit.Undefined, MassMomentOfInertia.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast(); foreach(var unit in units) { - if(unit == MassMomentOfInertiaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 7733cb647a..5559377230 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -91,12 +91,6 @@ public abstract partial class MassTestsBase : QuantityTestsBase protected virtual double TonnesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Mass((double)0.0, MassUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -149,7 +143,7 @@ public void Mass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Mass.Zero, quantityInfo.Zero); Assert.Equal("Mass", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MassUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -576,21 +570,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogram.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassUnit.Undefined, Mass.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassUnit)).Cast(); foreach(var unit in units) { - if(unit == MassUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 17dc5979f9..42eb69e369 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class MolarEnergyTestsBase : QuantityTestsBase protected virtual double MegajoulesPerMoleTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MolarEnergy((double)0.0, MolarEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void MolarEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarEnergy.Zero, quantityInfo.Zero); Assert.Equal("MolarEnergy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepermole.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarEnergyUnit.Undefined, MolarEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 8c8850d5be..751a802e09 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class MolarEntropyTestsBase : QuantityTestsBase protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MolarEntropy((double)0.0, MolarEntropyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void MolarEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarEntropy.Zero, quantityInfo.Zero); Assert.Equal("MolarEntropy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarEntropyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepermolekelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarEntropyUnit.Undefined, MolarEntropy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarEntropyUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarEntropyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index eb7c97bb69..c8b89dd0bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -65,12 +65,6 @@ public abstract partial class MolarMassTestsBase : QuantityTestsBase protected virtual double PoundsPerMoleTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MolarMass((double)0.0, MolarMassUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -123,7 +117,7 @@ public void MolarMass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarMass.Zero, quantityInfo.Zero); Assert.Equal("MolarMass", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarMassUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -407,21 +401,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampermole.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarMassUnit.Undefined, MolarMass.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarMassUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarMassUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 152f62104c..7811d0c762 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -57,12 +57,6 @@ public abstract partial class MolarityTestsBase : QuantityTestsBase protected virtual double PicomolesPerLiterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Molarity((double)0.0, MolarityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -115,7 +109,7 @@ public void Molarity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Molarity.Zero, quantityInfo.Zero); Assert.Equal("Molarity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -355,21 +349,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(molespercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarityUnit.Undefined, Molarity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarityUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 731cadc6a0..16b5c9cc05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class PermeabilityTestsBase : QuantityTestsBase protected virtual double HenriesPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Permeability((double)0.0, PermeabilityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void Permeability_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Permeability.Zero, quantityInfo.Zero); Assert.Equal("Permeability", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PermeabilityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(henrypermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PermeabilityUnit.Undefined, Permeability.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PermeabilityUnit)).Cast(); foreach(var unit in units) { - if(unit == PermeabilityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 5f2bea4f41..086ab3dae5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class PermittivityTestsBase : QuantityTestsBase protected virtual double FaradsPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Permittivity((double)0.0, PermittivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void Permittivity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Permittivity.Zero, quantityInfo.Zero); Assert.Equal("Permittivity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PermittivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(faradpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PermittivityUnit.Undefined, Permittivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PermittivityUnit)).Cast(); foreach(var unit in units) { - if(unit == PermittivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 46503289e2..eb3ab798a1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -129,12 +129,6 @@ public abstract partial class PowerDensityTestsBase : QuantityTestsBase protected virtual double WattsPerLiterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new PowerDensity((double)0.0, PowerDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -187,7 +181,7 @@ public void PowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(PowerDensity.Zero, quantityInfo.Zero); Assert.Equal("PowerDensity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PowerDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -823,21 +817,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PowerDensityUnit.Undefined, PowerDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PowerDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == PowerDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index f7817f52b6..869baf3bed 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -45,12 +45,6 @@ public abstract partial class PowerRatioTestsBase : QuantityTestsBase protected virtual double DecibelWattsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new PowerRatio((double)0.0, PowerRatioUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -103,7 +97,7 @@ public void PowerRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(PowerRatio.Zero, quantityInfo.Zero); Assert.Equal("PowerRatio", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PowerRatioUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -281,21 +275,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibelwatt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PowerRatioUnit.Undefined, PowerRatio.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PowerRatioUnit)).Cast(); foreach(var unit in units) { - if(unit == PowerRatioUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 22cd9e08f6..9b088e3797 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -91,12 +91,6 @@ public abstract partial class PowerTestsBase : QuantityTestsBase protected virtual double WattsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Power((decimal)0.0, PowerUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -137,7 +131,7 @@ public void Power_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Power.Zero, quantityInfo.Zero); Assert.Equal("Power", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PowerUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -551,21 +545,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(watt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PowerUnit.Undefined, Power.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PowerUnit)).Cast(); foreach(var unit in units) { - if(unit == PowerUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 87ea64ef9f..fdd01e5884 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -67,12 +67,6 @@ public abstract partial class PressureChangeRateTestsBase : QuantityTestsBase protected virtual double PoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new PressureChangeRate((double)0.0, PressureChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -125,7 +119,7 @@ public void PressureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(PressureChangeRate.Zero, quantityInfo.Zero); Assert.Equal("PressureChangeRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PressureChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -420,21 +414,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(pascalpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PressureChangeRateUnit.Undefined, PressureChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == PressureChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index cc7d8b733e..9e49e170b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -129,12 +129,6 @@ public abstract partial class PressureTestsBase : QuantityTestsBase protected virtual double TorrsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Pressure((double)0.0, PressureUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -187,7 +181,7 @@ public void Pressure_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Pressure.Zero, quantityInfo.Zero); Assert.Equal("Pressure", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {PressureUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -823,21 +817,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(pascal.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PressureUnit.Undefined, Pressure.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PressureUnit)).Cast(); foreach(var unit in units) { - if(unit == PressureUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index e5a8d75f97..d39cf73b69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -45,12 +45,6 @@ public abstract partial class RatioChangeRateTestsBase : QuantityTestsBase protected virtual double PercentsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RatioChangeRate((double)0.0, RatioChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -103,7 +97,7 @@ public void RatioChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(RatioChangeRate.Zero, quantityInfo.Zero); Assert.Equal("RatioChangeRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RatioChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -277,21 +271,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfractionpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RatioChangeRateUnit.Undefined, RatioChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == RatioChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 84c33e88b5..e7e44bd5d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -53,12 +53,6 @@ public abstract partial class RatioTestsBase : QuantityTestsBase protected virtual double PercentTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Ratio((double)0.0, RatioUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -111,7 +105,7 @@ public void Ratio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Ratio.Zero, quantityInfo.Zero); Assert.Equal("Ratio", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RatioUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -329,21 +323,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RatioUnit.Undefined, Ratio.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RatioUnit)).Cast(); foreach(var unit in units) { - if(unit == RatioUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 94b91dfae0..d8b610e0c3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class ReactiveEnergyTestsBase : QuantityTestsBase protected virtual double VoltampereReactiveHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReactiveEnergy((double)0.0, ReactiveEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void ReactiveEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReactiveEnergy.Zero, quantityInfo.Zero); Assert.Equal("ReactiveEnergy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ReactiveEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltamperereactivehour.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReactiveEnergyUnit.Undefined, ReactiveEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == ReactiveEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 5464222e57..3b842c8bf2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class ReactivePowerTestsBase : QuantityTestsBase protected virtual double VoltamperesReactiveTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReactivePower((double)0.0, ReactivePowerUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void ReactivePower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReactivePower.Zero, quantityInfo.Zero); Assert.Equal("ReactivePower", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ReactivePowerUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltamperereactive.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReactivePowerUnit.Undefined, ReactivePower.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReactivePowerUnit)).Cast(); foreach(var unit in units) { - if(unit == ReactivePowerUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 0fabdbb37f..ad92683bb0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -63,12 +63,6 @@ public abstract partial class ReciprocalAreaTestsBase : QuantityTestsBase protected virtual double InverseUsSurveySquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReciprocalArea((double)0.0, ReciprocalAreaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -121,7 +115,7 @@ public void ReciprocalArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReciprocalArea.Zero, quantityInfo.Zero); Assert.Equal("ReciprocalArea", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalAreaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -394,21 +388,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(inversesquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReciprocalAreaUnit.Undefined, ReciprocalArea.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast(); foreach(var unit in units) { - if(unit == ReciprocalAreaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 62b9b78790..ee40d44c71 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -61,12 +61,6 @@ public abstract partial class ReciprocalLengthTestsBase : QuantityTestsBase protected virtual double InverseYardsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReciprocalLength((double)0.0, ReciprocalLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -119,7 +113,7 @@ public void ReciprocalLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(ReciprocalLength.Zero, quantityInfo.Zero); Assert.Equal("ReciprocalLength", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -381,21 +375,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(inversemeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReciprocalLengthUnit.Undefined, ReciprocalLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == ReciprocalLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 8a12a4c70d..b63927f037 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class RelativeHumidityTestsBase : QuantityTestsBase protected virtual double PercentTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RelativeHumidity((double)0.0, RelativeHumidityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void RelativeHumidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(RelativeHumidity.Zero, quantityInfo.Zero); Assert.Equal("RelativeHumidity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RelativeHumidityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(percent.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RelativeHumidityUnit.Undefined, RelativeHumidity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast(); foreach(var unit in units) { - if(unit == RelativeHumidityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index fb226a255b..0707551ef8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class RotationalAccelerationTestsBase : QuantityTestsBas protected virtual double RevolutionsPerSecondSquaredTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalAcceleration((double)0.0, RotationalAccelerationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void RotationalAcceleration_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(RotationalAcceleration.Zero, quantityInfo.Zero); Assert.Equal("RotationalAcceleration", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalAccelerationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(radianpersecondsquared.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalAccelerationUnit.Undefined, RotationalAcceleration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalAccelerationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 84c1bd4e8b..a709595d3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -67,12 +67,6 @@ public abstract partial class RotationalSpeedTestsBase : QuantityTestsBase protected virtual double RevolutionsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalSpeed((double)0.0, RotationalSpeedUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -125,7 +119,7 @@ public void RotationalSpeed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(RotationalSpeed.Zero, quantityInfo.Zero); Assert.Equal("RotationalSpeed", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalSpeedUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -420,21 +414,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(radianpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalSpeedUnit.Undefined, RotationalSpeed.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalSpeedUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 35e7db379d..61b5cbdd4b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -51,12 +51,6 @@ public abstract partial class RotationalStiffnessPerLengthTestsBase : QuantityTe protected virtual double PoundForceFeetPerDegreesPerFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalStiffnessPerLength((double)0.0, RotationalStiffnessPerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -109,7 +103,7 @@ public void RotationalStiffnessPerLength_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(RotationalStiffnessPerLength.Zero, quantityInfo.Zero); Assert.Equal("RotationalStiffnessPerLength", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessPerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -316,21 +310,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeterperradianpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalStiffnessPerLengthUnit.Undefined, RotationalStiffnessPerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalStiffnessPerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 912e63f77e..17a107e34b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -107,12 +107,6 @@ public abstract partial class RotationalStiffnessTestsBase : QuantityTestsBase protected virtual double PoundForceFeetPerDegreesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalStiffness((double)0.0, RotationalStiffnessUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -165,7 +159,7 @@ public void RotationalStiffness_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(RotationalStiffness.Zero, quantityInfo.Zero); Assert.Equal("RotationalStiffness", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -680,21 +674,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeterperradian.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalStiffnessUnit.Undefined, RotationalStiffness.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalStiffnessUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index bf9ba33eeb..3d1c9d1e94 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class ScalarTestsBase : QuantityTestsBase protected virtual double AmountTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Scalar((double)0.0, ScalarUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void Scalar_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Scalar.Zero, quantityInfo.Zero); Assert.Equal("Scalar", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ScalarUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amount.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ScalarUnit.Undefined, Scalar.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ScalarUnit)).Cast(); foreach(var unit in units) { - if(unit == ScalarUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index b65e7b2a4f..8cc029e14e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class SolidAngleTestsBase : QuantityTestsBase protected virtual double SteradiansTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SolidAngle((double)0.0, SolidAngleUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void SolidAngle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SolidAngle.Zero, quantityInfo.Zero); Assert.Equal("SolidAngle", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SolidAngleUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(steradian.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SolidAngleUnit.Undefined, SolidAngle.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SolidAngleUnit)).Cast(); foreach(var unit in units) { - if(unit == SolidAngleUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 9a0e0d5f05..85416f5cdf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -91,12 +91,6 @@ public abstract partial class SpecificEnergyTestsBase : QuantityTestsBase protected virtual double WattHoursPerKilogramTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificEnergy((double)0.0, SpecificEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -149,7 +143,7 @@ public void SpecificEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificEnergy.Zero, quantityInfo.Zero); Assert.Equal("SpecificEnergy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -576,21 +570,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(jouleperkilogram.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificEnergyUnit.Undefined, SpecificEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 65481090e4..b62b6d96a2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -59,12 +59,6 @@ public abstract partial class SpecificEntropyTestsBase : QuantityTestsBase protected virtual double MegajoulesPerKilogramKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificEntropy((double)0.0, SpecificEntropyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -117,7 +111,7 @@ public void SpecificEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificEntropy.Zero, quantityInfo.Zero); Assert.Equal("SpecificEntropy", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEntropyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -368,21 +362,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(jouleperkilogramkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificEntropyUnit.Undefined, SpecificEntropy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificEntropyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 466865ad45..79e6a7341f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -49,12 +49,6 @@ public abstract partial class SpecificFuelConsumptionTestsBase : QuantityTestsBa protected virtual double PoundsMassPerPoundForceHourTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificFuelConsumption((double)0.0, SpecificFuelConsumptionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -107,7 +101,7 @@ public void SpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(SpecificFuelConsumption.Zero, quantityInfo.Zero); Assert.Equal("SpecificFuelConsumption", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificFuelConsumptionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -303,21 +297,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(gramperkilonewtonsecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificFuelConsumptionUnit.Undefined, SpecificFuelConsumption.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificFuelConsumptionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 42bb9b2d09..d6d86d0344 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -47,12 +47,6 @@ public abstract partial class SpecificVolumeTestsBase : QuantityTestsBase protected virtual double MillicubicMetersPerKilogramTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificVolume((double)0.0, SpecificVolumeUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -105,7 +99,7 @@ public void SpecificVolume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificVolume.Zero, quantityInfo.Zero); Assert.Equal("SpecificVolume", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificVolumeUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -290,21 +284,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterperkilogram.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificVolumeUnit.Undefined, SpecificVolume.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificVolumeUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 9c54526bfa..c8a96a481c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -75,12 +75,6 @@ public abstract partial class SpecificWeightTestsBase : QuantityTestsBase protected virtual double TonnesForcePerCubicMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificWeight((double)0.0, SpecificWeightUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -133,7 +127,7 @@ public void SpecificWeight_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificWeight.Zero, quantityInfo.Zero); Assert.Equal("SpecificWeight", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificWeightUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -472,21 +466,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonpercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificWeightUnit.Undefined, SpecificWeight.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificWeightUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificWeightUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index badb0e3dfe..515f48b7be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -105,12 +105,6 @@ public abstract partial class SpeedTestsBase : QuantityTestsBase protected virtual double YardsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Speed((double)0.0, SpeedUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -163,7 +157,7 @@ public void Speed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Speed.Zero, quantityInfo.Zero); Assert.Equal("Speed", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {SpeedUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -667,21 +661,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(meterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpeedUnit.Undefined, Speed.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpeedUnit)).Cast(); foreach(var unit in units) { - if(unit == SpeedUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 3e9dd9ce9a..24c5cafbc2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -59,12 +59,6 @@ public abstract partial class StandardVolumeFlowTestsBase : QuantityTestsBase protected virtual double StandardLitersPerMinuteTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new StandardVolumeFlow((double)0.0, StandardVolumeFlowUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -117,7 +111,7 @@ public void StandardVolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(StandardVolumeFlow.Zero, quantityInfo.Zero); Assert.Equal("StandardVolumeFlow", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {StandardVolumeFlowUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -368,21 +362,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(standardcubicmeterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(StandardVolumeFlowUnit.Undefined, StandardVolumeFlow.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast(); foreach(var unit in units) { - if(unit == StandardVolumeFlowUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index d0142ec5d0..11e4d6b737 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -61,12 +61,6 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase protected virtual double NanodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TemperatureChangeRate((double)0.0, TemperatureChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -119,7 +113,7 @@ public void TemperatureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuan Assert.Equal(TemperatureChangeRate.Zero, quantityInfo.Zero); Assert.Equal("TemperatureChangeRate", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -381,21 +375,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(degreecelsiuspersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureChangeRateUnit.Undefined, TemperatureChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 7e727b5d53..842a13aea3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -59,12 +59,6 @@ public abstract partial class TemperatureDeltaTestsBase : QuantityTestsBase protected virtual double MillidegreesCelsiusTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TemperatureDelta((double)0.0, TemperatureDeltaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -117,7 +111,7 @@ public void TemperatureDelta_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(TemperatureDelta.Zero, quantityInfo.Zero); Assert.Equal("TemperatureDelta", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureDeltaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -368,21 +362,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureDeltaUnit.Undefined, TemperatureDelta.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureDeltaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 24c065a159..4708c35505 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -61,12 +61,6 @@ public abstract partial class TemperatureTestsBase : QuantityTestsBase protected virtual double SolarTemperaturesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Temperature((double)0.0, TemperatureUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -119,7 +113,7 @@ public void Temperature_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Temperature.Zero, quantityInfo.Zero); Assert.Equal("Temperature", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -369,21 +363,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureUnit.Undefined, Temperature.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index c09c444f10..8c08d0df0b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -45,12 +45,6 @@ public abstract partial class ThermalConductivityTestsBase : QuantityTestsBase protected virtual double WattsPerMeterKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ThermalConductivity((double)0.0, ThermalConductivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -103,7 +97,7 @@ public void ThermalConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ThermalConductivity.Zero, quantityInfo.Zero); Assert.Equal("ThermalConductivity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ThermalConductivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -277,21 +271,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpermeterkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ThermalConductivityUnit.Undefined, ThermalConductivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast(); foreach(var unit in units) { - if(unit == ThermalConductivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index f9b088d081..0416e507af 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -51,12 +51,6 @@ public abstract partial class ThermalResistanceTestsBase : QuantityTestsBase protected virtual double SquareMeterKelvinsPerKilowattTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ThermalResistance((double)0.0, ThermalResistanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -109,7 +103,7 @@ public void ThermalResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(ThermalResistance.Zero, quantityInfo.Zero); Assert.Equal("ThermalResistance", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {ThermalResistanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -316,21 +310,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(squaremeterkelvinperkilowatt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ThermalResistanceUnit.Undefined, ThermalResistance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ThermalResistanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 8201166b49..6da638243a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -83,12 +83,6 @@ public abstract partial class TorquePerLengthTestsBase : QuantityTestsBase protected virtual double TonneForceMillimetersPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TorquePerLength((double)0.0, TorquePerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -141,7 +135,7 @@ public void TorquePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(TorquePerLength.Zero, quantityInfo.Zero); Assert.Equal("TorquePerLength", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {TorquePerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -524,21 +518,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeterpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TorquePerLengthUnit.Undefined, TorquePerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == TorquePerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index a6a91a44d8..7d035d938c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -85,12 +85,6 @@ public abstract partial class TorqueTestsBase : QuantityTestsBase protected virtual double TonneForceMillimetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Torque((double)0.0, TorqueUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -143,7 +137,7 @@ public void Torque_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Torque.Zero, quantityInfo.Zero); Assert.Equal("Torque", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {TorqueUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -537,21 +531,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TorqueUnit.Undefined, Torque.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TorqueUnit)).Cast(); foreach(var unit in units) { - if(unit == TorqueUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 75b1af7686..c6fdbd05ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class TurbidityTestsBase : QuantityTestsBase protected virtual double NTUTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Turbidity((double)0.0, TurbidityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void Turbidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Turbidity.Zero, quantityInfo.Zero); Assert.Equal("Turbidity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {TurbidityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ntu.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TurbidityUnit.Undefined, Turbidity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TurbidityUnit)).Cast(); foreach(var unit in units) { - if(unit == TurbidityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 032d274ded..5117d2667a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -43,12 +43,6 @@ public abstract partial class VitaminATestsBase : QuantityTestsBase protected virtual double InternationalUnitsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VitaminA((double)0.0, VitaminAUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -101,7 +95,7 @@ public void VitaminA_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VitaminA.Zero, quantityInfo.Zero); Assert.Equal("VitaminA", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {VitaminAUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -264,21 +258,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(internationalunit.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VitaminAUnit.Undefined, VitaminA.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VitaminAUnit)).Cast(); foreach(var unit in units) { - if(unit == VitaminAUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 8b9a1ae06c..0fe24b0b44 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -81,12 +81,6 @@ public abstract partial class VolumeConcentrationTestsBase : QuantityTestsBase protected virtual double PicolitersPerMililiterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumeConcentration((double)0.0, VolumeConcentrationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -139,7 +133,7 @@ public void VolumeConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(VolumeConcentration.Zero, quantityInfo.Zero); Assert.Equal("VolumeConcentration", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeConcentrationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -511,21 +505,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeConcentrationUnit.Undefined, VolumeConcentration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeConcentrationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 9ad6d05ebd..73e7760ddb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -153,12 +153,6 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase protected virtual double UsGallonsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumeFlow((double)0.0, VolumeFlowUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -211,7 +205,7 @@ public void VolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VolumeFlow.Zero, quantityInfo.Zero); Assert.Equal("VolumeFlow", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeFlowUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -979,21 +973,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeFlowUnit.Undefined, VolumeFlow.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeFlowUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeFlowUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 9eff21be27..acff9ac547 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -55,12 +55,6 @@ public abstract partial class VolumePerLengthTestsBase : QuantityTestsBase protected virtual double OilBarrelsPerFootTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumePerLength((double)0.0, VolumePerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -113,7 +107,7 @@ public void VolumePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VolumePerLength.Zero, quantityInfo.Zero); Assert.Equal("VolumePerLength", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumePerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -342,21 +336,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumePerLengthUnit.Undefined, VolumePerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumePerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 55e7de73ac..861325bb7c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -143,12 +143,6 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase protected virtual double UsTeaspoonsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Volume((double)0.0, VolumeUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -201,7 +195,7 @@ public void Volume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Volume.Zero, quantityInfo.Zero); Assert.Equal("Volume", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -914,21 +908,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeUnit.Undefined, Volume.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 6ec9034c39..36311bd6e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -59,12 +59,6 @@ public abstract partial class VolumetricHeatCapacityTestsBase : QuantityTestsBas protected virtual double MegajoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumetricHeatCapacity((double)0.0, VolumetricHeatCapacityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -117,7 +111,7 @@ public void VolumetricHeatCapacity_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(VolumetricHeatCapacity.Zero, quantityInfo.Zero); Assert.Equal("VolumetricHeatCapacity", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumetricHeatCapacityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -368,21 +362,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepercubicmeterkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumetricHeatCapacityUnit.Undefined, VolumetricHeatCapacity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumetricHeatCapacityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 3fc3a5c095..b6be03e8a5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -53,12 +53,6 @@ public abstract partial class WarpingMomentOfInertiaTestsBase : QuantityTestsBas protected virtual double MillimetersToTheSixthTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new WarpingMomentOfInertia((double)0.0, WarpingMomentOfInertiaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -111,7 +105,7 @@ public void WarpingMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(WarpingMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("WarpingMomentOfInertia", quantityInfo.Name); - var units = EnumUtils.GetEnumValues().Except(new[] {WarpingMomentOfInertiaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); } @@ -329,21 +323,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(metertothesixth.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(WarpingMomentOfInertiaUnit.Undefined, WarpingMomentOfInertia.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast(); foreach(var unit in units) { - if(unit == WarpingMomentOfInertiaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 97a70387c1..4dffcfd92c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -81,9 +81,6 @@ static Acceleration() /// If value is NaN or Infinity. public Acceleration(double value, AccelerationUnit unit) { - if(unit == AccelerationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,7 +122,7 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// All units of measurement for the Acceleration quantity. /// - public static AccelerationUnit[] Units { get; } = Enum.GetValues(typeof(AccelerationUnit)).Cast().Except(new AccelerationUnit[]{ AccelerationUnit.Undefined }).ToArray(); + public static AccelerationUnit[] Units { get; } = Enum.GetValues(typeof(AccelerationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecondSquared. diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 9890bc0981..664a0978d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -82,9 +82,6 @@ static AmountOfSubstance() /// If value is NaN or Infinity. public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) { - if(unit == AmountOfSubstanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,7 +123,7 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// All units of measurement for the AmountOfSubstance quantity. /// - public static AmountOfSubstanceUnit[] Units { get; } = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().Except(new AmountOfSubstanceUnit[]{ AmountOfSubstanceUnit.Undefined }).ToArray(); + public static AmountOfSubstanceUnit[] Units { get; } = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Mole. diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 3f9097e645..e5579bef32 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -71,9 +71,6 @@ static AmplitudeRatio() /// If value is NaN or Infinity. public AmplitudeRatio(double value, AmplitudeRatioUnit unit) { - if(unit == AmplitudeRatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// All units of measurement for the AmplitudeRatio quantity. /// - public static AmplitudeRatioUnit[] Units { get; } = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().Except(new AmplitudeRatioUnit[]{ AmplitudeRatioUnit.Undefined }).ToArray(); + public static AmplitudeRatioUnit[] Units { get; } = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecibelVolt. diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 90d782401e..7adf61cdd1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -83,9 +83,6 @@ static Angle() /// If value is NaN or Infinity. public Angle(double value, AngleUnit unit) { - if(unit == AngleUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -127,7 +124,7 @@ public Angle(double value, UnitSystem unitSystem) /// /// All units of measurement for the Angle quantity. /// - public static AngleUnit[] Units { get; } = Enum.GetValues(typeof(AngleUnit)).Cast().Except(new AngleUnit[]{ AngleUnit.Undefined }).ToArray(); + public static AngleUnit[] Units { get; } = Enum.GetValues(typeof(AngleUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Degree. diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index af34e41f09..ef3f649613 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -70,9 +70,6 @@ static ApparentEnergy() /// If value is NaN or Infinity. public ApparentEnergy(double value, ApparentEnergyUnit unit) { - if(unit == ApparentEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// All units of measurement for the ApparentEnergy quantity. /// - public static ApparentEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().Except(new ApparentEnergyUnit[]{ ApparentEnergyUnit.Undefined }).ToArray(); + public static ApparentEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereHour. diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 00704d3077..9a64a654f2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -71,9 +71,6 @@ static ApparentPower() /// If value is NaN or Infinity. public ApparentPower(double value, ApparentPowerUnit unit) { - if(unit == ApparentPowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// All units of measurement for the ApparentPower quantity. /// - public static ApparentPowerUnit[] Units { get; } = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().Except(new ApparentPowerUnit[]{ ApparentPowerUnit.Undefined }).ToArray(); + public static ApparentPowerUnit[] Units { get; } = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Voltampere. diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 8726105ac7..3d1806373f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -81,9 +81,6 @@ static Area() /// If value is NaN or Infinity. public Area(double value, AreaUnit unit) { - if(unit == AreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,7 +122,7 @@ public Area(double value, UnitSystem unitSystem) /// /// All units of measurement for the Area quantity. /// - public static AreaUnit[] Units { get; } = Enum.GetValues(typeof(AreaUnit)).Cast().Except(new AreaUnit[]{ AreaUnit.Undefined }).ToArray(); + public static AreaUnit[] Units { get; } = Enum.GetValues(typeof(AreaUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index df417da1e7..e2d43ad733 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -68,9 +68,6 @@ static AreaDensity() /// If value is NaN or Infinity. public AreaDensity(double value, AreaDensityUnit unit) { - if(unit == AreaDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -112,7 +109,7 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the AreaDensity quantity. /// - public static AreaDensityUnit[] Units { get; } = Enum.GetValues(typeof(AreaDensityUnit)).Cast().Except(new AreaDensityUnit[]{ AreaDensityUnit.Undefined }).ToArray(); + public static AreaDensityUnit[] Units { get; } = Enum.GetValues(typeof(AreaDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index f709471cfa..236e4591bd 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -73,9 +73,6 @@ static AreaMomentOfInertia() /// If value is NaN or Infinity. public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) { - if(unit == AreaMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// All units of measurement for the AreaMomentOfInertia quantity. /// - public static AreaMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().Except(new AreaMomentOfInertiaUnit[]{ AreaMomentOfInertiaUnit.Undefined }).ToArray(); + public static AreaMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheFourth. diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index c5960ed0b4..7ea5cd85ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -96,9 +96,6 @@ static BitRate() /// If value is NaN or Infinity. public BitRate(decimal value, BitRateUnit unit) { - if(unit == BitRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; _unit = unit; } @@ -140,7 +137,7 @@ public BitRate(decimal value, UnitSystem unitSystem) /// /// All units of measurement for the BitRate quantity. /// - public static BitRateUnit[] Units { get; } = Enum.GetValues(typeof(BitRateUnit)).Cast().Except(new BitRateUnit[]{ BitRateUnit.Undefined }).ToArray(); + public static BitRateUnit[] Units { get; } = Enum.GetValues(typeof(BitRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit BitPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 8c6945d91c..5aa8fb3069 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -70,9 +70,6 @@ static BrakeSpecificFuelConsumption() /// If value is NaN or Infinity. public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) { - if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// All units of measurement for the BrakeSpecificFuelConsumption quantity. /// - public static BrakeSpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().Except(new BrakeSpecificFuelConsumptionUnit[]{ BrakeSpecificFuelConsumptionUnit.Undefined }).ToArray(); + public static BrakeSpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerJoule. diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index a8bce3fea6..e6540218a5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -77,9 +77,6 @@ static Capacitance() /// If value is NaN or Infinity. public Capacitance(double value, CapacitanceUnit unit) { - if(unit == CapacitanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,7 +118,7 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// All units of measurement for the Capacitance quantity. /// - public static CapacitanceUnit[] Units { get; } = Enum.GetValues(typeof(CapacitanceUnit)).Cast().Except(new CapacitanceUnit[]{ CapacitanceUnit.Undefined }).ToArray(); + public static CapacitanceUnit[] Units { get; } = Enum.GetValues(typeof(CapacitanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Farad. diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 462f9b5a2c..2ebbd1bc5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -70,9 +70,6 @@ static CoefficientOfThermalExpansion() /// If value is NaN or Infinity. public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) { - if(unit == CoefficientOfThermalExpansionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// All units of measurement for the CoefficientOfThermalExpansion quantity. /// - public static CoefficientOfThermalExpansionUnit[] Units { get; } = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().Except(new CoefficientOfThermalExpansionUnit[]{ CoefficientOfThermalExpansionUnit.Undefined }).ToArray(); + public static CoefficientOfThermalExpansionUnit[] Units { get; } = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 15297d870d..7e86d0a19d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -110,9 +110,6 @@ static Density() /// If value is NaN or Infinity. public Density(double value, DensityUnit unit) { - if(unit == DensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -154,7 +151,7 @@ public Density(double value, UnitSystem unitSystem) /// /// All units of measurement for the Density quantity. /// - public static DensityUnit[] Units { get; } = Enum.GetValues(typeof(DensityUnit)).Cast().Except(new DensityUnit[]{ DensityUnit.Undefined }).ToArray(); + public static DensityUnit[] Units { get; } = Enum.GetValues(typeof(DensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index c84c7bb4d0..63ce411e3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -77,9 +77,6 @@ static Duration() /// If value is NaN or Infinity. public Duration(double value, DurationUnit unit) { - if(unit == DurationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,7 +118,7 @@ public Duration(double value, UnitSystem unitSystem) /// /// All units of measurement for the Duration quantity. /// - public static DurationUnit[] Units { get; } = Enum.GetValues(typeof(DurationUnit)).Cast().Except(new DurationUnit[]{ DurationUnit.Undefined }).ToArray(); + public static DurationUnit[] Units { get; } = Enum.GetValues(typeof(DurationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 50da1af660..40558b8725 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -80,9 +80,6 @@ static DynamicViscosity() /// If value is NaN or Infinity. public DynamicViscosity(double value, DynamicViscosityUnit unit) { - if(unit == DynamicViscosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,7 +121,7 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// All units of measurement for the DynamicViscosity quantity. /// - public static DynamicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().Except(new DynamicViscosityUnit[]{ DynamicViscosityUnit.Undefined }).ToArray(); + public static DynamicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonSecondPerMeterSquared. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index e8778623b6..b4522c7cac 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -71,9 +71,6 @@ static ElectricAdmittance() /// If value is NaN or Infinity. public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) { - if(unit == ElectricAdmittanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricAdmittance quantity. /// - public static ElectricAdmittanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().Except(new ElectricAdmittanceUnit[]{ ElectricAdmittanceUnit.Undefined }).ToArray(); + public static ElectricAdmittanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index f353ec9463..6b7391998e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -75,9 +75,6 @@ static ElectricCharge() /// If value is NaN or Infinity. public ElectricCharge(double value, ElectricChargeUnit unit) { - if(unit == ElectricChargeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -119,7 +116,7 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricCharge quantity. /// - public static ElectricChargeUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().Except(new ElectricChargeUnit[]{ ElectricChargeUnit.Undefined }).ToArray(); + public static ElectricChargeUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Coulomb. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 46a401a30f..8dc19643c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -71,9 +71,6 @@ static ElectricChargeDensity() /// If value is NaN or Infinity. public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) { - if(unit == ElectricChargeDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricChargeDensity quantity. /// - public static ElectricChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().Except(new ElectricChargeDensityUnit[]{ ElectricChargeDensityUnit.Undefined }).ToArray(); + public static ElectricChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerCubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index e4b9c97be1..6e189f0d25 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -73,9 +73,6 @@ static ElectricConductance() /// If value is NaN or Infinity. public ElectricConductance(double value, ElectricConductanceUnit unit) { - if(unit == ElectricConductanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricConductance quantity. /// - public static ElectricConductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().Except(new ElectricConductanceUnit[]{ ElectricConductanceUnit.Undefined }).ToArray(); + public static ElectricConductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Siemens. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 05d6597879..1893dc5268 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -73,9 +73,6 @@ static ElectricConductivity() /// If value is NaN or Infinity. public ElectricConductivity(double value, ElectricConductivityUnit unit) { - if(unit == ElectricConductivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricConductivity quantity. /// - public static ElectricConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().Except(new ElectricConductivityUnit[]{ ElectricConductivityUnit.Undefined }).ToArray(); + public static ElectricConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SiemensPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 79168272f3..1523f2bcca 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -75,9 +75,6 @@ static ElectricCurrent() /// If value is NaN or Infinity. public ElectricCurrent(double value, ElectricCurrentUnit unit) { - if(unit == ElectricCurrentUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -119,7 +116,7 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricCurrent quantity. /// - public static ElectricCurrentUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().Except(new ElectricCurrentUnit[]{ ElectricCurrentUnit.Undefined }).ToArray(); + public static ElectricCurrentUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Ampere. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 3f19fdd22b..49c5c1d160 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -73,9 +73,6 @@ static ElectricCurrentDensity() /// If value is NaN or Infinity. public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) { - if(unit == ElectricCurrentDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricCurrentDensity quantity. /// - public static ElectricCurrentDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().Except(new ElectricCurrentDensityUnit[]{ ElectricCurrentDensityUnit.Undefined }).ToArray(); + public static ElectricCurrentDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index bfcd86362f..01a5676cb2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -71,9 +71,6 @@ static ElectricCurrentGradient() /// If value is NaN or Infinity. public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) { - if(unit == ElectricCurrentGradientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricCurrentGradient quantity. /// - public static ElectricCurrentGradientUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().Except(new ElectricCurrentGradientUnit[]{ ElectricCurrentGradientUnit.Undefined }).ToArray(); + public static ElectricCurrentGradientUnit[] Units { get; } = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 9790fff6cc..2c695effa2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -71,9 +71,6 @@ static ElectricField() /// If value is NaN or Infinity. public ElectricField(double value, ElectricFieldUnit unit) { - if(unit == ElectricFieldUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricField quantity. /// - public static ElectricFieldUnit[] Units { get; } = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().Except(new ElectricFieldUnit[]{ ElectricFieldUnit.Undefined }).ToArray(); + public static ElectricFieldUnit[] Units { get; } = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index f91f2c6d0e..438dfba1a9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -74,9 +74,6 @@ static ElectricInductance() /// If value is NaN or Infinity. public ElectricInductance(double value, ElectricInductanceUnit unit) { - if(unit == ElectricInductanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,7 +115,7 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricInductance quantity. /// - public static ElectricInductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().Except(new ElectricInductanceUnit[]{ ElectricInductanceUnit.Undefined }).ToArray(); + public static ElectricInductanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Henry. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index b85de59b90..09bebc23cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -72,9 +72,6 @@ static ElectricPotential() /// If value is NaN or Infinity. public ElectricPotential(double value, ElectricPotentialUnit unit) { - if(unit == ElectricPotentialUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -116,7 +113,7 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricPotential quantity. /// - public static ElectricPotentialUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().Except(new ElectricPotentialUnit[]{ ElectricPotentialUnit.Undefined }).ToArray(); + public static ElectricPotentialUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Volt. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 38d9c099e6..40461405e5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -72,9 +72,6 @@ static ElectricPotentialAc() /// If value is NaN or Infinity. public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) { - if(unit == ElectricPotentialAcUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -116,7 +113,7 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricPotentialAc quantity. /// - public static ElectricPotentialAcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().Except(new ElectricPotentialAcUnit[]{ ElectricPotentialAcUnit.Undefined }).ToArray(); + public static ElectricPotentialAcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltAc. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index d47ba88419..9f2f599704 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -87,9 +87,6 @@ static ElectricPotentialChangeRate() /// If value is NaN or Infinity. public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) { - if(unit == ElectricPotentialChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -131,7 +128,7 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricPotentialChangeRate quantity. /// - public static ElectricPotentialChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast().Except(new ElectricPotentialChangeRateUnit[]{ ElectricPotentialChangeRateUnit.Undefined }).ToArray(); + public static ElectricPotentialChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index abef170f68..3ba695dfa5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -72,9 +72,6 @@ static ElectricPotentialDc() /// If value is NaN or Infinity. public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) { - if(unit == ElectricPotentialDcUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -116,7 +113,7 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricPotentialDc quantity. /// - public static ElectricPotentialDcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().Except(new ElectricPotentialDcUnit[]{ ElectricPotentialDcUnit.Undefined }).ToArray(); + public static ElectricPotentialDcUnit[] Units { get; } = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltDc. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index c4a6b3c4b5..a1894f2053 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -73,9 +73,6 @@ static ElectricResistance() /// If value is NaN or Infinity. public ElectricResistance(double value, ElectricResistanceUnit unit) { - if(unit == ElectricResistanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricResistance quantity. /// - public static ElectricResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().Except(new ElectricResistanceUnit[]{ ElectricResistanceUnit.Undefined }).ToArray(); + public static ElectricResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Ohm. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index d86e867757..1d3ee93615 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -84,9 +84,6 @@ static ElectricResistivity() /// If value is NaN or Infinity. public ElectricResistivity(double value, ElectricResistivityUnit unit) { - if(unit == ElectricResistivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,7 +125,7 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricResistivity quantity. /// - public static ElectricResistivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().Except(new ElectricResistivityUnit[]{ ElectricResistivityUnit.Undefined }).ToArray(); + public static ElectricResistivityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit OhmMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index c26ff1436b..63dc7800b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -73,9 +73,6 @@ static ElectricSurfaceChargeDensity() /// If value is NaN or Infinity. public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) { - if(unit == ElectricSurfaceChargeDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the ElectricSurfaceChargeDensity quantity. /// - public static ElectricSurfaceChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast().Except(new ElectricSurfaceChargeDensityUnit[]{ ElectricSurfaceChargeDensityUnit.Undefined }).ToArray(); + public static ElectricSurfaceChargeDensityUnit[] Units { get; } = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CoulombPerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 92887675fa..61a64c4673 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -103,9 +103,6 @@ static Energy() /// If value is NaN or Infinity. public Energy(double value, EnergyUnit unit) { - if(unit == EnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -147,7 +144,7 @@ public Energy(double value, UnitSystem unitSystem) /// /// All units of measurement for the Energy quantity. /// - public static EnergyUnit[] Units { get; } = Enum.GetValues(typeof(EnergyUnit)).Cast().Except(new EnergyUnit[]{ EnergyUnit.Undefined }).ToArray(); + public static EnergyUnit[] Units { get; } = Enum.GetValues(typeof(EnergyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Joule. diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 13fa637270..e29adb0c13 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -74,9 +74,6 @@ static Entropy() /// If value is NaN or Infinity. public Entropy(double value, EntropyUnit unit) { - if(unit == EntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,7 +115,7 @@ public Entropy(double value, UnitSystem unitSystem) /// /// All units of measurement for the Entropy quantity. /// - public static EntropyUnit[] Units { get; } = Enum.GetValues(typeof(EntropyUnit)).Cast().Except(new EntropyUnit[]{ EntropyUnit.Undefined }).ToArray(); + public static EntropyUnit[] Units { get; } = Enum.GetValues(typeof(EntropyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index a5a67f7e93..e738656374 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -82,9 +82,6 @@ static Force() /// If value is NaN or Infinity. public Force(double value, ForceUnit unit) { - if(unit == ForceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,7 +123,7 @@ public Force(double value, UnitSystem unitSystem) /// /// All units of measurement for the Force quantity. /// - public static ForceUnit[] Units { get; } = Enum.GetValues(typeof(ForceUnit)).Cast().Except(new ForceUnit[]{ ForceUnit.Undefined }).ToArray(); + public static ForceUnit[] Units { get; } = Enum.GetValues(typeof(ForceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Newton. diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 47d360eb4c..8fdbc01ce8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -82,9 +82,6 @@ static ForceChangeRate() /// If value is NaN or Infinity. public ForceChangeRate(double value, ForceChangeRateUnit unit) { - if(unit == ForceChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,7 +123,7 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// All units of measurement for the ForceChangeRate quantity. /// - public static ForceChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().Except(new ForceChangeRateUnit[]{ ForceChangeRateUnit.Undefined }).ToArray(); + public static ForceChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index b06632f34d..9013bbcb51 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -105,9 +105,6 @@ static ForcePerLength() /// If value is NaN or Infinity. public ForcePerLength(double value, ForcePerLengthUnit unit) { - if(unit == ForcePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -149,7 +146,7 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// All units of measurement for the ForcePerLength quantity. /// - public static ForcePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().Except(new ForcePerLengthUnit[]{ ForcePerLengthUnit.Undefined }).ToArray(); + public static ForcePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 0c5fdff5d5..1e68d9f663 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -78,9 +78,6 @@ static Frequency() /// If value is NaN or Infinity. public Frequency(double value, FrequencyUnit unit) { - if(unit == FrequencyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -122,7 +119,7 @@ public Frequency(double value, UnitSystem unitSystem) /// /// All units of measurement for the Frequency quantity. /// - public static FrequencyUnit[] Units { get; } = Enum.GetValues(typeof(FrequencyUnit)).Cast().Except(new FrequencyUnit[]{ FrequencyUnit.Undefined }).ToArray(); + public static FrequencyUnit[] Units { get; } = Enum.GetValues(typeof(FrequencyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Hertz. diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index c6363b09fa..aadbaf471b 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -74,9 +74,6 @@ static FuelEfficiency() /// If value is NaN or Infinity. public FuelEfficiency(double value, FuelEfficiencyUnit unit) { - if(unit == FuelEfficiencyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,7 +115,7 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// All units of measurement for the FuelEfficiency quantity. /// - public static FuelEfficiencyUnit[] Units { get; } = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast().Except(new FuelEfficiencyUnit[]{ FuelEfficiencyUnit.Undefined }).ToArray(); + public static FuelEfficiencyUnit[] Units { get; } = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit LiterPer100Kilometers. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index e32423863b..93a2929376 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -85,9 +85,6 @@ static HeatFlux() /// If value is NaN or Infinity. public HeatFlux(double value, HeatFluxUnit unit) { - if(unit == HeatFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,7 +126,7 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// All units of measurement for the HeatFlux quantity. /// - public static HeatFluxUnit[] Units { get; } = Enum.GetValues(typeof(HeatFluxUnit)).Cast().Except(new HeatFluxUnit[]{ HeatFluxUnit.Undefined }).ToArray(); + public static HeatFluxUnit[] Units { get; } = Enum.GetValues(typeof(HeatFluxUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 3740a28047..138bd4bb0e 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -70,9 +70,6 @@ static HeatTransferCoefficient() /// If value is NaN or Infinity. public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) { - if(unit == HeatTransferCoefficientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// All units of measurement for the HeatTransferCoefficient quantity. /// - public static HeatTransferCoefficientUnit[] Units { get; } = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().Except(new HeatTransferCoefficientUnit[]{ HeatTransferCoefficientUnit.Undefined }).ToArray(); + public static HeatTransferCoefficientUnit[] Units { get; } = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeterKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 930e98dda5..d93ecc167f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -74,9 +74,6 @@ static Illuminance() /// If value is NaN or Infinity. public Illuminance(double value, IlluminanceUnit unit) { - if(unit == IlluminanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,7 +115,7 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// All units of measurement for the Illuminance quantity. /// - public static IlluminanceUnit[] Units { get; } = Enum.GetValues(typeof(IlluminanceUnit)).Cast().Except(new IlluminanceUnit[]{ IlluminanceUnit.Undefined }).ToArray(); + public static IlluminanceUnit[] Units { get; } = Enum.GetValues(typeof(IlluminanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Lux. diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 9399dc0f41..0710f57b62 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -93,9 +93,6 @@ static Information() /// If value is NaN or Infinity. public Information(decimal value, InformationUnit unit) { - if(unit == InformationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; _unit = unit; } @@ -137,7 +134,7 @@ public Information(decimal value, UnitSystem unitSystem) /// /// All units of measurement for the Information quantity. /// - public static InformationUnit[] Units { get; } = Enum.GetValues(typeof(InformationUnit)).Cast().Except(new InformationUnit[]{ InformationUnit.Undefined }).ToArray(); + public static InformationUnit[] Units { get; } = Enum.GetValues(typeof(InformationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Bit. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index b7cc9cfab6..b8c4236ab0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -81,9 +81,6 @@ static Irradiance() /// If value is NaN or Infinity. public Irradiance(double value, IrradianceUnit unit) { - if(unit == IrradianceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,7 +122,7 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// All units of measurement for the Irradiance quantity. /// - public static IrradianceUnit[] Units { get; } = Enum.GetValues(typeof(IrradianceUnit)).Cast().Except(new IrradianceUnit[]{ IrradianceUnit.Undefined }).ToArray(); + public static IrradianceUnit[] Units { get; } = Enum.GetValues(typeof(IrradianceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index ce54e68df0..456ac93c1a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -77,9 +77,6 @@ static Irradiation() /// If value is NaN or Infinity. public Irradiation(double value, IrradiationUnit unit) { - if(unit == IrradiationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,7 +118,7 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// All units of measurement for the Irradiation quantity. /// - public static IrradiationUnit[] Units { get; } = Enum.GetValues(typeof(IrradiationUnit)).Cast().Except(new IrradiationUnit[]{ IrradiationUnit.Undefined }).ToArray(); + public static IrradiationUnit[] Units { get; } = Enum.GetValues(typeof(IrradiationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index ff5ce17908..667e8a61e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -79,9 +79,6 @@ static KinematicViscosity() /// If value is NaN or Infinity. public KinematicViscosity(double value, KinematicViscosityUnit unit) { - if(unit == KinematicViscosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,7 +120,7 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// All units of measurement for the KinematicViscosity quantity. /// - public static KinematicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().Except(new KinematicViscosityUnit[]{ KinematicViscosityUnit.Undefined }).ToArray(); + public static KinematicViscosityUnit[] Units { get; } = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index cfa6517177..5de0b33bda 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -68,9 +68,6 @@ static LapseRate() /// If value is NaN or Infinity. public LapseRate(double value, LapseRateUnit unit) { - if(unit == LapseRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -112,7 +109,7 @@ public LapseRate(double value, UnitSystem unitSystem) /// /// All units of measurement for the LapseRate quantity. /// - public static LapseRateUnit[] Units { get; } = Enum.GetValues(typeof(LapseRateUnit)).Cast().Except(new LapseRateUnit[]{ LapseRateUnit.Undefined }).ToArray(); + public static LapseRateUnit[] Units { get; } = Enum.GetValues(typeof(LapseRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerKilometer. diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index a2d49b9039..8c46739655 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -100,9 +100,6 @@ static Length() /// If value is NaN or Infinity. public Length(double value, LengthUnit unit) { - if(unit == LengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -144,7 +141,7 @@ public Length(double value, UnitSystem unitSystem) /// /// All units of measurement for the Length quantity. /// - public static LengthUnit[] Units { get; } = Enum.GetValues(typeof(LengthUnit)).Cast().Except(new LengthUnit[]{ LengthUnit.Undefined }).ToArray(); + public static LengthUnit[] Units { get; } = Enum.GetValues(typeof(LengthUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Meter. diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index b74d165689..b39988c8ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -69,9 +69,6 @@ static Level() /// If value is NaN or Infinity. public Level(double value, LevelUnit unit) { - if(unit == LevelUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -113,7 +110,7 @@ public Level(double value, UnitSystem unitSystem) /// /// All units of measurement for the Level quantity. /// - public static LevelUnit[] Units { get; } = Enum.GetValues(typeof(LevelUnit)).Cast().Except(new LevelUnit[]{ LevelUnit.Undefined }).ToArray(); + public static LevelUnit[] Units { get; } = Enum.GetValues(typeof(LevelUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Decibel. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index e6419b21e0..2959427397 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -84,9 +84,6 @@ static LinearDensity() /// If value is NaN or Infinity. public LinearDensity(double value, LinearDensityUnit unit) { - if(unit == LinearDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,7 +125,7 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the LinearDensity quantity. /// - public static LinearDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearDensityUnit)).Cast().Except(new LinearDensityUnit[]{ LinearDensityUnit.Undefined }).ToArray(); + public static LinearDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 7cf6a255dc..ed22711779 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -95,9 +95,6 @@ static LinearPowerDensity() /// If value is NaN or Infinity. public LinearPowerDensity(double value, LinearPowerDensityUnit unit) { - if(unit == LinearPowerDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,7 +136,7 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the LinearPowerDensity quantity. /// - public static LinearPowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast().Except(new LinearPowerDensityUnit[]{ LinearPowerDensityUnit.Undefined }).ToArray(); + public static LinearPowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 156af02864..e4acc51918 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -84,9 +84,6 @@ static Luminosity() /// If value is NaN or Infinity. public Luminosity(double value, LuminosityUnit unit) { - if(unit == LuminosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,7 +125,7 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// All units of measurement for the Luminosity quantity. /// - public static LuminosityUnit[] Units { get; } = Enum.GetValues(typeof(LuminosityUnit)).Cast().Except(new LuminosityUnit[]{ LuminosityUnit.Undefined }).ToArray(); + public static LuminosityUnit[] Units { get; } = Enum.GetValues(typeof(LuminosityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Watt. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 3cda60672f..36d9aca55d 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -71,9 +71,6 @@ static LuminousFlux() /// If value is NaN or Infinity. public LuminousFlux(double value, LuminousFluxUnit unit) { - if(unit == LuminousFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// All units of measurement for the LuminousFlux quantity. /// - public static LuminousFluxUnit[] Units { get; } = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().Except(new LuminousFluxUnit[]{ LuminousFluxUnit.Undefined }).ToArray(); + public static LuminousFluxUnit[] Units { get; } = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Lumen. diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index a6e45285b5..ffc303498b 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -71,9 +71,6 @@ static LuminousIntensity() /// If value is NaN or Infinity. public LuminousIntensity(double value, LuminousIntensityUnit unit) { - if(unit == LuminousIntensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the LuminousIntensity quantity. /// - public static LuminousIntensityUnit[] Units { get; } = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().Except(new LuminousIntensityUnit[]{ LuminousIntensityUnit.Undefined }).ToArray(); + public static LuminousIntensityUnit[] Units { get; } = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Candela. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index a52dfe861d..53e8298b60 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -76,9 +76,6 @@ static MagneticField() /// If value is NaN or Infinity. public MagneticField(double value, MagneticFieldUnit unit) { - if(unit == MagneticFieldUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -120,7 +117,7 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// All units of measurement for the MagneticField quantity. /// - public static MagneticFieldUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().Except(new MagneticFieldUnit[]{ MagneticFieldUnit.Undefined }).ToArray(); + public static MagneticFieldUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Tesla. diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index c7a0dea6a4..1c824ca0a7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -71,9 +71,6 @@ static MagneticFlux() /// If value is NaN or Infinity. public MagneticFlux(double value, MagneticFluxUnit unit) { - if(unit == MagneticFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// All units of measurement for the MagneticFlux quantity. /// - public static MagneticFluxUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().Except(new MagneticFluxUnit[]{ MagneticFluxUnit.Undefined }).ToArray(); + public static MagneticFluxUnit[] Units { get; } = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Weber. diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 905204d465..16254b179e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -71,9 +71,6 @@ static Magnetization() /// If value is NaN or Infinity. public Magnetization(double value, MagnetizationUnit unit) { - if(unit == MagnetizationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// All units of measurement for the Magnetization quantity. /// - public static MagnetizationUnit[] Units { get; } = Enum.GetValues(typeof(MagnetizationUnit)).Cast().Except(new MagnetizationUnit[]{ MagnetizationUnit.Undefined }).ToArray(); + public static MagnetizationUnit[] Units { get; } = Enum.GetValues(typeof(MagnetizationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit AmperePerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 116ec458f6..e93bc56083 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -92,9 +92,6 @@ static Mass() /// If value is NaN or Infinity. public Mass(double value, MassUnit unit) { - if(unit == MassUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -136,7 +133,7 @@ public Mass(double value, UnitSystem unitSystem) /// /// All units of measurement for the Mass quantity. /// - public static MassUnit[] Units { get; } = Enum.GetValues(typeof(MassUnit)).Cast().Except(new MassUnit[]{ MassUnit.Undefined }).ToArray(); + public static MassUnit[] Units { get; } = Enum.GetValues(typeof(MassUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Kilogram. diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 7131eac808..ad4ed45133 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -119,9 +119,6 @@ static MassConcentration() /// If value is NaN or Infinity. public MassConcentration(double value, MassConcentrationUnit unit) { - if(unit == MassConcentrationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -163,7 +160,7 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// All units of measurement for the MassConcentration quantity. /// - public static MassConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(MassConcentrationUnit)).Cast().Except(new MassConcentrationUnit[]{ MassConcentrationUnit.Undefined }).ToArray(); + public static MassConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(MassConcentrationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerCubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 523ddac416..a09a9f23fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -100,9 +100,6 @@ static MassFlow() /// If value is NaN or Infinity. public MassFlow(double value, MassFlowUnit unit) { - if(unit == MassFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -144,7 +141,7 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// All units of measurement for the MassFlow quantity. /// - public static MassFlowUnit[] Units { get; } = Enum.GetValues(typeof(MassFlowUnit)).Cast().Except(new MassFlowUnit[]{ MassFlowUnit.Undefined }).ToArray(); + public static MassFlowUnit[] Units { get; } = Enum.GetValues(typeof(MassFlowUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit GramPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index ce56bbf12c..71419d285a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -79,9 +79,6 @@ static MassFlux() /// If value is NaN or Infinity. public MassFlux(double value, MassFluxUnit unit) { - if(unit == MassFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,7 +120,7 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// All units of measurement for the MassFlux quantity. /// - public static MassFluxUnit[] Units { get; } = Enum.GetValues(typeof(MassFluxUnit)).Cast().Except(new MassFluxUnit[]{ MassFluxUnit.Undefined }).ToArray(); + public static MassFluxUnit[] Units { get; } = Enum.GetValues(typeof(MassFluxUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerSecondPerSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 21a503ca61..48e4e8450a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -94,9 +94,6 @@ static MassFraction() /// If value is NaN or Infinity. public MassFraction(double value, MassFractionUnit unit) { - if(unit == MassFractionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -138,7 +135,7 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// All units of measurement for the MassFraction quantity. /// - public static MassFractionUnit[] Units { get; } = Enum.GetValues(typeof(MassFractionUnit)).Cast().Except(new MassFractionUnit[]{ MassFractionUnit.Undefined }).ToArray(); + public static MassFractionUnit[] Units { get; } = Enum.GetValues(typeof(MassFractionUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 48c655db4c..8eddd8d974 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -95,9 +95,6 @@ static MassMomentOfInertia() /// If value is NaN or Infinity. public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) { - if(unit == MassMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,7 +136,7 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// All units of measurement for the MassMomentOfInertia quantity. /// - public static MassMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().Except(new MassMomentOfInertiaUnit[]{ MassMomentOfInertiaUnit.Undefined }).ToArray(); + public static MassMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 61e0bedd83..e3e64e37e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -70,9 +70,6 @@ static MolarEnergy() /// If value is NaN or Infinity. public MolarEnergy(double value, MolarEnergyUnit unit) { - if(unit == MolarEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// All units of measurement for the MolarEnergy quantity. /// - public static MolarEnergyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().Except(new MolarEnergyUnit[]{ MolarEnergyUnit.Undefined }).ToArray(); + public static MolarEnergyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMole. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index dafec903b4..fcce797603 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -70,9 +70,6 @@ static MolarEntropy() /// If value is NaN or Infinity. public MolarEntropy(double value, MolarEntropyUnit unit) { - if(unit == MolarEntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// All units of measurement for the MolarEntropy quantity. /// - public static MolarEntropyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().Except(new MolarEntropyUnit[]{ MolarEntropyUnit.Undefined }).ToArray(); + public static MolarEntropyUnit[] Units { get; } = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerMoleKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 0ba3fa3517..3eadc7a71e 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -79,9 +79,6 @@ static MolarMass() /// If value is NaN or Infinity. public MolarMass(double value, MolarMassUnit unit) { - if(unit == MolarMassUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,7 +120,7 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// All units of measurement for the MolarMass quantity. /// - public static MolarMassUnit[] Units { get; } = Enum.GetValues(typeof(MolarMassUnit)).Cast().Except(new MolarMassUnit[]{ MolarMassUnit.Undefined }).ToArray(); + public static MolarMassUnit[] Units { get; } = Enum.GetValues(typeof(MolarMassUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit KilogramPerMole. diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 645c298cc5..be1cae887b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -78,9 +78,6 @@ static Molarity() /// If value is NaN or Infinity. public Molarity(double value, MolarityUnit unit) { - if(unit == MolarityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -122,7 +119,7 @@ public Molarity(double value, UnitSystem unitSystem) /// /// All units of measurement for the Molarity quantity. /// - public static MolarityUnit[] Units { get; } = Enum.GetValues(typeof(MolarityUnit)).Cast().Except(new MolarityUnit[]{ MolarityUnit.Undefined }).ToArray(); + public static MolarityUnit[] Units { get; } = Enum.GetValues(typeof(MolarityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MolesPerCubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 91d63953e8..b4fc6ae99b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -71,9 +71,6 @@ static Permeability() /// If value is NaN or Infinity. public Permeability(double value, PermeabilityUnit unit) { - if(unit == PermeabilityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public Permeability(double value, UnitSystem unitSystem) /// /// All units of measurement for the Permeability quantity. /// - public static PermeabilityUnit[] Units { get; } = Enum.GetValues(typeof(PermeabilityUnit)).Cast().Except(new PermeabilityUnit[]{ PermeabilityUnit.Undefined }).ToArray(); + public static PermeabilityUnit[] Units { get; } = Enum.GetValues(typeof(PermeabilityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit HenryPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 85eae6b36f..e2d7783620 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -71,9 +71,6 @@ static Permittivity() /// If value is NaN or Infinity. public Permittivity(double value, PermittivityUnit unit) { - if(unit == PermittivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// All units of measurement for the Permittivity quantity. /// - public static PermittivityUnit[] Units { get; } = Enum.GetValues(typeof(PermittivityUnit)).Cast().Except(new PermittivityUnit[]{ PermittivityUnit.Undefined }).ToArray(); + public static PermittivityUnit[] Units { get; } = Enum.GetValues(typeof(PermittivityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit FaradPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 191e08e6f8..4ea38261ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -92,9 +92,6 @@ static Power() /// If value is NaN or Infinity. public Power(decimal value, PowerUnit unit) { - if(unit == PowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; _unit = unit; } @@ -136,7 +133,7 @@ public Power(decimal value, UnitSystem unitSystem) /// /// All units of measurement for the Power quantity. /// - public static PowerUnit[] Units { get; } = Enum.GetValues(typeof(PowerUnit)).Cast().Except(new PowerUnit[]{ PowerUnit.Undefined }).ToArray(); + public static PowerUnit[] Units { get; } = Enum.GetValues(typeof(PowerUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Watt. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index 2751d895f4..da30b48703 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -111,9 +111,6 @@ static PowerDensity() /// If value is NaN or Infinity. public PowerDensity(double value, PowerDensityUnit unit) { - if(unit == PowerDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -155,7 +152,7 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// All units of measurement for the PowerDensity quantity. /// - public static PowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(PowerDensityUnit)).Cast().Except(new PowerDensityUnit[]{ PowerDensityUnit.Undefined }).ToArray(); + public static PowerDensityUnit[] Units { get; } = Enum.GetValues(typeof(PowerDensityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerCubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 85efb4de93..b8cd8ef3d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -69,9 +69,6 @@ static PowerRatio() /// If value is NaN or Infinity. public PowerRatio(double value, PowerRatioUnit unit) { - if(unit == PowerRatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -113,7 +110,7 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// All units of measurement for the PowerRatio quantity. /// - public static PowerRatioUnit[] Units { get; } = Enum.GetValues(typeof(PowerRatioUnit)).Cast().Except(new PowerRatioUnit[]{ PowerRatioUnit.Undefined }).ToArray(); + public static PowerRatioUnit[] Units { get; } = Enum.GetValues(typeof(PowerRatioUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecibelWatt. diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 9caa5e9dea..999b492929 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -111,9 +111,6 @@ static Pressure() /// If value is NaN or Infinity. public Pressure(double value, PressureUnit unit) { - if(unit == PressureUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -155,7 +152,7 @@ public Pressure(double value, UnitSystem unitSystem) /// /// All units of measurement for the Pressure quantity. /// - public static PressureUnit[] Units { get; } = Enum.GetValues(typeof(PressureUnit)).Cast().Except(new PressureUnit[]{ PressureUnit.Undefined }).ToArray(); + public static PressureUnit[] Units { get; } = Enum.GetValues(typeof(PressureUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Pascal. diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index c4f102ab69..501bf3e9e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -80,9 +80,6 @@ static PressureChangeRate() /// If value is NaN or Infinity. public PressureChangeRate(double value, PressureChangeRateUnit unit) { - if(unit == PressureChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,7 +121,7 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// All units of measurement for the PressureChangeRate quantity. /// - public static PressureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().Except(new PressureChangeRateUnit[]{ PressureChangeRateUnit.Undefined }).ToArray(); + public static PressureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit PascalPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index ff6b2f08d9..b9e4d67b44 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -73,9 +73,6 @@ static Ratio() /// If value is NaN or Infinity. public Ratio(double value, RatioUnit unit) { - if(unit == RatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public Ratio(double value, UnitSystem unitSystem) /// /// All units of measurement for the Ratio quantity. /// - public static RatioUnit[] Units { get; } = Enum.GetValues(typeof(RatioUnit)).Cast().Except(new RatioUnit[]{ RatioUnit.Undefined }).ToArray(); + public static RatioUnit[] Units { get; } = Enum.GetValues(typeof(RatioUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 1f6a07f1c5..9e117422de 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -69,9 +69,6 @@ static RatioChangeRate() /// If value is NaN or Infinity. public RatioChangeRate(double value, RatioChangeRateUnit unit) { - if(unit == RatioChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -113,7 +110,7 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// All units of measurement for the RatioChangeRate quantity. /// - public static RatioChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast().Except(new RatioChangeRateUnit[]{ RatioChangeRateUnit.Undefined }).ToArray(); + public static RatioChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFractionPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 2cdd915e14..4e8ca0ff6a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -70,9 +70,6 @@ static ReactiveEnergy() /// If value is NaN or Infinity. public ReactiveEnergy(double value, ReactiveEnergyUnit unit) { - if(unit == ReactiveEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// All units of measurement for the ReactiveEnergy quantity. /// - public static ReactiveEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().Except(new ReactiveEnergyUnit[]{ ReactiveEnergyUnit.Undefined }).ToArray(); + public static ReactiveEnergyUnit[] Units { get; } = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactiveHour. diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index cce28dc18b..130f67545d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -71,9 +71,6 @@ static ReactivePower() /// If value is NaN or Infinity. public ReactivePower(double value, ReactivePowerUnit unit) { - if(unit == ReactivePowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// All units of measurement for the ReactivePower quantity. /// - public static ReactivePowerUnit[] Units { get; } = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().Except(new ReactivePowerUnit[]{ ReactivePowerUnit.Undefined }).ToArray(); + public static ReactivePowerUnit[] Units { get; } = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit VoltampereReactive. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 65163bdf19..fe8e4f1285 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -81,9 +81,6 @@ static ReciprocalArea() /// If value is NaN or Infinity. public ReciprocalArea(double value, ReciprocalAreaUnit unit) { - if(unit == ReciprocalAreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,7 +122,7 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// /// All units of measurement for the ReciprocalArea quantity. /// - public static ReciprocalAreaUnit[] Units { get; } = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast().Except(new ReciprocalAreaUnit[]{ ReciprocalAreaUnit.Undefined }).ToArray(); + public static ReciprocalAreaUnit[] Units { get; } = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseSquareMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 9563e8560e..e2f315d523 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -80,9 +80,6 @@ static ReciprocalLength() /// If value is NaN or Infinity. public ReciprocalLength(double value, ReciprocalLengthUnit unit) { - if(unit == ReciprocalLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,7 +121,7 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// /// All units of measurement for the ReciprocalLength quantity. /// - public static ReciprocalLengthUnit[] Units { get; } = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast().Except(new ReciprocalLengthUnit[]{ ReciprocalLengthUnit.Undefined }).ToArray(); + public static ReciprocalLengthUnit[] Units { get; } = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit InverseMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index a4ce4bf2c7..13eea57f43 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -68,9 +68,6 @@ static RelativeHumidity() /// If value is NaN or Infinity. public RelativeHumidity(double value, RelativeHumidityUnit unit) { - if(unit == RelativeHumidityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -112,7 +109,7 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// All units of measurement for the RelativeHumidity quantity. /// - public static RelativeHumidityUnit[] Units { get; } = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast().Except(new RelativeHumidityUnit[]{ RelativeHumidityUnit.Undefined }).ToArray(); + public static RelativeHumidityUnit[] Units { get; } = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Percent. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index a0004f3135..ea2f691f81 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -71,9 +71,6 @@ static RotationalAcceleration() /// If value is NaN or Infinity. public RotationalAcceleration(double value, RotationalAccelerationUnit unit) { - if(unit == RotationalAccelerationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// All units of measurement for the RotationalAcceleration quantity. /// - public static RotationalAccelerationUnit[] Units { get; } = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().Except(new RotationalAccelerationUnit[]{ RotationalAccelerationUnit.Undefined }).ToArray(); + public static RotationalAccelerationUnit[] Units { get; } = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecondSquared. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 95fa563e2a..b9412175fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -80,9 +80,6 @@ static RotationalSpeed() /// If value is NaN or Infinity. public RotationalSpeed(double value, RotationalSpeedUnit unit) { - if(unit == RotationalSpeedUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,7 +121,7 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// All units of measurement for the RotationalSpeed quantity. /// - public static RotationalSpeedUnit[] Units { get; } = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().Except(new RotationalSpeedUnit[]{ RotationalSpeedUnit.Undefined }).ToArray(); + public static RotationalSpeedUnit[] Units { get; } = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit RadianPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index c2d240a9ee..de2e19042f 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -100,9 +100,6 @@ static RotationalStiffness() /// If value is NaN or Infinity. public RotationalStiffness(double value, RotationalStiffnessUnit unit) { - if(unit == RotationalStiffnessUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -144,7 +141,7 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// All units of measurement for the RotationalStiffness quantity. /// - public static RotationalStiffnessUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().Except(new RotationalStiffnessUnit[]{ RotationalStiffnessUnit.Undefined }).ToArray(); + public static RotationalStiffnessUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadian. diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 91d4ad145a..a1ecf858aa 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -72,9 +72,6 @@ static RotationalStiffnessPerLength() /// If value is NaN or Infinity. public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) { - if(unit == RotationalStiffnessPerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -116,7 +113,7 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// All units of measurement for the RotationalStiffnessPerLength quantity. /// - public static RotationalStiffnessPerLengthUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().Except(new RotationalStiffnessPerLengthUnit[]{ RotationalStiffnessPerLengthUnit.Undefined }).ToArray(); + public static RotationalStiffnessPerLengthUnit[] Units { get; } = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerRadianPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 8c1c50aad8..26f317dbce 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -68,9 +68,6 @@ static Scalar() /// If value is NaN or Infinity. public Scalar(double value, ScalarUnit unit) { - if(unit == ScalarUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -112,7 +109,7 @@ public Scalar(double value, UnitSystem unitSystem) /// /// All units of measurement for the Scalar quantity. /// - public static ScalarUnit[] Units { get; } = Enum.GetValues(typeof(ScalarUnit)).Cast().Except(new ScalarUnit[]{ ScalarUnit.Undefined }).ToArray(); + public static ScalarUnit[] Units { get; } = Enum.GetValues(typeof(ScalarUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Amount. diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index d4cb24750b..9e96298279 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -71,9 +71,6 @@ static SolidAngle() /// If value is NaN or Infinity. public SolidAngle(double value, SolidAngleUnit unit) { - if(unit == SolidAngleUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// All units of measurement for the SolidAngle quantity. /// - public static SolidAngleUnit[] Units { get; } = Enum.GetValues(typeof(SolidAngleUnit)).Cast().Except(new SolidAngleUnit[]{ SolidAngleUnit.Undefined }).ToArray(); + public static SolidAngleUnit[] Units { get; } = Enum.GetValues(typeof(SolidAngleUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Steradian. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index f60095d963..091e6d1b36 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -95,9 +95,6 @@ static SpecificEnergy() /// If value is NaN or Infinity. public SpecificEnergy(double value, SpecificEnergyUnit unit) { - if(unit == SpecificEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,7 +136,7 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// All units of measurement for the SpecificEnergy quantity. /// - public static SpecificEnergyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().Except(new SpecificEnergyUnit[]{ SpecificEnergyUnit.Undefined }).ToArray(); + public static SpecificEnergyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogram. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 2b800d1fee..53c7a36e1e 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -76,9 +76,6 @@ static SpecificEntropy() /// If value is NaN or Infinity. public SpecificEntropy(double value, SpecificEntropyUnit unit) { - if(unit == SpecificEntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -120,7 +117,7 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// All units of measurement for the SpecificEntropy quantity. /// - public static SpecificEntropyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().Except(new SpecificEntropyUnit[]{ SpecificEntropyUnit.Undefined }).ToArray(); + public static SpecificEntropyUnit[] Units { get; } = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerKilogramKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index d466faab28..ba8facc26a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -74,9 +74,6 @@ static SpecificFuelConsumption() /// If value is NaN or Infinity. public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) { - if(unit == SpecificFuelConsumptionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,7 +115,7 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// All units of measurement for the SpecificFuelConsumption quantity. /// - public static SpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast().Except(new SpecificFuelConsumptionUnit[]{ SpecificFuelConsumptionUnit.Undefined }).ToArray(); + public static SpecificFuelConsumptionUnit[] Units { get; } = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit GramPerKiloNewtonSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index ad2f50a3f6..2218363887 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -70,9 +70,6 @@ static SpecificVolume() /// If value is NaN or Infinity. public SpecificVolume(double value, SpecificVolumeUnit unit) { - if(unit == SpecificVolumeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -114,7 +111,7 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// All units of measurement for the SpecificVolume quantity. /// - public static SpecificVolumeUnit[] Units { get; } = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().Except(new SpecificVolumeUnit[]{ SpecificVolumeUnit.Undefined }).ToArray(); + public static SpecificVolumeUnit[] Units { get; } = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerKilogram. diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 7404c07abc..cb49e68fb1 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -87,9 +87,6 @@ static SpecificWeight() /// If value is NaN or Infinity. public SpecificWeight(double value, SpecificWeightUnit unit) { - if(unit == SpecificWeightUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -131,7 +128,7 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// All units of measurement for the SpecificWeight quantity. /// - public static SpecificWeightUnit[] Units { get; } = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().Except(new SpecificWeightUnit[]{ SpecificWeightUnit.Undefined }).ToArray(); + public static SpecificWeightUnit[] Units { get; } = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonPerCubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 0d23c8bab9..6497447b54 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -99,9 +99,6 @@ static Speed() /// If value is NaN or Infinity. public Speed(double value, SpeedUnit unit) { - if(unit == SpeedUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -143,7 +140,7 @@ public Speed(double value, UnitSystem unitSystem) /// /// All units of measurement for the Speed quantity. /// - public static SpeedUnit[] Units { get; } = Enum.GetValues(typeof(SpeedUnit)).Cast().Except(new SpeedUnit[]{ SpeedUnit.Undefined }).ToArray(); + public static SpeedUnit[] Units { get; } = Enum.GetValues(typeof(SpeedUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 0e11056e34..71f1710e0d 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -76,9 +76,6 @@ static StandardVolumeFlow() /// If value is NaN or Infinity. public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) { - if(unit == StandardVolumeFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -120,7 +117,7 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// /// All units of measurement for the StandardVolumeFlow quantity. /// - public static StandardVolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast().Except(new StandardVolumeFlowUnit[]{ StandardVolumeFlowUnit.Undefined }).ToArray(); + public static StandardVolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit StandardCubicMeterPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index c8d429dbf3..0924ea0d06 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -77,9 +77,6 @@ static Temperature() /// If value is NaN or Infinity. public Temperature(double value, TemperatureUnit unit) { - if(unit == TemperatureUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,7 +118,7 @@ public Temperature(double value, UnitSystem unitSystem) /// /// All units of measurement for the Temperature quantity. /// - public static TemperatureUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureUnit)).Cast().Except(new TemperatureUnit[]{ TemperatureUnit.Undefined }).ToArray(); + public static TemperatureUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index e459a5b3d6..b52211a923 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -77,9 +77,6 @@ static TemperatureChangeRate() /// If value is NaN or Infinity. public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) { - if(unit == TemperatureChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,7 +118,7 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// All units of measurement for the TemperatureChangeRate quantity. /// - public static TemperatureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().Except(new TemperatureChangeRateUnit[]{ TemperatureChangeRateUnit.Undefined }).ToArray(); + public static TemperatureChangeRateUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DegreeCelsiusPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index f29646d81c..b3327e26cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -76,9 +76,6 @@ static TemperatureDelta() /// If value is NaN or Infinity. public TemperatureDelta(double value, TemperatureDeltaUnit unit) { - if(unit == TemperatureDeltaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -120,7 +117,7 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// All units of measurement for the TemperatureDelta quantity. /// - public static TemperatureDeltaUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().Except(new TemperatureDeltaUnit[]{ TemperatureDeltaUnit.Undefined }).ToArray(); + public static TemperatureDeltaUnit[] Units { get; } = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit Kelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 4fee01d256..3ea253614b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -72,9 +72,6 @@ static ThermalConductivity() /// If value is NaN or Infinity. public ThermalConductivity(double value, ThermalConductivityUnit unit) { - if(unit == ThermalConductivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -116,7 +113,7 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// All units of measurement for the ThermalConductivity quantity. /// - public static ThermalConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().Except(new ThermalConductivityUnit[]{ ThermalConductivityUnit.Undefined }).ToArray(); + public static ThermalConductivityUnit[] Units { get; } = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit WattPerMeterKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 0def34e49d..78069ccdef 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -72,9 +72,6 @@ static ThermalResistance() /// If value is NaN or Infinity. public ThermalResistance(double value, ThermalResistanceUnit unit) { - if(unit == ThermalResistanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -116,7 +113,7 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// All units of measurement for the ThermalResistance quantity. /// - public static ThermalResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().Except(new ThermalResistanceUnit[]{ ThermalResistanceUnit.Undefined }).ToArray(); + public static ThermalResistanceUnit[] Units { get; } = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit SquareMeterKelvinPerKilowatt. diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index b6f3d949b0..c6fa2bf91a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -89,9 +89,6 @@ static Torque() /// If value is NaN or Infinity. public Torque(double value, TorqueUnit unit) { - if(unit == TorqueUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -133,7 +130,7 @@ public Torque(double value, UnitSystem unitSystem) /// /// All units of measurement for the Torque quantity. /// - public static TorqueUnit[] Units { get; } = Enum.GetValues(typeof(TorqueUnit)).Cast().Except(new TorqueUnit[]{ TorqueUnit.Undefined }).ToArray(); + public static TorqueUnit[] Units { get; } = Enum.GetValues(typeof(TorqueUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 8bd8b8616d..a5572c05f4 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -88,9 +88,6 @@ static TorquePerLength() /// If value is NaN or Infinity. public TorquePerLength(double value, TorquePerLengthUnit unit) { - if(unit == TorquePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -132,7 +129,7 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// All units of measurement for the TorquePerLength quantity. /// - public static TorquePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().Except(new TorquePerLengthUnit[]{ TorquePerLengthUnit.Undefined }).ToArray(); + public static TorquePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NewtonMeterPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 8330b681a1..d069ce5217 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -71,9 +71,6 @@ static Turbidity() /// If value is NaN or Infinity. public Turbidity(double value, TurbidityUnit unit) { - if(unit == TurbidityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -115,7 +112,7 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// All units of measurement for the Turbidity quantity. /// - public static TurbidityUnit[] Units { get; } = Enum.GetValues(typeof(TurbidityUnit)).Cast().Except(new TurbidityUnit[]{ TurbidityUnit.Undefined }).ToArray(); + public static TurbidityUnit[] Units { get; } = Enum.GetValues(typeof(TurbidityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit NTU. diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 0870735155..04264c2de7 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -68,9 +68,6 @@ static VitaminA() /// If value is NaN or Infinity. public VitaminA(double value, VitaminAUnit unit) { - if(unit == VitaminAUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -112,7 +109,7 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// All units of measurement for the VitaminA quantity. /// - public static VitaminAUnit[] Units { get; } = Enum.GetValues(typeof(VitaminAUnit)).Cast().Except(new VitaminAUnit[]{ VitaminAUnit.Undefined }).ToArray(); + public static VitaminAUnit[] Units { get; } = Enum.GetValues(typeof(VitaminAUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit InternationalUnit. diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 0e4dcf26b4..d2efdac9cb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -118,9 +118,6 @@ static Volume() /// If value is NaN or Infinity. public Volume(double value, VolumeUnit unit) { - if(unit == VolumeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -162,7 +159,7 @@ public Volume(double value, UnitSystem unitSystem) /// /// All units of measurement for the Volume quantity. /// - public static VolumeUnit[] Units { get; } = Enum.GetValues(typeof(VolumeUnit)).Cast().Except(new VolumeUnit[]{ VolumeUnit.Undefined }).ToArray(); + public static VolumeUnit[] Units { get; } = Enum.GetValues(typeof(VolumeUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index bd18c9e62e..6da3ef7d45 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -90,9 +90,6 @@ static VolumeConcentration() /// If value is NaN or Infinity. public VolumeConcentration(double value, VolumeConcentrationUnit unit) { - if(unit == VolumeConcentrationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -134,7 +131,7 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// All units of measurement for the VolumeConcentration quantity. /// - public static VolumeConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast().Except(new VolumeConcentrationUnit[]{ VolumeConcentrationUnit.Undefined }).ToArray(); + public static VolumeConcentrationUnit[] Units { get; } = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit DecimalFraction. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 745fc3c32b..850797ad0c 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -123,9 +123,6 @@ static VolumeFlow() /// If value is NaN or Infinity. public VolumeFlow(double value, VolumeFlowUnit unit) { - if(unit == VolumeFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -167,7 +164,7 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// All units of measurement for the VolumeFlow quantity. /// - public static VolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().Except(new VolumeFlowUnit[]{ VolumeFlowUnit.Undefined }).ToArray(); + public static VolumeFlowUnit[] Units { get; } = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerSecond. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 226f76ddc9..f3de1d86a7 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -74,9 +74,6 @@ static VolumePerLength() /// If value is NaN or Infinity. public VolumePerLength(double value, VolumePerLengthUnit unit) { - if(unit == VolumePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,7 +115,7 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// All units of measurement for the VolumePerLength quantity. /// - public static VolumePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast().Except(new VolumePerLengthUnit[]{ VolumePerLengthUnit.Undefined }).ToArray(); + public static VolumePerLengthUnit[] Units { get; } = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit CubicMeterPerMeter. diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 9b9a4b0271..f9a15d4a7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -79,9 +79,6 @@ static VolumetricHeatCapacity() /// If value is NaN or Infinity. public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) { - if(unit == VolumetricHeatCapacityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,7 +120,7 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// /// All units of measurement for the VolumetricHeatCapacity quantity. /// - public static VolumetricHeatCapacityUnit[] Units { get; } = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast().Except(new VolumetricHeatCapacityUnit[]{ VolumetricHeatCapacityUnit.Undefined }).ToArray(); + public static VolumetricHeatCapacityUnit[] Units { get; } = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit JoulePerCubicMeterKelvin. diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 4e472711f3..cf7569d6bb 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -73,9 +73,6 @@ static WarpingMomentOfInertia() /// If value is NaN or Infinity. public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) { - if(unit == WarpingMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,7 +114,7 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// All units of measurement for the WarpingMomentOfInertia quantity. /// - public static WarpingMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast().Except(new WarpingMomentOfInertiaUnit[]{ WarpingMomentOfInertiaUnit.Undefined }).ToArray(); + public static WarpingMomentOfInertiaUnit[] Units { get; } = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast().ToArray(); /// /// Gets an instance of this quantity with a value of 0 in the base unit MeterToTheSixth. diff --git a/UnitsNet/GeneratedCode/Units/AccelerationUnit.g.cs b/UnitsNet/GeneratedCode/Units/AccelerationUnit.g.cs index 149fda76fb..d2c2b8f7f4 100644 --- a/UnitsNet/GeneratedCode/Units/AccelerationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AccelerationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AccelerationUnit { - Undefined = 0, CentimeterPerSecondSquared, DecimeterPerSecondSquared, FootPerSecondSquared, diff --git a/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs index ebd46a97d7..b2501da043 100644 --- a/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AmountOfSubstanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AmountOfSubstanceUnit { - Undefined = 0, Centimole, CentipoundMole, Decimole, diff --git a/UnitsNet/GeneratedCode/Units/AmplitudeRatioUnit.g.cs b/UnitsNet/GeneratedCode/Units/AmplitudeRatioUnit.g.cs index b7bb6ae224..cebbd5313e 100644 --- a/UnitsNet/GeneratedCode/Units/AmplitudeRatioUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AmplitudeRatioUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AmplitudeRatioUnit { - Undefined = 0, DecibelMicrovolt, DecibelMillivolt, DecibelUnloaded, diff --git a/UnitsNet/GeneratedCode/Units/AngleUnit.g.cs b/UnitsNet/GeneratedCode/Units/AngleUnit.g.cs index b61f169b80..6dffab599d 100644 --- a/UnitsNet/GeneratedCode/Units/AngleUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AngleUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AngleUnit { - Undefined = 0, Arcminute, Arcsecond, Centiradian, diff --git a/UnitsNet/GeneratedCode/Units/ApparentEnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/ApparentEnergyUnit.g.cs index e7b4f42ee4..f271723e09 100644 --- a/UnitsNet/GeneratedCode/Units/ApparentEnergyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ApparentEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ApparentEnergyUnit { - Undefined = 0, KilovoltampereHour, MegavoltampereHour, VoltampereHour, diff --git a/UnitsNet/GeneratedCode/Units/ApparentPowerUnit.g.cs b/UnitsNet/GeneratedCode/Units/ApparentPowerUnit.g.cs index cd5563c699..791a8bac4b 100644 --- a/UnitsNet/GeneratedCode/Units/ApparentPowerUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ApparentPowerUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ApparentPowerUnit { - Undefined = 0, Gigavoltampere, Kilovoltampere, Megavoltampere, diff --git a/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs index 84924b7cf3..a37dd1c1a7 100644 --- a/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AreaDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AreaDensityUnit { - Undefined = 0, KilogramPerSquareMeter, } diff --git a/UnitsNet/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs b/UnitsNet/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs index 3ca2fc3574..96cfb1072c 100644 --- a/UnitsNet/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AreaMomentOfInertiaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AreaMomentOfInertiaUnit { - Undefined = 0, CentimeterToTheFourth, DecimeterToTheFourth, FootToTheFourth, diff --git a/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs b/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs index 2db395608c..0bec95b55e 100644 --- a/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/AreaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum AreaUnit { - Undefined = 0, Acre, Hectare, SquareCentimeter, diff --git a/UnitsNet/GeneratedCode/Units/BitRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/BitRateUnit.g.cs index e6328d9e65..69affbf6d1 100644 --- a/UnitsNet/GeneratedCode/Units/BitRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/BitRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum BitRateUnit { - Undefined = 0, BitPerSecond, BytePerSecond, ExabitPerSecond, diff --git a/UnitsNet/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs b/UnitsNet/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs index bb10b001c3..2ec8d05234 100644 --- a/UnitsNet/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/BrakeSpecificFuelConsumptionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum BrakeSpecificFuelConsumptionUnit { - Undefined = 0, GramPerKiloWattHour, KilogramPerJoule, diff --git a/UnitsNet/GeneratedCode/Units/CapacitanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/CapacitanceUnit.g.cs index 9b6a538fb9..feaa108dab 100644 --- a/UnitsNet/GeneratedCode/Units/CapacitanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/CapacitanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum CapacitanceUnit { - Undefined = 0, Farad, Kilofarad, Megafarad, diff --git a/UnitsNet/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs b/UnitsNet/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs index 9db9fa9d0d..76316e54bc 100644 --- a/UnitsNet/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/CoefficientOfThermalExpansionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum CoefficientOfThermalExpansionUnit { - Undefined = 0, InverseDegreeCelsius, InverseDegreeFahrenheit, InverseKelvin, diff --git a/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs index 94f3fd7948..83405122c8 100644 --- a/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/DensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum DensityUnit { - Undefined = 0, CentigramPerDeciliter, CentigramPerLiter, CentigramPerMilliliter, diff --git a/UnitsNet/GeneratedCode/Units/DurationUnit.g.cs b/UnitsNet/GeneratedCode/Units/DurationUnit.g.cs index 63af8ab3f0..148dd2a9b5 100644 --- a/UnitsNet/GeneratedCode/Units/DurationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/DurationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum DurationUnit { - Undefined = 0, Day, Hour, Microsecond, diff --git a/UnitsNet/GeneratedCode/Units/DynamicViscosityUnit.g.cs b/UnitsNet/GeneratedCode/Units/DynamicViscosityUnit.g.cs index a0d6fc8e13..fa920a2d2f 100644 --- a/UnitsNet/GeneratedCode/Units/DynamicViscosityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/DynamicViscosityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum DynamicViscosityUnit { - Undefined = 0, Centipoise, MicropascalSecond, MillipascalSecond, diff --git a/UnitsNet/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs index 21e8f4edfa..f6c3afcc4c 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricAdmittanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricAdmittanceUnit { - Undefined = 0, Microsiemens, Millisiemens, Nanosiemens, diff --git a/UnitsNet/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs index 8797383f4a..24bc7adb18 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricChargeDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricChargeDensityUnit { - Undefined = 0, CoulombPerCubicMeter, } diff --git a/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs index 65c4b8b58d..7d775c82a3 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricChargeUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricChargeUnit { - Undefined = 0, AmpereHour, Coulomb, KiloampereHour, diff --git a/UnitsNet/GeneratedCode/Units/ElectricConductanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricConductanceUnit.g.cs index 5b852833d7..d87748356e 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricConductanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricConductanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricConductanceUnit { - Undefined = 0, Microsiemens, Millisiemens, Siemens, diff --git a/UnitsNet/GeneratedCode/Units/ElectricConductivityUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricConductivityUnit.g.cs index 6afee546c8..1c1f2ffc4b 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricConductivityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricConductivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricConductivityUnit { - Undefined = 0, SiemensPerFoot, SiemensPerInch, SiemensPerMeter, diff --git a/UnitsNet/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs index 9a0a8c9715..438ab45542 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricCurrentDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricCurrentDensityUnit { - Undefined = 0, AmperePerSquareFoot, AmperePerSquareInch, AmperePerSquareMeter, diff --git a/UnitsNet/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs index ec7e9f0e02..3f58821e0e 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricCurrentGradientUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricCurrentGradientUnit { - Undefined = 0, AmperePerMicrosecond, AmperePerMillisecond, AmperePerNanosecond, diff --git a/UnitsNet/GeneratedCode/Units/ElectricCurrentUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricCurrentUnit.g.cs index a2b690d5c4..73df60e25d 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricCurrentUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricCurrentUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricCurrentUnit { - Undefined = 0, Ampere, Centiampere, Kiloampere, diff --git a/UnitsNet/GeneratedCode/Units/ElectricFieldUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricFieldUnit.g.cs index c3710d6ad6..acd3de7d8c 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricFieldUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricFieldUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricFieldUnit { - Undefined = 0, VoltPerMeter, } diff --git a/UnitsNet/GeneratedCode/Units/ElectricInductanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricInductanceUnit.g.cs index 1cac8bbe3c..8e9db523e9 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricInductanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricInductanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricInductanceUnit { - Undefined = 0, Henry, Microhenry, Millihenry, diff --git a/UnitsNet/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs index 87ba58a573..6b44b3f3cd 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricPotentialAcUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialAcUnit { - Undefined = 0, KilovoltAc, MegavoltAc, MicrovoltAc, diff --git a/UnitsNet/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs index d77a1dd97b..c2764850a7 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricPotentialChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialChangeRateUnit { - Undefined = 0, KilovoltPerHour, KilovoltPerMicrosecond, KilovoltPerMinute, diff --git a/UnitsNet/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs index 8743571009..98e8b5b40f 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricPotentialDcUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialDcUnit { - Undefined = 0, KilovoltDc, MegavoltDc, MicrovoltDc, diff --git a/UnitsNet/GeneratedCode/Units/ElectricPotentialUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricPotentialUnit.g.cs index a50136ad6b..436e7c740a 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricPotentialUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricPotentialUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricPotentialUnit { - Undefined = 0, Kilovolt, Megavolt, Microvolt, diff --git a/UnitsNet/GeneratedCode/Units/ElectricResistanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricResistanceUnit.g.cs index e0cdbd4632..c7e9de7756 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricResistanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricResistanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricResistanceUnit { - Undefined = 0, Gigaohm, Kiloohm, Megaohm, diff --git a/UnitsNet/GeneratedCode/Units/ElectricResistivityUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricResistivityUnit.g.cs index cb6360eda3..8d198d3983 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricResistivityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricResistivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricResistivityUnit { - Undefined = 0, KiloohmCentimeter, KiloohmMeter, MegaohmCentimeter, diff --git a/UnitsNet/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs index 1e96388035..ce5be9b6fb 100644 --- a/UnitsNet/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ElectricSurfaceChargeDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ElectricSurfaceChargeDensityUnit { - Undefined = 0, CoulombPerSquareCentimeter, CoulombPerSquareInch, CoulombPerSquareMeter, diff --git a/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs index f0fb9bb49d..ccbf4d9d0b 100644 --- a/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/EnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum EnergyUnit { - Undefined = 0, BritishThermalUnit, Calorie, DecathermEc, diff --git a/UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs b/UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs index 527b5b7f3c..8f4a0f622e 100644 --- a/UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/EntropyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum EntropyUnit { - Undefined = 0, CaloriePerKelvin, JoulePerDegreeCelsius, JoulePerKelvin, diff --git a/UnitsNet/GeneratedCode/Units/ForceChangeRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/ForceChangeRateUnit.g.cs index 872ff7774c..990af24d02 100644 --- a/UnitsNet/GeneratedCode/Units/ForceChangeRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ForceChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ForceChangeRateUnit { - Undefined = 0, CentinewtonPerSecond, DecanewtonPerMinute, DecanewtonPerSecond, diff --git a/UnitsNet/GeneratedCode/Units/ForcePerLengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/ForcePerLengthUnit.g.cs index e5f004605f..b29b199249 100644 --- a/UnitsNet/GeneratedCode/Units/ForcePerLengthUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ForcePerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ForcePerLengthUnit { - Undefined = 0, CentinewtonPerCentimeter, CentinewtonPerMeter, CentinewtonPerMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs index b3124108bd..de87d0edc0 100644 --- a/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ForceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ForceUnit { - Undefined = 0, Decanewton, Dyn, KilogramForce, diff --git a/UnitsNet/GeneratedCode/Units/FrequencyUnit.g.cs b/UnitsNet/GeneratedCode/Units/FrequencyUnit.g.cs index fd5c104061..6db6d05233 100644 --- a/UnitsNet/GeneratedCode/Units/FrequencyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/FrequencyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum FrequencyUnit { - Undefined = 0, BeatPerMinute, BUnit, CyclePerHour, diff --git a/UnitsNet/GeneratedCode/Units/FuelEfficiencyUnit.g.cs b/UnitsNet/GeneratedCode/Units/FuelEfficiencyUnit.g.cs index 7dbfd0ab36..f2046a9aaf 100644 --- a/UnitsNet/GeneratedCode/Units/FuelEfficiencyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/FuelEfficiencyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum FuelEfficiencyUnit { - Undefined = 0, KilometerPerLiter, LiterPer100Kilometers, MilePerUkGallon, diff --git a/UnitsNet/GeneratedCode/Units/HeatFluxUnit.g.cs b/UnitsNet/GeneratedCode/Units/HeatFluxUnit.g.cs index bc76552e32..85bd6051b5 100644 --- a/UnitsNet/GeneratedCode/Units/HeatFluxUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/HeatFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum HeatFluxUnit { - Undefined = 0, BtuPerHourSquareFoot, BtuPerMinuteSquareFoot, BtuPerSecondSquareFoot, diff --git a/UnitsNet/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs b/UnitsNet/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs index 6494d31478..68eb7e0656 100644 --- a/UnitsNet/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/HeatTransferCoefficientUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum HeatTransferCoefficientUnit { - Undefined = 0, BtuPerSquareFootDegreeFahrenheit, WattPerSquareMeterCelsius, WattPerSquareMeterKelvin, diff --git a/UnitsNet/GeneratedCode/Units/IlluminanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/IlluminanceUnit.g.cs index 3584e96825..8d187efb2a 100644 --- a/UnitsNet/GeneratedCode/Units/IlluminanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/IlluminanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum IlluminanceUnit { - Undefined = 0, Kilolux, Lux, Megalux, diff --git a/UnitsNet/GeneratedCode/Units/InformationUnit.g.cs b/UnitsNet/GeneratedCode/Units/InformationUnit.g.cs index 2986de4b20..a6e00fdfd4 100644 --- a/UnitsNet/GeneratedCode/Units/InformationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/InformationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum InformationUnit { - Undefined = 0, Bit, Byte, Exabit, diff --git a/UnitsNet/GeneratedCode/Units/IrradianceUnit.g.cs b/UnitsNet/GeneratedCode/Units/IrradianceUnit.g.cs index 285e771afa..204dddebf5 100644 --- a/UnitsNet/GeneratedCode/Units/IrradianceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/IrradianceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum IrradianceUnit { - Undefined = 0, KilowattPerSquareCentimeter, KilowattPerSquareMeter, MegawattPerSquareCentimeter, diff --git a/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs b/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs index 1a13e8d425..2ce58066fc 100644 --- a/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/IrradiationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum IrradiationUnit { - Undefined = 0, JoulePerSquareCentimeter, JoulePerSquareMeter, JoulePerSquareMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/KinematicViscosityUnit.g.cs b/UnitsNet/GeneratedCode/Units/KinematicViscosityUnit.g.cs index af0c4a0e22..4bdb8e1759 100644 --- a/UnitsNet/GeneratedCode/Units/KinematicViscosityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/KinematicViscosityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum KinematicViscosityUnit { - Undefined = 0, Centistokes, Decistokes, Kilostokes, diff --git a/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs index 0db5758f3e..41f5b8bbe4 100644 --- a/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LapseRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LapseRateUnit { - Undefined = 0, DegreeCelsiusPerKilometer, } diff --git a/UnitsNet/GeneratedCode/Units/LengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/LengthUnit.g.cs index d2987f8ad4..c3e48b2d94 100644 --- a/UnitsNet/GeneratedCode/Units/LengthUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LengthUnit { - Undefined = 0, /// /// One Astronomical Unit is the distance from the solar system Star, the sun, to planet Earth. diff --git a/UnitsNet/GeneratedCode/Units/LevelUnit.g.cs b/UnitsNet/GeneratedCode/Units/LevelUnit.g.cs index d1cd5c65ed..1ec66cdc70 100644 --- a/UnitsNet/GeneratedCode/Units/LevelUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LevelUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LevelUnit { - Undefined = 0, Decibel, Neper, } diff --git a/UnitsNet/GeneratedCode/Units/LinearDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/LinearDensityUnit.g.cs index 70a4f47764..cff6234413 100644 --- a/UnitsNet/GeneratedCode/Units/LinearDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LinearDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LinearDensityUnit { - Undefined = 0, GramPerCentimeter, GramPerMeter, GramPerMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/LinearPowerDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/LinearPowerDensityUnit.g.cs index 0f744effb5..0eacaf457f 100644 --- a/UnitsNet/GeneratedCode/Units/LinearPowerDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LinearPowerDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LinearPowerDensityUnit { - Undefined = 0, GigawattPerCentimeter, GigawattPerFoot, GigawattPerInch, diff --git a/UnitsNet/GeneratedCode/Units/LuminosityUnit.g.cs b/UnitsNet/GeneratedCode/Units/LuminosityUnit.g.cs index 309e51093d..8c08810b72 100644 --- a/UnitsNet/GeneratedCode/Units/LuminosityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LuminosityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LuminosityUnit { - Undefined = 0, Decawatt, Deciwatt, Femtowatt, diff --git a/UnitsNet/GeneratedCode/Units/LuminousFluxUnit.g.cs b/UnitsNet/GeneratedCode/Units/LuminousFluxUnit.g.cs index 7d3122939f..77ebbc99e1 100644 --- a/UnitsNet/GeneratedCode/Units/LuminousFluxUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LuminousFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LuminousFluxUnit { - Undefined = 0, Lumen, } diff --git a/UnitsNet/GeneratedCode/Units/LuminousIntensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/LuminousIntensityUnit.g.cs index 16feeb4596..796be6f002 100644 --- a/UnitsNet/GeneratedCode/Units/LuminousIntensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/LuminousIntensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum LuminousIntensityUnit { - Undefined = 0, Candela, } diff --git a/UnitsNet/GeneratedCode/Units/MagneticFieldUnit.g.cs b/UnitsNet/GeneratedCode/Units/MagneticFieldUnit.g.cs index 5ce5acdc3f..c86ae72bf0 100644 --- a/UnitsNet/GeneratedCode/Units/MagneticFieldUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MagneticFieldUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MagneticFieldUnit { - Undefined = 0, Gauss, Microtesla, Milligauss, diff --git a/UnitsNet/GeneratedCode/Units/MagneticFluxUnit.g.cs b/UnitsNet/GeneratedCode/Units/MagneticFluxUnit.g.cs index 241a0fc57b..3429bbbd15 100644 --- a/UnitsNet/GeneratedCode/Units/MagneticFluxUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MagneticFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MagneticFluxUnit { - Undefined = 0, Weber, } diff --git a/UnitsNet/GeneratedCode/Units/MagnetizationUnit.g.cs b/UnitsNet/GeneratedCode/Units/MagnetizationUnit.g.cs index 96438162e4..600764abff 100644 --- a/UnitsNet/GeneratedCode/Units/MagnetizationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MagnetizationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MagnetizationUnit { - Undefined = 0, AmperePerMeter, } diff --git a/UnitsNet/GeneratedCode/Units/MassConcentrationUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassConcentrationUnit.g.cs index 75513af502..501dbffc36 100644 --- a/UnitsNet/GeneratedCode/Units/MassConcentrationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MassConcentrationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassConcentrationUnit { - Undefined = 0, CentigramPerDeciliter, CentigramPerLiter, CentigramPerMicroliter, diff --git a/UnitsNet/GeneratedCode/Units/MassFlowUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassFlowUnit.g.cs index acf8b9cba6..1288782e40 100644 --- a/UnitsNet/GeneratedCode/Units/MassFlowUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MassFlowUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassFlowUnit { - Undefined = 0, CentigramPerDay, CentigramPerSecond, DecagramPerDay, diff --git a/UnitsNet/GeneratedCode/Units/MassFluxUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassFluxUnit.g.cs index 2723abf13a..8eb72cbb51 100644 --- a/UnitsNet/GeneratedCode/Units/MassFluxUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MassFluxUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassFluxUnit { - Undefined = 0, GramPerHourPerSquareCentimeter, GramPerHourPerSquareMeter, GramPerHourPerSquareMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/MassFractionUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassFractionUnit.g.cs index 8151a08dfd..bcad070f95 100644 --- a/UnitsNet/GeneratedCode/Units/MassFractionUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MassFractionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassFractionUnit { - Undefined = 0, CentigramPerGram, CentigramPerKilogram, DecagramPerGram, diff --git a/UnitsNet/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs index 972b52d375..44042eba4c 100644 --- a/UnitsNet/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MassMomentOfInertiaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassMomentOfInertiaUnit { - Undefined = 0, GramSquareCentimeter, GramSquareDecimeter, GramSquareMeter, diff --git a/UnitsNet/GeneratedCode/Units/MassUnit.g.cs b/UnitsNet/GeneratedCode/Units/MassUnit.g.cs index 37a441d742..02ef7a2f78 100644 --- a/UnitsNet/GeneratedCode/Units/MassUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MassUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MassUnit { - Undefined = 0, Centigram, Decagram, Decigram, diff --git a/UnitsNet/GeneratedCode/Units/MolarEnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/MolarEnergyUnit.g.cs index cd0ba80e11..988b8203ec 100644 --- a/UnitsNet/GeneratedCode/Units/MolarEnergyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MolarEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarEnergyUnit { - Undefined = 0, JoulePerMole, KilojoulePerMole, MegajoulePerMole, diff --git a/UnitsNet/GeneratedCode/Units/MolarEntropyUnit.g.cs b/UnitsNet/GeneratedCode/Units/MolarEntropyUnit.g.cs index edd5decabe..2102e52d4c 100644 --- a/UnitsNet/GeneratedCode/Units/MolarEntropyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MolarEntropyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarEntropyUnit { - Undefined = 0, JoulePerMoleKelvin, KilojoulePerMoleKelvin, MegajoulePerMoleKelvin, diff --git a/UnitsNet/GeneratedCode/Units/MolarMassUnit.g.cs b/UnitsNet/GeneratedCode/Units/MolarMassUnit.g.cs index 2e955277a5..8fd58c4fce 100644 --- a/UnitsNet/GeneratedCode/Units/MolarMassUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MolarMassUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarMassUnit { - Undefined = 0, CentigramPerMole, DecagramPerMole, DecigramPerMole, diff --git a/UnitsNet/GeneratedCode/Units/MolarityUnit.g.cs b/UnitsNet/GeneratedCode/Units/MolarityUnit.g.cs index 854a8969e0..4bae6e2bf4 100644 --- a/UnitsNet/GeneratedCode/Units/MolarityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/MolarityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum MolarityUnit { - Undefined = 0, CentimolesPerLiter, DecimolesPerLiter, MicromolesPerLiter, diff --git a/UnitsNet/GeneratedCode/Units/PermeabilityUnit.g.cs b/UnitsNet/GeneratedCode/Units/PermeabilityUnit.g.cs index 9d236dbc9c..df63a1b08d 100644 --- a/UnitsNet/GeneratedCode/Units/PermeabilityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PermeabilityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PermeabilityUnit { - Undefined = 0, HenryPerMeter, } diff --git a/UnitsNet/GeneratedCode/Units/PermittivityUnit.g.cs b/UnitsNet/GeneratedCode/Units/PermittivityUnit.g.cs index 02caf933de..00938d92b6 100644 --- a/UnitsNet/GeneratedCode/Units/PermittivityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PermittivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PermittivityUnit { - Undefined = 0, FaradPerMeter, } diff --git a/UnitsNet/GeneratedCode/Units/PowerDensityUnit.g.cs b/UnitsNet/GeneratedCode/Units/PowerDensityUnit.g.cs index 10946ecb5b..ffda44acc7 100644 --- a/UnitsNet/GeneratedCode/Units/PowerDensityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PowerDensityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PowerDensityUnit { - Undefined = 0, DecawattPerCubicFoot, DecawattPerCubicInch, DecawattPerCubicMeter, diff --git a/UnitsNet/GeneratedCode/Units/PowerRatioUnit.g.cs b/UnitsNet/GeneratedCode/Units/PowerRatioUnit.g.cs index e4a29c66ed..cb75bef85e 100644 --- a/UnitsNet/GeneratedCode/Units/PowerRatioUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PowerRatioUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PowerRatioUnit { - Undefined = 0, DecibelMilliwatt, DecibelWatt, } diff --git a/UnitsNet/GeneratedCode/Units/PowerUnit.g.cs b/UnitsNet/GeneratedCode/Units/PowerUnit.g.cs index 43701759dc..5631baba5a 100644 --- a/UnitsNet/GeneratedCode/Units/PowerUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PowerUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PowerUnit { - Undefined = 0, BoilerHorsepower, BritishThermalUnitPerHour, Decawatt, diff --git a/UnitsNet/GeneratedCode/Units/PressureChangeRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/PressureChangeRateUnit.g.cs index 60fe8b12a9..321b81de30 100644 --- a/UnitsNet/GeneratedCode/Units/PressureChangeRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PressureChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PressureChangeRateUnit { - Undefined = 0, AtmospherePerSecond, KilopascalPerMinute, KilopascalPerSecond, diff --git a/UnitsNet/GeneratedCode/Units/PressureUnit.g.cs b/UnitsNet/GeneratedCode/Units/PressureUnit.g.cs index 19dc745d2f..044ee33d3c 100644 --- a/UnitsNet/GeneratedCode/Units/PressureUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/PressureUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum PressureUnit { - Undefined = 0, Atmosphere, Bar, Centibar, diff --git a/UnitsNet/GeneratedCode/Units/RatioChangeRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/RatioChangeRateUnit.g.cs index bcde32166e..a43cd4b250 100644 --- a/UnitsNet/GeneratedCode/Units/RatioChangeRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RatioChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RatioChangeRateUnit { - Undefined = 0, DecimalFractionPerSecond, PercentPerSecond, } diff --git a/UnitsNet/GeneratedCode/Units/RatioUnit.g.cs b/UnitsNet/GeneratedCode/Units/RatioUnit.g.cs index c4d62326dc..be13f76760 100644 --- a/UnitsNet/GeneratedCode/Units/RatioUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RatioUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RatioUnit { - Undefined = 0, DecimalFraction, PartPerBillion, PartPerMillion, diff --git a/UnitsNet/GeneratedCode/Units/ReactiveEnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/ReactiveEnergyUnit.g.cs index 9c5e12ddb0..863003f8ec 100644 --- a/UnitsNet/GeneratedCode/Units/ReactiveEnergyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ReactiveEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReactiveEnergyUnit { - Undefined = 0, KilovoltampereReactiveHour, MegavoltampereReactiveHour, VoltampereReactiveHour, diff --git a/UnitsNet/GeneratedCode/Units/ReactivePowerUnit.g.cs b/UnitsNet/GeneratedCode/Units/ReactivePowerUnit.g.cs index 6dcb0a2687..ae28daaec3 100644 --- a/UnitsNet/GeneratedCode/Units/ReactivePowerUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ReactivePowerUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReactivePowerUnit { - Undefined = 0, GigavoltampereReactive, KilovoltampereReactive, MegavoltampereReactive, diff --git a/UnitsNet/GeneratedCode/Units/ReciprocalAreaUnit.g.cs b/UnitsNet/GeneratedCode/Units/ReciprocalAreaUnit.g.cs index 822c6e03eb..122fd72e55 100644 --- a/UnitsNet/GeneratedCode/Units/ReciprocalAreaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ReciprocalAreaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReciprocalAreaUnit { - Undefined = 0, InverseSquareCentimeter, InverseSquareDecimeter, InverseSquareFoot, diff --git a/UnitsNet/GeneratedCode/Units/ReciprocalLengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/ReciprocalLengthUnit.g.cs index 166f08af87..2346e35c76 100644 --- a/UnitsNet/GeneratedCode/Units/ReciprocalLengthUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ReciprocalLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ReciprocalLengthUnit { - Undefined = 0, InverseCentimeter, InverseFoot, InverseInch, diff --git a/UnitsNet/GeneratedCode/Units/RelativeHumidityUnit.g.cs b/UnitsNet/GeneratedCode/Units/RelativeHumidityUnit.g.cs index d1ff2b1726..522ab7449b 100644 --- a/UnitsNet/GeneratedCode/Units/RelativeHumidityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RelativeHumidityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RelativeHumidityUnit { - Undefined = 0, Percent, } diff --git a/UnitsNet/GeneratedCode/Units/RotationalAccelerationUnit.g.cs b/UnitsNet/GeneratedCode/Units/RotationalAccelerationUnit.g.cs index e207d6c1ae..acc0acf6f6 100644 --- a/UnitsNet/GeneratedCode/Units/RotationalAccelerationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RotationalAccelerationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalAccelerationUnit { - Undefined = 0, DegreePerSecondSquared, RadianPerSecondSquared, RevolutionPerMinutePerSecond, diff --git a/UnitsNet/GeneratedCode/Units/RotationalSpeedUnit.g.cs b/UnitsNet/GeneratedCode/Units/RotationalSpeedUnit.g.cs index 93b644ac7c..d5c3290737 100644 --- a/UnitsNet/GeneratedCode/Units/RotationalSpeedUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RotationalSpeedUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalSpeedUnit { - Undefined = 0, CentiradianPerSecond, DeciradianPerSecond, DegreePerMinute, diff --git a/UnitsNet/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs index 479001f79c..a1e8777e2f 100644 --- a/UnitsNet/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RotationalStiffnessPerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalStiffnessPerLengthUnit { - Undefined = 0, KilonewtonMeterPerRadianPerMeter, KilopoundForceFootPerDegreesPerFoot, MeganewtonMeterPerRadianPerMeter, diff --git a/UnitsNet/GeneratedCode/Units/RotationalStiffnessUnit.g.cs b/UnitsNet/GeneratedCode/Units/RotationalStiffnessUnit.g.cs index 1ca970ecb1..99dfef7ae9 100644 --- a/UnitsNet/GeneratedCode/Units/RotationalStiffnessUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/RotationalStiffnessUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum RotationalStiffnessUnit { - Undefined = 0, CentinewtonMeterPerDegree, CentinewtonMillimeterPerDegree, CentinewtonMillimeterPerRadian, diff --git a/UnitsNet/GeneratedCode/Units/ScalarUnit.g.cs b/UnitsNet/GeneratedCode/Units/ScalarUnit.g.cs index 3b0891f314..0ba35b11d5 100644 --- a/UnitsNet/GeneratedCode/Units/ScalarUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ScalarUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ScalarUnit { - Undefined = 0, Amount, } diff --git a/UnitsNet/GeneratedCode/Units/SolidAngleUnit.g.cs b/UnitsNet/GeneratedCode/Units/SolidAngleUnit.g.cs index 1fa9137298..dcdd777eae 100644 --- a/UnitsNet/GeneratedCode/Units/SolidAngleUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SolidAngleUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SolidAngleUnit { - Undefined = 0, Steradian, } diff --git a/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs index 3c59f4a00f..02cc18028b 100644 --- a/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SpecificEnergyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificEnergyUnit { - Undefined = 0, BtuPerPound, CaloriePerGram, GigawattDayPerKilogram, diff --git a/UnitsNet/GeneratedCode/Units/SpecificEntropyUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpecificEntropyUnit.g.cs index 744c7608bf..f8611c6bb9 100644 --- a/UnitsNet/GeneratedCode/Units/SpecificEntropyUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SpecificEntropyUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificEntropyUnit { - Undefined = 0, BtuPerPoundFahrenheit, CaloriePerGramKelvin, JoulePerKilogramDegreeCelsius, diff --git a/UnitsNet/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs index f83628860d..c462612789 100644 --- a/UnitsNet/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SpecificFuelConsumptionUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificFuelConsumptionUnit { - Undefined = 0, GramPerKiloNewtonSecond, KilogramPerKilogramForceHour, KilogramPerKiloNewtonSecond, diff --git a/UnitsNet/GeneratedCode/Units/SpecificVolumeUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpecificVolumeUnit.g.cs index 64f2e15212..d1066753fe 100644 --- a/UnitsNet/GeneratedCode/Units/SpecificVolumeUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SpecificVolumeUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificVolumeUnit { - Undefined = 0, CubicFootPerPound, CubicMeterPerKilogram, MillicubicMeterPerKilogram, diff --git a/UnitsNet/GeneratedCode/Units/SpecificWeightUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpecificWeightUnit.g.cs index 21c71caacf..da2b36b6b4 100644 --- a/UnitsNet/GeneratedCode/Units/SpecificWeightUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SpecificWeightUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpecificWeightUnit { - Undefined = 0, KilogramForcePerCubicCentimeter, KilogramForcePerCubicMeter, KilogramForcePerCubicMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/SpeedUnit.g.cs b/UnitsNet/GeneratedCode/Units/SpeedUnit.g.cs index 77335fd679..fdd5854520 100644 --- a/UnitsNet/GeneratedCode/Units/SpeedUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/SpeedUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum SpeedUnit { - Undefined = 0, CentimeterPerHour, CentimeterPerMinute, CentimeterPerSecond, diff --git a/UnitsNet/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs b/UnitsNet/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs index 86f6e5d486..65ee3bd72b 100644 --- a/UnitsNet/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/StandardVolumeFlowUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum StandardVolumeFlowUnit { - Undefined = 0, StandardCubicCentimeterPerMinute, StandardCubicFootPerHour, StandardCubicFootPerMinute, diff --git a/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs b/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs index 1170aab72f..dc87b5b284 100644 --- a/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TemperatureChangeRateUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureChangeRateUnit { - Undefined = 0, CentidegreeCelsiusPerSecond, DecadegreeCelsiusPerSecond, DecidegreeCelsiusPerSecond, diff --git a/UnitsNet/GeneratedCode/Units/TemperatureDeltaUnit.g.cs b/UnitsNet/GeneratedCode/Units/TemperatureDeltaUnit.g.cs index 7fded81179..2b1b219672 100644 --- a/UnitsNet/GeneratedCode/Units/TemperatureDeltaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TemperatureDeltaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureDeltaUnit { - Undefined = 0, DegreeCelsius, DegreeDelisle, DegreeFahrenheit, diff --git a/UnitsNet/GeneratedCode/Units/TemperatureUnit.g.cs b/UnitsNet/GeneratedCode/Units/TemperatureUnit.g.cs index 9fef394aec..dcca0a9ba9 100644 --- a/UnitsNet/GeneratedCode/Units/TemperatureUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TemperatureUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureUnit { - Undefined = 0, DegreeCelsius, DegreeDelisle, DegreeFahrenheit, diff --git a/UnitsNet/GeneratedCode/Units/ThermalConductivityUnit.g.cs b/UnitsNet/GeneratedCode/Units/ThermalConductivityUnit.g.cs index b57d36aa6e..1cf78e2034 100644 --- a/UnitsNet/GeneratedCode/Units/ThermalConductivityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ThermalConductivityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ThermalConductivityUnit { - Undefined = 0, BtuPerHourFootFahrenheit, WattPerMeterKelvin, } diff --git a/UnitsNet/GeneratedCode/Units/ThermalResistanceUnit.g.cs b/UnitsNet/GeneratedCode/Units/ThermalResistanceUnit.g.cs index 643e5ba89f..5ca71e2a83 100644 --- a/UnitsNet/GeneratedCode/Units/ThermalResistanceUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/ThermalResistanceUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum ThermalResistanceUnit { - Undefined = 0, HourSquareFeetDegreeFahrenheitPerBtu, SquareCentimeterHourDegreeCelsiusPerKilocalorie, SquareCentimeterKelvinPerWatt, diff --git a/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs index f400c141d5..5338332165 100644 --- a/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TorquePerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TorquePerLengthUnit { - Undefined = 0, KilogramForceCentimeterPerMeter, KilogramForceMeterPerMeter, KilogramForceMillimeterPerMeter, diff --git a/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs b/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs index b8f52ad98e..7d73a74e8d 100644 --- a/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TorqueUnit { - Undefined = 0, KilogramForceCentimeter, KilogramForceMeter, KilogramForceMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/TurbidityUnit.g.cs b/UnitsNet/GeneratedCode/Units/TurbidityUnit.g.cs index 8e9c870a04..51be9ce794 100644 --- a/UnitsNet/GeneratedCode/Units/TurbidityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TurbidityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TurbidityUnit { - Undefined = 0, NTU, } diff --git a/UnitsNet/GeneratedCode/Units/VitaminAUnit.g.cs b/UnitsNet/GeneratedCode/Units/VitaminAUnit.g.cs index 566de16722..29a33a74f2 100644 --- a/UnitsNet/GeneratedCode/Units/VitaminAUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VitaminAUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VitaminAUnit { - Undefined = 0, InternationalUnit, } diff --git a/UnitsNet/GeneratedCode/Units/VolumeConcentrationUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeConcentrationUnit.g.cs index 5fa899ebe4..6be8480466 100644 --- a/UnitsNet/GeneratedCode/Units/VolumeConcentrationUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumeConcentrationUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeConcentrationUnit { - Undefined = 0, CentilitersPerLiter, CentilitersPerMililiter, DecilitersPerLiter, diff --git a/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs index f801690542..e213e441f1 100644 --- a/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumeFlowUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeFlowUnit { - Undefined = 0, AcreFootPerDay, AcreFootPerHour, AcreFootPerMinute, diff --git a/UnitsNet/GeneratedCode/Units/VolumePerLengthUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumePerLengthUnit.g.cs index 9fe06e5e68..059507a461 100644 --- a/UnitsNet/GeneratedCode/Units/VolumePerLengthUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumePerLengthUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumePerLengthUnit { - Undefined = 0, CubicMeterPerMeter, CubicYardPerFoot, CubicYardPerUsSurveyFoot, diff --git a/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs index 2f659cf5d4..c32808ad1e 100644 --- a/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumeUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeUnit { - Undefined = 0, AcreFoot, AuTablespoon, BoardFoot, diff --git a/UnitsNet/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs index 2f18602337..fda6345525 100644 --- a/UnitsNet/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumetricHeatCapacityUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumetricHeatCapacityUnit { - Undefined = 0, BtuPerCubicFootDegreeFahrenheit, CaloriePerCubicCentimeterDegreeCelsius, JoulePerCubicMeterDegreeCelsius, diff --git a/UnitsNet/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs b/UnitsNet/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs index a7e6d93c2e..64d2dc6cb8 100644 --- a/UnitsNet/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/WarpingMomentOfInertiaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum WarpingMomentOfInertiaUnit { - Undefined = 0, CentimeterToTheSixth, DecimeterToTheSixth, FootToTheSixth, From 60ee7ed67477f20915ebd2e4eb12bd7a3219d291 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 14 Nov 2021 00:26:25 +0100 Subject: [PATCH 44/66] fixup! Remove Undefined unit value Fix tests and compile errors after generating code --- UnitsNet.Tests/BaseUnitsTests.cs | 14 ++-- UnitsNet.Tests/QuantityFormatterTests.cs | 5 +- UnitsNet.Tests/UnitSystemTests.cs | 18 ++--- UnitsNet/BaseUnits.cs | 74 ++++++++++--------- UnitsNet/CustomCode/UnitAbbreviationsCache.cs | 10 +-- UnitsNet/CustomCode/UnitParser.cs | 8 +- .../CustomCode/UnitValueAbbreviationLookup.cs | 10 +-- UnitsNet/QuantityFormatter.cs | 2 +- 8 files changed, 75 insertions(+), 66 deletions(-) diff --git a/UnitsNet.Tests/BaseUnitsTests.cs b/UnitsNet.Tests/BaseUnitsTests.cs index f50580c387..545448e2ac 100644 --- a/UnitsNet.Tests/BaseUnitsTests.cs +++ b/UnitsNet.Tests/BaseUnitsTests.cs @@ -94,13 +94,13 @@ public void InequalityOperatorIsImplementedCorrectly() [Fact] public void UndefinedHasAllBaseUnitsAsUndefined() { - Assert.Equal(LengthUnit.Undefined, BaseUnits.Undefined.Length); - Assert.Equal(MassUnit.Undefined, BaseUnits.Undefined.Mass); - Assert.Equal(DurationUnit.Undefined, BaseUnits.Undefined.Time); - Assert.Equal(ElectricCurrentUnit.Undefined, BaseUnits.Undefined.Current); - Assert.Equal(TemperatureUnit.Undefined, BaseUnits.Undefined.Temperature); - Assert.Equal(AmountOfSubstanceUnit.Undefined, BaseUnits.Undefined.Amount); - Assert.Equal(LuminousIntensityUnit.Undefined, BaseUnits.Undefined.LuminousIntensity); + Assert.Null(BaseUnits.Undefined.Length); + Assert.Null(BaseUnits.Undefined.Mass); + Assert.Null(BaseUnits.Undefined.Time); + Assert.Null(BaseUnits.Undefined.Current); + Assert.Null(BaseUnits.Undefined.Temperature); + Assert.Null(BaseUnits.Undefined.Amount); + Assert.Null(BaseUnits.Undefined.LuminousIntensity); } [Fact] diff --git a/UnitsNet.Tests/QuantityFormatterTests.cs b/UnitsNet.Tests/QuantityFormatterTests.cs index eab7fe8d29..06628d5b44 100644 --- a/UnitsNet.Tests/QuantityFormatterTests.cs +++ b/UnitsNet.Tests/QuantityFormatterTests.cs @@ -117,10 +117,9 @@ public static void StandardNumericFormatStrings_Equals_ValueWithFormatStringAndA public static void StandardNumericFormatStringsAsPartOfLongerFormatStringsWork() { var length = Length.FromMeters(123.321); - var expected = "The distance is 123.3 m"; - var actual = string.Format(CultureInfo.InvariantCulture, $"The distance is {length:F1}"); - Assert.Equal(expected, actual); + var actual = $"The distance is {length.ToString("F1", CultureInfo.InvariantCulture)}"; + Assert.Equal(expected, actual); } [Theory] diff --git a/UnitsNet.Tests/UnitSystemTests.cs b/UnitsNet.Tests/UnitSystemTests.cs index a1463f5cb7..a3b106ca9b 100644 --- a/UnitsNet.Tests/UnitSystemTests.cs +++ b/UnitsNet.Tests/UnitSystemTests.cs @@ -27,15 +27,15 @@ public void ConstructorThrowsArgumentNullExceptionForNullBaseUnits() } [Theory] - [InlineData(LengthUnit.Undefined, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] - [InlineData(LengthUnit.Meter, MassUnit.Undefined, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] - [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Undefined, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] - [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Undefined, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] - [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Undefined, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] - [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Undefined, LuminousIntensityUnit.Candela)] - [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Undefined)] - public void ConstructorThrowsArgumentExceptionWithUndefinedUnits(LengthUnit length, MassUnit mass, DurationUnit time, ElectricCurrentUnit current, - TemperatureUnit temperature, AmountOfSubstanceUnit amount, LuminousIntensityUnit luminousIntensity) + [InlineData(null, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] + [InlineData(LengthUnit.Meter, null, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] + [InlineData(LengthUnit.Meter, MassUnit.Kilogram, null, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] + [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, null, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] + [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, null, AmountOfSubstanceUnit.Mole, LuminousIntensityUnit.Candela)] + [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, null, LuminousIntensityUnit.Candela)] + [InlineData(LengthUnit.Meter, MassUnit.Kilogram, DurationUnit.Second, ElectricCurrentUnit.Ampere, TemperatureUnit.Kelvin, AmountOfSubstanceUnit.Mole, null)] + public void ConstructorThrowsArgumentExceptionWithUndefinedUnits(LengthUnit? length, MassUnit? mass, DurationUnit? time, ElectricCurrentUnit? current, + TemperatureUnit? temperature, AmountOfSubstanceUnit? amount, LuminousIntensityUnit? luminousIntensity) { var baseUnits = new BaseUnits(length, mass, time, current, temperature, amount, luminousIntensity); Assert.Throws(() => new UnitSystem(baseUnits)); diff --git a/UnitsNet/BaseUnits.cs b/UnitsNet/BaseUnits.cs index 61d08b761f..89858ddb40 100644 --- a/UnitsNet/BaseUnits.cs +++ b/UnitsNet/BaseUnits.cs @@ -31,13 +31,13 @@ public sealed class BaseUnits: IEquatable /// The amount of substance unit (N). /// The luminous intensity unit (J). public BaseUnits( - LengthUnit length = LengthUnit.Undefined, - MassUnit mass = MassUnit.Undefined, - DurationUnit time = DurationUnit.Undefined, - ElectricCurrentUnit current = ElectricCurrentUnit.Undefined, - TemperatureUnit temperature = TemperatureUnit.Undefined, - AmountOfSubstanceUnit amount = AmountOfSubstanceUnit.Undefined, - LuminousIntensityUnit luminousIntensity = LuminousIntensityUnit.Undefined) + LengthUnit? length = null, + MassUnit? mass = null, + DurationUnit? time = null, + ElectricCurrentUnit? current = null, + TemperatureUnit? temperature = null, + AmountOfSubstanceUnit? amount = null, + LuminousIntensityUnit? luminousIntensity = null) { Length = length; Mass = mass; @@ -47,13 +47,13 @@ public BaseUnits( Amount = amount; LuminousIntensity = luminousIntensity; - IsFullyDefined = Length != LengthUnit.Undefined && - Mass != MassUnit.Undefined && - Time != DurationUnit.Undefined && - Current != ElectricCurrentUnit.Undefined && - Temperature != TemperatureUnit.Undefined && - Amount != AmountOfSubstanceUnit.Undefined && - LuminousIntensity != LuminousIntensityUnit.Undefined; + IsFullyDefined = Length is not null && + Mass is not null & + Time is not null && + Current is not null && + Temperature is not null && + Amount is not null && + LuminousIntensity is not null; } /// @@ -96,13 +96,13 @@ public bool IsSubsetOf(BaseUnits other) if (Equals(Undefined)) return other.Equals(Undefined); - return (Length == LengthUnit.Undefined || Length == other.Length) && - (Mass == MassUnit.Undefined || Mass == other.Mass) && - (Time == DurationUnit.Undefined || Time == other.Time) && - (Current == ElectricCurrentUnit.Undefined || Current == other.Current) && - (Temperature == TemperatureUnit.Undefined || Temperature == other.Temperature) && - (Amount == AmountOfSubstanceUnit.Undefined || Amount == other.Amount) && - (LuminousIntensity == LuminousIntensityUnit.Undefined || LuminousIntensity == other.LuminousIntensity); + return (Length == null || Length == other.Length) && + (Mass == null || Mass == other.Mass) && + (Time == null || Time == other.Time) && + (Current == null || Current == other.Current) && + (Temperature == null || Temperature == other.Temperature) && + (Amount == null || Amount == other.Amount) && + (LuminousIntensity == null || LuminousIntensity == other.LuminousIntensity); } /// @@ -140,13 +140,17 @@ public override string ToString() { var sb = new StringBuilder(); - sb.AppendFormat("[Length]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Length)); - sb.AppendFormat("[Mass]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Mass)); - sb.AppendFormat("[Time]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Time)); - sb.AppendFormat("[Current]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Current)); - sb.AppendFormat("[Temperature]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Temperature)); - sb.AppendFormat("[Amount]: {0}, ", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(Amount)); - sb.AppendFormat("[LuminousIntensity]: {0}", UnitAbbreviationsCache.Default.GetDefaultAbbreviation(LuminousIntensity)); + string GetDefaultAbbreviation(TUnitType? unitOrNull) where TUnitType : struct, Enum => unitOrNull is { } unit + ? UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit) + : "N/A"; + + sb.AppendFormat("[Length]: {0}, ", GetDefaultAbbreviation(Length)); + sb.AppendFormat("[Mass]: {0}, ", GetDefaultAbbreviation(Mass)); + sb.AppendFormat("[Time]: {0}, ", GetDefaultAbbreviation(Time)); + sb.AppendFormat("[Current]: {0}, ", GetDefaultAbbreviation(Current)); + sb.AppendFormat("[Temperature]: {0}, ", GetDefaultAbbreviation(Temperature)); + sb.AppendFormat("[Amount]: {0}, ", GetDefaultAbbreviation(Amount)); + sb.AppendFormat("[LuminousIntensity]: {0}", GetDefaultAbbreviation(LuminousIntensity)); return sb.ToString(); } @@ -154,37 +158,37 @@ public override string ToString() /// /// Gets the length unit (L). /// - public LengthUnit Length { get; } + public LengthUnit? Length { get; } /// /// Gets the mass unit (M). /// - public MassUnit Mass{ get; } + public MassUnit? Mass{ get; } /// /// Gets the time unit (T). /// - public DurationUnit Time{ get; } + public DurationUnit? Time{ get; } /// /// Gets the electric current unit (I). /// - public ElectricCurrentUnit Current{ get; } + public ElectricCurrentUnit? Current{ get; } /// /// Gets the temperature unit (Θ). /// - public TemperatureUnit Temperature{ get; } + public TemperatureUnit? Temperature{ get; } /// /// Gets the amount of substance unit (N). /// - public AmountOfSubstanceUnit Amount{ get; } + public AmountOfSubstanceUnit? Amount{ get; } /// /// Gets the luminous intensity unit (J). /// - public LuminousIntensityUnit LuminousIntensity{ get; } + public LuminousIntensityUnit? LuminousIntensity{ get; } /// /// Gets whether or not all of the base units are defined. diff --git a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs index 907fcd87fb..f17f2f409e 100644 --- a/UnitsNet/CustomCode/UnitAbbreviationsCache.cs +++ b/UnitsNet/CustomCode/UnitAbbreviationsCache.cs @@ -29,7 +29,7 @@ public sealed partial class UnitAbbreviationsCache /// culture, but no translation is defined, so we return the US English definition as a last resort. If it's not /// defined there either, an exception is thrown. /// - private static readonly CultureInfo FallbackCulture = new("en-US"); + internal static readonly CultureInfo FallbackCulture = new("en-US"); /// /// The static instance used internally for ToString() and Parse() of quantities and units. @@ -162,7 +162,7 @@ private void PerformAbbreviationMapping(Type unitType, int unitValue, IFormatPro if (abbreviations == null) throw new ArgumentNullException(nameof(abbreviations)); - formatProvider = formatProvider ?? CultureInfo.CurrentCulture; + formatProvider ??= CultureInfo.CurrentCulture; if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) quantitiesForProvider = _lookupsForCulture[formatProvider] = new UnitTypeToLookup(); @@ -256,7 +256,7 @@ public string[] GetUnitAbbreviations(TUnitType unit, IFormatProvider? /// Unit abbreviations associated with unit. public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvider? formatProvider = null) { - formatProvider = formatProvider ?? CultureInfo.CurrentCulture; + formatProvider ??= CultureInfo.CurrentCulture; if (!TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var lookup)) { @@ -284,7 +284,7 @@ public string[] GetUnitAbbreviations(Type unitType, int unitValue, IFormatProvid /// Unit abbreviations associated with unit. public string[] GetAllUnitAbbreviationsForQuantity(Type unitEnumType, IFormatProvider? formatProvider = null) { - formatProvider = formatProvider ?? CultureInfo.CurrentCulture; + formatProvider ??= CultureInfo.CurrentCulture; if (!TryGetUnitValueAbbreviationLookup(unitEnumType, formatProvider, out var lookup)) { @@ -300,7 +300,7 @@ internal bool TryGetUnitValueAbbreviationLookup(Type unitType, IFormatProvider? { unitToAbbreviations = null; - formatProvider = formatProvider ?? CultureInfo.CurrentCulture; + formatProvider ??= CultureInfo.CurrentCulture; if (!_lookupsForCulture.TryGetValue(formatProvider, out var quantitiesForProvider)) { diff --git a/UnitsNet/CustomCode/UnitParser.cs b/UnitsNet/CustomCode/UnitParser.cs index 7677eae796..4a5ddffe9d 100644 --- a/UnitsNet/CustomCode/UnitParser.cs +++ b/UnitsNet/CustomCode/UnitParser.cs @@ -69,7 +69,7 @@ public Enum Parse(string unitAbbreviation, Type unitType, IFormatProvider? forma if (unitAbbreviation == null) throw new ArgumentNullException(nameof(unitAbbreviation)); unitAbbreviation = unitAbbreviation.Trim(); - if(!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations)) + if (!_unitAbbreviationsCache.TryGetUnitValueAbbreviationLookup(unitType, formatProvider, out var abbreviations)) throw new UnitNotFoundException($"No abbreviations defined for unit type [{unitType}] for culture [{formatProvider}]."); var unitIntValues = abbreviations!.GetUnitsForAbbreviation(unitAbbreviation, ignoreCase: true); @@ -89,6 +89,12 @@ public Enum Parse(string unitAbbreviation, Type unitType, IFormatProvider? forma case 1: return (Enum) Enum.ToObject(unitType, unitIntValues[0]); case 0: + // Retry with fallback culture, if different. + if (!Equals(formatProvider, UnitAbbreviationsCache.FallbackCulture)) + { + return Parse(unitAbbreviation, unitType, UnitAbbreviationsCache.FallbackCulture); + } + throw new UnitNotFoundException($"Unit not found with abbreviation [{unitAbbreviation}] for unit type [{unitType}]."); default: string unitsCsv = string.Join(", ", unitIntValues.Select(x => Enum.GetName(unitType, x)).ToArray()); diff --git a/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs b/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs index 96d21a32a0..1eeaadf2d6 100644 --- a/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs +++ b/UnitsNet/CustomCode/UnitValueAbbreviationLookup.cs @@ -28,7 +28,7 @@ internal List GetAbbreviationsForUnit(TUnitType unit) where T internal List GetAbbreviationsForUnit(int unit) { - if(!_unitToAbbreviationMap.TryGetValue(unit, out var abbreviations)) + if (!_unitToAbbreviationMap.TryGetValue(unit, out var abbreviations)) _unitToAbbreviationMap[unit] = abbreviations = new List(); return abbreviations.Distinct().ToList(); @@ -40,7 +40,7 @@ internal List GetUnitsForAbbreviation(string abbreviation, bool ignoreCase) var key = ignoreCase ? lowerCaseAbbreviation : abbreviation; var map = ignoreCase ? _lowerCaseAbbreviationToUnitMap : _abbreviationToUnitMap; - if(!map.TryGetValue(key, out List units)) + if (!map.TryGetValue(key, out List units)) map[key] = units = new List(); return units.Distinct().ToList(); @@ -50,13 +50,13 @@ internal void Add(int unit, string abbreviation, bool setAsDefault = false) { var lowerCaseAbbreviation = abbreviation.ToLower(); - if(!_unitToAbbreviationMap.TryGetValue(unit, out var abbreviationsForUnit)) + if (!_unitToAbbreviationMap.TryGetValue(unit, out var abbreviationsForUnit)) abbreviationsForUnit = _unitToAbbreviationMap[unit] = new List(); - if(!_abbreviationToUnitMap.TryGetValue(abbreviation, out var unitsForAbbreviation)) + if (!_abbreviationToUnitMap.TryGetValue(abbreviation, out var unitsForAbbreviation)) _abbreviationToUnitMap[abbreviation] = unitsForAbbreviation = new List(); - if(!_lowerCaseAbbreviationToUnitMap.TryGetValue(lowerCaseAbbreviation, out var unitsForLowerCaseAbbreviation)) + if (!_lowerCaseAbbreviationToUnitMap.TryGetValue(lowerCaseAbbreviation, out var unitsForLowerCaseAbbreviation)) _lowerCaseAbbreviationToUnitMap[lowerCaseAbbreviation] = unitsForLowerCaseAbbreviation = new List(); unitsForLowerCaseAbbreviation.Remove(unit); diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index 154d5660bc..d19b3116ec 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -109,7 +109,7 @@ public static string Format(IQuantity quantity, string for public static string Format(IQuantity quantity, string format, IFormatProvider? formatProvider) where TUnitType : Enum { - formatProvider = formatProvider ?? CultureInfo.CurrentCulture; + formatProvider ??= CultureInfo.CurrentCulture; return FormatUntrimmed(quantity, format, formatProvider).TrimEnd(); } From 55a2904b430fdc80ad4ade13d500f9240616fe14 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 16 Nov 2021 22:18:19 +0100 Subject: [PATCH 45/66] Fix test cases after removing Undefinde --- .../DefaultDataContractJsonSerializerTests.cs | 74 ++++++++++++------- 1 file changed, 46 insertions(+), 28 deletions(-) diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index fcec387af0..adc83d8e16 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -40,10 +40,11 @@ protected override T DeserializeObject(string xml) } [Fact] - public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit() + public void DoubleQuantity_SerializedWithDoubleValueAndunitInt() { var quantity = new Mass(1.20, MassUnit.Milligram); - var expectedJson = "{\"Value\":1.2,\"Unit\":16}"; + var unitInt = (int)quantity.Unit; + var expectedJson = $"{{\"Value\":1.2,\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); @@ -51,10 +52,11 @@ public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit() } [Fact] - public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit() + public void DecimalQuantity_SerializedWithDecimalValueValueAndunitInt() { var quantity = new Information(1.20m, InformationUnit.Exabyte); - var expectedJson = "{\"Value\":1.20,\"Unit\":4}"; + var unitInt = (int)InformationUnit.Exabyte; + var expectedJson = $"{{\"Value\":1.20,\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); @@ -62,10 +64,11 @@ public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit() } [Fact] - public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndIntegerUnit() + public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndunitInt() { var quantity = new Mass(1E+9, MassUnit.Milligram); - var expectedJson = "{\"Value\":1000000000,\"Unit\":16}"; + var unitInt = (int)quantity.Unit; + var expectedJson = $"{{\"Value\":1000000000,\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); @@ -73,10 +76,11 @@ public void DoubleQuantity_InScientificNotation_SerializedWithExpandedValueAndIn } [Fact] - public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndIntegerUnit() + public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndunitInt() { var quantity = new Information(1E+9m, InformationUnit.Exabyte); - var expectedJson = "{\"Value\":1000000000,\"Unit\":4}"; + var unitInt = (int)quantity.Unit; + var expectedJson = $"{{\"Value\":1000000000,\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); @@ -84,36 +88,42 @@ public void DecimalQuantity_InScientificNotation_SerializedWithExpandedValueAndI } [Fact] - public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit() + public void DoubleQuantity_DeserializedFromDoubleValueAndunitInt() { - var json = "{\"Value\":1.2,\"Unit\":16}"; + var expectedUnit = MassUnit.Milligram; + var unitInt = (int)expectedUnit; + var json = $"{{\"Value\":1.2,\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); Assert.Equal(1.2, quantity.Value); - Assert.Equal(MassUnit.Milligram, quantity.Unit); + Assert.Equal(expectedUnit, quantity.Unit); } [Fact] - public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() + public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndunitInt() { - var json = "{\"Value\":\"1.2\",\"Unit\":16}"; + var expectedUnit = MassUnit.Milligram; + var unitInt = (int)expectedUnit; + var json = $"{{\"Value\":\"1.2\",\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); Assert.Equal(1.2, quantity.Value); - Assert.Equal(MassUnit.Milligram, quantity.Unit); + Assert.Equal(expectedUnit, quantity.Unit); } [Fact] - public void DoubleZeroQuantity_DeserializedFromIntegerUnitAndNoValue() + public void DoubleZeroQuantity_DeserializedFromunitIntAndNoValue() { - var json = "{\"Unit\":16}"; + var expectedUnit = MassUnit.Milligram; + var unitInt = (int)expectedUnit; + var json = $"{{\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); Assert.Equal(0, quantity.Value); - Assert.Equal(MassUnit.Milligram, quantity.Unit); + Assert.Equal(expectedUnit, quantity.Unit); } [Fact] @@ -139,38 +149,44 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() } [Fact] - public void DecimalQuantity_DeserializedFromDecimalValueAndIntegerUnit() + public void DecimalQuantity_DeserializedFromDecimalValueAndunitInt() { - var json = "{\"Value\":1.200,\"Unit\":4}"; + var expectedUnit = InformationUnit.Exabyte; + var unitInt = (int)expectedUnit; + var json = $"{{\"Value\":1.200,\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); Assert.Equal(1.200m, quantity.Value); Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); - Assert.Equal(InformationUnit.Exabyte, quantity.Unit); + Assert.Equal(expectedUnit, quantity.Unit); } [Fact] - public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndIntegerUnit() + public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndunitInt() { - var json = "{\"Value\":\"1.200\",\"Unit\":4}"; + var expectedUnit = InformationUnit.Exabyte; + var unitInt = (int)expectedUnit; + var json = $"{{\"Value\":\"1.200\",\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); Assert.Equal(1.200m, quantity.Value); Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); - Assert.Equal(InformationUnit.Exabyte, quantity.Unit); + Assert.Equal(expectedUnit, quantity.Unit); } [Fact] - public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue() + public void DecimalZeroQuantity_DeserializedFromunitIntAndNoValue() { - var json = "{\"Unit\":4}"; + var expectedUnit = InformationUnit.Exabyte; + var unitInt = (int)expectedUnit; + var json = $"{{\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); Assert.Equal(0, quantity.Value); - Assert.Equal(InformationUnit.Exabyte, quantity.Unit); + Assert.Equal(expectedUnit, quantity.Unit); } [Fact] @@ -199,8 +215,10 @@ public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput() [Fact] public void InterfaceObject_IncludesTypeInformation() { - var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) }; - var expectedJson = "{\"Quantity\":{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":4}}"; + var unit = InformationUnit.Exabyte; + var unitInt = (int)unit; + var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, unit) }; + var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":{unitInt}}}}}"; var json = SerializeObject(testObject); From 47cdd1f1c594a18381fa2203aaa38d1b23b93b57 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 16 Nov 2021 23:25:47 +0100 Subject: [PATCH 46/66] README: Update with v5 info Remove net4 target Add link to upgrade wiki page Add link to serialization wiki page (newly added with the new json/xml data contract serializers) Some cleanup here and there. --- README.md | 63 +++++++++++++++++-------------------------------------- 1 file changed, 19 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 84c2cadf90..45440273f5 100644 --- a/README.md +++ b/README.md @@ -7,38 +7,39 @@ Add strongly typed quantities to your code and get merrily on with your life. No more magic constants found on Stack Overflow, no more second-guessing the unit of parameters and variables. +[Upgrading from 4.x to 5.x](https://github.com/angularsen/UnitsNet/wiki/Upgrading-from-4.x-to-5.x) + ### Overview * [How to install](#how-to-install) -* [100+ quantities with 1200+ units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [C# CLI app](CodeGen) +* [100+ quantities with 1300+ units](UnitsNet/GeneratedCode/Units) generated from [JSON](Common/UnitDefinitions/) by [C# CLI app](CodeGen) * [8000+ unit tests](https://ci.appveyor.com/project/angularsen/unitsnet) on conversions and localizations -* Conforms to [Microsoft's open-source library guidance](https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/), in particular: - * [SourceLink](https://github.com/dotnet/sourcelink) to step into source code of NuGet package while debugging - * [Strong naming](https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/get-started#strong-naming) to make the library available to all developers -* Immutable structs that implement `IEquatable`, `IComparable` * [Statically typed quantities and units](#static-typing) to avoid mistakes and communicate intent -* [Operator overloads](#operator-overloads) for arithmetic on quantities -* [Parse and ToString()](#culture) supports cultures and localization +* Immutable structs +* [Operator overloads](#operator-overloads) for arithmetic +* [Parse and ToString()](#culture) supports localization * [Dynamically parse and convert](#dynamic-parsing) quantities and units * [Extensible with custom units](#custom-units) * [Example: Creating a unit converter app](#example-app) * [Example: WPF app using IValueConverter to parse quantities from input](#example-wpf-app-using-ivalueconverter-to-parse-quantities-from-input) * [Precision and accuracy](#precision) -* [Serialize with JSON.NET](#serialization) +* [Serialize to JSON, XML and more](#serialization) * [Contribute](#contribute) if you are missing some units * [Continuous integration](#ci) posts status reports to pull requests and commits * [Who are using this?](#who-are-using) -### How to install +### Installing via NuGet + +Add it via CLI -Run the following command in the [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console) or go to the [NuGet site](https://www.nuget.org/packages/UnitsNet/) for the complete release history. + dotnet add package UnitsNet + +or go to [NuGet Gallery | UnitsNet](https://www.nuget.org/packages/UnitsNet) for detailed instructions. -![Install-Package UnitsNet](https://raw.githubusercontent.com/angularsen/UnitsNet/master/Docs/Images/install_package_unitsnet.png "Install-Package UnitsNet") #### Build Targets * .NET Standard 2.0 -* .NET 4.0 * [.NET nanoFramework](https://www.nanoframework.net/) ### Static Typing @@ -250,7 +251,7 @@ Console.WriteLine(Convert(HowMuchUnit.Lots)); // 100 lts Console.WriteLine(Convert(HowMuchUnit.Tons)); // 10 tns ``` -### Example: Creating a dynamic unit converter app +### Example: Unit converter app [Source code](https://github.com/angularsen/UnitsNet/tree/master/Samples/UnitConverter.Wpf) for `Samples/UnitConverter.Wpf`
[Download](https://github.com/angularsen/UnitsNet/releases/tag/UnitConverterWpf%2F2018-11-09) (release 2018-11-09 for Windows) @@ -307,40 +308,14 @@ The tests accept an error up to 1E-5 for most units added so far. Exceptions inc For more details, see [Precision](https://github.com/angularsen/UnitsNet/wiki/Precision). -### Serialization - -* `UnitsNet.Serialization.JsonNet` ([nuget](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet), [src](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet), [tests](https://github.com/angularsen/UnitsNet/tree/master/UnitsNet.Serialization.JsonNet.Tests)) for JSON.NET +### Serialize to JSON, XML and more -#### Example of JSON Serialization -```c# -var jsonSerializerSettings = new JsonSerializerSettings {Formatting = Formatting.Indented}; -jsonSerializerSettings.Converters.Add(new UnitsNetIQuantityJsonConverter()); - -string json = JsonConvert.SerializeObject(new { Name = "Raiden", Weight = Mass.FromKilograms(90) }, jsonSerializerSettings); - -object obj = JsonConvert.DeserializeObject(json); -``` - -JSON output: -```json -{ - "Name": "Raiden", - "Weight": { - "Unit": "MassUnit.Kilogram", - "Value": 90.0 - } -} -``` - -If you need to support deserializing into properties/fields of type `IComparable` instead of type `IQuantity`, then you can add -```c# -jsonSerializerSettings.Converters.Add(new UnitsNetIComparableJsonConverter()); -``` +* [UnitsNet.Serialization.JsonNet](https://www.nuget.org/packages/UnitsNet.Serialization.JsonNet) with Json.NET (Newtonsoft) +* [DataContractSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.datacontractserializer) XML +* [DataContractJsonSerializer](https://docs.microsoft.com/en-us/dotnet/api/system.runtime.serialization.json.datacontractjsonserializer) JSON (not recommended*) -**Important!** -We cannot guarantee backwards compatibility, although we will strive to do that on a "best effort" basis and bumping the major nuget version when a change is necessary. +Read more at [Serializing to JSON, XML and more](https://github.com/angularsen/UnitsNet/wiki/Serializing-to-JSON,-XML-and-more). -The base unit of any unit should be treated as volatile as we have changed this several times in the history of this library already. Either to reduce precision errors of common units or to simplify code generation. An example is Mass, where the base unit was first Kilogram as this is the SI unit of mass, but in order to use powershell scripts to generate milligrams, nanograms etc. it was easier to choose Gram as the base unit of Mass. ### Want To Contribute? From 0ddfd57b6134f5a9cfb4e43ad684a31ca94b3d2e Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 8 Feb 2022 22:40:51 +0100 Subject: [PATCH 47/66] Rename ConversionBaseUnit back to BaseUnit Should instead rename BaseUnits to SiBaseUnits to distinguish them. --- .../NanoFrameworkGen/QuantityGenerator.cs | 12 +- .../UnitsNetGen/QuantityGenerator.cs | 14 +- .../UnitsNetGen/StaticQuantityGenerator.cs | 2 +- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 10 +- CodeGen/JsonTypes/Quantity.cs | 2 +- Common/UnitDefinitions/Acceleration.json | 2 +- Common/UnitDefinitions/AmountOfSubstance.json | 2 +- Common/UnitDefinitions/AmplitudeRatio.json | 2 +- Common/UnitDefinitions/Angle.json | 2 +- Common/UnitDefinitions/ApparentEnergy.json | 2 +- Common/UnitDefinitions/ApparentPower.json | 2 +- Common/UnitDefinitions/Area.json | 2 +- Common/UnitDefinitions/AreaDensity.json | 2 +- .../UnitDefinitions/AreaMomentOfInertia.json | 2 +- Common/UnitDefinitions/BitRate.json | 2 +- .../BrakeSpecificFuelConsumption.json | 2 +- Common/UnitDefinitions/Capacitance.json | 2 +- .../CoefficientOfThermalExpansion.json | 2 +- Common/UnitDefinitions/Density.json | 2 +- Common/UnitDefinitions/Duration.json | 2 +- Common/UnitDefinitions/DynamicViscosity.json | 2 +- .../UnitDefinitions/ElectricAdmittance.json | 2 +- Common/UnitDefinitions/ElectricCharge.json | 2 +- .../ElectricChargeDensity.json | 2 +- .../UnitDefinitions/ElectricConductance.json | 2 +- .../UnitDefinitions/ElectricConductivity.json | 2 +- Common/UnitDefinitions/ElectricCurrent.json | 2 +- .../ElectricCurrentDensity.json | 2 +- .../ElectricCurrentGradient.json | 2 +- Common/UnitDefinitions/ElectricField.json | 2 +- .../UnitDefinitions/ElectricInductance.json | 2 +- Common/UnitDefinitions/ElectricPotential.json | 2 +- .../UnitDefinitions/ElectricPotentialAc.json | 2 +- .../ElectricPotentialChangeRate.json | 2 +- .../UnitDefinitions/ElectricPotentialDc.json | 2 +- .../UnitDefinitions/ElectricResistance.json | 2 +- .../UnitDefinitions/ElectricResistivity.json | 2 +- .../ElectricSurfaceChargeDensity.json | 2 +- Common/UnitDefinitions/Energy.json | 2 +- Common/UnitDefinitions/Entropy.json | 2 +- Common/UnitDefinitions/Force.json | 2 +- Common/UnitDefinitions/ForceChangeRate.json | 2 +- Common/UnitDefinitions/ForcePerLength.json | 2 +- Common/UnitDefinitions/Frequency.json | 2 +- Common/UnitDefinitions/FuelEfficiency.json | 2 +- Common/UnitDefinitions/HeatFlux.json | 2 +- .../HeatTransferCoefficient.json | 2 +- Common/UnitDefinitions/Illuminance.json | 2 +- Common/UnitDefinitions/Information.json | 2 +- Common/UnitDefinitions/Irradiance.json | 2 +- Common/UnitDefinitions/Irradiation.json | 2 +- .../UnitDefinitions/KinematicViscosity.json | 2 +- Common/UnitDefinitions/LapseRate.json | 2 +- Common/UnitDefinitions/Length.json | 2 +- Common/UnitDefinitions/Level.json | 2 +- Common/UnitDefinitions/LinearDensity.json | 2 +- .../UnitDefinitions/LinearPowerDensity.json | 2 +- Common/UnitDefinitions/Luminosity.json | 2 +- Common/UnitDefinitions/LuminousFlux.json | 2 +- Common/UnitDefinitions/LuminousIntensity.json | 2 +- Common/UnitDefinitions/MagneticField.json | 2 +- Common/UnitDefinitions/MagneticFlux.json | 2 +- Common/UnitDefinitions/Magnetization.json | 2 +- Common/UnitDefinitions/Mass.json | 2 +- Common/UnitDefinitions/MassConcentration.json | 2 +- Common/UnitDefinitions/MassFlow.json | 2 +- Common/UnitDefinitions/MassFlux.json | 2 +- Common/UnitDefinitions/MassFraction.json | 2 +- .../UnitDefinitions/MassMomentOfInertia.json | 2 +- Common/UnitDefinitions/MolarEnergy.json | 2 +- Common/UnitDefinitions/MolarEntropy.json | 2 +- Common/UnitDefinitions/MolarMass.json | 2 +- Common/UnitDefinitions/Molarity.json | 2 +- Common/UnitDefinitions/Permeability.json | 2 +- Common/UnitDefinitions/Permittivity.json | 2 +- Common/UnitDefinitions/Power.json | 2 +- Common/UnitDefinitions/PowerDensity.json | 2 +- Common/UnitDefinitions/PowerRatio.json | 2 +- Common/UnitDefinitions/Pressure.json | 2 +- .../UnitDefinitions/PressureChangeRate.json | 2 +- Common/UnitDefinitions/Ratio.json | 2 +- Common/UnitDefinitions/RatioChangeRate.json | 2 +- Common/UnitDefinitions/ReactiveEnergy.json | 2 +- Common/UnitDefinitions/ReactivePower.json | 2 +- Common/UnitDefinitions/ReciprocalArea.json | 2 +- Common/UnitDefinitions/ReciprocalLength.json | 2 +- Common/UnitDefinitions/RelativeHumidity.json | 2 +- .../RotationalAcceleration.json | 2 +- Common/UnitDefinitions/RotationalSpeed.json | 2 +- .../UnitDefinitions/RotationalStiffness.json | 2 +- .../RotationalStiffnessPerLength.json | 2 +- Common/UnitDefinitions/Scalar.json | 2 +- Common/UnitDefinitions/SolidAngle.json | 2 +- Common/UnitDefinitions/SpecificEnergy.json | 2 +- Common/UnitDefinitions/SpecificEntropy.json | 2 +- .../SpecificFuelConsumption.json | 2 +- Common/UnitDefinitions/SpecificVolume.json | 2 +- Common/UnitDefinitions/SpecificWeight.json | 2 +- Common/UnitDefinitions/Speed.json | 2 +- .../UnitDefinitions/StandardVolumeFlow.json | 2 +- Common/UnitDefinitions/Temperature.json | 2 +- .../TemperatureChangeRate.json | 2 +- Common/UnitDefinitions/TemperatureDelta.json | 2 +- .../UnitDefinitions/ThermalConductivity.json | 2 +- Common/UnitDefinitions/ThermalResistance.json | 2 +- Common/UnitDefinitions/Torque.json | 2 +- Common/UnitDefinitions/TorquePerLength.json | 2 +- Common/UnitDefinitions/Turbidity.json | 2 +- Common/UnitDefinitions/VitaminA.json | 2 +- Common/UnitDefinitions/Volume.json | 2 +- .../UnitDefinitions/VolumeConcentration.json | 2 +- Common/UnitDefinitions/VolumeFlow.json | 2 +- Common/UnitDefinitions/VolumePerLength.json | 2 +- .../VolumetricHeatCapacity.json | 2 +- .../WarpingMomentOfInertia.json | 2 +- ...nitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- ...t.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../UnitsNet.NanoFramework.BitRate.nuspec | 2 +- ...mework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- ...ework.CoefficientOfThermalExpansion.nuspec | 2 +- .../UnitsNet.NanoFramework.Density.nuspec | 2 +- .../UnitsNet.NanoFramework.Duration.nuspec | 2 +- ...sNet.NanoFramework.DynamicViscosity.nuspec | 2 +- ...et.NanoFramework.ElectricAdmittance.nuspec | 2 +- ...itsNet.NanoFramework.ElectricCharge.nuspec | 2 +- ...NanoFramework.ElectricChargeDensity.nuspec | 2 +- ...t.NanoFramework.ElectricConductance.nuspec | 2 +- ....NanoFramework.ElectricConductivity.nuspec | 2 +- ...tsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- ...anoFramework.ElectricCurrentDensity.nuspec | 2 +- ...noFramework.ElectricCurrentGradient.nuspec | 2 +- ...nitsNet.NanoFramework.ElectricField.nuspec | 2 +- ...et.NanoFramework.ElectricInductance.nuspec | 2 +- ...Net.NanoFramework.ElectricPotential.nuspec | 2 +- ...t.NanoFramework.ElectricPotentialAc.nuspec | 2 +- ...amework.ElectricPotentialChangeRate.nuspec | 2 +- ...t.NanoFramework.ElectricPotentialDc.nuspec | 2 +- ...et.NanoFramework.ElectricResistance.nuspec | 2 +- ...t.NanoFramework.ElectricResistivity.nuspec | 2 +- ...mework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- ...tsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- ...itsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.Frequency.nuspec | 4 +- ...itsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- ...noFramework.HeatTransferCoefficient.nuspec | 2 +- .../UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../UnitsNet.NanoFramework.Information.nuspec | 2 +- .../UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- ...et.NanoFramework.KinematicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../UnitsNet.NanoFramework.Length.nuspec | 2 +- .../Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- ...nitsNet.NanoFramework.LinearDensity.nuspec | 2 +- ...et.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- ...UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- ...Net.NanoFramework.LuminousIntensity.nuspec | 2 +- ...nitsNet.NanoFramework.MagneticField.nuspec | 2 +- ...UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- ...nitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- ...Net.NanoFramework.MassConcentration.nuspec | 2 +- .../UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- ...UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- ...t.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- ...UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../UnitsNet.NanoFramework.Molarity.nuspec | 2 +- ...UnitsNet.NanoFramework.Permeability.nuspec | 2 +- ...UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- ...UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../UnitsNet.NanoFramework.Pressure.nuspec | 4 +- ...et.NanoFramework.PressureChangeRate.nuspec | 2 +- .../Quantities/Acceleration.g.cs | 8 +- .../Quantities/AmountOfSubstance.g.cs | 8 +- .../Quantities/AmplitudeRatio.g.cs | 8 +- .../GeneratedCode/Quantities/Angle.g.cs | 8 +- .../Quantities/ApparentEnergy.g.cs | 8 +- .../Quantities/ApparentPower.g.cs | 8 +- .../GeneratedCode/Quantities/Area.g.cs | 8 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 8 +- .../Quantities/AreaMomentOfInertia.g.cs | 8 +- .../GeneratedCode/Quantities/BitRate.g.cs | 8 +- .../BrakeSpecificFuelConsumption.g.cs | 8 +- .../GeneratedCode/Quantities/Capacitance.g.cs | 8 +- .../CoefficientOfThermalExpansion.g.cs | 8 +- .../GeneratedCode/Quantities/Density.g.cs | 8 +- .../GeneratedCode/Quantities/Duration.g.cs | 8 +- .../Quantities/DynamicViscosity.g.cs | 8 +- .../Quantities/ElectricAdmittance.g.cs | 8 +- .../Quantities/ElectricCharge.g.cs | 8 +- .../Quantities/ElectricChargeDensity.g.cs | 8 +- .../Quantities/ElectricConductance.g.cs | 8 +- .../Quantities/ElectricConductivity.g.cs | 8 +- .../Quantities/ElectricCurrent.g.cs | 8 +- .../Quantities/ElectricCurrentDensity.g.cs | 8 +- .../Quantities/ElectricCurrentGradient.g.cs | 8 +- .../Quantities/ElectricField.g.cs | 8 +- .../Quantities/ElectricInductance.g.cs | 8 +- .../Quantities/ElectricPotential.g.cs | 8 +- .../Quantities/ElectricPotentialAc.g.cs | 8 +- .../ElectricPotentialChangeRate.g.cs | 8 +- .../Quantities/ElectricPotentialDc.g.cs | 8 +- .../Quantities/ElectricResistance.g.cs | 8 +- .../Quantities/ElectricResistivity.g.cs | 8 +- .../ElectricSurfaceChargeDensity.g.cs | 8 +- .../GeneratedCode/Quantities/Energy.g.cs | 8 +- .../GeneratedCode/Quantities/Entropy.g.cs | 8 +- .../GeneratedCode/Quantities/Force.g.cs | 8 +- .../Quantities/ForceChangeRate.g.cs | 8 +- .../Quantities/ForcePerLength.g.cs | 8 +- .../GeneratedCode/Quantities/Frequency.g.cs | 8 +- .../Quantities/FuelEfficiency.g.cs | 8 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 8 +- .../Quantities/HeatTransferCoefficient.g.cs | 8 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 8 +- .../GeneratedCode/Quantities/Information.g.cs | 8 +- .../GeneratedCode/Quantities/Irradiance.g.cs | 8 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 8 +- .../Quantities/KinematicViscosity.g.cs | 8 +- .../GeneratedCode/Quantities/LapseRate.g.cs | 8 +- .../GeneratedCode/Quantities/Length.g.cs | 8 +- .../GeneratedCode/Quantities/Level.g.cs | 8 +- .../Quantities/LinearDensity.g.cs | 8 +- .../Quantities/LinearPowerDensity.g.cs | 8 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 8 +- .../Quantities/LuminousFlux.g.cs | 8 +- .../Quantities/LuminousIntensity.g.cs | 8 +- .../Quantities/MagneticField.g.cs | 8 +- .../Quantities/MagneticFlux.g.cs | 8 +- .../Quantities/Magnetization.g.cs | 8 +- .../GeneratedCode/Quantities/Mass.g.cs | 8 +- .../Quantities/MassConcentration.g.cs | 8 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 8 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 8 +- .../Quantities/MassFraction.g.cs | 8 +- .../Quantities/MassMomentOfInertia.g.cs | 8 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 8 +- .../Quantities/MolarEntropy.g.cs | 8 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 8 +- .../GeneratedCode/Quantities/Molarity.g.cs | 8 +- .../Quantities/Permeability.g.cs | 8 +- .../Quantities/Permittivity.g.cs | 8 +- .../GeneratedCode/Quantities/Power.g.cs | 8 +- .../Quantities/PowerDensity.g.cs | 8 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 8 +- .../GeneratedCode/Quantities/Pressure.g.cs | 8 +- .../Quantities/PressureChangeRate.g.cs | 8 +- .../GeneratedCode/Quantities/Ratio.g.cs | 8 +- .../Quantities/RatioChangeRate.g.cs | 8 +- .../Quantities/ReactiveEnergy.g.cs | 8 +- .../Quantities/ReactivePower.g.cs | 8 +- .../Quantities/ReciprocalArea.g.cs | 8 +- .../Quantities/ReciprocalLength.g.cs | 8 +- .../Quantities/RelativeHumidity.g.cs | 8 +- .../Quantities/RotationalAcceleration.g.cs | 8 +- .../Quantities/RotationalSpeed.g.cs | 8 +- .../Quantities/RotationalStiffness.g.cs | 8 +- .../RotationalStiffnessPerLength.g.cs | 8 +- .../GeneratedCode/Quantities/Scalar.g.cs | 8 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 8 +- .../Quantities/SpecificEnergy.g.cs | 8 +- .../Quantities/SpecificEntropy.g.cs | 8 +- .../Quantities/SpecificFuelConsumption.g.cs | 8 +- .../Quantities/SpecificVolume.g.cs | 8 +- .../Quantities/SpecificWeight.g.cs | 8 +- .../GeneratedCode/Quantities/Speed.g.cs | 8 +- .../Quantities/StandardVolumeFlow.g.cs | 8 +- .../GeneratedCode/Quantities/Temperature.g.cs | 8 +- .../Quantities/TemperatureChangeRate.g.cs | 8 +- .../Quantities/TemperatureDelta.g.cs | 8 +- .../Quantities/TemperatureGradient.g.cs | 6 +- .../Quantities/ThermalConductivity.g.cs | 8 +- .../Quantities/ThermalResistance.g.cs | 8 +- .../GeneratedCode/Quantities/Torque.g.cs | 8 +- .../Quantities/TorquePerLength.g.cs | 8 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 8 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 8 +- .../GeneratedCode/Quantities/Volume.g.cs | 8 +- .../Quantities/VolumeConcentration.g.cs | 8 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 8 +- .../Quantities/VolumeFlowPerArea.g.cs | 6 +- .../Quantities/VolumePerLength.g.cs | 8 +- .../Quantities/VolumetricHeatCapacity.g.cs | 8 +- .../Quantities/WarpingMomentOfInertia.g.cs | 8 +- .../Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- ...tsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- ...itsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- ...nitsNet.NanoFramework.ReactivePower.nuspec | 2 +- ...itsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- ...sNet.NanoFramework.ReciprocalLength.nuspec | 2 +- ...sNet.NanoFramework.RelativeHumidity.nuspec | 2 +- ...anoFramework.RotationalAcceleration.nuspec | 2 +- ...tsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- ...t.NanoFramework.RotationalStiffness.nuspec | 2 +- ...mework.RotationalStiffnessPerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- ...itsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- ...tsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- ...noFramework.SpecificFuelConsumption.nuspec | 2 +- ...itsNet.NanoFramework.SpecificVolume.nuspec | 2 +- ...itsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- ...et.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.Temperature.nuspec | 2 +- ...NanoFramework.TemperatureChangeRate.nuspec | 2 +- ...sNet.NanoFramework.TemperatureDelta.nuspec | 2 +- ...t.NanoFramework.TemperatureGradient.nuspec | 4 +- ...t.NanoFramework.ThermalConductivity.nuspec | 2 +- ...Net.NanoFramework.ThermalResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.Torque.nuspec | 2 +- ...tsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.Turbidity.nuspec | 4 +- .../Units/TemperatureGradientUnit.g.cs | 1 - .../GeneratedCode/Units/TorqueUnit.g.cs | 3 + .../Units/VolumeFlowPerAreaUnit.g.cs | 1 - .../UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../UnitsNet.NanoFramework.Volume.nuspec | 2 +- ...t.NanoFramework.VolumeConcentration.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- ...Net.NanoFramework.VolumeFlowPerArea.nuspec | 4 +- ...tsNet.NanoFramework.VolumePerLength.nuspec | 2 +- ...anoFramework.VolumetricHeatCapacity.nuspec | 2 +- ...anoFramework.WarpingMomentOfInertia.nuspec | 4 +- .../AbbreviatedUnitsConverter.cs | 4 +- .../CustomCode/MassConcentrationTests.cs | 4 +- .../GeneratedCode/IQuantityTests.g.cs | 119 --------- .../TestsBase/AccelerationTestsBase.g.cs | 112 ++------ .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 112 ++------ .../TestsBase/AmplitudeRatioTestsBase.g.cs | 112 ++------ .../TestsBase/AngleTestsBase.g.cs | 112 ++------ .../TestsBase/ApparentEnergyTestsBase.g.cs | 112 ++------ .../TestsBase/ApparentPowerTestsBase.g.cs | 112 ++------ .../TestsBase/AreaDensityTestsBase.g.cs | 112 ++------ .../AreaMomentOfInertiaTestsBase.g.cs | 112 ++------ .../TestsBase/AreaTestsBase.g.cs | 112 ++------ .../TestsBase/BitRateTestsBase.g.cs | 112 ++------ ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 112 ++------ .../TestsBase/CapacitanceTestsBase.g.cs | 112 ++------ ...oefficientOfThermalExpansionTestsBase.g.cs | 112 ++------ .../TestsBase/DensityTestsBase.g.cs | 112 ++------ .../TestsBase/DurationTestsBase.g.cs | 112 ++------ .../TestsBase/DynamicViscosityTestsBase.g.cs | 112 ++------ .../ElectricAdmittanceTestsBase.g.cs | 112 ++------ .../ElectricChargeDensityTestsBase.g.cs | 112 ++------ .../TestsBase/ElectricChargeTestsBase.g.cs | 112 ++------ .../ElectricConductanceTestsBase.g.cs | 112 ++------ .../ElectricConductivityTestsBase.g.cs | 112 ++------ .../ElectricCurrentDensityTestsBase.g.cs | 112 ++------ .../ElectricCurrentGradientTestsBase.g.cs | 112 ++------ .../TestsBase/ElectricCurrentTestsBase.g.cs | 112 ++------ .../TestsBase/ElectricFieldTestsBase.g.cs | 112 ++------ .../ElectricInductanceTestsBase.g.cs | 112 ++------ .../ElectricPotentialAcTestsBase.g.cs | 112 ++------ .../ElectricPotentialChangeRateTestsBase.g.cs | 112 ++------ .../ElectricPotentialDcTestsBase.g.cs | 112 ++------ .../TestsBase/ElectricPotentialTestsBase.g.cs | 112 ++------ .../ElectricResistanceTestsBase.g.cs | 112 ++------ .../ElectricResistivityTestsBase.g.cs | 112 ++------ ...ElectricSurfaceChargeDensityTestsBase.g.cs | 112 ++------ .../TestsBase/EnergyTestsBase.g.cs | 112 ++------ .../TestsBase/EntropyTestsBase.g.cs | 112 ++------ .../TestsBase/ForceChangeRateTestsBase.g.cs | 112 ++------ .../TestsBase/ForcePerLengthTestsBase.g.cs | 112 ++------ .../TestsBase/ForceTestsBase.g.cs | 112 ++------ .../TestsBase/FrequencyTestsBase.g.cs | 112 ++------ .../TestsBase/FuelEfficiencyTestsBase.g.cs | 112 ++------ .../TestsBase/HeatFluxTestsBase.g.cs | 112 ++------ .../HeatTransferCoefficientTestsBase.g.cs | 112 ++------ .../TestsBase/IlluminanceTestsBase.g.cs | 112 ++------ .../TestsBase/InformationTestsBase.g.cs | 112 ++------ .../TestsBase/IrradianceTestsBase.g.cs | 112 ++------ .../TestsBase/IrradiationTestsBase.g.cs | 112 ++------ .../KinematicViscosityTestsBase.g.cs | 112 ++------ .../TestsBase/LapseRateTestsBase.g.cs | 112 ++------ .../TestsBase/LengthTestsBase.g.cs | 112 ++------ .../TestsBase/LevelTestsBase.g.cs | 112 ++------ .../TestsBase/LinearDensityTestsBase.g.cs | 112 ++------ .../LinearPowerDensityTestsBase.g.cs | 112 ++------ .../TestsBase/LuminosityTestsBase.g.cs | 112 ++------ .../TestsBase/LuminousFluxTestsBase.g.cs | 112 ++------ .../TestsBase/LuminousIntensityTestsBase.g.cs | 112 ++------ .../TestsBase/MagneticFieldTestsBase.g.cs | 112 ++------ .../TestsBase/MagneticFluxTestsBase.g.cs | 112 ++------ .../TestsBase/MagnetizationTestsBase.g.cs | 112 ++------ .../TestsBase/MassConcentrationTestsBase.g.cs | 112 ++------ .../TestsBase/MassFlowTestsBase.g.cs | 112 ++------ .../TestsBase/MassFluxTestsBase.g.cs | 112 ++------ .../TestsBase/MassFractionTestsBase.g.cs | 112 ++------ .../MassMomentOfInertiaTestsBase.g.cs | 112 ++------ .../TestsBase/MassTestsBase.g.cs | 112 ++------ .../TestsBase/MolarEnergyTestsBase.g.cs | 112 ++------ .../TestsBase/MolarEntropyTestsBase.g.cs | 112 ++------ .../TestsBase/MolarMassTestsBase.g.cs | 112 ++------ .../TestsBase/MolarityTestsBase.g.cs | 112 ++------ .../TestsBase/PermeabilityTestsBase.g.cs | 112 ++------ .../TestsBase/PermittivityTestsBase.g.cs | 112 ++------ .../TestsBase/PowerDensityTestsBase.g.cs | 112 ++------ .../TestsBase/PowerRatioTestsBase.g.cs | 112 ++------ .../TestsBase/PowerTestsBase.g.cs | 112 ++------ .../PressureChangeRateTestsBase.g.cs | 112 ++------ .../TestsBase/PressureTestsBase.g.cs | 112 ++------ .../TestsBase/RatioChangeRateTestsBase.g.cs | 112 ++------ .../TestsBase/RatioTestsBase.g.cs | 112 ++------ .../TestsBase/ReactiveEnergyTestsBase.g.cs | 112 ++------ .../TestsBase/ReactivePowerTestsBase.g.cs | 112 ++------ .../TestsBase/ReciprocalAreaTestsBase.g.cs | 112 ++------ .../TestsBase/ReciprocalLengthTestsBase.g.cs | 112 ++------ .../TestsBase/RelativeHumidityTestsBase.g.cs | 112 ++------ .../RotationalAccelerationTestsBase.g.cs | 112 ++------ .../TestsBase/RotationalSpeedTestsBase.g.cs | 112 ++------ ...RotationalStiffnessPerLengthTestsBase.g.cs | 112 ++------ .../RotationalStiffnessTestsBase.g.cs | 112 ++------ .../TestsBase/ScalarTestsBase.g.cs | 112 ++------ .../TestsBase/SolidAngleTestsBase.g.cs | 112 ++------ .../TestsBase/SpecificEnergyTestsBase.g.cs | 112 ++------ .../TestsBase/SpecificEntropyTestsBase.g.cs | 112 ++------ .../SpecificFuelConsumptionTestsBase.g.cs | 112 ++------ .../TestsBase/SpecificVolumeTestsBase.g.cs | 112 ++------ .../TestsBase/SpecificWeightTestsBase.g.cs | 112 ++------ .../TestsBase/SpeedTestsBase.g.cs | 112 ++------ .../StandardVolumeFlowTestsBase.g.cs | 112 ++------ .../TemperatureChangeRateTestsBase.g.cs | 112 ++------ .../TestsBase/TemperatureDeltaTestsBase.g.cs | 112 ++------ .../TemperatureGradientTestsBase.g.cs | 112 ++------ .../TestsBase/TemperatureTestsBase.g.cs | 112 ++------ .../ThermalConductivityTestsBase.g.cs | 112 ++------ .../TestsBase/ThermalResistanceTestsBase.g.cs | 112 ++------ .../TestsBase/TorquePerLengthTestsBase.g.cs | 112 ++------ .../TestsBase/TorqueTestsBase.g.cs | 112 ++------ .../TestsBase/TurbidityTestsBase.g.cs | 112 ++------ .../TestsBase/VitaminATestsBase.g.cs | 112 ++------ .../VolumeConcentrationTestsBase.g.cs | 112 ++------ .../TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 112 ++------ .../TestsBase/VolumeFlowTestsBase.g.cs | 126 ++------- .../TestsBase/VolumePerLengthTestsBase.g.cs | 112 ++------ .../TestsBase/VolumeTestsBase.g.cs | 112 ++------ .../VolumetricHeatCapacityTestsBase.g.cs | 112 ++------ .../WarpingMomentOfInertiaTestsBase.g.cs | 112 ++------ UnitsNet.Tests/QuantityInfoTest.cs | 24 +- .../DefaultDataContractJsonSerializerTests.cs | 8 +- UnitsNet.Tests/UnitMathTests.cs | 2 +- .../Quantities/Acceleration.g.cs | 122 +-------- .../Quantities/AmountOfSubstance.g.cs | 122 +-------- .../Quantities/AmplitudeRatio.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 122 +-------- .../Quantities/ApparentEnergy.g.cs | 122 +-------- .../Quantities/ApparentPower.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 122 +-------- .../GeneratedCode/Quantities/AreaDensity.g.cs | 122 +-------- .../Quantities/AreaMomentOfInertia.g.cs | 122 +-------- .../GeneratedCode/Quantities/BitRate.g.cs | 122 +-------- .../BrakeSpecificFuelConsumption.g.cs | 122 +-------- .../GeneratedCode/Quantities/Capacitance.g.cs | 122 +-------- .../CoefficientOfThermalExpansion.g.cs | 122 +-------- .../GeneratedCode/Quantities/Density.g.cs | 122 +-------- .../GeneratedCode/Quantities/Duration.g.cs | 122 +-------- .../Quantities/DynamicViscosity.g.cs | 122 +-------- .../Quantities/ElectricAdmittance.g.cs | 122 +-------- .../Quantities/ElectricCharge.g.cs | 122 +-------- .../Quantities/ElectricChargeDensity.g.cs | 122 +-------- .../Quantities/ElectricConductance.g.cs | 122 +-------- .../Quantities/ElectricConductivity.g.cs | 122 +-------- .../Quantities/ElectricCurrent.g.cs | 122 +-------- .../Quantities/ElectricCurrentDensity.g.cs | 122 +-------- .../Quantities/ElectricCurrentGradient.g.cs | 122 +-------- .../Quantities/ElectricField.g.cs | 122 +-------- .../Quantities/ElectricInductance.g.cs | 122 +-------- .../Quantities/ElectricPotential.g.cs | 122 +-------- .../Quantities/ElectricPotentialAc.g.cs | 122 +-------- .../ElectricPotentialChangeRate.g.cs | 122 +-------- .../Quantities/ElectricPotentialDc.g.cs | 122 +-------- .../Quantities/ElectricResistance.g.cs | 122 +-------- .../Quantities/ElectricResistivity.g.cs | 122 +-------- .../ElectricSurfaceChargeDensity.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 122 +-------- .../GeneratedCode/Quantities/Entropy.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 122 +-------- .../Quantities/ForceChangeRate.g.cs | 122 +-------- .../Quantities/ForcePerLength.g.cs | 122 +-------- .../GeneratedCode/Quantities/Frequency.g.cs | 122 +-------- .../Quantities/FuelEfficiency.g.cs | 122 +-------- .../GeneratedCode/Quantities/HeatFlux.g.cs | 122 +-------- .../Quantities/HeatTransferCoefficient.g.cs | 122 +-------- .../GeneratedCode/Quantities/Illuminance.g.cs | 122 +-------- .../GeneratedCode/Quantities/Information.g.cs | 122 +-------- .../GeneratedCode/Quantities/Irradiance.g.cs | 122 +-------- .../GeneratedCode/Quantities/Irradiation.g.cs | 122 +-------- .../Quantities/KinematicViscosity.g.cs | 122 +-------- .../GeneratedCode/Quantities/LapseRate.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 122 +-------- .../Quantities/LinearDensity.g.cs | 122 +-------- .../Quantities/LinearPowerDensity.g.cs | 122 +-------- .../GeneratedCode/Quantities/Luminosity.g.cs | 122 +-------- .../Quantities/LuminousFlux.g.cs | 122 +-------- .../Quantities/LuminousIntensity.g.cs | 122 +-------- .../Quantities/MagneticField.g.cs | 122 +-------- .../Quantities/MagneticFlux.g.cs | 122 +-------- .../Quantities/Magnetization.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 122 +-------- .../Quantities/MassConcentration.g.cs | 122 +-------- .../GeneratedCode/Quantities/MassFlow.g.cs | 122 +-------- .../GeneratedCode/Quantities/MassFlux.g.cs | 122 +-------- .../Quantities/MassFraction.g.cs | 122 +-------- .../Quantities/MassMomentOfInertia.g.cs | 122 +-------- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 122 +-------- .../Quantities/MolarEntropy.g.cs | 122 +-------- .../GeneratedCode/Quantities/MolarMass.g.cs | 122 +-------- .../GeneratedCode/Quantities/Molarity.g.cs | 122 +-------- .../Quantities/Permeability.g.cs | 122 +-------- .../Quantities/Permittivity.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 122 +-------- .../Quantities/PowerDensity.g.cs | 122 +-------- .../GeneratedCode/Quantities/PowerRatio.g.cs | 122 +-------- .../GeneratedCode/Quantities/Pressure.g.cs | 122 +-------- .../Quantities/PressureChangeRate.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 122 +-------- .../Quantities/RatioChangeRate.g.cs | 122 +-------- .../Quantities/ReactiveEnergy.g.cs | 122 +-------- .../Quantities/ReactivePower.g.cs | 122 +-------- .../Quantities/ReciprocalArea.g.cs | 122 +-------- .../Quantities/ReciprocalLength.g.cs | 122 +-------- .../Quantities/RelativeHumidity.g.cs | 122 +-------- .../Quantities/RotationalAcceleration.g.cs | 122 +-------- .../Quantities/RotationalSpeed.g.cs | 122 +-------- .../Quantities/RotationalStiffness.g.cs | 122 +-------- .../RotationalStiffnessPerLength.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 122 +-------- .../GeneratedCode/Quantities/SolidAngle.g.cs | 122 +-------- .../Quantities/SpecificEnergy.g.cs | 122 +-------- .../Quantities/SpecificEntropy.g.cs | 122 +-------- .../Quantities/SpecificFuelConsumption.g.cs | 122 +-------- .../Quantities/SpecificVolume.g.cs | 122 +-------- .../Quantities/SpecificWeight.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 122 +-------- .../Quantities/StandardVolumeFlow.g.cs | 122 +-------- .../GeneratedCode/Quantities/Temperature.g.cs | 122 +-------- .../Quantities/TemperatureChangeRate.g.cs | 122 +-------- .../Quantities/TemperatureDelta.g.cs | 122 +-------- .../Quantities/TemperatureGradient.g.cs | 124 +-------- .../Quantities/ThermalConductivity.g.cs | 122 +-------- .../Quantities/ThermalResistance.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 122 +-------- .../Quantities/TorquePerLength.g.cs | 122 +-------- .../GeneratedCode/Quantities/Turbidity.g.cs | 122 +-------- .../GeneratedCode/Quantities/VitaminA.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 122 +-------- .../Quantities/VolumeConcentration.g.cs | 122 +-------- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 132 ++-------- .../Quantities/VolumeFlowPerArea.g.cs | 124 +-------- .../Quantities/VolumePerLength.g.cs | 122 +-------- .../Quantities/VolumetricHeatCapacity.g.cs | 122 +-------- .../Quantities/WarpingMomentOfInertia.g.cs | 122 +-------- UnitsNet/GeneratedCode/Quantity.g.cs | 246 +----------------- .../Units/TemperatureGradientUnit.g.cs | 1 - UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs | 1 - .../Units/VolumeFlowPerAreaUnit.g.cs | 1 - UnitsNet/IQuantity.cs | 2 +- 572 files changed, 4424 insertions(+), 23607 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs index 3c48fda353..a55cafde46 100644 --- a/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/QuantityGenerator.cs @@ -75,7 +75,7 @@ public struct {_quantity.Name} /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static {_unitEnumName} ConversionBaseUnit {{ get; }} = {_unitEnumName}.{_quantity.ConversionBaseUnit}; + public static {_unitEnumName} BaseUnit {{ get; }} = {_unitEnumName}.{_quantity.BaseUnit}; /// /// Represents the largest possible value of Duration @@ -83,27 +83,27 @@ public struct {_quantity.Name} // Non decimal Writer.WLCondition(_quantity.ValueType != "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, ConversionBaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, ConversionBaseUnit);"); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}({_quantity.ValueType}.MinValue, BaseUnit);"); // Decimal MaxValue = 79228162514264337593543950335M Writer.WLCondition(_quantity.ValueType == "decimal", $@" - public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, ConversionBaseUnit); + public static {_quantity.Name} MaxValue {{ get; }} = new {_quantity.Name}(79228162514264337593543950335M, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, ConversionBaseUnit);"); + public static {_quantity.Name} MinValue {{ get; }} = new {_quantity.Name}(-79228162514264337593543950335M, BaseUnit);"); Writer.WL($@" /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, ConversionBaseUnit);"); + public static {_quantity.Name} Zero {{ get; }} = new {_quantity.Name}(0, BaseUnit);"); GenerateConversionProperties(); GenerateStaticFactoryMethods(); diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index e67be48aeb..fd8e42d1a8 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -21,8 +21,8 @@ public QuantityGenerator(Quantity quantity) { _quantity = quantity ?? throw new ArgumentNullException(nameof(quantity)); - _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.ConversionBaseUnit) ?? - throw new ArgumentException($"No unit found with SingularName equal to ConversionBaseUnit [{_quantity.ConversionBaseUnit}]. This unit must be defined.", + _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.BaseUnit) ?? + throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", nameof(quantity)); _valueType = quantity.ValueType; @@ -162,7 +162,7 @@ private void GenerateStaticConstructor() Writer.WL($@" }}, - ConversionBaseUnit, Zero, BaseDimensions); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); }} @@ -235,7 +235,7 @@ private void GenerateStaticProperties() public static BaseDimensions BaseDimensions {{ get; }} /// - /// The base unit of {_quantity.Name}, which is {_quantity.ConversionBaseUnit}. All conversions go via this value. + /// The base unit of {_quantity.Name}, which is {_quantity.BaseUnit}. All conversions go via this value. /// public static {_unitEnumName} BaseUnit {{ get; }} @@ -245,7 +245,7 @@ private void GenerateStaticProperties() public static {_unitEnumName}[] Units {{ get; }} /// - /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.ConversionBaseUnit}. + /// Gets an instance of this quantity with a value of 0 in the base unit {_quantity.BaseUnit}. /// public static {_quantity.Name} Zero {{ get; }} @@ -279,7 +279,7 @@ private void GenerateProperties() Enum IQuantity.Unit => Unit; /// - public {_unitEnumName} Unit => _unit.GetValueOrDefault(ConversionBaseUnit); + public {_unitEnumName} Unit => _unit.GetValueOrDefault(BaseUnit); /// public QuantityInfo<{_unitEnumName}> QuantityInfo => Info; @@ -344,7 +344,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) } Writer.WL($@" - + // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction<{_quantity.Name}>({_unitEnumName}.{_quantity.BaseUnit}, {_unitEnumName}.{_quantity.BaseUnit}, quantity => quantity); diff --git a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs index 2374cb83b3..db95612692 100644 --- a/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/StaticQuantityGenerator.cs @@ -56,7 +56,7 @@ public static IQuantity FromQuantityInfo(QuantityInfo quantityInfo, QuantityValu var quantityName = quantity.Name; Writer.WL($@" case ""{quantityName}"": - return {quantityName}.From(value, {quantityName}.ConversionBaseUnit);"); + return {quantityName}.From(value, {quantityName}.BaseUnit);"); } Writer.WL(@" diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 5240fa7159..77c78d0cce 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -48,8 +48,8 @@ internal class UnitTestBaseClassGenerator : GeneratorBase public UnitTestBaseClassGenerator(Quantity quantity) { _quantity = quantity; - _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.ConversionBaseUnit) ?? - throw new ArgumentException($"No unit found with SingularName equal to ConversionBaseUnit [{_quantity.ConversionBaseUnit}]. This unit must be defined.", + _baseUnit = quantity.Units.FirstOrDefault(u => u.SingularName == _quantity.BaseUnit) ?? + throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", nameof(quantity)); _unitEnumName = $"{quantity.Name}Unit"; _baseUnitEnglishAbbreviation = GetEnglishAbbreviation(_baseUnit); @@ -242,7 +242,7 @@ public void As() [Fact] public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() {{ - var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.ConversionBaseUnit); + var quantity = new {_quantity.Name}(value: 1, unit: {_quantity.Name}.BaseUnit); Func AsWithSIUnitSystem = () => quantity.As(UnitSystem.SI); if (SupportsSIUnitSystem) @@ -282,11 +282,11 @@ public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit({_unitEnumName} unit) {{ // See if there is a unit available that is not the base unit. - var fromUnit = {_quantity.Name}.Units.FirstOrDefault(u => u != {_quantity.Name}.ConversionBaseUnit && u != {_unitEnumName}.Undefined); + var fromUnit = {_quantity.Name}.Units.FirstOrDefault(u => u != {_quantity.Name}.BaseUnit && u != {_unitEnumName}.Undefined); // If there is only one unit for the quantity, we must use the base unit. if(fromUnit == {_unitEnumName}.Undefined) - fromUnit = {_quantity.Name}.ConversionBaseUnit; + fromUnit = {_quantity.Name}.BaseUnit; var quantity = {_quantity.Name}.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/CodeGen/JsonTypes/Quantity.cs b/CodeGen/JsonTypes/Quantity.cs index 4534af2eb7..7075bdfe6a 100644 --- a/CodeGen/JsonTypes/Quantity.cs +++ b/CodeGen/JsonTypes/Quantity.cs @@ -13,7 +13,7 @@ internal class Quantity public BaseDimensions BaseDimensions = new(); // Default to empty public string ValueType = "double"; - public string ConversionBaseUnit; + public string BaseUnit; public bool GenerateArithmetic = true; public bool Logarithmic = false; public int LogarithmicScalingFactor = 1; diff --git a/Common/UnitDefinitions/Acceleration.json b/Common/UnitDefinitions/Acceleration.json index 1db4df18db..dc10f8cb30 100644 --- a/Common/UnitDefinitions/Acceleration.json +++ b/Common/UnitDefinitions/Acceleration.json @@ -1,6 +1,6 @@ { "Name": "Acceleration", - "ConversionBaseUnit": "MeterPerSecondSquared", + "BaseUnit": "MeterPerSecondSquared", "XmlDocSummary": "Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/AmountOfSubstance.json b/Common/UnitDefinitions/AmountOfSubstance.json index 65fb0a865f..25da235f6e 100644 --- a/Common/UnitDefinitions/AmountOfSubstance.json +++ b/Common/UnitDefinitions/AmountOfSubstance.json @@ -1,6 +1,6 @@ { "Name": "AmountOfSubstance", - "ConversionBaseUnit": "Mole", + "BaseUnit": "Mole", "XmlDocSummary": "Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals.", "BaseDimensions": { "N": 1 diff --git a/Common/UnitDefinitions/AmplitudeRatio.json b/Common/UnitDefinitions/AmplitudeRatio.json index 74774bbc75..0190799f4e 100644 --- a/Common/UnitDefinitions/AmplitudeRatio.json +++ b/Common/UnitDefinitions/AmplitudeRatio.json @@ -1,6 +1,6 @@ { "Name": "AmplitudeRatio", - "ConversionBaseUnit": "DecibelVolt", + "BaseUnit": "DecibelVolt", "Logarithmic": "True", "LogarithmicScalingFactor": "2", "XmlDocSummary": "The strength of a signal expressed in decibels (dB) relative to one volt RMS.", diff --git a/Common/UnitDefinitions/Angle.json b/Common/UnitDefinitions/Angle.json index 8c971ce681..bab8347b6a 100644 --- a/Common/UnitDefinitions/Angle.json +++ b/Common/UnitDefinitions/Angle.json @@ -1,6 +1,6 @@ { "Name": "Angle", - "ConversionBaseUnit": "Degree", + "BaseUnit": "Degree", "XmlDocSummary": "In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle.", "Units": [ { diff --git a/Common/UnitDefinitions/ApparentEnergy.json b/Common/UnitDefinitions/ApparentEnergy.json index 454f5deadf..f656a25c02 100644 --- a/Common/UnitDefinitions/ApparentEnergy.json +++ b/Common/UnitDefinitions/ApparentEnergy.json @@ -1,6 +1,6 @@ { "Name": "ApparentEnergy", - "ConversionBaseUnit": "VoltampereHour", + "BaseUnit": "VoltampereHour", "XmlDocSummary": "A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ApparentPower.json b/Common/UnitDefinitions/ApparentPower.json index 00561f41ee..2685557dbd 100644 --- a/Common/UnitDefinitions/ApparentPower.json +++ b/Common/UnitDefinitions/ApparentPower.json @@ -1,6 +1,6 @@ { "Name": "ApparentPower", - "ConversionBaseUnit": "Voltampere", + "BaseUnit": "Voltampere", "XmlDocSummary": "Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Area.json b/Common/UnitDefinitions/Area.json index e6a3664179..e53f83d7dd 100644 --- a/Common/UnitDefinitions/Area.json +++ b/Common/UnitDefinitions/Area.json @@ -1,6 +1,6 @@ { "Name": "Area", - "ConversionBaseUnit": "SquareMeter", + "BaseUnit": "SquareMeter", "XmlDocSummary": "Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept).", "BaseDimensions": { "L": 2 diff --git a/Common/UnitDefinitions/AreaDensity.json b/Common/UnitDefinitions/AreaDensity.json index dbc6251e59..04d5fc449a 100644 --- a/Common/UnitDefinitions/AreaDensity.json +++ b/Common/UnitDefinitions/AreaDensity.json @@ -1,6 +1,6 @@ { "Name": "AreaDensity", - "ConversionBaseUnit": "KilogramPerSquareMeter", + "BaseUnit": "KilogramPerSquareMeter", "XmlDocSummary": "The area density of a two-dimensional object is calculated as the mass per unit area.", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/AreaMomentOfInertia.json b/Common/UnitDefinitions/AreaMomentOfInertia.json index 26bab20f56..ae8b5cdc54 100644 --- a/Common/UnitDefinitions/AreaMomentOfInertia.json +++ b/Common/UnitDefinitions/AreaMomentOfInertia.json @@ -1,6 +1,6 @@ { "Name": "AreaMomentOfInertia", - "ConversionBaseUnit": "MeterToTheFourth", + "BaseUnit": "MeterToTheFourth", "XmlDocSummary": "A geometric property of an area that reflects how its points are distributed with regard to an axis.", "BaseDimensions": { "L": 4 diff --git a/Common/UnitDefinitions/BitRate.json b/Common/UnitDefinitions/BitRate.json index 97fe7b481b..aa4c540950 100644 --- a/Common/UnitDefinitions/BitRate.json +++ b/Common/UnitDefinitions/BitRate.json @@ -1,6 +1,6 @@ { "Name": "BitRate", - "ConversionBaseUnit": "BitPerSecond", + "BaseUnit": "BitPerSecond", "ValueType": "decimal", "XmlDocSummary": "In telecommunications and computing, bit rate is the number of bits that are conveyed or processed per unit of time.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Bit_rate", diff --git a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json index abef5cf80c..49d5c4e215 100644 --- a/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json +++ b/Common/UnitDefinitions/BrakeSpecificFuelConsumption.json @@ -1,6 +1,6 @@ { "Name": "BrakeSpecificFuelConsumption", - "ConversionBaseUnit": "KilogramPerJoule", + "BaseUnit": "KilogramPerJoule", "XmlDocSummary": "Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output.", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/Capacitance.json b/Common/UnitDefinitions/Capacitance.json index 056b52cce5..a7e88a5985 100644 --- a/Common/UnitDefinitions/Capacitance.json +++ b/Common/UnitDefinitions/Capacitance.json @@ -1,6 +1,6 @@ { "Name": "Capacitance", - "ConversionBaseUnit": "Farad", + "BaseUnit": "Farad", "XmlDocSummary": "Capacitance is the ability of a body to store an electric charge.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Capacitance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json index 0d0e3f1708..a0be5b620d 100644 --- a/Common/UnitDefinitions/CoefficientOfThermalExpansion.json +++ b/Common/UnitDefinitions/CoefficientOfThermalExpansion.json @@ -1,6 +1,6 @@ { "Name": "CoefficientOfThermalExpansion", - "ConversionBaseUnit": "InverseKelvin", + "BaseUnit": "InverseKelvin", "XmlDocSummary": "A unit that represents a fractional change in size in response to a change in temperature.", "BaseDimensions": { "Θ": -1 diff --git a/Common/UnitDefinitions/Density.json b/Common/UnitDefinitions/Density.json index d0f04c5a64..f82189caa2 100644 --- a/Common/UnitDefinitions/Density.json +++ b/Common/UnitDefinitions/Density.json @@ -1,6 +1,6 @@ { "Name": "Density", - "ConversionBaseUnit": "KilogramPerCubicMeter", + "BaseUnit": "KilogramPerCubicMeter", "XmlDocSummary": "The density, or more precisely, the volumetric mass density, of a substance is its mass per unit volume.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Duration.json b/Common/UnitDefinitions/Duration.json index c1b5a9888f..ab9b740531 100644 --- a/Common/UnitDefinitions/Duration.json +++ b/Common/UnitDefinitions/Duration.json @@ -1,6 +1,6 @@ { "Name": "Duration", - "ConversionBaseUnit": "Second", + "BaseUnit": "Second", "XmlDocSummary": "Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them.", "BaseDimensions": { "T": 1 diff --git a/Common/UnitDefinitions/DynamicViscosity.json b/Common/UnitDefinitions/DynamicViscosity.json index f49d05fc85..0e4d0bfe2a 100644 --- a/Common/UnitDefinitions/DynamicViscosity.json +++ b/Common/UnitDefinitions/DynamicViscosity.json @@ -1,6 +1,6 @@ { "Name": "DynamicViscosity", - "ConversionBaseUnit": "NewtonSecondPerMeterSquared", + "BaseUnit": "NewtonSecondPerMeterSquared", "XmlDocSummary": "The dynamic (shear) viscosity of a fluid expresses its resistance to shearing flows, where adjacent layers move parallel to each other with different speeds", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricAdmittance.json b/Common/UnitDefinitions/ElectricAdmittance.json index 4fabc206a4..4c75bbf0f1 100644 --- a/Common/UnitDefinitions/ElectricAdmittance.json +++ b/Common/UnitDefinitions/ElectricAdmittance.json @@ -1,6 +1,6 @@ { "Name": "ElectricAdmittance", - "ConversionBaseUnit": "Siemens", + "BaseUnit": "Siemens", "XmlDocSummary": "Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S).", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/ElectricCharge.json b/Common/UnitDefinitions/ElectricCharge.json index bcbcd71bee..c5db2aac29 100644 --- a/Common/UnitDefinitions/ElectricCharge.json +++ b/Common/UnitDefinitions/ElectricCharge.json @@ -1,6 +1,6 @@ { "Name": "ElectricCharge", - "ConversionBaseUnit": "Coulomb", + "BaseUnit": "Coulomb", "XmlDocSummary": "Electric charge is the physical property of matter that causes it to experience a force when placed in an electromagnetic field.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_charge", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricChargeDensity.json b/Common/UnitDefinitions/ElectricChargeDensity.json index 3755755dd0..ce36e8b19d 100644 --- a/Common/UnitDefinitions/ElectricChargeDensity.json +++ b/Common/UnitDefinitions/ElectricChargeDensity.json @@ -1,6 +1,6 @@ { "Name": "ElectricChargeDensity", - "ConversionBaseUnit": "CoulombPerCubicMeter", + "BaseUnit": "CoulombPerCubicMeter", "XmlDocSummary": "In electromagnetism, charge density is a measure of the amount of electric charge per volume.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Charge_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricConductance.json b/Common/UnitDefinitions/ElectricConductance.json index 24e3e79c81..334b6eaa64 100644 --- a/Common/UnitDefinitions/ElectricConductance.json +++ b/Common/UnitDefinitions/ElectricConductance.json @@ -1,6 +1,6 @@ { "Name": "ElectricConductance", - "ConversionBaseUnit": "Siemens", + "BaseUnit": "Siemens", "XmlDocSummary": "The electrical conductance of an electrical conductor is a measure of the easeness to pass an electric current through that conductor.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricConductivity.json b/Common/UnitDefinitions/ElectricConductivity.json index 39f3a1b0e7..a900255d75 100644 --- a/Common/UnitDefinitions/ElectricConductivity.json +++ b/Common/UnitDefinitions/ElectricConductivity.json @@ -1,6 +1,6 @@ { "Name": "ElectricConductivity", - "ConversionBaseUnit": "SiemensPerMeter", + "BaseUnit": "SiemensPerMeter", "XmlDocSummary": "Electrical conductivity or specific conductance is the reciprocal of electrical resistivity, and measures a material's ability to conduct an electric current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricCurrent.json b/Common/UnitDefinitions/ElectricCurrent.json index a9686826ad..6eba323536 100644 --- a/Common/UnitDefinitions/ElectricCurrent.json +++ b/Common/UnitDefinitions/ElectricCurrent.json @@ -1,6 +1,6 @@ { "Name": "ElectricCurrent", - "ConversionBaseUnit": "Ampere", + "BaseUnit": "Ampere", "XmlDocSummary": "An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma.", "BaseDimensions": { "I": 1 diff --git a/Common/UnitDefinitions/ElectricCurrentDensity.json b/Common/UnitDefinitions/ElectricCurrentDensity.json index 02a628d1f0..d59571b095 100644 --- a/Common/UnitDefinitions/ElectricCurrentDensity.json +++ b/Common/UnitDefinitions/ElectricCurrentDensity.json @@ -1,6 +1,6 @@ { "Name": "ElectricCurrentDensity", - "ConversionBaseUnit": "AmperePerSquareMeter", + "BaseUnit": "AmperePerSquareMeter", "XmlDocSummary": "In electromagnetism, current density is the electric current per unit area of cross section.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Current_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricCurrentGradient.json b/Common/UnitDefinitions/ElectricCurrentGradient.json index faf7f39f7e..cde900e067 100644 --- a/Common/UnitDefinitions/ElectricCurrentGradient.json +++ b/Common/UnitDefinitions/ElectricCurrentGradient.json @@ -1,6 +1,6 @@ { "Name": "ElectricCurrentGradient", - "ConversionBaseUnit": "AmperePerSecond", + "BaseUnit": "AmperePerSecond", "XmlDocSummary": "In electromagnetism, the current gradient describes how the current changes in time.", "BaseDimensions": { "T": -1, diff --git a/Common/UnitDefinitions/ElectricField.json b/Common/UnitDefinitions/ElectricField.json index 58c2028783..6b6b534fe8 100644 --- a/Common/UnitDefinitions/ElectricField.json +++ b/Common/UnitDefinitions/ElectricField.json @@ -1,6 +1,6 @@ { "Name": "ElectricField", - "ConversionBaseUnit": "VoltPerMeter", + "BaseUnit": "VoltPerMeter", "XmlDocSummary": "An electric field is a force field that surrounds electric charges that attracts or repels other electric charges.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electric_field", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricInductance.json b/Common/UnitDefinitions/ElectricInductance.json index 61f84c28df..cdf3fac8b7 100644 --- a/Common/UnitDefinitions/ElectricInductance.json +++ b/Common/UnitDefinitions/ElectricInductance.json @@ -1,6 +1,6 @@ { "Name": "ElectricInductance", - "ConversionBaseUnit": "Henry", + "BaseUnit": "Henry", "XmlDocSummary": "Inductance is a property of an electrical conductor which opposes a change in current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inductance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricPotential.json b/Common/UnitDefinitions/ElectricPotential.json index dcabe424b5..8ab5779792 100644 --- a/Common/UnitDefinitions/ElectricPotential.json +++ b/Common/UnitDefinitions/ElectricPotential.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotential", - "ConversionBaseUnit": "Volt", + "BaseUnit": "Volt", "XmlDocSummary": "In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricPotentialAc.json b/Common/UnitDefinitions/ElectricPotentialAc.json index d92f93e1c6..4fd5eb435d 100644 --- a/Common/UnitDefinitions/ElectricPotentialAc.json +++ b/Common/UnitDefinitions/ElectricPotentialAc.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotentialAc", - "ConversionBaseUnit": "VoltAc", + "BaseUnit": "VoltAc", "XmlDocSummary": "The Electric Potential of a system known to use Alternating Current.", "Units": [ { diff --git a/Common/UnitDefinitions/ElectricPotentialChangeRate.json b/Common/UnitDefinitions/ElectricPotentialChangeRate.json index 4e3d8e2848..36d8d1beae 100644 --- a/Common/UnitDefinitions/ElectricPotentialChangeRate.json +++ b/Common/UnitDefinitions/ElectricPotentialChangeRate.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotentialChangeRate", - "ConversionBaseUnit": "VoltPerSecond", + "BaseUnit": "VoltPerSecond", "XmlDocSummary": "ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time).", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricPotentialDc.json b/Common/UnitDefinitions/ElectricPotentialDc.json index fd19b0156d..734ac8bf70 100644 --- a/Common/UnitDefinitions/ElectricPotentialDc.json +++ b/Common/UnitDefinitions/ElectricPotentialDc.json @@ -1,6 +1,6 @@ { "Name": "ElectricPotentialDc", - "ConversionBaseUnit": "VoltDc", + "BaseUnit": "VoltDc", "XmlDocSummary": "The Electric Potential of a system known to use Direct Current.", "Units": [ { diff --git a/Common/UnitDefinitions/ElectricResistance.json b/Common/UnitDefinitions/ElectricResistance.json index 6d1adb2cbe..d6f608fedf 100644 --- a/Common/UnitDefinitions/ElectricResistance.json +++ b/Common/UnitDefinitions/ElectricResistance.json @@ -1,6 +1,6 @@ { "Name": "ElectricResistance", - "ConversionBaseUnit": "Ohm", + "BaseUnit": "Ohm", "XmlDocSummary": "The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ElectricResistivity.json b/Common/UnitDefinitions/ElectricResistivity.json index 0733690402..bbcf9e3acf 100644 --- a/Common/UnitDefinitions/ElectricResistivity.json +++ b/Common/UnitDefinitions/ElectricResistivity.json @@ -1,6 +1,6 @@ { "Name": "ElectricResistivity", - "ConversionBaseUnit": "OhmMeter", + "BaseUnit": "OhmMeter", "XmlDocSummary": "Electrical resistivity (also known as resistivity, specific electrical resistance, or volume resistivity) is a fundamental property that quantifies how strongly a given material opposes the flow of electric current.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json index 19a669f69e..471a6f828a 100644 --- a/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json +++ b/Common/UnitDefinitions/ElectricSurfaceChargeDensity.json @@ -1,6 +1,6 @@ { "Name": "ElectricSurfaceChargeDensity", - "ConversionBaseUnit": "CoulombPerSquareMeter", + "BaseUnit": "CoulombPerSquareMeter", "XmlDocSummary": "In electromagnetism, surface charge density is a measure of the amount of electric charge per surface area.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Charge_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Energy.json b/Common/UnitDefinitions/Energy.json index 9bbaad2b5a..6eb109782d 100644 --- a/Common/UnitDefinitions/Energy.json +++ b/Common/UnitDefinitions/Energy.json @@ -1,6 +1,6 @@ { "Name": "Energy", - "ConversionBaseUnit": "Joule", + "BaseUnit": "Joule", "XmlDocSummary": "The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Entropy.json b/Common/UnitDefinitions/Entropy.json index fc0450cd94..d702f35220 100644 --- a/Common/UnitDefinitions/Entropy.json +++ b/Common/UnitDefinitions/Entropy.json @@ -1,6 +1,6 @@ { "Name": "Entropy", - "ConversionBaseUnit": "JoulePerKelvin", + "BaseUnit": "JoulePerKelvin", "XmlDocSummary": "Entropy is an important concept in the branch of science known as thermodynamics. The idea of \"irreversibility\" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/Force.json b/Common/UnitDefinitions/Force.json index 5090d10efb..56b6d95418 100644 --- a/Common/UnitDefinitions/Force.json +++ b/Common/UnitDefinitions/Force.json @@ -1,6 +1,6 @@ { "Name": "Force", - "ConversionBaseUnit": "Newton", + "BaseUnit": "Newton", "XmlDocSummary": "In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/ForceChangeRate.json b/Common/UnitDefinitions/ForceChangeRate.json index 49f17a5945..70448e78eb 100644 --- a/Common/UnitDefinitions/ForceChangeRate.json +++ b/Common/UnitDefinitions/ForceChangeRate.json @@ -1,6 +1,6 @@ { "Name": "ForceChangeRate", - "ConversionBaseUnit": "NewtonPerSecond", + "BaseUnit": "NewtonPerSecond", "XmlDocSummary": "Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time).", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/ForcePerLength.json b/Common/UnitDefinitions/ForcePerLength.json index c52fb3d7b0..208ba66e0c 100644 --- a/Common/UnitDefinitions/ForcePerLength.json +++ b/Common/UnitDefinitions/ForcePerLength.json @@ -1,6 +1,6 @@ { "Name": "ForcePerLength", - "ConversionBaseUnit": "NewtonPerMeter", + "BaseUnit": "NewtonPerMeter", "XmlDocSummary": "The magnitude of force per unit length.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Frequency.json b/Common/UnitDefinitions/Frequency.json index e3377492c1..b85f2aca35 100644 --- a/Common/UnitDefinitions/Frequency.json +++ b/Common/UnitDefinitions/Frequency.json @@ -1,6 +1,6 @@ { "Name": "Frequency", - "ConversionBaseUnit": "Hertz", + "BaseUnit": "Hertz", "XmlDocSummary": "The number of occurrences of a repeating event per unit time.", "BaseDimensions": { "T": -1 diff --git a/Common/UnitDefinitions/FuelEfficiency.json b/Common/UnitDefinitions/FuelEfficiency.json index 497bfcb020..2f4be64758 100644 --- a/Common/UnitDefinitions/FuelEfficiency.json +++ b/Common/UnitDefinitions/FuelEfficiency.json @@ -1,6 +1,6 @@ { "Name": "FuelEfficiency", - "ConversionBaseUnit": "LiterPer100Kilometers", + "BaseUnit": "LiterPer100Kilometers", "XmlDocSummary": "Fuel efficiency is a form of thermal efficiency, meaning the ratio from effort to result of a process that converts chemical potential energy contained in a carrier (fuel) into kinetic energy or work. Fuel economy is stated as \"fuel consumption\" in liters per 100 kilometers (L/100 km). In countries using non-metric system, fuel economy is expressed in miles per gallon (mpg) (imperial galon or US galon).", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Fuel_efficiency", "Units": [{ diff --git a/Common/UnitDefinitions/HeatFlux.json b/Common/UnitDefinitions/HeatFlux.json index 22db22f203..2f7ef97abc 100644 --- a/Common/UnitDefinitions/HeatFlux.json +++ b/Common/UnitDefinitions/HeatFlux.json @@ -1,6 +1,6 @@ { "Name": "HeatFlux", - "ConversionBaseUnit": "WattPerSquareMeter", + "BaseUnit": "WattPerSquareMeter", "XmlDocSummary": "Heat flux is the flow of energy per unit of area per unit of time", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/HeatTransferCoefficient.json b/Common/UnitDefinitions/HeatTransferCoefficient.json index c009e4ac8b..4e6e82abd1 100644 --- a/Common/UnitDefinitions/HeatTransferCoefficient.json +++ b/Common/UnitDefinitions/HeatTransferCoefficient.json @@ -1,6 +1,6 @@ { "Name": "HeatTransferCoefficient", - "ConversionBaseUnit": "WattPerSquareMeterKelvin", + "BaseUnit": "WattPerSquareMeterKelvin", "XmlDocSummary": "The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT)", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Illuminance.json b/Common/UnitDefinitions/Illuminance.json index 075cbc9f42..2c8b07c52f 100644 --- a/Common/UnitDefinitions/Illuminance.json +++ b/Common/UnitDefinitions/Illuminance.json @@ -1,6 +1,6 @@ { "Name": "Illuminance", - "ConversionBaseUnit": "Lux", + "BaseUnit": "Lux", "XmlDocSummary": "In photometry, illuminance is the total luminous flux incident on a surface, per unit area.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Illuminance", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Information.json b/Common/UnitDefinitions/Information.json index 30e77e3579..8708b8519c 100644 --- a/Common/UnitDefinitions/Information.json +++ b/Common/UnitDefinitions/Information.json @@ -1,6 +1,6 @@ { "Name": "Information", - "ConversionBaseUnit": "Bit", + "BaseUnit": "Bit", "ValueType": "decimal", "XmlDocSummary": "In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables.", "Units": [ diff --git a/Common/UnitDefinitions/Irradiance.json b/Common/UnitDefinitions/Irradiance.json index 9120459019..302e1aa666 100644 --- a/Common/UnitDefinitions/Irradiance.json +++ b/Common/UnitDefinitions/Irradiance.json @@ -1,6 +1,6 @@ { "Name": "Irradiance", - "ConversionBaseUnit": "WattPerSquareMeter", + "BaseUnit": "WattPerSquareMeter", "XmlDocSummary": "Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Irradiation.json b/Common/UnitDefinitions/Irradiation.json index 4989e336e8..ba7ccf5651 100644 --- a/Common/UnitDefinitions/Irradiation.json +++ b/Common/UnitDefinitions/Irradiation.json @@ -1,6 +1,6 @@ { "Name": "Irradiation", - "ConversionBaseUnit": "JoulePerSquareMeter", + "BaseUnit": "JoulePerSquareMeter", "XmlDocSummary": "Irradiation is the process by which an object is exposed to radiation. The exposure can originate from various sources, including natural sources.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Irradiation", "BaseDimensions": { diff --git a/Common/UnitDefinitions/KinematicViscosity.json b/Common/UnitDefinitions/KinematicViscosity.json index 5ce4a5b634..fd03fe6bdb 100644 --- a/Common/UnitDefinitions/KinematicViscosity.json +++ b/Common/UnitDefinitions/KinematicViscosity.json @@ -1,6 +1,6 @@ { "Name": "KinematicViscosity", - "ConversionBaseUnit": "SquareMeterPerSecond", + "BaseUnit": "SquareMeterPerSecond", "XmlDocSummary": "The viscosity of a fluid is a measure of its resistance to gradual deformation by shear stress or tensile stress.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Viscosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LapseRate.json b/Common/UnitDefinitions/LapseRate.json index c5b6ab8896..8f6d875506 100644 --- a/Common/UnitDefinitions/LapseRate.json +++ b/Common/UnitDefinitions/LapseRate.json @@ -1,6 +1,6 @@ { "Name": "LapseRate", - "ConversionBaseUnit": "DegreeCelsiusPerKilometer", + "BaseUnit": "DegreeCelsiusPerKilometer", "XmlDocSummary": "Lapse rate is the rate at which Earth's atmospheric temperature decreases with an increase in altitude, or increases with the decrease in altitude.", "ObsoleteText": "Use TemperatureGradient instead.", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Length.json b/Common/UnitDefinitions/Length.json index fefca7d013..a47c0fb5db 100644 --- a/Common/UnitDefinitions/Length.json +++ b/Common/UnitDefinitions/Length.json @@ -1,6 +1,6 @@ { "Name": "Length", - "ConversionBaseUnit": "Meter", + "BaseUnit": "Meter", "XmlDocSummary": "Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units.", "BaseDimensions": { "L": 1 diff --git a/Common/UnitDefinitions/Level.json b/Common/UnitDefinitions/Level.json index 053d3229af..5ac0ba9095 100644 --- a/Common/UnitDefinitions/Level.json +++ b/Common/UnitDefinitions/Level.json @@ -1,6 +1,6 @@ { "Name": "Level", - "ConversionBaseUnit": "Decibel", + "BaseUnit": "Decibel", "Logarithmic": "True", "LogarithmicScalingFactor": "1", "XmlDocSummary": "Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units.", diff --git a/Common/UnitDefinitions/LinearDensity.json b/Common/UnitDefinitions/LinearDensity.json index 161a62f034..c39ccf66bc 100644 --- a/Common/UnitDefinitions/LinearDensity.json +++ b/Common/UnitDefinitions/LinearDensity.json @@ -1,6 +1,6 @@ { "Name": "LinearDensity", - "ConversionBaseUnit": "KilogramPerMeter", + "BaseUnit": "KilogramPerMeter", "XmlDocSummary": "The Linear Density, or more precisely, the linear mass density, of a substance is its mass per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Linear_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LinearPowerDensity.json b/Common/UnitDefinitions/LinearPowerDensity.json index d261d20037..15b48a0805 100644 --- a/Common/UnitDefinitions/LinearPowerDensity.json +++ b/Common/UnitDefinitions/LinearPowerDensity.json @@ -1,6 +1,6 @@ { "Name": "LinearPowerDensity", - "ConversionBaseUnit": "WattPerMeter", + "BaseUnit": "WattPerMeter", "XmlDocSummary": "The Linear Power Density of a substance is its power per unit length. The term linear density is most often used when describing the characteristics of one-dimensional objects, although linear density can also be used to describe the density of a three-dimensional quantity along one particular dimension.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Linear_density", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Luminosity.json b/Common/UnitDefinitions/Luminosity.json index 0a3bab1565..e0caa0eab7 100644 --- a/Common/UnitDefinitions/Luminosity.json +++ b/Common/UnitDefinitions/Luminosity.json @@ -1,6 +1,6 @@ { "Name": "Luminosity", - "ConversionBaseUnit": "Watt", + "BaseUnit": "Watt", "XmlDocSummary": "Luminosity is an absolute measure of radiated electromagnetic power (light), the radiant power emitted by a light-emitting object.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminosity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LuminousFlux.json b/Common/UnitDefinitions/LuminousFlux.json index d9a8fa38ee..844a6f2b69 100644 --- a/Common/UnitDefinitions/LuminousFlux.json +++ b/Common/UnitDefinitions/LuminousFlux.json @@ -1,6 +1,6 @@ { "Name": "LuminousFlux", - "ConversionBaseUnit": "Lumen", + "BaseUnit": "Lumen", "XmlDocSummary": "In photometry, luminous flux or luminous power is the measure of the perceived power of light.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminous_flux", "BaseDimensions": { diff --git a/Common/UnitDefinitions/LuminousIntensity.json b/Common/UnitDefinitions/LuminousIntensity.json index 8e1689939d..c363940d11 100644 --- a/Common/UnitDefinitions/LuminousIntensity.json +++ b/Common/UnitDefinitions/LuminousIntensity.json @@ -1,6 +1,6 @@ { "Name": "LuminousIntensity", - "ConversionBaseUnit": "Candela", + "BaseUnit": "Candela", "XmlDocSummary": "In photometry, luminous intensity is a measure of the wavelength-weighted power emitted by a light source in a particular direction per unit solid angle, based on the luminosity function, a standardized model of the sensitivity of the human eye.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Luminous_intensity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/MagneticField.json b/Common/UnitDefinitions/MagneticField.json index 4e19a774ee..2689762e31 100644 --- a/Common/UnitDefinitions/MagneticField.json +++ b/Common/UnitDefinitions/MagneticField.json @@ -1,6 +1,6 @@ { "Name": "MagneticField", - "ConversionBaseUnit": "Tesla", + "BaseUnit": "Tesla", "XmlDocSummary": "A magnetic field is a force field that is created by moving electric charges (electric currents) and magnetic dipoles, and exerts a force on other nearby moving charges and magnetic dipoles.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetic_field", "BaseDimensions": { diff --git a/Common/UnitDefinitions/MagneticFlux.json b/Common/UnitDefinitions/MagneticFlux.json index 1856210ce3..5307d9fad3 100644 --- a/Common/UnitDefinitions/MagneticFlux.json +++ b/Common/UnitDefinitions/MagneticFlux.json @@ -1,6 +1,6 @@ { "Name": "MagneticFlux", - "ConversionBaseUnit": "Weber", + "BaseUnit": "Weber", "XmlDocSummary": "In physics, specifically electromagnetism, the magnetic flux through a surface is the surface integral of the normal component of the magnetic field B passing through that surface.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetic_flux", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Magnetization.json b/Common/UnitDefinitions/Magnetization.json index d9d7ae8a03..a8a6b5f6fb 100644 --- a/Common/UnitDefinitions/Magnetization.json +++ b/Common/UnitDefinitions/Magnetization.json @@ -1,6 +1,6 @@ { "Name": "Magnetization", - "ConversionBaseUnit": "AmperePerMeter", + "BaseUnit": "AmperePerMeter", "XmlDocSummary": "In classical electromagnetism, magnetization is the vector field that expresses the density of permanent or induced magnetic dipole moments in a magnetic material.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Magnetization", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Mass.json b/Common/UnitDefinitions/Mass.json index 1d170de8ce..0cd9f7b4cf 100644 --- a/Common/UnitDefinitions/Mass.json +++ b/Common/UnitDefinitions/Mass.json @@ -1,6 +1,6 @@ { "Name": "Mass", - "ConversionBaseUnit": "Kilogram", + "BaseUnit": "Kilogram", "XmlDocSummary": "In physics, mass (from Greek μᾶζα \"barley cake, lump [of dough]\") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg).", "BaseDimensions": { "M": 1 diff --git a/Common/UnitDefinitions/MassConcentration.json b/Common/UnitDefinitions/MassConcentration.json index de6048259d..cd079d5f49 100644 --- a/Common/UnitDefinitions/MassConcentration.json +++ b/Common/UnitDefinitions/MassConcentration.json @@ -1,6 +1,6 @@ { "Name": "MassConcentration", - "ConversionBaseUnit": "KilogramPerCubicMeter", + "BaseUnit": "KilogramPerCubicMeter", "XmlDocSummary": "In chemistry, the mass concentration ρi (or γi) is defined as the mass of a constituent mi divided by the volume of the mixture V", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Mass_concentration_(chemistry)", "BaseDimensions": { diff --git a/Common/UnitDefinitions/MassFlow.json b/Common/UnitDefinitions/MassFlow.json index 0084516ea9..74152115b4 100644 --- a/Common/UnitDefinitions/MassFlow.json +++ b/Common/UnitDefinitions/MassFlow.json @@ -1,6 +1,6 @@ { "Name": "MassFlow", - "ConversionBaseUnit": "GramPerSecond", + "BaseUnit": "GramPerSecond", "XmlDocSummary": "Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time).", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/MassFlux.json b/Common/UnitDefinitions/MassFlux.json index 555dd65130..2fa43f7a30 100644 --- a/Common/UnitDefinitions/MassFlux.json +++ b/Common/UnitDefinitions/MassFlux.json @@ -1,6 +1,6 @@ { "Name": "MassFlux", - "ConversionBaseUnit": "KilogramPerSecondPerSquareMeter", + "BaseUnit": "KilogramPerSecondPerSquareMeter", "XmlDocSummary": "Mass flux is the mass flow rate per unit area.", "BaseDimensions": { "L": -2, diff --git a/Common/UnitDefinitions/MassFraction.json b/Common/UnitDefinitions/MassFraction.json index 1b780a7d27..bc51330ca2 100644 --- a/Common/UnitDefinitions/MassFraction.json +++ b/Common/UnitDefinitions/MassFraction.json @@ -1,6 +1,6 @@ { "Name": "MassFraction", - "ConversionBaseUnit": "DecimalFraction", + "BaseUnit": "DecimalFraction", "XmlDocSummary": "The mass fraction is defined as the mass of a constituent divided by the total mass of the mixture.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Mass_fraction_(chemistry)", "Units": [ diff --git a/Common/UnitDefinitions/MassMomentOfInertia.json b/Common/UnitDefinitions/MassMomentOfInertia.json index 1854183a68..023d409990 100644 --- a/Common/UnitDefinitions/MassMomentOfInertia.json +++ b/Common/UnitDefinitions/MassMomentOfInertia.json @@ -1,6 +1,6 @@ { "Name": "MassMomentOfInertia", - "ConversionBaseUnit": "KilogramSquareMeter", + "BaseUnit": "KilogramSquareMeter", "XmlDocSummary": "A property of body reflects how its mass is distributed with regard to an axis.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/MolarEnergy.json b/Common/UnitDefinitions/MolarEnergy.json index f1212ae78c..93add4f13e 100644 --- a/Common/UnitDefinitions/MolarEnergy.json +++ b/Common/UnitDefinitions/MolarEnergy.json @@ -1,6 +1,6 @@ { "Name": "MolarEnergy", - "ConversionBaseUnit": "JoulePerMole", + "BaseUnit": "JoulePerMole", "XmlDocSummary": "Molar energy is the amount of energy stored in 1 mole of a substance.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/MolarEntropy.json b/Common/UnitDefinitions/MolarEntropy.json index ff5baf5d2b..53b6c96bd5 100644 --- a/Common/UnitDefinitions/MolarEntropy.json +++ b/Common/UnitDefinitions/MolarEntropy.json @@ -1,6 +1,6 @@ { "Name": "MolarEntropy", - "ConversionBaseUnit": "JoulePerMoleKelvin", + "BaseUnit": "JoulePerMoleKelvin", "XmlDocSummary": "Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/MolarMass.json b/Common/UnitDefinitions/MolarMass.json index faf0d34459..e5b165d869 100644 --- a/Common/UnitDefinitions/MolarMass.json +++ b/Common/UnitDefinitions/MolarMass.json @@ -1,6 +1,6 @@ { "Name": "MolarMass", - "ConversionBaseUnit": "KilogramPerMole", + "BaseUnit": "KilogramPerMole", "XmlDocSummary": "In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Molarity.json b/Common/UnitDefinitions/Molarity.json index 8d12fca0ab..76d860342c 100644 --- a/Common/UnitDefinitions/Molarity.json +++ b/Common/UnitDefinitions/Molarity.json @@ -1,6 +1,6 @@ { "Name": "Molarity", - "ConversionBaseUnit": "MolesPerCubicMeter", + "BaseUnit": "MolesPerCubicMeter", "XmlDocSummary": "Molar concentration, also called molarity, amount concentration or substance concentration, is a measure of the concentration of a solute in a solution, or of any chemical species, in terms of amount of substance in a given volume. ", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Molar_concentration", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Permeability.json b/Common/UnitDefinitions/Permeability.json index 7c990ed7bf..cb6c794fe4 100644 --- a/Common/UnitDefinitions/Permeability.json +++ b/Common/UnitDefinitions/Permeability.json @@ -1,6 +1,6 @@ { "Name": "Permeability", - "ConversionBaseUnit": "HenryPerMeter", + "BaseUnit": "HenryPerMeter", "XmlDocSummary": "In electromagnetism, permeability is the measure of the ability of a material to support the formation of a magnetic field within itself.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Permeability_(electromagnetism)", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Permittivity.json b/Common/UnitDefinitions/Permittivity.json index f58ca6490b..ebdd6232f1 100644 --- a/Common/UnitDefinitions/Permittivity.json +++ b/Common/UnitDefinitions/Permittivity.json @@ -1,6 +1,6 @@ { "Name": "Permittivity", - "ConversionBaseUnit": "FaradPerMeter", + "BaseUnit": "FaradPerMeter", "XmlDocSummary": "In electromagnetism, permittivity is the measure of resistance that is encountered when forming an electric field in a particular medium.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Permittivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index f6983a071d..581d005667 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -1,6 +1,6 @@ { "Name": "Power", - "ConversionBaseUnit": "Watt", + "BaseUnit": "Watt", "ValueType": "decimal", "XmlDocSummary": "In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time.", "BaseDimensions": { diff --git a/Common/UnitDefinitions/PowerDensity.json b/Common/UnitDefinitions/PowerDensity.json index 040e4d0d2d..73844f211b 100644 --- a/Common/UnitDefinitions/PowerDensity.json +++ b/Common/UnitDefinitions/PowerDensity.json @@ -1,6 +1,6 @@ { "Name": "PowerDensity", - "ConversionBaseUnit": "WattPerCubicMeter", + "BaseUnit": "WattPerCubicMeter", "XmlDocSummary": "The amount of power in a volume.", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/PowerRatio.json b/Common/UnitDefinitions/PowerRatio.json index 675ddfeea7..6a7df73a1d 100644 --- a/Common/UnitDefinitions/PowerRatio.json +++ b/Common/UnitDefinitions/PowerRatio.json @@ -1,6 +1,6 @@ { "Name": "PowerRatio", - "ConversionBaseUnit": "DecibelWatt", + "BaseUnit": "DecibelWatt", "Logarithmic": "True", "LogarithmicScalingFactor": "1", "XmlDocSummary": "The strength of a signal expressed in decibels (dB) relative to one watt.", diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json index f1cebe3ba7..85680684ee 100644 --- a/Common/UnitDefinitions/Pressure.json +++ b/Common/UnitDefinitions/Pressure.json @@ -1,6 +1,6 @@ { "Name": "Pressure", - "ConversionBaseUnit": "Pascal", + "BaseUnit": "Pascal", "XmlDocSummary": "Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa).", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/PressureChangeRate.json b/Common/UnitDefinitions/PressureChangeRate.json index eac68a2c37..856f9116cb 100644 --- a/Common/UnitDefinitions/PressureChangeRate.json +++ b/Common/UnitDefinitions/PressureChangeRate.json @@ -1,6 +1,6 @@ { "Name": "PressureChangeRate", - "ConversionBaseUnit": "PascalPerSecond", + "BaseUnit": "PascalPerSecond", "XmlDocSummary": "Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time).", "BaseDimensions": { "L": -1, diff --git a/Common/UnitDefinitions/Ratio.json b/Common/UnitDefinitions/Ratio.json index e154c5a3aa..755ee784f1 100644 --- a/Common/UnitDefinitions/Ratio.json +++ b/Common/UnitDefinitions/Ratio.json @@ -1,6 +1,6 @@ { "Name": "Ratio", - "ConversionBaseUnit": "DecimalFraction", + "BaseUnit": "DecimalFraction", "XmlDocSummary": "In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as \"a to b\" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer).", "Units": [ { diff --git a/Common/UnitDefinitions/RatioChangeRate.json b/Common/UnitDefinitions/RatioChangeRate.json index f892154b27..638b94528f 100644 --- a/Common/UnitDefinitions/RatioChangeRate.json +++ b/Common/UnitDefinitions/RatioChangeRate.json @@ -1,6 +1,6 @@ { "Name": "RatioChangeRate", - "ConversionBaseUnit": "DecimalFractionPerSecond", + "BaseUnit": "DecimalFractionPerSecond", "XmlDocSummary": "The change in ratio per unit of time.", "BaseDimensions": { "T": -1 }, "Units": [ diff --git a/Common/UnitDefinitions/ReactiveEnergy.json b/Common/UnitDefinitions/ReactiveEnergy.json index d3bcc640d3..3180621fcf 100644 --- a/Common/UnitDefinitions/ReactiveEnergy.json +++ b/Common/UnitDefinitions/ReactiveEnergy.json @@ -1,6 +1,6 @@ { "Name": "ReactiveEnergy", - "ConversionBaseUnit": "VoltampereReactiveHour", + "BaseUnit": "VoltampereReactiveHour", "XmlDocSummary": "The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ReactivePower.json b/Common/UnitDefinitions/ReactivePower.json index 277bfc9aac..51c981cc83 100644 --- a/Common/UnitDefinitions/ReactivePower.json +++ b/Common/UnitDefinitions/ReactivePower.json @@ -1,6 +1,6 @@ { "Name": "ReactivePower", - "ConversionBaseUnit": "VoltampereReactive", + "BaseUnit": "VoltampereReactive", "XmlDocSummary": "Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/ReciprocalArea.json b/Common/UnitDefinitions/ReciprocalArea.json index 04eadd7ce3..256b360254 100644 --- a/Common/UnitDefinitions/ReciprocalArea.json +++ b/Common/UnitDefinitions/ReciprocalArea.json @@ -1,6 +1,6 @@ { "Name": "ReciprocalArea", - "ConversionBaseUnit": "InverseSquareMeter", + "BaseUnit": "InverseSquareMeter", "XmlDocSummary": "Reciprocal area (Inverse-square) quantity is used to specify a physical quantity inversely proportional to the square of the distance.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Inverse-square_law", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ReciprocalLength.json b/Common/UnitDefinitions/ReciprocalLength.json index 8cdaddb5f5..98cdc7e240 100644 --- a/Common/UnitDefinitions/ReciprocalLength.json +++ b/Common/UnitDefinitions/ReciprocalLength.json @@ -1,6 +1,6 @@ { "Name": "ReciprocalLength", - "ConversionBaseUnit": "InverseMeter", + "BaseUnit": "InverseMeter", "XmlDocSummary": "Reciprocal (Inverse) Length is used in various fields of science and mathematics. It is defined as the inverse value of a length unit.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Reciprocal_length", "BaseDimensions": { diff --git a/Common/UnitDefinitions/RelativeHumidity.json b/Common/UnitDefinitions/RelativeHumidity.json index e8fd15edfd..93f317a9fe 100644 --- a/Common/UnitDefinitions/RelativeHumidity.json +++ b/Common/UnitDefinitions/RelativeHumidity.json @@ -1,6 +1,6 @@ { "Name": "RelativeHumidity", - "ConversionBaseUnit": "Percent", + "BaseUnit": "Percent", "XmlDocSummary": "Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature.", "Units": [ { diff --git a/Common/UnitDefinitions/RotationalAcceleration.json b/Common/UnitDefinitions/RotationalAcceleration.json index 3e5d792cf7..3efeab6106 100644 --- a/Common/UnitDefinitions/RotationalAcceleration.json +++ b/Common/UnitDefinitions/RotationalAcceleration.json @@ -1,6 +1,6 @@ { "Name": "RotationalAcceleration", - "ConversionBaseUnit": "RadianPerSecondSquared", + "BaseUnit": "RadianPerSecondSquared", "XmlDocSummary": "Angular acceleration is the rate of change of rotational speed.", "BaseDimensions": { "T": -2 diff --git a/Common/UnitDefinitions/RotationalSpeed.json b/Common/UnitDefinitions/RotationalSpeed.json index 7387e1851d..5b1d1f8a0e 100644 --- a/Common/UnitDefinitions/RotationalSpeed.json +++ b/Common/UnitDefinitions/RotationalSpeed.json @@ -1,6 +1,6 @@ { "Name": "RotationalSpeed", - "ConversionBaseUnit": "RadianPerSecond", + "BaseUnit": "RadianPerSecond", "XmlDocSummary": "Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter \"omega\").", "BaseDimensions": { "T": -1 diff --git a/Common/UnitDefinitions/RotationalStiffness.json b/Common/UnitDefinitions/RotationalStiffness.json index 85dff491b8..1ba2f77429 100644 --- a/Common/UnitDefinitions/RotationalStiffness.json +++ b/Common/UnitDefinitions/RotationalStiffness.json @@ -1,6 +1,6 @@ { "Name": "RotationalStiffness", - "ConversionBaseUnit": "NewtonMeterPerRadian", + "BaseUnit": "NewtonMeterPerRadian", "XmlDocSummary": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/RotationalStiffnessPerLength.json b/Common/UnitDefinitions/RotationalStiffnessPerLength.json index 83b23ebb8b..a7da856548 100644 --- a/Common/UnitDefinitions/RotationalStiffnessPerLength.json +++ b/Common/UnitDefinitions/RotationalStiffnessPerLength.json @@ -1,6 +1,6 @@ { "Name": "RotationalStiffnessPerLength", - "ConversionBaseUnit": "NewtonMeterPerRadianPerMeter", + "BaseUnit": "NewtonMeterPerRadianPerMeter", "XmlDocSummary": "https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/Scalar.json b/Common/UnitDefinitions/Scalar.json index b6836e8f59..8c8a5ebea4 100644 --- a/Common/UnitDefinitions/Scalar.json +++ b/Common/UnitDefinitions/Scalar.json @@ -1,6 +1,6 @@ { "Name": "Scalar", - "ConversionBaseUnit": "Amount", + "BaseUnit": "Amount", "XmlDocSummary": "A way of representing a number of items.", "Units": [ { diff --git a/Common/UnitDefinitions/SolidAngle.json b/Common/UnitDefinitions/SolidAngle.json index 69296e685e..b19657d42a 100644 --- a/Common/UnitDefinitions/SolidAngle.json +++ b/Common/UnitDefinitions/SolidAngle.json @@ -1,6 +1,6 @@ { "Name": "SolidAngle", - "ConversionBaseUnit": "Steradian", + "BaseUnit": "Steradian", "XmlDocSummary": "In geometry, a solid angle is the two-dimensional angle in three-dimensional space that an object subtends at a point.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Solid_angle", "Units": [ diff --git a/Common/UnitDefinitions/SpecificEnergy.json b/Common/UnitDefinitions/SpecificEnergy.json index 261a3c0808..ae6e610376 100644 --- a/Common/UnitDefinitions/SpecificEnergy.json +++ b/Common/UnitDefinitions/SpecificEnergy.json @@ -1,6 +1,6 @@ { "Name": "SpecificEnergy", - "ConversionBaseUnit": "JoulePerKilogram", + "BaseUnit": "JoulePerKilogram", "XmlDocSummary": "The SpecificEnergy", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Specific_energy", "BaseDimensions": { diff --git a/Common/UnitDefinitions/SpecificEntropy.json b/Common/UnitDefinitions/SpecificEntropy.json index 2800548b8c..f396c994b6 100644 --- a/Common/UnitDefinitions/SpecificEntropy.json +++ b/Common/UnitDefinitions/SpecificEntropy.json @@ -1,6 +1,6 @@ { "Name": "SpecificEntropy", - "ConversionBaseUnit": "JoulePerKilogramKelvin", + "BaseUnit": "JoulePerKilogramKelvin", "XmlDocSummary": "Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/SpecificFuelConsumption.json b/Common/UnitDefinitions/SpecificFuelConsumption.json index 26b29c2a60..6c138acf90 100644 --- a/Common/UnitDefinitions/SpecificFuelConsumption.json +++ b/Common/UnitDefinitions/SpecificFuelConsumption.json @@ -1,6 +1,6 @@ { "Name": "SpecificFuelConsumption", - "ConversionBaseUnit": "GramPerKiloNewtonSecond", + "BaseUnit": "GramPerKiloNewtonSecond", "XmlDocSummary": "SFC is the fuel efficiency of an engine design with respect to thrust output", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption", "Units": [ diff --git a/Common/UnitDefinitions/SpecificVolume.json b/Common/UnitDefinitions/SpecificVolume.json index a27d4c4393..f0f150b957 100644 --- a/Common/UnitDefinitions/SpecificVolume.json +++ b/Common/UnitDefinitions/SpecificVolume.json @@ -1,6 +1,6 @@ { "Name": "SpecificVolume", - "ConversionBaseUnit": "CubicMeterPerKilogram", + "BaseUnit": "CubicMeterPerKilogram", "XmlDocSummary": "In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well.", "BaseDimensions": { "L": 3, diff --git a/Common/UnitDefinitions/SpecificWeight.json b/Common/UnitDefinitions/SpecificWeight.json index 3be8124750..b8273f44db 100644 --- a/Common/UnitDefinitions/SpecificWeight.json +++ b/Common/UnitDefinitions/SpecificWeight.json @@ -1,6 +1,6 @@ { "Name": "SpecificWeight", - "ConversionBaseUnit": "NewtonPerCubicMeter", + "BaseUnit": "NewtonPerCubicMeter", "XmlDocSummary": "The SpecificWeight, or more precisely, the volumetric weight density, of a substance is its weight per unit volume.", "XmlDocRemarks": "http://en.wikipedia.org/wiki/Specificweight", "BaseDimensions": { diff --git a/Common/UnitDefinitions/Speed.json b/Common/UnitDefinitions/Speed.json index 93d235926a..dfba94d7d4 100644 --- a/Common/UnitDefinitions/Speed.json +++ b/Common/UnitDefinitions/Speed.json @@ -1,6 +1,6 @@ { "Name": "Speed", - "ConversionBaseUnit": "MeterPerSecond", + "BaseUnit": "MeterPerSecond", "XmlDocSummary": "In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/StandardVolumeFlow.json b/Common/UnitDefinitions/StandardVolumeFlow.json index 310193515a..09b78a2558 100644 --- a/Common/UnitDefinitions/StandardVolumeFlow.json +++ b/Common/UnitDefinitions/StandardVolumeFlow.json @@ -1,6 +1,6 @@ { "Name": "StandardVolumeFlow", - "ConversionBaseUnit": "StandardCubicMeterPerSecond", + "BaseUnit": "StandardCubicMeterPerSecond", "XmlDocSummary": "The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions.", "BaseDimensions": { "M": 1, diff --git a/Common/UnitDefinitions/Temperature.json b/Common/UnitDefinitions/Temperature.json index c0fe0fa5b5..7d11f4c40f 100644 --- a/Common/UnitDefinitions/Temperature.json +++ b/Common/UnitDefinitions/Temperature.json @@ -1,6 +1,6 @@ { "Name": "Temperature", - "ConversionBaseUnit": "Kelvin", + "BaseUnit": "Kelvin", "XmlDocSummary": "A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics.", "GenerateArithmetic": false, "BaseDimensions": { diff --git a/Common/UnitDefinitions/TemperatureChangeRate.json b/Common/UnitDefinitions/TemperatureChangeRate.json index 688edbc052..ea499abf30 100644 --- a/Common/UnitDefinitions/TemperatureChangeRate.json +++ b/Common/UnitDefinitions/TemperatureChangeRate.json @@ -1,6 +1,6 @@ { "Name": "TemperatureChangeRate", - "ConversionBaseUnit": "DegreeCelsiusPerSecond", + "BaseUnit": "DegreeCelsiusPerSecond", "XmlDocSummary": "Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time).", "BaseDimensions": { "T": -1, diff --git a/Common/UnitDefinitions/TemperatureDelta.json b/Common/UnitDefinitions/TemperatureDelta.json index e6d5516c41..4617a52355 100644 --- a/Common/UnitDefinitions/TemperatureDelta.json +++ b/Common/UnitDefinitions/TemperatureDelta.json @@ -1,6 +1,6 @@ { "Name": "TemperatureDelta", - "ConversionBaseUnit": "Kelvin", + "BaseUnit": "Kelvin", "XmlDocSummary": "Difference between two temperatures. The conversions are different than for Temperature.", "BaseDimensions": { "Θ": 1 diff --git a/Common/UnitDefinitions/ThermalConductivity.json b/Common/UnitDefinitions/ThermalConductivity.json index 3ad9ef7149..fffb9a6c5b 100644 --- a/Common/UnitDefinitions/ThermalConductivity.json +++ b/Common/UnitDefinitions/ThermalConductivity.json @@ -1,6 +1,6 @@ { "Name": "ThermalConductivity", - "ConversionBaseUnit": "WattPerMeterKelvin", + "BaseUnit": "WattPerMeterKelvin", "XmlDocSummary": "Thermal conductivity is the property of a material to conduct heat.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Thermal_Conductivity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/ThermalResistance.json b/Common/UnitDefinitions/ThermalResistance.json index 8c066094dd..3424a6b8a9 100644 --- a/Common/UnitDefinitions/ThermalResistance.json +++ b/Common/UnitDefinitions/ThermalResistance.json @@ -1,6 +1,6 @@ { "Name": "ThermalResistance", - "ConversionBaseUnit": "SquareMeterKelvinPerKilowatt", + "BaseUnit": "SquareMeterKelvinPerKilowatt", "XmlDocSummary": "Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat.", "BaseDimensions": { "M": -1, diff --git a/Common/UnitDefinitions/Torque.json b/Common/UnitDefinitions/Torque.json index b360d8d307..7c9532cb1d 100644 --- a/Common/UnitDefinitions/Torque.json +++ b/Common/UnitDefinitions/Torque.json @@ -1,6 +1,6 @@ { "Name": "Torque", - "ConversionBaseUnit": "NewtonMeter", + "BaseUnit": "NewtonMeter", "XmlDocSummary": "Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt.", "BaseDimensions": { "L": 2, diff --git a/Common/UnitDefinitions/TorquePerLength.json b/Common/UnitDefinitions/TorquePerLength.json index 9bdc479069..718d104144 100644 --- a/Common/UnitDefinitions/TorquePerLength.json +++ b/Common/UnitDefinitions/TorquePerLength.json @@ -1,6 +1,6 @@ { "Name": "TorquePerLength", - "ConversionBaseUnit": "NewtonMeterPerMeter", + "BaseUnit": "NewtonMeterPerMeter", "XmlDocSummary": "The magnitude of torque per unit length.", "BaseDimensions": { "L": 1, diff --git a/Common/UnitDefinitions/Turbidity.json b/Common/UnitDefinitions/Turbidity.json index 8d5f2f3b28..0fd0b96e72 100644 --- a/Common/UnitDefinitions/Turbidity.json +++ b/Common/UnitDefinitions/Turbidity.json @@ -1,6 +1,6 @@ { "Name": "Turbidity", - "ConversionBaseUnit": "NTU", + "BaseUnit": "NTU", "XmlDocSummary": "Turbidity is the cloudiness or haziness of a fluid caused by large numbers of individual particles that are generally invisible to the naked eye, similar to smoke in air. The measurement of turbidity is a key test of water quality.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Turbidity", "Units": [ diff --git a/Common/UnitDefinitions/VitaminA.json b/Common/UnitDefinitions/VitaminA.json index 9888f3e89c..b7220f9b46 100644 --- a/Common/UnitDefinitions/VitaminA.json +++ b/Common/UnitDefinitions/VitaminA.json @@ -1,6 +1,6 @@ { "Name": "VitaminA", - "ConversionBaseUnit": "InternationalUnit", + "BaseUnit": "InternationalUnit", "XmlDocSummary": "Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene.", "Units": [ { diff --git a/Common/UnitDefinitions/Volume.json b/Common/UnitDefinitions/Volume.json index 679c4f1bcf..ca732bed1e 100644 --- a/Common/UnitDefinitions/Volume.json +++ b/Common/UnitDefinitions/Volume.json @@ -1,6 +1,6 @@ { "Name": "Volume", - "ConversionBaseUnit": "CubicMeter", + "BaseUnit": "CubicMeter", "XmlDocSummary": "Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces.", "BaseDimensions": { "L": 3 diff --git a/Common/UnitDefinitions/VolumeConcentration.json b/Common/UnitDefinitions/VolumeConcentration.json index e0cf395182..1c9d32b489 100644 --- a/Common/UnitDefinitions/VolumeConcentration.json +++ b/Common/UnitDefinitions/VolumeConcentration.json @@ -1,6 +1,6 @@ { "Name": "VolumeConcentration", - "ConversionBaseUnit": "DecimalFraction", + "BaseUnit": "DecimalFraction", "XmlDocSummary": "The volume concentration (not to be confused with volume fraction) is defined as the volume of a constituent divided by the total volume of the mixture.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Concentration#Volume_concentration", "Units": [ diff --git a/Common/UnitDefinitions/VolumeFlow.json b/Common/UnitDefinitions/VolumeFlow.json index 8c6d32e64a..4ac78ac9c0 100644 --- a/Common/UnitDefinitions/VolumeFlow.json +++ b/Common/UnitDefinitions/VolumeFlow.json @@ -1,6 +1,6 @@ { "Name": "VolumeFlow", - "ConversionBaseUnit": "CubicMeterPerSecond", + "BaseUnit": "CubicMeterPerSecond", "XmlDocSummary": "In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q.", "BaseDimensions": { "L": 3, diff --git a/Common/UnitDefinitions/VolumePerLength.json b/Common/UnitDefinitions/VolumePerLength.json index b28cbc95de..9db1e535f5 100644 --- a/Common/UnitDefinitions/VolumePerLength.json +++ b/Common/UnitDefinitions/VolumePerLength.json @@ -1,6 +1,6 @@ { "Name": "VolumePerLength", - "ConversionBaseUnit": "CubicMeterPerMeter", + "BaseUnit": "CubicMeterPerMeter", "XmlDocSummary": "Volume, typically of fluid, that a container can hold within a unit of length.", "BaseDimensions": { "L": 2 diff --git a/Common/UnitDefinitions/VolumetricHeatCapacity.json b/Common/UnitDefinitions/VolumetricHeatCapacity.json index 56389c8ccf..0beebc41bd 100644 --- a/Common/UnitDefinitions/VolumetricHeatCapacity.json +++ b/Common/UnitDefinitions/VolumetricHeatCapacity.json @@ -1,6 +1,6 @@ { "Name": "VolumetricHeatCapacity", - "ConversionBaseUnit": "JoulePerCubicMeterKelvin", + "BaseUnit": "JoulePerCubicMeterKelvin", "XmlDocSummary": "The volumetric heat capacity is the amount of energy that must be added, in the form of heat, to one unit of volume of the material in order to cause an increase of one unit in its temperature.", "XmlDocRemarks": "https://en.wikipedia.org/wiki/Volumetric_heat_capacity", "BaseDimensions": { diff --git a/Common/UnitDefinitions/WarpingMomentOfInertia.json b/Common/UnitDefinitions/WarpingMomentOfInertia.json index b41f223a9a..d784b7c44d 100644 --- a/Common/UnitDefinitions/WarpingMomentOfInertia.json +++ b/Common/UnitDefinitions/WarpingMomentOfInertia.json @@ -1,6 +1,6 @@ { "Name": "WarpingMomentOfInertia", - "ConversionBaseUnit": "MeterToTheSixth", + "BaseUnit": "MeterToTheSixth", "XmlDocSummary": "A geometric property of an area that is used to determine the warping stress.", "BaseDimensions": { "L": 6 diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index bdfe75a286..ce969829aa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -17,7 +17,7 @@ en-US nanoframework apparentpower unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index f899403a86..dcfa035342 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -17,7 +17,7 @@ en-US nanoframework area unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index acde105e35..4971ec6ef2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework areadensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index ded4243f57..55a99a7580 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -17,7 +17,7 @@ en-US nanoframework areamomentofinertia unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index dc1135b045..d0e0c00e2e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework bitrate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 78d24276ed..36ac2afad2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -17,7 +17,7 @@ en-US nanoframework brakespecificfuelconsumption unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index 1a32797d44..ed0a2d9f4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework capacitance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index c898ec5d9a..3a944fbff3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -17,7 +17,7 @@ en-US nanoframework coefficientofthermalexpansion unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 42000362ae..e8419a6ea8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -17,7 +17,7 @@ en-US nanoframework density unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index 47e2d4b40c..fe18e484d7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -17,7 +17,7 @@ en-US nanoframework duration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 87f25887ce..59c01a32cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework dynamicviscosity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index 03e7ad3290..27551ee8f4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricadmittance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index b5dfc4f4e9..ca4602a200 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electriccharge unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index c0d62746fc..a77474ea8a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricchargedensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 3e7cd89e67..65c4f64fdd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricconductance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index eed284504d..8c376649be 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricconductivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 77f4544b62..bdc1ed8db2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electriccurrent unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index 8837c5003f..373c8afb54 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electriccurrentdensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index dbbd150c11..f51e763385 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electriccurrentgradient unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index 5f28dfb95a..b2159bb0e0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricfield unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index 948e2e0ef6..3d7cf1b1cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricinductance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index 9bb7728c83..3b3bd2a434 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricpotential unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index 35389cd8db..3b1b22941d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricpotentialac unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 38747159b6..635d406dea 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricpotentialchangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index dfe017ffaf..04a1ecc0b4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricpotentialdc unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index a5d9db22c3..74cad82bf4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricresistance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index e057577492..d08e223ee6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricresistivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index e607563132..a3b87150c2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework electricsurfacechargedensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index 06cd6bb28f..659e85e0d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework energy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 9db45d1069..1b5362b22a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework entropy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index edd9a3a462..bb09272210 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -17,7 +17,7 @@ en-US nanoframework force unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index b588e6de2c..550b93c201 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework forcechangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index b295121900..62cfe13687 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -17,7 +17,7 @@ en-US nanoframework forceperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 6fda5475ae..801101676c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -17,8 +17,8 @@ en-US nanoframework frequency unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - - + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index 1093232877..712e9f43b1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -17,7 +17,7 @@ en-US nanoframework fuelefficiency unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index 2dfd4e9458..9fa6d16ca6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -17,7 +17,7 @@ en-US nanoframework heatflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index d78e5fba45..0deabefa77 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -17,7 +17,7 @@ en-US nanoframework heattransfercoefficient unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index 2e82948d0b..8b72fe0a56 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework illuminance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index ab46f059b1..edacf1bf20 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -17,7 +17,7 @@ en-US nanoframework information unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index 485ad55410..089fdae6e9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework irradiance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index 771c93435d..0a454f706f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -17,7 +17,7 @@ en-US nanoframework irradiation unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index 4af2b0296a..46b45bb025 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework kinematicviscosity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index 0410e079d5..0bfbfc88ca 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework lapserate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index 2c6e6f10f2..f3e6d1c5c7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -17,7 +17,7 @@ en-US nanoframework length unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index d60e33ff6c..4bb19c4e0b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -17,7 +17,7 @@ en-US nanoframework level unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index 76c24de746..830f5752d1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework lineardensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index 113ce7d4da..f0846ba928 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework linearpowerdensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index e06ac1b85e..0cbf449a29 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework luminosity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 8aeabdc864..0443052802 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -17,7 +17,7 @@ en-US nanoframework luminousflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index 7650c77e07..c4d9f3f099 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework luminousintensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index 3221eefd8e..c703531dcf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -17,7 +17,7 @@ en-US nanoframework magneticfield unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index c48a53fd9d..818b8b9f12 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -17,7 +17,7 @@ en-US nanoframework magneticflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index 925969d978..d9678da7cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -17,7 +17,7 @@ en-US nanoframework magnetization unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index 3e181e08ab..985a6e191f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -17,7 +17,7 @@ en-US nanoframework mass unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index a63d0dcaf8..8d111e86d1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -17,7 +17,7 @@ en-US nanoframework massconcentration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 854ed4d095..1005ba90ec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -17,7 +17,7 @@ en-US nanoframework massflow unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index f3215d573b..ecc7ac2a73 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -17,7 +17,7 @@ en-US nanoframework massflux unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index a244cfcfbc..64b0e667e5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -17,7 +17,7 @@ en-US nanoframework massfraction unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index 002f744311..86eba1aca1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -17,7 +17,7 @@ en-US nanoframework massmomentofinertia unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index a0793057d0..e75d037adc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework molarenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index 6ef93fa055..4e06b6d583 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework molarentropy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index 185c225cd1..1b2f2c776a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -17,7 +17,7 @@ en-US nanoframework molarmass unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 90105db26b..7f3b7a144a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework molarity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index c06b557a93..227064762a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -17,7 +17,7 @@ en-US nanoframework permeability unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index 309e9d42ef..c1157481e0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework permittivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index ccadfa2044..6a4fe71779 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -17,7 +17,7 @@ en-US nanoframework power unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 23c938ddab..8903bd7547 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework powerdensity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index 18a7d3fbb9..8852cf9f08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -17,7 +17,7 @@ en-US nanoframework powerratio unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 245541ddf4..10ef301476 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -17,8 +17,8 @@ en-US nanoframework pressure unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - - + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index d768538458..dea12b0db4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework pressurechangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs index 24fba27aff..006dd9a38a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Acceleration.g.cs @@ -60,21 +60,21 @@ public Acceleration(double value, AccelerationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AccelerationUnit ConversionBaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; + public static AccelerationUnit BaseUnit { get; } = AccelerationUnit.MeterPerSecondSquared; /// /// Represents the largest possible value of Duration /// - public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, ConversionBaseUnit); + public static Acceleration MaxValue { get; } = new Acceleration(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, ConversionBaseUnit); + public static Acceleration MinValue { get; } = new Acceleration(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Acceleration Zero { get; } = new Acceleration(0, ConversionBaseUnit); + public static Acceleration Zero { get; } = new Acceleration(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs index e8d5316bbe..62bc8d8e6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -60,21 +60,21 @@ public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AmountOfSubstanceUnit ConversionBaseUnit { get; } = AmountOfSubstanceUnit.Mole; + public static AmountOfSubstanceUnit BaseUnit { get; } = AmountOfSubstanceUnit.Mole; /// /// Represents the largest possible value of Duration /// - public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, ConversionBaseUnit); + public static AmountOfSubstance MaxValue { get; } = new AmountOfSubstance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, ConversionBaseUnit); + public static AmountOfSubstance MinValue { get; } = new AmountOfSubstance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, ConversionBaseUnit); + public static AmountOfSubstance Zero { get; } = new AmountOfSubstance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 542157716d..b89bc911f9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -60,21 +60,21 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AmplitudeRatioUnit ConversionBaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; + public static AmplitudeRatioUnit BaseUnit { get; } = AmplitudeRatioUnit.DecibelVolt; /// /// Represents the largest possible value of Duration /// - public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, ConversionBaseUnit); + public static AmplitudeRatio MaxValue { get; } = new AmplitudeRatio(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, ConversionBaseUnit); + public static AmplitudeRatio MinValue { get; } = new AmplitudeRatio(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, ConversionBaseUnit); + public static AmplitudeRatio Zero { get; } = new AmplitudeRatio(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs index 5f424d72b9..8d7a397186 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs @@ -60,21 +60,21 @@ public Angle(double value, AngleUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AngleUnit ConversionBaseUnit { get; } = AngleUnit.Degree; + public static AngleUnit BaseUnit { get; } = AngleUnit.Degree; /// /// Represents the largest possible value of Duration /// - public static Angle MaxValue { get; } = new Angle(double.MaxValue, ConversionBaseUnit); + public static Angle MaxValue { get; } = new Angle(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Angle MinValue { get; } = new Angle(double.MinValue, ConversionBaseUnit); + public static Angle MinValue { get; } = new Angle(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Angle Zero { get; } = new Angle(0, ConversionBaseUnit); + public static Angle Zero { get; } = new Angle(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs index 83876b1d1f..a0d6ecbf08 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -60,21 +60,21 @@ public ApparentEnergy(double value, ApparentEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ApparentEnergyUnit ConversionBaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; + public static ApparentEnergyUnit BaseUnit { get; } = ApparentEnergyUnit.VoltampereHour; /// /// Represents the largest possible value of Duration /// - public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, ConversionBaseUnit); + public static ApparentEnergy MaxValue { get; } = new ApparentEnergy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, ConversionBaseUnit); + public static ApparentEnergy MinValue { get; } = new ApparentEnergy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, ConversionBaseUnit); + public static ApparentEnergy Zero { get; } = new ApparentEnergy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs index d0c726813c..a6b72c5ba8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ApparentPower.g.cs @@ -60,21 +60,21 @@ public ApparentPower(double value, ApparentPowerUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ApparentPowerUnit ConversionBaseUnit { get; } = ApparentPowerUnit.Voltampere; + public static ApparentPowerUnit BaseUnit { get; } = ApparentPowerUnit.Voltampere; /// /// Represents the largest possible value of Duration /// - public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, ConversionBaseUnit); + public static ApparentPower MaxValue { get; } = new ApparentPower(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, ConversionBaseUnit); + public static ApparentPower MinValue { get; } = new ApparentPower(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ApparentPower Zero { get; } = new ApparentPower(0, ConversionBaseUnit); + public static ApparentPower Zero { get; } = new ApparentPower(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs index 8cb620d8a2..c37df3a010 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Area.g.cs @@ -60,21 +60,21 @@ public Area(double value, AreaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AreaUnit ConversionBaseUnit { get; } = AreaUnit.SquareMeter; + public static AreaUnit BaseUnit { get; } = AreaUnit.SquareMeter; /// /// Represents the largest possible value of Duration /// - public static Area MaxValue { get; } = new Area(double.MaxValue, ConversionBaseUnit); + public static Area MaxValue { get; } = new Area(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Area MinValue { get; } = new Area(double.MinValue, ConversionBaseUnit); + public static Area MinValue { get; } = new Area(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Area Zero { get; } = new Area(0, ConversionBaseUnit); + public static Area Zero { get; } = new Area(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs index c46ad04edf..0f3176f20e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaDensity.g.cs @@ -60,21 +60,21 @@ public AreaDensity(double value, AreaDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AreaDensityUnit ConversionBaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; + public static AreaDensityUnit BaseUnit { get; } = AreaDensityUnit.KilogramPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, ConversionBaseUnit); + public static AreaDensity MaxValue { get; } = new AreaDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, ConversionBaseUnit); + public static AreaDensity MinValue { get; } = new AreaDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AreaDensity Zero { get; } = new AreaDensity(0, ConversionBaseUnit); + public static AreaDensity Zero { get; } = new AreaDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 2a20928c79..350446cd78 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -60,21 +60,21 @@ public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static AreaMomentOfInertiaUnit ConversionBaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; + public static AreaMomentOfInertiaUnit BaseUnit { get; } = AreaMomentOfInertiaUnit.MeterToTheFourth; /// /// Represents the largest possible value of Duration /// - public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, ConversionBaseUnit); + public static AreaMomentOfInertia MaxValue { get; } = new AreaMomentOfInertia(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, ConversionBaseUnit); + public static AreaMomentOfInertia MinValue { get; } = new AreaMomentOfInertia(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, ConversionBaseUnit); + public static AreaMomentOfInertia Zero { get; } = new AreaMomentOfInertia(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs index e28a03eff5..0219dc2d80 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BitRate.g.cs @@ -63,21 +63,21 @@ public BitRate(double value, BitRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static BitRateUnit ConversionBaseUnit { get; } = BitRateUnit.BitPerSecond; + public static BitRateUnit BaseUnit { get; } = BitRateUnit.BitPerSecond; /// /// Represents the largest possible value of Duration /// - public static BitRate MaxValue { get; } = new BitRate(79228162514264337593543950335d, ConversionBaseUnit); + public static BitRate MaxValue { get; } = new BitRate(79228162514264337593543950335d, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static BitRate MinValue { get; } = new BitRate(-79228162514264337593543950335d, ConversionBaseUnit); + public static BitRate MinValue { get; } = new BitRate(-79228162514264337593543950335d, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static BitRate Zero { get; } = new BitRate(0, ConversionBaseUnit); + public static BitRate Zero { get; } = new BitRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index e0ccfe50ed..1e70048b9e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -60,21 +60,21 @@ public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUn /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static BrakeSpecificFuelConsumptionUnit ConversionBaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; + public static BrakeSpecificFuelConsumptionUnit BaseUnit { get; } = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; /// /// Represents the largest possible value of Duration /// - public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); + public static BrakeSpecificFuelConsumption MaxValue { get; } = new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, ConversionBaseUnit); + public static BrakeSpecificFuelConsumption MinValue { get; } = new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, ConversionBaseUnit); + public static BrakeSpecificFuelConsumption Zero { get; } = new BrakeSpecificFuelConsumption(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs index ba329c5e57..db03ebb402 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Capacitance.g.cs @@ -63,21 +63,21 @@ public Capacitance(double value, CapacitanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static CapacitanceUnit ConversionBaseUnit { get; } = CapacitanceUnit.Farad; + public static CapacitanceUnit BaseUnit { get; } = CapacitanceUnit.Farad; /// /// Represents the largest possible value of Duration /// - public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, ConversionBaseUnit); + public static Capacitance MaxValue { get; } = new Capacitance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, ConversionBaseUnit); + public static Capacitance MinValue { get; } = new Capacitance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Capacitance Zero { get; } = new Capacitance(0, ConversionBaseUnit); + public static Capacitance Zero { get; } = new Capacitance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index a4f787f3b8..50f9dea17f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -60,21 +60,21 @@ public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansion /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static CoefficientOfThermalExpansionUnit ConversionBaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; + public static CoefficientOfThermalExpansionUnit BaseUnit { get; } = CoefficientOfThermalExpansionUnit.InverseKelvin; /// /// Represents the largest possible value of Duration /// - public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, ConversionBaseUnit); + public static CoefficientOfThermalExpansion MaxValue { get; } = new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, ConversionBaseUnit); + public static CoefficientOfThermalExpansion MinValue { get; } = new CoefficientOfThermalExpansion(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, ConversionBaseUnit); + public static CoefficientOfThermalExpansion Zero { get; } = new CoefficientOfThermalExpansion(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs index d63414feb3..5ded41b840 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Density.g.cs @@ -63,21 +63,21 @@ public Density(double value, DensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DensityUnit ConversionBaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; + public static DensityUnit BaseUnit { get; } = DensityUnit.KilogramPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static Density MaxValue { get; } = new Density(double.MaxValue, ConversionBaseUnit); + public static Density MaxValue { get; } = new Density(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Density MinValue { get; } = new Density(double.MinValue, ConversionBaseUnit); + public static Density MinValue { get; } = new Density(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Density Zero { get; } = new Density(0, ConversionBaseUnit); + public static Density Zero { get; } = new Density(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs index 2d99a76bbc..83a2e3d60e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Duration.g.cs @@ -60,21 +60,21 @@ public Duration(double value, DurationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DurationUnit ConversionBaseUnit { get; } = DurationUnit.Second; + public static DurationUnit BaseUnit { get; } = DurationUnit.Second; /// /// Represents the largest possible value of Duration /// - public static Duration MaxValue { get; } = new Duration(double.MaxValue, ConversionBaseUnit); + public static Duration MaxValue { get; } = new Duration(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Duration MinValue { get; } = new Duration(double.MinValue, ConversionBaseUnit); + public static Duration MinValue { get; } = new Duration(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Duration Zero { get; } = new Duration(0, ConversionBaseUnit); + public static Duration Zero { get; } = new Duration(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs index 1f23e8cb52..eb3dd56cb0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -63,21 +63,21 @@ public DynamicViscosity(double value, DynamicViscosityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static DynamicViscosityUnit ConversionBaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; + public static DynamicViscosityUnit BaseUnit { get; } = DynamicViscosityUnit.NewtonSecondPerMeterSquared; /// /// Represents the largest possible value of Duration /// - public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, ConversionBaseUnit); + public static DynamicViscosity MaxValue { get; } = new DynamicViscosity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, ConversionBaseUnit); + public static DynamicViscosity MinValue { get; } = new DynamicViscosity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, ConversionBaseUnit); + public static DynamicViscosity Zero { get; } = new DynamicViscosity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs index bf81230351..79cdeed972 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -60,21 +60,21 @@ public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricAdmittanceUnit ConversionBaseUnit { get; } = ElectricAdmittanceUnit.Siemens; + public static ElectricAdmittanceUnit BaseUnit { get; } = ElectricAdmittanceUnit.Siemens; /// /// Represents the largest possible value of Duration /// - public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, ConversionBaseUnit); + public static ElectricAdmittance MaxValue { get; } = new ElectricAdmittance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, ConversionBaseUnit); + public static ElectricAdmittance MinValue { get; } = new ElectricAdmittance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, ConversionBaseUnit); + public static ElectricAdmittance Zero { get; } = new ElectricAdmittance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs index 5964b55fb4..eab01fda2b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -63,21 +63,21 @@ public ElectricCharge(double value, ElectricChargeUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricChargeUnit ConversionBaseUnit { get; } = ElectricChargeUnit.Coulomb; + public static ElectricChargeUnit BaseUnit { get; } = ElectricChargeUnit.Coulomb; /// /// Represents the largest possible value of Duration /// - public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, ConversionBaseUnit); + public static ElectricCharge MaxValue { get; } = new ElectricCharge(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, ConversionBaseUnit); + public static ElectricCharge MinValue { get; } = new ElectricCharge(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCharge Zero { get; } = new ElectricCharge(0, ConversionBaseUnit); + public static ElectricCharge Zero { get; } = new ElectricCharge(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 1adb4bf3e7..7f820b38d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -63,21 +63,21 @@ public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricChargeDensityUnit ConversionBaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; + public static ElectricChargeDensityUnit BaseUnit { get; } = ElectricChargeDensityUnit.CoulombPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, ConversionBaseUnit); + public static ElectricChargeDensity MaxValue { get; } = new ElectricChargeDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, ConversionBaseUnit); + public static ElectricChargeDensity MinValue { get; } = new ElectricChargeDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, ConversionBaseUnit); + public static ElectricChargeDensity Zero { get; } = new ElectricChargeDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs index fdadeb0eac..07779a8bf6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -63,21 +63,21 @@ public ElectricConductance(double value, ElectricConductanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricConductanceUnit ConversionBaseUnit { get; } = ElectricConductanceUnit.Siemens; + public static ElectricConductanceUnit BaseUnit { get; } = ElectricConductanceUnit.Siemens; /// /// Represents the largest possible value of Duration /// - public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, ConversionBaseUnit); + public static ElectricConductance MaxValue { get; } = new ElectricConductance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, ConversionBaseUnit); + public static ElectricConductance MinValue { get; } = new ElectricConductance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricConductance Zero { get; } = new ElectricConductance(0, ConversionBaseUnit); + public static ElectricConductance Zero { get; } = new ElectricConductance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs index 7561614880..e96aaca59c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -63,21 +63,21 @@ public ElectricConductivity(double value, ElectricConductivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricConductivityUnit ConversionBaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; + public static ElectricConductivityUnit BaseUnit { get; } = ElectricConductivityUnit.SiemensPerMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, ConversionBaseUnit); + public static ElectricConductivity MaxValue { get; } = new ElectricConductivity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, ConversionBaseUnit); + public static ElectricConductivity MinValue { get; } = new ElectricConductivity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, ConversionBaseUnit); + public static ElectricConductivity Zero { get; } = new ElectricConductivity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs index ae17ce22e3..8fa4c9b20b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -60,21 +60,21 @@ public ElectricCurrent(double value, ElectricCurrentUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricCurrentUnit ConversionBaseUnit { get; } = ElectricCurrentUnit.Ampere; + public static ElectricCurrentUnit BaseUnit { get; } = ElectricCurrentUnit.Ampere; /// /// Represents the largest possible value of Duration /// - public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, ConversionBaseUnit); + public static ElectricCurrent MaxValue { get; } = new ElectricCurrent(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, ConversionBaseUnit); + public static ElectricCurrent MinValue { get; } = new ElectricCurrent(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, ConversionBaseUnit); + public static ElectricCurrent Zero { get; } = new ElectricCurrent(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index efceeb3627..50afdd9434 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -63,21 +63,21 @@ public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricCurrentDensityUnit ConversionBaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; + public static ElectricCurrentDensityUnit BaseUnit { get; } = ElectricCurrentDensityUnit.AmperePerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, ConversionBaseUnit); + public static ElectricCurrentDensity MaxValue { get; } = new ElectricCurrentDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, ConversionBaseUnit); + public static ElectricCurrentDensity MinValue { get; } = new ElectricCurrentDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, ConversionBaseUnit); + public static ElectricCurrentDensity Zero { get; } = new ElectricCurrentDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 4817effa45..00088eefb1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -60,21 +60,21 @@ public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricCurrentGradientUnit ConversionBaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; + public static ElectricCurrentGradientUnit BaseUnit { get; } = ElectricCurrentGradientUnit.AmperePerSecond; /// /// Represents the largest possible value of Duration /// - public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, ConversionBaseUnit); + public static ElectricCurrentGradient MaxValue { get; } = new ElectricCurrentGradient(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, ConversionBaseUnit); + public static ElectricCurrentGradient MinValue { get; } = new ElectricCurrentGradient(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, ConversionBaseUnit); + public static ElectricCurrentGradient Zero { get; } = new ElectricCurrentGradient(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs index ea62a800f6..7c590fa890 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricField.g.cs @@ -63,21 +63,21 @@ public ElectricField(double value, ElectricFieldUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricFieldUnit ConversionBaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; + public static ElectricFieldUnit BaseUnit { get; } = ElectricFieldUnit.VoltPerMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, ConversionBaseUnit); + public static ElectricField MaxValue { get; } = new ElectricField(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, ConversionBaseUnit); + public static ElectricField MinValue { get; } = new ElectricField(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricField Zero { get; } = new ElectricField(0, ConversionBaseUnit); + public static ElectricField Zero { get; } = new ElectricField(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs index 1afd8ccb9b..744e4171e8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -63,21 +63,21 @@ public ElectricInductance(double value, ElectricInductanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricInductanceUnit ConversionBaseUnit { get; } = ElectricInductanceUnit.Henry; + public static ElectricInductanceUnit BaseUnit { get; } = ElectricInductanceUnit.Henry; /// /// Represents the largest possible value of Duration /// - public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, ConversionBaseUnit); + public static ElectricInductance MaxValue { get; } = new ElectricInductance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, ConversionBaseUnit); + public static ElectricInductance MinValue { get; } = new ElectricInductance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricInductance Zero { get; } = new ElectricInductance(0, ConversionBaseUnit); + public static ElectricInductance Zero { get; } = new ElectricInductance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs index 84698afc08..661b1f06b8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -60,21 +60,21 @@ public ElectricPotential(double value, ElectricPotentialUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialUnit ConversionBaseUnit { get; } = ElectricPotentialUnit.Volt; + public static ElectricPotentialUnit BaseUnit { get; } = ElectricPotentialUnit.Volt; /// /// Represents the largest possible value of Duration /// - public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, ConversionBaseUnit); + public static ElectricPotential MaxValue { get; } = new ElectricPotential(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, ConversionBaseUnit); + public static ElectricPotential MinValue { get; } = new ElectricPotential(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotential Zero { get; } = new ElectricPotential(0, ConversionBaseUnit); + public static ElectricPotential Zero { get; } = new ElectricPotential(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 02b62ae184..4e84a16d02 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -60,21 +60,21 @@ public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialAcUnit ConversionBaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; + public static ElectricPotentialAcUnit BaseUnit { get; } = ElectricPotentialAcUnit.VoltAc; /// /// Represents the largest possible value of Duration /// - public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, ConversionBaseUnit); + public static ElectricPotentialAc MaxValue { get; } = new ElectricPotentialAc(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, ConversionBaseUnit); + public static ElectricPotentialAc MinValue { get; } = new ElectricPotentialAc(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, ConversionBaseUnit); + public static ElectricPotentialAc Zero { get; } = new ElectricPotentialAc(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index b33ffc6718..12af1844bc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -60,21 +60,21 @@ public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialChangeRateUnit ConversionBaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; + public static ElectricPotentialChangeRateUnit BaseUnit { get; } = ElectricPotentialChangeRateUnit.VoltPerSecond; /// /// Represents the largest possible value of Duration /// - public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, ConversionBaseUnit); + public static ElectricPotentialChangeRate MaxValue { get; } = new ElectricPotentialChangeRate(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, ConversionBaseUnit); + public static ElectricPotentialChangeRate MinValue { get; } = new ElectricPotentialChangeRate(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, ConversionBaseUnit); + public static ElectricPotentialChangeRate Zero { get; } = new ElectricPotentialChangeRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index de59867ffa..8fd938c6c6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -60,21 +60,21 @@ public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricPotentialDcUnit ConversionBaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; + public static ElectricPotentialDcUnit BaseUnit { get; } = ElectricPotentialDcUnit.VoltDc; /// /// Represents the largest possible value of Duration /// - public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, ConversionBaseUnit); + public static ElectricPotentialDc MaxValue { get; } = new ElectricPotentialDc(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, ConversionBaseUnit); + public static ElectricPotentialDc MinValue { get; } = new ElectricPotentialDc(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, ConversionBaseUnit); + public static ElectricPotentialDc Zero { get; } = new ElectricPotentialDc(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs index dd207ee46d..b949552c1d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -60,21 +60,21 @@ public ElectricResistance(double value, ElectricResistanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricResistanceUnit ConversionBaseUnit { get; } = ElectricResistanceUnit.Ohm; + public static ElectricResistanceUnit BaseUnit { get; } = ElectricResistanceUnit.Ohm; /// /// Represents the largest possible value of Duration /// - public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, ConversionBaseUnit); + public static ElectricResistance MaxValue { get; } = new ElectricResistance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, ConversionBaseUnit); + public static ElectricResistance MinValue { get; } = new ElectricResistance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricResistance Zero { get; } = new ElectricResistance(0, ConversionBaseUnit); + public static ElectricResistance Zero { get; } = new ElectricResistance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs index f4201a8793..f6f2fd5878 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -63,21 +63,21 @@ public ElectricResistivity(double value, ElectricResistivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricResistivityUnit ConversionBaseUnit { get; } = ElectricResistivityUnit.OhmMeter; + public static ElectricResistivityUnit BaseUnit { get; } = ElectricResistivityUnit.OhmMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, ConversionBaseUnit); + public static ElectricResistivity MaxValue { get; } = new ElectricResistivity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, ConversionBaseUnit); + public static ElectricResistivity MinValue { get; } = new ElectricResistivity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, ConversionBaseUnit); + public static ElectricResistivity Zero { get; } = new ElectricResistivity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index d45dcfc057..5098463995 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -63,21 +63,21 @@ public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUn /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ElectricSurfaceChargeDensityUnit ConversionBaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; + public static ElectricSurfaceChargeDensityUnit BaseUnit { get; } = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, ConversionBaseUnit); + public static ElectricSurfaceChargeDensity MaxValue { get; } = new ElectricSurfaceChargeDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, ConversionBaseUnit); + public static ElectricSurfaceChargeDensity MinValue { get; } = new ElectricSurfaceChargeDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, ConversionBaseUnit); + public static ElectricSurfaceChargeDensity Zero { get; } = new ElectricSurfaceChargeDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs index fa5e992b62..2442450def 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Energy.g.cs @@ -60,21 +60,21 @@ public Energy(double value, EnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static EnergyUnit ConversionBaseUnit { get; } = EnergyUnit.Joule; + public static EnergyUnit BaseUnit { get; } = EnergyUnit.Joule; /// /// Represents the largest possible value of Duration /// - public static Energy MaxValue { get; } = new Energy(double.MaxValue, ConversionBaseUnit); + public static Energy MaxValue { get; } = new Energy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Energy MinValue { get; } = new Energy(double.MinValue, ConversionBaseUnit); + public static Energy MinValue { get; } = new Energy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Energy Zero { get; } = new Energy(0, ConversionBaseUnit); + public static Energy Zero { get; } = new Energy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs index 40938ece69..02ffc3e2fe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Entropy.g.cs @@ -60,21 +60,21 @@ public Entropy(double value, EntropyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static EntropyUnit ConversionBaseUnit { get; } = EntropyUnit.JoulePerKelvin; + public static EntropyUnit BaseUnit { get; } = EntropyUnit.JoulePerKelvin; /// /// Represents the largest possible value of Duration /// - public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, ConversionBaseUnit); + public static Entropy MaxValue { get; } = new Entropy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Entropy MinValue { get; } = new Entropy(double.MinValue, ConversionBaseUnit); + public static Entropy MinValue { get; } = new Entropy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Entropy Zero { get; } = new Entropy(0, ConversionBaseUnit); + public static Entropy Zero { get; } = new Entropy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs index 054d12fcee..eb249e5720 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Force.g.cs @@ -60,21 +60,21 @@ public Force(double value, ForceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ForceUnit ConversionBaseUnit { get; } = ForceUnit.Newton; + public static ForceUnit BaseUnit { get; } = ForceUnit.Newton; /// /// Represents the largest possible value of Duration /// - public static Force MaxValue { get; } = new Force(double.MaxValue, ConversionBaseUnit); + public static Force MaxValue { get; } = new Force(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Force MinValue { get; } = new Force(double.MinValue, ConversionBaseUnit); + public static Force MinValue { get; } = new Force(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Force Zero { get; } = new Force(0, ConversionBaseUnit); + public static Force Zero { get; } = new Force(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs index 2d312ca7b6..fd0e82729e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -60,21 +60,21 @@ public ForceChangeRate(double value, ForceChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ForceChangeRateUnit ConversionBaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; + public static ForceChangeRateUnit BaseUnit { get; } = ForceChangeRateUnit.NewtonPerSecond; /// /// Represents the largest possible value of Duration /// - public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, ConversionBaseUnit); + public static ForceChangeRate MaxValue { get; } = new ForceChangeRate(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, ConversionBaseUnit); + public static ForceChangeRate MinValue { get; } = new ForceChangeRate(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, ConversionBaseUnit); + public static ForceChangeRate Zero { get; } = new ForceChangeRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs index cde6bcd3dc..f384bd869c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -60,21 +60,21 @@ public ForcePerLength(double value, ForcePerLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ForcePerLengthUnit ConversionBaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; + public static ForcePerLengthUnit BaseUnit { get; } = ForcePerLengthUnit.NewtonPerMeter; /// /// Represents the largest possible value of Duration /// - public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, ConversionBaseUnit); + public static ForcePerLength MaxValue { get; } = new ForcePerLength(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, ConversionBaseUnit); + public static ForcePerLength MinValue { get; } = new ForcePerLength(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ForcePerLength Zero { get; } = new ForcePerLength(0, ConversionBaseUnit); + public static ForcePerLength Zero { get; } = new ForcePerLength(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs index 2195a7452f..338b477857 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs @@ -60,21 +60,21 @@ public Frequency(double value, FrequencyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static FrequencyUnit ConversionBaseUnit { get; } = FrequencyUnit.Hertz; + public static FrequencyUnit BaseUnit { get; } = FrequencyUnit.Hertz; /// /// Represents the largest possible value of Duration /// - public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, ConversionBaseUnit); + public static Frequency MaxValue { get; } = new Frequency(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Frequency MinValue { get; } = new Frequency(double.MinValue, ConversionBaseUnit); + public static Frequency MinValue { get; } = new Frequency(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Frequency Zero { get; } = new Frequency(0, ConversionBaseUnit); + public static Frequency Zero { get; } = new Frequency(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs index 9028d058a3..edb44b4de9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -63,21 +63,21 @@ public FuelEfficiency(double value, FuelEfficiencyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static FuelEfficiencyUnit ConversionBaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; + public static FuelEfficiencyUnit BaseUnit { get; } = FuelEfficiencyUnit.LiterPer100Kilometers; /// /// Represents the largest possible value of Duration /// - public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, ConversionBaseUnit); + public static FuelEfficiency MaxValue { get; } = new FuelEfficiency(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, ConversionBaseUnit); + public static FuelEfficiency MinValue { get; } = new FuelEfficiency(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, ConversionBaseUnit); + public static FuelEfficiency Zero { get; } = new FuelEfficiency(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs index b4ef29ee9a..95c80aeec8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatFlux.g.cs @@ -60,21 +60,21 @@ public HeatFlux(double value, HeatFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static HeatFluxUnit ConversionBaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; + public static HeatFluxUnit BaseUnit { get; } = HeatFluxUnit.WattPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, ConversionBaseUnit); + public static HeatFlux MaxValue { get; } = new HeatFlux(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, ConversionBaseUnit); + public static HeatFlux MinValue { get; } = new HeatFlux(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static HeatFlux Zero { get; } = new HeatFlux(0, ConversionBaseUnit); + public static HeatFlux Zero { get; } = new HeatFlux(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 6ab4488345..5402c4ead4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -60,21 +60,21 @@ public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static HeatTransferCoefficientUnit ConversionBaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; + public static HeatTransferCoefficientUnit BaseUnit { get; } = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; /// /// Represents the largest possible value of Duration /// - public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, ConversionBaseUnit); + public static HeatTransferCoefficient MaxValue { get; } = new HeatTransferCoefficient(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, ConversionBaseUnit); + public static HeatTransferCoefficient MinValue { get; } = new HeatTransferCoefficient(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, ConversionBaseUnit); + public static HeatTransferCoefficient Zero { get; } = new HeatTransferCoefficient(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs index 7913154465..ab75adbbbb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Illuminance.g.cs @@ -63,21 +63,21 @@ public Illuminance(double value, IlluminanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static IlluminanceUnit ConversionBaseUnit { get; } = IlluminanceUnit.Lux; + public static IlluminanceUnit BaseUnit { get; } = IlluminanceUnit.Lux; /// /// Represents the largest possible value of Duration /// - public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, ConversionBaseUnit); + public static Illuminance MaxValue { get; } = new Illuminance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, ConversionBaseUnit); + public static Illuminance MinValue { get; } = new Illuminance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Illuminance Zero { get; } = new Illuminance(0, ConversionBaseUnit); + public static Illuminance Zero { get; } = new Illuminance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs index d1c6d38a14..800eb13b25 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Information.g.cs @@ -60,21 +60,21 @@ public Information(double value, InformationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static InformationUnit ConversionBaseUnit { get; } = InformationUnit.Bit; + public static InformationUnit BaseUnit { get; } = InformationUnit.Bit; /// /// Represents the largest possible value of Duration /// - public static Information MaxValue { get; } = new Information(79228162514264337593543950335d, ConversionBaseUnit); + public static Information MaxValue { get; } = new Information(79228162514264337593543950335d, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Information MinValue { get; } = new Information(-79228162514264337593543950335d, ConversionBaseUnit); + public static Information MinValue { get; } = new Information(-79228162514264337593543950335d, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Information Zero { get; } = new Information(0, ConversionBaseUnit); + public static Information Zero { get; } = new Information(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs index 66f49b34e7..741d4de643 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiance.g.cs @@ -60,21 +60,21 @@ public Irradiance(double value, IrradianceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static IrradianceUnit ConversionBaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; + public static IrradianceUnit BaseUnit { get; } = IrradianceUnit.WattPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, ConversionBaseUnit); + public static Irradiance MaxValue { get; } = new Irradiance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, ConversionBaseUnit); + public static Irradiance MinValue { get; } = new Irradiance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Irradiance Zero { get; } = new Irradiance(0, ConversionBaseUnit); + public static Irradiance Zero { get; } = new Irradiance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs index 1b12772832..7f7d5c7d5f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Irradiation.g.cs @@ -63,21 +63,21 @@ public Irradiation(double value, IrradiationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static IrradiationUnit ConversionBaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; + public static IrradiationUnit BaseUnit { get; } = IrradiationUnit.JoulePerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, ConversionBaseUnit); + public static Irradiation MaxValue { get; } = new Irradiation(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, ConversionBaseUnit); + public static Irradiation MinValue { get; } = new Irradiation(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Irradiation Zero { get; } = new Irradiation(0, ConversionBaseUnit); + public static Irradiation Zero { get; } = new Irradiation(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs index ad6c311057..8a15c9a760 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -63,21 +63,21 @@ public KinematicViscosity(double value, KinematicViscosityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static KinematicViscosityUnit ConversionBaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; + public static KinematicViscosityUnit BaseUnit { get; } = KinematicViscosityUnit.SquareMeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, ConversionBaseUnit); + public static KinematicViscosity MaxValue { get; } = new KinematicViscosity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, ConversionBaseUnit); + public static KinematicViscosity MinValue { get; } = new KinematicViscosity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, ConversionBaseUnit); + public static KinematicViscosity Zero { get; } = new KinematicViscosity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs index 361a1cbf25..d38d90e225 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LapseRate.g.cs @@ -60,21 +60,21 @@ public LapseRate(double value, LapseRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LapseRateUnit ConversionBaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; + public static LapseRateUnit BaseUnit { get; } = LapseRateUnit.DegreeCelsiusPerKilometer; /// /// Represents the largest possible value of Duration /// - public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, ConversionBaseUnit); + public static LapseRate MaxValue { get; } = new LapseRate(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, ConversionBaseUnit); + public static LapseRate MinValue { get; } = new LapseRate(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LapseRate Zero { get; } = new LapseRate(0, ConversionBaseUnit); + public static LapseRate Zero { get; } = new LapseRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs index e64e698fe3..4310050ddb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Length.g.cs @@ -60,21 +60,21 @@ public Length(double value, LengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LengthUnit ConversionBaseUnit { get; } = LengthUnit.Meter; + public static LengthUnit BaseUnit { get; } = LengthUnit.Meter; /// /// Represents the largest possible value of Duration /// - public static Length MaxValue { get; } = new Length(double.MaxValue, ConversionBaseUnit); + public static Length MaxValue { get; } = new Length(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Length MinValue { get; } = new Length(double.MinValue, ConversionBaseUnit); + public static Length MinValue { get; } = new Length(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Length Zero { get; } = new Length(0, ConversionBaseUnit); + public static Length Zero { get; } = new Length(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs index 7e08980ca1..1ee0c3333f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Level.g.cs @@ -60,21 +60,21 @@ public Level(double value, LevelUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LevelUnit ConversionBaseUnit { get; } = LevelUnit.Decibel; + public static LevelUnit BaseUnit { get; } = LevelUnit.Decibel; /// /// Represents the largest possible value of Duration /// - public static Level MaxValue { get; } = new Level(double.MaxValue, ConversionBaseUnit); + public static Level MaxValue { get; } = new Level(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Level MinValue { get; } = new Level(double.MinValue, ConversionBaseUnit); + public static Level MinValue { get; } = new Level(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Level Zero { get; } = new Level(0, ConversionBaseUnit); + public static Level Zero { get; } = new Level(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs index badd92703a..0f4cdf4517 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearDensity.g.cs @@ -63,21 +63,21 @@ public LinearDensity(double value, LinearDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LinearDensityUnit ConversionBaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; + public static LinearDensityUnit BaseUnit { get; } = LinearDensityUnit.KilogramPerMeter; /// /// Represents the largest possible value of Duration /// - public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, ConversionBaseUnit); + public static LinearDensity MaxValue { get; } = new LinearDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, ConversionBaseUnit); + public static LinearDensity MinValue { get; } = new LinearDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LinearDensity Zero { get; } = new LinearDensity(0, ConversionBaseUnit); + public static LinearDensity Zero { get; } = new LinearDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs index f07158d33d..e6925ddabd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -63,21 +63,21 @@ public LinearPowerDensity(double value, LinearPowerDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LinearPowerDensityUnit ConversionBaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; + public static LinearPowerDensityUnit BaseUnit { get; } = LinearPowerDensityUnit.WattPerMeter; /// /// Represents the largest possible value of Duration /// - public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, ConversionBaseUnit); + public static LinearPowerDensity MaxValue { get; } = new LinearPowerDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, ConversionBaseUnit); + public static LinearPowerDensity MinValue { get; } = new LinearPowerDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, ConversionBaseUnit); + public static LinearPowerDensity Zero { get; } = new LinearPowerDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs index db5f5bf32e..85cb61427a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Luminosity.g.cs @@ -63,21 +63,21 @@ public Luminosity(double value, LuminosityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LuminosityUnit ConversionBaseUnit { get; } = LuminosityUnit.Watt; + public static LuminosityUnit BaseUnit { get; } = LuminosityUnit.Watt; /// /// Represents the largest possible value of Duration /// - public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, ConversionBaseUnit); + public static Luminosity MaxValue { get; } = new Luminosity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, ConversionBaseUnit); + public static Luminosity MinValue { get; } = new Luminosity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Luminosity Zero { get; } = new Luminosity(0, ConversionBaseUnit); + public static Luminosity Zero { get; } = new Luminosity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs index 5fb05e4cc1..42b1b0eb27 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -63,21 +63,21 @@ public LuminousFlux(double value, LuminousFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LuminousFluxUnit ConversionBaseUnit { get; } = LuminousFluxUnit.Lumen; + public static LuminousFluxUnit BaseUnit { get; } = LuminousFluxUnit.Lumen; /// /// Represents the largest possible value of Duration /// - public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, ConversionBaseUnit); + public static LuminousFlux MaxValue { get; } = new LuminousFlux(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, ConversionBaseUnit); + public static LuminousFlux MinValue { get; } = new LuminousFlux(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LuminousFlux Zero { get; } = new LuminousFlux(0, ConversionBaseUnit); + public static LuminousFlux Zero { get; } = new LuminousFlux(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs index 113e45474c..5095f63a96 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -63,21 +63,21 @@ public LuminousIntensity(double value, LuminousIntensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static LuminousIntensityUnit ConversionBaseUnit { get; } = LuminousIntensityUnit.Candela; + public static LuminousIntensityUnit BaseUnit { get; } = LuminousIntensityUnit.Candela; /// /// Represents the largest possible value of Duration /// - public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, ConversionBaseUnit); + public static LuminousIntensity MaxValue { get; } = new LuminousIntensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, ConversionBaseUnit); + public static LuminousIntensity MinValue { get; } = new LuminousIntensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, ConversionBaseUnit); + public static LuminousIntensity Zero { get; } = new LuminousIntensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs index e9bf740bd5..df565b872c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticField.g.cs @@ -63,21 +63,21 @@ public MagneticField(double value, MagneticFieldUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MagneticFieldUnit ConversionBaseUnit { get; } = MagneticFieldUnit.Tesla; + public static MagneticFieldUnit BaseUnit { get; } = MagneticFieldUnit.Tesla; /// /// Represents the largest possible value of Duration /// - public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, ConversionBaseUnit); + public static MagneticField MaxValue { get; } = new MagneticField(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, ConversionBaseUnit); + public static MagneticField MinValue { get; } = new MagneticField(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MagneticField Zero { get; } = new MagneticField(0, ConversionBaseUnit); + public static MagneticField Zero { get; } = new MagneticField(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs index 32e41056ed..b2a2a42a0c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -63,21 +63,21 @@ public MagneticFlux(double value, MagneticFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MagneticFluxUnit ConversionBaseUnit { get; } = MagneticFluxUnit.Weber; + public static MagneticFluxUnit BaseUnit { get; } = MagneticFluxUnit.Weber; /// /// Represents the largest possible value of Duration /// - public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, ConversionBaseUnit); + public static MagneticFlux MaxValue { get; } = new MagneticFlux(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, ConversionBaseUnit); + public static MagneticFlux MinValue { get; } = new MagneticFlux(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MagneticFlux Zero { get; } = new MagneticFlux(0, ConversionBaseUnit); + public static MagneticFlux Zero { get; } = new MagneticFlux(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs index a25126cc42..ffdb4cf185 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Magnetization.g.cs @@ -63,21 +63,21 @@ public Magnetization(double value, MagnetizationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MagnetizationUnit ConversionBaseUnit { get; } = MagnetizationUnit.AmperePerMeter; + public static MagnetizationUnit BaseUnit { get; } = MagnetizationUnit.AmperePerMeter; /// /// Represents the largest possible value of Duration /// - public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, ConversionBaseUnit); + public static Magnetization MaxValue { get; } = new Magnetization(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, ConversionBaseUnit); + public static Magnetization MinValue { get; } = new Magnetization(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Magnetization Zero { get; } = new Magnetization(0, ConversionBaseUnit); + public static Magnetization Zero { get; } = new Magnetization(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs index ebcf4e7a0c..ff283c6b4f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Mass.g.cs @@ -60,21 +60,21 @@ public Mass(double value, MassUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassUnit ConversionBaseUnit { get; } = MassUnit.Kilogram; + public static MassUnit BaseUnit { get; } = MassUnit.Kilogram; /// /// Represents the largest possible value of Duration /// - public static Mass MaxValue { get; } = new Mass(double.MaxValue, ConversionBaseUnit); + public static Mass MaxValue { get; } = new Mass(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Mass MinValue { get; } = new Mass(double.MinValue, ConversionBaseUnit); + public static Mass MinValue { get; } = new Mass(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Mass Zero { get; } = new Mass(0, ConversionBaseUnit); + public static Mass Zero { get; } = new Mass(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs index 5fd6903a0e..2b1dc5f065 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassConcentration.g.cs @@ -63,21 +63,21 @@ public MassConcentration(double value, MassConcentrationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassConcentrationUnit ConversionBaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; + public static MassConcentrationUnit BaseUnit { get; } = MassConcentrationUnit.KilogramPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, ConversionBaseUnit); + public static MassConcentration MaxValue { get; } = new MassConcentration(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, ConversionBaseUnit); + public static MassConcentration MinValue { get; } = new MassConcentration(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassConcentration Zero { get; } = new MassConcentration(0, ConversionBaseUnit); + public static MassConcentration Zero { get; } = new MassConcentration(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs index be0d7a8a8b..fe7f04d271 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlow.g.cs @@ -60,21 +60,21 @@ public MassFlow(double value, MassFlowUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassFlowUnit ConversionBaseUnit { get; } = MassFlowUnit.GramPerSecond; + public static MassFlowUnit BaseUnit { get; } = MassFlowUnit.GramPerSecond; /// /// Represents the largest possible value of Duration /// - public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, ConversionBaseUnit); + public static MassFlow MaxValue { get; } = new MassFlow(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, ConversionBaseUnit); + public static MassFlow MinValue { get; } = new MassFlow(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassFlow Zero { get; } = new MassFlow(0, ConversionBaseUnit); + public static MassFlow Zero { get; } = new MassFlow(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs index b22220235b..d5531a5480 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFlux.g.cs @@ -60,21 +60,21 @@ public MassFlux(double value, MassFluxUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassFluxUnit ConversionBaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; + public static MassFluxUnit BaseUnit { get; } = MassFluxUnit.KilogramPerSecondPerSquareMeter; /// /// Represents the largest possible value of Duration /// - public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, ConversionBaseUnit); + public static MassFlux MaxValue { get; } = new MassFlux(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, ConversionBaseUnit); + public static MassFlux MinValue { get; } = new MassFlux(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassFlux Zero { get; } = new MassFlux(0, ConversionBaseUnit); + public static MassFlux Zero { get; } = new MassFlux(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs index 2044ac2ee3..ba4f7935a0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassFraction.g.cs @@ -63,21 +63,21 @@ public MassFraction(double value, MassFractionUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassFractionUnit ConversionBaseUnit { get; } = MassFractionUnit.DecimalFraction; + public static MassFractionUnit BaseUnit { get; } = MassFractionUnit.DecimalFraction; /// /// Represents the largest possible value of Duration /// - public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, ConversionBaseUnit); + public static MassFraction MaxValue { get; } = new MassFraction(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, ConversionBaseUnit); + public static MassFraction MinValue { get; } = new MassFraction(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassFraction Zero { get; } = new MassFraction(0, ConversionBaseUnit); + public static MassFraction Zero { get; } = new MassFraction(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 69dc6dd481..bc8ae81cd1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -60,21 +60,21 @@ public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MassMomentOfInertiaUnit ConversionBaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; + public static MassMomentOfInertiaUnit BaseUnit { get; } = MassMomentOfInertiaUnit.KilogramSquareMeter; /// /// Represents the largest possible value of Duration /// - public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, ConversionBaseUnit); + public static MassMomentOfInertia MaxValue { get; } = new MassMomentOfInertia(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, ConversionBaseUnit); + public static MassMomentOfInertia MinValue { get; } = new MassMomentOfInertia(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, ConversionBaseUnit); + public static MassMomentOfInertia Zero { get; } = new MassMomentOfInertia(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs index fc159b70c1..4806c771e1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -60,21 +60,21 @@ public MolarEnergy(double value, MolarEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarEnergyUnit ConversionBaseUnit { get; } = MolarEnergyUnit.JoulePerMole; + public static MolarEnergyUnit BaseUnit { get; } = MolarEnergyUnit.JoulePerMole; /// /// Represents the largest possible value of Duration /// - public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, ConversionBaseUnit); + public static MolarEnergy MaxValue { get; } = new MolarEnergy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, ConversionBaseUnit); + public static MolarEnergy MinValue { get; } = new MolarEnergy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MolarEnergy Zero { get; } = new MolarEnergy(0, ConversionBaseUnit); + public static MolarEnergy Zero { get; } = new MolarEnergy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs index 8b08c53f6a..89a76290b7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -60,21 +60,21 @@ public MolarEntropy(double value, MolarEntropyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarEntropyUnit ConversionBaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; + public static MolarEntropyUnit BaseUnit { get; } = MolarEntropyUnit.JoulePerMoleKelvin; /// /// Represents the largest possible value of Duration /// - public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, ConversionBaseUnit); + public static MolarEntropy MaxValue { get; } = new MolarEntropy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, ConversionBaseUnit); + public static MolarEntropy MinValue { get; } = new MolarEntropy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MolarEntropy Zero { get; } = new MolarEntropy(0, ConversionBaseUnit); + public static MolarEntropy Zero { get; } = new MolarEntropy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs index 771ee65e2d..af1c5c06f3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/MolarMass.g.cs @@ -60,21 +60,21 @@ public MolarMass(double value, MolarMassUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarMassUnit ConversionBaseUnit { get; } = MolarMassUnit.KilogramPerMole; + public static MolarMassUnit BaseUnit { get; } = MolarMassUnit.KilogramPerMole; /// /// Represents the largest possible value of Duration /// - public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, ConversionBaseUnit); + public static MolarMass MaxValue { get; } = new MolarMass(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, ConversionBaseUnit); + public static MolarMass MinValue { get; } = new MolarMass(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static MolarMass Zero { get; } = new MolarMass(0, ConversionBaseUnit); + public static MolarMass Zero { get; } = new MolarMass(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs index 9f3dd7caee..912d53a9b4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Molarity.g.cs @@ -63,21 +63,21 @@ public Molarity(double value, MolarityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static MolarityUnit ConversionBaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; + public static MolarityUnit BaseUnit { get; } = MolarityUnit.MolesPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, ConversionBaseUnit); + public static Molarity MaxValue { get; } = new Molarity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Molarity MinValue { get; } = new Molarity(double.MinValue, ConversionBaseUnit); + public static Molarity MinValue { get; } = new Molarity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Molarity Zero { get; } = new Molarity(0, ConversionBaseUnit); + public static Molarity Zero { get; } = new Molarity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs index df87d75cb5..65743c0e5c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permeability.g.cs @@ -63,21 +63,21 @@ public Permeability(double value, PermeabilityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PermeabilityUnit ConversionBaseUnit { get; } = PermeabilityUnit.HenryPerMeter; + public static PermeabilityUnit BaseUnit { get; } = PermeabilityUnit.HenryPerMeter; /// /// Represents the largest possible value of Duration /// - public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, ConversionBaseUnit); + public static Permeability MaxValue { get; } = new Permeability(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Permeability MinValue { get; } = new Permeability(double.MinValue, ConversionBaseUnit); + public static Permeability MinValue { get; } = new Permeability(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Permeability Zero { get; } = new Permeability(0, ConversionBaseUnit); + public static Permeability Zero { get; } = new Permeability(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs index fbc4d428f9..956502a4b5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Permittivity.g.cs @@ -63,21 +63,21 @@ public Permittivity(double value, PermittivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PermittivityUnit ConversionBaseUnit { get; } = PermittivityUnit.FaradPerMeter; + public static PermittivityUnit BaseUnit { get; } = PermittivityUnit.FaradPerMeter; /// /// Represents the largest possible value of Duration /// - public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, ConversionBaseUnit); + public static Permittivity MaxValue { get; } = new Permittivity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, ConversionBaseUnit); + public static Permittivity MinValue { get; } = new Permittivity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Permittivity Zero { get; } = new Permittivity(0, ConversionBaseUnit); + public static Permittivity Zero { get; } = new Permittivity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index b41950408d..67c8d362bb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -60,21 +60,21 @@ public Power(double value, PowerUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PowerUnit ConversionBaseUnit { get; } = PowerUnit.Watt; + public static PowerUnit BaseUnit { get; } = PowerUnit.Watt; /// /// Represents the largest possible value of Duration /// - public static Power MaxValue { get; } = new Power(79228162514264337593543950335d, ConversionBaseUnit); + public static Power MaxValue { get; } = new Power(79228162514264337593543950335d, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Power MinValue { get; } = new Power(-79228162514264337593543950335d, ConversionBaseUnit); + public static Power MinValue { get; } = new Power(-79228162514264337593543950335d, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Power Zero { get; } = new Power(0, ConversionBaseUnit); + public static Power Zero { get; } = new Power(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs index 708f3986cf..dfc69462fa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerDensity.g.cs @@ -60,21 +60,21 @@ public PowerDensity(double value, PowerDensityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PowerDensityUnit ConversionBaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; + public static PowerDensityUnit BaseUnit { get; } = PowerDensityUnit.WattPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, ConversionBaseUnit); + public static PowerDensity MaxValue { get; } = new PowerDensity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, ConversionBaseUnit); + public static PowerDensity MinValue { get; } = new PowerDensity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static PowerDensity Zero { get; } = new PowerDensity(0, ConversionBaseUnit); + public static PowerDensity Zero { get; } = new PowerDensity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs index 2f58ed1c0f..03af5cc0de 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PowerRatio.g.cs @@ -60,21 +60,21 @@ public PowerRatio(double value, PowerRatioUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PowerRatioUnit ConversionBaseUnit { get; } = PowerRatioUnit.DecibelWatt; + public static PowerRatioUnit BaseUnit { get; } = PowerRatioUnit.DecibelWatt; /// /// Represents the largest possible value of Duration /// - public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, ConversionBaseUnit); + public static PowerRatio MaxValue { get; } = new PowerRatio(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, ConversionBaseUnit); + public static PowerRatio MinValue { get; } = new PowerRatio(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static PowerRatio Zero { get; } = new PowerRatio(0, ConversionBaseUnit); + public static PowerRatio Zero { get; } = new PowerRatio(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs index 640ab490b9..4b13061ee4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs @@ -60,21 +60,21 @@ public Pressure(double value, PressureUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PressureUnit ConversionBaseUnit { get; } = PressureUnit.Pascal; + public static PressureUnit BaseUnit { get; } = PressureUnit.Pascal; /// /// Represents the largest possible value of Duration /// - public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, ConversionBaseUnit); + public static Pressure MaxValue { get; } = new Pressure(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Pressure MinValue { get; } = new Pressure(double.MinValue, ConversionBaseUnit); + public static Pressure MinValue { get; } = new Pressure(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Pressure Zero { get; } = new Pressure(0, ConversionBaseUnit); + public static Pressure Zero { get; } = new Pressure(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs index d28a02317c..46e35cc81d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -60,21 +60,21 @@ public PressureChangeRate(double value, PressureChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static PressureChangeRateUnit ConversionBaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; + public static PressureChangeRateUnit BaseUnit { get; } = PressureChangeRateUnit.PascalPerSecond; /// /// Represents the largest possible value of Duration /// - public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, ConversionBaseUnit); + public static PressureChangeRate MaxValue { get; } = new PressureChangeRate(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, ConversionBaseUnit); + public static PressureChangeRate MinValue { get; } = new PressureChangeRate(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, ConversionBaseUnit); + public static PressureChangeRate Zero { get; } = new PressureChangeRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs index b50c2c3dec..fcdc6e0316 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Ratio.g.cs @@ -60,21 +60,21 @@ public Ratio(double value, RatioUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RatioUnit ConversionBaseUnit { get; } = RatioUnit.DecimalFraction; + public static RatioUnit BaseUnit { get; } = RatioUnit.DecimalFraction; /// /// Represents the largest possible value of Duration /// - public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, ConversionBaseUnit); + public static Ratio MaxValue { get; } = new Ratio(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Ratio MinValue { get; } = new Ratio(double.MinValue, ConversionBaseUnit); + public static Ratio MinValue { get; } = new Ratio(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Ratio Zero { get; } = new Ratio(0, ConversionBaseUnit); + public static Ratio Zero { get; } = new Ratio(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs index dad2208e98..a918d231d1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -60,21 +60,21 @@ public RatioChangeRate(double value, RatioChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RatioChangeRateUnit ConversionBaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; + public static RatioChangeRateUnit BaseUnit { get; } = RatioChangeRateUnit.DecimalFractionPerSecond; /// /// Represents the largest possible value of Duration /// - public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, ConversionBaseUnit); + public static RatioChangeRate MaxValue { get; } = new RatioChangeRate(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, ConversionBaseUnit); + public static RatioChangeRate MinValue { get; } = new RatioChangeRate(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, ConversionBaseUnit); + public static RatioChangeRate Zero { get; } = new RatioChangeRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 3b39ca6765..755cab2ff7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -60,21 +60,21 @@ public ReactiveEnergy(double value, ReactiveEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReactiveEnergyUnit ConversionBaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; + public static ReactiveEnergyUnit BaseUnit { get; } = ReactiveEnergyUnit.VoltampereReactiveHour; /// /// Represents the largest possible value of Duration /// - public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, ConversionBaseUnit); + public static ReactiveEnergy MaxValue { get; } = new ReactiveEnergy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, ConversionBaseUnit); + public static ReactiveEnergy MinValue { get; } = new ReactiveEnergy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, ConversionBaseUnit); + public static ReactiveEnergy Zero { get; } = new ReactiveEnergy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs index 9806533a22..0928a01487 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReactivePower.g.cs @@ -60,21 +60,21 @@ public ReactivePower(double value, ReactivePowerUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReactivePowerUnit ConversionBaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; + public static ReactivePowerUnit BaseUnit { get; } = ReactivePowerUnit.VoltampereReactive; /// /// Represents the largest possible value of Duration /// - public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, ConversionBaseUnit); + public static ReactivePower MaxValue { get; } = new ReactivePower(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, ConversionBaseUnit); + public static ReactivePower MinValue { get; } = new ReactivePower(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReactivePower Zero { get; } = new ReactivePower(0, ConversionBaseUnit); + public static ReactivePower Zero { get; } = new ReactivePower(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs index 4f6f5e81b0..82a5bd986b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -63,21 +63,21 @@ public ReciprocalArea(double value, ReciprocalAreaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReciprocalAreaUnit ConversionBaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; + public static ReciprocalAreaUnit BaseUnit { get; } = ReciprocalAreaUnit.InverseSquareMeter; /// /// Represents the largest possible value of Duration /// - public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, ConversionBaseUnit); + public static ReciprocalArea MaxValue { get; } = new ReciprocalArea(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, ConversionBaseUnit); + public static ReciprocalArea MinValue { get; } = new ReciprocalArea(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, ConversionBaseUnit); + public static ReciprocalArea Zero { get; } = new ReciprocalArea(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs index fdad8374d7..3cfdcc453b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -63,21 +63,21 @@ public ReciprocalLength(double value, ReciprocalLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ReciprocalLengthUnit ConversionBaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; + public static ReciprocalLengthUnit BaseUnit { get; } = ReciprocalLengthUnit.InverseMeter; /// /// Represents the largest possible value of Duration /// - public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, ConversionBaseUnit); + public static ReciprocalLength MaxValue { get; } = new ReciprocalLength(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, ConversionBaseUnit); + public static ReciprocalLength MinValue { get; } = new ReciprocalLength(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, ConversionBaseUnit); + public static ReciprocalLength Zero { get; } = new ReciprocalLength(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs index b88f20b22e..31cbe1cb80 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -60,21 +60,21 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RelativeHumidityUnit ConversionBaseUnit { get; } = RelativeHumidityUnit.Percent; + public static RelativeHumidityUnit BaseUnit { get; } = RelativeHumidityUnit.Percent; /// /// Represents the largest possible value of Duration /// - public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, ConversionBaseUnit); + public static RelativeHumidity MaxValue { get; } = new RelativeHumidity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, ConversionBaseUnit); + public static RelativeHumidity MinValue { get; } = new RelativeHumidity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, ConversionBaseUnit); + public static RelativeHumidity Zero { get; } = new RelativeHumidity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 6220115730..688284d93c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -60,21 +60,21 @@ public RotationalAcceleration(double value, RotationalAccelerationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalAccelerationUnit ConversionBaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; + public static RotationalAccelerationUnit BaseUnit { get; } = RotationalAccelerationUnit.RadianPerSecondSquared; /// /// Represents the largest possible value of Duration /// - public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, ConversionBaseUnit); + public static RotationalAcceleration MaxValue { get; } = new RotationalAcceleration(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, ConversionBaseUnit); + public static RotationalAcceleration MinValue { get; } = new RotationalAcceleration(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, ConversionBaseUnit); + public static RotationalAcceleration Zero { get; } = new RotationalAcceleration(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs index 103ca82edb..ff1d7a7b9b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -60,21 +60,21 @@ public RotationalSpeed(double value, RotationalSpeedUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalSpeedUnit ConversionBaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; + public static RotationalSpeedUnit BaseUnit { get; } = RotationalSpeedUnit.RadianPerSecond; /// /// Represents the largest possible value of Duration /// - public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, ConversionBaseUnit); + public static RotationalSpeed MaxValue { get; } = new RotationalSpeed(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, ConversionBaseUnit); + public static RotationalSpeed MinValue { get; } = new RotationalSpeed(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, ConversionBaseUnit); + public static RotationalSpeed Zero { get; } = new RotationalSpeed(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs index 9fb984fd5b..357b9df4cc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -60,21 +60,21 @@ public RotationalStiffness(double value, RotationalStiffnessUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalStiffnessUnit ConversionBaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; + public static RotationalStiffnessUnit BaseUnit { get; } = RotationalStiffnessUnit.NewtonMeterPerRadian; /// /// Represents the largest possible value of Duration /// - public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, ConversionBaseUnit); + public static RotationalStiffness MaxValue { get; } = new RotationalStiffness(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, ConversionBaseUnit); + public static RotationalStiffness MinValue { get; } = new RotationalStiffness(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, ConversionBaseUnit); + public static RotationalStiffness Zero { get; } = new RotationalStiffness(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index a0c9bd6d60..04df8bc714 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -60,21 +60,21 @@ public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUn /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static RotationalStiffnessPerLengthUnit ConversionBaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; + public static RotationalStiffnessPerLengthUnit BaseUnit { get; } = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; /// /// Represents the largest possible value of Duration /// - public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, ConversionBaseUnit); + public static RotationalStiffnessPerLength MaxValue { get; } = new RotationalStiffnessPerLength(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, ConversionBaseUnit); + public static RotationalStiffnessPerLength MinValue { get; } = new RotationalStiffnessPerLength(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, ConversionBaseUnit); + public static RotationalStiffnessPerLength Zero { get; } = new RotationalStiffnessPerLength(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs index dff884f280..3921c8e64c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Scalar.g.cs @@ -60,21 +60,21 @@ public Scalar(double value, ScalarUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ScalarUnit ConversionBaseUnit { get; } = ScalarUnit.Amount; + public static ScalarUnit BaseUnit { get; } = ScalarUnit.Amount; /// /// Represents the largest possible value of Duration /// - public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, ConversionBaseUnit); + public static Scalar MaxValue { get; } = new Scalar(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Scalar MinValue { get; } = new Scalar(double.MinValue, ConversionBaseUnit); + public static Scalar MinValue { get; } = new Scalar(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Scalar Zero { get; } = new Scalar(0, ConversionBaseUnit); + public static Scalar Zero { get; } = new Scalar(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs index 4f26b53b3b..4027060780 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SolidAngle.g.cs @@ -63,21 +63,21 @@ public SolidAngle(double value, SolidAngleUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SolidAngleUnit ConversionBaseUnit { get; } = SolidAngleUnit.Steradian; + public static SolidAngleUnit BaseUnit { get; } = SolidAngleUnit.Steradian; /// /// Represents the largest possible value of Duration /// - public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, ConversionBaseUnit); + public static SolidAngle MaxValue { get; } = new SolidAngle(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, ConversionBaseUnit); + public static SolidAngle MinValue { get; } = new SolidAngle(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SolidAngle Zero { get; } = new SolidAngle(0, ConversionBaseUnit); + public static SolidAngle Zero { get; } = new SolidAngle(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs index 7de56dcb7e..5ea946369e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -63,21 +63,21 @@ public SpecificEnergy(double value, SpecificEnergyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificEnergyUnit ConversionBaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; + public static SpecificEnergyUnit BaseUnit { get; } = SpecificEnergyUnit.JoulePerKilogram; /// /// Represents the largest possible value of Duration /// - public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, ConversionBaseUnit); + public static SpecificEnergy MaxValue { get; } = new SpecificEnergy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, ConversionBaseUnit); + public static SpecificEnergy MinValue { get; } = new SpecificEnergy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, ConversionBaseUnit); + public static SpecificEnergy Zero { get; } = new SpecificEnergy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs index 8a41ecd236..c4b7d5c870 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -60,21 +60,21 @@ public SpecificEntropy(double value, SpecificEntropyUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificEntropyUnit ConversionBaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; + public static SpecificEntropyUnit BaseUnit { get; } = SpecificEntropyUnit.JoulePerKilogramKelvin; /// /// Represents the largest possible value of Duration /// - public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, ConversionBaseUnit); + public static SpecificEntropy MaxValue { get; } = new SpecificEntropy(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, ConversionBaseUnit); + public static SpecificEntropy MinValue { get; } = new SpecificEntropy(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, ConversionBaseUnit); + public static SpecificEntropy Zero { get; } = new SpecificEntropy(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 44955da03b..a025518be0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -63,21 +63,21 @@ public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificFuelConsumptionUnit ConversionBaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; + public static SpecificFuelConsumptionUnit BaseUnit { get; } = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; /// /// Represents the largest possible value of Duration /// - public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, ConversionBaseUnit); + public static SpecificFuelConsumption MaxValue { get; } = new SpecificFuelConsumption(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, ConversionBaseUnit); + public static SpecificFuelConsumption MinValue { get; } = new SpecificFuelConsumption(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, ConversionBaseUnit); + public static SpecificFuelConsumption Zero { get; } = new SpecificFuelConsumption(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs index 33dbbac149..4e4d578411 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -60,21 +60,21 @@ public SpecificVolume(double value, SpecificVolumeUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificVolumeUnit ConversionBaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; + public static SpecificVolumeUnit BaseUnit { get; } = SpecificVolumeUnit.CubicMeterPerKilogram; /// /// Represents the largest possible value of Duration /// - public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, ConversionBaseUnit); + public static SpecificVolume MaxValue { get; } = new SpecificVolume(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, ConversionBaseUnit); + public static SpecificVolume MinValue { get; } = new SpecificVolume(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificVolume Zero { get; } = new SpecificVolume(0, ConversionBaseUnit); + public static SpecificVolume Zero { get; } = new SpecificVolume(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs index 4a22c775bf..cf2de3ee8c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -63,21 +63,21 @@ public SpecificWeight(double value, SpecificWeightUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpecificWeightUnit ConversionBaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; + public static SpecificWeightUnit BaseUnit { get; } = SpecificWeightUnit.NewtonPerCubicMeter; /// /// Represents the largest possible value of Duration /// - public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, ConversionBaseUnit); + public static SpecificWeight MaxValue { get; } = new SpecificWeight(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, ConversionBaseUnit); + public static SpecificWeight MinValue { get; } = new SpecificWeight(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static SpecificWeight Zero { get; } = new SpecificWeight(0, ConversionBaseUnit); + public static SpecificWeight Zero { get; } = new SpecificWeight(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs index 37f45f13d2..5fab885936 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Speed.g.cs @@ -60,21 +60,21 @@ public Speed(double value, SpeedUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static SpeedUnit ConversionBaseUnit { get; } = SpeedUnit.MeterPerSecond; + public static SpeedUnit BaseUnit { get; } = SpeedUnit.MeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static Speed MaxValue { get; } = new Speed(double.MaxValue, ConversionBaseUnit); + public static Speed MaxValue { get; } = new Speed(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Speed MinValue { get; } = new Speed(double.MinValue, ConversionBaseUnit); + public static Speed MinValue { get; } = new Speed(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Speed Zero { get; } = new Speed(0, ConversionBaseUnit); + public static Speed Zero { get; } = new Speed(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index bdc7a9d536..02561d73e1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -60,21 +60,21 @@ public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static StandardVolumeFlowUnit ConversionBaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; + public static StandardVolumeFlowUnit BaseUnit { get; } = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, ConversionBaseUnit); + public static StandardVolumeFlow MaxValue { get; } = new StandardVolumeFlow(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, ConversionBaseUnit); + public static StandardVolumeFlow MinValue { get; } = new StandardVolumeFlow(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, ConversionBaseUnit); + public static StandardVolumeFlow Zero { get; } = new StandardVolumeFlow(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs index 267721e761..9f8adcb7fc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Temperature.g.cs @@ -60,21 +60,21 @@ public Temperature(double value, TemperatureUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TemperatureUnit ConversionBaseUnit { get; } = TemperatureUnit.Kelvin; + public static TemperatureUnit BaseUnit { get; } = TemperatureUnit.Kelvin; /// /// Represents the largest possible value of Duration /// - public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, ConversionBaseUnit); + public static Temperature MaxValue { get; } = new Temperature(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Temperature MinValue { get; } = new Temperature(double.MinValue, ConversionBaseUnit); + public static Temperature MinValue { get; } = new Temperature(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Temperature Zero { get; } = new Temperature(0, ConversionBaseUnit); + public static Temperature Zero { get; } = new Temperature(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index fb1652b96b..66ebd57ecd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -60,21 +60,21 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TemperatureChangeRateUnit ConversionBaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; + public static TemperatureChangeRateUnit BaseUnit { get; } = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; /// /// Represents the largest possible value of Duration /// - public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, ConversionBaseUnit); + public static TemperatureChangeRate MaxValue { get; } = new TemperatureChangeRate(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, ConversionBaseUnit); + public static TemperatureChangeRate MinValue { get; } = new TemperatureChangeRate(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, ConversionBaseUnit); + public static TemperatureChangeRate Zero { get; } = new TemperatureChangeRate(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs index 74b6b7a7f2..bb4c823483 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -60,21 +60,21 @@ public TemperatureDelta(double value, TemperatureDeltaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TemperatureDeltaUnit ConversionBaseUnit { get; } = TemperatureDeltaUnit.Kelvin; + public static TemperatureDeltaUnit BaseUnit { get; } = TemperatureDeltaUnit.Kelvin; /// /// Represents the largest possible value of Duration /// - public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, ConversionBaseUnit); + public static TemperatureDelta MaxValue { get; } = new TemperatureDelta(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, ConversionBaseUnit); + public static TemperatureDelta MinValue { get; } = new TemperatureDelta(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, ConversionBaseUnit); + public static TemperatureDelta Zero { get; } = new TemperatureDelta(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs index d7e669c3bd..220fb38230 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -24,7 +24,7 @@ namespace UnitsNet { /// /// - /// The rate of change of temperature with displacement in a given direction (as with increase of height) + /// /// public struct TemperatureGradient { @@ -145,7 +145,7 @@ public static TemperatureGradient From(double value, TemperatureGradientUnit fro /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureGradientUnit unit) => GetValueAs(unit); + public double As(TemperatureGradientUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -153,12 +153,10 @@ public static TemperatureGradient From(double value, TemperatureGradientUnit fro /// A Duration with the specified unit. public TemperatureGradient ToUnit(TemperatureGradientUnit unit) { - var convertedValue = GetValueAs(unit); return new TemperatureGradient(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs index a485c0ece0..9b302699a0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -63,21 +63,21 @@ public ThermalConductivity(double value, ThermalConductivityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ThermalConductivityUnit ConversionBaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; + public static ThermalConductivityUnit BaseUnit { get; } = ThermalConductivityUnit.WattPerMeterKelvin; /// /// Represents the largest possible value of Duration /// - public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, ConversionBaseUnit); + public static ThermalConductivity MaxValue { get; } = new ThermalConductivity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, ConversionBaseUnit); + public static ThermalConductivity MinValue { get; } = new ThermalConductivity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, ConversionBaseUnit); + public static ThermalConductivity Zero { get; } = new ThermalConductivity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs index 1b6ce040c2..2ea60eaabf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -60,21 +60,21 @@ public ThermalResistance(double value, ThermalResistanceUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static ThermalResistanceUnit ConversionBaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; + public static ThermalResistanceUnit BaseUnit { get; } = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; /// /// Represents the largest possible value of Duration /// - public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, ConversionBaseUnit); + public static ThermalResistance MaxValue { get; } = new ThermalResistance(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, ConversionBaseUnit); + public static ThermalResistance MinValue { get; } = new ThermalResistance(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static ThermalResistance Zero { get; } = new ThermalResistance(0, ConversionBaseUnit); + public static ThermalResistance Zero { get; } = new ThermalResistance(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs index 1e2c050f88..271e61c99c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Torque.g.cs @@ -60,21 +60,21 @@ public Torque(double value, TorqueUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TorqueUnit ConversionBaseUnit { get; } = TorqueUnit.NewtonMeter; + public static TorqueUnit BaseUnit { get; } = TorqueUnit.NewtonMeter; /// /// Represents the largest possible value of Duration /// - public static Torque MaxValue { get; } = new Torque(double.MaxValue, ConversionBaseUnit); + public static Torque MaxValue { get; } = new Torque(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Torque MinValue { get; } = new Torque(double.MinValue, ConversionBaseUnit); + public static Torque MinValue { get; } = new Torque(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Torque Zero { get; } = new Torque(0, ConversionBaseUnit); + public static Torque Zero { get; } = new Torque(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs index 07100acd54..47c6976e31 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -60,21 +60,21 @@ public TorquePerLength(double value, TorquePerLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TorquePerLengthUnit ConversionBaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; + public static TorquePerLengthUnit BaseUnit { get; } = TorquePerLengthUnit.NewtonMeterPerMeter; /// /// Represents the largest possible value of Duration /// - public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, ConversionBaseUnit); + public static TorquePerLength MaxValue { get; } = new TorquePerLength(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, ConversionBaseUnit); + public static TorquePerLength MinValue { get; } = new TorquePerLength(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static TorquePerLength Zero { get; } = new TorquePerLength(0, ConversionBaseUnit); + public static TorquePerLength Zero { get; } = new TorquePerLength(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs index cf832215b5..858e3190d3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Turbidity.g.cs @@ -63,21 +63,21 @@ public Turbidity(double value, TurbidityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static TurbidityUnit ConversionBaseUnit { get; } = TurbidityUnit.NTU; + public static TurbidityUnit BaseUnit { get; } = TurbidityUnit.NTU; /// /// Represents the largest possible value of Duration /// - public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, ConversionBaseUnit); + public static Turbidity MaxValue { get; } = new Turbidity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, ConversionBaseUnit); + public static Turbidity MinValue { get; } = new Turbidity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Turbidity Zero { get; } = new Turbidity(0, ConversionBaseUnit); + public static Turbidity Zero { get; } = new Turbidity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs index 4cd3af8af2..df06654ece 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VitaminA.g.cs @@ -60,21 +60,21 @@ public VitaminA(double value, VitaminAUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VitaminAUnit ConversionBaseUnit { get; } = VitaminAUnit.InternationalUnit; + public static VitaminAUnit BaseUnit { get; } = VitaminAUnit.InternationalUnit; /// /// Represents the largest possible value of Duration /// - public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, ConversionBaseUnit); + public static VitaminA MaxValue { get; } = new VitaminA(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, ConversionBaseUnit); + public static VitaminA MinValue { get; } = new VitaminA(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VitaminA Zero { get; } = new VitaminA(0, ConversionBaseUnit); + public static VitaminA Zero { get; } = new VitaminA(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs index 89b6f3c9e3..a8a5214703 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Volume.g.cs @@ -60,21 +60,21 @@ public Volume(double value, VolumeUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumeUnit ConversionBaseUnit { get; } = VolumeUnit.CubicMeter; + public static VolumeUnit BaseUnit { get; } = VolumeUnit.CubicMeter; /// /// Represents the largest possible value of Duration /// - public static Volume MaxValue { get; } = new Volume(double.MaxValue, ConversionBaseUnit); + public static Volume MaxValue { get; } = new Volume(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static Volume MinValue { get; } = new Volume(double.MinValue, ConversionBaseUnit); + public static Volume MinValue { get; } = new Volume(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static Volume Zero { get; } = new Volume(0, ConversionBaseUnit); + public static Volume Zero { get; } = new Volume(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs index 6c68dd64ed..f4f3931526 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -63,21 +63,21 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumeConcentrationUnit ConversionBaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; + public static VolumeConcentrationUnit BaseUnit { get; } = VolumeConcentrationUnit.DecimalFraction; /// /// Represents the largest possible value of Duration /// - public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, ConversionBaseUnit); + public static VolumeConcentration MaxValue { get; } = new VolumeConcentration(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, ConversionBaseUnit); + public static VolumeConcentration MinValue { get; } = new VolumeConcentration(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, ConversionBaseUnit); + public static VolumeConcentration Zero { get; } = new VolumeConcentration(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs index fbbf02defc..3c7c5272bf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -60,21 +60,21 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumeFlowUnit ConversionBaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; + public static VolumeFlowUnit BaseUnit { get; } = VolumeFlowUnit.CubicMeterPerSecond; /// /// Represents the largest possible value of Duration /// - public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, ConversionBaseUnit); + public static VolumeFlow MaxValue { get; } = new VolumeFlow(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, ConversionBaseUnit); + public static VolumeFlow MinValue { get; } = new VolumeFlow(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumeFlow Zero { get; } = new VolumeFlow(0, ConversionBaseUnit); + public static VolumeFlow Zero { get; } = new VolumeFlow(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 0ca23a6a9b..77253cc19a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -24,7 +24,7 @@ namespace UnitsNet { /// /// - /// The volumetric flow rate per area is the volume of fluid which passes through a given unit surface area per unit time. + /// /// public struct VolumeFlowPerArea { @@ -123,7 +123,7 @@ public static VolumeFlowPerArea From(double value, VolumeFlowPerAreaUnit fromUni /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowPerAreaUnit unit) => GetValueAs(unit); + public double As(VolumeFlowPerAreaUnit unit) => GetValueAs(unit); /// /// Converts this Duration to another Duration with the unit representation . @@ -131,12 +131,10 @@ public static VolumeFlowPerArea From(double value, VolumeFlowPerAreaUnit fromUni /// A Duration with the specified unit. public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit) { - var convertedValue = GetValueAs(unit); return new VolumeFlowPerArea(convertedValue, unit); } - /// /// Converts the current value + unit to the base unit. /// This is typically the first step in converting from one unit to another. diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs index 36dd77870f..8debc1b867 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -60,21 +60,21 @@ public VolumePerLength(double value, VolumePerLengthUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumePerLengthUnit ConversionBaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; + public static VolumePerLengthUnit BaseUnit { get; } = VolumePerLengthUnit.CubicMeterPerMeter; /// /// Represents the largest possible value of Duration /// - public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, ConversionBaseUnit); + public static VolumePerLength MaxValue { get; } = new VolumePerLength(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, ConversionBaseUnit); + public static VolumePerLength MinValue { get; } = new VolumePerLength(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumePerLength Zero { get; } = new VolumePerLength(0, ConversionBaseUnit); + public static VolumePerLength Zero { get; } = new VolumePerLength(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 6444462d88..dba984b206 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -63,21 +63,21 @@ public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static VolumetricHeatCapacityUnit ConversionBaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; + public static VolumetricHeatCapacityUnit BaseUnit { get; } = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; /// /// Represents the largest possible value of Duration /// - public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, ConversionBaseUnit); + public static VolumetricHeatCapacity MaxValue { get; } = new VolumetricHeatCapacity(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, ConversionBaseUnit); + public static VolumetricHeatCapacity MinValue { get; } = new VolumetricHeatCapacity(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, ConversionBaseUnit); + public static VolumetricHeatCapacity Zero { get; } = new VolumetricHeatCapacity(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 4634701b08..6c4a1f49ba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -60,21 +60,21 @@ public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) /// /// The base unit of Duration, which is Second. All conversions go via this value. /// - public static WarpingMomentOfInertiaUnit ConversionBaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; + public static WarpingMomentOfInertiaUnit BaseUnit { get; } = WarpingMomentOfInertiaUnit.MeterToTheSixth; /// /// Represents the largest possible value of Duration /// - public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, ConversionBaseUnit); + public static WarpingMomentOfInertia MaxValue { get; } = new WarpingMomentOfInertia(double.MaxValue, BaseUnit); /// /// Represents the smallest possible value of Duration /// - public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, ConversionBaseUnit); + public static WarpingMomentOfInertia MinValue { get; } = new WarpingMomentOfInertia(double.MinValue, BaseUnit); /// /// Gets an instance of this quantity with a value of 0 in the base unit Second. /// - public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, ConversionBaseUnit); + public static WarpingMomentOfInertia Zero { get; } = new WarpingMomentOfInertia(0, BaseUnit); #region Conversion Properties /// diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index 6c4b20b5e9..60ece765c9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -17,7 +17,7 @@ en-US nanoframework ratio unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index b40933a6c2..7e0b56564a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework ratiochangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index ad46b7b1f0..eba7e099ae 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework reactiveenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 4eb803531a..7916e78ac8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -17,7 +17,7 @@ en-US nanoframework reactivepower unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index 1290ce7df4..2f76b03223 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -17,7 +17,7 @@ en-US nanoframework reciprocalarea unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index e886a67dd3..2725557426 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -17,7 +17,7 @@ en-US nanoframework reciprocallength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index d5a7d116eb..98e49e5bc1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework relativehumidity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index c17f3a5aab..74d807fe0c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -17,7 +17,7 @@ en-US nanoframework rotationalacceleration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index 8a1bc126f4..a79097ea8b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -17,7 +17,7 @@ en-US nanoframework rotationalspeed unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 7e6f09861e..4e4b18af9c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -17,7 +17,7 @@ en-US nanoframework rotationalstiffness unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index 9769c9b93c..d5f36020cc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -17,7 +17,7 @@ en-US nanoframework rotationalstiffnessperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index 9f2896e6b7..70b9143e4d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -17,7 +17,7 @@ en-US nanoframework scalar unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 001eb8ed44..3442cde919 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -17,7 +17,7 @@ en-US nanoframework solidangle unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 2dcf9d548e..d23bdce654 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework specificenergy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index 49c2e0e323..3648c1980e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -17,7 +17,7 @@ en-US nanoframework specificentropy unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index d5dcc278cc..9f57cae0ec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -17,7 +17,7 @@ en-US nanoframework specificfuelconsumption unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index 42f8fdbcd1..7f6e2cc9ab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -17,7 +17,7 @@ en-US nanoframework specificvolume unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 4cfbcfeb5b..8b29474ceb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -17,7 +17,7 @@ en-US nanoframework specificweight unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index ef2db2ee9d..a85c9fbe15 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -17,7 +17,7 @@ en-US nanoframework speed unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 10092b6e10..4bd5bed311 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -17,7 +17,7 @@ en-US nanoframework standardvolumeflow unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index 870f5b206f..5d14df7635 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -17,7 +17,7 @@ en-US nanoframework temperature unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 4a342fd5d5..46c2af71bf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -17,7 +17,7 @@ en-US nanoframework temperaturechangerate unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 58f63f369a..be70f7be97 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -17,7 +17,7 @@ en-US nanoframework temperaturedelta unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec index 835a9d54c4..c399aaf38a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureGradient - 4.117.0 + 5.0.0-alpha003 Units.NET TemperatureGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component temperaturegradient + nanoframework temperaturegradient unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index 6d1b194e63..93ee115ce9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework thermalconductivity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index b9fc4a2c1c..98570096a9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -17,7 +17,7 @@ en-US nanoframework thermalresistance unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 9d9ea70a28..af31bd51e1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -17,7 +17,7 @@ en-US nanoframework torque unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index 321faabafe..5a4465132a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -17,7 +17,7 @@ en-US nanoframework torqueperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 41c4b8beaf..6e856fad9e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -17,8 +17,8 @@ en-US nanoframework turbidity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - - + + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureGradientUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureGradientUnit.g.cs index 96522d6572..4e838b9e49 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureGradientUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TemperatureGradientUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureGradientUnit { - Undefined = 0, DegreeCelsiusPerKilometer, DegreeCelsiusPerMeter, DegreeFahrenheitPerFoot, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs index 7d73a74e8d..c05db06585 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/TorqueUnit.g.cs @@ -25,6 +25,9 @@ namespace UnitsNet.Units public enum TorqueUnit { + GramForceCentimeter, + GramForceMeter, + GramForceMillimeter, KilogramForceCentimeter, KilogramForceMeter, KilogramForceMillimeter, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs index 10ea6694f7..c89e187674 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeFlowPerAreaUnit { - Undefined = 0, CubicFootPerMinutePerSquareFoot, CubicMeterPerSecondPerSquareMeter, } diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index 9c911082c5..a2fd6bb63e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -17,7 +17,7 @@ en-US nanoframework vitamina unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index f90f43a0df..f16d96bb9b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -17,7 +17,7 @@ en-US nanoframework volume unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index cf43fbdd1f..b441c18a2f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -17,7 +17,7 @@ en-US nanoframework volumeconcentration unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index fba8c8c6d0..76de20a01c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -17,7 +17,7 @@ en-US nanoframework volumeflow unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec index 166045843d..97ece58b56 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlowPerArea - 4.117.0 + 5.0.0-alpha003 Units.NET VolumeFlowPerArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet @@ -15,7 +15,7 @@ Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). en-US - nanoframework unit units measurement si metric imperial abbreviation abbreviations convert conversion parse c# .net immutable uwp uap winrt win10 windows runtime component volumeflowperarea + nanoframework volumeflowperarea unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index 70dafffb56..8e5a19e395 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -17,7 +17,7 @@ en-US nanoframework volumeperlength unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 0a6ca1ba1f..2edab4fc19 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -17,7 +17,7 @@ en-US nanoframework volumetricheatcapacity unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - + diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 0008c32898..78ced70d1d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -17,8 +17,8 @@ en-US nanoframework warpingmomentofinertia unit units quantity quantities measurement si metric imperial abbreviation abbreviations convert conversion parse immutable - - + + diff --git a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs index 8f53ddf9d2..ee9383e0e5 100644 --- a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs +++ b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs @@ -24,7 +24,7 @@ public class AbbreviatedUnitsConverter : JsonConverter { private const string ValueProperty = "Value"; private const string UnitProperty = "Unit"; - private const string TypeProperty = "Type"; + private const string TypeProperty = "Type"; private readonly UnitAbbreviationsCache _abbreviations; private readonly IEqualityComparer _propertyComparer; @@ -183,7 +183,7 @@ public override IQuantity ReadJson(JsonReader reader, Type objectType, IQuantity return Quantity.From(value, unit); } - + /// /// Attempt to find an a unique (non-ambiguous) unit matching the provided abbreviation. /// diff --git a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs index baecac921c..05dc6123f8 100644 --- a/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs +++ b/UnitsNet.Tests/CustomCode/MassConcentrationTests.cs @@ -136,12 +136,12 @@ public static void ComponentMassFromMassConcentrationAndSolutionVolume( AssertEx.EqualTolerance(expectedMassValue, massComponent.As(expectedMassUnit), tolerance); } - [Fact(Skip = "No ConversionBaseUnit defined: see https://github.com/angularsen/UnitsNet/issues/651")] + [Fact(Skip = "No BaseUnit defined: see https://github.com/angularsen/UnitsNet/issues/651")] public void DefaultSIUnitIsKgPerCubicMeter() { var massConcentration = new MassConcentration(1, UnitSystem.SI); - Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, massConcentration.Unit); // MassConcentration.ConversionBaseUnit = KilogramPerCubicMeter + Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, massConcentration.Unit); // MassConcentration.BaseUnit = KilogramPerCubicMeter } [Fact] diff --git a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs index 636742bff9..0349294dbf 100644 --- a/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs +++ b/UnitsNet.Tests/GeneratedCode/IQuantityTests.g.cs @@ -267,125 +267,6 @@ public void QuantityInfo_IsSameAsStaticInfoProperty() Assertion(WarpingMomentOfInertia.Info, WarpingMomentOfInertia.Zero); } - [Fact] - public void Type_EqualsStaticQuantityTypeProperty() - { - void Assertion(QuantityType expected, IQuantity quantity) => Assert.Equal(expected, quantity.Type); - - Assertion(Acceleration.QuantityType, Acceleration.Zero); - Assertion(AmountOfSubstance.QuantityType, AmountOfSubstance.Zero); - Assertion(AmplitudeRatio.QuantityType, AmplitudeRatio.Zero); - Assertion(Angle.QuantityType, Angle.Zero); - Assertion(ApparentEnergy.QuantityType, ApparentEnergy.Zero); - Assertion(ApparentPower.QuantityType, ApparentPower.Zero); - Assertion(Area.QuantityType, Area.Zero); - Assertion(AreaDensity.QuantityType, AreaDensity.Zero); - Assertion(AreaMomentOfInertia.QuantityType, AreaMomentOfInertia.Zero); - Assertion(BitRate.QuantityType, BitRate.Zero); - Assertion(BrakeSpecificFuelConsumption.QuantityType, BrakeSpecificFuelConsumption.Zero); - Assertion(Capacitance.QuantityType, Capacitance.Zero); - Assertion(CoefficientOfThermalExpansion.QuantityType, CoefficientOfThermalExpansion.Zero); - Assertion(Density.QuantityType, Density.Zero); - Assertion(Duration.QuantityType, Duration.Zero); - Assertion(DynamicViscosity.QuantityType, DynamicViscosity.Zero); - Assertion(ElectricAdmittance.QuantityType, ElectricAdmittance.Zero); - Assertion(ElectricCharge.QuantityType, ElectricCharge.Zero); - Assertion(ElectricChargeDensity.QuantityType, ElectricChargeDensity.Zero); - Assertion(ElectricConductance.QuantityType, ElectricConductance.Zero); - Assertion(ElectricConductivity.QuantityType, ElectricConductivity.Zero); - Assertion(ElectricCurrent.QuantityType, ElectricCurrent.Zero); - Assertion(ElectricCurrentDensity.QuantityType, ElectricCurrentDensity.Zero); - Assertion(ElectricCurrentGradient.QuantityType, ElectricCurrentGradient.Zero); - Assertion(ElectricField.QuantityType, ElectricField.Zero); - Assertion(ElectricInductance.QuantityType, ElectricInductance.Zero); - Assertion(ElectricPotential.QuantityType, ElectricPotential.Zero); - Assertion(ElectricPotentialAc.QuantityType, ElectricPotentialAc.Zero); - Assertion(ElectricPotentialChangeRate.QuantityType, ElectricPotentialChangeRate.Zero); - Assertion(ElectricPotentialDc.QuantityType, ElectricPotentialDc.Zero); - Assertion(ElectricResistance.QuantityType, ElectricResistance.Zero); - Assertion(ElectricResistivity.QuantityType, ElectricResistivity.Zero); - Assertion(ElectricSurfaceChargeDensity.QuantityType, ElectricSurfaceChargeDensity.Zero); - Assertion(Energy.QuantityType, Energy.Zero); - Assertion(Entropy.QuantityType, Entropy.Zero); - Assertion(Force.QuantityType, Force.Zero); - Assertion(ForceChangeRate.QuantityType, ForceChangeRate.Zero); - Assertion(ForcePerLength.QuantityType, ForcePerLength.Zero); - Assertion(Frequency.QuantityType, Frequency.Zero); - Assertion(FuelEfficiency.QuantityType, FuelEfficiency.Zero); - Assertion(HeatFlux.QuantityType, HeatFlux.Zero); - Assertion(HeatTransferCoefficient.QuantityType, HeatTransferCoefficient.Zero); - Assertion(Illuminance.QuantityType, Illuminance.Zero); - Assertion(Information.QuantityType, Information.Zero); - Assertion(Irradiance.QuantityType, Irradiance.Zero); - Assertion(Irradiation.QuantityType, Irradiation.Zero); - Assertion(KinematicViscosity.QuantityType, KinematicViscosity.Zero); - Assertion(LapseRate.QuantityType, LapseRate.Zero); - Assertion(Length.QuantityType, Length.Zero); - Assertion(Level.QuantityType, Level.Zero); - Assertion(LinearDensity.QuantityType, LinearDensity.Zero); - Assertion(LinearPowerDensity.QuantityType, LinearPowerDensity.Zero); - Assertion(Luminosity.QuantityType, Luminosity.Zero); - Assertion(LuminousFlux.QuantityType, LuminousFlux.Zero); - Assertion(LuminousIntensity.QuantityType, LuminousIntensity.Zero); - Assertion(MagneticField.QuantityType, MagneticField.Zero); - Assertion(MagneticFlux.QuantityType, MagneticFlux.Zero); - Assertion(Magnetization.QuantityType, Magnetization.Zero); - Assertion(Mass.QuantityType, Mass.Zero); - Assertion(MassConcentration.QuantityType, MassConcentration.Zero); - Assertion(MassFlow.QuantityType, MassFlow.Zero); - Assertion(MassFlux.QuantityType, MassFlux.Zero); - Assertion(MassFraction.QuantityType, MassFraction.Zero); - Assertion(MassMomentOfInertia.QuantityType, MassMomentOfInertia.Zero); - Assertion(MolarEnergy.QuantityType, MolarEnergy.Zero); - Assertion(MolarEntropy.QuantityType, MolarEntropy.Zero); - Assertion(Molarity.QuantityType, Molarity.Zero); - Assertion(MolarMass.QuantityType, MolarMass.Zero); - Assertion(Permeability.QuantityType, Permeability.Zero); - Assertion(Permittivity.QuantityType, Permittivity.Zero); - Assertion(Power.QuantityType, Power.Zero); - Assertion(PowerDensity.QuantityType, PowerDensity.Zero); - Assertion(PowerRatio.QuantityType, PowerRatio.Zero); - Assertion(Pressure.QuantityType, Pressure.Zero); - Assertion(PressureChangeRate.QuantityType, PressureChangeRate.Zero); - Assertion(Ratio.QuantityType, Ratio.Zero); - Assertion(RatioChangeRate.QuantityType, RatioChangeRate.Zero); - Assertion(ReactiveEnergy.QuantityType, ReactiveEnergy.Zero); - Assertion(ReactivePower.QuantityType, ReactivePower.Zero); - Assertion(ReciprocalArea.QuantityType, ReciprocalArea.Zero); - Assertion(ReciprocalLength.QuantityType, ReciprocalLength.Zero); - Assertion(RelativeHumidity.QuantityType, RelativeHumidity.Zero); - Assertion(RotationalAcceleration.QuantityType, RotationalAcceleration.Zero); - Assertion(RotationalSpeed.QuantityType, RotationalSpeed.Zero); - Assertion(RotationalStiffness.QuantityType, RotationalStiffness.Zero); - Assertion(RotationalStiffnessPerLength.QuantityType, RotationalStiffnessPerLength.Zero); - Assertion(Scalar.QuantityType, Scalar.Zero); - Assertion(SolidAngle.QuantityType, SolidAngle.Zero); - Assertion(SpecificEnergy.QuantityType, SpecificEnergy.Zero); - Assertion(SpecificEntropy.QuantityType, SpecificEntropy.Zero); - Assertion(SpecificFuelConsumption.QuantityType, SpecificFuelConsumption.Zero); - Assertion(SpecificVolume.QuantityType, SpecificVolume.Zero); - Assertion(SpecificWeight.QuantityType, SpecificWeight.Zero); - Assertion(Speed.QuantityType, Speed.Zero); - Assertion(StandardVolumeFlow.QuantityType, StandardVolumeFlow.Zero); - Assertion(Temperature.QuantityType, Temperature.Zero); - Assertion(TemperatureChangeRate.QuantityType, TemperatureChangeRate.Zero); - Assertion(TemperatureDelta.QuantityType, TemperatureDelta.Zero); - Assertion(TemperatureGradient.QuantityType, TemperatureGradient.Zero); - Assertion(ThermalConductivity.QuantityType, ThermalConductivity.Zero); - Assertion(ThermalResistance.QuantityType, ThermalResistance.Zero); - Assertion(Torque.QuantityType, Torque.Zero); - Assertion(TorquePerLength.QuantityType, TorquePerLength.Zero); - Assertion(Turbidity.QuantityType, Turbidity.Zero); - Assertion(VitaminA.QuantityType, VitaminA.Zero); - Assertion(Volume.QuantityType, Volume.Zero); - Assertion(VolumeConcentration.QuantityType, VolumeConcentration.Zero); - Assertion(VolumeFlow.QuantityType, VolumeFlow.Zero); - Assertion(VolumeFlowPerArea.QuantityType, VolumeFlowPerArea.Zero); - Assertion(VolumePerLength.QuantityType, VolumePerLength.Zero); - Assertion(VolumetricHeatCapacity.QuantityType, VolumetricHeatCapacity.Zero); - Assertion(WarpingMomentOfInertia.QuantityType, WarpingMomentOfInertia.Zero); - } - [Fact] public void Dimensions_IsSameAsStaticBaseDimensions() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index 13abeeccbc..a1ad568e91 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class AccelerationTestsBase : QuantityTestsBase new object[] { AccelerationUnit.StandardGravity }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Acceleration((double)0.0, AccelerationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AccelerationUnit.MeterPerSecondSquared, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void Acceleration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Acceleration.Zero, quantityInfo.Zero); Assert.Equal("Acceleration", quantityInfo.Name); - Assert.Equal(QuantityType.Acceleration, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AccelerationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => meterpersecondsquared.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Acceleration.FromMetersPerSecondSquared(1); - var b = Acceleration.FromMetersPerSecondSquared(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Acceleration.FromMetersPerSecondSquared(1); - var b = Acceleration.FromMetersPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Acceleration.FromMetersPerSecondSquared(1); - object b = Acceleration.FromMetersPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(meterpersecondsquared.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AccelerationUnit.Undefined, Acceleration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AccelerationUnit)).Cast(); foreach(var unit in units) { - if(unit == AccelerationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm/s²", new Acceleration(1, AccelerationUnit.CentimeterPerSecondSquared).ToString()); Assert.Equal("1 dm/s²", new Acceleration(1, AccelerationUnit.DecimeterPerSecondSquared).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s1")); Assert.Equal("0.12 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s2")); Assert.Equal("0.123 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m/s²", new Acceleration(0.123456, AccelerationUnit.MeterPerSecondSquared).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AccelerationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(QuantityType.Acceleration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 01cd7be916..a0284b0bd1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -114,12 +114,6 @@ public abstract partial class AmountOfSubstanceTestsBase : QuantityTestsBase new object[] { AmountOfSubstanceUnit.PoundMole }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AmountOfSubstance((double)0.0, AmountOfSubstanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -128,7 +122,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AmountOfSubstanceUnit.Mole, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -172,14 +165,9 @@ public void AmountOfSubstance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(AmountOfSubstance.Zero, quantityInfo.Zero); Assert.Equal("AmountOfSubstance", quantityInfo.Name); - Assert.Equal(QuantityType.AmountOfSubstance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AmountOfSubstanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -430,49 +418,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => mole.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AmountOfSubstance.FromMoles(1); - var b = AmountOfSubstance.FromMoles(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AmountOfSubstance.FromMoles(1); - var b = AmountOfSubstance.FromMoles(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AmountOfSubstance.FromMoles(1); - object b = AmountOfSubstance.FromMoles(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -502,21 +447,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(mole.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AmountOfSubstanceUnit.Undefined, AmountOfSubstance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast(); foreach(var unit in units) { - if(unit == AmountOfSubstanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -530,8 +466,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cmol", new AmountOfSubstance(1, AmountOfSubstanceUnit.Centimole).ToString()); Assert.Equal("1 clbmol", new AmountOfSubstance(1, AmountOfSubstanceUnit.CentipoundMole).ToString()); @@ -551,7 +487,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -581,10 +517,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s1")); Assert.Equal("0.12 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s2")); Assert.Equal("0.123 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s3")); @@ -592,7 +528,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -606,29 +542,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 mol", new AmountOfSubstance(0.123456, AmountOfSubstanceUnit.Mole).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -748,13 +683,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AmountOfSubstanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(QuantityType.AmountOfSubstance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index eb9a8dc24f..8760874da8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class AmplitudeRatioTestsBase : QuantityTestsBase new object[] { AmplitudeRatioUnit.DecibelVolt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AmplitudeRatio((double)0.0, AmplitudeRatioUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AmplitudeRatioUnit.DecibelVolt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void AmplitudeRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(AmplitudeRatio.Zero, quantityInfo.Zero); Assert.Equal("AmplitudeRatio", quantityInfo.Name); - Assert.Equal(QuantityType.AmplitudeRatio, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AmplitudeRatioUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -313,49 +301,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decibelvolt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AmplitudeRatio.FromDecibelVolts(1); - var b = AmplitudeRatio.FromDecibelVolts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AmplitudeRatio.FromDecibelVolts(1); - var b = AmplitudeRatio.FromDecibelVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AmplitudeRatio.FromDecibelVolts(1); - object b = AmplitudeRatio.FromDecibelVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -385,21 +330,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibelvolt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AmplitudeRatioUnit.Undefined, AmplitudeRatio.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast(); foreach(var unit in units) { - if(unit == AmplitudeRatioUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -413,8 +349,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 dBµV", new AmplitudeRatio(1, AmplitudeRatioUnit.DecibelMicrovolt).ToString()); Assert.Equal("1 dBmV", new AmplitudeRatio(1, AmplitudeRatioUnit.DecibelMillivolt).ToString()); @@ -423,7 +359,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -442,10 +378,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s1")); Assert.Equal("0.12 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s2")); Assert.Equal("0.123 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s3")); @@ -453,7 +389,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -467,29 +403,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dBV", new AmplitudeRatio(0.123456, AmplitudeRatioUnit.DecibelVolt).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -609,13 +544,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AmplitudeRatioUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(QuantityType.AmplitudeRatio, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index bfecc91bbc..df94837810 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -118,12 +118,6 @@ public abstract partial class AngleTestsBase : QuantityTestsBase new object[] { AngleUnit.Tilt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Angle((double)0.0, AngleUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -132,7 +126,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AngleUnit.Degree, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -176,14 +169,9 @@ public void Angle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Angle.Zero, quantityInfo.Zero); Assert.Equal("Angle", quantityInfo.Name); - Assert.Equal(QuantityType.Angle, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AngleUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -441,49 +429,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => degree.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Angle.FromDegrees(1); - var b = Angle.FromDegrees(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Angle.FromDegrees(1); - var b = Angle.FromDegrees(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Angle.FromDegrees(1); - object b = Angle.FromDegrees(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -513,21 +458,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(degree.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AngleUnit.Undefined, Angle.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AngleUnit)).Cast(); foreach(var unit in units) { - if(unit == AngleUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -541,8 +477,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 '", new Angle(1, AngleUnit.Arcminute).ToString()); Assert.Equal("1 ″", new Angle(1, AngleUnit.Arcsecond).ToString()); @@ -563,7 +499,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -594,10 +530,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 °", new Angle(0.123456, AngleUnit.Degree).ToString("s1")); Assert.Equal("0.12 °", new Angle(0.123456, AngleUnit.Degree).ToString("s2")); Assert.Equal("0.123 °", new Angle(0.123456, AngleUnit.Degree).ToString("s3")); @@ -605,7 +541,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -619,29 +555,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 °", new Angle(0.123456, AngleUnit.Degree).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Angle.FromDegrees(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Angle.FromDegrees(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Angle.FromDegrees(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -761,13 +696,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AngleUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal(QuantityType.Angle, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 3731afa216..1cd4f4acb8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class ApparentEnergyTestsBase : QuantityTestsBase new object[] { ApparentEnergyUnit.VoltampereHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ApparentEnergy((double)0.0, ApparentEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ApparentEnergyUnit.VoltampereHour, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void ApparentEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ApparentEnergy.Zero, quantityInfo.Zero); Assert.Equal("ApparentEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.ApparentEnergy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ApparentEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltamperehour.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ApparentEnergy.FromVoltampereHours(1); - var b = ApparentEnergy.FromVoltampereHours(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ApparentEnergy.FromVoltampereHours(1); - var b = ApparentEnergy.FromVoltampereHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ApparentEnergy.FromVoltampereHours(1); - object b = ApparentEnergy.FromVoltampereHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltamperehour.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ApparentEnergyUnit.Undefined, ApparentEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == ApparentEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kVAh", new ApparentEnergy(1, ApparentEnergyUnit.KilovoltampereHour).ToString()); Assert.Equal("1 MVAh", new ApparentEnergy(1, ApparentEnergyUnit.MegavoltampereHour).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s1")); Assert.Equal("0.12 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s2")); Assert.Equal("0.123 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 VAh", new ApparentEnergy(0.123456, ApparentEnergyUnit.VoltampereHour).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ApparentEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(QuantityType.ApparentEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index aa5184f730..39dad546c8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class ApparentPowerTestsBase : QuantityTestsBase new object[] { ApparentPowerUnit.Voltampere }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ApparentPower((double)0.0, ApparentPowerUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ApparentPowerUnit.Voltampere, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void ApparentPower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ApparentPower.Zero, quantityInfo.Zero); Assert.Equal("ApparentPower", quantityInfo.Name); - Assert.Equal(QuantityType.ApparentPower, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ApparentPowerUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltampere.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ApparentPower.FromVoltamperes(1); - var b = ApparentPower.FromVoltamperes(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ApparentPower.FromVoltamperes(1); - var b = ApparentPower.FromVoltamperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ApparentPower.FromVoltamperes(1); - object b = ApparentPower.FromVoltamperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltampere.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ApparentPowerUnit.Undefined, ApparentPower.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ApparentPowerUnit)).Cast(); foreach(var unit in units) { - if(unit == ApparentPowerUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 GVA", new ApparentPower(1, ApparentPowerUnit.Gigavoltampere).ToString()); Assert.Equal("1 kVA", new ApparentPower(1, ApparentPowerUnit.Kilovoltampere).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s1")); Assert.Equal("0.12 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s2")); Assert.Equal("0.123 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 VA", new ApparentPower(0.123456, ApparentPowerUnit.Voltampere).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ApparentPowerUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(QuantityType.ApparentPower, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 1d8d35a570..6b48a4fb02 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase new object[] { AreaDensityUnit.KilogramPerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AreaDensity((double)0.0, AreaDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaDensityUnit.KilogramPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void AreaDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(AreaDensity.Zero, quantityInfo.Zero); Assert.Equal("AreaDensity", quantityInfo.Name); - Assert.Equal(QuantityType.AreaDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AreaDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AreaDensity.FromKilogramsPerSquareMeter(1); - var b = AreaDensity.FromKilogramsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AreaDensity.FromKilogramsPerSquareMeter(1); - var b = AreaDensity.FromKilogramsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AreaDensity.FromKilogramsPerSquareMeter(1); - object b = AreaDensity.FromKilogramsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AreaDensityUnit.Undefined, AreaDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AreaDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == AreaDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kg/m²", new AreaDensity(1, AreaDensityUnit.KilogramPerSquareMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s1")); Assert.Equal("0.12 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s2")); Assert.Equal("0.123 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m²", new AreaDensity(0.123456, AreaDensityUnit.KilogramPerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(QuantityType.AreaDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 835911e9a6..89a72b86e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -78,12 +78,6 @@ public abstract partial class AreaMomentOfInertiaTestsBase : QuantityTestsBase new object[] { AreaMomentOfInertiaUnit.MillimeterToTheFourth }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new AreaMomentOfInertia((double)0.0, AreaMomentOfInertiaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -92,7 +86,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaMomentOfInertiaUnit.MeterToTheFourth, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -136,14 +129,9 @@ public void AreaMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(AreaMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("AreaMomentOfInertia", quantityInfo.Name); - Assert.Equal(QuantityType.AreaMomentOfInertia, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AreaMomentOfInertiaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -331,49 +319,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => metertothefourth.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = AreaMomentOfInertia.FromMetersToTheFourth(1); - var b = AreaMomentOfInertia.FromMetersToTheFourth(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = AreaMomentOfInertia.FromMetersToTheFourth(1); - var b = AreaMomentOfInertia.FromMetersToTheFourth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = AreaMomentOfInertia.FromMetersToTheFourth(1); - object b = AreaMomentOfInertia.FromMetersToTheFourth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -403,21 +348,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(metertothefourth.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AreaMomentOfInertiaUnit.Undefined, AreaMomentOfInertia.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast(); foreach(var unit in units) { - if(unit == AreaMomentOfInertiaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -431,8 +367,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁴", new AreaMomentOfInertia(1, AreaMomentOfInertiaUnit.CentimeterToTheFourth).ToString()); Assert.Equal("1 dm⁴", new AreaMomentOfInertia(1, AreaMomentOfInertiaUnit.DecimeterToTheFourth).ToString()); @@ -443,7 +379,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -464,10 +400,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s1")); Assert.Equal("0.12 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s2")); Assert.Equal("0.123 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s3")); @@ -475,7 +411,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -489,29 +425,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁴", new AreaMomentOfInertia(0.123456, AreaMomentOfInertiaUnit.MeterToTheFourth).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -631,13 +566,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaMomentOfInertiaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(QuantityType.AreaMomentOfInertia, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index d77e8fbd30..3ff66b950c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class AreaTestsBase : QuantityTestsBase new object[] { AreaUnit.UsSurveySquareFoot }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Area((double)0.0, AreaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(AreaUnit.SquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void Area_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Area.Zero, quantityInfo.Zero); Assert.Equal("Area", quantityInfo.Name); - Assert.Equal(QuantityType.Area, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {AreaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => squaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Area.FromSquareMeters(1); - var b = Area.FromSquareMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Area.FromSquareMeters(1); - var b = Area.FromSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Area.FromSquareMeters(1); - object b = Area.FromSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(squaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(AreaUnit.Undefined, Area.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(AreaUnit)).Cast(); foreach(var unit in units) { - if(unit == AreaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ac", new Area(1, AreaUnit.Acre).ToString()); Assert.Equal("1 ha", new Area(1, AreaUnit.Hectare).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s1")); Assert.Equal("0.12 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s2")); Assert.Equal("0.123 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²", new Area(0.123456, AreaUnit.SquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Area.FromSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Area.FromSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(AreaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(QuantityType.Area, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 7b0d1ce275..e8d97a3667 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -158,12 +158,6 @@ public abstract partial class BitRateTestsBase : QuantityTestsBase new object[] { BitRateUnit.TerabytePerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new BitRate((decimal)0.0, BitRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -173,7 +167,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(BitRateUnit.BitPerSecond, quantity.Unit); } - [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() { @@ -204,14 +197,9 @@ public void BitRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(BitRate.Zero, quantityInfo.Zero); Assert.Equal("BitRate", quantityInfo.Name); - Assert.Equal(QuantityType.BitRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {BitRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -526,49 +514,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => bitpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = BitRate.FromBitsPerSecond(1); - var b = BitRate.FromBitsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = BitRate.FromBitsPerSecond(1); - var b = BitRate.FromBitsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = BitRate.FromBitsPerSecond(1); - object b = BitRate.FromBitsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -598,21 +543,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(bitpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(BitRateUnit.Undefined, BitRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(BitRateUnit)).Cast(); foreach(var unit in units) { - if(unit == BitRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -626,8 +562,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 bit/s", new BitRate(1, BitRateUnit.BitPerSecond).ToString()); Assert.Equal("1 B/s", new BitRate(1, BitRateUnit.BytePerSecond).ToString()); @@ -658,7 +594,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -699,10 +635,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s1")); Assert.Equal("0.12 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s2")); Assert.Equal("0.123 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s3")); @@ -710,7 +646,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -724,29 +660,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 bit/s", new BitRate(0.123456m, BitRateUnit.BitPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -866,13 +801,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(BitRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(QuantityType.BitRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index cdbd7f043f..f99e802238 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class BrakeSpecificFuelConsumptionTestsBase : QuantityTe new object[] { BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new BrakeSpecificFuelConsumption((double)0.0, BrakeSpecificFuelConsumptionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void BrakeSpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(BrakeSpecificFuelConsumption.Zero, quantityInfo.Zero); Assert.Equal("BrakeSpecificFuelConsumption", quantityInfo.Name); - Assert.Equal(QuantityType.BrakeSpecificFuelConsumption, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {BrakeSpecificFuelConsumptionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogramperjoule.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - var b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1); - object b = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogramperjoule.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(BrakeSpecificFuelConsumptionUnit.Undefined, BrakeSpecificFuelConsumption.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast(); foreach(var unit in units) { - if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g/kWh", new BrakeSpecificFuelConsumption(1, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour).ToString()); Assert.Equal("1 kg/J", new BrakeSpecificFuelConsumption(1, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s1")); Assert.Equal("0.12 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s2")); Assert.Equal("0.123 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/J", new BrakeSpecificFuelConsumption(0.123456, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(BrakeSpecificFuelConsumptionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(QuantityType.BrakeSpecificFuelConsumption, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index d6dc3c5031..5874678e42 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -82,12 +82,6 @@ public abstract partial class CapacitanceTestsBase : QuantityTestsBase new object[] { CapacitanceUnit.Picofarad }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Capacitance((double)0.0, CapacitanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -96,7 +90,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CapacitanceUnit.Farad, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -140,14 +133,9 @@ public void Capacitance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Capacitance.Zero, quantityInfo.Zero); Assert.Equal("Capacitance", quantityInfo.Name); - Assert.Equal(QuantityType.Capacitance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {CapacitanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -342,49 +330,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => farad.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Capacitance.FromFarads(1); - var b = Capacitance.FromFarads(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Capacitance.FromFarads(1); - var b = Capacitance.FromFarads(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Capacitance.FromFarads(1); - object b = Capacitance.FromFarads(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -414,21 +359,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(farad.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(CapacitanceUnit.Undefined, Capacitance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(CapacitanceUnit)).Cast(); foreach(var unit in units) { - if(unit == CapacitanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -442,8 +378,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 F", new Capacitance(1, CapacitanceUnit.Farad).ToString()); Assert.Equal("1 kF", new Capacitance(1, CapacitanceUnit.Kilofarad).ToString()); @@ -455,7 +391,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -477,10 +413,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s1")); Assert.Equal("0.12 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s2")); Assert.Equal("0.123 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s3")); @@ -488,7 +424,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -502,29 +438,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 F", new Capacitance(0.123456, CapacitanceUnit.Farad).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Capacitance.FromFarads(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Capacitance.FromFarads(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -644,13 +579,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(CapacitanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(QuantityType.Capacitance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index b0ac487406..114c10f4a8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class CoefficientOfThermalExpansionTestsBase : QuantityT new object[] { CoefficientOfThermalExpansionUnit.InverseKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new CoefficientOfThermalExpansion((double)0.0, CoefficientOfThermalExpansionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(CoefficientOfThermalExpansionUnit.InverseKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void CoefficientOfThermalExpansion_QuantityInfo_ReturnsQuantityInfoDescri Assert.Equal(CoefficientOfThermalExpansion.Zero, quantityInfo.Zero); Assert.Equal("CoefficientOfThermalExpansion", quantityInfo.Name); - Assert.Equal(QuantityType.CoefficientOfThermalExpansion, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {CoefficientOfThermalExpansionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => inversekelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - var b = CoefficientOfThermalExpansion.FromInverseKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = CoefficientOfThermalExpansion.FromInverseKelvin(1); - object b = CoefficientOfThermalExpansion.FromInverseKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(inversekelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(CoefficientOfThermalExpansionUnit.Undefined, CoefficientOfThermalExpansion.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast(); foreach(var unit in units) { - if(unit == CoefficientOfThermalExpansionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 °C⁻¹", new CoefficientOfThermalExpansion(1, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius).ToString()); Assert.Equal("1 °F⁻¹", new CoefficientOfThermalExpansion(1, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s1")); Assert.Equal("0.12 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s2")); Assert.Equal("0.123 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 K⁻¹", new CoefficientOfThermalExpansion(0.123456, CoefficientOfThermalExpansionUnit.InverseKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(CoefficientOfThermalExpansionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(QuantityType.CoefficientOfThermalExpansion, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index c7643f3540..a9e5fd322d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -258,12 +258,6 @@ public abstract partial class DensityTestsBase : QuantityTestsBase new object[] { DensityUnit.TonnePerCubicMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Density((double)0.0, DensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -272,7 +266,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DensityUnit.KilogramPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -316,14 +309,9 @@ public void Density_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Density.Zero, quantityInfo.Zero); Assert.Equal("Density", quantityInfo.Name); - Assert.Equal(QuantityType.Density, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {DensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -826,49 +814,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Density.FromKilogramsPerCubicMeter(1); - var b = Density.FromKilogramsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Density.FromKilogramsPerCubicMeter(1); - var b = Density.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Density.FromKilogramsPerCubicMeter(1); - object b = Density.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -898,21 +843,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(DensityUnit.Undefined, Density.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(DensityUnit)).Cast(); foreach(var unit in units) { - if(unit == DensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -926,8 +862,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/dl", new Density(1, DensityUnit.CentigramPerDeciliter).ToString()); Assert.Equal("1 cg/L", new Density(1, DensityUnit.CentigramPerLiter).ToString()); @@ -983,7 +919,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1049,10 +985,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s1")); Assert.Equal("0.12 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s2")); Assert.Equal("0.123 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s3")); @@ -1060,7 +996,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1074,29 +1010,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m³", new Density(0.123456, DensityUnit.KilogramPerCubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1216,13 +1151,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(QuantityType.Density, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index bb1ca8753d..04af8d5b2b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -98,12 +98,6 @@ public abstract partial class DurationTestsBase : QuantityTestsBase new object[] { DurationUnit.Year365 }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Duration((double)0.0, DurationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -112,7 +106,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DurationUnit.Second, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -156,14 +149,9 @@ public void Duration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Duration.Zero, quantityInfo.Zero); Assert.Equal("Duration", quantityInfo.Name); - Assert.Equal(QuantityType.Duration, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {DurationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -386,49 +374,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => second.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Duration.FromSeconds(1); - var b = Duration.FromSeconds(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Duration.FromSeconds(1); - var b = Duration.FromSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Duration.FromSeconds(1); - object b = Duration.FromSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -458,21 +403,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(second.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(DurationUnit.Undefined, Duration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(DurationUnit)).Cast(); foreach(var unit in units) { - if(unit == DurationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -486,8 +422,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 d", new Duration(1, DurationUnit.Day).ToString()); Assert.Equal("1 h", new Duration(1, DurationUnit.Hour).ToString()); @@ -503,7 +439,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -529,10 +465,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 s", new Duration(0.123456, DurationUnit.Second).ToString("s1")); Assert.Equal("0.12 s", new Duration(0.123456, DurationUnit.Second).ToString("s2")); Assert.Equal("0.123 s", new Duration(0.123456, DurationUnit.Second).ToString("s3")); @@ -540,7 +476,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -554,29 +490,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 s", new Duration(0.123456, DurationUnit.Second).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Duration.FromSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Duration.FromSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -696,13 +631,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DurationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal(QuantityType.Duration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 743e6be92f..c6d3ff54f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -94,12 +94,6 @@ public abstract partial class DynamicViscosityTestsBase : QuantityTestsBase new object[] { DynamicViscosityUnit.Reyn }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new DynamicViscosity((double)0.0, DynamicViscosityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -108,7 +102,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(DynamicViscosityUnit.NewtonSecondPerMeterSquared, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -152,14 +145,9 @@ public void DynamicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(DynamicViscosity.Zero, quantityInfo.Zero); Assert.Equal("DynamicViscosity", quantityInfo.Name); - Assert.Equal(QuantityType.DynamicViscosity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {DynamicViscosityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -375,49 +363,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonsecondpermetersquared.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - var b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1); - object b = DynamicViscosity.FromNewtonSecondsPerMeterSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -447,21 +392,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonsecondpermetersquared.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(DynamicViscosityUnit.Undefined, DynamicViscosity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast(); foreach(var unit in units) { - if(unit == DynamicViscosityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -475,8 +411,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cP", new DynamicViscosity(1, DynamicViscosityUnit.Centipoise).ToString()); Assert.Equal("1 µPa·s", new DynamicViscosity(1, DynamicViscosityUnit.MicropascalSecond).ToString()); @@ -491,7 +427,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -516,10 +452,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s1")); Assert.Equal("0.12 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s2")); Assert.Equal("0.123 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s3")); @@ -527,7 +463,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -541,29 +477,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ns/m²", new DynamicViscosity(0.123456, DynamicViscosityUnit.NewtonSecondPerMeterSquared).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -683,13 +618,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(DynamicViscosityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(QuantityType.DynamicViscosity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index b4c6557bde..518592f9cb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class ElectricAdmittanceTestsBase : QuantityTestsBase new object[] { ElectricAdmittanceUnit.Siemens }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricAdmittance((double)0.0, ElectricAdmittanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricAdmittanceUnit.Siemens, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void ElectricAdmittance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricAdmittance.Zero, quantityInfo.Zero); Assert.Equal("ElectricAdmittance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricAdmittance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricAdmittanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => siemens.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricAdmittance.FromSiemens(1); - var b = ElectricAdmittance.FromSiemens(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricAdmittance.FromSiemens(1); - var b = ElectricAdmittance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricAdmittance.FromSiemens(1); - object b = ElectricAdmittance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(siemens.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricAdmittanceUnit.Undefined, ElectricAdmittance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricAdmittanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 µS", new ElectricAdmittance(1, ElectricAdmittanceUnit.Microsiemens).ToString()); Assert.Equal("1 mS", new ElectricAdmittance(1, ElectricAdmittanceUnit.Millisiemens).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s1")); Assert.Equal("0.12 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s2")); Assert.Equal("0.123 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S", new ElectricAdmittance(0.123456, ElectricAdmittanceUnit.Siemens).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricAdmittanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(QuantityType.ElectricAdmittance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 17e05c7b60..8a07b41703 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class ElectricChargeDensityTestsBase : QuantityTestsBase new object[] { ElectricChargeDensityUnit.CoulombPerCubicMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricChargeDensity((double)0.0, ElectricChargeDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricChargeDensityUnit.CoulombPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void ElectricChargeDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuan Assert.Equal(ElectricChargeDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricChargeDensity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricChargeDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => coulombpercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - var b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricChargeDensity.FromCoulombsPerCubicMeter(1); - object b = ElectricChargeDensity.FromCoulombsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(coulombpercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricChargeDensityUnit.Undefined, ElectricChargeDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricChargeDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 C/m³", new ElectricChargeDensity(1, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s1")); Assert.Equal("0.12 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s2")); Assert.Equal("0.123 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C/m³", new ElectricChargeDensity(0.123456, ElectricChargeDensityUnit.CoulombPerCubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricChargeDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(QuantityType.ElectricChargeDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 7fefdc564b..3ecbf90468 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -74,12 +74,6 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase new object[] { ElectricChargeUnit.MilliampereHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCharge((double)0.0, ElectricChargeUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -88,7 +82,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricChargeUnit.Coulomb, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -132,14 +125,9 @@ public void ElectricCharge_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricCharge.Zero, quantityInfo.Zero); Assert.Equal("ElectricCharge", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCharge, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricChargeUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -320,49 +308,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => coulomb.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCharge.FromCoulombs(1); - var b = ElectricCharge.FromCoulombs(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCharge.FromCoulombs(1); - var b = ElectricCharge.FromCoulombs(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCharge.FromCoulombs(1); - object b = ElectricCharge.FromCoulombs(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -392,21 +337,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(coulomb.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricChargeUnit.Undefined, ElectricCharge.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricChargeUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricChargeUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -420,8 +356,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A-h", new ElectricCharge(1, ElectricChargeUnit.AmpereHour).ToString()); Assert.Equal("1 C", new ElectricCharge(1, ElectricChargeUnit.Coulomb).ToString()); @@ -431,7 +367,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -451,10 +387,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s1")); Assert.Equal("0.12 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s2")); Assert.Equal("0.123 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s3")); @@ -462,7 +398,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,29 +412,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C", new ElectricCharge(0.123456, ElectricChargeUnit.Coulomb).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -618,13 +553,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricChargeUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(QuantityType.ElectricCharge, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 1e4cd156e5..c412146307 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class ElectricConductanceTestsBase : QuantityTestsBase new object[] { ElectricConductanceUnit.Siemens }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricConductance((double)0.0, ElectricConductanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricConductanceUnit.Siemens, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void ElectricConductance_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricConductance.Zero, quantityInfo.Zero); Assert.Equal("ElectricConductance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricConductance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => siemens.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricConductance.FromSiemens(1); - var b = ElectricConductance.FromSiemens(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricConductance.FromSiemens(1); - var b = ElectricConductance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricConductance.FromSiemens(1); - object b = ElectricConductance.FromSiemens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(siemens.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricConductanceUnit.Undefined, ElectricConductance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricConductanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 µS", new ElectricConductance(1, ElectricConductanceUnit.Microsiemens).ToString()); Assert.Equal("1 mS", new ElectricConductance(1, ElectricConductanceUnit.Millisiemens).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s1")); Assert.Equal("0.12 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s2")); Assert.Equal("0.123 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S", new ElectricConductance(0.123456, ElectricConductanceUnit.Siemens).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricConductanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(QuantityType.ElectricConductance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 55a741771f..074f43ee50 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class ElectricConductivityTestsBase : QuantityTestsBase new object[] { ElectricConductivityUnit.SiemensPerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricConductivity((double)0.0, ElectricConductivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricConductivityUnit.SiemensPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void ElectricConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuant Assert.Equal(ElectricConductivity.Zero, quantityInfo.Zero); Assert.Equal("ElectricConductivity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricConductivity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricConductivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => siemenspermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricConductivity.FromSiemensPerMeter(1); - var b = ElectricConductivity.FromSiemensPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricConductivity.FromSiemensPerMeter(1); - var b = ElectricConductivity.FromSiemensPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricConductivity.FromSiemensPerMeter(1); - object b = ElectricConductivity.FromSiemensPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(siemenspermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricConductivityUnit.Undefined, ElectricConductivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricConductivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 S/ft", new ElectricConductivity(1, ElectricConductivityUnit.SiemensPerFoot).ToString()); Assert.Equal("1 S/in", new ElectricConductivity(1, ElectricConductivityUnit.SiemensPerInch).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s1")); Assert.Equal("0.12 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s2")); Assert.Equal("0.123 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 S/m", new ElectricConductivity(0.123456, ElectricConductivityUnit.SiemensPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricConductivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(QuantityType.ElectricConductivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index e3c7067ce5..24be160877 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class ElectricCurrentDensityTestsBase : QuantityTestsBas new object[] { ElectricCurrentDensityUnit.AmperePerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCurrentDensity((double)0.0, ElectricCurrentDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentDensityUnit.AmperePerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void ElectricCurrentDensity_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(ElectricCurrentDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrentDensity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCurrentDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amperepersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - var b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCurrentDensity.FromAmperesPerSquareMeter(1); - object b = ElectricCurrentDensity.FromAmperesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amperepersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricCurrentDensityUnit.Undefined, ElectricCurrentDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricCurrentDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A/ft²", new ElectricCurrentDensity(1, ElectricCurrentDensityUnit.AmperePerSquareFoot).ToString()); Assert.Equal("1 A/in²", new ElectricCurrentDensity(1, ElectricCurrentDensityUnit.AmperePerSquareInch).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s1")); Assert.Equal("0.12 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s2")); Assert.Equal("0.123 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/m²", new ElectricCurrentDensity(0.123456, ElectricCurrentDensityUnit.AmperePerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(QuantityType.ElectricCurrentDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 9663d96458..b1a71d97ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class ElectricCurrentGradientTestsBase : QuantityTestsBa new object[] { ElectricCurrentGradientUnit.AmperePerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCurrentGradient((double)0.0, ElectricCurrentGradientUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentGradientUnit.AmperePerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void ElectricCurrentGradient_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(ElectricCurrentGradient.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrentGradient", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCurrentGradient, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentGradientUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amperepersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCurrentGradient.FromAmperesPerSecond(1); - var b = ElectricCurrentGradient.FromAmperesPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCurrentGradient.FromAmperesPerSecond(1); - var b = ElectricCurrentGradient.FromAmperesPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCurrentGradient.FromAmperesPerSecond(1); - object b = ElectricCurrentGradient.FromAmperesPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amperepersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricCurrentGradientUnit.Undefined, ElectricCurrentGradient.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricCurrentGradientUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A/μs", new ElectricCurrentGradient(1, ElectricCurrentGradientUnit.AmperePerMicrosecond).ToString()); Assert.Equal("1 A/ms", new ElectricCurrentGradient(1, ElectricCurrentGradientUnit.AmperePerMillisecond).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s1")); Assert.Equal("0.12 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s2")); Assert.Equal("0.123 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/s", new ElectricCurrentGradient(0.123456, ElectricCurrentGradientUnit.AmperePerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentGradientUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(QuantityType.ElectricCurrentGradient, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 3374cd2321..5462c0386a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -86,12 +86,6 @@ public abstract partial class ElectricCurrentTestsBase : QuantityTestsBase new object[] { ElectricCurrentUnit.Picoampere }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricCurrent((double)0.0, ElectricCurrentUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -100,7 +94,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricCurrentUnit.Ampere, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -144,14 +137,9 @@ public void ElectricCurrent_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricCurrent.Zero, quantityInfo.Zero); Assert.Equal("ElectricCurrent", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricCurrent, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricCurrentUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -353,49 +341,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ampere.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricCurrent.FromAmperes(1); - var b = ElectricCurrent.FromAmperes(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricCurrent.FromAmperes(1); - var b = ElectricCurrent.FromAmperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricCurrent.FromAmperes(1); - object b = ElectricCurrent.FromAmperes(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -425,21 +370,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ampere.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricCurrentUnit.Undefined, ElectricCurrent.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricCurrentUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -453,8 +389,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A", new ElectricCurrent(1, ElectricCurrentUnit.Ampere).ToString()); Assert.Equal("1 cA", new ElectricCurrent(1, ElectricCurrentUnit.Centiampere).ToString()); @@ -467,7 +403,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -490,10 +426,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s1")); Assert.Equal("0.12 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s2")); Assert.Equal("0.123 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s3")); @@ -501,7 +437,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -515,29 +451,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A", new ElectricCurrent(0.123456, ElectricCurrentUnit.Ampere).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -657,13 +592,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricCurrentUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(QuantityType.ElectricCurrent, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 825ea88e65..cb8fecce6c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class ElectricFieldTestsBase : QuantityTestsBase new object[] { ElectricFieldUnit.VoltPerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricField((double)0.0, ElectricFieldUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricFieldUnit.VoltPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void ElectricField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ElectricField.Zero, quantityInfo.Zero); Assert.Equal("ElectricField", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricField, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricFieldUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricField.FromVoltsPerMeter(1); - var b = ElectricField.FromVoltsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricField.FromVoltsPerMeter(1); - var b = ElectricField.FromVoltsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricField.FromVoltsPerMeter(1); - object b = ElectricField.FromVoltsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricFieldUnit.Undefined, ElectricField.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricFieldUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricFieldUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 V/m", new ElectricField(1, ElectricFieldUnit.VoltPerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s1")); Assert.Equal("0.12 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s2")); Assert.Equal("0.123 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V/m", new ElectricField(0.123456, ElectricFieldUnit.VoltPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricFieldUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(QuantityType.ElectricField, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 8c7f0f8f83..f750b9a5b3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class ElectricInductanceTestsBase : QuantityTestsBase new object[] { ElectricInductanceUnit.Nanohenry }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricInductance((double)0.0, ElectricInductanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricInductanceUnit.Henry, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void ElectricInductance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricInductance.Zero, quantityInfo.Zero); Assert.Equal("ElectricInductance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricInductance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricInductanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => henry.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricInductance.FromHenries(1); - var b = ElectricInductance.FromHenries(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricInductance.FromHenries(1); - var b = ElectricInductance.FromHenries(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricInductance.FromHenries(1); - object b = ElectricInductance.FromHenries(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(henry.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricInductanceUnit.Undefined, ElectricInductance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricInductanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 H", new ElectricInductance(1, ElectricInductanceUnit.Henry).ToString()); Assert.Equal("1 µH", new ElectricInductance(1, ElectricInductanceUnit.Microhenry).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s1")); Assert.Equal("0.12 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s2")); Assert.Equal("0.123 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 H", new ElectricInductance(0.123456, ElectricInductanceUnit.Henry).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricInductanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(QuantityType.ElectricInductance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index dc62cb8d5d..98c1296257 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -74,12 +74,6 @@ public abstract partial class ElectricPotentialAcTestsBase : QuantityTestsBase new object[] { ElectricPotentialAcUnit.VoltAc }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotentialAc((double)0.0, ElectricPotentialAcUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -88,7 +82,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialAcUnit.VoltAc, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -132,14 +125,9 @@ public void ElectricPotentialAc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricPotentialAc.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialAc", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotentialAc, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialAcUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -320,49 +308,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltac.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotentialAc.FromVoltsAc(1); - var b = ElectricPotentialAc.FromVoltsAc(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotentialAc.FromVoltsAc(1); - var b = ElectricPotentialAc.FromVoltsAc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotentialAc.FromVoltsAc(1); - object b = ElectricPotentialAc.FromVoltsAc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -392,21 +337,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltac.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialAcUnit.Undefined, ElectricPotentialAc.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialAcUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -420,8 +356,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kVac", new ElectricPotentialAc(1, ElectricPotentialAcUnit.KilovoltAc).ToString()); Assert.Equal("1 MVac", new ElectricPotentialAc(1, ElectricPotentialAcUnit.MegavoltAc).ToString()); @@ -431,7 +367,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -451,10 +387,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s1")); Assert.Equal("0.12 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s2")); Assert.Equal("0.123 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s3")); @@ -462,7 +398,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,29 +412,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Vac", new ElectricPotentialAc(0.123456, ElectricPotentialAcUnit.VoltAc).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -618,13 +553,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialAcUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(QuantityType.ElectricPotentialAc, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 6cbe276aab..460607b95a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -134,12 +134,6 @@ public abstract partial class ElectricPotentialChangeRateTestsBase : QuantityTes new object[] { ElectricPotentialChangeRateUnit.VoltPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotentialChangeRate((double)0.0, ElectricPotentialChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -148,7 +142,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialChangeRateUnit.VoltPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -192,14 +185,9 @@ public void ElectricPotentialChangeRate_QuantityInfo_ReturnsQuantityInfoDescribi Assert.Equal(ElectricPotentialChangeRate.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotentialChangeRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -485,49 +473,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - var b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotentialChangeRate.FromVoltsPerSeconds(1); - object b = ElectricPotentialChangeRate.FromVoltsPerSeconds(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -557,21 +502,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialChangeRateUnit.Undefined, ElectricPotentialChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -585,8 +521,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kV/h", new ElectricPotentialChangeRate(1, ElectricPotentialChangeRateUnit.KilovoltPerHour).ToString()); Assert.Equal("1 kV/μs", new ElectricPotentialChangeRate(1, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond).ToString()); @@ -611,7 +547,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -646,10 +582,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s1")); Assert.Equal("0.12 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s2")); Assert.Equal("0.123 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s3")); @@ -657,7 +593,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -671,29 +607,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V/s", new ElectricPotentialChangeRate(0.123456, ElectricPotentialChangeRateUnit.VoltPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -813,13 +748,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(QuantityType.ElectricPotentialChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index df1cfbd31f..cc5f09e1e1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -74,12 +74,6 @@ public abstract partial class ElectricPotentialDcTestsBase : QuantityTestsBase new object[] { ElectricPotentialDcUnit.VoltDc }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotentialDc((double)0.0, ElectricPotentialDcUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -88,7 +82,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialDcUnit.VoltDc, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -132,14 +125,9 @@ public void ElectricPotentialDc_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricPotentialDc.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotentialDc", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotentialDc, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialDcUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -320,49 +308,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltdc.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotentialDc.FromVoltsDc(1); - var b = ElectricPotentialDc.FromVoltsDc(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotentialDc.FromVoltsDc(1); - var b = ElectricPotentialDc.FromVoltsDc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotentialDc.FromVoltsDc(1); - object b = ElectricPotentialDc.FromVoltsDc(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -392,21 +337,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltdc.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialDcUnit.Undefined, ElectricPotentialDc.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialDcUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -420,8 +356,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kVdc", new ElectricPotentialDc(1, ElectricPotentialDcUnit.KilovoltDc).ToString()); Assert.Equal("1 MVdc", new ElectricPotentialDc(1, ElectricPotentialDcUnit.MegavoltDc).ToString()); @@ -431,7 +367,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -451,10 +387,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s1")); Assert.Equal("0.12 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s2")); Assert.Equal("0.123 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s3")); @@ -462,7 +398,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,29 +412,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Vdc", new ElectricPotentialDc(0.123456, ElectricPotentialDcUnit.VoltDc).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -618,13 +553,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialDcUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(QuantityType.ElectricPotentialDc, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 89742b883c..0ee99e3511 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -74,12 +74,6 @@ public abstract partial class ElectricPotentialTestsBase : QuantityTestsBase new object[] { ElectricPotentialUnit.Volt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricPotential((double)0.0, ElectricPotentialUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -88,7 +82,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricPotentialUnit.Volt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -132,14 +125,9 @@ public void ElectricPotential_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(ElectricPotential.Zero, quantityInfo.Zero); Assert.Equal("ElectricPotential", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricPotential, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricPotentialUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -320,49 +308,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => volt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricPotential.FromVolts(1); - var b = ElectricPotential.FromVolts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricPotential.FromVolts(1); - var b = ElectricPotential.FromVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricPotential.FromVolts(1); - object b = ElectricPotential.FromVolts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -392,21 +337,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(volt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricPotentialUnit.Undefined, ElectricPotential.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricPotentialUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -420,8 +356,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kV", new ElectricPotential(1, ElectricPotentialUnit.Kilovolt).ToString()); Assert.Equal("1 MV", new ElectricPotential(1, ElectricPotentialUnit.Megavolt).ToString()); @@ -431,7 +367,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -451,10 +387,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s1")); Assert.Equal("0.12 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s2")); Assert.Equal("0.123 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s3")); @@ -462,7 +398,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,29 +412,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 V", new ElectricPotential(0.123456, ElectricPotentialUnit.Volt).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -618,13 +553,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricPotentialUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(QuantityType.ElectricPotential, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index fedf7e6908..9259dce55c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -78,12 +78,6 @@ public abstract partial class ElectricResistanceTestsBase : QuantityTestsBase new object[] { ElectricResistanceUnit.Ohm }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricResistance((double)0.0, ElectricResistanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -92,7 +86,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricResistanceUnit.Ohm, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -136,14 +129,9 @@ public void ElectricResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(ElectricResistance.Zero, quantityInfo.Zero); Assert.Equal("ElectricResistance", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricResistance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -331,49 +319,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ohm.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricResistance.FromOhms(1); - var b = ElectricResistance.FromOhms(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricResistance.FromOhms(1); - var b = ElectricResistance.FromOhms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricResistance.FromOhms(1); - object b = ElectricResistance.FromOhms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -403,21 +348,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ohm.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricResistanceUnit.Undefined, ElectricResistance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricResistanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -431,8 +367,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 GΩ", new ElectricResistance(1, ElectricResistanceUnit.Gigaohm).ToString()); Assert.Equal("1 kΩ", new ElectricResistance(1, ElectricResistanceUnit.Kiloohm).ToString()); @@ -443,7 +379,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -464,10 +400,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s1")); Assert.Equal("0.12 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s2")); Assert.Equal("0.123 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s3")); @@ -475,7 +411,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -489,29 +425,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ω", new ElectricResistance(0.123456, ElectricResistanceUnit.Ohm).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -631,13 +566,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricResistanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(QuantityType.ElectricResistance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 3c9463fa71..c453d415e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class ElectricResistivityTestsBase : QuantityTestsBase new object[] { ElectricResistivityUnit.PicoohmMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricResistivity((double)0.0, ElectricResistivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricResistivityUnit.OhmMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void ElectricResistivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ElectricResistivity.Zero, quantityInfo.Zero); Assert.Equal("ElectricResistivity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricResistivity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricResistivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ohmmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricResistivity.FromOhmMeters(1); - var b = ElectricResistivity.FromOhmMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricResistivity.FromOhmMeters(1); - var b = ElectricResistivity.FromOhmMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricResistivity.FromOhmMeters(1); - object b = ElectricResistivity.FromOhmMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ohmmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricResistivityUnit.Undefined, ElectricResistivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricResistivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kΩ·cm", new ElectricResistivity(1, ElectricResistivityUnit.KiloohmCentimeter).ToString()); Assert.Equal("1 kΩ·m", new ElectricResistivity(1, ElectricResistivityUnit.KiloohmMeter).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s1")); Assert.Equal("0.12 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s2")); Assert.Equal("0.123 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Ω·m", new ElectricResistivity(0.123456, ElectricResistivityUnit.OhmMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricResistivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(QuantityType.ElectricResistivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index baf69ed89a..6557f4977a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class ElectricSurfaceChargeDensityTestsBase : QuantityTe new object[] { ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ElectricSurfaceChargeDensity((double)0.0, ElectricSurfaceChargeDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void ElectricSurfaceChargeDensity_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(ElectricSurfaceChargeDensity.Zero, quantityInfo.Zero); Assert.Equal("ElectricSurfaceChargeDensity", quantityInfo.Name); - Assert.Equal(QuantityType.ElectricSurfaceChargeDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ElectricSurfaceChargeDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => coulombpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - var b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1); - object b = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(coulombpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ElectricSurfaceChargeDensityUnit.Undefined, ElectricSurfaceChargeDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == ElectricSurfaceChargeDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 C/cm²", new ElectricSurfaceChargeDensity(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter).ToString()); Assert.Equal("1 C/in²", new ElectricSurfaceChargeDensity(1, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s1")); Assert.Equal("0.12 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s2")); Assert.Equal("0.123 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 C/m²", new ElectricSurfaceChargeDensity(0.123456, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ElectricSurfaceChargeDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(QuantityType.ElectricSurfaceChargeDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 4f31580566..e3e7f4113a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -198,12 +198,6 @@ public abstract partial class EnergyTestsBase : QuantityTestsBase new object[] { EnergyUnit.WattHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Energy((double)0.0, EnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -212,7 +206,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EnergyUnit.Joule, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -256,14 +249,9 @@ public void Energy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Energy.Zero, quantityInfo.Zero); Assert.Equal("Energy", quantityInfo.Name); - Assert.Equal(QuantityType.Energy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {EnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -661,49 +649,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joule.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Energy.FromJoules(1); - var b = Energy.FromJoules(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Energy.FromJoules(1); - var b = Energy.FromJoules(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Energy.FromJoules(1); - object b = Energy.FromJoules(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -733,21 +678,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joule.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(EnergyUnit.Undefined, Energy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(EnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == EnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -761,8 +697,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU", new Energy(1, EnergyUnit.BritishThermalUnit).ToString()); Assert.Equal("1 cal", new Energy(1, EnergyUnit.Calorie).ToString()); @@ -803,7 +739,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -854,10 +790,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s1")); Assert.Equal("0.12 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s2")); Assert.Equal("0.123 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s3")); @@ -865,7 +801,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -879,29 +815,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J", new Energy(0.123456, EnergyUnit.Joule).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Energy.FromJoules(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Energy.FromJoules(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Energy.FromJoules(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1021,13 +956,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(EnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Energy.FromJoules(1.0); - Assert.Equal(QuantityType.Energy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 55859a487e..9727226701 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -82,12 +82,6 @@ public abstract partial class EntropyTestsBase : QuantityTestsBase new object[] { EntropyUnit.MegajoulePerKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Entropy((double)0.0, EntropyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -96,7 +90,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(EntropyUnit.JoulePerKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -140,14 +133,9 @@ public void Entropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Entropy.Zero, quantityInfo.Zero); Assert.Equal("Entropy", quantityInfo.Name); - Assert.Equal(QuantityType.Entropy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {EntropyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -342,49 +330,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => jouleperkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Entropy.FromJoulesPerKelvin(1); - var b = Entropy.FromJoulesPerKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Entropy.FromJoulesPerKelvin(1); - var b = Entropy.FromJoulesPerKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Entropy.FromJoulesPerKelvin(1); - object b = Entropy.FromJoulesPerKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -414,21 +359,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(jouleperkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(EntropyUnit.Undefined, Entropy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(EntropyUnit)).Cast(); foreach(var unit in units) { - if(unit == EntropyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -442,8 +378,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cal/K", new Entropy(1, EntropyUnit.CaloriePerKelvin).ToString()); Assert.Equal("1 J/C", new Entropy(1, EntropyUnit.JoulePerDegreeCelsius).ToString()); @@ -455,7 +391,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -477,10 +413,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s1")); Assert.Equal("0.12 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s2")); Assert.Equal("0.123 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s3")); @@ -488,7 +424,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -502,29 +438,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/K", new Entropy(0.123456, EntropyUnit.JoulePerKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -644,13 +579,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(EntropyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(QuantityType.Entropy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index fe9203fc90..755e55b21a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -114,12 +114,6 @@ public abstract partial class ForceChangeRateTestsBase : QuantityTestsBase new object[] { ForceChangeRateUnit.PoundForcePerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ForceChangeRate((double)0.0, ForceChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -128,7 +122,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForceChangeRateUnit.NewtonPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -172,14 +165,9 @@ public void ForceChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ForceChangeRate.Zero, quantityInfo.Zero); Assert.Equal("ForceChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.ForceChangeRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ForceChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -430,49 +418,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ForceChangeRate.FromNewtonsPerSecond(1); - var b = ForceChangeRate.FromNewtonsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ForceChangeRate.FromNewtonsPerSecond(1); - var b = ForceChangeRate.FromNewtonsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ForceChangeRate.FromNewtonsPerSecond(1); - object b = ForceChangeRate.FromNewtonsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -502,21 +447,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ForceChangeRateUnit.Undefined, ForceChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == ForceChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -530,8 +466,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cN/s", new ForceChangeRate(1, ForceChangeRateUnit.CentinewtonPerSecond).ToString()); Assert.Equal("1 daN/min", new ForceChangeRate(1, ForceChangeRateUnit.DecanewtonPerMinute).ToString()); @@ -551,7 +487,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -581,10 +517,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s1")); Assert.Equal("0.12 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s2")); Assert.Equal("0.123 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s3")); @@ -592,7 +528,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -606,29 +542,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/s", new ForceChangeRate(0.123456, ForceChangeRateUnit.NewtonPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -748,13 +683,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ForceChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(QuantityType.ForceChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 7ddeacc15a..974a5ecece 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -206,12 +206,6 @@ public abstract partial class ForcePerLengthTestsBase : QuantityTestsBase new object[] { ForcePerLengthUnit.TonneForcePerMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ForcePerLength((double)0.0, ForcePerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -220,7 +214,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForcePerLengthUnit.NewtonPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -264,14 +257,9 @@ public void ForcePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ForcePerLength.Zero, quantityInfo.Zero); Assert.Equal("ForcePerLength", quantityInfo.Name); - Assert.Equal(QuantityType.ForcePerLength, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ForcePerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -683,49 +671,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ForcePerLength.FromNewtonsPerMeter(1); - var b = ForcePerLength.FromNewtonsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ForcePerLength.FromNewtonsPerMeter(1); - var b = ForcePerLength.FromNewtonsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ForcePerLength.FromNewtonsPerMeter(1); - object b = ForcePerLength.FromNewtonsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -755,21 +700,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ForcePerLengthUnit.Undefined, ForcePerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == ForcePerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -783,8 +719,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cN/cm", new ForcePerLength(1, ForcePerLengthUnit.CentinewtonPerCentimeter).ToString()); Assert.Equal("1 cN/m", new ForcePerLength(1, ForcePerLengthUnit.CentinewtonPerMeter).ToString()); @@ -827,7 +763,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -880,10 +816,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s1")); Assert.Equal("0.12 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s2")); Assert.Equal("0.123 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s3")); @@ -891,7 +827,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -905,29 +841,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/m", new ForcePerLength(0.123456, ForcePerLengthUnit.NewtonPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1047,13 +982,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ForcePerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(QuantityType.ForcePerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 38541fa42f..69bde63e5d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -114,12 +114,6 @@ public abstract partial class ForceTestsBase : QuantityTestsBase new object[] { ForceUnit.TonneForce }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Force((double)0.0, ForceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -128,7 +122,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ForceUnit.Newton, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -172,14 +165,9 @@ public void Force_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Force.Zero, quantityInfo.Zero); Assert.Equal("Force", quantityInfo.Name); - Assert.Equal(QuantityType.Force, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ForceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -430,49 +418,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newton.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Force.FromNewtons(1); - var b = Force.FromNewtons(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Force.FromNewtons(1); - var b = Force.FromNewtons(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Force.FromNewtons(1); - object b = Force.FromNewtons(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -502,21 +447,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newton.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ForceUnit.Undefined, Force.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ForceUnit)).Cast(); foreach(var unit in units) { - if(unit == ForceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -530,8 +466,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 daN", new Force(1, ForceUnit.Decanewton).ToString()); Assert.Equal("1 dyn", new Force(1, ForceUnit.Dyn).ToString()); @@ -551,7 +487,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -581,10 +517,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N", new Force(0.123456, ForceUnit.Newton).ToString("s1")); Assert.Equal("0.12 N", new Force(0.123456, ForceUnit.Newton).ToString("s2")); Assert.Equal("0.123 N", new Force(0.123456, ForceUnit.Newton).ToString("s3")); @@ -592,7 +528,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -606,29 +542,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N", new Force(0.123456, ForceUnit.Newton).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Force.FromNewtons(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Force.FromNewtons(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Force.FromNewtons(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -748,13 +683,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ForceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Force.FromNewtons(1.0); - Assert.Equal(QuantityType.Force, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index b98ac9dc61..a3e830dc3f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -98,12 +98,6 @@ public abstract partial class FrequencyTestsBase : QuantityTestsBase new object[] { FrequencyUnit.Terahertz }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Frequency((double)0.0, FrequencyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -112,7 +106,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(FrequencyUnit.Hertz, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -156,14 +149,9 @@ public void Frequency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Frequency.Zero, quantityInfo.Zero); Assert.Equal("Frequency", quantityInfo.Name); - Assert.Equal(QuantityType.Frequency, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {FrequencyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -386,49 +374,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => hertz.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Frequency.FromHertz(1); - var b = Frequency.FromHertz(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Frequency.FromHertz(1); - var b = Frequency.FromHertz(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Frequency.FromHertz(1); - object b = Frequency.FromHertz(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -458,21 +403,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(hertz.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(FrequencyUnit.Undefined, Frequency.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(FrequencyUnit)).Cast(); foreach(var unit in units) { - if(unit == FrequencyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -486,8 +422,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 bpm", new Frequency(1, FrequencyUnit.BeatPerMinute).ToString()); Assert.Equal("1 B Units", new Frequency(1, FrequencyUnit.BUnit).ToString()); @@ -503,7 +439,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -529,10 +465,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s1")); Assert.Equal("0.12 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s2")); Assert.Equal("0.123 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s3")); @@ -540,7 +476,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -554,29 +490,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Hz", new Frequency(0.123456, FrequencyUnit.Hertz).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Frequency.FromHertz(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Frequency.FromHertz(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -696,13 +631,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(FrequencyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal(QuantityType.Frequency, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 3cb1885b6f..743404183b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class FuelEfficiencyTestsBase : QuantityTestsBase new object[] { FuelEfficiencyUnit.MilePerUsGallon }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new FuelEfficiency((double)0.0, FuelEfficiencyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(FuelEfficiencyUnit.LiterPer100Kilometers, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void FuelEfficiency_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(FuelEfficiency.Zero, quantityInfo.Zero); Assert.Equal("FuelEfficiency", quantityInfo.Name); - Assert.Equal(QuantityType.FuelEfficiency, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {FuelEfficiencyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => literper100kilometers.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = FuelEfficiency.FromLitersPer100Kilometers(1); - var b = FuelEfficiency.FromLitersPer100Kilometers(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = FuelEfficiency.FromLitersPer100Kilometers(1); - var b = FuelEfficiency.FromLitersPer100Kilometers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = FuelEfficiency.FromLitersPer100Kilometers(1); - object b = FuelEfficiency.FromLitersPer100Kilometers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(literper100kilometers.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(FuelEfficiencyUnit.Undefined, FuelEfficiency.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast(); foreach(var unit in units) { - if(unit == FuelEfficiencyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 km/L", new FuelEfficiency(1, FuelEfficiencyUnit.KilometerPerLiter).ToString()); Assert.Equal("1 L/100km", new FuelEfficiency(1, FuelEfficiencyUnit.LiterPer100Kilometers).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s1")); Assert.Equal("0.12 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s2")); Assert.Equal("0.123 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 L/100km", new FuelEfficiency(0.123456, FuelEfficiencyUnit.LiterPer100Kilometers).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(FuelEfficiencyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(QuantityType.FuelEfficiency, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 327cc30781..f4493d925c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -126,12 +126,6 @@ public abstract partial class HeatFluxTestsBase : QuantityTestsBase new object[] { HeatFluxUnit.WattPerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new HeatFlux((double)0.0, HeatFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -140,7 +134,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(HeatFluxUnit.WattPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -184,14 +177,9 @@ public void HeatFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(HeatFlux.Zero, quantityInfo.Zero); Assert.Equal("HeatFlux", quantityInfo.Name); - Assert.Equal(QuantityType.HeatFlux, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {HeatFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -463,49 +451,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = HeatFlux.FromWattsPerSquareMeter(1); - var b = HeatFlux.FromWattsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = HeatFlux.FromWattsPerSquareMeter(1); - var b = HeatFlux.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = HeatFlux.FromWattsPerSquareMeter(1); - object b = HeatFlux.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -535,21 +480,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(HeatFluxUnit.Undefined, HeatFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(HeatFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == HeatFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -563,8 +499,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/h·ft²", new HeatFlux(1, HeatFluxUnit.BtuPerHourSquareFoot).ToString()); Assert.Equal("1 BTU/min·ft²", new HeatFlux(1, HeatFluxUnit.BtuPerMinuteSquareFoot).ToString()); @@ -587,7 +523,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -620,10 +556,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s1")); Assert.Equal("0.12 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s2")); Assert.Equal("0.123 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s3")); @@ -631,7 +567,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -645,29 +581,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²", new HeatFlux(0.123456, HeatFluxUnit.WattPerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -787,13 +722,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(HeatFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(QuantityType.HeatFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 5688e459b1..2fa48e4fea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class HeatTransferCoefficientTestsBase : QuantityTestsBa new object[] { HeatTransferCoefficientUnit.WattPerSquareMeterKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new HeatTransferCoefficient((double)0.0, HeatTransferCoefficientUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void HeatTransferCoefficient_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(HeatTransferCoefficient.Zero, quantityInfo.Zero); Assert.Equal("HeatTransferCoefficient", quantityInfo.Name); - Assert.Equal(QuantityType.HeatTransferCoefficient, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {HeatTransferCoefficientUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpersquaremeterkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - var b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1); - object b = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpersquaremeterkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(HeatTransferCoefficientUnit.Undefined, HeatTransferCoefficient.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast(); foreach(var unit in units) { - if(unit == HeatTransferCoefficientUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Btu/ft²·hr·°F", new HeatTransferCoefficient(1, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit).ToString()); Assert.Equal("1 W/m²·°C", new HeatTransferCoefficient(1, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s1")); Assert.Equal("0.12 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s2")); Assert.Equal("0.123 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²·K", new HeatTransferCoefficient(0.123456, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(HeatTransferCoefficientUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(QuantityType.HeatTransferCoefficient, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 5dad5be5cd..706c09e781 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class IlluminanceTestsBase : QuantityTestsBase new object[] { IlluminanceUnit.Millilux }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Illuminance((double)0.0, IlluminanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IlluminanceUnit.Lux, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void Illuminance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Illuminance.Zero, quantityInfo.Zero); Assert.Equal("Illuminance", quantityInfo.Name); - Assert.Equal(QuantityType.Illuminance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {IlluminanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => lux.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Illuminance.FromLux(1); - var b = Illuminance.FromLux(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Illuminance.FromLux(1); - var b = Illuminance.FromLux(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Illuminance.FromLux(1); - object b = Illuminance.FromLux(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(lux.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(IlluminanceUnit.Undefined, Illuminance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(IlluminanceUnit)).Cast(); foreach(var unit in units) { - if(unit == IlluminanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 klx", new Illuminance(1, IlluminanceUnit.Kilolux).ToString()); Assert.Equal("1 lx", new Illuminance(1, IlluminanceUnit.Lux).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s1")); Assert.Equal("0.12 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s2")); Assert.Equal("0.123 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 lx", new Illuminance(0.123456, IlluminanceUnit.Lux).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Illuminance.FromLux(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Illuminance.FromLux(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(IlluminanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal(QuantityType.Illuminance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index d42510c69f..bf0b55b237 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -158,12 +158,6 @@ public abstract partial class InformationTestsBase : QuantityTestsBase new object[] { InformationUnit.Terabyte }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Information((decimal)0.0, InformationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -173,7 +167,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(InformationUnit.Bit, quantity.Unit); } - [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() { @@ -204,14 +197,9 @@ public void Information_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Information.Zero, quantityInfo.Zero); Assert.Equal("Information", quantityInfo.Name); - Assert.Equal(QuantityType.Information, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {InformationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -526,49 +514,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => bit.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Information.FromBits(1); - var b = Information.FromBits(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Information.FromBits(1); - var b = Information.FromBits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Information.FromBits(1); - object b = Information.FromBits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -598,21 +543,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(bit.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(InformationUnit.Undefined, Information.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(InformationUnit)).Cast(); foreach(var unit in units) { - if(unit == InformationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -626,8 +562,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 b", new Information(1, InformationUnit.Bit).ToString()); Assert.Equal("1 B", new Information(1, InformationUnit.Byte).ToString()); @@ -658,7 +594,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -699,10 +635,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 b", new Information(0.123456m, InformationUnit.Bit).ToString("s1")); Assert.Equal("0.12 b", new Information(0.123456m, InformationUnit.Bit).ToString("s2")); Assert.Equal("0.123 b", new Information(0.123456m, InformationUnit.Bit).ToString("s3")); @@ -710,7 +646,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -724,29 +660,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 b", new Information(0.123456m, InformationUnit.Bit).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Information.FromBits(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Information.FromBits(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Information.FromBits(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -866,13 +801,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(InformationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Information.FromBits(1.0); - Assert.Equal(QuantityType.Information, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 6e6f49a82a..a0acd33473 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class IrradianceTestsBase : QuantityTestsBase new object[] { IrradianceUnit.WattPerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Irradiance((double)0.0, IrradianceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IrradianceUnit.WattPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void Irradiance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Irradiance.Zero, quantityInfo.Zero); Assert.Equal("Irradiance", quantityInfo.Name); - Assert.Equal(QuantityType.Irradiance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {IrradianceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Irradiance.FromWattsPerSquareMeter(1); - var b = Irradiance.FromWattsPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Irradiance.FromWattsPerSquareMeter(1); - var b = Irradiance.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Irradiance.FromWattsPerSquareMeter(1); - object b = Irradiance.FromWattsPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(IrradianceUnit.Undefined, Irradiance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(IrradianceUnit)).Cast(); foreach(var unit in units) { - if(unit == IrradianceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kW/cm²", new Irradiance(1, IrradianceUnit.KilowattPerSquareCentimeter).ToString()); Assert.Equal("1 kW/m²", new Irradiance(1, IrradianceUnit.KilowattPerSquareMeter).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s1")); Assert.Equal("0.12 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s2")); Assert.Equal("0.123 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m²", new Irradiance(0.123456, IrradianceUnit.WattPerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(IrradianceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(QuantityType.Irradiance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 1fa8cb53cd..31495a2400 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -82,12 +82,6 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase new object[] { IrradiationUnit.WattHourPerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Irradiation((double)0.0, IrradiationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -96,7 +90,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(IrradiationUnit.JoulePerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -140,14 +133,9 @@ public void Irradiation_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Irradiation.Zero, quantityInfo.Zero); Assert.Equal("Irradiation", quantityInfo.Name); - Assert.Equal(QuantityType.Irradiation, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {IrradiationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -342,49 +330,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Irradiation.FromJoulesPerSquareMeter(1); - var b = Irradiation.FromJoulesPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Irradiation.FromJoulesPerSquareMeter(1); - var b = Irradiation.FromJoulesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Irradiation.FromJoulesPerSquareMeter(1); - object b = Irradiation.FromJoulesPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -414,21 +359,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(IrradiationUnit.Undefined, Irradiation.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(IrradiationUnit)).Cast(); foreach(var unit in units) { - if(unit == IrradiationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -442,8 +378,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 J/cm²", new Irradiation(1, IrradiationUnit.JoulePerSquareCentimeter).ToString()); Assert.Equal("1 J/m²", new Irradiation(1, IrradiationUnit.JoulePerSquareMeter).ToString()); @@ -455,7 +391,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -477,10 +413,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s1")); Assert.Equal("0.12 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s2")); Assert.Equal("0.123 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s3")); @@ -488,7 +424,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -502,29 +438,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/m²", new Irradiation(0.123456, IrradiationUnit.JoulePerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -644,13 +579,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(IrradiationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(QuantityType.Irradiation, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 75b9a0be85..396438bdda 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -90,12 +90,6 @@ public abstract partial class KinematicViscosityTestsBase : QuantityTestsBase new object[] { KinematicViscosityUnit.Stokes }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new KinematicViscosity((double)0.0, KinematicViscosityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -104,7 +98,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(KinematicViscosityUnit.SquareMeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -148,14 +141,9 @@ public void KinematicViscosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(KinematicViscosity.Zero, quantityInfo.Zero); Assert.Equal("KinematicViscosity", quantityInfo.Name); - Assert.Equal(QuantityType.KinematicViscosity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {KinematicViscosityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -364,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => squaremeterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = KinematicViscosity.FromSquareMetersPerSecond(1); - var b = KinematicViscosity.FromSquareMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = KinematicViscosity.FromSquareMetersPerSecond(1); - var b = KinematicViscosity.FromSquareMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = KinematicViscosity.FromSquareMetersPerSecond(1); - object b = KinematicViscosity.FromSquareMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -436,21 +381,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(squaremeterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(KinematicViscosityUnit.Undefined, KinematicViscosity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast(); foreach(var unit in units) { - if(unit == KinematicViscosityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -464,8 +400,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cSt", new KinematicViscosity(1, KinematicViscosityUnit.Centistokes).ToString()); Assert.Equal("1 dSt", new KinematicViscosity(1, KinematicViscosityUnit.Decistokes).ToString()); @@ -479,7 +415,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -503,10 +439,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s1")); Assert.Equal("0.12 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s2")); Assert.Equal("0.123 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s3")); @@ -514,7 +450,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -528,29 +464,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²/s", new KinematicViscosity(0.123456, KinematicViscosityUnit.SquareMeterPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -670,13 +605,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(KinematicViscosityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(QuantityType.KinematicViscosity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index abd317b6b1..8e23c0ff48 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class LapseRateTestsBase : QuantityTestsBase new object[] { LapseRateUnit.DegreeCelsiusPerKilometer }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LapseRate((double)0.0, LapseRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LapseRateUnit.DegreeCelsiusPerKilometer, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void LapseRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LapseRate.Zero, quantityInfo.Zero); Assert.Equal("LapseRate", quantityInfo.Name); - Assert.Equal(QuantityType.LapseRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LapseRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => degreecelsiusperkilometer.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LapseRate.FromDegreesCelciusPerKilometer(1); - var b = LapseRate.FromDegreesCelciusPerKilometer(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LapseRate.FromDegreesCelciusPerKilometer(1); - var b = LapseRate.FromDegreesCelciusPerKilometer(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LapseRate.FromDegreesCelciusPerKilometer(1); - object b = LapseRate.FromDegreesCelciusPerKilometer(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(degreecelsiusperkilometer.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LapseRateUnit.Undefined, LapseRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LapseRateUnit)).Cast(); foreach(var unit in units) { - if(unit == LapseRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ∆°C/km", new LapseRate(1, LapseRateUnit.DegreeCelsiusPerKilometer).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s1")); Assert.Equal("0.12 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s2")); Assert.Equal("0.123 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆°C/km", new LapseRate(0.123456, LapseRateUnit.DegreeCelsiusPerKilometer).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LapseRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(QuantityType.LapseRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 4c7526e104..69eb087cd4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -186,12 +186,6 @@ public abstract partial class LengthTestsBase : QuantityTestsBase new object[] { LengthUnit.Yard }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Length((double)0.0, LengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -200,7 +194,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LengthUnit.Meter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -244,14 +237,9 @@ public void Length_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Length.Zero, quantityInfo.Zero); Assert.Equal("Length", quantityInfo.Name); - Assert.Equal(QuantityType.Length, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -628,49 +616,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => meter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Length.FromMeters(1); - var b = Length.FromMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Length.FromMeters(1); - var b = Length.FromMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Length.FromMeters(1); - object b = Length.FromMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -700,21 +645,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(meter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LengthUnit.Undefined, Length.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LengthUnit)).Cast(); foreach(var unit in units) { - if(unit == LengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -728,8 +664,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 au", new Length(1, LengthUnit.AstronomicalUnit).ToString()); Assert.Equal("1 cm", new Length(1, LengthUnit.Centimeter).ToString()); @@ -767,7 +703,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -815,10 +751,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m", new Length(0.123456, LengthUnit.Meter).ToString("s1")); Assert.Equal("0.12 m", new Length(0.123456, LengthUnit.Meter).ToString("s2")); Assert.Equal("0.123 m", new Length(0.123456, LengthUnit.Meter).ToString("s3")); @@ -826,7 +762,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -840,29 +776,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m", new Length(0.123456, LengthUnit.Meter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Length.FromMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Length.FromMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Length.FromMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -982,13 +917,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Length.FromMeters(1.0); - Assert.Equal(QuantityType.Length, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 27aca88bbf..222902e19f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -62,12 +62,6 @@ public abstract partial class LevelTestsBase : QuantityTestsBase new object[] { LevelUnit.Neper }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Level((double)0.0, LevelUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -76,7 +70,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LevelUnit.Decibel, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -120,14 +113,9 @@ public void Level_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Level.Zero, quantityInfo.Zero); Assert.Equal("Level", quantityInfo.Name); - Assert.Equal(QuantityType.Level, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LevelUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -291,49 +279,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decibel.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Level.FromDecibels(1); - var b = Level.FromDecibels(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Level.FromDecibels(1); - var b = Level.FromDecibels(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Level.FromDecibels(1); - object b = Level.FromDecibels(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -363,21 +308,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibel.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LevelUnit.Undefined, Level.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LevelUnit)).Cast(); foreach(var unit in units) { - if(unit == LevelUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -391,15 +327,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 dB", new Level(1, LevelUnit.Decibel).ToString()); Assert.Equal("1 Np", new Level(1, LevelUnit.Neper).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -416,10 +352,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s1")); Assert.Equal("0.12 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s2")); Assert.Equal("0.123 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s3")); @@ -427,7 +363,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -441,29 +377,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dB", new Level(0.123456, LevelUnit.Decibel).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Level.FromDecibels(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Level.FromDecibels(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Level.FromDecibels(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -583,13 +518,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LevelUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Level.FromDecibels(1.0); - Assert.Equal(QuantityType.Level, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 94e1aab652..f4379dc545 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class LinearDensityTestsBase : QuantityTestsBase new object[] { LinearDensityUnit.PoundPerInch }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LinearDensity((double)0.0, LinearDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LinearDensityUnit.KilogramPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void LinearDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LinearDensity.Zero, quantityInfo.Zero); Assert.Equal("LinearDensity", quantityInfo.Name); - Assert.Equal(QuantityType.LinearDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LinearDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LinearDensity.FromKilogramsPerMeter(1); - var b = LinearDensity.FromKilogramsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LinearDensity.FromKilogramsPerMeter(1); - var b = LinearDensity.FromKilogramsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LinearDensity.FromKilogramsPerMeter(1); - object b = LinearDensity.FromKilogramsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LinearDensityUnit.Undefined, LinearDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LinearDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == LinearDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g/cm", new LinearDensity(1, LinearDensityUnit.GramPerCentimeter).ToString()); Assert.Equal("1 g/m", new LinearDensity(1, LinearDensityUnit.GramPerMeter).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s1")); Assert.Equal("0.12 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s2")); Assert.Equal("0.123 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m", new LinearDensity(0.123456, LinearDensityUnit.KilogramPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LinearDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(QuantityType.LinearDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 9ced6699e2..cd8fa346f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -154,12 +154,6 @@ public abstract partial class LinearPowerDensityTestsBase : QuantityTestsBase new object[] { LinearPowerDensityUnit.WattPerMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LinearPowerDensity((double)0.0, LinearPowerDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -168,7 +162,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LinearPowerDensityUnit.WattPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -212,14 +205,9 @@ public void LinearPowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(LinearPowerDensity.Zero, quantityInfo.Zero); Assert.Equal("LinearPowerDensity", quantityInfo.Name); - Assert.Equal(QuantityType.LinearPowerDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LinearPowerDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -540,49 +528,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LinearPowerDensity.FromWattsPerMeter(1); - var b = LinearPowerDensity.FromWattsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LinearPowerDensity.FromWattsPerMeter(1); - var b = LinearPowerDensity.FromWattsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LinearPowerDensity.FromWattsPerMeter(1); - object b = LinearPowerDensity.FromWattsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -612,21 +557,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LinearPowerDensityUnit.Undefined, LinearPowerDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == LinearPowerDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -640,8 +576,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 GW/cm", new LinearPowerDensity(1, LinearPowerDensityUnit.GigawattPerCentimeter).ToString()); Assert.Equal("1 GW/ft", new LinearPowerDensity(1, LinearPowerDensityUnit.GigawattPerFoot).ToString()); @@ -671,7 +607,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -711,10 +647,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s1")); Assert.Equal("0.12 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s2")); Assert.Equal("0.123 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s3")); @@ -722,7 +658,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -736,29 +672,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m", new LinearPowerDensity(0.123456, LinearPowerDensityUnit.WattPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -878,13 +813,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LinearPowerDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(QuantityType.LinearPowerDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 28c34e2b5c..dd6dfd4fdc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class LuminosityTestsBase : QuantityTestsBase new object[] { LuminosityUnit.Watt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Luminosity((double)0.0, LuminosityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminosityUnit.Watt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void Luminosity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Luminosity.Zero, quantityInfo.Zero); Assert.Equal("Luminosity", quantityInfo.Name); - Assert.Equal(QuantityType.Luminosity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LuminosityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => watt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Luminosity.FromWatts(1); - var b = Luminosity.FromWatts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Luminosity.FromWatts(1); - var b = Luminosity.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Luminosity.FromWatts(1); - object b = Luminosity.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(watt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LuminosityUnit.Undefined, Luminosity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LuminosityUnit)).Cast(); foreach(var unit in units) { - if(unit == LuminosityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 daW", new Luminosity(1, LuminosityUnit.Decawatt).ToString()); Assert.Equal("1 dW", new Luminosity(1, LuminosityUnit.Deciwatt).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s1")); Assert.Equal("0.12 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s2")); Assert.Equal("0.123 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W", new Luminosity(0.123456, LuminosityUnit.Watt).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Luminosity.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Luminosity.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminosityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(QuantityType.Luminosity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 4cbf4ecf65..b43cd4a72b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class LuminousFluxTestsBase : QuantityTestsBase new object[] { LuminousFluxUnit.Lumen }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LuminousFlux((double)0.0, LuminousFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminousFluxUnit.Lumen, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void LuminousFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(LuminousFlux.Zero, quantityInfo.Zero); Assert.Equal("LuminousFlux", quantityInfo.Name); - Assert.Equal(QuantityType.LuminousFlux, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LuminousFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => lumen.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LuminousFlux.FromLumens(1); - var b = LuminousFlux.FromLumens(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LuminousFlux.FromLumens(1); - var b = LuminousFlux.FromLumens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LuminousFlux.FromLumens(1); - object b = LuminousFlux.FromLumens(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(lumen.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LuminousFluxUnit.Undefined, LuminousFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LuminousFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == LuminousFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 lm", new LuminousFlux(1, LuminousFluxUnit.Lumen).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s1")); Assert.Equal("0.12 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s2")); Assert.Equal("0.123 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 lm", new LuminousFlux(0.123456, LuminousFluxUnit.Lumen).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminousFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(QuantityType.LuminousFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 6b4462baa1..6919b51bdf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class LuminousIntensityTestsBase : QuantityTestsBase new object[] { LuminousIntensityUnit.Candela }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new LuminousIntensity((double)0.0, LuminousIntensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(LuminousIntensityUnit.Candela, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void LuminousIntensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(LuminousIntensity.Zero, quantityInfo.Zero); Assert.Equal("LuminousIntensity", quantityInfo.Name); - Assert.Equal(QuantityType.LuminousIntensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {LuminousIntensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => candela.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = LuminousIntensity.FromCandela(1); - var b = LuminousIntensity.FromCandela(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = LuminousIntensity.FromCandela(1); - var b = LuminousIntensity.FromCandela(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = LuminousIntensity.FromCandela(1); - object b = LuminousIntensity.FromCandela(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(candela.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(LuminousIntensityUnit.Undefined, LuminousIntensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast(); foreach(var unit in units) { - if(unit == LuminousIntensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cd", new LuminousIntensity(1, LuminousIntensityUnit.Candela).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s1")); Assert.Equal("0.12 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s2")); Assert.Equal("0.123 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 cd", new LuminousIntensity(0.123456, LuminousIntensityUnit.Candela).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(LuminousIntensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(QuantityType.LuminousIntensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 535a956905..85851a709b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -78,12 +78,6 @@ public abstract partial class MagneticFieldTestsBase : QuantityTestsBase new object[] { MagneticFieldUnit.Tesla }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MagneticField((double)0.0, MagneticFieldUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -92,7 +86,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagneticFieldUnit.Tesla, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -136,14 +129,9 @@ public void MagneticField_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MagneticField.Zero, quantityInfo.Zero); Assert.Equal("MagneticField", quantityInfo.Name); - Assert.Equal(QuantityType.MagneticField, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFieldUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -331,49 +319,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => tesla.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MagneticField.FromTeslas(1); - var b = MagneticField.FromTeslas(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MagneticField.FromTeslas(1); - var b = MagneticField.FromTeslas(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MagneticField.FromTeslas(1); - object b = MagneticField.FromTeslas(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -403,21 +348,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(tesla.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MagneticFieldUnit.Undefined, MagneticField.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MagneticFieldUnit)).Cast(); foreach(var unit in units) { - if(unit == MagneticFieldUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -431,8 +367,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 G", new MagneticField(1, MagneticFieldUnit.Gauss).ToString()); Assert.Equal("1 µT", new MagneticField(1, MagneticFieldUnit.Microtesla).ToString()); @@ -443,7 +379,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -464,10 +400,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s1")); Assert.Equal("0.12 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s2")); Assert.Equal("0.123 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s3")); @@ -475,7 +411,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -489,29 +425,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 T", new MagneticField(0.123456, MagneticFieldUnit.Tesla).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MagneticField.FromTeslas(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -631,13 +566,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagneticFieldUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(QuantityType.MagneticField, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 53cceaa13a..674c9b33fd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class MagneticFluxTestsBase : QuantityTestsBase new object[] { MagneticFluxUnit.Weber }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MagneticFlux((double)0.0, MagneticFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagneticFluxUnit.Weber, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void MagneticFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MagneticFlux.Zero, quantityInfo.Zero); Assert.Equal("MagneticFlux", quantityInfo.Name); - Assert.Equal(QuantityType.MagneticFlux, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MagneticFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => weber.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MagneticFlux.FromWebers(1); - var b = MagneticFlux.FromWebers(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MagneticFlux.FromWebers(1); - var b = MagneticFlux.FromWebers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MagneticFlux.FromWebers(1); - object b = MagneticFlux.FromWebers(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(weber.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MagneticFluxUnit.Undefined, MagneticFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MagneticFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == MagneticFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Wb", new MagneticFlux(1, MagneticFluxUnit.Weber).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s1")); Assert.Equal("0.12 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s2")); Assert.Equal("0.123 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Wb", new MagneticFlux(0.123456, MagneticFluxUnit.Weber).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagneticFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(QuantityType.MagneticFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index f77864e13f..22e0854306 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class MagnetizationTestsBase : QuantityTestsBase new object[] { MagnetizationUnit.AmperePerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Magnetization((double)0.0, MagnetizationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MagnetizationUnit.AmperePerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void Magnetization_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Magnetization.Zero, quantityInfo.Zero); Assert.Equal("Magnetization", quantityInfo.Name); - Assert.Equal(QuantityType.Magnetization, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MagnetizationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amperepermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Magnetization.FromAmperesPerMeter(1); - var b = Magnetization.FromAmperesPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Magnetization.FromAmperesPerMeter(1); - var b = Magnetization.FromAmperesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Magnetization.FromAmperesPerMeter(1); - object b = Magnetization.FromAmperesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amperepermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MagnetizationUnit.Undefined, Magnetization.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MagnetizationUnit)).Cast(); foreach(var unit in units) { - if(unit == MagnetizationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 A/m", new Magnetization(1, MagnetizationUnit.AmperePerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s1")); Assert.Equal("0.12 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s2")); Assert.Equal("0.123 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 A/m", new Magnetization(0.123456, MagnetizationUnit.AmperePerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MagnetizationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(QuantityType.Magnetization, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 8281d5947a..345e708967 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -250,12 +250,6 @@ public abstract partial class MassConcentrationTestsBase : QuantityTestsBase new object[] { MassConcentrationUnit.TonnePerCubicMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassConcentration((double)0.0, MassConcentrationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -264,7 +258,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassConcentrationUnit.KilogramPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -308,14 +301,9 @@ public void MassConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(MassConcentration.Zero, quantityInfo.Zero); Assert.Equal("MassConcentration", quantityInfo.Name); - Assert.Equal(QuantityType.MassConcentration, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MassConcentrationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -804,49 +792,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassConcentration.FromKilogramsPerCubicMeter(1); - var b = MassConcentration.FromKilogramsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassConcentration.FromKilogramsPerCubicMeter(1); - var b = MassConcentration.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassConcentration.FromKilogramsPerCubicMeter(1); - object b = MassConcentration.FromKilogramsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -876,21 +821,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassConcentrationUnit.Undefined, MassConcentration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassConcentrationUnit)).Cast(); foreach(var unit in units) { - if(unit == MassConcentrationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -904,8 +840,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/dL", new MassConcentration(1, MassConcentrationUnit.CentigramPerDeciliter).ToString()); Assert.Equal("1 cg/L", new MassConcentration(1, MassConcentrationUnit.CentigramPerLiter).ToString()); @@ -959,7 +895,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1023,10 +959,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s1")); Assert.Equal("0.12 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s2")); Assert.Equal("0.123 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s3")); @@ -1034,7 +970,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1048,29 +984,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/m³", new MassConcentration(0.123456, MassConcentrationUnit.KilogramPerCubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1190,13 +1125,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassConcentrationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(QuantityType.MassConcentration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 8ca2653751..b6fedd0138 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -186,12 +186,6 @@ public abstract partial class MassFlowTestsBase : QuantityTestsBase new object[] { MassFlowUnit.TonnePerHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassFlow((double)0.0, MassFlowUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -200,7 +194,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFlowUnit.GramPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -244,14 +237,9 @@ public void MassFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFlow.Zero, quantityInfo.Zero); Assert.Equal("MassFlow", quantityInfo.Name); - Assert.Equal(QuantityType.MassFlow, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MassFlowUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -628,49 +616,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => grampersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassFlow.FromGramsPerSecond(1); - var b = MassFlow.FromGramsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassFlow.FromGramsPerSecond(1); - var b = MassFlow.FromGramsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassFlow.FromGramsPerSecond(1); - object b = MassFlow.FromGramsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -700,21 +645,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(grampersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassFlowUnit.Undefined, MassFlow.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassFlowUnit)).Cast(); foreach(var unit in units) { - if(unit == MassFlowUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -728,8 +664,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/d", new MassFlow(1, MassFlowUnit.CentigramPerDay).ToString()); Assert.Equal("1 cg/s", new MassFlow(1, MassFlowUnit.CentigramPerSecond).ToString()); @@ -767,7 +703,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -815,10 +751,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s1")); Assert.Equal("0.12 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s2")); Assert.Equal("0.123 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s3")); @@ -826,7 +762,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -840,29 +776,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 g/s", new MassFlow(0.123456, MassFlowUnit.GramPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -982,13 +917,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassFlowUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(QuantityType.MassFlow, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index e4ee54db7d..3ca2bd3623 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -102,12 +102,6 @@ public abstract partial class MassFluxTestsBase : QuantityTestsBase new object[] { MassFluxUnit.KilogramPerSecondPerSquareMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassFlux((double)0.0, MassFluxUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -116,7 +110,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFluxUnit.KilogramPerSecondPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -160,14 +153,9 @@ public void MassFlux_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFlux.Zero, quantityInfo.Zero); Assert.Equal("MassFlux", quantityInfo.Name); - Assert.Equal(QuantityType.MassFlux, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MassFluxUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -397,49 +385,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampersecondpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - var b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassFlux.FromKilogramsPerSecondPerSquareMeter(1); - object b = MassFlux.FromKilogramsPerSecondPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -469,21 +414,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampersecondpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassFluxUnit.Undefined, MassFlux.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassFluxUnit)).Cast(); foreach(var unit in units) { - if(unit == MassFluxUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -497,8 +433,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g·h⁻¹·cm⁻²", new MassFlux(1, MassFluxUnit.GramPerHourPerSquareCentimeter).ToString()); Assert.Equal("1 g·h⁻¹·m⁻²", new MassFlux(1, MassFluxUnit.GramPerHourPerSquareMeter).ToString()); @@ -515,7 +451,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -542,10 +478,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s1")); Assert.Equal("0.12 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s2")); Assert.Equal("0.123 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s3")); @@ -553,7 +489,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -567,29 +503,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg·s⁻¹·m⁻²", new MassFlux(0.123456, MassFluxUnit.KilogramPerSecondPerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -709,13 +644,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassFluxUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(QuantityType.MassFlux, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 2e1f094d53..59f2ba1f43 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -150,12 +150,6 @@ public abstract partial class MassFractionTestsBase : QuantityTestsBase new object[] { MassFractionUnit.Percent }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassFraction((double)0.0, MassFractionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -164,7 +158,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassFractionUnit.DecimalFraction, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -208,14 +201,9 @@ public void MassFraction_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MassFraction.Zero, quantityInfo.Zero); Assert.Equal("MassFraction", quantityInfo.Name); - Assert.Equal(QuantityType.MassFraction, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MassFractionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -529,49 +517,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfraction.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassFraction.FromDecimalFractions(1); - var b = MassFraction.FromDecimalFractions(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassFraction.FromDecimalFractions(1); - var b = MassFraction.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassFraction.FromDecimalFractions(1); - object b = MassFraction.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -601,21 +546,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassFractionUnit.Undefined, MassFraction.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassFractionUnit)).Cast(); foreach(var unit in units) { - if(unit == MassFractionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -629,8 +565,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/g", new MassFraction(1, MassFractionUnit.CentigramPerGram).ToString()); Assert.Equal("1 cg/kg", new MassFraction(1, MassFractionUnit.CentigramPerKilogram).ToString()); @@ -659,7 +595,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -698,10 +634,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s1")); Assert.Equal("0.12", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s2")); Assert.Equal("0.123", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s3")); @@ -709,7 +645,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -723,29 +659,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new MassFraction(0.123456, MassFractionUnit.DecimalFraction).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -865,13 +800,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassFractionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(QuantityType.MassFraction, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index f4b8bb0263..1b9cb17886 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -166,12 +166,6 @@ public abstract partial class MassMomentOfInertiaTestsBase : QuantityTestsBase new object[] { MassMomentOfInertiaUnit.TonneSquareMilimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MassMomentOfInertia((double)0.0, MassMomentOfInertiaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -180,7 +174,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassMomentOfInertiaUnit.KilogramSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -224,14 +217,9 @@ public void MassMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(MassMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("MassMomentOfInertia", quantityInfo.Name); - Assert.Equal(QuantityType.MassMomentOfInertia, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MassMomentOfInertiaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -573,49 +561,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogramsquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MassMomentOfInertia.FromKilogramSquareMeters(1); - var b = MassMomentOfInertia.FromKilogramSquareMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MassMomentOfInertia.FromKilogramSquareMeters(1); - var b = MassMomentOfInertia.FromKilogramSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MassMomentOfInertia.FromKilogramSquareMeters(1); - object b = MassMomentOfInertia.FromKilogramSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -645,21 +590,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogramsquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassMomentOfInertiaUnit.Undefined, MassMomentOfInertia.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast(); foreach(var unit in units) { - if(unit == MassMomentOfInertiaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -673,8 +609,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g·cm²", new MassMomentOfInertia(1, MassMomentOfInertiaUnit.GramSquareCentimeter).ToString()); Assert.Equal("1 g·dm²", new MassMomentOfInertia(1, MassMomentOfInertiaUnit.GramSquareDecimeter).ToString()); @@ -707,7 +643,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -750,10 +686,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s1")); Assert.Equal("0.12 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s2")); Assert.Equal("0.123 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s3")); @@ -761,7 +697,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -775,29 +711,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg·m²", new MassMomentOfInertia(0.123456, MassMomentOfInertiaUnit.KilogramSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -917,13 +852,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassMomentOfInertiaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(QuantityType.MassMomentOfInertia, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index ae7364df1b..fa3a664518 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -154,12 +154,6 @@ public abstract partial class MassTestsBase : QuantityTestsBase new object[] { MassUnit.Tonne }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Mass((double)0.0, MassUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -168,7 +162,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MassUnit.Kilogram, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -212,14 +205,9 @@ public void Mass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Mass.Zero, quantityInfo.Zero); Assert.Equal("Mass", quantityInfo.Name); - Assert.Equal(QuantityType.Mass, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MassUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -540,49 +528,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogram.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Mass.FromKilograms(1); - var b = Mass.FromKilograms(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Mass.FromKilograms(1); - var b = Mass.FromKilograms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Mass.FromKilograms(1); - object b = Mass.FromKilograms(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -612,21 +557,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogram.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MassUnit.Undefined, Mass.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MassUnit)).Cast(); foreach(var unit in units) { - if(unit == MassUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -640,8 +576,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg", new Mass(1, MassUnit.Centigram).ToString()); Assert.Equal("1 dag", new Mass(1, MassUnit.Decagram).ToString()); @@ -671,7 +607,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -711,10 +647,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s1")); Assert.Equal("0.12 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s2")); Assert.Equal("0.123 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s3")); @@ -722,7 +658,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -736,29 +672,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg", new Mass(0.123456, MassUnit.Kilogram).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Mass.FromKilograms(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Mass.FromKilograms(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -878,13 +813,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MassUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal(QuantityType.Mass, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index fdbfa2178c..f2b7eb3230 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class MolarEnergyTestsBase : QuantityTestsBase new object[] { MolarEnergyUnit.MegajoulePerMole }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MolarEnergy((double)0.0, MolarEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarEnergyUnit.JoulePerMole, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void MolarEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarEnergy.Zero, quantityInfo.Zero); Assert.Equal("MolarEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.MolarEnergy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepermole.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MolarEnergy.FromJoulesPerMole(1); - var b = MolarEnergy.FromJoulesPerMole(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MolarEnergy.FromJoulesPerMole(1); - var b = MolarEnergy.FromJoulesPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MolarEnergy.FromJoulesPerMole(1); - object b = MolarEnergy.FromJoulesPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepermole.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarEnergyUnit.Undefined, MolarEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 J/mol", new MolarEnergy(1, MolarEnergyUnit.JoulePerMole).ToString()); Assert.Equal("1 kJ/mol", new MolarEnergy(1, MolarEnergyUnit.KilojoulePerMole).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s1")); Assert.Equal("0.12 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s2")); Assert.Equal("0.123 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/mol", new MolarEnergy(0.123456, MolarEnergyUnit.JoulePerMole).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(QuantityType.MolarEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 93ef01239e..09a1a538b7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class MolarEntropyTestsBase : QuantityTestsBase new object[] { MolarEntropyUnit.MegajoulePerMoleKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MolarEntropy((double)0.0, MolarEntropyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarEntropyUnit.JoulePerMoleKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void MolarEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarEntropy.Zero, quantityInfo.Zero); Assert.Equal("MolarEntropy", quantityInfo.Name); - Assert.Equal(QuantityType.MolarEntropy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarEntropyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepermolekelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MolarEntropy.FromJoulesPerMoleKelvin(1); - var b = MolarEntropy.FromJoulesPerMoleKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MolarEntropy.FromJoulesPerMoleKelvin(1); - var b = MolarEntropy.FromJoulesPerMoleKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MolarEntropy.FromJoulesPerMoleKelvin(1); - object b = MolarEntropy.FromJoulesPerMoleKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepermolekelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarEntropyUnit.Undefined, MolarEntropy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarEntropyUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarEntropyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 J/(mol*K)", new MolarEntropy(1, MolarEntropyUnit.JoulePerMoleKelvin).ToString()); Assert.Equal("1 kJ/(mol*K)", new MolarEntropy(1, MolarEntropyUnit.KilojoulePerMoleKelvin).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s1")); Assert.Equal("0.12 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s2")); Assert.Equal("0.123 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/(mol*K)", new MolarEntropy(0.123456, MolarEntropyUnit.JoulePerMoleKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarEntropyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(QuantityType.MolarEntropy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index b6b58539ad..132a796ed7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -102,12 +102,6 @@ public abstract partial class MolarMassTestsBase : QuantityTestsBase new object[] { MolarMassUnit.PoundPerMole }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new MolarMass((double)0.0, MolarMassUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -116,7 +110,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarMassUnit.KilogramPerMole, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -160,14 +153,9 @@ public void MolarMass_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(MolarMass.Zero, quantityInfo.Zero); Assert.Equal("MolarMass", quantityInfo.Name); - Assert.Equal(QuantityType.MolarMass, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarMassUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -397,49 +385,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kilogrampermole.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = MolarMass.FromKilogramsPerMole(1); - var b = MolarMass.FromKilogramsPerMole(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = MolarMass.FromKilogramsPerMole(1); - var b = MolarMass.FromKilogramsPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = MolarMass.FromKilogramsPerMole(1); - object b = MolarMass.FromKilogramsPerMole(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -469,21 +414,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kilogrampermole.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarMassUnit.Undefined, MolarMass.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarMassUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarMassUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -497,8 +433,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cg/mol", new MolarMass(1, MolarMassUnit.CentigramPerMole).ToString()); Assert.Equal("1 dag/mol", new MolarMass(1, MolarMassUnit.DecagramPerMole).ToString()); @@ -515,7 +451,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -542,10 +478,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s1")); Assert.Equal("0.12 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s2")); Assert.Equal("0.123 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s3")); @@ -553,7 +489,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -567,29 +503,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 kg/mol", new MolarMass(0.123456, MolarMassUnit.KilogramPerMole).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -709,13 +644,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarMassUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(QuantityType.MolarMass, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index f0592f4211..38bf769616 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -86,12 +86,6 @@ public abstract partial class MolarityTestsBase : QuantityTestsBase new object[] { MolarityUnit.PicomolesPerLiter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Molarity((double)0.0, MolarityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -100,7 +94,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(MolarityUnit.MolesPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -144,14 +137,9 @@ public void Molarity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Molarity.Zero, quantityInfo.Zero); Assert.Equal("Molarity", quantityInfo.Name); - Assert.Equal(QuantityType.Molarity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {MolarityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -353,49 +341,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => molespercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Molarity.FromMolesPerCubicMeter(1); - var b = Molarity.FromMolesPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Molarity.FromMolesPerCubicMeter(1); - var b = Molarity.FromMolesPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Molarity.FromMolesPerCubicMeter(1); - object b = Molarity.FromMolesPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -425,21 +370,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(molespercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(MolarityUnit.Undefined, Molarity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(MolarityUnit)).Cast(); foreach(var unit in units) { - if(unit == MolarityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -453,8 +389,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cmol/L", new Molarity(1, MolarityUnit.CentimolesPerLiter).ToString()); Assert.Equal("1 dmol/L", new Molarity(1, MolarityUnit.DecimolesPerLiter).ToString()); @@ -467,7 +403,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -490,10 +426,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s1")); Assert.Equal("0.12 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s2")); Assert.Equal("0.123 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s3")); @@ -501,7 +437,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -515,29 +451,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 mol/m³", new Molarity(0.123456, MolarityUnit.MolesPerCubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -657,13 +592,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(MolarityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(QuantityType.Molarity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index bfc744d102..0afdd91818 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class PermeabilityTestsBase : QuantityTestsBase new object[] { PermeabilityUnit.HenryPerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Permeability((double)0.0, PermeabilityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PermeabilityUnit.HenryPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void Permeability_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Permeability.Zero, quantityInfo.Zero); Assert.Equal("Permeability", quantityInfo.Name); - Assert.Equal(QuantityType.Permeability, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PermeabilityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => henrypermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Permeability.FromHenriesPerMeter(1); - var b = Permeability.FromHenriesPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Permeability.FromHenriesPerMeter(1); - var b = Permeability.FromHenriesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Permeability.FromHenriesPerMeter(1); - object b = Permeability.FromHenriesPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(henrypermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PermeabilityUnit.Undefined, Permeability.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PermeabilityUnit)).Cast(); foreach(var unit in units) { - if(unit == PermeabilityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 H/m", new Permeability(1, PermeabilityUnit.HenryPerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s1")); Assert.Equal("0.12 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s2")); Assert.Equal("0.123 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 H/m", new Permeability(0.123456, PermeabilityUnit.HenryPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PermeabilityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(QuantityType.Permeability, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 553dc76b6c..5cb2b7a6d3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class PermittivityTestsBase : QuantityTestsBase new object[] { PermittivityUnit.FaradPerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Permittivity((double)0.0, PermittivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PermittivityUnit.FaradPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void Permittivity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Permittivity.Zero, quantityInfo.Zero); Assert.Equal("Permittivity", quantityInfo.Name); - Assert.Equal(QuantityType.Permittivity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PermittivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => faradpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Permittivity.FromFaradsPerMeter(1); - var b = Permittivity.FromFaradsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Permittivity.FromFaradsPerMeter(1); - var b = Permittivity.FromFaradsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Permittivity.FromFaradsPerMeter(1); - object b = Permittivity.FromFaradsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(faradpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PermittivityUnit.Undefined, Permittivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PermittivityUnit)).Cast(); foreach(var unit in units) { - if(unit == PermittivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 F/m", new Permittivity(1, PermittivityUnit.FaradPerMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s1")); Assert.Equal("0.12 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s2")); Assert.Equal("0.123 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 F/m", new Permittivity(0.123456, PermittivityUnit.FaradPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PermittivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(QuantityType.Permittivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 5a479b3bc7..fac82cd29b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -230,12 +230,6 @@ public abstract partial class PowerDensityTestsBase : QuantityTestsBase new object[] { PowerDensityUnit.WattPerLiter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new PowerDensity((double)0.0, PowerDensityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -244,7 +238,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerDensityUnit.WattPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -288,14 +281,9 @@ public void PowerDensity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(PowerDensity.Zero, quantityInfo.Zero); Assert.Equal("PowerDensity", quantityInfo.Name); - Assert.Equal(QuantityType.PowerDensity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PowerDensityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -749,49 +737,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = PowerDensity.FromWattsPerCubicMeter(1); - var b = PowerDensity.FromWattsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = PowerDensity.FromWattsPerCubicMeter(1); - var b = PowerDensity.FromWattsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = PowerDensity.FromWattsPerCubicMeter(1); - object b = PowerDensity.FromWattsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -821,21 +766,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PowerDensityUnit.Undefined, PowerDensity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PowerDensityUnit)).Cast(); foreach(var unit in units) { - if(unit == PowerDensityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -849,8 +785,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 daW/ft³", new PowerDensity(1, PowerDensityUnit.DecawattPerCubicFoot).ToString()); Assert.Equal("1 daW/in³", new PowerDensity(1, PowerDensityUnit.DecawattPerCubicInch).ToString()); @@ -899,7 +835,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -958,10 +894,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s1")); Assert.Equal("0.12 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s2")); Assert.Equal("0.123 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s3")); @@ -969,7 +905,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -983,29 +919,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m³", new PowerDensity(0.123456, PowerDensityUnit.WattPerCubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1125,13 +1060,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerDensityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(QuantityType.PowerDensity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 2105344f09..91dd5509f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -62,12 +62,6 @@ public abstract partial class PowerRatioTestsBase : QuantityTestsBase new object[] { PowerRatioUnit.DecibelWatt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new PowerRatio((double)0.0, PowerRatioUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -76,7 +70,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerRatioUnit.DecibelWatt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -120,14 +113,9 @@ public void PowerRatio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(PowerRatio.Zero, quantityInfo.Zero); Assert.Equal("PowerRatio", quantityInfo.Name); - Assert.Equal(QuantityType.PowerRatio, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PowerRatioUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -291,49 +279,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decibelwatt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = PowerRatio.FromDecibelWatts(1); - var b = PowerRatio.FromDecibelWatts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = PowerRatio.FromDecibelWatts(1); - var b = PowerRatio.FromDecibelWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = PowerRatio.FromDecibelWatts(1); - object b = PowerRatio.FromDecibelWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -363,21 +308,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decibelwatt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PowerRatioUnit.Undefined, PowerRatio.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PowerRatioUnit)).Cast(); foreach(var unit in units) { - if(unit == PowerRatioUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -391,15 +327,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 dBmW", new PowerRatio(1, PowerRatioUnit.DecibelMilliwatt).ToString()); Assert.Equal("1 dBW", new PowerRatio(1, PowerRatioUnit.DecibelWatt).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -416,10 +352,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s1")); Assert.Equal("0.12 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s2")); Assert.Equal("0.123 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s3")); @@ -427,7 +363,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -441,29 +377,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 dBW", new PowerRatio(0.123456, PowerRatioUnit.DecibelWatt).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -583,13 +518,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerRatioUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(QuantityType.PowerRatio, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 7dcfd7a6a4..05f9eda632 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -154,12 +154,6 @@ public abstract partial class PowerTestsBase : QuantityTestsBase new object[] { PowerUnit.Watt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Power((decimal)0.0, PowerUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -169,7 +163,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PowerUnit.Watt, quantity.Unit); } - [Fact] public void Ctor_NullAsUnitSystem_ThrowsArgumentNullException() { @@ -200,14 +193,9 @@ public void Power_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Power.Zero, quantityInfo.Zero); Assert.Equal("Power", quantityInfo.Name); - Assert.Equal(QuantityType.Power, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PowerUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -515,49 +503,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => watt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Power.FromWatts(1); - var b = Power.FromWatts(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Power.FromWatts(1); - var b = Power.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Power.FromWatts(1); - object b = Power.FromWatts(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -587,21 +532,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(watt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PowerUnit.Undefined, Power.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PowerUnit)).Cast(); foreach(var unit in units) { - if(unit == PowerUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -615,8 +551,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 hp(S)", new Power(1, PowerUnit.BoilerHorsepower).ToString()); Assert.Equal("1 Btu/h", new Power(1, PowerUnit.BritishThermalUnitPerHour).ToString()); @@ -646,7 +582,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -686,10 +622,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W", new Power(0.123456m, PowerUnit.Watt).ToString("s1")); Assert.Equal("0.12 W", new Power(0.123456m, PowerUnit.Watt).ToString("s2")); Assert.Equal("0.123 W", new Power(0.123456m, PowerUnit.Watt).ToString("s3")); @@ -697,7 +633,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -711,29 +647,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W", new Power(0.123456m, PowerUnit.Watt).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Power.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Power.FromWatts(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Power.FromWatts(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -853,13 +788,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PowerUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Power.FromWatts(1.0); - Assert.Equal(QuantityType.Power, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index 6a73fa3571..b8e937553d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -110,12 +110,6 @@ public abstract partial class PressureChangeRateTestsBase : QuantityTestsBase new object[] { PressureChangeRateUnit.PoundForcePerSquareInchPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new PressureChangeRate((double)0.0, PressureChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -124,7 +118,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PressureChangeRateUnit.PascalPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -168,14 +161,9 @@ public void PressureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(PressureChangeRate.Zero, quantityInfo.Zero); Assert.Equal("PressureChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.PressureChangeRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PressureChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -419,49 +407,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => pascalpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = PressureChangeRate.FromPascalsPerSecond(1); - var b = PressureChangeRate.FromPascalsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = PressureChangeRate.FromPascalsPerSecond(1); - var b = PressureChangeRate.FromPascalsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = PressureChangeRate.FromPascalsPerSecond(1); - object b = PressureChangeRate.FromPascalsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -491,21 +436,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(pascalpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PressureChangeRateUnit.Undefined, PressureChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == PressureChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -519,8 +455,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 atm/s", new PressureChangeRate(1, PressureChangeRateUnit.AtmospherePerSecond).ToString()); Assert.Equal("1 kPa/min", new PressureChangeRate(1, PressureChangeRateUnit.KilopascalPerMinute).ToString()); @@ -539,7 +475,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -568,10 +504,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s1")); Assert.Equal("0.12 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s2")); Assert.Equal("0.123 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s3")); @@ -579,7 +515,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -593,29 +529,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Pa/s", new PressureChangeRate(0.123456, PressureChangeRateUnit.PascalPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -735,13 +670,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PressureChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(QuantityType.PressureChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 5c78f02394..23ff9c63d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -234,12 +234,6 @@ public abstract partial class PressureTestsBase : QuantityTestsBase new object[] { PressureUnit.Torr }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Pressure((double)0.0, PressureUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -248,7 +242,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(PressureUnit.Pascal, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -292,14 +285,9 @@ public void Pressure_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Pressure.Zero, quantityInfo.Zero); Assert.Equal("Pressure", quantityInfo.Name); - Assert.Equal(QuantityType.Pressure, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {PressureUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -760,49 +748,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => pascal.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Pressure.FromPascals(1); - var b = Pressure.FromPascals(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Pressure.FromPascals(1); - var b = Pressure.FromPascals(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Pressure.FromPascals(1); - object b = Pressure.FromPascals(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -832,21 +777,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(pascal.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(PressureUnit.Undefined, Pressure.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(PressureUnit)).Cast(); foreach(var unit in units) { - if(unit == PressureUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -860,8 +796,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 atm", new Pressure(1, PressureUnit.Atmosphere).ToString()); Assert.Equal("1 bar", new Pressure(1, PressureUnit.Bar).ToString()); @@ -911,7 +847,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -971,10 +907,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s1")); Assert.Equal("0.12 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s2")); Assert.Equal("0.123 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s3")); @@ -982,7 +918,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -996,29 +932,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Pa", new Pressure(0.123456, PressureUnit.Pascal).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Pressure.FromPascals(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Pressure.FromPascals(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1138,13 +1073,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(PressureUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal(QuantityType.Pressure, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 41395a85c3..e9d3dae76b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -62,12 +62,6 @@ public abstract partial class RatioChangeRateTestsBase : QuantityTestsBase new object[] { RatioChangeRateUnit.PercentPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RatioChangeRate((double)0.0, RatioChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -76,7 +70,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RatioChangeRateUnit.DecimalFractionPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -120,14 +113,9 @@ public void RatioChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(RatioChangeRate.Zero, quantityInfo.Zero); Assert.Equal("RatioChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.RatioChangeRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RatioChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -287,49 +275,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfractionpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - var b = RatioChangeRate.FromDecimalFractionsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RatioChangeRate.FromDecimalFractionsPerSecond(1); - object b = RatioChangeRate.FromDecimalFractionsPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -359,21 +304,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfractionpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RatioChangeRateUnit.Undefined, RatioChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == RatioChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -387,15 +323,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 /s", new RatioChangeRate(1, RatioChangeRateUnit.DecimalFractionPerSecond).ToString()); Assert.Equal("1 %/s", new RatioChangeRate(1, RatioChangeRateUnit.PercentPerSecond).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -412,10 +348,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s1")); Assert.Equal("0.12 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s2")); Assert.Equal("0.123 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s3")); @@ -423,7 +359,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -437,29 +373,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 /s", new RatioChangeRate(0.123456, RatioChangeRateUnit.DecimalFractionPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -579,13 +514,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RatioChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(QuantityType.RatioChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 58ab0bb668..b72cf9d68a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -78,12 +78,6 @@ public abstract partial class RatioTestsBase : QuantityTestsBase new object[] { RatioUnit.Percent }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Ratio((double)0.0, RatioUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -92,7 +86,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RatioUnit.DecimalFraction, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -136,14 +129,9 @@ public void Ratio_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Ratio.Zero, quantityInfo.Zero); Assert.Equal("Ratio", quantityInfo.Name); - Assert.Equal(QuantityType.Ratio, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RatioUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -331,49 +319,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfraction.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Ratio.FromDecimalFractions(1); - var b = Ratio.FromDecimalFractions(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Ratio.FromDecimalFractions(1); - var b = Ratio.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Ratio.FromDecimalFractions(1); - object b = Ratio.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -403,21 +348,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RatioUnit.Undefined, Ratio.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RatioUnit)).Cast(); foreach(var unit in units) { - if(unit == RatioUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -431,8 +367,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1", new Ratio(1, RatioUnit.DecimalFraction).ToString()); Assert.Equal("1 ppb", new Ratio(1, RatioUnit.PartPerBillion).ToString()); @@ -443,7 +379,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -464,10 +400,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s1")); Assert.Equal("0.12", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s2")); Assert.Equal("0.123", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s3")); @@ -475,7 +411,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -489,29 +425,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new Ratio(0.123456, RatioUnit.DecimalFraction).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -631,13 +566,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RatioUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(QuantityType.Ratio, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 26420e02ad..59e49a5465 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class ReactiveEnergyTestsBase : QuantityTestsBase new object[] { ReactiveEnergyUnit.VoltampereReactiveHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReactiveEnergy((double)0.0, ReactiveEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReactiveEnergyUnit.VoltampereReactiveHour, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void ReactiveEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReactiveEnergy.Zero, quantityInfo.Zero); Assert.Equal("ReactiveEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.ReactiveEnergy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ReactiveEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltamperereactivehour.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReactiveEnergy.FromVoltampereReactiveHours(1); - var b = ReactiveEnergy.FromVoltampereReactiveHours(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReactiveEnergy.FromVoltampereReactiveHours(1); - var b = ReactiveEnergy.FromVoltampereReactiveHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReactiveEnergy.FromVoltampereReactiveHours(1); - object b = ReactiveEnergy.FromVoltampereReactiveHours(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltamperereactivehour.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReactiveEnergyUnit.Undefined, ReactiveEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == ReactiveEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kvarh", new ReactiveEnergy(1, ReactiveEnergyUnit.KilovoltampereReactiveHour).ToString()); Assert.Equal("1 Mvarh", new ReactiveEnergy(1, ReactiveEnergyUnit.MegavoltampereReactiveHour).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s1")); Assert.Equal("0.12 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s2")); Assert.Equal("0.123 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 varh", new ReactiveEnergy(0.123456, ReactiveEnergyUnit.VoltampereReactiveHour).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReactiveEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(QuantityType.ReactiveEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 9b122787b6..24c8d3bf60 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class ReactivePowerTestsBase : QuantityTestsBase new object[] { ReactivePowerUnit.VoltampereReactive }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReactivePower((double)0.0, ReactivePowerUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReactivePowerUnit.VoltampereReactive, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void ReactivePower_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReactivePower.Zero, quantityInfo.Zero); Assert.Equal("ReactivePower", quantityInfo.Name); - Assert.Equal(QuantityType.ReactivePower, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ReactivePowerUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => voltamperereactive.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReactivePower.FromVoltamperesReactive(1); - var b = ReactivePower.FromVoltamperesReactive(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReactivePower.FromVoltamperesReactive(1); - var b = ReactivePower.FromVoltamperesReactive(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReactivePower.FromVoltamperesReactive(1); - object b = ReactivePower.FromVoltamperesReactive(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(voltamperereactive.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReactivePowerUnit.Undefined, ReactivePower.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReactivePowerUnit)).Cast(); foreach(var unit in units) { - if(unit == ReactivePowerUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Gvar", new ReactivePower(1, ReactivePowerUnit.GigavoltampereReactive).ToString()); Assert.Equal("1 kvar", new ReactivePower(1, ReactivePowerUnit.KilovoltampereReactive).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s1")); Assert.Equal("0.12 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s2")); Assert.Equal("0.123 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 var", new ReactivePower(0.123456, ReactivePowerUnit.VoltampereReactive).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReactivePowerUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(QuantityType.ReactivePower, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 639244d32b..1d677b2246 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -98,12 +98,6 @@ public abstract partial class ReciprocalAreaTestsBase : QuantityTestsBase new object[] { ReciprocalAreaUnit.InverseUsSurveySquareFoot }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReciprocalArea((double)0.0, ReciprocalAreaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -112,7 +106,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReciprocalAreaUnit.InverseSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -156,14 +149,9 @@ public void ReciprocalArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(ReciprocalArea.Zero, quantityInfo.Zero); Assert.Equal("ReciprocalArea", quantityInfo.Name); - Assert.Equal(QuantityType.ReciprocalArea, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalAreaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -386,49 +374,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => inversesquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReciprocalArea.FromInverseSquareMeters(1); - var b = ReciprocalArea.FromInverseSquareMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReciprocalArea.FromInverseSquareMeters(1); - var b = ReciprocalArea.FromInverseSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReciprocalArea.FromInverseSquareMeters(1); - object b = ReciprocalArea.FromInverseSquareMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -458,21 +403,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(inversesquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReciprocalAreaUnit.Undefined, ReciprocalArea.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast(); foreach(var unit in units) { - if(unit == ReciprocalAreaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -486,8 +422,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁻²", new ReciprocalArea(1, ReciprocalAreaUnit.InverseSquareCentimeter).ToString()); Assert.Equal("1 dm⁻²", new ReciprocalArea(1, ReciprocalAreaUnit.InverseSquareDecimeter).ToString()); @@ -503,7 +439,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -529,10 +465,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s1")); Assert.Equal("0.12 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s2")); Assert.Equal("0.123 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s3")); @@ -540,7 +476,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -554,29 +490,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁻²", new ReciprocalArea(0.123456, ReciprocalAreaUnit.InverseSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -696,13 +631,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReciprocalAreaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(QuantityType.ReciprocalArea, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 96ae80abdd..d6255e9f94 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -94,12 +94,6 @@ public abstract partial class ReciprocalLengthTestsBase : QuantityTestsBase new object[] { ReciprocalLengthUnit.InverseYard }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ReciprocalLength((double)0.0, ReciprocalLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -108,7 +102,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ReciprocalLengthUnit.InverseMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -152,14 +145,9 @@ public void ReciprocalLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(ReciprocalLength.Zero, quantityInfo.Zero); Assert.Equal("ReciprocalLength", quantityInfo.Name); - Assert.Equal(QuantityType.ReciprocalLength, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ReciprocalLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -375,49 +363,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => inversemeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ReciprocalLength.FromInverseMeters(1); - var b = ReciprocalLength.FromInverseMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ReciprocalLength.FromInverseMeters(1); - var b = ReciprocalLength.FromInverseMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ReciprocalLength.FromInverseMeters(1); - object b = ReciprocalLength.FromInverseMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -447,21 +392,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(inversemeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ReciprocalLengthUnit.Undefined, ReciprocalLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == ReciprocalLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -475,8 +411,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁻¹", new ReciprocalLength(1, ReciprocalLengthUnit.InverseCentimeter).ToString()); Assert.Equal("1 ft⁻¹", new ReciprocalLength(1, ReciprocalLengthUnit.InverseFoot).ToString()); @@ -491,7 +427,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -516,10 +452,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s1")); Assert.Equal("0.12 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s2")); Assert.Equal("0.123 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s3")); @@ -527,7 +463,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -541,29 +477,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁻¹", new ReciprocalLength(0.123456, ReciprocalLengthUnit.InverseMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -683,13 +618,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ReciprocalLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(QuantityType.ReciprocalLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 736579b1a4..f429c7e5c6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class RelativeHumidityTestsBase : QuantityTestsBase new object[] { RelativeHumidityUnit.Percent }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RelativeHumidity((double)0.0, RelativeHumidityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RelativeHumidityUnit.Percent, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void RelativeHumidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(RelativeHumidity.Zero, quantityInfo.Zero); Assert.Equal("RelativeHumidity", quantityInfo.Name); - Assert.Equal(QuantityType.RelativeHumidity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RelativeHumidityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => percent.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RelativeHumidity.FromPercent(1); - var b = RelativeHumidity.FromPercent(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RelativeHumidity.FromPercent(1); - var b = RelativeHumidity.FromPercent(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RelativeHumidity.FromPercent(1); - object b = RelativeHumidity.FromPercent(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(percent.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RelativeHumidityUnit.Undefined, RelativeHumidity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast(); foreach(var unit in units) { - if(unit == RelativeHumidityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 %RH", new RelativeHumidity(1, RelativeHumidityUnit.Percent).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s1")); Assert.Equal("0.12 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s2")); Assert.Equal("0.123 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 %RH", new RelativeHumidity(0.123456, RelativeHumidityUnit.Percent).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RelativeHumidityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(QuantityType.RelativeHumidity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 63d84cdbdc..d475df9f4a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class RotationalAccelerationTestsBase : QuantityTestsBas new object[] { RotationalAccelerationUnit.RevolutionPerSecondSquared }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalAcceleration((double)0.0, RotationalAccelerationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalAccelerationUnit.RadianPerSecondSquared, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void RotationalAcceleration_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(RotationalAcceleration.Zero, quantityInfo.Zero); Assert.Equal("RotationalAcceleration", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalAcceleration, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalAccelerationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => radianpersecondsquared.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - var b = RotationalAcceleration.FromRadiansPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalAcceleration.FromRadiansPerSecondSquared(1); - object b = RotationalAcceleration.FromRadiansPerSecondSquared(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(radianpersecondsquared.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalAccelerationUnit.Undefined, RotationalAcceleration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalAccelerationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 °/s²", new RotationalAcceleration(1, RotationalAccelerationUnit.DegreePerSecondSquared).ToString()); Assert.Equal("1 rad/s²", new RotationalAcceleration(1, RotationalAccelerationUnit.RadianPerSecondSquared).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s1")); Assert.Equal("0.12 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s2")); Assert.Equal("0.123 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 rad/s²", new RotationalAcceleration(0.123456, RotationalAccelerationUnit.RadianPerSecondSquared).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalAccelerationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(QuantityType.RotationalAcceleration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index d6e6f12cf1..fa195adab2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -106,12 +106,6 @@ public abstract partial class RotationalSpeedTestsBase : QuantityTestsBase new object[] { RotationalSpeedUnit.RevolutionPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalSpeed((double)0.0, RotationalSpeedUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -120,7 +114,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalSpeedUnit.RadianPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -164,14 +157,9 @@ public void RotationalSpeed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(RotationalSpeed.Zero, quantityInfo.Zero); Assert.Equal("RotationalSpeed", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalSpeed, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalSpeedUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -408,49 +396,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => radianpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalSpeed.FromRadiansPerSecond(1); - var b = RotationalSpeed.FromRadiansPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalSpeed.FromRadiansPerSecond(1); - var b = RotationalSpeed.FromRadiansPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalSpeed.FromRadiansPerSecond(1); - object b = RotationalSpeed.FromRadiansPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -480,21 +425,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(radianpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalSpeedUnit.Undefined, RotationalSpeed.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalSpeedUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -508,8 +444,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 crad/s", new RotationalSpeed(1, RotationalSpeedUnit.CentiradianPerSecond).ToString()); Assert.Equal("1 drad/s", new RotationalSpeed(1, RotationalSpeedUnit.DeciradianPerSecond).ToString()); @@ -527,7 +463,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -555,10 +491,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s1")); Assert.Equal("0.12 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s2")); Assert.Equal("0.123 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s3")); @@ -566,7 +502,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -580,29 +516,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 rad/s", new RotationalSpeed(0.123456, RotationalSpeedUnit.RadianPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -722,13 +657,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalSpeedUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(QuantityType.RotationalSpeed, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 763be52685..d3611d730f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -74,12 +74,6 @@ public abstract partial class RotationalStiffnessPerLengthTestsBase : QuantityTe new object[] { RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalStiffnessPerLength((double)0.0, RotationalStiffnessPerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -88,7 +82,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -132,14 +125,9 @@ public void RotationalStiffnessPerLength_QuantityInfo_ReturnsQuantityInfoDescrib Assert.Equal(RotationalStiffnessPerLength.Zero, quantityInfo.Zero); Assert.Equal("RotationalStiffnessPerLength", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalStiffnessPerLength, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessPerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -320,49 +308,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeterperradianpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - var b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1); - object b = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -392,21 +337,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeterperradianpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalStiffnessPerLengthUnit.Undefined, RotationalStiffnessPerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalStiffnessPerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -420,8 +356,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kN·m/rad/m", new RotationalStiffnessPerLength(1, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter).ToString()); Assert.Equal("1 kipf·ft/°/ft", new RotationalStiffnessPerLength(1, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot).ToString()); @@ -431,7 +367,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -451,10 +387,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s1")); Assert.Equal("0.12 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s2")); Assert.Equal("0.123 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s3")); @@ -462,7 +398,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -476,29 +412,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/rad/m", new RotationalStiffnessPerLength(0.123456, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -618,13 +553,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalStiffnessPerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(QuantityType.RotationalStiffnessPerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 6129bd22c8..673f7c15e9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -186,12 +186,6 @@ public abstract partial class RotationalStiffnessTestsBase : QuantityTestsBase new object[] { RotationalStiffnessUnit.PoundForceFootPerDegrees }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new RotationalStiffness((double)0.0, RotationalStiffnessUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -200,7 +194,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(RotationalStiffnessUnit.NewtonMeterPerRadian, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -244,14 +237,9 @@ public void RotationalStiffness_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(RotationalStiffness.Zero, quantityInfo.Zero); Assert.Equal("RotationalStiffness", quantityInfo.Name); - Assert.Equal(QuantityType.RotationalStiffness, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {RotationalStiffnessUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -628,49 +616,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeterperradian.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = RotationalStiffness.FromNewtonMetersPerRadian(1); - var b = RotationalStiffness.FromNewtonMetersPerRadian(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = RotationalStiffness.FromNewtonMetersPerRadian(1); - var b = RotationalStiffness.FromNewtonMetersPerRadian(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = RotationalStiffness.FromNewtonMetersPerRadian(1); - object b = RotationalStiffness.FromNewtonMetersPerRadian(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -700,21 +645,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeterperradian.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(RotationalStiffnessUnit.Undefined, RotationalStiffness.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast(); foreach(var unit in units) { - if(unit == RotationalStiffnessUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -728,8 +664,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cN·m/deg", new RotationalStiffness(1, RotationalStiffnessUnit.CentinewtonMeterPerDegree).ToString()); Assert.Equal("1 cN·mm/deg", new RotationalStiffness(1, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree).ToString()); @@ -767,7 +703,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -815,10 +751,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s1")); Assert.Equal("0.12 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s2")); Assert.Equal("0.123 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s3")); @@ -826,7 +762,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -840,29 +776,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/rad", new RotationalStiffness(0.123456, RotationalStiffnessUnit.NewtonMeterPerRadian).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -982,13 +917,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(RotationalStiffnessUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(QuantityType.RotationalStiffness, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 0a1f6c8422..7b967a3d89 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class ScalarTestsBase : QuantityTestsBase new object[] { ScalarUnit.Amount }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Scalar((double)0.0, ScalarUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ScalarUnit.Amount, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void Scalar_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Scalar.Zero, quantityInfo.Zero); Assert.Equal("Scalar", quantityInfo.Name); - Assert.Equal(QuantityType.Scalar, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ScalarUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => amount.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Scalar.FromAmount(1); - var b = Scalar.FromAmount(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Scalar.FromAmount(1); - var b = Scalar.FromAmount(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Scalar.FromAmount(1); - object b = Scalar.FromAmount(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(amount.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ScalarUnit.Undefined, Scalar.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ScalarUnit)).Cast(); foreach(var unit in units) { - if(unit == ScalarUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1", new Scalar(1, ScalarUnit.Amount).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new Scalar(0.123456, ScalarUnit.Amount).ToString("s1")); Assert.Equal("0.12", new Scalar(0.123456, ScalarUnit.Amount).ToString("s2")); Assert.Equal("0.123", new Scalar(0.123456, ScalarUnit.Amount).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new Scalar(0.123456, ScalarUnit.Amount).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Scalar.FromAmount(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Scalar.FromAmount(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ScalarUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal(QuantityType.Scalar, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 505594fca5..0332eb584a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class SolidAngleTestsBase : QuantityTestsBase new object[] { SolidAngleUnit.Steradian }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SolidAngle((double)0.0, SolidAngleUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SolidAngleUnit.Steradian, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void SolidAngle_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SolidAngle.Zero, quantityInfo.Zero); Assert.Equal("SolidAngle", quantityInfo.Name); - Assert.Equal(QuantityType.SolidAngle, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SolidAngleUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => steradian.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SolidAngle.FromSteradians(1); - var b = SolidAngle.FromSteradians(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SolidAngle.FromSteradians(1); - var b = SolidAngle.FromSteradians(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SolidAngle.FromSteradians(1); - object b = SolidAngle.FromSteradians(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(steradian.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SolidAngleUnit.Undefined, SolidAngle.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SolidAngleUnit)).Cast(); foreach(var unit in units) { - if(unit == SolidAngleUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 sr", new SolidAngle(1, SolidAngleUnit.Steradian).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s1")); Assert.Equal("0.12 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s2")); Assert.Equal("0.123 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 sr", new SolidAngle(0.123456, SolidAngleUnit.Steradian).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SolidAngleUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(QuantityType.SolidAngle, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 00999677a8..a646c53cb2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -154,12 +154,6 @@ public abstract partial class SpecificEnergyTestsBase : QuantityTestsBase new object[] { SpecificEnergyUnit.WattHourPerKilogram }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificEnergy((double)0.0, SpecificEnergyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -168,7 +162,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificEnergyUnit.JoulePerKilogram, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -212,14 +205,9 @@ public void SpecificEnergy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificEnergy.Zero, quantityInfo.Zero); Assert.Equal("SpecificEnergy", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificEnergy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEnergyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -540,49 +528,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => jouleperkilogram.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificEnergy.FromJoulesPerKilogram(1); - var b = SpecificEnergy.FromJoulesPerKilogram(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificEnergy.FromJoulesPerKilogram(1); - var b = SpecificEnergy.FromJoulesPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificEnergy.FromJoulesPerKilogram(1); - object b = SpecificEnergy.FromJoulesPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -612,21 +557,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(jouleperkilogram.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificEnergyUnit.Undefined, SpecificEnergy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificEnergyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -640,8 +576,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 btu/lb", new SpecificEnergy(1, SpecificEnergyUnit.BtuPerPound).ToString()); Assert.Equal("1 cal/g", new SpecificEnergy(1, SpecificEnergyUnit.CaloriePerGram).ToString()); @@ -671,7 +607,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -711,10 +647,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s1")); Assert.Equal("0.12 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s2")); Assert.Equal("0.123 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s3")); @@ -722,7 +658,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -736,29 +672,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/kg", new SpecificEnergy(0.123456, SpecificEnergyUnit.JoulePerKilogram).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -878,13 +813,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificEnergyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(QuantityType.SpecificEnergy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 9c9f018be4..0647a4c4fc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -90,12 +90,6 @@ public abstract partial class SpecificEntropyTestsBase : QuantityTestsBase new object[] { SpecificEntropyUnit.MegajoulePerKilogramKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificEntropy((double)0.0, SpecificEntropyUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -104,7 +98,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificEntropyUnit.JoulePerKilogramKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -148,14 +141,9 @@ public void SpecificEntropy_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificEntropy.Zero, quantityInfo.Zero); Assert.Equal("SpecificEntropy", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificEntropy, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificEntropyUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -364,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => jouleperkilogramkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - var b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificEntropy.FromJoulesPerKilogramKelvin(1); - object b = SpecificEntropy.FromJoulesPerKilogramKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -436,21 +381,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(jouleperkilogramkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificEntropyUnit.Undefined, SpecificEntropy.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificEntropyUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -464,8 +400,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/lb·°F", new SpecificEntropy(1, SpecificEntropyUnit.BtuPerPoundFahrenheit).ToString()); Assert.Equal("1 cal/g.K", new SpecificEntropy(1, SpecificEntropyUnit.CaloriePerGramKelvin).ToString()); @@ -479,7 +415,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -503,10 +439,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s1")); Assert.Equal("0.12 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s2")); Assert.Equal("0.123 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s3")); @@ -514,7 +450,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -528,29 +464,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/kg.K", new SpecificEntropy(0.123456, SpecificEntropyUnit.JoulePerKilogramKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -670,13 +605,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificEntropyUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(QuantityType.SpecificEntropy, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index 99dca952d1..01bbef6c22 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class SpecificFuelConsumptionTestsBase : QuantityTestsBa new object[] { SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificFuelConsumption((double)0.0, SpecificFuelConsumptionUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void SpecificFuelConsumption_QuantityInfo_ReturnsQuantityInfoDescribingQu Assert.Equal(SpecificFuelConsumption.Zero, quantityInfo.Zero); Assert.Equal("SpecificFuelConsumption", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificFuelConsumption, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificFuelConsumptionUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => gramperkilonewtonsecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1); - var b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1); - var b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1); - object b = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(gramperkilonewtonsecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificFuelConsumptionUnit.Undefined, SpecificFuelConsumption.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificFuelConsumptionUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 g/(kN�s)", new SpecificFuelConsumption(1, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString()); Assert.Equal("1 kg/(kgf�h)", new SpecificFuelConsumption(1, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s1")); Assert.Equal("0.12 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s2")); Assert.Equal("0.123 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 g/(kN�s)", new SpecificFuelConsumption(0.123456, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificFuelConsumptionUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(QuantityType.SpecificFuelConsumption, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 3547c01001..c4007d0541 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -66,12 +66,6 @@ public abstract partial class SpecificVolumeTestsBase : QuantityTestsBase new object[] { SpecificVolumeUnit.MillicubicMeterPerKilogram }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificVolume((double)0.0, SpecificVolumeUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -80,7 +74,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificVolumeUnit.CubicMeterPerKilogram, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -124,14 +117,9 @@ public void SpecificVolume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificVolume.Zero, quantityInfo.Zero); Assert.Equal("SpecificVolume", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificVolume, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificVolumeUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -298,49 +286,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterperkilogram.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificVolume.FromCubicMetersPerKilogram(1); - var b = SpecificVolume.FromCubicMetersPerKilogram(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificVolume.FromCubicMetersPerKilogram(1); - var b = SpecificVolume.FromCubicMetersPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificVolume.FromCubicMetersPerKilogram(1); - object b = SpecificVolume.FromCubicMetersPerKilogram(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -370,21 +315,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterperkilogram.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificVolumeUnit.Undefined, SpecificVolume.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificVolumeUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -398,8 +334,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ft³/lb", new SpecificVolume(1, SpecificVolumeUnit.CubicFootPerPound).ToString()); Assert.Equal("1 m³/kg", new SpecificVolume(1, SpecificVolumeUnit.CubicMeterPerKilogram).ToString()); @@ -407,7 +343,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -425,10 +361,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s1")); Assert.Equal("0.12 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s2")); Assert.Equal("0.123 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s3")); @@ -436,7 +372,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -450,29 +386,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/kg", new SpecificVolume(0.123456, SpecificVolumeUnit.CubicMeterPerKilogram).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -592,13 +527,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificVolumeUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(QuantityType.SpecificVolume, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 631236e82c..0b61b0a37b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -122,12 +122,6 @@ public abstract partial class SpecificWeightTestsBase : QuantityTestsBase new object[] { SpecificWeightUnit.TonneForcePerCubicMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new SpecificWeight((double)0.0, SpecificWeightUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -136,7 +130,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpecificWeightUnit.NewtonPerCubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -180,14 +173,9 @@ public void SpecificWeight_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(SpecificWeight.Zero, quantityInfo.Zero); Assert.Equal("SpecificWeight", quantityInfo.Name); - Assert.Equal(QuantityType.SpecificWeight, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SpecificWeightUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -452,49 +440,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonpercubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = SpecificWeight.FromNewtonsPerCubicMeter(1); - var b = SpecificWeight.FromNewtonsPerCubicMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = SpecificWeight.FromNewtonsPerCubicMeter(1); - var b = SpecificWeight.FromNewtonsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = SpecificWeight.FromNewtonsPerCubicMeter(1); - object b = SpecificWeight.FromNewtonsPerCubicMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -524,21 +469,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonpercubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpecificWeightUnit.Undefined, SpecificWeight.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpecificWeightUnit)).Cast(); foreach(var unit in units) { - if(unit == SpecificWeightUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -552,8 +488,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kgf/cm³", new SpecificWeight(1, SpecificWeightUnit.KilogramForcePerCubicCentimeter).ToString()); Assert.Equal("1 kgf/m³", new SpecificWeight(1, SpecificWeightUnit.KilogramForcePerCubicMeter).ToString()); @@ -575,7 +511,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -607,10 +543,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s1")); Assert.Equal("0.12 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s2")); Assert.Equal("0.123 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s3")); @@ -618,7 +554,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -632,29 +568,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N/m³", new SpecificWeight(0.123456, SpecificWeightUnit.NewtonPerCubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -774,13 +709,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpecificWeightUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(QuantityType.SpecificWeight, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index d1ba6b077a..cd8cf8f97c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -182,12 +182,6 @@ public abstract partial class SpeedTestsBase : QuantityTestsBase new object[] { SpeedUnit.YardPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Speed((double)0.0, SpeedUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -196,7 +190,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(SpeedUnit.MeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -240,14 +233,9 @@ public void Speed_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Speed.Zero, quantityInfo.Zero); Assert.Equal("Speed", quantityInfo.Name); - Assert.Equal(QuantityType.Speed, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {SpeedUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -617,49 +605,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => meterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Speed.FromMetersPerSecond(1); - var b = Speed.FromMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Speed.FromMetersPerSecond(1); - var b = Speed.FromMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Speed.FromMetersPerSecond(1); - object b = Speed.FromMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -689,21 +634,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(meterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(SpeedUnit.Undefined, Speed.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(SpeedUnit)).Cast(); foreach(var unit in units) { - if(unit == SpeedUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -717,8 +653,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm/h", new Speed(1, SpeedUnit.CentimeterPerHour).ToString()); Assert.Equal("1 cm/min", new Speed(1, SpeedUnit.CentimeterPerMinute).ToString()); @@ -755,7 +691,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -802,10 +738,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s1")); Assert.Equal("0.12 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s2")); Assert.Equal("0.123 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s3")); @@ -813,7 +749,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -827,29 +763,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m/s", new Speed(0.123456, SpeedUnit.MeterPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -969,13 +904,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(SpeedUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(QuantityType.Speed, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index eabb7fd0f9..dfd8c986ab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -90,12 +90,6 @@ public abstract partial class StandardVolumeFlowTestsBase : QuantityTestsBase new object[] { StandardVolumeFlowUnit.StandardLiterPerMinute }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new StandardVolumeFlow((double)0.0, StandardVolumeFlowUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -104,7 +98,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -148,14 +141,9 @@ public void StandardVolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantit Assert.Equal(StandardVolumeFlow.Zero, quantityInfo.Zero); Assert.Equal("StandardVolumeFlow", quantityInfo.Name); - Assert.Equal(QuantityType.StandardVolumeFlow, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {StandardVolumeFlowUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -364,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => standardcubicmeterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - var b = StandardVolumeFlow.FromStandardCubicMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - var b = StandardVolumeFlow.FromStandardCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1); - object b = StandardVolumeFlow.FromStandardCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -436,21 +381,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(standardcubicmeterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(StandardVolumeFlowUnit.Undefined, StandardVolumeFlow.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast(); foreach(var unit in units) { - if(unit == StandardVolumeFlowUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -464,8 +400,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 sccm", new StandardVolumeFlow(1, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute).ToString()); Assert.Equal("1 scfh", new StandardVolumeFlow(1, StandardVolumeFlowUnit.StandardCubicFootPerHour).ToString()); @@ -479,7 +415,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -503,10 +439,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s1")); Assert.Equal("0.12 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s2")); Assert.Equal("0.123 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s3")); @@ -514,7 +450,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -528,29 +464,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 Sm³/s", new StandardVolumeFlow(0.123456, StandardVolumeFlowUnit.StandardCubicMeterPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -670,13 +605,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(StandardVolumeFlowUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(QuantityType.StandardVolumeFlow, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 8af86a0b20..067212531e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -94,12 +94,6 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase new object[] { TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TemperatureChangeRate((double)0.0, TemperatureChangeRateUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -108,7 +102,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -152,14 +145,9 @@ public void TemperatureChangeRate_QuantityInfo_ReturnsQuantityInfoDescribingQuan Assert.Equal(TemperatureChangeRate.Zero, quantityInfo.Zero); Assert.Equal("TemperatureChangeRate", quantityInfo.Name); - Assert.Equal(QuantityType.TemperatureChangeRate, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureChangeRateUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -375,49 +363,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => degreecelsiuspersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - var b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1); - object b = TemperatureChangeRate.FromDegreesCelsiusPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -447,21 +392,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(degreecelsiuspersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureChangeRateUnit.Undefined, TemperatureChangeRate.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureChangeRateUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -475,8 +411,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 c°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond).ToString()); Assert.Equal("1 da°C/s", new TemperatureChangeRate(1, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond).ToString()); @@ -491,7 +427,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -516,10 +452,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s1")); Assert.Equal("0.12 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s2")); Assert.Equal("0.123 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s3")); @@ -527,7 +463,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -541,29 +477,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 °C/s", new TemperatureChangeRate(0.123456, TemperatureChangeRateUnit.DegreeCelsiusPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -683,13 +618,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureChangeRateUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(QuantityType.TemperatureChangeRate, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 8c51fb93b6..5388e0eb80 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -90,12 +90,6 @@ public abstract partial class TemperatureDeltaTestsBase : QuantityTestsBase new object[] { TemperatureDeltaUnit.MillidegreeCelsius }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TemperatureDelta((double)0.0, TemperatureDeltaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -104,7 +98,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureDeltaUnit.Kelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -148,14 +141,9 @@ public void TemperatureDelta_QuantityInfo_ReturnsQuantityInfoDescribingQuantity( Assert.Equal(TemperatureDelta.Zero, quantityInfo.Zero); Assert.Equal("TemperatureDelta", quantityInfo.Name); - Assert.Equal(QuantityType.TemperatureDelta, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureDeltaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -364,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TemperatureDelta.FromKelvins(1); - var b = TemperatureDelta.FromKelvins(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TemperatureDelta.FromKelvins(1); - var b = TemperatureDelta.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TemperatureDelta.FromKelvins(1); - object b = TemperatureDelta.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -436,21 +381,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureDeltaUnit.Undefined, TemperatureDelta.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureDeltaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -464,8 +400,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ∆°C", new TemperatureDelta(1, TemperatureDeltaUnit.DegreeCelsius).ToString()); Assert.Equal("1 ∆°De", new TemperatureDelta(1, TemperatureDeltaUnit.DegreeDelisle).ToString()); @@ -479,7 +415,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -503,10 +439,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s1")); Assert.Equal("0.12 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s2")); Assert.Equal("0.123 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s3")); @@ -514,7 +450,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -528,29 +464,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆K", new TemperatureDelta(0.123456, TemperatureDeltaUnit.Kelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -670,13 +605,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureDeltaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(QuantityType.TemperatureDelta, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index 75372fd4e2..9692d22d5d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -70,12 +70,6 @@ public abstract partial class TemperatureGradientTestsBase : QuantityTestsBase new object[] { TemperatureGradientUnit.KelvinPerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TemperatureGradient((double)0.0, TemperatureGradientUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -84,7 +78,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureGradientUnit.KelvinPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -128,14 +121,9 @@ public void TemperatureGradient_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(TemperatureGradient.Zero, quantityInfo.Zero); Assert.Equal("TemperatureGradient", quantityInfo.Name); - Assert.Equal(QuantityType.TemperatureGradient, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureGradientUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -309,49 +297,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kelvinpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TemperatureGradient.FromKelvinsPerMeter(1); - var b = TemperatureGradient.FromKelvinsPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TemperatureGradient.FromKelvinsPerMeter(1); - var b = TemperatureGradient.FromKelvinsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TemperatureGradient.FromKelvinsPerMeter(1); - object b = TemperatureGradient.FromKelvinsPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -381,21 +326,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kelvinpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureGradientUnit.Undefined, TemperatureGradient.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureGradientUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureGradientUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -409,8 +345,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ∆°C/km", new TemperatureGradient(1, TemperatureGradientUnit.DegreeCelsiusPerKilometer).ToString()); Assert.Equal("1 ∆°C/m", new TemperatureGradient(1, TemperatureGradientUnit.DegreeCelsiusPerMeter).ToString()); @@ -419,7 +355,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -438,10 +374,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 ∆°K/m", new TemperatureGradient(0.123456, TemperatureGradientUnit.KelvinPerMeter).ToString("s1")); Assert.Equal("0.12 ∆°K/m", new TemperatureGradient(0.123456, TemperatureGradientUnit.KelvinPerMeter).ToString("s2")); Assert.Equal("0.123 ∆°K/m", new TemperatureGradient(0.123456, TemperatureGradientUnit.KelvinPerMeter).ToString("s3")); @@ -449,7 +385,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -463,29 +399,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 ∆°K/m", new TemperatureGradient(0.123456, TemperatureGradientUnit.KelvinPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -605,13 +540,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureGradientUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal(QuantityType.TemperatureGradient, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 9e0c160da4..e414eafde0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -94,12 +94,6 @@ public abstract partial class TemperatureTestsBase : QuantityTestsBase new object[] { TemperatureUnit.SolarTemperature }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Temperature((double)0.0, TemperatureUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -108,7 +102,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TemperatureUnit.Kelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -152,14 +145,9 @@ public void Temperature_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Temperature.Zero, quantityInfo.Zero); Assert.Equal("Temperature", quantityInfo.Name); - Assert.Equal(QuantityType.Temperature, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TemperatureUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -363,49 +351,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => kelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Temperature.FromKelvins(1); - var b = Temperature.FromKelvins(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Temperature.FromKelvins(1); - var b = Temperature.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Temperature.FromKelvins(1); - object b = Temperature.FromKelvins(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -435,21 +380,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(kelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TemperatureUnit.Undefined, Temperature.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TemperatureUnit)).Cast(); foreach(var unit in units) { - if(unit == TemperatureUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -463,8 +399,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 °C", new Temperature(1, TemperatureUnit.DegreeCelsius).ToString()); Assert.Equal("1 °De", new Temperature(1, TemperatureUnit.DegreeDelisle).ToString()); @@ -479,7 +415,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -504,10 +440,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s1")); Assert.Equal("0.12 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s2")); Assert.Equal("0.123 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s3")); @@ -515,7 +451,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -529,29 +465,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 K", new Temperature(0.123456, TemperatureUnit.Kelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Temperature.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Temperature.FromKelvins(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -671,13 +606,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TemperatureUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(QuantityType.Temperature, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 2fd369651a..028a55d62e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -62,12 +62,6 @@ public abstract partial class ThermalConductivityTestsBase : QuantityTestsBase new object[] { ThermalConductivityUnit.WattPerMeterKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ThermalConductivity((double)0.0, ThermalConductivityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -76,7 +70,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ThermalConductivityUnit.WattPerMeterKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -120,14 +113,9 @@ public void ThermalConductivity_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(ThermalConductivity.Zero, quantityInfo.Zero); Assert.Equal("ThermalConductivity", quantityInfo.Name); - Assert.Equal(QuantityType.ThermalConductivity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ThermalConductivityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -287,49 +275,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => wattpermeterkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ThermalConductivity.FromWattsPerMeterKelvin(1); - var b = ThermalConductivity.FromWattsPerMeterKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ThermalConductivity.FromWattsPerMeterKelvin(1); - var b = ThermalConductivity.FromWattsPerMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ThermalConductivity.FromWattsPerMeterKelvin(1); - object b = ThermalConductivity.FromWattsPerMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -359,21 +304,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(wattpermeterkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ThermalConductivityUnit.Undefined, ThermalConductivity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast(); foreach(var unit in units) { - if(unit == ThermalConductivityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -387,15 +323,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/h·ft·°F", new ThermalConductivity(1, ThermalConductivityUnit.BtuPerHourFootFahrenheit).ToString()); Assert.Equal("1 W/m·K", new ThermalConductivity(1, ThermalConductivityUnit.WattPerMeterKelvin).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -412,10 +348,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s1")); Assert.Equal("0.12 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s2")); Assert.Equal("0.123 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s3")); @@ -423,7 +359,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -437,29 +373,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 W/m·K", new ThermalConductivity(0.123456, ThermalConductivityUnit.WattPerMeterKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -579,13 +514,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ThermalConductivityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(QuantityType.ThermalConductivity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 213aea5006..4aef9541cb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -78,12 +78,6 @@ public abstract partial class ThermalResistanceTestsBase : QuantityTestsBase new object[] { ThermalResistanceUnit.SquareMeterKelvinPerWatt }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new ThermalResistance((double)0.0, ThermalResistanceUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -92,7 +86,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -136,14 +129,9 @@ public void ThermalResistance_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(ThermalResistance.Zero, quantityInfo.Zero); Assert.Equal("ThermalResistance", quantityInfo.Name); - Assert.Equal(QuantityType.ThermalResistance, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {ThermalResistanceUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -331,49 +319,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => squaremeterkelvinperkilowatt.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - var b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1); - object b = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -403,21 +348,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(squaremeterkelvinperkilowatt.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(ThermalResistanceUnit.Undefined, ThermalResistance.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast(); foreach(var unit in units) { - if(unit == ThermalResistanceUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -431,8 +367,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 Hrft²°F/Btu", new ThermalResistance(1, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu).ToString()); Assert.Equal("1 cm²Hr°C/kcal", new ThermalResistance(1, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie).ToString()); @@ -443,7 +379,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -464,10 +400,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s1")); Assert.Equal("0.12 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s2")); Assert.Equal("0.123 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s3")); @@ -475,7 +411,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -489,29 +425,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m²K/kW", new ThermalResistance(0.123456, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -631,13 +566,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(ThermalResistanceUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(QuantityType.ThermalResistance, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 96315802a1..c1ecece267 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -138,12 +138,6 @@ public abstract partial class TorquePerLengthTestsBase : QuantityTestsBase new object[] { TorquePerLengthUnit.TonneForceMillimeterPerMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new TorquePerLength((double)0.0, TorquePerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -152,7 +146,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TorquePerLengthUnit.NewtonMeterPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -196,14 +189,9 @@ public void TorquePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(TorquePerLength.Zero, quantityInfo.Zero); Assert.Equal("TorquePerLength", quantityInfo.Name); - Assert.Equal(QuantityType.TorquePerLength, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TorquePerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -496,49 +484,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeterpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = TorquePerLength.FromNewtonMetersPerMeter(1); - var b = TorquePerLength.FromNewtonMetersPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = TorquePerLength.FromNewtonMetersPerMeter(1); - var b = TorquePerLength.FromNewtonMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = TorquePerLength.FromNewtonMetersPerMeter(1); - object b = TorquePerLength.FromNewtonMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -568,21 +513,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeterpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TorquePerLengthUnit.Undefined, TorquePerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == TorquePerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -596,8 +532,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 kgf·cm/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceCentimeterPerMeter).ToString()); Assert.Equal("1 kgf·m/m", new TorquePerLength(1, TorquePerLengthUnit.KilogramForceMeterPerMeter).ToString()); @@ -623,7 +559,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -659,10 +595,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s1")); Assert.Equal("0.12 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s2")); Assert.Equal("0.123 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s3")); @@ -670,7 +606,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -684,29 +620,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m/m", new TorquePerLength(0.123456, TorquePerLengthUnit.NewtonMeterPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -826,13 +761,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TorquePerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(QuantityType.TorquePerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 6f91770d4b..3427723bff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -154,12 +154,6 @@ public abstract partial class TorqueTestsBase : QuantityTestsBase new object[] { TorqueUnit.TonneForceMillimeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Torque((double)0.0, TorqueUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -168,7 +162,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TorqueUnit.NewtonMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -212,14 +205,9 @@ public void Torque_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Torque.Zero, quantityInfo.Zero); Assert.Equal("Torque", quantityInfo.Name); - Assert.Equal(QuantityType.Torque, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TorqueUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -540,49 +528,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => newtonmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Torque.FromNewtonMeters(1); - var b = Torque.FromNewtonMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Torque.FromNewtonMeters(1); - var b = Torque.FromNewtonMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Torque.FromNewtonMeters(1); - object b = Torque.FromNewtonMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -612,21 +557,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(newtonmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TorqueUnit.Undefined, Torque.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TorqueUnit)).Cast(); foreach(var unit in units) { - if(unit == TorqueUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -640,8 +576,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 gf·cm", new Torque(1, TorqueUnit.GramForceCentimeter).ToString()); Assert.Equal("1 gf·m", new Torque(1, TorqueUnit.GramForceMeter).ToString()); @@ -671,7 +607,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -711,10 +647,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s1")); Assert.Equal("0.12 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s2")); Assert.Equal("0.123 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s3")); @@ -722,7 +658,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -736,29 +672,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 N·m", new Torque(0.123456, TorqueUnit.NewtonMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -878,13 +813,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TorqueUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(QuantityType.Torque, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 808250da97..356228cf17 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class TurbidityTestsBase : QuantityTestsBase new object[] { TurbidityUnit.NTU }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Turbidity((double)0.0, TurbidityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(TurbidityUnit.NTU, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void Turbidity_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Turbidity.Zero, quantityInfo.Zero); Assert.Equal("Turbidity", quantityInfo.Name); - Assert.Equal(QuantityType.Turbidity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {TurbidityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => ntu.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Turbidity.FromNTU(1); - var b = Turbidity.FromNTU(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Turbidity.FromNTU(1); - var b = Turbidity.FromNTU(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Turbidity.FromNTU(1); - object b = Turbidity.FromNTU(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(ntu.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(TurbidityUnit.Undefined, Turbidity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(TurbidityUnit)).Cast(); foreach(var unit in units) { - if(unit == TurbidityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 NTU", new Turbidity(1, TurbidityUnit.NTU).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s1")); Assert.Equal("0.12 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s2")); Assert.Equal("0.123 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 NTU", new Turbidity(0.123456, TurbidityUnit.NTU).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Turbidity.FromNTU(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Turbidity.FromNTU(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(TurbidityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(QuantityType.Turbidity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 0858d5e41e..0b4cc97b90 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -58,12 +58,6 @@ public abstract partial class VitaminATestsBase : QuantityTestsBase new object[] { VitaminAUnit.InternationalUnit }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VitaminA((double)0.0, VitaminAUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -72,7 +66,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VitaminAUnit.InternationalUnit, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -116,14 +109,9 @@ public void VitaminA_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VitaminA.Zero, quantityInfo.Zero); Assert.Equal("VitaminA", quantityInfo.Name); - Assert.Equal(QuantityType.VitaminA, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VitaminAUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -276,49 +264,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => internationalunit.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VitaminA.FromInternationalUnits(1); - var b = VitaminA.FromInternationalUnits(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VitaminA.FromInternationalUnits(1); - var b = VitaminA.FromInternationalUnits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VitaminA.FromInternationalUnits(1); - object b = VitaminA.FromInternationalUnits(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -348,21 +293,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(internationalunit.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VitaminAUnit.Undefined, VitaminA.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VitaminAUnit)).Cast(); foreach(var unit in units) { - if(unit == VitaminAUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -376,14 +312,14 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 IU", new VitaminA(1, VitaminAUnit.InternationalUnit).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -399,10 +335,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s1")); Assert.Equal("0.12 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s2")); Assert.Equal("0.123 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s3")); @@ -410,7 +346,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -424,29 +360,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 IU", new VitaminA(0.123456, VitaminAUnit.InternationalUnit).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -566,13 +501,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VitaminAUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(QuantityType.VitaminA, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 9db1eea2be..3eb13d9482 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -134,12 +134,6 @@ public abstract partial class VolumeConcentrationTestsBase : QuantityTestsBase new object[] { VolumeConcentrationUnit.PicolitersPerMililiter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumeConcentration((double)0.0, VolumeConcentrationUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -148,7 +142,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeConcentrationUnit.DecimalFraction, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -192,14 +185,9 @@ public void VolumeConcentration_QuantityInfo_ReturnsQuantityInfoDescribingQuanti Assert.Equal(VolumeConcentration.Zero, quantityInfo.Zero); Assert.Equal("VolumeConcentration", quantityInfo.Name); - Assert.Equal(QuantityType.VolumeConcentration, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeConcentrationUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -485,49 +473,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => decimalfraction.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumeConcentration.FromDecimalFractions(1); - var b = VolumeConcentration.FromDecimalFractions(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumeConcentration.FromDecimalFractions(1); - var b = VolumeConcentration.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumeConcentration.FromDecimalFractions(1); - object b = VolumeConcentration.FromDecimalFractions(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -557,21 +502,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(decimalfraction.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeConcentrationUnit.Undefined, VolumeConcentration.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeConcentrationUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -585,8 +521,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cL/L", new VolumeConcentration(1, VolumeConcentrationUnit.CentilitersPerLiter).ToString()); Assert.Equal("1 cL/mL", new VolumeConcentration(1, VolumeConcentrationUnit.CentilitersPerMililiter).ToString()); @@ -611,7 +547,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -646,10 +582,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s1")); Assert.Equal("0.12", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s2")); Assert.Equal("0.123", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s3")); @@ -657,7 +593,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -671,29 +607,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235", new VolumeConcentration(0.123456, VolumeConcentrationUnit.DecimalFraction).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -813,13 +748,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeConcentrationUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(QuantityType.VolumeConcentration, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 6758c1bdb2..9bf7f8b876 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -62,12 +62,6 @@ public abstract partial class VolumeFlowPerAreaTestsBase : QuantityTestsBase new object[] { VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumeFlowPerArea((double)0.0, VolumeFlowPerAreaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -76,7 +70,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -120,14 +113,9 @@ public void VolumeFlowPerArea_QuantityInfo_ReturnsQuantityInfoDescribingQuantity Assert.Equal(VolumeFlowPerArea.Zero, quantityInfo.Zero); Assert.Equal("VolumeFlowPerArea", quantityInfo.Name); - Assert.Equal(QuantityType.VolumeFlowPerArea, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeFlowPerAreaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -287,49 +275,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterpersecondpersquaremeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - var b = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - var b = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1); - object b = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -359,21 +304,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterpersecondpersquaremeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeFlowPerAreaUnit.Undefined, VolumeFlowPerArea.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeFlowPerAreaUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeFlowPerAreaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -387,15 +323,15 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 CFM/ft²", new VolumeFlowPerArea(1, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot).ToString()); Assert.Equal("1 m³/(s·m²)", new VolumeFlowPerArea(1, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter).ToString()); } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -412,10 +348,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/(s·m²)", new VolumeFlowPerArea(0.123456, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter).ToString("s1")); Assert.Equal("0.12 m³/(s·m²)", new VolumeFlowPerArea(0.123456, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter).ToString("s2")); Assert.Equal("0.123 m³/(s·m²)", new VolumeFlowPerArea(0.123456, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter).ToString("s3")); @@ -423,7 +359,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -437,29 +373,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/(s·m²)", new VolumeFlowPerArea(0.123456, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -579,13 +514,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeFlowPerAreaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal(QuantityType.VolumeFlowPerArea, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index bbbc2ee7a6..017ac66c98 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -215,7 +215,7 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase VolumeFlowUnit.MilliliterPerHour => (MillilitersPerHourInOneCubicMeterPerSecond, MillilitersPerHourTolerance), VolumeFlowUnit.MilliliterPerMinute => (MillilitersPerMinuteInOneCubicMeterPerSecond, MillilitersPerMinuteTolerance), VolumeFlowUnit.MilliliterPerSecond => (MillilitersPerSecondInOneCubicMeterPerSecond, MillilitersPerSecondTolerance), - VolumeFlowUnit.MillionUsGallonsPerDay => (MillionUsGallonsPerDayInOneCubicMeterPerSecond, MillionUsGallonsPerDayTolerance), + VolumeFlowUnit.MillionUsGallonPerDay => (MillionUsGallonsPerDayInOneCubicMeterPerSecond, MillionUsGallonsPerDayTolerance), VolumeFlowUnit.NanoliterPerDay => (NanolitersPerDayInOneCubicMeterPerSecond, NanolitersPerDayTolerance), VolumeFlowUnit.NanoliterPerHour => (NanolitersPerHourInOneCubicMeterPerSecond, NanolitersPerHourTolerance), VolumeFlowUnit.NanoliterPerMinute => (NanolitersPerMinuteInOneCubicMeterPerSecond, NanolitersPerMinuteTolerance), @@ -283,7 +283,7 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase new object[] { VolumeFlowUnit.MilliliterPerHour }, new object[] { VolumeFlowUnit.MilliliterPerMinute }, new object[] { VolumeFlowUnit.MilliliterPerSecond }, - new object[] { VolumeFlowUnit.MillionUsGallonsPerDay }, + new object[] { VolumeFlowUnit.MillionUsGallonPerDay }, new object[] { VolumeFlowUnit.NanoliterPerDay }, new object[] { VolumeFlowUnit.NanoliterPerHour }, new object[] { VolumeFlowUnit.NanoliterPerMinute }, @@ -302,12 +302,6 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase new object[] { VolumeFlowUnit.UsGallonPerSecond }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumeFlow((double)0.0, VolumeFlowUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -316,7 +310,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeFlowUnit.CubicMeterPerSecond, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -360,14 +353,9 @@ public void VolumeFlow_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VolumeFlow.Zero, quantityInfo.Zero); Assert.Equal("VolumeFlow", quantityInfo.Name); - Assert.Equal(QuantityType.VolumeFlow, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeFlowUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -621,9 +609,9 @@ public void From_ValueAndUnit_ReturnsQuantityWithSameValueAndUnit() AssertEx.EqualTolerance(1, quantity44.MillilitersPerSecond, MillilitersPerSecondTolerance); Assert.Equal(VolumeFlowUnit.MilliliterPerSecond, quantity44.Unit); - var quantity45 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonsPerDay); + var quantity45 = VolumeFlow.From(1, VolumeFlowUnit.MillionUsGallonPerDay); AssertEx.EqualTolerance(1, quantity45.MillionUsGallonsPerDay, MillionUsGallonsPerDayTolerance); - Assert.Equal(VolumeFlowUnit.MillionUsGallonsPerDay, quantity45.Unit); + Assert.Equal(VolumeFlowUnit.MillionUsGallonPerDay, quantity45.Unit); var quantity46 = VolumeFlow.From(1, VolumeFlowUnit.NanoliterPerDay); AssertEx.EqualTolerance(1, quantity46.NanolitersPerDay, NanolitersPerDayTolerance); @@ -753,7 +741,7 @@ public void As() AssertEx.EqualTolerance(MillilitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MilliliterPerHour), MillilitersPerHourTolerance); AssertEx.EqualTolerance(MillilitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MilliliterPerMinute), MillilitersPerMinuteTolerance); AssertEx.EqualTolerance(MillilitersPerSecondInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MilliliterPerSecond), MillilitersPerSecondTolerance); - AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MillionUsGallonsPerDay), MillionUsGallonsPerDayTolerance); + AssertEx.EqualTolerance(MillionUsGallonsPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.MillionUsGallonPerDay), MillionUsGallonsPerDayTolerance); AssertEx.EqualTolerance(NanolitersPerDayInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.NanoliterPerDay), NanolitersPerDayTolerance); AssertEx.EqualTolerance(NanolitersPerHourInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.NanoliterPerHour), NanolitersPerHourTolerance); AssertEx.EqualTolerance(NanolitersPerMinuteInOneCubicMeterPerSecond, cubicmeterpersecond.As(VolumeFlowUnit.NanoliterPerMinute), NanolitersPerMinuteTolerance); @@ -947,49 +935,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterpersecond.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumeFlow.FromCubicMetersPerSecond(1); - var b = VolumeFlow.FromCubicMetersPerSecond(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumeFlow.FromCubicMetersPerSecond(1); - var b = VolumeFlow.FromCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumeFlow.FromCubicMetersPerSecond(1); - object b = VolumeFlow.FromCubicMetersPerSecond(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -1019,21 +964,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterpersecond.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeFlowUnit.Undefined, VolumeFlow.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeFlowUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeFlowUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -1047,8 +983,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 af/d", new VolumeFlow(1, VolumeFlowUnit.AcreFootPerDay).ToString()); Assert.Equal("1 af/h", new VolumeFlow(1, VolumeFlowUnit.AcreFootPerHour).ToString()); @@ -1095,7 +1031,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() Assert.Equal("1 mL/h", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerHour).ToString()); Assert.Equal("1 mL/min", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerMinute).ToString()); Assert.Equal("1 mL/s", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerSecond).ToString()); - Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonsPerDay).ToString()); + Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonPerDay).ToString()); Assert.Equal("1 nl/day", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerDay).ToString()); Assert.Equal("1 nL/h", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerHour).ToString()); Assert.Equal("1 nL/min", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerMinute).ToString()); @@ -1115,7 +1051,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1170,7 +1106,7 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture Assert.Equal("1 mL/h", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerHour).ToString(swedishCulture)); Assert.Equal("1 mL/min", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerMinute).ToString(swedishCulture)); Assert.Equal("1 mL/s", new VolumeFlow(1, VolumeFlowUnit.MilliliterPerSecond).ToString(swedishCulture)); - Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonsPerDay).ToString(swedishCulture)); + Assert.Equal("1 MGD", new VolumeFlow(1, VolumeFlowUnit.MillionUsGallonPerDay).ToString(swedishCulture)); Assert.Equal("1 nl/day", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerDay).ToString(swedishCulture)); Assert.Equal("1 nL/h", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerHour).ToString(swedishCulture)); Assert.Equal("1 nL/min", new VolumeFlow(1, VolumeFlowUnit.NanoliterPerMinute).ToString(swedishCulture)); @@ -1192,10 +1128,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s1")); Assert.Equal("0.12 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s2")); Assert.Equal("0.123 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s3")); @@ -1203,7 +1139,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1217,29 +1153,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/s", new VolumeFlow(0.123456, VolumeFlowUnit.CubicMeterPerSecond).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1359,13 +1294,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeFlowUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(QuantityType.VolumeFlow, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 99b3b19301..99f8e7ab62 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -82,12 +82,6 @@ public abstract partial class VolumePerLengthTestsBase : QuantityTestsBase new object[] { VolumePerLengthUnit.OilBarrelPerFoot }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumePerLength((double)0.0, VolumePerLengthUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -96,7 +90,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumePerLengthUnit.CubicMeterPerMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -140,14 +133,9 @@ public void VolumePerLength_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(VolumePerLength.Zero, quantityInfo.Zero); Assert.Equal("VolumePerLength", quantityInfo.Name); - Assert.Equal(QuantityType.VolumePerLength, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumePerLengthUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -342,49 +330,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeterpermeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumePerLength.FromCubicMetersPerMeter(1); - var b = VolumePerLength.FromCubicMetersPerMeter(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumePerLength.FromCubicMetersPerMeter(1); - var b = VolumePerLength.FromCubicMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumePerLength.FromCubicMetersPerMeter(1); - object b = VolumePerLength.FromCubicMetersPerMeter(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -414,21 +359,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeterpermeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumePerLengthUnit.Undefined, VolumePerLength.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumePerLengthUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -442,8 +378,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 m³/m", new VolumePerLength(1, VolumePerLengthUnit.CubicMeterPerMeter).ToString()); Assert.Equal("1 yd³/ft", new VolumePerLength(1, VolumePerLengthUnit.CubicYardPerFoot).ToString()); @@ -455,7 +391,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -477,10 +413,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s1")); Assert.Equal("0.12 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s2")); Assert.Equal("0.123 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s3")); @@ -488,7 +424,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -502,29 +438,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³/m", new VolumePerLength(0.123456, VolumePerLengthUnit.CubicMeterPerMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -644,13 +579,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumePerLengthUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(QuantityType.VolumePerLength, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 53acb7dd64..508997e8dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -258,12 +258,6 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase new object[] { VolumeUnit.UsTeaspoon }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new Volume((double)0.0, VolumeUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -272,7 +266,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumeUnit.CubicMeter, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -316,14 +309,9 @@ public void Volume_QuantityInfo_ReturnsQuantityInfoDescribingQuantity() Assert.Equal(Volume.Zero, quantityInfo.Zero); Assert.Equal("Volume", quantityInfo.Name); - Assert.Equal(QuantityType.Volume, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumeUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -826,49 +814,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => cubicmeter.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = Volume.FromCubicMeters(1); - var b = Volume.FromCubicMeters(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = Volume.FromCubicMeters(1); - var b = Volume.FromCubicMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = Volume.FromCubicMeters(1); - object b = Volume.FromCubicMeters(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -898,21 +843,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(cubicmeter.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumeUnit.Undefined, Volume.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumeUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumeUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -926,8 +862,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 ac-ft", new Volume(1, VolumeUnit.AcreFoot).ToString()); Assert.Equal("1", new Volume(1, VolumeUnit.AuTablespoon).ToString()); @@ -983,7 +919,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -1049,10 +985,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s1")); Assert.Equal("0.12 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s2")); Assert.Equal("0.123 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s3")); @@ -1060,7 +996,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -1074,29 +1010,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m³", new Volume(0.123456, VolumeUnit.CubicMeter).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = Volume.FromCubicMeters(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -1216,13 +1151,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumeUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(QuantityType.Volume, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 68f191f66c..961497b00a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -90,12 +90,6 @@ public abstract partial class VolumetricHeatCapacityTestsBase : QuantityTestsBas new object[] { VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new VolumetricHeatCapacity((double)0.0, VolumetricHeatCapacityUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -104,7 +98,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -148,14 +141,9 @@ public void VolumetricHeatCapacity_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(VolumetricHeatCapacity.Zero, quantityInfo.Zero); Assert.Equal("VolumetricHeatCapacity", quantityInfo.Name); - Assert.Equal(QuantityType.VolumetricHeatCapacity, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {VolumetricHeatCapacityUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -364,49 +352,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => joulepercubicmeterkelvin.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - var b = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - var b = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1); - object b = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -436,21 +381,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(joulepercubicmeterkelvin.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(VolumetricHeatCapacityUnit.Undefined, VolumetricHeatCapacity.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast(); foreach(var unit in units) { - if(unit == VolumetricHeatCapacityUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -464,8 +400,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 BTU/ft³·°F", new VolumetricHeatCapacity(1, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit).ToString()); Assert.Equal("1 cal/cm³·°C", new VolumetricHeatCapacity(1, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius).ToString()); @@ -479,7 +415,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -503,10 +439,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s1")); Assert.Equal("0.12 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s2")); Assert.Equal("0.123 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s3")); @@ -514,7 +450,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -528,29 +464,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 J/m³·K", new VolumetricHeatCapacity(0.123456, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -670,13 +605,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(VolumetricHeatCapacityUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(QuantityType.VolumetricHeatCapacity, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 6f1677cfb9..351b131581 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -78,12 +78,6 @@ public abstract partial class WarpingMomentOfInertiaTestsBase : QuantityTestsBas new object[] { WarpingMomentOfInertiaUnit.MillimeterToTheSixth }, }; - [Fact] - public void Ctor_WithUndefinedUnit_ThrowsArgumentException() - { - Assert.Throws(() => new WarpingMomentOfInertia((double)0.0, WarpingMomentOfInertiaUnit.Undefined)); - } - [Fact] public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() { @@ -92,7 +86,6 @@ public void DefaultCtor_ReturnsQuantityWithZeroValueAndBaseUnit() Assert.Equal(WarpingMomentOfInertiaUnit.MeterToTheSixth, quantity.Unit); } - [Fact] public void Ctor_WithInfinityValue_ThrowsArgumentException() { @@ -136,14 +129,9 @@ public void WarpingMomentOfInertia_QuantityInfo_ReturnsQuantityInfoDescribingQua Assert.Equal(WarpingMomentOfInertia.Zero, quantityInfo.Zero); Assert.Equal("WarpingMomentOfInertia", quantityInfo.Name); - Assert.Equal(QuantityType.WarpingMomentOfInertia, quantityInfo.QuantityType); - var units = EnumUtils.GetEnumValues().Except(new[] {WarpingMomentOfInertiaUnit.Undefined}).ToArray(); + var units = EnumUtils.GetEnumValues().ToArray(); var unitNames = units.Select(x => x.ToString()); - - // Obsolete members - Assert.Equal(units, quantityInfo.Units); - Assert.Equal(unitNames, quantityInfo.UnitNames); } [Fact] @@ -331,49 +319,6 @@ public void CompareToThrowsOnNull() Assert.Throws(() => metertothesixth.CompareTo(null)); } - [Fact] - public void EqualityOperators() - { - var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); - -#pragma warning disable CS8073 -// ReSharper disable EqualExpressionComparison - - Assert.True(a == a); - Assert.False(a != a); - - Assert.True(a != b); - Assert.False(a == b); - - Assert.False(a == null); - Assert.False(null == a); - -// ReSharper restore EqualExpressionComparison -#pragma warning restore CS8073 - } - - [Fact] - public void Equals_SameType_IsImplemented() - { - var a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - var b = WarpingMomentOfInertia.FromMetersToTheSixth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - } - - [Fact] - public void Equals_QuantityAsObject_IsImplemented() - { - object a = WarpingMomentOfInertia.FromMetersToTheSixth(1); - object b = WarpingMomentOfInertia.FromMetersToTheSixth(2); - - Assert.True(a.Equals(a)); - Assert.False(a.Equals(b)); - Assert.False(a.Equals((object)null)); - } - [Fact] public void Equals_RelativeTolerance_IsImplemented() { @@ -403,21 +348,12 @@ public void EqualsReturnsFalseOnNull() Assert.False(metertothesixth.Equals(null)); } - [Fact] - public void UnitsDoesNotContainUndefined() - { - Assert.DoesNotContain(WarpingMomentOfInertiaUnit.Undefined, WarpingMomentOfInertia.Units); - } - [Fact] public void HasAtLeastOneAbbreviationSpecified() { var units = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast(); foreach(var unit in units) { - if(unit == WarpingMomentOfInertiaUnit.Undefined) - continue; - var defaultAbbreviation = UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit); } } @@ -431,8 +367,8 @@ public void BaseDimensionsShouldNeverBeNull() [Fact] public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() { - var prevCulture = Thread.CurrentThread.CurrentUICulture; - Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US"); + var prevCulture = Thread.CurrentThread.CurrentCulture; + Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-US"); try { Assert.Equal("1 cm⁶", new WarpingMomentOfInertia(1, WarpingMomentOfInertiaUnit.CentimeterToTheSixth).ToString()); Assert.Equal("1 dm⁶", new WarpingMomentOfInertia(1, WarpingMomentOfInertiaUnit.DecimeterToTheSixth).ToString()); @@ -443,7 +379,7 @@ public void ToString_ReturnsValueAndUnitAbbreviationInCurrentCulture() } finally { - Thread.CurrentThread.CurrentUICulture = prevCulture; + Thread.CurrentThread.CurrentCulture = prevCulture; } } @@ -464,10 +400,10 @@ public void ToString_WithSwedishCulture_ReturnsUnitAbbreviationForEnglishCulture [Fact] public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCulture() { - var oldCulture = CultureInfo.CurrentUICulture; + var oldCulture = CultureInfo.CurrentCulture; try { - CultureInfo.CurrentUICulture = CultureInfo.InvariantCulture; + CultureInfo.CurrentCulture = CultureInfo.InvariantCulture; Assert.Equal("0.1 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s1")); Assert.Equal("0.12 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s2")); Assert.Equal("0.123 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s3")); @@ -475,7 +411,7 @@ public void ToString_SFormat_FormatsNumberWithGivenDigitsAfterRadixForCurrentCul } finally { - CultureInfo.CurrentUICulture = oldCulture; + CultureInfo.CurrentCulture = oldCulture; } } @@ -489,29 +425,28 @@ public void ToString_SFormatAndCulture_FormatsNumberWithGivenDigitsAfterRadixFor Assert.Equal("0.1235 m⁶", new WarpingMomentOfInertia(0.123456, WarpingMomentOfInertiaUnit.MeterToTheSixth).ToString("s4", culture)); } - - [Fact] - public void ToString_NullFormat_ThrowsArgumentNullException() + [Theory] + [InlineData(null)] + [InlineData("en-US")] + public void ToString_NullFormat_DefaultsToGeneralFormat(string cultureName) { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Throws(() => quantity.ToString(null, null, null)); - } + CultureInfo formatProvider = cultureName == null + ? null + : CultureInfo.GetCultureInfo(cultureName); - [Fact] - public void ToString_NullArgs_ThrowsArgumentNullException() - { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Throws(() => quantity.ToString(null, "g", null)); + Assert.Equal(quantity.ToString("g", formatProvider), quantity.ToString(null, formatProvider)); } - [Fact] - public void ToString_NullProvider_EqualsCurrentUICulture() + [Theory] + [InlineData(null)] + [InlineData("g")] + public void ToString_NullProvider_EqualsCurrentCulture(string format) { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(quantity.ToString(CultureInfo.CurrentUICulture, "g"), quantity.ToString(null, "g")); + Assert.Equal(quantity.ToString(format, CultureInfo.CurrentCulture), quantity.ToString(format, null)); } - [Fact] public void Convert_ToBool_ThrowsInvalidCastException() { @@ -631,13 +566,6 @@ public void Convert_ChangeType_UnitType_EqualsUnit() Assert.Equal(quantity.Unit, Convert.ChangeType(quantity, typeof(WarpingMomentOfInertiaUnit))); } - [Fact] - public void Convert_ChangeType_QuantityType_EqualsQuantityType() - { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(QuantityType.WarpingMomentOfInertia, Convert.ChangeType(quantity, typeof(QuantityType))); - } - [Fact] public void Convert_ChangeType_QuantityInfo_EqualsQuantityInfo() { diff --git a/UnitsNet.Tests/QuantityInfoTest.cs b/UnitsNet.Tests/QuantityInfoTest.cs index cff89598a6..bdaab3dca9 100644 --- a/UnitsNet.Tests/QuantityInfoTest.cs +++ b/UnitsNet.Tests/QuantityInfoTest.cs @@ -75,7 +75,7 @@ public void GenericsConstructor_AssignsProperties() public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -83,7 +83,7 @@ public void Constructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -99,7 +99,7 @@ public void Constructor_GivenNullAsBaseUnit_ThrowsArgumentNullException() public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -107,7 +107,7 @@ public void Constructor_GivenNullAsZero_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -115,7 +115,7 @@ public void GenericsConstructor_GivenNullAsZero_ThrowsArgumentNullException() public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), typeof(LengthUnit), - Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } [Fact] @@ -123,14 +123,14 @@ public void Constructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() public void GenericsConstructor_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(nameof(Length), - Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } [Fact] [SuppressMessage("ReSharper", "AssignNullToNotNullAttribute")] public void Constructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, typeof(LengthUnit), - null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -138,7 +138,7 @@ public void Constructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() public void GenericsConstructor2_GivenNullAsUnitInfos_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, - null, Length.ConversionBaseUnit, Length.Zero, Length.BaseDimensions)); + null, Length.BaseUnit, Length.Zero, Length.BaseDimensions)); } [Fact] @@ -154,7 +154,7 @@ public void Constructor2_GivenNullAsBaseUnit_ThrowsArgumentNullException() public void Constructor2_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, typeof(LengthUnit), - Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -162,7 +162,7 @@ public void Constructor2_GivenNullAsZero_ThrowsArgumentNullException() public void GenericsConstructor2_GivenNullAsZero_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, - Length.Info.UnitInfos, Length.ConversionBaseUnit, null, Length.BaseDimensions)); + Length.Info.UnitInfos, Length.BaseUnit, null, Length.BaseDimensions)); } [Fact] @@ -170,7 +170,7 @@ public void GenericsConstructor2_GivenNullAsZero_ThrowsArgumentNullException() public void Constructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, typeof(LengthUnit), - Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } [Fact] @@ -178,7 +178,7 @@ public void Constructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullException() public void GenericsConstructor2_GivenNullAsBaseDimensions_ThrowsArgumentNullException() { Assert.Throws(() => new QuantityInfo(Length.Info.Name, - Length.Info.UnitInfos, Length.ConversionBaseUnit, Length.Zero, null)); + Length.Info.UnitInfos, Length.BaseUnit, Length.Zero, null)); } [Fact] diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index de956577ec..d556757893 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -129,7 +129,7 @@ public void DoubleBaseUnitQuantity_DeserializedFromValueAndNoUnit() var quantity = DeserializeObject(json); Assert.Equal(1.2, quantity.Value); - Assert.Equal(Mass.ConversionBaseUnit, quantity.Unit); + Assert.Equal(Mass.BaseUnit, quantity.Unit); } [Fact] @@ -140,7 +140,7 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() var quantity = DeserializeObject(json); Assert.Equal(0, quantity.Value); - Assert.Equal(Mass.ConversionBaseUnit, quantity.Unit); + Assert.Equal(Mass.BaseUnit, quantity.Unit); } [Fact] @@ -201,7 +201,7 @@ public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit() Assert.Equal(1.200m, quantity.Value); Assert.Equal("1.200", quantity.Value.ToString(CultureInfo.InvariantCulture)); - Assert.Equal(Information.ConversionBaseUnit, quantity.Unit); + Assert.Equal(Information.BaseUnit, quantity.Unit); } [Fact] @@ -212,7 +212,7 @@ public void DecimalZeroBaseQuantity_DeserializedFromEmptyInput() var quantity = DeserializeObject(json); Assert.Equal(0, quantity.Value); - Assert.Equal(Information.ConversionBaseUnit, quantity.Unit); + Assert.Equal(Information.BaseUnit, quantity.Unit); } #endregion diff --git a/UnitsNet.Tests/UnitMathTests.cs b/UnitsNet.Tests/UnitMathTests.cs index 64dd3827d7..1951549863 100644 --- a/UnitsNet.Tests/UnitMathTests.cs +++ b/UnitsNet.Tests/UnitMathTests.cs @@ -276,7 +276,7 @@ public void SumOfEmptySourceReturnsZero() { var units = new Length[] { }; - Length sum = units.Sum(Length.ConversionBaseUnit); + Length sum = units.Sum(Length.BaseUnit); Assert.Equal(Length.Zero, sum); } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 6463a39af7..ebce0f320b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. /// [DataContract] - public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Acceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -77,7 +76,7 @@ static Acceleration() new UnitInfo(AccelerationUnit.NanometerPerSecondSquared, "NanometersPerSecondSquared", BaseUnits.Undefined), new UnitInfo(AccelerationUnit.StandardGravity, "StandardGravity", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Acceleration); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -90,9 +89,6 @@ static Acceleration() /// If value is NaN or Infinity. public Acceleration(double value, AccelerationUnit unit) { - if(unit == AccelerationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -136,24 +132,6 @@ public Acceleration(double value, UnitSystem unitSystem) /// public static AccelerationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Acceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Acceleration MaxValue { get; } - - /// - /// Represents the smallest possible value of Acceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Acceleration MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Acceleration quantity. /// @@ -184,12 +162,6 @@ public Acceleration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Acceleration; - /// /// The of this quantity. /// @@ -293,7 +265,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MillistandardGravity, quantity => new Acceleration((quantity.Value/9.80665) / 1e-3d, AccelerationUnit.MillistandardGravity)); unitConverter.SetConversionFunction(AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.NanometerPerSecondSquared, quantity => new Acceleration((quantity.Value) / 1e-9d, AccelerationUnit.NanometerPerSecondSquared)); unitConverter.SetConversionFunction(AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.StandardGravity, quantity => new Acceleration(quantity.Value/9.80665, AccelerationUnit.StandardGravity)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AccelerationUnit.MeterPerSecondSquared, AccelerationUnit.MeterPerSecondSquared, quantity => quantity); @@ -328,7 +299,7 @@ public static string GetAbbreviation(AccelerationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -529,7 +500,7 @@ public static Acceleration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Acceleration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -560,7 +531,7 @@ public static bool TryParse(string? str, out Acceleration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Acceleration result) { return QuantityParser.Default.TryParse( @@ -588,7 +559,7 @@ public static AccelerationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -614,7 +585,7 @@ public static bool TryParseUnit(string str, out AccelerationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AccelerationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -694,20 +665,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Acceleration left, Acceleration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Acceleration left, Acceleration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -723,23 +680,6 @@ public int CompareTo(Acceleration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Acceleration objAcceleration)) - return false; - - return Equals(objAcceleration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Acceleration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Acceleration within the given absolute or relative tolerance. @@ -931,7 +871,7 @@ private double GetValueAs(AccelerationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -950,63 +890,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1088,8 +994,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AccelerationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Acceleration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Acceleration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index f0a95c8bff..8dcae71a63 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. /// [DataContract] - public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmountOfSubstance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -78,7 +77,7 @@ static AmountOfSubstance() new UnitInfo(AmountOfSubstanceUnit.NanopoundMole, "NanopoundMoles", BaseUnits.Undefined), new UnitInfo(AmountOfSubstanceUnit.PoundMole, "PoundMoles", new BaseUnits(amount: AmountOfSubstanceUnit.PoundMole)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AmountOfSubstance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -91,9 +90,6 @@ static AmountOfSubstance() /// If value is NaN or Infinity. public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) { - if(unit == AmountOfSubstanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -137,24 +133,6 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// public static AmountOfSubstanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of AmountOfSubstance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmountOfSubstance MaxValue { get; } - - /// - /// Represents the smallest possible value of AmountOfSubstance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmountOfSubstance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the AmountOfSubstance quantity. /// @@ -185,12 +163,6 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.AmountOfSubstance; - /// /// The of this quantity. /// @@ -300,7 +272,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Nanomole, quantity => new AmountOfSubstance((quantity.Value) / 1e-9d, AmountOfSubstanceUnit.Nanomole)); unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.NanopoundMole, quantity => new AmountOfSubstance((quantity.Value/453.59237) / 1e-9d, AmountOfSubstanceUnit.NanopoundMole)); unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.PoundMole, quantity => new AmountOfSubstance(quantity.Value/453.59237, AmountOfSubstanceUnit.PoundMole)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AmountOfSubstanceUnit.Mole, AmountOfSubstanceUnit.Mole, quantity => quantity); @@ -336,7 +307,7 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -546,7 +517,7 @@ public static AmountOfSubstance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AmountOfSubstance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -577,7 +548,7 @@ public static bool TryParse(string? str, out AmountOfSubstance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AmountOfSubstance result) { return QuantityParser.Default.TryParse( @@ -605,7 +576,7 @@ public static AmountOfSubstanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -631,7 +602,7 @@ public static bool TryParseUnit(string str, out AmountOfSubstanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AmountOfSubstanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -711,20 +682,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -740,23 +697,6 @@ public int CompareTo(AmountOfSubstance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) - return false; - - return Equals(objAmountOfSubstance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmountOfSubstance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AmountOfSubstance within the given absolute or relative tolerance. @@ -948,7 +888,7 @@ private double GetValueAs(AmountOfSubstanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -967,63 +907,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1105,8 +1011,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AmountOfSubstanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AmountOfSubstance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AmountOfSubstance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 5cb7f6c4ec..fc836a0822 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. /// [DataContract] - public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmplitudeRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static AmplitudeRatio() new UnitInfo(AmplitudeRatioUnit.DecibelUnloaded, "DecibelsUnloaded", BaseUnits.Undefined), new UnitInfo(AmplitudeRatioUnit.DecibelVolt, "DecibelVolts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AmplitudeRatio); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static AmplitudeRatio() /// If value is NaN or Infinity. public AmplitudeRatio(double value, AmplitudeRatioUnit unit) { - if(unit == AmplitudeRatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// public static AmplitudeRatioUnit BaseUnit { get; } - /// - /// Represents the largest possible value of AmplitudeRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmplitudeRatio MaxValue { get; } - - /// - /// Represents the smallest possible value of AmplitudeRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AmplitudeRatio MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the AmplitudeRatio quantity. /// @@ -174,12 +152,6 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.AmplitudeRatio; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelMicrovolt, quantity => new AmplitudeRatio(quantity.Value + 120, AmplitudeRatioUnit.DecibelMicrovolt)); unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelMillivolt, quantity => new AmplitudeRatio(quantity.Value + 60, AmplitudeRatioUnit.DecibelMillivolt)); unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelUnloaded, quantity => new AmplitudeRatio(quantity.Value + 2.218487499, AmplitudeRatioUnit.DecibelUnloaded)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AmplitudeRatioUnit.DecibelVolt, AmplitudeRatioUnit.DecibelVolt, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static AmplitudeRatio Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AmplitudeRatio Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out AmplitudeRatio result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AmplitudeRatio result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static AmplitudeRatioUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out AmplitudeRatioUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AmplitudeRatioUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -532,20 +503,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -561,23 +518,6 @@ public int CompareTo(AmplitudeRatio other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) - return false; - - return Equals(objAmplitudeRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmplitudeRatio other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AmplitudeRatio within the given absolute or relative tolerance. @@ -769,7 +709,7 @@ private double GetValueAs(AmplitudeRatioUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -788,63 +728,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -926,8 +832,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AmplitudeRatioUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AmplitudeRatio.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AmplitudeRatio.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 0bb72a8223..1c491fe14b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. /// [DataContract] - public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Angle : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -79,7 +78,7 @@ static Angle() new UnitInfo(AngleUnit.Revolution, "Revolutions", BaseUnits.Undefined), new UnitInfo(AngleUnit.Tilt, "Tilt", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Angle); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -92,9 +91,6 @@ static Angle() /// If value is NaN or Infinity. public Angle(double value, AngleUnit unit) { - if(unit == AngleUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -138,24 +134,6 @@ public Angle(double value, UnitSystem unitSystem) /// public static AngleUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Angle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Angle MaxValue { get; } - - /// - /// Represents the smallest possible value of Angle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Angle MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Angle quantity. /// @@ -186,12 +164,6 @@ public Angle(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Angle; - /// /// The of this quantity. /// @@ -307,7 +279,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Radian, quantity => new Angle(quantity.Value/180*Math.PI, AngleUnit.Radian)); unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Revolution, quantity => new Angle(quantity.Value/360, AngleUnit.Revolution)); unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Tilt, quantity => new Angle(Math.Sin(quantity.Value/180*Math.PI), AngleUnit.Tilt)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Degree, quantity => quantity); @@ -344,7 +315,7 @@ public static string GetAbbreviation(AngleUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -563,7 +534,7 @@ public static Angle Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Angle Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -594,7 +565,7 @@ public static bool TryParse(string? str, out Angle result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Angle result) { return QuantityParser.Default.TryParse( @@ -622,7 +593,7 @@ public static AngleUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -648,7 +619,7 @@ public static bool TryParseUnit(string str, out AngleUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AngleUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -728,20 +699,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Angle left, Angle right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Angle left, Angle right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -757,23 +714,6 @@ public int CompareTo(Angle other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Angle objAngle)) - return false; - - return Equals(objAngle); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Angle other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Angle within the given absolute or relative tolerance. @@ -965,7 +905,7 @@ private double GetValueAs(AngleUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -984,63 +924,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1122,8 +1028,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AngleUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Angle.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Angle.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 4c8700c719..21405e7c2f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. /// [DataContract] - public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static ApparentEnergy() new UnitInfo(ApparentEnergyUnit.MegavoltampereHour, "MegavoltampereHours", BaseUnits.Undefined), new UnitInfo(ApparentEnergyUnit.VoltampereHour, "VoltampereHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ApparentEnergy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static ApparentEnergy() /// If value is NaN or Infinity. public ApparentEnergy(double value, ApparentEnergyUnit unit) { - if(unit == ApparentEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// public static ApparentEnergyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ApparentEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentEnergy MaxValue { get; } - - /// - /// Represents the smallest possible value of ApparentEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentEnergy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ApparentEnergy quantity. /// @@ -173,12 +151,6 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ApparentEnergy; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> ApparentEnergyUnit unitConverter.SetConversionFunction(ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.KilovoltampereHour, quantity => new ApparentEnergy((quantity.Value) / 1e3d, ApparentEnergyUnit.KilovoltampereHour)); unitConverter.SetConversionFunction(ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.MegavoltampereHour, quantity => new ApparentEnergy((quantity.Value) / 1e6d, ApparentEnergyUnit.MegavoltampereHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ApparentEnergyUnit.VoltampereHour, ApparentEnergyUnit.VoltampereHour, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(ApparentEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static ApparentEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ApparentEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out ApparentEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ApparentEnergy result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static ApparentEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out ApparentEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ApparentEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentEnergy left, ApparentEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentEnergy left, ApparentEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(ApparentEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ApparentEnergy objApparentEnergy)) - return false; - - return Equals(objApparentEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ApparentEnergy within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(ApparentEnergyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ApparentEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ApparentEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ApparentEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index eff9b336d8..aaf4948fda 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. /// [DataContract] - public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentPower : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static ApparentPower() new UnitInfo(ApparentPowerUnit.Megavoltampere, "Megavoltamperes", BaseUnits.Undefined), new UnitInfo(ApparentPowerUnit.Voltampere, "Voltamperes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ApparentPower); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static ApparentPower() /// If value is NaN or Infinity. public ApparentPower(double value, ApparentPowerUnit unit) { - if(unit == ApparentPowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public ApparentPower(double value, UnitSystem unitSystem) /// public static ApparentPowerUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ApparentPower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentPower MaxValue { get; } - - /// - /// Represents the smallest possible value of ApparentPower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ApparentPower MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ApparentPower quantity. /// @@ -174,12 +152,6 @@ public ApparentPower(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ApparentPower; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ApparentPowerUnit.Voltampere, ApparentPowerUnit.Gigavoltampere, quantity => new ApparentPower((quantity.Value) / 1e9d, ApparentPowerUnit.Gigavoltampere)); unitConverter.SetConversionFunction(ApparentPowerUnit.Voltampere, ApparentPowerUnit.Kilovoltampere, quantity => new ApparentPower((quantity.Value) / 1e3d, ApparentPowerUnit.Kilovoltampere)); unitConverter.SetConversionFunction(ApparentPowerUnit.Voltampere, ApparentPowerUnit.Megavoltampere, quantity => new ApparentPower((quantity.Value) / 1e6d, ApparentPowerUnit.Megavoltampere)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ApparentPowerUnit.Voltampere, ApparentPowerUnit.Voltampere, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(ApparentPowerUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static ApparentPower Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ApparentPower Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out ApparentPower result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ApparentPower result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static ApparentPowerUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out ApparentPowerUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ApparentPowerUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -524,20 +495,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentPower left, ApparentPower right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentPower left, ApparentPower right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -553,23 +510,6 @@ public int CompareTo(ApparentPower other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ApparentPower objApparentPower)) - return false; - - return Equals(objApparentPower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentPower other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ApparentPower within the given absolute or relative tolerance. @@ -761,7 +701,7 @@ private double GetValueAs(ApparentPowerUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -780,63 +720,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -918,8 +824,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ApparentPowerUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ApparentPower.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ApparentPower.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 50722ef5af..7247872f09 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). /// [DataContract] - public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Area : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -77,7 +76,7 @@ static Area() new UnitInfo(AreaUnit.SquareYard, "SquareYards", new BaseUnits(length: LengthUnit.Yard)), new UnitInfo(AreaUnit.UsSurveySquareFoot, "UsSurveySquareFeet", new BaseUnits(length: LengthUnit.UsSurveyFoot)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Area); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -90,9 +89,6 @@ static Area() /// If value is NaN or Infinity. public Area(double value, AreaUnit unit) { - if(unit == AreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -136,24 +132,6 @@ public Area(double value, UnitSystem unitSystem) /// public static AreaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Area - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Area MaxValue { get; } - - /// - /// Represents the smallest possible value of Area - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Area MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Area quantity. /// @@ -184,12 +162,6 @@ public Area(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Area; - /// /// The of this quantity. /// @@ -293,7 +265,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AreaUnit.SquareMeter, AreaUnit.SquareNauticalMile, quantity => new Area(quantity.Value/3429904, AreaUnit.SquareNauticalMile)); unitConverter.SetConversionFunction(AreaUnit.SquareMeter, AreaUnit.SquareYard, quantity => new Area(quantity.Value/0.836127, AreaUnit.SquareYard)); unitConverter.SetConversionFunction(AreaUnit.SquareMeter, AreaUnit.UsSurveySquareFoot, quantity => new Area(quantity.Value/0.09290341161, AreaUnit.UsSurveySquareFoot)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AreaUnit.SquareMeter, AreaUnit.SquareMeter, quantity => quantity); @@ -328,7 +299,7 @@ public static string GetAbbreviation(AreaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -529,7 +500,7 @@ public static Area Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Area Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -560,7 +531,7 @@ public static bool TryParse(string? str, out Area result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Area result) { return QuantityParser.Default.TryParse( @@ -588,7 +559,7 @@ public static AreaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -614,7 +585,7 @@ public static bool TryParseUnit(string str, out AreaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -694,20 +665,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Area left, Area right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Area left, Area right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -723,23 +680,6 @@ public int CompareTo(Area other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Area objArea)) - return false; - - return Equals(objArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Area other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Area within the given absolute or relative tolerance. @@ -931,7 +871,7 @@ private double GetValueAs(AreaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -950,63 +890,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1088,8 +994,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AreaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Area.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Area.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 3915eb7e03..6cdbf1ab2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The area density of a two-dimensional object is calculated as the mass per unit area. /// [DataContract] - public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -64,7 +63,7 @@ static AreaDensity() { new UnitInfo(AreaDensityUnit.KilogramPerSquareMeter, "KilogramsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AreaDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -77,9 +76,6 @@ static AreaDensity() /// If value is NaN or Infinity. public AreaDensity(double value, AreaDensityUnit unit) { - if(unit == AreaDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,24 +119,6 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public static AreaDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of AreaDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of AreaDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the AreaDensity quantity. /// @@ -171,12 +149,6 @@ public AreaDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.AreaDensity; - /// /// The of this quantity. /// @@ -202,7 +174,6 @@ public AreaDensity(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> AreaDensityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AreaDensityUnit.KilogramPerSquareMeter, AreaDensityUnit.KilogramPerSquareMeter, quantity => quantity); @@ -224,7 +195,7 @@ public static string GetAbbreviation(AreaDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -308,7 +279,7 @@ public static AreaDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AreaDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -339,7 +310,7 @@ public static bool TryParse(string? str, out AreaDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AreaDensity result) { return QuantityParser.Default.TryParse( @@ -367,7 +338,7 @@ public static AreaDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -393,7 +364,7 @@ public static bool TryParseUnit(string str, out AreaDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -473,20 +444,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaDensity left, AreaDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaDensity left, AreaDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -502,23 +459,6 @@ public int CompareTo(AreaDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AreaDensity objAreaDensity)) - return false; - - return Equals(objAreaDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AreaDensity within the given absolute or relative tolerance. @@ -710,7 +650,7 @@ private double GetValueAs(AreaDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -729,63 +669,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -867,8 +773,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AreaDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AreaDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AreaDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 5644e5dda7..3a74192b19 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A geometric property of an area that reflects how its points are distributed with regard to an axis. /// [DataContract] - public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static AreaMomentOfInertia() new UnitInfo(AreaMomentOfInertiaUnit.MeterToTheFourth, "MetersToTheFourth", new BaseUnits(length: LengthUnit.Meter)), new UnitInfo(AreaMomentOfInertiaUnit.MillimeterToTheFourth, "MillimetersToTheFourth", new BaseUnits(length: LengthUnit.Millimeter)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.AreaMomentOfInertia); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static AreaMomentOfInertia() /// If value is NaN or Infinity. public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) { - if(unit == AreaMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// public static AreaMomentOfInertiaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of AreaMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaMomentOfInertia MaxValue { get; } - - /// - /// Represents the smallest possible value of AreaMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static AreaMomentOfInertia MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the AreaMomentOfInertia quantity. /// @@ -176,12 +154,6 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.AreaMomentOfInertia; - /// /// The of this quantity. /// @@ -237,7 +209,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.FootToTheFourth, quantity => new AreaMomentOfInertia(quantity.Value/Math.Pow(0.3048, 4), AreaMomentOfInertiaUnit.FootToTheFourth)); unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.InchToTheFourth, quantity => new AreaMomentOfInertia(quantity.Value/Math.Pow(2.54e-2, 4), AreaMomentOfInertiaUnit.InchToTheFourth)); unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.MillimeterToTheFourth, quantity => new AreaMomentOfInertia(quantity.Value*1e12, AreaMomentOfInertiaUnit.MillimeterToTheFourth)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AreaMomentOfInertiaUnit.MeterToTheFourth, AreaMomentOfInertiaUnit.MeterToTheFourth, quantity => quantity); @@ -264,7 +235,7 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -393,7 +364,7 @@ public static AreaMomentOfInertia Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static AreaMomentOfInertia Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -424,7 +395,7 @@ public static bool TryParse(string? str, out AreaMomentOfInertia result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out AreaMomentOfInertia result) { return QuantityParser.Default.TryParse( @@ -452,7 +423,7 @@ public static AreaMomentOfInertiaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -478,7 +449,7 @@ public static bool TryParseUnit(string str, out AreaMomentOfInertiaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaMomentOfInertiaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -558,20 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -587,23 +544,6 @@ public int CompareTo(AreaMomentOfInertia other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) - return false; - - return Equals(objAreaMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaMomentOfInertia other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another AreaMomentOfInertia within the given absolute or relative tolerance. @@ -795,7 +735,7 @@ private double GetValueAs(AreaMomentOfInertiaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -814,63 +754,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -952,8 +858,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(AreaMomentOfInertiaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return AreaMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) return AreaMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 3de47d828b..d5e188f2e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Bit_rate /// [DataContract] - public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BitRate : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -92,7 +91,7 @@ static BitRate() new UnitInfo(BitRateUnit.TerabitPerSecond, "TerabitsPerSecond", BaseUnits.Undefined), new UnitInfo(BitRateUnit.TerabytePerSecond, "TerabytesPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.BitRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -105,9 +104,6 @@ static BitRate() /// If value is NaN or Infinity. public BitRate(decimal value, BitRateUnit unit) { - if(unit == BitRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; _unit = unit; } @@ -151,24 +147,6 @@ public BitRate(decimal value, UnitSystem unitSystem) /// public static BitRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of BitRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BitRate MaxValue { get; } - - /// - /// Represents the smallest possible value of BitRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BitRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the BitRate quantity. /// @@ -204,12 +182,6 @@ public BitRate(decimal value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.BitRate; - /// /// The of this quantity. /// @@ -385,7 +357,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(BitRateUnit.BitPerSecond, BitRateUnit.TebibytePerSecond, quantity => new BitRate((quantity.Value/8m) / (1024m * 1024 * 1024 * 1024), BitRateUnit.TebibytePerSecond)); unitConverter.SetConversionFunction(BitRateUnit.BitPerSecond, BitRateUnit.TerabitPerSecond, quantity => new BitRate((quantity.Value) / 1e12m, BitRateUnit.TerabitPerSecond)); unitConverter.SetConversionFunction(BitRateUnit.BitPerSecond, BitRateUnit.TerabytePerSecond, quantity => new BitRate((quantity.Value/8m) / 1e12m, BitRateUnit.TerabytePerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(BitRateUnit.BitPerSecond, BitRateUnit.BitPerSecond, quantity => quantity); @@ -432,7 +403,7 @@ public static string GetAbbreviation(BitRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -741,7 +712,7 @@ public static BitRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static BitRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -772,7 +743,7 @@ public static bool TryParse(string? str, out BitRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out BitRate result) { return QuantityParser.Default.TryParse( @@ -800,7 +771,7 @@ public static BitRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -826,7 +797,7 @@ public static bool TryParseUnit(string str, out BitRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -906,20 +877,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BitRate left, BitRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BitRate left, BitRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -935,23 +892,6 @@ public int CompareTo(BitRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is BitRate objBitRate)) - return false; - - return Equals(objBitRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(BitRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another BitRate within the given absolute or relative tolerance. @@ -1143,7 +1083,7 @@ private decimal GetValueAs(BitRateUnit unit) { var converted = ToUnit(unit); return (decimal)converted.Value; - } + } #endregion @@ -1162,63 +1102,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1300,8 +1206,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(BitRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return BitRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return BitRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index c89db18280..561f4e0043 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. /// [DataContract] - public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BrakeSpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static BrakeSpecificFuelConsumption() new UnitInfo(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, "KilogramsPerJoule", BaseUnits.Undefined), new UnitInfo(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, "PoundsPerMechanicalHorsepowerHour", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.BrakeSpecificFuelConsumption); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static BrakeSpecificFuelConsumption() /// If value is NaN or Infinity. public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) { - if(unit == BrakeSpecificFuelConsumptionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// public static BrakeSpecificFuelConsumptionUnit BaseUnit { get; } - /// - /// Represents the largest possible value of BrakeSpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BrakeSpecificFuelConsumption MaxValue { get; } - - /// - /// Represents the smallest possible value of BrakeSpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static BrakeSpecificFuelConsumption MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the BrakeSpecificFuelConsumption quantity. /// @@ -173,12 +151,6 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.BrakeSpecificFuelConsumption; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> BrakeSpecificFuelConsumptionUnit unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour, quantity => new BrakeSpecificFuelConsumption(quantity.Value*3.6e9, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour)); unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour, quantity => new BrakeSpecificFuelConsumption(quantity.Value/1.689659410672e-7, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static BrakeSpecificFuelConsumption Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static BrakeSpecificFuelConsumption Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out BrakeSpecificFuelConsumption result /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out BrakeSpecificFuelConsumption result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static BrakeSpecificFuelConsumptionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out BrakeSpecificFuelConsumptionUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out BrakeSpecificFuelConsumptionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(BrakeSpecificFuelConsumption other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) - return false; - - return Equals(objBrakeSpecificFuelConsumption); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(BrakeSpecificFuelConsumption other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another BrakeSpecificFuelConsumption within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(BrakeSpecificFuelConsumptionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return BrakeSpecificFuelConsumption.QuantityType; else if(conversionType == typeof(QuantityInfo)) return BrakeSpecificFuelConsumption.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 137371654b..1fa5fbf214 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Capacitance /// [DataContract] - public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Capacitance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -73,7 +72,7 @@ static Capacitance() new UnitInfo(CapacitanceUnit.Nanofarad, "Nanofarads", BaseUnits.Undefined), new UnitInfo(CapacitanceUnit.Picofarad, "Picofarads", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Capacitance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -86,9 +85,6 @@ static Capacitance() /// If value is NaN or Infinity. public Capacitance(double value, CapacitanceUnit unit) { - if(unit == CapacitanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -132,24 +128,6 @@ public Capacitance(double value, UnitSystem unitSystem) /// public static CapacitanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Capacitance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Capacitance MaxValue { get; } - - /// - /// Represents the smallest possible value of Capacitance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Capacitance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Capacitance quantity. /// @@ -180,12 +158,6 @@ public Capacitance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Capacitance; - /// /// The of this quantity. /// @@ -247,7 +219,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(CapacitanceUnit.Farad, CapacitanceUnit.Millifarad, quantity => new Capacitance((quantity.Value) / 1e-3d, CapacitanceUnit.Millifarad)); unitConverter.SetConversionFunction(CapacitanceUnit.Farad, CapacitanceUnit.Nanofarad, quantity => new Capacitance((quantity.Value) / 1e-9d, CapacitanceUnit.Nanofarad)); unitConverter.SetConversionFunction(CapacitanceUnit.Farad, CapacitanceUnit.Picofarad, quantity => new Capacitance((quantity.Value) / 1e-12d, CapacitanceUnit.Picofarad)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(CapacitanceUnit.Farad, CapacitanceUnit.Farad, quantity => quantity); @@ -275,7 +246,7 @@ public static string GetAbbreviation(CapacitanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -413,7 +384,7 @@ public static Capacitance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Capacitance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -444,7 +415,7 @@ public static bool TryParse(string? str, out Capacitance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Capacitance result) { return QuantityParser.Default.TryParse( @@ -472,7 +443,7 @@ public static CapacitanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -498,7 +469,7 @@ public static bool TryParseUnit(string str, out CapacitanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out CapacitanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -578,20 +549,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Capacitance left, Capacitance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Capacitance left, Capacitance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -607,23 +564,6 @@ public int CompareTo(Capacitance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Capacitance objCapacitance)) - return false; - - return Equals(objCapacitance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Capacitance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Capacitance within the given absolute or relative tolerance. @@ -815,7 +755,7 @@ private double GetValueAs(CapacitanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -834,63 +774,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -972,8 +878,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(CapacitanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Capacitance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Capacitance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index ea35b86766..3d8b263e9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A unit that represents a fractional change in size in response to a change in temperature. /// [DataContract] - public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct CoefficientOfThermalExpansion : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static CoefficientOfThermalExpansion() new UnitInfo(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, "InverseDegreeFahrenheit", new BaseUnits(temperature: TemperatureUnit.DegreeFahrenheit)), new UnitInfo(CoefficientOfThermalExpansionUnit.InverseKelvin, "InverseKelvin", new BaseUnits(temperature: TemperatureUnit.Kelvin)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.CoefficientOfThermalExpansion); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static CoefficientOfThermalExpansion() /// If value is NaN or Infinity. public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) { - if(unit == CoefficientOfThermalExpansionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// public static CoefficientOfThermalExpansionUnit BaseUnit { get; } - /// - /// Represents the largest possible value of CoefficientOfThermalExpansion - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static CoefficientOfThermalExpansion MaxValue { get; } - - /// - /// Represents the smallest possible value of CoefficientOfThermalExpansion - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static CoefficientOfThermalExpansion MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the CoefficientOfThermalExpansion quantity. /// @@ -173,12 +151,6 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.CoefficientOfThermalExpansion; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> CoefficientOfThermalExpansionUnit unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseKelvin, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius, quantity => new CoefficientOfThermalExpansion(quantity.Value, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius)); unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseKelvin, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit, quantity => new CoefficientOfThermalExpansion(quantity.Value*5/9, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(CoefficientOfThermalExpansionUnit.InverseKelvin, CoefficientOfThermalExpansionUnit.InverseKelvin, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static CoefficientOfThermalExpansion Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static CoefficientOfThermalExpansion Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out CoefficientOfThermalExpansion resul /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out CoefficientOfThermalExpansion result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static CoefficientOfThermalExpansionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out CoefficientOfThermalExpansionUni /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out CoefficientOfThermalExpansionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(CoefficientOfThermalExpansion other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) - return false; - - return Equals(objCoefficientOfThermalExpansion); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(CoefficientOfThermalExpansion other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another CoefficientOfThermalExpansion within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(CoefficientOfThermalExpansionUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(CoefficientOfThermalExpansionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return CoefficientOfThermalExpansion.QuantityType; else if(conversionType == typeof(QuantityInfo)) return CoefficientOfThermalExpansion.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 300d1689f8..c8d175aee9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Density /// [DataContract] - public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Density : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -117,7 +116,7 @@ static Density() new UnitInfo(DensityUnit.TonnePerCubicMeter, "TonnesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Tonne)), new UnitInfo(DensityUnit.TonnePerCubicMillimeter, "TonnesPerCubicMillimeter", new BaseUnits(length: LengthUnit.Millimeter, mass: MassUnit.Tonne)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Density); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -130,9 +129,6 @@ static Density() /// If value is NaN or Infinity. public Density(double value, DensityUnit unit) { - if(unit == DensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -176,24 +172,6 @@ public Density(double value, UnitSystem unitSystem) /// public static DensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Density - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Density MaxValue { get; } - - /// - /// Represents the smallest possible value of Density - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Density MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Density quantity. /// @@ -224,12 +202,6 @@ public Density(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Density; - /// /// The of this quantity. /// @@ -555,7 +527,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicInch, quantity => new Density(quantity.Value/6.10237440947323e7, DensityUnit.TonnePerCubicInch)); unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicMeter, quantity => new Density(quantity.Value*0.001, DensityUnit.TonnePerCubicMeter)); unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMeter, DensityUnit.TonnePerCubicMillimeter, quantity => new Density(quantity.Value*1e-12, DensityUnit.TonnePerCubicMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(DensityUnit.KilogramPerCubicMeter, DensityUnit.KilogramPerCubicMeter, quantity => quantity); @@ -627,7 +598,7 @@ public static string GetAbbreviation(DensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1161,7 +1132,7 @@ public static Density Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Density Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1192,7 +1163,7 @@ public static bool TryParse(string? str, out Density result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Density result) { return QuantityParser.Default.TryParse( @@ -1220,7 +1191,7 @@ public static DensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1246,7 +1217,7 @@ public static bool TryParseUnit(string str, out DensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out DensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1326,20 +1297,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Density left, Density right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Density left, Density right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1355,23 +1312,6 @@ public int CompareTo(Density other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Density objDensity)) - return false; - - return Equals(objDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Density other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Density within the given absolute or relative tolerance. @@ -1563,7 +1503,7 @@ private double GetValueAs(DensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1582,63 +1522,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1720,8 +1626,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(DensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Density.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Density.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 6dfce1e501..1694cc27c8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. /// [DataContract] - public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Duration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -74,7 +73,7 @@ static Duration() new UnitInfo(DurationUnit.Week, "Weeks", new BaseUnits(time: DurationUnit.Week)), new UnitInfo(DurationUnit.Year365, "Years365", new BaseUnits(time: DurationUnit.Year365)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Duration); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -87,9 +86,6 @@ static Duration() /// If value is NaN or Infinity. public Duration(double value, DurationUnit unit) { - if(unit == DurationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -133,24 +129,6 @@ public Duration(double value, UnitSystem unitSystem) /// public static DurationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Duration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Duration MaxValue { get; } - - /// - /// Represents the smallest possible value of Duration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Duration MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Duration quantity. /// @@ -181,12 +159,6 @@ public Duration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Duration; - /// /// The of this quantity. /// @@ -272,7 +244,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(DurationUnit.Second, DurationUnit.Nanosecond, quantity => new Duration((quantity.Value) / 1e-9d, DurationUnit.Nanosecond)); unitConverter.SetConversionFunction(DurationUnit.Second, DurationUnit.Week, quantity => new Duration(quantity.Value/(7*24*3600), DurationUnit.Week)); unitConverter.SetConversionFunction(DurationUnit.Second, DurationUnit.Year365, quantity => new Duration(quantity.Value/(365*24*3600), DurationUnit.Year365)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(DurationUnit.Second, DurationUnit.Second, quantity => quantity); @@ -304,7 +275,7 @@ public static string GetAbbreviation(DurationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -478,7 +449,7 @@ public static Duration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Duration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -509,7 +480,7 @@ public static bool TryParse(string? str, out Duration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Duration result) { return QuantityParser.Default.TryParse( @@ -537,7 +508,7 @@ public static DurationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -563,7 +534,7 @@ public static bool TryParseUnit(string str, out DurationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out DurationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -643,20 +614,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Duration left, Duration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Duration left, Duration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -672,23 +629,6 @@ public int CompareTo(Duration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Duration objDuration)) - return false; - - return Equals(objDuration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Duration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Duration within the given absolute or relative tolerance. @@ -880,7 +820,7 @@ private double GetValueAs(DurationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -899,63 +839,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1037,8 +943,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(DurationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Duration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Duration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 27281267bc..31ba433faf 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity /// [DataContract] - public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct DynamicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -76,7 +75,7 @@ static DynamicViscosity() new UnitInfo(DynamicViscosityUnit.PoundPerFootSecond, "PoundsPerFootSecond", BaseUnits.Undefined), new UnitInfo(DynamicViscosityUnit.Reyn, "Reyns", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.DynamicViscosity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -89,9 +88,6 @@ static DynamicViscosity() /// If value is NaN or Infinity. public DynamicViscosity(double value, DynamicViscosityUnit unit) { - if(unit == DynamicViscosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -135,24 +131,6 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// public static DynamicViscosityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of DynamicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static DynamicViscosity MaxValue { get; } - - /// - /// Represents the smallest possible value of DynamicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static DynamicViscosity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the DynamicViscosity quantity. /// @@ -183,12 +161,6 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.DynamicViscosity; - /// /// The of this quantity. /// @@ -268,7 +240,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundForceSecondPerSquareInch, quantity => new DynamicViscosity(quantity.Value / 6.8947572931683613e3, DynamicViscosityUnit.PoundForceSecondPerSquareInch)); unitConverter.SetConversionFunction(DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.PoundPerFootSecond, quantity => new DynamicViscosity(quantity.Value / 1.4881639, DynamicViscosityUnit.PoundPerFootSecond)); unitConverter.SetConversionFunction(DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.Reyn, quantity => new DynamicViscosity(quantity.Value / 6.8947572931683613e3, DynamicViscosityUnit.Reyn)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(DynamicViscosityUnit.NewtonSecondPerMeterSquared, DynamicViscosityUnit.NewtonSecondPerMeterSquared, quantity => quantity); @@ -299,7 +270,7 @@ public static string GetAbbreviation(DynamicViscosityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -464,7 +435,7 @@ public static DynamicViscosity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static DynamicViscosity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -495,7 +466,7 @@ public static bool TryParse(string? str, out DynamicViscosity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out DynamicViscosity result) { return QuantityParser.Default.TryParse( @@ -523,7 +494,7 @@ public static DynamicViscosityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -549,7 +520,7 @@ public static bool TryParseUnit(string str, out DynamicViscosityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out DynamicViscosityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -629,20 +600,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(DynamicViscosity left, DynamicViscosity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(DynamicViscosity left, DynamicViscosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -658,23 +615,6 @@ public int CompareTo(DynamicViscosity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is DynamicViscosity objDynamicViscosity)) - return false; - - return Equals(objDynamicViscosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(DynamicViscosity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another DynamicViscosity within the given absolute or relative tolerance. @@ -866,7 +806,7 @@ private double GetValueAs(DynamicViscosityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -885,63 +825,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1023,8 +929,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(DynamicViscosityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return DynamicViscosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return DynamicViscosity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 6dd2c96dc9..35043d2f42 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). /// [DataContract] - public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricAdmittance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static ElectricAdmittance() new UnitInfo(ElectricAdmittanceUnit.Nanosiemens, "Nanosiemens", BaseUnits.Undefined), new UnitInfo(ElectricAdmittanceUnit.Siemens, "Siemens", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricAdmittance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static ElectricAdmittance() /// If value is NaN or Infinity. public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) { - if(unit == ElectricAdmittanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// public static ElectricAdmittanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricAdmittance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricAdmittance MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricAdmittance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricAdmittance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricAdmittance quantity. /// @@ -174,12 +152,6 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricAdmittance; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Microsiemens, quantity => new ElectricAdmittance((quantity.Value) / 1e-6d, ElectricAdmittanceUnit.Microsiemens)); unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Millisiemens, quantity => new ElectricAdmittance((quantity.Value) / 1e-3d, ElectricAdmittanceUnit.Millisiemens)); unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Nanosiemens, quantity => new ElectricAdmittance((quantity.Value) / 1e-9d, ElectricAdmittanceUnit.Nanosiemens)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricAdmittanceUnit.Siemens, ElectricAdmittanceUnit.Siemens, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static ElectricAdmittance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricAdmittance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out ElectricAdmittance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricAdmittance result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static ElectricAdmittanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out ElectricAdmittanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricAdmittanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -524,20 +495,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -553,23 +510,6 @@ public int CompareTo(ElectricAdmittance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) - return false; - - return Equals(objElectricAdmittance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricAdmittance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricAdmittance within the given absolute or relative tolerance. @@ -761,7 +701,7 @@ private double GetValueAs(ElectricAdmittanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -780,63 +720,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -918,8 +824,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricAdmittanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricAdmittance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricAdmittance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index c45f4151e7..164a4426bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_charge /// [DataContract] - public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCharge : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -71,7 +70,7 @@ static ElectricCharge() new UnitInfo(ElectricChargeUnit.MegaampereHour, "MegaampereHours", BaseUnits.Undefined), new UnitInfo(ElectricChargeUnit.MilliampereHour, "MilliampereHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCharge); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -84,9 +83,6 @@ static ElectricCharge() /// If value is NaN or Infinity. public ElectricCharge(double value, ElectricChargeUnit unit) { - if(unit == ElectricChargeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -130,24 +126,6 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// public static ElectricChargeUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricCharge - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCharge MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricCharge - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCharge MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricCharge quantity. /// @@ -178,12 +156,6 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricCharge; - /// /// The of this quantity. /// @@ -233,7 +205,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.KiloampereHour, quantity => new ElectricCharge((quantity.Value*2.77777777777e-4) / 1e3d, ElectricChargeUnit.KiloampereHour)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.MegaampereHour, quantity => new ElectricCharge((quantity.Value*2.77777777777e-4) / 1e6d, ElectricChargeUnit.MegaampereHour)); unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.MilliampereHour, quantity => new ElectricCharge((quantity.Value*2.77777777777e-4) / 1e-3d, ElectricChargeUnit.MilliampereHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricChargeUnit.Coulomb, ElectricChargeUnit.Coulomb, quantity => quantity); @@ -259,7 +230,7 @@ public static string GetAbbreviation(ElectricChargeUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -379,7 +350,7 @@ public static ElectricCharge Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCharge Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -410,7 +381,7 @@ public static bool TryParse(string? str, out ElectricCharge result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCharge result) { return QuantityParser.Default.TryParse( @@ -438,7 +409,7 @@ public static ElectricChargeUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -464,7 +435,7 @@ public static bool TryParseUnit(string str, out ElectricChargeUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricChargeUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -544,20 +515,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCharge left, ElectricCharge right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCharge left, ElectricCharge right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -573,23 +530,6 @@ public int CompareTo(ElectricCharge other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCharge objElectricCharge)) - return false; - - return Equals(objElectricCharge); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCharge other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCharge within the given absolute or relative tolerance. @@ -781,7 +721,7 @@ private double GetValueAs(ElectricChargeUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -800,63 +740,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -938,8 +844,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricChargeUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCharge.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCharge.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 650ec31e1b..5159730292 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static ElectricChargeDensity() { new UnitInfo(ElectricChargeDensityUnit.CoulombPerCubicMeter, "CoulombsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricChargeDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static ElectricChargeDensity() /// If value is NaN or Infinity. public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) { - if(unit == ElectricChargeDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// public static ElectricChargeDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricChargeDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricChargeDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricChargeDensity quantity. /// @@ -174,12 +152,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricChargeDensity; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> ElectricChargeDensityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricChargeDensityUnit.CoulombPerCubicMeter, ElectricChargeDensityUnit.CoulombPerCubicMeter, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static ElectricChargeDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricChargeDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out ElectricChargeDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricChargeDensity result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static ElectricChargeDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out ElectricChargeDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricChargeDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(ElectricChargeDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) - return false; - - return Equals(objElectricChargeDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricChargeDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricChargeDensity within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(ElectricChargeDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricChargeDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricChargeDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricChargeDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 4b0eee43ad..d3ce17a00d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance /// [DataContract] - public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static ElectricConductance() new UnitInfo(ElectricConductanceUnit.Millisiemens, "Millisiemens", BaseUnits.Undefined), new UnitInfo(ElectricConductanceUnit.Siemens, "Siemens", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static ElectricConductance() /// If value is NaN or Infinity. public ElectricConductance(double value, ElectricConductanceUnit unit) { - if(unit == ElectricConductanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// public static ElectricConductanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricConductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductance MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricConductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricConductance quantity. /// @@ -176,12 +154,6 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricConductance; - /// /// The of this quantity. /// @@ -219,7 +191,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> ElectricConductanceUnit unitConverter.SetConversionFunction(ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Microsiemens, quantity => new ElectricConductance((quantity.Value) / 1e-6d, ElectricConductanceUnit.Microsiemens)); unitConverter.SetConversionFunction(ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Millisiemens, quantity => new ElectricConductance((quantity.Value) / 1e-3d, ElectricConductanceUnit.Millisiemens)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricConductanceUnit.Siemens, ElectricConductanceUnit.Siemens, quantity => quantity); @@ -243,7 +214,7 @@ public static string GetAbbreviation(ElectricConductanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -345,7 +316,7 @@ public static ElectricConductance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricConductance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -376,7 +347,7 @@ public static bool TryParse(string? str, out ElectricConductance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductance result) { return QuantityParser.Default.TryParse( @@ -404,7 +375,7 @@ public static ElectricConductanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -430,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricConductanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -510,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductance left, ElectricConductance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductance left, ElectricConductance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -539,23 +496,6 @@ public int CompareTo(ElectricConductance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricConductance objElectricConductance)) - return false; - - return Equals(objElectricConductance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricConductance within the given absolute or relative tolerance. @@ -747,7 +687,7 @@ private double GetValueAs(ElectricConductanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -766,63 +706,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -904,8 +810,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricConductanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricConductance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricConductance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index f1a0603574..f5cd771b98 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static ElectricConductivity() new UnitInfo(ElectricConductivityUnit.SiemensPerInch, "SiemensPerInch", BaseUnits.Undefined), new UnitInfo(ElectricConductivityUnit.SiemensPerMeter, "SiemensPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricConductivity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static ElectricConductivity() /// If value is NaN or Infinity. public ElectricConductivity(double value, ElectricConductivityUnit unit) { - if(unit == ElectricConductivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// public static ElectricConductivityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductivity MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricConductivity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricConductivity quantity. /// @@ -176,12 +154,6 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricConductivity; - /// /// The of this quantity. /// @@ -219,7 +191,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> ElectricConductivityUnit unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerFoot, quantity => new ElectricConductivity(quantity.Value / 3.2808398950131234, ElectricConductivityUnit.SiemensPerFoot)); unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerInch, quantity => new ElectricConductivity(quantity.Value / 3.937007874015748e1, ElectricConductivityUnit.SiemensPerInch)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricConductivityUnit.SiemensPerMeter, ElectricConductivityUnit.SiemensPerMeter, quantity => quantity); @@ -243,7 +214,7 @@ public static string GetAbbreviation(ElectricConductivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -345,7 +316,7 @@ public static ElectricConductivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricConductivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -376,7 +347,7 @@ public static bool TryParse(string? str, out ElectricConductivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricConductivity result) { return QuantityParser.Default.TryParse( @@ -404,7 +375,7 @@ public static ElectricConductivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -430,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricConductivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricConductivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -510,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductivity left, ElectricConductivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductivity left, ElectricConductivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -539,23 +496,6 @@ public int CompareTo(ElectricConductivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricConductivity objElectricConductivity)) - return false; - - return Equals(objElectricConductivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricConductivity within the given absolute or relative tolerance. @@ -747,7 +687,7 @@ private double GetValueAs(ElectricConductivityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -766,63 +706,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -904,8 +810,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricConductivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricConductivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricConductivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 9058c84dc8..e6cbe1735a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. /// [DataContract] - public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrent : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -71,7 +70,7 @@ static ElectricCurrent() new UnitInfo(ElectricCurrentUnit.Nanoampere, "Nanoamperes", BaseUnits.Undefined), new UnitInfo(ElectricCurrentUnit.Picoampere, "Picoamperes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrent); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -84,9 +83,6 @@ static ElectricCurrent() /// If value is NaN or Infinity. public ElectricCurrent(double value, ElectricCurrentUnit unit) { - if(unit == ElectricCurrentUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -130,24 +126,6 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// public static ElectricCurrentUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricCurrent - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrent MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricCurrent - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrent MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricCurrent quantity. /// @@ -178,12 +156,6 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricCurrent; - /// /// The of this quantity. /// @@ -251,7 +223,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Milliampere, quantity => new ElectricCurrent((quantity.Value) / 1e-3d, ElectricCurrentUnit.Milliampere)); unitConverter.SetConversionFunction(ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Nanoampere, quantity => new ElectricCurrent((quantity.Value) / 1e-9d, ElectricCurrentUnit.Nanoampere)); unitConverter.SetConversionFunction(ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Picoampere, quantity => new ElectricCurrent((quantity.Value) / 1e-12d, ElectricCurrentUnit.Picoampere)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricCurrentUnit.Ampere, ElectricCurrentUnit.Ampere, quantity => quantity); @@ -280,7 +251,7 @@ public static string GetAbbreviation(ElectricCurrentUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -427,7 +398,7 @@ public static ElectricCurrent Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCurrent Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -458,7 +429,7 @@ public static bool TryParse(string? str, out ElectricCurrent result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrent result) { return QuantityParser.Default.TryParse( @@ -486,7 +457,7 @@ public static ElectricCurrentUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -512,7 +483,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -592,20 +563,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrent left, ElectricCurrent right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrent left, ElectricCurrent right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -621,23 +578,6 @@ public int CompareTo(ElectricCurrent other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrent objElectricCurrent)) - return false; - - return Equals(objElectricCurrent); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrent other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCurrent within the given absolute or relative tolerance. @@ -829,7 +769,7 @@ private double GetValueAs(ElectricCurrentUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -848,63 +788,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -986,8 +892,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricCurrentUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCurrent.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCurrent.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index d56c032e32..72242763ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Current_density /// [DataContract] - public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static ElectricCurrentDensity() new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareInch, "AmperesPerSquareInch", new BaseUnits(length: LengthUnit.Inch, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricCurrentDensityUnit.AmperePerSquareMeter, "AmperesPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static ElectricCurrentDensity() /// If value is NaN or Infinity. public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) { - if(unit == ElectricCurrentDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// public static ElectricCurrentDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricCurrentDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricCurrentDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricCurrentDensity quantity. /// @@ -176,12 +154,6 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricCurrentDensity; - /// /// The of this quantity. /// @@ -219,7 +191,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> ElectricCurrentDensityUnit unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareFoot, quantity => new ElectricCurrentDensity(quantity.Value / 1.0763910416709722e1, ElectricCurrentDensityUnit.AmperePerSquareFoot)); unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareInch, quantity => new ElectricCurrentDensity(quantity.Value / 1.5500031000062000e3, ElectricCurrentDensityUnit.AmperePerSquareInch)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricCurrentDensityUnit.AmperePerSquareMeter, ElectricCurrentDensityUnit.AmperePerSquareMeter, quantity => quantity); @@ -243,7 +214,7 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -345,7 +316,7 @@ public static ElectricCurrentDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCurrentDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -376,7 +347,7 @@ public static bool TryParse(string? str, out ElectricCurrentDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentDensity result) { return QuantityParser.Default.TryParse( @@ -404,7 +375,7 @@ public static ElectricCurrentDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -430,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -510,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -539,23 +496,6 @@ public int CompareTo(ElectricCurrentDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) - return false; - - return Equals(objElectricCurrentDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCurrentDensity within the given absolute or relative tolerance. @@ -747,7 +687,7 @@ private double GetValueAs(ElectricCurrentDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -766,63 +706,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -904,8 +810,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricCurrentDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCurrentDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCurrentDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 5eb7088c3b..c48f5cd723 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In electromagnetism, the current gradient describes how the current changes in time. /// [DataContract] - public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static ElectricCurrentGradient() new UnitInfo(ElectricCurrentGradientUnit.AmperePerNanosecond, "AmperesPerNanosecond", new BaseUnits(time: DurationUnit.Nanosecond, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricCurrentGradientUnit.AmperePerSecond, "AmperesPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricCurrentGradient); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static ElectricCurrentGradient() /// If value is NaN or Infinity. public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) { - if(unit == ElectricCurrentGradientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// public static ElectricCurrentGradientUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricCurrentGradient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentGradient MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricCurrentGradient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricCurrentGradient MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricCurrentGradient quantity. /// @@ -174,12 +152,6 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricCurrentGradient; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMicrosecond, quantity => new ElectricCurrentGradient(quantity.Value/1E6, ElectricCurrentGradientUnit.AmperePerMicrosecond)); unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerMillisecond, quantity => new ElectricCurrentGradient(quantity.Value/1E3, ElectricCurrentGradientUnit.AmperePerMillisecond)); unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerNanosecond, quantity => new ElectricCurrentGradient(quantity.Value/1E9, ElectricCurrentGradientUnit.AmperePerNanosecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricCurrentGradientUnit.AmperePerSecond, ElectricCurrentGradientUnit.AmperePerSecond, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static ElectricCurrentGradient Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricCurrentGradient Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out ElectricCurrentGradient result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricCurrentGradient result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static ElectricCurrentGradientUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out ElectricCurrentGradientUnit unit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricCurrentGradientUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -524,20 +495,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -553,23 +510,6 @@ public int CompareTo(ElectricCurrentGradient other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) - return false; - - return Equals(objElectricCurrentGradient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentGradient other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricCurrentGradient within the given absolute or relative tolerance. @@ -761,7 +701,7 @@ private double GetValueAs(ElectricCurrentGradientUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -780,63 +720,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -918,8 +824,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricCurrentGradientUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricCurrentGradient.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricCurrentGradient.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 337e64f3a1..c2c22d1dfb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_field /// [DataContract] - public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricField : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static ElectricField() { new UnitInfo(ElectricFieldUnit.VoltPerMeter, "VoltsPerMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricField); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static ElectricField() /// If value is NaN or Infinity. public ElectricField(double value, ElectricFieldUnit unit) { - if(unit == ElectricFieldUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public ElectricField(double value, UnitSystem unitSystem) /// public static ElectricFieldUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricField MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricField MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricField quantity. /// @@ -174,12 +152,6 @@ public ElectricField(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricField; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public ElectricField(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> ElectricFieldUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricFieldUnit.VoltPerMeter, ElectricFieldUnit.VoltPerMeter, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(ElectricFieldUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static ElectricField Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricField Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out ElectricField result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricField result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static ElectricFieldUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out ElectricFieldUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricFieldUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricField left, ElectricField right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricField left, ElectricField right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(ElectricField other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricField objElectricField)) - return false; - - return Equals(objElectricField); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricField other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricField within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(ElectricFieldUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricFieldUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricField.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricField.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index dd3409f6c9..189c454274 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inductance /// [DataContract] - public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricInductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -70,7 +69,7 @@ static ElectricInductance() new UnitInfo(ElectricInductanceUnit.Millihenry, "Millihenries", BaseUnits.Undefined), new UnitInfo(ElectricInductanceUnit.Nanohenry, "Nanohenries", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricInductance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -83,9 +82,6 @@ static ElectricInductance() /// If value is NaN or Infinity. public ElectricInductance(double value, ElectricInductanceUnit unit) { - if(unit == ElectricInductanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,24 +125,6 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// public static ElectricInductanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricInductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricInductance MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricInductance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricInductance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricInductance quantity. /// @@ -177,12 +155,6 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricInductance; - /// /// The of this quantity. /// @@ -226,7 +198,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricInductanceUnit.Henry, ElectricInductanceUnit.Microhenry, quantity => new ElectricInductance((quantity.Value) / 1e-6d, ElectricInductanceUnit.Microhenry)); unitConverter.SetConversionFunction(ElectricInductanceUnit.Henry, ElectricInductanceUnit.Millihenry, quantity => new ElectricInductance((quantity.Value) / 1e-3d, ElectricInductanceUnit.Millihenry)); unitConverter.SetConversionFunction(ElectricInductanceUnit.Henry, ElectricInductanceUnit.Nanohenry, quantity => new ElectricInductance((quantity.Value) / 1e-9d, ElectricInductanceUnit.Nanohenry)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricInductanceUnit.Henry, ElectricInductanceUnit.Henry, quantity => quantity); @@ -251,7 +222,7 @@ public static string GetAbbreviation(ElectricInductanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -362,7 +333,7 @@ public static ElectricInductance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricInductance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -393,7 +364,7 @@ public static bool TryParse(string? str, out ElectricInductance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricInductance result) { return QuantityParser.Default.TryParse( @@ -421,7 +392,7 @@ public static ElectricInductanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -447,7 +418,7 @@ public static bool TryParseUnit(string str, out ElectricInductanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricInductanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -527,20 +498,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricInductance left, ElectricInductance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricInductance left, ElectricInductance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -556,23 +513,6 @@ public int CompareTo(ElectricInductance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricInductance objElectricInductance)) - return false; - - return Equals(objElectricInductance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricInductance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricInductance within the given absolute or relative tolerance. @@ -764,7 +704,7 @@ private double GetValueAs(ElectricInductanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -783,63 +723,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -921,8 +827,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricInductanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricInductance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricInductance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3d34221b08..2377d7b4fb 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. /// [DataContract] - public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotential : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -68,7 +67,7 @@ static ElectricPotential() new UnitInfo(ElectricPotentialUnit.Millivolt, "Millivolts", BaseUnits.Undefined), new UnitInfo(ElectricPotentialUnit.Volt, "Volts", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotential); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -81,9 +80,6 @@ static ElectricPotential() /// If value is NaN or Infinity. public ElectricPotential(double value, ElectricPotentialUnit unit) { - if(unit == ElectricPotentialUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -127,24 +123,6 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// public static ElectricPotentialUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricPotential - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotential MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricPotential - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotential MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricPotential quantity. /// @@ -175,12 +153,6 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricPotential; - /// /// The of this quantity. /// @@ -230,7 +202,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricPotentialUnit.Volt, ElectricPotentialUnit.Megavolt, quantity => new ElectricPotential((quantity.Value) / 1e6d, ElectricPotentialUnit.Megavolt)); unitConverter.SetConversionFunction(ElectricPotentialUnit.Volt, ElectricPotentialUnit.Microvolt, quantity => new ElectricPotential((quantity.Value) / 1e-6d, ElectricPotentialUnit.Microvolt)); unitConverter.SetConversionFunction(ElectricPotentialUnit.Volt, ElectricPotentialUnit.Millivolt, quantity => new ElectricPotential((quantity.Value) / 1e-3d, ElectricPotentialUnit.Millivolt)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricPotentialUnit.Volt, ElectricPotentialUnit.Volt, quantity => quantity); @@ -256,7 +227,7 @@ public static string GetAbbreviation(ElectricPotentialUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +347,7 @@ public static ElectricPotential Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotential Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +378,7 @@ public static bool TryParse(string? str, out ElectricPotential result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotential result) { return QuantityParser.Default.TryParse( @@ -435,7 +406,7 @@ public static ElectricPotentialUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +432,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -541,20 +512,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotential left, ElectricPotential right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotential left, ElectricPotential right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +527,6 @@ public int CompareTo(ElectricPotential other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotential objElectricPotential)) - return false; - - return Equals(objElectricPotential); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotential other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotential within the given absolute or relative tolerance. @@ -778,7 +718,7 @@ private double GetValueAs(ElectricPotentialUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -797,63 +737,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -935,8 +841,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotential.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotential.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index b9a1b51444..35ac727e30 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The Electric Potential of a system known to use Alternating Current. /// [DataContract] - public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialAc : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -68,7 +67,7 @@ static ElectricPotentialAc() new UnitInfo(ElectricPotentialAcUnit.MillivoltAc, "MillivoltsAc", BaseUnits.Undefined), new UnitInfo(ElectricPotentialAcUnit.VoltAc, "VoltsAc", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialAc); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -81,9 +80,6 @@ static ElectricPotentialAc() /// If value is NaN or Infinity. public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) { - if(unit == ElectricPotentialAcUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -127,24 +123,6 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// public static ElectricPotentialAcUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricPotentialAc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialAc MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricPotentialAc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialAc MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricPotentialAc quantity. /// @@ -175,12 +153,6 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricPotentialAc; - /// /// The of this quantity. /// @@ -230,7 +202,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MegavoltAc, quantity => new ElectricPotentialAc((quantity.Value) / 1e6d, ElectricPotentialAcUnit.MegavoltAc)); unitConverter.SetConversionFunction(ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MicrovoltAc, quantity => new ElectricPotentialAc((quantity.Value) / 1e-6d, ElectricPotentialAcUnit.MicrovoltAc)); unitConverter.SetConversionFunction(ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.MillivoltAc, quantity => new ElectricPotentialAc((quantity.Value) / 1e-3d, ElectricPotentialAcUnit.MillivoltAc)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricPotentialAcUnit.VoltAc, ElectricPotentialAcUnit.VoltAc, quantity => quantity); @@ -256,7 +227,7 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +347,7 @@ public static ElectricPotentialAc Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotentialAc Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +378,7 @@ public static bool TryParse(string? str, out ElectricPotentialAc result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialAc result) { return QuantityParser.Default.TryParse( @@ -435,7 +406,7 @@ public static ElectricPotentialAcUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +432,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialAcUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialAcUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -541,20 +512,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +527,6 @@ public int CompareTo(ElectricPotentialAc other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) - return false; - - return Equals(objElectricPotentialAc); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialAc other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotentialAc within the given absolute or relative tolerance. @@ -778,7 +718,7 @@ private double GetValueAs(ElectricPotentialAcUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -797,63 +737,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -935,8 +841,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialAcUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotentialAc.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotentialAc.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index ffdb9ee3ee..3066a4d90f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). /// [DataContract] - public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -83,7 +82,7 @@ static ElectricPotentialChangeRate() new UnitInfo(ElectricPotentialChangeRateUnit.VoltPerMinute, "VoltsPerMinutes", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Minute, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricPotentialChangeRateUnit.VoltPerSecond, "VoltsPerSeconds", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialChangeRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -96,9 +95,6 @@ static ElectricPotentialChangeRate() /// If value is NaN or Infinity. public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) { - if(unit == ElectricPotentialChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -142,24 +138,6 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// public static ElectricPotentialChangeRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricPotentialChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialChangeRate MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricPotentialChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialChangeRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricPotentialChangeRate quantity. /// @@ -190,12 +168,6 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricPotentialChangeRate; - /// /// The of this quantity. /// @@ -335,7 +307,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerHour, quantity => new ElectricPotentialChangeRate(quantity.Value*3600, ElectricPotentialChangeRateUnit.VoltPerHour)); unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerMicrosecond, quantity => new ElectricPotentialChangeRate(quantity.Value/1E6, ElectricPotentialChangeRateUnit.VoltPerMicrosecond)); unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerMinute, quantity => new ElectricPotentialChangeRate(quantity.Value*60, ElectricPotentialChangeRateUnit.VoltPerMinute)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricPotentialChangeRateUnit.VoltPerSecond, ElectricPotentialChangeRateUnit.VoltPerSecond, quantity => quantity); @@ -376,7 +347,7 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -631,7 +602,7 @@ public static ElectricPotentialChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotentialChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -662,7 +633,7 @@ public static bool TryParse(string? str, out ElectricPotentialChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialChangeRate result) { return QuantityParser.Default.TryParse( @@ -690,7 +661,7 @@ public static ElectricPotentialChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -716,7 +687,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialChangeRateUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -796,20 +767,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -825,23 +782,6 @@ public int CompareTo(ElectricPotentialChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) - return false; - - return Equals(objElectricPotentialChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotentialChangeRate within the given absolute or relative tolerance. @@ -1033,7 +973,7 @@ private double GetValueAs(ElectricPotentialChangeRateUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1052,63 +992,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1190,8 +1096,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotentialChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotentialChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 78f412670a..f91ea68422 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The Electric Potential of a system known to use Direct Current. /// [DataContract] - public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialDc : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -68,7 +67,7 @@ static ElectricPotentialDc() new UnitInfo(ElectricPotentialDcUnit.MillivoltDc, "MillivoltsDc", BaseUnits.Undefined), new UnitInfo(ElectricPotentialDcUnit.VoltDc, "VoltsDc", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricPotentialDc); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -81,9 +80,6 @@ static ElectricPotentialDc() /// If value is NaN or Infinity. public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) { - if(unit == ElectricPotentialDcUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -127,24 +123,6 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// public static ElectricPotentialDcUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricPotentialDc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialDc MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricPotentialDc - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricPotentialDc MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricPotentialDc quantity. /// @@ -175,12 +153,6 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricPotentialDc; - /// /// The of this quantity. /// @@ -230,7 +202,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MegavoltDc, quantity => new ElectricPotentialDc((quantity.Value) / 1e6d, ElectricPotentialDcUnit.MegavoltDc)); unitConverter.SetConversionFunction(ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MicrovoltDc, quantity => new ElectricPotentialDc((quantity.Value) / 1e-6d, ElectricPotentialDcUnit.MicrovoltDc)); unitConverter.SetConversionFunction(ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.MillivoltDc, quantity => new ElectricPotentialDc((quantity.Value) / 1e-3d, ElectricPotentialDcUnit.MillivoltDc)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricPotentialDcUnit.VoltDc, ElectricPotentialDcUnit.VoltDc, quantity => quantity); @@ -256,7 +227,7 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +347,7 @@ public static ElectricPotentialDc Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricPotentialDc Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +378,7 @@ public static bool TryParse(string? str, out ElectricPotentialDc result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricPotentialDc result) { return QuantityParser.Default.TryParse( @@ -435,7 +406,7 @@ public static ElectricPotentialDcUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +432,7 @@ public static bool TryParseUnit(string str, out ElectricPotentialDcUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricPotentialDcUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -541,20 +512,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +527,6 @@ public int CompareTo(ElectricPotentialDc other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) - return false; - - return Equals(objElectricPotentialDc); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialDc other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricPotentialDc within the given absolute or relative tolerance. @@ -778,7 +718,7 @@ private double GetValueAs(ElectricPotentialDcUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -797,63 +737,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -935,8 +841,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricPotentialDcUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricPotentialDc.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricPotentialDc.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 2e30530e76..849e068929 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. /// [DataContract] - public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static ElectricResistance() new UnitInfo(ElectricResistanceUnit.Milliohm, "Milliohms", BaseUnits.Undefined), new UnitInfo(ElectricResistanceUnit.Ohm, "Ohms", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static ElectricResistance() /// If value is NaN or Infinity. public ElectricResistance(double value, ElectricResistanceUnit unit) { - if(unit == ElectricResistanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// public static ElectricResistanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistance MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricResistance quantity. /// @@ -176,12 +154,6 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricResistance; - /// /// The of this quantity. /// @@ -237,7 +209,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Megaohm, quantity => new ElectricResistance((quantity.Value) / 1e6d, ElectricResistanceUnit.Megaohm)); unitConverter.SetConversionFunction(ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Microohm, quantity => new ElectricResistance((quantity.Value) / 1e-6d, ElectricResistanceUnit.Microohm)); unitConverter.SetConversionFunction(ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Milliohm, quantity => new ElectricResistance((quantity.Value) / 1e-3d, ElectricResistanceUnit.Milliohm)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricResistanceUnit.Ohm, ElectricResistanceUnit.Ohm, quantity => quantity); @@ -264,7 +235,7 @@ public static string GetAbbreviation(ElectricResistanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -393,7 +364,7 @@ public static ElectricResistance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricResistance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -424,7 +395,7 @@ public static bool TryParse(string? str, out ElectricResistance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistance result) { return QuantityParser.Default.TryParse( @@ -452,7 +423,7 @@ public static ElectricResistanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -478,7 +449,7 @@ public static bool TryParseUnit(string str, out ElectricResistanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricResistanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -558,20 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistance left, ElectricResistance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistance left, ElectricResistance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -587,23 +544,6 @@ public int CompareTo(ElectricResistance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricResistance objElectricResistance)) - return false; - - return Equals(objElectricResistance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricResistance within the given absolute or relative tolerance. @@ -795,7 +735,7 @@ private double GetValueAs(ElectricResistanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -814,63 +754,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -952,8 +858,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricResistanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricResistance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricResistance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index a627507c7d..fadba2fb33 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -80,7 +79,7 @@ static ElectricResistivity() new UnitInfo(ElectricResistivityUnit.PicoohmCentimeter, "PicoohmsCentimeter", BaseUnits.Undefined), new UnitInfo(ElectricResistivityUnit.PicoohmMeter, "PicoohmMeters", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricResistivity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -93,9 +92,6 @@ static ElectricResistivity() /// If value is NaN or Infinity. public ElectricResistivity(double value, ElectricResistivityUnit unit) { - if(unit == ElectricResistivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,24 +135,6 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// public static ElectricResistivityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricResistivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistivity MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricResistivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricResistivity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricResistivity quantity. /// @@ -187,12 +165,6 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricResistivity; - /// /// The of this quantity. /// @@ -296,7 +268,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.OhmCentimeter, quantity => new ElectricResistivity(quantity.Value*100, ElectricResistivityUnit.OhmCentimeter)); unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.PicoohmCentimeter, quantity => new ElectricResistivity((quantity.Value*100) / 1e-12d, ElectricResistivityUnit.PicoohmCentimeter)); unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.PicoohmMeter, quantity => new ElectricResistivity((quantity.Value) / 1e-12d, ElectricResistivityUnit.PicoohmMeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricResistivityUnit.OhmMeter, ElectricResistivityUnit.OhmMeter, quantity => quantity); @@ -331,7 +302,7 @@ public static string GetAbbreviation(ElectricResistivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -532,7 +503,7 @@ public static ElectricResistivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricResistivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -563,7 +534,7 @@ public static bool TryParse(string? str, out ElectricResistivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricResistivity result) { return QuantityParser.Default.TryParse( @@ -591,7 +562,7 @@ public static ElectricResistivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -617,7 +588,7 @@ public static bool TryParseUnit(string str, out ElectricResistivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricResistivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -697,20 +668,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistivity left, ElectricResistivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistivity left, ElectricResistivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -726,23 +683,6 @@ public int CompareTo(ElectricResistivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricResistivity objElectricResistivity)) - return false; - - return Equals(objElectricResistivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricResistivity within the given absolute or relative tolerance. @@ -934,7 +874,7 @@ private double GetValueAs(ElectricResistivityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -953,63 +893,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1091,8 +997,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricResistivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricResistivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricResistivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 8c11c9f3fa..f46c896115 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricSurfaceChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static ElectricSurfaceChargeDensity() new UnitInfo(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, "CoulombsPerSquareInch", new BaseUnits(length: LengthUnit.Inch, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), new UnitInfo(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, "CoulombsPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ElectricSurfaceChargeDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static ElectricSurfaceChargeDensity() /// If value is NaN or Infinity. public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) { - if(unit == ElectricSurfaceChargeDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// public static ElectricSurfaceChargeDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ElectricSurfaceChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricSurfaceChargeDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of ElectricSurfaceChargeDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ElectricSurfaceChargeDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ElectricSurfaceChargeDensity quantity. /// @@ -176,12 +154,6 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ElectricSurfaceChargeDensity; - /// /// The of this quantity. /// @@ -219,7 +191,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> ElectricSurfaceChargeDensityUnit unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter, quantity => new ElectricSurfaceChargeDensity(quantity.Value / 1.0e4, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter)); unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch, quantity => new ElectricSurfaceChargeDensity(quantity.Value / 1.5500031000062000e3, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter, quantity => quantity); @@ -243,7 +214,7 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -345,7 +316,7 @@ public static ElectricSurfaceChargeDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ElectricSurfaceChargeDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -376,7 +347,7 @@ public static bool TryParse(string? str, out ElectricSurfaceChargeDensity result /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ElectricSurfaceChargeDensity result) { return QuantityParser.Default.TryParse( @@ -404,7 +375,7 @@ public static ElectricSurfaceChargeDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -430,7 +401,7 @@ public static bool TryParseUnit(string str, out ElectricSurfaceChargeDensityUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ElectricSurfaceChargeDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -510,20 +481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -539,23 +496,6 @@ public int CompareTo(ElectricSurfaceChargeDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) - return false; - - return Equals(objElectricSurfaceChargeDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricSurfaceChargeDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ElectricSurfaceChargeDensity within the given absolute or relative tolerance. @@ -747,7 +687,7 @@ private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -766,63 +706,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -904,8 +810,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ElectricSurfaceChargeDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ElectricSurfaceChargeDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ElectricSurfaceChargeDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 55ce400bf1..77c78e47fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. /// [DataContract] - public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Energy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -99,7 +98,7 @@ static Energy() new UnitInfo(EnergyUnit.WattDay, "WattDays", BaseUnits.Undefined), new UnitInfo(EnergyUnit.WattHour, "WattHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Energy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -112,9 +111,6 @@ static Energy() /// If value is NaN or Infinity. public Energy(double value, EnergyUnit unit) { - if(unit == EnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -158,24 +154,6 @@ public Energy(double value, UnitSystem unitSystem) /// public static EnergyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Energy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Energy MaxValue { get; } - - /// - /// Represents the smallest possible value of Energy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Energy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Energy quantity. /// @@ -206,12 +184,6 @@ public Energy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Energy; - /// /// The of this quantity. /// @@ -447,7 +419,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(EnergyUnit.Joule, EnergyUnit.ThermUs, quantity => new Energy(quantity.Value/1.054804e8, EnergyUnit.ThermUs)); unitConverter.SetConversionFunction(EnergyUnit.Joule, EnergyUnit.WattDay, quantity => new Energy(quantity.Value/(24*3600d), EnergyUnit.WattDay)); unitConverter.SetConversionFunction(EnergyUnit.Joule, EnergyUnit.WattHour, quantity => new Energy(quantity.Value/3600d, EnergyUnit.WattHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(EnergyUnit.Joule, EnergyUnit.Joule, quantity => quantity); @@ -504,7 +475,7 @@ public static string GetAbbreviation(EnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -903,7 +874,7 @@ public static Energy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Energy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -934,7 +905,7 @@ public static bool TryParse(string? str, out Energy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Energy result) { return QuantityParser.Default.TryParse( @@ -962,7 +933,7 @@ public static EnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -988,7 +959,7 @@ public static bool TryParseUnit(string str, out EnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out EnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1068,20 +1039,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Energy left, Energy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Energy left, Energy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1097,23 +1054,6 @@ public int CompareTo(Energy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Energy objEnergy)) - return false; - - return Equals(objEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Energy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Energy within the given absolute or relative tolerance. @@ -1305,7 +1245,7 @@ private double GetValueAs(EnergyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1324,63 +1264,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1462,8 +1368,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(EnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Energy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Energy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 342c252f07..d454624d1d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units /// [DataContract] - public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Entropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -70,7 +69,7 @@ static Entropy() new UnitInfo(EntropyUnit.KilojoulePerKelvin, "KilojoulesPerKelvin", BaseUnits.Undefined), new UnitInfo(EntropyUnit.MegajoulePerKelvin, "MegajoulesPerKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Entropy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -83,9 +82,6 @@ static Entropy() /// If value is NaN or Infinity. public Entropy(double value, EntropyUnit unit) { - if(unit == EntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,24 +125,6 @@ public Entropy(double value, UnitSystem unitSystem) /// public static EntropyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Entropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Entropy MaxValue { get; } - - /// - /// Represents the smallest possible value of Entropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Entropy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Entropy quantity. /// @@ -177,12 +155,6 @@ public Entropy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Entropy; - /// /// The of this quantity. /// @@ -244,7 +216,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(EntropyUnit.JoulePerKelvin, EntropyUnit.KilojoulePerDegreeCelsius, quantity => new Entropy((quantity.Value) / 1e3d, EntropyUnit.KilojoulePerDegreeCelsius)); unitConverter.SetConversionFunction(EntropyUnit.JoulePerKelvin, EntropyUnit.KilojoulePerKelvin, quantity => new Entropy((quantity.Value) / 1e3d, EntropyUnit.KilojoulePerKelvin)); unitConverter.SetConversionFunction(EntropyUnit.JoulePerKelvin, EntropyUnit.MegajoulePerKelvin, quantity => new Entropy((quantity.Value) / 1e6d, EntropyUnit.MegajoulePerKelvin)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(EntropyUnit.JoulePerKelvin, EntropyUnit.JoulePerKelvin, quantity => quantity); @@ -272,7 +243,7 @@ public static string GetAbbreviation(EntropyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -410,7 +381,7 @@ public static Entropy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Entropy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -441,7 +412,7 @@ public static bool TryParse(string? str, out Entropy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Entropy result) { return QuantityParser.Default.TryParse( @@ -469,7 +440,7 @@ public static EntropyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -495,7 +466,7 @@ public static bool TryParseUnit(string str, out EntropyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out EntropyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -575,20 +546,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Entropy left, Entropy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Entropy left, Entropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -604,23 +561,6 @@ public int CompareTo(Entropy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Entropy objEntropy)) - return false; - - return Equals(objEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Entropy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Entropy within the given absolute or relative tolerance. @@ -812,7 +752,7 @@ private double GetValueAs(EntropyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -831,63 +771,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -969,8 +875,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(EntropyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Entropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Entropy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index fe0fe1efd7..d887b03194 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. /// [DataContract] - public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Force : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -78,7 +77,7 @@ static Force() new UnitInfo(ForceUnit.ShortTonForce, "ShortTonsForce", BaseUnits.Undefined), new UnitInfo(ForceUnit.TonneForce, "TonnesForce", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Force); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -91,9 +90,6 @@ static Force() /// If value is NaN or Infinity. public Force(double value, ForceUnit unit) { - if(unit == ForceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -137,24 +133,6 @@ public Force(double value, UnitSystem unitSystem) /// public static ForceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Force - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Force MaxValue { get; } - - /// - /// Represents the smallest possible value of Force - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Force MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Force quantity. /// @@ -185,12 +163,6 @@ public Force(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Force; - /// /// The of this quantity. /// @@ -300,7 +272,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ForceUnit.Newton, ForceUnit.PoundForce, quantity => new Force(quantity.Value/4.4482216152605095551842641431421, ForceUnit.PoundForce)); unitConverter.SetConversionFunction(ForceUnit.Newton, ForceUnit.ShortTonForce, quantity => new Force(quantity.Value/8.896443230521e3, ForceUnit.ShortTonForce)); unitConverter.SetConversionFunction(ForceUnit.Newton, ForceUnit.TonneForce, quantity => new Force(quantity.Value/9.80665002864e3, ForceUnit.TonneForce)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ForceUnit.Newton, ForceUnit.Newton, quantity => quantity); @@ -336,7 +307,7 @@ public static string GetAbbreviation(ForceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -546,7 +517,7 @@ public static Force Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Force Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -577,7 +548,7 @@ public static bool TryParse(string? str, out Force result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Force result) { return QuantityParser.Default.TryParse( @@ -605,7 +576,7 @@ public static ForceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -631,7 +602,7 @@ public static bool TryParseUnit(string str, out ForceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ForceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -711,20 +682,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Force left, Force right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Force left, Force right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -740,23 +697,6 @@ public int CompareTo(Force other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Force objForce)) - return false; - - return Equals(objForce); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Force other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Force within the given absolute or relative tolerance. @@ -948,7 +888,7 @@ private double GetValueAs(ForceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -967,63 +907,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1105,8 +1011,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ForceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Force.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Force.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 31a79483b1..c7c0452c9f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). /// [DataContract] - public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForceChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -78,7 +77,7 @@ static ForceChangeRate() new UnitInfo(ForceChangeRateUnit.PoundForcePerMinute, "PoundsForcePerMinute", BaseUnits.Undefined), new UnitInfo(ForceChangeRateUnit.PoundForcePerSecond, "PoundsForcePerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ForceChangeRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -91,9 +90,6 @@ static ForceChangeRate() /// If value is NaN or Infinity. public ForceChangeRate(double value, ForceChangeRateUnit unit) { - if(unit == ForceChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -137,24 +133,6 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// public static ForceChangeRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ForceChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForceChangeRate MaxValue { get; } - - /// - /// Represents the smallest possible value of ForceChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForceChangeRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ForceChangeRate quantity. /// @@ -185,12 +163,6 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ForceChangeRate; - /// /// The of this quantity. /// @@ -300,7 +272,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.NewtonPerMinute, quantity => new ForceChangeRate(quantity.Value*60, ForceChangeRateUnit.NewtonPerMinute)); unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.PoundForcePerMinute, quantity => new ForceChangeRate(quantity.Value/4.4482216152605095551842641431421*60, ForceChangeRateUnit.PoundForcePerMinute)); unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.PoundForcePerSecond, quantity => new ForceChangeRate(quantity.Value/4.4482216152605095551842641431421, ForceChangeRateUnit.PoundForcePerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ForceChangeRateUnit.NewtonPerSecond, ForceChangeRateUnit.NewtonPerSecond, quantity => quantity); @@ -336,7 +307,7 @@ public static string GetAbbreviation(ForceChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -546,7 +517,7 @@ public static ForceChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ForceChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -577,7 +548,7 @@ public static bool TryParse(string? str, out ForceChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ForceChangeRate result) { return QuantityParser.Default.TryParse( @@ -605,7 +576,7 @@ public static ForceChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -631,7 +602,7 @@ public static bool TryParseUnit(string str, out ForceChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ForceChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -711,20 +682,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForceChangeRate left, ForceChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForceChangeRate left, ForceChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -740,23 +697,6 @@ public int CompareTo(ForceChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ForceChangeRate objForceChangeRate)) - return false; - - return Equals(objForceChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForceChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ForceChangeRate within the given absolute or relative tolerance. @@ -948,7 +888,7 @@ private double GetValueAs(ForceChangeRateUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -967,63 +907,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1105,8 +1011,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ForceChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ForceChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ForceChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index d20ba0ec47..3dc594a43c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The magnitude of force per unit length. /// [DataContract] - public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForcePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -101,7 +100,7 @@ static ForcePerLength() new UnitInfo(ForcePerLengthUnit.TonneForcePerMeter, "TonnesForcePerMeter", BaseUnits.Undefined), new UnitInfo(ForcePerLengthUnit.TonneForcePerMillimeter, "TonnesForcePerMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ForcePerLength); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -114,9 +113,6 @@ static ForcePerLength() /// If value is NaN or Infinity. public ForcePerLength(double value, ForcePerLengthUnit unit) { - if(unit == ForcePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -160,24 +156,6 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// public static ForcePerLengthUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ForcePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForcePerLength MaxValue { get; } - - /// - /// Represents the smallest possible value of ForcePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ForcePerLength MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ForcePerLength quantity. /// @@ -208,12 +186,6 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ForcePerLength; - /// /// The of this quantity. /// @@ -461,7 +433,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerCentimeter, quantity => new ForcePerLength(quantity.Value/9.80665002864e5, ForcePerLengthUnit.TonneForcePerCentimeter)); unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerMeter, quantity => new ForcePerLength(quantity.Value/9.80665002864e3, ForcePerLengthUnit.TonneForcePerMeter)); unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.TonneForcePerMillimeter, quantity => new ForcePerLength(quantity.Value/9.80665002864e6, ForcePerLengthUnit.TonneForcePerMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ForcePerLengthUnit.NewtonPerMeter, ForcePerLengthUnit.NewtonPerMeter, quantity => quantity); @@ -520,7 +491,7 @@ public static string GetAbbreviation(ForcePerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -937,7 +908,7 @@ public static ForcePerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ForcePerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -968,7 +939,7 @@ public static bool TryParse(string? str, out ForcePerLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ForcePerLength result) { return QuantityParser.Default.TryParse( @@ -996,7 +967,7 @@ public static ForcePerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1022,7 +993,7 @@ public static bool TryParseUnit(string str, out ForcePerLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ForcePerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1102,20 +1073,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForcePerLength left, ForcePerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForcePerLength left, ForcePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1131,23 +1088,6 @@ public int CompareTo(ForcePerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ForcePerLength objForcePerLength)) - return false; - - return Equals(objForcePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForcePerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ForcePerLength within the given absolute or relative tolerance. @@ -1339,7 +1279,7 @@ private double GetValueAs(ForcePerLengthUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1358,63 +1298,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1496,8 +1402,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ForcePerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ForcePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ForcePerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 43abae81b3..b4a9b7cc44 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The number of occurrences of a repeating event per unit time. /// [DataContract] - public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Frequency : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -74,7 +73,7 @@ static Frequency() new UnitInfo(FrequencyUnit.RadianPerSecond, "RadiansPerSecond", BaseUnits.Undefined), new UnitInfo(FrequencyUnit.Terahertz, "Terahertz", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Frequency); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -87,9 +86,6 @@ static Frequency() /// If value is NaN or Infinity. public Frequency(double value, FrequencyUnit unit) { - if(unit == FrequencyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -133,24 +129,6 @@ public Frequency(double value, UnitSystem unitSystem) /// public static FrequencyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Frequency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Frequency MaxValue { get; } - - /// - /// Represents the smallest possible value of Frequency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Frequency MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Frequency quantity. /// @@ -181,12 +159,6 @@ public Frequency(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Frequency; - /// /// The of this quantity. /// @@ -272,7 +244,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(FrequencyUnit.Hertz, FrequencyUnit.PerSecond, quantity => new Frequency(quantity.Value, FrequencyUnit.PerSecond)); unitConverter.SetConversionFunction(FrequencyUnit.Hertz, FrequencyUnit.RadianPerSecond, quantity => new Frequency(quantity.Value*6.2831853072, FrequencyUnit.RadianPerSecond)); unitConverter.SetConversionFunction(FrequencyUnit.Hertz, FrequencyUnit.Terahertz, quantity => new Frequency((quantity.Value) / 1e12d, FrequencyUnit.Terahertz)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(FrequencyUnit.Hertz, FrequencyUnit.Hertz, quantity => quantity); @@ -304,7 +275,7 @@ public static string GetAbbreviation(FrequencyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -478,7 +449,7 @@ public static Frequency Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Frequency Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -509,7 +480,7 @@ public static bool TryParse(string? str, out Frequency result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Frequency result) { return QuantityParser.Default.TryParse( @@ -537,7 +508,7 @@ public static FrequencyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -563,7 +534,7 @@ public static bool TryParseUnit(string str, out FrequencyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out FrequencyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -643,20 +614,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Frequency left, Frequency right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Frequency left, Frequency right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -672,23 +629,6 @@ public int CompareTo(Frequency other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Frequency objFrequency)) - return false; - - return Equals(objFrequency); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Frequency other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Frequency within the given absolute or relative tolerance. @@ -880,7 +820,7 @@ private double GetValueAs(FrequencyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -899,63 +839,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1037,8 +943,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(FrequencyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Frequency.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Frequency.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index f8a889effe..8f12d766b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Fuel_efficiency /// [DataContract] - public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct FuelEfficiency : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -70,7 +69,7 @@ static FuelEfficiency() new UnitInfo(FuelEfficiencyUnit.MilePerUkGallon, "MilesPerUkGallon", BaseUnits.Undefined), new UnitInfo(FuelEfficiencyUnit.MilePerUsGallon, "MilesPerUsGallon", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.FuelEfficiency); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -83,9 +82,6 @@ static FuelEfficiency() /// If value is NaN or Infinity. public FuelEfficiency(double value, FuelEfficiencyUnit unit) { - if(unit == FuelEfficiencyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,24 +125,6 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// public static FuelEfficiencyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of FuelEfficiency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static FuelEfficiency MaxValue { get; } - - /// - /// Represents the smallest possible value of FuelEfficiency - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static FuelEfficiency MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the FuelEfficiency quantity. /// @@ -177,12 +155,6 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.FuelEfficiency; - /// /// The of this quantity. /// @@ -226,7 +198,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.KilometerPerLiter, quantity => new FuelEfficiency(100/quantity.Value, FuelEfficiencyUnit.KilometerPerLiter)); unitConverter.SetConversionFunction(FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.MilePerUkGallon, quantity => new FuelEfficiency((100*4.54609188)/(1.609344*quantity.Value), FuelEfficiencyUnit.MilePerUkGallon)); unitConverter.SetConversionFunction(FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.MilePerUsGallon, quantity => new FuelEfficiency((100*3.785411784)/(1.609344*quantity.Value), FuelEfficiencyUnit.MilePerUsGallon)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(FuelEfficiencyUnit.LiterPer100Kilometers, FuelEfficiencyUnit.LiterPer100Kilometers, quantity => quantity); @@ -251,7 +222,7 @@ public static string GetAbbreviation(FuelEfficiencyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(FuelEfficiencyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -362,7 +333,7 @@ public static FuelEfficiency Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static FuelEfficiency Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -393,7 +364,7 @@ public static bool TryParse(string? str, out FuelEfficiency result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out FuelEfficiency result) { return QuantityParser.Default.TryParse( @@ -421,7 +392,7 @@ public static FuelEfficiencyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -447,7 +418,7 @@ public static bool TryParseUnit(string str, out FuelEfficiencyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelEfficiencyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -527,20 +498,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(FuelEfficiency left, FuelEfficiency right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(FuelEfficiency left, FuelEfficiency right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -556,23 +513,6 @@ public int CompareTo(FuelEfficiency other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is FuelEfficiency objFuelEfficiency)) - return false; - - return Equals(objFuelEfficiency); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(FuelEfficiency other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another FuelEfficiency within the given absolute or relative tolerance. @@ -764,7 +704,7 @@ private double GetValueAs(FuelEfficiencyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -783,63 +723,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -921,8 +827,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(FuelEfficiencyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return FuelEfficiency.QuantityType; else if(conversionType == typeof(QuantityInfo)) return FuelEfficiency.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index b9c909cf55..4b5fc81aff 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Heat flux is the flow of energy per unit of area per unit of time /// [DataContract] - public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -81,7 +80,7 @@ static HeatFlux() new UnitInfo(HeatFluxUnit.WattPerSquareInch, "WattsPerSquareInch", BaseUnits.Undefined), new UnitInfo(HeatFluxUnit.WattPerSquareMeter, "WattsPerSquareMeter", new BaseUnits(mass: MassUnit.Kilogram, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.HeatFlux); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -94,9 +93,6 @@ static HeatFlux() /// If value is NaN or Infinity. public HeatFlux(double value, HeatFluxUnit unit) { - if(unit == HeatFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -140,24 +136,6 @@ public HeatFlux(double value, UnitSystem unitSystem) /// public static HeatFluxUnit BaseUnit { get; } - /// - /// Represents the largest possible value of HeatFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatFlux MaxValue { get; } - - /// - /// Represents the smallest possible value of HeatFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatFlux MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the HeatFlux quantity. /// @@ -188,12 +166,6 @@ public HeatFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.HeatFlux; - /// /// The of this quantity. /// @@ -321,7 +293,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.PoundPerSecondCubed, quantity => new HeatFlux(quantity.Value/4.5359237e-1, HeatFluxUnit.PoundPerSecondCubed)); unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareFoot, quantity => new HeatFlux(quantity.Value/1.07639e1, HeatFluxUnit.WattPerSquareFoot)); unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareInch, quantity => new HeatFlux(quantity.Value/1.5500031e3, HeatFluxUnit.WattPerSquareInch)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(HeatFluxUnit.WattPerSquareMeter, HeatFluxUnit.WattPerSquareMeter, quantity => quantity); @@ -360,7 +331,7 @@ public static string GetAbbreviation(HeatFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(HeatFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -597,7 +568,7 @@ public static HeatFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static HeatFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -628,7 +599,7 @@ public static bool TryParse(string? str, out HeatFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out HeatFlux result) { return QuantityParser.Default.TryParse( @@ -656,7 +627,7 @@ public static HeatFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -682,7 +653,7 @@ public static bool TryParseUnit(string str, out HeatFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -762,20 +733,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatFlux left, HeatFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatFlux left, HeatFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -791,23 +748,6 @@ public int CompareTo(HeatFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is HeatFlux objHeatFlux)) - return false; - - return Equals(objHeatFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another HeatFlux within the given absolute or relative tolerance. @@ -999,7 +939,7 @@ private double GetValueAs(HeatFluxUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1018,63 +958,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1156,8 +1062,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(HeatFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return HeatFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return HeatFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index d68bbf0e57..b727cebe2d 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) /// [DataContract] - public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatTransferCoefficient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static HeatTransferCoefficient() new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, "WattsPerSquareMeterCelsius", BaseUnits.Undefined), new UnitInfo(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, "WattsPerSquareMeterKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.HeatTransferCoefficient); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static HeatTransferCoefficient() /// If value is NaN or Infinity. public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) { - if(unit == HeatTransferCoefficientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// public static HeatTransferCoefficientUnit BaseUnit { get; } - /// - /// Represents the largest possible value of HeatTransferCoefficient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatTransferCoefficient MaxValue { get; } - - /// - /// Represents the smallest possible value of HeatTransferCoefficient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static HeatTransferCoefficient MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the HeatTransferCoefficient quantity. /// @@ -173,12 +151,6 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.HeatTransferCoefficient; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> HeatTransferCoefficientUnit unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit, quantity => new HeatTransferCoefficient(quantity.Value / 5.6782633411134878, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit)); unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius, quantity => new HeatTransferCoefficient(quantity.Value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(HeatTransferCoefficientUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(HeatTransferCoefficientUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static HeatTransferCoefficient Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static HeatTransferCoefficient Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out HeatTransferCoefficient result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out HeatTransferCoefficient result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static HeatTransferCoefficientUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out HeatTransferCoefficientUnit unit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatTransferCoefficientUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(HeatTransferCoefficient other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) - return false; - - return Equals(objHeatTransferCoefficient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatTransferCoefficient other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another HeatTransferCoefficient within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(HeatTransferCoefficientUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(HeatTransferCoefficientUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return HeatTransferCoefficient.QuantityType; else if(conversionType == typeof(QuantityInfo)) return HeatTransferCoefficient.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index c8cad2b403..85976ffc02 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Illuminance /// [DataContract] - public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Illuminance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -70,7 +69,7 @@ static Illuminance() new UnitInfo(IlluminanceUnit.Megalux, "Megalux", BaseUnits.Undefined), new UnitInfo(IlluminanceUnit.Millilux, "Millilux", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Illuminance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -83,9 +82,6 @@ static Illuminance() /// If value is NaN or Infinity. public Illuminance(double value, IlluminanceUnit unit) { - if(unit == IlluminanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,24 +125,6 @@ public Illuminance(double value, UnitSystem unitSystem) /// public static IlluminanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Illuminance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Illuminance MaxValue { get; } - - /// - /// Represents the smallest possible value of Illuminance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Illuminance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Illuminance quantity. /// @@ -177,12 +155,6 @@ public Illuminance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Illuminance; - /// /// The of this quantity. /// @@ -226,7 +198,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(IlluminanceUnit.Lux, IlluminanceUnit.Kilolux, quantity => new Illuminance((quantity.Value) / 1e3d, IlluminanceUnit.Kilolux)); unitConverter.SetConversionFunction(IlluminanceUnit.Lux, IlluminanceUnit.Megalux, quantity => new Illuminance((quantity.Value) / 1e6d, IlluminanceUnit.Megalux)); unitConverter.SetConversionFunction(IlluminanceUnit.Lux, IlluminanceUnit.Millilux, quantity => new Illuminance((quantity.Value) / 1e-3d, IlluminanceUnit.Millilux)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(IlluminanceUnit.Lux, IlluminanceUnit.Lux, quantity => quantity); @@ -251,7 +222,7 @@ public static string GetAbbreviation(IlluminanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(IlluminanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -362,7 +333,7 @@ public static Illuminance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Illuminance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -393,7 +364,7 @@ public static bool TryParse(string? str, out Illuminance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Illuminance result) { return QuantityParser.Default.TryParse( @@ -421,7 +392,7 @@ public static IlluminanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -447,7 +418,7 @@ public static bool TryParseUnit(string str, out IlluminanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out IlluminanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -527,20 +498,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Illuminance left, Illuminance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Illuminance left, Illuminance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -556,23 +513,6 @@ public int CompareTo(Illuminance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Illuminance objIlluminance)) - return false; - - return Equals(objIlluminance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Illuminance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Illuminance within the given absolute or relative tolerance. @@ -764,7 +704,7 @@ private double GetValueAs(IlluminanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -783,63 +723,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -921,8 +827,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(IlluminanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Illuminance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Illuminance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index be8ff4f661..75aae4fde5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. /// [DataContract] - public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Information : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -89,7 +88,7 @@ static Information() new UnitInfo(InformationUnit.Terabit, "Terabits", BaseUnits.Undefined), new UnitInfo(InformationUnit.Terabyte, "Terabytes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Information); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -102,9 +101,6 @@ static Information() /// If value is NaN or Infinity. public Information(decimal value, InformationUnit unit) { - if(unit == InformationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; _unit = unit; } @@ -148,24 +144,6 @@ public Information(decimal value, UnitSystem unitSystem) /// public static InformationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Information - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Information MaxValue { get; } - - /// - /// Represents the smallest possible value of Information - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Information MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Information quantity. /// @@ -201,12 +179,6 @@ public Information(decimal value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Information; - /// /// The of this quantity. /// @@ -382,7 +354,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(InformationUnit.Bit, InformationUnit.Tebibyte, quantity => new Information((quantity.Value/8m) / (1024m * 1024 * 1024 * 1024), InformationUnit.Tebibyte)); unitConverter.SetConversionFunction(InformationUnit.Bit, InformationUnit.Terabit, quantity => new Information((quantity.Value) / 1e12m, InformationUnit.Terabit)); unitConverter.SetConversionFunction(InformationUnit.Bit, InformationUnit.Terabyte, quantity => new Information((quantity.Value/8m) / 1e12m, InformationUnit.Terabyte)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(InformationUnit.Bit, InformationUnit.Bit, quantity => quantity); @@ -429,7 +400,7 @@ public static string GetAbbreviation(InformationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(InformationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -738,7 +709,7 @@ public static Information Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Information Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -769,7 +740,7 @@ public static bool TryParse(string? str, out Information result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Information result) { return QuantityParser.Default.TryParse( @@ -797,7 +768,7 @@ public static InformationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -823,7 +794,7 @@ public static bool TryParseUnit(string str, out InformationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out InformationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -903,20 +874,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Information left, Information right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Information left, Information right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -932,23 +889,6 @@ public int CompareTo(Information other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Information objInformation)) - return false; - - return Equals(objInformation); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Information other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Information within the given absolute or relative tolerance. @@ -1140,7 +1080,7 @@ private decimal GetValueAs(InformationUnit unit) { var converted = ToUnit(unit); return (decimal)converted.Value; - } + } #endregion @@ -1159,63 +1099,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1297,8 +1203,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(InformationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Information.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Information.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 465440fd78..38b7bd0d92 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. /// [DataContract] - public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -77,7 +76,7 @@ static Irradiance() new UnitInfo(IrradianceUnit.WattPerSquareCentimeter, "WattsPerSquareCentimeter", BaseUnits.Undefined), new UnitInfo(IrradianceUnit.WattPerSquareMeter, "WattsPerSquareMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Irradiance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -90,9 +89,6 @@ static Irradiance() /// If value is NaN or Infinity. public Irradiance(double value, IrradianceUnit unit) { - if(unit == IrradianceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -136,24 +132,6 @@ public Irradiance(double value, UnitSystem unitSystem) /// public static IrradianceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Irradiance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiance MaxValue { get; } - - /// - /// Represents the smallest possible value of Irradiance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Irradiance quantity. /// @@ -184,12 +162,6 @@ public Irradiance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Irradiance; - /// /// The of this quantity. /// @@ -293,7 +265,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareMeter, IrradianceUnit.PicowattPerSquareCentimeter, quantity => new Irradiance((quantity.Value*0.0001) / 1e-12d, IrradianceUnit.PicowattPerSquareCentimeter)); unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareMeter, IrradianceUnit.PicowattPerSquareMeter, quantity => new Irradiance((quantity.Value) / 1e-12d, IrradianceUnit.PicowattPerSquareMeter)); unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareMeter, IrradianceUnit.WattPerSquareCentimeter, quantity => new Irradiance(quantity.Value*0.0001, IrradianceUnit.WattPerSquareCentimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(IrradianceUnit.WattPerSquareMeter, IrradianceUnit.WattPerSquareMeter, quantity => quantity); @@ -328,7 +299,7 @@ public static string GetAbbreviation(IrradianceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(IrradianceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -529,7 +500,7 @@ public static Irradiance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Irradiance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -560,7 +531,7 @@ public static bool TryParse(string? str, out Irradiance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Irradiance result) { return QuantityParser.Default.TryParse( @@ -588,7 +559,7 @@ public static IrradianceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -614,7 +585,7 @@ public static bool TryParseUnit(string str, out IrradianceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out IrradianceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -694,20 +665,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiance left, Irradiance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiance left, Irradiance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -723,23 +680,6 @@ public int CompareTo(Irradiance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Irradiance objIrradiance)) - return false; - - return Equals(objIrradiance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Irradiance within the given absolute or relative tolerance. @@ -931,7 +871,7 @@ private double GetValueAs(IrradianceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -950,63 +890,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1088,8 +994,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(IrradianceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Irradiance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Irradiance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index ab538380dd..57d42f0684 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Irradiation /// [DataContract] - public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiation : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -73,7 +72,7 @@ static Irradiation() new UnitInfo(IrradiationUnit.MillijoulePerSquareCentimeter, "MillijoulesPerSquareCentimeter", BaseUnits.Undefined), new UnitInfo(IrradiationUnit.WattHourPerSquareMeter, "WattHoursPerSquareMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Irradiation); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -86,9 +85,6 @@ static Irradiation() /// If value is NaN or Infinity. public Irradiation(double value, IrradiationUnit unit) { - if(unit == IrradiationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -132,24 +128,6 @@ public Irradiation(double value, UnitSystem unitSystem) /// public static IrradiationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Irradiation - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiation MaxValue { get; } - - /// - /// Represents the smallest possible value of Irradiation - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Irradiation MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Irradiation quantity. /// @@ -180,12 +158,6 @@ public Irradiation(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Irradiation; - /// /// The of this quantity. /// @@ -247,7 +219,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.KilowattHourPerSquareMeter, quantity => new Irradiation((quantity.Value/3600d) / 1e3d, IrradiationUnit.KilowattHourPerSquareMeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.MillijoulePerSquareCentimeter, quantity => new Irradiation((quantity.Value/1e4) / 1e-3d, IrradiationUnit.MillijoulePerSquareCentimeter)); unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.WattHourPerSquareMeter, quantity => new Irradiation(quantity.Value/3600d, IrradiationUnit.WattHourPerSquareMeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(IrradiationUnit.JoulePerSquareMeter, IrradiationUnit.JoulePerSquareMeter, quantity => quantity); @@ -275,7 +246,7 @@ public static string GetAbbreviation(IrradiationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(IrradiationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -413,7 +384,7 @@ public static Irradiation Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Irradiation Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -444,7 +415,7 @@ public static bool TryParse(string? str, out Irradiation result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Irradiation result) { return QuantityParser.Default.TryParse( @@ -472,7 +443,7 @@ public static IrradiationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -498,7 +469,7 @@ public static bool TryParseUnit(string str, out IrradiationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out IrradiationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -578,20 +549,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiation left, Irradiation right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiation left, Irradiation right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -607,23 +564,6 @@ public int CompareTo(Irradiation other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Irradiation objIrradiation)) - return false; - - return Equals(objIrradiation); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiation other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Irradiation within the given absolute or relative tolerance. @@ -815,7 +755,7 @@ private double GetValueAs(IrradiationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -834,63 +774,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -972,8 +878,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(IrradiationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Irradiation.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Irradiation.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 8c7ad7c34c..2697cb2a1b 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Viscosity /// [DataContract] - public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct KinematicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -75,7 +74,7 @@ static KinematicViscosity() new UnitInfo(KinematicViscosityUnit.SquareMeterPerSecond, "SquareMetersPerSecond", BaseUnits.Undefined), new UnitInfo(KinematicViscosityUnit.Stokes, "Stokes", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.KinematicViscosity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -88,9 +87,6 @@ static KinematicViscosity() /// If value is NaN or Infinity. public KinematicViscosity(double value, KinematicViscosityUnit unit) { - if(unit == KinematicViscosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -134,24 +130,6 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// public static KinematicViscosityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of KinematicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static KinematicViscosity MaxValue { get; } - - /// - /// Represents the smallest possible value of KinematicViscosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static KinematicViscosity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the KinematicViscosity quantity. /// @@ -182,12 +160,6 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.KinematicViscosity; - /// /// The of this quantity. /// @@ -261,7 +233,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Nanostokes, quantity => new KinematicViscosity((quantity.Value*1e4) / 1e-9d, KinematicViscosityUnit.Nanostokes)); unitConverter.SetConversionFunction(KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.SquareFootPerSecond, quantity => new KinematicViscosity(quantity.Value*10.7639, KinematicViscosityUnit.SquareFootPerSecond)); unitConverter.SetConversionFunction(KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.Stokes, quantity => new KinematicViscosity(quantity.Value*1e4, KinematicViscosityUnit.Stokes)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(KinematicViscosityUnit.SquareMeterPerSecond, KinematicViscosityUnit.SquareMeterPerSecond, quantity => quantity); @@ -291,7 +262,7 @@ public static string GetAbbreviation(KinematicViscosityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(KinematicViscosityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -447,7 +418,7 @@ public static KinematicViscosity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static KinematicViscosity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -478,7 +449,7 @@ public static bool TryParse(string? str, out KinematicViscosity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out KinematicViscosity result) { return QuantityParser.Default.TryParse( @@ -506,7 +477,7 @@ public static KinematicViscosityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -532,7 +503,7 @@ public static bool TryParseUnit(string str, out KinematicViscosityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out KinematicViscosityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -612,20 +583,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(KinematicViscosity left, KinematicViscosity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(KinematicViscosity left, KinematicViscosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -641,23 +598,6 @@ public int CompareTo(KinematicViscosity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is KinematicViscosity objKinematicViscosity)) - return false; - - return Equals(objKinematicViscosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(KinematicViscosity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another KinematicViscosity within the given absolute or relative tolerance. @@ -849,7 +789,7 @@ private double GetValueAs(KinematicViscosityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -868,63 +808,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1006,8 +912,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(KinematicViscosityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return KinematicViscosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return KinematicViscosity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 631689eaab..8536b93a47 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -37,7 +36,7 @@ namespace UnitsNet /// [System.Obsolete("Use TemperatureGradient instead.")] [DataContract] - public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LapseRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -65,7 +64,7 @@ static LapseRate() { new UnitInfo(LapseRateUnit.DegreeCelsiusPerKilometer, "DegreesCelciusPerKilometer", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LapseRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -78,9 +77,6 @@ static LapseRate() /// If value is NaN or Infinity. public LapseRate(double value, LapseRateUnit unit) { - if(unit == LapseRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,24 +120,6 @@ public LapseRate(double value, UnitSystem unitSystem) /// public static LapseRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of LapseRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LapseRate MaxValue { get; } - - /// - /// Represents the smallest possible value of LapseRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LapseRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the LapseRate quantity. /// @@ -172,12 +150,6 @@ public LapseRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.LapseRate; - /// /// The of this quantity. /// @@ -203,7 +175,6 @@ public LapseRate(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> LapseRateUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LapseRateUnit.DegreeCelsiusPerKilometer, LapseRateUnit.DegreeCelsiusPerKilometer, quantity => quantity); @@ -225,7 +196,7 @@ public static string GetAbbreviation(LapseRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LapseRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -309,7 +280,7 @@ public static LapseRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LapseRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -340,7 +311,7 @@ public static bool TryParse(string? str, out LapseRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LapseRate result) { return QuantityParser.Default.TryParse( @@ -368,7 +339,7 @@ public static LapseRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -394,7 +365,7 @@ public static bool TryParseUnit(string str, out LapseRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LapseRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -474,20 +445,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LapseRate left, LapseRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LapseRate left, LapseRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -503,23 +460,6 @@ public int CompareTo(LapseRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LapseRate objLapseRate)) - return false; - - return Equals(objLapseRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LapseRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LapseRate within the given absolute or relative tolerance. @@ -711,7 +651,7 @@ private double GetValueAs(LapseRateUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -730,63 +670,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -868,8 +774,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LapseRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LapseRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LapseRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 8d9c598f31..46bdd38a14 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. /// [DataContract] - public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Length : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -96,7 +95,7 @@ static Length() new UnitInfo(LengthUnit.UsSurveyFoot, "UsSurveyFeet", new BaseUnits(length: LengthUnit.UsSurveyFoot)), new UnitInfo(LengthUnit.Yard, "Yards", new BaseUnits(length: LengthUnit.Yard)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Length); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -109,9 +108,6 @@ static Length() /// If value is NaN or Infinity. public Length(double value, LengthUnit unit) { - if(unit == LengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -155,24 +151,6 @@ public Length(double value, UnitSystem unitSystem) /// public static LengthUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Length - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Length MaxValue { get; } - - /// - /// Represents the smallest possible value of Length - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Length MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Length quantity. /// @@ -203,12 +181,6 @@ public Length(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Length; - /// /// The of this quantity. /// @@ -426,7 +398,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.Twip, quantity => new Length(quantity.Value*56692.913385826, LengthUnit.Twip)); unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.UsSurveyFoot, quantity => new Length(quantity.Value*3937/1200, LengthUnit.UsSurveyFoot)); unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.Yard, quantity => new Length(quantity.Value/0.9144, LengthUnit.Yard)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LengthUnit.Meter, LengthUnit.Meter, quantity => quantity); @@ -480,7 +451,7 @@ public static string GetAbbreviation(LengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -852,7 +823,7 @@ public static Length Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Length Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -883,7 +854,7 @@ public static bool TryParse(string? str, out Length result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Length result) { return QuantityParser.Default.TryParse( @@ -911,7 +882,7 @@ public static LengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -937,7 +908,7 @@ public static bool TryParseUnit(string str, out LengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1017,20 +988,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Length left, Length right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Length left, Length right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1046,23 +1003,6 @@ public int CompareTo(Length other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Length objLength)) - return false; - - return Equals(objLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Length other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Length within the given absolute or relative tolerance. @@ -1254,7 +1194,7 @@ private double GetValueAs(LengthUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1273,63 +1213,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1411,8 +1317,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Length.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Length.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 9a49ff10bb..f5ae6fcc54 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. /// [DataContract] - public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Level : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -65,7 +64,7 @@ static Level() new UnitInfo(LevelUnit.Decibel, "Decibels", BaseUnits.Undefined), new UnitInfo(LevelUnit.Neper, "Nepers", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Level); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -78,9 +77,6 @@ static Level() /// If value is NaN or Infinity. public Level(double value, LevelUnit unit) { - if(unit == LevelUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,24 +120,6 @@ public Level(double value, UnitSystem unitSystem) /// public static LevelUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Level - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Level MaxValue { get; } - - /// - /// Represents the smallest possible value of Level - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Level MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Level quantity. /// @@ -172,12 +150,6 @@ public Level(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Level; - /// /// The of this quantity. /// @@ -209,7 +181,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> LevelUnit unitConverter.SetConversionFunction(LevelUnit.Decibel, LevelUnit.Neper, quantity => new Level(0.115129254*quantity.Value, LevelUnit.Neper)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LevelUnit.Decibel, LevelUnit.Decibel, quantity => quantity); @@ -232,7 +203,7 @@ public static string GetAbbreviation(LevelUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LevelUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -325,7 +296,7 @@ public static Level Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Level Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -356,7 +327,7 @@ public static bool TryParse(string? str, out Level result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Level result) { return QuantityParser.Default.TryParse( @@ -384,7 +355,7 @@ public static LevelUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -410,7 +381,7 @@ public static bool TryParseUnit(string str, out LevelUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LevelUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -498,20 +469,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Level left, Level right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Level left, Level right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -527,23 +484,6 @@ public int CompareTo(Level other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Level objLevel)) - return false; - - return Equals(objLevel); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Level other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Level within the given absolute or relative tolerance. @@ -735,7 +675,7 @@ private double GetValueAs(LevelUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -754,63 +694,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -892,8 +798,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LevelUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Level.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Level.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 5a80f9c715..66c93f2578 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -80,7 +79,7 @@ static LinearDensity() new UnitInfo(LinearDensityUnit.PoundPerFoot, "PoundsPerFoot", BaseUnits.Undefined), new UnitInfo(LinearDensityUnit.PoundPerInch, "PoundsPerInch", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LinearDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -93,9 +92,6 @@ static LinearDensity() /// If value is NaN or Infinity. public LinearDensity(double value, LinearDensityUnit unit) { - if(unit == LinearDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,24 +135,6 @@ public LinearDensity(double value, UnitSystem unitSystem) /// public static LinearDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of LinearDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of LinearDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the LinearDensity quantity. /// @@ -187,12 +165,6 @@ public LinearDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.LinearDensity; - /// /// The of this quantity. /// @@ -296,7 +268,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.MilligramPerMillimeter, quantity => new LinearDensity((quantity.Value) / 1e-3d, LinearDensityUnit.MilligramPerMillimeter)); unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.PoundPerFoot, quantity => new LinearDensity(quantity.Value/1.48816394, LinearDensityUnit.PoundPerFoot)); unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.PoundPerInch, quantity => new LinearDensity(quantity.Value*5.5997415e-2, LinearDensityUnit.PoundPerInch)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LinearDensityUnit.KilogramPerMeter, LinearDensityUnit.KilogramPerMeter, quantity => quantity); @@ -331,7 +302,7 @@ public static string GetAbbreviation(LinearDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LinearDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -532,7 +503,7 @@ public static LinearDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LinearDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -563,7 +534,7 @@ public static bool TryParse(string? str, out LinearDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LinearDensity result) { return QuantityParser.Default.TryParse( @@ -591,7 +562,7 @@ public static LinearDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -617,7 +588,7 @@ public static bool TryParseUnit(string str, out LinearDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LinearDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -697,20 +668,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearDensity left, LinearDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearDensity left, LinearDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -726,23 +683,6 @@ public int CompareTo(LinearDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LinearDensity objLinearDensity)) - return false; - - return Equals(objLinearDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LinearDensity within the given absolute or relative tolerance. @@ -934,7 +874,7 @@ private double GetValueAs(LinearDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -953,63 +893,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1091,8 +997,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LinearDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LinearDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LinearDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index b6190259cb..7e47dede4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearPowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -91,7 +90,7 @@ static LinearPowerDensity() new UnitInfo(LinearPowerDensityUnit.WattPerMeter, "WattsPerMeter", BaseUnits.Undefined), new UnitInfo(LinearPowerDensityUnit.WattPerMillimeter, "WattsPerMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LinearPowerDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -104,9 +103,6 @@ static LinearPowerDensity() /// If value is NaN or Infinity. public LinearPowerDensity(double value, LinearPowerDensityUnit unit) { - if(unit == LinearPowerDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -150,24 +146,6 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// public static LinearPowerDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of LinearPowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearPowerDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of LinearPowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LinearPowerDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the LinearPowerDensity quantity. /// @@ -198,12 +176,6 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.LinearPowerDensity; - /// /// The of this quantity. /// @@ -373,7 +345,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerFoot, quantity => new LinearPowerDensity(quantity.Value/3.280839895, LinearPowerDensityUnit.WattPerFoot)); unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerInch, quantity => new LinearPowerDensity(quantity.Value/39.37007874, LinearPowerDensityUnit.WattPerInch)); unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerMillimeter, quantity => new LinearPowerDensity(quantity.Value/1e3, LinearPowerDensityUnit.WattPerMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LinearPowerDensityUnit.WattPerMeter, LinearPowerDensityUnit.WattPerMeter, quantity => quantity); @@ -419,7 +390,7 @@ public static string GetAbbreviation(LinearPowerDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LinearPowerDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -719,7 +690,7 @@ public static LinearPowerDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LinearPowerDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -750,7 +721,7 @@ public static bool TryParse(string? str, out LinearPowerDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LinearPowerDensity result) { return QuantityParser.Default.TryParse( @@ -778,7 +749,7 @@ public static LinearPowerDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -804,7 +775,7 @@ public static bool TryParseUnit(string str, out LinearPowerDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LinearPowerDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -884,20 +855,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -913,23 +870,6 @@ public int CompareTo(LinearPowerDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) - return false; - - return Equals(objLinearPowerDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearPowerDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LinearPowerDensity within the given absolute or relative tolerance. @@ -1121,7 +1061,7 @@ private double GetValueAs(LinearPowerDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1140,63 +1080,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1278,8 +1184,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LinearPowerDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LinearPowerDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LinearPowerDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index a35ea5b25b..6de38ac3f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminosity /// [DataContract] - public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Luminosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -80,7 +79,7 @@ static Luminosity() new UnitInfo(LuminosityUnit.Terawatt, "Terawatts", BaseUnits.Undefined), new UnitInfo(LuminosityUnit.Watt, "Watts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Luminosity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -93,9 +92,6 @@ static Luminosity() /// If value is NaN or Infinity. public Luminosity(double value, LuminosityUnit unit) { - if(unit == LuminosityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,24 +135,6 @@ public Luminosity(double value, UnitSystem unitSystem) /// public static LuminosityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Luminosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Luminosity MaxValue { get; } - - /// - /// Represents the smallest possible value of Luminosity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Luminosity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Luminosity quantity. /// @@ -187,12 +165,6 @@ public Luminosity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Luminosity; - /// /// The of this quantity. /// @@ -296,7 +268,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(LuminosityUnit.Watt, LuminosityUnit.Picowatt, quantity => new Luminosity((quantity.Value) / 1e-12d, LuminosityUnit.Picowatt)); unitConverter.SetConversionFunction(LuminosityUnit.Watt, LuminosityUnit.SolarLuminosity, quantity => new Luminosity(quantity.Value / 3.846e26, LuminosityUnit.SolarLuminosity)); unitConverter.SetConversionFunction(LuminosityUnit.Watt, LuminosityUnit.Terawatt, quantity => new Luminosity((quantity.Value) / 1e12d, LuminosityUnit.Terawatt)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LuminosityUnit.Watt, LuminosityUnit.Watt, quantity => quantity); @@ -331,7 +302,7 @@ public static string GetAbbreviation(LuminosityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LuminosityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -532,7 +503,7 @@ public static Luminosity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Luminosity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -563,7 +534,7 @@ public static bool TryParse(string? str, out Luminosity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Luminosity result) { return QuantityParser.Default.TryParse( @@ -591,7 +562,7 @@ public static LuminosityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -617,7 +588,7 @@ public static bool TryParseUnit(string str, out LuminosityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LuminosityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -697,20 +668,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Luminosity left, Luminosity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Luminosity left, Luminosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -726,23 +683,6 @@ public int CompareTo(Luminosity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Luminosity objLuminosity)) - return false; - - return Equals(objLuminosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Luminosity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Luminosity within the given absolute or relative tolerance. @@ -934,7 +874,7 @@ private double GetValueAs(LuminosityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -953,63 +893,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1091,8 +997,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LuminosityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Luminosity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Luminosity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index b2e462ad23..a0ebc8ef96 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_flux /// [DataContract] - public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static LuminousFlux() { new UnitInfo(LuminousFluxUnit.Lumen, "Lumens", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LuminousFlux); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static LuminousFlux() /// If value is NaN or Infinity. public LuminousFlux(double value, LuminousFluxUnit unit) { - if(unit == LuminousFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// public static LuminousFluxUnit BaseUnit { get; } - /// - /// Represents the largest possible value of LuminousFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousFlux MaxValue { get; } - - /// - /// Represents the smallest possible value of LuminousFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousFlux MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the LuminousFlux quantity. /// @@ -174,12 +152,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.LuminousFlux; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public LuminousFlux(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> LuminousFluxUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LuminousFluxUnit.Lumen, LuminousFluxUnit.Lumen, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(LuminousFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LuminousFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static LuminousFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LuminousFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out LuminousFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LuminousFlux result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static LuminousFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out LuminousFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LuminousFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousFlux left, LuminousFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousFlux left, LuminousFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(LuminousFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LuminousFlux objLuminousFlux)) - return false; - - return Equals(objLuminousFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LuminousFlux within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(LuminousFluxUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LuminousFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LuminousFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LuminousFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index b4e165c352..70bbbc7802 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_intensity /// [DataContract] - public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousIntensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static LuminousIntensity() { new UnitInfo(LuminousIntensityUnit.Candela, "Candela", new BaseUnits(luminousIntensity: LuminousIntensityUnit.Candela)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.LuminousIntensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static LuminousIntensity() /// If value is NaN or Infinity. public LuminousIntensity(double value, LuminousIntensityUnit unit) { - if(unit == LuminousIntensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// public static LuminousIntensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of LuminousIntensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousIntensity MaxValue { get; } - - /// - /// Represents the smallest possible value of LuminousIntensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static LuminousIntensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the LuminousIntensity quantity. /// @@ -174,12 +152,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.LuminousIntensity; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public LuminousIntensity(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> LuminousIntensityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(LuminousIntensityUnit.Candela, LuminousIntensityUnit.Candela, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(LuminousIntensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(LuminousIntensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static LuminousIntensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static LuminousIntensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out LuminousIntensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out LuminousIntensity result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static LuminousIntensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out LuminousIntensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out LuminousIntensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousIntensity left, LuminousIntensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousIntensity left, LuminousIntensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(LuminousIntensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is LuminousIntensity objLuminousIntensity)) - return false; - - return Equals(objLuminousIntensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousIntensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another LuminousIntensity within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(LuminousIntensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(LuminousIntensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return LuminousIntensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return LuminousIntensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 9248258677..5a2a4abc43 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_field /// [DataContract] - public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticField : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -72,7 +71,7 @@ static MagneticField() new UnitInfo(MagneticFieldUnit.Nanotesla, "Nanoteslas", BaseUnits.Undefined), new UnitInfo(MagneticFieldUnit.Tesla, "Teslas", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MagneticField); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -85,9 +84,6 @@ static MagneticField() /// If value is NaN or Infinity. public MagneticField(double value, MagneticFieldUnit unit) { - if(unit == MagneticFieldUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -131,24 +127,6 @@ public MagneticField(double value, UnitSystem unitSystem) /// public static MagneticFieldUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MagneticField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticField MaxValue { get; } - - /// - /// Represents the smallest possible value of MagneticField - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticField MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MagneticField quantity. /// @@ -179,12 +157,6 @@ public MagneticField(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MagneticField; - /// /// The of this quantity. /// @@ -240,7 +212,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MagneticFieldUnit.Tesla, MagneticFieldUnit.Milligauss, quantity => new MagneticField((quantity.Value*1e4) / 1e-3d, MagneticFieldUnit.Milligauss)); unitConverter.SetConversionFunction(MagneticFieldUnit.Tesla, MagneticFieldUnit.Millitesla, quantity => new MagneticField((quantity.Value) / 1e-3d, MagneticFieldUnit.Millitesla)); unitConverter.SetConversionFunction(MagneticFieldUnit.Tesla, MagneticFieldUnit.Nanotesla, quantity => new MagneticField((quantity.Value) / 1e-9d, MagneticFieldUnit.Nanotesla)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MagneticFieldUnit.Tesla, MagneticFieldUnit.Tesla, quantity => quantity); @@ -267,7 +238,7 @@ public static string GetAbbreviation(MagneticFieldUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MagneticFieldUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -396,7 +367,7 @@ public static MagneticField Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MagneticField Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -427,7 +398,7 @@ public static bool TryParse(string? str, out MagneticField result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MagneticField result) { return QuantityParser.Default.TryParse( @@ -455,7 +426,7 @@ public static MagneticFieldUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -481,7 +452,7 @@ public static bool TryParseUnit(string str, out MagneticFieldUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MagneticFieldUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -561,20 +532,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticField left, MagneticField right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticField left, MagneticField right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -590,23 +547,6 @@ public int CompareTo(MagneticField other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MagneticField objMagneticField)) - return false; - - return Equals(objMagneticField); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticField other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MagneticField within the given absolute or relative tolerance. @@ -798,7 +738,7 @@ private double GetValueAs(MagneticFieldUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -817,63 +757,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -955,8 +861,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MagneticFieldUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MagneticField.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MagneticField.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index e13e4ea0e9..f96cf1ffdf 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_flux /// [DataContract] - public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static MagneticFlux() { new UnitInfo(MagneticFluxUnit.Weber, "Webers", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MagneticFlux); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static MagneticFlux() /// If value is NaN or Infinity. public MagneticFlux(double value, MagneticFluxUnit unit) { - if(unit == MagneticFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// public static MagneticFluxUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MagneticFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticFlux MaxValue { get; } - - /// - /// Represents the smallest possible value of MagneticFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MagneticFlux MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MagneticFlux quantity. /// @@ -174,12 +152,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MagneticFlux; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public MagneticFlux(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> MagneticFluxUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MagneticFluxUnit.Weber, MagneticFluxUnit.Weber, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(MagneticFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MagneticFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static MagneticFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MagneticFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out MagneticFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MagneticFlux result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static MagneticFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out MagneticFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MagneticFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticFlux left, MagneticFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticFlux left, MagneticFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(MagneticFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MagneticFlux objMagneticFlux)) - return false; - - return Equals(objMagneticFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MagneticFlux within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(MagneticFluxUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MagneticFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MagneticFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MagneticFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 4c623332cc..5380313ceb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetization /// [DataContract] - public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Magnetization : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static Magnetization() { new UnitInfo(MagnetizationUnit.AmperePerMeter, "AmperesPerMeter", new BaseUnits(length: LengthUnit.Meter, current: ElectricCurrentUnit.Ampere)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Magnetization); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static Magnetization() /// If value is NaN or Infinity. public Magnetization(double value, MagnetizationUnit unit) { - if(unit == MagnetizationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public Magnetization(double value, UnitSystem unitSystem) /// public static MagnetizationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Magnetization - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Magnetization MaxValue { get; } - - /// - /// Represents the smallest possible value of Magnetization - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Magnetization MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Magnetization quantity. /// @@ -174,12 +152,6 @@ public Magnetization(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Magnetization; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public Magnetization(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> MagnetizationUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MagnetizationUnit.AmperePerMeter, MagnetizationUnit.AmperePerMeter, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(MagnetizationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MagnetizationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static Magnetization Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Magnetization Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out Magnetization result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Magnetization result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static MagnetizationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out MagnetizationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MagnetizationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Magnetization left, Magnetization right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Magnetization left, Magnetization right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(Magnetization other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Magnetization objMagnetization)) - return false; - - return Equals(objMagnetization); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Magnetization other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Magnetization within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(MagnetizationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MagnetizationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Magnetization.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Magnetization.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index a66b43a579..6c61cdfe1d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). /// [DataContract] - public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Mass : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -88,7 +87,7 @@ static Mass() new UnitInfo(MassUnit.Stone, "Stone", new BaseUnits(mass: MassUnit.Stone)), new UnitInfo(MassUnit.Tonne, "Tonnes", new BaseUnits(mass: MassUnit.Tonne)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Mass); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -101,9 +100,6 @@ static Mass() /// If value is NaN or Infinity. public Mass(double value, MassUnit unit) { - if(unit == MassUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -147,24 +143,6 @@ public Mass(double value, UnitSystem unitSystem) /// public static MassUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Mass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Mass MaxValue { get; } - - /// - /// Represents the smallest possible value of Mass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Mass MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Mass quantity. /// @@ -195,12 +173,6 @@ public Mass(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Mass; - /// /// The of this quantity. /// @@ -370,7 +342,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MassUnit.Kilogram, MassUnit.SolarMass, quantity => new Mass(quantity.Value / 1.98947e30, MassUnit.SolarMass)); unitConverter.SetConversionFunction(MassUnit.Kilogram, MassUnit.Stone, quantity => new Mass(quantity.Value*0.1574731728702698, MassUnit.Stone)); unitConverter.SetConversionFunction(MassUnit.Kilogram, MassUnit.Tonne, quantity => new Mass(quantity.Value/1e3, MassUnit.Tonne)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MassUnit.Kilogram, MassUnit.Kilogram, quantity => quantity); @@ -416,7 +387,7 @@ public static string GetAbbreviation(MassUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -716,7 +687,7 @@ public static Mass Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Mass Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -747,7 +718,7 @@ public static bool TryParse(string? str, out Mass result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Mass result) { return QuantityParser.Default.TryParse( @@ -775,7 +746,7 @@ public static MassUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -801,7 +772,7 @@ public static bool TryParseUnit(string str, out MassUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -881,20 +852,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Mass left, Mass right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Mass left, Mass right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -910,23 +867,6 @@ public int CompareTo(Mass other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Mass objMass)) - return false; - - return Equals(objMass); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Mass other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Mass within the given absolute or relative tolerance. @@ -1118,7 +1058,7 @@ private double GetValueAs(MassUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1137,63 +1077,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1275,8 +1181,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Mass.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Mass.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 2ac346ac3d..3ab6bffa55 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) /// [DataContract] - public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -115,7 +114,7 @@ static MassConcentration() new UnitInfo(MassConcentrationUnit.TonnePerCubicMeter, "TonnesPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Tonne)), new UnitInfo(MassConcentrationUnit.TonnePerCubicMillimeter, "TonnesPerCubicMillimeter", new BaseUnits(length: LengthUnit.Millimeter, mass: MassUnit.Tonne)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassConcentration); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -128,9 +127,6 @@ static MassConcentration() /// If value is NaN or Infinity. public MassConcentration(double value, MassConcentrationUnit unit) { - if(unit == MassConcentrationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -174,24 +170,6 @@ public MassConcentration(double value, UnitSystem unitSystem) /// public static MassConcentrationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MassConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassConcentration MaxValue { get; } - - /// - /// Represents the smallest possible value of MassConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassConcentration MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MassConcentration quantity. /// @@ -222,12 +200,6 @@ public MassConcentration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MassConcentration; - /// /// The of this quantity. /// @@ -541,7 +513,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicCentimeter, quantity => new MassConcentration(quantity.Value*1e-9, MassConcentrationUnit.TonnePerCubicCentimeter)); unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicMeter, quantity => new MassConcentration(quantity.Value*0.001, MassConcentrationUnit.TonnePerCubicMeter)); unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.TonnePerCubicMillimeter, quantity => new MassConcentration(quantity.Value*1e-12, MassConcentrationUnit.TonnePerCubicMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MassConcentrationUnit.KilogramPerCubicMeter, MassConcentrationUnit.KilogramPerCubicMeter, quantity => quantity); @@ -611,7 +582,7 @@ public static string GetAbbreviation(MassConcentrationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassConcentrationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1127,7 +1098,7 @@ public static MassConcentration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassConcentration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1158,7 +1129,7 @@ public static bool TryParse(string? str, out MassConcentration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassConcentration result) { return QuantityParser.Default.TryParse( @@ -1186,7 +1157,7 @@ public static MassConcentrationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1212,7 +1183,7 @@ public static bool TryParseUnit(string str, out MassConcentrationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassConcentrationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1292,20 +1263,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassConcentration left, MassConcentration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassConcentration left, MassConcentration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1321,23 +1278,6 @@ public int CompareTo(MassConcentration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassConcentration objMassConcentration)) - return false; - - return Equals(objMassConcentration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassConcentration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassConcentration within the given absolute or relative tolerance. @@ -1529,7 +1469,7 @@ private double GetValueAs(MassConcentrationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1548,63 +1488,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1686,8 +1592,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassConcentrationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassConcentration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassConcentration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 539980472b..56c3299e00 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). /// [DataContract] - public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -96,7 +95,7 @@ static MassFlow() new UnitInfo(MassFlowUnit.TonnePerDay, "TonnesPerDay", BaseUnits.Undefined), new UnitInfo(MassFlowUnit.TonnePerHour, "TonnesPerHour", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassFlow); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -109,9 +108,6 @@ static MassFlow() /// If value is NaN or Infinity. public MassFlow(double value, MassFlowUnit unit) { - if(unit == MassFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -155,24 +151,6 @@ public MassFlow(double value, UnitSystem unitSystem) /// public static MassFlowUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MassFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlow MaxValue { get; } - - /// - /// Represents the smallest possible value of MassFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlow MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MassFlow quantity. /// @@ -203,12 +181,6 @@ public MassFlow(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MassFlow; - /// /// The of this quantity. /// @@ -426,7 +398,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MassFlowUnit.GramPerSecond, MassFlowUnit.ShortTonPerHour, quantity => new MassFlow(quantity.Value/251.9957611, MassFlowUnit.ShortTonPerHour)); unitConverter.SetConversionFunction(MassFlowUnit.GramPerSecond, MassFlowUnit.TonnePerDay, quantity => new MassFlow(quantity.Value*0.0864000, MassFlowUnit.TonnePerDay)); unitConverter.SetConversionFunction(MassFlowUnit.GramPerSecond, MassFlowUnit.TonnePerHour, quantity => new MassFlow(quantity.Value*3.6/1000, MassFlowUnit.TonnePerHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MassFlowUnit.GramPerSecond, MassFlowUnit.GramPerSecond, quantity => quantity); @@ -480,7 +451,7 @@ public static string GetAbbreviation(MassFlowUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassFlowUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -852,7 +823,7 @@ public static MassFlow Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassFlow Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -883,7 +854,7 @@ public static bool TryParse(string? str, out MassFlow result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassFlow result) { return QuantityParser.Default.TryParse( @@ -911,7 +882,7 @@ public static MassFlowUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -937,7 +908,7 @@ public static bool TryParseUnit(string str, out MassFlowUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassFlowUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1017,20 +988,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlow left, MassFlow right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlow left, MassFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1046,23 +1003,6 @@ public int CompareTo(MassFlow other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFlow objMassFlow)) - return false; - - return Equals(objMassFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlow other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassFlow within the given absolute or relative tolerance. @@ -1254,7 +1194,7 @@ private double GetValueAs(MassFlowUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1273,63 +1213,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1411,8 +1317,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassFlowUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassFlow.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 5ed0048169..9522b5e08c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Mass flux is the mass flow rate per unit area. /// [DataContract] - public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -75,7 +74,7 @@ static MassFlux() new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMeter, "KilogramsPerSecondPerSquareMeter", BaseUnits.Undefined), new UnitInfo(MassFluxUnit.KilogramPerSecondPerSquareMillimeter, "KilogramsPerSecondPerSquareMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassFlux); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -88,9 +87,6 @@ static MassFlux() /// If value is NaN or Infinity. public MassFlux(double value, MassFluxUnit unit) { - if(unit == MassFluxUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -134,24 +130,6 @@ public MassFlux(double value, UnitSystem unitSystem) /// public static MassFluxUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MassFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlux MaxValue { get; } - - /// - /// Represents the smallest possible value of MassFlux - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFlux MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MassFlux quantity. /// @@ -182,12 +160,6 @@ public MassFlux(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MassFlux; - /// /// The of this quantity. /// @@ -279,7 +251,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerHourPerSquareMillimeter, quantity => new MassFlux((quantity.Value*3.6e0) / 1e3d, MassFluxUnit.KilogramPerHourPerSquareMillimeter)); unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareCentimeter, quantity => new MassFlux((quantity.Value*1e-1) / 1e3d, MassFluxUnit.KilogramPerSecondPerSquareCentimeter)); unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMillimeter, quantity => new MassFlux((quantity.Value*1e-3) / 1e3d, MassFluxUnit.KilogramPerSecondPerSquareMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MassFluxUnit.KilogramPerSecondPerSquareMeter, MassFluxUnit.KilogramPerSecondPerSquareMeter, quantity => quantity); @@ -312,7 +283,7 @@ public static string GetAbbreviation(MassFluxUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassFluxUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -495,7 +466,7 @@ public static MassFlux Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassFlux Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -526,7 +497,7 @@ public static bool TryParse(string? str, out MassFlux result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassFlux result) { return QuantityParser.Default.TryParse( @@ -554,7 +525,7 @@ public static MassFluxUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -580,7 +551,7 @@ public static bool TryParseUnit(string str, out MassFluxUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassFluxUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -660,20 +631,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlux left, MassFlux right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlux left, MassFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -689,23 +646,6 @@ public int CompareTo(MassFlux other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFlux objMassFlux)) - return false; - - return Equals(objMassFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlux other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassFlux within the given absolute or relative tolerance. @@ -897,7 +837,7 @@ private double GetValueAs(MassFluxUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -916,63 +856,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1054,8 +960,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassFluxUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassFlux.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassFlux.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 67380089bb..e65dee5ce5 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) /// [DataContract] - public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFraction : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -90,7 +89,7 @@ static MassFraction() new UnitInfo(MassFractionUnit.PartPerTrillion, "PartsPerTrillion", BaseUnits.Undefined), new UnitInfo(MassFractionUnit.Percent, "Percent", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassFraction); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -103,9 +102,6 @@ static MassFraction() /// If value is NaN or Infinity. public MassFraction(double value, MassFractionUnit unit) { - if(unit == MassFractionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -149,24 +145,6 @@ public MassFraction(double value, UnitSystem unitSystem) /// public static MassFractionUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MassFraction - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFraction MaxValue { get; } - - /// - /// Represents the smallest possible value of MassFraction - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassFraction MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MassFraction quantity. /// @@ -197,12 +175,6 @@ public MassFraction(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MassFraction; - /// /// The of this quantity. /// @@ -366,7 +338,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerThousand, quantity => new MassFraction(quantity.Value*1e3, MassFractionUnit.PartPerThousand)); unitConverter.SetConversionFunction(MassFractionUnit.DecimalFraction, MassFractionUnit.PartPerTrillion, quantity => new MassFraction(quantity.Value*1e12, MassFractionUnit.PartPerTrillion)); unitConverter.SetConversionFunction(MassFractionUnit.DecimalFraction, MassFractionUnit.Percent, quantity => new MassFraction(quantity.Value*1e2, MassFractionUnit.Percent)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MassFractionUnit.DecimalFraction, MassFractionUnit.DecimalFraction, quantity => quantity); @@ -411,7 +382,7 @@ public static string GetAbbreviation(MassFractionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassFractionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -702,7 +673,7 @@ public static MassFraction Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassFraction Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -733,7 +704,7 @@ public static bool TryParse(string? str, out MassFraction result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassFraction result) { return QuantityParser.Default.TryParse( @@ -761,7 +732,7 @@ public static MassFractionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -787,7 +758,7 @@ public static bool TryParseUnit(string str, out MassFractionUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassFractionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -867,20 +838,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFraction left, MassFraction right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFraction left, MassFraction right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -896,23 +853,6 @@ public int CompareTo(MassFraction other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassFraction objMassFraction)) - return false; - - return Equals(objMassFraction); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFraction other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassFraction within the given absolute or relative tolerance. @@ -1104,7 +1044,7 @@ private double GetValueAs(MassFractionUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1123,63 +1063,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1261,8 +1167,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassFractionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassFraction.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassFraction.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 7f8adc4f76..019b1992a9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A property of body reflects how its mass is distributed with regard to an axis. /// [DataContract] - public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -91,7 +90,7 @@ static MassMomentOfInertia() new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMeter, "TonneSquareMeters", BaseUnits.Undefined), new UnitInfo(MassMomentOfInertiaUnit.TonneSquareMilimeter, "TonneSquareMilimeters", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MassMomentOfInertia); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -104,9 +103,6 @@ static MassMomentOfInertia() /// If value is NaN or Infinity. public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) { - if(unit == MassMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -150,24 +146,6 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// public static MassMomentOfInertiaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MassMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassMomentOfInertia MaxValue { get; } - - /// - /// Represents the smallest possible value of MassMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MassMomentOfInertia MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MassMomentOfInertia quantity. /// @@ -198,12 +176,6 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MassMomentOfInertia; - /// /// The of this quantity. /// @@ -391,7 +363,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareDecimeter, quantity => new MassMomentOfInertia(quantity.Value*1e-1, MassMomentOfInertiaUnit.TonneSquareDecimeter)); unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareMeter, quantity => new MassMomentOfInertia(quantity.Value*1e-3, MassMomentOfInertiaUnit.TonneSquareMeter)); unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.TonneSquareMilimeter, quantity => new MassMomentOfInertia(quantity.Value*1e3, MassMomentOfInertiaUnit.TonneSquareMilimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MassMomentOfInertiaUnit.KilogramSquareMeter, MassMomentOfInertiaUnit.KilogramSquareMeter, quantity => quantity); @@ -440,7 +411,7 @@ public static string GetAbbreviation(MassMomentOfInertiaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MassMomentOfInertiaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -767,7 +738,7 @@ public static MassMomentOfInertia Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MassMomentOfInertia Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -798,7 +769,7 @@ public static bool TryParse(string? str, out MassMomentOfInertia result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MassMomentOfInertia result) { return QuantityParser.Default.TryParse( @@ -826,7 +797,7 @@ public static MassMomentOfInertiaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -852,7 +823,7 @@ public static bool TryParseUnit(string str, out MassMomentOfInertiaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MassMomentOfInertiaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -932,20 +903,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -961,23 +918,6 @@ public int CompareTo(MassMomentOfInertia other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) - return false; - - return Equals(objMassMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassMomentOfInertia other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MassMomentOfInertia within the given absolute or relative tolerance. @@ -1169,7 +1109,7 @@ private double GetValueAs(MassMomentOfInertiaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1188,63 +1128,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1326,8 +1232,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MassMomentOfInertiaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MassMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MassMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index e5df95fc5e..6c211c711b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Molar energy is the amount of energy stored in 1 mole of a substance. /// [DataContract] - public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static MolarEnergy() new UnitInfo(MolarEnergyUnit.KilojoulePerMole, "KilojoulesPerMole", BaseUnits.Undefined), new UnitInfo(MolarEnergyUnit.MegajoulePerMole, "MegajoulesPerMole", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MolarEnergy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static MolarEnergy() /// If value is NaN or Infinity. public MolarEnergy(double value, MolarEnergyUnit unit) { - if(unit == MolarEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// public static MolarEnergyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MolarEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEnergy MaxValue { get; } - - /// - /// Represents the smallest possible value of MolarEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEnergy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MolarEnergy quantity. /// @@ -173,12 +151,6 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MolarEnergy; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> MolarEnergyUnit unitConverter.SetConversionFunction(MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.KilojoulePerMole, quantity => new MolarEnergy((quantity.Value) / 1e3d, MolarEnergyUnit.KilojoulePerMole)); unitConverter.SetConversionFunction(MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.MegajoulePerMole, quantity => new MolarEnergy((quantity.Value) / 1e6d, MolarEnergyUnit.MegajoulePerMole)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MolarEnergyUnit.JoulePerMole, MolarEnergyUnit.JoulePerMole, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(MolarEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static MolarEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MolarEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out MolarEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MolarEnergy result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static MolarEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out MolarEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEnergy left, MolarEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEnergy left, MolarEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(MolarEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarEnergy objMolarEnergy)) - return false; - - return Equals(objMolarEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MolarEnergy within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(MolarEnergyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MolarEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MolarEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 00da84ca93..6d4e5ca06b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// [DataContract] - public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static MolarEntropy() new UnitInfo(MolarEntropyUnit.KilojoulePerMoleKelvin, "KilojoulesPerMoleKelvin", BaseUnits.Undefined), new UnitInfo(MolarEntropyUnit.MegajoulePerMoleKelvin, "MegajoulesPerMoleKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MolarEntropy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static MolarEntropy() /// If value is NaN or Infinity. public MolarEntropy(double value, MolarEntropyUnit unit) { - if(unit == MolarEntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// public static MolarEntropyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MolarEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEntropy MaxValue { get; } - - /// - /// Represents the smallest possible value of MolarEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarEntropy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MolarEntropy quantity. /// @@ -173,12 +151,6 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MolarEntropy; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> MolarEntropyUnit unitConverter.SetConversionFunction(MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.KilojoulePerMoleKelvin, quantity => new MolarEntropy((quantity.Value) / 1e3d, MolarEntropyUnit.KilojoulePerMoleKelvin)); unitConverter.SetConversionFunction(MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.MegajoulePerMoleKelvin, quantity => new MolarEntropy((quantity.Value) / 1e6d, MolarEntropyUnit.MegajoulePerMoleKelvin)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MolarEntropyUnit.JoulePerMoleKelvin, MolarEntropyUnit.JoulePerMoleKelvin, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(MolarEntropyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarEntropyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static MolarEntropy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MolarEntropy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out MolarEntropy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MolarEntropy result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static MolarEntropyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out MolarEntropyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarEntropyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEntropy left, MolarEntropy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEntropy left, MolarEntropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(MolarEntropy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarEntropy objMolarEntropy)) - return false; - - return Equals(objMolarEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEntropy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MolarEntropy within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(MolarEntropyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarEntropyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MolarEntropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MolarEntropy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 810adc25f9..e574b34ed6 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. /// [DataContract] - public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarMass : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -75,7 +74,7 @@ static MolarMass() new UnitInfo(MolarMassUnit.NanogramPerMole, "NanogramsPerMole", BaseUnits.Undefined), new UnitInfo(MolarMassUnit.PoundPerMole, "PoundsPerMole", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.MolarMass); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -88,9 +87,6 @@ static MolarMass() /// If value is NaN or Infinity. public MolarMass(double value, MolarMassUnit unit) { - if(unit == MolarMassUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -134,24 +130,6 @@ public MolarMass(double value, UnitSystem unitSystem) /// public static MolarMassUnit BaseUnit { get; } - /// - /// Represents the largest possible value of MolarMass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarMass MaxValue { get; } - - /// - /// Represents the smallest possible value of MolarMass - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static MolarMass MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the MolarMass quantity. /// @@ -182,12 +160,6 @@ public MolarMass(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.MolarMass; - /// /// The of this quantity. /// @@ -279,7 +251,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MolarMassUnit.KilogramPerMole, MolarMassUnit.MilligramPerMole, quantity => new MolarMass((quantity.Value*1e3) / 1e-3d, MolarMassUnit.MilligramPerMole)); unitConverter.SetConversionFunction(MolarMassUnit.KilogramPerMole, MolarMassUnit.NanogramPerMole, quantity => new MolarMass((quantity.Value*1e3) / 1e-9d, MolarMassUnit.NanogramPerMole)); unitConverter.SetConversionFunction(MolarMassUnit.KilogramPerMole, MolarMassUnit.PoundPerMole, quantity => new MolarMass(quantity.Value/0.45359237, MolarMassUnit.PoundPerMole)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MolarMassUnit.KilogramPerMole, MolarMassUnit.KilogramPerMole, quantity => quantity); @@ -312,7 +283,7 @@ public static string GetAbbreviation(MolarMassUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarMassUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -495,7 +466,7 @@ public static MolarMass Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static MolarMass Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -526,7 +497,7 @@ public static bool TryParse(string? str, out MolarMass result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out MolarMass result) { return QuantityParser.Default.TryParse( @@ -554,7 +525,7 @@ public static MolarMassUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -580,7 +551,7 @@ public static bool TryParseUnit(string str, out MolarMassUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarMassUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -660,20 +631,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarMass left, MolarMass right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarMass left, MolarMass right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -689,23 +646,6 @@ public int CompareTo(MolarMass other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is MolarMass objMolarMass)) - return false; - - return Equals(objMolarMass); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarMass other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another MolarMass within the given absolute or relative tolerance. @@ -897,7 +837,7 @@ private double GetValueAs(MolarMassUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -916,63 +856,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1054,8 +960,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarMassUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return MolarMass.QuantityType; else if(conversionType == typeof(QuantityInfo)) return MolarMass.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 3768ed7fd4..40a2bfc2b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Molar_concentration /// [DataContract] - public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Molarity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -74,7 +73,7 @@ static Molarity() new UnitInfo(MolarityUnit.NanomolesPerLiter, "NanomolesPerLiter", BaseUnits.Undefined), new UnitInfo(MolarityUnit.PicomolesPerLiter, "PicomolesPerLiter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Molarity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -87,9 +86,6 @@ static Molarity() /// If value is NaN or Infinity. public Molarity(double value, MolarityUnit unit) { - if(unit == MolarityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -133,24 +129,6 @@ public Molarity(double value, UnitSystem unitSystem) /// public static MolarityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Molarity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Molarity MaxValue { get; } - - /// - /// Represents the smallest possible value of Molarity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Molarity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Molarity quantity. /// @@ -181,12 +159,6 @@ public Molarity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Molarity; - /// /// The of this quantity. /// @@ -254,7 +226,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(MolarityUnit.MolesPerCubicMeter, MolarityUnit.MolesPerLiter, quantity => new Molarity(quantity.Value*1e-3, MolarityUnit.MolesPerLiter)); unitConverter.SetConversionFunction(MolarityUnit.MolesPerCubicMeter, MolarityUnit.NanomolesPerLiter, quantity => new Molarity((quantity.Value*1e-3) / 1e-9d, MolarityUnit.NanomolesPerLiter)); unitConverter.SetConversionFunction(MolarityUnit.MolesPerCubicMeter, MolarityUnit.PicomolesPerLiter, quantity => new Molarity((quantity.Value*1e-3) / 1e-12d, MolarityUnit.PicomolesPerLiter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(MolarityUnit.MolesPerCubicMeter, MolarityUnit.MolesPerCubicMeter, quantity => quantity); @@ -283,7 +254,7 @@ public static string GetAbbreviation(MolarityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(MolarityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -430,7 +401,7 @@ public static Molarity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Molarity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -461,7 +432,7 @@ public static bool TryParse(string? str, out Molarity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Molarity result) { return QuantityParser.Default.TryParse( @@ -489,7 +460,7 @@ public static MolarityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -515,7 +486,7 @@ public static bool TryParseUnit(string str, out MolarityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out MolarityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -595,20 +566,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Molarity left, Molarity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Molarity left, Molarity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -624,23 +581,6 @@ public int CompareTo(Molarity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Molarity objMolarity)) - return false; - - return Equals(objMolarity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Molarity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Molarity within the given absolute or relative tolerance. @@ -832,7 +772,7 @@ private double GetValueAs(MolarityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -851,63 +791,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -989,8 +895,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(MolarityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Molarity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Molarity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 9a747267fe..dea8ebf24a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) /// [DataContract] - public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permeability : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static Permeability() { new UnitInfo(PermeabilityUnit.HenryPerMeter, "HenriesPerMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Permeability); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static Permeability() /// If value is NaN or Infinity. public Permeability(double value, PermeabilityUnit unit) { - if(unit == PermeabilityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public Permeability(double value, UnitSystem unitSystem) /// public static PermeabilityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Permeability - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permeability MaxValue { get; } - - /// - /// Represents the smallest possible value of Permeability - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permeability MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Permeability quantity. /// @@ -174,12 +152,6 @@ public Permeability(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Permeability; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public Permeability(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PermeabilityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PermeabilityUnit.HenryPerMeter, PermeabilityUnit.HenryPerMeter, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(PermeabilityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PermeabilityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static Permeability Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Permeability Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out Permeability result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Permeability result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static PermeabilityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out PermeabilityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PermeabilityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permeability left, Permeability right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permeability left, Permeability right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(Permeability other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Permeability objPermeability)) - return false; - - return Equals(objPermeability); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permeability other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Permeability within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(PermeabilityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PermeabilityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Permeability.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Permeability.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index fbb77f2c71..f5482b8d24 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permittivity /// [DataContract] - public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permittivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static Permittivity() { new UnitInfo(PermittivityUnit.FaradPerMeter, "FaradsPerMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Permittivity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static Permittivity() /// If value is NaN or Infinity. public Permittivity(double value, PermittivityUnit unit) { - if(unit == PermittivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public Permittivity(double value, UnitSystem unitSystem) /// public static PermittivityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Permittivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permittivity MaxValue { get; } - - /// - /// Represents the smallest possible value of Permittivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Permittivity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Permittivity quantity. /// @@ -174,12 +152,6 @@ public Permittivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Permittivity; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public Permittivity(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PermittivityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PermittivityUnit.FaradPerMeter, PermittivityUnit.FaradPerMeter, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(PermittivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PermittivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static Permittivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Permittivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out Permittivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Permittivity result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static PermittivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out PermittivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PermittivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permittivity left, Permittivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permittivity left, Permittivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(Permittivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Permittivity objPermittivity)) - return false; - - return Equals(objPermittivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permittivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Permittivity within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(PermittivityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PermittivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Permittivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Permittivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 1cd5ca7258..4a06e70d5d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. /// [DataContract] - public partial struct Power : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Power : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -88,7 +87,7 @@ static Power() new UnitInfo(PowerUnit.Terawatt, "Terawatts", BaseUnits.Undefined), new UnitInfo(PowerUnit.Watt, "Watts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Power); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -101,9 +100,6 @@ static Power() /// If value is NaN or Infinity. public Power(decimal value, PowerUnit unit) { - if(unit == PowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = value; _unit = unit; } @@ -147,24 +143,6 @@ public Power(decimal value, UnitSystem unitSystem) /// public static PowerUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Power - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Power MaxValue { get; } - - /// - /// Represents the smallest possible value of Power - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Power MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Power quantity. /// @@ -200,12 +178,6 @@ public Power(decimal value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Power; - /// /// The of this quantity. /// @@ -375,7 +347,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Petawatt, quantity => new Power((quantity.Value) / 1e15m, PowerUnit.Petawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Picowatt, quantity => new Power((quantity.Value) / 1e-12m, PowerUnit.Picowatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Terawatt, quantity => new Power((quantity.Value) / 1e12m, PowerUnit.Terawatt)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Watt, quantity => quantity); @@ -421,7 +392,7 @@ public static string GetAbbreviation(PowerUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -721,7 +692,7 @@ public static Power Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Power Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -752,7 +723,7 @@ public static bool TryParse(string? str, out Power result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Power result) { return QuantityParser.Default.TryParse( @@ -780,7 +751,7 @@ public static PowerUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -806,7 +777,7 @@ public static bool TryParseUnit(string str, out PowerUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PowerUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -886,20 +857,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Power left, Power right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Power left, Power right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -915,23 +872,6 @@ public int CompareTo(Power other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Power objPower)) - return false; - - return Equals(objPower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Power other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Power within the given absolute or relative tolerance. @@ -1123,7 +1063,7 @@ private decimal GetValueAs(PowerUnit unit) { var converted = ToUnit(unit); return (decimal)converted.Value; - } + } #endregion @@ -1142,63 +1082,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1280,8 +1186,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PowerUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Power.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Power.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index f461a7aab0..e76fb7e8f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The amount of power in a volume. /// [DataContract] - public partial struct PowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -107,7 +106,7 @@ static PowerDensity() new UnitInfo(PowerDensityUnit.WattPerCubicMeter, "WattsPerCubicMeter", new BaseUnits(length: LengthUnit.Meter, mass: MassUnit.Kilogram, time: DurationUnit.Second)), new UnitInfo(PowerDensityUnit.WattPerLiter, "WattsPerLiter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.PowerDensity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -120,9 +119,6 @@ static PowerDensity() /// If value is NaN or Infinity. public PowerDensity(double value, PowerDensityUnit unit) { - if(unit == PowerDensityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -166,24 +162,6 @@ public PowerDensity(double value, UnitSystem unitSystem) /// public static PowerDensityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of PowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerDensity MaxValue { get; } - - /// - /// Represents the smallest possible value of PowerDensity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerDensity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the PowerDensity quantity. /// @@ -214,12 +192,6 @@ public PowerDensity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.PowerDensity; - /// /// The of this quantity. /// @@ -503,7 +475,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicFoot, quantity => new PowerDensity(quantity.Value/3.531466672148859e1, PowerDensityUnit.WattPerCubicFoot)); unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicInch, quantity => new PowerDensity(quantity.Value/6.102374409473228e4, PowerDensityUnit.WattPerCubicInch)); unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerLiter, quantity => new PowerDensity(quantity.Value/1.0e3, PowerDensityUnit.WattPerLiter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PowerDensityUnit.WattPerCubicMeter, PowerDensityUnit.WattPerCubicMeter, quantity => quantity); @@ -568,7 +539,7 @@ public static string GetAbbreviation(PowerDensityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PowerDensityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1039,7 +1010,7 @@ public static PowerDensity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static PowerDensity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1070,7 +1041,7 @@ public static bool TryParse(string? str, out PowerDensity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out PowerDensity result) { return QuantityParser.Default.TryParse( @@ -1098,7 +1069,7 @@ public static PowerDensityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1124,7 +1095,7 @@ public static bool TryParseUnit(string str, out PowerDensityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PowerDensityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1204,20 +1175,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerDensity left, PowerDensity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerDensity left, PowerDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1233,23 +1190,6 @@ public int CompareTo(PowerDensity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is PowerDensity objPowerDensity)) - return false; - - return Equals(objPowerDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerDensity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another PowerDensity within the given absolute or relative tolerance. @@ -1441,7 +1381,7 @@ private double GetValueAs(PowerDensityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1460,63 +1400,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1598,8 +1504,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PowerDensityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return PowerDensity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return PowerDensity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index 94317bac25..d21924252a 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one watt. /// [DataContract] - public partial struct PowerRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -65,7 +64,7 @@ static PowerRatio() new UnitInfo(PowerRatioUnit.DecibelMilliwatt, "DecibelMilliwatts", BaseUnits.Undefined), new UnitInfo(PowerRatioUnit.DecibelWatt, "DecibelWatts", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.PowerRatio); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -78,9 +77,6 @@ static PowerRatio() /// If value is NaN or Infinity. public PowerRatio(double value, PowerRatioUnit unit) { - if(unit == PowerRatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,24 +120,6 @@ public PowerRatio(double value, UnitSystem unitSystem) /// public static PowerRatioUnit BaseUnit { get; } - /// - /// Represents the largest possible value of PowerRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerRatio MaxValue { get; } - - /// - /// Represents the smallest possible value of PowerRatio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PowerRatio MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the PowerRatio quantity. /// @@ -172,12 +150,6 @@ public PowerRatio(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.PowerRatio; - /// /// The of this quantity. /// @@ -209,7 +181,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PowerRatioUnit unitConverter.SetConversionFunction(PowerRatioUnit.DecibelWatt, PowerRatioUnit.DecibelMilliwatt, quantity => new PowerRatio(quantity.Value + 30, PowerRatioUnit.DecibelMilliwatt)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PowerRatioUnit.DecibelWatt, PowerRatioUnit.DecibelWatt, quantity => quantity); @@ -232,7 +203,7 @@ public static string GetAbbreviation(PowerRatioUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PowerRatioUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -325,7 +296,7 @@ public static PowerRatio Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static PowerRatio Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -356,7 +327,7 @@ public static bool TryParse(string? str, out PowerRatio result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out PowerRatio result) { return QuantityParser.Default.TryParse( @@ -384,7 +355,7 @@ public static PowerRatioUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -410,7 +381,7 @@ public static bool TryParseUnit(string str, out PowerRatioUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PowerRatioUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -498,20 +469,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerRatio left, PowerRatio right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerRatio left, PowerRatio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -527,23 +484,6 @@ public int CompareTo(PowerRatio other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is PowerRatio objPowerRatio)) - return false; - - return Equals(objPowerRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerRatio other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another PowerRatio within the given absolute or relative tolerance. @@ -735,7 +675,7 @@ private double GetValueAs(PowerRatioUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -754,63 +694,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -892,8 +798,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PowerRatioUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return PowerRatio.QuantityType; else if(conversionType == typeof(QuantityInfo)) return PowerRatio.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 2939d0d85e..5a63f826de 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). /// [DataContract] - public partial struct Pressure : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Pressure : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -108,7 +107,7 @@ static Pressure() new UnitInfo(PressureUnit.TonneForcePerSquareMillimeter, "TonnesForcePerSquareMillimeter", BaseUnits.Undefined), new UnitInfo(PressureUnit.Torr, "Torrs", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Pressure); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -121,9 +120,6 @@ static Pressure() /// If value is NaN or Infinity. public Pressure(double value, PressureUnit unit) { - if(unit == PressureUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -167,24 +163,6 @@ public Pressure(double value, UnitSystem unitSystem) /// public static PressureUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Pressure - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Pressure MaxValue { get; } - - /// - /// Represents the smallest possible value of Pressure - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Pressure MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Pressure quantity. /// @@ -215,12 +193,6 @@ public Pressure(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Pressure; - /// /// The of this quantity. /// @@ -510,7 +482,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.TonneForcePerSquareMeter, quantity => new Pressure(quantity.Value/9.80665e3, PressureUnit.TonneForcePerSquareMeter)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.TonneForcePerSquareMillimeter, quantity => new Pressure(quantity.Value/9.80665e9, PressureUnit.TonneForcePerSquareMillimeter)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Torr, quantity => new Pressure(quantity.Value/(1.3332266752*1e2), PressureUnit.Torr)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Pascal, quantity => quantity); @@ -576,7 +547,7 @@ public static string GetAbbreviation(PressureUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PressureUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1056,7 +1027,7 @@ public static Pressure Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Pressure Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1087,7 +1058,7 @@ public static bool TryParse(string? str, out Pressure result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Pressure result) { return QuantityParser.Default.TryParse( @@ -1115,7 +1086,7 @@ public static PressureUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1141,7 +1112,7 @@ public static bool TryParseUnit(string str, out PressureUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PressureUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1221,20 +1192,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Pressure left, Pressure right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Pressure left, Pressure right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1250,23 +1207,6 @@ public int CompareTo(Pressure other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Pressure objPressure)) - return false; - - return Equals(objPressure); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Pressure other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Pressure within the given absolute or relative tolerance. @@ -1458,7 +1398,7 @@ private double GetValueAs(PressureUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1477,63 +1417,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1615,8 +1521,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PressureUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Pressure.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Pressure.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 8349035ece..fea3058817 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). /// [DataContract] - public partial struct PressureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PressureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -77,7 +76,7 @@ static PressureChangeRate() new UnitInfo(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, "PoundsForcePerSquareInchPerMinute", BaseUnits.Undefined), new UnitInfo(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, "PoundsForcePerSquareInchPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.PressureChangeRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -90,9 +89,6 @@ static PressureChangeRate() /// If value is NaN or Infinity. public PressureChangeRate(double value, PressureChangeRateUnit unit) { - if(unit == PressureChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -136,24 +132,6 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// public static PressureChangeRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of PressureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PressureChangeRate MaxValue { get; } - - /// - /// Represents the smallest possible value of PressureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static PressureChangeRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the PressureChangeRate quantity. /// @@ -184,12 +162,6 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.PressureChangeRate; - /// /// The of this quantity. /// @@ -293,7 +265,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PascalPerMinute, quantity => new PressureChangeRate(quantity.Value*60, PressureChangeRateUnit.PascalPerMinute)); unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute, quantity => new PressureChangeRate(quantity.Value/6.894757293168361e3*60, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute)); unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond, quantity => new PressureChangeRate(quantity.Value/6.894757293168361e3, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(PressureChangeRateUnit.PascalPerSecond, PressureChangeRateUnit.PascalPerSecond, quantity => quantity); @@ -328,7 +299,7 @@ public static string GetAbbreviation(PressureChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(PressureChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -529,7 +500,7 @@ public static PressureChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static PressureChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -560,7 +531,7 @@ public static bool TryParse(string? str, out PressureChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out PressureChangeRate result) { return QuantityParser.Default.TryParse( @@ -588,7 +559,7 @@ public static PressureChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -614,7 +585,7 @@ public static bool TryParseUnit(string str, out PressureChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out PressureChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -694,20 +665,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PressureChangeRate left, PressureChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PressureChangeRate left, PressureChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -723,23 +680,6 @@ public int CompareTo(PressureChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is PressureChangeRate objPressureChangeRate)) - return false; - - return Equals(objPressureChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PressureChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another PressureChangeRate within the given absolute or relative tolerance. @@ -931,7 +871,7 @@ private double GetValueAs(PressureChangeRateUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -950,63 +890,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1088,8 +994,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(PressureChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return PressureChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return PressureChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 160a6aea25..3617781297 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). /// [DataContract] - public partial struct Ratio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Ratio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static Ratio() new UnitInfo(RatioUnit.PartPerTrillion, "PartsPerTrillion", BaseUnits.Undefined), new UnitInfo(RatioUnit.Percent, "Percent", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Ratio); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static Ratio() /// If value is NaN or Infinity. public Ratio(double value, RatioUnit unit) { - if(unit == RatioUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public Ratio(double value, UnitSystem unitSystem) /// public static RatioUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Ratio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Ratio MaxValue { get; } - - /// - /// Represents the smallest possible value of Ratio - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Ratio MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Ratio quantity. /// @@ -176,12 +154,6 @@ public Ratio(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Ratio; - /// /// The of this quantity. /// @@ -237,7 +209,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(RatioUnit.DecimalFraction, RatioUnit.PartPerThousand, quantity => new Ratio(quantity.Value*1e3, RatioUnit.PartPerThousand)); unitConverter.SetConversionFunction(RatioUnit.DecimalFraction, RatioUnit.PartPerTrillion, quantity => new Ratio(quantity.Value*1e12, RatioUnit.PartPerTrillion)); unitConverter.SetConversionFunction(RatioUnit.DecimalFraction, RatioUnit.Percent, quantity => new Ratio(quantity.Value*1e2, RatioUnit.Percent)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RatioUnit.DecimalFraction, RatioUnit.DecimalFraction, quantity => quantity); @@ -264,7 +235,7 @@ public static string GetAbbreviation(RatioUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RatioUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -393,7 +364,7 @@ public static Ratio Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Ratio Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -424,7 +395,7 @@ public static bool TryParse(string? str, out Ratio result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Ratio result) { return QuantityParser.Default.TryParse( @@ -452,7 +423,7 @@ public static RatioUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -478,7 +449,7 @@ public static bool TryParseUnit(string str, out RatioUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RatioUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -558,20 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Ratio left, Ratio right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Ratio left, Ratio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -587,23 +544,6 @@ public int CompareTo(Ratio other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Ratio objRatio)) - return false; - - return Equals(objRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Ratio other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Ratio within the given absolute or relative tolerance. @@ -795,7 +735,7 @@ private double GetValueAs(RatioUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -814,63 +754,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -952,8 +858,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RatioUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Ratio.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Ratio.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 4fa52a2934..1e81d0ca03 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The change in ratio per unit of time. /// [DataContract] - public partial struct RatioChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RatioChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -65,7 +64,7 @@ static RatioChangeRate() new UnitInfo(RatioChangeRateUnit.DecimalFractionPerSecond, "DecimalFractionsPerSecond", BaseUnits.Undefined), new UnitInfo(RatioChangeRateUnit.PercentPerSecond, "PercentsPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RatioChangeRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -78,9 +77,6 @@ static RatioChangeRate() /// If value is NaN or Infinity. public RatioChangeRate(double value, RatioChangeRateUnit unit) { - if(unit == RatioChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,24 +120,6 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// public static RatioChangeRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of RatioChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RatioChangeRate MaxValue { get; } - - /// - /// Represents the smallest possible value of RatioChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RatioChangeRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the RatioChangeRate quantity. /// @@ -172,12 +150,6 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.RatioChangeRate; - /// /// The of this quantity. /// @@ -209,7 +181,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> RatioChangeRateUnit unitConverter.SetConversionFunction(RatioChangeRateUnit.DecimalFractionPerSecond, RatioChangeRateUnit.PercentPerSecond, quantity => new RatioChangeRate(quantity.Value*1e2, RatioChangeRateUnit.PercentPerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RatioChangeRateUnit.DecimalFractionPerSecond, RatioChangeRateUnit.DecimalFractionPerSecond, quantity => quantity); @@ -232,7 +203,7 @@ public static string GetAbbreviation(RatioChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RatioChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -325,7 +296,7 @@ public static RatioChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RatioChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -356,7 +327,7 @@ public static bool TryParse(string? str, out RatioChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RatioChangeRate result) { return QuantityParser.Default.TryParse( @@ -384,7 +355,7 @@ public static RatioChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -410,7 +381,7 @@ public static bool TryParseUnit(string str, out RatioChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RatioChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -490,20 +461,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RatioChangeRate left, RatioChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RatioChangeRate left, RatioChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -519,23 +476,6 @@ public int CompareTo(RatioChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RatioChangeRate objRatioChangeRate)) - return false; - - return Equals(objRatioChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RatioChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RatioChangeRate within the given absolute or relative tolerance. @@ -727,7 +667,7 @@ private double GetValueAs(RatioChangeRateUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -746,63 +686,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -884,8 +790,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RatioChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RatioChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RatioChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index 3d199f5c00..a7a23c6703 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. /// [DataContract] - public partial struct ReactiveEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactiveEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static ReactiveEnergy() new UnitInfo(ReactiveEnergyUnit.MegavoltampereReactiveHour, "MegavoltampereReactiveHours", BaseUnits.Undefined), new UnitInfo(ReactiveEnergyUnit.VoltampereReactiveHour, "VoltampereReactiveHours", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReactiveEnergy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static ReactiveEnergy() /// If value is NaN or Infinity. public ReactiveEnergy(double value, ReactiveEnergyUnit unit) { - if(unit == ReactiveEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// public static ReactiveEnergyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ReactiveEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactiveEnergy MaxValue { get; } - - /// - /// Represents the smallest possible value of ReactiveEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactiveEnergy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ReactiveEnergy quantity. /// @@ -173,12 +151,6 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ReactiveEnergy; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> ReactiveEnergyUnit unitConverter.SetConversionFunction(ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.KilovoltampereReactiveHour, quantity => new ReactiveEnergy((quantity.Value) / 1e3d, ReactiveEnergyUnit.KilovoltampereReactiveHour)); unitConverter.SetConversionFunction(ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.MegavoltampereReactiveHour, quantity => new ReactiveEnergy((quantity.Value) / 1e6d, ReactiveEnergyUnit.MegavoltampereReactiveHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ReactiveEnergyUnit.VoltampereReactiveHour, ReactiveEnergyUnit.VoltampereReactiveHour, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(ReactiveEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReactiveEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static ReactiveEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReactiveEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out ReactiveEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReactiveEnergy result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static ReactiveEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out ReactiveEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReactiveEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(ReactiveEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) - return false; - - return Equals(objReactiveEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactiveEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReactiveEnergy within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(ReactiveEnergyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReactiveEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReactiveEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReactiveEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 2bcb0c60a8..bad065ccbf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. /// [DataContract] - public partial struct ReactivePower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactivePower : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static ReactivePower() new UnitInfo(ReactivePowerUnit.MegavoltampereReactive, "MegavoltamperesReactive", BaseUnits.Undefined), new UnitInfo(ReactivePowerUnit.VoltampereReactive, "VoltamperesReactive", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReactivePower); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static ReactivePower() /// If value is NaN or Infinity. public ReactivePower(double value, ReactivePowerUnit unit) { - if(unit == ReactivePowerUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public ReactivePower(double value, UnitSystem unitSystem) /// public static ReactivePowerUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ReactivePower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactivePower MaxValue { get; } - - /// - /// Represents the smallest possible value of ReactivePower - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReactivePower MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ReactivePower quantity. /// @@ -174,12 +152,6 @@ public ReactivePower(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ReactivePower; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.GigavoltampereReactive, quantity => new ReactivePower((quantity.Value) / 1e9d, ReactivePowerUnit.GigavoltampereReactive)); unitConverter.SetConversionFunction(ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.KilovoltampereReactive, quantity => new ReactivePower((quantity.Value) / 1e3d, ReactivePowerUnit.KilovoltampereReactive)); unitConverter.SetConversionFunction(ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.MegavoltampereReactive, quantity => new ReactivePower((quantity.Value) / 1e6d, ReactivePowerUnit.MegavoltampereReactive)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ReactivePowerUnit.VoltampereReactive, ReactivePowerUnit.VoltampereReactive, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(ReactivePowerUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReactivePowerUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static ReactivePower Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReactivePower Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out ReactivePower result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReactivePower result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static ReactivePowerUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out ReactivePowerUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReactivePowerUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -524,20 +495,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactivePower left, ReactivePower right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactivePower left, ReactivePower right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -553,23 +510,6 @@ public int CompareTo(ReactivePower other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReactivePower objReactivePower)) - return false; - - return Equals(objReactivePower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactivePower other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReactivePower within the given absolute or relative tolerance. @@ -761,7 +701,7 @@ private double GetValueAs(ReactivePowerUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -780,63 +720,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -918,8 +824,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReactivePowerUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReactivePower.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReactivePower.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index 09cb2b475d..b14ce2bb70 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inverse-square_law /// [DataContract] - public partial struct ReciprocalArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -77,7 +76,7 @@ static ReciprocalArea() new UnitInfo(ReciprocalAreaUnit.InverseSquareYard, "InverseSquareYards", BaseUnits.Undefined), new UnitInfo(ReciprocalAreaUnit.InverseUsSurveySquareFoot, "InverseUsSurveySquareFeet", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalArea); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -90,9 +89,6 @@ static ReciprocalArea() /// If value is NaN or Infinity. public ReciprocalArea(double value, ReciprocalAreaUnit unit) { - if(unit == ReciprocalAreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -136,24 +132,6 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// public static ReciprocalAreaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ReciprocalArea - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalArea MaxValue { get; } - - /// - /// Represents the smallest possible value of ReciprocalArea - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalArea MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ReciprocalArea quantity. /// @@ -184,12 +162,6 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ReciprocalArea; - /// /// The of this quantity. /// @@ -275,7 +247,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMillimeter, quantity => new ReciprocalArea(quantity.Value*1e-6, ReciprocalAreaUnit.InverseSquareMillimeter)); unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareYard, quantity => new ReciprocalArea(quantity.Value*0.836127, ReciprocalAreaUnit.InverseSquareYard)); unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseUsSurveySquareFoot, quantity => new ReciprocalArea(quantity.Value*0.09290341161, ReciprocalAreaUnit.InverseUsSurveySquareFoot)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ReciprocalAreaUnit.InverseSquareMeter, ReciprocalAreaUnit.InverseSquareMeter, quantity => quantity); @@ -307,7 +278,7 @@ public static string GetAbbreviation(ReciprocalAreaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReciprocalAreaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -481,7 +452,7 @@ public static ReciprocalArea Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReciprocalArea Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -512,7 +483,7 @@ public static bool TryParse(string? str, out ReciprocalArea result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReciprocalArea result) { return QuantityParser.Default.TryParse( @@ -540,7 +511,7 @@ public static ReciprocalAreaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -566,7 +537,7 @@ public static bool TryParseUnit(string str, out ReciprocalAreaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReciprocalAreaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -646,20 +617,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReciprocalArea left, ReciprocalArea right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReciprocalArea left, ReciprocalArea right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -675,23 +632,6 @@ public int CompareTo(ReciprocalArea other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReciprocalArea objReciprocalArea)) - return false; - - return Equals(objReciprocalArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReciprocalArea other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReciprocalArea within the given absolute or relative tolerance. @@ -883,7 +823,7 @@ private double GetValueAs(ReciprocalAreaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -902,63 +842,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1040,8 +946,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReciprocalAreaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReciprocalArea.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReciprocalArea.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 2d5290337b..5d77f2feaf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Reciprocal_length /// [DataContract] - public partial struct ReciprocalLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -76,7 +75,7 @@ static ReciprocalLength() new UnitInfo(ReciprocalLengthUnit.InverseUsSurveyFoot, "InverseUsSurveyFeet", BaseUnits.Undefined), new UnitInfo(ReciprocalLengthUnit.InverseYard, "InverseYards", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ReciprocalLength); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -89,9 +88,6 @@ static ReciprocalLength() /// If value is NaN or Infinity. public ReciprocalLength(double value, ReciprocalLengthUnit unit) { - if(unit == ReciprocalLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -135,24 +131,6 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// public static ReciprocalLengthUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ReciprocalLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalLength MaxValue { get; } - - /// - /// Represents the smallest possible value of ReciprocalLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ReciprocalLength MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ReciprocalLength quantity. /// @@ -183,12 +161,6 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ReciprocalLength; - /// /// The of this quantity. /// @@ -268,7 +240,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMillimeter, quantity => new ReciprocalLength(quantity.Value/1e3, ReciprocalLengthUnit.InverseMillimeter)); unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseUsSurveyFoot, quantity => new ReciprocalLength(quantity.Value*1200/3937, ReciprocalLengthUnit.InverseUsSurveyFoot)); unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseYard, quantity => new ReciprocalLength(quantity.Value*0.9144, ReciprocalLengthUnit.InverseYard)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ReciprocalLengthUnit.InverseMeter, ReciprocalLengthUnit.InverseMeter, quantity => quantity); @@ -299,7 +270,7 @@ public static string GetAbbreviation(ReciprocalLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ReciprocalLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -464,7 +435,7 @@ public static ReciprocalLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ReciprocalLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -495,7 +466,7 @@ public static bool TryParse(string? str, out ReciprocalLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ReciprocalLength result) { return QuantityParser.Default.TryParse( @@ -523,7 +494,7 @@ public static ReciprocalLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -549,7 +520,7 @@ public static bool TryParseUnit(string str, out ReciprocalLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ReciprocalLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -629,20 +600,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReciprocalLength left, ReciprocalLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReciprocalLength left, ReciprocalLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -658,23 +615,6 @@ public int CompareTo(ReciprocalLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ReciprocalLength objReciprocalLength)) - return false; - - return Equals(objReciprocalLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReciprocalLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ReciprocalLength within the given absolute or relative tolerance. @@ -866,7 +806,7 @@ private double GetValueAs(ReciprocalLengthUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -885,63 +825,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1023,8 +929,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ReciprocalLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ReciprocalLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ReciprocalLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index cac5aa4717..7b7c78084c 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. /// [DataContract] - public partial struct RelativeHumidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RelativeHumidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -64,7 +63,7 @@ static RelativeHumidity() { new UnitInfo(RelativeHumidityUnit.Percent, "Percent", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RelativeHumidity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -77,9 +76,6 @@ static RelativeHumidity() /// If value is NaN or Infinity. public RelativeHumidity(double value, RelativeHumidityUnit unit) { - if(unit == RelativeHumidityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,24 +119,6 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// public static RelativeHumidityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of RelativeHumidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RelativeHumidity MaxValue { get; } - - /// - /// Represents the smallest possible value of RelativeHumidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RelativeHumidity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the RelativeHumidity quantity. /// @@ -171,12 +149,6 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.RelativeHumidity; - /// /// The of this quantity. /// @@ -202,7 +174,6 @@ public RelativeHumidity(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> RelativeHumidityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RelativeHumidityUnit.Percent, RelativeHumidityUnit.Percent, quantity => quantity); @@ -224,7 +195,7 @@ public static string GetAbbreviation(RelativeHumidityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RelativeHumidityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -308,7 +279,7 @@ public static RelativeHumidity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RelativeHumidity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -339,7 +310,7 @@ public static bool TryParse(string? str, out RelativeHumidity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RelativeHumidity result) { return QuantityParser.Default.TryParse( @@ -367,7 +338,7 @@ public static RelativeHumidityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -393,7 +364,7 @@ public static bool TryParseUnit(string str, out RelativeHumidityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RelativeHumidityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -473,20 +444,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RelativeHumidity left, RelativeHumidity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RelativeHumidity left, RelativeHumidity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -502,23 +459,6 @@ public int CompareTo(RelativeHumidity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RelativeHumidity objRelativeHumidity)) - return false; - - return Equals(objRelativeHumidity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RelativeHumidity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RelativeHumidity within the given absolute or relative tolerance. @@ -710,7 +650,7 @@ private double GetValueAs(RelativeHumidityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -729,63 +669,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -867,8 +773,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RelativeHumidityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RelativeHumidity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RelativeHumidity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 9f6fcecc94..dc055946b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Angular acceleration is the rate of change of rotational speed. /// [DataContract] - public partial struct RotationalAcceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalAcceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static RotationalAcceleration() new UnitInfo(RotationalAccelerationUnit.RevolutionPerMinutePerSecond, "RevolutionsPerMinutePerSecond", BaseUnits.Undefined), new UnitInfo(RotationalAccelerationUnit.RevolutionPerSecondSquared, "RevolutionsPerSecondSquared", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalAcceleration); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static RotationalAcceleration() /// If value is NaN or Infinity. public RotationalAcceleration(double value, RotationalAccelerationUnit unit) { - if(unit == RotationalAccelerationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// public static RotationalAccelerationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of RotationalAcceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalAcceleration MaxValue { get; } - - /// - /// Represents the smallest possible value of RotationalAcceleration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalAcceleration MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the RotationalAcceleration quantity. /// @@ -174,12 +152,6 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.RotationalAcceleration; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.DegreePerSecondSquared, quantity => new RotationalAcceleration((180/Math.PI)*quantity.Value, RotationalAccelerationUnit.DegreePerSecondSquared)); unitConverter.SetConversionFunction(RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RevolutionPerMinutePerSecond, quantity => new RotationalAcceleration((60/(2*Math.PI))*quantity.Value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond)); unitConverter.SetConversionFunction(RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RevolutionPerSecondSquared, quantity => new RotationalAcceleration((1/(2*Math.PI))*quantity.Value, RotationalAccelerationUnit.RevolutionPerSecondSquared)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RotationalAccelerationUnit.RadianPerSecondSquared, RotationalAccelerationUnit.RadianPerSecondSquared, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(RotationalAccelerationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalAccelerationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static RotationalAcceleration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalAcceleration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out RotationalAcceleration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalAcceleration result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static RotationalAccelerationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out RotationalAccelerationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalAccelerationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -524,20 +495,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -553,23 +510,6 @@ public int CompareTo(RotationalAcceleration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) - return false; - - return Equals(objRotationalAcceleration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalAcceleration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalAcceleration within the given absolute or relative tolerance. @@ -761,7 +701,7 @@ private double GetValueAs(RotationalAccelerationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -780,63 +720,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -918,8 +824,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalAccelerationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalAcceleration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalAcceleration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index ee44a12cc9..5143f39ea1 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). /// [DataContract] - public partial struct RotationalSpeed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalSpeed : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -76,7 +75,7 @@ static RotationalSpeed() new UnitInfo(RotationalSpeedUnit.RevolutionPerMinute, "RevolutionsPerMinute", BaseUnits.Undefined), new UnitInfo(RotationalSpeedUnit.RevolutionPerSecond, "RevolutionsPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalSpeed); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -89,9 +88,6 @@ static RotationalSpeed() /// If value is NaN or Infinity. public RotationalSpeed(double value, RotationalSpeedUnit unit) { - if(unit == RotationalSpeedUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -135,24 +131,6 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// public static RotationalSpeedUnit BaseUnit { get; } - /// - /// Represents the largest possible value of RotationalSpeed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalSpeed MaxValue { get; } - - /// - /// Represents the smallest possible value of RotationalSpeed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalSpeed MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the RotationalSpeed quantity. /// @@ -183,12 +161,6 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.RotationalSpeed; - /// /// The of this quantity. /// @@ -286,7 +258,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.NanoradianPerSecond, quantity => new RotationalSpeed((quantity.Value) / 1e-9d, RotationalSpeedUnit.NanoradianPerSecond)); unitConverter.SetConversionFunction(RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RevolutionPerMinute, quantity => new RotationalSpeed((quantity.Value/6.2831853072)*60, RotationalSpeedUnit.RevolutionPerMinute)); unitConverter.SetConversionFunction(RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RevolutionPerSecond, quantity => new RotationalSpeed(quantity.Value/6.2831853072, RotationalSpeedUnit.RevolutionPerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RotationalSpeedUnit.RadianPerSecond, RotationalSpeedUnit.RadianPerSecond, quantity => quantity); @@ -320,7 +291,7 @@ public static string GetAbbreviation(RotationalSpeedUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalSpeedUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -512,7 +483,7 @@ public static RotationalSpeed Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalSpeed Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -543,7 +514,7 @@ public static bool TryParse(string? str, out RotationalSpeed result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalSpeed result) { return QuantityParser.Default.TryParse( @@ -571,7 +542,7 @@ public static RotationalSpeedUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -597,7 +568,7 @@ public static bool TryParseUnit(string str, out RotationalSpeedUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalSpeedUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -677,20 +648,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalSpeed left, RotationalSpeed right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalSpeed left, RotationalSpeed right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -706,23 +663,6 @@ public int CompareTo(RotationalSpeed other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalSpeed objRotationalSpeed)) - return false; - - return Equals(objRotationalSpeed); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalSpeed other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalSpeed within the given absolute or relative tolerance. @@ -914,7 +854,7 @@ private double GetValueAs(RotationalSpeedUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -933,63 +873,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1071,8 +977,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalSpeedUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalSpeed.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalSpeed.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index b9e10d468f..a8083db4b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffness : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffness : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -96,7 +95,7 @@ static RotationalStiffness() new UnitInfo(RotationalStiffnessUnit.PoundForceFeetPerRadian, "PoundForceFeetPerRadian", BaseUnits.Undefined), new UnitInfo(RotationalStiffnessUnit.PoundForceFootPerDegrees, "PoundForceFeetPerDegrees", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffness); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -109,9 +108,6 @@ static RotationalStiffness() /// If value is NaN or Infinity. public RotationalStiffness(double value, RotationalStiffnessUnit unit) { - if(unit == RotationalStiffnessUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -155,24 +151,6 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// public static RotationalStiffnessUnit BaseUnit { get; } - /// - /// Represents the largest possible value of RotationalStiffness - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffness MaxValue { get; } - - /// - /// Represents the smallest possible value of RotationalStiffness - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffness MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the RotationalStiffness quantity. /// @@ -203,12 +181,6 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.RotationalStiffness; - /// /// The of this quantity. /// @@ -426,7 +398,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMillimeterPerRadian, quantity => new RotationalStiffness(quantity.Value*1000, RotationalStiffnessUnit.NewtonMillimeterPerRadian)); unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.PoundForceFeetPerRadian, quantity => new RotationalStiffness(quantity.Value/1.3558179483314, RotationalStiffnessUnit.PoundForceFeetPerRadian)); unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.PoundForceFootPerDegrees, quantity => new RotationalStiffness(quantity.Value/77.6826, RotationalStiffnessUnit.PoundForceFootPerDegrees)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RotationalStiffnessUnit.NewtonMeterPerRadian, RotationalStiffnessUnit.NewtonMeterPerRadian, quantity => quantity); @@ -480,7 +451,7 @@ public static string GetAbbreviation(RotationalStiffnessUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalStiffnessUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -852,7 +823,7 @@ public static RotationalStiffness Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalStiffness Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -883,7 +854,7 @@ public static bool TryParse(string? str, out RotationalStiffness result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffness result) { return QuantityParser.Default.TryParse( @@ -911,7 +882,7 @@ public static RotationalStiffnessUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -937,7 +908,7 @@ public static bool TryParseUnit(string str, out RotationalStiffnessUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalStiffnessUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1017,20 +988,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffness left, RotationalStiffness right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffness left, RotationalStiffness right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1046,23 +1003,6 @@ public int CompareTo(RotationalStiffness other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalStiffness objRotationalStiffness)) - return false; - - return Equals(objRotationalStiffness); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffness other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalStiffness within the given absolute or relative tolerance. @@ -1254,7 +1194,7 @@ private double GetValueAs(RotationalStiffnessUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1273,63 +1213,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1411,8 +1317,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalStiffnessUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalStiffness.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalStiffness.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 484b312dab..abb7b6a9c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffnessPerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffnessPerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -68,7 +67,7 @@ static RotationalStiffnessPerLength() new UnitInfo(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, "NewtonMetersPerRadianPerMeter", BaseUnits.Undefined), new UnitInfo(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, "PoundForceFeetPerDegreesPerFeet", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.RotationalStiffnessPerLength); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -81,9 +80,6 @@ static RotationalStiffnessPerLength() /// If value is NaN or Infinity. public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) { - if(unit == RotationalStiffnessPerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -127,24 +123,6 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// public static RotationalStiffnessPerLengthUnit BaseUnit { get; } - /// - /// Represents the largest possible value of RotationalStiffnessPerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffnessPerLength MaxValue { get; } - - /// - /// Represents the smallest possible value of RotationalStiffnessPerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static RotationalStiffnessPerLength MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the RotationalStiffnessPerLength quantity. /// @@ -175,12 +153,6 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.RotationalStiffnessPerLength; - /// /// The of this quantity. /// @@ -230,7 +202,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot, quantity => new RotationalStiffnessPerLength(quantity.Value/254864.324570, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot)); unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter, quantity => new RotationalStiffnessPerLength((quantity.Value) / 1e6d, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter)); unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot, quantity => new RotationalStiffnessPerLength(quantity.Value/254.864324570, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter, quantity => quantity); @@ -256,7 +227,7 @@ public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -376,7 +347,7 @@ public static RotationalStiffnessPerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static RotationalStiffnessPerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -407,7 +378,7 @@ public static bool TryParse(string? str, out RotationalStiffnessPerLength result /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out RotationalStiffnessPerLength result) { return QuantityParser.Default.TryParse( @@ -435,7 +406,7 @@ public static RotationalStiffnessPerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -461,7 +432,7 @@ public static bool TryParseUnit(string str, out RotationalStiffnessPerLengthUnit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out RotationalStiffnessPerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -541,20 +512,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -570,23 +527,6 @@ public int CompareTo(RotationalStiffnessPerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) - return false; - - return Equals(objRotationalStiffnessPerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffnessPerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another RotationalStiffnessPerLength within the given absolute or relative tolerance. @@ -778,7 +718,7 @@ private double GetValueAs(RotationalStiffnessPerLengthUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -797,63 +737,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -935,8 +841,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(RotationalStiffnessPerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return RotationalStiffnessPerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return RotationalStiffnessPerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 22d5c68e1f..2eb17c6451 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A way of representing a number of items. /// [DataContract] - public partial struct Scalar : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Scalar : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -64,7 +63,7 @@ static Scalar() { new UnitInfo(ScalarUnit.Amount, "Amount", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Scalar); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -77,9 +76,6 @@ static Scalar() /// If value is NaN or Infinity. public Scalar(double value, ScalarUnit unit) { - if(unit == ScalarUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,24 +119,6 @@ public Scalar(double value, UnitSystem unitSystem) /// public static ScalarUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Scalar - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Scalar MaxValue { get; } - - /// - /// Represents the smallest possible value of Scalar - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Scalar MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Scalar quantity. /// @@ -171,12 +149,6 @@ public Scalar(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Scalar; - /// /// The of this quantity. /// @@ -202,7 +174,6 @@ public Scalar(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> ScalarUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ScalarUnit.Amount, ScalarUnit.Amount, quantity => quantity); @@ -224,7 +195,7 @@ public static string GetAbbreviation(ScalarUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ScalarUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -308,7 +279,7 @@ public static Scalar Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Scalar Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -339,7 +310,7 @@ public static bool TryParse(string? str, out Scalar result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Scalar result) { return QuantityParser.Default.TryParse( @@ -367,7 +338,7 @@ public static ScalarUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -393,7 +364,7 @@ public static bool TryParseUnit(string str, out ScalarUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ScalarUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -473,20 +444,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Scalar left, Scalar right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Scalar left, Scalar right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -502,23 +459,6 @@ public int CompareTo(Scalar other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Scalar objScalar)) - return false; - - return Equals(objScalar); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Scalar other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Scalar within the given absolute or relative tolerance. @@ -710,7 +650,7 @@ private double GetValueAs(ScalarUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -729,63 +669,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -867,8 +773,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ScalarUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Scalar.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Scalar.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 5110cf3f1f..3bd62e9397 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Solid_angle /// [DataContract] - public partial struct SolidAngle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SolidAngle : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static SolidAngle() { new UnitInfo(SolidAngleUnit.Steradian, "Steradians", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SolidAngle); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static SolidAngle() /// If value is NaN or Infinity. public SolidAngle(double value, SolidAngleUnit unit) { - if(unit == SolidAngleUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public SolidAngle(double value, UnitSystem unitSystem) /// public static SolidAngleUnit BaseUnit { get; } - /// - /// Represents the largest possible value of SolidAngle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SolidAngle MaxValue { get; } - - /// - /// Represents the smallest possible value of SolidAngle - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SolidAngle MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the SolidAngle quantity. /// @@ -174,12 +152,6 @@ public SolidAngle(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.SolidAngle; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public SolidAngle(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> SolidAngleUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SolidAngleUnit.Steradian, SolidAngleUnit.Steradian, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(SolidAngleUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SolidAngleUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static SolidAngle Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SolidAngle Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out SolidAngle result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SolidAngle result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static SolidAngleUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out SolidAngleUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SolidAngleUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SolidAngle left, SolidAngle right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SolidAngle left, SolidAngle right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(SolidAngle other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SolidAngle objSolidAngle)) - return false; - - return Equals(objSolidAngle); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SolidAngle other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SolidAngle within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(SolidAngleUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SolidAngleUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SolidAngle.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SolidAngle.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 0c03a88f55..520ce131af 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Specific_energy /// [DataContract] - public partial struct SpecificEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -91,7 +90,7 @@ static SpecificEnergy() new UnitInfo(SpecificEnergyUnit.WattDayPerTonne, "WattDaysPerTonne", BaseUnits.Undefined), new UnitInfo(SpecificEnergyUnit.WattHourPerKilogram, "WattHoursPerKilogram", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificEnergy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -104,9 +103,6 @@ static SpecificEnergy() /// If value is NaN or Infinity. public SpecificEnergy(double value, SpecificEnergyUnit unit) { - if(unit == SpecificEnergyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -150,24 +146,6 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// public static SpecificEnergyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of SpecificEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEnergy MaxValue { get; } - - /// - /// Represents the smallest possible value of SpecificEnergy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEnergy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the SpecificEnergy quantity. /// @@ -198,12 +176,6 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.SpecificEnergy; - /// /// The of this quantity. /// @@ -373,7 +345,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerShortTon, quantity => new SpecificEnergy(quantity.Value/((24*3.6e3)/9.0718474e2), SpecificEnergyUnit.WattDayPerShortTon)); unitConverter.SetConversionFunction(SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattDayPerTonne, quantity => new SpecificEnergy(quantity.Value/((24*3.6e3)/1e3), SpecificEnergyUnit.WattDayPerTonne)); unitConverter.SetConversionFunction(SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.WattHourPerKilogram, quantity => new SpecificEnergy(quantity.Value/3.6e3, SpecificEnergyUnit.WattHourPerKilogram)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SpecificEnergyUnit.JoulePerKilogram, SpecificEnergyUnit.JoulePerKilogram, quantity => quantity); @@ -419,7 +390,7 @@ public static string GetAbbreviation(SpecificEnergyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificEnergyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -719,7 +690,7 @@ public static SpecificEnergy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificEnergy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -750,7 +721,7 @@ public static bool TryParse(string? str, out SpecificEnergy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEnergy result) { return QuantityParser.Default.TryParse( @@ -778,7 +749,7 @@ public static SpecificEnergyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -804,7 +775,7 @@ public static bool TryParseUnit(string str, out SpecificEnergyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificEnergyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -884,20 +855,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEnergy left, SpecificEnergy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEnergy left, SpecificEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -913,23 +870,6 @@ public int CompareTo(SpecificEnergy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificEnergy objSpecificEnergy)) - return false; - - return Equals(objSpecificEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEnergy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificEnergy within the given absolute or relative tolerance. @@ -1121,7 +1061,7 @@ private double GetValueAs(SpecificEnergyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1140,63 +1080,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1278,8 +1184,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificEnergyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificEnergy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificEnergy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index fe401995fa..a64eb9a3ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. /// [DataContract] - public partial struct SpecificEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -72,7 +71,7 @@ static SpecificEntropy() new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, "MegajoulesPerKilogramDegreeCelsius", BaseUnits.Undefined), new UnitInfo(SpecificEntropyUnit.MegajoulePerKilogramKelvin, "MegajoulesPerKilogramKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificEntropy); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -85,9 +84,6 @@ static SpecificEntropy() /// If value is NaN or Infinity. public SpecificEntropy(double value, SpecificEntropyUnit unit) { - if(unit == SpecificEntropyUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -131,24 +127,6 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// public static SpecificEntropyUnit BaseUnit { get; } - /// - /// Represents the largest possible value of SpecificEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEntropy MaxValue { get; } - - /// - /// Represents the smallest possible value of SpecificEntropy - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificEntropy MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the SpecificEntropy quantity. /// @@ -179,12 +157,6 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.SpecificEntropy; - /// /// The of this quantity. /// @@ -258,7 +230,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.KilojoulePerKilogramKelvin, quantity => new SpecificEntropy((quantity.Value) / 1e3d, SpecificEntropyUnit.KilojoulePerKilogramKelvin)); unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius, quantity => new SpecificEntropy((quantity.Value) / 1e6d, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius)); unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.MegajoulePerKilogramKelvin, quantity => new SpecificEntropy((quantity.Value) / 1e6d, SpecificEntropyUnit.MegajoulePerKilogramKelvin)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SpecificEntropyUnit.JoulePerKilogramKelvin, SpecificEntropyUnit.JoulePerKilogramKelvin, quantity => quantity); @@ -288,7 +259,7 @@ public static string GetAbbreviation(SpecificEntropyUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificEntropyUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -444,7 +415,7 @@ public static SpecificEntropy Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificEntropy Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -475,7 +446,7 @@ public static bool TryParse(string? str, out SpecificEntropy result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificEntropy result) { return QuantityParser.Default.TryParse( @@ -503,7 +474,7 @@ public static SpecificEntropyUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -529,7 +500,7 @@ public static bool TryParseUnit(string str, out SpecificEntropyUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificEntropyUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -609,20 +580,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEntropy left, SpecificEntropy right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEntropy left, SpecificEntropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -638,23 +595,6 @@ public int CompareTo(SpecificEntropy other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificEntropy objSpecificEntropy)) - return false; - - return Equals(objSpecificEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEntropy other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificEntropy within the given absolute or relative tolerance. @@ -846,7 +786,7 @@ private double GetValueAs(SpecificEntropyUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -865,63 +805,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1003,8 +909,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificEntropyUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificEntropy.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificEntropy.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index e216a4952f..a8afd2bbe3 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption /// [DataContract] - public partial struct SpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -70,7 +69,7 @@ static SpecificFuelConsumption() new UnitInfo(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, "KilogramsPerKiloNewtonSecond", BaseUnits.Undefined), new UnitInfo(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, "PoundsMassPerPoundForceHour", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificFuelConsumption); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -83,9 +82,6 @@ static SpecificFuelConsumption() /// If value is NaN or Infinity. public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) { - if(unit == SpecificFuelConsumptionUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,24 +125,6 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// public static SpecificFuelConsumptionUnit BaseUnit { get; } - /// - /// Represents the largest possible value of SpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificFuelConsumption MaxValue { get; } - - /// - /// Represents the smallest possible value of SpecificFuelConsumption - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificFuelConsumption MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the SpecificFuelConsumption quantity. /// @@ -177,12 +155,6 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.SpecificFuelConsumption; - /// /// The of this quantity. /// @@ -226,7 +198,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour, quantity => new SpecificFuelConsumption(quantity.Value/28.33, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour)); unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond, quantity => new SpecificFuelConsumption((quantity.Value) / 1e3d, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond)); unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour, quantity => new SpecificFuelConsumption(quantity.Value/28.33, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond, quantity => quantity); @@ -251,7 +222,7 @@ public static string GetAbbreviation(SpecificFuelConsumptionUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificFuelConsumptionUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -362,7 +333,7 @@ public static SpecificFuelConsumption Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificFuelConsumption Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -393,7 +364,7 @@ public static bool TryParse(string? str, out SpecificFuelConsumption result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificFuelConsumption result) { return QuantityParser.Default.TryParse( @@ -421,7 +392,7 @@ public static SpecificFuelConsumptionUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -447,7 +418,7 @@ public static bool TryParseUnit(string str, out SpecificFuelConsumptionUnit unit /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificFuelConsumptionUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -527,20 +498,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificFuelConsumption left, SpecificFuelConsumption right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificFuelConsumption left, SpecificFuelConsumption right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -556,23 +513,6 @@ public int CompareTo(SpecificFuelConsumption other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificFuelConsumption objSpecificFuelConsumption)) - return false; - - return Equals(objSpecificFuelConsumption); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificFuelConsumption other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificFuelConsumption within the given absolute or relative tolerance. @@ -764,7 +704,7 @@ private double GetValueAs(SpecificFuelConsumptionUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -783,63 +723,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -921,8 +827,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificFuelConsumptionUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificFuelConsumption.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificFuelConsumption.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 3428ccae74..3d9cebcb4c 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. /// [DataContract] - public partial struct SpecificVolume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificVolume : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -66,7 +65,7 @@ static SpecificVolume() new UnitInfo(SpecificVolumeUnit.CubicMeterPerKilogram, "CubicMetersPerKilogram", BaseUnits.Undefined), new UnitInfo(SpecificVolumeUnit.MillicubicMeterPerKilogram, "MillicubicMetersPerKilogram", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificVolume); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -79,9 +78,6 @@ static SpecificVolume() /// If value is NaN or Infinity. public SpecificVolume(double value, SpecificVolumeUnit unit) { - if(unit == SpecificVolumeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -125,24 +121,6 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// public static SpecificVolumeUnit BaseUnit { get; } - /// - /// Represents the largest possible value of SpecificVolume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificVolume MaxValue { get; } - - /// - /// Represents the smallest possible value of SpecificVolume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificVolume MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the SpecificVolume quantity. /// @@ -173,12 +151,6 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.SpecificVolume; - /// /// The of this quantity. /// @@ -216,7 +188,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: BaseUnit -> SpecificVolumeUnit unitConverter.SetConversionFunction(SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.CubicFootPerPound, quantity => new SpecificVolume(quantity.Value*16.01846353, SpecificVolumeUnit.CubicFootPerPound)); unitConverter.SetConversionFunction(SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.MillicubicMeterPerKilogram, quantity => new SpecificVolume((quantity.Value) / 1e-3d, SpecificVolumeUnit.MillicubicMeterPerKilogram)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SpecificVolumeUnit.CubicMeterPerKilogram, SpecificVolumeUnit.CubicMeterPerKilogram, quantity => quantity); @@ -240,7 +211,7 @@ public static string GetAbbreviation(SpecificVolumeUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificVolumeUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -342,7 +313,7 @@ public static SpecificVolume Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificVolume Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -373,7 +344,7 @@ public static bool TryParse(string? str, out SpecificVolume result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificVolume result) { return QuantityParser.Default.TryParse( @@ -401,7 +372,7 @@ public static SpecificVolumeUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -427,7 +398,7 @@ public static bool TryParseUnit(string str, out SpecificVolumeUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificVolumeUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -507,20 +478,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificVolume left, SpecificVolume right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificVolume left, SpecificVolume right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,23 +493,6 @@ public int CompareTo(SpecificVolume other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificVolume objSpecificVolume)) - return false; - - return Equals(objSpecificVolume); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificVolume other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificVolume within the given absolute or relative tolerance. @@ -744,7 +684,7 @@ private double GetValueAs(SpecificVolumeUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -763,63 +703,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -901,8 +807,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificVolumeUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificVolume.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificVolume.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 81ed9de775..059ece510a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Specificweight /// [DataContract] - public partial struct SpecificWeight : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificWeight : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -83,7 +82,7 @@ static SpecificWeight() new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMeter, "TonnesForcePerCubicMeter", BaseUnits.Undefined), new UnitInfo(SpecificWeightUnit.TonneForcePerCubicMillimeter, "TonnesForcePerCubicMillimeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.SpecificWeight); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -96,9 +95,6 @@ static SpecificWeight() /// If value is NaN or Infinity. public SpecificWeight(double value, SpecificWeightUnit unit) { - if(unit == SpecificWeightUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -142,24 +138,6 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// public static SpecificWeightUnit BaseUnit { get; } - /// - /// Represents the largest possible value of SpecificWeight - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificWeight MaxValue { get; } - - /// - /// Represents the smallest possible value of SpecificWeight - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static SpecificWeight MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the SpecificWeight quantity. /// @@ -190,12 +168,6 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.SpecificWeight; - /// /// The of this quantity. /// @@ -317,7 +289,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicCentimeter, quantity => new SpecificWeight(quantity.Value/9.80665e9, SpecificWeightUnit.TonneForcePerCubicCentimeter)); unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicMeter, quantity => new SpecificWeight(quantity.Value/9.80665e3, SpecificWeightUnit.TonneForcePerCubicMeter)); unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.TonneForcePerCubicMillimeter, quantity => new SpecificWeight(quantity.Value/9.80665e12, SpecificWeightUnit.TonneForcePerCubicMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SpecificWeightUnit.NewtonPerCubicMeter, SpecificWeightUnit.NewtonPerCubicMeter, quantity => quantity); @@ -355,7 +326,7 @@ public static string GetAbbreviation(SpecificWeightUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpecificWeightUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -583,7 +554,7 @@ public static SpecificWeight Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static SpecificWeight Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -614,7 +585,7 @@ public static bool TryParse(string? str, out SpecificWeight result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out SpecificWeight result) { return QuantityParser.Default.TryParse( @@ -642,7 +613,7 @@ public static SpecificWeightUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -668,7 +639,7 @@ public static bool TryParseUnit(string str, out SpecificWeightUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpecificWeightUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -748,20 +719,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificWeight left, SpecificWeight right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificWeight left, SpecificWeight right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -777,23 +734,6 @@ public int CompareTo(SpecificWeight other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is SpecificWeight objSpecificWeight)) - return false; - - return Equals(objSpecificWeight); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificWeight other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another SpecificWeight within the given absolute or relative tolerance. @@ -985,7 +925,7 @@ private double GetValueAs(SpecificWeightUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1004,63 +944,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1142,8 +1048,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpecificWeightUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return SpecificWeight.QuantityType; else if(conversionType == typeof(QuantityInfo)) return SpecificWeight.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 3a5701a29e..680bb2a105 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. /// [DataContract] - public partial struct Speed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Speed : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -95,7 +94,7 @@ static Speed() new UnitInfo(SpeedUnit.YardPerMinute, "YardsPerMinute", new BaseUnits(length: LengthUnit.Yard, time: DurationUnit.Minute)), new UnitInfo(SpeedUnit.YardPerSecond, "YardsPerSecond", new BaseUnits(length: LengthUnit.Yard, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Speed); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -108,9 +107,6 @@ static Speed() /// If value is NaN or Infinity. public Speed(double value, SpeedUnit unit) { - if(unit == SpeedUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -154,24 +150,6 @@ public Speed(double value, UnitSystem unitSystem) /// public static SpeedUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Speed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Speed MaxValue { get; } - - /// - /// Represents the smallest possible value of Speed - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Speed MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Speed quantity. /// @@ -202,12 +180,6 @@ public Speed(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Speed; - /// /// The of this quantity. /// @@ -419,7 +391,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(SpeedUnit.MeterPerSecond, SpeedUnit.YardPerHour, quantity => new Speed(quantity.Value/0.9144*3600, SpeedUnit.YardPerHour)); unitConverter.SetConversionFunction(SpeedUnit.MeterPerSecond, SpeedUnit.YardPerMinute, quantity => new Speed(quantity.Value/0.9144*60, SpeedUnit.YardPerMinute)); unitConverter.SetConversionFunction(SpeedUnit.MeterPerSecond, SpeedUnit.YardPerSecond, quantity => new Speed(quantity.Value/0.9144, SpeedUnit.YardPerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(SpeedUnit.MeterPerSecond, SpeedUnit.MeterPerSecond, quantity => quantity); @@ -472,7 +443,7 @@ public static string GetAbbreviation(SpeedUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(SpeedUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -835,7 +806,7 @@ public static Speed Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Speed Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -866,7 +837,7 @@ public static bool TryParse(string? str, out Speed result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Speed result) { return QuantityParser.Default.TryParse( @@ -894,7 +865,7 @@ public static SpeedUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -920,7 +891,7 @@ public static bool TryParseUnit(string str, out SpeedUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out SpeedUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1000,20 +971,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Speed left, Speed right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Speed left, Speed right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1029,23 +986,6 @@ public int CompareTo(Speed other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Speed objSpeed)) - return false; - - return Equals(objSpeed); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Speed other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Speed within the given absolute or relative tolerance. @@ -1237,7 +1177,7 @@ private double GetValueAs(SpeedUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1256,63 +1196,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1394,8 +1300,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(SpeedUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Speed.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Speed.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 9c1f265359..b9962a10db 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions. /// [DataContract] - public partial struct StandardVolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct StandardVolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -72,7 +71,7 @@ static StandardVolumeFlow() new UnitInfo(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, "StandardCubicMetersPerSecond", BaseUnits.Undefined), new UnitInfo(StandardVolumeFlowUnit.StandardLiterPerMinute, "StandardLitersPerMinute", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.StandardVolumeFlow); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -85,9 +84,6 @@ static StandardVolumeFlow() /// If value is NaN or Infinity. public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) { - if(unit == StandardVolumeFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -131,24 +127,6 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// public static StandardVolumeFlowUnit BaseUnit { get; } - /// - /// Represents the largest possible value of StandardVolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static StandardVolumeFlow MaxValue { get; } - - /// - /// Represents the smallest possible value of StandardVolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static StandardVolumeFlow MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the StandardVolumeFlow quantity. /// @@ -179,12 +157,6 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.StandardVolumeFlow; - /// /// The of this quantity. /// @@ -258,7 +230,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerHour, quantity => new StandardVolumeFlow(quantity.Value*3600, StandardVolumeFlowUnit.StandardCubicMeterPerHour)); unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerMinute, quantity => new StandardVolumeFlow(quantity.Value*60, StandardVolumeFlowUnit.StandardCubicMeterPerMinute)); unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardLiterPerMinute, quantity => new StandardVolumeFlow(quantity.Value*60000, StandardVolumeFlowUnit.StandardLiterPerMinute)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(StandardVolumeFlowUnit.StandardCubicMeterPerSecond, StandardVolumeFlowUnit.StandardCubicMeterPerSecond, quantity => quantity); @@ -288,7 +259,7 @@ public static string GetAbbreviation(StandardVolumeFlowUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(StandardVolumeFlowUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -444,7 +415,7 @@ public static StandardVolumeFlow Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static StandardVolumeFlow Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -475,7 +446,7 @@ public static bool TryParse(string? str, out StandardVolumeFlow result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out StandardVolumeFlow result) { return QuantityParser.Default.TryParse( @@ -503,7 +474,7 @@ public static StandardVolumeFlowUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -529,7 +500,7 @@ public static bool TryParseUnit(string str, out StandardVolumeFlowUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out StandardVolumeFlowUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -609,20 +580,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(StandardVolumeFlow left, StandardVolumeFlow right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(StandardVolumeFlow left, StandardVolumeFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -638,23 +595,6 @@ public int CompareTo(StandardVolumeFlow other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is StandardVolumeFlow objStandardVolumeFlow)) - return false; - - return Equals(objStandardVolumeFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(StandardVolumeFlow other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another StandardVolumeFlow within the given absolute or relative tolerance. @@ -846,7 +786,7 @@ private double GetValueAs(StandardVolumeFlowUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -865,63 +805,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1003,8 +909,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(StandardVolumeFlowUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return StandardVolumeFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) return StandardVolumeFlow.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 1739b95e8b..8683ba2ef2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. /// [DataContract] - public partial struct Temperature : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Temperature : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -73,7 +72,7 @@ static Temperature() new UnitInfo(TemperatureUnit.MillidegreeCelsius, "MillidegreesCelsius", new BaseUnits(temperature: TemperatureUnit.DegreeCelsius)), new UnitInfo(TemperatureUnit.SolarTemperature, "SolarTemperatures", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Temperature); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -86,9 +85,6 @@ static Temperature() /// If value is NaN or Infinity. public Temperature(double value, TemperatureUnit unit) { - if(unit == TemperatureUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -132,24 +128,6 @@ public Temperature(double value, UnitSystem unitSystem) /// public static TemperatureUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Temperature - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Temperature MaxValue { get; } - - /// - /// Represents the smallest possible value of Temperature - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Temperature MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Temperature quantity. /// @@ -180,12 +158,6 @@ public Temperature(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Temperature; - /// /// The of this quantity. /// @@ -265,7 +237,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TemperatureUnit.Kelvin, TemperatureUnit.DegreeRoemer, quantity => new Temperature((quantity.Value - (273.15 - 7.5*40d/21))*21/40, TemperatureUnit.DegreeRoemer)); unitConverter.SetConversionFunction(TemperatureUnit.Kelvin, TemperatureUnit.MillidegreeCelsius, quantity => new Temperature((quantity.Value - 273.15) * 1000, TemperatureUnit.MillidegreeCelsius)); unitConverter.SetConversionFunction(TemperatureUnit.Kelvin, TemperatureUnit.SolarTemperature, quantity => new Temperature(quantity.Value / 5778, TemperatureUnit.SolarTemperature)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TemperatureUnit.Kelvin, TemperatureUnit.Kelvin, quantity => quantity); @@ -296,7 +267,7 @@ public static string GetAbbreviation(TemperatureUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -461,7 +432,7 @@ public static Temperature Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Temperature Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -492,7 +463,7 @@ public static bool TryParse(string? str, out Temperature result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Temperature result) { return QuantityParser.Default.TryParse( @@ -520,7 +491,7 @@ public static TemperatureUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -546,7 +517,7 @@ public static bool TryParseUnit(string str, out TemperatureUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -580,20 +551,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Temperature left, Temperature right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Temperature left, Temperature right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -609,23 +566,6 @@ public int CompareTo(Temperature other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Temperature objTemperature)) - return false; - - return Equals(objTemperature); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Temperature other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Temperature within the given absolute or relative tolerance. @@ -817,7 +757,7 @@ private double GetValueAs(TemperatureUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -836,63 +776,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -974,8 +880,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Temperature.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Temperature.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 600b004abc..c3270bb6ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). /// [DataContract] - public partial struct TemperatureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -73,7 +72,7 @@ static TemperatureChangeRate() new UnitInfo(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, "MillidegreesCelsiusPerSecond", BaseUnits.Undefined), new UnitInfo(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, "NanodegreesCelsiusPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TemperatureChangeRate); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -86,9 +85,6 @@ static TemperatureChangeRate() /// If value is NaN or Infinity. public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) { - if(unit == TemperatureChangeRateUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -132,24 +128,6 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// public static TemperatureChangeRateUnit BaseUnit { get; } - /// - /// Represents the largest possible value of TemperatureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureChangeRate MaxValue { get; } - - /// - /// Represents the smallest possible value of TemperatureChangeRate - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureChangeRate MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the TemperatureChangeRate quantity. /// @@ -180,12 +158,6 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.TemperatureChangeRate; - /// /// The of this quantity. /// @@ -265,7 +237,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond, quantity => new TemperatureChangeRate((quantity.Value) / 1e-6d, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond, quantity => new TemperatureChangeRate((quantity.Value) / 1e-3d, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond)); unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond, quantity => new TemperatureChangeRate((quantity.Value) / 1e-9d, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TemperatureChangeRateUnit.DegreeCelsiusPerSecond, TemperatureChangeRateUnit.DegreeCelsiusPerSecond, quantity => quantity); @@ -296,7 +267,7 @@ public static string GetAbbreviation(TemperatureChangeRateUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureChangeRateUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -461,7 +432,7 @@ public static TemperatureChangeRate Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TemperatureChangeRate Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -492,7 +463,7 @@ public static bool TryParse(string? str, out TemperatureChangeRate result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureChangeRate result) { return QuantityParser.Default.TryParse( @@ -520,7 +491,7 @@ public static TemperatureChangeRateUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -546,7 +517,7 @@ public static bool TryParseUnit(string str, out TemperatureChangeRateUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureChangeRateUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -626,20 +597,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -655,23 +612,6 @@ public int CompareTo(TemperatureChangeRate other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) - return false; - - return Equals(objTemperatureChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureChangeRate other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TemperatureChangeRate within the given absolute or relative tolerance. @@ -863,7 +803,7 @@ private double GetValueAs(TemperatureChangeRateUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -882,63 +822,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1020,8 +926,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureChangeRateUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TemperatureChangeRate.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TemperatureChangeRate.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 6cddec2aae..20d8d90796 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Difference between two temperatures. The conversions are different than for Temperature. /// [DataContract] - public partial struct TemperatureDelta : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureDelta : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -72,7 +71,7 @@ static TemperatureDelta() new UnitInfo(TemperatureDeltaUnit.Kelvin, "Kelvins", BaseUnits.Undefined), new UnitInfo(TemperatureDeltaUnit.MillidegreeCelsius, "MillidegreesCelsius", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TemperatureDelta); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -85,9 +84,6 @@ static TemperatureDelta() /// If value is NaN or Infinity. public TemperatureDelta(double value, TemperatureDeltaUnit unit) { - if(unit == TemperatureDeltaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -131,24 +127,6 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// public static TemperatureDeltaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of TemperatureDelta - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureDelta MaxValue { get; } - - /// - /// Represents the smallest possible value of TemperatureDelta - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureDelta MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the TemperatureDelta quantity. /// @@ -179,12 +157,6 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.TemperatureDelta; - /// /// The of this quantity. /// @@ -258,7 +230,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeReaumur, quantity => new TemperatureDelta(quantity.Value*4/5, TemperatureDeltaUnit.DegreeReaumur)); unitConverter.SetConversionFunction(TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.DegreeRoemer, quantity => new TemperatureDelta(quantity.Value*21/40, TemperatureDeltaUnit.DegreeRoemer)); unitConverter.SetConversionFunction(TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.MillidegreeCelsius, quantity => new TemperatureDelta((quantity.Value) / 1e-3d, TemperatureDeltaUnit.MillidegreeCelsius)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TemperatureDeltaUnit.Kelvin, TemperatureDeltaUnit.Kelvin, quantity => quantity); @@ -288,7 +259,7 @@ public static string GetAbbreviation(TemperatureDeltaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureDeltaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -444,7 +415,7 @@ public static TemperatureDelta Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TemperatureDelta Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -475,7 +446,7 @@ public static bool TryParse(string? str, out TemperatureDelta result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureDelta result) { return QuantityParser.Default.TryParse( @@ -503,7 +474,7 @@ public static TemperatureDeltaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -529,7 +500,7 @@ public static bool TryParseUnit(string str, out TemperatureDeltaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureDeltaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -609,20 +580,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureDelta left, TemperatureDelta right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureDelta left, TemperatureDelta right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -638,23 +595,6 @@ public int CompareTo(TemperatureDelta other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureDelta objTemperatureDelta)) - return false; - - return Equals(objTemperatureDelta); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureDelta other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TemperatureDelta within the given absolute or relative tolerance. @@ -846,7 +786,7 @@ private double GetValueAs(TemperatureDeltaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -865,63 +805,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1003,8 +909,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureDeltaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TemperatureDelta.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TemperatureDelta.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index e6c454181a..9fab64e15f 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -33,10 +32,10 @@ namespace UnitsNet { /// /// - /// The rate of change of temperature with displacement in a given direction (as with increase of height) + /// /// [DataContract] - public partial struct TemperatureGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static TemperatureGradient() new UnitInfo(TemperatureGradientUnit.DegreeFahrenheitPerFoot, "DegreesFahrenheitPerFoot", new BaseUnits(length: LengthUnit.Foot, temperature: TemperatureUnit.DegreeFahrenheit)), new UnitInfo(TemperatureGradientUnit.KelvinPerMeter, "KelvinsPerMeter", new BaseUnits(length: LengthUnit.Meter, temperature: TemperatureUnit.Kelvin)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TemperatureGradient); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static TemperatureGradient() /// If value is NaN or Infinity. public TemperatureGradient(double value, TemperatureGradientUnit unit) { - if(unit == TemperatureGradientUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// public static TemperatureGradientUnit BaseUnit { get; } - /// - /// Represents the largest possible value of TemperatureGradient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureGradient MaxValue { get; } - - /// - /// Represents the smallest possible value of TemperatureGradient - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TemperatureGradient MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the TemperatureGradient quantity. /// @@ -174,12 +152,6 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.TemperatureGradient; - /// /// The of this quantity. /// @@ -223,7 +195,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeCelsiusPerKilometer, quantity => new TemperatureGradient(quantity.Value * 1e3, TemperatureGradientUnit.DegreeCelsiusPerKilometer)); unitConverter.SetConversionFunction(TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeCelsiusPerMeter, quantity => new TemperatureGradient(quantity.Value, TemperatureGradientUnit.DegreeCelsiusPerMeter)); unitConverter.SetConversionFunction(TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.DegreeFahrenheitPerFoot, quantity => new TemperatureGradient((quantity.Value * 0.3048) * 9/5, TemperatureGradientUnit.DegreeFahrenheitPerFoot)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TemperatureGradientUnit.KelvinPerMeter, TemperatureGradientUnit.KelvinPerMeter, quantity => quantity); @@ -248,7 +219,7 @@ public static string GetAbbreviation(TemperatureGradientUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TemperatureGradientUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -359,7 +330,7 @@ public static TemperatureGradient Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TemperatureGradient Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -390,7 +361,7 @@ public static bool TryParse(string? str, out TemperatureGradient result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TemperatureGradient result) { return QuantityParser.Default.TryParse( @@ -418,7 +389,7 @@ public static TemperatureGradientUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -444,7 +415,7 @@ public static bool TryParseUnit(string str, out TemperatureGradientUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TemperatureGradientUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -524,20 +495,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureGradient left, TemperatureGradient right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureGradient left, TemperatureGradient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -553,23 +510,6 @@ public int CompareTo(TemperatureGradient other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TemperatureGradient objTemperatureGradient)) - return false; - - return Equals(objTemperatureGradient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureGradient other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TemperatureGradient within the given absolute or relative tolerance. @@ -761,7 +701,7 @@ private double GetValueAs(TemperatureGradientUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -780,63 +720,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -918,8 +824,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TemperatureGradientUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TemperatureGradient.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TemperatureGradient.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 8a8c92f774..f0d37172c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thermal_Conductivity /// [DataContract] - public partial struct ThermalConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -68,7 +67,7 @@ static ThermalConductivity() new UnitInfo(ThermalConductivityUnit.BtuPerHourFootFahrenheit, "BtusPerHourFootFahrenheit", BaseUnits.Undefined), new UnitInfo(ThermalConductivityUnit.WattPerMeterKelvin, "WattsPerMeterKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ThermalConductivity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -81,9 +80,6 @@ static ThermalConductivity() /// If value is NaN or Infinity. public ThermalConductivity(double value, ThermalConductivityUnit unit) { - if(unit == ThermalConductivityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -127,24 +123,6 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// public static ThermalConductivityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ThermalConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalConductivity MaxValue { get; } - - /// - /// Represents the smallest possible value of ThermalConductivity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalConductivity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ThermalConductivity quantity. /// @@ -175,12 +153,6 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ThermalConductivity; - /// /// The of this quantity. /// @@ -212,7 +184,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> ThermalConductivityUnit unitConverter.SetConversionFunction(ThermalConductivityUnit.WattPerMeterKelvin, ThermalConductivityUnit.BtuPerHourFootFahrenheit, quantity => new ThermalConductivity(quantity.Value/1.73073467, ThermalConductivityUnit.BtuPerHourFootFahrenheit)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ThermalConductivityUnit.WattPerMeterKelvin, ThermalConductivityUnit.WattPerMeterKelvin, quantity => quantity); @@ -235,7 +206,7 @@ public static string GetAbbreviation(ThermalConductivityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ThermalConductivityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -328,7 +299,7 @@ public static ThermalConductivity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ThermalConductivity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -359,7 +330,7 @@ public static bool TryParse(string? str, out ThermalConductivity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ThermalConductivity result) { return QuantityParser.Default.TryParse( @@ -387,7 +358,7 @@ public static ThermalConductivityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -413,7 +384,7 @@ public static bool TryParseUnit(string str, out ThermalConductivityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ThermalConductivityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -493,20 +464,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalConductivity left, ThermalConductivity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalConductivity left, ThermalConductivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -522,23 +479,6 @@ public int CompareTo(ThermalConductivity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ThermalConductivity objThermalConductivity)) - return false; - - return Equals(objThermalConductivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalConductivity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ThermalConductivity within the given absolute or relative tolerance. @@ -730,7 +670,7 @@ private double GetValueAs(ThermalConductivityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -749,63 +689,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -887,8 +793,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ThermalConductivityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ThermalConductivity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ThermalConductivity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index a4940c6b83..247588f545 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. /// [DataContract] - public partial struct ThermalResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static ThermalResistance() new UnitInfo(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, "SquareMeterKelvinsPerKilowatt", BaseUnits.Undefined), new UnitInfo(ThermalResistanceUnit.SquareMeterKelvinPerWatt, "SquareMeterKelvinsPerWatt", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.ThermalResistance); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static ThermalResistance() /// If value is NaN or Infinity. public ThermalResistance(double value, ThermalResistanceUnit unit) { - if(unit == ThermalResistanceUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// public static ThermalResistanceUnit BaseUnit { get; } - /// - /// Represents the largest possible value of ThermalResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalResistance MaxValue { get; } - - /// - /// Represents the smallest possible value of ThermalResistance - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static ThermalResistance MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the ThermalResistance quantity. /// @@ -176,12 +154,6 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.ThermalResistance; - /// /// The of this quantity. /// @@ -237,7 +209,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt, quantity => new ThermalResistance(quantity.Value/0.0999964777570357, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt)); unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt, quantity => new ThermalResistance(quantity.Value/1000.088056074108, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt)); unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareMeterKelvinPerWatt, quantity => new ThermalResistance(quantity.Value/1000, ThermalResistanceUnit.SquareMeterKelvinPerWatt)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt, quantity => quantity); @@ -264,7 +235,7 @@ public static string GetAbbreviation(ThermalResistanceUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(ThermalResistanceUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -393,7 +364,7 @@ public static ThermalResistance Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static ThermalResistance Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -424,7 +395,7 @@ public static bool TryParse(string? str, out ThermalResistance result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out ThermalResistance result) { return QuantityParser.Default.TryParse( @@ -452,7 +423,7 @@ public static ThermalResistanceUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -478,7 +449,7 @@ public static bool TryParseUnit(string str, out ThermalResistanceUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out ThermalResistanceUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -558,20 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalResistance left, ThermalResistance right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalResistance left, ThermalResistance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -587,23 +544,6 @@ public int CompareTo(ThermalResistance other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is ThermalResistance objThermalResistance)) - return false; - - return Equals(objThermalResistance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalResistance other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another ThermalResistance within the given absolute or relative tolerance. @@ -795,7 +735,7 @@ private double GetValueAs(ThermalResistanceUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -814,63 +754,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -952,8 +858,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(ThermalResistanceUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return ThermalResistance.QuantityType; else if(conversionType == typeof(QuantityInfo)) return ThermalResistance.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 058123a677..7904a0431c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. /// [DataContract] - public partial struct Torque : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Torque : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -88,7 +87,7 @@ static Torque() new UnitInfo(TorqueUnit.TonneForceMeter, "TonneForceMeters", BaseUnits.Undefined), new UnitInfo(TorqueUnit.TonneForceMillimeter, "TonneForceMillimeters", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Torque); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -101,9 +100,6 @@ static Torque() /// If value is NaN or Infinity. public Torque(double value, TorqueUnit unit) { - if(unit == TorqueUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -147,24 +143,6 @@ public Torque(double value, UnitSystem unitSystem) /// public static TorqueUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Torque - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Torque MaxValue { get; } - - /// - /// Represents the smallest possible value of Torque - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Torque MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Torque quantity. /// @@ -195,12 +173,6 @@ public Torque(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Torque; - /// /// The of this quantity. /// @@ -370,7 +342,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TorqueUnit.NewtonMeter, TorqueUnit.TonneForceCentimeter, quantity => new Torque(quantity.Value/9.80665e1, TorqueUnit.TonneForceCentimeter)); unitConverter.SetConversionFunction(TorqueUnit.NewtonMeter, TorqueUnit.TonneForceMeter, quantity => new Torque(quantity.Value/9.80665e3, TorqueUnit.TonneForceMeter)); unitConverter.SetConversionFunction(TorqueUnit.NewtonMeter, TorqueUnit.TonneForceMillimeter, quantity => new Torque(quantity.Value/9.80665, TorqueUnit.TonneForceMillimeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TorqueUnit.NewtonMeter, TorqueUnit.NewtonMeter, quantity => quantity); @@ -416,7 +387,7 @@ public static string GetAbbreviation(TorqueUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TorqueUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -716,7 +687,7 @@ public static Torque Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Torque Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -747,7 +718,7 @@ public static bool TryParse(string? str, out Torque result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Torque result) { return QuantityParser.Default.TryParse( @@ -775,7 +746,7 @@ public static TorqueUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -801,7 +772,7 @@ public static bool TryParseUnit(string str, out TorqueUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TorqueUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -881,20 +852,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Torque left, Torque right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Torque left, Torque right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -910,23 +867,6 @@ public int CompareTo(Torque other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Torque objTorque)) - return false; - - return Equals(objTorque); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Torque other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Torque within the given absolute or relative tolerance. @@ -1118,7 +1058,7 @@ private double GetValueAs(TorqueUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1137,63 +1077,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1275,8 +1181,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TorqueUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Torque.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Torque.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 6abd534194..78a603f6a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// The magnitude of torque per unit length. /// [DataContract] - public partial struct TorquePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TorquePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -84,7 +83,7 @@ static TorquePerLength() new UnitInfo(TorquePerLengthUnit.TonneForceMeterPerMeter, "TonneForceMetersPerMeter", BaseUnits.Undefined), new UnitInfo(TorquePerLengthUnit.TonneForceMillimeterPerMeter, "TonneForceMillimetersPerMeter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.TorquePerLength); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -97,9 +96,6 @@ static TorquePerLength() /// If value is NaN or Infinity. public TorquePerLength(double value, TorquePerLengthUnit unit) { - if(unit == TorquePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -143,24 +139,6 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// public static TorquePerLengthUnit BaseUnit { get; } - /// - /// Represents the largest possible value of TorquePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TorquePerLength MaxValue { get; } - - /// - /// Represents the smallest possible value of TorquePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static TorquePerLength MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the TorquePerLength quantity. /// @@ -191,12 +169,6 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.TorquePerLength; - /// /// The of this quantity. /// @@ -342,7 +314,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceCentimeterPerMeter, quantity => new TorquePerLength(quantity.Value*0.0101971619222242, TorquePerLengthUnit.TonneForceCentimeterPerMeter)); unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMeterPerMeter, quantity => new TorquePerLength(quantity.Value*0.000101971619222242, TorquePerLengthUnit.TonneForceMeterPerMeter)); unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.TonneForceMillimeterPerMeter, quantity => new TorquePerLength(quantity.Value*0.101971619222242, TorquePerLengthUnit.TonneForceMillimeterPerMeter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TorquePerLengthUnit.NewtonMeterPerMeter, TorquePerLengthUnit.NewtonMeterPerMeter, quantity => quantity); @@ -384,7 +355,7 @@ public static string GetAbbreviation(TorquePerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TorquePerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -648,7 +619,7 @@ public static TorquePerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static TorquePerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -679,7 +650,7 @@ public static bool TryParse(string? str, out TorquePerLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out TorquePerLength result) { return QuantityParser.Default.TryParse( @@ -707,7 +678,7 @@ public static TorquePerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -733,7 +704,7 @@ public static bool TryParseUnit(string str, out TorquePerLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TorquePerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -813,20 +784,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TorquePerLength left, TorquePerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TorquePerLength left, TorquePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -842,23 +799,6 @@ public int CompareTo(TorquePerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is TorquePerLength objTorquePerLength)) - return false; - - return Equals(objTorquePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TorquePerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another TorquePerLength within the given absolute or relative tolerance. @@ -1050,7 +990,7 @@ private double GetValueAs(TorquePerLengthUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1069,63 +1009,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1207,8 +1113,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TorquePerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return TorquePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return TorquePerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 41528464f1..ef11543d8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Turbidity /// [DataContract] - public partial struct Turbidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Turbidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -67,7 +66,7 @@ static Turbidity() { new UnitInfo(TurbidityUnit.NTU, "NTU", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Turbidity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -80,9 +79,6 @@ static Turbidity() /// If value is NaN or Infinity. public Turbidity(double value, TurbidityUnit unit) { - if(unit == TurbidityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -126,24 +122,6 @@ public Turbidity(double value, UnitSystem unitSystem) /// public static TurbidityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Turbidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Turbidity MaxValue { get; } - - /// - /// Represents the smallest possible value of Turbidity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Turbidity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Turbidity quantity. /// @@ -174,12 +152,6 @@ public Turbidity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Turbidity; - /// /// The of this quantity. /// @@ -205,7 +177,6 @@ public Turbidity(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> TurbidityUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(TurbidityUnit.NTU, TurbidityUnit.NTU, quantity => quantity); @@ -227,7 +198,7 @@ public static string GetAbbreviation(TurbidityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(TurbidityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -311,7 +282,7 @@ public static Turbidity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Turbidity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -342,7 +313,7 @@ public static bool TryParse(string? str, out Turbidity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Turbidity result) { return QuantityParser.Default.TryParse( @@ -370,7 +341,7 @@ public static TurbidityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -396,7 +367,7 @@ public static bool TryParseUnit(string str, out TurbidityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out TurbidityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -476,20 +447,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Turbidity left, Turbidity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Turbidity left, Turbidity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -505,23 +462,6 @@ public int CompareTo(Turbidity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Turbidity objTurbidity)) - return false; - - return Equals(objTurbidity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Turbidity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Turbidity within the given absolute or relative tolerance. @@ -713,7 +653,7 @@ private double GetValueAs(TurbidityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -732,63 +672,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -870,8 +776,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(TurbidityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Turbidity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Turbidity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index e0b0f0544c..d671f03462 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. /// [DataContract] - public partial struct VitaminA : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VitaminA : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -64,7 +63,7 @@ static VitaminA() { new UnitInfo(VitaminAUnit.InternationalUnit, "InternationalUnits", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VitaminA); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -77,9 +76,6 @@ static VitaminA() /// If value is NaN or Infinity. public VitaminA(double value, VitaminAUnit unit) { - if(unit == VitaminAUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,24 +119,6 @@ public VitaminA(double value, UnitSystem unitSystem) /// public static VitaminAUnit BaseUnit { get; } - /// - /// Represents the largest possible value of VitaminA - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VitaminA MaxValue { get; } - - /// - /// Represents the smallest possible value of VitaminA - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VitaminA MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the VitaminA quantity. /// @@ -171,12 +149,6 @@ public VitaminA(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.VitaminA; - /// /// The of this quantity. /// @@ -202,7 +174,6 @@ public VitaminA(double value, UnitSystem unitSystem) internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> VitaminAUnit - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VitaminAUnit.InternationalUnit, VitaminAUnit.InternationalUnit, quantity => quantity); @@ -224,7 +195,7 @@ public static string GetAbbreviation(VitaminAUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VitaminAUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -308,7 +279,7 @@ public static VitaminA Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VitaminA Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -339,7 +310,7 @@ public static bool TryParse(string? str, out VitaminA result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VitaminA result) { return QuantityParser.Default.TryParse( @@ -367,7 +338,7 @@ public static VitaminAUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -393,7 +364,7 @@ public static bool TryParseUnit(string str, out VitaminAUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VitaminAUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -473,20 +444,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VitaminA left, VitaminA right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VitaminA left, VitaminA right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -502,23 +459,6 @@ public int CompareTo(VitaminA other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VitaminA objVitaminA)) - return false; - - return Equals(objVitaminA); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VitaminA other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VitaminA within the given absolute or relative tolerance. @@ -710,7 +650,7 @@ private double GetValueAs(VitaminAUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -729,63 +669,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -867,8 +773,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VitaminAUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VitaminA.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VitaminA.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 1bebc4a629..d3c91e7bbc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. /// [DataContract] - public partial struct Volume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Volume : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -114,7 +113,7 @@ static Volume() new UnitInfo(VolumeUnit.UsTablespoon, "UsTablespoons", BaseUnits.Undefined), new UnitInfo(VolumeUnit.UsTeaspoon, "UsTeaspoons", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.Volume); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -127,9 +126,6 @@ static Volume() /// If value is NaN or Infinity. public Volume(double value, VolumeUnit unit) { - if(unit == VolumeUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -173,24 +169,6 @@ public Volume(double value, UnitSystem unitSystem) /// public static VolumeUnit BaseUnit { get; } - /// - /// Represents the largest possible value of Volume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Volume MaxValue { get; } - - /// - /// Represents the smallest possible value of Volume - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static Volume MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the Volume quantity. /// @@ -221,12 +199,6 @@ public Volume(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.Volume; - /// /// The of this quantity. /// @@ -552,7 +524,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.UsQuart, quantity => new Volume(quantity.Value/9.46352946e-4, VolumeUnit.UsQuart)); unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.UsTablespoon, quantity => new Volume(quantity.Value/1.478676478125e-5, VolumeUnit.UsTablespoon)); unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.UsTeaspoon, quantity => new Volume(quantity.Value/4.92892159375e-6, VolumeUnit.UsTeaspoon)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VolumeUnit.CubicMeter, VolumeUnit.CubicMeter, quantity => quantity); @@ -624,7 +595,7 @@ public static string GetAbbreviation(VolumeUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1158,7 +1129,7 @@ public static Volume Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static Volume Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1189,7 +1160,7 @@ public static bool TryParse(string? str, out Volume result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out Volume result) { return QuantityParser.Default.TryParse( @@ -1217,7 +1188,7 @@ public static VolumeUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1243,7 +1214,7 @@ public static bool TryParseUnit(string str, out VolumeUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1323,20 +1294,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Volume left, Volume right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Volume left, Volume right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1352,23 +1309,6 @@ public int CompareTo(Volume other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is Volume objVolume)) - return false; - - return Equals(objVolume); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Volume other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another Volume within the given absolute or relative tolerance. @@ -1560,7 +1500,7 @@ private double GetValueAs(VolumeUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1579,63 +1519,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1717,8 +1623,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return Volume.QuantityType; else if(conversionType == typeof(QuantityInfo)) return Volume.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index e0b2294a8e..7bc3fe5e7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration /// [DataContract] - public partial struct VolumeConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -86,7 +85,7 @@ static VolumeConcentration() new UnitInfo(VolumeConcentrationUnit.PicolitersPerLiter, "PicolitersPerLiter", BaseUnits.Undefined), new UnitInfo(VolumeConcentrationUnit.PicolitersPerMililiter, "PicolitersPerMililiter", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumeConcentration); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -99,9 +98,6 @@ static VolumeConcentration() /// If value is NaN or Infinity. public VolumeConcentration(double value, VolumeConcentrationUnit unit) { - if(unit == VolumeConcentrationUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -145,24 +141,6 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// public static VolumeConcentrationUnit BaseUnit { get; } - /// - /// Represents the largest possible value of VolumeConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeConcentration MaxValue { get; } - - /// - /// Represents the smallest possible value of VolumeConcentration - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeConcentration MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the VolumeConcentration quantity. /// @@ -193,12 +171,6 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.VolumeConcentration; - /// /// The of this quantity. /// @@ -338,7 +310,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.Percent, quantity => new VolumeConcentration(quantity.Value*1e2, VolumeConcentrationUnit.Percent)); unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PicolitersPerLiter, quantity => new VolumeConcentration((quantity.Value) / 1e-12d, VolumeConcentrationUnit.PicolitersPerLiter)); unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.PicolitersPerMililiter, quantity => new VolumeConcentration((quantity.Value*1e-3) / 1e-12d, VolumeConcentrationUnit.PicolitersPerMililiter)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VolumeConcentrationUnit.DecimalFraction, VolumeConcentrationUnit.DecimalFraction, quantity => quantity); @@ -379,7 +350,7 @@ public static string GetAbbreviation(VolumeConcentrationUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeConcentrationUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -634,7 +605,7 @@ public static VolumeConcentration Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumeConcentration Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -665,7 +636,7 @@ public static bool TryParse(string? str, out VolumeConcentration result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumeConcentration result) { return QuantityParser.Default.TryParse( @@ -693,7 +664,7 @@ public static VolumeConcentrationUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -719,7 +690,7 @@ public static bool TryParseUnit(string str, out VolumeConcentrationUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeConcentrationUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -799,20 +770,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeConcentration left, VolumeConcentration right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeConcentration left, VolumeConcentration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -828,23 +785,6 @@ public int CompareTo(VolumeConcentration other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeConcentration objVolumeConcentration)) - return false; - - return Equals(objVolumeConcentration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeConcentration other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumeConcentration within the given absolute or relative tolerance. @@ -1036,7 +976,7 @@ private double GetValueAs(VolumeConcentrationUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1055,63 +995,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1193,8 +1099,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeConcentrationUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumeConcentration.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumeConcentration.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 2d7446d292..f25d0e25ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. /// [DataContract] - public partial struct VolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -107,7 +106,7 @@ static VolumeFlow() new UnitInfo(VolumeFlowUnit.MilliliterPerHour, "MillilitersPerHour", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.MilliliterPerMinute, "MillilitersPerMinute", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.MilliliterPerSecond, "MillilitersPerSecond", BaseUnits.Undefined), - new UnitInfo(VolumeFlowUnit.MillionUsGallonsPerDay, "MillionUsGallonsPerDay", BaseUnits.Undefined), + new UnitInfo(VolumeFlowUnit.MillionUsGallonPerDay, "MillionUsGallonsPerDay", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.NanoliterPerDay, "NanolitersPerDay", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.NanoliterPerHour, "NanolitersPerHour", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.NanoliterPerMinute, "NanolitersPerMinute", BaseUnits.Undefined), @@ -125,7 +124,7 @@ static VolumeFlow() new UnitInfo(VolumeFlowUnit.UsGallonPerMinute, "UsGallonsPerMinute", BaseUnits.Undefined), new UnitInfo(VolumeFlowUnit.UsGallonPerSecond, "UsGallonsPerSecond", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumeFlow); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -138,9 +137,6 @@ static VolumeFlow() /// If value is NaN or Infinity. public VolumeFlow(double value, VolumeFlowUnit unit) { - if(unit == VolumeFlowUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -184,24 +180,6 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// public static VolumeFlowUnit BaseUnit { get; } - /// - /// Represents the largest possible value of VolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlow MaxValue { get; } - - /// - /// Represents the smallest possible value of VolumeFlow - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlow MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the VolumeFlow quantity. /// @@ -232,12 +210,6 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.VolumeFlow; - /// /// The of this quantity. /// @@ -475,7 +447,7 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// Get VolumeFlow in MillionUsGallonsPerDay. /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonsPerDay); + public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); /// /// Get VolumeFlow in NanolitersPerDay. @@ -612,7 +584,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerHour, quantity => new VolumeFlow((quantity.Value*3600000.000) / 1e-3d, VolumeFlowUnit.MilliliterPerHour)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerMinute, quantity => new VolumeFlow((quantity.Value*60000.00000) / 1e-3d, VolumeFlowUnit.MilliliterPerMinute)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MilliliterPerSecond, quantity => new VolumeFlow((quantity.Value*1000) / 1e-3d, VolumeFlowUnit.MilliliterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MillionUsGallonsPerDay, quantity => new VolumeFlow(quantity.Value*22.824465227, VolumeFlowUnit.MillionUsGallonsPerDay)); + unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.MillionUsGallonPerDay, quantity => new VolumeFlow(quantity.Value*22.824465227, VolumeFlowUnit.MillionUsGallonPerDay)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerDay, quantity => new VolumeFlow((quantity.Value*86400000) / 1e-9d, VolumeFlowUnit.NanoliterPerDay)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerHour, quantity => new VolumeFlow((quantity.Value*3600000.000) / 1e-9d, VolumeFlowUnit.NanoliterPerHour)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.NanoliterPerMinute, quantity => new VolumeFlow((quantity.Value*60000.00000) / 1e-9d, VolumeFlowUnit.NanoliterPerMinute)); @@ -629,7 +601,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerHour, quantity => new VolumeFlow(quantity.Value*951019.38848933424, VolumeFlowUnit.UsGallonPerHour)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerMinute, quantity => new VolumeFlow(quantity.Value*15850.323141489, VolumeFlowUnit.UsGallonPerMinute)); unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.UsGallonPerSecond, quantity => new VolumeFlow(quantity.Value*264.1720523581484, VolumeFlowUnit.UsGallonPerSecond)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VolumeFlowUnit.CubicMeterPerSecond, VolumeFlowUnit.CubicMeterPerSecond, quantity => quantity); @@ -678,7 +649,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow((quantity.Value/3600000.000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow((quantity.Value/60000.00000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.MilliliterPerSecond, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow((quantity.Value/1000) * 1e-3d, VolumeFlowUnit.CubicMeterPerSecond)); - unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonsPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow(quantity.Value/22.824465227, VolumeFlowUnit.CubicMeterPerSecond)); + unitConverter.SetConversionFunction(VolumeFlowUnit.MillionUsGallonPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow(quantity.Value/22.824465227, VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerDay, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow((quantity.Value/86400000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerHour, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow((quantity.Value/3600000.000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond)); unitConverter.SetConversionFunction(VolumeFlowUnit.NanoliterPerMinute, VolumeFlowUnit.CubicMeterPerSecond, quantity => new VolumeFlow((quantity.Value/60000.00000) * 1e-9d, VolumeFlowUnit.CubicMeterPerSecond)); @@ -712,7 +683,7 @@ public static string GetAbbreviation(VolumeFlowUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeFlowUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -1134,7 +1105,7 @@ public static VolumeFlow FromMillilitersPerSecond(QuantityValue millilitersperse public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday) { double value = (double) millionusgallonsperday; - return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonsPerDay); + return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonPerDay); } /// /// Get VolumeFlow from NanolitersPerDay. @@ -1345,7 +1316,7 @@ public static VolumeFlow Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumeFlow Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -1376,7 +1347,7 @@ public static bool TryParse(string? str, out VolumeFlow result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumeFlow result) { return QuantityParser.Default.TryParse( @@ -1404,7 +1375,7 @@ public static VolumeFlowUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -1430,7 +1401,7 @@ public static bool TryParseUnit(string str, out VolumeFlowUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeFlowUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -1510,20 +1481,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeFlow left, VolumeFlow right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeFlow left, VolumeFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1539,23 +1496,6 @@ public int CompareTo(VolumeFlow other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeFlow objVolumeFlow)) - return false; - - return Equals(objVolumeFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeFlow other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumeFlow within the given absolute or relative tolerance. @@ -1747,7 +1687,7 @@ private double GetValueAs(VolumeFlowUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -1766,63 +1706,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1904,8 +1810,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeFlowUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumeFlow.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumeFlow.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index c6f0ba00b1..bb30d0f071 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -33,10 +32,10 @@ namespace UnitsNet { /// /// - /// The volumetric flow rate per area is the volume of fluid which passes through a given unit surface area per unit time. + /// /// [DataContract] - public partial struct VolumeFlowPerArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlowPerArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -65,7 +64,7 @@ static VolumeFlowPerArea() new UnitInfo(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, "CubicFeetPerMinutePerSquareFoot", new BaseUnits(length: LengthUnit.Foot, time: DurationUnit.Minute)), new UnitInfo(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, "CubicMetersPerSecondPerSquareMeter", new BaseUnits(length: LengthUnit.Meter, time: DurationUnit.Second)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumeFlowPerArea); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -78,9 +77,6 @@ static VolumeFlowPerArea() /// If value is NaN or Infinity. public VolumeFlowPerArea(double value, VolumeFlowPerAreaUnit unit) { - if(unit == VolumeFlowPerAreaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -124,24 +120,6 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// public static VolumeFlowPerAreaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of VolumeFlowPerArea - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlowPerArea MaxValue { get; } - - /// - /// Represents the smallest possible value of VolumeFlowPerArea - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumeFlowPerArea MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the VolumeFlowPerArea quantity. /// @@ -172,12 +150,6 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.VolumeFlowPerArea; - /// /// The of this quantity. /// @@ -209,7 +181,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> VolumeFlowPerAreaUnit unitConverter.SetConversionFunction(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot, quantity => new VolumeFlowPerArea(quantity.Value*196.850394, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter, quantity => quantity); @@ -232,7 +203,7 @@ public static string GetAbbreviation(VolumeFlowPerAreaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumeFlowPerAreaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -325,7 +296,7 @@ public static VolumeFlowPerArea Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumeFlowPerArea Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -356,7 +327,7 @@ public static bool TryParse(string? str, out VolumeFlowPerArea result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumeFlowPerArea result) { return QuantityParser.Default.TryParse( @@ -384,7 +355,7 @@ public static VolumeFlowPerAreaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -410,7 +381,7 @@ public static bool TryParseUnit(string str, out VolumeFlowPerAreaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumeFlowPerAreaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -490,20 +461,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeFlowPerArea left, VolumeFlowPerArea right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeFlowPerArea left, VolumeFlowPerArea right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -519,23 +476,6 @@ public int CompareTo(VolumeFlowPerArea other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumeFlowPerArea objVolumeFlowPerArea)) - return false; - - return Equals(objVolumeFlowPerArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeFlowPerArea other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumeFlowPerArea within the given absolute or relative tolerance. @@ -727,7 +667,7 @@ private double GetValueAs(VolumeFlowPerAreaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -746,63 +686,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -884,8 +790,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumeFlowPerAreaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumeFlowPerArea.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumeFlowPerArea.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index ad2c242fcf..c60804ee99 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// Volume, typically of fluid, that a container can hold within a unit of length. /// [DataContract] - public partial struct VolumePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -70,7 +69,7 @@ static VolumePerLength() new UnitInfo(VolumePerLengthUnit.LiterPerMillimeter, "LitersPerMillimeter", BaseUnits.Undefined), new UnitInfo(VolumePerLengthUnit.OilBarrelPerFoot, "OilBarrelsPerFoot", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumePerLength); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -83,9 +82,6 @@ static VolumePerLength() /// If value is NaN or Infinity. public VolumePerLength(double value, VolumePerLengthUnit unit) { - if(unit == VolumePerLengthUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,24 +125,6 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// public static VolumePerLengthUnit BaseUnit { get; } - /// - /// Represents the largest possible value of VolumePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumePerLength MaxValue { get; } - - /// - /// Represents the smallest possible value of VolumePerLength - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumePerLength MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the VolumePerLength quantity. /// @@ -177,12 +155,6 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.VolumePerLength; - /// /// The of this quantity. /// @@ -244,7 +216,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.LiterPerMeter, quantity => new VolumePerLength(quantity.Value*1000, VolumePerLengthUnit.LiterPerMeter)); unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.LiterPerMillimeter, quantity => new VolumePerLength(quantity.Value, VolumePerLengthUnit.LiterPerMillimeter)); unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.OilBarrelPerFoot, quantity => new VolumePerLength(quantity.Value*1.91713408, VolumePerLengthUnit.OilBarrelPerFoot)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VolumePerLengthUnit.CubicMeterPerMeter, VolumePerLengthUnit.CubicMeterPerMeter, quantity => quantity); @@ -272,7 +243,7 @@ public static string GetAbbreviation(VolumePerLengthUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumePerLengthUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -410,7 +381,7 @@ public static VolumePerLength Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumePerLength Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -441,7 +412,7 @@ public static bool TryParse(string? str, out VolumePerLength result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumePerLength result) { return QuantityParser.Default.TryParse( @@ -469,7 +440,7 @@ public static VolumePerLengthUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -495,7 +466,7 @@ public static bool TryParseUnit(string str, out VolumePerLengthUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumePerLengthUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -575,20 +546,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumePerLength left, VolumePerLength right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumePerLength left, VolumePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -604,23 +561,6 @@ public int CompareTo(VolumePerLength other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumePerLength objVolumePerLength)) - return false; - - return Equals(objVolumePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumePerLength other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumePerLength within the given absolute or relative tolerance. @@ -812,7 +752,7 @@ private double GetValueAs(VolumePerLengthUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -831,63 +771,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -969,8 +875,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumePerLengthUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumePerLength.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumePerLength.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 4e11b4358f..a2221cf549 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -39,7 +38,7 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Volumetric_heat_capacity /// [DataContract] - public partial struct VolumetricHeatCapacity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumetricHeatCapacity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -75,7 +74,7 @@ static VolumetricHeatCapacity() new UnitInfo(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, "MegajoulesPerCubicMeterDegreeCelsius", BaseUnits.Undefined), new UnitInfo(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, "MegajoulesPerCubicMeterKelvin", BaseUnits.Undefined), }, - BaseUnit, Zero, BaseDimensions, QuantityType.VolumetricHeatCapacity); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -88,9 +87,6 @@ static VolumetricHeatCapacity() /// If value is NaN or Infinity. public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) { - if(unit == VolumetricHeatCapacityUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -134,24 +130,6 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// public static VolumetricHeatCapacityUnit BaseUnit { get; } - /// - /// Represents the largest possible value of VolumetricHeatCapacity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumetricHeatCapacity MaxValue { get; } - - /// - /// Represents the smallest possible value of VolumetricHeatCapacity - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static VolumetricHeatCapacity MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the VolumetricHeatCapacity quantity. /// @@ -182,12 +160,6 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.VolumetricHeatCapacity; - /// /// The of this quantity. /// @@ -261,7 +233,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin, quantity => new VolumetricHeatCapacity((quantity.Value) / 1e3d, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin)); unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius, quantity => new VolumetricHeatCapacity((quantity.Value) / 1e6d, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius)); unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin, quantity => new VolumetricHeatCapacity((quantity.Value) / 1e6d, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin, quantity => quantity); @@ -291,7 +262,7 @@ public static string GetAbbreviation(VolumetricHeatCapacityUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(VolumetricHeatCapacityUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -447,7 +418,7 @@ public static VolumetricHeatCapacity Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static VolumetricHeatCapacity Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -478,7 +449,7 @@ public static bool TryParse(string? str, out VolumetricHeatCapacity result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out VolumetricHeatCapacity result) { return QuantityParser.Default.TryParse( @@ -506,7 +477,7 @@ public static VolumetricHeatCapacityUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -532,7 +503,7 @@ public static bool TryParseUnit(string str, out VolumetricHeatCapacityUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out VolumetricHeatCapacityUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -612,20 +583,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumetricHeatCapacity left, VolumetricHeatCapacity right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumetricHeatCapacity left, VolumetricHeatCapacity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -641,23 +598,6 @@ public int CompareTo(VolumetricHeatCapacity other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is VolumetricHeatCapacity objVolumetricHeatCapacity)) - return false; - - return Equals(objVolumetricHeatCapacity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumetricHeatCapacity other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another VolumetricHeatCapacity within the given absolute or relative tolerance. @@ -849,7 +789,7 @@ private double GetValueAs(VolumetricHeatCapacityUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -868,63 +808,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -1006,8 +912,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(VolumetricHeatCapacityUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return VolumetricHeatCapacity.QuantityType; else if(conversionType == typeof(QuantityInfo)) return VolumetricHeatCapacity.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index a20a3aecb2..2e3b3016e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -21,7 +21,6 @@ using System.Globalization; using System.Linq; using System.Runtime.Serialization; -using JetBrains.Annotations; using UnitsNet.InternalHelpers; using UnitsNet.Units; @@ -36,7 +35,7 @@ namespace UnitsNet /// A geometric property of an area that is used to determine the warping stress. /// [DataContract] - public partial struct WarpingMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct WarpingMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. @@ -69,7 +68,7 @@ static WarpingMomentOfInertia() new UnitInfo(WarpingMomentOfInertiaUnit.MeterToTheSixth, "MetersToTheSixth", new BaseUnits(length: LengthUnit.Meter)), new UnitInfo(WarpingMomentOfInertiaUnit.MillimeterToTheSixth, "MillimetersToTheSixth", new BaseUnits(length: LengthUnit.Millimeter)), }, - BaseUnit, Zero, BaseDimensions, QuantityType.WarpingMomentOfInertia); + BaseUnit, Zero, BaseDimensions); RegisterDefaultConversions(DefaultConversionFunctions); } @@ -82,9 +81,6 @@ static WarpingMomentOfInertia() /// If value is NaN or Infinity. public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) { - if(unit == WarpingMomentOfInertiaUnit.Undefined) - throw new ArgumentException("The quantity can not be created with an undefined unit.", nameof(unit)); - _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -128,24 +124,6 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// public static WarpingMomentOfInertiaUnit BaseUnit { get; } - /// - /// Represents the largest possible value of WarpingMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static WarpingMomentOfInertia MaxValue { get; } - - /// - /// Represents the smallest possible value of WarpingMomentOfInertia - /// - [Obsolete("MaxValue and MinValue will be removed. Choose your own value or use nullability for unbounded lower/upper range checks. See discussion in https://github.com/angularsen/UnitsNet/issues/848.")] - public static WarpingMomentOfInertia MinValue { get; } - - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public static QuantityType QuantityType { get; } - /// /// All units of measurement for the WarpingMomentOfInertia quantity. /// @@ -176,12 +154,6 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// QuantityInfo IQuantity.QuantityInfo => Info; - /// - /// The of this quantity. - /// - [Obsolete("QuantityType will be removed in the future. Use the Info property instead.")] - public QuantityType Type => QuantityType.WarpingMomentOfInertia; - /// /// The of this quantity. /// @@ -237,7 +209,6 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.FootToTheSixth, quantity => new WarpingMomentOfInertia(quantity.Value/Math.Pow(0.3048, 6), WarpingMomentOfInertiaUnit.FootToTheSixth)); unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.InchToTheSixth, quantity => new WarpingMomentOfInertia(quantity.Value/Math.Pow(2.54e-2, 6), WarpingMomentOfInertiaUnit.InchToTheSixth)); unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.MillimeterToTheSixth, quantity => new WarpingMomentOfInertia(quantity.Value*1e18, WarpingMomentOfInertiaUnit.MillimeterToTheSixth)); - // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(WarpingMomentOfInertiaUnit.MeterToTheSixth, WarpingMomentOfInertiaUnit.MeterToTheSixth, quantity => quantity); @@ -264,7 +235,7 @@ public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit) /// /// Unit to get abbreviation for. /// Unit abbreviation string. - /// Format to use for localization. Defaults to if null. + /// Format to use for localization. Defaults to if null. public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, IFormatProvider? provider) { return UnitAbbreviationsCache.Default.GetDefaultAbbreviation(unit, provider); @@ -393,7 +364,7 @@ public static WarpingMomentOfInertia Parse(string str) /// We wrap exceptions in to allow you to distinguish /// Units.NET exceptions from other exceptions. /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static WarpingMomentOfInertia Parse(string str, IFormatProvider? provider) { return QuantityParser.Default.Parse( @@ -424,7 +395,7 @@ public static bool TryParse(string? str, out WarpingMomentOfInertia result) /// /// Length.Parse("5.5 m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParse(string? str, IFormatProvider? provider, out WarpingMomentOfInertia result) { return QuantityParser.Default.TryParse( @@ -452,7 +423,7 @@ public static WarpingMomentOfInertiaUnit ParseUnit(string str) /// Parse a unit string. /// /// String to parse. Typically in the form: {number} {unit} - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. /// /// Length.ParseUnit("m", new CultureInfo("en-US")); /// @@ -478,7 +449,7 @@ public static bool TryParseUnit(string str, out WarpingMomentOfInertiaUnit unit) /// /// Length.TryParseUnit("m", new CultureInfo("en-US")); /// - /// Format to use when parsing number and unit. Defaults to if null. + /// Format to use when parsing number and unit. Defaults to if null. public static bool TryParseUnit(string str, IFormatProvider? provider, out WarpingMomentOfInertiaUnit unit) { return UnitParser.Default.TryParse(str, provider, out unit); @@ -558,20 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) - { - return left.Equals(right); - } - - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -587,23 +544,6 @@ public int CompareTo(WarpingMomentOfInertia other) return _value.CompareTo(other.GetValueAs(this.Unit)); } - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if(obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) - return false; - - return Equals(objWarpingMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(WarpingMomentOfInertia other) - { - return _value.Equals(other.GetValueAs(this.Unit)); - } - /// /// /// Compare equality to another WarpingMomentOfInertia within the given absolute or relative tolerance. @@ -795,7 +735,7 @@ private double GetValueAs(WarpingMomentOfInertiaUnit unit) { var converted = ToUnit(unit); return (double)converted.Value; - } + } #endregion @@ -814,63 +754,29 @@ public override string ToString() /// Gets the default string representation of value and unit using the given format provider. /// /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. public string ToString(IFormatProvider? provider) { return ToString("g", provider); } - /// - /// Get string representation of value and unit. - /// - /// The number of significant digits after the radix point. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete(@"This method is deprecated and will be removed at a future release. Please use ToString(""s2"") or ToString(""s2"", provider) where 2 is an example of the number passed to significantDigitsAfterRadix.")] - public string ToString(IFormatProvider? provider, int significantDigitsAfterRadix) - { - var value = Convert.ToDouble(Value); - var format = UnitFormatter.GetFormat(value, significantDigitsAfterRadix); - return ToString(provider, format); - } - - /// - /// Get string representation of value and unit. - /// - /// String format to use. Default: "{0:0.##} {1} for value and unit abbreviation respectively." - /// Arguments for string format. Value and unit are implicitly included as arguments 0 and 1. - /// String representation. - /// Format to use for localization and number formatting. Defaults to if null. - [Obsolete("This method is deprecated and will be removed at a future release. Please use string.Format().")] - public string ToString(IFormatProvider? provider, [NotNull] string format, [NotNull] params object[] args) - { - if (format == null) throw new ArgumentNullException(nameof(format)); - if (args == null) throw new ArgumentNullException(nameof(args)); - - provider = provider ?? CultureInfo.CurrentUICulture; - - var value = Convert.ToDouble(Value); - var formatArgs = UnitFormatter.GetFormatArgs(Unit, value, provider, args); - return string.Format(provider, format, formatArgs); - } - /// /// - /// Gets the string representation of this instance in the specified format string using . + /// Gets the string representation of this instance in the specified format string using . /// /// The format string. /// The string representation. public string ToString(string format) { - return ToString(format, CultureInfo.CurrentUICulture); + return ToString(format, CultureInfo.CurrentCulture); } /// /// - /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. + /// Gets the string representation of this instance in the specified format string using the specified format provider, or if null. /// /// The format string. - /// Format to use for localization and number formatting. Defaults to if null. + /// Format to use for localization and number formatting. Defaults to if null. /// The string representation. public string ToString(string format, IFormatProvider? provider) { @@ -952,8 +858,6 @@ object IConvertible.ToType(Type conversionType, IFormatProvider provider) return this; else if(conversionType == typeof(WarpingMomentOfInertiaUnit)) return Unit; - else if(conversionType == typeof(QuantityType)) - return WarpingMomentOfInertia.QuantityType; else if(conversionType == typeof(QuantityInfo)) return WarpingMomentOfInertia.Info; else if(conversionType == typeof(BaseDimensions)) diff --git a/UnitsNet/GeneratedCode/Quantity.g.cs b/UnitsNet/GeneratedCode/Quantity.g.cs index 2a033a2d36..bae24d5f4a 100644 --- a/UnitsNet/GeneratedCode/Quantity.g.cs +++ b/UnitsNet/GeneratedCode/Quantity.g.cs @@ -19,8 +19,6 @@ using System; using System.Globalization; -using JetBrains.Annotations; -using UnitsNet.InternalHelpers; using UnitsNet.Units; using System.Collections.Generic; @@ -152,246 +150,6 @@ public static partial class Quantity { "WarpingMomentOfInertia", WarpingMomentOfInertia.Info }, }; - /// - /// Dynamically constructs a quantity of the given with the value in the quantity's base units. - /// - /// The of the quantity to create. - /// The value to construct the quantity with. - /// The created quantity. - [Obsolete("QuantityType will be removed. Use FromQuantityInfo(QuantityInfo, QuantityValue) instead.")] - public static IQuantity FromQuantityType(QuantityType quantityType, QuantityValue value) - { - switch(quantityType) - { - 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."); - } - } - /// /// Dynamically constructs a quantity of the given with the value in the quantity's base units. /// @@ -989,7 +747,7 @@ public static bool TryFrom(QuantityValue value, Enum unit, out IQuantity? quanti /// /// Try to dynamically parse a quantity string representation. /// - /// The format provider to use for lookup. Defaults to if null. + /// The format provider to use for lookup. Defaults to if null. /// Type of quantity, such as . /// Quantity string representation, such as "1.5 kg". Must be compatible with given quantity type. /// The resulting quantity if successful, otherwise default. @@ -998,7 +756,7 @@ public static bool TryParse(IFormatProvider? formatProvider, Type quantityType, { quantity = default(IQuantity); - if (!typeof(IQuantity).Wrap().IsAssignableFrom(quantityType)) + if (!typeof(IQuantity).IsAssignableFrom(quantityType)) return false; var parser = QuantityParser.Default; diff --git a/UnitsNet/GeneratedCode/Units/TemperatureGradientUnit.g.cs b/UnitsNet/GeneratedCode/Units/TemperatureGradientUnit.g.cs index 96522d6572..4e838b9e49 100644 --- a/UnitsNet/GeneratedCode/Units/TemperatureGradientUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TemperatureGradientUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TemperatureGradientUnit { - Undefined = 0, DegreeCelsiusPerKilometer, DegreeCelsiusPerMeter, DegreeFahrenheitPerFoot, diff --git a/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs b/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs index cb0b260725..c05db06585 100644 --- a/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/TorqueUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum TorqueUnit { - Undefined = 0, GramForceCentimeter, GramForceMeter, GramForceMillimeter, diff --git a/UnitsNet/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs b/UnitsNet/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs index 10ea6694f7..c89e187674 100644 --- a/UnitsNet/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs +++ b/UnitsNet/GeneratedCode/Units/VolumeFlowPerAreaUnit.g.cs @@ -25,7 +25,6 @@ namespace UnitsNet.Units public enum VolumeFlowPerAreaUnit { - Undefined = 0, CubicFootPerMinutePerSquareFoot, CubicMeterPerSecondPerSquareMeter, } diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index be618533d0..b1577a3276 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -39,7 +39,7 @@ public interface IQuantity : IFormattable double As(UnitSystem unitSystem); /// - /// The unit this quantity was constructed with -or- ConversionBaseUnit if default ctor was used. + /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. /// Enum Unit { get; } From ad5311ad8efd829e3ce336ece3bd6b3ed0c938b6 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 8 Feb 2022 22:44:46 +0100 Subject: [PATCH 48/66] Revert MaxValue, MinValue, QuantityType merged in from origin/master --- CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/BitRate.g.cs | 5 +---- .../Quantities/BrakeSpecificFuelConsumption.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs | 5 +---- .../Quantities/CoefficientOfThermalExpansion.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Density.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Duration.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs | 5 +---- .../GeneratedCode/Quantities/ElectricCurrentDensity.g.cs | 5 +---- .../GeneratedCode/Quantities/ElectricCurrentGradient.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs | 5 +---- .../Quantities/ElectricPotentialChangeRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs | 5 +---- .../Quantities/ElectricSurfaceChargeDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Entropy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Frequency.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs | 5 +---- .../GeneratedCode/Quantities/HeatTransferCoefficient.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Information.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Molarity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Permeability.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Pressure.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs | 5 +---- .../GeneratedCode/Quantities/RotationalAcceleration.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs | 5 +---- .../Quantities/RotationalStiffnessPerLength.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs | 5 +---- .../GeneratedCode/Quantities/SpecificFuelConsumption.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Temperature.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs | 5 +---- UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs | 5 +---- .../GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs | 5 +---- .../GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs | 5 +---- 113 files changed, 113 insertions(+), 452 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index fd8e42d1a8..8bc5c6609c 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -124,10 +124,7 @@ private void GenerateStaticConstructor() Writer.WL($@" BaseUnit = {_unitEnumName}.{_quantity.BaseUnit}; - MaxValue = new {_quantity.Name}({_valueType}.MaxValue, BaseUnit); - MinValue = new {_quantity.Name}({_valueType}.MinValue, BaseUnit); - QuantityType = QuantityType.{_quantity.Name}; - Units = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().Except(new {_unitEnumName}[]{{ {_unitEnumName}.Undefined }}).ToArray(); + Units = Enum.GetValues(typeof({_unitEnumName})).Cast<{_unitEnumName}>().ToArray(); Zero = new {_quantity.Name}(0, BaseUnit); Info = new QuantityInfo<{_unitEnumName}>(""{_quantity.Name}"", new UnitInfo<{_unitEnumName}>[] diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index ebce0f320b..4fefc8b20d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -53,10 +53,7 @@ static Acceleration() { BaseDimensions = new BaseDimensions(1, 0, -2, 0, 0, 0, 0); BaseUnit = AccelerationUnit.MeterPerSecondSquared; - MaxValue = new Acceleration(double.MaxValue, BaseUnit); - MinValue = new Acceleration(double.MinValue, BaseUnit); - QuantityType = QuantityType.Acceleration; - Units = Enum.GetValues(typeof(AccelerationUnit)).Cast().Except(new AccelerationUnit[]{ AccelerationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AccelerationUnit)).Cast().ToArray(); Zero = new Acceleration(0, BaseUnit); Info = new QuantityInfo("Acceleration", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 8dcae71a63..86b5ad1c29 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -53,10 +53,7 @@ static AmountOfSubstance() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 1, 0); BaseUnit = AmountOfSubstanceUnit.Mole; - MaxValue = new AmountOfSubstance(double.MaxValue, BaseUnit); - MinValue = new AmountOfSubstance(double.MinValue, BaseUnit); - QuantityType = QuantityType.AmountOfSubstance; - Units = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().Except(new AmountOfSubstanceUnit[]{ AmountOfSubstanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AmountOfSubstanceUnit)).Cast().ToArray(); Zero = new AmountOfSubstance(0, BaseUnit); Info = new QuantityInfo("AmountOfSubstance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index fc836a0822..4021996b1d 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -53,10 +53,7 @@ static AmplitudeRatio() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = AmplitudeRatioUnit.DecibelVolt; - MaxValue = new AmplitudeRatio(double.MaxValue, BaseUnit); - MinValue = new AmplitudeRatio(double.MinValue, BaseUnit); - QuantityType = QuantityType.AmplitudeRatio; - Units = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().Except(new AmplitudeRatioUnit[]{ AmplitudeRatioUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AmplitudeRatioUnit)).Cast().ToArray(); Zero = new AmplitudeRatio(0, BaseUnit); Info = new QuantityInfo("AmplitudeRatio", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 1c491fe14b..912100dacb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -53,10 +53,7 @@ static Angle() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = AngleUnit.Degree; - MaxValue = new Angle(double.MaxValue, BaseUnit); - MinValue = new Angle(double.MinValue, BaseUnit); - QuantityType = QuantityType.Angle; - Units = Enum.GetValues(typeof(AngleUnit)).Cast().Except(new AngleUnit[]{ AngleUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AngleUnit)).Cast().ToArray(); Zero = new Angle(0, BaseUnit); Info = new QuantityInfo("Angle", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index 21405e7c2f..da219d1054 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -53,10 +53,7 @@ static ApparentEnergy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); BaseUnit = ApparentEnergyUnit.VoltampereHour; - MaxValue = new ApparentEnergy(double.MaxValue, BaseUnit); - MinValue = new ApparentEnergy(double.MinValue, BaseUnit); - QuantityType = QuantityType.ApparentEnergy; - Units = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().Except(new ApparentEnergyUnit[]{ ApparentEnergyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ApparentEnergyUnit)).Cast().ToArray(); Zero = new ApparentEnergy(0, BaseUnit); Info = new QuantityInfo("ApparentEnergy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index aaf4948fda..0b3f5efd41 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -53,10 +53,7 @@ static ApparentPower() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); BaseUnit = ApparentPowerUnit.Voltampere; - MaxValue = new ApparentPower(double.MaxValue, BaseUnit); - MinValue = new ApparentPower(double.MinValue, BaseUnit); - QuantityType = QuantityType.ApparentPower; - Units = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().Except(new ApparentPowerUnit[]{ ApparentPowerUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ApparentPowerUnit)).Cast().ToArray(); Zero = new ApparentPower(0, BaseUnit); Info = new QuantityInfo("ApparentPower", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index 7247872f09..643192fedf 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -53,10 +53,7 @@ static Area() { BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); BaseUnit = AreaUnit.SquareMeter; - MaxValue = new Area(double.MaxValue, BaseUnit); - MinValue = new Area(double.MinValue, BaseUnit); - QuantityType = QuantityType.Area; - Units = Enum.GetValues(typeof(AreaUnit)).Cast().Except(new AreaUnit[]{ AreaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AreaUnit)).Cast().ToArray(); Zero = new Area(0, BaseUnit); Info = new QuantityInfo("Area", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 6cdbf1ab2c..fbc5d484be 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -53,10 +53,7 @@ static AreaDensity() { BaseDimensions = new BaseDimensions(-2, 1, 0, 0, 0, 0, 0); BaseUnit = AreaDensityUnit.KilogramPerSquareMeter; - MaxValue = new AreaDensity(double.MaxValue, BaseUnit); - MinValue = new AreaDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.AreaDensity; - Units = Enum.GetValues(typeof(AreaDensityUnit)).Cast().Except(new AreaDensityUnit[]{ AreaDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AreaDensityUnit)).Cast().ToArray(); Zero = new AreaDensity(0, BaseUnit); Info = new QuantityInfo("AreaDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 3a74192b19..34520b6739 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -53,10 +53,7 @@ static AreaMomentOfInertia() { BaseDimensions = new BaseDimensions(4, 0, 0, 0, 0, 0, 0); BaseUnit = AreaMomentOfInertiaUnit.MeterToTheFourth; - MaxValue = new AreaMomentOfInertia(double.MaxValue, BaseUnit); - MinValue = new AreaMomentOfInertia(double.MinValue, BaseUnit); - QuantityType = QuantityType.AreaMomentOfInertia; - Units = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().Except(new AreaMomentOfInertiaUnit[]{ AreaMomentOfInertiaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(AreaMomentOfInertiaUnit)).Cast().ToArray(); Zero = new AreaMomentOfInertia(0, BaseUnit); Info = new QuantityInfo("AreaMomentOfInertia", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index d5e188f2e9..4b35958b3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -56,10 +56,7 @@ static BitRate() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); BaseUnit = BitRateUnit.BitPerSecond; - MaxValue = new BitRate(decimal.MaxValue, BaseUnit); - MinValue = new BitRate(decimal.MinValue, BaseUnit); - QuantityType = QuantityType.BitRate; - Units = Enum.GetValues(typeof(BitRateUnit)).Cast().Except(new BitRateUnit[]{ BitRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(BitRateUnit)).Cast().ToArray(); Zero = new BitRate(0, BaseUnit); Info = new QuantityInfo("BitRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 561f4e0043..f70aa2b02f 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -53,10 +53,7 @@ static BrakeSpecificFuelConsumption() { BaseDimensions = new BaseDimensions(-2, 0, 2, 0, 0, 0, 0); BaseUnit = BrakeSpecificFuelConsumptionUnit.KilogramPerJoule; - MaxValue = new BrakeSpecificFuelConsumption(double.MaxValue, BaseUnit); - MinValue = new BrakeSpecificFuelConsumption(double.MinValue, BaseUnit); - QuantityType = QuantityType.BrakeSpecificFuelConsumption; - Units = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().Except(new BrakeSpecificFuelConsumptionUnit[]{ BrakeSpecificFuelConsumptionUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(BrakeSpecificFuelConsumptionUnit)).Cast().ToArray(); Zero = new BrakeSpecificFuelConsumption(0, BaseUnit); Info = new QuantityInfo("BrakeSpecificFuelConsumption", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 1fa5fbf214..0b31b5f29e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -56,10 +56,7 @@ static Capacitance() { BaseDimensions = new BaseDimensions(-2, -1, 4, 2, 0, 0, 0); BaseUnit = CapacitanceUnit.Farad; - MaxValue = new Capacitance(double.MaxValue, BaseUnit); - MinValue = new Capacitance(double.MinValue, BaseUnit); - QuantityType = QuantityType.Capacitance; - Units = Enum.GetValues(typeof(CapacitanceUnit)).Cast().Except(new CapacitanceUnit[]{ CapacitanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(CapacitanceUnit)).Cast().ToArray(); Zero = new Capacitance(0, BaseUnit); Info = new QuantityInfo("Capacitance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 3d8b263e9f..9948d2e45e 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -53,10 +53,7 @@ static CoefficientOfThermalExpansion() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, -1, 0, 0); BaseUnit = CoefficientOfThermalExpansionUnit.InverseKelvin; - MaxValue = new CoefficientOfThermalExpansion(double.MaxValue, BaseUnit); - MinValue = new CoefficientOfThermalExpansion(double.MinValue, BaseUnit); - QuantityType = QuantityType.CoefficientOfThermalExpansion; - Units = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().Except(new CoefficientOfThermalExpansionUnit[]{ CoefficientOfThermalExpansionUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(CoefficientOfThermalExpansionUnit)).Cast().ToArray(); Zero = new CoefficientOfThermalExpansion(0, BaseUnit); Info = new QuantityInfo("CoefficientOfThermalExpansion", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index c8d175aee9..47fa34b8ad 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -56,10 +56,7 @@ static Density() { BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); BaseUnit = DensityUnit.KilogramPerCubicMeter; - MaxValue = new Density(double.MaxValue, BaseUnit); - MinValue = new Density(double.MinValue, BaseUnit); - QuantityType = QuantityType.Density; - Units = Enum.GetValues(typeof(DensityUnit)).Cast().Except(new DensityUnit[]{ DensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(DensityUnit)).Cast().ToArray(); Zero = new Density(0, BaseUnit); Info = new QuantityInfo("Density", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 1694cc27c8..fad9f655c0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -53,10 +53,7 @@ static Duration() { BaseDimensions = new BaseDimensions(0, 0, 1, 0, 0, 0, 0); BaseUnit = DurationUnit.Second; - MaxValue = new Duration(double.MaxValue, BaseUnit); - MinValue = new Duration(double.MinValue, BaseUnit); - QuantityType = QuantityType.Duration; - Units = Enum.GetValues(typeof(DurationUnit)).Cast().Except(new DurationUnit[]{ DurationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(DurationUnit)).Cast().ToArray(); Zero = new Duration(0, BaseUnit); Info = new QuantityInfo("Duration", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 31ba433faf..fba29ee39e 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -56,10 +56,7 @@ static DynamicViscosity() { BaseDimensions = new BaseDimensions(-1, 1, -1, 0, 0, 0, 0); BaseUnit = DynamicViscosityUnit.NewtonSecondPerMeterSquared; - MaxValue = new DynamicViscosity(double.MaxValue, BaseUnit); - MinValue = new DynamicViscosity(double.MinValue, BaseUnit); - QuantityType = QuantityType.DynamicViscosity; - Units = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().Except(new DynamicViscosityUnit[]{ DynamicViscosityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(DynamicViscosityUnit)).Cast().ToArray(); Zero = new DynamicViscosity(0, BaseUnit); Info = new QuantityInfo("DynamicViscosity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 35043d2f42..bcb74eb388 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -53,10 +53,7 @@ static ElectricAdmittance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); BaseUnit = ElectricAdmittanceUnit.Siemens; - MaxValue = new ElectricAdmittance(double.MaxValue, BaseUnit); - MinValue = new ElectricAdmittance(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricAdmittance; - Units = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().Except(new ElectricAdmittanceUnit[]{ ElectricAdmittanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricAdmittanceUnit)).Cast().ToArray(); Zero = new ElectricAdmittance(0, BaseUnit); Info = new QuantityInfo("ElectricAdmittance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 164a4426bf..aaa4b4add1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -56,10 +56,7 @@ static ElectricCharge() { BaseDimensions = new BaseDimensions(0, 0, 1, 1, 0, 0, 0); BaseUnit = ElectricChargeUnit.Coulomb; - MaxValue = new ElectricCharge(double.MaxValue, BaseUnit); - MinValue = new ElectricCharge(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricCharge; - Units = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().Except(new ElectricChargeUnit[]{ ElectricChargeUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricChargeUnit)).Cast().ToArray(); Zero = new ElectricCharge(0, BaseUnit); Info = new QuantityInfo("ElectricCharge", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 5159730292..9b0e6bc1ab 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -56,10 +56,7 @@ static ElectricChargeDensity() { BaseDimensions = new BaseDimensions(-3, 0, 1, 1, 0, 0, 0); BaseUnit = ElectricChargeDensityUnit.CoulombPerCubicMeter; - MaxValue = new ElectricChargeDensity(double.MaxValue, BaseUnit); - MinValue = new ElectricChargeDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricChargeDensity; - Units = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().Except(new ElectricChargeDensityUnit[]{ ElectricChargeDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricChargeDensityUnit)).Cast().ToArray(); Zero = new ElectricChargeDensity(0, BaseUnit); Info = new QuantityInfo("ElectricChargeDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index d3ce17a00d..585e100eb0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -56,10 +56,7 @@ static ElectricConductance() { BaseDimensions = new BaseDimensions(-2, -1, 3, 2, 0, 0, 0); BaseUnit = ElectricConductanceUnit.Siemens; - MaxValue = new ElectricConductance(double.MaxValue, BaseUnit); - MinValue = new ElectricConductance(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricConductance; - Units = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().Except(new ElectricConductanceUnit[]{ ElectricConductanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricConductanceUnit)).Cast().ToArray(); Zero = new ElectricConductance(0, BaseUnit); Info = new QuantityInfo("ElectricConductance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index f5cd771b98..2f83032118 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -56,10 +56,7 @@ static ElectricConductivity() { BaseDimensions = new BaseDimensions(-3, -1, 3, 2, 0, 0, 0); BaseUnit = ElectricConductivityUnit.SiemensPerMeter; - MaxValue = new ElectricConductivity(double.MaxValue, BaseUnit); - MinValue = new ElectricConductivity(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricConductivity; - Units = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().Except(new ElectricConductivityUnit[]{ ElectricConductivityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricConductivityUnit)).Cast().ToArray(); Zero = new ElectricConductivity(0, BaseUnit); Info = new QuantityInfo("ElectricConductivity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index e6cbe1735a..18dbe5203c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -53,10 +53,7 @@ static ElectricCurrent() { BaseDimensions = new BaseDimensions(0, 0, 0, 1, 0, 0, 0); BaseUnit = ElectricCurrentUnit.Ampere; - MaxValue = new ElectricCurrent(double.MaxValue, BaseUnit); - MinValue = new ElectricCurrent(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricCurrent; - Units = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().Except(new ElectricCurrentUnit[]{ ElectricCurrentUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricCurrentUnit)).Cast().ToArray(); Zero = new ElectricCurrent(0, BaseUnit); Info = new QuantityInfo("ElectricCurrent", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 72242763ea..b4d19178fe 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -56,10 +56,7 @@ static ElectricCurrentDensity() { BaseDimensions = new BaseDimensions(-2, 0, 0, 1, 0, 0, 0); BaseUnit = ElectricCurrentDensityUnit.AmperePerSquareMeter; - MaxValue = new ElectricCurrentDensity(double.MaxValue, BaseUnit); - MinValue = new ElectricCurrentDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricCurrentDensity; - Units = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().Except(new ElectricCurrentDensityUnit[]{ ElectricCurrentDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricCurrentDensityUnit)).Cast().ToArray(); Zero = new ElectricCurrentDensity(0, BaseUnit); Info = new QuantityInfo("ElectricCurrentDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index c48f5cd723..01ec4f88e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -53,10 +53,7 @@ static ElectricCurrentGradient() { BaseDimensions = new BaseDimensions(0, 0, -1, 1, 0, 0, 0); BaseUnit = ElectricCurrentGradientUnit.AmperePerSecond; - MaxValue = new ElectricCurrentGradient(double.MaxValue, BaseUnit); - MinValue = new ElectricCurrentGradient(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricCurrentGradient; - Units = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().Except(new ElectricCurrentGradientUnit[]{ ElectricCurrentGradientUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricCurrentGradientUnit)).Cast().ToArray(); Zero = new ElectricCurrentGradient(0, BaseUnit); Info = new QuantityInfo("ElectricCurrentGradient", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index c2c22d1dfb..6ed08f4f56 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -56,10 +56,7 @@ static ElectricField() { BaseDimensions = new BaseDimensions(1, 1, -3, -1, 0, 0, 0); BaseUnit = ElectricFieldUnit.VoltPerMeter; - MaxValue = new ElectricField(double.MaxValue, BaseUnit); - MinValue = new ElectricField(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricField; - Units = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().Except(new ElectricFieldUnit[]{ ElectricFieldUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricFieldUnit)).Cast().ToArray(); Zero = new ElectricField(0, BaseUnit); Info = new QuantityInfo("ElectricField", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 189c454274..4b48269a76 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -56,10 +56,7 @@ static ElectricInductance() { BaseDimensions = new BaseDimensions(2, 1, -2, -2, 0, 0, 0); BaseUnit = ElectricInductanceUnit.Henry; - MaxValue = new ElectricInductance(double.MaxValue, BaseUnit); - MinValue = new ElectricInductance(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricInductance; - Units = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().Except(new ElectricInductanceUnit[]{ ElectricInductanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricInductanceUnit)).Cast().ToArray(); Zero = new ElectricInductance(0, BaseUnit); Info = new QuantityInfo("ElectricInductance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 2377d7b4fb..c08f0498f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -53,10 +53,7 @@ static ElectricPotential() { BaseDimensions = new BaseDimensions(2, 1, -3, -1, 0, 0, 0); BaseUnit = ElectricPotentialUnit.Volt; - MaxValue = new ElectricPotential(double.MaxValue, BaseUnit); - MinValue = new ElectricPotential(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricPotential; - Units = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().Except(new ElectricPotentialUnit[]{ ElectricPotentialUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricPotentialUnit)).Cast().ToArray(); Zero = new ElectricPotential(0, BaseUnit); Info = new QuantityInfo("ElectricPotential", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index 35ac727e30..957bd519ea 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -53,10 +53,7 @@ static ElectricPotentialAc() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = ElectricPotentialAcUnit.VoltAc; - MaxValue = new ElectricPotentialAc(double.MaxValue, BaseUnit); - MinValue = new ElectricPotentialAc(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricPotentialAc; - Units = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().Except(new ElectricPotentialAcUnit[]{ ElectricPotentialAcUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricPotentialAcUnit)).Cast().ToArray(); Zero = new ElectricPotentialAc(0, BaseUnit); Info = new QuantityInfo("ElectricPotentialAc", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 3066a4d90f..301ca139dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -53,10 +53,7 @@ static ElectricPotentialChangeRate() { BaseDimensions = new BaseDimensions(2, 1, -4, -1, 0, 0, 0); BaseUnit = ElectricPotentialChangeRateUnit.VoltPerSecond; - MaxValue = new ElectricPotentialChangeRate(double.MaxValue, BaseUnit); - MinValue = new ElectricPotentialChangeRate(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricPotentialChangeRate; - Units = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast().Except(new ElectricPotentialChangeRateUnit[]{ ElectricPotentialChangeRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricPotentialChangeRateUnit)).Cast().ToArray(); Zero = new ElectricPotentialChangeRate(0, BaseUnit); Info = new QuantityInfo("ElectricPotentialChangeRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index f91ea68422..b9ec1f7ddf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -53,10 +53,7 @@ static ElectricPotentialDc() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = ElectricPotentialDcUnit.VoltDc; - MaxValue = new ElectricPotentialDc(double.MaxValue, BaseUnit); - MinValue = new ElectricPotentialDc(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricPotentialDc; - Units = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().Except(new ElectricPotentialDcUnit[]{ ElectricPotentialDcUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricPotentialDcUnit)).Cast().ToArray(); Zero = new ElectricPotentialDc(0, BaseUnit); Info = new QuantityInfo("ElectricPotentialDc", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 849e068929..6c2d2b1fa6 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -53,10 +53,7 @@ static ElectricResistance() { BaseDimensions = new BaseDimensions(2, 1, -3, -2, 0, 0, 0); BaseUnit = ElectricResistanceUnit.Ohm; - MaxValue = new ElectricResistance(double.MaxValue, BaseUnit); - MinValue = new ElectricResistance(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricResistance; - Units = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().Except(new ElectricResistanceUnit[]{ ElectricResistanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricResistanceUnit)).Cast().ToArray(); Zero = new ElectricResistance(0, BaseUnit); Info = new QuantityInfo("ElectricResistance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index fadba2fb33..7510528e03 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -56,10 +56,7 @@ static ElectricResistivity() { BaseDimensions = new BaseDimensions(3, 1, -3, -2, 0, 0, 0); BaseUnit = ElectricResistivityUnit.OhmMeter; - MaxValue = new ElectricResistivity(double.MaxValue, BaseUnit); - MinValue = new ElectricResistivity(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricResistivity; - Units = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().Except(new ElectricResistivityUnit[]{ ElectricResistivityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricResistivityUnit)).Cast().ToArray(); Zero = new ElectricResistivity(0, BaseUnit); Info = new QuantityInfo("ElectricResistivity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index f46c896115..4c6c50bdd3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -56,10 +56,7 @@ static ElectricSurfaceChargeDensity() { BaseDimensions = new BaseDimensions(-2, 0, 1, 1, 0, 0, 0); BaseUnit = ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter; - MaxValue = new ElectricSurfaceChargeDensity(double.MaxValue, BaseUnit); - MinValue = new ElectricSurfaceChargeDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.ElectricSurfaceChargeDensity; - Units = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast().Except(new ElectricSurfaceChargeDensityUnit[]{ ElectricSurfaceChargeDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ElectricSurfaceChargeDensityUnit)).Cast().ToArray(); Zero = new ElectricSurfaceChargeDensity(0, BaseUnit); Info = new QuantityInfo("ElectricSurfaceChargeDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 77c78e47fa..8169a65b04 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -53,10 +53,7 @@ static Energy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); BaseUnit = EnergyUnit.Joule; - MaxValue = new Energy(double.MaxValue, BaseUnit); - MinValue = new Energy(double.MinValue, BaseUnit); - QuantityType = QuantityType.Energy; - Units = Enum.GetValues(typeof(EnergyUnit)).Cast().Except(new EnergyUnit[]{ EnergyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(EnergyUnit)).Cast().ToArray(); Zero = new Energy(0, BaseUnit); Info = new QuantityInfo("Energy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index d454624d1d..ad67a3d183 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -53,10 +53,7 @@ static Entropy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, 0, 0); BaseUnit = EntropyUnit.JoulePerKelvin; - MaxValue = new Entropy(double.MaxValue, BaseUnit); - MinValue = new Entropy(double.MinValue, BaseUnit); - QuantityType = QuantityType.Entropy; - Units = Enum.GetValues(typeof(EntropyUnit)).Cast().Except(new EntropyUnit[]{ EntropyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(EntropyUnit)).Cast().ToArray(); Zero = new Entropy(0, BaseUnit); Info = new QuantityInfo("Entropy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index d887b03194..36611b9d11 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -53,10 +53,7 @@ static Force() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); BaseUnit = ForceUnit.Newton; - MaxValue = new Force(double.MaxValue, BaseUnit); - MinValue = new Force(double.MinValue, BaseUnit); - QuantityType = QuantityType.Force; - Units = Enum.GetValues(typeof(ForceUnit)).Cast().Except(new ForceUnit[]{ ForceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ForceUnit)).Cast().ToArray(); Zero = new Force(0, BaseUnit); Info = new QuantityInfo("Force", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index c7c0452c9f..565bbc223b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -53,10 +53,7 @@ static ForceChangeRate() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); BaseUnit = ForceChangeRateUnit.NewtonPerSecond; - MaxValue = new ForceChangeRate(double.MaxValue, BaseUnit); - MinValue = new ForceChangeRate(double.MinValue, BaseUnit); - QuantityType = QuantityType.ForceChangeRate; - Units = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().Except(new ForceChangeRateUnit[]{ ForceChangeRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ForceChangeRateUnit)).Cast().ToArray(); Zero = new ForceChangeRate(0, BaseUnit); Info = new QuantityInfo("ForceChangeRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 3dc594a43c..9cb32d408d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -53,10 +53,7 @@ static ForcePerLength() { BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); BaseUnit = ForcePerLengthUnit.NewtonPerMeter; - MaxValue = new ForcePerLength(double.MaxValue, BaseUnit); - MinValue = new ForcePerLength(double.MinValue, BaseUnit); - QuantityType = QuantityType.ForcePerLength; - Units = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().Except(new ForcePerLengthUnit[]{ ForcePerLengthUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ForcePerLengthUnit)).Cast().ToArray(); Zero = new ForcePerLength(0, BaseUnit); Info = new QuantityInfo("ForcePerLength", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index b4a9b7cc44..1139fa35fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -53,10 +53,7 @@ static Frequency() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); BaseUnit = FrequencyUnit.Hertz; - MaxValue = new Frequency(double.MaxValue, BaseUnit); - MinValue = new Frequency(double.MinValue, BaseUnit); - QuantityType = QuantityType.Frequency; - Units = Enum.GetValues(typeof(FrequencyUnit)).Cast().Except(new FrequencyUnit[]{ FrequencyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(FrequencyUnit)).Cast().ToArray(); Zero = new Frequency(0, BaseUnit); Info = new QuantityInfo("Frequency", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 8f12d766b6..980ed2e5fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -56,10 +56,7 @@ static FuelEfficiency() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = FuelEfficiencyUnit.LiterPer100Kilometers; - MaxValue = new FuelEfficiency(double.MaxValue, BaseUnit); - MinValue = new FuelEfficiency(double.MinValue, BaseUnit); - QuantityType = QuantityType.FuelEfficiency; - Units = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast().Except(new FuelEfficiencyUnit[]{ FuelEfficiencyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(FuelEfficiencyUnit)).Cast().ToArray(); Zero = new FuelEfficiency(0, BaseUnit); Info = new QuantityInfo("FuelEfficiency", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 4b5fc81aff..2e58e55878 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -53,10 +53,7 @@ static HeatFlux() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); BaseUnit = HeatFluxUnit.WattPerSquareMeter; - MaxValue = new HeatFlux(double.MaxValue, BaseUnit); - MinValue = new HeatFlux(double.MinValue, BaseUnit); - QuantityType = QuantityType.HeatFlux; - Units = Enum.GetValues(typeof(HeatFluxUnit)).Cast().Except(new HeatFluxUnit[]{ HeatFluxUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(HeatFluxUnit)).Cast().ToArray(); Zero = new HeatFlux(0, BaseUnit); Info = new QuantityInfo("HeatFlux", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index b727cebe2d..8734364149 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -53,10 +53,7 @@ static HeatTransferCoefficient() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, -1, 0, 0); BaseUnit = HeatTransferCoefficientUnit.WattPerSquareMeterKelvin; - MaxValue = new HeatTransferCoefficient(double.MaxValue, BaseUnit); - MinValue = new HeatTransferCoefficient(double.MinValue, BaseUnit); - QuantityType = QuantityType.HeatTransferCoefficient; - Units = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().Except(new HeatTransferCoefficientUnit[]{ HeatTransferCoefficientUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(HeatTransferCoefficientUnit)).Cast().ToArray(); Zero = new HeatTransferCoefficient(0, BaseUnit); Info = new QuantityInfo("HeatTransferCoefficient", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 85976ffc02..0cc0d125e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -56,10 +56,7 @@ static Illuminance() { BaseDimensions = new BaseDimensions(-2, 0, 0, 0, 0, 0, 1); BaseUnit = IlluminanceUnit.Lux; - MaxValue = new Illuminance(double.MaxValue, BaseUnit); - MinValue = new Illuminance(double.MinValue, BaseUnit); - QuantityType = QuantityType.Illuminance; - Units = Enum.GetValues(typeof(IlluminanceUnit)).Cast().Except(new IlluminanceUnit[]{ IlluminanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(IlluminanceUnit)).Cast().ToArray(); Zero = new Illuminance(0, BaseUnit); Info = new QuantityInfo("Illuminance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 75aae4fde5..fd08ac7064 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -53,10 +53,7 @@ static Information() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = InformationUnit.Bit; - MaxValue = new Information(decimal.MaxValue, BaseUnit); - MinValue = new Information(decimal.MinValue, BaseUnit); - QuantityType = QuantityType.Information; - Units = Enum.GetValues(typeof(InformationUnit)).Cast().Except(new InformationUnit[]{ InformationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(InformationUnit)).Cast().ToArray(); Zero = new Information(0, BaseUnit); Info = new QuantityInfo("Information", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 38b7bd0d92..c1881678b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -53,10 +53,7 @@ static Irradiance() { BaseDimensions = new BaseDimensions(0, 1, -3, 0, 0, 0, 0); BaseUnit = IrradianceUnit.WattPerSquareMeter; - MaxValue = new Irradiance(double.MaxValue, BaseUnit); - MinValue = new Irradiance(double.MinValue, BaseUnit); - QuantityType = QuantityType.Irradiance; - Units = Enum.GetValues(typeof(IrradianceUnit)).Cast().Except(new IrradianceUnit[]{ IrradianceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(IrradianceUnit)).Cast().ToArray(); Zero = new Irradiance(0, BaseUnit); Info = new QuantityInfo("Irradiance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 57d42f0684..a6e24e79fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -56,10 +56,7 @@ static Irradiation() { BaseDimensions = new BaseDimensions(0, 1, -2, 0, 0, 0, 0); BaseUnit = IrradiationUnit.JoulePerSquareMeter; - MaxValue = new Irradiation(double.MaxValue, BaseUnit); - MinValue = new Irradiation(double.MinValue, BaseUnit); - QuantityType = QuantityType.Irradiation; - Units = Enum.GetValues(typeof(IrradiationUnit)).Cast().Except(new IrradiationUnit[]{ IrradiationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(IrradiationUnit)).Cast().ToArray(); Zero = new Irradiation(0, BaseUnit); Info = new QuantityInfo("Irradiation", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 2697cb2a1b..1e805ac81a 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -56,10 +56,7 @@ static KinematicViscosity() { BaseDimensions = new BaseDimensions(2, 0, -1, 0, 0, 0, 0); BaseUnit = KinematicViscosityUnit.SquareMeterPerSecond; - MaxValue = new KinematicViscosity(double.MaxValue, BaseUnit); - MinValue = new KinematicViscosity(double.MinValue, BaseUnit); - QuantityType = QuantityType.KinematicViscosity; - Units = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().Except(new KinematicViscosityUnit[]{ KinematicViscosityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(KinematicViscosityUnit)).Cast().ToArray(); Zero = new KinematicViscosity(0, BaseUnit); Info = new QuantityInfo("KinematicViscosity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 8536b93a47..d5c6d2fe96 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -54,10 +54,7 @@ static LapseRate() { BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0); BaseUnit = LapseRateUnit.DegreeCelsiusPerKilometer; - MaxValue = new LapseRate(double.MaxValue, BaseUnit); - MinValue = new LapseRate(double.MinValue, BaseUnit); - QuantityType = QuantityType.LapseRate; - Units = Enum.GetValues(typeof(LapseRateUnit)).Cast().Except(new LapseRateUnit[]{ LapseRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LapseRateUnit)).Cast().ToArray(); Zero = new LapseRate(0, BaseUnit); Info = new QuantityInfo("LapseRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 46bdd38a14..3252218822 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -53,10 +53,7 @@ static Length() { BaseDimensions = new BaseDimensions(1, 0, 0, 0, 0, 0, 0); BaseUnit = LengthUnit.Meter; - MaxValue = new Length(double.MaxValue, BaseUnit); - MinValue = new Length(double.MinValue, BaseUnit); - QuantityType = QuantityType.Length; - Units = Enum.GetValues(typeof(LengthUnit)).Cast().Except(new LengthUnit[]{ LengthUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LengthUnit)).Cast().ToArray(); Zero = new Length(0, BaseUnit); Info = new QuantityInfo("Length", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index f5ae6fcc54..04f904fc5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -53,10 +53,7 @@ static Level() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = LevelUnit.Decibel; - MaxValue = new Level(double.MaxValue, BaseUnit); - MinValue = new Level(double.MinValue, BaseUnit); - QuantityType = QuantityType.Level; - Units = Enum.GetValues(typeof(LevelUnit)).Cast().Except(new LevelUnit[]{ LevelUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LevelUnit)).Cast().ToArray(); Zero = new Level(0, BaseUnit); Info = new QuantityInfo("Level", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 66c93f2578..dde2bd6414 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -56,10 +56,7 @@ static LinearDensity() { BaseDimensions = new BaseDimensions(-1, 1, 0, 0, 0, 0, 0); BaseUnit = LinearDensityUnit.KilogramPerMeter; - MaxValue = new LinearDensity(double.MaxValue, BaseUnit); - MinValue = new LinearDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.LinearDensity; - Units = Enum.GetValues(typeof(LinearDensityUnit)).Cast().Except(new LinearDensityUnit[]{ LinearDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LinearDensityUnit)).Cast().ToArray(); Zero = new LinearDensity(0, BaseUnit); Info = new QuantityInfo("LinearDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 7e47dede4e..a19614e44f 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -56,10 +56,7 @@ static LinearPowerDensity() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, 0, 0, 0); BaseUnit = LinearPowerDensityUnit.WattPerMeter; - MaxValue = new LinearPowerDensity(double.MaxValue, BaseUnit); - MinValue = new LinearPowerDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.LinearPowerDensity; - Units = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast().Except(new LinearPowerDensityUnit[]{ LinearPowerDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LinearPowerDensityUnit)).Cast().ToArray(); Zero = new LinearPowerDensity(0, BaseUnit); Info = new QuantityInfo("LinearPowerDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 6de38ac3f5..c3f54bd321 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -56,10 +56,7 @@ static Luminosity() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); BaseUnit = LuminosityUnit.Watt; - MaxValue = new Luminosity(double.MaxValue, BaseUnit); - MinValue = new Luminosity(double.MinValue, BaseUnit); - QuantityType = QuantityType.Luminosity; - Units = Enum.GetValues(typeof(LuminosityUnit)).Cast().Except(new LuminosityUnit[]{ LuminosityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LuminosityUnit)).Cast().ToArray(); Zero = new Luminosity(0, BaseUnit); Info = new QuantityInfo("Luminosity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index a0ebc8ef96..72eae16d53 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -56,10 +56,7 @@ static LuminousFlux() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); BaseUnit = LuminousFluxUnit.Lumen; - MaxValue = new LuminousFlux(double.MaxValue, BaseUnit); - MinValue = new LuminousFlux(double.MinValue, BaseUnit); - QuantityType = QuantityType.LuminousFlux; - Units = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().Except(new LuminousFluxUnit[]{ LuminousFluxUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LuminousFluxUnit)).Cast().ToArray(); Zero = new LuminousFlux(0, BaseUnit); Info = new QuantityInfo("LuminousFlux", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 70bbbc7802..1e7f3afbe1 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -56,10 +56,7 @@ static LuminousIntensity() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 0, 0, 1); BaseUnit = LuminousIntensityUnit.Candela; - MaxValue = new LuminousIntensity(double.MaxValue, BaseUnit); - MinValue = new LuminousIntensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.LuminousIntensity; - Units = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().Except(new LuminousIntensityUnit[]{ LuminousIntensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(LuminousIntensityUnit)).Cast().ToArray(); Zero = new LuminousIntensity(0, BaseUnit); Info = new QuantityInfo("LuminousIntensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 5a2a4abc43..df4dc20da6 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -56,10 +56,7 @@ static MagneticField() { BaseDimensions = new BaseDimensions(0, 1, -2, -1, 0, 0, 0); BaseUnit = MagneticFieldUnit.Tesla; - MaxValue = new MagneticField(double.MaxValue, BaseUnit); - MinValue = new MagneticField(double.MinValue, BaseUnit); - QuantityType = QuantityType.MagneticField; - Units = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().Except(new MagneticFieldUnit[]{ MagneticFieldUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MagneticFieldUnit)).Cast().ToArray(); Zero = new MagneticField(0, BaseUnit); Info = new QuantityInfo("MagneticField", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index f96cf1ffdf..397a6a80f8 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -56,10 +56,7 @@ static MagneticFlux() { BaseDimensions = new BaseDimensions(2, 1, -2, -1, 0, 0, 0); BaseUnit = MagneticFluxUnit.Weber; - MaxValue = new MagneticFlux(double.MaxValue, BaseUnit); - MinValue = new MagneticFlux(double.MinValue, BaseUnit); - QuantityType = QuantityType.MagneticFlux; - Units = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().Except(new MagneticFluxUnit[]{ MagneticFluxUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MagneticFluxUnit)).Cast().ToArray(); Zero = new MagneticFlux(0, BaseUnit); Info = new QuantityInfo("MagneticFlux", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 5380313ceb..ca202ff955 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -56,10 +56,7 @@ static Magnetization() { BaseDimensions = new BaseDimensions(-1, 0, 0, 1, 0, 0, 0); BaseUnit = MagnetizationUnit.AmperePerMeter; - MaxValue = new Magnetization(double.MaxValue, BaseUnit); - MinValue = new Magnetization(double.MinValue, BaseUnit); - QuantityType = QuantityType.Magnetization; - Units = Enum.GetValues(typeof(MagnetizationUnit)).Cast().Except(new MagnetizationUnit[]{ MagnetizationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MagnetizationUnit)).Cast().ToArray(); Zero = new Magnetization(0, BaseUnit); Info = new QuantityInfo("Magnetization", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 6c61cdfe1d..3d72acdadd 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -53,10 +53,7 @@ static Mass() { BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, 0, 0); BaseUnit = MassUnit.Kilogram; - MaxValue = new Mass(double.MaxValue, BaseUnit); - MinValue = new Mass(double.MinValue, BaseUnit); - QuantityType = QuantityType.Mass; - Units = Enum.GetValues(typeof(MassUnit)).Cast().Except(new MassUnit[]{ MassUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MassUnit)).Cast().ToArray(); Zero = new Mass(0, BaseUnit); Info = new QuantityInfo("Mass", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 3ab6bffa55..019b27b196 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -56,10 +56,7 @@ static MassConcentration() { BaseDimensions = new BaseDimensions(-3, 1, 0, 0, 0, 0, 0); BaseUnit = MassConcentrationUnit.KilogramPerCubicMeter; - MaxValue = new MassConcentration(double.MaxValue, BaseUnit); - MinValue = new MassConcentration(double.MinValue, BaseUnit); - QuantityType = QuantityType.MassConcentration; - Units = Enum.GetValues(typeof(MassConcentrationUnit)).Cast().Except(new MassConcentrationUnit[]{ MassConcentrationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MassConcentrationUnit)).Cast().ToArray(); Zero = new MassConcentration(0, BaseUnit); Info = new QuantityInfo("MassConcentration", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 56c3299e00..2216d21e26 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -53,10 +53,7 @@ static MassFlow() { BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); BaseUnit = MassFlowUnit.GramPerSecond; - MaxValue = new MassFlow(double.MaxValue, BaseUnit); - MinValue = new MassFlow(double.MinValue, BaseUnit); - QuantityType = QuantityType.MassFlow; - Units = Enum.GetValues(typeof(MassFlowUnit)).Cast().Except(new MassFlowUnit[]{ MassFlowUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MassFlowUnit)).Cast().ToArray(); Zero = new MassFlow(0, BaseUnit); Info = new QuantityInfo("MassFlow", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 9522b5e08c..8d08a6c266 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -53,10 +53,7 @@ static MassFlux() { BaseDimensions = new BaseDimensions(-2, 1, -1, 0, 0, 0, 0); BaseUnit = MassFluxUnit.KilogramPerSecondPerSquareMeter; - MaxValue = new MassFlux(double.MaxValue, BaseUnit); - MinValue = new MassFlux(double.MinValue, BaseUnit); - QuantityType = QuantityType.MassFlux; - Units = Enum.GetValues(typeof(MassFluxUnit)).Cast().Except(new MassFluxUnit[]{ MassFluxUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MassFluxUnit)).Cast().ToArray(); Zero = new MassFlux(0, BaseUnit); Info = new QuantityInfo("MassFlux", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index e65dee5ce5..3e6089aa9c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -56,10 +56,7 @@ static MassFraction() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = MassFractionUnit.DecimalFraction; - MaxValue = new MassFraction(double.MaxValue, BaseUnit); - MinValue = new MassFraction(double.MinValue, BaseUnit); - QuantityType = QuantityType.MassFraction; - Units = Enum.GetValues(typeof(MassFractionUnit)).Cast().Except(new MassFractionUnit[]{ MassFractionUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MassFractionUnit)).Cast().ToArray(); Zero = new MassFraction(0, BaseUnit); Info = new QuantityInfo("MassFraction", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 019b1992a9..9ef3563a3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -53,10 +53,7 @@ static MassMomentOfInertia() { BaseDimensions = new BaseDimensions(2, 1, 0, 0, 0, 0, 0); BaseUnit = MassMomentOfInertiaUnit.KilogramSquareMeter; - MaxValue = new MassMomentOfInertia(double.MaxValue, BaseUnit); - MinValue = new MassMomentOfInertia(double.MinValue, BaseUnit); - QuantityType = QuantityType.MassMomentOfInertia; - Units = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().Except(new MassMomentOfInertiaUnit[]{ MassMomentOfInertiaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MassMomentOfInertiaUnit)).Cast().ToArray(); Zero = new MassMomentOfInertia(0, BaseUnit); Info = new QuantityInfo("MassMomentOfInertia", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 6c211c711b..2ad7857380 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -53,10 +53,7 @@ static MolarEnergy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, -1, 0); BaseUnit = MolarEnergyUnit.JoulePerMole; - MaxValue = new MolarEnergy(double.MaxValue, BaseUnit); - MinValue = new MolarEnergy(double.MinValue, BaseUnit); - QuantityType = QuantityType.MolarEnergy; - Units = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().Except(new MolarEnergyUnit[]{ MolarEnergyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MolarEnergyUnit)).Cast().ToArray(); Zero = new MolarEnergy(0, BaseUnit); Info = new QuantityInfo("MolarEnergy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 6d4e5ca06b..022840e92b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -53,10 +53,7 @@ static MolarEntropy() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, -1, -1, 0); BaseUnit = MolarEntropyUnit.JoulePerMoleKelvin; - MaxValue = new MolarEntropy(double.MaxValue, BaseUnit); - MinValue = new MolarEntropy(double.MinValue, BaseUnit); - QuantityType = QuantityType.MolarEntropy; - Units = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().Except(new MolarEntropyUnit[]{ MolarEntropyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MolarEntropyUnit)).Cast().ToArray(); Zero = new MolarEntropy(0, BaseUnit); Info = new QuantityInfo("MolarEntropy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index e574b34ed6..388fab464e 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -53,10 +53,7 @@ static MolarMass() { BaseDimensions = new BaseDimensions(0, 1, 0, 0, 0, -1, 0); BaseUnit = MolarMassUnit.KilogramPerMole; - MaxValue = new MolarMass(double.MaxValue, BaseUnit); - MinValue = new MolarMass(double.MinValue, BaseUnit); - QuantityType = QuantityType.MolarMass; - Units = Enum.GetValues(typeof(MolarMassUnit)).Cast().Except(new MolarMassUnit[]{ MolarMassUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MolarMassUnit)).Cast().ToArray(); Zero = new MolarMass(0, BaseUnit); Info = new QuantityInfo("MolarMass", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 40a2bfc2b0..e480b3c9c7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -56,10 +56,7 @@ static Molarity() { BaseDimensions = new BaseDimensions(-3, 0, 0, 0, 0, 1, 0); BaseUnit = MolarityUnit.MolesPerCubicMeter; - MaxValue = new Molarity(double.MaxValue, BaseUnit); - MinValue = new Molarity(double.MinValue, BaseUnit); - QuantityType = QuantityType.Molarity; - Units = Enum.GetValues(typeof(MolarityUnit)).Cast().Except(new MolarityUnit[]{ MolarityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(MolarityUnit)).Cast().ToArray(); Zero = new Molarity(0, BaseUnit); Info = new QuantityInfo("Molarity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index dea8ebf24a..5521453f3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -56,10 +56,7 @@ static Permeability() { BaseDimensions = new BaseDimensions(1, 1, -2, -2, 0, 0, 0); BaseUnit = PermeabilityUnit.HenryPerMeter; - MaxValue = new Permeability(double.MaxValue, BaseUnit); - MinValue = new Permeability(double.MinValue, BaseUnit); - QuantityType = QuantityType.Permeability; - Units = Enum.GetValues(typeof(PermeabilityUnit)).Cast().Except(new PermeabilityUnit[]{ PermeabilityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PermeabilityUnit)).Cast().ToArray(); Zero = new Permeability(0, BaseUnit); Info = new QuantityInfo("Permeability", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index f5482b8d24..4505de7197 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -56,10 +56,7 @@ static Permittivity() { BaseDimensions = new BaseDimensions(-3, -1, 4, 2, 0, 0, 0); BaseUnit = PermittivityUnit.FaradPerMeter; - MaxValue = new Permittivity(double.MaxValue, BaseUnit); - MinValue = new Permittivity(double.MinValue, BaseUnit); - QuantityType = QuantityType.Permittivity; - Units = Enum.GetValues(typeof(PermittivityUnit)).Cast().Except(new PermittivityUnit[]{ PermittivityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PermittivityUnit)).Cast().ToArray(); Zero = new Permittivity(0, BaseUnit); Info = new QuantityInfo("Permittivity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 4a06e70d5d..953d52ee70 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -53,10 +53,7 @@ static Power() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); BaseUnit = PowerUnit.Watt; - MaxValue = new Power(decimal.MaxValue, BaseUnit); - MinValue = new Power(decimal.MinValue, BaseUnit); - QuantityType = QuantityType.Power; - Units = Enum.GetValues(typeof(PowerUnit)).Cast().Except(new PowerUnit[]{ PowerUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PowerUnit)).Cast().ToArray(); Zero = new Power(0, BaseUnit); Info = new QuantityInfo("Power", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index e76fb7e8f7..aeae72fdb1 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -53,10 +53,7 @@ static PowerDensity() { BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); BaseUnit = PowerDensityUnit.WattPerCubicMeter; - MaxValue = new PowerDensity(double.MaxValue, BaseUnit); - MinValue = new PowerDensity(double.MinValue, BaseUnit); - QuantityType = QuantityType.PowerDensity; - Units = Enum.GetValues(typeof(PowerDensityUnit)).Cast().Except(new PowerDensityUnit[]{ PowerDensityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PowerDensityUnit)).Cast().ToArray(); Zero = new PowerDensity(0, BaseUnit); Info = new QuantityInfo("PowerDensity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index d21924252a..763e5d5ba6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -53,10 +53,7 @@ static PowerRatio() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = PowerRatioUnit.DecibelWatt; - MaxValue = new PowerRatio(double.MaxValue, BaseUnit); - MinValue = new PowerRatio(double.MinValue, BaseUnit); - QuantityType = QuantityType.PowerRatio; - Units = Enum.GetValues(typeof(PowerRatioUnit)).Cast().Except(new PowerRatioUnit[]{ PowerRatioUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PowerRatioUnit)).Cast().ToArray(); Zero = new PowerRatio(0, BaseUnit); Info = new QuantityInfo("PowerRatio", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 5a63f826de..d7f45c1c0f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -53,10 +53,7 @@ static Pressure() { BaseDimensions = new BaseDimensions(-1, 1, -2, 0, 0, 0, 0); BaseUnit = PressureUnit.Pascal; - MaxValue = new Pressure(double.MaxValue, BaseUnit); - MinValue = new Pressure(double.MinValue, BaseUnit); - QuantityType = QuantityType.Pressure; - Units = Enum.GetValues(typeof(PressureUnit)).Cast().Except(new PressureUnit[]{ PressureUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PressureUnit)).Cast().ToArray(); Zero = new Pressure(0, BaseUnit); Info = new QuantityInfo("Pressure", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index fea3058817..efb44bdb5f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -53,10 +53,7 @@ static PressureChangeRate() { BaseDimensions = new BaseDimensions(-1, 1, -3, 0, 0, 0, 0); BaseUnit = PressureChangeRateUnit.PascalPerSecond; - MaxValue = new PressureChangeRate(double.MaxValue, BaseUnit); - MinValue = new PressureChangeRate(double.MinValue, BaseUnit); - QuantityType = QuantityType.PressureChangeRate; - Units = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().Except(new PressureChangeRateUnit[]{ PressureChangeRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(PressureChangeRateUnit)).Cast().ToArray(); Zero = new PressureChangeRate(0, BaseUnit); Info = new QuantityInfo("PressureChangeRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 3617781297..03e645a6c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -53,10 +53,7 @@ static Ratio() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = RatioUnit.DecimalFraction; - MaxValue = new Ratio(double.MaxValue, BaseUnit); - MinValue = new Ratio(double.MinValue, BaseUnit); - QuantityType = QuantityType.Ratio; - Units = Enum.GetValues(typeof(RatioUnit)).Cast().Except(new RatioUnit[]{ RatioUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RatioUnit)).Cast().ToArray(); Zero = new Ratio(0, BaseUnit); Info = new QuantityInfo("Ratio", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 1e81d0ca03..c142e8241e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -53,10 +53,7 @@ static RatioChangeRate() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); BaseUnit = RatioChangeRateUnit.DecimalFractionPerSecond; - MaxValue = new RatioChangeRate(double.MaxValue, BaseUnit); - MinValue = new RatioChangeRate(double.MinValue, BaseUnit); - QuantityType = QuantityType.RatioChangeRate; - Units = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast().Except(new RatioChangeRateUnit[]{ RatioChangeRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RatioChangeRateUnit)).Cast().ToArray(); Zero = new RatioChangeRate(0, BaseUnit); Info = new QuantityInfo("RatioChangeRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index a7a23c6703..6c1457ed0b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -53,10 +53,7 @@ static ReactiveEnergy() { BaseDimensions = new BaseDimensions(2, 1, -1, 0, 0, 0, 0); BaseUnit = ReactiveEnergyUnit.VoltampereReactiveHour; - MaxValue = new ReactiveEnergy(double.MaxValue, BaseUnit); - MinValue = new ReactiveEnergy(double.MinValue, BaseUnit); - QuantityType = QuantityType.ReactiveEnergy; - Units = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().Except(new ReactiveEnergyUnit[]{ ReactiveEnergyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ReactiveEnergyUnit)).Cast().ToArray(); Zero = new ReactiveEnergy(0, BaseUnit); Info = new QuantityInfo("ReactiveEnergy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index bad065ccbf..f43d62b394 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -53,10 +53,7 @@ static ReactivePower() { BaseDimensions = new BaseDimensions(2, 1, -3, 0, 0, 0, 0); BaseUnit = ReactivePowerUnit.VoltampereReactive; - MaxValue = new ReactivePower(double.MaxValue, BaseUnit); - MinValue = new ReactivePower(double.MinValue, BaseUnit); - QuantityType = QuantityType.ReactivePower; - Units = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().Except(new ReactivePowerUnit[]{ ReactivePowerUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ReactivePowerUnit)).Cast().ToArray(); Zero = new ReactivePower(0, BaseUnit); Info = new QuantityInfo("ReactivePower", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index b14ce2bb70..064bcd236d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -56,10 +56,7 @@ static ReciprocalArea() { BaseDimensions = new BaseDimensions(-2, 0, 0, 0, 0, 0, 0); BaseUnit = ReciprocalAreaUnit.InverseSquareMeter; - MaxValue = new ReciprocalArea(double.MaxValue, BaseUnit); - MinValue = new ReciprocalArea(double.MinValue, BaseUnit); - QuantityType = QuantityType.ReciprocalArea; - Units = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast().Except(new ReciprocalAreaUnit[]{ ReciprocalAreaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ReciprocalAreaUnit)).Cast().ToArray(); Zero = new ReciprocalArea(0, BaseUnit); Info = new QuantityInfo("ReciprocalArea", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 5d77f2feaf..4391bce7c9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -56,10 +56,7 @@ static ReciprocalLength() { BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 0, 0, 0); BaseUnit = ReciprocalLengthUnit.InverseMeter; - MaxValue = new ReciprocalLength(double.MaxValue, BaseUnit); - MinValue = new ReciprocalLength(double.MinValue, BaseUnit); - QuantityType = QuantityType.ReciprocalLength; - Units = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast().Except(new ReciprocalLengthUnit[]{ ReciprocalLengthUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ReciprocalLengthUnit)).Cast().ToArray(); Zero = new ReciprocalLength(0, BaseUnit); Info = new QuantityInfo("ReciprocalLength", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 7b7c78084c..a56ec0d4ae 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -53,10 +53,7 @@ static RelativeHumidity() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = RelativeHumidityUnit.Percent; - MaxValue = new RelativeHumidity(double.MaxValue, BaseUnit); - MinValue = new RelativeHumidity(double.MinValue, BaseUnit); - QuantityType = QuantityType.RelativeHumidity; - Units = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast().Except(new RelativeHumidityUnit[]{ RelativeHumidityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RelativeHumidityUnit)).Cast().ToArray(); Zero = new RelativeHumidity(0, BaseUnit); Info = new QuantityInfo("RelativeHumidity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index dc055946b3..e5d10c80ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -53,10 +53,7 @@ static RotationalAcceleration() { BaseDimensions = new BaseDimensions(0, 0, -2, 0, 0, 0, 0); BaseUnit = RotationalAccelerationUnit.RadianPerSecondSquared; - MaxValue = new RotationalAcceleration(double.MaxValue, BaseUnit); - MinValue = new RotationalAcceleration(double.MinValue, BaseUnit); - QuantityType = QuantityType.RotationalAcceleration; - Units = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().Except(new RotationalAccelerationUnit[]{ RotationalAccelerationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RotationalAccelerationUnit)).Cast().ToArray(); Zero = new RotationalAcceleration(0, BaseUnit); Info = new QuantityInfo("RotationalAcceleration", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 5143f39ea1..56cb832506 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -53,10 +53,7 @@ static RotationalSpeed() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 0, 0, 0); BaseUnit = RotationalSpeedUnit.RadianPerSecond; - MaxValue = new RotationalSpeed(double.MaxValue, BaseUnit); - MinValue = new RotationalSpeed(double.MinValue, BaseUnit); - QuantityType = QuantityType.RotationalSpeed; - Units = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().Except(new RotationalSpeedUnit[]{ RotationalSpeedUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RotationalSpeedUnit)).Cast().ToArray(); Zero = new RotationalSpeed(0, BaseUnit); Info = new QuantityInfo("RotationalSpeed", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index a8083db4b5..612b00d2a6 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -53,10 +53,7 @@ static RotationalStiffness() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); BaseUnit = RotationalStiffnessUnit.NewtonMeterPerRadian; - MaxValue = new RotationalStiffness(double.MaxValue, BaseUnit); - MinValue = new RotationalStiffness(double.MinValue, BaseUnit); - QuantityType = QuantityType.RotationalStiffness; - Units = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().Except(new RotationalStiffnessUnit[]{ RotationalStiffnessUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RotationalStiffnessUnit)).Cast().ToArray(); Zero = new RotationalStiffness(0, BaseUnit); Info = new QuantityInfo("RotationalStiffness", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index abb7b6a9c4..9d8c26bda2 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -53,10 +53,7 @@ static RotationalStiffnessPerLength() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); BaseUnit = RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter; - MaxValue = new RotationalStiffnessPerLength(double.MaxValue, BaseUnit); - MinValue = new RotationalStiffnessPerLength(double.MinValue, BaseUnit); - QuantityType = QuantityType.RotationalStiffnessPerLength; - Units = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().Except(new RotationalStiffnessPerLengthUnit[]{ RotationalStiffnessPerLengthUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(RotationalStiffnessPerLengthUnit)).Cast().ToArray(); Zero = new RotationalStiffnessPerLength(0, BaseUnit); Info = new QuantityInfo("RotationalStiffnessPerLength", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 2eb17c6451..f8f8e6633a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -53,10 +53,7 @@ static Scalar() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = ScalarUnit.Amount; - MaxValue = new Scalar(double.MaxValue, BaseUnit); - MinValue = new Scalar(double.MinValue, BaseUnit); - QuantityType = QuantityType.Scalar; - Units = Enum.GetValues(typeof(ScalarUnit)).Cast().Except(new ScalarUnit[]{ ScalarUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ScalarUnit)).Cast().ToArray(); Zero = new Scalar(0, BaseUnit); Info = new QuantityInfo("Scalar", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 3bd62e9397..35b663e5eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -56,10 +56,7 @@ static SolidAngle() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = SolidAngleUnit.Steradian; - MaxValue = new SolidAngle(double.MaxValue, BaseUnit); - MinValue = new SolidAngle(double.MinValue, BaseUnit); - QuantityType = QuantityType.SolidAngle; - Units = Enum.GetValues(typeof(SolidAngleUnit)).Cast().Except(new SolidAngleUnit[]{ SolidAngleUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SolidAngleUnit)).Cast().ToArray(); Zero = new SolidAngle(0, BaseUnit); Info = new QuantityInfo("SolidAngle", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 520ce131af..443dbc132c 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -56,10 +56,7 @@ static SpecificEnergy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, 0, 0, 0); BaseUnit = SpecificEnergyUnit.JoulePerKilogram; - MaxValue = new SpecificEnergy(double.MaxValue, BaseUnit); - MinValue = new SpecificEnergy(double.MinValue, BaseUnit); - QuantityType = QuantityType.SpecificEnergy; - Units = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().Except(new SpecificEnergyUnit[]{ SpecificEnergyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SpecificEnergyUnit)).Cast().ToArray(); Zero = new SpecificEnergy(0, BaseUnit); Info = new QuantityInfo("SpecificEnergy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index a64eb9a3ec..7997c33e09 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -53,10 +53,7 @@ static SpecificEntropy() { BaseDimensions = new BaseDimensions(2, 0, -2, 0, -1, 0, 0); BaseUnit = SpecificEntropyUnit.JoulePerKilogramKelvin; - MaxValue = new SpecificEntropy(double.MaxValue, BaseUnit); - MinValue = new SpecificEntropy(double.MinValue, BaseUnit); - QuantityType = QuantityType.SpecificEntropy; - Units = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().Except(new SpecificEntropyUnit[]{ SpecificEntropyUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SpecificEntropyUnit)).Cast().ToArray(); Zero = new SpecificEntropy(0, BaseUnit); Info = new QuantityInfo("SpecificEntropy", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index a8afd2bbe3..756f978a86 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -56,10 +56,7 @@ static SpecificFuelConsumption() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond; - MaxValue = new SpecificFuelConsumption(double.MaxValue, BaseUnit); - MinValue = new SpecificFuelConsumption(double.MinValue, BaseUnit); - QuantityType = QuantityType.SpecificFuelConsumption; - Units = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast().Except(new SpecificFuelConsumptionUnit[]{ SpecificFuelConsumptionUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SpecificFuelConsumptionUnit)).Cast().ToArray(); Zero = new SpecificFuelConsumption(0, BaseUnit); Info = new QuantityInfo("SpecificFuelConsumption", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 3d9cebcb4c..6a8ee936b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -53,10 +53,7 @@ static SpecificVolume() { BaseDimensions = new BaseDimensions(3, -1, 0, 0, 0, 0, 0); BaseUnit = SpecificVolumeUnit.CubicMeterPerKilogram; - MaxValue = new SpecificVolume(double.MaxValue, BaseUnit); - MinValue = new SpecificVolume(double.MinValue, BaseUnit); - QuantityType = QuantityType.SpecificVolume; - Units = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().Except(new SpecificVolumeUnit[]{ SpecificVolumeUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SpecificVolumeUnit)).Cast().ToArray(); Zero = new SpecificVolume(0, BaseUnit); Info = new QuantityInfo("SpecificVolume", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 059ece510a..9c1039d03b 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -56,10 +56,7 @@ static SpecificWeight() { BaseDimensions = new BaseDimensions(-2, 1, -2, 0, 0, 0, 0); BaseUnit = SpecificWeightUnit.NewtonPerCubicMeter; - MaxValue = new SpecificWeight(double.MaxValue, BaseUnit); - MinValue = new SpecificWeight(double.MinValue, BaseUnit); - QuantityType = QuantityType.SpecificWeight; - Units = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().Except(new SpecificWeightUnit[]{ SpecificWeightUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SpecificWeightUnit)).Cast().ToArray(); Zero = new SpecificWeight(0, BaseUnit); Info = new QuantityInfo("SpecificWeight", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index 680bb2a105..2456c12dc7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -53,10 +53,7 @@ static Speed() { BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); BaseUnit = SpeedUnit.MeterPerSecond; - MaxValue = new Speed(double.MaxValue, BaseUnit); - MinValue = new Speed(double.MinValue, BaseUnit); - QuantityType = QuantityType.Speed; - Units = Enum.GetValues(typeof(SpeedUnit)).Cast().Except(new SpeedUnit[]{ SpeedUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(SpeedUnit)).Cast().ToArray(); Zero = new Speed(0, BaseUnit); Info = new QuantityInfo("Speed", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index b9962a10db..fb9ed48532 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -53,10 +53,7 @@ static StandardVolumeFlow() { BaseDimensions = new BaseDimensions(0, 1, -1, 0, 0, 0, 0); BaseUnit = StandardVolumeFlowUnit.StandardCubicMeterPerSecond; - MaxValue = new StandardVolumeFlow(double.MaxValue, BaseUnit); - MinValue = new StandardVolumeFlow(double.MinValue, BaseUnit); - QuantityType = QuantityType.StandardVolumeFlow; - Units = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast().Except(new StandardVolumeFlowUnit[]{ StandardVolumeFlowUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(StandardVolumeFlowUnit)).Cast().ToArray(); Zero = new StandardVolumeFlow(0, BaseUnit); Info = new QuantityInfo("StandardVolumeFlow", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 8683ba2ef2..cba358c3c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -53,10 +53,7 @@ static Temperature() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); BaseUnit = TemperatureUnit.Kelvin; - MaxValue = new Temperature(double.MaxValue, BaseUnit); - MinValue = new Temperature(double.MinValue, BaseUnit); - QuantityType = QuantityType.Temperature; - Units = Enum.GetValues(typeof(TemperatureUnit)).Cast().Except(new TemperatureUnit[]{ TemperatureUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TemperatureUnit)).Cast().ToArray(); Zero = new Temperature(0, BaseUnit); Info = new QuantityInfo("Temperature", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index c3270bb6ad..045a786d33 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -53,10 +53,7 @@ static TemperatureChangeRate() { BaseDimensions = new BaseDimensions(0, 0, -1, 0, 1, 0, 0); BaseUnit = TemperatureChangeRateUnit.DegreeCelsiusPerSecond; - MaxValue = new TemperatureChangeRate(double.MaxValue, BaseUnit); - MinValue = new TemperatureChangeRate(double.MinValue, BaseUnit); - QuantityType = QuantityType.TemperatureChangeRate; - Units = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().Except(new TemperatureChangeRateUnit[]{ TemperatureChangeRateUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TemperatureChangeRateUnit)).Cast().ToArray(); Zero = new TemperatureChangeRate(0, BaseUnit); Info = new QuantityInfo("TemperatureChangeRate", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 20d8d90796..bb3a4fec36 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -53,10 +53,7 @@ static TemperatureDelta() { BaseDimensions = new BaseDimensions(0, 0, 0, 0, 1, 0, 0); BaseUnit = TemperatureDeltaUnit.Kelvin; - MaxValue = new TemperatureDelta(double.MaxValue, BaseUnit); - MinValue = new TemperatureDelta(double.MinValue, BaseUnit); - QuantityType = QuantityType.TemperatureDelta; - Units = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().Except(new TemperatureDeltaUnit[]{ TemperatureDeltaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TemperatureDeltaUnit)).Cast().ToArray(); Zero = new TemperatureDelta(0, BaseUnit); Info = new QuantityInfo("TemperatureDelta", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 9fab64e15f..4ac12aee03 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -53,10 +53,7 @@ static TemperatureGradient() { BaseDimensions = new BaseDimensions(-1, 0, 0, 0, 1, 0, 0); BaseUnit = TemperatureGradientUnit.KelvinPerMeter; - MaxValue = new TemperatureGradient(double.MaxValue, BaseUnit); - MinValue = new TemperatureGradient(double.MinValue, BaseUnit); - QuantityType = QuantityType.TemperatureGradient; - Units = Enum.GetValues(typeof(TemperatureGradientUnit)).Cast().Except(new TemperatureGradientUnit[]{ TemperatureGradientUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TemperatureGradientUnit)).Cast().ToArray(); Zero = new TemperatureGradient(0, BaseUnit); Info = new QuantityInfo("TemperatureGradient", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index f0d37172c5..e4620213c0 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -56,10 +56,7 @@ static ThermalConductivity() { BaseDimensions = new BaseDimensions(1, 1, -3, 0, -1, 0, 0); BaseUnit = ThermalConductivityUnit.WattPerMeterKelvin; - MaxValue = new ThermalConductivity(double.MaxValue, BaseUnit); - MinValue = new ThermalConductivity(double.MinValue, BaseUnit); - QuantityType = QuantityType.ThermalConductivity; - Units = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().Except(new ThermalConductivityUnit[]{ ThermalConductivityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ThermalConductivityUnit)).Cast().ToArray(); Zero = new ThermalConductivity(0, BaseUnit); Info = new QuantityInfo("ThermalConductivity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 247588f545..424676d811 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -53,10 +53,7 @@ static ThermalResistance() { BaseDimensions = new BaseDimensions(0, -1, 3, 0, 1, 0, 0); BaseUnit = ThermalResistanceUnit.SquareMeterKelvinPerKilowatt; - MaxValue = new ThermalResistance(double.MaxValue, BaseUnit); - MinValue = new ThermalResistance(double.MinValue, BaseUnit); - QuantityType = QuantityType.ThermalResistance; - Units = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().Except(new ThermalResistanceUnit[]{ ThermalResistanceUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(ThermalResistanceUnit)).Cast().ToArray(); Zero = new ThermalResistance(0, BaseUnit); Info = new QuantityInfo("ThermalResistance", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 7904a0431c..b915778f8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -53,10 +53,7 @@ static Torque() { BaseDimensions = new BaseDimensions(2, 1, -2, 0, 0, 0, 0); BaseUnit = TorqueUnit.NewtonMeter; - MaxValue = new Torque(double.MaxValue, BaseUnit); - MinValue = new Torque(double.MinValue, BaseUnit); - QuantityType = QuantityType.Torque; - Units = Enum.GetValues(typeof(TorqueUnit)).Cast().Except(new TorqueUnit[]{ TorqueUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TorqueUnit)).Cast().ToArray(); Zero = new Torque(0, BaseUnit); Info = new QuantityInfo("Torque", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 78a603f6a2..e7e0a65c88 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -53,10 +53,7 @@ static TorquePerLength() { BaseDimensions = new BaseDimensions(1, 1, -2, 0, 0, 0, 0); BaseUnit = TorquePerLengthUnit.NewtonMeterPerMeter; - MaxValue = new TorquePerLength(double.MaxValue, BaseUnit); - MinValue = new TorquePerLength(double.MinValue, BaseUnit); - QuantityType = QuantityType.TorquePerLength; - Units = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().Except(new TorquePerLengthUnit[]{ TorquePerLengthUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TorquePerLengthUnit)).Cast().ToArray(); Zero = new TorquePerLength(0, BaseUnit); Info = new QuantityInfo("TorquePerLength", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index ef11543d8c..12c7aa9da1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -56,10 +56,7 @@ static Turbidity() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = TurbidityUnit.NTU; - MaxValue = new Turbidity(double.MaxValue, BaseUnit); - MinValue = new Turbidity(double.MinValue, BaseUnit); - QuantityType = QuantityType.Turbidity; - Units = Enum.GetValues(typeof(TurbidityUnit)).Cast().Except(new TurbidityUnit[]{ TurbidityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(TurbidityUnit)).Cast().ToArray(); Zero = new Turbidity(0, BaseUnit); Info = new QuantityInfo("Turbidity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index d671f03462..9b3a5d484a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -53,10 +53,7 @@ static VitaminA() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = VitaminAUnit.InternationalUnit; - MaxValue = new VitaminA(double.MaxValue, BaseUnit); - MinValue = new VitaminA(double.MinValue, BaseUnit); - QuantityType = QuantityType.VitaminA; - Units = Enum.GetValues(typeof(VitaminAUnit)).Cast().Except(new VitaminAUnit[]{ VitaminAUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VitaminAUnit)).Cast().ToArray(); Zero = new VitaminA(0, BaseUnit); Info = new QuantityInfo("VitaminA", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index d3c91e7bbc..3fa1bc31dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -53,10 +53,7 @@ static Volume() { BaseDimensions = new BaseDimensions(3, 0, 0, 0, 0, 0, 0); BaseUnit = VolumeUnit.CubicMeter; - MaxValue = new Volume(double.MaxValue, BaseUnit); - MinValue = new Volume(double.MinValue, BaseUnit); - QuantityType = QuantityType.Volume; - Units = Enum.GetValues(typeof(VolumeUnit)).Cast().Except(new VolumeUnit[]{ VolumeUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VolumeUnit)).Cast().ToArray(); Zero = new Volume(0, BaseUnit); Info = new QuantityInfo("Volume", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 7bc3fe5e7b..fd1c9cf25a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -56,10 +56,7 @@ static VolumeConcentration() { BaseDimensions = BaseDimensions.Dimensionless; BaseUnit = VolumeConcentrationUnit.DecimalFraction; - MaxValue = new VolumeConcentration(double.MaxValue, BaseUnit); - MinValue = new VolumeConcentration(double.MinValue, BaseUnit); - QuantityType = QuantityType.VolumeConcentration; - Units = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast().Except(new VolumeConcentrationUnit[]{ VolumeConcentrationUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VolumeConcentrationUnit)).Cast().ToArray(); Zero = new VolumeConcentration(0, BaseUnit); Info = new QuantityInfo("VolumeConcentration", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index f25d0e25ab..c49ef0a065 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -53,10 +53,7 @@ static VolumeFlow() { BaseDimensions = new BaseDimensions(3, 0, -1, 0, 0, 0, 0); BaseUnit = VolumeFlowUnit.CubicMeterPerSecond; - MaxValue = new VolumeFlow(double.MaxValue, BaseUnit); - MinValue = new VolumeFlow(double.MinValue, BaseUnit); - QuantityType = QuantityType.VolumeFlow; - Units = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().Except(new VolumeFlowUnit[]{ VolumeFlowUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VolumeFlowUnit)).Cast().ToArray(); Zero = new VolumeFlow(0, BaseUnit); Info = new QuantityInfo("VolumeFlow", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index bb30d0f071..f12c0c79f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -53,10 +53,7 @@ static VolumeFlowPerArea() { BaseDimensions = new BaseDimensions(1, 0, -1, 0, 0, 0, 0); BaseUnit = VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter; - MaxValue = new VolumeFlowPerArea(double.MaxValue, BaseUnit); - MinValue = new VolumeFlowPerArea(double.MinValue, BaseUnit); - QuantityType = QuantityType.VolumeFlowPerArea; - Units = Enum.GetValues(typeof(VolumeFlowPerAreaUnit)).Cast().Except(new VolumeFlowPerAreaUnit[]{ VolumeFlowPerAreaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VolumeFlowPerAreaUnit)).Cast().ToArray(); Zero = new VolumeFlowPerArea(0, BaseUnit); Info = new QuantityInfo("VolumeFlowPerArea", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index c60804ee99..08481f853f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -53,10 +53,7 @@ static VolumePerLength() { BaseDimensions = new BaseDimensions(2, 0, 0, 0, 0, 0, 0); BaseUnit = VolumePerLengthUnit.CubicMeterPerMeter; - MaxValue = new VolumePerLength(double.MaxValue, BaseUnit); - MinValue = new VolumePerLength(double.MinValue, BaseUnit); - QuantityType = QuantityType.VolumePerLength; - Units = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast().Except(new VolumePerLengthUnit[]{ VolumePerLengthUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VolumePerLengthUnit)).Cast().ToArray(); Zero = new VolumePerLength(0, BaseUnit); Info = new QuantityInfo("VolumePerLength", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index a2221cf549..69fd721882 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -56,10 +56,7 @@ static VolumetricHeatCapacity() { BaseDimensions = new BaseDimensions(-1, 1, -2, 0, -1, 0, 0); BaseUnit = VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin; - MaxValue = new VolumetricHeatCapacity(double.MaxValue, BaseUnit); - MinValue = new VolumetricHeatCapacity(double.MinValue, BaseUnit); - QuantityType = QuantityType.VolumetricHeatCapacity; - Units = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast().Except(new VolumetricHeatCapacityUnit[]{ VolumetricHeatCapacityUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(VolumetricHeatCapacityUnit)).Cast().ToArray(); Zero = new VolumetricHeatCapacity(0, BaseUnit); Info = new QuantityInfo("VolumetricHeatCapacity", new UnitInfo[] diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 2e3b3016e2..6b97670fcb 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -53,10 +53,7 @@ static WarpingMomentOfInertia() { BaseDimensions = new BaseDimensions(6, 0, 0, 0, 0, 0, 0); BaseUnit = WarpingMomentOfInertiaUnit.MeterToTheSixth; - MaxValue = new WarpingMomentOfInertia(double.MaxValue, BaseUnit); - MinValue = new WarpingMomentOfInertia(double.MinValue, BaseUnit); - QuantityType = QuantityType.WarpingMomentOfInertia; - Units = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast().Except(new WarpingMomentOfInertiaUnit[]{ WarpingMomentOfInertiaUnit.Undefined }).ToArray(); + Units = Enum.GetValues(typeof(WarpingMomentOfInertiaUnit)).Cast().ToArray(); Zero = new WarpingMomentOfInertia(0, BaseUnit); Info = new QuantityInfo("WarpingMomentOfInertia", new UnitInfo[] From 3d8f6324b76a9d4430e90a809cc685b888d225c7 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 8 Feb 2022 23:13:51 +0100 Subject: [PATCH 49/66] UnitsNet: 5.0.0-alpha004 --- CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.AmountOfSubstance.nuspec | 2 +- .../AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- .../ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- .../ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec | 2 +- .../UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- .../UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec | 2 +- .../GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec | 2 +- .../Duration/UnitsNet.NanoFramework.Duration.nuspec | 2 +- .../UnitsNet.NanoFramework.DynamicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricAdmittance.nuspec | 2 +- .../ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec | 2 +- .../ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricInductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotential.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialAc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialDc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- .../UnitsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- .../ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../Frequency/UnitsNet.NanoFramework.Frequency.nuspec | 2 +- .../FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec | 2 +- .../Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../Information/UnitsNet.NanoFramework.Information.nuspec | 2 +- .../Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- .../UnitsNet.NanoFramework.KinematicViscosity.nuspec | 2 +- .../LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec | 2 +- .../GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- .../LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- .../LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.LuminousIntensity.nuspec | 2 +- .../MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec | 2 +- .../MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- .../Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- .../UnitsNet.NanoFramework.MassConcentration.nuspec | 2 +- .../MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- .../MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- .../UnitsNet.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- .../MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../Molarity/UnitsNet.NanoFramework.Molarity.nuspec | 2 +- .../Permeability/UnitsNet.NanoFramework.Permeability.nuspec | 2 +- .../Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- .../PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../Pressure/UnitsNet.NanoFramework.Pressure.nuspec | 2 +- .../UnitsNet.NanoFramework.PressureChangeRate.nuspec | 2 +- .../GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- .../UnitsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- .../ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- .../ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec | 2 +- .../ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalLength.nuspec | 2 +- .../UnitsNet.NanoFramework.RelativeHumidity.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalAcceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffness.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec | 2 +- .../GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- .../SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec | 2 +- .../SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec | 2 +- .../SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- .../UnitsNet.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../Temperature/UnitsNet.NanoFramework.Temperature.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureDelta.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureGradient.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalResistance.nuspec | 2 +- .../GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec | 2 +- .../UnitsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeConcentration.nuspec | 2 +- .../VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec | 2 +- .../UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 2 +- UnitsNet/UnitsNet.csproj | 2 +- 115 files changed, 115 insertions(+), 115 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index 9a145ee43d..66c8a92bd5 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index 8d7966958f..9e59f701cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Acceleration - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index 476913a897..01b435c952 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmountOfSubstance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index dafe706533..375e579ab7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmplitudeRatio - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index 0e891af72e..c18250aab5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Angle - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 71140c1bd2..6a1e0929af 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentEnergy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index ce969829aa..41338fa307 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentPower - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index dcfa035342..99fa402d7b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Area - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index 4971ec6ef2..8343c93cdc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index 55a99a7580..3c4347a182 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index d0e0c00e2e..65877897d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BitRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 36ac2afad2..7376b2e682 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index ed0a2d9f4c..7f222351de 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Capacitance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index 3a944fbff3..b9bda16df1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index e8419a6ea8..256dfba8ba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Density - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index fe18e484d7..6ee95f0e4b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Duration - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 59c01a32cd..f61c5e62d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.DynamicViscosity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index 27551ee8f4..2044e98f7d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricAdmittance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index ca4602a200..68f4c17671 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCharge - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index a77474ea8a..09e62cb0b8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 65c4f64fdd..ac0ee4d250 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index 8c376649be..25e16ee47f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductivity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index bdc1ed8db2..95a1219023 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrent - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index 373c8afb54..8cb459b8f0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index f51e763385..645e2c0c8f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index b2159bb0e0..67b85b55ec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricField - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index 3d7cf1b1cd..e98456a5e2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricInductance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index 3b3bd2a434..b12878d7c4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotential - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index 3b1b22941d..92e19e7630 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 635d406dea..55f6c6cb8c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index 04a1ecc0b4..1f79937521 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 74cad82bf4..7d06cd0dee 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index d08e223ee6..2e619c9bd2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistivity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index a3b87150c2..920ec2cf6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index 659e85e0d6..925c21cc1a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Energy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 1b5362b22a..7aaf49b406 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Entropy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index bb09272210..885890b7d6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Force - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index 550b93c201..cdbc02608c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForceChangeRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index 62cfe13687..ba91bb1dba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForcePerLength - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 801101676c..e82b4d0f59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Frequency - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index 712e9f43b1..a2cb5fd389 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.FuelEfficiency - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index 9fa6d16ca6..b4b66f951b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatFlux - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index 0deabefa77..40f55d87f3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index 8b72fe0a56..1f0bb32a3e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Illuminance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index edacf1bf20..8defc5fc0e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Information - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index 089fdae6e9..e67e56b1a3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index 0a454f706f..d51ff676a2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiation - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index 46b45bb025..ea488aa606 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.KinematicViscosity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index 0bfbfc88ca..81de963230 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LapseRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index f3e6d1c5c7..228db3fc8f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Length - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index 4bb19c4e0b..07ec85c9e4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Level - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index 830f5752d1..9a7409937b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index f0846ba928..5f03aaea7d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearPowerDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index 0cbf449a29..7e51c74239 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Luminosity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 0443052802..e5ebb6e702 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousFlux - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index c4d9f3f099..ab86922c6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousIntensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index c703531dcf..1ecd0d764c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticField - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 818b8b9f12..33628cceec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticFlux - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index d9678da7cd..5c71db1054 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Magnetization - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index 985a6e191f..1ea3261804 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Mass - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index 8d111e86d1..2ab6100659 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassConcentration - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 1005ba90ec..e9efbfe6f9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlow - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index ecc7ac2a73..50dabbeaaf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlux - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 64b0e667e5..013329c705 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFraction - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index 86eba1aca1..7e712c0dfc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index e75d037adc..cd8955a92c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEnergy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index 4e06b6d583..dface4d274 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEntropy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index 1b2f2c776a..2051ea8d59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarMass - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 7f3b7a144a..958640756a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Molarity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 227064762a..f681a8fc87 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permeability - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index c1157481e0..3502515e00 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permittivity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index 6a4fe71779..d161b63b62 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Power - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 8903bd7547..b0a674e6f6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerDensity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index 8852cf9f08..5bafa1ec27 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerRatio - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 10ef301476..f35abe5847 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Pressure - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index dea12b0db4..f6d994d425 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PressureChangeRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index 60ece765c9..079a30038f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Ratio - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index 7e0b56564a..b5e676e15d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RatioChangeRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index eba7e099ae..fed24a63bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactiveEnergy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 7916e78ac8..4030c64b79 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactivePower - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index 2f76b03223..84da1cb309 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalArea - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 2725557426..7be63a46b7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalLength - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index 98e49e5bc1..3177abc1bb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RelativeHumidity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index 74d807fe0c..272b126b94 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalAcceleration - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index a79097ea8b..6d61518c90 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalSpeed - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 4e4b18af9c..6733d599fa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffness - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index d5f36020cc..220b8b3c07 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index 70b9143e4d..0abc9e0014 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Scalar - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 3442cde919..c1998b56dc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SolidAngle - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index d23bdce654..4a4e313d95 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEnergy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index 3648c1980e..b10f830731 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEntropy - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 9f57cae0ec..0a8cf7acd7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index 7f6e2cc9ab..b305293c81 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificVolume - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 8b29474ceb..aac67ad7a6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificWeight - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index a85c9fbe15..8989e88427 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Speed - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 4bd5bed311..20c1ffb458 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index 5d14df7635..549266671b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Temperature - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 46c2af71bf..9a8844ce6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index be70f7be97..f94cd663f4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureDelta - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec index c399aaf38a..4e6097460d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureGradient - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET TemperatureGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index 93ee115ce9..3ae55f161a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalConductivity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index 98570096a9..e7f2f7671b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalResistance - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index af31bd51e1..d18f742cdb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Torque - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index 5a4465132a..d349aef42a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TorquePerLength - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 6e856fad9e..fe04c2e418 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Turbidity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index a2fd6bb63e..cf17f7d5d4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VitaminA - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index f16d96bb9b..7bde042b95 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Volume - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index b441c18a2f..2e612e1cf7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeConcentration - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index 76de20a01c..54dd1e65c8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlow - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec index 97ece58b56..a77db54f43 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlowPerArea - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET VolumeFlowPerArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index 8e5a19e395..728040fbd5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumePerLength - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 2edab4fc19..abeaae6d76 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 78ced70d1d..c3faedc2c8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 5.0.0-alpha003 + 5.0.0-alpha004 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index 459e3d6e26..6034143911 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -2,7 +2,7 @@ UnitsNet.NumberExtensions - 5.0.0-alpha003 + 5.0.0-alpha004 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 29efb2b7ae..4038c870e0 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -2,7 +2,7 @@ UnitsNet - 5.0.0-alpha003 + 5.0.0-alpha004 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. From e2118ef676d2c2ed9d5507dd00a0066836646897 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 8 Feb 2022 23:13:59 +0100 Subject: [PATCH 50/66] JsonNet: 5.0.0-alpha003 --- .../UnitsNet.Serialization.JsonNet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 3e062331f1..2f58753c0e 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -2,7 +2,7 @@ UnitsNet.Serialization.JsonNet - 5.0.0-alpha002 + 5.0.0-alpha003 Andreas Gullberg Larsen Units.NET Serialization with Json.NET A helper library for serializing and deserializing types in Units.NET using Json.NET. From 74e50721160cae39427efc871c5ff48e7c4f8ecb Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 8 Feb 2022 23:14:17 +0100 Subject: [PATCH 51/66] JsonNet: 5.0.0-alpha004 --- .../UnitsNet.Serialization.JsonNet.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj index 2f58753c0e..1af4067f8a 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj +++ b/UnitsNet.Serialization.JsonNet/UnitsNet.Serialization.JsonNet.csproj @@ -2,7 +2,7 @@ UnitsNet.Serialization.JsonNet - 5.0.0-alpha003 + 5.0.0-alpha004 Andreas Gullberg Larsen Units.NET Serialization with Json.NET A helper library for serializing and deserializing types in Units.NET using Json.NET. From 6e2f40ce6432e1177a11a7e65bb1e9120f6134df Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Sun, 20 Mar 2022 12:12:01 +0100 Subject: [PATCH 52/66] UnitsNet: 5.0.0-alpha005 --- CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.AmountOfSubstance.nuspec | 2 +- .../AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- .../ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- .../ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec | 2 +- .../UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- .../UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec | 2 +- .../GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec | 2 +- .../Duration/UnitsNet.NanoFramework.Duration.nuspec | 2 +- .../UnitsNet.NanoFramework.DynamicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricAdmittance.nuspec | 2 +- .../ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec | 2 +- .../ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricInductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotential.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialAc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialDc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- .../UnitsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- .../ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../Frequency/UnitsNet.NanoFramework.Frequency.nuspec | 2 +- .../FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec | 2 +- .../Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../Information/UnitsNet.NanoFramework.Information.nuspec | 2 +- .../Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- .../UnitsNet.NanoFramework.KinematicViscosity.nuspec | 2 +- .../LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec | 2 +- .../GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- .../LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- .../LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.LuminousIntensity.nuspec | 2 +- .../MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec | 2 +- .../MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- .../Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- .../UnitsNet.NanoFramework.MassConcentration.nuspec | 2 +- .../MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- .../MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- .../UnitsNet.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- .../MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../Molarity/UnitsNet.NanoFramework.Molarity.nuspec | 2 +- .../Permeability/UnitsNet.NanoFramework.Permeability.nuspec | 2 +- .../Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- .../PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../Pressure/UnitsNet.NanoFramework.Pressure.nuspec | 2 +- .../UnitsNet.NanoFramework.PressureChangeRate.nuspec | 2 +- .../GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- .../UnitsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- .../ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- .../ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec | 2 +- .../ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalLength.nuspec | 2 +- .../UnitsNet.NanoFramework.RelativeHumidity.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalAcceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffness.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec | 2 +- .../GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- .../SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec | 2 +- .../SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec | 2 +- .../SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- .../UnitsNet.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../Temperature/UnitsNet.NanoFramework.Temperature.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureDelta.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureGradient.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalResistance.nuspec | 2 +- .../GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec | 2 +- .../UnitsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeConcentration.nuspec | 2 +- .../VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec | 2 +- .../UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 2 +- UnitsNet/UnitsNet.csproj | 2 +- 115 files changed, 115 insertions(+), 115 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index ffd3e29749..4e09942588 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index 95ec68e08a..cc71839494 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Acceleration - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index 5d39191e60..079b492877 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmountOfSubstance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index f1a0090b8e..9f7ac54f12 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmplitudeRatio - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index bb41c69900..82005e05b5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Angle - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 6c66ab7ec0..43ced8db8b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentEnergy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index 6de0fe63b9..47b2da7359 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentPower - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index a394e8f413..bf011b3ffc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Area - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index 75b74f35a5..1c9ee9fdf4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index e5f8e30b22..69042e60d3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index 7cad762093..b3be3e6234 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BitRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index e288e6c4fc..bf67af6fe5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index 4a587d127c..d9acd718b1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Capacitance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index 058e732b24..addc5e5164 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 7ff8d0549f..bf332de860 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Density - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index 3e7f0c4e90..46f8537f82 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Duration - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 8e32c0e880..76cad8c4e5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.DynamicViscosity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index a9b360e70b..389fed5e05 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricAdmittance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index a6d95ab2b5..8e76c30993 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCharge - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index 887441212c..356eb248a1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index 320200506a..164691c65e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index 09e9ef9779..00c9579255 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductivity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 3174b3897a..15b8270964 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrent - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index 7fe7ce4dec..5cb099df45 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index fade81d712..a2005d3927 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index d2462dff20..e4defe7435 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricField - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index 0fce0d4967..2c068a60a4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricInductance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index 46ec14c2f2..eab270e188 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotential - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index a37325943a..a3231ce604 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index 897777b892..ab84c43a59 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index f1fa6d49ca..16dc93563a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index dc110c209c..ae0bb55b0d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index 3bdc379c20..0bd4260b6f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistivity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index eb994329a4..5d3e26c478 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index 8b4b6a6a48..20bdffbed5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Energy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index f9e9addad5..9d5e0c8eb8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Entropy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index 1dac067c7d..5259bc9b24 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Force - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index f5cc0104b1..2a8e68d61e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForceChangeRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index 4af28d13fd..c0913547dc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForcePerLength - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 253817e278..4c4911e9d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Frequency - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index 7d0a45948f..c61bc3579f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.FuelEfficiency - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index 21849ec360..da7dc7c065 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatFlux - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index 8e9b9d341a..901e01460a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index 5e347e03af..65b5fa36e9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Illuminance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index ee7e436da6..02aabb2025 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Information - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index d3fc99f50b..7cde059169 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index 0c9b6fbe97..8f87c6fa88 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiation - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index f27c6c2a59..6315b1596f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.KinematicViscosity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index f9bb8eb62b..23c4138921 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LapseRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index ca817c731b..2bcaae1137 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Length - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index 2a96bed41d..cfe363c5df 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Level - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index c9e37b5eee..b1d8241c54 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index bf2ccc2bd7..d54518c6ea 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearPowerDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index 202b5eb914..e7d81eb57f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Luminosity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 6f8e9a39ff..fe2beaa058 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousFlux - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index 82cec70548..9d6866fd7e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousIntensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index eae8e78cc0..a95a4ff6ed 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticField - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 76712a2038..6b24461a99 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticFlux - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index b842a872f1..84b923e628 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Magnetization - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index 57fa8585a6..5d35c6c5cd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Mass - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index dac2520350..fd077260b8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassConcentration - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index 77d21bda79..fc225fe0cf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlow - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index 83e38a4f50..35c1e55ea8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlux - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index b7dad6ab45..db3347457b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFraction - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index bdb4135107..efa5b2b809 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index f491321f3f..2ddbcfe0cb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEnergy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index 0f465b8081..0281456301 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEntropy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index 0eeae0b348..6c24438fb0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarMass - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 2d5b8632c0..25a8d8b0f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Molarity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index 61fb1eb790..6faa77f469 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permeability - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index 77c7891a9c..c66e99638c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permittivity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index d514a2c320..23779f2f48 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Power - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 7f7ba439df..250a15c75f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerDensity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index ba7b04c41b..d7ba7a2bbe 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerRatio - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index e51597baf0..5c5e804c76 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Pressure - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index 94051b0c5e..b25e0fb171 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PressureChangeRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index 02471319c7..48cbeec67a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Ratio - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index f3e6b8f72a..9afc82153d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RatioChangeRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index 7385518aa6..ccd594b721 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactiveEnergy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index f771473493..2d05427112 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactivePower - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index d14e1875b8..b3fd4977d8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalArea - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 6feca8a6c1..8c456ebc83 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalLength - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index efd4a56148..a4332e6b1f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RelativeHumidity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index afa2e1dc09..38e4c3c30c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalAcceleration - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index 5d53e3882a..82f1455f63 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalSpeed - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 45b0c8f1e4..fafa8bfd1b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffness - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index 49d04b1916..7de5bf587f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index 8d23bfa120..da4a49ceb6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Scalar - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 4d163e4cec..6f987a9af6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SolidAngle - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 62f04808b5..379708d64b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEnergy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index cdfdb74b95..a1b9d8aa05 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEntropy - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 8e67b3cae6..558a6be5f5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index f88cebce8a..5dfb2f7034 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificVolume - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 943451a6c6..ef32a9d648 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificWeight - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index a8c4abab87..8a5cd41aee 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Speed - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index dff5d5c584..04ba2e6216 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index 05025c7a0d..c1741a7578 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Temperature - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index a229354278..4bdee51374 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 167aa669fe..36231c7bab 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureDelta - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec index 2ad7b8821a..16ad759d15 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureGradient - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET TemperatureGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index c93c476139..38ec269682 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalConductivity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index 5488b341e9..4f4ffed1c5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalResistance - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 864762cd64..bbbbbebbb2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Torque - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index 9a4516d1c1..0f4354f1b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TorquePerLength - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index b22983f4ad..cd46cf1cc3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Turbidity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index 600c670339..0c8e045788 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VitaminA - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index 92663af7e6..832a93db6c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Volume - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index c9795a3af3..84b8b58875 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeConcentration - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index a889d50447..beac36fe0c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlow - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec index 9e9483db72..07b8fa211b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlowPerArea - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET VolumeFlowPerArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index e4c0ce1149..ad43b238dc 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumePerLength - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index e8009d349b..9bdf1dfa6a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 8a24a21f1a..e7e3f5f059 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 5.0.0-alpha004 + 5.0.0-alpha005 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index 6034143911..c9a4def318 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -2,7 +2,7 @@ UnitsNet.NumberExtensions - 5.0.0-alpha004 + 5.0.0-alpha005 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 4038c870e0..7c2904b540 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -2,7 +2,7 @@ UnitsNet - 5.0.0-alpha004 + 5.0.0-alpha005 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. From 0171225b8a0bcacc559b6cb31c87e926c9612795 Mon Sep 17 00:00:00 2001 From: Andreas Leeb <30859615+AndreasLeeb@users.noreply.github.com> Date: Fri, 3 Jun 2022 21:20:38 +0200 Subject: [PATCH 53/66] QuantityValue: 16 bytes instead of 40 bytes (#1084) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Andreas Leeb Fixes #875 Regarding https://github.com/angularsen/UnitsNet/discussions/875#discussioncomment-2690100 a PR draft for https://github.com/angularsen/UnitsNet/discussions/875#discussioncomment-2689636 Size comparison ``` Before: Marshal.SizeOf(): 40 B After: Marshal.SizeOf(): 16 B ``` `UnderlyingDataType` could support up to 256 different enum values, I guess we won't ever need more different underlying types that can fit into this struct 😄 --- UnitsNet/InternalHelpers/BytesUtility.cs | 40 +++++++++++ UnitsNet/QuantityValue.cs | 92 ++++++++++++++++++------ 2 files changed, 110 insertions(+), 22 deletions(-) create mode 100644 UnitsNet/InternalHelpers/BytesUtility.cs diff --git a/UnitsNet/InternalHelpers/BytesUtility.cs b/UnitsNet/InternalHelpers/BytesUtility.cs new file mode 100644 index 0000000000..e75e467773 --- /dev/null +++ b/UnitsNet/InternalHelpers/BytesUtility.cs @@ -0,0 +1,40 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using System.Runtime.InteropServices; + +namespace UnitsNet.InternalHelpers +{ + /// + /// Utility methods for working with the byte representation of structs. + /// + internal static class BytesUtility + { + /// + /// Converts the given to an array of its underlying bytes. + /// + /// The struct type. + /// The struct value to convert. + /// A byte array representing a copy of s bytes. + internal static byte[] GetBytes(T value) where T : struct + { + int size = Marshal.SizeOf(value); + byte[] array = new byte[size]; + + IntPtr ptr = Marshal.AllocHGlobal(size); + + try + { + Marshal.StructureToPtr(value, ptr, true); + Marshal.Copy(ptr, array, 0, size); + } + finally + { + Marshal.FreeHGlobal(ptr); + } + + return array; + } + } +} diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index 98cb83b493..d25d184e98 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -1,7 +1,10 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Text; using UnitsNet.InternalHelpers; namespace UnitsNet @@ -16,35 +19,49 @@ namespace UnitsNet /// /// /// - /// At the time of this writing, this reduces the number of From(value, unit) overloads to 1/4th: + /// At the time of this writing, this reduces the number of From(value, unit) overloads to 1/4th: /// From 8 (int, long, double, decimal + each nullable) down to 2 (QuantityValue and QuantityValue?). - /// This also adds more numeric types with no extra overhead, such as float, short and byte. + /// This also adds more numeric types with no extra overhead, such as float, short and byte. + /// So far, the internal representation can be either or , + /// but as this struct is realized as a union struct with overlapping fields, only the amount of memory of the largest data type is used. + /// This allows for adding support for smaller data types without increasing the overall size. /// - public struct QuantityValue + [StructLayout(LayoutKind.Explicit)] + [DebuggerDisplay("{GetDebugRepresentation()}")] + public readonly struct QuantityValue { /// /// Value assigned when implicitly casting from all numeric types except , since - /// has the greatest range and is 64 bits versus 128 bits for . + /// has the greatest range. /// - private readonly double? _value; + [FieldOffset(8)] // so that it does not interfere with the Type field + private readonly double _doubleValue; /// /// Value assigned when implicitly casting from type, since it has a greater precision than /// and we want to preserve that when constructing quantities that use /// as their value type. /// - private readonly decimal? _valueDecimal; + [FieldOffset(0)] + // bytes layout: 0-1 unused, 2 exponent, 3 sign (only highest bit), 4-15 number + private readonly decimal _decimalValue; + + /// + /// Determines the underlying type of this . + /// + [FieldOffset(0)] // using unused byte for storing type + public readonly UnderlyingDataType Type; - private QuantityValue(double val) + private QuantityValue(double val) : this() { - _value = Guard.EnsureValidNumber(val, nameof(val)); - _valueDecimal = null; + _doubleValue = Guard.EnsureValidNumber(val, nameof(val)); + Type = UnderlyingDataType.Double; } - private QuantityValue(decimal val) + private QuantityValue(decimal val) : this() { - _valueDecimal = val; - _value = null; + _decimalValue = val; + Type = UnderlyingDataType.Decimal; } #region To QuantityValue @@ -72,10 +89,12 @@ private QuantityValue(decimal val) /// Explicit cast from to . public static explicit operator double(QuantityValue number) - { - // double -> decimal -> zero (since we can't implement the default struct ctor) - return number._value ?? (double) number._valueDecimal.GetValueOrDefault(); - } + => number.Type switch + { + UnderlyingDataType.Decimal => (double)number._decimalValue, + UnderlyingDataType.Double => number._doubleValue, + _ => throw new NotImplementedException() + }; #endregion @@ -83,17 +102,46 @@ public static explicit operator double(QuantityValue number) /// Explicit cast from to . public static explicit operator decimal(QuantityValue number) - { - // decimal -> double -> zero (since we can't implement the default struct ctor) - return number._valueDecimal ?? (decimal) number._value.GetValueOrDefault(); - } + => number.Type switch + { + UnderlyingDataType.Decimal => number._decimalValue, + UnderlyingDataType.Double => (decimal)number._doubleValue, + _ => throw new NotImplementedException() + }; #endregion /// Returns the string representation of the numeric value. public override string ToString() + => Type switch + { + UnderlyingDataType.Decimal => _decimalValue.ToString(), + UnderlyingDataType.Double => _doubleValue.ToString(), + _ => throw new NotImplementedException() + }; + + private string GetDebugRepresentation() + { + StringBuilder builder = new($"{Type} {ToString()} Hex:"); + + byte[] bytes = BytesUtility.GetBytes(this); + for (int i = bytes.Length - 1; i >= 0; i--) + { + builder.Append($" {bytes[i]:X2}"); + } + + return builder.ToString(); + } + + /// + /// Describes the underlying type of a . + /// + public enum UnderlyingDataType : byte { - return _value.HasValue ? _value.ToString() : _valueDecimal.ToString(); + /// must have the value 0 due to the bit structure of . + Decimal = 0, + /// + Double = 1 } } } From 97a6d165379eb926c19f99ac79d99982277e0ef6 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Fri, 3 Jun 2022 22:37:02 +0200 Subject: [PATCH 54/66] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Upgrade=20all=20net5?= =?UTF-8?q?.0=20projects=20to=20net6.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CodeGen/CodeGen.csproj | 2 +- UnitsNet.Benchmark/UnitsNet.Benchmark.csproj | 2 +- .../UnitsNet.NumberExtensions.Tests.csproj | 2 +- .../UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj | 2 +- .../UnitsNet.Serialization.JsonNet.Tests.csproj | 2 +- UnitsNet.Tests/UnitsNet.Tests.csproj | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CodeGen/CodeGen.csproj b/CodeGen/CodeGen.csproj index 728ec19e25..2198eafc82 100644 --- a/CodeGen/CodeGen.csproj +++ b/CodeGen/CodeGen.csproj @@ -2,7 +2,7 @@ Exe - netcoreapp5.0 + netcoreapp6.0 latest enable diff --git a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj index e8c458bfcf..7beb1cde43 100644 --- a/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj +++ b/UnitsNet.Benchmark/UnitsNet.Benchmark.csproj @@ -1,7 +1,7 @@  Exe - net6.0;net5.0;net48 + net6.0;net48 4.0.0.0 4.0.0.0 UnitsNet.Benchmark diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index 9bf36ee5d1..019f535f11 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -1,7 +1,7 @@ - net5.0 + net6.0 UnitsNet.NumberExtensions.Tests latest enable diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj index e870fab409..4e5d9e6587 100644 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 UnitsNet.Serialization.JsonNet.CompatibilityTests latest true diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj index 8454bed3f0..9ac270a3ab 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj @@ -1,7 +1,7 @@  - net5.0 + net6.0 UnitsNet.Serialization.JsonNet.Tests latest true diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index ffbd1b9edc..7b7adc4d42 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -1,7 +1,7 @@  - net5.0;net48 + net6.0;net48 UnitsNet.Tests latest true From 4fe83be73bf70515e852caa1b6f571f734b59aec Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Fri, 3 Jun 2022 22:38:46 +0200 Subject: [PATCH 55/66] UnitsNet: 5.0.0-alpha006 --- CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs | 2 +- .../Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.AmountOfSubstance.nuspec | 2 +- .../AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec | 2 +- .../GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec | 2 +- .../ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec | 2 +- .../ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec | 2 +- .../GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec | 2 +- .../AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec | 2 +- .../GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec | 2 +- .../UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec | 2 +- .../Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec | 2 +- .../UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec | 2 +- .../UnitsNet.NanoFramework.Compressibility.nuspec | 2 +- .../GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec | 2 +- .../Duration/UnitsNet.NanoFramework.Duration.nuspec | 2 +- .../UnitsNet.NanoFramework.DynamicViscosity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricAdmittance.nuspec | 2 +- .../ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricChargeDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrent.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec | 2 +- .../ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricInductance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotential.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialAc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricPotentialDc.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistance.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricResistivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec | 2 +- .../GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec | 2 +- .../GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec | 2 +- .../GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec | 2 +- .../UnitsNet.NanoFramework.ForceChangeRate.nuspec | 2 +- .../ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec | 2 +- .../Frequency/UnitsNet.NanoFramework.Frequency.nuspec | 2 +- .../FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec | 2 +- .../HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec | 2 +- .../Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec | 2 +- .../Information/UnitsNet.NanoFramework.Information.nuspec | 2 +- .../Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec | 2 +- .../Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec | 2 +- .../GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec | 2 +- .../UnitsNet.NanoFramework.KinematicViscosity.nuspec | 2 +- .../LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec | 2 +- .../GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec | 2 +- .../GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec | 2 +- .../LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec | 2 +- .../UnitsNet.NanoFramework.LinearPowerDensity.nuspec | 2 +- .../Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec | 2 +- .../LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec | 2 +- .../UnitsNet.NanoFramework.LuminousIntensity.nuspec | 2 +- .../MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec | 2 +- .../MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec | 2 +- .../Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec | 2 +- .../GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec | 2 +- .../UnitsNet.NanoFramework.MassConcentration.nuspec | 2 +- .../MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec | 2 +- .../MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec | 2 +- .../MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec | 2 +- .../UnitsNet.NanoFramework.MassMomentOfInertia.nuspec | 2 +- .../MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec | 2 +- .../MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec | 2 +- .../MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec | 2 +- .../Molarity/UnitsNet.NanoFramework.Molarity.nuspec | 2 +- .../Permeability/UnitsNet.NanoFramework.Permeability.nuspec | 2 +- .../Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec | 2 +- .../UnitsNet.NanoFramework.PorousMediumPermeability.nuspec | 2 +- .../GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec | 2 +- .../PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec | 2 +- .../PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec | 2 +- .../Pressure/UnitsNet.NanoFramework.Pressure.nuspec | 2 +- .../UnitsNet.NanoFramework.PressureChangeRate.nuspec | 2 +- .../GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec | 2 +- .../UnitsNet.NanoFramework.RatioChangeRate.nuspec | 2 +- .../ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec | 2 +- .../ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec | 2 +- .../ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec | 2 +- .../UnitsNet.NanoFramework.ReciprocalLength.nuspec | 2 +- .../UnitsNet.NanoFramework.RelativeHumidity.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalAcceleration.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalSpeed.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffness.nuspec | 2 +- .../UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec | 2 +- .../GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec | 2 +- .../SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec | 2 +- .../SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificEntropy.nuspec | 2 +- .../UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec | 2 +- .../SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec | 2 +- .../SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec | 2 +- .../GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec | 2 +- .../UnitsNet.NanoFramework.StandardVolumeFlow.nuspec | 2 +- .../Temperature/UnitsNet.NanoFramework.Temperature.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureChangeRate.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureDelta.nuspec | 2 +- .../UnitsNet.NanoFramework.TemperatureGradient.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalConductivity.nuspec | 2 +- .../UnitsNet.NanoFramework.ThermalResistance.nuspec | 2 +- .../GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec | 2 +- .../UnitsNet.NanoFramework.TorquePerLength.nuspec | 2 +- .../Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec | 2 +- .../VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec | 2 +- .../GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeConcentration.nuspec | 2 +- .../VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumePerLength.nuspec | 2 +- .../UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec | 2 +- .../UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec | 2 +- UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj | 2 +- UnitsNet/UnitsNet.csproj | 2 +- 118 files changed, 118 insertions(+), 118 deletions(-) diff --git a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs index 4e09942588..5d1cf278e4 100644 --- a/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/NuspecGenerator.cs @@ -25,7 +25,7 @@ public string Generate() UnitsNet.nanoFramework.{_quantity.Name} - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET {_quantity.Name} - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec index aa13d79371..f57f4d556e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/UnitsNet.NanoFramework.Acceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Acceleration - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Acceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec index 2e2a38c27a..cc5dc3b0a1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/UnitsNet.NanoFramework.AmountOfSubstance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmountOfSubstance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET AmountOfSubstance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec index ff9abac436..19ecbdffce 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/UnitsNet.NanoFramework.AmplitudeRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AmplitudeRatio - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET AmplitudeRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec index e67d7ae0d2..d38067b2ce 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/UnitsNet.NanoFramework.Angle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Angle - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Angle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec index 45fca512bf..446c4274c6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/UnitsNet.NanoFramework.ApparentEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentEnergy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ApparentEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec index f6a5624030..095f17421f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/UnitsNet.NanoFramework.ApparentPower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ApparentPower - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ApparentPower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec index 3ef3775204..c92217ec8b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/UnitsNet.NanoFramework.Area.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Area - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Area - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec index b439cd0a6d..ec72b39edb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/UnitsNet.NanoFramework.AreaDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET AreaDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec index 5dd17e840d..47303c671a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/UnitsNet.NanoFramework.AreaMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.AreaMomentOfInertia - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET AreaMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec index b4748ae8bc..6700e9ab1c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/UnitsNet.NanoFramework.BitRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BitRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET BitRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec index 57bdcf9b83..c12999cf54 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/UnitsNet.NanoFramework.BrakeSpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.BrakeSpecificFuelConsumption - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET BrakeSpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec index 9e15a8c48c..a7c17a1d6e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/UnitsNet.NanoFramework.Capacitance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Capacitance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Capacitance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec index 854417b38d..8a9503d767 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/UnitsNet.NanoFramework.CoefficientOfThermalExpansion.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.CoefficientOfThermalExpansion - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET CoefficientOfThermalExpansion - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec index 221c3b7519..e70d87c235 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Compressibility/UnitsNet.NanoFramework.Compressibility.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Compressibility - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Compressibility - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec index 7c4bf1124c..370ad8735e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/UnitsNet.NanoFramework.Density.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Density - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Density - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec index ecd704c134..e0099ab649 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/UnitsNet.NanoFramework.Duration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Duration - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Duration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec index 309cb362cb..d2473939c4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/UnitsNet.NanoFramework.DynamicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.DynamicViscosity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET DynamicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec index 0df49b4a45..b2b871edaa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/UnitsNet.NanoFramework.ElectricAdmittance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricAdmittance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricAdmittance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec index 30c0f2db99..93f22057ea 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/UnitsNet.NanoFramework.ElectricCharge.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCharge - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricCharge - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec index e5f503fda4..d0b34da395 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/UnitsNet.NanoFramework.ElectricChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricChargeDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec index a76bab4865..4c292127b1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/UnitsNet.NanoFramework.ElectricConductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricConductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec index a68bc0225a..57b7d5d90a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/UnitsNet.NanoFramework.ElectricConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricConductivity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec index 5b8a24c26c..2fa448b60c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/UnitsNet.NanoFramework.ElectricCurrent.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrent - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricCurrent - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec index a6eb1f241a..ed8c952851 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/UnitsNet.NanoFramework.ElectricCurrentDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricCurrentDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec index a199dc79ac..7164f23981 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/UnitsNet.NanoFramework.ElectricCurrentGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricCurrentGradient - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricCurrentGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec index d9a58f66bb..96508b853a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/UnitsNet.NanoFramework.ElectricField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricField - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec index a114ef809e..45ffc9e9fb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/UnitsNet.NanoFramework.ElectricInductance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricInductance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricInductance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec index c96d8fdb41..511cbe67d0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/UnitsNet.NanoFramework.ElectricPotential.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotential - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricPotential - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec index d9f78b95b7..919ed09470 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/UnitsNet.NanoFramework.ElectricPotentialAc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialAc - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricPotentialAc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec index a29717f419..9f608b3c28 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/UnitsNet.NanoFramework.ElectricPotentialChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialChangeRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricPotentialChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec index 09e68d3e76..cdcc61cd87 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/UnitsNet.NanoFramework.ElectricPotentialDc.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricPotentialDc - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricPotentialDc - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec index 39d54a9a08..ed165d1442 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/UnitsNet.NanoFramework.ElectricResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec index ac33ea8298..9d06bf2a2d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/UnitsNet.NanoFramework.ElectricResistivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricResistivity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricResistivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec index af907667fe..9e5c76adcf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/UnitsNet.NanoFramework.ElectricSurfaceChargeDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ElectricSurfaceChargeDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ElectricSurfaceChargeDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec index 47d6b68a09..87d4974861 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/UnitsNet.NanoFramework.Energy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Energy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Energy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec index 91a96ae2b2..c2a0612073 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/UnitsNet.NanoFramework.Entropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Entropy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Entropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec index 30582d3bee..7bfefad299 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/UnitsNet.NanoFramework.Force.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Force - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Force - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec index be65f8c63e..f2a396cbd7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/UnitsNet.NanoFramework.ForceChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForceChangeRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ForceChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec index 38f2e48c27..0444b620e2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/UnitsNet.NanoFramework.ForcePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ForcePerLength - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ForcePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec index 41e42b63b1..86bd10a258 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/UnitsNet.NanoFramework.Frequency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Frequency - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Frequency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec index f88b94de72..caa857b2bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/UnitsNet.NanoFramework.FuelEfficiency.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.FuelEfficiency - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET FuelEfficiency - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec index f14663a01f..3eb1b247b8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/UnitsNet.NanoFramework.HeatFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatFlux - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET HeatFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec index 9020904efd..548e66b807 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/UnitsNet.NanoFramework.HeatTransferCoefficient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.HeatTransferCoefficient - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET HeatTransferCoefficient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec index 72cc93faff..de69ea8843 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/UnitsNet.NanoFramework.Illuminance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Illuminance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Illuminance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec index 98739cfed2..29aed3fd4c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/UnitsNet.NanoFramework.Information.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Information - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Information - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec index 06991d0a3c..d44c1b68a5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/UnitsNet.NanoFramework.Irradiance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Irradiance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec index b262f02489..a2ef2cf391 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/UnitsNet.NanoFramework.Irradiation.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Irradiation - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Irradiation - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec index ab0d387d28..3c80d53f53 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Jerk/UnitsNet.NanoFramework.Jerk.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Jerk - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Jerk - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec index c6303b8f9e..3b296a88ac 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/UnitsNet.NanoFramework.KinematicViscosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.KinematicViscosity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET KinematicViscosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec index 221eeb1cf3..e2c1f55189 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/UnitsNet.NanoFramework.LapseRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LapseRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET LapseRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec index b9ec01e82e..d0234d69a8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/UnitsNet.NanoFramework.Length.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Length - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Length - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec index 03a32b49ed..64e716c4e2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/UnitsNet.NanoFramework.Level.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Level - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Level - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec index a4ebe6c11e..84731f32f9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/UnitsNet.NanoFramework.LinearDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET LinearDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec index 3c67625c40..624bb6c8b7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/UnitsNet.NanoFramework.LinearPowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LinearPowerDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET LinearPowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec index 56a2367317..da32a0d41f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/UnitsNet.NanoFramework.Luminosity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Luminosity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Luminosity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec index 1d6e51756b..f5301fb6c8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/UnitsNet.NanoFramework.LuminousFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousFlux - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET LuminousFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec index 712a4b3ca4..b26f171a6a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/UnitsNet.NanoFramework.LuminousIntensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.LuminousIntensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET LuminousIntensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec index 8c7cf49775..eb1173c643 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/UnitsNet.NanoFramework.MagneticField.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticField - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MagneticField - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec index 4db97bc863..3b7651d310 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/UnitsNet.NanoFramework.MagneticFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MagneticFlux - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MagneticFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec index 017d407c24..a9196414f4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/UnitsNet.NanoFramework.Magnetization.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Magnetization - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Magnetization - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec index 2c5bfffb1d..7a79bb5c84 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/UnitsNet.NanoFramework.Mass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Mass - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Mass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec index c010b76ab0..72294257ce 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/UnitsNet.NanoFramework.MassConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassConcentration - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MassConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec index e7cb5bb989..a7647773b4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/UnitsNet.NanoFramework.MassFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlow - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MassFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec index 11bc91ce35..b827bf7c2f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/UnitsNet.NanoFramework.MassFlux.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFlux - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MassFlux - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec index 1c23033c8d..239cffb145 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/UnitsNet.NanoFramework.MassFraction.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassFraction - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MassFraction - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec index 929fdbc1b8..9892393b2c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/UnitsNet.NanoFramework.MassMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MassMomentOfInertia - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MassMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec index c5c1711f50..6d66b68146 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/UnitsNet.NanoFramework.MolarEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEnergy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MolarEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec index b0448748a0..981298c1a8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/UnitsNet.NanoFramework.MolarEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarEntropy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MolarEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec index de6d2c0903..4782a5ddea 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/UnitsNet.NanoFramework.MolarMass.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.MolarMass - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET MolarMass - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec index 05a4652e35..5e2a827c1f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/UnitsNet.NanoFramework.Molarity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Molarity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Molarity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec index f3d4b4f621..1fd298d26a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/UnitsNet.NanoFramework.Permeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permeability - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Permeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec index b5cc56957d..31229df5f6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/UnitsNet.NanoFramework.Permittivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Permittivity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Permittivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec index bf63ce1650..ca1aab9f1c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/UnitsNet.NanoFramework.PorousMediumPermeability.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PorousMediumPermeability - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET PorousMediumPermeability - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec index 55147956a4..ef6aa51c71 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/UnitsNet.NanoFramework.Power.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Power - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Power - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec index 391cbecb8c..a68fa7305a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/UnitsNet.NanoFramework.PowerDensity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerDensity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET PowerDensity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec index a8374cd844..638365280a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/UnitsNet.NanoFramework.PowerRatio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PowerRatio - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET PowerRatio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec index 42ef1064b9..d93cfca381 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/UnitsNet.NanoFramework.Pressure.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Pressure - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Pressure - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec index 24691262e0..4c1bf18e52 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/UnitsNet.NanoFramework.PressureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.PressureChangeRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET PressureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec index fa190a8938..337563c346 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/UnitsNet.NanoFramework.Ratio.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Ratio - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Ratio - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec index 0bebb9be5d..39e9e02671 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/UnitsNet.NanoFramework.RatioChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RatioChangeRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET RatioChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec index ee462d24d2..c1978ea296 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/UnitsNet.NanoFramework.ReactiveEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactiveEnergy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ReactiveEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec index 42956fe581..598bbb35a2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/UnitsNet.NanoFramework.ReactivePower.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReactivePower - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ReactivePower - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec index 107dcc39d9..28d35c9b77 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/UnitsNet.NanoFramework.ReciprocalArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalArea - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ReciprocalArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec index 88b37a03f1..ab8e8317d4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/UnitsNet.NanoFramework.ReciprocalLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ReciprocalLength - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ReciprocalLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec index 21dba90b07..c4555fb407 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/UnitsNet.NanoFramework.RelativeHumidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RelativeHumidity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET RelativeHumidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec index d0187a339b..c401e49eba 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/UnitsNet.NanoFramework.RotationalAcceleration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalAcceleration - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET RotationalAcceleration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec index dbba306589..d18b7b5e27 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/UnitsNet.NanoFramework.RotationalSpeed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalSpeed - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET RotationalSpeed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec index 0c560d8be3..f77e7444b2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/UnitsNet.NanoFramework.RotationalStiffness.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffness - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET RotationalStiffness - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec index 14d423038f..6ee561a153 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/UnitsNet.NanoFramework.RotationalStiffnessPerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.RotationalStiffnessPerLength - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET RotationalStiffnessPerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec index 069152c512..71dad6b5bd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/UnitsNet.NanoFramework.Scalar.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Scalar - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Scalar - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec index 218e5cf573..2b42d0c370 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/UnitsNet.NanoFramework.SolidAngle.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SolidAngle - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET SolidAngle - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec index 3bddff4475..e7dd6c06d9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/UnitsNet.NanoFramework.SpecificEnergy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEnergy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET SpecificEnergy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec index 370c54fbaf..d9afab8b74 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/UnitsNet.NanoFramework.SpecificEntropy.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificEntropy - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET SpecificEntropy - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec index 79d2eb9edd..b6e5a3172c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/UnitsNet.NanoFramework.SpecificFuelConsumption.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificFuelConsumption - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET SpecificFuelConsumption - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec index 541a0b19cc..6db6282380 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/UnitsNet.NanoFramework.SpecificVolume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificVolume - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET SpecificVolume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec index 8e224ce750..d9b569a4e0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/UnitsNet.NanoFramework.SpecificWeight.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.SpecificWeight - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET SpecificWeight - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec index 271511f6e9..48c083c774 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/UnitsNet.NanoFramework.Speed.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Speed - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Speed - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec index 75674d591e..976d1fe522 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/UnitsNet.NanoFramework.StandardVolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.StandardVolumeFlow - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET StandardVolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec index ca4f134917..2d7b9ce7e6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/UnitsNet.NanoFramework.Temperature.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Temperature - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Temperature - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec index 3f91d07816..68226fe94b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/UnitsNet.NanoFramework.TemperatureChangeRate.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureChangeRate - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET TemperatureChangeRate - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec index 49d07614e2..11283b17f8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/UnitsNet.NanoFramework.TemperatureDelta.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureDelta - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET TemperatureDelta - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec index 9ca767900b..cc8e7bd4eb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/UnitsNet.NanoFramework.TemperatureGradient.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TemperatureGradient - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET TemperatureGradient - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec index 1e1d125c11..9756892b1b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/UnitsNet.NanoFramework.ThermalConductivity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalConductivity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ThermalConductivity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec index 7a3c7bd6e7..3115a66f26 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/UnitsNet.NanoFramework.ThermalResistance.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.ThermalResistance - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET ThermalResistance - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec index 505ca537d7..196df51b07 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/UnitsNet.NanoFramework.Torque.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Torque - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Torque - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec index d893625498..589ade5328 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/UnitsNet.NanoFramework.TorquePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.TorquePerLength - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET TorquePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec index 4e540432a6..f19f08c647 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/UnitsNet.NanoFramework.Turbidity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Turbidity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Turbidity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec index c39c263c11..b8756009cf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/UnitsNet.NanoFramework.VitaminA.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VitaminA - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET VitaminA - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec index dfbbde938c..6fa4857d84 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/UnitsNet.NanoFramework.Volume.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.Volume - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET Volume - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec index 33a413e0de..38905744ac 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/UnitsNet.NanoFramework.VolumeConcentration.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeConcentration - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET VolumeConcentration - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec index 3296f1b795..d8a477b581 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/UnitsNet.NanoFramework.VolumeFlow.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlow - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET VolumeFlow - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec index a5ea670920..67e12a7426 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/UnitsNet.NanoFramework.VolumeFlowPerArea.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumeFlowPerArea - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET VolumeFlowPerArea - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec index 2f189f1a3a..ff83aee088 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/UnitsNet.NanoFramework.VolumePerLength.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumePerLength - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET VolumePerLength - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec index 7ad85c3a5a..4c45a39ada 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/UnitsNet.NanoFramework.VolumetricHeatCapacity.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.VolumetricHeatCapacity - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET VolumetricHeatCapacity - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec index 58190ba323..62cf81e2f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/UnitsNet.NanoFramework.WarpingMomentOfInertia.nuspec @@ -2,7 +2,7 @@ UnitsNet.nanoFramework.WarpingMomentOfInertia - 5.0.0-alpha005 + 5.0.0-alpha006 Units.NET WarpingMomentOfInertia - nanoFramework Andreas Gullberg Larsen,nanoFramework project contributors UnitsNet diff --git a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj index c9a4def318..331edc0c0b 100644 --- a/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj +++ b/UnitsNet.NumberExtensions/UnitsNet.NumberExtensions.csproj @@ -2,7 +2,7 @@ UnitsNet.NumberExtensions - 5.0.0-alpha005 + 5.0.0-alpha006 Andreas Gullberg Larsen, Lu Li, Jon Suda Units.NET NumberExtensions Adds extension methods to number types to more easily create quantities, such as 5.Meters() instead of Length.FromMeters(5). diff --git a/UnitsNet/UnitsNet.csproj b/UnitsNet/UnitsNet.csproj index 7c2904b540..365ec7e8d6 100644 --- a/UnitsNet/UnitsNet.csproj +++ b/UnitsNet/UnitsNet.csproj @@ -2,7 +2,7 @@ UnitsNet - 5.0.0-alpha005 + 5.0.0-alpha006 Andreas Gullberg Larsen Units.NET Get all the common units of measurement and the conversions between them. It is light-weight and thoroughly tested. From 06da6d16d0e6167dac40278956e51d26cc8a5f7d Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Fri, 3 Jun 2022 23:45:55 +0200 Subject: [PATCH 56/66] Log debug info for nanoframework installation --- Build/init.ps1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/Build/init.ps1 b/Build/init.ps1 index bdd5300503..2640e20ffa 100644 --- a/Build/init.ps1 +++ b/Build/init.ps1 @@ -61,19 +61,24 @@ if (!(Test-Path "$msbuildPath/nanoFramework")) { $extensionVersion = $vs2019Tag } - Write-Output "Downloading visx..." -NoNewline + Write-Output "Downloading visx..." # download VS extension - Write-Debug "Download VSIX file from $extensionUrl to $vsixPath" + Write-Host "Download VSIX file from $extensionUrl to $vsixPath" $webClient.DownloadFile($extensionUrl, $vsixPath) $outputPath = "$tempDir\nf-extension" $vsixPath = Join-Path -Path $tempDir -ChildPath "nf-extension.zip" - $webClient.DownloadFile($extensionUrl,$vsixPath) - Expand-Archive -LiteralPath $vsixPath -DestinationPath $outputPath | Write-Host + $webClient.DownloadFile($extensionUrl, $vsixPath) + + Write-Host "Extract VSIX file to $outputPath" + Expand-Archive -LiteralPath $vsixPath -DestinationPath $outputPath -Force | Write-Host + + $copyFrom = "$outputPath\`$MSBuild\nanoFramework" - Copy-Item -Path "$outputPath\`$MSBuild\nanoFramework" -Destination $msbuildPath -Recurse + Write-Host "Copy from $copyFrom to $msbuildPath" + Copy-Item -Path "$copyFrom" -Destination $msbuildPath -Recurse Write-Host "Installed VS extension $extensionVersion" } From 847489657ce3fa5e05816a712358e8dda9bcb8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Sim=C3=B5es?= Date: Tue, 7 Jun 2022 15:24:29 +0100 Subject: [PATCH 57/66] Switch nanoFramework build to x64 (#1095) * Switch nanoFramework build to x64 * Migrate nanoFramework projects and generator to VS2022 style --- Build/build-functions.psm1 | 2 +- CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs | 2 +- .../GeneratedCode/Acceleration/Acceleration.nfproj | 2 +- .../GeneratedCode/AmountOfSubstance/AmountOfSubstance.nfproj | 2 +- .../GeneratedCode/AmplitudeRatio/AmplitudeRatio.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Angle/Angle.nfproj | 2 +- .../GeneratedCode/ApparentEnergy/ApparentEnergy.nfproj | 2 +- .../GeneratedCode/ApparentPower/ApparentPower.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Area/Area.nfproj | 2 +- .../GeneratedCode/AreaDensity/AreaDensity.nfproj | 2 +- .../AreaMomentOfInertia/AreaMomentOfInertia.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/BitRate/BitRate.nfproj | 2 +- .../BrakeSpecificFuelConsumption.nfproj | 2 +- .../GeneratedCode/Capacitance/Capacitance.nfproj | 2 +- .../CoefficientOfThermalExpansion.nfproj | 2 +- .../GeneratedCode/Compressibility/Compressibility.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Density/Density.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Duration/Duration.nfproj | 2 +- .../GeneratedCode/DynamicViscosity/DynamicViscosity.nfproj | 2 +- .../GeneratedCode/ElectricAdmittance/ElectricAdmittance.nfproj | 2 +- .../GeneratedCode/ElectricCharge/ElectricCharge.nfproj | 2 +- .../ElectricChargeDensity/ElectricChargeDensity.nfproj | 2 +- .../ElectricConductance/ElectricConductance.nfproj | 2 +- .../ElectricConductivity/ElectricConductivity.nfproj | 2 +- .../GeneratedCode/ElectricCurrent/ElectricCurrent.nfproj | 2 +- .../ElectricCurrentDensity/ElectricCurrentDensity.nfproj | 2 +- .../ElectricCurrentGradient/ElectricCurrentGradient.nfproj | 2 +- .../GeneratedCode/ElectricField/ElectricField.nfproj | 2 +- .../GeneratedCode/ElectricInductance/ElectricInductance.nfproj | 2 +- .../GeneratedCode/ElectricPotential/ElectricPotential.nfproj | 2 +- .../ElectricPotentialAc/ElectricPotentialAc.nfproj | 2 +- .../ElectricPotentialChangeRate.nfproj | 2 +- .../ElectricPotentialDc/ElectricPotentialDc.nfproj | 2 +- .../GeneratedCode/ElectricResistance/ElectricResistance.nfproj | 2 +- .../ElectricResistivity/ElectricResistivity.nfproj | 2 +- .../ElectricSurfaceChargeDensity.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Energy/Energy.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Entropy/Entropy.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Force/Force.nfproj | 2 +- .../GeneratedCode/ForceChangeRate/ForceChangeRate.nfproj | 2 +- .../GeneratedCode/ForcePerLength/ForcePerLength.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Frequency/Frequency.nfproj | 2 +- .../GeneratedCode/FuelEfficiency/FuelEfficiency.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/HeatFlux/HeatFlux.nfproj | 2 +- .../HeatTransferCoefficient/HeatTransferCoefficient.nfproj | 2 +- .../GeneratedCode/Illuminance/Illuminance.nfproj | 2 +- .../GeneratedCode/Information/Information.nfproj | 2 +- .../GeneratedCode/Irradiance/Irradiance.nfproj | 2 +- .../GeneratedCode/Irradiation/Irradiation.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Jerk/Jerk.nfproj | 2 +- .../GeneratedCode/KinematicViscosity/KinematicViscosity.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/LapseRate/LapseRate.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Length/Length.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Level/Level.nfproj | 2 +- .../GeneratedCode/LinearDensity/LinearDensity.nfproj | 2 +- .../GeneratedCode/LinearPowerDensity/LinearPowerDensity.nfproj | 2 +- .../GeneratedCode/Luminosity/Luminosity.nfproj | 2 +- .../GeneratedCode/LuminousFlux/LuminousFlux.nfproj | 2 +- .../GeneratedCode/LuminousIntensity/LuminousIntensity.nfproj | 2 +- .../GeneratedCode/MagneticField/MagneticField.nfproj | 2 +- .../GeneratedCode/MagneticFlux/MagneticFlux.nfproj | 2 +- .../GeneratedCode/Magnetization/Magnetization.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Mass/Mass.nfproj | 2 +- .../GeneratedCode/MassConcentration/MassConcentration.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/MassFlow/MassFlow.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/MassFlux/MassFlux.nfproj | 2 +- .../GeneratedCode/MassFraction/MassFraction.nfproj | 2 +- .../MassMomentOfInertia/MassMomentOfInertia.nfproj | 2 +- .../GeneratedCode/MolarEnergy/MolarEnergy.nfproj | 2 +- .../GeneratedCode/MolarEntropy/MolarEntropy.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/MolarMass/MolarMass.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Molarity/Molarity.nfproj | 2 +- .../GeneratedCode/Permeability/Permeability.nfproj | 2 +- .../GeneratedCode/Permittivity/Permittivity.nfproj | 2 +- .../PorousMediumPermeability/PorousMediumPermeability.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Power/Power.nfproj | 2 +- .../GeneratedCode/PowerDensity/PowerDensity.nfproj | 2 +- .../GeneratedCode/PowerRatio/PowerRatio.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Pressure/Pressure.nfproj | 2 +- .../GeneratedCode/PressureChangeRate/PressureChangeRate.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Ratio/Ratio.nfproj | 2 +- .../GeneratedCode/RatioChangeRate/RatioChangeRate.nfproj | 2 +- .../GeneratedCode/ReactiveEnergy/ReactiveEnergy.nfproj | 2 +- .../GeneratedCode/ReactivePower/ReactivePower.nfproj | 2 +- .../GeneratedCode/ReciprocalArea/ReciprocalArea.nfproj | 2 +- .../GeneratedCode/ReciprocalLength/ReciprocalLength.nfproj | 2 +- .../GeneratedCode/RelativeHumidity/RelativeHumidity.nfproj | 2 +- .../RotationalAcceleration/RotationalAcceleration.nfproj | 2 +- .../GeneratedCode/RotationalSpeed/RotationalSpeed.nfproj | 2 +- .../RotationalStiffness/RotationalStiffness.nfproj | 2 +- .../RotationalStiffnessPerLength.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Scalar/Scalar.nfproj | 2 +- .../GeneratedCode/SolidAngle/SolidAngle.nfproj | 2 +- .../GeneratedCode/SpecificEnergy/SpecificEnergy.nfproj | 2 +- .../GeneratedCode/SpecificEntropy/SpecificEntropy.nfproj | 2 +- .../SpecificFuelConsumption/SpecificFuelConsumption.nfproj | 2 +- .../GeneratedCode/SpecificVolume/SpecificVolume.nfproj | 2 +- .../GeneratedCode/SpecificWeight/SpecificWeight.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Speed/Speed.nfproj | 2 +- .../GeneratedCode/StandardVolumeFlow/StandardVolumeFlow.nfproj | 2 +- .../GeneratedCode/Temperature/Temperature.nfproj | 2 +- .../TemperatureChangeRate/TemperatureChangeRate.nfproj | 2 +- .../GeneratedCode/TemperatureDelta/TemperatureDelta.nfproj | 2 +- .../TemperatureGradient/TemperatureGradient.nfproj | 2 +- .../ThermalConductivity/ThermalConductivity.nfproj | 2 +- .../GeneratedCode/ThermalResistance/ThermalResistance.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Torque/Torque.nfproj | 2 +- .../GeneratedCode/TorquePerLength/TorquePerLength.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Turbidity/Turbidity.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/VitaminA/VitaminA.nfproj | 2 +- UnitsNet.NanoFramework/GeneratedCode/Volume/Volume.nfproj | 2 +- .../VolumeConcentration/VolumeConcentration.nfproj | 2 +- .../GeneratedCode/VolumeFlow/VolumeFlow.nfproj | 2 +- .../GeneratedCode/VolumeFlowPerArea/VolumeFlowPerArea.nfproj | 2 +- .../GeneratedCode/VolumePerLength/VolumePerLength.nfproj | 2 +- .../VolumetricHeatCapacity/VolumetricHeatCapacity.nfproj | 2 +- .../WarpingMomentOfInertia/WarpingMomentOfInertia.nfproj | 2 +- 117 files changed, 117 insertions(+), 117 deletions(-) diff --git a/Build/build-functions.psm1 b/Build/build-functions.psm1 index 052d631f1c..398b3dae35 100644 --- a/Build/build-functions.psm1 +++ b/Build/build-functions.psm1 @@ -7,7 +7,7 @@ $nuget = "$root\Tools\NuGet.exe" $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" $msbuild = & $vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath if ($msbuild) { - $msbuild = join-path $msbuild 'MSBuild\Current\Bin\MSBuild.exe' + $msbuild = join-path $msbuild 'MSBuild\Current\Bin\amd64\MSBuild.exe' } import-module $PSScriptRoot\build-pack-nano-nugets.psm1 diff --git a/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs b/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs index 85c31baf4f..4a9503df5d 100644 --- a/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs +++ b/CodeGen/Generators/NanoFrameworkGen/ProjectGenerator.cs @@ -19,7 +19,7 @@ public string Generate() Writer.WL($@" - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/Acceleration.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/Acceleration.nfproj index 35636ffc6f..e8388a5e5c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Acceleration/Acceleration.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Acceleration/Acceleration.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/AmountOfSubstance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/AmountOfSubstance.nfproj index 4593c5685a..7e3b0f9312 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/AmountOfSubstance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/AmountOfSubstance/AmountOfSubstance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/AmplitudeRatio.nfproj b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/AmplitudeRatio.nfproj index 18b007fc18..79b3ccc427 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/AmplitudeRatio.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/AmplitudeRatio/AmplitudeRatio.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Angle/Angle.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Angle/Angle.nfproj index 07aac36251..88d9e39dd2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Angle/Angle.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Angle/Angle.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/ApparentEnergy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/ApparentEnergy.nfproj index a0ba8b0613..63cf7e3d87 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/ApparentEnergy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentEnergy/ApparentEnergy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/ApparentPower.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/ApparentPower.nfproj index 802d0e13c9..0e79e80bde 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/ApparentPower.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ApparentPower/ApparentPower.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Area/Area.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Area/Area.nfproj index a080a8e830..5ef019afb9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Area/Area.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Area/Area.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/AreaDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/AreaDensity.nfproj index 6e31463c19..43becbb5c3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/AreaDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaDensity/AreaDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/AreaMomentOfInertia.nfproj b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/AreaMomentOfInertia.nfproj index fd24ed1450..99903d92ad 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/AreaMomentOfInertia.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/AreaMomentOfInertia/AreaMomentOfInertia.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/BitRate/BitRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/BitRate/BitRate.nfproj index 7626b22477..e1cead2457 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BitRate/BitRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/BitRate/BitRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/BrakeSpecificFuelConsumption.nfproj b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/BrakeSpecificFuelConsumption.nfproj index ba5176d322..5db96d6b87 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/BrakeSpecificFuelConsumption.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/BrakeSpecificFuelConsumption/BrakeSpecificFuelConsumption.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/Capacitance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/Capacitance.nfproj index 9dbdb85bbf..0a2dcbce40 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Capacitance/Capacitance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Capacitance/Capacitance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/CoefficientOfThermalExpansion.nfproj b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/CoefficientOfThermalExpansion.nfproj index 4bedb64508..2b6f6025c5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/CoefficientOfThermalExpansion.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/CoefficientOfThermalExpansion/CoefficientOfThermalExpansion.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Compressibility/Compressibility.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Compressibility/Compressibility.nfproj index 0a39e881a9..9f8ce30bd0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Compressibility/Compressibility.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Compressibility/Compressibility.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Density/Density.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Density/Density.nfproj index 384769c2fa..a0afb05001 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Density/Density.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Density/Density.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Duration/Duration.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Duration/Duration.nfproj index 0cb21f1a47..752b93d720 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Duration/Duration.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Duration/Duration.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/DynamicViscosity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/DynamicViscosity.nfproj index 1a5ae409cf..35f6a8708f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/DynamicViscosity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/DynamicViscosity/DynamicViscosity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/ElectricAdmittance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/ElectricAdmittance.nfproj index 2e308488d0..0f6e7d584f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/ElectricAdmittance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricAdmittance/ElectricAdmittance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/ElectricCharge.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/ElectricCharge.nfproj index 45a24363df..0fadbf0d6c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/ElectricCharge.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCharge/ElectricCharge.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/ElectricChargeDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/ElectricChargeDensity.nfproj index 79f5fb3d48..7f67b6f598 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/ElectricChargeDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricChargeDensity/ElectricChargeDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/ElectricConductance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/ElectricConductance.nfproj index 166dc59c8b..b82a0029fb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/ElectricConductance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductance/ElectricConductance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/ElectricConductivity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/ElectricConductivity.nfproj index 18451c910b..601830e19b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/ElectricConductivity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricConductivity/ElectricConductivity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/ElectricCurrent.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/ElectricCurrent.nfproj index d1c1e5d3ae..57532ce337 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/ElectricCurrent.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrent/ElectricCurrent.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/ElectricCurrentDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/ElectricCurrentDensity.nfproj index 9d62d125cf..19d6418144 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/ElectricCurrentDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentDensity/ElectricCurrentDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/ElectricCurrentGradient.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/ElectricCurrentGradient.nfproj index 5976c25a21..a96cb6bde2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/ElectricCurrentGradient.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricCurrentGradient/ElectricCurrentGradient.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/ElectricField.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/ElectricField.nfproj index 04cfc2600b..e2b7ec0c2f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricField/ElectricField.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricField/ElectricField.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/ElectricInductance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/ElectricInductance.nfproj index 5b8f9d5f86..5ea978b5e1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/ElectricInductance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricInductance/ElectricInductance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/ElectricPotential.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/ElectricPotential.nfproj index 36ba27b37d..a2cec81338 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/ElectricPotential.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotential/ElectricPotential.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/ElectricPotentialAc.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/ElectricPotentialAc.nfproj index a94d532016..92ef89c047 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/ElectricPotentialAc.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialAc/ElectricPotentialAc.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/ElectricPotentialChangeRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/ElectricPotentialChangeRate.nfproj index 2e150a5dd4..bab779ae5f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/ElectricPotentialChangeRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialChangeRate/ElectricPotentialChangeRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/ElectricPotentialDc.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/ElectricPotentialDc.nfproj index 3b42752235..8a375f5b0b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/ElectricPotentialDc.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricPotentialDc/ElectricPotentialDc.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/ElectricResistance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/ElectricResistance.nfproj index 30f4ebb6a6..bd01e4dfe0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/ElectricResistance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistance/ElectricResistance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/ElectricResistivity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/ElectricResistivity.nfproj index 0d4f0ed907..9670923eec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/ElectricResistivity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricResistivity/ElectricResistivity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/ElectricSurfaceChargeDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/ElectricSurfaceChargeDensity.nfproj index e9840ecc03..f4ce693cec 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/ElectricSurfaceChargeDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ElectricSurfaceChargeDensity/ElectricSurfaceChargeDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Energy/Energy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Energy/Energy.nfproj index ad39822f04..882621ab80 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Energy/Energy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Energy/Energy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Entropy/Entropy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Entropy/Entropy.nfproj index 6e90d50056..c8885277c9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Entropy/Entropy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Entropy/Entropy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Force/Force.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Force/Force.nfproj index 9aba48dc4d..79c2166d26 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Force/Force.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Force/Force.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/ForceChangeRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/ForceChangeRate.nfproj index 64a9a9a4d7..47262a8e7c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/ForceChangeRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ForceChangeRate/ForceChangeRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/ForcePerLength.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/ForcePerLength.nfproj index d6b3ac141b..bc37d84fbb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/ForcePerLength.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ForcePerLength/ForcePerLength.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Frequency/Frequency.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Frequency/Frequency.nfproj index 8717db20ee..e407a29fa6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Frequency/Frequency.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Frequency/Frequency.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/FuelEfficiency.nfproj b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/FuelEfficiency.nfproj index 7d20535061..e755711f20 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/FuelEfficiency.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/FuelEfficiency/FuelEfficiency.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/HeatFlux.nfproj b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/HeatFlux.nfproj index ebec65442d..435fdebe13 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/HeatFlux.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatFlux/HeatFlux.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/HeatTransferCoefficient.nfproj b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/HeatTransferCoefficient.nfproj index 7b0fefa187..510ed3ea69 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/HeatTransferCoefficient.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/HeatTransferCoefficient/HeatTransferCoefficient.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/Illuminance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/Illuminance.nfproj index 9ba1eeaee5..73caf27f09 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Illuminance/Illuminance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Illuminance/Illuminance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Information/Information.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Information/Information.nfproj index 7d63e9e525..01c5c22db9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Information/Information.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Information/Information.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/Irradiance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/Irradiance.nfproj index 94f10e57ea..6602d68ee2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiance/Irradiance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiance/Irradiance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/Irradiation.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/Irradiation.nfproj index 99906559c2..9df1555821 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Irradiation/Irradiation.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Irradiation/Irradiation.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Jerk/Jerk.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Jerk/Jerk.nfproj index 68f2fe12ab..984969abc3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Jerk/Jerk.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Jerk/Jerk.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/KinematicViscosity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/KinematicViscosity.nfproj index caa5f9fdf1..2e03a2c3f7 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/KinematicViscosity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/KinematicViscosity/KinematicViscosity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/LapseRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/LapseRate.nfproj index 9735d17c90..c315332929 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LapseRate/LapseRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/LapseRate/LapseRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Length/Length.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Length/Length.nfproj index d28078b785..eb98bee282 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Length/Length.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Length/Length.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Level/Level.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Level/Level.nfproj index 5f09cb78dd..06ac88a340 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Level/Level.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Level/Level.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/LinearDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/LinearDensity.nfproj index 2332195d53..c78101f36f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/LinearDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearDensity/LinearDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/LinearPowerDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/LinearPowerDensity.nfproj index 329e6bc0d2..a014054b0b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/LinearPowerDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/LinearPowerDensity/LinearPowerDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/Luminosity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/Luminosity.nfproj index c644fd2850..e4d81b46e0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Luminosity/Luminosity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Luminosity/Luminosity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/LuminousFlux.nfproj b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/LuminousFlux.nfproj index 18cd9089d6..0482e811c9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/LuminousFlux.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousFlux/LuminousFlux.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/LuminousIntensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/LuminousIntensity.nfproj index 8641ce1859..03997ae58f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/LuminousIntensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/LuminousIntensity/LuminousIntensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/MagneticField.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/MagneticField.nfproj index 45c06506f9..d0e489a5f2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticField/MagneticField.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticField/MagneticField.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/MagneticFlux.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/MagneticFlux.nfproj index 8b22ef8530..5f1f145560 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/MagneticFlux.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MagneticFlux/MagneticFlux.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/Magnetization.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/Magnetization.nfproj index b6d06152b4..63fe602f3a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Magnetization/Magnetization.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Magnetization/Magnetization.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Mass/Mass.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Mass/Mass.nfproj index 7ca7298831..9e8b0ed4c4 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Mass/Mass.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Mass/Mass.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/MassConcentration.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/MassConcentration.nfproj index 99f35b70de..3352ff9114 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/MassConcentration.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MassConcentration/MassConcentration.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/MassFlow.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/MassFlow.nfproj index ff7cf942fb..c0fc8abdc3 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlow/MassFlow.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlow/MassFlow.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/MassFlux.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/MassFlux.nfproj index 3b23a0c90c..586c61d81e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFlux/MassFlux.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFlux/MassFlux.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/MassFraction.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/MassFraction.nfproj index a656124061..6b8e662ec2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassFraction/MassFraction.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MassFraction/MassFraction.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/MassMomentOfInertia.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/MassMomentOfInertia.nfproj index 35ea62aa0a..16badc1cc9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/MassMomentOfInertia.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MassMomentOfInertia/MassMomentOfInertia.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/MolarEnergy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/MolarEnergy.nfproj index efc484f2c2..01b9088476 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/MolarEnergy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEnergy/MolarEnergy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/MolarEntropy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/MolarEntropy.nfproj index f17128ca2f..41bc176438 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/MolarEntropy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarEntropy/MolarEntropy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/MolarMass.nfproj b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/MolarMass.nfproj index 8940fb1139..e0eaef87de 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/MolarMass/MolarMass.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/MolarMass/MolarMass.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Molarity/Molarity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Molarity/Molarity.nfproj index 5f829db395..eeb7b6c33c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Molarity/Molarity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Molarity/Molarity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permeability/Permeability.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Permeability/Permeability.nfproj index 7c5cac9ae6..1f9dd3b6c8 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permeability/Permeability.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Permeability/Permeability.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/Permittivity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/Permittivity.nfproj index 9547a04261..f341132070 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Permittivity/Permittivity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Permittivity/Permittivity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/PorousMediumPermeability.nfproj b/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/PorousMediumPermeability.nfproj index bc4b58d560..ef9f98c1b1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/PorousMediumPermeability.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/PorousMediumPermeability/PorousMediumPermeability.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Power/Power.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Power/Power.nfproj index 3424272f47..049034bbc5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Power/Power.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Power/Power.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/PowerDensity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/PowerDensity.nfproj index ff48ea01d3..b1686cd792 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/PowerDensity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerDensity/PowerDensity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/PowerRatio.nfproj b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/PowerRatio.nfproj index 124f5e72ce..62fc65fb5e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/PowerRatio.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/PowerRatio/PowerRatio.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Pressure/Pressure.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Pressure/Pressure.nfproj index 950ff16ab8..270145bc3e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Pressure/Pressure.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Pressure/Pressure.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/PressureChangeRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/PressureChangeRate.nfproj index 907b787306..9a3daaeeeb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/PressureChangeRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/PressureChangeRate/PressureChangeRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Ratio/Ratio.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Ratio/Ratio.nfproj index 6ead588561..0cfae1995b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Ratio/Ratio.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Ratio/Ratio.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/RatioChangeRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/RatioChangeRate.nfproj index 8fe6a6f46c..1066763a7f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/RatioChangeRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/RatioChangeRate/RatioChangeRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/ReactiveEnergy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/ReactiveEnergy.nfproj index a5a0fc3d05..beb8a7707b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/ReactiveEnergy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactiveEnergy/ReactiveEnergy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/ReactivePower.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/ReactivePower.nfproj index 0f42536dd8..568acb4204 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/ReactivePower.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ReactivePower/ReactivePower.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/ReciprocalArea.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/ReciprocalArea.nfproj index d57f494411..151bb2a60c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/ReciprocalArea.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalArea/ReciprocalArea.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/ReciprocalLength.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/ReciprocalLength.nfproj index bbf467439d..6ded221538 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/ReciprocalLength.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ReciprocalLength/ReciprocalLength.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/RelativeHumidity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/RelativeHumidity.nfproj index 4f83ae707d..3de2fd805a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/RelativeHumidity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/RelativeHumidity/RelativeHumidity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/RotationalAcceleration.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/RotationalAcceleration.nfproj index 8f976927fc..67cf27f87e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/RotationalAcceleration.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalAcceleration/RotationalAcceleration.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/RotationalSpeed.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/RotationalSpeed.nfproj index 1c305d1916..d2ccd7f27a 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/RotationalSpeed.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalSpeed/RotationalSpeed.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/RotationalStiffness.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/RotationalStiffness.nfproj index aa20646d49..4996ea1064 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/RotationalStiffness.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffness/RotationalStiffness.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/RotationalStiffnessPerLength.nfproj b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/RotationalStiffnessPerLength.nfproj index 333b2a6134..3c32173ccb 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/RotationalStiffnessPerLength.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/RotationalStiffnessPerLength/RotationalStiffnessPerLength.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Scalar/Scalar.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Scalar/Scalar.nfproj index b3ca16ede5..d1d0dd917c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Scalar/Scalar.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Scalar/Scalar.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/SolidAngle.nfproj b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/SolidAngle.nfproj index 41062f7200..cb6906befa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/SolidAngle.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/SolidAngle/SolidAngle.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/SpecificEnergy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/SpecificEnergy.nfproj index 11585fdb41..c0df24ef71 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/SpecificEnergy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEnergy/SpecificEnergy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/SpecificEntropy.nfproj b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/SpecificEntropy.nfproj index 4a36c4a784..19a3d01a82 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/SpecificEntropy.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificEntropy/SpecificEntropy.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/SpecificFuelConsumption.nfproj b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/SpecificFuelConsumption.nfproj index a709aec043..4e1596d2c5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/SpecificFuelConsumption.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificFuelConsumption/SpecificFuelConsumption.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/SpecificVolume.nfproj b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/SpecificVolume.nfproj index da8891d07d..b187886810 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/SpecificVolume.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificVolume/SpecificVolume.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/SpecificWeight.nfproj b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/SpecificWeight.nfproj index 1fc30b4e48..40a47a708e 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/SpecificWeight.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/SpecificWeight/SpecificWeight.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Speed/Speed.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Speed/Speed.nfproj index ec68b4e5c5..8e6aaf1d89 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Speed/Speed.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Speed/Speed.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/StandardVolumeFlow.nfproj b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/StandardVolumeFlow.nfproj index 2bc692872a..b6f44c4a19 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/StandardVolumeFlow.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/StandardVolumeFlow/StandardVolumeFlow.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Temperature/Temperature.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Temperature/Temperature.nfproj index e5d08e7cf5..2c117ed193 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Temperature/Temperature.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Temperature/Temperature.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/TemperatureChangeRate.nfproj b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/TemperatureChangeRate.nfproj index 982b7a9a0e..0141f5783d 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/TemperatureChangeRate.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureChangeRate/TemperatureChangeRate.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/TemperatureDelta.nfproj b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/TemperatureDelta.nfproj index b9f362eb49..34262194b0 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/TemperatureDelta.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureDelta/TemperatureDelta.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/TemperatureGradient.nfproj b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/TemperatureGradient.nfproj index 380b278cc7..17da3e1116 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/TemperatureGradient.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/TemperatureGradient/TemperatureGradient.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/ThermalConductivity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/ThermalConductivity.nfproj index f33c3f5a0f..318630be01 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/ThermalConductivity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalConductivity/ThermalConductivity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/ThermalResistance.nfproj b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/ThermalResistance.nfproj index ee7fccbfb0..15bb0640d1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/ThermalResistance.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/ThermalResistance/ThermalResistance.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Torque/Torque.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Torque/Torque.nfproj index ce7a2799f0..9533f369a9 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Torque/Torque.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Torque/Torque.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj index 09c316cfd5..56ed5642fa 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/TorquePerLength/TorquePerLength.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/Turbidity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/Turbidity.nfproj index 09c52833d4..f2854a614b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Turbidity/Turbidity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Turbidity/Turbidity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/VitaminA.nfproj b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/VitaminA.nfproj index 85d2745fef..040467dc4f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VitaminA/VitaminA.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/VitaminA/VitaminA.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/Volume/Volume.nfproj b/UnitsNet.NanoFramework/GeneratedCode/Volume/Volume.nfproj index c7bb646da1..873415b3dd 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Volume/Volume.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/Volume/Volume.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/VolumeConcentration.nfproj b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/VolumeConcentration.nfproj index 19d337469a..25858bf2d2 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/VolumeConcentration.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeConcentration/VolumeConcentration.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/VolumeFlow.nfproj b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/VolumeFlow.nfproj index 0d5eac4518..a7cad74bcf 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/VolumeFlow.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlow/VolumeFlow.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/VolumeFlowPerArea.nfproj b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/VolumeFlowPerArea.nfproj index be1bf7ed87..af1090f04f 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/VolumeFlowPerArea.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumeFlowPerArea/VolumeFlowPerArea.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/VolumePerLength.nfproj b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/VolumePerLength.nfproj index cecf53d87b..bde1b96b57 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/VolumePerLength.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumePerLength/VolumePerLength.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/VolumetricHeatCapacity.nfproj b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/VolumetricHeatCapacity.nfproj index 418fc35d3e..eebb50e94c 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/VolumetricHeatCapacity.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/VolumetricHeatCapacity/VolumetricHeatCapacity.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ diff --git a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/WarpingMomentOfInertia.nfproj b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/WarpingMomentOfInertia.nfproj index 17cabc3f6b..5d547a13b6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/WarpingMomentOfInertia.nfproj +++ b/UnitsNet.NanoFramework/GeneratedCode/WarpingMomentOfInertia/WarpingMomentOfInertia.nfproj @@ -1,7 +1,7 @@ - $(MSBuildToolsPath)..\..\..\nanoFramework\v1.0\ + $(MSBuildExtensionsPath)\nanoFramework\v1.0\ From 37fa69085f75fa3281e110429c822050fb04e7fc Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 7 Jun 2022 16:34:45 +0200 Subject: [PATCH 58/66] appveyor: Re-enable flag to not build release/v5 twice --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index 9b3345671c..c7f41e1945 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,7 +2,7 @@ version: '{build}' image: Visual Studio 2022 # Don't build PR commits twice -skip_branch_with_pr: false +skip_branch_with_pr: true # Don't build tags, avoid duplicate builds on master when bumping version skip_tags: true From 3038381604a14832553efffd21759e5363625c24 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 14 Jun 2022 22:06:10 +0200 Subject: [PATCH 59/66] =?UTF-8?q?=F0=9F=92=9A=20Fix=20stack=20overflow=20i?= =?UTF-8?q?n=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There is no unit with enum value 0 anymore. In v4, this was Undefined. --- CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs | 2 +- .../GeneratedCode/TestsBase/AccelerationTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs | 2 +- .../TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs | 2 +- .../TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs | 2 +- .../TestsBase/ElectricCurrentDensityTestsBase.g.cs | 2 +- .../TestsBase/ElectricCurrentGradientTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs | 2 +- .../TestsBase/ElectricPotentialChangeRateTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs | 2 +- .../TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs | 2 +- .../TestsBase/HeatTransferCoefficientTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/InformationTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/IrradiationTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MassFractionTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/PermittivityTestsBase.g.cs | 2 +- .../TestsBase/PorousMediumPermeabilityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs | 2 +- .../TestsBase/RotationalAccelerationTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs | 2 +- .../TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs | 2 +- .../TestsBase/SpecificFuelConsumptionTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/TemperatureTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs | 2 +- .../GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs | 2 +- UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs | 2 +- .../TestsBase/VolumetricHeatCapacityTestsBase.g.cs | 2 +- .../TestsBase/WarpingMomentOfInertiaTestsBase.g.cs | 2 +- 116 files changed, 116 insertions(+), 116 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 19ff96c95a..b9a4f2db68 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -373,7 +373,7 @@ public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit({_unitEnumName} unit) {{ // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = {_quantity.Name}.Units.FirstOrDefault(u => u != {_quantity.Name}.BaseUnit); + var fromUnit = {_quantity.Name}.Units.Where(u => u != {_quantity.Name}.BaseUnit).DefaultIfEmpty({_quantity.Name}.BaseUnit).FirstOrDefault(); var quantity = {_quantity.Name}.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index db2d4a2f0c..f70180cba6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -1015,7 +1015,7 @@ public void ToUnit_WithSameUnits_AreEqual(AccelerationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AccelerationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Acceleration.Units.FirstOrDefault(u => u != Acceleration.BaseUnit); + var fromUnit = Acceleration.Units.Where(u => u != Acceleration.BaseUnit).DefaultIfEmpty(Acceleration.BaseUnit).FirstOrDefault(); var quantity = Acceleration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 984af03f89..52cc5fa708 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -691,7 +691,7 @@ public void ToUnit_WithSameUnits_AreEqual(AmountOfSubstanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AmountOfSubstanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AmountOfSubstance.Units.FirstOrDefault(u => u != AmountOfSubstance.BaseUnit); + var fromUnit = AmountOfSubstance.Units.Where(u => u != AmountOfSubstance.BaseUnit).DefaultIfEmpty(AmountOfSubstance.BaseUnit).FirstOrDefault(); var quantity = AmountOfSubstance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 0948419045..53181b282b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(AmplitudeRatioUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AmplitudeRatioUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AmplitudeRatio.Units.FirstOrDefault(u => u != AmplitudeRatio.BaseUnit); + var fromUnit = AmplitudeRatio.Units.Where(u => u != AmplitudeRatio.BaseUnit).DefaultIfEmpty(AmplitudeRatio.BaseUnit).FirstOrDefault(); var quantity = AmplitudeRatio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index fb42205076..b6f83dd254 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -1275,7 +1275,7 @@ public void ToUnit_WithSameUnits_AreEqual(AngleUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AngleUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Angle.Units.FirstOrDefault(u => u != Angle.BaseUnit); + var fromUnit = Angle.Units.Where(u => u != Angle.BaseUnit).DefaultIfEmpty(Angle.BaseUnit).FirstOrDefault(); var quantity = Angle.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 89c4c6896d..e84c7b0aad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(ApparentEnergyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ApparentEnergyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ApparentEnergy.Units.FirstOrDefault(u => u != ApparentEnergy.BaseUnit); + var fromUnit = ApparentEnergy.Units.Where(u => u != ApparentEnergy.BaseUnit).DefaultIfEmpty(ApparentEnergy.BaseUnit).FirstOrDefault(); var quantity = ApparentEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 25de138533..b650b9bcd9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(ApparentPowerUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ApparentPowerUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ApparentPower.Units.FirstOrDefault(u => u != ApparentPower.BaseUnit); + var fromUnit = ApparentPower.Units.Where(u => u != ApparentPower.BaseUnit).DefaultIfEmpty(ApparentPower.BaseUnit).FirstOrDefault(); var quantity = ApparentPower.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index a7d6c00e27..a9585c99c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(AreaDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AreaDensity.Units.FirstOrDefault(u => u != AreaDensity.BaseUnit); + var fromUnit = AreaDensity.Units.Where(u => u != AreaDensity.BaseUnit).DefaultIfEmpty(AreaDensity.BaseUnit).FirstOrDefault(); var quantity = AreaDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 3f9cf81f6e..2321a0aadf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -551,7 +551,7 @@ public void ToUnit_WithSameUnits_AreEqual(AreaMomentOfInertiaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaMomentOfInertiaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AreaMomentOfInertia.Units.FirstOrDefault(u => u != AreaMomentOfInertia.BaseUnit); + var fromUnit = AreaMomentOfInertia.Units.Where(u => u != AreaMomentOfInertia.BaseUnit).DefaultIfEmpty(AreaMomentOfInertia.BaseUnit).FirstOrDefault(); var quantity = AreaMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 68ea99df0e..39bffa73de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -1305,7 +1305,7 @@ public void ToUnit_WithSameUnits_AreEqual(AreaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Area.Units.FirstOrDefault(u => u != Area.BaseUnit); + var fromUnit = Area.Units.Where(u => u != Area.BaseUnit).DefaultIfEmpty(Area.BaseUnit).FirstOrDefault(); var quantity = Area.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 4169589be5..a26e942ea8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -1374,7 +1374,7 @@ public void ToUnit_WithSameUnits_AreEqual(BitRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(BitRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = BitRate.Units.FirstOrDefault(u => u != BitRate.BaseUnit); + var fromUnit = BitRate.Units.Where(u => u != BitRate.BaseUnit).DefaultIfEmpty(BitRate.BaseUnit).FirstOrDefault(); var quantity = BitRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 6f628ab80d..6e1bc6b653 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(BrakeSpecificFuelConsumptionUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(BrakeSpecificFuelConsumptionUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = BrakeSpecificFuelConsumption.Units.FirstOrDefault(u => u != BrakeSpecificFuelConsumption.BaseUnit); + var fromUnit = BrakeSpecificFuelConsumption.Units.Where(u => u != BrakeSpecificFuelConsumption.BaseUnit).DefaultIfEmpty(BrakeSpecificFuelConsumption.BaseUnit).FirstOrDefault(); var quantity = BrakeSpecificFuelConsumption.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index 054de18a82..e6d03a76dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -419,7 +419,7 @@ public void ToUnit_WithSameUnits_AreEqual(CapacitanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CapacitanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Capacitance.Units.FirstOrDefault(u => u != Capacitance.BaseUnit); + var fromUnit = Capacitance.Units.Where(u => u != Capacitance.BaseUnit).DefaultIfEmpty(Capacitance.BaseUnit).FirstOrDefault(); var quantity = Capacitance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 0aae036b82..01b59f24d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -377,7 +377,7 @@ public void ToUnit_WithSameUnits_AreEqual(CoefficientOfThermalExpansionUnit unit public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CoefficientOfThermalExpansionUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = CoefficientOfThermalExpansion.Units.FirstOrDefault(u => u != CoefficientOfThermalExpansion.BaseUnit); + var fromUnit = CoefficientOfThermalExpansion.Units.Where(u => u != CoefficientOfThermalExpansion.BaseUnit).DefaultIfEmpty(CoefficientOfThermalExpansion.BaseUnit).FirstOrDefault(); var quantity = CoefficientOfThermalExpansion.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index 285865a160..aaf1331202 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -609,7 +609,7 @@ public void ToUnit_WithSameUnits_AreEqual(CompressibilityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CompressibilityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Compressibility.Units.FirstOrDefault(u => u != Compressibility.BaseUnit); + var fromUnit = Compressibility.Units.Where(u => u != Compressibility.BaseUnit).DefaultIfEmpty(Compressibility.BaseUnit).FirstOrDefault(); var quantity = Compressibility.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 5082d38ce8..a37f498d85 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -2033,7 +2033,7 @@ public void ToUnit_WithSameUnits_AreEqual(DensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Density.Units.FirstOrDefault(u => u != Density.BaseUnit); + var fromUnit = Density.Units.Where(u => u != Density.BaseUnit).DefaultIfEmpty(Density.BaseUnit).FirstOrDefault(); var quantity = Density.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index d1deb46527..528fb07f8f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -1753,7 +1753,7 @@ public void ToUnit_WithSameUnits_AreEqual(DurationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DurationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Duration.Units.FirstOrDefault(u => u != Duration.BaseUnit); + var fromUnit = Duration.Units.Where(u => u != Duration.BaseUnit).DefaultIfEmpty(Duration.BaseUnit).FirstOrDefault(); var quantity = Duration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index e31f560c32..ee6a1a3d95 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -615,7 +615,7 @@ public void ToUnit_WithSameUnits_AreEqual(DynamicViscosityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DynamicViscosityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = DynamicViscosity.Units.FirstOrDefault(u => u != DynamicViscosity.BaseUnit); + var fromUnit = DynamicViscosity.Units.Where(u => u != DynamicViscosity.BaseUnit).DefaultIfEmpty(DynamicViscosity.BaseUnit).FirstOrDefault(); var quantity = DynamicViscosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index ef583bb706..baf2955386 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricAdmittanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricAdmittanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricAdmittance.Units.FirstOrDefault(u => u != ElectricAdmittance.BaseUnit); + var fromUnit = ElectricAdmittance.Units.Where(u => u != ElectricAdmittance.BaseUnit).DefaultIfEmpty(ElectricAdmittance.BaseUnit).FirstOrDefault(); var quantity = ElectricAdmittance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index c73c8815e4..e5f237ac25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricChargeDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricChargeDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricChargeDensity.Units.FirstOrDefault(u => u != ElectricChargeDensity.BaseUnit); + var fromUnit = ElectricChargeDensity.Units.Where(u => u != ElectricChargeDensity.BaseUnit).DefaultIfEmpty(ElectricChargeDensity.BaseUnit).FirstOrDefault(); var quantity = ElectricChargeDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index 1d726e077a..ffd6b25293 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -425,7 +425,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricChargeUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricChargeUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCharge.Units.FirstOrDefault(u => u != ElectricCharge.BaseUnit); + var fromUnit = ElectricCharge.Units.Where(u => u != ElectricCharge.BaseUnit).DefaultIfEmpty(ElectricCharge.BaseUnit).FirstOrDefault(); var quantity = ElectricCharge.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index f37f896a10..d7e199bded 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricConductanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricConductance.Units.FirstOrDefault(u => u != ElectricConductance.BaseUnit); + var fromUnit = ElectricConductance.Units.Where(u => u != ElectricConductance.BaseUnit).DefaultIfEmpty(ElectricConductance.BaseUnit).FirstOrDefault(); var quantity = ElectricConductance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 444d9c549a..1819849908 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricConductivityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductivityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricConductivity.Units.FirstOrDefault(u => u != ElectricConductivity.BaseUnit); + var fromUnit = ElectricConductivity.Units.Where(u => u != ElectricConductivity.BaseUnit).DefaultIfEmpty(ElectricConductivity.BaseUnit).FirstOrDefault(); var quantity = ElectricConductivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index f8b533c17d..8269cdcded 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCurrentDensity.Units.FirstOrDefault(u => u != ElectricCurrentDensity.BaseUnit); + var fromUnit = ElectricCurrentDensity.Units.Where(u => u != ElectricCurrentDensity.BaseUnit).DefaultIfEmpty(ElectricCurrentDensity.BaseUnit).FirstOrDefault(); var quantity = ElectricCurrentDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 899b96760f..415f793b1c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentGradientUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentGradientUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCurrentGradient.Units.FirstOrDefault(u => u != ElectricCurrentGradient.BaseUnit); + var fromUnit = ElectricCurrentGradient.Units.Where(u => u != ElectricCurrentGradient.BaseUnit).DefaultIfEmpty(ElectricCurrentGradient.BaseUnit).FirstOrDefault(); var quantity = ElectricCurrentGradient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index c531575357..14be5a3b96 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -453,7 +453,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCurrent.Units.FirstOrDefault(u => u != ElectricCurrent.BaseUnit); + var fromUnit = ElectricCurrent.Units.Where(u => u != ElectricCurrent.BaseUnit).DefaultIfEmpty(ElectricCurrent.BaseUnit).FirstOrDefault(); var quantity = ElectricCurrent.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index c08c4b0ae2..e75dc3285b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricFieldUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricFieldUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricField.Units.FirstOrDefault(u => u != ElectricField.BaseUnit); + var fromUnit = ElectricField.Units.Where(u => u != ElectricField.BaseUnit).DefaultIfEmpty(ElectricField.BaseUnit).FirstOrDefault(); var quantity = ElectricField.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 10c89a66db..b436a94c0d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricInductanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricInductanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricInductance.Units.FirstOrDefault(u => u != ElectricInductance.BaseUnit); + var fromUnit = ElectricInductance.Units.Where(u => u != ElectricInductance.BaseUnit).DefaultIfEmpty(ElectricInductance.BaseUnit).FirstOrDefault(); var quantity = ElectricInductance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 1259ab4e67..54413cf013 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -351,7 +351,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialAcUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialAcUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotentialAc.Units.FirstOrDefault(u => u != ElectricPotentialAc.BaseUnit); + var fromUnit = ElectricPotentialAc.Units.Where(u => u != ElectricPotentialAc.BaseUnit).DefaultIfEmpty(ElectricPotentialAc.BaseUnit).FirstOrDefault(); var quantity = ElectricPotentialAc.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 05278a23c3..11f38843a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -795,7 +795,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialChangeRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialChangeRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotentialChangeRate.Units.FirstOrDefault(u => u != ElectricPotentialChangeRate.BaseUnit); + var fromUnit = ElectricPotentialChangeRate.Units.Where(u => u != ElectricPotentialChangeRate.BaseUnit).DefaultIfEmpty(ElectricPotentialChangeRate.BaseUnit).FirstOrDefault(); var quantity = ElectricPotentialChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index cda98a23fa..d7b84a15dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -351,7 +351,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialDcUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialDcUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotentialDc.Units.FirstOrDefault(u => u != ElectricPotentialDc.BaseUnit); + var fromUnit = ElectricPotentialDc.Units.Where(u => u != ElectricPotentialDc.BaseUnit).DefaultIfEmpty(ElectricPotentialDc.BaseUnit).FirstOrDefault(); var quantity = ElectricPotentialDc.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 0c0579f636..85c888287a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -449,7 +449,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotential.Units.FirstOrDefault(u => u != ElectricPotential.BaseUnit); + var fromUnit = ElectricPotential.Units.Where(u => u != ElectricPotential.BaseUnit).DefaultIfEmpty(ElectricPotential.BaseUnit).FirstOrDefault(); var quantity = ElectricPotential.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 7c5ef01713..2f5ab2b600 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -385,7 +385,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricResistanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricResistanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricResistance.Units.FirstOrDefault(u => u != ElectricResistance.BaseUnit); + var fromUnit = ElectricResistance.Units.Where(u => u != ElectricResistance.BaseUnit).DefaultIfEmpty(ElectricResistance.BaseUnit).FirstOrDefault(); var quantity = ElectricResistance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 5058e4834a..061188ed83 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -635,7 +635,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricResistivityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricResistivityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricResistivity.Units.FirstOrDefault(u => u != ElectricResistivity.BaseUnit); + var fromUnit = ElectricResistivity.Units.Where(u => u != ElectricResistivity.BaseUnit).DefaultIfEmpty(ElectricResistivity.BaseUnit).FirstOrDefault(); var quantity = ElectricResistivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index e957586110..50650f67de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricSurfaceChargeDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricSurfaceChargeDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricSurfaceChargeDensity.Units.FirstOrDefault(u => u != ElectricSurfaceChargeDensity.BaseUnit); + var fromUnit = ElectricSurfaceChargeDensity.Units.Where(u => u != ElectricSurfaceChargeDensity.BaseUnit).DefaultIfEmpty(ElectricSurfaceChargeDensity.BaseUnit).FirstOrDefault(); var quantity = ElectricSurfaceChargeDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index b7b9f08014..22b563d859 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -1909,7 +1909,7 @@ public void ToUnit_WithSameUnits_AreEqual(EnergyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(EnergyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Energy.Units.FirstOrDefault(u => u != Energy.BaseUnit); + var fromUnit = Energy.Units.Where(u => u != Energy.BaseUnit).DefaultIfEmpty(Energy.BaseUnit).FirstOrDefault(); var quantity = Energy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 398c8a69da..06ae0fd4e5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -441,7 +441,7 @@ public void ToUnit_WithSameUnits_AreEqual(EntropyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(EntropyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Entropy.Units.FirstOrDefault(u => u != Entropy.BaseUnit); + var fromUnit = Entropy.Units.Where(u => u != Entropy.BaseUnit).DefaultIfEmpty(Entropy.BaseUnit).FirstOrDefault(); var quantity = Entropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 1effb6678d..6e46e12a28 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -809,7 +809,7 @@ public void ToUnit_WithSameUnits_AreEqual(ForceChangeRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForceChangeRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ForceChangeRate.Units.FirstOrDefault(u => u != ForceChangeRate.BaseUnit); + var fromUnit = ForceChangeRate.Units.Where(u => u != ForceChangeRate.BaseUnit).DefaultIfEmpty(ForceChangeRate.BaseUnit).FirstOrDefault(); var quantity = ForceChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index e651bef0d9..c9979db3cf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -1669,7 +1669,7 @@ public void ToUnit_WithSameUnits_AreEqual(ForcePerLengthUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForcePerLengthUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ForcePerLength.Units.FirstOrDefault(u => u != ForcePerLength.BaseUnit); + var fromUnit = ForcePerLength.Units.Where(u => u != ForcePerLength.BaseUnit).DefaultIfEmpty(ForcePerLength.BaseUnit).FirstOrDefault(); var quantity = ForcePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 61bc18f03d..28a015c7a7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -1127,7 +1127,7 @@ public void ToUnit_WithSameUnits_AreEqual(ForceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Force.Units.FirstOrDefault(u => u != Force.BaseUnit); + var fromUnit = Force.Units.Where(u => u != Force.BaseUnit).DefaultIfEmpty(Force.BaseUnit).FirstOrDefault(); var quantity = Force.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 8d107be5ad..6235036d30 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -745,7 +745,7 @@ public void ToUnit_WithSameUnits_AreEqual(FrequencyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FrequencyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Frequency.Units.FirstOrDefault(u => u != Frequency.BaseUnit); + var fromUnit = Frequency.Units.Where(u => u != Frequency.BaseUnit).DefaultIfEmpty(Frequency.BaseUnit).FirstOrDefault(); var quantity = Frequency.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index b2f55165de..267c73802f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(FuelEfficiencyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FuelEfficiencyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = FuelEfficiency.Units.FirstOrDefault(u => u != FuelEfficiency.BaseUnit); + var fromUnit = FuelEfficiency.Units.Where(u => u != FuelEfficiency.BaseUnit).DefaultIfEmpty(FuelEfficiency.BaseUnit).FirstOrDefault(); var quantity = FuelEfficiency.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index 1a096a8b27..d894f51294 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -839,7 +839,7 @@ public void ToUnit_WithSameUnits_AreEqual(HeatFluxUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(HeatFluxUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = HeatFlux.Units.FirstOrDefault(u => u != HeatFlux.BaseUnit); + var fromUnit = HeatFlux.Units.Where(u => u != HeatFlux.BaseUnit).DefaultIfEmpty(HeatFlux.BaseUnit).FirstOrDefault(); var quantity = HeatFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 35f4d6cbc5..0050e1ba0e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(HeatTransferCoefficientUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(HeatTransferCoefficientUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = HeatTransferCoefficient.Units.FirstOrDefault(u => u != HeatTransferCoefficient.BaseUnit); + var fromUnit = HeatTransferCoefficient.Units.Where(u => u != HeatTransferCoefficient.BaseUnit).DefaultIfEmpty(HeatTransferCoefficient.BaseUnit).FirstOrDefault(); var quantity = HeatTransferCoefficient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index c458002c20..d53ecaf4e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -317,7 +317,7 @@ public void ToUnit_WithSameUnits_AreEqual(IlluminanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IlluminanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Illuminance.Units.FirstOrDefault(u => u != Illuminance.BaseUnit); + var fromUnit = Illuminance.Units.Where(u => u != Illuminance.BaseUnit).DefaultIfEmpty(Illuminance.BaseUnit).FirstOrDefault(); var quantity = Illuminance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 4056a7cf20..f48c5b7434 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -776,7 +776,7 @@ public void ToUnit_WithSameUnits_AreEqual(InformationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(InformationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Information.Units.FirstOrDefault(u => u != Information.BaseUnit); + var fromUnit = Information.Units.Where(u => u != Information.BaseUnit).DefaultIfEmpty(Information.BaseUnit).FirstOrDefault(); var quantity = Information.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 74362a752d..c0d10394f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -635,7 +635,7 @@ public void ToUnit_WithSameUnits_AreEqual(IrradianceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IrradianceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Irradiance.Units.FirstOrDefault(u => u != Irradiance.BaseUnit); + var fromUnit = Irradiance.Units.Where(u => u != Irradiance.BaseUnit).DefaultIfEmpty(Irradiance.BaseUnit).FirstOrDefault(); var quantity = Irradiance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 71dc1a3e79..db173e10e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -441,7 +441,7 @@ public void ToUnit_WithSameUnits_AreEqual(IrradiationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IrradiationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Irradiation.Units.FirstOrDefault(u => u != Irradiation.BaseUnit); + var fromUnit = Irradiation.Units.Where(u => u != Irradiation.BaseUnit).DefaultIfEmpty(Irradiation.BaseUnit).FirstOrDefault(); var quantity = Irradiation.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index 4848944541..4b8961c1d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -841,7 +841,7 @@ public void ToUnit_WithSameUnits_AreEqual(JerkUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(JerkUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Jerk.Units.FirstOrDefault(u => u != Jerk.BaseUnit); + var fromUnit = Jerk.Units.Where(u => u != Jerk.BaseUnit).DefaultIfEmpty(Jerk.BaseUnit).FirstOrDefault(); var quantity = Jerk.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 44f076e8cf..aad81609de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -701,7 +701,7 @@ public void ToUnit_WithSameUnits_AreEqual(KinematicViscosityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(KinematicViscosityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = KinematicViscosity.Units.FirstOrDefault(u => u != KinematicViscosity.BaseUnit); + var fromUnit = KinematicViscosity.Units.Where(u => u != KinematicViscosity.BaseUnit).DefaultIfEmpty(KinematicViscosity.BaseUnit).FirstOrDefault(); var quantity = KinematicViscosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 1407a366ef..840ff97042 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(LapseRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LapseRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LapseRate.Units.FirstOrDefault(u => u != LapseRate.BaseUnit); + var fromUnit = LapseRate.Units.Where(u => u != LapseRate.BaseUnit).DefaultIfEmpty(LapseRate.BaseUnit).FirstOrDefault(); var quantity = LapseRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index 7c3912abab..b063af3c1d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -2231,7 +2231,7 @@ public void ToUnit_WithSameUnits_AreEqual(LengthUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LengthUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Length.Units.FirstOrDefault(u => u != Length.BaseUnit); + var fromUnit = Length.Units.Where(u => u != Length.BaseUnit).DefaultIfEmpty(Length.BaseUnit).FirstOrDefault(); var quantity = Length.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index 8841b16ed1..aa977dc3e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -271,7 +271,7 @@ public void ToUnit_WithSameUnits_AreEqual(LevelUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LevelUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Level.Units.FirstOrDefault(u => u != Level.BaseUnit); + var fromUnit = Level.Units.Where(u => u != Level.BaseUnit).DefaultIfEmpty(Level.BaseUnit).FirstOrDefault(); var quantity = Level.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index 7bfeb17c47..da6d13e43c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -679,7 +679,7 @@ public void ToUnit_WithSameUnits_AreEqual(LinearDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LinearDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LinearDensity.Units.FirstOrDefault(u => u != LinearDensity.BaseUnit); + var fromUnit = LinearDensity.Units.Where(u => u != LinearDensity.BaseUnit).DefaultIfEmpty(LinearDensity.BaseUnit).FirstOrDefault(); var quantity = LinearDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 3cd61e4aaa..89f251de69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -943,7 +943,7 @@ public void ToUnit_WithSameUnits_AreEqual(LinearPowerDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LinearPowerDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LinearPowerDensity.Units.FirstOrDefault(u => u != LinearPowerDensity.BaseUnit); + var fromUnit = LinearPowerDensity.Units.Where(u => u != LinearPowerDensity.BaseUnit).DefaultIfEmpty(LinearPowerDensity.BaseUnit).FirstOrDefault(); var quantity = LinearPowerDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 64285ea511..007e99449e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -635,7 +635,7 @@ public void ToUnit_WithSameUnits_AreEqual(LuminosityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminosityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Luminosity.Units.FirstOrDefault(u => u != Luminosity.BaseUnit); + var fromUnit = Luminosity.Units.Where(u => u != Luminosity.BaseUnit).DefaultIfEmpty(Luminosity.BaseUnit).FirstOrDefault(); var quantity = Luminosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index 6af6101bf0..dcb107c35f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(LuminousFluxUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminousFluxUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LuminousFlux.Units.FirstOrDefault(u => u != LuminousFlux.BaseUnit); + var fromUnit = LuminousFlux.Units.Where(u => u != LuminousFlux.BaseUnit).DefaultIfEmpty(LuminousFlux.BaseUnit).FirstOrDefault(); var quantity = LuminousFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 6c4b71722d..fcd3954377 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(LuminousIntensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminousIntensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LuminousIntensity.Units.FirstOrDefault(u => u != LuminousIntensity.BaseUnit); + var fromUnit = LuminousIntensity.Units.Where(u => u != LuminousIntensity.BaseUnit).DefaultIfEmpty(LuminousIntensity.BaseUnit).FirstOrDefault(); var quantity = LuminousIntensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index ba1782631b..174b05b5bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -407,7 +407,7 @@ public void ToUnit_WithSameUnits_AreEqual(MagneticFieldUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagneticFieldUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MagneticField.Units.FirstOrDefault(u => u != MagneticField.BaseUnit); + var fromUnit = MagneticField.Units.Where(u => u != MagneticField.BaseUnit).DefaultIfEmpty(MagneticField.BaseUnit).FirstOrDefault(); var quantity = MagneticField.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index 2ff473abd4..acee8f296b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(MagneticFluxUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagneticFluxUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MagneticFlux.Units.FirstOrDefault(u => u != MagneticFlux.BaseUnit); + var fromUnit = MagneticFlux.Units.Where(u => u != MagneticFlux.BaseUnit).DefaultIfEmpty(MagneticFlux.BaseUnit).FirstOrDefault(); var quantity = MagneticFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index 8b5812bac8..b6e2f93739 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(MagnetizationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagnetizationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Magnetization.Units.FirstOrDefault(u => u != Magnetization.BaseUnit); + var fromUnit = Magnetization.Units.Where(u => u != Magnetization.BaseUnit).DefaultIfEmpty(Magnetization.BaseUnit).FirstOrDefault(); var quantity = Magnetization.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 9e61bfeb9a..4f1778b29c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -1965,7 +1965,7 @@ public void ToUnit_WithSameUnits_AreEqual(MassConcentrationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassConcentrationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassConcentration.Units.FirstOrDefault(u => u != MassConcentration.BaseUnit); + var fromUnit = MassConcentration.Units.Where(u => u != MassConcentration.BaseUnit).DefaultIfEmpty(MassConcentration.BaseUnit).FirstOrDefault(); var quantity = MassConcentration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 54e67726b3..d4696be3d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -1567,7 +1567,7 @@ public void ToUnit_WithSameUnits_AreEqual(MassFlowUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFlowUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassFlow.Units.FirstOrDefault(u => u != MassFlow.BaseUnit); + var fromUnit = MassFlow.Units.Where(u => u != MassFlow.BaseUnit).DefaultIfEmpty(MassFlow.BaseUnit).FirstOrDefault(); var quantity = MassFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index b5c51a13c1..54a6e654cf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -611,7 +611,7 @@ public void ToUnit_WithSameUnits_AreEqual(MassFluxUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFluxUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassFlux.Units.FirstOrDefault(u => u != MassFlux.BaseUnit); + var fromUnit = MassFlux.Units.Where(u => u != MassFlux.BaseUnit).DefaultIfEmpty(MassFlux.BaseUnit).FirstOrDefault(); var quantity = MassFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 5dabf2191e..1cdfeb11b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -1043,7 +1043,7 @@ public void ToUnit_WithSameUnits_AreEqual(MassFractionUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFractionUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassFraction.Units.FirstOrDefault(u => u != MassFraction.BaseUnit); + var fromUnit = MassFraction.Units.Where(u => u != MassFraction.BaseUnit).DefaultIfEmpty(MassFraction.BaseUnit).FirstOrDefault(); var quantity = MassFraction.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 547b49d550..12f6d91b6e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -1155,7 +1155,7 @@ public void ToUnit_WithSameUnits_AreEqual(MassMomentOfInertiaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassMomentOfInertiaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassMomentOfInertia.Units.FirstOrDefault(u => u != MassMomentOfInertia.BaseUnit); + var fromUnit = MassMomentOfInertia.Units.Where(u => u != MassMomentOfInertia.BaseUnit).DefaultIfEmpty(MassMomentOfInertia.BaseUnit).FirstOrDefault(); var quantity = MassMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 0b260bc510..aee8d32ea4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -2041,7 +2041,7 @@ public void ToUnit_WithSameUnits_AreEqual(MassUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Mass.Units.FirstOrDefault(u => u != Mass.BaseUnit); + var fromUnit = Mass.Units.Where(u => u != Mass.BaseUnit).DefaultIfEmpty(Mass.BaseUnit).FirstOrDefault(); var quantity = Mass.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 3769b2c8aa..d02524f56e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(MolarEnergyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarEnergyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MolarEnergy.Units.FirstOrDefault(u => u != MolarEnergy.BaseUnit); + var fromUnit = MolarEnergy.Units.Where(u => u != MolarEnergy.BaseUnit).DefaultIfEmpty(MolarEnergy.BaseUnit).FirstOrDefault(); var quantity = MolarEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index c92a02ed71..78a88ecb39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(MolarEntropyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarEntropyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MolarEntropy.Units.FirstOrDefault(u => u != MolarEntropy.BaseUnit); + var fromUnit = MolarEntropy.Units.Where(u => u != MolarEntropy.BaseUnit).DefaultIfEmpty(MolarEntropy.BaseUnit).FirstOrDefault(); var quantity = MolarEntropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index c675e40af3..ffe0f30f77 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -899,7 +899,7 @@ public void ToUnit_WithSameUnits_AreEqual(MolarMassUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarMassUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MolarMass.Units.FirstOrDefault(u => u != MolarMass.BaseUnit); + var fromUnit = MolarMass.Units.Where(u => u != MolarMass.BaseUnit).DefaultIfEmpty(MolarMass.BaseUnit).FirstOrDefault(); var quantity = MolarMass.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index ff6f7a2762..923b01a6b3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -600,7 +600,7 @@ public void ToUnit_WithSameUnits_AreEqual(MolarityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Molarity.Units.FirstOrDefault(u => u != Molarity.BaseUnit); + var fromUnit = Molarity.Units.Where(u => u != Molarity.BaseUnit).DefaultIfEmpty(Molarity.BaseUnit).FirstOrDefault(); var quantity = Molarity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index e0aaa30e73..af5bee7872 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(PermeabilityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PermeabilityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Permeability.Units.FirstOrDefault(u => u != Permeability.BaseUnit); + var fromUnit = Permeability.Units.Where(u => u != Permeability.BaseUnit).DefaultIfEmpty(Permeability.BaseUnit).FirstOrDefault(); var quantity = Permeability.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 60d4c64637..1a1aa929fa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(PermittivityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PermittivityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Permittivity.Units.FirstOrDefault(u => u != Permittivity.BaseUnit); + var fromUnit = Permittivity.Units.Where(u => u != Permittivity.BaseUnit).DefaultIfEmpty(Permittivity.BaseUnit).FirstOrDefault(); var quantity = Permittivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index d6e80c9e72..88b7bcfa81 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -373,7 +373,7 @@ public void ToUnit_WithSameUnits_AreEqual(PorousMediumPermeabilityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PorousMediumPermeabilityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PorousMediumPermeability.Units.FirstOrDefault(u => u != PorousMediumPermeability.BaseUnit); + var fromUnit = PorousMediumPermeability.Units.Where(u => u != PorousMediumPermeability.BaseUnit).DefaultIfEmpty(PorousMediumPermeability.BaseUnit).FirstOrDefault(); var quantity = PorousMediumPermeability.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index cdde25d67b..9888200c48 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -1611,7 +1611,7 @@ public void ToUnit_WithSameUnits_AreEqual(PowerDensityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerDensityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PowerDensity.Units.FirstOrDefault(u => u != PowerDensity.BaseUnit); + var fromUnit = PowerDensity.Units.Where(u => u != PowerDensity.BaseUnit).DefaultIfEmpty(PowerDensity.BaseUnit).FirstOrDefault(); var quantity = PowerDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index d76c341477..3cd613b917 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -295,7 +295,7 @@ public void ToUnit_WithSameUnits_AreEqual(PowerRatioUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerRatioUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PowerRatio.Units.FirstOrDefault(u => u != PowerRatio.BaseUnit); + var fromUnit = PowerRatio.Units.Where(u => u != PowerRatio.BaseUnit).DefaultIfEmpty(PowerRatio.BaseUnit).FirstOrDefault(); var quantity = PowerRatio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 61c534fb2e..84e4e66f28 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -1068,7 +1068,7 @@ public void ToUnit_WithSameUnits_AreEqual(PowerUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Power.Units.FirstOrDefault(u => u != Power.BaseUnit); + var fromUnit = Power.Units.Where(u => u != Power.BaseUnit).DefaultIfEmpty(Power.BaseUnit).FirstOrDefault(); var quantity = Power.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index d0c13282d3..c489b22624 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -1303,7 +1303,7 @@ public void ToUnit_WithSameUnits_AreEqual(PressureChangeRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PressureChangeRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PressureChangeRate.Units.FirstOrDefault(u => u != PressureChangeRate.BaseUnit); + var fromUnit = PressureChangeRate.Units.Where(u => u != PressureChangeRate.BaseUnit).DefaultIfEmpty(PressureChangeRate.BaseUnit).FirstOrDefault(); var quantity = PressureChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 7f2a38c99f..3db47ed7e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -2651,7 +2651,7 @@ public void ToUnit_WithSameUnits_AreEqual(PressureUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PressureUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Pressure.Units.FirstOrDefault(u => u != Pressure.BaseUnit); + var fromUnit = Pressure.Units.Where(u => u != Pressure.BaseUnit).DefaultIfEmpty(Pressure.BaseUnit).FirstOrDefault(); var quantity = Pressure.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index d997e0b7b5..989c017044 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -271,7 +271,7 @@ public void ToUnit_WithSameUnits_AreEqual(RatioChangeRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RatioChangeRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RatioChangeRate.Units.FirstOrDefault(u => u != RatioChangeRate.BaseUnit); + var fromUnit = RatioChangeRate.Units.Where(u => u != RatioChangeRate.BaseUnit).DefaultIfEmpty(RatioChangeRate.BaseUnit).FirstOrDefault(); var quantity = RatioChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index e247cd796a..8714c6f6a3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -407,7 +407,7 @@ public void ToUnit_WithSameUnits_AreEqual(RatioUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RatioUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Ratio.Units.FirstOrDefault(u => u != Ratio.BaseUnit); + var fromUnit = Ratio.Units.Where(u => u != Ratio.BaseUnit).DefaultIfEmpty(Ratio.BaseUnit).FirstOrDefault(); var quantity = Ratio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index f0440eab38..8c4ddb264c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(ReactiveEnergyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReactiveEnergyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReactiveEnergy.Units.FirstOrDefault(u => u != ReactiveEnergy.BaseUnit); + var fromUnit = ReactiveEnergy.Units.Where(u => u != ReactiveEnergy.BaseUnit).DefaultIfEmpty(ReactiveEnergy.BaseUnit).FirstOrDefault(); var quantity = ReactiveEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 3a70cd7a04..807b553fda 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(ReactivePowerUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReactivePowerUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReactivePower.Units.FirstOrDefault(u => u != ReactivePower.BaseUnit); + var fromUnit = ReactivePower.Units.Where(u => u != ReactivePower.BaseUnit).DefaultIfEmpty(ReactivePower.BaseUnit).FirstOrDefault(); var quantity = ReactivePower.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index a240a54464..93590fd301 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -577,7 +577,7 @@ public void ToUnit_WithSameUnits_AreEqual(ReciprocalAreaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReciprocalAreaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReciprocalArea.Units.FirstOrDefault(u => u != ReciprocalArea.BaseUnit); + var fromUnit = ReciprocalArea.Units.Where(u => u != ReciprocalArea.BaseUnit).DefaultIfEmpty(ReciprocalArea.BaseUnit).FirstOrDefault(); var quantity = ReciprocalArea.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 996aceeb8f..3de7afaf9e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -783,7 +783,7 @@ public void ToUnit_WithSameUnits_AreEqual(ReciprocalLengthUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReciprocalLengthUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReciprocalLength.Units.FirstOrDefault(u => u != ReciprocalLength.BaseUnit); + var fromUnit = ReciprocalLength.Units.Where(u => u != ReciprocalLength.BaseUnit).DefaultIfEmpty(ReciprocalLength.BaseUnit).FirstOrDefault(); var quantity = ReciprocalLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index ba3bbfa071..60f67c7468 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(RelativeHumidityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RelativeHumidityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RelativeHumidity.Units.FirstOrDefault(u => u != RelativeHumidity.BaseUnit); + var fromUnit = RelativeHumidity.Units.Where(u => u != RelativeHumidity.BaseUnit).DefaultIfEmpty(RelativeHumidity.BaseUnit).FirstOrDefault(); var quantity = RelativeHumidity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 3b1b021934..f0cc297b7e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -363,7 +363,7 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalAccelerationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalAccelerationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalAcceleration.Units.FirstOrDefault(u => u != RotationalAcceleration.BaseUnit); + var fromUnit = RotationalAcceleration.Units.Where(u => u != RotationalAcceleration.BaseUnit).DefaultIfEmpty(RotationalAcceleration.BaseUnit).FirstOrDefault(); var quantity = RotationalAcceleration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 2ed718bd84..a2df678911 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -1077,7 +1077,7 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalSpeedUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalSpeedUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalSpeed.Units.FirstOrDefault(u => u != RotationalSpeed.BaseUnit); + var fromUnit = RotationalSpeed.Units.Where(u => u != RotationalSpeed.BaseUnit).DefaultIfEmpty(RotationalSpeed.BaseUnit).FirstOrDefault(); var quantity = RotationalSpeed.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 78c836b23d..7880b8d001 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -565,7 +565,7 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessPerLengthUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalStiffnessPerLengthUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalStiffnessPerLength.Units.FirstOrDefault(u => u != RotationalStiffnessPerLength.BaseUnit); + var fromUnit = RotationalStiffnessPerLength.Units.Where(u => u != RotationalStiffnessPerLength.BaseUnit).DefaultIfEmpty(RotationalStiffnessPerLength.BaseUnit).FirstOrDefault(); var quantity = RotationalStiffnessPerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index a855f711df..8557dab512 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -2809,7 +2809,7 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalStiffnessUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalStiffness.Units.FirstOrDefault(u => u != RotationalStiffness.BaseUnit); + var fromUnit = RotationalStiffness.Units.Where(u => u != RotationalStiffness.BaseUnit).DefaultIfEmpty(RotationalStiffness.BaseUnit).FirstOrDefault(); var quantity = RotationalStiffness.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 213efc7e9a..427c4da867 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(ScalarUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ScalarUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Scalar.Units.FirstOrDefault(u => u != Scalar.BaseUnit); + var fromUnit = Scalar.Units.Where(u => u != Scalar.BaseUnit).DefaultIfEmpty(Scalar.BaseUnit).FirstOrDefault(); var quantity = Scalar.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 7bd2750ec7..6fe1a3602c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(SolidAngleUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SolidAngleUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SolidAngle.Units.FirstOrDefault(u => u != SolidAngle.BaseUnit); + var fromUnit = SolidAngle.Units.Where(u => u != SolidAngle.BaseUnit).DefaultIfEmpty(SolidAngle.BaseUnit).FirstOrDefault(); var quantity = SolidAngle.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index ea15dd0821..32be1e830a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -1189,7 +1189,7 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificEnergyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificEnergyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificEnergy.Units.FirstOrDefault(u => u != SpecificEnergy.BaseUnit); + var fromUnit = SpecificEnergy.Units.Where(u => u != SpecificEnergy.BaseUnit).DefaultIfEmpty(SpecificEnergy.BaseUnit).FirstOrDefault(); var quantity = SpecificEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index fb89d1c5c6..b58e37b641 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -533,7 +533,7 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificEntropyUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificEntropyUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificEntropy.Units.FirstOrDefault(u => u != SpecificEntropy.BaseUnit); + var fromUnit = SpecificEntropy.Units.Where(u => u != SpecificEntropy.BaseUnit).DefaultIfEmpty(SpecificEntropy.BaseUnit).FirstOrDefault(); var quantity = SpecificEntropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index b938f281de..e0e7e9e8cc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificFuelConsumptionUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificFuelConsumptionUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificFuelConsumption.Units.FirstOrDefault(u => u != SpecificFuelConsumption.BaseUnit); + var fromUnit = SpecificFuelConsumption.Units.Where(u => u != SpecificFuelConsumption.BaseUnit).DefaultIfEmpty(SpecificFuelConsumption.BaseUnit).FirstOrDefault(); var quantity = SpecificFuelConsumption.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 02fae72184..44c9025100 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -305,7 +305,7 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificVolumeUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificVolumeUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificVolume.Units.FirstOrDefault(u => u != SpecificVolume.BaseUnit); + var fromUnit = SpecificVolume.Units.Where(u => u != SpecificVolume.BaseUnit).DefaultIfEmpty(SpecificVolume.BaseUnit).FirstOrDefault(); var quantity = SpecificVolume.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 16acf1b9c4..daf5cffeae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -781,7 +781,7 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificWeightUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificWeightUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificWeight.Units.FirstOrDefault(u => u != SpecificWeight.BaseUnit); + var fromUnit = SpecificWeight.Units.Where(u => u != SpecificWeight.BaseUnit).DefaultIfEmpty(SpecificWeight.BaseUnit).FirstOrDefault(); var quantity = SpecificWeight.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 3e69f94360..9ef94f5cab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -1915,7 +1915,7 @@ public void ToUnit_WithSameUnits_AreEqual(SpeedUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpeedUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Speed.Units.FirstOrDefault(u => u != Speed.BaseUnit); + var fromUnit = Speed.Units.Where(u => u != Speed.BaseUnit).DefaultIfEmpty(Speed.BaseUnit).FirstOrDefault(); var quantity = Speed.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 7706b8d34c..7dfaf4c928 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -509,7 +509,7 @@ public void ToUnit_WithSameUnits_AreEqual(StandardVolumeFlowUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(StandardVolumeFlowUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = StandardVolumeFlow.Units.FirstOrDefault(u => u != StandardVolumeFlow.BaseUnit); + var fromUnit = StandardVolumeFlow.Units.Where(u => u != StandardVolumeFlow.BaseUnit).DefaultIfEmpty(StandardVolumeFlow.BaseUnit).FirstOrDefault(); var quantity = StandardVolumeFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index ce63af78e6..6e8098579d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -543,7 +543,7 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureChangeRateUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureChangeRateUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TemperatureChangeRate.Units.FirstOrDefault(u => u != TemperatureChangeRate.BaseUnit); + var fromUnit = TemperatureChangeRate.Units.Where(u => u != TemperatureChangeRate.BaseUnit).DefaultIfEmpty(TemperatureChangeRate.BaseUnit).FirstOrDefault(); var quantity = TemperatureChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index c8bc31c08a..7febab8e92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -509,7 +509,7 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureDeltaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureDeltaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TemperatureDelta.Units.FirstOrDefault(u => u != TemperatureDelta.BaseUnit); + var fromUnit = TemperatureDelta.Units.Where(u => u != TemperatureDelta.BaseUnit).DefaultIfEmpty(TemperatureDelta.BaseUnit).FirstOrDefault(); var quantity = TemperatureDelta.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index 9773df75c7..e0a6f79454 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -339,7 +339,7 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureGradientUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureGradientUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TemperatureGradient.Units.FirstOrDefault(u => u != TemperatureGradient.BaseUnit); + var fromUnit = TemperatureGradient.Units.Where(u => u != TemperatureGradient.BaseUnit).DefaultIfEmpty(TemperatureGradient.BaseUnit).FirstOrDefault(); var quantity = TemperatureGradient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 70bf79fe97..fe54557914 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -543,7 +543,7 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Temperature.Units.FirstOrDefault(u => u != Temperature.BaseUnit); + var fromUnit = Temperature.Units.Where(u => u != Temperature.BaseUnit).DefaultIfEmpty(Temperature.BaseUnit).FirstOrDefault(); var quantity = Temperature.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index 44d7f9f8cf..f9ba3e2d05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -271,7 +271,7 @@ public void ToUnit_WithSameUnits_AreEqual(ThermalConductivityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ThermalConductivityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ThermalConductivity.Units.FirstOrDefault(u => u != ThermalConductivity.BaseUnit); + var fromUnit = ThermalConductivity.Units.Where(u => u != ThermalConductivity.BaseUnit).DefaultIfEmpty(ThermalConductivity.BaseUnit).FirstOrDefault(); var quantity = ThermalConductivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index b9dcf13b1a..00f985ad3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -407,7 +407,7 @@ public void ToUnit_WithSameUnits_AreEqual(ThermalResistanceUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ThermalResistanceUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ThermalResistance.Units.FirstOrDefault(u => u != ThermalResistance.BaseUnit); + var fromUnit = ThermalResistance.Units.Where(u => u != ThermalResistance.BaseUnit).DefaultIfEmpty(ThermalResistance.BaseUnit).FirstOrDefault(); var quantity = ThermalResistance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 11c8a3bbbe..4d7495ee03 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -989,7 +989,7 @@ public void ToUnit_WithSameUnits_AreEqual(TorquePerLengthUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorquePerLengthUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TorquePerLength.Units.FirstOrDefault(u => u != TorquePerLength.BaseUnit); + var fromUnit = TorquePerLength.Units.Where(u => u != TorquePerLength.BaseUnit).DefaultIfEmpty(TorquePerLength.BaseUnit).FirstOrDefault(); var quantity = TorquePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 4d60d9e744..322306450f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -1125,7 +1125,7 @@ public void ToUnit_WithSameUnits_AreEqual(TorqueUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorqueUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Torque.Units.FirstOrDefault(u => u != Torque.BaseUnit); + var fromUnit = Torque.Units.Where(u => u != Torque.BaseUnit).DefaultIfEmpty(Torque.BaseUnit).FirstOrDefault(); var quantity = Torque.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index cac7242f8f..65fd4b5012 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(TurbidityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TurbidityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Turbidity.Units.FirstOrDefault(u => u != Turbidity.BaseUnit); + var fromUnit = Turbidity.Units.Where(u => u != Turbidity.BaseUnit).DefaultIfEmpty(Turbidity.BaseUnit).FirstOrDefault(); var quantity = Turbidity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 3bdb4a958e..36661f561c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -237,7 +237,7 @@ public void ToUnit_WithSameUnits_AreEqual(VitaminAUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VitaminAUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VitaminA.Units.FirstOrDefault(u => u != VitaminA.BaseUnit); + var fromUnit = VitaminA.Units.Where(u => u != VitaminA.BaseUnit).DefaultIfEmpty(VitaminA.BaseUnit).FirstOrDefault(); var quantity = VitaminA.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index daed095a89..d807ec47aa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -907,7 +907,7 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeConcentrationUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeConcentrationUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumeConcentration.Units.FirstOrDefault(u => u != VolumeConcentration.BaseUnit); + var fromUnit = VolumeConcentration.Units.Where(u => u != VolumeConcentration.BaseUnit).DefaultIfEmpty(VolumeConcentration.BaseUnit).FirstOrDefault(); var quantity = VolumeConcentration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 64b606c5fd..722f63a1d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -271,7 +271,7 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeFlowPerAreaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeFlowPerAreaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumeFlowPerArea.Units.FirstOrDefault(u => u != VolumeFlowPerArea.BaseUnit); + var fromUnit = VolumeFlowPerArea.Units.Where(u => u != VolumeFlowPerArea.BaseUnit).DefaultIfEmpty(VolumeFlowPerArea.BaseUnit).FirstOrDefault(); var quantity = VolumeFlowPerArea.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index f07e3509be..caf0e209b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -3973,7 +3973,7 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeFlowUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeFlowUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumeFlow.Units.FirstOrDefault(u => u != VolumeFlow.BaseUnit); + var fromUnit = VolumeFlow.Units.Where(u => u != VolumeFlow.BaseUnit).DefaultIfEmpty(VolumeFlow.BaseUnit).FirstOrDefault(); var quantity = VolumeFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index b5ac97902c..98f4ce00c7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -441,7 +441,7 @@ public void ToUnit_WithSameUnits_AreEqual(VolumePerLengthUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumePerLengthUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumePerLength.Units.FirstOrDefault(u => u != VolumePerLength.BaseUnit); + var fromUnit = VolumePerLength.Units.Where(u => u != VolumePerLength.BaseUnit).DefaultIfEmpty(VolumePerLength.BaseUnit).FirstOrDefault(); var quantity = VolumePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index e7d7922df7..4447d491b4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -2967,7 +2967,7 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Volume.Units.FirstOrDefault(u => u != Volume.BaseUnit); + var fromUnit = Volume.Units.Where(u => u != Volume.BaseUnit).DefaultIfEmpty(Volume.BaseUnit).FirstOrDefault(); var quantity = Volume.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index eb8a54826e..030c251bde 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -509,7 +509,7 @@ public void ToUnit_WithSameUnits_AreEqual(VolumetricHeatCapacityUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumetricHeatCapacityUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumetricHeatCapacity.Units.FirstOrDefault(u => u != VolumetricHeatCapacity.BaseUnit); + var fromUnit = VolumetricHeatCapacity.Units.Where(u => u != VolumetricHeatCapacity.BaseUnit).DefaultIfEmpty(VolumetricHeatCapacity.BaseUnit).FirstOrDefault(); var quantity = VolumetricHeatCapacity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index ced48543cb..683a9313ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -551,7 +551,7 @@ public void ToUnit_WithSameUnits_AreEqual(WarpingMomentOfInertiaUnit unit) public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(WarpingMomentOfInertiaUnit unit) { // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = WarpingMomentOfInertia.Units.FirstOrDefault(u => u != WarpingMomentOfInertia.BaseUnit); + var fromUnit = WarpingMomentOfInertia.Units.Where(u => u != WarpingMomentOfInertia.BaseUnit).DefaultIfEmpty(WarpingMomentOfInertia.BaseUnit).FirstOrDefault(); var quantity = WarpingMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); From c1a2ba7e7a9191d60315959ef384459d293dd913 Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Wed, 15 Jun 2022 00:11:28 +0200 Subject: [PATCH 60/66] Disable azure pipelines trigger --- azure-pipelines.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 03f8fdd48c..9ee6f55381 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,8 +3,7 @@ # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml -trigger: -- master +trigger: none pool: vmImage: ubuntu-latest From eae2fd55f6366514b016172a3417e43b8f071123 Mon Sep 17 00:00:00 2001 From: lipchev Date: Tue, 23 Aug 2022 04:09:56 +0300 Subject: [PATCH 61/66] IQuantity with QuantityValue as Value type (PoC) - QuantityValue implements most of the INumber interface members / operators (operations preserving decimal when possible, failing back to double, clamped to the real values- infinities excluded) - changed the type of IQuantity.Value/As to QuantityValue (explicit cast required) - added back the IEquatable interface: behavior depending on the runtime type of the quantity values (strict equality comparison for double/double) - added back the fix for the non-reflexive CompareTo issue (and the corresponding tests) - added a check preventing the possible stack overflow exception when calling ToUnit() with default(TUnit) (or any other invalid Enum value) - DataContracts changed to reflect the possible use of either double or decimal as ValueType (the Json converters were not changed- but probably should be) - removed the obsolete Json converter tests --- CodeGen/CodeGen.csproj | 2 +- .../UnitsNetGen/QuantityGenerator.cs | 131 +++-- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 74 ++- Common/UnitDefinitions/Angle.json | 4 +- Common/UnitDefinitions/Frequency.json | 2 +- Common/UnitDefinitions/Power.json | 4 +- Common/UnitDefinitions/Pressure.json | 8 +- .../UnitDefinitions/PressureChangeRate.json | 4 +- UnitsNet.Benchmark/Program.cs | 10 +- .../GeneratedCode/Quantities/Angle.g.cs | 4 +- .../GeneratedCode/Quantities/Frequency.g.cs | 2 +- .../GeneratedCode/Quantities/Power.g.cs | 12 +- .../GeneratedCode/Quantities/Pressure.g.cs | 8 +- .../UnitsNet.NumberExtensions.Tests.csproj | 4 +- ...lization.JsonNet.CompatibilityTests.csproj | 32 -- .../UnitsNetJsonConverterTests.cs | 464 ---------------- ...nitsNet.Serialization.JsonNet.Tests.csproj | 4 +- .../UnitsNetBaseJsonConverterTest.cs | 2 +- .../UnitsNetIComparableJsonConverterTest.cs | 2 +- .../UnitsNetIQuantityJsonConverterTest.cs | 2 +- .../AbbreviatedUnitsConverter.cs | 2 +- .../UnitsNetBaseJsonConverter.cs | 5 +- UnitsNet.Tests/AssertEx.cs | 30 ++ .../CustomCode/AmplitudeRatioTests.cs | 10 +- UnitsNet.Tests/CustomCode/AreaTests.cs | 4 +- UnitsNet.Tests/CustomCode/BitRateTests.cs | 52 +- .../BrakeSpecificFuelConsumptionTests.cs | 4 +- UnitsNet.Tests/CustomCode/InformationTests.cs | 52 +- UnitsNet.Tests/CustomCode/MassFlowTests.cs | 2 +- UnitsNet.Tests/CustomCode/ParseTests.cs | 12 +- UnitsNet.Tests/CustomCode/PowerRatioTests.cs | 11 +- UnitsNet.Tests/CustomCode/PowerTests.cs | 52 +- .../CustomCode/SpecificEnergyTests.cs | 4 +- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 8 +- UnitsNet.Tests/DecimalOverloadTests.cs | 2 +- UnitsNet.Tests/DummyIQuantity.cs | 6 +- .../TestsBase/AccelerationTestsBase.g.cs | 94 ++-- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 96 ++-- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 74 ++- .../TestsBase/AngleTestsBase.g.cs | 98 ++-- .../TestsBase/ApparentEnergyTestsBase.g.cs | 72 ++- .../TestsBase/ApparentPowerTestsBase.g.cs | 74 ++- .../TestsBase/AreaDensityTestsBase.g.cs | 70 ++- .../AreaMomentOfInertiaTestsBase.g.cs | 78 +-- .../TestsBase/AreaTestsBase.g.cs | 94 ++-- .../TestsBase/BitRateTestsBase.g.cs | 172 +++--- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 72 ++- .../TestsBase/CapacitanceTestsBase.g.cs | 80 +-- ...oefficientOfThermalExpansionTestsBase.g.cs | 72 ++- .../TestsBase/CompressibilityTestsBase.g.cs | 80 +-- .../TestsBase/DensityTestsBase.g.cs | 168 +++--- .../TestsBase/DurationTestsBase.g.cs | 88 ++-- .../TestsBase/DynamicViscosityTestsBase.g.cs | 86 +-- .../ElectricAdmittanceTestsBase.g.cs | 74 ++- .../ElectricChargeDensityTestsBase.g.cs | 70 ++- .../TestsBase/ElectricChargeTestsBase.g.cs | 76 +-- .../ElectricConductanceTestsBase.g.cs | 72 ++- .../ElectricConductivityTestsBase.g.cs | 72 ++- .../ElectricCurrentDensityTestsBase.g.cs | 72 ++- .../ElectricCurrentGradientTestsBase.g.cs | 74 ++- .../TestsBase/ElectricCurrentTestsBase.g.cs | 82 +-- .../TestsBase/ElectricFieldTestsBase.g.cs | 70 ++- .../ElectricInductanceTestsBase.g.cs | 74 ++- .../ElectricPotentialAcTestsBase.g.cs | 76 +-- .../ElectricPotentialChangeRateTestsBase.g.cs | 106 ++-- .../ElectricPotentialDcTestsBase.g.cs | 76 +-- .../TestsBase/ElectricPotentialTestsBase.g.cs | 76 +-- .../ElectricResistanceTestsBase.g.cs | 78 +-- .../ElectricResistivityTestsBase.g.cs | 94 ++-- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 72 ++- .../TestsBase/EnergyTestsBase.g.cs | 138 ++--- .../TestsBase/EntropyTestsBase.g.cs | 80 +-- .../TestsBase/ForceChangeRateTestsBase.g.cs | 96 ++-- .../TestsBase/ForcePerLengthTestsBase.g.cs | 142 ++--- .../TestsBase/ForceTestsBase.g.cs | 96 ++-- .../TestsBase/FrequencyTestsBase.g.cs | 88 ++-- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 74 ++- .../TestsBase/HeatFluxTestsBase.g.cs | 102 ++-- .../HeatTransferCoefficientTestsBase.g.cs | 72 ++- .../TestsBase/IlluminanceTestsBase.g.cs | 74 ++- .../TestsBase/InformationTestsBase.g.cs | 172 +++--- .../TestsBase/IrradianceTestsBase.g.cs | 94 ++-- .../TestsBase/IrradiationTestsBase.g.cs | 80 +-- .../TestsBase/JerkTestsBase.g.cs | 88 ++-- .../KinematicViscosityTestsBase.g.cs | 84 +-- .../TestsBase/LapseRateTestsBase.g.cs | 70 ++- .../TestsBase/LengthTestsBase.g.cs | 138 ++--- .../TestsBase/LevelTestsBase.g.cs | 70 ++- .../TestsBase/LinearDensityTestsBase.g.cs | 94 ++-- .../LinearPowerDensityTestsBase.g.cs | 116 ++-- .../TestsBase/LuminosityTestsBase.g.cs | 94 ++-- .../TestsBase/LuminousFluxTestsBase.g.cs | 70 ++- .../TestsBase/LuminousIntensityTestsBase.g.cs | 70 ++- .../TestsBase/MagneticFieldTestsBase.g.cs | 78 +-- .../TestsBase/MagneticFluxTestsBase.g.cs | 70 ++- .../TestsBase/MagnetizationTestsBase.g.cs | 70 ++- .../TestsBase/MassConcentrationTestsBase.g.cs | 164 +++--- .../TestsBase/MassFlowTestsBase.g.cs | 132 +++-- .../TestsBase/MassFluxTestsBase.g.cs | 90 ++-- .../TestsBase/MassFractionTestsBase.g.cs | 114 ++-- .../MassMomentOfInertiaTestsBase.g.cs | 122 +++-- .../TestsBase/MassTestsBase.g.cs | 116 ++-- .../TestsBase/MolarEnergyTestsBase.g.cs | 72 ++- .../TestsBase/MolarEntropyTestsBase.g.cs | 72 ++- .../TestsBase/MolarMassTestsBase.g.cs | 90 ++-- .../TestsBase/MolarityTestsBase.g.cs | 84 +-- .../TestsBase/PermeabilityTestsBase.g.cs | 70 ++- .../TestsBase/PermittivityTestsBase.g.cs | 70 ++- .../PorousMediumPermeabilityTestsBase.g.cs | 76 +-- .../TestsBase/PowerDensityTestsBase.g.cs | 154 +++--- .../TestsBase/PowerRatioTestsBase.g.cs | 70 ++- .../TestsBase/PowerTestsBase.g.cs | 172 +++--- .../PressureChangeRateTestsBase.g.cs | 94 ++-- .../TestsBase/PressureTestsBase.g.cs | 160 +++--- .../TestsBase/RatioChangeRateTestsBase.g.cs | 70 ++- .../TestsBase/RatioTestsBase.g.cs | 78 +-- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 72 ++- .../TestsBase/ReactivePowerTestsBase.g.cs | 74 ++- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 88 ++-- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 86 +-- .../TestsBase/RelativeHumidityTestsBase.g.cs | 70 ++- .../RotationalAccelerationTestsBase.g.cs | 74 ++- .../TestsBase/RotationalSpeedTestsBase.g.cs | 92 ++-- ...RotationalStiffnessPerLengthTestsBase.g.cs | 76 +-- .../RotationalStiffnessTestsBase.g.cs | 132 +++-- .../TestsBase/ScalarTestsBase.g.cs | 70 ++- .../TestsBase/SolidAngleTestsBase.g.cs | 70 ++- .../TestsBase/SpecificEnergyTestsBase.g.cs | 124 +++-- .../TestsBase/SpecificEntropyTestsBase.g.cs | 84 +-- .../SpecificFuelConsumptionTestsBase.g.cs | 74 ++- .../TestsBase/SpecificVolumeTestsBase.g.cs | 72 ++- .../TestsBase/SpecificWeightTestsBase.g.cs | 100 ++-- .../TestsBase/SpeedTestsBase.g.cs | 130 +++-- .../StandardVolumeFlowTestsBase.g.cs | 84 +-- .../TemperatureChangeRateTestsBase.g.cs | 86 +-- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 84 +-- .../TemperatureGradientTestsBase.g.cs | 74 ++- .../TestsBase/TemperatureTestsBase.g.cs | 86 +-- .../ThermalConductivityTestsBase.g.cs | 70 ++- .../TestsBase/ThermalResistanceTestsBase.g.cs | 78 +-- .../TestsBase/TorquePerLengthTestsBase.g.cs | 108 ++-- .../TestsBase/TorqueTestsBase.g.cs | 116 ++-- .../TestsBase/TurbidityTestsBase.g.cs | 70 ++- .../TestsBase/VitaminATestsBase.g.cs | 70 ++- .../VolumeConcentrationTestsBase.g.cs | 106 ++-- .../TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 70 ++- .../TestsBase/VolumeFlowTestsBase.g.cs | 190 ++++--- .../TestsBase/VolumePerLengthTestsBase.g.cs | 80 +-- .../TestsBase/VolumeTestsBase.g.cs | 170 +++--- .../VolumetricHeatCapacityTestsBase.g.cs | 84 +-- .../WarpingMomentOfInertiaTestsBase.g.cs | 78 +-- UnitsNet.Tests/GeneratedQuantityCodeTests.cs | 2 +- UnitsNet.Tests/IntOverloadTests.cs | 2 +- UnitsNet.Tests/LongOverloadTests.cs | 2 +- UnitsNet.Tests/QuantityComparisonTests.cs | 194 +++++++ UnitsNet.Tests/QuantityValueTests.cs | 150 ++++++ .../DefaultDataContractJsonSerializerTests.cs | 40 +- .../Serialization/SerializationTestsBase.cs | 2 +- .../Xml/DataContractSerializerTests.cs | 6 +- UnitsNet.Tests/UnitConverterTest.cs | 20 +- UnitsNet.Tests/UnitsNet.Tests.csproj | 4 +- UnitsNet.sln | 52 +- UnitsNet/Comparison.cs | 118 ++++- .../Quantities/AmountOfSubstance.extra.cs | 2 +- .../Quantities/AmplitudeRatio.extra.cs | 6 +- .../BrakeSpecificFuelConsumption.extra.cs | 8 +- .../CustomCode/Quantities/Duration.extra.cs | 6 +- UnitsNet/CustomCode/Quantities/Force.extra.cs | 2 +- .../CustomCode/Quantities/Length.extra.cs | 2 +- UnitsNet/CustomCode/Quantities/Mass.extra.cs | 2 +- .../CustomCode/Quantities/MassFlow.extra.cs | 1 + UnitsNet/CustomCode/Quantities/Power.extra.cs | 3 +- .../CustomCode/Quantities/PowerRatio.extra.cs | 6 +- .../Quantities/SpecificEnergy.extra.cs | 2 +- .../Quantities/Temperature.extra.cs | 4 +- .../CustomCode/Quantities/Volume.extra.cs | 2 +- .../CustomCode/Wrappers/ReferencePressure.cs | 4 +- .../Quantities/Acceleration.g.cs | 185 ++++--- .../Quantities/AmountOfSubstance.g.cs | 191 ++++--- .../Quantities/AmplitudeRatio.g.cs | 127 +++-- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 201 ++++--- .../Quantities/ApparentEnergy.g.cs | 119 +++-- .../Quantities/ApparentPower.g.cs | 125 +++-- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 185 ++++--- .../GeneratedCode/Quantities/AreaDensity.g.cs | 107 ++-- .../Quantities/AreaMomentOfInertia.g.cs | 137 +++-- .../GeneratedCode/Quantities/BitRate.g.cs | 255 +++++---- .../BrakeSpecificFuelConsumption.g.cs | 119 +++-- .../GeneratedCode/Quantities/Capacitance.g.cs | 143 +++-- .../CoefficientOfThermalExpansion.g.cs | 119 +++-- .../Quantities/Compressibility.g.cs | 143 +++-- .../GeneratedCode/Quantities/Density.g.cs | 407 +++++++------- .../GeneratedCode/Quantities/Duration.g.cs | 167 +++--- .../Quantities/DynamicViscosity.g.cs | 161 +++--- .../Quantities/ElectricAdmittance.g.cs | 125 +++-- .../Quantities/ElectricCharge.g.cs | 131 +++-- .../Quantities/ElectricChargeDensity.g.cs | 107 ++-- .../Quantities/ElectricConductance.g.cs | 119 +++-- .../Quantities/ElectricConductivity.g.cs | 119 +++-- .../Quantities/ElectricCurrent.g.cs | 149 ++++-- .../Quantities/ElectricCurrentDensity.g.cs | 119 +++-- .../Quantities/ElectricCurrentGradient.g.cs | 125 +++-- .../Quantities/ElectricField.g.cs | 107 ++-- .../Quantities/ElectricInductance.g.cs | 125 +++-- .../Quantities/ElectricPotential.g.cs | 131 +++-- .../Quantities/ElectricPotentialAc.g.cs | 131 +++-- .../ElectricPotentialChangeRate.g.cs | 221 ++++---- .../Quantities/ElectricPotentialDc.g.cs | 131 +++-- .../Quantities/ElectricResistance.g.cs | 137 +++-- .../Quantities/ElectricResistivity.g.cs | 185 ++++--- .../ElectricSurfaceChargeDensity.g.cs | 119 +++-- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 317 ++++++----- .../GeneratedCode/Quantities/Entropy.g.cs | 143 +++-- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 191 ++++--- .../Quantities/ForceChangeRate.g.cs | 191 ++++--- .../Quantities/ForcePerLength.g.cs | 329 +++++++----- .../GeneratedCode/Quantities/Frequency.g.cs | 169 +++--- .../Quantities/FuelEfficiency.g.cs | 125 +++-- .../GeneratedCode/Quantities/HeatFlux.g.cs | 209 +++++--- .../Quantities/HeatTransferCoefficient.g.cs | 119 +++-- .../GeneratedCode/Quantities/Illuminance.g.cs | 125 +++-- .../GeneratedCode/Quantities/Information.g.cs | 255 +++++---- .../GeneratedCode/Quantities/Irradiance.g.cs | 185 ++++--- .../GeneratedCode/Quantities/Irradiation.g.cs | 143 +++-- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 167 +++--- .../Quantities/KinematicViscosity.g.cs | 155 +++--- .../GeneratedCode/Quantities/LapseRate.g.cs | 107 ++-- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 317 ++++++----- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 115 ++-- .../Quantities/LinearDensity.g.cs | 185 ++++--- .../Quantities/LinearPowerDensity.g.cs | 251 +++++---- .../GeneratedCode/Quantities/Luminosity.g.cs | 185 ++++--- .../Quantities/LuminousFlux.g.cs | 107 ++-- .../Quantities/LuminousIntensity.g.cs | 107 ++-- .../Quantities/MagneticField.g.cs | 137 +++-- .../Quantities/MagneticFlux.g.cs | 107 ++-- .../Quantities/Magnetization.g.cs | 107 ++-- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 251 +++++---- .../Quantities/MassConcentration.g.cs | 395 +++++++------- .../GeneratedCode/Quantities/MassFlow.g.cs | 299 ++++++----- .../GeneratedCode/Quantities/MassFlux.g.cs | 173 +++--- .../Quantities/MassFraction.g.cs | 245 +++++---- .../Quantities/MassMomentOfInertia.g.cs | 269 ++++++---- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 119 +++-- .../Quantities/MolarEntropy.g.cs | 119 +++-- .../GeneratedCode/Quantities/MolarMass.g.cs | 173 +++--- .../GeneratedCode/Quantities/Molarity.g.cs | 155 +++--- .../Quantities/Permeability.g.cs | 107 ++-- .../Quantities/Permittivity.g.cs | 107 ++-- .../Quantities/PorousMediumPermeability.g.cs | 131 +++-- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 267 ++++++---- .../Quantities/PowerDensity.g.cs | 365 +++++++------ .../GeneratedCode/Quantities/PowerRatio.g.cs | 115 ++-- .../GeneratedCode/Quantities/Pressure.g.cs | 391 +++++++------- .../Quantities/PressureChangeRate.g.cs | 185 ++++--- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 137 +++-- .../Quantities/RatioChangeRate.g.cs | 113 ++-- .../Quantities/ReactiveEnergy.g.cs | 119 +++-- .../Quantities/ReactivePower.g.cs | 125 +++-- .../Quantities/ReciprocalArea.g.cs | 167 +++--- .../Quantities/ReciprocalLength.g.cs | 161 +++--- .../Quantities/RelativeHumidity.g.cs | 107 ++-- .../Quantities/RotationalAcceleration.g.cs | 125 +++-- .../Quantities/RotationalSpeed.g.cs | 179 ++++--- .../Quantities/RotationalStiffness.g.cs | 299 ++++++----- .../RotationalStiffnessPerLength.g.cs | 131 +++-- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 107 ++-- .../GeneratedCode/Quantities/SolidAngle.g.cs | 107 ++-- .../Quantities/SpecificEnergy.g.cs | 275 +++++----- .../Quantities/SpecificEntropy.g.cs | 155 +++--- .../Quantities/SpecificFuelConsumption.g.cs | 125 +++-- .../Quantities/SpecificVolume.g.cs | 119 +++-- .../Quantities/SpecificWeight.g.cs | 203 ++++--- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 293 ++++++----- .../Quantities/StandardVolumeFlow.g.cs | 155 +++--- .../GeneratedCode/Quantities/Temperature.g.cs | 153 ++++-- .../Quantities/TemperatureChangeRate.g.cs | 161 +++--- .../Quantities/TemperatureDelta.g.cs | 155 +++--- .../Quantities/TemperatureGradient.g.cs | 125 +++-- .../Quantities/ThermalConductivity.g.cs | 113 ++-- .../Quantities/ThermalResistance.g.cs | 137 +++-- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 251 +++++---- .../Quantities/TorquePerLength.g.cs | 227 ++++---- .../GeneratedCode/Quantities/Turbidity.g.cs | 107 ++-- .../GeneratedCode/Quantities/VitaminA.g.cs | 107 ++-- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 413 ++++++++------- .../Quantities/VolumeConcentration.g.cs | 221 ++++---- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 473 +++++++++-------- .../Quantities/VolumeFlowPerArea.g.cs | 113 ++-- .../Quantities/VolumePerLength.g.cs | 143 +++-- .../Quantities/VolumetricHeatCapacity.g.cs | 155 +++--- .../Quantities/WarpingMomentOfInertia.g.cs | 137 +++-- UnitsNet/IQuantity.cs | 8 +- UnitsNet/QuantityFormatter.cs | 5 +- UnitsNet/QuantityValue.cs | 498 ++++++++++++++++-- UnitsNet/UnitConverter.cs | 16 +- UnitsNet/UnitMath.cs | 39 +- 297 files changed, 19705 insertions(+), 13077 deletions(-) delete mode 100644 UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj delete mode 100644 UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs create mode 100644 UnitsNet.Tests/QuantityComparisonTests.cs create mode 100644 UnitsNet.Tests/QuantityValueTests.cs diff --git a/CodeGen/CodeGen.csproj b/CodeGen/CodeGen.csproj index 8e71a7f710..091df14572 100644 --- a/CodeGen/CodeGen.csproj +++ b/CodeGen/CodeGen.csproj @@ -11,7 +11,7 @@ - + diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index cf48ef7b4d..edebcc1281 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -25,7 +25,7 @@ public QuantityGenerator(Quantity quantity) throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", nameof(quantity)); - _valueType = quantity.ValueType; + _valueType = "QuantityValue";// quantity.ValueType; _unitEnumName = $"{quantity.Name}Unit"; BaseDimensions baseDimensions = quantity.BaseDimensions; @@ -77,14 +77,14 @@ public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); Writer.W("IDecimalQuantity, "); } - Writer.WL($"IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); + Writer.WL($"IEquatable<{_quantity.Name}>, IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); Writer.WL($@" {{ /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = ""Value"", Order = 0)] - private readonly {_quantity.ValueType} _value; + private readonly {_valueType} _value; /// /// The unit this quantity was constructed with. @@ -176,9 +176,9 @@ private void GenerateInstanceConstructors() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) + public {_quantity.Name}({_valueType} value, {_unitEnumName} unit) {{"); - Writer.WL(_quantity.ValueType == "double" + Writer.WL(_valueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" : @" @@ -203,7 +203,7 @@ private void GenerateInstanceConstructors() var firstUnitInfo = unitInfos.FirstOrDefault(); "); - Writer.WL(_quantity.ValueType == "double" + Writer.WL(_valueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" : @" @@ -262,15 +262,15 @@ private void GenerateProperties() public {_valueType} Value => _value; "); - // Need to provide explicit interface implementation for decimal quantities like Information - if (_quantity.ValueType != "double") - Writer.WL(@" - double IQuantity.Value => (double) _value; + Writer.WL($@" + /// + {_valueType} IQuantity.Value => _value; "); + // Need to provide explicit interface implementation for decimal quantities like Information if (_quantity.ValueType == "decimal") Writer.WL(@" /// - decimal IDecimalQuantity.Value => _value; + decimal IDecimalQuantity.Value => (decimal)_value; "); Writer.WL($@" @@ -306,11 +306,11 @@ private void GenerateConversionProperties() Writer.WL($@" /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public {_valueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -426,7 +426,7 @@ private void GenerateStaticFactoryMethods() /// If value is NaN or Infinity."); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}(QuantityValue {valueParamName}) + public static {_quantity.Name} From{unit.PluralName}({_valueType} {valueParamName}) {{ {_valueType} value = ({_valueType}) {valueParamName}; return new {_quantity.Name}(value, {_unitEnumName}.{unit.SingularName}); @@ -651,7 +651,7 @@ private void GenerateArithmeticOperators() }} /// Get ratio value from dividing by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + public static {_valueType} operator /({_quantity.Name} left, {_quantity.Name} right) {{ return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; }} @@ -679,7 +679,7 @@ private void GenerateLogarithmicArithmeticOperators() {{ // Logarithmic addition // Formula: {x} * log10(10^(x/{x}) + 10^(y/{x})) - return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value/{x}) + Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); + return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, (double)left.Value/{x}) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/{x})), left.Unit); }} /// Get from logarithmic subtraction of two . @@ -687,7 +687,7 @@ private void GenerateLogarithmicArithmeticOperators() {{ // Logarithmic subtraction // Formula: {x} * log10(10^(x/{x}) - 10^(y/{x})) - return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value/{x}) - Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); + return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, (double)left.Value/{x}) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/{x})), left.Unit); }} /// Get from logarithmic multiplication of value and . @@ -751,6 +751,19 @@ private void GenerateEqualityAndComparison() return left.Value > right.GetValueAs(left.Unit); }} + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) + {{ + return left.Equals(right); + }} + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) + {{ + return !(left == right); + }} + /// public int CompareTo(object obj) {{ @@ -763,7 +776,29 @@ public int CompareTo(object obj) /// public int CompareTo({_quantity.Name} other) {{ - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + }} + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + {{ + if (obj is null || !(obj is {_quantity.Name} obj{_quantity.Name})) + return false; + return Equals(obj{_quantity.Name}); + }} + + /// + /// Consider using for safely comparing floating point values. + public bool Equals({_quantity.Name} other) + {{ + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); }} /// @@ -806,13 +841,13 @@ public int CompareTo({_quantity.Name} other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) + public bool Equals({_quantity.Name} other, {_valueType} tolerance, ComparisonType comparisonType) {{ if (tolerance < 0) throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + {_valueType} thisValue = this.Value; + {_valueType} otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); }} @@ -823,7 +858,7 @@ public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comp /// A hash code for the current {_quantity.Name}. public override int GetHashCode() {{ - return new {{ Info.Name, Value, Unit }}.GetHashCode(); + return Info.Name.GetHashCode(); }} #endregion @@ -839,17 +874,30 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As({_unitEnumName} unit) + public {_valueType} As({_unitEnumName} unit) {{ - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); }} +"); + + if (_valueType == "decimal") + { + Writer.WL($@" + + {_valueType} IQuantity<{_unitEnumName}>.As({_unitEnumName} unit) + {{ + return ({_valueType})As(unit); + }} +"); + } + + Writer.WL($@" /// - public double As(UnitSystem unitSystem) + public {_valueType} As(UnitSystem unitSystem) {{ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -862,14 +910,27 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); }} +"); + + if (_valueType == "decimal") + { + Writer.WL($@" + /// + {_valueType} IQuantity.As(UnitSystem unitSystem) + {{ + return ({_valueType})As(unitSystem); + }} +"); + } + Writer.WL($@" /// - double IQuantity.As(Enum unit) + {_valueType} IQuantity.As(Enum unit) {{ - if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) + if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return As(unitAs{_unitEnumName}); + return ({_valueType})As(typedUnit); }} /// @@ -901,7 +962,7 @@ double IQuantity.As(Enum unit) var converted = conversionFunction(this); return ({_quantity.Name})converted; }} - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof({_unitEnumName}), unit)) {{ // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -909,17 +970,17 @@ double IQuantity.As(Enum unit) }} else {{ - throw new NotImplementedException($""Can not convert {{Unit}} to {{unit}}.""); + throw new NotSupportedException($""Can not convert {{Unit}} to {{unit}}.""); }} }} /// IQuantity IQuantity.ToUnit(Enum unit) {{ - if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) + if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ToUnit(unitAs{_unitEnumName}, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); }} /// diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index b9a4f2db68..2c7d1a3d8a 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -102,7 +102,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected abstract double {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); + protected abstract {_quantity.ValueType} {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); } Writer.WL(""); @@ -114,12 +114,12 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected virtual double {unit.PluralName}Tolerance {{ get {{ return 1e-5; }} }}"); + protected virtual {_quantity.ValueType} {unit.PluralName}Tolerance {{ get {{ return { (_quantity.ValueType == "decimal" ? "1E-9m" : "1E-5") }; }} }}"); } Writer.WL($@" // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor({_unitEnumName} unit) + protected ({_quantity.ValueType} UnitsInBaseUnit, {_quantity.ValueType} Tolerence) GetConversionFactor({_unitEnumName} unit) {{ return unit switch {{"); @@ -260,7 +260,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) {{ - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); }} else @@ -351,14 +351,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit({_unitEnumName} unit) {{ - var inBaseUnits = {_quantity.Name}.From(1.0, {_quantity.Name}.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = {_quantity.Name}.From(1.0, {_quantity.Name}.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); }} + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + {{ + var inBaseUnit = {_quantity.Name}.From(1.0, {_quantity.Name}.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default({_unitEnumName}))); + }} + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) @@ -368,12 +375,12 @@ public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) Assert.Equal(quantity, toUnitWithSameUnit); }} - [Theory] + [Theory{(_quantity.Units.Length == 1 ? "(Skip = \"Multiple units required\")" : string.Empty)}] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit({_unitEnumName} unit) {{ - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = {_quantity.Name}.Units.Where(u => u != {_quantity.Name}.BaseUnit).DefaultIfEmpty({_quantity.Name}.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = {_quantity.Name}.Units.First(u => u != {_quantity.Name}.BaseUnit); var quantity = {_quantity.Name}.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -612,8 +619,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); }} [Fact] @@ -647,36 +655,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); }} [Fact] public void Convert_ToInt32_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); }} [Fact] public void Convert_ToInt64_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); }} [Fact] public void Convert_ToSByte_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); }} [Fact] public void Convert_ToSingle_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); }} [Fact] @@ -689,22 +702,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); }} [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); }} [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() {{ - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); }} [Fact] @@ -746,7 +762,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal(new {{{_quantity.Name}.Info.Name, quantity.Value, quantity.Unit}}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal({_quantity.Name}.Info.Name.GetHashCode(), quantity.GetHashCode()); }} "); diff --git a/Common/UnitDefinitions/Angle.json b/Common/UnitDefinitions/Angle.json index 1f7b908af1..2b240f025d 100644 --- a/Common/UnitDefinitions/Angle.json +++ b/Common/UnitDefinitions/Angle.json @@ -108,8 +108,8 @@ { "SingularName": "Tilt", "PluralName": "Tilt", - "FromUnitToBaseFunc": "Math.Asin({x}) * 180 / Math.PI", - "FromBaseToUnitFunc": "Math.Sin({x} / 180 * Math.PI)", + "FromUnitToBaseFunc": "Math.Asin((double){x}) * 180 / Math.PI", + "FromBaseToUnitFunc": "Math.Sin((double){x} / 180 * Math.PI)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Frequency.json b/Common/UnitDefinitions/Frequency.json index 400a4f7f87..eb901b4740 100644 --- a/Common/UnitDefinitions/Frequency.json +++ b/Common/UnitDefinitions/Frequency.json @@ -95,7 +95,7 @@ { "SingularName": "BUnit", "PluralName": "BUnits", - "FromUnitToBaseFunc": "Math.Sqrt({x} * 1e3)", + "FromUnitToBaseFunc": "Math.Sqrt((double){x} * 1e3)", "FromBaseToUnitFunc": "{x} * {x} * 1e-3", "Localization": [ { diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index 89f98458eb..ce491fa507 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -85,8 +85,8 @@ { "SingularName": "BritishThermalUnitPerHour", "PluralName": "BritishThermalUnitsPerHour", - "FromUnitToBaseFunc": "{x} * 0.293071m", - "FromBaseToUnitFunc": "{x} / 0.293071m", + "FromUnitToBaseFunc": "{x} * 0.29307107017m", + "FromBaseToUnitFunc": "{x} / 0.29307107017m", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json index 89b22e4e3c..86f5bd3018 100644 --- a/Common/UnitDefinitions/Pressure.json +++ b/Common/UnitDefinitions/Pressure.json @@ -380,8 +380,8 @@ { "SingularName": "MeterOfElevation", "PluralName": "MetersOfElevation", - "FromUnitToBaseFunc": "Math.Pow(1.0 - ({x} / 44307.69396), 5.2553026003237266401799415610351) * 101325.0", - "FromBaseToUnitFunc": "(1.0 - Math.Pow({x} / 101325.0, 0.190284)) * 44307.69396", + "FromUnitToBaseFunc": "Math.Pow(1.0 - ((double){x} / 44307.69396), 5.2553026003237266401799415610351) * 101325.0", + "FromBaseToUnitFunc": "(1.0 - Math.Pow((double){x} / 101325.0, 0.190284)) * 44307.69396", "Localization": [ { "Culture": "en-US", @@ -392,8 +392,8 @@ { "SingularName": "FootOfElevation", "PluralName": "FeetOfElevation", - "FromUnitToBaseFunc": "Math.Pow(1.0 - ({x} / 145366.45), 5.2553026003237266401799415610351) * 101325.0", - "FromBaseToUnitFunc": "(1.0 - Math.Pow({x} / 101325.0, 0.190284)) * 145366.45", + "FromUnitToBaseFunc": "Math.Pow(1.0 - ((double){x} / 145366.45), 5.2553026003237266401799415610351) * 101325.0", + "FromBaseToUnitFunc": "(1.0 - Math.Pow((double){x} / 101325.0, 0.190284)) * 145366.45", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/PressureChangeRate.json b/Common/UnitDefinitions/PressureChangeRate.json index befcc49275..6f60ee8d25 100644 --- a/Common/UnitDefinitions/PressureChangeRate.json +++ b/Common/UnitDefinitions/PressureChangeRate.json @@ -50,11 +50,11 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "mmHg/s" ], + "Abbreviations": [ "mmHg/s" ] }, { "Culture": "ru-RU", - "Abbreviations": [ "mmHg/с" ], + "Abbreviations": [ "mmHg/с" ] } ] }, diff --git a/UnitsNet.Benchmark/Program.cs b/UnitsNet.Benchmark/Program.cs index 25d32af6e7..7cbd986157 100644 --- a/UnitsNet.Benchmark/Program.cs +++ b/UnitsNet.Benchmark/Program.cs @@ -24,15 +24,15 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Transformation")] - public double ToProperty() => _length.Centimeters; + public QuantityValue ToProperty() => _length.Centimeters; [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double As() => _length.As(LengthUnit.Centimeter); + public QuantityValue As() => _length.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double As_SI() => _length.As(UnitSystem.SI); + public QuantityValue As_SI() => _length.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] @@ -64,11 +64,11 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); + public QuantityValue IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public double IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); + public QuantityValue IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs index 1305cad4f6..07fcb9af0b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs @@ -314,7 +314,7 @@ private double GetValueInBaseUnit() AngleUnit.NatoMil => _value * 9 / 160, AngleUnit.Radian => _value * 180 / 3.1415926535897931, AngleUnit.Revolution => _value * 360, - AngleUnit.Tilt => Math.Asin(_value) * 180 / 3.1415926535897931, + AngleUnit.Tilt => Math.Asin((double)_value) * 180 / 3.1415926535897931, _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") }; } @@ -343,7 +343,7 @@ private double GetValueAs(AngleUnit unit) AngleUnit.NatoMil => baseUnitValue * 160 / 9, AngleUnit.Radian => baseUnitValue / 180 * 3.1415926535897931, AngleUnit.Revolution => baseUnitValue / 360, - AngleUnit.Tilt => Math.Sin(baseUnitValue / 180 * 3.1415926535897931), + AngleUnit.Tilt => Math.Sin((double)baseUnitValue / 180 * 3.1415926535897931), _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs index 735e48489b..805a01cbe5 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs @@ -245,7 +245,7 @@ private double GetValueInBaseUnit() return Unit switch { FrequencyUnit.BeatPerMinute => _value / 60, - FrequencyUnit.BUnit => Math.Sqrt(_value * 1e3), + FrequencyUnit.BUnit => Math.Sqrt((double)_value * 1e3), FrequencyUnit.CyclePerHour => _value / 3600, FrequencyUnit.CyclePerMinute => _value / 60, FrequencyUnit.Gigahertz => (_value) * 1e9d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index 5c25292799..e10cb3d208 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -410,7 +410,7 @@ private double GetValueInBaseUnit() return Unit switch { PowerUnit.BoilerHorsepower => _value * 9812.5d, - PowerUnit.BritishThermalUnitPerHour => _value * 0.293071d, + PowerUnit.BritishThermalUnitPerHour => _value * 0.29307107017d, PowerUnit.Decawatt => (_value) * 1e1d, PowerUnit.Deciwatt => (_value) * 1e-1d, PowerUnit.ElectricalHorsepower => _value * 746d, @@ -419,11 +419,11 @@ private double GetValueInBaseUnit() PowerUnit.Gigawatt => (_value) * 1e9d, PowerUnit.HydraulicHorsepower => _value * 745.69988145d, PowerUnit.JoulePerHour => _value / 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.293071d) * 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e3d, PowerUnit.KilojoulePerHour => (_value / 3600d) * 1e3d, PowerUnit.Kilowatt => (_value) * 1e3d, PowerUnit.MechanicalHorsepower => _value * 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.293071d) * 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e6d, PowerUnit.MegajoulePerHour => (_value / 3600d) * 1e6d, PowerUnit.Megawatt => (_value) * 1e6d, PowerUnit.MetricHorsepower => _value * 735.49875d, @@ -449,7 +449,7 @@ private double GetValueAs(PowerUnit unit) return unit switch { PowerUnit.BoilerHorsepower => baseUnitValue / 9812.5d, - PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.293071d, + PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.29307107017d, PowerUnit.Decawatt => (baseUnitValue) / 1e1d, PowerUnit.Deciwatt => (baseUnitValue) / 1e-1d, PowerUnit.ElectricalHorsepower => baseUnitValue / 746d, @@ -458,11 +458,11 @@ private double GetValueAs(PowerUnit unit) PowerUnit.Gigawatt => (baseUnitValue) / 1e9d, PowerUnit.HydraulicHorsepower => baseUnitValue / 745.69988145d, PowerUnit.JoulePerHour => baseUnitValue * 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e3d, PowerUnit.KilojoulePerHour => (baseUnitValue * 3600d) / 1e3d, PowerUnit.Kilowatt => (baseUnitValue) / 1e3d, PowerUnit.MechanicalHorsepower => baseUnitValue / 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e6d, PowerUnit.MegajoulePerHour => (baseUnitValue * 3600d) / 1e6d, PowerUnit.Megawatt => (baseUnitValue) / 1e6d, PowerUnit.MetricHorsepower => baseUnitValue / 735.49875d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs index fe89149b52..2e773ff8a1 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs @@ -646,7 +646,7 @@ private double GetValueInBaseUnit() 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.FootOfElevation => Math.Pow(1.0 - ((double)_value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.FootOfHead => _value * 2989.0669, PressureUnit.Gigapascal => (_value) * 1e9d, PressureUnit.Hectopascal => (_value) * 1e2d, @@ -666,7 +666,7 @@ private double GetValueInBaseUnit() 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.MeterOfElevation => Math.Pow(1.0 - ((double)_value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.MeterOfHead => _value * 9804.139432, PressureUnit.Microbar => (_value * 1e5) * 1e-6d, PressureUnit.Micropascal => (_value) * 1e-6d, @@ -706,7 +706,7 @@ private double GetValueAs(PressureUnit unit) 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.FootOfElevation => (1.0 - Math.Pow((double)baseUnitValue / 101325.0, 0.190284)) * 145366.45, PressureUnit.FootOfHead => baseUnitValue * 0.000334552565551, PressureUnit.Gigapascal => (baseUnitValue) / 1e9d, PressureUnit.Hectopascal => (baseUnitValue) / 1e2d, @@ -726,7 +726,7 @@ private double GetValueAs(PressureUnit unit) 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.MeterOfElevation => (1.0 - Math.Pow((double)baseUnitValue / 101325.0, 0.190284)) * 44307.69396, PressureUnit.MeterOfHead => baseUnitValue * 0.0001019977334, PressureUnit.Microbar => (baseUnitValue / 1e5) / 1e-6d, PressureUnit.Micropascal => (baseUnitValue) / 1e-6d, diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index 0d09ca57fd..f0c5f3c1d4 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -25,8 +25,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj deleted file mode 100644 index 8bcee805f8..0000000000 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net6.0 - UnitsNet.Serialization.JsonNet.CompatibilityTests - latest - true - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs deleted file mode 100644 index 6775d8769d..0000000000 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using Newtonsoft.Json; -using Xunit; - -namespace UnitsNet.Serialization.JsonNet.CompatibilityTests -{ - public class UnitsNetJsonConverterTests - { - private readonly JsonSerializerSettings _jsonSerializerSettings; - - protected UnitsNetJsonConverterTests() - { - _jsonSerializerSettings = new JsonSerializerSettings {Formatting = Formatting.Indented}; - _jsonSerializerSettings.Converters.Add(new UnitsNetJsonConverter()); - } - - private string SerializeObject(object obj) - { - return JsonConvert.SerializeObject(obj, _jsonSerializerSettings).Replace("\r\n", "\n"); - } - - private T DeserializeObject(string json) - { - return JsonConvert.DeserializeObject(json, _jsonSerializerSettings); - } - - public class Serialize : UnitsNetJsonConverterTests - { - [Fact] - public void Information_CanSerializeVeryLargeValues() - { - Information i = Information.FromExabytes(1E+9); - var expectedJson = "{\n \"Unit\": \"InformationUnit.Exabyte\",\n \"Value\": 1000000000.0\n}"; - - string json = SerializeObject(i); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void Mass_ExpectConstructedValueAndUnit() - { - Mass mass = Mass.FromPounds(200); - var expectedJson = "{\n \"Unit\": \"MassUnit.Pound\",\n \"Value\": 200.0\n}"; - - string json = SerializeObject(mass); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void Information_ExpectConstructedValueAndUnit() - { - Information quantity = Information.FromKilobytes(54); - var expectedJson = "{\n \"Unit\": \"InformationUnit.Kilobyte\",\n \"Value\": 54.0\n}"; - - string json = SerializeObject(quantity); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void NonNullNullableValue_ExpectJsonUnaffected() - { - Mass? nullableMass = Mass.FromKilograms(10); - var expectedJson = "{\n \"Unit\": \"MassUnit.Kilogram\",\n \"Value\": 10.0\n}"; - - string json = SerializeObject(nullableMass); - - // There shouldn't be any change in the JSON for the non-null nullable value. - Assert.Equal(expectedJson, json); - } - - [Fact] - public void NonNullNullableValueNestedInObject_ExpectJsonUnaffected() - { - var testObj = new TestObj - { - NullableFrequency = Frequency.FromHertz(10), - NonNullableFrequency = Frequency.FromHertz(10) - }; - // Ugly manually formatted JSON string is used because string literals with newlines are rendered differently - // on the build server (i.e. the build server uses '\r' instead of '\n') - string expectedJson = "{\n" + - " \"NullableFrequency\": {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " \"NonNullableFrequency\": {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - "}"; - - string json = SerializeObject(testObj); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void NullValue_ExpectJsonContainsNullString() - { - string json = SerializeObject(null); - Assert.Equal("null", json); - } - - [Fact] - public void Ratio_ExpectDecimalFractionsUsedAsBaseValueAndUnit() - { - Ratio ratio = Ratio.FromPartsPerThousand(250); - var expectedJson = "{\n \"Unit\": \"RatioUnit.PartPerThousand\",\n \"Value\": 250.0\n}"; - - string json = SerializeObject(ratio); - - Assert.Equal(expectedJson, json); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void ArrayValue_ExpectJsonArray() - { - Frequency[] testObj = new Frequency[] { Frequency.FromHertz(10), Frequency.FromHertz(10) }; - - string expectedJson = "[\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - "]"; - - string json = SerializeObject(testObj); - - Assert.Equal(expectedJson, json); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void EmptyArrayValue_ExpectJsonArray() - { - Frequency[] testObj = { }; - - string expectedJson = "[]"; - - string json = SerializeObject(testObj); - Assert.Equal(expectedJson, json); - } - } - - public class Deserialize : UnitsNetJsonConverterTests - { - [Fact] - public void Information_CanDeserializeVeryLargeValues() - { - Information original = Information.FromExabytes(1E+9); - string json = SerializeObject(original); - var deserialized = DeserializeObject(json); - - Assert.Equal(original, deserialized); - } - - [Fact] - public void Mass_ExpectJsonCorrectlyDeserialized() - { - Mass originalMass = Mass.FromKilograms(33.33); - string json = SerializeObject(originalMass); - - var deserializedMass = DeserializeObject(json); - - Assert.Equal(originalMass, deserializedMass); - } - - [Fact] - public void NonNullNullableValue_ExpectValueDeserializedCorrectly() - { - Mass? nullableMass = Mass.FromKilograms(10); - string json = SerializeObject(nullableMass); - - Mass? deserializedNullableMass = DeserializeObject(json); - - Assert.Equal(nullableMass.Value, deserializedNullableMass); - } - - [Fact] - public void NonNullNullableValueNestedInObject_ExpectValueDeserializedCorrectly() - { - var testObj = new TestObj - { - NullableFrequency = Frequency.FromHertz(10), - NonNullableFrequency = Frequency.FromHertz(10) - }; - string json = SerializeObject(testObj); - - var deserializedTestObj = DeserializeObject(json); - - Assert.Equal(testObj.NullableFrequency, deserializedTestObj.NullableFrequency); - } - - [Fact] - public void NullValue_ExpectNullReturned() - { - string json = SerializeObject(null); - var deserializedNullMass = DeserializeObject(json); - - Assert.Null(deserializedNullMass); - } - - [Fact] - public void NullValueNestedInObject_ExpectValueDeserializedToNullCorrectly() - { - var testObj = new TestObj - { - NullableFrequency = null, - NonNullableFrequency = Frequency.FromHertz(10) - }; - string json = SerializeObject(testObj); - - var deserializedTestObj = DeserializeObject(json); - - Assert.Null(deserializedTestObj.NullableFrequency); - } - - [Fact] - public void UnitEnumChangedAfterSerialization_ExpectUnitCorrectlyDeserialized() - { - Mass originalMass = Mass.FromKilograms(33.33); - string json = SerializeObject(originalMass); - // Someone manually changed the serialized JSON string to 1000 grams. - json = json.Replace("33.33", "1000"); - json = json.Replace("MassUnit.Kilogram", "MassUnit.Gram"); - - var deserializedMass = DeserializeObject(json); - - // The original value serialized was 33.33 kg, but someone edited the JSON to be 1000 g. We expect the JSON is - // still deserializable, and the correct value of 1000 g is obtained. - Assert.Equal(1000, deserializedMass.Grams); - } - - [Fact] - public void UnitInIComparable_ExpectUnitCorrectlyDeserialized() - { - TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() - { - Value = Power.FromWatts(10) - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - - var deserializedTestObject = JsonConvert.DeserializeObject(json,jsonSerializerSettings); - - Assert.Equal(typeof(Power), deserializedTestObject.Value.GetType()); - Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value); - } - - [Fact] - public void DoubleInIComparable_ExpectUnitCorrectlyDeserialized() - { - TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() - { - Value = 10.0 - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - - var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(double), deserializedTestObject.Value.GetType()); - Assert.Equal(10d, (double)deserializedTestObject.Value); - } - - [Fact] - public void ClassInIComparable_ExpectUnitCorrectlyDeserialized() - { - TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() - { - Value = new ComparableClass() { Value = 10 } - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value.GetType()); - Assert.Equal(10d, ((ComparableClass) deserializedTestObject.Value).Value); - } - - [Fact] - public void OtherObjectWithUnitAndValue_ExpectCorrectResturnValues() - { - TestObjWithValueAndUnit testObjWithValueAndUnit = new TestObjWithValueAndUnit() - { - Value = 5, - Unit = "Test", - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithValueAndUnit, jsonSerializerSettings); - TestObjWithValueAndUnit deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(double), deserializedTestObject.Value.GetType()); - Assert.Equal(5d, deserializedTestObject.Value); - Assert.Equal("Test", deserializedTestObject.Unit); - } - - [Fact] - public void ThreeObjectsInIComparableWithDifferentValues_ExpectAllCorrectlyDeserialized() - { - TestObjWithThreeIComparable testObjWithIComparable = new TestObjWithThreeIComparable() - { - Value1 = 10.0, - Value2 = Power.FromWatts(19), - Value3 = new ComparableClass() { Value = 10 }, - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(double), deserializedTestObject.Value1.GetType()); - Assert.Equal(10d, deserializedTestObject.Value1); - Assert.Equal(typeof(Power), deserializedTestObject.Value2.GetType()); - Assert.Equal(Power.FromWatts(19), deserializedTestObject.Value2); - Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value3.GetType()); - Assert.Equal(testObjWithIComparable.Value3, deserializedTestObject.Value3); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void ArrayOfUnits_ExpectCorrectlyDeserialized() - { - Frequency[] expected = new Frequency[] { Frequency.FromHertz(10), Frequency.FromHertz(10) }; - - string json = "[\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - "]"; - - Frequency[] result = DeserializeObject(json); - - Assert.Equal(expected, result); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void MultiDimArrayOfUnits_ExpectCorrectlyDeserialized() - { - Frequency[,] expected = { { Frequency.FromHertz(10), Frequency.FromHertz(10) }, { Frequency.FromHertz(10), Frequency.FromHertz(10) } }; - - string json = "[\n" + - " [\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - " ],\n" + - " [\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - " ]\n" + - "]"; - - Frequency[,] result = DeserializeObject(json); - - Assert.Equal(expected, result); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void EmptyArray_ExpectCorrectlyDeserialized() - { - string json = "[]"; - - Frequency[] result = DeserializeObject(json); - - Assert.Empty(result); - } - - private static JsonSerializerSettings CreateJsonSerializerSettings() - { - var jsonSerializerSettings = new JsonSerializerSettings() - { - Formatting = Formatting.Indented, - TypeNameHandling = TypeNameHandling.Auto - }; - jsonSerializerSettings.Converters.Add(new UnitsNetJsonConverter()); - return jsonSerializerSettings; - } - } - - private class TestObj - { - public Frequency? NullableFrequency { get; set; } - public Frequency NonNullableFrequency { get; set; } - } - - private class TestObjWithValueAndUnit : IComparable - { - public double Value { get; set; } - public string Unit { get; set; } - - public int CompareTo(object obj) - { - return ((IComparable)Value).CompareTo(obj); - } - } - - private class ComparableClass : IComparable - { - public int Value { get; set; } - public int CompareTo(object obj) - { - return ((IComparable)Value).CompareTo(obj); - } - - // Needed for virfying that the deserialized object is the same, should not affect the serilization code - public override bool Equals(object obj) - { - if (obj == null || GetType() != obj.GetType()) - { - return false; - } - return Value.Equals(((ComparableClass)obj).Value); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - } - - private class TestObjWithIComparable - { - public IComparable Value { get; set; } - } - - private class TestObjWithThreeIComparable - { - public IComparable Value1 { get; set; } - - public IComparable Value2 { get; set; } - - public IComparable Value3 { get; set; } - } - } -} diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj index 8dbc78c305..b9176c0e6b 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj @@ -14,8 +14,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index 9aa3d59239..76e82be109 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -54,7 +54,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5, ComparisonType.Absolute)); + Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5m, ComparisonType.Absolute)); } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs index f8053607da..bbe5522852 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs @@ -117,7 +117,7 @@ public void UnitsNetIComparableJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(120D, ((Power)result).Watts); + Assert.Equal(120M, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs index ea87af940d..8ed7de7c29 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs @@ -135,7 +135,7 @@ public void UnitsNetIQuantityJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(10.3654D, ((Power)result).Watts); + Assert.Equal(10.3654M, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs index b7a150b944..2b89bee8df 100644 --- a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs +++ b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs @@ -85,7 +85,7 @@ public override void WriteJson(JsonWriter writer, IQuantity? quantity, JsonSeria } else { - writer.WriteValue(quantity.Value); + writer.WriteValue((double)quantity.Value); } // write the 'Unit' abbreviation diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index 2e804182c7..3373b27b26 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -186,13 +186,14 @@ protected ValueUnit ConvertIQuantity(IQuantity quantity) return new ExtendedValueUnit { Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}", - Value = quantity.Value, + // The type of "Value" is still double + Value = (double)quantity.Value, ValueString = d.Value.ToString(CultureInfo.InvariantCulture), ValueType = "decimal" }; } - return new ValueUnit {Value = quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; + return new ValueUnit {Value = (double)quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; } /// diff --git a/UnitsNet.Tests/AssertEx.cs b/UnitsNet.Tests/AssertEx.cs index d052adfeec..34f270251c 100644 --- a/UnitsNet.Tests/AssertEx.cs +++ b/UnitsNet.Tests/AssertEx.cs @@ -25,5 +25,35 @@ public static void EqualTolerance(double expected, double actual, double toleran Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" ); } } + + public static void EqualTolerance(decimal expected, decimal actual, decimal tolerance, ComparisonType comparisonType = ComparisonType.Relative) + { + if (comparisonType == ComparisonType.Relative) + { + bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance); + + decimal difference = Math.Abs(expected - actual); + decimal relativeDifference = difference / expected; + + Assert.True(areEqual, $"Values are not equal within relative tolerance: {tolerance:P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}"); + } + else if (comparisonType == ComparisonType.Absolute) + { + bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance); + Assert.True(areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}"); + } + } + + public static void EqualTolerance(QuantityValue expected, QuantityValue actual, double tolerance, + ComparisonType comparisonType = ComparisonType.Relative) + { + EqualTolerance((double)expected, (double)actual, tolerance, comparisonType); + } + + public static void EqualTolerance(QuantityValue expected, QuantityValue actual, decimal tolerance, + ComparisonType comparisonType = ComparisonType.Relative) + { + EqualTolerance((decimal)expected, (decimal)actual, tolerance, comparisonType); + } } } diff --git a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs index 726457cbe1..92960b547a 100644 --- a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs @@ -51,7 +51,7 @@ public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, doub // Amplitude ratio increases linearly by 20 dBV with power-of-10 increases of voltage. ElectricPotential v = ElectricPotential.FromVolts(voltage); - double actual = AmplitudeRatio.FromElectricPotential(v).DecibelVolts; + double actual = (double)AmplitudeRatio.FromElectricPotential(v).DecibelVolts; Assert.Equal(expected, actual); } @@ -61,12 +61,12 @@ public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, doub [InlineData(0, 1)] [InlineData(20, 10)] [InlineData(40, 100)] - public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRatio, double expected) + public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(QuantityValue amplitudeRatio, QuantityValue expected) { // Voltage increases by powers of 10 for every 20 dBV increase in amplitude ratio. AmplitudeRatio ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio); - double actual = ar.ToElectricPotential().Volts; + QuantityValue actual = ar.ToElectricPotential().Volts; Assert.Equal(expected, actual); } @@ -81,7 +81,7 @@ public void AmplitudeRatioToPowerRatio_50OhmImpedance(double dBmV, double expect { AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); + double actual = Math.Round((double)ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); Assert.Equal(expected, actual); } @@ -94,7 +94,7 @@ public void AmplitudeRatioToPowerRatio_75OhmImpedance(double dBmV, double expect { AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); + double actual = Math.Round((double)ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index 5cea83c962..966fc50aca 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -68,7 +68,7 @@ public void AreaFromCicleDiameterCalculatedCorrectly(double diameterMeters, doub { Length diameter = Length.FromMeters(diameterMeters); - double actual = Area.FromCircleDiameter(diameter).SquareMeters; + double actual = (double)Area.FromCircleDiameter(diameter).SquareMeters; Assert.Equal(expected, actual); } @@ -82,7 +82,7 @@ public void AreaFromCicleRadiusCalculatedCorrectly(double radiusMeters, double e { Length radius = Length.FromMeters(radiusMeters); - double actual = Area.FromCircleRadius(radius).SquareMeters; + double actual = (double)Area.FromCircleRadius(radius).SquareMeters; Assert.Equal(expected, actual); } diff --git a/UnitsNet.Tests/CustomCode/BitRateTests.cs b/UnitsNet.Tests/CustomCode/BitRateTests.cs index 2afe11ae27..5e49dc8ad3 100644 --- a/UnitsNet.Tests/CustomCode/BitRateTests.cs +++ b/UnitsNet.Tests/CustomCode/BitRateTests.cs @@ -29,37 +29,37 @@ public class BitRateTests : BitRateTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double BitsPerSecondInOneBitPerSecond => 1d; - protected override double BytesPerSecondInOneBitPerSecond => 1.25E-1d; + protected override decimal BitsPerSecondInOneBitPerSecond => 1m; + protected override decimal BytesPerSecondInOneBitPerSecond => 1.25E-1m; - protected override double KilobitsPerSecondInOneBitPerSecond => 1E-3d; - protected override double KilobytesPerSecondInOneBitPerSecond => 1.25E-4d; - protected override double KibibitsPerSecondInOneBitPerSecond => 0.0009765625d; - protected override double KibibytesPerSecondInOneBitPerSecond => 0.0001220703125d; + protected override decimal KilobitsPerSecondInOneBitPerSecond => 1E-3m; + protected override decimal KilobytesPerSecondInOneBitPerSecond => 1.25E-4m; + protected override decimal KibibitsPerSecondInOneBitPerSecond => 0.0009765625m; + protected override decimal KibibytesPerSecondInOneBitPerSecond => 0.0001220703125m; - protected override double MegabitsPerSecondInOneBitPerSecond => 1E-6d; - protected override double MegabytesPerSecondInOneBitPerSecond => 1.25E-07d; - protected override double MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07d; - protected override double MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07d; + protected override decimal MegabitsPerSecondInOneBitPerSecond => 1E-6m; + protected override decimal MegabytesPerSecondInOneBitPerSecond => 1.25E-07m; + protected override decimal MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07m; + protected override decimal MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07m; - protected override double GigabitsPerSecondInOneBitPerSecond => 1E-9d; - protected override double GigabytesPerSecondInOneBitPerSecond => 1.25E-10d; - protected override double GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10d; - protected override double GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10d; + protected override decimal GigabitsPerSecondInOneBitPerSecond => 1E-9m; + protected override decimal GigabytesPerSecondInOneBitPerSecond => 1.25E-10m; + protected override decimal GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10m; + protected override decimal GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10m; - protected override double TerabitsPerSecondInOneBitPerSecond => 1E-12d; - protected override double TerabytesPerSecondInOneBitPerSecond => 1.25E-13d; - protected override double TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13d; - protected override double TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13d; + protected override decimal TerabitsPerSecondInOneBitPerSecond => 1E-12m; + protected override decimal TerabytesPerSecondInOneBitPerSecond => 1.25E-13m; + protected override decimal TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13m; + protected override decimal TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13m; - protected override double PetabitsPerSecondInOneBitPerSecond => 1E-15d; - protected override double PetabytesPerSecondInOneBitPerSecond => 1.25E-16d; - protected override double PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16d; - protected override double PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16d; + protected override decimal PetabitsPerSecondInOneBitPerSecond => 1E-15m; + protected override decimal PetabytesPerSecondInOneBitPerSecond => 1.25E-16m; + protected override decimal PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16m; + protected override decimal PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16m; - protected override double ExabitsPerSecondInOneBitPerSecond => 1E-18d; - protected override double ExabytesPerSecondInOneBitPerSecond => 1.25E-19d; - protected override double ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19d; - protected override double ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19d; + protected override decimal ExabitsPerSecondInOneBitPerSecond => 1E-18m; + protected override decimal ExabytesPerSecondInOneBitPerSecond => 1.25E-19m; + protected override decimal ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19m; + protected override decimal ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19m; } } diff --git a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs index 3079c5d0d6..77ec95385c 100644 --- a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs +++ b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs @@ -33,8 +33,8 @@ public void DoubleDividedByBrakeSpecificFuelConsumptionEqualsSpecificEnergy() [Fact] public void BrakeSpecificFuelConsumptionTimesSpecificEnergyEqualsEnergy() { - double value = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); - Assert.Equal(200.0, value); + decimal value = (decimal)(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0)); + Assert.Equal(200.0m, value); } } } diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs index dc0dbfd879..4e2b1fa474 100644 --- a/UnitsNet.Tests/CustomCode/InformationTests.cs +++ b/UnitsNet.Tests/CustomCode/InformationTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class InformationTests : InformationTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double BitsInOneBit => 1d; + protected override decimal BitsInOneBit => 1m; - protected override double BytesInOneBit => 0.125d; + protected override decimal BytesInOneBit => 0.125m; - protected override double ExabitsInOneBit => 1e-18d; + protected override decimal ExabitsInOneBit => 1e-18m; - protected override double ExabytesInOneBit => 0.125d*1e-18d; + protected override decimal ExabytesInOneBit => 0.125m*1e-18m; - protected override double ExbibitsInOneBit => 1d/Math.Pow(1024, 6); + protected override decimal ExbibitsInOneBit => 1m/(decimal)Math.Pow(1024, 6); - protected override double ExbibytesInOneBit => 1/8d/Math.Pow(1024, 6); + protected override decimal ExbibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 6); - protected override double GibibitsInOneBit => 1d/Math.Pow(1024, 3); + protected override decimal GibibitsInOneBit => 1m/(decimal)Math.Pow(1024, 3); - protected override double GibibytesInOneBit => 1d/8/Math.Pow(1024, 3); + protected override decimal GibibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 3); - protected override double GigabitsInOneBit => 1e-9d; + protected override decimal GigabitsInOneBit => 1e-9m; - protected override double GigabytesInOneBit => 0.125d*1e-9d; + protected override decimal GigabytesInOneBit => 0.125m*1e-9m; - protected override double KibibitsInOneBit => 1d/1024d; + protected override decimal KibibitsInOneBit => 1m/1024m; - protected override double KibibytesInOneBit => 1d/8/1024d; + protected override decimal KibibytesInOneBit => 1m/8/1024m; - protected override double KilobitsInOneBit => 0.001d; + protected override decimal KilobitsInOneBit => 0.001m; - protected override double KilobytesInOneBit => 0.000125d; + protected override decimal KilobytesInOneBit => 0.000125m; - protected override double MebibitsInOneBit => 1d/Math.Pow(1024, 2); + protected override decimal MebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 2); - protected override double MebibytesInOneBit => 1d/8/Math.Pow(1024, 2); + protected override decimal MebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 2); - protected override double MegabitsInOneBit => 1e-6d; + protected override decimal MegabitsInOneBit => 1e-6m; - protected override double MegabytesInOneBit => 0.125d*1e-6d; + protected override decimal MegabytesInOneBit => 0.125m*1e-6m; - protected override double PebibitsInOneBit => 1d/Math.Pow(1024, 5); + protected override decimal PebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 5); - protected override double PebibytesInOneBit => 1d/8/Math.Pow(1024, 5); + protected override decimal PebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 5); - protected override double PetabitsInOneBit => 1e-15d; + protected override decimal PetabitsInOneBit => 1e-15m; - protected override double PetabytesInOneBit => 0.125d*1e-15d; + protected override decimal PetabytesInOneBit => 0.125m*1e-15m; - protected override double TebibitsInOneBit => 1d/Math.Pow(1024, 4); + protected override decimal TebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 4); - protected override double TebibytesInOneBit => 1d/8/Math.Pow(1024, 4); + protected override decimal TebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 4); - protected override double TerabitsInOneBit => 1e-12d; + protected override decimal TerabitsInOneBit => 1e-12m; - protected override double TerabytesInOneBit => 0.125d*1e-12d; + protected override decimal TerabytesInOneBit => 0.125m*1e-12m; [Fact] public void OneKBHas1000Bytes() diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index 9d7cb97f2d..711f82b28d 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -108,7 +108,7 @@ public void TimeSpanTimesMassFlowEqualsMass() public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower() { Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); - Assert.Equal(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts); + AssertEx.EqualTolerance(20.0m / 24.0m * 1e6m / 180.0m, power.Kilowatts, 1E-11m); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/ParseTests.cs b/UnitsNet.Tests/CustomCode/ParseTests.cs index 06a1f7cdc9..ccf4c2ec56 100644 --- a/UnitsNet.Tests/CustomCode/ParseTests.cs +++ b/UnitsNet.Tests/CustomCode/ParseTests.cs @@ -25,10 +25,10 @@ public class ParseTests [InlineData("1e-3 km", 1)] [InlineData("5.5 m", 5.5)] [InlineData("500,005 m", 500005)] - public void ParseLengthToMetersUsEnglish(string s, double expected) + public void ParseLengthToMetersUsEnglish(string s, QuantityValue expected) { CultureInfo usEnglish = new CultureInfo("en-US"); - double actual = Length.Parse(s, usEnglish).Meters; + QuantityValue actual = Length.Parse(s, usEnglish).Meters; Assert.Equal(expected, actual); } @@ -50,7 +50,7 @@ public void ParseLength_InvalidString_USEnglish_ThrowsException(string s, Type e [InlineData("5.5 m", 5.5)] [InlineData("500 005 m", 500005)] // quantity doesn't match number format - public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, double expected) + public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, QuantityValue expected) { var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone(); numberFormat.NumberGroupSeparator = " "; @@ -58,7 +58,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, double expe numberFormat.NumberDecimalSeparator = "."; numberFormat.CurrencyDecimalSeparator = "."; - double actual = Length.Parse(s, numberFormat).Meters; + QuantityValue actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } @@ -81,7 +81,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators_ThrowsExceptionOnInva [InlineData("5,5 m", 5.5)] [InlineData("500.005.050,001 m", 500005050.001)] [InlineData("5.555 m", 5555)] // Dot is group separator not decimal - public void ParseWithCultureUsingDotAsThousandSeparators(string s, double expected) + public void ParseWithCultureUsingDotAsThousandSeparators(string s, QuantityValue expected) { var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone(); numberFormat.NumberGroupSeparator = "."; @@ -89,7 +89,7 @@ public void ParseWithCultureUsingDotAsThousandSeparators(string s, double expect numberFormat.NumberDecimalSeparator = ","; numberFormat.CurrencyDecimalSeparator = ","; - double actual = Length.Parse(s, numberFormat).Meters; + QuantityValue actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs index e6820ea023..f34ed66db4 100644 --- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs @@ -41,11 +41,12 @@ public void InvalidPower_ExpectArgumentOutOfRangeException(double power) public void ExpectPowerConvertedCorrectly(double power, double expected) { Power p = Power.FromWatts(power); - double actual = PowerRatio.FromPower(p).DecibelWatts; + double actual = (double)PowerRatio.FromPower(p).DecibelWatts; Assert.Equal(expected, actual); } [Theory] + // Note: Attribute arguments cannot be of type decimal. [InlineData(-20, 0.01)] [InlineData(-10, 0.1)] [InlineData(0, 1)] @@ -54,8 +55,8 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected) { PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio); - double actual = pr.ToPower().Watts; - Assert.Equal(expected, actual); + decimal actual = (decimal)pr.ToPower().Watts; + Assert.Equal((decimal)expected, actual); } // http://www.maximintegrated.com/en/app-notes/index.mvp/id/808 @@ -69,7 +70,7 @@ public void PowerRatioToAmplitudeRatio_50OhmImpedance(double dBmW, double expect { PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); + double actual = Math.Round((double)powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); Assert.Equal(expected, actual); } @@ -82,7 +83,7 @@ public void PowerRatioToAmplitudeRatio_75OhmImpedance(double dBmW, double expect { PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); + double actual = Math.Round((double)powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs index b965e8fa83..8161a50849 100644 --- a/UnitsNet.Tests/CustomCode/PowerTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class PowerTests : PowerTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double FemtowattsInOneWatt => 1e15; + protected override decimal FemtowattsInOneWatt => 1e15m; - protected override double GigajoulesPerHourInOneWatt => 3600e-9; + protected override decimal GigajoulesPerHourInOneWatt => 3600e-9m; - protected override double PicowattsInOneWatt => 1e12; + protected override decimal PicowattsInOneWatt => 1e12m; - protected override double NanowattsInOneWatt => 1e9; + protected override decimal NanowattsInOneWatt => 1e9m; - protected override double MicrowattsInOneWatt => 1e6; + protected override decimal MicrowattsInOneWatt => 1e6m; - protected override double MillijoulesPerHourInOneWatt => 3600e3; + protected override decimal MillijoulesPerHourInOneWatt => 3600e3m; - protected override double MilliwattsInOneWatt => 1e3; + protected override decimal MilliwattsInOneWatt => 1e3m; - protected override double DeciwattsInOneWatt => 1e1; + protected override decimal DeciwattsInOneWatt => 1e1m; - protected override double WattsInOneWatt => 1; + protected override decimal WattsInOneWatt => 1; - protected override double DecawattsInOneWatt => 1e-1; + protected override decimal DecawattsInOneWatt => 1e-1m; - protected override double KilojoulesPerHourInOneWatt => 3600e-3; + protected override decimal KilojoulesPerHourInOneWatt => 3600e-3m; - protected override double KilowattsInOneWatt => 1e-3; + protected override decimal KilowattsInOneWatt => 1e-3m; - protected override double MegajoulesPerHourInOneWatt => 3600e-6; + protected override decimal MegajoulesPerHourInOneWatt => 3600e-6m; - protected override double MegawattsInOneWatt => 1e-6; + protected override decimal MegawattsInOneWatt => 1e-6m; - protected override double GigawattsInOneWatt => 1e-9; + protected override decimal GigawattsInOneWatt => 1e-9m; - protected override double TerawattsInOneWatt => 1e-12; + protected override decimal TerawattsInOneWatt => 1e-12m; - protected override double PetawattsInOneWatt => 1e-15; + protected override decimal PetawattsInOneWatt => 1e-15m; - protected override double JoulesPerHourInOneWatt => 3600; + protected override decimal JoulesPerHourInOneWatt => 3600; - protected override double KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3; + protected override decimal KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3m; - protected override double MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6; + protected override decimal BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4m; - protected override double BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4; + protected override decimal MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6m; - protected override double BritishThermalUnitsPerHourInOneWatt => 3.412141633; + protected override decimal BritishThermalUnitsPerHourInOneWatt => 3.412141633m; - protected override double ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279; + protected override decimal ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279m; - protected override double HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719; + protected override decimal HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719m; - protected override double MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992; + protected override decimal MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992m; - protected override double MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425; + protected override decimal MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425m; [Fact] public void DurationTimesPowerEqualsEnergy() diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index 15fb16bb45..4da3858304 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -70,13 +70,13 @@ public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption() public void SpecificEnergyTimesMassFlowEqualsPower() { Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0); - Assert.Equal(200d, power.Watts); + Assert.Equal(200m, power.Watts); } [Fact] public void SpecificEnergyTimesBrakeSpecificFuelConsumptionEqualsEnergy() { - double value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0); + double value = (double)(SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0)); Assert.Equal(200d, value); } } diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index cafdfc75ae..c64a1af059 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -17,7 +17,7 @@ public HowMuch(double value, HowMuchUnit unit) Enum IQuantity.Unit => Unit; public HowMuchUnit Unit { get; } - public double Value { get; } + public QuantityValue Value { get; } #region IQuantity @@ -38,13 +38,13 @@ public HowMuch(double value, HowMuchUnit unit) Zero, BaseDimensions.Dimensionless); - public double As(Enum unit) => Convert.ToDouble(unit); + public QuantityValue As(Enum unit) => Convert.ToDouble(unit); - public double As(UnitSystem unitSystem) => throw new NotImplementedException(); + public QuantityValue As(UnitSystem unitSystem) => throw new NotImplementedException(); public IQuantity ToUnit(Enum unit) { - if (unit is HowMuchUnit howMuchUnit) return new HowMuch(As(unit), howMuchUnit); + if (unit is HowMuchUnit howMuchUnit) return new HowMuch((double)As(unit), howMuchUnit); throw new ArgumentException("Must be of type HowMuchUnit.", nameof(unit)); } diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs index 841c9b162b..6b9842d0aa 100644 --- a/UnitsNet.Tests/DecimalOverloadTests.cs +++ b/UnitsNet.Tests/DecimalOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorre public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue() { Power power = Power.FromWatts(1m); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index cda0f506b1..95bebe55e5 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -11,11 +11,11 @@ internal class DummyIQuantity : IQuantity public Enum Unit => throw new NotImplementedException(); - public double Value => throw new NotImplementedException(); + public QuantityValue Value => throw new NotImplementedException(); - public double As(Enum unit ) => throw new NotImplementedException(); + public QuantityValue As(Enum unit ) => throw new NotImplementedException(); - public double As(UnitSystem unitSystem ) => throw new NotImplementedException(); + public QuantityValue As(UnitSystem unitSystem ) => throw new NotImplementedException(); public string ToString(IFormatProvider? provider) => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index f70180cba6..a525d6afba 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class AccelerationTestsBase : QuantityTestsBase protected abstract double StandardGravityInOneMeterPerSecondSquared { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double DecimetersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double FeetPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double InchesPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double KilometersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double KnotsPerHourTolerance { get { return 1e-5; } } - protected virtual double KnotsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double KnotsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MetersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double MicrometersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double MillimetersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double MillistandardGravityTolerance { get { return 1e-5; } } - protected virtual double NanometersPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double StandardGravityTolerance { get { return 1e-5; } } + protected virtual double CentimetersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double DecimetersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double FeetPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double InchesPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double KilometersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double KnotsPerHourTolerance { get { return 1E-5; } } + protected virtual double KnotsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double KnotsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MetersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double MicrometersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double MillimetersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double MillistandardGravityTolerance { get { return 1E-5; } } + protected virtual double NanometersPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double StandardGravityTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AccelerationUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -993,14 +993,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AccelerationUnit unit) { - var inBaseUnits = Acceleration.From(1.0, Acceleration.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Acceleration.From(1.0, Acceleration.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Acceleration.From(1.0, Acceleration.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AccelerationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AccelerationUnit unit) @@ -1014,8 +1021,8 @@ public void ToUnit_WithSameUnits_AreEqual(AccelerationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AccelerationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Acceleration.Units.Where(u => u != Acceleration.BaseUnit).DefaultIfEmpty(Acceleration.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Acceleration.Units.First(u => u != Acceleration.BaseUnit); var quantity = Acceleration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1249,8 +1256,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1284,36 +1292,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1326,22 +1339,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Acceleration.FromMetersPerSecondSquared(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1383,7 +1399,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(new {Acceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Acceleration.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 52cc5fa708..5d469e8a46 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -55,21 +55,21 @@ public abstract partial class AmountOfSubstanceTestsBase : QuantityTestsBase protected abstract double PoundMolesInOneMole { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimolesTolerance { get { return 1e-5; } } - protected virtual double CentipoundMolesTolerance { get { return 1e-5; } } - protected virtual double DecimolesTolerance { get { return 1e-5; } } - protected virtual double DecipoundMolesTolerance { get { return 1e-5; } } - protected virtual double KilomolesTolerance { get { return 1e-5; } } - protected virtual double KilopoundMolesTolerance { get { return 1e-5; } } - protected virtual double MegamolesTolerance { get { return 1e-5; } } - protected virtual double MicromolesTolerance { get { return 1e-5; } } - protected virtual double MicropoundMolesTolerance { get { return 1e-5; } } - protected virtual double MillimolesTolerance { get { return 1e-5; } } - protected virtual double MillipoundMolesTolerance { get { return 1e-5; } } - protected virtual double MolesTolerance { get { return 1e-5; } } - protected virtual double NanomolesTolerance { get { return 1e-5; } } - protected virtual double NanopoundMolesTolerance { get { return 1e-5; } } - protected virtual double PoundMolesTolerance { get { return 1e-5; } } + protected virtual double CentimolesTolerance { get { return 1E-5; } } + protected virtual double CentipoundMolesTolerance { get { return 1E-5; } } + protected virtual double DecimolesTolerance { get { return 1E-5; } } + protected virtual double DecipoundMolesTolerance { get { return 1E-5; } } + protected virtual double KilomolesTolerance { get { return 1E-5; } } + protected virtual double KilopoundMolesTolerance { get { return 1E-5; } } + protected virtual double MegamolesTolerance { get { return 1E-5; } } + protected virtual double MicromolesTolerance { get { return 1E-5; } } + protected virtual double MicropoundMolesTolerance { get { return 1E-5; } } + protected virtual double MillimolesTolerance { get { return 1E-5; } } + protected virtual double MillipoundMolesTolerance { get { return 1E-5; } } + protected virtual double MolesTolerance { get { return 1E-5; } } + protected virtual double NanomolesTolerance { get { return 1E-5; } } + protected virtual double NanopoundMolesTolerance { get { return 1E-5; } } + protected virtual double PoundMolesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AmountOfSubstanceUnit unit) @@ -298,7 +298,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -669,14 +669,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AmountOfSubstanceUnit unit) { - var inBaseUnits = AmountOfSubstance.From(1.0, AmountOfSubstance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = AmountOfSubstance.From(1.0, AmountOfSubstance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = AmountOfSubstance.From(1.0, AmountOfSubstance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AmountOfSubstanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AmountOfSubstanceUnit unit) @@ -690,8 +697,8 @@ public void ToUnit_WithSameUnits_AreEqual(AmountOfSubstanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AmountOfSubstanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AmountOfSubstance.Units.Where(u => u != AmountOfSubstance.BaseUnit).DefaultIfEmpty(AmountOfSubstance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = AmountOfSubstance.Units.First(u => u != AmountOfSubstance.BaseUnit); var quantity = AmountOfSubstance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -928,8 +935,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -963,36 +971,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1005,22 +1018,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = AmountOfSubstance.FromMoles(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1062,7 +1078,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(new {AmountOfSubstance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(AmountOfSubstance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 53181b282b..20d580e082 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class AmplitudeRatioTestsBase : QuantityTestsBase protected abstract double DecibelVoltsInOneDecibelVolt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecibelMicrovoltsTolerance { get { return 1e-5; } } - protected virtual double DecibelMillivoltsTolerance { get { return 1e-5; } } - protected virtual double DecibelsUnloadedTolerance { get { return 1e-5; } } - protected virtual double DecibelVoltsTolerance { get { return 1e-5; } } + protected virtual double DecibelMicrovoltsTolerance { get { return 1E-5; } } + protected virtual double DecibelMillivoltsTolerance { get { return 1E-5; } } + protected virtual double DecibelsUnloadedTolerance { get { return 1E-5; } } + protected virtual double DecibelVoltsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AmplitudeRatioUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AmplitudeRatioUnit unit) { - var inBaseUnits = AmplitudeRatio.From(1.0, AmplitudeRatio.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = AmplitudeRatio.From(1.0, AmplitudeRatio.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = AmplitudeRatio.From(1.0, AmplitudeRatio.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AmplitudeRatioUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AmplitudeRatioUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(AmplitudeRatioUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AmplitudeRatioUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AmplitudeRatio.Units.Where(u => u != AmplitudeRatio.BaseUnit).DefaultIfEmpty(AmplitudeRatio.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = AmplitudeRatio.Units.First(u => u != AmplitudeRatio.BaseUnit); var quantity = AmplitudeRatio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -547,8 +554,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -582,36 +590,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -624,22 +637,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = AmplitudeRatio.FromDecibelVolts(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -681,7 +697,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(new {AmplitudeRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(AmplitudeRatio.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index b6f83dd254..8d1a7c53f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -56,22 +56,22 @@ public abstract partial class AngleTestsBase : QuantityTestsBase protected abstract double TiltInOneDegree { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double ArcminutesTolerance { get { return 1e-5; } } - protected virtual double ArcsecondsTolerance { get { return 1e-5; } } - protected virtual double CentiradiansTolerance { get { return 1e-5; } } - protected virtual double DeciradiansTolerance { get { return 1e-5; } } - protected virtual double DegreesTolerance { get { return 1e-5; } } - protected virtual double GradiansTolerance { get { return 1e-5; } } - protected virtual double MicrodegreesTolerance { get { return 1e-5; } } - protected virtual double MicroradiansTolerance { get { return 1e-5; } } - protected virtual double MillidegreesTolerance { get { return 1e-5; } } - protected virtual double MilliradiansTolerance { get { return 1e-5; } } - protected virtual double NanodegreesTolerance { get { return 1e-5; } } - protected virtual double NanoradiansTolerance { get { return 1e-5; } } - protected virtual double NatoMilsTolerance { get { return 1e-5; } } - protected virtual double RadiansTolerance { get { return 1e-5; } } - protected virtual double RevolutionsTolerance { get { return 1e-5; } } - protected virtual double TiltTolerance { get { return 1e-5; } } + protected virtual double ArcminutesTolerance { get { return 1E-5; } } + protected virtual double ArcsecondsTolerance { get { return 1E-5; } } + protected virtual double CentiradiansTolerance { get { return 1E-5; } } + protected virtual double DeciradiansTolerance { get { return 1E-5; } } + protected virtual double DegreesTolerance { get { return 1E-5; } } + protected virtual double GradiansTolerance { get { return 1E-5; } } + protected virtual double MicrodegreesTolerance { get { return 1E-5; } } + protected virtual double MicroradiansTolerance { get { return 1E-5; } } + protected virtual double MillidegreesTolerance { get { return 1E-5; } } + protected virtual double MilliradiansTolerance { get { return 1E-5; } } + protected virtual double NanodegreesTolerance { get { return 1E-5; } } + protected virtual double NanoradiansTolerance { get { return 1E-5; } } + protected virtual double NatoMilsTolerance { get { return 1E-5; } } + protected virtual double RadiansTolerance { get { return 1E-5; } } + protected virtual double RevolutionsTolerance { get { return 1E-5; } } + protected virtual double TiltTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AngleUnit unit) @@ -308,7 +308,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1253,14 +1253,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AngleUnit unit) { - var inBaseUnits = Angle.From(1.0, Angle.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Angle.From(1.0, Angle.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Angle.From(1.0, Angle.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AngleUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AngleUnit unit) @@ -1274,8 +1281,8 @@ public void ToUnit_WithSameUnits_AreEqual(AngleUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AngleUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Angle.Units.Where(u => u != Angle.BaseUnit).DefaultIfEmpty(Angle.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Angle.Units.First(u => u != Angle.BaseUnit); var quantity = Angle.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1515,8 +1522,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1550,36 +1558,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1592,22 +1605,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Angle.FromDegrees(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Angle.FromDegrees(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1649,7 +1665,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Angle.FromDegrees(1.0); - Assert.Equal(new {Angle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Angle.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index e84c7b0aad..14687f0e3a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ApparentEnergyTestsBase : QuantityTestsBase protected abstract double VoltampereHoursInOneVoltampereHour { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltampereHoursTolerance { get { return 1e-5; } } - protected virtual double MegavoltampereHoursTolerance { get { return 1e-5; } } - protected virtual double VoltampereHoursTolerance { get { return 1e-5; } } + protected virtual double KilovoltampereHoursTolerance { get { return 1E-5; } } + protected virtual double MegavoltampereHoursTolerance { get { return 1E-5; } } + protected virtual double VoltampereHoursTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ApparentEnergyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ApparentEnergyUnit unit) { - var inBaseUnits = ApparentEnergy.From(1.0, ApparentEnergy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ApparentEnergy.From(1.0, ApparentEnergy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ApparentEnergy.From(1.0, ApparentEnergy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ApparentEnergyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ApparentEnergyUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(ApparentEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ApparentEnergyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ApparentEnergy.Units.Where(u => u != ApparentEnergy.BaseUnit).DefaultIfEmpty(ApparentEnergy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ApparentEnergy.Units.First(u => u != ApparentEnergy.BaseUnit); var quantity = ApparentEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ApparentEnergy.FromVoltampereHours(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(new {ApparentEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ApparentEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index b650b9bcd9..38ce76774c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ApparentPowerTestsBase : QuantityTestsBase protected abstract double VoltamperesInOneVoltampere { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigavoltamperesTolerance { get { return 1e-5; } } - protected virtual double KilovoltamperesTolerance { get { return 1e-5; } } - protected virtual double MegavoltamperesTolerance { get { return 1e-5; } } - protected virtual double VoltamperesTolerance { get { return 1e-5; } } + protected virtual double GigavoltamperesTolerance { get { return 1E-5; } } + protected virtual double KilovoltamperesTolerance { get { return 1E-5; } } + protected virtual double MegavoltamperesTolerance { get { return 1E-5; } } + protected virtual double VoltamperesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ApparentPowerUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ApparentPowerUnit unit) { - var inBaseUnits = ApparentPower.From(1.0, ApparentPower.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ApparentPower.From(1.0, ApparentPower.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ApparentPower.From(1.0, ApparentPower.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ApparentPowerUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ApparentPowerUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(ApparentPowerUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ApparentPowerUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ApparentPower.Units.Where(u => u != ApparentPower.BaseUnit).DefaultIfEmpty(ApparentPower.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ApparentPower.Units.First(u => u != ApparentPower.BaseUnit); var quantity = ApparentPower.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ApparentPower.FromVoltamperes(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(new {ApparentPower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ApparentPower.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index a9585c99c0..6dcc5c0bc3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaDensityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AreaDensityUnit unit) { - var inBaseUnits = AreaDensity.From(1.0, AreaDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = AreaDensity.From(1.0, AreaDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = AreaDensity.From(1.0, AreaDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AreaDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AreaDensityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(AreaDensityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AreaDensity.Units.Where(u => u != AreaDensity.BaseUnit).DefaultIfEmpty(AreaDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = AreaDensity.Units.First(u => u != AreaDensity.BaseUnit); var quantity = AreaDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(new {AreaDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(AreaDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 2321a0aadf..e511ec6831 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class AreaMomentOfInertiaTestsBase : QuantityTestsBase protected abstract double MillimetersToTheFourthInOneMeterToTheFourth { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersToTheFourthTolerance { get { return 1e-5; } } - protected virtual double DecimetersToTheFourthTolerance { get { return 1e-5; } } - protected virtual double FeetToTheFourthTolerance { get { return 1e-5; } } - protected virtual double InchesToTheFourthTolerance { get { return 1e-5; } } - protected virtual double MetersToTheFourthTolerance { get { return 1e-5; } } - protected virtual double MillimetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double CentimetersToTheFourthTolerance { get { return 1E-5; } } + protected virtual double DecimetersToTheFourthTolerance { get { return 1E-5; } } + protected virtual double FeetToTheFourthTolerance { get { return 1E-5; } } + protected virtual double InchesToTheFourthTolerance { get { return 1E-5; } } + protected virtual double MetersToTheFourthTolerance { get { return 1E-5; } } + protected virtual double MillimetersToTheFourthTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaMomentOfInertiaUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -529,14 +529,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AreaMomentOfInertiaUnit unit) { - var inBaseUnits = AreaMomentOfInertia.From(1.0, AreaMomentOfInertia.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = AreaMomentOfInertia.From(1.0, AreaMomentOfInertia.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = AreaMomentOfInertia.From(1.0, AreaMomentOfInertia.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AreaMomentOfInertiaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AreaMomentOfInertiaUnit unit) @@ -550,8 +557,8 @@ public void ToUnit_WithSameUnits_AreEqual(AreaMomentOfInertiaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaMomentOfInertiaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = AreaMomentOfInertia.Units.Where(u => u != AreaMomentOfInertia.BaseUnit).DefaultIfEmpty(AreaMomentOfInertia.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = AreaMomentOfInertia.Units.First(u => u != AreaMomentOfInertia.BaseUnit); var quantity = AreaMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -761,8 +768,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -796,36 +804,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -838,22 +851,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -895,7 +911,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(new {AreaMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(AreaMomentOfInertia.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 39bffa73de..5d06c6612e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class AreaTestsBase : QuantityTestsBase protected abstract double UsSurveySquareFeetInOneSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AcresTolerance { get { return 1e-5; } } - protected virtual double HectaresTolerance { get { return 1e-5; } } - protected virtual double SquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double SquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double SquareFeetTolerance { get { return 1e-5; } } - protected virtual double SquareInchesTolerance { get { return 1e-5; } } - protected virtual double SquareKilometersTolerance { get { return 1e-5; } } - protected virtual double SquareMetersTolerance { get { return 1e-5; } } - protected virtual double SquareMicrometersTolerance { get { return 1e-5; } } - protected virtual double SquareMilesTolerance { get { return 1e-5; } } - protected virtual double SquareMillimetersTolerance { get { return 1e-5; } } - protected virtual double SquareNauticalMilesTolerance { get { return 1e-5; } } - protected virtual double SquareYardsTolerance { get { return 1e-5; } } - protected virtual double UsSurveySquareFeetTolerance { get { return 1e-5; } } + protected virtual double AcresTolerance { get { return 1E-5; } } + protected virtual double HectaresTolerance { get { return 1E-5; } } + protected virtual double SquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double SquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double SquareFeetTolerance { get { return 1E-5; } } + protected virtual double SquareInchesTolerance { get { return 1E-5; } } + protected virtual double SquareKilometersTolerance { get { return 1E-5; } } + protected virtual double SquareMetersTolerance { get { return 1E-5; } } + protected virtual double SquareMicrometersTolerance { get { return 1E-5; } } + protected virtual double SquareMilesTolerance { get { return 1E-5; } } + protected virtual double SquareMillimetersTolerance { get { return 1E-5; } } + protected virtual double SquareNauticalMilesTolerance { get { return 1E-5; } } + protected virtual double SquareYardsTolerance { get { return 1E-5; } } + protected virtual double UsSurveySquareFeetTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1283,14 +1283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AreaUnit unit) { - var inBaseUnits = Area.From(1.0, Area.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Area.From(1.0, Area.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Area.From(1.0, Area.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(AreaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AreaUnit unit) @@ -1304,8 +1311,8 @@ public void ToUnit_WithSameUnits_AreEqual(AreaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Area.Units.Where(u => u != Area.BaseUnit).DefaultIfEmpty(Area.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Area.Units.First(u => u != Area.BaseUnit); var quantity = Area.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1539,8 +1546,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1574,36 +1582,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1616,22 +1629,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Area.FromSquareMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Area.FromSquareMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1673,7 +1689,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(new {Area.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Area.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index a26e942ea8..756eab3893 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class BitRateTestsBase : QuantityTestsBase { - protected abstract double BitsPerSecondInOneBitPerSecond { get; } - protected abstract double BytesPerSecondInOneBitPerSecond { get; } - protected abstract double ExabitsPerSecondInOneBitPerSecond { get; } - protected abstract double ExabytesPerSecondInOneBitPerSecond { get; } - protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; } - protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; } - protected abstract double GibibitsPerSecondInOneBitPerSecond { get; } - protected abstract double GibibytesPerSecondInOneBitPerSecond { get; } - protected abstract double GigabitsPerSecondInOneBitPerSecond { get; } - protected abstract double GigabytesPerSecondInOneBitPerSecond { get; } - protected abstract double KibibitsPerSecondInOneBitPerSecond { get; } - protected abstract double KibibytesPerSecondInOneBitPerSecond { get; } - protected abstract double KilobitsPerSecondInOneBitPerSecond { get; } - protected abstract double KilobytesPerSecondInOneBitPerSecond { get; } - protected abstract double MebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double MebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double MegabitsPerSecondInOneBitPerSecond { get; } - protected abstract double MegabytesPerSecondInOneBitPerSecond { get; } - protected abstract double PebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double PebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double PetabitsPerSecondInOneBitPerSecond { get; } - protected abstract double PetabytesPerSecondInOneBitPerSecond { get; } - protected abstract double TebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double TebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double TerabitsPerSecondInOneBitPerSecond { get; } - protected abstract double TerabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal BitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal BytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExbibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExbibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal GibibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal GibibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal GigabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal GigabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal KibibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal KibibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal KilobitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal KilobytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal MebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal MebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal MegabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal MegabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal PebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal PebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal PetabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal PetabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal TebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal TebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal TerabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal TerabytesPerSecondInOneBitPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double BytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual decimal BitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal BytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal ExabitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal ExabytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal ExbibitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal ExbibytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal GibibitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal GibibytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal GigabitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal GigabytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal KibibitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal KibibytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal KilobitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal KilobytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal MebibitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal MebibytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal MegabitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal MegabytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal PebibitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal PebibytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal PetabitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal PetabytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal TebibitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal TebibytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal TerabitsPerSecondTolerance { get { return 1E-9m; } } + protected virtual decimal TerabytesPerSecondTolerance { get { return 1E-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BitRateUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(BitRateUnit unit) { return unit switch { @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1352,14 +1352,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(BitRateUnit unit) { - var inBaseUnits = BitRate.From(1.0, BitRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = BitRate.From(1.0, BitRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = BitRate.From(1.0, BitRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(BitRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(BitRateUnit unit) @@ -1373,8 +1380,8 @@ public void ToUnit_WithSameUnits_AreEqual(BitRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(BitRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = BitRate.Units.Where(u => u != BitRate.BaseUnit).DefaultIfEmpty(BitRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = BitRate.Units.First(u => u != BitRate.BaseUnit); var quantity = BitRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1644,8 +1651,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1679,36 +1687,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1721,22 +1734,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = BitRate.FromBitsPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1778,7 +1794,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(new {BitRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(BitRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 6e1bc6b653..3a3de29b37 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class BrakeSpecificFuelConsumptionTestsBase : QuantityTe protected abstract double PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerKiloWattHourTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerJouleTolerance { get { return 1e-5; } } - protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1e-5; } } + protected virtual double GramsPerKiloWattHourTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerJouleTolerance { get { return 1E-5; } } + protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BrakeSpecificFuelConsumptionUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(BrakeSpecificFuelConsumptionUnit unit) { - var inBaseUnits = BrakeSpecificFuelConsumption.From(1.0, BrakeSpecificFuelConsumption.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = BrakeSpecificFuelConsumption.From(1.0, BrakeSpecificFuelConsumption.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = BrakeSpecificFuelConsumption.From(1.0, BrakeSpecificFuelConsumption.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(BrakeSpecificFuelConsumptionUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(BrakeSpecificFuelConsumptionUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(BrakeSpecificFuelConsumptionUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(BrakeSpecificFuelConsumptionUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = BrakeSpecificFuelConsumption.Units.Where(u => u != BrakeSpecificFuelConsumption.BaseUnit).DefaultIfEmpty(BrakeSpecificFuelConsumption.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = BrakeSpecificFuelConsumption.Units.First(u => u != BrakeSpecificFuelConsumption.BaseUnit); var quantity = BrakeSpecificFuelConsumption.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(new {BrakeSpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(BrakeSpecificFuelConsumption.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index e6d03a76dc..f3e59bbd3b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class CapacitanceTestsBase : QuantityTestsBase protected abstract double PicofaradsInOneFarad { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double FaradsTolerance { get { return 1e-5; } } - protected virtual double KilofaradsTolerance { get { return 1e-5; } } - protected virtual double MegafaradsTolerance { get { return 1e-5; } } - protected virtual double MicrofaradsTolerance { get { return 1e-5; } } - protected virtual double MillifaradsTolerance { get { return 1e-5; } } - protected virtual double NanofaradsTolerance { get { return 1e-5; } } - protected virtual double PicofaradsTolerance { get { return 1e-5; } } + protected virtual double FaradsTolerance { get { return 1E-5; } } + protected virtual double KilofaradsTolerance { get { return 1E-5; } } + protected virtual double MegafaradsTolerance { get { return 1E-5; } } + protected virtual double MicrofaradsTolerance { get { return 1E-5; } } + protected virtual double MillifaradsTolerance { get { return 1E-5; } } + protected virtual double NanofaradsTolerance { get { return 1E-5; } } + protected virtual double PicofaradsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(CapacitanceUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -397,14 +397,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(CapacitanceUnit unit) { - var inBaseUnits = Capacitance.From(1.0, Capacitance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Capacitance.From(1.0, Capacitance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Capacitance.From(1.0, Capacitance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(CapacitanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(CapacitanceUnit unit) @@ -418,8 +425,8 @@ public void ToUnit_WithSameUnits_AreEqual(CapacitanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CapacitanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Capacitance.Units.Where(u => u != Capacitance.BaseUnit).DefaultIfEmpty(Capacitance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Capacitance.Units.First(u => u != Capacitance.BaseUnit); var quantity = Capacitance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -632,8 +639,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -667,36 +675,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -709,22 +722,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Capacitance.FromFarads(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Capacitance.FromFarads(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -766,7 +782,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(new {Capacitance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Capacitance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 01b59f24d5..8cb26ee1e6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class CoefficientOfThermalExpansionTestsBase : QuantityT protected abstract double InverseKelvinInOneInverseKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double InverseDegreeFahrenheitTolerance { get { return 1e-5; } } - protected virtual double InverseKelvinTolerance { get { return 1e-5; } } + protected virtual double InverseDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double InverseDegreeFahrenheitTolerance { get { return 1E-5; } } + protected virtual double InverseKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(CoefficientOfThermalExpansionUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -355,14 +355,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(CoefficientOfThermalExpansionUnit unit) { - var inBaseUnits = CoefficientOfThermalExpansion.From(1.0, CoefficientOfThermalExpansion.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = CoefficientOfThermalExpansion.From(1.0, CoefficientOfThermalExpansion.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = CoefficientOfThermalExpansion.From(1.0, CoefficientOfThermalExpansion.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(CoefficientOfThermalExpansionUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(CoefficientOfThermalExpansionUnit unit) @@ -376,8 +383,8 @@ public void ToUnit_WithSameUnits_AreEqual(CoefficientOfThermalExpansionUnit unit [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CoefficientOfThermalExpansionUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = CoefficientOfThermalExpansion.Units.Where(u => u != CoefficientOfThermalExpansion.BaseUnit).DefaultIfEmpty(CoefficientOfThermalExpansion.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = CoefficientOfThermalExpansion.Units.First(u => u != CoefficientOfThermalExpansion.BaseUnit); var quantity = CoefficientOfThermalExpansion.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -578,8 +585,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -613,36 +621,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -655,22 +668,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -712,7 +728,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(new {CoefficientOfThermalExpansion.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(CoefficientOfThermalExpansion.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index aaf1331202..32d816d194 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class CompressibilityTestsBase : QuantityTestsBase protected abstract double InversePoundsForcePerSquareInchInOneInversePascal { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseAtmospheresTolerance { get { return 1e-5; } } - protected virtual double InverseBarsTolerance { get { return 1e-5; } } - protected virtual double InverseKilopascalsTolerance { get { return 1e-5; } } - protected virtual double InverseMegapascalsTolerance { get { return 1e-5; } } - protected virtual double InverseMillibarsTolerance { get { return 1e-5; } } - protected virtual double InversePascalsTolerance { get { return 1e-5; } } - protected virtual double InversePoundsForcePerSquareInchTolerance { get { return 1e-5; } } + protected virtual double InverseAtmospheresTolerance { get { return 1E-5; } } + protected virtual double InverseBarsTolerance { get { return 1E-5; } } + protected virtual double InverseKilopascalsTolerance { get { return 1E-5; } } + protected virtual double InverseMegapascalsTolerance { get { return 1E-5; } } + protected virtual double InverseMillibarsTolerance { get { return 1E-5; } } + protected virtual double InversePascalsTolerance { get { return 1E-5; } } + protected virtual double InversePoundsForcePerSquareInchTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(CompressibilityUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -587,14 +587,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(CompressibilityUnit unit) { - var inBaseUnits = Compressibility.From(1.0, Compressibility.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Compressibility.From(1.0, Compressibility.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Compressibility.From(1.0, Compressibility.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(CompressibilityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(CompressibilityUnit unit) @@ -608,8 +615,8 @@ public void ToUnit_WithSameUnits_AreEqual(CompressibilityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CompressibilityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Compressibility.Units.Where(u => u != Compressibility.BaseUnit).DefaultIfEmpty(Compressibility.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Compressibility.Units.First(u => u != Compressibility.BaseUnit); var quantity = Compressibility.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -822,8 +829,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -857,36 +865,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -899,22 +912,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Compressibility.FromInversePascals(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -956,7 +972,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal(new {Compressibility.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Compressibility.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index a37f498d85..4533308beb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -91,57 +91,57 @@ public abstract partial class DensityTestsBase : QuantityTestsBase protected abstract double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double GramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double GramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double KilopoundsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerDeciLiterTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double PoundsPerImperialGallonTolerance { get { return 1e-5; } } - protected virtual double PoundsPerUSGallonTolerance { get { return 1e-5; } } - protected virtual double SlugsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double SlugsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double SlugsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double SlugsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double SlugsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double GramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double GramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double KilopoundsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double KilopoundsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerDeciLiterTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double PoundsPerImperialGallonTolerance { get { return 1E-5; } } + protected virtual double PoundsPerUSGallonTolerance { get { return 1E-5; } } + protected virtual double SlugsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double SlugsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double SlugsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double SlugsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double SlugsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(DensityUnit unit) @@ -658,7 +658,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2011,14 +2011,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(DensityUnit unit) { - var inBaseUnits = Density.From(1.0, Density.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Density.From(1.0, Density.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Density.From(1.0, Density.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(DensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(DensityUnit unit) @@ -2032,8 +2039,8 @@ public void ToUnit_WithSameUnits_AreEqual(DensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Density.Units.Where(u => u != Density.BaseUnit).DefaultIfEmpty(Density.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Density.Units.First(u => u != Density.BaseUnit); var quantity = Density.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2378,8 +2385,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2413,36 +2421,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2455,22 +2468,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Density.FromKilogramsPerCubicMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2512,7 +2528,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(new {Density.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Density.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 528fb07f8f..3868ee2b75 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class DurationTestsBase : QuantityTestsBase protected abstract double Years365InOneSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DaysTolerance { get { return 1e-5; } } - protected virtual double HoursTolerance { get { return 1e-5; } } - protected virtual double JulianYearsTolerance { get { return 1e-5; } } - protected virtual double MicrosecondsTolerance { get { return 1e-5; } } - protected virtual double MillisecondsTolerance { get { return 1e-5; } } - protected virtual double MinutesTolerance { get { return 1e-5; } } - protected virtual double Months30Tolerance { get { return 1e-5; } } - protected virtual double NanosecondsTolerance { get { return 1e-5; } } - protected virtual double SecondsTolerance { get { return 1e-5; } } - protected virtual double WeeksTolerance { get { return 1e-5; } } - protected virtual double Years365Tolerance { get { return 1e-5; } } + protected virtual double DaysTolerance { get { return 1E-5; } } + protected virtual double HoursTolerance { get { return 1E-5; } } + protected virtual double JulianYearsTolerance { get { return 1E-5; } } + protected virtual double MicrosecondsTolerance { get { return 1E-5; } } + protected virtual double MillisecondsTolerance { get { return 1E-5; } } + protected virtual double MinutesTolerance { get { return 1E-5; } } + protected virtual double Months30Tolerance { get { return 1E-5; } } + protected virtual double NanosecondsTolerance { get { return 1E-5; } } + protected virtual double SecondsTolerance { get { return 1E-5; } } + protected virtual double WeeksTolerance { get { return 1E-5; } } + protected virtual double Years365Tolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(DurationUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1731,14 +1731,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(DurationUnit unit) { - var inBaseUnits = Duration.From(1.0, Duration.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Duration.From(1.0, Duration.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Duration.From(1.0, Duration.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(DurationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(DurationUnit unit) @@ -1752,8 +1759,8 @@ public void ToUnit_WithSameUnits_AreEqual(DurationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DurationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Duration.Units.Where(u => u != Duration.BaseUnit).DefaultIfEmpty(Duration.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Duration.Units.First(u => u != Duration.BaseUnit); var quantity = Duration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1978,8 +1985,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2013,36 +2021,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2055,22 +2068,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Duration.FromSeconds(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Duration.FromSeconds(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2112,7 +2128,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(new {Duration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Duration.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index ee6a1a3d95..6cf20a34dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class DynamicViscosityTestsBase : QuantityTestsBase protected abstract double ReynsInOneNewtonSecondPerMeterSquared { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentipoiseTolerance { get { return 1e-5; } } - protected virtual double MicropascalSecondsTolerance { get { return 1e-5; } } - protected virtual double MillipascalSecondsTolerance { get { return 1e-5; } } - protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1e-5; } } - protected virtual double PascalSecondsTolerance { get { return 1e-5; } } - protected virtual double PoiseTolerance { get { return 1e-5; } } - protected virtual double PoundsForceSecondPerSquareFootTolerance { get { return 1e-5; } } - protected virtual double PoundsForceSecondPerSquareInchTolerance { get { return 1e-5; } } - protected virtual double PoundsPerFootSecondTolerance { get { return 1e-5; } } - protected virtual double ReynsTolerance { get { return 1e-5; } } + protected virtual double CentipoiseTolerance { get { return 1E-5; } } + protected virtual double MicropascalSecondsTolerance { get { return 1E-5; } } + protected virtual double MillipascalSecondsTolerance { get { return 1E-5; } } + protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1E-5; } } + protected virtual double PascalSecondsTolerance { get { return 1E-5; } } + protected virtual double PoiseTolerance { get { return 1E-5; } } + protected virtual double PoundsForceSecondPerSquareFootTolerance { get { return 1E-5; } } + protected virtual double PoundsForceSecondPerSquareInchTolerance { get { return 1E-5; } } + protected virtual double PoundsPerFootSecondTolerance { get { return 1E-5; } } + protected virtual double ReynsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(DynamicViscosityUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -593,14 +593,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(DynamicViscosityUnit unit) { - var inBaseUnits = DynamicViscosity.From(1.0, DynamicViscosity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = DynamicViscosity.From(1.0, DynamicViscosity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = DynamicViscosity.From(1.0, DynamicViscosity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(DynamicViscosityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(DynamicViscosityUnit unit) @@ -614,8 +621,8 @@ public void ToUnit_WithSameUnits_AreEqual(DynamicViscosityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DynamicViscosityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = DynamicViscosity.Units.Where(u => u != DynamicViscosity.BaseUnit).DefaultIfEmpty(DynamicViscosity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = DynamicViscosity.Units.First(u => u != DynamicViscosity.BaseUnit); var quantity = DynamicViscosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -837,8 +844,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -872,36 +880,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -914,22 +927,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -971,7 +987,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(new {DynamicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(DynamicViscosity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index baf2955386..13bcf04bc8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ElectricAdmittanceTestsBase : QuantityTestsBase protected abstract double SiemensInOneSiemens { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double MicrosiemensTolerance { get { return 1e-5; } } - protected virtual double MillisiemensTolerance { get { return 1e-5; } } - protected virtual double NanosiemensTolerance { get { return 1e-5; } } - protected virtual double SiemensTolerance { get { return 1e-5; } } + protected virtual double MicrosiemensTolerance { get { return 1E-5; } } + protected virtual double MillisiemensTolerance { get { return 1E-5; } } + protected virtual double NanosiemensTolerance { get { return 1E-5; } } + protected virtual double SiemensTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricAdmittanceUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricAdmittanceUnit unit) { - var inBaseUnits = ElectricAdmittance.From(1.0, ElectricAdmittance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricAdmittance.From(1.0, ElectricAdmittance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricAdmittance.From(1.0, ElectricAdmittance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricAdmittanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricAdmittanceUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricAdmittanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricAdmittanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricAdmittance.Units.Where(u => u != ElectricAdmittance.BaseUnit).DefaultIfEmpty(ElectricAdmittance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricAdmittance.Units.First(u => u != ElectricAdmittance.BaseUnit); var quantity = ElectricAdmittance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricAdmittance.FromSiemens(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(new {ElectricAdmittance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricAdmittance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index e5f237ac25..97fc662ca0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class ElectricChargeDensityTestsBase : QuantityTestsBase protected abstract double CoulombsPerCubicMeterInOneCoulombPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CoulombsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double CoulombsPerCubicMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricChargeDensityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricChargeDensityUnit unit) { - var inBaseUnits = ElectricChargeDensity.From(1.0, ElectricChargeDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricChargeDensity.From(1.0, ElectricChargeDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricChargeDensity.From(1.0, ElectricChargeDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricChargeDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricChargeDensityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricChargeDensityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricChargeDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricChargeDensity.Units.Where(u => u != ElectricChargeDensity.BaseUnit).DefaultIfEmpty(ElectricChargeDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricChargeDensity.Units.First(u => u != ElectricChargeDensity.BaseUnit); var quantity = ElectricChargeDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(new {ElectricChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricChargeDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index ffd6b25293..b1583f9a0e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase protected abstract double MilliampereHoursInOneCoulomb { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmpereHoursTolerance { get { return 1e-5; } } - protected virtual double CoulombsTolerance { get { return 1e-5; } } - protected virtual double KiloampereHoursTolerance { get { return 1e-5; } } - protected virtual double MegaampereHoursTolerance { get { return 1e-5; } } - protected virtual double MilliampereHoursTolerance { get { return 1e-5; } } + protected virtual double AmpereHoursTolerance { get { return 1E-5; } } + protected virtual double CoulombsTolerance { get { return 1E-5; } } + protected virtual double KiloampereHoursTolerance { get { return 1E-5; } } + protected virtual double MegaampereHoursTolerance { get { return 1E-5; } } + protected virtual double MilliampereHoursTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricChargeUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -403,14 +403,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricChargeUnit unit) { - var inBaseUnits = ElectricCharge.From(1.0, ElectricCharge.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricCharge.From(1.0, ElectricCharge.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricCharge.From(1.0, ElectricCharge.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricChargeUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricChargeUnit unit) @@ -424,8 +431,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricChargeUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricChargeUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCharge.Units.Where(u => u != ElectricCharge.BaseUnit).DefaultIfEmpty(ElectricCharge.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricCharge.Units.First(u => u != ElectricCharge.BaseUnit); var quantity = ElectricCharge.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -632,8 +639,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -667,36 +675,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -709,22 +722,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricCharge.FromCoulombs(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -766,7 +782,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(new {ElectricCharge.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricCharge.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index d7e199bded..45c97940ed 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricConductanceTestsBase : QuantityTestsBase protected abstract double SiemensInOneSiemens { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double MicrosiemensTolerance { get { return 1e-5; } } - protected virtual double MillisiemensTolerance { get { return 1e-5; } } - protected virtual double SiemensTolerance { get { return 1e-5; } } + protected virtual double MicrosiemensTolerance { get { return 1E-5; } } + protected virtual double MillisiemensTolerance { get { return 1E-5; } } + protected virtual double SiemensTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricConductanceUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricConductanceUnit unit) { - var inBaseUnits = ElectricConductance.From(1.0, ElectricConductance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricConductance.From(1.0, ElectricConductance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricConductance.From(1.0, ElectricConductance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricConductanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricConductanceUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricConductanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricConductance.Units.Where(u => u != ElectricConductance.BaseUnit).DefaultIfEmpty(ElectricConductance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricConductance.Units.First(u => u != ElectricConductance.BaseUnit); var quantity = ElectricConductance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricConductance.FromSiemens(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(new {ElectricConductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricConductance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 1819849908..07497ee847 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricConductivityTestsBase : QuantityTestsBase protected abstract double SiemensPerMeterInOneSiemensPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double SiemensPerFootTolerance { get { return 1e-5; } } - protected virtual double SiemensPerInchTolerance { get { return 1e-5; } } - protected virtual double SiemensPerMeterTolerance { get { return 1e-5; } } + protected virtual double SiemensPerFootTolerance { get { return 1E-5; } } + protected virtual double SiemensPerInchTolerance { get { return 1E-5; } } + protected virtual double SiemensPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricConductivityUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricConductivityUnit unit) { - var inBaseUnits = ElectricConductivity.From(1.0, ElectricConductivity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricConductivity.From(1.0, ElectricConductivity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricConductivity.From(1.0, ElectricConductivity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricConductivityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricConductivityUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricConductivityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductivityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricConductivity.Units.Where(u => u != ElectricConductivity.BaseUnit).DefaultIfEmpty(ElectricConductivity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricConductivity.Units.First(u => u != ElectricConductivity.BaseUnit); var quantity = ElectricConductivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricConductivity.FromSiemensPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(new {ElectricConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricConductivity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 8269cdcded..23c9af5e3b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricCurrentDensityTestsBase : QuantityTestsBas protected abstract double AmperesPerSquareMeterInOneAmperePerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesPerSquareFootTolerance { get { return 1e-5; } } - protected virtual double AmperesPerSquareInchTolerance { get { return 1e-5; } } - protected virtual double AmperesPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double AmperesPerSquareFootTolerance { get { return 1E-5; } } + protected virtual double AmperesPerSquareInchTolerance { get { return 1E-5; } } + protected virtual double AmperesPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricCurrentDensityUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricCurrentDensityUnit unit) { - var inBaseUnits = ElectricCurrentDensity.From(1.0, ElectricCurrentDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricCurrentDensity.From(1.0, ElectricCurrentDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricCurrentDensity.From(1.0, ElectricCurrentDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricCurrentDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentDensityUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCurrentDensity.Units.Where(u => u != ElectricCurrentDensity.BaseUnit).DefaultIfEmpty(ElectricCurrentDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricCurrentDensity.Units.First(u => u != ElectricCurrentDensity.BaseUnit); var quantity = ElectricCurrentDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(new {ElectricCurrentDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricCurrentDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 415f793b1c..dacad49bc8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ElectricCurrentGradientTestsBase : QuantityTestsBa protected abstract double AmperesPerSecondInOneAmperePerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesPerMicrosecondTolerance { get { return 1e-5; } } - protected virtual double AmperesPerMillisecondTolerance { get { return 1e-5; } } - protected virtual double AmperesPerNanosecondTolerance { get { return 1e-5; } } - protected virtual double AmperesPerSecondTolerance { get { return 1e-5; } } + protected virtual double AmperesPerMicrosecondTolerance { get { return 1E-5; } } + protected virtual double AmperesPerMillisecondTolerance { get { return 1E-5; } } + protected virtual double AmperesPerNanosecondTolerance { get { return 1E-5; } } + protected virtual double AmperesPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricCurrentGradientUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricCurrentGradientUnit unit) { - var inBaseUnits = ElectricCurrentGradient.From(1.0, ElectricCurrentGradient.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricCurrentGradient.From(1.0, ElectricCurrentGradient.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricCurrentGradient.From(1.0, ElectricCurrentGradient.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricCurrentGradientUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentGradientUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentGradientUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentGradientUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCurrentGradient.Units.Where(u => u != ElectricCurrentGradient.BaseUnit).DefaultIfEmpty(ElectricCurrentGradient.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricCurrentGradient.Units.First(u => u != ElectricCurrentGradient.BaseUnit); var quantity = ElectricCurrentGradient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(new {ElectricCurrentGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricCurrentGradient.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 14be5a3b96..0c602d7e0f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -48,14 +48,14 @@ public abstract partial class ElectricCurrentTestsBase : QuantityTestsBase protected abstract double PicoamperesInOneAmpere { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesTolerance { get { return 1e-5; } } - protected virtual double CentiamperesTolerance { get { return 1e-5; } } - protected virtual double KiloamperesTolerance { get { return 1e-5; } } - protected virtual double MegaamperesTolerance { get { return 1e-5; } } - protected virtual double MicroamperesTolerance { get { return 1e-5; } } - protected virtual double MilliamperesTolerance { get { return 1e-5; } } - protected virtual double NanoamperesTolerance { get { return 1e-5; } } - protected virtual double PicoamperesTolerance { get { return 1e-5; } } + protected virtual double AmperesTolerance { get { return 1E-5; } } + protected virtual double CentiamperesTolerance { get { return 1E-5; } } + protected virtual double KiloamperesTolerance { get { return 1E-5; } } + protected virtual double MegaamperesTolerance { get { return 1E-5; } } + protected virtual double MicroamperesTolerance { get { return 1E-5; } } + protected virtual double MilliamperesTolerance { get { return 1E-5; } } + protected virtual double NanoamperesTolerance { get { return 1E-5; } } + protected virtual double PicoamperesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricCurrentUnit unit) @@ -228,7 +228,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -431,14 +431,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricCurrentUnit unit) { - var inBaseUnits = ElectricCurrent.From(1.0, ElectricCurrent.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricCurrent.From(1.0, ElectricCurrent.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricCurrent.From(1.0, ElectricCurrent.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricCurrentUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentUnit unit) @@ -452,8 +459,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricCurrent.Units.Where(u => u != ElectricCurrent.BaseUnit).DefaultIfEmpty(ElectricCurrent.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricCurrent.Units.First(u => u != ElectricCurrent.BaseUnit); var quantity = ElectricCurrent.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -669,8 +676,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -704,36 +712,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -746,22 +759,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricCurrent.FromAmperes(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -803,7 +819,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(new {ElectricCurrent.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricCurrent.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index e75dc3285b..07ad008f4f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class ElectricFieldTestsBase : QuantityTestsBase protected abstract double VoltsPerMeterInOneVoltPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double VoltsPerMeterTolerance { get { return 1e-5; } } + protected virtual double VoltsPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricFieldUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricFieldUnit unit) { - var inBaseUnits = ElectricField.From(1.0, ElectricField.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricField.From(1.0, ElectricField.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricField.From(1.0, ElectricField.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricFieldUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricFieldUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricFieldUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricFieldUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricField.Units.Where(u => u != ElectricField.BaseUnit).DefaultIfEmpty(ElectricField.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricField.Units.First(u => u != ElectricField.BaseUnit); var quantity = ElectricField.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricField.FromVoltsPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(new {ElectricField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricField.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index b436a94c0d..1df0aaa724 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ElectricInductanceTestsBase : QuantityTestsBase protected abstract double NanohenriesInOneHenry { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double HenriesTolerance { get { return 1e-5; } } - protected virtual double MicrohenriesTolerance { get { return 1e-5; } } - protected virtual double MillihenriesTolerance { get { return 1e-5; } } - protected virtual double NanohenriesTolerance { get { return 1e-5; } } + protected virtual double HenriesTolerance { get { return 1E-5; } } + protected virtual double MicrohenriesTolerance { get { return 1E-5; } } + protected virtual double MillihenriesTolerance { get { return 1E-5; } } + protected virtual double NanohenriesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricInductanceUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricInductanceUnit unit) { - var inBaseUnits = ElectricInductance.From(1.0, ElectricInductance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricInductance.From(1.0, ElectricInductance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricInductance.From(1.0, ElectricInductance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricInductanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricInductanceUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricInductanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricInductanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricInductance.Units.Where(u => u != ElectricInductance.BaseUnit).DefaultIfEmpty(ElectricInductance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricInductance.Units.First(u => u != ElectricInductance.BaseUnit); var quantity = ElectricInductance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricInductance.FromHenries(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(new {ElectricInductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricInductance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 54413cf013..18ff2da9ff 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricPotentialAcTestsBase : QuantityTestsBase protected abstract double VoltsAcInOneVoltAc { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsAcTolerance { get { return 1e-5; } } - protected virtual double MegavoltsAcTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsAcTolerance { get { return 1e-5; } } - protected virtual double MillivoltsAcTolerance { get { return 1e-5; } } - protected virtual double VoltsAcTolerance { get { return 1e-5; } } + protected virtual double KilovoltsAcTolerance { get { return 1E-5; } } + protected virtual double MegavoltsAcTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsAcTolerance { get { return 1E-5; } } + protected virtual double MillivoltsAcTolerance { get { return 1E-5; } } + protected virtual double VoltsAcTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialAcUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -329,14 +329,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialAcUnit unit) { - var inBaseUnits = ElectricPotentialAc.From(1.0, ElectricPotentialAc.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricPotentialAc.From(1.0, ElectricPotentialAc.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricPotentialAc.From(1.0, ElectricPotentialAc.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialAcUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialAcUnit unit) @@ -350,8 +357,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialAcUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialAcUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotentialAc.Units.Where(u => u != ElectricPotentialAc.BaseUnit).DefaultIfEmpty(ElectricPotentialAc.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricPotentialAc.Units.First(u => u != ElectricPotentialAc.BaseUnit); var quantity = ElectricPotentialAc.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -558,8 +565,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -593,36 +601,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -635,22 +648,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotentialAc.FromVoltsAc(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -692,7 +708,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(new {ElectricPotentialAc.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricPotentialAc.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 11f38843a9..90068daab5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -60,26 +60,26 @@ public abstract partial class ElectricPotentialChangeRateTestsBase : QuantityTes protected abstract double VoltsPerSecondsInOneVoltPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsPerHoursTolerance { get { return 1e-5; } } - protected virtual double KilovoltsPerMicrosecondsTolerance { get { return 1e-5; } } - protected virtual double KilovoltsPerMinutesTolerance { get { return 1e-5; } } - protected virtual double KilovoltsPerSecondsTolerance { get { return 1e-5; } } - protected virtual double MegavoltsPerHoursTolerance { get { return 1e-5; } } - protected virtual double MegavoltsPerMicrosecondsTolerance { get { return 1e-5; } } - protected virtual double MegavoltsPerMinutesTolerance { get { return 1e-5; } } - protected virtual double MegavoltsPerSecondsTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsPerHoursTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsPerMicrosecondsTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsPerMinutesTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsPerSecondsTolerance { get { return 1e-5; } } - protected virtual double MillivoltsPerHoursTolerance { get { return 1e-5; } } - protected virtual double MillivoltsPerMicrosecondsTolerance { get { return 1e-5; } } - protected virtual double MillivoltsPerMinutesTolerance { get { return 1e-5; } } - protected virtual double MillivoltsPerSecondsTolerance { get { return 1e-5; } } - protected virtual double VoltsPerHoursTolerance { get { return 1e-5; } } - protected virtual double VoltsPerMicrosecondsTolerance { get { return 1e-5; } } - protected virtual double VoltsPerMinutesTolerance { get { return 1e-5; } } - protected virtual double VoltsPerSecondsTolerance { get { return 1e-5; } } + protected virtual double KilovoltsPerHoursTolerance { get { return 1E-5; } } + protected virtual double KilovoltsPerMicrosecondsTolerance { get { return 1E-5; } } + protected virtual double KilovoltsPerMinutesTolerance { get { return 1E-5; } } + protected virtual double KilovoltsPerSecondsTolerance { get { return 1E-5; } } + protected virtual double MegavoltsPerHoursTolerance { get { return 1E-5; } } + protected virtual double MegavoltsPerMicrosecondsTolerance { get { return 1E-5; } } + protected virtual double MegavoltsPerMinutesTolerance { get { return 1E-5; } } + protected virtual double MegavoltsPerSecondsTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsPerHoursTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsPerMicrosecondsTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsPerMinutesTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsPerSecondsTolerance { get { return 1E-5; } } + protected virtual double MillivoltsPerHoursTolerance { get { return 1E-5; } } + protected virtual double MillivoltsPerMicrosecondsTolerance { get { return 1E-5; } } + protected virtual double MillivoltsPerMinutesTolerance { get { return 1E-5; } } + protected virtual double MillivoltsPerSecondsTolerance { get { return 1E-5; } } + protected virtual double VoltsPerHoursTolerance { get { return 1E-5; } } + protected virtual double VoltsPerMicrosecondsTolerance { get { return 1E-5; } } + protected virtual double VoltsPerMinutesTolerance { get { return 1E-5; } } + protected virtual double VoltsPerSecondsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialChangeRateUnit unit) @@ -348,7 +348,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -773,14 +773,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialChangeRateUnit unit) { - var inBaseUnits = ElectricPotentialChangeRate.From(1.0, ElectricPotentialChangeRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricPotentialChangeRate.From(1.0, ElectricPotentialChangeRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricPotentialChangeRate.From(1.0, ElectricPotentialChangeRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialChangeRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialChangeRateUnit unit) @@ -794,8 +801,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialChangeRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotentialChangeRate.Units.Where(u => u != ElectricPotentialChangeRate.BaseUnit).DefaultIfEmpty(ElectricPotentialChangeRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricPotentialChangeRate.Units.First(u => u != ElectricPotentialChangeRate.BaseUnit); var quantity = ElectricPotentialChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1047,8 +1054,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1082,36 +1090,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1124,22 +1137,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1181,7 +1197,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(new {ElectricPotentialChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricPotentialChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index d7b84a15dc..f2b5dfedca 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricPotentialDcTestsBase : QuantityTestsBase protected abstract double VoltsDcInOneVoltDc { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsDcTolerance { get { return 1e-5; } } - protected virtual double MegavoltsDcTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsDcTolerance { get { return 1e-5; } } - protected virtual double MillivoltsDcTolerance { get { return 1e-5; } } - protected virtual double VoltsDcTolerance { get { return 1e-5; } } + protected virtual double KilovoltsDcTolerance { get { return 1E-5; } } + protected virtual double MegavoltsDcTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsDcTolerance { get { return 1E-5; } } + protected virtual double MillivoltsDcTolerance { get { return 1E-5; } } + protected virtual double VoltsDcTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialDcUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -329,14 +329,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialDcUnit unit) { - var inBaseUnits = ElectricPotentialDc.From(1.0, ElectricPotentialDc.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricPotentialDc.From(1.0, ElectricPotentialDc.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricPotentialDc.From(1.0, ElectricPotentialDc.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialDcUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialDcUnit unit) @@ -350,8 +357,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialDcUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialDcUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotentialDc.Units.Where(u => u != ElectricPotentialDc.BaseUnit).DefaultIfEmpty(ElectricPotentialDc.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricPotentialDc.Units.First(u => u != ElectricPotentialDc.BaseUnit); var quantity = ElectricPotentialDc.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -558,8 +565,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -593,36 +601,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -635,22 +648,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotentialDc.FromVoltsDc(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -692,7 +708,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(new {ElectricPotentialDc.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricPotentialDc.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 85c888287a..c9ad5757af 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricPotentialTestsBase : QuantityTestsBase protected abstract double VoltsInOneVolt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsTolerance { get { return 1e-5; } } - protected virtual double MegavoltsTolerance { get { return 1e-5; } } - protected virtual double MicrovoltsTolerance { get { return 1e-5; } } - protected virtual double MillivoltsTolerance { get { return 1e-5; } } - protected virtual double VoltsTolerance { get { return 1e-5; } } + protected virtual double KilovoltsTolerance { get { return 1E-5; } } + protected virtual double MegavoltsTolerance { get { return 1E-5; } } + protected virtual double MicrovoltsTolerance { get { return 1E-5; } } + protected virtual double MillivoltsTolerance { get { return 1E-5; } } + protected virtual double VoltsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -427,14 +427,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialUnit unit) { - var inBaseUnits = ElectricPotential.From(1.0, ElectricPotential.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricPotential.From(1.0, ElectricPotential.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricPotential.From(1.0, ElectricPotential.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialUnit unit) @@ -448,8 +455,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricPotential.Units.Where(u => u != ElectricPotential.BaseUnit).DefaultIfEmpty(ElectricPotential.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricPotential.Units.First(u => u != ElectricPotential.BaseUnit); var quantity = ElectricPotential.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -656,8 +663,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -691,36 +699,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -733,22 +746,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricPotential.FromVolts(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -790,7 +806,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(new {ElectricPotential.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricPotential.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 2f5ab2b600..bb80d8cfb3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class ElectricResistanceTestsBase : QuantityTestsBase protected abstract double OhmsInOneOhm { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigaohmsTolerance { get { return 1e-5; } } - protected virtual double KiloohmsTolerance { get { return 1e-5; } } - protected virtual double MegaohmsTolerance { get { return 1e-5; } } - protected virtual double MicroohmsTolerance { get { return 1e-5; } } - protected virtual double MilliohmsTolerance { get { return 1e-5; } } - protected virtual double OhmsTolerance { get { return 1e-5; } } + protected virtual double GigaohmsTolerance { get { return 1E-5; } } + protected virtual double KiloohmsTolerance { get { return 1E-5; } } + protected virtual double MegaohmsTolerance { get { return 1E-5; } } + protected virtual double MicroohmsTolerance { get { return 1E-5; } } + protected virtual double MilliohmsTolerance { get { return 1E-5; } } + protected virtual double OhmsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricResistanceUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -363,14 +363,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricResistanceUnit unit) { - var inBaseUnits = ElectricResistance.From(1.0, ElectricResistance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricResistance.From(1.0, ElectricResistance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricResistance.From(1.0, ElectricResistance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricResistanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricResistanceUnit unit) @@ -384,8 +391,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricResistanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricResistanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricResistance.Units.Where(u => u != ElectricResistance.BaseUnit).DefaultIfEmpty(ElectricResistance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricResistance.Units.First(u => u != ElectricResistance.BaseUnit); var quantity = ElectricResistance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -595,8 +602,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -630,36 +638,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -672,22 +685,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricResistance.FromOhms(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -729,7 +745,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(new {ElectricResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricResistance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 061188ed83..e6c2c14fab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class ElectricResistivityTestsBase : QuantityTestsBase protected abstract double PicoohmMetersInOneOhmMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KiloohmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double KiloohmMetersTolerance { get { return 1e-5; } } - protected virtual double MegaohmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double MegaohmMetersTolerance { get { return 1e-5; } } - protected virtual double MicroohmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double MicroohmMetersTolerance { get { return 1e-5; } } - protected virtual double MilliohmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double MilliohmMetersTolerance { get { return 1e-5; } } - protected virtual double NanoohmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double NanoohmMetersTolerance { get { return 1e-5; } } - protected virtual double OhmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double OhmMetersTolerance { get { return 1e-5; } } - protected virtual double PicoohmsCentimeterTolerance { get { return 1e-5; } } - protected virtual double PicoohmMetersTolerance { get { return 1e-5; } } + protected virtual double KiloohmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double KiloohmMetersTolerance { get { return 1E-5; } } + protected virtual double MegaohmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double MegaohmMetersTolerance { get { return 1E-5; } } + protected virtual double MicroohmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double MicroohmMetersTolerance { get { return 1E-5; } } + protected virtual double MilliohmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double MilliohmMetersTolerance { get { return 1E-5; } } + protected virtual double NanoohmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double NanoohmMetersTolerance { get { return 1E-5; } } + protected virtual double OhmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double OhmMetersTolerance { get { return 1E-5; } } + protected virtual double PicoohmsCentimeterTolerance { get { return 1E-5; } } + protected virtual double PicoohmMetersTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricResistivityUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -613,14 +613,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricResistivityUnit unit) { - var inBaseUnits = ElectricResistivity.From(1.0, ElectricResistivity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricResistivity.From(1.0, ElectricResistivity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricResistivity.From(1.0, ElectricResistivity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricResistivityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricResistivityUnit unit) @@ -634,8 +641,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricResistivityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricResistivityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricResistivity.Units.Where(u => u != ElectricResistivity.BaseUnit).DefaultIfEmpty(ElectricResistivity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricResistivity.Units.First(u => u != ElectricResistivity.BaseUnit); var quantity = ElectricResistivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -869,8 +876,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -904,36 +912,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -946,22 +959,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricResistivity.FromOhmMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1003,7 +1019,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(new {ElectricResistivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricResistivity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 50650f67de..ffd7ee2f84 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricSurfaceChargeDensityTestsBase : QuantityTe protected abstract double CoulombsPerSquareMeterInOneCoulombPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CoulombsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double CoulombsPerSquareInchTolerance { get { return 1e-5; } } - protected virtual double CoulombsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double CoulombsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double CoulombsPerSquareInchTolerance { get { return 1E-5; } } + protected virtual double CoulombsPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricSurfaceChargeDensityUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricSurfaceChargeDensityUnit unit) { - var inBaseUnits = ElectricSurfaceChargeDensity.From(1.0, ElectricSurfaceChargeDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ElectricSurfaceChargeDensity.From(1.0, ElectricSurfaceChargeDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ElectricSurfaceChargeDensity.From(1.0, ElectricSurfaceChargeDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricSurfaceChargeDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricSurfaceChargeDensityUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricSurfaceChargeDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricSurfaceChargeDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ElectricSurfaceChargeDensity.Units.Where(u => u != ElectricSurfaceChargeDensity.BaseUnit).DefaultIfEmpty(ElectricSurfaceChargeDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ElectricSurfaceChargeDensity.Units.First(u => u != ElectricSurfaceChargeDensity.BaseUnit); var quantity = ElectricSurfaceChargeDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(new {ElectricSurfaceChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ElectricSurfaceChargeDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 22b563d859..37c8e3730f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -76,42 +76,42 @@ public abstract partial class EnergyTestsBase : QuantityTestsBase protected abstract double WattHoursInOneJoule { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BritishThermalUnitsTolerance { get { return 1e-5; } } - protected virtual double CaloriesTolerance { get { return 1e-5; } } - protected virtual double DecathermsEcTolerance { get { return 1e-5; } } - protected virtual double DecathermsImperialTolerance { get { return 1e-5; } } - protected virtual double DecathermsUsTolerance { get { return 1e-5; } } - protected virtual double ElectronVoltsTolerance { get { return 1e-5; } } - protected virtual double ErgsTolerance { get { return 1e-5; } } - protected virtual double FootPoundsTolerance { get { return 1e-5; } } - protected virtual double GigabritishThermalUnitsTolerance { get { return 1e-5; } } - protected virtual double GigaelectronVoltsTolerance { get { return 1e-5; } } - protected virtual double GigajoulesTolerance { get { return 1e-5; } } - protected virtual double GigawattDaysTolerance { get { return 1e-5; } } - protected virtual double GigawattHoursTolerance { get { return 1e-5; } } - protected virtual double HorsepowerHoursTolerance { get { return 1e-5; } } - protected virtual double JoulesTolerance { get { return 1e-5; } } - protected virtual double KilobritishThermalUnitsTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesTolerance { get { return 1e-5; } } - protected virtual double KiloelectronVoltsTolerance { get { return 1e-5; } } - protected virtual double KilojoulesTolerance { get { return 1e-5; } } - protected virtual double KilowattDaysTolerance { get { return 1e-5; } } - protected virtual double KilowattHoursTolerance { get { return 1e-5; } } - protected virtual double MegabritishThermalUnitsTolerance { get { return 1e-5; } } - protected virtual double MegacaloriesTolerance { get { return 1e-5; } } - protected virtual double MegaelectronVoltsTolerance { get { return 1e-5; } } - protected virtual double MegajoulesTolerance { get { return 1e-5; } } - protected virtual double MegawattDaysTolerance { get { return 1e-5; } } - protected virtual double MegawattHoursTolerance { get { return 1e-5; } } - protected virtual double MillijoulesTolerance { get { return 1e-5; } } - protected virtual double TeraelectronVoltsTolerance { get { return 1e-5; } } - protected virtual double TerawattDaysTolerance { get { return 1e-5; } } - protected virtual double TerawattHoursTolerance { get { return 1e-5; } } - protected virtual double ThermsEcTolerance { get { return 1e-5; } } - protected virtual double ThermsImperialTolerance { get { return 1e-5; } } - protected virtual double ThermsUsTolerance { get { return 1e-5; } } - protected virtual double WattDaysTolerance { get { return 1e-5; } } - protected virtual double WattHoursTolerance { get { return 1e-5; } } + protected virtual double BritishThermalUnitsTolerance { get { return 1E-5; } } + protected virtual double CaloriesTolerance { get { return 1E-5; } } + protected virtual double DecathermsEcTolerance { get { return 1E-5; } } + protected virtual double DecathermsImperialTolerance { get { return 1E-5; } } + protected virtual double DecathermsUsTolerance { get { return 1E-5; } } + protected virtual double ElectronVoltsTolerance { get { return 1E-5; } } + protected virtual double ErgsTolerance { get { return 1E-5; } } + protected virtual double FootPoundsTolerance { get { return 1E-5; } } + protected virtual double GigabritishThermalUnitsTolerance { get { return 1E-5; } } + protected virtual double GigaelectronVoltsTolerance { get { return 1E-5; } } + protected virtual double GigajoulesTolerance { get { return 1E-5; } } + protected virtual double GigawattDaysTolerance { get { return 1E-5; } } + protected virtual double GigawattHoursTolerance { get { return 1E-5; } } + protected virtual double HorsepowerHoursTolerance { get { return 1E-5; } } + protected virtual double JoulesTolerance { get { return 1E-5; } } + protected virtual double KilobritishThermalUnitsTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesTolerance { get { return 1E-5; } } + protected virtual double KiloelectronVoltsTolerance { get { return 1E-5; } } + protected virtual double KilojoulesTolerance { get { return 1E-5; } } + protected virtual double KilowattDaysTolerance { get { return 1E-5; } } + protected virtual double KilowattHoursTolerance { get { return 1E-5; } } + protected virtual double MegabritishThermalUnitsTolerance { get { return 1E-5; } } + protected virtual double MegacaloriesTolerance { get { return 1E-5; } } + protected virtual double MegaelectronVoltsTolerance { get { return 1E-5; } } + protected virtual double MegajoulesTolerance { get { return 1E-5; } } + protected virtual double MegawattDaysTolerance { get { return 1E-5; } } + protected virtual double MegawattHoursTolerance { get { return 1E-5; } } + protected virtual double MillijoulesTolerance { get { return 1E-5; } } + protected virtual double TeraelectronVoltsTolerance { get { return 1E-5; } } + protected virtual double TerawattDaysTolerance { get { return 1E-5; } } + protected virtual double TerawattHoursTolerance { get { return 1E-5; } } + protected virtual double ThermsEcTolerance { get { return 1E-5; } } + protected virtual double ThermsImperialTolerance { get { return 1E-5; } } + protected virtual double ThermsUsTolerance { get { return 1E-5; } } + protected virtual double WattDaysTolerance { get { return 1E-5; } } + protected virtual double WattHoursTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(EnergyUnit unit) @@ -508,7 +508,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1887,14 +1887,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(EnergyUnit unit) { - var inBaseUnits = Energy.From(1.0, Energy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Energy.From(1.0, Energy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Energy.From(1.0, Energy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(EnergyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(EnergyUnit unit) @@ -1908,8 +1915,8 @@ public void ToUnit_WithSameUnits_AreEqual(EnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(EnergyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Energy.Units.Where(u => u != Energy.BaseUnit).DefaultIfEmpty(Energy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Energy.Units.First(u => u != Energy.BaseUnit); var quantity = Energy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2209,8 +2216,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2244,36 +2252,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2286,22 +2299,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Energy.FromJoules(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Energy.FromJoules(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2343,7 +2359,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Energy.FromJoules(1.0); - Assert.Equal(new {Energy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Energy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 06ae0fd4e5..acfce61703 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class EntropyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerKelvinInOneJoulePerKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CaloriesPerKelvinTolerance { get { return 1e-5; } } - protected virtual double JoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double JoulesPerKelvinTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesPerKelvinTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerKelvinTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double CaloriesPerKelvinTolerance { get { return 1E-5; } } + protected virtual double JoulesPerDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double JoulesPerKelvinTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesPerKelvinTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerKelvinTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(EntropyUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -419,14 +419,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(EntropyUnit unit) { - var inBaseUnits = Entropy.From(1.0, Entropy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Entropy.From(1.0, Entropy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Entropy.From(1.0, Entropy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(EntropyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(EntropyUnit unit) @@ -440,8 +447,8 @@ public void ToUnit_WithSameUnits_AreEqual(EntropyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(EntropyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Entropy.Units.Where(u => u != Entropy.BaseUnit).DefaultIfEmpty(Entropy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Entropy.Units.First(u => u != Entropy.BaseUnit); var quantity = Entropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -654,8 +661,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -689,36 +697,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -731,22 +744,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Entropy.FromJoulesPerKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -788,7 +804,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(new {Entropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Entropy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 6e46e12a28..e0e2d9473f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -55,21 +55,21 @@ public abstract partial class ForceChangeRateTestsBase : QuantityTestsBase protected abstract double PoundsForcePerSecondInOneNewtonPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentinewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecanewtonsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double DecanewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecinewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerMinuteTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerSecondTolerance { get { return 1e-5; } } - protected virtual double MicronewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MillinewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanonewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerMinuteTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerSecondTolerance { get { return 1e-5; } } + protected virtual double CentinewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecanewtonsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double DecanewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecinewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerMinuteTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerSecondTolerance { get { return 1E-5; } } + protected virtual double MicronewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MillinewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanonewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerMinuteTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ForceChangeRateUnit unit) @@ -298,7 +298,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -787,14 +787,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ForceChangeRateUnit unit) { - var inBaseUnits = ForceChangeRate.From(1.0, ForceChangeRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ForceChangeRate.From(1.0, ForceChangeRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ForceChangeRate.From(1.0, ForceChangeRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ForceChangeRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ForceChangeRateUnit unit) @@ -808,8 +815,8 @@ public void ToUnit_WithSameUnits_AreEqual(ForceChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForceChangeRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ForceChangeRate.Units.Where(u => u != ForceChangeRate.BaseUnit).DefaultIfEmpty(ForceChangeRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ForceChangeRate.Units.First(u => u != ForceChangeRate.BaseUnit); var quantity = ForceChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1046,8 +1053,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1081,36 +1089,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1123,22 +1136,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ForceChangeRate.FromNewtonsPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1180,7 +1196,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(new {ForceChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ForceChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index c9979db3cf..2b2a3554ad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -78,44 +78,44 @@ public abstract partial class ForcePerLengthTestsBase : QuantityTestsBase protected abstract double TonnesForcePerMillimeterInOneNewtonPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentinewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double CentinewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double CentinewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double DecanewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double DecanewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double DecanewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double DecinewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double DecinewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double DecinewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerInchTolerance { get { return 1e-5; } } - protected virtual double MeganewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MeganewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MeganewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double MicronewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MicronewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MicronewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double MillinewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MillinewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MillinewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double NanonewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double NanonewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double NanonewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerFootTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerInchTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerYardTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerCentimeterTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerMeterTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerMillimeterTolerance { get { return 1e-5; } } + protected virtual double CentinewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double CentinewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double CentinewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double DecanewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double DecanewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double DecanewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double DecinewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double DecinewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double DecinewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerFootTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerInchTolerance { get { return 1E-5; } } + protected virtual double MeganewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MeganewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MeganewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double MicronewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MicronewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MicronewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double MillinewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MillinewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MillinewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double NanonewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double NanonewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double NanonewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerFootTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerInchTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerYardTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerCentimeterTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerMeterTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerMillimeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ForcePerLengthUnit unit) @@ -528,7 +528,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1647,14 +1647,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ForcePerLengthUnit unit) { - var inBaseUnits = ForcePerLength.From(1.0, ForcePerLength.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ForcePerLength.From(1.0, ForcePerLength.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ForcePerLength.From(1.0, ForcePerLength.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ForcePerLengthUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ForcePerLengthUnit unit) @@ -1668,8 +1675,8 @@ public void ToUnit_WithSameUnits_AreEqual(ForcePerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForcePerLengthUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ForcePerLength.Units.Where(u => u != ForcePerLength.BaseUnit).DefaultIfEmpty(ForcePerLength.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ForcePerLength.Units.First(u => u != ForcePerLength.BaseUnit); var quantity = ForcePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1975,8 +1982,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2010,36 +2018,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2052,22 +2065,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ForcePerLength.FromNewtonsPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2109,7 +2125,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(new {ForcePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ForcePerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 28a015c7a7..cd8251764d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -55,21 +55,21 @@ public abstract partial class ForceTestsBase : QuantityTestsBase protected abstract double TonnesForceInOneNewton { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecanewtonsTolerance { get { return 1e-5; } } - protected virtual double DyneTolerance { get { return 1e-5; } } - protected virtual double KilogramsForceTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsTolerance { get { return 1e-5; } } - protected virtual double KiloPondsTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForceTolerance { get { return 1e-5; } } - protected virtual double MeganewtonsTolerance { get { return 1e-5; } } - protected virtual double MicronewtonsTolerance { get { return 1e-5; } } - protected virtual double MillinewtonsTolerance { get { return 1e-5; } } - protected virtual double NewtonsTolerance { get { return 1e-5; } } - protected virtual double OunceForceTolerance { get { return 1e-5; } } - protected virtual double PoundalsTolerance { get { return 1e-5; } } - protected virtual double PoundsForceTolerance { get { return 1e-5; } } - protected virtual double ShortTonsForceTolerance { get { return 1e-5; } } - protected virtual double TonnesForceTolerance { get { return 1e-5; } } + protected virtual double DecanewtonsTolerance { get { return 1E-5; } } + protected virtual double DyneTolerance { get { return 1E-5; } } + protected virtual double KilogramsForceTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsTolerance { get { return 1E-5; } } + protected virtual double KiloPondsTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForceTolerance { get { return 1E-5; } } + protected virtual double MeganewtonsTolerance { get { return 1E-5; } } + protected virtual double MicronewtonsTolerance { get { return 1E-5; } } + protected virtual double MillinewtonsTolerance { get { return 1E-5; } } + protected virtual double NewtonsTolerance { get { return 1E-5; } } + protected virtual double OunceForceTolerance { get { return 1E-5; } } + protected virtual double PoundalsTolerance { get { return 1E-5; } } + protected virtual double PoundsForceTolerance { get { return 1E-5; } } + protected virtual double ShortTonsForceTolerance { get { return 1E-5; } } + protected virtual double TonnesForceTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ForceUnit unit) @@ -298,7 +298,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1105,14 +1105,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ForceUnit unit) { - var inBaseUnits = Force.From(1.0, Force.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Force.From(1.0, Force.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Force.From(1.0, Force.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ForceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ForceUnit unit) @@ -1126,8 +1133,8 @@ public void ToUnit_WithSameUnits_AreEqual(ForceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Force.Units.Where(u => u != Force.BaseUnit).DefaultIfEmpty(Force.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Force.Units.First(u => u != Force.BaseUnit); var quantity = Force.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1364,8 +1371,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1399,36 +1407,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1441,22 +1454,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Force.FromNewtons(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Force.FromNewtons(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1498,7 +1514,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Force.FromNewtons(1.0); - Assert.Equal(new {Force.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Force.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 6235036d30..1cd5ef04d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class FrequencyTestsBase : QuantityTestsBase protected abstract double TerahertzInOneHertz { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BeatsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double BUnitsTolerance { get { return 1e-5; } } - protected virtual double CyclesPerHourTolerance { get { return 1e-5; } } - protected virtual double CyclesPerMinuteTolerance { get { return 1e-5; } } - protected virtual double GigahertzTolerance { get { return 1e-5; } } - protected virtual double HertzTolerance { get { return 1e-5; } } - protected virtual double KilohertzTolerance { get { return 1e-5; } } - protected virtual double MegahertzTolerance { get { return 1e-5; } } - protected virtual double PerSecondTolerance { get { return 1e-5; } } - protected virtual double RadiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerahertzTolerance { get { return 1e-5; } } + protected virtual double BeatsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double BUnitsTolerance { get { return 1E-5; } } + protected virtual double CyclesPerHourTolerance { get { return 1E-5; } } + protected virtual double CyclesPerMinuteTolerance { get { return 1E-5; } } + protected virtual double GigahertzTolerance { get { return 1E-5; } } + protected virtual double HertzTolerance { get { return 1E-5; } } + protected virtual double KilohertzTolerance { get { return 1E-5; } } + protected virtual double MegahertzTolerance { get { return 1E-5; } } + protected virtual double PerSecondTolerance { get { return 1E-5; } } + protected virtual double RadiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double TerahertzTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(FrequencyUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -723,14 +723,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(FrequencyUnit unit) { - var inBaseUnits = Frequency.From(1.0, Frequency.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Frequency.From(1.0, Frequency.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Frequency.From(1.0, Frequency.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(FrequencyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(FrequencyUnit unit) @@ -744,8 +751,8 @@ public void ToUnit_WithSameUnits_AreEqual(FrequencyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FrequencyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Frequency.Units.Where(u => u != Frequency.BaseUnit).DefaultIfEmpty(Frequency.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Frequency.Units.First(u => u != Frequency.BaseUnit); var quantity = Frequency.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -970,8 +977,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1005,36 +1013,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1047,22 +1060,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Frequency.FromHertz(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Frequency.FromHertz(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1104,7 +1120,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(new {Frequency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Frequency.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 267c73802f..188d454a36 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class FuelEfficiencyTestsBase : QuantityTestsBase protected abstract double MilesPerUsGallonInOneLiterPer100Kilometers { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilometersPerLitersTolerance { get { return 1e-5; } } - protected virtual double LitersPer100KilometersTolerance { get { return 1e-5; } } - protected virtual double MilesPerUkGallonTolerance { get { return 1e-5; } } - protected virtual double MilesPerUsGallonTolerance { get { return 1e-5; } } + protected virtual double KilometersPerLitersTolerance { get { return 1E-5; } } + protected virtual double LitersPer100KilometersTolerance { get { return 1E-5; } } + protected virtual double MilesPerUkGallonTolerance { get { return 1E-5; } } + protected virtual double MilesPerUsGallonTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(FuelEfficiencyUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(FuelEfficiencyUnit unit) { - var inBaseUnits = FuelEfficiency.From(1.0, FuelEfficiency.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = FuelEfficiency.From(1.0, FuelEfficiency.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = FuelEfficiency.From(1.0, FuelEfficiency.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(FuelEfficiencyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(FuelEfficiencyUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(FuelEfficiencyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FuelEfficiencyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = FuelEfficiency.Units.Where(u => u != FuelEfficiency.BaseUnit).DefaultIfEmpty(FuelEfficiency.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = FuelEfficiency.Units.First(u => u != FuelEfficiency.BaseUnit); var quantity = FuelEfficiency.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(new {FuelEfficiency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(FuelEfficiency.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index d894f51294..a4d2ec5d11 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -58,24 +58,24 @@ public abstract partial class HeatFluxTestsBase : QuantityTestsBase protected abstract double WattsPerSquareMeterInOneWattPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerHourSquareFootTolerance { get { return 1e-5; } } - protected virtual double BtusPerMinuteSquareFootTolerance { get { return 1e-5; } } - protected virtual double BtusPerSecondSquareFootTolerance { get { return 1e-5; } } - protected virtual double BtusPerSecondSquareInchTolerance { get { return 1e-5; } } - protected virtual double CaloriesPerSecondSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double CentiwattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double DeciwattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesPerHourSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesPerSecondSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerFootSecondTolerance { get { return 1e-5; } } - protected virtual double PoundsPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareFootTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareInchTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double BtusPerHourSquareFootTolerance { get { return 1E-5; } } + protected virtual double BtusPerMinuteSquareFootTolerance { get { return 1E-5; } } + protected virtual double BtusPerSecondSquareFootTolerance { get { return 1E-5; } } + protected virtual double BtusPerSecondSquareInchTolerance { get { return 1E-5; } } + protected virtual double CaloriesPerSecondSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double CentiwattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double DeciwattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesPerHourSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesPerSecondSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerFootSecondTolerance { get { return 1E-5; } } + protected virtual double PoundsPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareFootTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareInchTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(HeatFluxUnit unit) @@ -328,7 +328,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -817,14 +817,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(HeatFluxUnit unit) { - var inBaseUnits = HeatFlux.From(1.0, HeatFlux.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = HeatFlux.From(1.0, HeatFlux.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = HeatFlux.From(1.0, HeatFlux.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(HeatFluxUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(HeatFluxUnit unit) @@ -838,8 +845,8 @@ public void ToUnit_WithSameUnits_AreEqual(HeatFluxUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(HeatFluxUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = HeatFlux.Units.Where(u => u != HeatFlux.BaseUnit).DefaultIfEmpty(HeatFlux.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = HeatFlux.Units.First(u => u != HeatFlux.BaseUnit); var quantity = HeatFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1085,8 +1092,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1120,36 +1128,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1162,22 +1175,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = HeatFlux.FromWattsPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1219,7 +1235,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(new {HeatFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(HeatFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 0050e1ba0e..4c041ee287 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class HeatTransferCoefficientTestsBase : QuantityTestsBa protected abstract double WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerSquareFootDegreeFahrenheitTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareMeterCelsiusTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareMeterKelvinTolerance { get { return 1e-5; } } + protected virtual double BtusPerSquareFootDegreeFahrenheitTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareMeterCelsiusTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareMeterKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(HeatTransferCoefficientUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(HeatTransferCoefficientUnit unit) { - var inBaseUnits = HeatTransferCoefficient.From(1.0, HeatTransferCoefficient.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = HeatTransferCoefficient.From(1.0, HeatTransferCoefficient.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = HeatTransferCoefficient.From(1.0, HeatTransferCoefficient.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(HeatTransferCoefficientUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(HeatTransferCoefficientUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(HeatTransferCoefficientUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(HeatTransferCoefficientUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = HeatTransferCoefficient.Units.Where(u => u != HeatTransferCoefficient.BaseUnit).DefaultIfEmpty(HeatTransferCoefficient.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = HeatTransferCoefficient.Units.First(u => u != HeatTransferCoefficient.BaseUnit); var quantity = HeatTransferCoefficient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(new {HeatTransferCoefficient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(HeatTransferCoefficient.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index d53ecaf4e4..112256392c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class IlluminanceTestsBase : QuantityTestsBase protected abstract double MilliluxInOneLux { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KiloluxTolerance { get { return 1e-5; } } - protected virtual double LuxTolerance { get { return 1e-5; } } - protected virtual double MegaluxTolerance { get { return 1e-5; } } - protected virtual double MilliluxTolerance { get { return 1e-5; } } + protected virtual double KiloluxTolerance { get { return 1E-5; } } + protected virtual double LuxTolerance { get { return 1E-5; } } + protected virtual double MegaluxTolerance { get { return 1E-5; } } + protected virtual double MilliluxTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(IlluminanceUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -295,14 +295,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(IlluminanceUnit unit) { - var inBaseUnits = Illuminance.From(1.0, Illuminance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Illuminance.From(1.0, Illuminance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Illuminance.From(1.0, Illuminance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(IlluminanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(IlluminanceUnit unit) @@ -316,8 +323,8 @@ public void ToUnit_WithSameUnits_AreEqual(IlluminanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IlluminanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Illuminance.Units.Where(u => u != Illuminance.BaseUnit).DefaultIfEmpty(Illuminance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Illuminance.Units.First(u => u != Illuminance.BaseUnit); var quantity = Illuminance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -521,8 +528,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -556,36 +564,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -598,22 +611,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Illuminance.FromLux(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Illuminance.FromLux(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -655,7 +671,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(new {Illuminance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Illuminance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index f48c5b7434..4224811b4b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class InformationTestsBase : QuantityTestsBase { - protected abstract double BitsInOneBit { get; } - protected abstract double BytesInOneBit { get; } - protected abstract double ExabitsInOneBit { get; } - protected abstract double ExabytesInOneBit { get; } - protected abstract double ExbibitsInOneBit { get; } - protected abstract double ExbibytesInOneBit { get; } - protected abstract double GibibitsInOneBit { get; } - protected abstract double GibibytesInOneBit { get; } - protected abstract double GigabitsInOneBit { get; } - protected abstract double GigabytesInOneBit { get; } - protected abstract double KibibitsInOneBit { get; } - protected abstract double KibibytesInOneBit { get; } - protected abstract double KilobitsInOneBit { get; } - protected abstract double KilobytesInOneBit { get; } - protected abstract double MebibitsInOneBit { get; } - protected abstract double MebibytesInOneBit { get; } - protected abstract double MegabitsInOneBit { get; } - protected abstract double MegabytesInOneBit { get; } - protected abstract double PebibitsInOneBit { get; } - protected abstract double PebibytesInOneBit { get; } - protected abstract double PetabitsInOneBit { get; } - protected abstract double PetabytesInOneBit { get; } - protected abstract double TebibitsInOneBit { get; } - protected abstract double TebibytesInOneBit { get; } - protected abstract double TerabitsInOneBit { get; } - protected abstract double TerabytesInOneBit { get; } + protected abstract decimal BitsInOneBit { get; } + protected abstract decimal BytesInOneBit { get; } + protected abstract decimal ExabitsInOneBit { get; } + protected abstract decimal ExabytesInOneBit { get; } + protected abstract decimal ExbibitsInOneBit { get; } + protected abstract decimal ExbibytesInOneBit { get; } + protected abstract decimal GibibitsInOneBit { get; } + protected abstract decimal GibibytesInOneBit { get; } + protected abstract decimal GigabitsInOneBit { get; } + protected abstract decimal GigabytesInOneBit { get; } + protected abstract decimal KibibitsInOneBit { get; } + protected abstract decimal KibibytesInOneBit { get; } + protected abstract decimal KilobitsInOneBit { get; } + protected abstract decimal KilobytesInOneBit { get; } + protected abstract decimal MebibitsInOneBit { get; } + protected abstract decimal MebibytesInOneBit { get; } + protected abstract decimal MegabitsInOneBit { get; } + protected abstract decimal MegabytesInOneBit { get; } + protected abstract decimal PebibitsInOneBit { get; } + protected abstract decimal PebibytesInOneBit { get; } + protected abstract decimal PetabitsInOneBit { get; } + protected abstract decimal PetabytesInOneBit { get; } + protected abstract decimal TebibitsInOneBit { get; } + protected abstract decimal TebibytesInOneBit { get; } + protected abstract decimal TerabitsInOneBit { get; } + protected abstract decimal TerabytesInOneBit { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BitsTolerance { get { return 1e-5; } } - protected virtual double BytesTolerance { get { return 1e-5; } } - protected virtual double ExabitsTolerance { get { return 1e-5; } } - protected virtual double ExabytesTolerance { get { return 1e-5; } } - protected virtual double ExbibitsTolerance { get { return 1e-5; } } - protected virtual double ExbibytesTolerance { get { return 1e-5; } } - protected virtual double GibibitsTolerance { get { return 1e-5; } } - protected virtual double GibibytesTolerance { get { return 1e-5; } } - protected virtual double GigabitsTolerance { get { return 1e-5; } } - protected virtual double GigabytesTolerance { get { return 1e-5; } } - protected virtual double KibibitsTolerance { get { return 1e-5; } } - protected virtual double KibibytesTolerance { get { return 1e-5; } } - protected virtual double KilobitsTolerance { get { return 1e-5; } } - protected virtual double KilobytesTolerance { get { return 1e-5; } } - protected virtual double MebibitsTolerance { get { return 1e-5; } } - protected virtual double MebibytesTolerance { get { return 1e-5; } } - protected virtual double MegabitsTolerance { get { return 1e-5; } } - protected virtual double MegabytesTolerance { get { return 1e-5; } } - protected virtual double PebibitsTolerance { get { return 1e-5; } } - protected virtual double PebibytesTolerance { get { return 1e-5; } } - protected virtual double PetabitsTolerance { get { return 1e-5; } } - protected virtual double PetabytesTolerance { get { return 1e-5; } } - protected virtual double TebibitsTolerance { get { return 1e-5; } } - protected virtual double TebibytesTolerance { get { return 1e-5; } } - protected virtual double TerabitsTolerance { get { return 1e-5; } } - protected virtual double TerabytesTolerance { get { return 1e-5; } } + protected virtual decimal BitsTolerance { get { return 1E-9m; } } + protected virtual decimal BytesTolerance { get { return 1E-9m; } } + protected virtual decimal ExabitsTolerance { get { return 1E-9m; } } + protected virtual decimal ExabytesTolerance { get { return 1E-9m; } } + protected virtual decimal ExbibitsTolerance { get { return 1E-9m; } } + protected virtual decimal ExbibytesTolerance { get { return 1E-9m; } } + protected virtual decimal GibibitsTolerance { get { return 1E-9m; } } + protected virtual decimal GibibytesTolerance { get { return 1E-9m; } } + protected virtual decimal GigabitsTolerance { get { return 1E-9m; } } + protected virtual decimal GigabytesTolerance { get { return 1E-9m; } } + protected virtual decimal KibibitsTolerance { get { return 1E-9m; } } + protected virtual decimal KibibytesTolerance { get { return 1E-9m; } } + protected virtual decimal KilobitsTolerance { get { return 1E-9m; } } + protected virtual decimal KilobytesTolerance { get { return 1E-9m; } } + protected virtual decimal MebibitsTolerance { get { return 1E-9m; } } + protected virtual decimal MebibytesTolerance { get { return 1E-9m; } } + protected virtual decimal MegabitsTolerance { get { return 1E-9m; } } + protected virtual decimal MegabytesTolerance { get { return 1E-9m; } } + protected virtual decimal PebibitsTolerance { get { return 1E-9m; } } + protected virtual decimal PebibytesTolerance { get { return 1E-9m; } } + protected virtual decimal PetabitsTolerance { get { return 1E-9m; } } + protected virtual decimal PetabytesTolerance { get { return 1E-9m; } } + protected virtual decimal TebibitsTolerance { get { return 1E-9m; } } + protected virtual decimal TebibytesTolerance { get { return 1E-9m; } } + protected virtual decimal TerabitsTolerance { get { return 1E-9m; } } + protected virtual decimal TerabytesTolerance { get { return 1E-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(InformationUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(InformationUnit unit) { return unit switch { @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -754,14 +754,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(InformationUnit unit) { - var inBaseUnits = Information.From(1.0, Information.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Information.From(1.0, Information.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Information.From(1.0, Information.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(InformationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(InformationUnit unit) @@ -775,8 +782,8 @@ public void ToUnit_WithSameUnits_AreEqual(InformationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(InformationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Information.Units.Where(u => u != Information.BaseUnit).DefaultIfEmpty(Information.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Information.Units.First(u => u != Information.BaseUnit); var quantity = Information.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1046,8 +1053,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1081,36 +1089,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1123,22 +1136,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Information.FromBits(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Information.FromBits(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1180,7 +1196,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Information.FromBits(1.0); - Assert.Equal(new {Information.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Information.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index c0d10394f7..48f79afd6c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class IrradianceTestsBase : QuantityTestsBase protected abstract double WattsPerSquareMeterInOneWattPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilowattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double PicowattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double PicowattsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double WattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double PicowattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double PicowattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double WattsPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(IrradianceUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -613,14 +613,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(IrradianceUnit unit) { - var inBaseUnits = Irradiance.From(1.0, Irradiance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Irradiance.From(1.0, Irradiance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Irradiance.From(1.0, Irradiance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(IrradianceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(IrradianceUnit unit) @@ -634,8 +641,8 @@ public void ToUnit_WithSameUnits_AreEqual(IrradianceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IrradianceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Irradiance.Units.Where(u => u != Irradiance.BaseUnit).DefaultIfEmpty(Irradiance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Irradiance.Units.First(u => u != Irradiance.BaseUnit); var quantity = Irradiance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -869,8 +876,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -904,36 +912,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -946,22 +959,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Irradiance.FromWattsPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1003,7 +1019,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(new {Irradiance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Irradiance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index db173e10e8..63fe8c16a7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase protected abstract double WattHoursPerSquareMeterInOneJoulePerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double JoulesPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double JoulesPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double JoulesPerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilowattHoursPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MillijoulesPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double WattHoursPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double JoulesPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double JoulesPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double JoulesPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilowattHoursPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MillijoulesPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double WattHoursPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(IrradiationUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -419,14 +419,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(IrradiationUnit unit) { - var inBaseUnits = Irradiation.From(1.0, Irradiation.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Irradiation.From(1.0, Irradiation.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Irradiation.From(1.0, Irradiation.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(IrradiationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(IrradiationUnit unit) @@ -440,8 +447,8 @@ public void ToUnit_WithSameUnits_AreEqual(IrradiationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IrradiationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Irradiation.Units.Where(u => u != Irradiation.BaseUnit).DefaultIfEmpty(Irradiation.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Irradiation.Units.First(u => u != Irradiation.BaseUnit); var quantity = Irradiation.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -654,8 +661,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -689,36 +697,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -731,22 +744,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Irradiation.FromJoulesPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -788,7 +804,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(new {Irradiation.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Irradiation.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index 4b8961c1d7..d1d835449e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class JerkTestsBase : QuantityTestsBase protected abstract double StandardGravitiesPerSecondInOneMeterPerSecondCubed { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double DecimetersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double FeetPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double InchesPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double KilometersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double MetersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double MicrometersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double MillimetersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double MillistandardGravitiesPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanometersPerSecondCubedTolerance { get { return 1e-5; } } - protected virtual double StandardGravitiesPerSecondTolerance { get { return 1e-5; } } + protected virtual double CentimetersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double DecimetersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double FeetPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double InchesPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double KilometersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double MetersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double MicrometersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double MillimetersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double MillistandardGravitiesPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanometersPerSecondCubedTolerance { get { return 1E-5; } } + protected virtual double StandardGravitiesPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(JerkUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -819,14 +819,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(JerkUnit unit) { - var inBaseUnits = Jerk.From(1.0, Jerk.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Jerk.From(1.0, Jerk.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Jerk.From(1.0, Jerk.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(JerkUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(JerkUnit unit) @@ -840,8 +847,8 @@ public void ToUnit_WithSameUnits_AreEqual(JerkUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(JerkUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Jerk.Units.Where(u => u != Jerk.BaseUnit).DefaultIfEmpty(Jerk.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Jerk.Units.First(u => u != Jerk.BaseUnit); var quantity = Jerk.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1066,8 +1073,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1101,36 +1109,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1143,22 +1156,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Jerk.FromMetersPerSecondCubed(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1200,7 +1216,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal(new {Jerk.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Jerk.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index aad81609de..113c50e125 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class KinematicViscosityTestsBase : QuantityTestsBase protected abstract double StokesInOneSquareMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentistokesTolerance { get { return 1e-5; } } - protected virtual double DecistokesTolerance { get { return 1e-5; } } - protected virtual double KilostokesTolerance { get { return 1e-5; } } - protected virtual double MicrostokesTolerance { get { return 1e-5; } } - protected virtual double MillistokesTolerance { get { return 1e-5; } } - protected virtual double NanostokesTolerance { get { return 1e-5; } } - protected virtual double SquareFeetPerSecondTolerance { get { return 1e-5; } } - protected virtual double SquareMetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double StokesTolerance { get { return 1e-5; } } + protected virtual double CentistokesTolerance { get { return 1E-5; } } + protected virtual double DecistokesTolerance { get { return 1E-5; } } + protected virtual double KilostokesTolerance { get { return 1E-5; } } + protected virtual double MicrostokesTolerance { get { return 1E-5; } } + protected virtual double MillistokesTolerance { get { return 1E-5; } } + protected virtual double NanostokesTolerance { get { return 1E-5; } } + protected virtual double SquareFeetPerSecondTolerance { get { return 1E-5; } } + protected virtual double SquareMetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double StokesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(KinematicViscosityUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -679,14 +679,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(KinematicViscosityUnit unit) { - var inBaseUnits = KinematicViscosity.From(1.0, KinematicViscosity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = KinematicViscosity.From(1.0, KinematicViscosity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = KinematicViscosity.From(1.0, KinematicViscosity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(KinematicViscosityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(KinematicViscosityUnit unit) @@ -700,8 +707,8 @@ public void ToUnit_WithSameUnits_AreEqual(KinematicViscosityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(KinematicViscosityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = KinematicViscosity.Units.Where(u => u != KinematicViscosity.BaseUnit).DefaultIfEmpty(KinematicViscosity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = KinematicViscosity.Units.First(u => u != KinematicViscosity.BaseUnit); var quantity = KinematicViscosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -920,8 +927,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -955,36 +963,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -997,22 +1010,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1054,7 +1070,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(new {KinematicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(KinematicViscosity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 840ff97042..6402bac337 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class LapseRateTestsBase : QuantityTestsBase protected abstract double DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1e-5; } } + protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LapseRateUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LapseRateUnit unit) { - var inBaseUnits = LapseRate.From(1.0, LapseRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = LapseRate.From(1.0, LapseRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = LapseRate.From(1.0, LapseRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LapseRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LapseRateUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(LapseRateUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LapseRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LapseRate.Units.Where(u => u != LapseRate.BaseUnit).DefaultIfEmpty(LapseRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = LapseRate.Units.First(u => u != LapseRate.BaseUnit); var quantity = LapseRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(new {LapseRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(LapseRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index b063af3c1d..cd116fb5be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -76,42 +76,42 @@ public abstract partial class LengthTestsBase : QuantityTestsBase protected abstract double YardsInOneMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AngstromsTolerance { get { return 1e-5; } } - protected virtual double AstronomicalUnitsTolerance { get { return 1e-5; } } - protected virtual double CentimetersTolerance { get { return 1e-5; } } - protected virtual double ChainsTolerance { get { return 1e-5; } } - protected virtual double DataMilesTolerance { get { return 1e-5; } } - protected virtual double DecametersTolerance { get { return 1e-5; } } - protected virtual double DecimetersTolerance { get { return 1e-5; } } - protected virtual double DtpPicasTolerance { get { return 1e-5; } } - protected virtual double DtpPointsTolerance { get { return 1e-5; } } - protected virtual double FathomsTolerance { get { return 1e-5; } } - protected virtual double FeetTolerance { get { return 1e-5; } } - protected virtual double HandsTolerance { get { return 1e-5; } } - protected virtual double HectometersTolerance { get { return 1e-5; } } - protected virtual double InchesTolerance { get { return 1e-5; } } - protected virtual double KilolightYearsTolerance { get { return 1e-5; } } - protected virtual double KilometersTolerance { get { return 1e-5; } } - protected virtual double KiloparsecsTolerance { get { return 1e-5; } } - protected virtual double LightYearsTolerance { get { return 1e-5; } } - protected virtual double MegalightYearsTolerance { get { return 1e-5; } } - protected virtual double MegaparsecsTolerance { get { return 1e-5; } } - protected virtual double MetersTolerance { get { return 1e-5; } } - protected virtual double MicroinchesTolerance { get { return 1e-5; } } - protected virtual double MicrometersTolerance { get { return 1e-5; } } - protected virtual double MilsTolerance { get { return 1e-5; } } - protected virtual double MilesTolerance { get { return 1e-5; } } - protected virtual double MillimetersTolerance { get { return 1e-5; } } - protected virtual double NanometersTolerance { get { return 1e-5; } } - protected virtual double NauticalMilesTolerance { get { return 1e-5; } } - protected virtual double ParsecsTolerance { get { return 1e-5; } } - protected virtual double PrinterPicasTolerance { get { return 1e-5; } } - protected virtual double PrinterPointsTolerance { get { return 1e-5; } } - protected virtual double ShacklesTolerance { get { return 1e-5; } } - protected virtual double SolarRadiusesTolerance { get { return 1e-5; } } - protected virtual double TwipsTolerance { get { return 1e-5; } } - protected virtual double UsSurveyFeetTolerance { get { return 1e-5; } } - protected virtual double YardsTolerance { get { return 1e-5; } } + protected virtual double AngstromsTolerance { get { return 1E-5; } } + protected virtual double AstronomicalUnitsTolerance { get { return 1E-5; } } + protected virtual double CentimetersTolerance { get { return 1E-5; } } + protected virtual double ChainsTolerance { get { return 1E-5; } } + protected virtual double DataMilesTolerance { get { return 1E-5; } } + protected virtual double DecametersTolerance { get { return 1E-5; } } + protected virtual double DecimetersTolerance { get { return 1E-5; } } + protected virtual double DtpPicasTolerance { get { return 1E-5; } } + protected virtual double DtpPointsTolerance { get { return 1E-5; } } + protected virtual double FathomsTolerance { get { return 1E-5; } } + protected virtual double FeetTolerance { get { return 1E-5; } } + protected virtual double HandsTolerance { get { return 1E-5; } } + protected virtual double HectometersTolerance { get { return 1E-5; } } + protected virtual double InchesTolerance { get { return 1E-5; } } + protected virtual double KilolightYearsTolerance { get { return 1E-5; } } + protected virtual double KilometersTolerance { get { return 1E-5; } } + protected virtual double KiloparsecsTolerance { get { return 1E-5; } } + protected virtual double LightYearsTolerance { get { return 1E-5; } } + protected virtual double MegalightYearsTolerance { get { return 1E-5; } } + protected virtual double MegaparsecsTolerance { get { return 1E-5; } } + protected virtual double MetersTolerance { get { return 1E-5; } } + protected virtual double MicroinchesTolerance { get { return 1E-5; } } + protected virtual double MicrometersTolerance { get { return 1E-5; } } + protected virtual double MilsTolerance { get { return 1E-5; } } + protected virtual double MilesTolerance { get { return 1E-5; } } + protected virtual double MillimetersTolerance { get { return 1E-5; } } + protected virtual double NanometersTolerance { get { return 1E-5; } } + protected virtual double NauticalMilesTolerance { get { return 1E-5; } } + protected virtual double ParsecsTolerance { get { return 1E-5; } } + protected virtual double PrinterPicasTolerance { get { return 1E-5; } } + protected virtual double PrinterPointsTolerance { get { return 1E-5; } } + protected virtual double ShacklesTolerance { get { return 1E-5; } } + protected virtual double SolarRadiusesTolerance { get { return 1E-5; } } + protected virtual double TwipsTolerance { get { return 1E-5; } } + protected virtual double UsSurveyFeetTolerance { get { return 1E-5; } } + protected virtual double YardsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LengthUnit unit) @@ -508,7 +508,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2209,14 +2209,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LengthUnit unit) { - var inBaseUnits = Length.From(1.0, Length.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Length.From(1.0, Length.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Length.From(1.0, Length.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LengthUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LengthUnit unit) @@ -2230,8 +2237,8 @@ public void ToUnit_WithSameUnits_AreEqual(LengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LengthUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Length.Units.Where(u => u != Length.BaseUnit).DefaultIfEmpty(Length.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Length.Units.First(u => u != Length.BaseUnit); var quantity = Length.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2531,8 +2538,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2566,36 +2574,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2608,22 +2621,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Length.FromMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Length.FromMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2665,7 +2681,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Length.FromMeters(1.0); - Assert.Equal(new {Length.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Length.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index aa977dc3e4..db6fd2269e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class LevelTestsBase : QuantityTestsBase protected abstract double NepersInOneDecibel { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecibelsTolerance { get { return 1e-5; } } - protected virtual double NepersTolerance { get { return 1e-5; } } + protected virtual double DecibelsTolerance { get { return 1E-5; } } + protected virtual double NepersTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LevelUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,14 +249,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LevelUnit unit) { - var inBaseUnits = Level.From(1.0, Level.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Level.From(1.0, Level.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Level.From(1.0, Level.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LevelUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LevelUnit unit) @@ -270,8 +277,8 @@ public void ToUnit_WithSameUnits_AreEqual(LevelUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LevelUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Level.Units.Where(u => u != Level.BaseUnit).DefaultIfEmpty(Level.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Level.Units.First(u => u != Level.BaseUnit); var quantity = Level.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -473,8 +480,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -508,36 +516,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -550,22 +563,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Level.FromDecibels(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Level.FromDecibels(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -607,7 +623,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Level.FromDecibels(1.0); - Assert.Equal(new {Level.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Level.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index da6d13e43c..dc31e147c1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class LinearDensityTestsBase : QuantityTestsBase protected abstract double PoundsPerInchInOneKilogramPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerMeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double PoundsPerFootTolerance { get { return 1e-5; } } - protected virtual double PoundsPerInchTolerance { get { return 1e-5; } } + protected virtual double GramsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerMeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double PoundsPerFootTolerance { get { return 1E-5; } } + protected virtual double PoundsPerInchTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LinearDensityUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -657,14 +657,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LinearDensityUnit unit) { - var inBaseUnits = LinearDensity.From(1.0, LinearDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = LinearDensity.From(1.0, LinearDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = LinearDensity.From(1.0, LinearDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LinearDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LinearDensityUnit unit) @@ -678,8 +685,8 @@ public void ToUnit_WithSameUnits_AreEqual(LinearDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LinearDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LinearDensity.Units.Where(u => u != LinearDensity.BaseUnit).DefaultIfEmpty(LinearDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = LinearDensity.Units.First(u => u != LinearDensity.BaseUnit); var quantity = LinearDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -913,8 +920,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -948,36 +956,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -990,22 +1003,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = LinearDensity.FromKilogramsPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1047,7 +1063,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(new {LinearDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(LinearDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 89f251de69..457cb71019 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -65,31 +65,31 @@ public abstract partial class LinearPowerDensityTestsBase : QuantityTestsBase protected abstract double WattsPerMillimeterInOneWattPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigawattsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerFootTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerInchTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerMeterTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerFootTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerInchTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerFootTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerInchTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerFootTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerInchTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerMeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double WattsPerCentimeterTolerance { get { return 1e-5; } } - protected virtual double WattsPerFootTolerance { get { return 1e-5; } } - protected virtual double WattsPerInchTolerance { get { return 1e-5; } } - protected virtual double WattsPerMeterTolerance { get { return 1e-5; } } - protected virtual double WattsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerFootTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerInchTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerMeterTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerFootTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerInchTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerFootTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerInchTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerFootTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerInchTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerMeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double WattsPerCentimeterTolerance { get { return 1E-5; } } + protected virtual double WattsPerFootTolerance { get { return 1E-5; } } + protected virtual double WattsPerInchTolerance { get { return 1E-5; } } + protected virtual double WattsPerMeterTolerance { get { return 1E-5; } } + protected virtual double WattsPerMillimeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LinearPowerDensityUnit unit) @@ -398,7 +398,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -921,14 +921,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LinearPowerDensityUnit unit) { - var inBaseUnits = LinearPowerDensity.From(1.0, LinearPowerDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = LinearPowerDensity.From(1.0, LinearPowerDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = LinearPowerDensity.From(1.0, LinearPowerDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LinearPowerDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LinearPowerDensityUnit unit) @@ -942,8 +949,8 @@ public void ToUnit_WithSameUnits_AreEqual(LinearPowerDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LinearPowerDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LinearPowerDensity.Units.Where(u => u != LinearPowerDensity.BaseUnit).DefaultIfEmpty(LinearPowerDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = LinearPowerDensity.Units.First(u => u != LinearPowerDensity.BaseUnit); var quantity = LinearPowerDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1210,8 +1217,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1245,36 +1253,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1287,22 +1300,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = LinearPowerDensity.FromWattsPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1344,7 +1360,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(new {LinearPowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(LinearPowerDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 007e99449e..8849176e7d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class LuminosityTestsBase : QuantityTestsBase protected abstract double WattsInOneWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecawattsTolerance { get { return 1e-5; } } - protected virtual double DeciwattsTolerance { get { return 1e-5; } } - protected virtual double FemtowattsTolerance { get { return 1e-5; } } - protected virtual double GigawattsTolerance { get { return 1e-5; } } - protected virtual double KilowattsTolerance { get { return 1e-5; } } - protected virtual double MegawattsTolerance { get { return 1e-5; } } - protected virtual double MicrowattsTolerance { get { return 1e-5; } } - protected virtual double MilliwattsTolerance { get { return 1e-5; } } - protected virtual double NanowattsTolerance { get { return 1e-5; } } - protected virtual double PetawattsTolerance { get { return 1e-5; } } - protected virtual double PicowattsTolerance { get { return 1e-5; } } - protected virtual double SolarLuminositiesTolerance { get { return 1e-5; } } - protected virtual double TerawattsTolerance { get { return 1e-5; } } - protected virtual double WattsTolerance { get { return 1e-5; } } + protected virtual double DecawattsTolerance { get { return 1E-5; } } + protected virtual double DeciwattsTolerance { get { return 1E-5; } } + protected virtual double FemtowattsTolerance { get { return 1E-5; } } + protected virtual double GigawattsTolerance { get { return 1E-5; } } + protected virtual double KilowattsTolerance { get { return 1E-5; } } + protected virtual double MegawattsTolerance { get { return 1E-5; } } + protected virtual double MicrowattsTolerance { get { return 1E-5; } } + protected virtual double MilliwattsTolerance { get { return 1E-5; } } + protected virtual double NanowattsTolerance { get { return 1E-5; } } + protected virtual double PetawattsTolerance { get { return 1E-5; } } + protected virtual double PicowattsTolerance { get { return 1E-5; } } + protected virtual double SolarLuminositiesTolerance { get { return 1E-5; } } + protected virtual double TerawattsTolerance { get { return 1E-5; } } + protected virtual double WattsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LuminosityUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -613,14 +613,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LuminosityUnit unit) { - var inBaseUnits = Luminosity.From(1.0, Luminosity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Luminosity.From(1.0, Luminosity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Luminosity.From(1.0, Luminosity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LuminosityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LuminosityUnit unit) @@ -634,8 +641,8 @@ public void ToUnit_WithSameUnits_AreEqual(LuminosityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminosityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Luminosity.Units.Where(u => u != Luminosity.BaseUnit).DefaultIfEmpty(Luminosity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Luminosity.Units.First(u => u != Luminosity.BaseUnit); var quantity = Luminosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -869,8 +876,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -904,36 +912,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -946,22 +959,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Luminosity.FromWatts(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Luminosity.FromWatts(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1003,7 +1019,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(new {Luminosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Luminosity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index dcb107c35f..ad27f5af83 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class LuminousFluxTestsBase : QuantityTestsBase protected abstract double LumensInOneLumen { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double LumensTolerance { get { return 1e-5; } } + protected virtual double LumensTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LuminousFluxUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LuminousFluxUnit unit) { - var inBaseUnits = LuminousFlux.From(1.0, LuminousFlux.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = LuminousFlux.From(1.0, LuminousFlux.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = LuminousFlux.From(1.0, LuminousFlux.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LuminousFluxUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LuminousFluxUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(LuminousFluxUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminousFluxUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LuminousFlux.Units.Where(u => u != LuminousFlux.BaseUnit).DefaultIfEmpty(LuminousFlux.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = LuminousFlux.Units.First(u => u != LuminousFlux.BaseUnit); var quantity = LuminousFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = LuminousFlux.FromLumens(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(new {LuminousFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(LuminousFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index fcd3954377..04ec63b13a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class LuminousIntensityTestsBase : QuantityTestsBase protected abstract double CandelaInOneCandela { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CandelaTolerance { get { return 1e-5; } } + protected virtual double CandelaTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LuminousIntensityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LuminousIntensityUnit unit) { - var inBaseUnits = LuminousIntensity.From(1.0, LuminousIntensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = LuminousIntensity.From(1.0, LuminousIntensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = LuminousIntensity.From(1.0, LuminousIntensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(LuminousIntensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LuminousIntensityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(LuminousIntensityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminousIntensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = LuminousIntensity.Units.Where(u => u != LuminousIntensity.BaseUnit).DefaultIfEmpty(LuminousIntensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = LuminousIntensity.Units.First(u => u != LuminousIntensity.BaseUnit); var quantity = LuminousIntensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = LuminousIntensity.FromCandela(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(new {LuminousIntensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(LuminousIntensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 174b05b5bc..f0e1ec76db 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class MagneticFieldTestsBase : QuantityTestsBase protected abstract double TeslasInOneTesla { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GaussesTolerance { get { return 1e-5; } } - protected virtual double MicroteslasTolerance { get { return 1e-5; } } - protected virtual double MilligaussesTolerance { get { return 1e-5; } } - protected virtual double MilliteslasTolerance { get { return 1e-5; } } - protected virtual double NanoteslasTolerance { get { return 1e-5; } } - protected virtual double TeslasTolerance { get { return 1e-5; } } + protected virtual double GaussesTolerance { get { return 1E-5; } } + protected virtual double MicroteslasTolerance { get { return 1E-5; } } + protected virtual double MilligaussesTolerance { get { return 1E-5; } } + protected virtual double MilliteslasTolerance { get { return 1E-5; } } + protected virtual double NanoteslasTolerance { get { return 1E-5; } } + protected virtual double TeslasTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MagneticFieldUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -385,14 +385,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MagneticFieldUnit unit) { - var inBaseUnits = MagneticField.From(1.0, MagneticField.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MagneticField.From(1.0, MagneticField.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MagneticField.From(1.0, MagneticField.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MagneticFieldUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MagneticFieldUnit unit) @@ -406,8 +413,8 @@ public void ToUnit_WithSameUnits_AreEqual(MagneticFieldUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagneticFieldUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MagneticField.Units.Where(u => u != MagneticField.BaseUnit).DefaultIfEmpty(MagneticField.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MagneticField.Units.First(u => u != MagneticField.BaseUnit); var quantity = MagneticField.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -617,8 +624,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -652,36 +660,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -694,22 +707,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MagneticField.FromTeslas(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -751,7 +767,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(new {MagneticField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MagneticField.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index acee8f296b..d76291cc93 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class MagneticFluxTestsBase : QuantityTestsBase protected abstract double WebersInOneWeber { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double WebersTolerance { get { return 1e-5; } } + protected virtual double WebersTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MagneticFluxUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MagneticFluxUnit unit) { - var inBaseUnits = MagneticFlux.From(1.0, MagneticFlux.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MagneticFlux.From(1.0, MagneticFlux.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MagneticFlux.From(1.0, MagneticFlux.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MagneticFluxUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MagneticFluxUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(MagneticFluxUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagneticFluxUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MagneticFlux.Units.Where(u => u != MagneticFlux.BaseUnit).DefaultIfEmpty(MagneticFlux.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MagneticFlux.Units.First(u => u != MagneticFlux.BaseUnit); var quantity = MagneticFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MagneticFlux.FromWebers(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(new {MagneticFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MagneticFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index b6e2f93739..ea30c1f26e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class MagnetizationTestsBase : QuantityTestsBase protected abstract double AmperesPerMeterInOneAmperePerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesPerMeterTolerance { get { return 1e-5; } } + protected virtual double AmperesPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MagnetizationUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MagnetizationUnit unit) { - var inBaseUnits = Magnetization.From(1.0, Magnetization.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Magnetization.From(1.0, Magnetization.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Magnetization.From(1.0, Magnetization.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MagnetizationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MagnetizationUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(MagnetizationUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagnetizationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Magnetization.Units.Where(u => u != Magnetization.BaseUnit).DefaultIfEmpty(Magnetization.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Magnetization.Units.First(u => u != Magnetization.BaseUnit); var quantity = Magnetization.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Magnetization.FromAmperesPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(new {Magnetization.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Magnetization.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 4f1778b29c..9fceb48029 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -89,55 +89,55 @@ public abstract partial class MassConcentrationTestsBase : QuantityTestsBase protected abstract double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double GramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double GramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double GramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double KilopoundsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double OuncesPerImperialGallonTolerance { get { return 1e-5; } } - protected virtual double OuncesPerUSGallonTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerDeciliterTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerLiterTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerMicroliterTolerance { get { return 1e-5; } } - protected virtual double PicogramsPerMilliliterTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double PoundsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double PoundsPerImperialGallonTolerance { get { return 1e-5; } } - protected virtual double PoundsPerUSGallonTolerance { get { return 1e-5; } } - protected virtual double SlugsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double GramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double GramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double GramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double KilopoundsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double KilopoundsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double OuncesPerImperialGallonTolerance { get { return 1E-5; } } + protected virtual double OuncesPerUSGallonTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerDeciliterTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerLiterTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerMicroliterTolerance { get { return 1E-5; } } + protected virtual double PicogramsPerMilliliterTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double PoundsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double PoundsPerImperialGallonTolerance { get { return 1E-5; } } + protected virtual double PoundsPerUSGallonTolerance { get { return 1E-5; } } + protected virtual double SlugsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassConcentrationUnit unit) @@ -638,7 +638,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1943,14 +1943,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassConcentrationUnit unit) { - var inBaseUnits = MassConcentration.From(1.0, MassConcentration.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MassConcentration.From(1.0, MassConcentration.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MassConcentration.From(1.0, MassConcentration.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MassConcentrationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassConcentrationUnit unit) @@ -1964,8 +1971,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassConcentrationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassConcentrationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassConcentration.Units.Where(u => u != MassConcentration.BaseUnit).DefaultIfEmpty(MassConcentration.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MassConcentration.Units.First(u => u != MassConcentration.BaseUnit); var quantity = MassConcentration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2304,8 +2311,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2339,36 +2347,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2381,22 +2394,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2438,7 +2454,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(new {MassConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MassConcentration.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index d4696be3d2..93648bfbf7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -73,39 +73,39 @@ public abstract partial class MassFlowTestsBase : QuantityTestsBase protected abstract double TonnesPerHourInOneGramPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerDayTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecagramsPerDayTolerance { get { return 1e-5; } } - protected virtual double DecagramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerDayTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GramsPerDayTolerance { get { return 1e-5; } } - protected virtual double GramsPerHourTolerance { get { return 1e-5; } } - protected virtual double GramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double HectogramsPerDayTolerance { get { return 1e-5; } } - protected virtual double HectogramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerDayTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerHourTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegagramsPerDayTolerance { get { return 1e-5; } } - protected virtual double MegapoundsPerDayTolerance { get { return 1e-5; } } - protected virtual double MegapoundsPerHourTolerance { get { return 1e-5; } } - protected virtual double MegapoundsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double MegapoundsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerDayTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerDayTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerDayTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PoundsPerDayTolerance { get { return 1e-5; } } - protected virtual double PoundsPerHourTolerance { get { return 1e-5; } } - protected virtual double PoundsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double PoundsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ShortTonsPerHourTolerance { get { return 1e-5; } } - protected virtual double TonnesPerDayTolerance { get { return 1e-5; } } - protected virtual double TonnesPerHourTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerDayTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecagramsPerDayTolerance { get { return 1E-5; } } + protected virtual double DecagramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerDayTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double GramsPerDayTolerance { get { return 1E-5; } } + protected virtual double GramsPerHourTolerance { get { return 1E-5; } } + protected virtual double GramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double HectogramsPerDayTolerance { get { return 1E-5; } } + protected virtual double HectogramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerDayTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerHourTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MegagramsPerDayTolerance { get { return 1E-5; } } + protected virtual double MegapoundsPerDayTolerance { get { return 1E-5; } } + protected virtual double MegapoundsPerHourTolerance { get { return 1E-5; } } + protected virtual double MegapoundsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double MegapoundsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerDayTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerDayTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerDayTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerSecondTolerance { get { return 1E-5; } } + protected virtual double PoundsPerDayTolerance { get { return 1E-5; } } + protected virtual double PoundsPerHourTolerance { get { return 1E-5; } } + protected virtual double PoundsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double PoundsPerSecondTolerance { get { return 1E-5; } } + protected virtual double ShortTonsPerHourTolerance { get { return 1E-5; } } + protected virtual double TonnesPerDayTolerance { get { return 1E-5; } } + protected virtual double TonnesPerHourTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassFlowUnit unit) @@ -478,7 +478,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1545,14 +1545,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassFlowUnit unit) { - var inBaseUnits = MassFlow.From(1.0, MassFlow.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MassFlow.From(1.0, MassFlow.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MassFlow.From(1.0, MassFlow.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MassFlowUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassFlowUnit unit) @@ -1566,8 +1573,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassFlowUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFlowUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassFlow.Units.Where(u => u != MassFlow.BaseUnit).DefaultIfEmpty(MassFlow.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MassFlow.Units.First(u => u != MassFlow.BaseUnit); var quantity = MassFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1858,8 +1865,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1893,36 +1901,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1935,22 +1948,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MassFlow.FromGramsPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1992,7 +2008,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(new {MassFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MassFlow.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 54a6e654cf..629a37cbb0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -52,18 +52,18 @@ public abstract partial class MassFluxTestsBase : QuantityTestsBase protected abstract double KilogramsPerSecondPerSquareMillimeterInOneKilogramPerSecondPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerHourPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerHourPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerHourPerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerSecondPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerSecondPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double GramsPerSecondPerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerHourPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerHourPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerHourPerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerSecondPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerSecondPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerSecondPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerHourPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerHourPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerHourPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerSecondPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerSecondPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerSecondPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerHourPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerHourPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerHourPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerSecondPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerSecondPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerSecondPerSquareMillimeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassFluxUnit unit) @@ -268,7 +268,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -589,14 +589,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassFluxUnit unit) { - var inBaseUnits = MassFlux.From(1.0, MassFlux.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MassFlux.From(1.0, MassFlux.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MassFlux.From(1.0, MassFlux.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MassFluxUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassFluxUnit unit) @@ -610,8 +617,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassFluxUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFluxUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassFlux.Units.Where(u => u != MassFlux.BaseUnit).DefaultIfEmpty(MassFlux.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MassFlux.Units.First(u => u != MassFlux.BaseUnit); var quantity = MassFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -839,8 +846,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -874,36 +882,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -916,22 +929,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -973,7 +989,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(new {MassFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MassFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 1cdfeb11b5..00b3490646 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -64,30 +64,30 @@ public abstract partial class MassFractionTestsBase : QuantityTestsBase protected abstract double PercentInOneDecimalFraction { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerGramTolerance { get { return 1e-5; } } - protected virtual double CentigramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double DecagramsPerGramTolerance { get { return 1e-5; } } - protected virtual double DecagramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerGramTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } - protected virtual double GramsPerGramTolerance { get { return 1e-5; } } - protected virtual double GramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double HectogramsPerGramTolerance { get { return 1e-5; } } - protected virtual double HectogramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerGramTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerGramTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerGramTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerGramTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerKilogramTolerance { get { return 1e-5; } } - protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } - protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } - protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } - protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } - protected virtual double PercentTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerGramTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double DecagramsPerGramTolerance { get { return 1E-5; } } + protected virtual double DecagramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerGramTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double DecimalFractionsTolerance { get { return 1E-5; } } + protected virtual double GramsPerGramTolerance { get { return 1E-5; } } + protected virtual double GramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double HectogramsPerGramTolerance { get { return 1E-5; } } + protected virtual double HectogramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerGramTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerGramTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerGramTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerGramTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerKilogramTolerance { get { return 1E-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1E-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1E-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1E-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1E-5; } } + protected virtual double PercentTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassFractionUnit unit) @@ -388,7 +388,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1021,14 +1021,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassFractionUnit unit) { - var inBaseUnits = MassFraction.From(1.0, MassFraction.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MassFraction.From(1.0, MassFraction.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MassFraction.From(1.0, MassFraction.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MassFractionUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassFractionUnit unit) @@ -1042,8 +1049,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassFractionUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFractionUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassFraction.Units.Where(u => u != MassFraction.BaseUnit).DefaultIfEmpty(MassFraction.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MassFraction.Units.First(u => u != MassFraction.BaseUnit); var quantity = MassFraction.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1307,8 +1314,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1342,36 +1350,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1384,22 +1397,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MassFraction.FromDecimalFractions(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1441,7 +1457,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(new {MassFraction.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MassFraction.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 12f6d91b6e..ae4900fe18 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -68,34 +68,34 @@ public abstract partial class MassMomentOfInertiaTestsBase : QuantityTestsBase protected abstract double TonneSquareMilimetersInOneKilogramSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double GramSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double GramSquareMetersTolerance { get { return 1e-5; } } - protected virtual double GramSquareMillimetersTolerance { get { return 1e-5; } } - protected virtual double KilogramSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double KilogramSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double KilogramSquareMetersTolerance { get { return 1e-5; } } - protected virtual double KilogramSquareMillimetersTolerance { get { return 1e-5; } } - protected virtual double KilotonneSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double KilotonneSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double KilotonneSquareMetersTolerance { get { return 1e-5; } } - protected virtual double KilotonneSquareMilimetersTolerance { get { return 1e-5; } } - protected virtual double MegatonneSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double MegatonneSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double MegatonneSquareMetersTolerance { get { return 1e-5; } } - protected virtual double MegatonneSquareMilimetersTolerance { get { return 1e-5; } } - protected virtual double MilligramSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double MilligramSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double MilligramSquareMetersTolerance { get { return 1e-5; } } - protected virtual double MilligramSquareMillimetersTolerance { get { return 1e-5; } } - protected virtual double PoundSquareFeetTolerance { get { return 1e-5; } } - protected virtual double PoundSquareInchesTolerance { get { return 1e-5; } } - protected virtual double SlugSquareFeetTolerance { get { return 1e-5; } } - protected virtual double SlugSquareInchesTolerance { get { return 1e-5; } } - protected virtual double TonneSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double TonneSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double TonneSquareMetersTolerance { get { return 1e-5; } } - protected virtual double TonneSquareMilimetersTolerance { get { return 1e-5; } } + protected virtual double GramSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double GramSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double GramSquareMetersTolerance { get { return 1E-5; } } + protected virtual double GramSquareMillimetersTolerance { get { return 1E-5; } } + protected virtual double KilogramSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double KilogramSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double KilogramSquareMetersTolerance { get { return 1E-5; } } + protected virtual double KilogramSquareMillimetersTolerance { get { return 1E-5; } } + protected virtual double KilotonneSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double KilotonneSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double KilotonneSquareMetersTolerance { get { return 1E-5; } } + protected virtual double KilotonneSquareMilimetersTolerance { get { return 1E-5; } } + protected virtual double MegatonneSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double MegatonneSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double MegatonneSquareMetersTolerance { get { return 1E-5; } } + protected virtual double MegatonneSquareMilimetersTolerance { get { return 1E-5; } } + protected virtual double MilligramSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double MilligramSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double MilligramSquareMetersTolerance { get { return 1E-5; } } + protected virtual double MilligramSquareMillimetersTolerance { get { return 1E-5; } } + protected virtual double PoundSquareFeetTolerance { get { return 1E-5; } } + protected virtual double PoundSquareInchesTolerance { get { return 1E-5; } } + protected virtual double SlugSquareFeetTolerance { get { return 1E-5; } } + protected virtual double SlugSquareInchesTolerance { get { return 1E-5; } } + protected virtual double TonneSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double TonneSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double TonneSquareMetersTolerance { get { return 1E-5; } } + protected virtual double TonneSquareMilimetersTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassMomentOfInertiaUnit unit) @@ -428,7 +428,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1133,14 +1133,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassMomentOfInertiaUnit unit) { - var inBaseUnits = MassMomentOfInertia.From(1.0, MassMomentOfInertia.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MassMomentOfInertia.From(1.0, MassMomentOfInertia.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MassMomentOfInertia.From(1.0, MassMomentOfInertia.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MassMomentOfInertiaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassMomentOfInertiaUnit unit) @@ -1154,8 +1161,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassMomentOfInertiaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassMomentOfInertiaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MassMomentOfInertia.Units.Where(u => u != MassMomentOfInertia.BaseUnit).DefaultIfEmpty(MassMomentOfInertia.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MassMomentOfInertia.Units.First(u => u != MassMomentOfInertia.BaseUnit); var quantity = MassMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1431,8 +1438,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1466,36 +1474,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1508,22 +1521,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1565,7 +1581,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(new {MassMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MassMomentOfInertia.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index aee8d32ea4..53bbe5b415 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -65,31 +65,31 @@ public abstract partial class MassTestsBase : QuantityTestsBase protected abstract double TonnesInOneKilogram { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsTolerance { get { return 1e-5; } } - protected virtual double DecagramsTolerance { get { return 1e-5; } } - protected virtual double DecigramsTolerance { get { return 1e-5; } } - protected virtual double EarthMassesTolerance { get { return 1e-5; } } - protected virtual double GrainsTolerance { get { return 1e-5; } } - protected virtual double GramsTolerance { get { return 1e-5; } } - protected virtual double HectogramsTolerance { get { return 1e-5; } } - protected virtual double KilogramsTolerance { get { return 1e-5; } } - protected virtual double KilopoundsTolerance { get { return 1e-5; } } - protected virtual double KilotonnesTolerance { get { return 1e-5; } } - protected virtual double LongHundredweightTolerance { get { return 1e-5; } } - protected virtual double LongTonsTolerance { get { return 1e-5; } } - protected virtual double MegapoundsTolerance { get { return 1e-5; } } - protected virtual double MegatonnesTolerance { get { return 1e-5; } } - protected virtual double MicrogramsTolerance { get { return 1e-5; } } - protected virtual double MilligramsTolerance { get { return 1e-5; } } - protected virtual double NanogramsTolerance { get { return 1e-5; } } - protected virtual double OuncesTolerance { get { return 1e-5; } } - protected virtual double PoundsTolerance { get { return 1e-5; } } - protected virtual double ShortHundredweightTolerance { get { return 1e-5; } } - protected virtual double ShortTonsTolerance { get { return 1e-5; } } - protected virtual double SlugsTolerance { get { return 1e-5; } } - protected virtual double SolarMassesTolerance { get { return 1e-5; } } - protected virtual double StoneTolerance { get { return 1e-5; } } - protected virtual double TonnesTolerance { get { return 1e-5; } } + protected virtual double CentigramsTolerance { get { return 1E-5; } } + protected virtual double DecagramsTolerance { get { return 1E-5; } } + protected virtual double DecigramsTolerance { get { return 1E-5; } } + protected virtual double EarthMassesTolerance { get { return 1E-5; } } + protected virtual double GrainsTolerance { get { return 1E-5; } } + protected virtual double GramsTolerance { get { return 1E-5; } } + protected virtual double HectogramsTolerance { get { return 1E-5; } } + protected virtual double KilogramsTolerance { get { return 1E-5; } } + protected virtual double KilopoundsTolerance { get { return 1E-5; } } + protected virtual double KilotonnesTolerance { get { return 1E-5; } } + protected virtual double LongHundredweightTolerance { get { return 1E-5; } } + protected virtual double LongTonsTolerance { get { return 1E-5; } } + protected virtual double MegapoundsTolerance { get { return 1E-5; } } + protected virtual double MegatonnesTolerance { get { return 1E-5; } } + protected virtual double MicrogramsTolerance { get { return 1E-5; } } + protected virtual double MilligramsTolerance { get { return 1E-5; } } + protected virtual double NanogramsTolerance { get { return 1E-5; } } + protected virtual double OuncesTolerance { get { return 1E-5; } } + protected virtual double PoundsTolerance { get { return 1E-5; } } + protected virtual double ShortHundredweightTolerance { get { return 1E-5; } } + protected virtual double ShortTonsTolerance { get { return 1E-5; } } + protected virtual double SlugsTolerance { get { return 1E-5; } } + protected virtual double SolarMassesTolerance { get { return 1E-5; } } + protected virtual double StoneTolerance { get { return 1E-5; } } + protected virtual double TonnesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassUnit unit) @@ -398,7 +398,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2019,14 +2019,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassUnit unit) { - var inBaseUnits = Mass.From(1.0, Mass.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Mass.From(1.0, Mass.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Mass.From(1.0, Mass.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MassUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassUnit unit) @@ -2040,8 +2047,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Mass.Units.Where(u => u != Mass.BaseUnit).DefaultIfEmpty(Mass.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Mass.Units.First(u => u != Mass.BaseUnit); var quantity = Mass.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2308,8 +2315,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2343,36 +2351,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2385,22 +2398,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Mass.FromKilograms(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Mass.FromKilograms(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2442,7 +2458,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(new {Mass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Mass.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index d02524f56e..67173dd576 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class MolarEnergyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerMoleInOneJoulePerMole { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double JoulesPerMoleTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerMoleTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerMoleTolerance { get { return 1e-5; } } + protected virtual double JoulesPerMoleTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerMoleTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerMoleTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarEnergyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarEnergyUnit unit) { - var inBaseUnits = MolarEnergy.From(1.0, MolarEnergy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MolarEnergy.From(1.0, MolarEnergy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MolarEnergy.From(1.0, MolarEnergy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MolarEnergyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarEnergyUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarEnergyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MolarEnergy.Units.Where(u => u != MolarEnergy.BaseUnit).DefaultIfEmpty(MolarEnergy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MolarEnergy.Units.First(u => u != MolarEnergy.BaseUnit); var quantity = MolarEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MolarEnergy.FromJoulesPerMole(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(new {MolarEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MolarEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 78a88ecb39..27d2a3f3ef 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class MolarEntropyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double JoulesPerMoleKelvinTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1e-5; } } + protected virtual double JoulesPerMoleKelvinTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarEntropyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarEntropyUnit unit) { - var inBaseUnits = MolarEntropy.From(1.0, MolarEntropy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MolarEntropy.From(1.0, MolarEntropy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MolarEntropy.From(1.0, MolarEntropy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MolarEntropyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarEntropyUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarEntropyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarEntropyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MolarEntropy.Units.Where(u => u != MolarEntropy.BaseUnit).DefaultIfEmpty(MolarEntropy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MolarEntropy.Units.First(u => u != MolarEntropy.BaseUnit); var quantity = MolarEntropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(new {MolarEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MolarEntropy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index ffe0f30f77..1386699ba0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -52,18 +52,18 @@ public abstract partial class MolarMassTestsBase : QuantityTestsBase protected abstract double PoundsPerMoleInOneKilogramPerMole { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double DecagramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double DecigramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double GramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double HectogramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double KilopoundsPerMoleTolerance { get { return 1e-5; } } - protected virtual double MegapoundsPerMoleTolerance { get { return 1e-5; } } - protected virtual double MicrogramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double MilligramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double NanogramsPerMoleTolerance { get { return 1e-5; } } - protected virtual double PoundsPerMoleTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double DecagramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double DecigramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double GramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double HectogramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double KilopoundsPerMoleTolerance { get { return 1E-5; } } + protected virtual double MegapoundsPerMoleTolerance { get { return 1E-5; } } + protected virtual double MicrogramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double MilligramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double NanogramsPerMoleTolerance { get { return 1E-5; } } + protected virtual double PoundsPerMoleTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarMassUnit unit) @@ -268,7 +268,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -877,14 +877,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarMassUnit unit) { - var inBaseUnits = MolarMass.From(1.0, MolarMass.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = MolarMass.From(1.0, MolarMass.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = MolarMass.From(1.0, MolarMass.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MolarMassUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarMassUnit unit) @@ -898,8 +905,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarMassUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarMassUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = MolarMass.Units.Where(u => u != MolarMass.BaseUnit).DefaultIfEmpty(MolarMass.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = MolarMass.Units.First(u => u != MolarMass.BaseUnit); var quantity = MolarMass.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1127,8 +1134,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1162,36 +1170,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1204,22 +1217,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = MolarMass.FromKilogramsPerMole(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1261,7 +1277,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(new {MolarMass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(MolarMass.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 923b01a6b3..960cddfa8f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class MolarityTestsBase : QuantityTestsBase protected abstract double PicomolesPerLiterInOneMolesPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double DecimolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double FemtomolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double MicromolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double MillimolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double MolesPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double NanomolesPerLiterTolerance { get { return 1e-5; } } - protected virtual double PicomolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double CentimolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double DecimolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double FemtomolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double MicromolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double MillimolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double MolesPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double NanomolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double PicomolesPerLiterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarityUnit unit) @@ -302,7 +302,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -578,14 +578,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarityUnit unit) { - var inBaseUnits = Molarity.From(1.0, Molarity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Molarity.From(1.0, Molarity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Molarity.From(1.0, Molarity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(MolarityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarityUnit unit) @@ -599,8 +606,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Molarity.Units.Where(u => u != Molarity.BaseUnit).DefaultIfEmpty(Molarity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Molarity.Units.First(u => u != Molarity.BaseUnit); var quantity = Molarity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -843,8 +850,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -878,36 +886,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -920,22 +933,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Molarity.FromMolesPerCubicMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -977,7 +993,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(new {Molarity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Molarity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index af5bee7872..748184a20e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class PermeabilityTestsBase : QuantityTestsBase protected abstract double HenriesPerMeterInOneHenryPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double HenriesPerMeterTolerance { get { return 1e-5; } } + protected virtual double HenriesPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PermeabilityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PermeabilityUnit unit) { - var inBaseUnits = Permeability.From(1.0, Permeability.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Permeability.From(1.0, Permeability.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Permeability.From(1.0, Permeability.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PermeabilityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PermeabilityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(PermeabilityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PermeabilityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Permeability.Units.Where(u => u != Permeability.BaseUnit).DefaultIfEmpty(Permeability.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Permeability.Units.First(u => u != Permeability.BaseUnit); var quantity = Permeability.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Permeability.FromHenriesPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(new {Permeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Permeability.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 1a1aa929fa..4e6467c7df 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class PermittivityTestsBase : QuantityTestsBase protected abstract double FaradsPerMeterInOneFaradPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double FaradsPerMeterTolerance { get { return 1e-5; } } + protected virtual double FaradsPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PermittivityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PermittivityUnit unit) { - var inBaseUnits = Permittivity.From(1.0, Permittivity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Permittivity.From(1.0, Permittivity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Permittivity.From(1.0, Permittivity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PermittivityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PermittivityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(PermittivityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PermittivityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Permittivity.Units.Where(u => u != Permittivity.BaseUnit).DefaultIfEmpty(Permittivity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Permittivity.Units.First(u => u != Permittivity.BaseUnit); var quantity = Permittivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Permittivity.FromFaradsPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(new {Permittivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Permittivity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 88b7bcfa81..414490e545 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class PorousMediumPermeabilityTestsBase : QuantityTestsB protected abstract double SquareMetersInOneSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DarcysTolerance { get { return 1e-5; } } - protected virtual double MicrodarcysTolerance { get { return 1e-5; } } - protected virtual double MillidarcysTolerance { get { return 1e-5; } } - protected virtual double SquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double SquareMetersTolerance { get { return 1e-5; } } + protected virtual double DarcysTolerance { get { return 1E-5; } } + protected virtual double MicrodarcysTolerance { get { return 1E-5; } } + protected virtual double MillidarcysTolerance { get { return 1E-5; } } + protected virtual double SquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double SquareMetersTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PorousMediumPermeabilityUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -351,14 +351,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PorousMediumPermeabilityUnit unit) { - var inBaseUnits = PorousMediumPermeability.From(1.0, PorousMediumPermeability.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = PorousMediumPermeability.From(1.0, PorousMediumPermeability.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = PorousMediumPermeability.From(1.0, PorousMediumPermeability.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PorousMediumPermeabilityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PorousMediumPermeabilityUnit unit) @@ -372,8 +379,8 @@ public void ToUnit_WithSameUnits_AreEqual(PorousMediumPermeabilityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PorousMediumPermeabilityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PorousMediumPermeability.Units.Where(u => u != PorousMediumPermeability.BaseUnit).DefaultIfEmpty(PorousMediumPermeability.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = PorousMediumPermeability.Units.First(u => u != PorousMediumPermeability.BaseUnit); var quantity = PorousMediumPermeability.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -580,8 +587,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -615,36 +623,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -657,22 +670,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = PorousMediumPermeability.FromSquareMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -714,7 +730,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal(new {PorousMediumPermeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(PorousMediumPermeability.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 9888200c48..82d5a94817 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -84,50 +84,50 @@ public abstract partial class PowerDensityTestsBase : QuantityTestsBase protected abstract double WattsPerLiterInOneWattPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecawattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double DecawattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double DecawattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double DecawattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double DeciwattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double DeciwattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double DeciwattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double DeciwattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double GigawattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double KilowattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MegawattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MicrowattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double MilliwattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double NanowattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double PicowattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double PicowattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double PicowattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double PicowattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double TerawattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double TerawattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double TerawattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double TerawattsPerLiterTolerance { get { return 1e-5; } } - protected virtual double WattsPerCubicFootTolerance { get { return 1e-5; } } - protected virtual double WattsPerCubicInchTolerance { get { return 1e-5; } } - protected virtual double WattsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double WattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double DecawattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double DecawattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double DecawattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double DecawattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double DeciwattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double DeciwattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double DeciwattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double DeciwattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MegawattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MicrowattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double MilliwattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double NanowattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double PicowattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double PicowattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double PicowattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double PicowattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double TerawattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double TerawattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double TerawattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double TerawattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double WattsPerCubicFootTolerance { get { return 1E-5; } } + protected virtual double WattsPerCubicInchTolerance { get { return 1E-5; } } + protected virtual double WattsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double WattsPerLiterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerDensityUnit unit) @@ -588,7 +588,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1589,14 +1589,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PowerDensityUnit unit) { - var inBaseUnits = PowerDensity.From(1.0, PowerDensity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = PowerDensity.From(1.0, PowerDensity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = PowerDensity.From(1.0, PowerDensity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PowerDensityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PowerDensityUnit unit) @@ -1610,8 +1617,8 @@ public void ToUnit_WithSameUnits_AreEqual(PowerDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerDensityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PowerDensity.Units.Where(u => u != PowerDensity.BaseUnit).DefaultIfEmpty(PowerDensity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = PowerDensity.Units.First(u => u != PowerDensity.BaseUnit); var quantity = PowerDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1935,8 +1942,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1970,36 +1978,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2012,22 +2025,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = PowerDensity.FromWattsPerCubicMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2069,7 +2085,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(new {PowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(PowerDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 3cd613b917..42ab82780f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class PowerRatioTestsBase : QuantityTestsBase protected abstract double DecibelWattsInOneDecibelWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecibelMilliwattsTolerance { get { return 1e-5; } } - protected virtual double DecibelWattsTolerance { get { return 1e-5; } } + protected virtual double DecibelMilliwattsTolerance { get { return 1E-5; } } + protected virtual double DecibelWattsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerRatioUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -273,14 +273,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PowerRatioUnit unit) { - var inBaseUnits = PowerRatio.From(1.0, PowerRatio.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = PowerRatio.From(1.0, PowerRatio.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = PowerRatio.From(1.0, PowerRatio.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PowerRatioUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PowerRatioUnit unit) @@ -294,8 +301,8 @@ public void ToUnit_WithSameUnits_AreEqual(PowerRatioUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerRatioUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PowerRatio.Units.Where(u => u != PowerRatio.BaseUnit).DefaultIfEmpty(PowerRatio.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = PowerRatio.Units.First(u => u != PowerRatio.BaseUnit); var quantity = PowerRatio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -497,8 +504,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -532,36 +540,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -574,22 +587,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = PowerRatio.FromDecibelWatts(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -631,7 +647,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(new {PowerRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(PowerRatio.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 84e4e66f28..99130bf8c2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class PowerTestsBase : QuantityTestsBase { - protected abstract double BoilerHorsepowerInOneWatt { get; } - protected abstract double BritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double DecawattsInOneWatt { get; } - protected abstract double DeciwattsInOneWatt { get; } - protected abstract double ElectricalHorsepowerInOneWatt { get; } - protected abstract double FemtowattsInOneWatt { get; } - protected abstract double GigajoulesPerHourInOneWatt { get; } - protected abstract double GigawattsInOneWatt { get; } - protected abstract double HydraulicHorsepowerInOneWatt { get; } - protected abstract double JoulesPerHourInOneWatt { get; } - protected abstract double KilobritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double KilojoulesPerHourInOneWatt { get; } - protected abstract double KilowattsInOneWatt { get; } - protected abstract double MechanicalHorsepowerInOneWatt { get; } - protected abstract double MegabritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double MegajoulesPerHourInOneWatt { get; } - protected abstract double MegawattsInOneWatt { get; } - protected abstract double MetricHorsepowerInOneWatt { get; } - protected abstract double MicrowattsInOneWatt { get; } - protected abstract double MillijoulesPerHourInOneWatt { get; } - protected abstract double MilliwattsInOneWatt { get; } - protected abstract double NanowattsInOneWatt { get; } - protected abstract double PetawattsInOneWatt { get; } - protected abstract double PicowattsInOneWatt { get; } - protected abstract double TerawattsInOneWatt { get; } - protected abstract double WattsInOneWatt { get; } + protected abstract decimal BoilerHorsepowerInOneWatt { get; } + protected abstract decimal BritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal DecawattsInOneWatt { get; } + protected abstract decimal DeciwattsInOneWatt { get; } + protected abstract decimal ElectricalHorsepowerInOneWatt { get; } + protected abstract decimal FemtowattsInOneWatt { get; } + protected abstract decimal GigajoulesPerHourInOneWatt { get; } + protected abstract decimal GigawattsInOneWatt { get; } + protected abstract decimal HydraulicHorsepowerInOneWatt { get; } + protected abstract decimal JoulesPerHourInOneWatt { get; } + protected abstract decimal KilobritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal KilojoulesPerHourInOneWatt { get; } + protected abstract decimal KilowattsInOneWatt { get; } + protected abstract decimal MechanicalHorsepowerInOneWatt { get; } + protected abstract decimal MegabritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal MegajoulesPerHourInOneWatt { get; } + protected abstract decimal MegawattsInOneWatt { get; } + protected abstract decimal MetricHorsepowerInOneWatt { get; } + protected abstract decimal MicrowattsInOneWatt { get; } + protected abstract decimal MillijoulesPerHourInOneWatt { get; } + protected abstract decimal MilliwattsInOneWatt { get; } + protected abstract decimal NanowattsInOneWatt { get; } + protected abstract decimal PetawattsInOneWatt { get; } + protected abstract decimal PicowattsInOneWatt { get; } + protected abstract decimal TerawattsInOneWatt { get; } + protected abstract decimal WattsInOneWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BoilerHorsepowerTolerance { get { return 1e-5; } } - protected virtual double BritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double DecawattsTolerance { get { return 1e-5; } } - protected virtual double DeciwattsTolerance { get { return 1e-5; } } - protected virtual double ElectricalHorsepowerTolerance { get { return 1e-5; } } - protected virtual double FemtowattsTolerance { get { return 1e-5; } } - protected virtual double GigajoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double GigawattsTolerance { get { return 1e-5; } } - protected virtual double HydraulicHorsepowerTolerance { get { return 1e-5; } } - protected virtual double JoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double KilobritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double KilowattsTolerance { get { return 1e-5; } } - protected virtual double MechanicalHorsepowerTolerance { get { return 1e-5; } } - protected virtual double MegabritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double MegawattsTolerance { get { return 1e-5; } } - protected virtual double MetricHorsepowerTolerance { get { return 1e-5; } } - protected virtual double MicrowattsTolerance { get { return 1e-5; } } - protected virtual double MillijoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double MilliwattsTolerance { get { return 1e-5; } } - protected virtual double NanowattsTolerance { get { return 1e-5; } } - protected virtual double PetawattsTolerance { get { return 1e-5; } } - protected virtual double PicowattsTolerance { get { return 1e-5; } } - protected virtual double TerawattsTolerance { get { return 1e-5; } } - protected virtual double WattsTolerance { get { return 1e-5; } } + protected virtual decimal BoilerHorsepowerTolerance { get { return 1E-9m; } } + protected virtual decimal BritishThermalUnitsPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal DecawattsTolerance { get { return 1E-9m; } } + protected virtual decimal DeciwattsTolerance { get { return 1E-9m; } } + protected virtual decimal ElectricalHorsepowerTolerance { get { return 1E-9m; } } + protected virtual decimal FemtowattsTolerance { get { return 1E-9m; } } + protected virtual decimal GigajoulesPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal GigawattsTolerance { get { return 1E-9m; } } + protected virtual decimal HydraulicHorsepowerTolerance { get { return 1E-9m; } } + protected virtual decimal JoulesPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal KilobritishThermalUnitsPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal KilojoulesPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal KilowattsTolerance { get { return 1E-9m; } } + protected virtual decimal MechanicalHorsepowerTolerance { get { return 1E-9m; } } + protected virtual decimal MegabritishThermalUnitsPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal MegajoulesPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal MegawattsTolerance { get { return 1E-9m; } } + protected virtual decimal MetricHorsepowerTolerance { get { return 1E-9m; } } + protected virtual decimal MicrowattsTolerance { get { return 1E-9m; } } + protected virtual decimal MillijoulesPerHourTolerance { get { return 1E-9m; } } + protected virtual decimal MilliwattsTolerance { get { return 1E-9m; } } + protected virtual decimal NanowattsTolerance { get { return 1E-9m; } } + protected virtual decimal PetawattsTolerance { get { return 1E-9m; } } + protected virtual decimal PicowattsTolerance { get { return 1E-9m; } } + protected virtual decimal TerawattsTolerance { get { return 1E-9m; } } + protected virtual decimal WattsTolerance { get { return 1E-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(PowerUnit unit) { return unit switch { @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1046,14 +1046,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PowerUnit unit) { - var inBaseUnits = Power.From(1.0, Power.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Power.From(1.0, Power.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Power.From(1.0, Power.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PowerUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PowerUnit unit) @@ -1067,8 +1074,8 @@ public void ToUnit_WithSameUnits_AreEqual(PowerUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Power.Units.Where(u => u != Power.BaseUnit).DefaultIfEmpty(Power.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Power.Units.First(u => u != Power.BaseUnit); var quantity = Power.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1338,8 +1345,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1373,36 +1381,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1415,22 +1428,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Power.FromWatts(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Power.FromWatts(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1472,7 +1488,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Power.FromWatts(1.0); - Assert.Equal(new {Power.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Power.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index c489b22624..cbd23636df 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class PressureChangeRateTestsBase : QuantityTestsBase protected abstract double PoundsForcePerSquareInchPerSecondInOnePascalPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AtmospheresPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilopascalsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double KilopascalsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerSquareInchPerMinuteTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegapascalsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double MegapascalsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegapoundsForcePerSquareInchPerMinuteTolerance { get { return 1e-5; } } - protected virtual double MegapoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } - protected virtual double MillimetersOfMercuryPerSecondTolerance { get { return 1e-5; } } - protected virtual double PascalsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double PascalsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerSquareInchPerMinuteTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } + protected virtual double AtmospheresPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilopascalsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double KilopascalsPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerSquareInchPerMinuteTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerSquareInchPerSecondTolerance { get { return 1E-5; } } + protected virtual double MegapascalsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double MegapascalsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MegapoundsForcePerSquareInchPerMinuteTolerance { get { return 1E-5; } } + protected virtual double MegapoundsForcePerSquareInchPerSecondTolerance { get { return 1E-5; } } + protected virtual double MillimetersOfMercuryPerSecondTolerance { get { return 1E-5; } } + protected virtual double PascalsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double PascalsPerSecondTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerSquareInchPerMinuteTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerSquareInchPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PressureChangeRateUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1281,14 +1281,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PressureChangeRateUnit unit) { - var inBaseUnits = PressureChangeRate.From(1.0, PressureChangeRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = PressureChangeRate.From(1.0, PressureChangeRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = PressureChangeRate.From(1.0, PressureChangeRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PressureChangeRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PressureChangeRateUnit unit) @@ -1302,8 +1309,8 @@ public void ToUnit_WithSameUnits_AreEqual(PressureChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PressureChangeRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = PressureChangeRate.Units.Where(u => u != PressureChangeRate.BaseUnit).DefaultIfEmpty(PressureChangeRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = PressureChangeRate.Units.First(u => u != PressureChangeRate.BaseUnit); var quantity = PressureChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1537,8 +1544,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1572,36 +1580,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1614,22 +1627,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = PressureChangeRate.FromPascalsPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1671,7 +1687,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(new {PressureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(PressureChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 3db47ed7e7..7d21a9bb4a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -87,53 +87,53 @@ public abstract partial class PressureTestsBase : QuantityTestsBase protected abstract double TorrsInOnePascal { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AtmospheresTolerance { get { return 1e-5; } } - protected virtual double BarsTolerance { get { return 1e-5; } } - protected virtual double CentibarsTolerance { get { return 1e-5; } } - protected virtual double DecapascalsTolerance { get { return 1e-5; } } - protected virtual double DecibarsTolerance { get { return 1e-5; } } - protected virtual double DynesPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double FeetOfElevationTolerance { get { return 1e-5; } } - protected virtual double FeetOfHeadTolerance { get { return 1e-5; } } - protected virtual double GigapascalsTolerance { get { return 1e-5; } } - protected virtual double HectopascalsTolerance { get { return 1e-5; } } - protected virtual double InchesOfMercuryTolerance { get { return 1e-5; } } - protected virtual double InchesOfWaterColumnTolerance { get { return 1e-5; } } - protected virtual double KilobarsTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilopascalsTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerSquareFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerSquareInchTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerSquareMilTolerance { get { return 1e-5; } } - protected virtual double MegabarsTolerance { get { return 1e-5; } } - protected virtual double MeganewtonsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double MegapascalsTolerance { get { return 1e-5; } } - protected virtual double MetersOfElevationTolerance { get { return 1e-5; } } - protected virtual double MetersOfHeadTolerance { get { return 1e-5; } } - protected virtual double MicrobarsTolerance { get { return 1e-5; } } - protected virtual double MicropascalsTolerance { get { return 1e-5; } } - protected virtual double MillibarsTolerance { get { return 1e-5; } } - protected virtual double MillimetersOfMercuryTolerance { get { return 1e-5; } } - protected virtual double MillimeterOfWaterColumnTolerance { get { return 1e-5; } } - protected virtual double MillipascalsTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double PascalsTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerSquareFootTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerSquareInchTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerSquareMilTolerance { get { return 1e-5; } } - protected virtual double PoundsPerInchSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double TechnicalAtmospheresTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerSquareCentimeterTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerSquareMeterTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerSquareMillimeterTolerance { get { return 1e-5; } } - protected virtual double TorrsTolerance { get { return 1e-5; } } + protected virtual double AtmospheresTolerance { get { return 1E-5; } } + protected virtual double BarsTolerance { get { return 1E-5; } } + protected virtual double CentibarsTolerance { get { return 1E-5; } } + protected virtual double DecapascalsTolerance { get { return 1E-5; } } + protected virtual double DecibarsTolerance { get { return 1E-5; } } + protected virtual double DynesPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double FeetOfElevationTolerance { get { return 1E-5; } } + protected virtual double FeetOfHeadTolerance { get { return 1E-5; } } + protected virtual double GigapascalsTolerance { get { return 1E-5; } } + protected virtual double HectopascalsTolerance { get { return 1E-5; } } + protected virtual double InchesOfMercuryTolerance { get { return 1E-5; } } + protected virtual double InchesOfWaterColumnTolerance { get { return 1E-5; } } + protected virtual double KilobarsTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilopascalsTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerSquareFootTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerSquareInchTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerSquareMilTolerance { get { return 1E-5; } } + protected virtual double MegabarsTolerance { get { return 1E-5; } } + protected virtual double MeganewtonsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double MegapascalsTolerance { get { return 1E-5; } } + protected virtual double MetersOfElevationTolerance { get { return 1E-5; } } + protected virtual double MetersOfHeadTolerance { get { return 1E-5; } } + protected virtual double MicrobarsTolerance { get { return 1E-5; } } + protected virtual double MicropascalsTolerance { get { return 1E-5; } } + protected virtual double MillibarsTolerance { get { return 1E-5; } } + protected virtual double MillimetersOfMercuryTolerance { get { return 1E-5; } } + protected virtual double MillimeterOfWaterColumnTolerance { get { return 1E-5; } } + protected virtual double MillipascalsTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double PascalsTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerSquareFootTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerSquareInchTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerSquareMilTolerance { get { return 1E-5; } } + protected virtual double PoundsPerInchSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double TechnicalAtmospheresTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerSquareCentimeterTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double TorrsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PressureUnit unit) @@ -618,7 +618,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2629,14 +2629,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PressureUnit unit) { - var inBaseUnits = Pressure.From(1.0, Pressure.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Pressure.From(1.0, Pressure.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Pressure.From(1.0, Pressure.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(PressureUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PressureUnit unit) @@ -2650,8 +2657,8 @@ public void ToUnit_WithSameUnits_AreEqual(PressureUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PressureUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Pressure.Units.Where(u => u != Pressure.BaseUnit).DefaultIfEmpty(Pressure.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Pressure.Units.First(u => u != Pressure.BaseUnit); var quantity = Pressure.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2984,8 +2991,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -3019,36 +3027,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -3061,22 +3074,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Pressure.FromPascals(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Pressure.FromPascals(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -3118,7 +3134,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(new {Pressure.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Pressure.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 989c017044..3978af69d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class RatioChangeRateTestsBase : QuantityTestsBase protected abstract double PercentsPerSecondInOneDecimalFractionPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecimalFractionsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PercentsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecimalFractionsPerSecondTolerance { get { return 1E-5; } } + protected virtual double PercentsPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RatioChangeRateUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,14 +249,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RatioChangeRateUnit unit) { - var inBaseUnits = RatioChangeRate.From(1.0, RatioChangeRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = RatioChangeRate.From(1.0, RatioChangeRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = RatioChangeRate.From(1.0, RatioChangeRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RatioChangeRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RatioChangeRateUnit unit) @@ -270,8 +277,8 @@ public void ToUnit_WithSameUnits_AreEqual(RatioChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RatioChangeRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RatioChangeRate.Units.Where(u => u != RatioChangeRate.BaseUnit).DefaultIfEmpty(RatioChangeRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = RatioChangeRate.Units.First(u => u != RatioChangeRate.BaseUnit); var quantity = RatioChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -469,8 +476,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -504,36 +512,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -546,22 +559,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -603,7 +619,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(new {RatioChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(RatioChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 8714c6f6a3..4c84253dd5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class RatioTestsBase : QuantityTestsBase protected abstract double PercentInOneDecimalFraction { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } - protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } - protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } - protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } - protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } - protected virtual double PercentTolerance { get { return 1e-5; } } + protected virtual double DecimalFractionsTolerance { get { return 1E-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1E-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1E-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1E-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1E-5; } } + protected virtual double PercentTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RatioUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -385,14 +385,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RatioUnit unit) { - var inBaseUnits = Ratio.From(1.0, Ratio.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Ratio.From(1.0, Ratio.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Ratio.From(1.0, Ratio.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RatioUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RatioUnit unit) @@ -406,8 +413,8 @@ public void ToUnit_WithSameUnits_AreEqual(RatioUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RatioUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Ratio.Units.Where(u => u != Ratio.BaseUnit).DefaultIfEmpty(Ratio.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Ratio.Units.First(u => u != Ratio.BaseUnit); var quantity = Ratio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -617,8 +624,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -652,36 +660,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -694,22 +707,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Ratio.FromDecimalFractions(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -751,7 +767,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(new {Ratio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Ratio.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 8c4ddb264c..be05f748b3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ReactiveEnergyTestsBase : QuantityTestsBase protected abstract double VoltampereReactiveHoursInOneVoltampereReactiveHour { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltampereReactiveHoursTolerance { get { return 1e-5; } } - protected virtual double MegavoltampereReactiveHoursTolerance { get { return 1e-5; } } - protected virtual double VoltampereReactiveHoursTolerance { get { return 1e-5; } } + protected virtual double KilovoltampereReactiveHoursTolerance { get { return 1E-5; } } + protected virtual double MegavoltampereReactiveHoursTolerance { get { return 1E-5; } } + protected virtual double VoltampereReactiveHoursTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReactiveEnergyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReactiveEnergyUnit unit) { - var inBaseUnits = ReactiveEnergy.From(1.0, ReactiveEnergy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ReactiveEnergy.From(1.0, ReactiveEnergy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ReactiveEnergy.From(1.0, ReactiveEnergy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ReactiveEnergyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReactiveEnergyUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReactiveEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReactiveEnergyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReactiveEnergy.Units.Where(u => u != ReactiveEnergy.BaseUnit).DefaultIfEmpty(ReactiveEnergy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ReactiveEnergy.Units.First(u => u != ReactiveEnergy.BaseUnit); var quantity = ReactiveEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(new {ReactiveEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ReactiveEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 807b553fda..ef116e631d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ReactivePowerTestsBase : QuantityTestsBase protected abstract double VoltamperesReactiveInOneVoltampereReactive { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigavoltamperesReactiveTolerance { get { return 1e-5; } } - protected virtual double KilovoltamperesReactiveTolerance { get { return 1e-5; } } - protected virtual double MegavoltamperesReactiveTolerance { get { return 1e-5; } } - protected virtual double VoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double GigavoltamperesReactiveTolerance { get { return 1E-5; } } + protected virtual double KilovoltamperesReactiveTolerance { get { return 1E-5; } } + protected virtual double MegavoltamperesReactiveTolerance { get { return 1E-5; } } + protected virtual double VoltamperesReactiveTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReactivePowerUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReactivePowerUnit unit) { - var inBaseUnits = ReactivePower.From(1.0, ReactivePower.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ReactivePower.From(1.0, ReactivePower.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ReactivePower.From(1.0, ReactivePower.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ReactivePowerUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReactivePowerUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReactivePowerUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReactivePowerUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReactivePower.Units.Where(u => u != ReactivePower.BaseUnit).DefaultIfEmpty(ReactivePower.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ReactivePower.Units.First(u => u != ReactivePower.BaseUnit); var quantity = ReactivePower.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ReactivePower.FromVoltamperesReactive(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(new {ReactivePower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ReactivePower.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 93590fd301..3b7ffb3eb6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class ReciprocalAreaTestsBase : QuantityTestsBase protected abstract double InverseUsSurveySquareFeetInOneInverseSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseSquareCentimetersTolerance { get { return 1e-5; } } - protected virtual double InverseSquareDecimetersTolerance { get { return 1e-5; } } - protected virtual double InverseSquareFeetTolerance { get { return 1e-5; } } - protected virtual double InverseSquareInchesTolerance { get { return 1e-5; } } - protected virtual double InverseSquareKilometersTolerance { get { return 1e-5; } } - protected virtual double InverseSquareMetersTolerance { get { return 1e-5; } } - protected virtual double InverseSquareMicrometersTolerance { get { return 1e-5; } } - protected virtual double InverseSquareMilesTolerance { get { return 1e-5; } } - protected virtual double InverseSquareMillimetersTolerance { get { return 1e-5; } } - protected virtual double InverseSquareYardsTolerance { get { return 1e-5; } } - protected virtual double InverseUsSurveySquareFeetTolerance { get { return 1e-5; } } + protected virtual double InverseSquareCentimetersTolerance { get { return 1E-5; } } + protected virtual double InverseSquareDecimetersTolerance { get { return 1E-5; } } + protected virtual double InverseSquareFeetTolerance { get { return 1E-5; } } + protected virtual double InverseSquareInchesTolerance { get { return 1E-5; } } + protected virtual double InverseSquareKilometersTolerance { get { return 1E-5; } } + protected virtual double InverseSquareMetersTolerance { get { return 1E-5; } } + protected virtual double InverseSquareMicrometersTolerance { get { return 1E-5; } } + protected virtual double InverseSquareMilesTolerance { get { return 1E-5; } } + protected virtual double InverseSquareMillimetersTolerance { get { return 1E-5; } } + protected virtual double InverseSquareYardsTolerance { get { return 1E-5; } } + protected virtual double InverseUsSurveySquareFeetTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReciprocalAreaUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -555,14 +555,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReciprocalAreaUnit unit) { - var inBaseUnits = ReciprocalArea.From(1.0, ReciprocalArea.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ReciprocalArea.From(1.0, ReciprocalArea.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ReciprocalArea.From(1.0, ReciprocalArea.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ReciprocalAreaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReciprocalAreaUnit unit) @@ -576,8 +583,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReciprocalAreaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReciprocalAreaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReciprocalArea.Units.Where(u => u != ReciprocalArea.BaseUnit).DefaultIfEmpty(ReciprocalArea.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ReciprocalArea.Units.First(u => u != ReciprocalArea.BaseUnit); var quantity = ReciprocalArea.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -802,8 +809,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -837,36 +845,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -879,22 +892,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ReciprocalArea.FromInverseSquareMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -936,7 +952,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(new {ReciprocalArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ReciprocalArea.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 3de7afaf9e..a4292f5bdb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class ReciprocalLengthTestsBase : QuantityTestsBase protected abstract double InverseYardsInOneInverseMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseCentimetersTolerance { get { return 1e-5; } } - protected virtual double InverseFeetTolerance { get { return 1e-5; } } - protected virtual double InverseInchesTolerance { get { return 1e-5; } } - protected virtual double InverseMetersTolerance { get { return 1e-5; } } - protected virtual double InverseMicroinchesTolerance { get { return 1e-5; } } - protected virtual double InverseMilsTolerance { get { return 1e-5; } } - protected virtual double InverseMilesTolerance { get { return 1e-5; } } - protected virtual double InverseMillimetersTolerance { get { return 1e-5; } } - protected virtual double InverseUsSurveyFeetTolerance { get { return 1e-5; } } - protected virtual double InverseYardsTolerance { get { return 1e-5; } } + protected virtual double InverseCentimetersTolerance { get { return 1E-5; } } + protected virtual double InverseFeetTolerance { get { return 1E-5; } } + protected virtual double InverseInchesTolerance { get { return 1E-5; } } + protected virtual double InverseMetersTolerance { get { return 1E-5; } } + protected virtual double InverseMicroinchesTolerance { get { return 1E-5; } } + protected virtual double InverseMilsTolerance { get { return 1E-5; } } + protected virtual double InverseMilesTolerance { get { return 1E-5; } } + protected virtual double InverseMillimetersTolerance { get { return 1E-5; } } + protected virtual double InverseUsSurveyFeetTolerance { get { return 1E-5; } } + protected virtual double InverseYardsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReciprocalLengthUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -761,14 +761,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReciprocalLengthUnit unit) { - var inBaseUnits = ReciprocalLength.From(1.0, ReciprocalLength.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ReciprocalLength.From(1.0, ReciprocalLength.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ReciprocalLength.From(1.0, ReciprocalLength.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ReciprocalLengthUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReciprocalLengthUnit unit) @@ -782,8 +789,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReciprocalLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReciprocalLengthUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ReciprocalLength.Units.Where(u => u != ReciprocalLength.BaseUnit).DefaultIfEmpty(ReciprocalLength.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ReciprocalLength.Units.First(u => u != ReciprocalLength.BaseUnit); var quantity = ReciprocalLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1005,8 +1012,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1040,36 +1048,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1082,22 +1095,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ReciprocalLength.FromInverseMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1139,7 +1155,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(new {ReciprocalLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ReciprocalLength.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 60f67c7468..cd282ea216 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class RelativeHumidityTestsBase : QuantityTestsBase protected abstract double PercentInOnePercent { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double PercentTolerance { get { return 1e-5; } } + protected virtual double PercentTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RelativeHumidityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RelativeHumidityUnit unit) { - var inBaseUnits = RelativeHumidity.From(1.0, RelativeHumidity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = RelativeHumidity.From(1.0, RelativeHumidity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = RelativeHumidity.From(1.0, RelativeHumidity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RelativeHumidityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RelativeHumidityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(RelativeHumidityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RelativeHumidityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RelativeHumidity.Units.Where(u => u != RelativeHumidity.BaseUnit).DefaultIfEmpty(RelativeHumidity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = RelativeHumidity.Units.First(u => u != RelativeHumidity.BaseUnit); var quantity = RelativeHumidity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = RelativeHumidity.FromPercent(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(new {RelativeHumidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(RelativeHumidity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index f0cc297b7e..1b6e0489a5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class RotationalAccelerationTestsBase : QuantityTestsBas protected abstract double RevolutionsPerSecondSquaredInOneRadianPerSecondSquared { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double RadiansPerSecondSquaredTolerance { get { return 1e-5; } } - protected virtual double RevolutionsPerMinutePerSecondTolerance { get { return 1e-5; } } - protected virtual double RevolutionsPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double DegreesPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double RadiansPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double RevolutionsPerMinutePerSecondTolerance { get { return 1E-5; } } + protected virtual double RevolutionsPerSecondSquaredTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalAccelerationUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -341,14 +341,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalAccelerationUnit unit) { - var inBaseUnits = RotationalAcceleration.From(1.0, RotationalAcceleration.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = RotationalAcceleration.From(1.0, RotationalAcceleration.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = RotationalAcceleration.From(1.0, RotationalAcceleration.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalAccelerationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalAccelerationUnit unit) @@ -362,8 +369,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalAccelerationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalAccelerationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalAcceleration.Units.Where(u => u != RotationalAcceleration.BaseUnit).DefaultIfEmpty(RotationalAcceleration.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = RotationalAcceleration.Units.First(u => u != RotationalAcceleration.BaseUnit); var quantity = RotationalAcceleration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -567,8 +574,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -602,36 +610,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -644,22 +657,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -701,7 +717,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(new {RotationalAcceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(RotationalAcceleration.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index a2df678911..084fe1f460 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -53,19 +53,19 @@ public abstract partial class RotationalSpeedTestsBase : QuantityTestsBase protected abstract double RevolutionsPerSecondInOneRadianPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentiradiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double DeciradiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double DegreesPerMinuteTolerance { get { return 1e-5; } } - protected virtual double DegreesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MicrodegreesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MicroradiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double MillidegreesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MilliradiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanodegreesPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanoradiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double RadiansPerSecondTolerance { get { return 1e-5; } } - protected virtual double RevolutionsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double RevolutionsPerSecondTolerance { get { return 1e-5; } } + protected virtual double CentiradiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double DeciradiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double DegreesPerMinuteTolerance { get { return 1E-5; } } + protected virtual double DegreesPerSecondTolerance { get { return 1E-5; } } + protected virtual double MicrodegreesPerSecondTolerance { get { return 1E-5; } } + protected virtual double MicroradiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double MillidegreesPerSecondTolerance { get { return 1E-5; } } + protected virtual double MilliradiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanodegreesPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanoradiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double RadiansPerSecondTolerance { get { return 1E-5; } } + protected virtual double RevolutionsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double RevolutionsPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalSpeedUnit unit) @@ -278,7 +278,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1055,14 +1055,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalSpeedUnit unit) { - var inBaseUnits = RotationalSpeed.From(1.0, RotationalSpeed.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = RotationalSpeed.From(1.0, RotationalSpeed.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = RotationalSpeed.From(1.0, RotationalSpeed.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalSpeedUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalSpeedUnit unit) @@ -1076,8 +1083,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalSpeedUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalSpeedUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalSpeed.Units.Where(u => u != RotationalSpeed.BaseUnit).DefaultIfEmpty(RotationalSpeed.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = RotationalSpeed.Units.First(u => u != RotationalSpeed.BaseUnit); var quantity = RotationalSpeed.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1308,8 +1315,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1343,36 +1351,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1385,22 +1398,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = RotationalSpeed.FromRadiansPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1442,7 +1458,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(new {RotationalSpeed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(RotationalSpeed.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 7880b8d001..02d476b09e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class RotationalStiffnessPerLengthTestsBase : QuantityTe protected abstract double PoundForceFeetPerDegreesPerFeetInOneNewtonMeterPerRadianPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilonewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceFeetPerDegreesPerFeetTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } - protected virtual double PoundForceFeetPerDegreesPerFeetTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMetersPerRadianPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilopoundForceFeetPerDegreesPerFeetTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMetersPerRadianPerMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonMetersPerRadianPerMeterTolerance { get { return 1E-5; } } + protected virtual double PoundForceFeetPerDegreesPerFeetTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalStiffnessPerLengthUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -543,14 +543,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalStiffnessPerLengthUnit unit) { - var inBaseUnits = RotationalStiffnessPerLength.From(1.0, RotationalStiffnessPerLength.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = RotationalStiffnessPerLength.From(1.0, RotationalStiffnessPerLength.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = RotationalStiffnessPerLength.From(1.0, RotationalStiffnessPerLength.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalStiffnessPerLengthUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessPerLengthUnit unit) @@ -564,8 +571,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessPerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalStiffnessPerLengthUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalStiffnessPerLength.Units.Where(u => u != RotationalStiffnessPerLength.BaseUnit).DefaultIfEmpty(RotationalStiffnessPerLength.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = RotationalStiffnessPerLength.Units.First(u => u != RotationalStiffnessPerLength.BaseUnit); var quantity = RotationalStiffnessPerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -772,8 +779,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -807,36 +815,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -849,22 +862,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -906,7 +922,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(new {RotationalStiffnessPerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(RotationalStiffnessPerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 8557dab512..afc2d9ab68 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -73,39 +73,39 @@ public abstract partial class RotationalStiffnessTestsBase : QuantityTestsBase protected abstract double PoundForceFeetPerDegreesInOneNewtonMeterPerRadian { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentinewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double CentinewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double CentinewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double DecanewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double DecanewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double DecanewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double DecinewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double DecinewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double DecinewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceFeetPerDegreesTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double MicronewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double MicronewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double MicronewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double MillinewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double MillinewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double MillinewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double NanonewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double NanonewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double NanonewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double NewtonMetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double NewtonMetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double NewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } - protected virtual double NewtonMillimetersPerRadianTolerance { get { return 1e-5; } } - protected virtual double PoundForceFeetPerRadianTolerance { get { return 1e-5; } } - protected virtual double PoundForceFeetPerDegreesTolerance { get { return 1e-5; } } + protected virtual double CentinewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double CentinewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double CentinewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double DecanewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double DecanewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double DecanewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double DecinewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double DecinewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double DecinewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double KilopoundForceFeetPerDegreesTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double MicronewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double MicronewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double MicronewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double MillinewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double MillinewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double MillinewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double NanonewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double NanonewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double NanonewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double NewtonMetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double NewtonMetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double NewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } + protected virtual double NewtonMillimetersPerRadianTolerance { get { return 1E-5; } } + protected virtual double PoundForceFeetPerRadianTolerance { get { return 1E-5; } } + protected virtual double PoundForceFeetPerDegreesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalStiffnessUnit unit) @@ -478,7 +478,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2787,14 +2787,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalStiffnessUnit unit) { - var inBaseUnits = RotationalStiffness.From(1.0, RotationalStiffness.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = RotationalStiffness.From(1.0, RotationalStiffness.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = RotationalStiffness.From(1.0, RotationalStiffness.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalStiffnessUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessUnit unit) @@ -2808,8 +2815,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalStiffnessUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = RotationalStiffness.Units.Where(u => u != RotationalStiffness.BaseUnit).DefaultIfEmpty(RotationalStiffness.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = RotationalStiffness.Units.First(u => u != RotationalStiffness.BaseUnit); var quantity = RotationalStiffness.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -3100,8 +3107,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -3135,36 +3143,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -3177,22 +3190,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -3234,7 +3250,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(new {RotationalStiffness.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(RotationalStiffness.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 427c4da867..ed5f413d32 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class ScalarTestsBase : QuantityTestsBase protected abstract double AmountInOneAmount { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmountTolerance { get { return 1e-5; } } + protected virtual double AmountTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ScalarUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ScalarUnit unit) { - var inBaseUnits = Scalar.From(1.0, Scalar.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Scalar.From(1.0, Scalar.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Scalar.From(1.0, Scalar.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ScalarUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ScalarUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(ScalarUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ScalarUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Scalar.Units.Where(u => u != Scalar.BaseUnit).DefaultIfEmpty(Scalar.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Scalar.Units.First(u => u != Scalar.BaseUnit); var quantity = Scalar.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Scalar.FromAmount(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Scalar.FromAmount(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(new {Scalar.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Scalar.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 6fe1a3602c..3785ea8be3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class SolidAngleTestsBase : QuantityTestsBase protected abstract double SteradiansInOneSteradian { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double SteradiansTolerance { get { return 1e-5; } } + protected virtual double SteradiansTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SolidAngleUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SolidAngleUnit unit) { - var inBaseUnits = SolidAngle.From(1.0, SolidAngle.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = SolidAngle.From(1.0, SolidAngle.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = SolidAngle.From(1.0, SolidAngle.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SolidAngleUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SolidAngleUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(SolidAngleUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SolidAngleUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SolidAngle.Units.Where(u => u != SolidAngle.BaseUnit).DefaultIfEmpty(SolidAngle.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = SolidAngle.Units.First(u => u != SolidAngle.BaseUnit); var quantity = SolidAngle.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = SolidAngle.FromSteradians(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(new {SolidAngle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(SolidAngle.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 32be1e830a..0c2e9defed 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -69,35 +69,35 @@ public abstract partial class SpecificEnergyTestsBase : QuantityTestsBase protected abstract double WattHoursPerPoundInOneJoulePerKilogram { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtuPerPoundTolerance { get { return 1e-5; } } - protected virtual double CaloriesPerGramTolerance { get { return 1e-5; } } - protected virtual double GigawattDaysPerKilogramTolerance { get { return 1e-5; } } - protected virtual double GigawattDaysPerShortTonTolerance { get { return 1e-5; } } - protected virtual double GigawattDaysPerTonneTolerance { get { return 1e-5; } } - protected virtual double GigawattHoursPerKilogramTolerance { get { return 1e-5; } } - protected virtual double GigawattHoursPerPoundTolerance { get { return 1e-5; } } - protected virtual double JoulesPerKilogramTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesPerGramTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerKilogramTolerance { get { return 1e-5; } } - protected virtual double KilowattDaysPerKilogramTolerance { get { return 1e-5; } } - protected virtual double KilowattDaysPerShortTonTolerance { get { return 1e-5; } } - protected virtual double KilowattDaysPerTonneTolerance { get { return 1e-5; } } - protected virtual double KilowattHoursPerKilogramTolerance { get { return 1e-5; } } - protected virtual double KilowattHoursPerPoundTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerKilogramTolerance { get { return 1e-5; } } - protected virtual double MegawattDaysPerKilogramTolerance { get { return 1e-5; } } - protected virtual double MegawattDaysPerShortTonTolerance { get { return 1e-5; } } - protected virtual double MegawattDaysPerTonneTolerance { get { return 1e-5; } } - protected virtual double MegawattHoursPerKilogramTolerance { get { return 1e-5; } } - protected virtual double MegawattHoursPerPoundTolerance { get { return 1e-5; } } - protected virtual double TerawattDaysPerKilogramTolerance { get { return 1e-5; } } - protected virtual double TerawattDaysPerShortTonTolerance { get { return 1e-5; } } - protected virtual double TerawattDaysPerTonneTolerance { get { return 1e-5; } } - protected virtual double WattDaysPerKilogramTolerance { get { return 1e-5; } } - protected virtual double WattDaysPerShortTonTolerance { get { return 1e-5; } } - protected virtual double WattDaysPerTonneTolerance { get { return 1e-5; } } - protected virtual double WattHoursPerKilogramTolerance { get { return 1e-5; } } - protected virtual double WattHoursPerPoundTolerance { get { return 1e-5; } } + protected virtual double BtuPerPoundTolerance { get { return 1E-5; } } + protected virtual double CaloriesPerGramTolerance { get { return 1E-5; } } + protected virtual double GigawattDaysPerKilogramTolerance { get { return 1E-5; } } + protected virtual double GigawattDaysPerShortTonTolerance { get { return 1E-5; } } + protected virtual double GigawattDaysPerTonneTolerance { get { return 1E-5; } } + protected virtual double GigawattHoursPerKilogramTolerance { get { return 1E-5; } } + protected virtual double GigawattHoursPerPoundTolerance { get { return 1E-5; } } + protected virtual double JoulesPerKilogramTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesPerGramTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerKilogramTolerance { get { return 1E-5; } } + protected virtual double KilowattDaysPerKilogramTolerance { get { return 1E-5; } } + protected virtual double KilowattDaysPerShortTonTolerance { get { return 1E-5; } } + protected virtual double KilowattDaysPerTonneTolerance { get { return 1E-5; } } + protected virtual double KilowattHoursPerKilogramTolerance { get { return 1E-5; } } + protected virtual double KilowattHoursPerPoundTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerKilogramTolerance { get { return 1E-5; } } + protected virtual double MegawattDaysPerKilogramTolerance { get { return 1E-5; } } + protected virtual double MegawattDaysPerShortTonTolerance { get { return 1E-5; } } + protected virtual double MegawattDaysPerTonneTolerance { get { return 1E-5; } } + protected virtual double MegawattHoursPerKilogramTolerance { get { return 1E-5; } } + protected virtual double MegawattHoursPerPoundTolerance { get { return 1E-5; } } + protected virtual double TerawattDaysPerKilogramTolerance { get { return 1E-5; } } + protected virtual double TerawattDaysPerShortTonTolerance { get { return 1E-5; } } + protected virtual double TerawattDaysPerTonneTolerance { get { return 1E-5; } } + protected virtual double WattDaysPerKilogramTolerance { get { return 1E-5; } } + protected virtual double WattDaysPerShortTonTolerance { get { return 1E-5; } } + protected virtual double WattDaysPerTonneTolerance { get { return 1E-5; } } + protected virtual double WattHoursPerKilogramTolerance { get { return 1E-5; } } + protected virtual double WattHoursPerPoundTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificEnergyUnit unit) @@ -438,7 +438,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1167,14 +1167,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificEnergyUnit unit) { - var inBaseUnits = SpecificEnergy.From(1.0, SpecificEnergy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = SpecificEnergy.From(1.0, SpecificEnergy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = SpecificEnergy.From(1.0, SpecificEnergy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificEnergyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificEnergyUnit unit) @@ -1188,8 +1195,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificEnergyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificEnergy.Units.Where(u => u != SpecificEnergy.BaseUnit).DefaultIfEmpty(SpecificEnergy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = SpecificEnergy.Units.First(u => u != SpecificEnergy.BaseUnit); var quantity = SpecificEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1468,8 +1475,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1503,36 +1511,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1545,22 +1558,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = SpecificEnergy.FromJoulesPerKilogram(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1602,7 +1618,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(new {SpecificEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(SpecificEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index b58e37b641..751acae18f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class SpecificEntropyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerKilogramKelvinInOneJoulePerKilogramKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerPoundFahrenheitTolerance { get { return 1e-5; } } - protected virtual double CaloriesPerGramKelvinTolerance { get { return 1e-5; } } - protected virtual double JoulesPerKilogramDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double JoulesPerKilogramKelvinTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesPerGramKelvinTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerKilogramDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerKilogramKelvinTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerKilogramDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerKilogramKelvinTolerance { get { return 1e-5; } } + protected virtual double BtusPerPoundFahrenheitTolerance { get { return 1E-5; } } + protected virtual double CaloriesPerGramKelvinTolerance { get { return 1E-5; } } + protected virtual double JoulesPerKilogramDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double JoulesPerKilogramKelvinTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesPerGramKelvinTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerKilogramDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerKilogramKelvinTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerKilogramDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerKilogramKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificEntropyUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -511,14 +511,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificEntropyUnit unit) { - var inBaseUnits = SpecificEntropy.From(1.0, SpecificEntropy.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = SpecificEntropy.From(1.0, SpecificEntropy.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = SpecificEntropy.From(1.0, SpecificEntropy.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificEntropyUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificEntropyUnit unit) @@ -532,8 +539,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificEntropyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificEntropyUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificEntropy.Units.Where(u => u != SpecificEntropy.BaseUnit).DefaultIfEmpty(SpecificEntropy.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = SpecificEntropy.Units.First(u => u != SpecificEntropy.BaseUnit); var quantity = SpecificEntropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -752,8 +759,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -787,36 +795,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -829,22 +842,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -886,7 +902,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(new {SpecificEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(SpecificEntropy.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index e0e7e9e8cc..b3b875a146 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class SpecificFuelConsumptionTestsBase : QuantityTestsBa protected abstract double PoundsMassPerPoundForceHourInOneGramPerKiloNewtonSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerKiloNewtonSecondTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerKilogramForceHourTolerance { get { return 1e-5; } } - protected virtual double KilogramsPerKiloNewtonSecondTolerance { get { return 1e-5; } } - protected virtual double PoundsMassPerPoundForceHourTolerance { get { return 1e-5; } } + protected virtual double GramsPerKiloNewtonSecondTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerKilogramForceHourTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerKiloNewtonSecondTolerance { get { return 1E-5; } } + protected virtual double PoundsMassPerPoundForceHourTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificFuelConsumptionUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificFuelConsumptionUnit unit) { - var inBaseUnits = SpecificFuelConsumption.From(1.0, SpecificFuelConsumption.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = SpecificFuelConsumption.From(1.0, SpecificFuelConsumption.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = SpecificFuelConsumption.From(1.0, SpecificFuelConsumption.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificFuelConsumptionUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificFuelConsumptionUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificFuelConsumptionUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificFuelConsumptionUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificFuelConsumption.Units.Where(u => u != SpecificFuelConsumption.BaseUnit).DefaultIfEmpty(SpecificFuelConsumption.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = SpecificFuelConsumption.Units.First(u => u != SpecificFuelConsumption.BaseUnit); var quantity = SpecificFuelConsumption.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(new {SpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(SpecificFuelConsumption.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 44c9025100..770ffe6f5d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class SpecificVolumeTestsBase : QuantityTestsBase protected abstract double MillicubicMetersPerKilogramInOneCubicMeterPerKilogram { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CubicFeetPerPoundTolerance { get { return 1e-5; } } - protected virtual double CubicMetersPerKilogramTolerance { get { return 1e-5; } } - protected virtual double MillicubicMetersPerKilogramTolerance { get { return 1e-5; } } + protected virtual double CubicFeetPerPoundTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerKilogramTolerance { get { return 1E-5; } } + protected virtual double MillicubicMetersPerKilogramTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificVolumeUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,14 +283,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificVolumeUnit unit) { - var inBaseUnits = SpecificVolume.From(1.0, SpecificVolume.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = SpecificVolume.From(1.0, SpecificVolume.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = SpecificVolume.From(1.0, SpecificVolume.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificVolumeUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificVolumeUnit unit) @@ -304,8 +311,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificVolumeUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificVolumeUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificVolume.Units.Where(u => u != SpecificVolume.BaseUnit).DefaultIfEmpty(SpecificVolume.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = SpecificVolume.Units.First(u => u != SpecificVolume.BaseUnit); var quantity = SpecificVolume.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -506,8 +513,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -541,36 +549,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -583,22 +596,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -640,7 +656,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(new {SpecificVolume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(SpecificVolume.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index daf5cffeae..300b216a12 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -57,23 +57,23 @@ public abstract partial class SpecificWeightTestsBase : QuantityTestsBase protected abstract double TonnesForcePerCubicMillimeterInOneNewtonPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramsForcePerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramsForcePerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerCubicFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundsForcePerCubicInchTolerance { get { return 1e-5; } } - protected virtual double MeganewtonsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonsPerCubicMillimeterTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerCubicFootTolerance { get { return 1e-5; } } - protected virtual double PoundsForcePerCubicInchTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerCubicCentimeterTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerCubicMeterTolerance { get { return 1e-5; } } - protected virtual double TonnesForcePerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerCubicFootTolerance { get { return 1E-5; } } + protected virtual double KilopoundsForcePerCubicInchTolerance { get { return 1E-5; } } + protected virtual double MeganewtonsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonsPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerCubicFootTolerance { get { return 1E-5; } } + protected virtual double PoundsForcePerCubicInchTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerCubicCentimeterTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double TonnesForcePerCubicMillimeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificWeightUnit unit) @@ -318,7 +318,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -759,14 +759,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificWeightUnit unit) { - var inBaseUnits = SpecificWeight.From(1.0, SpecificWeight.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = SpecificWeight.From(1.0, SpecificWeight.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = SpecificWeight.From(1.0, SpecificWeight.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificWeightUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificWeightUnit unit) @@ -780,8 +787,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificWeightUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificWeightUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = SpecificWeight.Units.Where(u => u != SpecificWeight.BaseUnit).DefaultIfEmpty(SpecificWeight.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = SpecificWeight.Units.First(u => u != SpecificWeight.BaseUnit); var quantity = SpecificWeight.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1024,8 +1031,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1059,36 +1067,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1101,22 +1114,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1158,7 +1174,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(new {SpecificWeight.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(SpecificWeight.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 9ef94f5cab..6f91fa89b4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -72,38 +72,38 @@ public abstract partial class SpeedTestsBase : QuantityTestsBase protected abstract double YardsPerSecondInOneMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersPerHourTolerance { get { return 1e-5; } } - protected virtual double CentimetersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double CentimetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecimetersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double DecimetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double FeetPerHourTolerance { get { return 1e-5; } } - protected virtual double FeetPerMinuteTolerance { get { return 1e-5; } } - protected virtual double FeetPerSecondTolerance { get { return 1e-5; } } - protected virtual double InchesPerHourTolerance { get { return 1e-5; } } - protected virtual double InchesPerMinuteTolerance { get { return 1e-5; } } - protected virtual double InchesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilometersPerHourTolerance { get { return 1e-5; } } - protected virtual double KilometersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double KilometersPerSecondTolerance { get { return 1e-5; } } - protected virtual double KnotsTolerance { get { return 1e-5; } } - protected virtual double MetersPerHourTolerance { get { return 1e-5; } } - protected virtual double MetersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double MetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double MicrometersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double MicrometersPerSecondTolerance { get { return 1e-5; } } - protected virtual double MilesPerHourTolerance { get { return 1e-5; } } - protected virtual double MillimetersPerHourTolerance { get { return 1e-5; } } - protected virtual double MillimetersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double MillimetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanometersPerMinutesTolerance { get { return 1e-5; } } - protected virtual double NanometersPerSecondTolerance { get { return 1e-5; } } - protected virtual double UsSurveyFeetPerHourTolerance { get { return 1e-5; } } - protected virtual double UsSurveyFeetPerMinuteTolerance { get { return 1e-5; } } - protected virtual double UsSurveyFeetPerSecondTolerance { get { return 1e-5; } } - protected virtual double YardsPerHourTolerance { get { return 1e-5; } } - protected virtual double YardsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double YardsPerSecondTolerance { get { return 1e-5; } } + protected virtual double CentimetersPerHourTolerance { get { return 1E-5; } } + protected virtual double CentimetersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double CentimetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecimetersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double DecimetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double FeetPerHourTolerance { get { return 1E-5; } } + protected virtual double FeetPerMinuteTolerance { get { return 1E-5; } } + protected virtual double FeetPerSecondTolerance { get { return 1E-5; } } + protected virtual double InchesPerHourTolerance { get { return 1E-5; } } + protected virtual double InchesPerMinuteTolerance { get { return 1E-5; } } + protected virtual double InchesPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilometersPerHourTolerance { get { return 1E-5; } } + protected virtual double KilometersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double KilometersPerSecondTolerance { get { return 1E-5; } } + protected virtual double KnotsTolerance { get { return 1E-5; } } + protected virtual double MetersPerHourTolerance { get { return 1E-5; } } + protected virtual double MetersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double MetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double MicrometersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double MicrometersPerSecondTolerance { get { return 1E-5; } } + protected virtual double MilesPerHourTolerance { get { return 1E-5; } } + protected virtual double MillimetersPerHourTolerance { get { return 1E-5; } } + protected virtual double MillimetersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double MillimetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanometersPerMinutesTolerance { get { return 1E-5; } } + protected virtual double NanometersPerSecondTolerance { get { return 1E-5; } } + protected virtual double UsSurveyFeetPerHourTolerance { get { return 1E-5; } } + protected virtual double UsSurveyFeetPerMinuteTolerance { get { return 1E-5; } } + protected virtual double UsSurveyFeetPerSecondTolerance { get { return 1E-5; } } + protected virtual double YardsPerHourTolerance { get { return 1E-5; } } + protected virtual double YardsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double YardsPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpeedUnit unit) @@ -468,7 +468,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1893,14 +1893,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpeedUnit unit) { - var inBaseUnits = Speed.From(1.0, Speed.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Speed.From(1.0, Speed.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Speed.From(1.0, Speed.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(SpeedUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpeedUnit unit) @@ -1914,8 +1921,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpeedUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpeedUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Speed.Units.Where(u => u != Speed.BaseUnit).DefaultIfEmpty(Speed.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Speed.Units.First(u => u != Speed.BaseUnit); var quantity = Speed.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2203,8 +2210,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -2238,36 +2246,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -2280,22 +2293,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Speed.FromMetersPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -2337,7 +2353,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(new {Speed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Speed.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 7dfaf4c928..29b28819d8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class StandardVolumeFlowTestsBase : QuantityTestsBase protected abstract double StandardLitersPerMinuteInOneStandardCubicMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double StandardCubicCentimetersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double StandardCubicFeetPerHourTolerance { get { return 1e-5; } } - protected virtual double StandardCubicFeetPerMinuteTolerance { get { return 1e-5; } } - protected virtual double StandardCubicFeetPerSecondTolerance { get { return 1e-5; } } - protected virtual double StandardCubicMetersPerDayTolerance { get { return 1e-5; } } - protected virtual double StandardCubicMetersPerHourTolerance { get { return 1e-5; } } - protected virtual double StandardCubicMetersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double StandardCubicMetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double StandardLitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double StandardCubicCentimetersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double StandardCubicFeetPerHourTolerance { get { return 1E-5; } } + protected virtual double StandardCubicFeetPerMinuteTolerance { get { return 1E-5; } } + protected virtual double StandardCubicFeetPerSecondTolerance { get { return 1E-5; } } + protected virtual double StandardCubicMetersPerDayTolerance { get { return 1E-5; } } + protected virtual double StandardCubicMetersPerHourTolerance { get { return 1E-5; } } + protected virtual double StandardCubicMetersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double StandardCubicMetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double StandardLitersPerMinuteTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(StandardVolumeFlowUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -487,14 +487,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(StandardVolumeFlowUnit unit) { - var inBaseUnits = StandardVolumeFlow.From(1.0, StandardVolumeFlow.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = StandardVolumeFlow.From(1.0, StandardVolumeFlow.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = StandardVolumeFlow.From(1.0, StandardVolumeFlow.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(StandardVolumeFlowUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(StandardVolumeFlowUnit unit) @@ -508,8 +515,8 @@ public void ToUnit_WithSameUnits_AreEqual(StandardVolumeFlowUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(StandardVolumeFlowUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = StandardVolumeFlow.Units.Where(u => u != StandardVolumeFlow.BaseUnit).DefaultIfEmpty(StandardVolumeFlow.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = StandardVolumeFlow.Units.First(u => u != StandardVolumeFlow.BaseUnit); var quantity = StandardVolumeFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -728,8 +735,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -763,36 +771,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -805,22 +818,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -862,7 +878,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(new {StandardVolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(StandardVolumeFlow.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 6e8098579d..1126f1cbf4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase protected abstract double NanodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecadegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double DegreesCelsiusPerMinuteTolerance { get { return 1e-5; } } - protected virtual double DegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double HectodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double MicrodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double MillidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } - protected virtual double NanodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double CentidegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecadegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecidegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double DegreesCelsiusPerMinuteTolerance { get { return 1E-5; } } + protected virtual double DegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double HectodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double MicrodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double MillidegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double NanodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureChangeRateUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -521,14 +521,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureChangeRateUnit unit) { - var inBaseUnits = TemperatureChangeRate.From(1.0, TemperatureChangeRate.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = TemperatureChangeRate.From(1.0, TemperatureChangeRate.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = TemperatureChangeRate.From(1.0, TemperatureChangeRate.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureChangeRateUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureChangeRateUnit unit) @@ -542,8 +549,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureChangeRateUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TemperatureChangeRate.Units.Where(u => u != TemperatureChangeRate.BaseUnit).DefaultIfEmpty(TemperatureChangeRate.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = TemperatureChangeRate.Units.First(u => u != TemperatureChangeRate.BaseUnit); var quantity = TemperatureChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -765,8 +772,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -800,36 +808,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -842,22 +855,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -899,7 +915,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(new {TemperatureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(TemperatureChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 7febab8e92..888100c7d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class TemperatureDeltaTestsBase : QuantityTestsBase protected abstract double MillidegreesCelsiusInOneKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelsiusTolerance { get { return 1e-5; } } - protected virtual double DegreesDelisleTolerance { get { return 1e-5; } } - protected virtual double DegreesFahrenheitTolerance { get { return 1e-5; } } - protected virtual double DegreesNewtonTolerance { get { return 1e-5; } } - protected virtual double DegreesRankineTolerance { get { return 1e-5; } } - protected virtual double DegreesReaumurTolerance { get { return 1e-5; } } - protected virtual double DegreesRoemerTolerance { get { return 1e-5; } } - protected virtual double KelvinsTolerance { get { return 1e-5; } } - protected virtual double MillidegreesCelsiusTolerance { get { return 1e-5; } } + protected virtual double DegreesCelsiusTolerance { get { return 1E-5; } } + protected virtual double DegreesDelisleTolerance { get { return 1E-5; } } + protected virtual double DegreesFahrenheitTolerance { get { return 1E-5; } } + protected virtual double DegreesNewtonTolerance { get { return 1E-5; } } + protected virtual double DegreesRankineTolerance { get { return 1E-5; } } + protected virtual double DegreesReaumurTolerance { get { return 1E-5; } } + protected virtual double DegreesRoemerTolerance { get { return 1E-5; } } + protected virtual double KelvinsTolerance { get { return 1E-5; } } + protected virtual double MillidegreesCelsiusTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureDeltaUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -487,14 +487,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureDeltaUnit unit) { - var inBaseUnits = TemperatureDelta.From(1.0, TemperatureDelta.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = TemperatureDelta.From(1.0, TemperatureDelta.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = TemperatureDelta.From(1.0, TemperatureDelta.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureDeltaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureDeltaUnit unit) @@ -508,8 +515,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureDeltaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureDeltaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TemperatureDelta.Units.Where(u => u != TemperatureDelta.BaseUnit).DefaultIfEmpty(TemperatureDelta.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = TemperatureDelta.Units.First(u => u != TemperatureDelta.BaseUnit); var quantity = TemperatureDelta.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -728,8 +735,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -763,36 +771,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -805,22 +818,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = TemperatureDelta.FromKelvins(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -862,7 +878,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(new {TemperatureDelta.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(TemperatureDelta.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index e0a6f79454..6ba368aafa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class TemperatureGradientTestsBase : QuantityTestsBase protected abstract double KelvinsPerMeterInOneKelvinPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1e-5; } } - protected virtual double DegreesCelciusPerMeterTolerance { get { return 1e-5; } } - protected virtual double DegreesFahrenheitPerFootTolerance { get { return 1e-5; } } - protected virtual double KelvinsPerMeterTolerance { get { return 1e-5; } } + protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1E-5; } } + protected virtual double DegreesCelciusPerMeterTolerance { get { return 1E-5; } } + protected virtual double DegreesFahrenheitPerFootTolerance { get { return 1E-5; } } + protected virtual double KelvinsPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureGradientUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,14 +317,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureGradientUnit unit) { - var inBaseUnits = TemperatureGradient.From(1.0, TemperatureGradient.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = TemperatureGradient.From(1.0, TemperatureGradient.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = TemperatureGradient.From(1.0, TemperatureGradient.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureGradientUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureGradientUnit unit) @@ -338,8 +345,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureGradientUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureGradientUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TemperatureGradient.Units.Where(u => u != TemperatureGradient.BaseUnit).DefaultIfEmpty(TemperatureGradient.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = TemperatureGradient.Units.First(u => u != TemperatureGradient.BaseUnit); var quantity = TemperatureGradient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -543,8 +550,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -578,36 +586,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -620,22 +633,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = TemperatureGradient.FromKelvinsPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -677,7 +693,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal(new {TemperatureGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(TemperatureGradient.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index fe54557914..17da2c0e60 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class TemperatureTestsBase : QuantityTestsBase protected abstract double SolarTemperaturesInOneKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelsiusTolerance { get { return 1e-5; } } - protected virtual double DegreesDelisleTolerance { get { return 1e-5; } } - protected virtual double DegreesFahrenheitTolerance { get { return 1e-5; } } - protected virtual double DegreesNewtonTolerance { get { return 1e-5; } } - protected virtual double DegreesRankineTolerance { get { return 1e-5; } } - protected virtual double DegreesReaumurTolerance { get { return 1e-5; } } - protected virtual double DegreesRoemerTolerance { get { return 1e-5; } } - protected virtual double KelvinsTolerance { get { return 1e-5; } } - protected virtual double MillidegreesCelsiusTolerance { get { return 1e-5; } } - protected virtual double SolarTemperaturesTolerance { get { return 1e-5; } } + protected virtual double DegreesCelsiusTolerance { get { return 1E-5; } } + protected virtual double DegreesDelisleTolerance { get { return 1E-5; } } + protected virtual double DegreesFahrenheitTolerance { get { return 1E-5; } } + protected virtual double DegreesNewtonTolerance { get { return 1E-5; } } + protected virtual double DegreesRankineTolerance { get { return 1E-5; } } + protected virtual double DegreesReaumurTolerance { get { return 1E-5; } } + protected virtual double DegreesRoemerTolerance { get { return 1E-5; } } + protected virtual double KelvinsTolerance { get { return 1E-5; } } + protected virtual double MillidegreesCelsiusTolerance { get { return 1E-5; } } + protected virtual double SolarTemperaturesTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -521,14 +521,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureUnit unit) { - var inBaseUnits = Temperature.From(1.0, Temperature.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Temperature.From(1.0, Temperature.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Temperature.From(1.0, Temperature.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureUnit unit) @@ -542,8 +549,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Temperature.Units.Where(u => u != Temperature.BaseUnit).DefaultIfEmpty(Temperature.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Temperature.Units.First(u => u != Temperature.BaseUnit); var quantity = Temperature.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -753,8 +760,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -788,36 +796,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -830,22 +843,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Temperature.FromKelvins(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Temperature.FromKelvins(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -887,7 +903,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(new {Temperature.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Temperature.Info.Name.GetHashCode(), quantity.GetHashCode()); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index f9ba3e2d05..a1e2152df9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class ThermalConductivityTestsBase : QuantityTestsBase protected abstract double WattsPerMeterKelvinInOneWattPerMeterKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerHourFootFahrenheitTolerance { get { return 1e-5; } } - protected virtual double WattsPerMeterKelvinTolerance { get { return 1e-5; } } + protected virtual double BtusPerHourFootFahrenheitTolerance { get { return 1E-5; } } + protected virtual double WattsPerMeterKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ThermalConductivityUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,14 +249,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ThermalConductivityUnit unit) { - var inBaseUnits = ThermalConductivity.From(1.0, ThermalConductivity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ThermalConductivity.From(1.0, ThermalConductivity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ThermalConductivity.From(1.0, ThermalConductivity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ThermalConductivityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ThermalConductivityUnit unit) @@ -270,8 +277,8 @@ public void ToUnit_WithSameUnits_AreEqual(ThermalConductivityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ThermalConductivityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ThermalConductivity.Units.Where(u => u != ThermalConductivity.BaseUnit).DefaultIfEmpty(ThermalConductivity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ThermalConductivity.Units.First(u => u != ThermalConductivity.BaseUnit); var quantity = ThermalConductivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -469,8 +476,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -504,36 +512,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -546,22 +559,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -603,7 +619,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(new {ThermalConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ThermalConductivity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 00f985ad3e..00b775c402 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class ThermalResistanceTestsBase : QuantityTestsBase protected abstract double SquareMeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double HourSquareFeetDegreesFahrenheitPerBtuTolerance { get { return 1e-5; } } - protected virtual double SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance { get { return 1e-5; } } - protected virtual double SquareCentimeterKelvinsPerWattTolerance { get { return 1e-5; } } - protected virtual double SquareMeterDegreesCelsiusPerWattTolerance { get { return 1e-5; } } - protected virtual double SquareMeterKelvinsPerKilowattTolerance { get { return 1e-5; } } - protected virtual double SquareMeterKelvinsPerWattTolerance { get { return 1e-5; } } + protected virtual double HourSquareFeetDegreesFahrenheitPerBtuTolerance { get { return 1E-5; } } + protected virtual double SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance { get { return 1E-5; } } + protected virtual double SquareCentimeterKelvinsPerWattTolerance { get { return 1E-5; } } + protected virtual double SquareMeterDegreesCelsiusPerWattTolerance { get { return 1E-5; } } + protected virtual double SquareMeterKelvinsPerKilowattTolerance { get { return 1E-5; } } + protected virtual double SquareMeterKelvinsPerWattTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ThermalResistanceUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -385,14 +385,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ThermalResistanceUnit unit) { - var inBaseUnits = ThermalResistance.From(1.0, ThermalResistance.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = ThermalResistance.From(1.0, ThermalResistance.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = ThermalResistance.From(1.0, ThermalResistance.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(ThermalResistanceUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ThermalResistanceUnit unit) @@ -406,8 +413,8 @@ public void ToUnit_WithSameUnits_AreEqual(ThermalResistanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ThermalResistanceUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = ThermalResistance.Units.Where(u => u != ThermalResistance.BaseUnit).DefaultIfEmpty(ThermalResistance.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = ThermalResistance.Units.First(u => u != ThermalResistance.BaseUnit); var quantity = ThermalResistance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -617,8 +624,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -652,36 +660,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -694,22 +707,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -751,7 +767,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(new {ThermalResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(ThermalResistance.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 4d7495ee03..ca4ffc8708 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -61,27 +61,27 @@ public abstract partial class TorquePerLengthTestsBase : QuantityTestsBase protected abstract double TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramForceCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramForceMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilogramForceMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceFeetPerFootTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceInchesPerFootTolerance { get { return 1e-5; } } - protected virtual double MeganewtonCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double MegapoundForceFeetPerFootTolerance { get { return 1e-5; } } - protected virtual double MegapoundForceInchesPerFootTolerance { get { return 1e-5; } } - protected virtual double NewtonCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double NewtonMillimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double PoundForceFeetPerFootTolerance { get { return 1e-5; } } - protected virtual double PoundForceInchesPerFootTolerance { get { return 1e-5; } } - protected virtual double TonneForceCentimetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double TonneForceMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double TonneForceMillimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramForceCentimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramForceMetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramForceMillimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonCentimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMillimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilopoundForceFeetPerFootTolerance { get { return 1E-5; } } + protected virtual double KilopoundForceInchesPerFootTolerance { get { return 1E-5; } } + protected virtual double MeganewtonCentimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMillimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double MegapoundForceFeetPerFootTolerance { get { return 1E-5; } } + protected virtual double MegapoundForceInchesPerFootTolerance { get { return 1E-5; } } + protected virtual double NewtonCentimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonMetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double NewtonMillimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double PoundForceFeetPerFootTolerance { get { return 1E-5; } } + protected virtual double PoundForceInchesPerFootTolerance { get { return 1E-5; } } + protected virtual double TonneForceCentimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double TonneForceMetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double TonneForceMillimetersPerMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TorquePerLengthUnit unit) @@ -358,7 +358,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -967,14 +967,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TorquePerLengthUnit unit) { - var inBaseUnits = TorquePerLength.From(1.0, TorquePerLength.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = TorquePerLength.From(1.0, TorquePerLength.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = TorquePerLength.From(1.0, TorquePerLength.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TorquePerLengthUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TorquePerLengthUnit unit) @@ -988,8 +995,8 @@ public void ToUnit_WithSameUnits_AreEqual(TorquePerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorquePerLengthUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = TorquePerLength.Units.Where(u => u != TorquePerLength.BaseUnit).DefaultIfEmpty(TorquePerLength.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = TorquePerLength.Units.First(u => u != TorquePerLength.BaseUnit); var quantity = TorquePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1244,8 +1251,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1279,36 +1287,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1321,22 +1334,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1378,7 +1394,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(new {TorquePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(TorquePerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 322306450f..803d7bce5a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -65,31 +65,31 @@ public abstract partial class TorqueTestsBase : QuantityTestsBase protected abstract double TonneForceMillimetersInOneNewtonMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramForceCentimetersTolerance { get { return 1e-5; } } - protected virtual double GramForceMetersTolerance { get { return 1e-5; } } - protected virtual double GramForceMillimetersTolerance { get { return 1e-5; } } - protected virtual double KilogramForceCentimetersTolerance { get { return 1e-5; } } - protected virtual double KilogramForceMetersTolerance { get { return 1e-5; } } - protected virtual double KilogramForceMillimetersTolerance { get { return 1e-5; } } - protected virtual double KilonewtonCentimetersTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMetersTolerance { get { return 1e-5; } } - protected virtual double KilonewtonMillimetersTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceFeetTolerance { get { return 1e-5; } } - protected virtual double KilopoundForceInchesTolerance { get { return 1e-5; } } - protected virtual double MeganewtonCentimetersTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMetersTolerance { get { return 1e-5; } } - protected virtual double MeganewtonMillimetersTolerance { get { return 1e-5; } } - protected virtual double MegapoundForceFeetTolerance { get { return 1e-5; } } - protected virtual double MegapoundForceInchesTolerance { get { return 1e-5; } } - protected virtual double NewtonCentimetersTolerance { get { return 1e-5; } } - protected virtual double NewtonMetersTolerance { get { return 1e-5; } } - protected virtual double NewtonMillimetersTolerance { get { return 1e-5; } } - protected virtual double PoundalFeetTolerance { get { return 1e-5; } } - protected virtual double PoundForceFeetTolerance { get { return 1e-5; } } - protected virtual double PoundForceInchesTolerance { get { return 1e-5; } } - protected virtual double TonneForceCentimetersTolerance { get { return 1e-5; } } - protected virtual double TonneForceMetersTolerance { get { return 1e-5; } } - protected virtual double TonneForceMillimetersTolerance { get { return 1e-5; } } + protected virtual double GramForceCentimetersTolerance { get { return 1E-5; } } + protected virtual double GramForceMetersTolerance { get { return 1E-5; } } + protected virtual double GramForceMillimetersTolerance { get { return 1E-5; } } + protected virtual double KilogramForceCentimetersTolerance { get { return 1E-5; } } + protected virtual double KilogramForceMetersTolerance { get { return 1E-5; } } + protected virtual double KilogramForceMillimetersTolerance { get { return 1E-5; } } + protected virtual double KilonewtonCentimetersTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMetersTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMillimetersTolerance { get { return 1E-5; } } + protected virtual double KilopoundForceFeetTolerance { get { return 1E-5; } } + protected virtual double KilopoundForceInchesTolerance { get { return 1E-5; } } + protected virtual double MeganewtonCentimetersTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMetersTolerance { get { return 1E-5; } } + protected virtual double MeganewtonMillimetersTolerance { get { return 1E-5; } } + protected virtual double MegapoundForceFeetTolerance { get { return 1E-5; } } + protected virtual double MegapoundForceInchesTolerance { get { return 1E-5; } } + protected virtual double NewtonCentimetersTolerance { get { return 1E-5; } } + protected virtual double NewtonMetersTolerance { get { return 1E-5; } } + protected virtual double NewtonMillimetersTolerance { get { return 1E-5; } } + protected virtual double PoundalFeetTolerance { get { return 1E-5; } } + protected virtual double PoundForceFeetTolerance { get { return 1E-5; } } + protected virtual double PoundForceInchesTolerance { get { return 1E-5; } } + protected virtual double TonneForceCentimetersTolerance { get { return 1E-5; } } + protected virtual double TonneForceMetersTolerance { get { return 1E-5; } } + protected virtual double TonneForceMillimetersTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TorqueUnit unit) @@ -398,7 +398,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1103,14 +1103,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TorqueUnit unit) { - var inBaseUnits = Torque.From(1.0, Torque.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Torque.From(1.0, Torque.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Torque.From(1.0, Torque.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TorqueUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TorqueUnit unit) @@ -1124,8 +1131,8 @@ public void ToUnit_WithSameUnits_AreEqual(TorqueUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorqueUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Torque.Units.Where(u => u != Torque.BaseUnit).DefaultIfEmpty(Torque.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Torque.Units.First(u => u != Torque.BaseUnit); var quantity = Torque.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1392,8 +1399,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1427,36 +1435,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1469,22 +1482,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Torque.FromNewtonMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1526,7 +1542,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(new {Torque.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Torque.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 65fd4b5012..c7fec73200 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class TurbidityTestsBase : QuantityTestsBase protected abstract double NTUInOneNTU { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double NTUTolerance { get { return 1e-5; } } + protected virtual double NTUTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TurbidityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TurbidityUnit unit) { - var inBaseUnits = Turbidity.From(1.0, Turbidity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Turbidity.From(1.0, Turbidity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Turbidity.From(1.0, Turbidity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(TurbidityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TurbidityUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(TurbidityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TurbidityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Turbidity.Units.Where(u => u != Turbidity.BaseUnit).DefaultIfEmpty(Turbidity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Turbidity.Units.First(u => u != Turbidity.BaseUnit); var quantity = Turbidity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Turbidity.FromNTU(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Turbidity.FromNTU(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(new {Turbidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Turbidity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 36661f561c..b08943ff4b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class VitaminATestsBase : QuantityTestsBase protected abstract double InternationalUnitsInOneInternationalUnit { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InternationalUnitsTolerance { get { return 1e-5; } } + protected virtual double InternationalUnitsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VitaminAUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,14 +215,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VitaminAUnit unit) { - var inBaseUnits = VitaminA.From(1.0, VitaminA.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = VitaminA.From(1.0, VitaminA.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = VitaminA.From(1.0, VitaminA.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VitaminAUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VitaminAUnit unit) @@ -232,12 +239,12 @@ public void ToUnit_WithSameUnits_AreEqual(VitaminAUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory] + [Theory(Skip = "Multiple units required")] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VitaminAUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VitaminA.Units.Where(u => u != VitaminA.BaseUnit).DefaultIfEmpty(VitaminA.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = VitaminA.Units.First(u => u != VitaminA.BaseUnit); var quantity = VitaminA.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -432,8 +439,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -467,36 +475,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -509,22 +522,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = VitaminA.FromInternationalUnits(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -566,7 +582,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(new {VitaminA.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(VitaminA.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index d807ec47aa..4367e649aa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -60,26 +60,26 @@ public abstract partial class VolumeConcentrationTestsBase : QuantityTestsBase protected abstract double PicolitersPerMililiterInOneDecimalFraction { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentilitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double CentilitersPerMililiterTolerance { get { return 1e-5; } } - protected virtual double DecilitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double DecilitersPerMililiterTolerance { get { return 1e-5; } } - protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } - protected virtual double LitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double LitersPerMililiterTolerance { get { return 1e-5; } } - protected virtual double MicrolitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double MicrolitersPerMililiterTolerance { get { return 1e-5; } } - protected virtual double MillilitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double MillilitersPerMililiterTolerance { get { return 1e-5; } } - protected virtual double NanolitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double NanolitersPerMililiterTolerance { get { return 1e-5; } } - protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } - protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } - protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } - protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } - protected virtual double PercentTolerance { get { return 1e-5; } } - protected virtual double PicolitersPerLiterTolerance { get { return 1e-5; } } - protected virtual double PicolitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double CentilitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double CentilitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double DecilitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double DecilitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double DecimalFractionsTolerance { get { return 1E-5; } } + protected virtual double LitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double LitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double MicrolitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double MicrolitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double MillilitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double MillilitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double NanolitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double NanolitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1E-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1E-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1E-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1E-5; } } + protected virtual double PercentTolerance { get { return 1E-5; } } + protected virtual double PicolitersPerLiterTolerance { get { return 1E-5; } } + protected virtual double PicolitersPerMililiterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeConcentrationUnit unit) @@ -348,7 +348,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -885,14 +885,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeConcentrationUnit unit) { - var inBaseUnits = VolumeConcentration.From(1.0, VolumeConcentration.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = VolumeConcentration.From(1.0, VolumeConcentration.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = VolumeConcentration.From(1.0, VolumeConcentration.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeConcentrationUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeConcentrationUnit unit) @@ -906,8 +913,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeConcentrationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeConcentrationUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumeConcentration.Units.Where(u => u != VolumeConcentration.BaseUnit).DefaultIfEmpty(VolumeConcentration.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = VolumeConcentration.Units.First(u => u != VolumeConcentration.BaseUnit); var quantity = VolumeConcentration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1159,8 +1166,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -1194,36 +1202,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -1236,22 +1249,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = VolumeConcentration.FromDecimalFractions(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -1293,7 +1309,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(new {VolumeConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(VolumeConcentration.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 722f63a1d7..918eab8558 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class VolumeFlowPerAreaTestsBase : QuantityTestsBase protected abstract double CubicMetersPerSecondPerSquareMeterInOneCubicMeterPerSecondPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CubicFeetPerMinutePerSquareFootTolerance { get { return 1e-5; } } - protected virtual double CubicMetersPerSecondPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double CubicFeetPerMinutePerSquareFootTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerSecondPerSquareMeterTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeFlowPerAreaUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,14 +249,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeFlowPerAreaUnit unit) { - var inBaseUnits = VolumeFlowPerArea.From(1.0, VolumeFlowPerArea.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = VolumeFlowPerArea.From(1.0, VolumeFlowPerArea.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = VolumeFlowPerArea.From(1.0, VolumeFlowPerArea.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeFlowPerAreaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeFlowPerAreaUnit unit) @@ -270,8 +277,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeFlowPerAreaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeFlowPerAreaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumeFlowPerArea.Units.Where(u => u != VolumeFlowPerArea.BaseUnit).DefaultIfEmpty(VolumeFlowPerArea.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = VolumeFlowPerArea.Units.First(u => u != VolumeFlowPerArea.BaseUnit); var quantity = VolumeFlowPerArea.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -469,8 +476,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -504,36 +512,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -546,22 +559,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -603,7 +619,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal(new {VolumeFlowPerArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(VolumeFlowPerArea.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index caf0e209b2..7a84a2581a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -102,68 +102,68 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase protected abstract double UsGallonsPerSecondInOneCubicMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AcreFeetPerDayTolerance { get { return 1e-5; } } - protected virtual double AcreFeetPerHourTolerance { get { return 1e-5; } } - protected virtual double AcreFeetPerMinuteTolerance { get { return 1e-5; } } - protected virtual double AcreFeetPerSecondTolerance { get { return 1e-5; } } - protected virtual double CentilitersPerDayTolerance { get { return 1e-5; } } - protected virtual double CentilitersPerHourTolerance { get { return 1e-5; } } - protected virtual double CentilitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double CentilitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double CubicCentimetersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double CubicDecimetersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double CubicFeetPerHourTolerance { get { return 1e-5; } } - protected virtual double CubicFeetPerMinuteTolerance { get { return 1e-5; } } - protected virtual double CubicFeetPerSecondTolerance { get { return 1e-5; } } - protected virtual double CubicMetersPerDayTolerance { get { return 1e-5; } } - protected virtual double CubicMetersPerHourTolerance { get { return 1e-5; } } - protected virtual double CubicMetersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double CubicMetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double CubicMillimetersPerSecondTolerance { get { return 1e-5; } } - protected virtual double CubicYardsPerDayTolerance { get { return 1e-5; } } - protected virtual double CubicYardsPerHourTolerance { get { return 1e-5; } } - protected virtual double CubicYardsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double CubicYardsPerSecondTolerance { get { return 1e-5; } } - protected virtual double DecilitersPerDayTolerance { get { return 1e-5; } } - protected virtual double DecilitersPerHourTolerance { get { return 1e-5; } } - protected virtual double DecilitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double DecilitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilolitersPerDayTolerance { get { return 1e-5; } } - protected virtual double KilolitersPerHourTolerance { get { return 1e-5; } } - protected virtual double KilolitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double KilolitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilousGallonsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double LitersPerDayTolerance { get { return 1e-5; } } - protected virtual double LitersPerHourTolerance { get { return 1e-5; } } - protected virtual double LitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double LitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegalitersPerDayTolerance { get { return 1e-5; } } - protected virtual double MegaukGallonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MicrolitersPerDayTolerance { get { return 1e-5; } } - protected virtual double MicrolitersPerHourTolerance { get { return 1e-5; } } - protected virtual double MicrolitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double MicrolitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double MillilitersPerDayTolerance { get { return 1e-5; } } - protected virtual double MillilitersPerHourTolerance { get { return 1e-5; } } - protected virtual double MillilitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double MillilitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double MillionUsGallonsPerDayTolerance { get { return 1e-5; } } - protected virtual double NanolitersPerDayTolerance { get { return 1e-5; } } - protected virtual double NanolitersPerHourTolerance { get { return 1e-5; } } - protected virtual double NanolitersPerMinuteTolerance { get { return 1e-5; } } - protected virtual double NanolitersPerSecondTolerance { get { return 1e-5; } } - protected virtual double OilBarrelsPerDayTolerance { get { return 1e-5; } } - protected virtual double OilBarrelsPerHourTolerance { get { return 1e-5; } } - protected virtual double OilBarrelsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double OilBarrelsPerSecondTolerance { get { return 1e-5; } } - protected virtual double UkGallonsPerDayTolerance { get { return 1e-5; } } - protected virtual double UkGallonsPerHourTolerance { get { return 1e-5; } } - protected virtual double UkGallonsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double UkGallonsPerSecondTolerance { get { return 1e-5; } } - protected virtual double UsGallonsPerDayTolerance { get { return 1e-5; } } - protected virtual double UsGallonsPerHourTolerance { get { return 1e-5; } } - protected virtual double UsGallonsPerMinuteTolerance { get { return 1e-5; } } - protected virtual double UsGallonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double AcreFeetPerDayTolerance { get { return 1E-5; } } + protected virtual double AcreFeetPerHourTolerance { get { return 1E-5; } } + protected virtual double AcreFeetPerMinuteTolerance { get { return 1E-5; } } + protected virtual double AcreFeetPerSecondTolerance { get { return 1E-5; } } + protected virtual double CentilitersPerDayTolerance { get { return 1E-5; } } + protected virtual double CentilitersPerHourTolerance { get { return 1E-5; } } + protected virtual double CentilitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double CentilitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double CubicCentimetersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double CubicDecimetersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double CubicFeetPerHourTolerance { get { return 1E-5; } } + protected virtual double CubicFeetPerMinuteTolerance { get { return 1E-5; } } + protected virtual double CubicFeetPerSecondTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerDayTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerHourTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double CubicMillimetersPerSecondTolerance { get { return 1E-5; } } + protected virtual double CubicYardsPerDayTolerance { get { return 1E-5; } } + protected virtual double CubicYardsPerHourTolerance { get { return 1E-5; } } + protected virtual double CubicYardsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double CubicYardsPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecilitersPerDayTolerance { get { return 1E-5; } } + protected virtual double DecilitersPerHourTolerance { get { return 1E-5; } } + protected virtual double DecilitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double DecilitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilolitersPerDayTolerance { get { return 1E-5; } } + protected virtual double KilolitersPerHourTolerance { get { return 1E-5; } } + protected virtual double KilolitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double KilolitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double KilousGallonsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double LitersPerDayTolerance { get { return 1E-5; } } + protected virtual double LitersPerHourTolerance { get { return 1E-5; } } + protected virtual double LitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double LitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double MegalitersPerDayTolerance { get { return 1E-5; } } + protected virtual double MegaukGallonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double MicrolitersPerDayTolerance { get { return 1E-5; } } + protected virtual double MicrolitersPerHourTolerance { get { return 1E-5; } } + protected virtual double MicrolitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double MicrolitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double MillilitersPerDayTolerance { get { return 1E-5; } } + protected virtual double MillilitersPerHourTolerance { get { return 1E-5; } } + protected virtual double MillilitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double MillilitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double MillionUsGallonsPerDayTolerance { get { return 1E-5; } } + protected virtual double NanolitersPerDayTolerance { get { return 1E-5; } } + protected virtual double NanolitersPerHourTolerance { get { return 1E-5; } } + protected virtual double NanolitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double NanolitersPerSecondTolerance { get { return 1E-5; } } + protected virtual double OilBarrelsPerDayTolerance { get { return 1E-5; } } + protected virtual double OilBarrelsPerHourTolerance { get { return 1E-5; } } + protected virtual double OilBarrelsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double OilBarrelsPerSecondTolerance { get { return 1E-5; } } + protected virtual double UkGallonsPerDayTolerance { get { return 1E-5; } } + protected virtual double UkGallonsPerHourTolerance { get { return 1E-5; } } + protected virtual double UkGallonsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double UkGallonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double UsGallonsPerDayTolerance { get { return 1E-5; } } + protected virtual double UsGallonsPerHourTolerance { get { return 1E-5; } } + protected virtual double UsGallonsPerMinuteTolerance { get { return 1E-5; } } + protected virtual double UsGallonsPerSecondTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeFlowUnit unit) @@ -768,7 +768,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -3951,14 +3951,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeFlowUnit unit) { - var inBaseUnits = VolumeFlow.From(1.0, VolumeFlow.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = VolumeFlow.From(1.0, VolumeFlow.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = VolumeFlow.From(1.0, VolumeFlow.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeFlowUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeFlowUnit unit) @@ -3972,8 +3979,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeFlowUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeFlowUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumeFlow.Units.Where(u => u != VolumeFlow.BaseUnit).DefaultIfEmpty(VolumeFlow.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = VolumeFlow.Units.First(u => u != VolumeFlow.BaseUnit); var quantity = VolumeFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -4351,8 +4358,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -4386,36 +4394,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -4428,22 +4441,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = VolumeFlow.FromCubicMetersPerSecond(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -4485,7 +4501,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(new {VolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(VolumeFlow.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 98f4ce00c7..ca1a1da646 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class VolumePerLengthTestsBase : QuantityTestsBase protected abstract double OilBarrelsPerFootInOneCubicMeterPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CubicMetersPerMeterTolerance { get { return 1e-5; } } - protected virtual double CubicYardsPerFootTolerance { get { return 1e-5; } } - protected virtual double CubicYardsPerUsSurveyFootTolerance { get { return 1e-5; } } - protected virtual double LitersPerKilometerTolerance { get { return 1e-5; } } - protected virtual double LitersPerMeterTolerance { get { return 1e-5; } } - protected virtual double LitersPerMillimeterTolerance { get { return 1e-5; } } - protected virtual double OilBarrelsPerFootTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double CubicYardsPerFootTolerance { get { return 1E-5; } } + protected virtual double CubicYardsPerUsSurveyFootTolerance { get { return 1E-5; } } + protected virtual double LitersPerKilometerTolerance { get { return 1E-5; } } + protected virtual double LitersPerMeterTolerance { get { return 1E-5; } } + protected virtual double LitersPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double OilBarrelsPerFootTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumePerLengthUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -419,14 +419,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumePerLengthUnit unit) { - var inBaseUnits = VolumePerLength.From(1.0, VolumePerLength.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = VolumePerLength.From(1.0, VolumePerLength.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = VolumePerLength.From(1.0, VolumePerLength.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VolumePerLengthUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumePerLengthUnit unit) @@ -440,8 +447,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumePerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumePerLengthUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumePerLength.Units.Where(u => u != VolumePerLength.BaseUnit).DefaultIfEmpty(VolumePerLength.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = VolumePerLength.Units.First(u => u != VolumePerLength.BaseUnit); var quantity = VolumePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -654,8 +661,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -689,36 +697,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -731,22 +744,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = VolumePerLength.FromCubicMetersPerMeter(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -788,7 +804,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(new {VolumePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(VolumePerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 4447d491b4..2828a5de16 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -92,58 +92,58 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase protected abstract double UsTeaspoonsInOneCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AcreFeetTolerance { get { return 1e-5; } } - protected virtual double AuTablespoonsTolerance { get { return 1e-5; } } - protected virtual double BoardFeetTolerance { get { return 1e-5; } } - protected virtual double CentilitersTolerance { get { return 1e-5; } } - protected virtual double CubicCentimetersTolerance { get { return 1e-5; } } - protected virtual double CubicDecimetersTolerance { get { return 1e-5; } } - protected virtual double CubicFeetTolerance { get { return 1e-5; } } - protected virtual double CubicHectometersTolerance { get { return 1e-5; } } - protected virtual double CubicInchesTolerance { get { return 1e-5; } } - protected virtual double CubicKilometersTolerance { get { return 1e-5; } } - protected virtual double CubicMetersTolerance { get { return 1e-5; } } - protected virtual double CubicMicrometersTolerance { get { return 1e-5; } } - protected virtual double CubicMilesTolerance { get { return 1e-5; } } - protected virtual double CubicMillimetersTolerance { get { return 1e-5; } } - protected virtual double CubicYardsTolerance { get { return 1e-5; } } - protected virtual double DecalitersTolerance { get { return 1e-5; } } - protected virtual double DecausGallonsTolerance { get { return 1e-5; } } - protected virtual double DecilitersTolerance { get { return 1e-5; } } - protected virtual double DeciusGallonsTolerance { get { return 1e-5; } } - protected virtual double HectocubicFeetTolerance { get { return 1e-5; } } - protected virtual double HectocubicMetersTolerance { get { return 1e-5; } } - protected virtual double HectolitersTolerance { get { return 1e-5; } } - protected virtual double HectousGallonsTolerance { get { return 1e-5; } } - protected virtual double ImperialBeerBarrelsTolerance { get { return 1e-5; } } - protected virtual double ImperialGallonsTolerance { get { return 1e-5; } } - protected virtual double ImperialOuncesTolerance { get { return 1e-5; } } - protected virtual double ImperialPintsTolerance { get { return 1e-5; } } - protected virtual double KilocubicFeetTolerance { get { return 1e-5; } } - protected virtual double KilocubicMetersTolerance { get { return 1e-5; } } - protected virtual double KiloimperialGallonsTolerance { get { return 1e-5; } } - protected virtual double KilolitersTolerance { get { return 1e-5; } } - protected virtual double KilousGallonsTolerance { get { return 1e-5; } } - protected virtual double LitersTolerance { get { return 1e-5; } } - protected virtual double MegacubicFeetTolerance { get { return 1e-5; } } - protected virtual double MegaimperialGallonsTolerance { get { return 1e-5; } } - protected virtual double MegalitersTolerance { get { return 1e-5; } } - protected virtual double MegausGallonsTolerance { get { return 1e-5; } } - protected virtual double MetricCupsTolerance { get { return 1e-5; } } - protected virtual double MetricTeaspoonsTolerance { get { return 1e-5; } } - protected virtual double MicrolitersTolerance { get { return 1e-5; } } - protected virtual double MillilitersTolerance { get { return 1e-5; } } - protected virtual double OilBarrelsTolerance { get { return 1e-5; } } - protected virtual double UkTablespoonsTolerance { get { return 1e-5; } } - protected virtual double UsBeerBarrelsTolerance { get { return 1e-5; } } - protected virtual double UsCustomaryCupsTolerance { get { return 1e-5; } } - protected virtual double UsGallonsTolerance { get { return 1e-5; } } - protected virtual double UsLegalCupsTolerance { get { return 1e-5; } } - protected virtual double UsOuncesTolerance { get { return 1e-5; } } - protected virtual double UsPintsTolerance { get { return 1e-5; } } - protected virtual double UsQuartsTolerance { get { return 1e-5; } } - protected virtual double UsTablespoonsTolerance { get { return 1e-5; } } - protected virtual double UsTeaspoonsTolerance { get { return 1e-5; } } + protected virtual double AcreFeetTolerance { get { return 1E-5; } } + protected virtual double AuTablespoonsTolerance { get { return 1E-5; } } + protected virtual double BoardFeetTolerance { get { return 1E-5; } } + protected virtual double CentilitersTolerance { get { return 1E-5; } } + protected virtual double CubicCentimetersTolerance { get { return 1E-5; } } + protected virtual double CubicDecimetersTolerance { get { return 1E-5; } } + protected virtual double CubicFeetTolerance { get { return 1E-5; } } + protected virtual double CubicHectometersTolerance { get { return 1E-5; } } + protected virtual double CubicInchesTolerance { get { return 1E-5; } } + protected virtual double CubicKilometersTolerance { get { return 1E-5; } } + protected virtual double CubicMetersTolerance { get { return 1E-5; } } + protected virtual double CubicMicrometersTolerance { get { return 1E-5; } } + protected virtual double CubicMilesTolerance { get { return 1E-5; } } + protected virtual double CubicMillimetersTolerance { get { return 1E-5; } } + protected virtual double CubicYardsTolerance { get { return 1E-5; } } + protected virtual double DecalitersTolerance { get { return 1E-5; } } + protected virtual double DecausGallonsTolerance { get { return 1E-5; } } + protected virtual double DecilitersTolerance { get { return 1E-5; } } + protected virtual double DeciusGallonsTolerance { get { return 1E-5; } } + protected virtual double HectocubicFeetTolerance { get { return 1E-5; } } + protected virtual double HectocubicMetersTolerance { get { return 1E-5; } } + protected virtual double HectolitersTolerance { get { return 1E-5; } } + protected virtual double HectousGallonsTolerance { get { return 1E-5; } } + protected virtual double ImperialBeerBarrelsTolerance { get { return 1E-5; } } + protected virtual double ImperialGallonsTolerance { get { return 1E-5; } } + protected virtual double ImperialOuncesTolerance { get { return 1E-5; } } + protected virtual double ImperialPintsTolerance { get { return 1E-5; } } + protected virtual double KilocubicFeetTolerance { get { return 1E-5; } } + protected virtual double KilocubicMetersTolerance { get { return 1E-5; } } + protected virtual double KiloimperialGallonsTolerance { get { return 1E-5; } } + protected virtual double KilolitersTolerance { get { return 1E-5; } } + protected virtual double KilousGallonsTolerance { get { return 1E-5; } } + protected virtual double LitersTolerance { get { return 1E-5; } } + protected virtual double MegacubicFeetTolerance { get { return 1E-5; } } + protected virtual double MegaimperialGallonsTolerance { get { return 1E-5; } } + protected virtual double MegalitersTolerance { get { return 1E-5; } } + protected virtual double MegausGallonsTolerance { get { return 1E-5; } } + protected virtual double MetricCupsTolerance { get { return 1E-5; } } + protected virtual double MetricTeaspoonsTolerance { get { return 1E-5; } } + protected virtual double MicrolitersTolerance { get { return 1E-5; } } + protected virtual double MillilitersTolerance { get { return 1E-5; } } + protected virtual double OilBarrelsTolerance { get { return 1E-5; } } + protected virtual double UkTablespoonsTolerance { get { return 1E-5; } } + protected virtual double UsBeerBarrelsTolerance { get { return 1E-5; } } + protected virtual double UsCustomaryCupsTolerance { get { return 1E-5; } } + protected virtual double UsGallonsTolerance { get { return 1E-5; } } + protected virtual double UsLegalCupsTolerance { get { return 1E-5; } } + protected virtual double UsOuncesTolerance { get { return 1E-5; } } + protected virtual double UsPintsTolerance { get { return 1E-5; } } + protected virtual double UsQuartsTolerance { get { return 1E-5; } } + protected virtual double UsTablespoonsTolerance { get { return 1E-5; } } + protected virtual double UsTeaspoonsTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeUnit unit) @@ -668,7 +668,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2945,14 +2945,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeUnit unit) { - var inBaseUnits = Volume.From(1.0, Volume.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = Volume.From(1.0, Volume.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = Volume.From(1.0, Volume.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeUnit unit) @@ -2966,8 +2973,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = Volume.Units.Where(u => u != Volume.BaseUnit).DefaultIfEmpty(Volume.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = Volume.Units.First(u => u != Volume.BaseUnit); var quantity = Volume.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -3315,8 +3322,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -3350,36 +3358,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -3392,22 +3405,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = Volume.FromCubicMeters(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -3449,7 +3465,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(new {Volume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(Volume.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 030c251bde..6c205dcb92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class VolumetricHeatCapacityTestsBase : QuantityTestsBas protected abstract double MegajoulesPerCubicMeterKelvinInOneJoulePerCubicMeterKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerCubicFootDegreeFahrenheitTolerance { get { return 1e-5; } } - protected virtual double CaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double JoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double JoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } - protected virtual double KilocaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } + protected virtual double BtusPerCubicFootDegreeFahrenheitTolerance { get { return 1E-5; } } + protected virtual double CaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double JoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double JoulesPerCubicMeterKelvinTolerance { get { return 1E-5; } } + protected virtual double KilocaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double KilojoulesPerCubicMeterKelvinTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1E-5; } } + protected virtual double MegajoulesPerCubicMeterKelvinTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumetricHeatCapacityUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -487,14 +487,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumetricHeatCapacityUnit unit) { - var inBaseUnits = VolumetricHeatCapacity.From(1.0, VolumetricHeatCapacity.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = VolumetricHeatCapacity.From(1.0, VolumetricHeatCapacity.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = VolumetricHeatCapacity.From(1.0, VolumetricHeatCapacity.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(VolumetricHeatCapacityUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumetricHeatCapacityUnit unit) @@ -508,8 +515,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumetricHeatCapacityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumetricHeatCapacityUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = VolumetricHeatCapacity.Units.Where(u => u != VolumetricHeatCapacity.BaseUnit).DefaultIfEmpty(VolumetricHeatCapacity.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = VolumetricHeatCapacity.Units.First(u => u != VolumetricHeatCapacity.BaseUnit); var quantity = VolumetricHeatCapacity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -728,8 +735,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -763,36 +771,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -805,22 +818,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -862,7 +878,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(new {VolumetricHeatCapacity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(VolumetricHeatCapacity.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 683a9313ae..216a8b4dd8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class WarpingMomentOfInertiaTestsBase : QuantityTestsBas protected abstract double MillimetersToTheSixthInOneMeterToTheSixth { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersToTheSixthTolerance { get { return 1e-5; } } - protected virtual double DecimetersToTheSixthTolerance { get { return 1e-5; } } - protected virtual double FeetToTheSixthTolerance { get { return 1e-5; } } - protected virtual double InchesToTheSixthTolerance { get { return 1e-5; } } - protected virtual double MetersToTheSixthTolerance { get { return 1e-5; } } - protected virtual double MillimetersToTheSixthTolerance { get { return 1e-5; } } + protected virtual double CentimetersToTheSixthTolerance { get { return 1E-5; } } + protected virtual double DecimetersToTheSixthTolerance { get { return 1E-5; } } + protected virtual double FeetToTheSixthTolerance { get { return 1E-5; } } + protected virtual double InchesToTheSixthTolerance { get { return 1E-5; } } + protected virtual double MetersToTheSixthTolerance { get { return 1E-5; } } + protected virtual double MillimetersToTheSixthTolerance { get { return 1E-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(WarpingMomentOfInertiaUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) AsWithSIUnitSystem(); + var value = (double) (QuantityValue) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -529,14 +529,21 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(WarpingMomentOfInertiaUnit unit) { - var inBaseUnits = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); - var converted = inBaseUnits.ToUnit(unit); + var inBaseUnit = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); + var converted = inBaseUnit.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } + [Fact] + public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() + { + var inBaseUnit = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); + Assert.Throws(() => inBaseUnit.ToUnit(default(WarpingMomentOfInertiaUnit))); + } + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(WarpingMomentOfInertiaUnit unit) @@ -550,8 +557,8 @@ public void ToUnit_WithSameUnits_AreEqual(WarpingMomentOfInertiaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(WarpingMomentOfInertiaUnit unit) { - // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. - var fromUnit = WarpingMomentOfInertia.Units.Where(u => u != WarpingMomentOfInertia.BaseUnit).DefaultIfEmpty(WarpingMomentOfInertia.BaseUnit).FirstOrDefault(); + // This test is only available for quantities with more than one units. + var fromUnit = WarpingMomentOfInertia.Units.First(u => u != WarpingMomentOfInertia.BaseUnit); var quantity = WarpingMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -761,8 +768,9 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((byte)value, Convert.ToByte(quantity)); } [Fact] @@ -796,36 +804,41 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((short)value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((int)value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((long)value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((float)value, Convert.ToSingle(quantity)); } [Fact] @@ -838,22 +851,25 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((uint)value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); + var value = 1.0; + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); + Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); } [Fact] @@ -895,7 +911,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(new {WarpingMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(WarpingMomentOfInertia.Info.Name.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs index d02428161f..87882f3ad3 100644 --- a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs +++ b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs @@ -26,7 +26,7 @@ public void LengthEquals_GivenMaxError_ReturnsTrueIfWithinError() Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), 0, ComparisonType.Relative), "Integer values have zero difference."); Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), smallError, ComparisonType.Relative), "Using a max difference value should not change that fact."); - Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0, ComparisonType.Relative), + Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0.0, ComparisonType.Relative), "Example of floating precision arithmetic that produces slightly different results."); Assert.True(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), smallError, ComparisonType.Relative), "But the difference is very small"); } diff --git a/UnitsNet.Tests/IntOverloadTests.cs b/UnitsNet.Tests/IntOverloadTests.cs index bf63007ba7..9d059dcc46 100644 --- a/UnitsNet.Tests/IntOverloadTests.cs +++ b/UnitsNet.Tests/IntOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromIntReturnsCorrectVa public static void CreatingQuantityWithIntBackingFieldFromIntReturnsCorrectValue() { Power power = Power.FromWatts(1); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/LongOverloadTests.cs b/UnitsNet.Tests/LongOverloadTests.cs index fd54377f08..ba5c00a538 100644 --- a/UnitsNet.Tests/LongOverloadTests.cs +++ b/UnitsNet.Tests/LongOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromLongReturnsCorrectV public static void CreatingQuantityWithLongBackingFieldFromLongReturnsCorrectValue() { Power power = Power.FromWatts(1L); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/QuantityComparisonTests.cs b/UnitsNet.Tests/QuantityComparisonTests.cs new file mode 100644 index 0000000000..2947c2c251 --- /dev/null +++ b/UnitsNet.Tests/QuantityComparisonTests.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using UnitsNet.Units; +using Xunit; + +namespace UnitsNet.Tests +{ + public class QuantityComparisonTests + { + private static readonly decimal DecimalEpsilon = new decimal(1, 0, 0, false, 28); //1e-28m; + + #region IComparable + + [Fact] + public void CompareTo_DoubleQuantityWithSameQuantityInAnotherUnit_ReturnsZero() + { + var firstMass = Mass.FromGrams(0.001); + var secondMass = firstMass.ToUnit(MassUnit.Microgram); + + Assert.Equal(0, firstMass.CompareTo(secondMass)); + Assert.Equal(0, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DecimalQuantityWithSameQuantityInAnotherUnit_ReturnsZero() + { + var firstMass = Mass.FromGrams(0.001m); + var secondMass = firstMass.ToUnit(MassUnit.Microgram); + + Assert.Equal(0, firstMass.CompareTo(secondMass)); + Assert.Equal(0, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DoubleQuantityWithVeryCloseDoubleQuantity_ReturnsNonZero() + { + var firstMass = Mass.FromGrams(0.0); + var secondMass = Mass.FromGrams(double.Epsilon); + + Assert.Equal(-1, firstMass.CompareTo(secondMass)); + Assert.Equal(1, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DecimalQuantityWithVeryCloseDecimalQuantity_ReturnsNonZero() + { + var firstMass = Mass.FromGrams(0m); + var secondMass = Mass.FromGrams(DecimalEpsilon); + + Assert.Equal(-1, firstMass.CompareTo(secondMass)); + Assert.Equal(1, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DoubleQuantityWithVeryCloseDecimalQuantity_ReturnsNonZero() + { + var firstMass = Mass.FromGrams(-double.Epsilon); + var secondMass = Mass.FromGrams(0m); + + Assert.Equal(-1, firstMass.CompareTo(secondMass)); + Assert.Equal(1, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DecimalQuantityWithVeryCloseDoubleQuantity_ReturnsNonZero() + { + var firstMass = Mass.FromGrams(0m); + var secondMass = Mass.FromGrams(double.Epsilon); + + Assert.Equal(-1, firstMass.CompareTo(secondMass)); + Assert.Equal(1, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DecimalQuantityWithVeryLargeDoubleQuantity_ReturnsNonZero() + { + var firstMass = Mass.FromGrams(0m); + var secondMass = Mass.FromGrams(double.MaxValue); + + Assert.Equal(-1, firstMass.CompareTo(secondMass)); + Assert.Equal(1, secondMass.CompareTo(firstMass)); + } + + [Fact] + public void CompareTo_DecimalQuantityWithVerySmallDoubleQuantity_ReturnsNonZero() + { + var firstMass = Mass.FromGrams(0m); + var secondMass = Mass.FromGrams(double.MinValue); + + Assert.Equal(1, firstMass.CompareTo(secondMass)); + Assert.Equal(-1, secondMass.CompareTo(firstMass)); + } + + #endregion + + [Fact] + public void Equals_DoubleQuantityWithSameQuantityInAnotherUnit_ReturnsFalse() + { + var firstMass = Mass.FromGrams(0.001); + var secondMass = firstMass.ToUnit(MassUnit.Microgram); + + Assert.NotEqual(firstMass, secondMass); + Assert.NotEqual(secondMass, firstMass); + } + + [Fact] + public void Equals_DecimalQuantityWithSameQuantityInAnotherUnit_ReturnsTrue() + { + var firstMass = Mass.FromGrams(0.001m); + var secondMass = firstMass.ToUnit(MassUnit.Microgram); + + Assert.Equal(firstMass, secondMass); + Assert.Equal(secondMass, firstMass); + } + + [Fact] + public void Equals_DecimalQuantityWithVeryCloseDoubleQuantityInSameUnit_ReturnsFalse() + { + var firstMass = Mass.FromGrams(0m); + var secondMass = Mass.FromGrams(double.Epsilon); + + Assert.NotEqual(firstMass, secondMass); + Assert.NotEqual(secondMass, firstMass); + } + + [Fact] + public void GetHashCode_WithSameQuantityInAnotherUnit_ReturnsSameValue() + { + var firstMass = Mass.FromGrams(0.001); + var secondMass = firstMass.ToUnit(MassUnit.Microgram); + + Assert.Equal(firstMass.GetHashCode(), secondMass.GetHashCode()); + } + + [Fact] + public void GetHashCode_WithVeryCloseQuantities_ReturnsSameValue() + { + var firstMass = Mass.FromGrams(0); + var secondMass = Mass.FromGrams(double.Epsilon); + + Assert.Equal(firstMass.GetHashCode(), secondMass.GetHashCode()); + } + + [Fact] + public void Contains_CollectionWithMixedUnits_DependsOnTheOrderOfInsertion() + { + var firstMass = Mass.FromGrams(0.001); + var secondMass = firstMass.ToUnit(MassUnit.Microgram); + + var collectionWithFirst = new HashSet {firstMass}; + var collectionWithSecond = new HashSet {secondMass}; + + Assert.Contains(firstMass, collectionWithFirst); + Assert.DoesNotContain(secondMass, collectionWithFirst); + + Assert.DoesNotContain(firstMass, collectionWithSecond); + Assert.Contains(secondMass, collectionWithSecond); + } + + [Fact] + public void Contains_CollectionWithVeryCloseQuantities_ReturnsTrueIfValuesAreStrictlyEqual() + { + var firstMass = Mass.FromGrams(0); + var secondMass = Mass.FromGrams(double.Epsilon); + + var collection = new HashSet {firstMass}; + + // equal hash codes do not imply object equality + Assert.Equal(firstMass.GetHashCode(), secondMass.GetHashCode()); + Assert.NotEqual(firstMass, secondMass); + + // Contains first checks HashCode, followed by Equals check + Assert.Contains(firstMass, collection); + Assert.DoesNotContain(secondMass, collection); + } + + [Fact] + public void Sort_CollectionWithMixedUnits_SortedByNaturalOrder() + { + var firstMass = Mass.FromGrams(0); + var secondMass = Mass.FromGrams(double.Epsilon); + var thirdMass = Mass.FromGrams(0.001); + var fourthMass = thirdMass.ToUnit(MassUnit.Microgram); + + var collection = new[] {thirdMass, firstMass, fourthMass, secondMass}; + Array.Sort(collection); + + Assert.Equal(firstMass, collection[0]); + Assert.Equal(secondMass, collection[1]); + Assert.Equal(thirdMass, collection[2]); + Assert.Equal(fourthMass, collection[3]); + } + } +} diff --git a/UnitsNet.Tests/QuantityValueTests.cs b/UnitsNet.Tests/QuantityValueTests.cs new file mode 100644 index 0000000000..8df8cfb717 --- /dev/null +++ b/UnitsNet.Tests/QuantityValueTests.cs @@ -0,0 +1,150 @@ +using System; +using Xunit; + +namespace UnitsNet.Tests; + +public class QuantityValueTests +{ + [Fact] + public void QuantityValue_FromDouble_ContainsDouble() + { + QuantityValue value = 1.0; + + Assert.False(value.IsDecimal); + Assert.Equal(1.0, (double)value); + } + + [Fact] + public void QuantityValue_FromDecimal_ContainsDecimal() + { + QuantityValue value = 1.0m; + + Assert.True(value.IsDecimal); + Assert.Equal(1.0m, (decimal)value); + } + + [Fact] + public void QuantityValue_FromInteger_ContainsDecimal() + { + QuantityValue value = 1; + + Assert.True(value.IsDecimal); + Assert.Equal(1m, (decimal)value); + } + + [Fact] + public void QuantityValue_FromNaN_ThrowsException() + { + Assert.Throws(() => (QuantityValue)double.NaN); + } + + [Fact] + public void QuantityValue_FromInfinity_ThrowsException() + { + Assert.Throws(() => (QuantityValue)double.PositiveInfinity); + Assert.Throws(() => (QuantityValue)double.NegativeInfinity); + } + + [Fact] + public void Operations_WithDoubles_ReturnDoubles() + { + QuantityValue two = 2.0; + + QuantityValue twoPlusTwo = two + two; + QuantityValue twoMinusTwo = two - two; + QuantityValue twoTimesTwo = two * two; + QuantityValue twoDividedByTwo = two / two; + + Assert.False(twoPlusTwo.IsDecimal); + Assert.False(twoMinusTwo.IsDecimal); + Assert.False(twoTimesTwo.IsDecimal); + Assert.False(twoDividedByTwo.IsDecimal); + + Assert.Equal(4.0, (double)twoPlusTwo); + Assert.Equal(0.0, (double)twoMinusTwo); + Assert.Equal(4.0, (double)twoTimesTwo); + Assert.Equal(1.0, (double)twoDividedByTwo); + } + + [Fact] + public void Operations_WithDecimal_ReturnDecimals() + { + QuantityValue two = 2.0m; + + QuantityValue twoPlusTwo = two + two; + QuantityValue twoMinusTwo = two - two; + QuantityValue twoTimesTwo = two * two; + QuantityValue twoDividedByTwo = two / two; + + Assert.True(twoPlusTwo.IsDecimal); + Assert.True(twoMinusTwo.IsDecimal); + Assert.True(twoTimesTwo.IsDecimal); + Assert.True(twoDividedByTwo.IsDecimal); + + Assert.Equal(4.0m, (decimal)twoPlusTwo); + Assert.Equal(0.0m, (decimal)twoMinusTwo); + Assert.Equal(4.0m, (decimal)twoTimesTwo); + Assert.Equal(1.0m, (decimal)twoDividedByTwo); + } + + [Fact] + public void Operations_WithDoubleAndDecimal_ReturnDecimals() + { + QuantityValue twoFromDouble = 2.0; + QuantityValue twoFromDecimal = 2.0m; + + QuantityValue twoPlusTwo = twoFromDouble + twoFromDecimal; + QuantityValue twoMinusTwo = twoFromDouble - twoFromDecimal; + QuantityValue twoTimesTwo = twoFromDouble * twoFromDecimal; + QuantityValue twoDividedByTwo = twoFromDouble / twoFromDecimal; + + Assert.True(twoPlusTwo.IsDecimal); + Assert.True(twoMinusTwo.IsDecimal); + Assert.True(twoTimesTwo.IsDecimal); + Assert.True(twoDividedByTwo.IsDecimal); + + Assert.Equal(4.0m, (decimal)twoPlusTwo); + Assert.Equal(0.0m, (decimal)twoMinusTwo); + Assert.Equal(4.0m, (decimal)twoTimesTwo); + Assert.Equal(1.0m, (decimal)twoDividedByTwo); + } + + [Fact] + public void OverflowingOperations_WithDecimal_ReturnDoubles() + { + // TODO see about exposing a QuantityValue.MaxDecimal constant + const decimal maxDecimalValue = decimal.MaxValue * 1E-6m; // the clamping value is actual smaller than the decimal.MaxValue (ensuring the minimal conversion precision) + QuantityValue maxDecimal = maxDecimalValue; + + QuantityValue twoTimesMax = maxDecimal + maxDecimal; + QuantityValue twoTimesMin = -maxDecimal - maxDecimal; + QuantityValue maxSquared = maxDecimal * maxDecimal; + QuantityValue oneOverMax = 0.1 / maxDecimal; + + Assert.True(maxDecimal.IsDecimal); + Assert.False(twoTimesMax.IsDecimal); + Assert.False(twoTimesMin.IsDecimal); + Assert.False(maxSquared.IsDecimal); + Assert.False(oneOverMax.IsDecimal); + + const double max = (double)maxDecimalValue; + Assert.Equal(max + max, (double)twoTimesMax); + Assert.Equal(-max - max, (double)twoTimesMin); + Assert.Equal(max * max, (double)maxSquared); + Assert.Equal(0.1 / max, (double)oneOverMax); + } + + [Fact] + public void OverflowingOperations_WithDouble_ThrowArgumentException() + { + // TODO see about supporting Positive/Negative infinity + QuantityValue maxDouble = double.MaxValue; + + Assert.Throws(() => maxDouble + maxDouble); + Assert.Throws(() => -maxDouble - maxDouble); + Assert.Throws(() => maxDouble * maxDouble); + Assert.Throws(() => maxDouble / 0); + } + + // TODO add tests for IEquatable / IComparable (decimal comparison when both values are in the decimal range) +} diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index d556757893..ea9fdf9429 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -1,4 +1,5 @@ -using System.Globalization; +using System; +using System.Globalization; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; @@ -41,12 +42,13 @@ protected override T DeserializeObject(string xml) #region Serialization tests + [Fact] - public void DoubleQuantity_SerializedWithDoubleValueAndunitInt() + public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit() { var quantity = new Mass(1.20, MassUnit.Milligram); var unitInt = (int)quantity.Unit; - var expectedJson = $"{{\"Value\":1.2,\"Unit\":{unitInt}}}"; + var expectedJson = $"{{\"Value\":{{\"Double\":1.2}},\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); @@ -54,14 +56,14 @@ public void DoubleQuantity_SerializedWithDoubleValueAndunitInt() } [Fact] - public void DecimalQuantity_SerializedWithDecimalValueValueAndunitInt() + public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit() { var quantity = new Information(1.20m, InformationUnit.Exabyte); var unitInt = (int)InformationUnit.Exabyte; - var expectedJson = $"{{\"Value\":1.20,\"Unit\":{unitInt}}}"; + var expectedJson = $"{{\"Value\":{{\"Decimal\":1.20}},\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); - + Assert.Equal(expectedJson, json); } @@ -70,11 +72,11 @@ public void DecimalQuantity_SerializedWithDecimalValueValueAndunitInt() #region Deserialization tests [Fact] - public void DoubleQuantity_DeserializedFromDoubleValueAndunitInt() + public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit() { var expectedUnit = MassUnit.Milligram; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":1.2,\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":{{\"Double\":1.2}},\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -83,11 +85,11 @@ public void DoubleQuantity_DeserializedFromDoubleValueAndunitInt() } [Fact] - public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndunitInt() + public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() { var expectedUnit = MassUnit.Milligram; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":\"1.2\",\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":{{\"Double\":\"1.2\"}},\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -96,7 +98,7 @@ public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndunitInt() } [Fact] - public void DoubleZeroQuantity_DeserializedFromunitIntAndNoValue() + public void DoubleZeroQuantity_DeserializedFromIntegerUnitAndNoValue() { var expectedUnit = MassUnit.Milligram; var unitInt = (int)expectedUnit; @@ -114,7 +116,7 @@ public void InterfaceObject_IncludesTypeInformation() var unit = InformationUnit.Exabyte; var unitInt = (int)unit; var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, unit) }; - var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":{unitInt}}}}}"; + var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":{{\"Decimal\":1.20}},\"Unit\":{unitInt}}}}}"; var json = SerializeObject(testObject); @@ -124,7 +126,7 @@ public void InterfaceObject_IncludesTypeInformation() [Fact] public void DoubleBaseUnitQuantity_DeserializedFromValueAndNoUnit() { - var json = "{\"Value\":1.2}"; + var json = "{\"Value\":{\"Double\":1.2}}"; var quantity = DeserializeObject(json); @@ -144,11 +146,11 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() } [Fact] - public void DecimalQuantity_DeserializedFromDecimalValueAndunitInt() + public void DecimalQuantity_DeserializedFromDecimalValueAndIntegerUnit() { var expectedUnit = InformationUnit.Exabyte; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":1.200,\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":{{\"Decimal\":1.200}},\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -166,11 +168,11 @@ public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationE } [Fact] - public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndunitInt() + public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndDecimalUnit() { var expectedUnit = InformationUnit.Exabyte; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":\"1.200\",\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":{{\"Decimal\":\"1.200\"}},\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -180,7 +182,7 @@ public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndunitInt() } [Fact] - public void DecimalZeroQuantity_DeserializedFromunitIntAndNoValue() + public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue() { var expectedUnit = InformationUnit.Exabyte; var unitInt = (int)expectedUnit; @@ -195,7 +197,7 @@ public void DecimalZeroQuantity_DeserializedFromunitIntAndNoValue() [Fact] public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit() { - var json = "{\"Value\":1.200}"; + var json = "{\"Value\":{\"Decimal\":1.200}}"; var quantity = DeserializeObject(json); diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs index d2a4f6d6b8..83f468bd41 100644 --- a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs +++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs @@ -64,7 +64,7 @@ public void DecimalValueQuantity_SerializationRoundTrips() [Fact] public void LargeDecimalValueQuantity_SerializationRoundTrips() { - var quantity = Information.FromExabytes(1E+24); + var quantity = Information.FromExabytes(1E+24m); var payload = SerializeObject(quantity); var result = DeserializeObject(payload); diff --git a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs index ca45df9395..21d4c6d989 100644 --- a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs @@ -39,7 +39,7 @@ protected override T DeserializeObject(string xml) public void DoubleQuantity_SerializedWithValueAndMemberName() { var quantity = new Mass(1.20, MassUnit.Milligram); - var expectedXml = $"1.2Milligram"; + var expectedXml = $"1.2Milligram"; var xml = SerializeObject(quantity); @@ -50,7 +50,7 @@ public void DoubleQuantity_SerializedWithValueAndMemberName() public void DecimalQuantity_SerializedWithValueAndMemberName() { var quantity = new Information(1.20m, InformationUnit.Exabyte); - var expectedXml = $"1.20Exabyte"; + var expectedXml = $"1.20Exabyte"; var xml = SerializeObject(quantity); @@ -63,7 +63,7 @@ public void InterfaceObject_IncludesTypeInformation() var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) }; var quantityNamespace = "xmlns:a=\"http://schemas.datacontract.org/2004/07/UnitsNet\""; // there is an extra 'a' compared to Namespace - var expectedQuantityXml = $"1.20Exabyte"; + var expectedQuantityXml = $"1.20Exabyte"; var expectedXml = $"{expectedQuantityXml}"; var xml = SerializeObject(testObject); diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index 421d7fef23..b58f13a258 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -112,8 +112,8 @@ public void ConversionForUnitsOfCustomQuantity(double fromValue, HowMuchUnit fro { // Intentionally don't map conversion Some->Some, it is not necessary var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch(x.Value * 2, HowMuchUnit.ATon)); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch(x.Value * 10, HowMuchUnit.AShitTon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch((double)x.Value * 2, HowMuchUnit.ATon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch((double)x.Value * 10, HowMuchUnit.AShitTon)); var foundConversionFunction = unitConverter.GetConversionFunction(fromUnit, toUnit); var converted = foundConversionFunction(new HowMuch(fromValue, fromUnit)); @@ -164,9 +164,9 @@ public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUnit(doubl [InlineData(1, "UnknownQuantity", "Meter", "Centimeter")] [InlineData(1, "Length", "UnknownFromUnit", "Centimeter")] [InlineData(1, "Length", "Meter", "UnknownToUnit")] - public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) + public void TryConvertByName_ReturnsFalseForInvalidInput(QuantityValue inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); + Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out var result)); Assert.Equal(0, result); } @@ -175,10 +175,10 @@ public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, stri [InlineData(100, 1, "Length", "Meter", "Centimeter")] [InlineData(1, 1000, "Mass", "Gram", "Kilogram")] [InlineData(1000, 1, "ElectricCurrent", "Kiloampere", "Ampere")] - public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, + public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(QuantityValue expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByName() return value."); + Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out var result), "TryConvertByName() return value."); Assert.Equal(expectedValue, result); } @@ -211,9 +211,9 @@ public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUn [InlineData(1, "UnknownQuantity", "m", "cm")] [InlineData(1, "Length", "UnknownFromUnit", "cm")] [InlineData(1, "Length", "m", "UnknownToUnit")] - public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) + public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(QuantityValue inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); + Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out var result)); Assert.Equal(0, result); } @@ -222,10 +222,10 @@ public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputVal [InlineData(100, 1, "Length", "m", "cm")] [InlineData(1, 1000, "Mass", "g", "kg")] [InlineData(1000, 1, "ElectricCurrent", "kA", "A")] - public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, + public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(QuantityValue expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByAbbreviation() return value."); + Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out var result), "TryConvertByAbbreviation() return value."); Assert.Equal(expectedValue, result); } } diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index 1d79559af7..5bc5c3cf63 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -24,8 +24,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.sln b/UnitsNet.sln index 6ae0d3d8b3..4b402d54ec 100644 --- a/UnitsNet.sln +++ b/UnitsNet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29609.76 +# Visual Studio Version 17 +VisualStudioVersion = 17.3.32811.315 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet", "UnitsNet\UnitsNet.csproj", "{CBEAD842-07BC-4B08-9D9D-D6659813776F}" EndProject @@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.Json EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Tests", "UnitsNet.Tests\UnitsNet.Tests.csproj", "{0E3B7567-5DF2-44BD-88DB-CCF050D3F943}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.JsonNet.CompatibilityTests", "UnitsNet.Serialization.JsonNet.CompatibilityTests\UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj", "{21F2FFAC-BF39-487F-9ADE-37100162F955}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Benchmark", "UnitsNet.Benchmark\UnitsNet.Benchmark.csproj", "{76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeGen", "CodeGen\CodeGen.csproj", "{078E3D44-4F60-46B3-9099-91A7CBF0B213}" @@ -22,27 +20,27 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.NumberExtensions.Tests", "UnitsNet.NumberExtensions.Tests\UnitsNet.NumberExtensions.Tests.csproj", "{B4996AF5-9A8B-481A-9018-EC7F5B1605FF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Files", "_Files", "{B92B01BE-243E-4CCB-B5E5-AF469ADB1F54}" -ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - .gitattributes = .gitattributes - .gitignore = .gitignore - appveyor.yml = appveyor.yml - build.bat = build.bat - build-all-targets.bat = build-all-targets.bat - clean.bat = clean.bat - CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md - CONTRIBUTING.md = CONTRIBUTING.md - Directory.Build.props = Directory.Build.props - generate-code.bat = generate-code.bat - init.bat = init.bat - LICENSE = LICENSE - nuget.config = nuget.config - publish-unitsnet.bat = publish-unitsnet.bat - README.md = README.md - test.bat = test.bat - UnitsNet.sln.DotSettings = UnitsNet.sln.DotSettings - UnitsNet.snk = UnitsNet.snk -EndProjectSection + ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .gitattributes = .gitattributes + .gitignore = .gitignore + appveyor.yml = appveyor.yml + build-all-targets.bat = build-all-targets.bat + build.bat = build.bat + clean.bat = clean.bat + CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md + CONTRIBUTING.md = CONTRIBUTING.md + Directory.Build.props = Directory.Build.props + generate-code.bat = generate-code.bat + init.bat = init.bat + LICENSE = LICENSE + nuget.config = nuget.config + publish-unitsnet.bat = publish-unitsnet.bat + README.md = README.md + test.bat = test.bat + UnitsNet.sln.DotSettings = UnitsNet.sln.DotSettings + UnitsNet.snk = UnitsNet.snk + EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -66,10 +64,6 @@ Global {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.Build.0 = Release|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Release|Any CPU.Build.0 = Release|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index 575707e6b5..7a448f9b89 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -49,7 +49,66 @@ public static class Comparison /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// Whether the tolerance is absolute or relative. /// - public static bool Equals(double referenceValue, double otherValue, double tolerance, ComparisonType comparisonType) + public static bool Equals(QuantityValue referenceValue, QuantityValue otherValue, QuantityValue tolerance, ComparisonType comparisonType) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + switch (comparisonType) + { + case ComparisonType.Relative: + return referenceValue.IsDecimal || otherValue.IsDecimal || tolerance.IsDecimal + ? EqualsRelative((decimal)referenceValue, (decimal)otherValue, (decimal)tolerance) + : EqualsRelative((double)referenceValue, (double)otherValue, (double)tolerance); + case ComparisonType.Absolute: + return referenceValue.IsDecimal || otherValue.IsDecimal || tolerance.IsDecimal + ? EqualsAbsolute((decimal)referenceValue, (decimal)otherValue, (decimal)tolerance) + : EqualsAbsolute((double)referenceValue, (double)otherValue, (double)tolerance); + default: + throw new InvalidOperationException("The given ComparisonType is not supported."); + } + } + + /// + /// + /// Checks if two values are equal with a given relative or absolute tolerance. + /// + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// Equals(a, b, 0.01, ComparisonType.Relative); + /// + /// + /// + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// + /// The reference value. If using relative tolerance, it is the value which the relative + /// tolerance will be calculated against. + /// + /// The value to compare to. + /// The absolute or relative tolerance value. Must be greater than or equal to 0. + /// Whether the tolerance is absolute or relative. + /// + public static bool Equals(decimal referenceValue, decimal otherValue, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); @@ -95,6 +154,36 @@ public static bool EqualsRelative(double referenceValue, double otherValue, doub return Math.Abs(referenceValue - otherValue) <= maxVariation; } + /// + /// Checks if two values are equal with a given relative tolerance. + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// EqualsRelative(a, b, 0.01); + /// + /// + /// + /// + /// The reference value which the tolerance will be calculated against. + /// The value to compare to. + /// The relative tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given relative tolerance, otherwise false. + public static bool EqualsRelative(decimal referenceValue, decimal otherValue, decimal tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + var maxVariation = Math.Abs(referenceValue * tolerance); + return Math.Abs(referenceValue - otherValue) <= maxVariation; + } + /// /// Checks if two values are equal with a given absolute tolerance. /// @@ -121,5 +210,32 @@ public static bool EqualsAbsolute(double value1, double value2, double tolerance return Math.Abs(value1 - value2) <= tolerance; } + + /// + /// Checks if two values are equal with a given absolute tolerance. + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// The first value. + /// The second value. + /// The absolute tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given absolute tolerance, otherwise false. + public static bool EqualsAbsolute(decimal value1, decimal value2, decimal tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + return Math.Abs(value1 - value2) <= tolerance; + } } } diff --git a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs index 5d486417ec..8b88ed6197 100644 --- a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs @@ -31,7 +31,7 @@ public partial struct AmountOfSubstance public double NumberOfParticles() { var moles = GetValueAs(AmountOfSubstanceUnit.Mole); - return AvogadroConstant * moles; + return AvogadroConstant * (double) moles; } /// Get from and a given . diff --git a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs index cc0a3cfcdf..b67402cd73 100644 --- a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs @@ -24,7 +24,7 @@ public AmplitudeRatio(ElectricPotential voltage) "The base-10 logarithm of a number ≤ 0 is undefined. Voltage must be greater than 0 V."); // E(dBV) = 20*log10(value(V)/reference(V)) - _value = 20 * Math.Log10(voltage.Volts / 1); + _value = 20 * Math.Log10((double)(voltage.Volts / 1)); _unit = AmplitudeRatioUnit.DecibelVolt; } @@ -40,7 +40,7 @@ public AmplitudeRatio(ElectricPotential voltage) public ElectricPotential ToElectricPotential() { // E(V) = 1V * 10^(E(dBV)/20) - return ElectricPotential.FromVolts( Math.Pow( 10, DecibelVolts / 20 ) ); + return ElectricPotential.FromVolts( Math.Pow( 10, (double)(DecibelVolts / 20) ) ); } /// @@ -51,7 +51,7 @@ public ElectricPotential ToElectricPotential() public PowerRatio ToPowerRatio( ElectricResistance impedance ) { // P(dBW) = E(dBV) - 10*log10(Z(Ω)/1) - return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( impedance.Ohms / 1 ) ); + return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( (double)(impedance.Ohms / 1) ) ); } #region Static Methods diff --git a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs index 5bd29a877a..46785cd29a 100644 --- a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs +++ b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs @@ -1,6 +1,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using UnitsNet.Units; + namespace UnitsNet { public partial struct BrakeSpecificFuelConsumption @@ -8,7 +10,7 @@ public partial struct BrakeSpecificFuelConsumption /// Get from times . public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule*power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * power.Watts); } /// Get from divided by . @@ -18,9 +20,9 @@ public partial struct BrakeSpecificFuelConsumption } /// Get constant from times . - public static double operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy) + public static QuantityValue operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy) { - return specificEnergy.JoulesPerKilogram*bsfc.KilogramsPerJoule; + return specificEnergy.JoulesPerKilogram * bsfc.KilogramsPerJoule; } } } diff --git a/UnitsNet/CustomCode/Quantities/Duration.extra.cs b/UnitsNet/CustomCode/Quantities/Duration.extra.cs index e1e898c62d..537a5d619d 100644 --- a/UnitsNet/CustomCode/Quantities/Duration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Duration.extra.cs @@ -18,19 +18,19 @@ public TimeSpan ToTimeSpan() if ( Seconds > TimeSpan.MaxValue.TotalSeconds || Seconds < TimeSpan.MinValue.TotalSeconds ) throw new ArgumentOutOfRangeException( nameof( Duration ), "The duration is too large or small to fit in a TimeSpan" ); - return TimeSpan.FromTicks((long)(Seconds * TimeSpan.TicksPerSecond)); + return TimeSpan.FromTicks((long)((double)Seconds * TimeSpan.TicksPerSecond)); } /// Get from plus . public static DateTime operator +(DateTime time, Duration duration) { - return time.AddSeconds(duration.Seconds); + return time.AddSeconds((double)duration.Seconds); } /// Get from minus . public static DateTime operator -(DateTime time, Duration duration) { - return time.AddSeconds(-duration.Seconds); + return time.AddSeconds(-(double)duration.Seconds); } /// Explicitly cast to . diff --git a/UnitsNet/CustomCode/Quantities/Force.extra.cs b/UnitsNet/CustomCode/Quantities/Force.extra.cs index 7972c0f412..38f3742e71 100644 --- a/UnitsNet/CustomCode/Quantities/Force.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Force.extra.cs @@ -10,7 +10,7 @@ public partial struct Force /// Get from divided by . public static Force FromPressureByArea(Pressure p, Area area) { - double newtons = p.Pascals * area.SquareMeters; + var newtons = p.Pascals * area.SquareMeters; return new Force(newtons, ForceUnit.Newton); } diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index 5bb37e2562..ae8e78eb01 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -32,7 +32,7 @@ public FeetInches FeetInches { get { - var inInches = Inches; + var inInches = (double)Inches; var feet = Math.Truncate(inInches / InchesInOneFoot); var inches = inInches % InchesInOneFoot; diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index 3b8f101e7e..f87d867b48 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -29,7 +29,7 @@ public StonePounds StonePounds { get { - var inPounds = Pounds; + var inPounds = (double)Pounds; var stones = Math.Truncate(inPounds / StonesInOnePound); var pounds = inPounds % StonesInOnePound; diff --git a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs index e60c5c75d8..dd552aa937 100644 --- a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { diff --git a/UnitsNet/CustomCode/Quantities/Power.extra.cs b/UnitsNet/CustomCode/Quantities/Power.extra.cs index 187c2740fc..024c4f44e9 100644 --- a/UnitsNet/CustomCode/Quantities/Power.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Power.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { @@ -90,7 +91,7 @@ public PowerRatio ToPowerRatio() /// Get from divided by . public static Area operator /(Power power, HeatFlux heatFlux) { - return Area.FromSquareMeters( power.Watts / heatFlux.WattsPerSquareMeter ); + return Area.FromSquareMeters(power.Watts / heatFlux.WattsPerSquareMeter ); } /// Calculate from divided by . diff --git a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs index f563f720ae..3cbc0d9e10 100644 --- a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs @@ -21,7 +21,7 @@ public PowerRatio(Power power) nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10(power.Watts / 1); + _value = 10 * Math.Log10((double)power.Watts); _unit = PowerRatioUnit.DecibelWatt; } @@ -37,7 +37,7 @@ public PowerRatio(Power power) public Power ToPower() { // P(W) = 1W * 10^(P(dBW)/10) - return Power.FromWatts(Math.Pow(10, DecibelWatts / 10)); + return Power.FromWatts(Math.Pow(10, (double)(DecibelWatts / 10))); } /// @@ -47,7 +47,7 @@ public Power ToPower() public AmplitudeRatio ToAmplitudeRatio(ElectricResistance impedance) { // E(dBV) = 10*log10(Z(Ω)/1) + P(dBW) - return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10(impedance.Ohms / 1) + DecibelWatts); + return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10((double)(impedance.Ohms / 1)) + DecibelWatts); } #region Static Methods diff --git a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs index 45f4473f80..c6d0c172ad 100644 --- a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs +++ b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs @@ -24,7 +24,7 @@ public partial struct SpecificEnergy } /// Get from times . - public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc) + public static QuantityValue operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc) { return specificEnergy.JoulesPerKilogram * bsfc.KilogramsPerJoule; } diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index 4556009fc6..60b411f358 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -60,7 +60,7 @@ public partial struct Temperature /// The resulting . public Temperature Multiply(double factor, TemperatureUnit unit) { - double resultInUnit = As(unit) * factor; + var resultInUnit = As(unit) * factor; return From(resultInUnit, unit); } @@ -77,7 +77,7 @@ public Temperature Multiply(double factor, TemperatureUnit unit) /// The resulting . public Temperature Divide(double divisor, TemperatureUnit unit) { - double resultInUnit = As(unit) / divisor; + var resultInUnit = As(unit) / divisor; return From(resultInUnit, unit); } } diff --git a/UnitsNet/CustomCode/Quantities/Volume.extra.cs b/UnitsNet/CustomCode/Quantities/Volume.extra.cs index aab43915a4..1debb193e1 100644 --- a/UnitsNet/CustomCode/Quantities/Volume.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Volume.extra.cs @@ -34,7 +34,7 @@ public partial struct Volume /// Get from divided by . public static TimeSpan operator /(Volume volume, VolumeFlow volumeFlow) { - return TimeSpan.FromSeconds(volume.CubicMeters / volumeFlow.CubicMetersPerSecond); + return TimeSpan.FromSeconds((double)(volume.CubicMeters / volumeFlow.CubicMetersPerSecond)); } } } diff --git a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs index 5291b7d77b..dea64fb637 100644 --- a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs +++ b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs @@ -130,7 +130,7 @@ private Pressure As(PressureReference reference) /// /// The to convert to. /// The value of pressure at - private double AsBaseNumericType(PressureReference reference) + private QuantityValue AsBaseNumericType(PressureReference reference) { var baseReferenceValue = AsBaseReference(); @@ -156,7 +156,7 @@ private double AsBaseNumericType(PressureReference reference) /// /// /// The value of pressure at the - private double AsBaseReference() + private QuantityValue AsBaseReference() { switch (Reference) { diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 820cb3a395..082b101238 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. /// [DataContract] - public partial struct Acceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static Acceleration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Acceleration(double value, AccelerationUnit unit) + public Acceleration(QuantityValue value, AccelerationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -99,14 +99,14 @@ public Acceleration(double value, AccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Acceleration(double value, UnitSystem unitSystem) + public Acceleration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,7 +147,10 @@ public Acceleration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -170,74 +173,74 @@ public Acceleration(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); + public QuantityValue CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); + public QuantityValue DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); + public QuantityValue FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); + public QuantityValue InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); + public QuantityValue KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KnotsPerHour => As(AccelerationUnit.KnotPerHour); + public QuantityValue KnotsPerHour => As(AccelerationUnit.KnotPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); + public QuantityValue KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); + public QuantityValue KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); + public QuantityValue MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); + public QuantityValue MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); + public QuantityValue MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillistandardGravity => As(AccelerationUnit.MillistandardGravity); + public QuantityValue MillistandardGravity => As(AccelerationUnit.MillistandardGravity); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); + public QuantityValue NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardGravity => As(AccelerationUnit.StandardGravity); + public QuantityValue StandardGravity => As(AccelerationUnit.StandardGravity); #endregion @@ -346,7 +349,7 @@ public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static Acceleration FromCentimetersPerSecondSquared(QuantityValue centimeterspersecondsquared) { - double value = (double) centimeterspersecondsquared; + QuantityValue value = (QuantityValue) centimeterspersecondsquared; return new Acceleration(value, AccelerationUnit.CentimeterPerSecondSquared); } @@ -356,7 +359,7 @@ public static Acceleration FromCentimetersPerSecondSquared(QuantityValue centime /// If value is NaN or Infinity. public static Acceleration FromDecimetersPerSecondSquared(QuantityValue decimeterspersecondsquared) { - double value = (double) decimeterspersecondsquared; + QuantityValue value = (QuantityValue) decimeterspersecondsquared; return new Acceleration(value, AccelerationUnit.DecimeterPerSecondSquared); } @@ -366,7 +369,7 @@ public static Acceleration FromDecimetersPerSecondSquared(QuantityValue decimete /// If value is NaN or Infinity. public static Acceleration FromFeetPerSecondSquared(QuantityValue feetpersecondsquared) { - double value = (double) feetpersecondsquared; + QuantityValue value = (QuantityValue) feetpersecondsquared; return new Acceleration(value, AccelerationUnit.FootPerSecondSquared); } @@ -376,7 +379,7 @@ public static Acceleration FromFeetPerSecondSquared(QuantityValue feetperseconds /// If value is NaN or Infinity. public static Acceleration FromInchesPerSecondSquared(QuantityValue inchespersecondsquared) { - double value = (double) inchespersecondsquared; + QuantityValue value = (QuantityValue) inchespersecondsquared; return new Acceleration(value, AccelerationUnit.InchPerSecondSquared); } @@ -386,7 +389,7 @@ public static Acceleration FromInchesPerSecondSquared(QuantityValue inchespersec /// If value is NaN or Infinity. public static Acceleration FromKilometersPerSecondSquared(QuantityValue kilometerspersecondsquared) { - double value = (double) kilometerspersecondsquared; + QuantityValue value = (QuantityValue) kilometerspersecondsquared; return new Acceleration(value, AccelerationUnit.KilometerPerSecondSquared); } @@ -396,7 +399,7 @@ public static Acceleration FromKilometersPerSecondSquared(QuantityValue kilomete /// If value is NaN or Infinity. public static Acceleration FromKnotsPerHour(QuantityValue knotsperhour) { - double value = (double) knotsperhour; + QuantityValue value = (QuantityValue) knotsperhour; return new Acceleration(value, AccelerationUnit.KnotPerHour); } @@ -406,7 +409,7 @@ public static Acceleration FromKnotsPerHour(QuantityValue knotsperhour) /// If value is NaN or Infinity. public static Acceleration FromKnotsPerMinute(QuantityValue knotsperminute) { - double value = (double) knotsperminute; + QuantityValue value = (QuantityValue) knotsperminute; return new Acceleration(value, AccelerationUnit.KnotPerMinute); } @@ -416,7 +419,7 @@ public static Acceleration FromKnotsPerMinute(QuantityValue knotsperminute) /// If value is NaN or Infinity. public static Acceleration FromKnotsPerSecond(QuantityValue knotspersecond) { - double value = (double) knotspersecond; + QuantityValue value = (QuantityValue) knotspersecond; return new Acceleration(value, AccelerationUnit.KnotPerSecond); } @@ -426,7 +429,7 @@ public static Acceleration FromKnotsPerSecond(QuantityValue knotspersecond) /// If value is NaN or Infinity. public static Acceleration FromMetersPerSecondSquared(QuantityValue meterspersecondsquared) { - double value = (double) meterspersecondsquared; + QuantityValue value = (QuantityValue) meterspersecondsquared; return new Acceleration(value, AccelerationUnit.MeterPerSecondSquared); } @@ -436,7 +439,7 @@ public static Acceleration FromMetersPerSecondSquared(QuantityValue meterspersec /// If value is NaN or Infinity. public static Acceleration FromMicrometersPerSecondSquared(QuantityValue micrometerspersecondsquared) { - double value = (double) micrometerspersecondsquared; + QuantityValue value = (QuantityValue) micrometerspersecondsquared; return new Acceleration(value, AccelerationUnit.MicrometerPerSecondSquared); } @@ -446,7 +449,7 @@ public static Acceleration FromMicrometersPerSecondSquared(QuantityValue microme /// If value is NaN or Infinity. public static Acceleration FromMillimetersPerSecondSquared(QuantityValue millimeterspersecondsquared) { - double value = (double) millimeterspersecondsquared; + QuantityValue value = (QuantityValue) millimeterspersecondsquared; return new Acceleration(value, AccelerationUnit.MillimeterPerSecondSquared); } @@ -456,7 +459,7 @@ public static Acceleration FromMillimetersPerSecondSquared(QuantityValue millime /// If value is NaN or Infinity. public static Acceleration FromMillistandardGravity(QuantityValue millistandardgravity) { - double value = (double) millistandardgravity; + QuantityValue value = (QuantityValue) millistandardgravity; return new Acceleration(value, AccelerationUnit.MillistandardGravity); } @@ -466,7 +469,7 @@ public static Acceleration FromMillistandardGravity(QuantityValue millistandardg /// If value is NaN or Infinity. public static Acceleration FromNanometersPerSecondSquared(QuantityValue nanometerspersecondsquared) { - double value = (double) nanometerspersecondsquared; + QuantityValue value = (QuantityValue) nanometerspersecondsquared; return new Acceleration(value, AccelerationUnit.NanometerPerSecondSquared); } @@ -476,7 +479,7 @@ public static Acceleration FromNanometersPerSecondSquared(QuantityValue nanomete /// If value is NaN or Infinity. public static Acceleration FromStandardGravity(QuantityValue standardgravity) { - double value = (double) standardgravity; + QuantityValue value = (QuantityValue) standardgravity; return new Acceleration(value, AccelerationUnit.StandardGravity); } @@ -488,7 +491,7 @@ public static Acceleration FromStandardGravity(QuantityValue standardgravity) /// Acceleration unit value. public static Acceleration From(QuantityValue value, AccelerationUnit fromUnit) { - return new Acceleration((double)value, fromUnit); + return new Acceleration((QuantityValue)value, fromUnit); } #endregion @@ -658,25 +661,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel } /// Get from multiplying value and . - public static Acceleration operator *(double left, Acceleration right) + public static Acceleration operator *(QuantityValue left, Acceleration right) { return new Acceleration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Acceleration operator *(Acceleration left, double right) + public static Acceleration operator *(Acceleration left, QuantityValue right) { return new Acceleration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Acceleration operator /(Acceleration left, double right) + public static Acceleration operator /(Acceleration left, QuantityValue right) { return new Acceleration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Acceleration left, Acceleration right) + public static QuantityValue operator /(Acceleration left, Acceleration right) { return left.MetersPerSecondSquared / right.MetersPerSecondSquared; } @@ -709,6 +712,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Acceleration left, Acceleration right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Acceleration left, Acceleration right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -721,7 +737,29 @@ public int CompareTo(object obj) /// public int CompareTo(Acceleration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Acceleration objAcceleration)) + return false; + return Equals(objAcceleration); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Acceleration other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -764,13 +802,13 @@ public int CompareTo(Acceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType) + public bool Equals(Acceleration other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -781,7 +819,7 @@ public bool Equals(Acceleration other, double tolerance, ComparisonType comparis /// A hash code for the current Acceleration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -792,17 +830,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AccelerationUnit unit) + public QuantityValue As(AccelerationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -817,12 +854,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AccelerationUnit unitAsAccelerationUnit)) + if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsAccelerationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -854,7 +891,7 @@ public Acceleration ToUnit(AccelerationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Acceleration)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AccelerationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -862,17 +899,17 @@ public Acceleration ToUnit(AccelerationUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AccelerationUnit unitAsAccelerationUnit)) + if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAccelerationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -899,10 +936,10 @@ public Acceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AccelerationUnit unit) + private QuantityValue GetValueAs(AccelerationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 6b796bdd8a..31197dbed3 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. /// [DataContract] - public partial struct AmountOfSubstance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,9 +86,9 @@ static AmountOfSubstance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) + public AmountOfSubstance(QuantityValue value, AmountOfSubstanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -100,14 +100,14 @@ public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmountOfSubstance(double value, UnitSystem unitSystem) + public AmountOfSubstance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -148,7 +148,10 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -171,79 +174,79 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centimoles => As(AmountOfSubstanceUnit.Centimole); + public QuantityValue Centimoles => As(AmountOfSubstanceUnit.Centimole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); + public QuantityValue CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decimoles => As(AmountOfSubstanceUnit.Decimole); + public QuantityValue Decimoles => As(AmountOfSubstanceUnit.Decimole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); + public QuantityValue DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilomoles => As(AmountOfSubstanceUnit.Kilomole); + public QuantityValue Kilomoles => As(AmountOfSubstanceUnit.Kilomole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); + public QuantityValue KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megamoles => As(AmountOfSubstanceUnit.Megamole); + public QuantityValue Megamoles => As(AmountOfSubstanceUnit.Megamole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Micromoles => As(AmountOfSubstanceUnit.Micromole); + public QuantityValue Micromoles => As(AmountOfSubstanceUnit.Micromole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); + public QuantityValue MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millimoles => As(AmountOfSubstanceUnit.Millimole); + public QuantityValue Millimoles => As(AmountOfSubstanceUnit.Millimole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); + public QuantityValue MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Moles => As(AmountOfSubstanceUnit.Mole); + public QuantityValue Moles => As(AmountOfSubstanceUnit.Mole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanomoles => As(AmountOfSubstanceUnit.Nanomole); + public QuantityValue Nanomoles => As(AmountOfSubstanceUnit.Nanomole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); + public QuantityValue NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundMoles => As(AmountOfSubstanceUnit.PoundMole); + public QuantityValue PoundMoles => As(AmountOfSubstanceUnit.PoundMole); #endregion @@ -341,7 +344,7 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider /// If value is NaN or Infinity. public static AmountOfSubstance FromCentimoles(QuantityValue centimoles) { - double value = (double) centimoles; + QuantityValue value = (QuantityValue) centimoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Centimole); } @@ -351,7 +354,7 @@ public static AmountOfSubstance FromCentimoles(QuantityValue centimoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmoles) { - double value = (double) centipoundmoles; + QuantityValue value = (QuantityValue) centipoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.CentipoundMole); } @@ -361,7 +364,7 @@ public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmole /// If value is NaN or Infinity. public static AmountOfSubstance FromDecimoles(QuantityValue decimoles) { - double value = (double) decimoles; + QuantityValue value = (QuantityValue) decimoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Decimole); } @@ -371,7 +374,7 @@ public static AmountOfSubstance FromDecimoles(QuantityValue decimoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles) { - double value = (double) decipoundmoles; + QuantityValue value = (QuantityValue) decipoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.DecipoundMole); } @@ -381,7 +384,7 @@ public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles) { - double value = (double) kilomoles; + QuantityValue value = (QuantityValue) kilomoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Kilomole); } @@ -391,7 +394,7 @@ public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles) { - double value = (double) kilopoundmoles; + QuantityValue value = (QuantityValue) kilopoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.KilopoundMole); } @@ -401,7 +404,7 @@ public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMegamoles(QuantityValue megamoles) { - double value = (double) megamoles; + QuantityValue value = (QuantityValue) megamoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Megamole); } @@ -411,7 +414,7 @@ public static AmountOfSubstance FromMegamoles(QuantityValue megamoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMicromoles(QuantityValue micromoles) { - double value = (double) micromoles; + QuantityValue value = (QuantityValue) micromoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Micromole); } @@ -421,7 +424,7 @@ public static AmountOfSubstance FromMicromoles(QuantityValue micromoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmoles) { - double value = (double) micropoundmoles; + QuantityValue value = (QuantityValue) micropoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.MicropoundMole); } @@ -431,7 +434,7 @@ public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmole /// If value is NaN or Infinity. public static AmountOfSubstance FromMillimoles(QuantityValue millimoles) { - double value = (double) millimoles; + QuantityValue value = (QuantityValue) millimoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Millimole); } @@ -441,7 +444,7 @@ public static AmountOfSubstance FromMillimoles(QuantityValue millimoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmoles) { - double value = (double) millipoundmoles; + QuantityValue value = (QuantityValue) millipoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.MillipoundMole); } @@ -451,7 +454,7 @@ public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmole /// If value is NaN or Infinity. public static AmountOfSubstance FromMoles(QuantityValue moles) { - double value = (double) moles; + QuantityValue value = (QuantityValue) moles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Mole); } @@ -461,7 +464,7 @@ public static AmountOfSubstance FromMoles(QuantityValue moles) /// If value is NaN or Infinity. public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles) { - double value = (double) nanomoles; + QuantityValue value = (QuantityValue) nanomoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Nanomole); } @@ -471,7 +474,7 @@ public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles) { - double value = (double) nanopoundmoles; + QuantityValue value = (QuantityValue) nanopoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.NanopoundMole); } @@ -481,7 +484,7 @@ public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromPoundMoles(QuantityValue poundmoles) { - double value = (double) poundmoles; + QuantityValue value = (QuantityValue) poundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.PoundMole); } @@ -493,7 +496,7 @@ public static AmountOfSubstance FromPoundMoles(QuantityValue poundmoles) /// AmountOfSubstance unit value. public static AmountOfSubstance From(QuantityValue value, AmountOfSubstanceUnit fromUnit) { - return new AmountOfSubstance((double)value, fromUnit); + return new AmountOfSubstance((QuantityValue)value, fromUnit); } #endregion @@ -663,25 +666,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun } /// Get from multiplying value and . - public static AmountOfSubstance operator *(double left, AmountOfSubstance right) + public static AmountOfSubstance operator *(QuantityValue left, AmountOfSubstance right) { return new AmountOfSubstance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AmountOfSubstance operator *(AmountOfSubstance left, double right) + public static AmountOfSubstance operator *(AmountOfSubstance left, QuantityValue right) { return new AmountOfSubstance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AmountOfSubstance operator /(AmountOfSubstance left, double right) + public static AmountOfSubstance operator /(AmountOfSubstance left, QuantityValue right) { return new AmountOfSubstance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AmountOfSubstance left, AmountOfSubstance right) + public static QuantityValue operator /(AmountOfSubstance left, AmountOfSubstance right) { return left.Moles / right.Moles; } @@ -714,6 +717,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -726,7 +742,29 @@ public int CompareTo(object obj) /// public int CompareTo(AmountOfSubstance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) + return false; + return Equals(objAmountOfSubstance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(AmountOfSubstance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -769,13 +807,13 @@ public int CompareTo(AmountOfSubstance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType) + public bool Equals(AmountOfSubstance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -786,7 +824,7 @@ public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType com /// A hash code for the current AmountOfSubstance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -797,17 +835,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmountOfSubstanceUnit unit) + public QuantityValue As(AmountOfSubstanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -822,12 +859,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) + if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return As(unitAsAmountOfSubstanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -859,7 +896,7 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (AmountOfSubstance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AmountOfSubstanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -867,17 +904,17 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit, UnitConverter unitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) + if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAmountOfSubstanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -904,10 +941,10 @@ public AmountOfSubstance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AmountOfSubstanceUnit unit) + private QuantityValue GetValueAs(AmountOfSubstanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 05d7dfc95a..1a13590478 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. /// [DataContract] - public partial struct AmplitudeRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static AmplitudeRatio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AmplitudeRatio(double value, AmplitudeRatioUnit unit) + public AmplitudeRatio(QuantityValue value, AmplitudeRatioUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public AmplitudeRatio(double value, AmplitudeRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmplitudeRatio(double value, UnitSystem unitSystem) + public AmplitudeRatio(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); + public QuantityValue DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); + public QuantityValue DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); + public QuantityValue DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); + public QuantityValue DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue decibelmicrovolts) { - double value = (double) decibelmicrovolts; + QuantityValue value = (QuantityValue) decibelmicrovolts; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMicrovolt); } @@ -252,7 +255,7 @@ public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue decibelmicrovol /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelMillivolts(QuantityValue decibelmillivolts) { - double value = (double) decibelmillivolts; + QuantityValue value = (QuantityValue) decibelmillivolts; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMillivolt); } @@ -262,7 +265,7 @@ public static AmplitudeRatio FromDecibelMillivolts(QuantityValue decibelmillivol /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue decibelsunloaded) { - double value = (double) decibelsunloaded; + QuantityValue value = (QuantityValue) decibelsunloaded; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelUnloaded); } @@ -272,7 +275,7 @@ public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue decibelsunloaded /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelVolts(QuantityValue decibelvolts) { - double value = (double) decibelvolts; + QuantityValue value = (QuantityValue) decibelvolts; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelVolt); } @@ -284,7 +287,7 @@ public static AmplitudeRatio FromDecibelVolts(QuantityValue decibelvolts) /// AmplitudeRatio unit value. public static AmplitudeRatio From(QuantityValue value, AmplitudeRatioUnit fromUnit) { - return new AmplitudeRatio((double)value, fromUnit); + return new AmplitudeRatio((QuantityValue)value, fromUnit); } #endregion @@ -446,7 +449,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli { // Logarithmic addition // Formula: 20 * log10(10^(x/20) + 10^(y/20)) - return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, left.Value/20) + Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); + return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, (double)left.Value/20) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/20)), left.Unit); } /// Get from logarithmic subtraction of two . @@ -454,11 +457,11 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli { // Logarithmic subtraction // Formula: 20 * log10(10^(x/20) - 10^(y/20)) - return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, left.Value/20) - Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); + return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, (double)left.Value/20) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/20)), left.Unit); } /// Get from logarithmic multiplication of value and . - public static AmplitudeRatio operator *(double left, AmplitudeRatio right) + public static AmplitudeRatio operator *(QuantityValue left, AmplitudeRatio right) { // Logarithmic multiplication = addition return new AmplitudeRatio(left + right.Value, right.Unit); @@ -468,14 +471,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli public static AmplitudeRatio operator *(AmplitudeRatio left, double right) { // Logarithmic multiplication = addition - return new AmplitudeRatio(left.Value + (double)right, left.Unit); + return new AmplitudeRatio(left.Value + (QuantityValue)right, left.Unit); } /// Get from logarithmic division of by value. public static AmplitudeRatio operator /(AmplitudeRatio left, double right) { // Logarithmic division = subtraction - return new AmplitudeRatio(left.Value - (double)right, left.Unit); + return new AmplitudeRatio(left.Value - (QuantityValue)right, left.Unit); } /// Get ratio value from logarithmic division of by . @@ -513,6 +516,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -525,7 +541,29 @@ public int CompareTo(object obj) /// public int CompareTo(AmplitudeRatio other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) + return false; + return Equals(objAmplitudeRatio); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(AmplitudeRatio other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -568,13 +606,13 @@ public int CompareTo(AmplitudeRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType) + public bool Equals(AmplitudeRatio other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -585,7 +623,7 @@ public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType compar /// A hash code for the current AmplitudeRatio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -596,17 +634,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AmplitudeRatioUnit unit) + public QuantityValue As(AmplitudeRatioUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -621,12 +658,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) + if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return As(unitAsAmplitudeRatioUnit); + return (QuantityValue)As(typedUnit); } /// @@ -658,7 +695,7 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (AmplitudeRatio)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AmplitudeRatioUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -666,17 +703,17 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) + if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAmplitudeRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -703,10 +740,10 @@ public AmplitudeRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AmplitudeRatioUnit unit) + private QuantityValue GetValueAs(AmplitudeRatioUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 55d9a88517..210b47270f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. /// [DataContract] - public partial struct Angle : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -87,9 +87,9 @@ static Angle() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Angle(double value, AngleUnit unit) + public Angle(QuantityValue value, AngleUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -101,14 +101,14 @@ public Angle(double value, AngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Angle(double value, UnitSystem unitSystem) + public Angle(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -149,7 +149,10 @@ public Angle(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -172,84 +175,84 @@ public Angle(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Arcminutes => As(AngleUnit.Arcminute); + public QuantityValue Arcminutes => As(AngleUnit.Arcminute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Arcseconds => As(AngleUnit.Arcsecond); + public QuantityValue Arcseconds => As(AngleUnit.Arcsecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centiradians => As(AngleUnit.Centiradian); + public QuantityValue Centiradians => As(AngleUnit.Centiradian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Deciradians => As(AngleUnit.Deciradian); + public QuantityValue Deciradians => As(AngleUnit.Deciradian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Degrees => As(AngleUnit.Degree); + public QuantityValue Degrees => As(AngleUnit.Degree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gradians => As(AngleUnit.Gradian); + public QuantityValue Gradians => As(AngleUnit.Gradian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microdegrees => As(AngleUnit.Microdegree); + public QuantityValue Microdegrees => As(AngleUnit.Microdegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microradians => As(AngleUnit.Microradian); + public QuantityValue Microradians => As(AngleUnit.Microradian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millidegrees => As(AngleUnit.Millidegree); + public QuantityValue Millidegrees => As(AngleUnit.Millidegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliradians => As(AngleUnit.Milliradian); + public QuantityValue Milliradians => As(AngleUnit.Milliradian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanodegrees => As(AngleUnit.Nanodegree); + public QuantityValue Nanodegrees => As(AngleUnit.Nanodegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanoradians => As(AngleUnit.Nanoradian); + public QuantityValue Nanoradians => As(AngleUnit.Nanoradian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NatoMils => As(AngleUnit.NatoMil); + public QuantityValue NatoMils => As(AngleUnit.NatoMil); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Radians => As(AngleUnit.Radian); + public QuantityValue Radians => As(AngleUnit.Radian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Revolutions => As(AngleUnit.Revolution); + public QuantityValue Revolutions => As(AngleUnit.Revolution); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Tilt => As(AngleUnit.Tilt); + public QuantityValue Tilt => As(AngleUnit.Tilt); #endregion @@ -276,7 +279,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.NatoMil, quantity => new Angle(quantity.Value * 160 / 9, AngleUnit.NatoMil)); unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Radian, quantity => new Angle(quantity.Value / 180 * Math.PI, AngleUnit.Radian)); unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Revolution, quantity => new Angle(quantity.Value / 360, AngleUnit.Revolution)); - unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Tilt, quantity => new Angle(Math.Sin(quantity.Value / 180 * Math.PI), AngleUnit.Tilt)); + unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Tilt, quantity => new Angle(Math.Sin((double)quantity.Value / 180 * Math.PI), AngleUnit.Tilt)); // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Degree, quantity => quantity); @@ -296,7 +299,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AngleUnit.NatoMil, AngleUnit.Degree, quantity => new Angle(quantity.Value * 9 / 160, AngleUnit.Degree)); unitConverter.SetConversionFunction(AngleUnit.Radian, AngleUnit.Degree, quantity => new Angle(quantity.Value * 180 / Math.PI, AngleUnit.Degree)); unitConverter.SetConversionFunction(AngleUnit.Revolution, AngleUnit.Degree, quantity => new Angle(quantity.Value * 360, AngleUnit.Degree)); - unitConverter.SetConversionFunction(AngleUnit.Tilt, AngleUnit.Degree, quantity => new Angle(Math.Asin(quantity.Value) * 180 / Math.PI, AngleUnit.Degree)); + unitConverter.SetConversionFunction(AngleUnit.Tilt, AngleUnit.Degree, quantity => new Angle(Math.Asin((double)quantity.Value) * 180 / Math.PI, AngleUnit.Degree)); } internal static void MapGeneratedLocalizations(UnitAbbreviationsCache unitAbbreviationsCache) @@ -362,7 +365,7 @@ public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Angle FromArcminutes(QuantityValue arcminutes) { - double value = (double) arcminutes; + QuantityValue value = (QuantityValue) arcminutes; return new Angle(value, AngleUnit.Arcminute); } @@ -372,7 +375,7 @@ public static Angle FromArcminutes(QuantityValue arcminutes) /// If value is NaN or Infinity. public static Angle FromArcseconds(QuantityValue arcseconds) { - double value = (double) arcseconds; + QuantityValue value = (QuantityValue) arcseconds; return new Angle(value, AngleUnit.Arcsecond); } @@ -382,7 +385,7 @@ public static Angle FromArcseconds(QuantityValue arcseconds) /// If value is NaN or Infinity. public static Angle FromCentiradians(QuantityValue centiradians) { - double value = (double) centiradians; + QuantityValue value = (QuantityValue) centiradians; return new Angle(value, AngleUnit.Centiradian); } @@ -392,7 +395,7 @@ public static Angle FromCentiradians(QuantityValue centiradians) /// If value is NaN or Infinity. public static Angle FromDeciradians(QuantityValue deciradians) { - double value = (double) deciradians; + QuantityValue value = (QuantityValue) deciradians; return new Angle(value, AngleUnit.Deciradian); } @@ -402,7 +405,7 @@ public static Angle FromDeciradians(QuantityValue deciradians) /// If value is NaN or Infinity. public static Angle FromDegrees(QuantityValue degrees) { - double value = (double) degrees; + QuantityValue value = (QuantityValue) degrees; return new Angle(value, AngleUnit.Degree); } @@ -412,7 +415,7 @@ public static Angle FromDegrees(QuantityValue degrees) /// If value is NaN or Infinity. public static Angle FromGradians(QuantityValue gradians) { - double value = (double) gradians; + QuantityValue value = (QuantityValue) gradians; return new Angle(value, AngleUnit.Gradian); } @@ -422,7 +425,7 @@ public static Angle FromGradians(QuantityValue gradians) /// If value is NaN or Infinity. public static Angle FromMicrodegrees(QuantityValue microdegrees) { - double value = (double) microdegrees; + QuantityValue value = (QuantityValue) microdegrees; return new Angle(value, AngleUnit.Microdegree); } @@ -432,7 +435,7 @@ public static Angle FromMicrodegrees(QuantityValue microdegrees) /// If value is NaN or Infinity. public static Angle FromMicroradians(QuantityValue microradians) { - double value = (double) microradians; + QuantityValue value = (QuantityValue) microradians; return new Angle(value, AngleUnit.Microradian); } @@ -442,7 +445,7 @@ public static Angle FromMicroradians(QuantityValue microradians) /// If value is NaN or Infinity. public static Angle FromMillidegrees(QuantityValue millidegrees) { - double value = (double) millidegrees; + QuantityValue value = (QuantityValue) millidegrees; return new Angle(value, AngleUnit.Millidegree); } @@ -452,7 +455,7 @@ public static Angle FromMillidegrees(QuantityValue millidegrees) /// If value is NaN or Infinity. public static Angle FromMilliradians(QuantityValue milliradians) { - double value = (double) milliradians; + QuantityValue value = (QuantityValue) milliradians; return new Angle(value, AngleUnit.Milliradian); } @@ -462,7 +465,7 @@ public static Angle FromMilliradians(QuantityValue milliradians) /// If value is NaN or Infinity. public static Angle FromNanodegrees(QuantityValue nanodegrees) { - double value = (double) nanodegrees; + QuantityValue value = (QuantityValue) nanodegrees; return new Angle(value, AngleUnit.Nanodegree); } @@ -472,7 +475,7 @@ public static Angle FromNanodegrees(QuantityValue nanodegrees) /// If value is NaN or Infinity. public static Angle FromNanoradians(QuantityValue nanoradians) { - double value = (double) nanoradians; + QuantityValue value = (QuantityValue) nanoradians; return new Angle(value, AngleUnit.Nanoradian); } @@ -482,7 +485,7 @@ public static Angle FromNanoradians(QuantityValue nanoradians) /// If value is NaN or Infinity. public static Angle FromNatoMils(QuantityValue natomils) { - double value = (double) natomils; + QuantityValue value = (QuantityValue) natomils; return new Angle(value, AngleUnit.NatoMil); } @@ -492,7 +495,7 @@ public static Angle FromNatoMils(QuantityValue natomils) /// If value is NaN or Infinity. public static Angle FromRadians(QuantityValue radians) { - double value = (double) radians; + QuantityValue value = (QuantityValue) radians; return new Angle(value, AngleUnit.Radian); } @@ -502,7 +505,7 @@ public static Angle FromRadians(QuantityValue radians) /// If value is NaN or Infinity. public static Angle FromRevolutions(QuantityValue revolutions) { - double value = (double) revolutions; + QuantityValue value = (QuantityValue) revolutions; return new Angle(value, AngleUnit.Revolution); } @@ -512,7 +515,7 @@ public static Angle FromRevolutions(QuantityValue revolutions) /// If value is NaN or Infinity. public static Angle FromTilt(QuantityValue tilt) { - double value = (double) tilt; + QuantityValue value = (QuantityValue) tilt; return new Angle(value, AngleUnit.Tilt); } @@ -524,7 +527,7 @@ public static Angle FromTilt(QuantityValue tilt) /// Angle unit value. public static Angle From(QuantityValue value, AngleUnit fromUnit) { - return new Angle((double)value, fromUnit); + return new Angle((QuantityValue)value, fromUnit); } #endregion @@ -694,25 +697,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle } /// Get from multiplying value and . - public static Angle operator *(double left, Angle right) + public static Angle operator *(QuantityValue left, Angle right) { return new Angle(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Angle operator *(Angle left, double right) + public static Angle operator *(Angle left, QuantityValue right) { return new Angle(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Angle operator /(Angle left, double right) + public static Angle operator /(Angle left, QuantityValue right) { return new Angle(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Angle left, Angle right) + public static QuantityValue operator /(Angle left, Angle right) { return left.Degrees / right.Degrees; } @@ -745,6 +748,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Angle left, Angle right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Angle left, Angle right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -757,7 +773,29 @@ public int CompareTo(object obj) /// public int CompareTo(Angle other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Angle objAngle)) + return false; + return Equals(objAngle); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Angle other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -800,13 +838,13 @@ public int CompareTo(Angle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) + public bool Equals(Angle other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -817,7 +855,7 @@ public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Angle. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -828,17 +866,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AngleUnit unit) + public QuantityValue As(AngleUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -853,12 +890,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AngleUnit unitAsAngleUnit)) + if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return As(unitAsAngleUnit); + return (QuantityValue)As(typedUnit); } /// @@ -890,7 +927,7 @@ public Angle ToUnit(AngleUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Angle)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AngleUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -898,17 +935,17 @@ public Angle ToUnit(AngleUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AngleUnit unitAsAngleUnit)) + if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAngleUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -935,10 +972,10 @@ public Angle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AngleUnit unit) + private QuantityValue GetValueAs(AngleUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index db89646bfd..fc7df3950d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. /// [DataContract] - public partial struct ApparentEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static ApparentEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ApparentEnergy(double value, ApparentEnergyUnit unit) + public ApparentEnergy(QuantityValue value, ApparentEnergyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public ApparentEnergy(double value, ApparentEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentEnergy(double value, UnitSystem unitSystem) + public ApparentEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public ApparentEnergy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); + public QuantityValue KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); + public QuantityValue MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); + public QuantityValue VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ApparentEnergy FromKilovoltampereHours(QuantityValue kilovoltamperehours) { - double value = (double) kilovoltamperehours; + QuantityValue value = (QuantityValue) kilovoltamperehours; return new ApparentEnergy(value, ApparentEnergyUnit.KilovoltampereHour); } @@ -243,7 +246,7 @@ public static ApparentEnergy FromKilovoltampereHours(QuantityValue kilovoltamper /// If value is NaN or Infinity. public static ApparentEnergy FromMegavoltampereHours(QuantityValue megavoltamperehours) { - double value = (double) megavoltamperehours; + QuantityValue value = (QuantityValue) megavoltamperehours; return new ApparentEnergy(value, ApparentEnergyUnit.MegavoltampereHour); } @@ -253,7 +256,7 @@ public static ApparentEnergy FromMegavoltampereHours(QuantityValue megavoltamper /// If value is NaN or Infinity. public static ApparentEnergy FromVoltampereHours(QuantityValue voltamperehours) { - double value = (double) voltamperehours; + QuantityValue value = (QuantityValue) voltamperehours; return new ApparentEnergy(value, ApparentEnergyUnit.VoltampereHour); } @@ -265,7 +268,7 @@ public static ApparentEnergy FromVoltampereHours(QuantityValue voltamperehours) /// ApparentEnergy unit value. public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUnit) { - return new ApparentEnergy((double)value, fromUnit); + return new ApparentEnergy((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar } /// Get from multiplying value and . - public static ApparentEnergy operator *(double left, ApparentEnergy right) + public static ApparentEnergy operator *(QuantityValue left, ApparentEnergy right) { return new ApparentEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ApparentEnergy operator *(ApparentEnergy left, double right) + public static ApparentEnergy operator *(ApparentEnergy left, QuantityValue right) { return new ApparentEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ApparentEnergy operator /(ApparentEnergy left, double right) + public static ApparentEnergy operator /(ApparentEnergy left, QuantityValue right) { return new ApparentEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ApparentEnergy left, ApparentEnergy right) + public static QuantityValue operator /(ApparentEnergy left, ApparentEnergy right) { return left.VoltampereHours / right.VoltampereHours; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ApparentEnergy left, ApparentEnergy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ApparentEnergy left, ApparentEnergy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(ApparentEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ApparentEnergy objApparentEnergy)) + return false; + return Equals(objApparentEnergy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ApparentEnergy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(ApparentEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(ApparentEnergy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(ApparentEnergy other, double tolerance, ComparisonType compar /// A hash code for the current ApparentEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentEnergyUnit unit) + public QuantityValue As(ApparentEnergyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) + if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsApparentEnergyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ApparentEnergy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ApparentEnergyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) + if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsApparentEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public ApparentEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ApparentEnergyUnit unit) + private QuantityValue GetValueAs(ApparentEnergyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 403251e02c..b39709e9b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. /// [DataContract] - public partial struct ApparentPower : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ApparentPower() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ApparentPower(double value, ApparentPowerUnit unit) + public ApparentPower(QuantityValue value, ApparentPowerUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public ApparentPower(double value, ApparentPowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentPower(double value, UnitSystem unitSystem) + public ApparentPower(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public ApparentPower(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public ApparentPower(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); + public QuantityValue Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); + public QuantityValue Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); + public QuantityValue Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Voltamperes => As(ApparentPowerUnit.Voltampere); + public QuantityValue Voltamperes => As(ApparentPowerUnit.Voltampere); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static ApparentPower FromGigavoltamperes(QuantityValue gigavoltamperes) { - double value = (double) gigavoltamperes; + QuantityValue value = (QuantityValue) gigavoltamperes; return new ApparentPower(value, ApparentPowerUnit.Gigavoltampere); } @@ -252,7 +255,7 @@ public static ApparentPower FromGigavoltamperes(QuantityValue gigavoltamperes) /// If value is NaN or Infinity. public static ApparentPower FromKilovoltamperes(QuantityValue kilovoltamperes) { - double value = (double) kilovoltamperes; + QuantityValue value = (QuantityValue) kilovoltamperes; return new ApparentPower(value, ApparentPowerUnit.Kilovoltampere); } @@ -262,7 +265,7 @@ public static ApparentPower FromKilovoltamperes(QuantityValue kilovoltamperes) /// If value is NaN or Infinity. public static ApparentPower FromMegavoltamperes(QuantityValue megavoltamperes) { - double value = (double) megavoltamperes; + QuantityValue value = (QuantityValue) megavoltamperes; return new ApparentPower(value, ApparentPowerUnit.Megavoltampere); } @@ -272,7 +275,7 @@ public static ApparentPower FromMegavoltamperes(QuantityValue megavoltamperes) /// If value is NaN or Infinity. public static ApparentPower FromVoltamperes(QuantityValue voltamperes) { - double value = (double) voltamperes; + QuantityValue value = (QuantityValue) voltamperes; return new ApparentPower(value, ApparentPowerUnit.Voltampere); } @@ -284,7 +287,7 @@ public static ApparentPower FromVoltamperes(QuantityValue voltamperes) /// ApparentPower unit value. public static ApparentPower From(QuantityValue value, ApparentPowerUnit fromUnit) { - return new ApparentPower((double)value, fromUnit); + return new ApparentPower((QuantityValue)value, fromUnit); } #endregion @@ -454,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar } /// Get from multiplying value and . - public static ApparentPower operator *(double left, ApparentPower right) + public static ApparentPower operator *(QuantityValue left, ApparentPower right) { return new ApparentPower(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ApparentPower operator *(ApparentPower left, double right) + public static ApparentPower operator *(ApparentPower left, QuantityValue right) { return new ApparentPower(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ApparentPower operator /(ApparentPower left, double right) + public static ApparentPower operator /(ApparentPower left, QuantityValue right) { return new ApparentPower(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ApparentPower left, ApparentPower right) + public static QuantityValue operator /(ApparentPower left, ApparentPower right) { return left.Voltamperes / right.Voltamperes; } @@ -505,6 +508,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ApparentPower left, ApparentPower right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ApparentPower left, ApparentPower right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -517,7 +533,29 @@ public int CompareTo(object obj) /// public int CompareTo(ApparentPower other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ApparentPower objApparentPower)) + return false; + return Equals(objApparentPower); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ApparentPower other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -560,13 +598,13 @@ public int CompareTo(ApparentPower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType) + public bool Equals(ApparentPower other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +615,7 @@ public bool Equals(ApparentPower other, double tolerance, ComparisonType compari /// A hash code for the current ApparentPower. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -588,17 +626,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ApparentPowerUnit unit) + public QuantityValue As(ApparentPowerUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,12 +650,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) + if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return As(unitAsApparentPowerUnit); + return (QuantityValue)As(typedUnit); } /// @@ -650,7 +687,7 @@ public ApparentPower ToUnit(ApparentPowerUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (ApparentPower)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ApparentPowerUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -658,17 +695,17 @@ public ApparentPower ToUnit(ApparentPowerUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) + if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsApparentPowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -695,10 +732,10 @@ public ApparentPower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ApparentPowerUnit unit) + private QuantityValue GetValueAs(ApparentPowerUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index e7b786a82d..b09d112214 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). /// [DataContract] - public partial struct Area : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static Area() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Area(double value, AreaUnit unit) + public Area(QuantityValue value, AreaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -99,14 +99,14 @@ public Area(double value, AreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Area(double value, UnitSystem unitSystem) + public Area(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,7 +147,10 @@ public Area(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -170,74 +173,74 @@ public Area(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Acres => As(AreaUnit.Acre); + public QuantityValue Acres => As(AreaUnit.Acre); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hectares => As(AreaUnit.Hectare); + public QuantityValue Hectares => As(AreaUnit.Hectare); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareCentimeters => As(AreaUnit.SquareCentimeter); + public QuantityValue SquareCentimeters => As(AreaUnit.SquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareDecimeters => As(AreaUnit.SquareDecimeter); + public QuantityValue SquareDecimeters => As(AreaUnit.SquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareFeet => As(AreaUnit.SquareFoot); + public QuantityValue SquareFeet => As(AreaUnit.SquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareInches => As(AreaUnit.SquareInch); + public QuantityValue SquareInches => As(AreaUnit.SquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareKilometers => As(AreaUnit.SquareKilometer); + public QuantityValue SquareKilometers => As(AreaUnit.SquareKilometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMeters => As(AreaUnit.SquareMeter); + public QuantityValue SquareMeters => As(AreaUnit.SquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMicrometers => As(AreaUnit.SquareMicrometer); + public QuantityValue SquareMicrometers => As(AreaUnit.SquareMicrometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMiles => As(AreaUnit.SquareMile); + public QuantityValue SquareMiles => As(AreaUnit.SquareMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMillimeters => As(AreaUnit.SquareMillimeter); + public QuantityValue SquareMillimeters => As(AreaUnit.SquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); + public QuantityValue SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareYards => As(AreaUnit.SquareYard); + public QuantityValue SquareYards => As(AreaUnit.SquareYard); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); + public QuantityValue UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); #endregion @@ -359,7 +362,7 @@ public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Area FromAcres(QuantityValue acres) { - double value = (double) acres; + QuantityValue value = (QuantityValue) acres; return new Area(value, AreaUnit.Acre); } @@ -369,7 +372,7 @@ public static Area FromAcres(QuantityValue acres) /// If value is NaN or Infinity. public static Area FromHectares(QuantityValue hectares) { - double value = (double) hectares; + QuantityValue value = (QuantityValue) hectares; return new Area(value, AreaUnit.Hectare); } @@ -379,7 +382,7 @@ public static Area FromHectares(QuantityValue hectares) /// If value is NaN or Infinity. public static Area FromSquareCentimeters(QuantityValue squarecentimeters) { - double value = (double) squarecentimeters; + QuantityValue value = (QuantityValue) squarecentimeters; return new Area(value, AreaUnit.SquareCentimeter); } @@ -389,7 +392,7 @@ public static Area FromSquareCentimeters(QuantityValue squarecentimeters) /// If value is NaN or Infinity. public static Area FromSquareDecimeters(QuantityValue squaredecimeters) { - double value = (double) squaredecimeters; + QuantityValue value = (QuantityValue) squaredecimeters; return new Area(value, AreaUnit.SquareDecimeter); } @@ -399,7 +402,7 @@ public static Area FromSquareDecimeters(QuantityValue squaredecimeters) /// If value is NaN or Infinity. public static Area FromSquareFeet(QuantityValue squarefeet) { - double value = (double) squarefeet; + QuantityValue value = (QuantityValue) squarefeet; return new Area(value, AreaUnit.SquareFoot); } @@ -409,7 +412,7 @@ public static Area FromSquareFeet(QuantityValue squarefeet) /// If value is NaN or Infinity. public static Area FromSquareInches(QuantityValue squareinches) { - double value = (double) squareinches; + QuantityValue value = (QuantityValue) squareinches; return new Area(value, AreaUnit.SquareInch); } @@ -419,7 +422,7 @@ public static Area FromSquareInches(QuantityValue squareinches) /// If value is NaN or Infinity. public static Area FromSquareKilometers(QuantityValue squarekilometers) { - double value = (double) squarekilometers; + QuantityValue value = (QuantityValue) squarekilometers; return new Area(value, AreaUnit.SquareKilometer); } @@ -429,7 +432,7 @@ public static Area FromSquareKilometers(QuantityValue squarekilometers) /// If value is NaN or Infinity. public static Area FromSquareMeters(QuantityValue squaremeters) { - double value = (double) squaremeters; + QuantityValue value = (QuantityValue) squaremeters; return new Area(value, AreaUnit.SquareMeter); } @@ -439,7 +442,7 @@ public static Area FromSquareMeters(QuantityValue squaremeters) /// If value is NaN or Infinity. public static Area FromSquareMicrometers(QuantityValue squaremicrometers) { - double value = (double) squaremicrometers; + QuantityValue value = (QuantityValue) squaremicrometers; return new Area(value, AreaUnit.SquareMicrometer); } @@ -449,7 +452,7 @@ public static Area FromSquareMicrometers(QuantityValue squaremicrometers) /// If value is NaN or Infinity. public static Area FromSquareMiles(QuantityValue squaremiles) { - double value = (double) squaremiles; + QuantityValue value = (QuantityValue) squaremiles; return new Area(value, AreaUnit.SquareMile); } @@ -459,7 +462,7 @@ public static Area FromSquareMiles(QuantityValue squaremiles) /// If value is NaN or Infinity. public static Area FromSquareMillimeters(QuantityValue squaremillimeters) { - double value = (double) squaremillimeters; + QuantityValue value = (QuantityValue) squaremillimeters; return new Area(value, AreaUnit.SquareMillimeter); } @@ -469,7 +472,7 @@ public static Area FromSquareMillimeters(QuantityValue squaremillimeters) /// If value is NaN or Infinity. public static Area FromSquareNauticalMiles(QuantityValue squarenauticalmiles) { - double value = (double) squarenauticalmiles; + QuantityValue value = (QuantityValue) squarenauticalmiles; return new Area(value, AreaUnit.SquareNauticalMile); } @@ -479,7 +482,7 @@ public static Area FromSquareNauticalMiles(QuantityValue squarenauticalmiles) /// If value is NaN or Infinity. public static Area FromSquareYards(QuantityValue squareyards) { - double value = (double) squareyards; + QuantityValue value = (QuantityValue) squareyards; return new Area(value, AreaUnit.SquareYard); } @@ -489,7 +492,7 @@ public static Area FromSquareYards(QuantityValue squareyards) /// If value is NaN or Infinity. public static Area FromUsSurveySquareFeet(QuantityValue ussurveysquarefeet) { - double value = (double) ussurveysquarefeet; + QuantityValue value = (QuantityValue) ussurveysquarefeet; return new Area(value, AreaUnit.UsSurveySquareFoot); } @@ -501,7 +504,7 @@ public static Area FromUsSurveySquareFeet(QuantityValue ussurveysquarefeet) /// Area unit value. public static Area From(QuantityValue value, AreaUnit fromUnit) { - return new Area((double)value, fromUnit); + return new Area((QuantityValue)value, fromUnit); } #endregion @@ -671,25 +674,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU } /// Get from multiplying value and . - public static Area operator *(double left, Area right) + public static Area operator *(QuantityValue left, Area right) { return new Area(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Area operator *(Area left, double right) + public static Area operator *(Area left, QuantityValue right) { return new Area(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Area operator /(Area left, double right) + public static Area operator /(Area left, QuantityValue right) { return new Area(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Area left, Area right) + public static QuantityValue operator /(Area left, Area right) { return left.SquareMeters / right.SquareMeters; } @@ -722,6 +725,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Area left, Area right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Area left, Area right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -734,7 +750,29 @@ public int CompareTo(object obj) /// public int CompareTo(Area other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Area objArea)) + return false; + return Equals(objArea); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Area other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -777,13 +815,13 @@ public int CompareTo(Area other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Area other, double tolerance, ComparisonType comparisonType) + public bool Equals(Area other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -794,7 +832,7 @@ public bool Equals(Area other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Area. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -805,17 +843,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaUnit unit) + public QuantityValue As(AreaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -830,12 +867,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AreaUnit unitAsAreaUnit)) + if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -867,7 +904,7 @@ public Area ToUnit(AreaUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Area)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AreaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -875,17 +912,17 @@ public Area ToUnit(AreaUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaUnit unitAsAreaUnit)) + if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -912,10 +949,10 @@ public Area ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AreaUnit unit) + private QuantityValue GetValueAs(AreaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 76e73b46b3..9258a2c16d 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The area density of a two-dimensional object is calculated as the mass per unit area. /// [DataContract] - public partial struct AreaDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static AreaDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AreaDensity(double value, AreaDensityUnit unit) + public AreaDensity(QuantityValue value, AreaDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -86,14 +86,14 @@ public AreaDensity(double value, AreaDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaDensity(double value, UnitSystem unitSystem) + public AreaDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,7 +134,10 @@ public AreaDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -157,9 +160,9 @@ public AreaDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); + public QuantityValue KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); #endregion @@ -215,7 +218,7 @@ public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue kilogramspersquaremeter) { - double value = (double) kilogramspersquaremeter; + QuantityValue value = (QuantityValue) kilogramspersquaremeter; return new AreaDensity(value, AreaDensityUnit.KilogramPerSquareMeter); } @@ -227,7 +230,7 @@ public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue kilogramsper /// AreaDensity unit value. public static AreaDensity From(QuantityValue value, AreaDensityUnit fromUnit) { - return new AreaDensity((double)value, fromUnit); + return new AreaDensity((QuantityValue)value, fromUnit); } #endregion @@ -397,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD } /// Get from multiplying value and . - public static AreaDensity operator *(double left, AreaDensity right) + public static AreaDensity operator *(QuantityValue left, AreaDensity right) { return new AreaDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AreaDensity operator *(AreaDensity left, double right) + public static AreaDensity operator *(AreaDensity left, QuantityValue right) { return new AreaDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AreaDensity operator /(AreaDensity left, double right) + public static AreaDensity operator /(AreaDensity left, QuantityValue right) { return new AreaDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AreaDensity left, AreaDensity right) + public static QuantityValue operator /(AreaDensity left, AreaDensity right) { return left.KilogramsPerSquareMeter / right.KilogramsPerSquareMeter; } @@ -448,6 +451,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(AreaDensity left, AreaDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(AreaDensity left, AreaDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -460,7 +476,29 @@ public int CompareTo(object obj) /// public int CompareTo(AreaDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is AreaDensity objAreaDensity)) + return false; + return Equals(objAreaDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(AreaDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -503,13 +541,13 @@ public int CompareTo(AreaDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(AreaDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -520,7 +558,7 @@ public bool Equals(AreaDensity other, double tolerance, ComparisonType compariso /// A hash code for the current AreaDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -531,17 +569,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaDensityUnit unit) + public QuantityValue As(AreaDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -556,12 +593,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) + if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return As(unitAsAreaDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -593,7 +630,7 @@ public AreaDensity ToUnit(AreaDensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (AreaDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AreaDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -601,17 +638,17 @@ public AreaDensity ToUnit(AreaDensityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) + if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -638,10 +675,10 @@ public AreaDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AreaDensityUnit unit) + private QuantityValue GetValueAs(AreaDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 26632ad748..80dedcc912 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A geometric property of an area that reflects how its points are distributed with regard to an axis. /// [DataContract] - public partial struct AreaMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static AreaMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) + public AreaMomentOfInertia(QuantityValue value, AreaMomentOfInertiaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaMomentOfInertia(double value, UnitSystem unitSystem) + public AreaMomentOfInertia(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,34 +165,34 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); + public QuantityValue CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); + public QuantityValue DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); + public QuantityValue FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); + public QuantityValue InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); + public QuantityValue MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); + public QuantityValue MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); #endregion @@ -260,7 +263,7 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvid /// If value is NaN or Infinity. public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue centimeterstothefourth) { - double value = (double) centimeterstothefourth; + QuantityValue value = (QuantityValue) centimeterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.CentimeterToTheFourth); } @@ -270,7 +273,7 @@ public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue centi /// If value is NaN or Infinity. public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue decimeterstothefourth) { - double value = (double) decimeterstothefourth; + QuantityValue value = (QuantityValue) decimeterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.DecimeterToTheFourth); } @@ -280,7 +283,7 @@ public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue decime /// If value is NaN or Infinity. public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue feettothefourth) { - double value = (double) feettothefourth; + QuantityValue value = (QuantityValue) feettothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.FootToTheFourth); } @@ -290,7 +293,7 @@ public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue feettothefou /// If value is NaN or Infinity. public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue inchestothefourth) { - double value = (double) inchestothefourth; + QuantityValue value = (QuantityValue) inchestothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.InchToTheFourth); } @@ -300,7 +303,7 @@ public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue inchestoth /// If value is NaN or Infinity. public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue meterstothefourth) { - double value = (double) meterstothefourth; + QuantityValue value = (QuantityValue) meterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MeterToTheFourth); } @@ -310,7 +313,7 @@ public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue meterstoth /// If value is NaN or Infinity. public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue millimeterstothefourth) { - double value = (double) millimeterstothefourth; + QuantityValue value = (QuantityValue) millimeterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MillimeterToTheFourth); } @@ -322,7 +325,7 @@ public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue milli /// AreaMomentOfInertia unit value. public static AreaMomentOfInertia From(QuantityValue value, AreaMomentOfInertiaUnit fromUnit) { - return new AreaMomentOfInertia((double)value, fromUnit); + return new AreaMomentOfInertia((QuantityValue)value, fromUnit); } #endregion @@ -492,25 +495,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM } /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(double left, AreaMomentOfInertia right) + public static AreaMomentOfInertia operator *(QuantityValue left, AreaMomentOfInertia right) { return new AreaMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, double right) + public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, QuantityValue right) { return new AreaMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, double right) + public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, QuantityValue right) { return new AreaMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static QuantityValue operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.MetersToTheFourth / right.MetersToTheFourth; } @@ -543,6 +546,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -555,7 +571,29 @@ public int CompareTo(object obj) /// public int CompareTo(AreaMomentOfInertia other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) + return false; + return Equals(objAreaMomentOfInertia); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(AreaMomentOfInertia other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -598,13 +636,13 @@ public int CompareTo(AreaMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType) + public bool Equals(AreaMomentOfInertia other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +653,7 @@ public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType c /// A hash code for the current AreaMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -626,17 +664,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(AreaMomentOfInertiaUnit unit) + public QuantityValue As(AreaMomentOfInertiaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -651,12 +688,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) + if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaMomentOfInertiaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -688,7 +725,7 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit, UnitConverter un var converted = conversionFunction(this); return (AreaMomentOfInertia)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(AreaMomentOfInertiaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -696,17 +733,17 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) + if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -733,10 +770,10 @@ public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(AreaMomentOfInertiaUnit unit) + private QuantityValue GetValueAs(AreaMomentOfInertiaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 1ce28dd1dd..cbb22d9243 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Bit_rate /// [DataContract] - public partial struct BitRate : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly decimal _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -100,7 +100,7 @@ static BitRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public BitRate(decimal value, BitRateUnit unit) + public BitRate(QuantityValue value, BitRateUnit unit) { _value = value; _unit = unit; @@ -114,7 +114,7 @@ public BitRate(decimal value, BitRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BitRate(decimal value, UnitSystem unitSystem) + public BitRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -162,12 +162,13 @@ public BitRate(decimal value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public decimal Value => _value; + public QuantityValue Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// - decimal IDecimalQuantity.Value => _value; + decimal IDecimalQuantity.Value => (decimal)_value; Enum IQuantity.Unit => Unit; @@ -190,134 +191,134 @@ public BitRate(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BitsPerSecond => As(BitRateUnit.BitPerSecond); + public QuantityValue BitsPerSecond => As(BitRateUnit.BitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BytesPerSecond => As(BitRateUnit.BytePerSecond); + public QuantityValue BytesPerSecond => As(BitRateUnit.BytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); + public QuantityValue ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); + public QuantityValue ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); + public QuantityValue ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); + public QuantityValue ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); + public QuantityValue GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); + public QuantityValue GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); + public QuantityValue GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); + public QuantityValue GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); + public QuantityValue KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); + public QuantityValue KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); + public QuantityValue KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); + public QuantityValue KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); + public QuantityValue MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); + public QuantityValue MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); + public QuantityValue MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); + public QuantityValue MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); + public QuantityValue PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); + public QuantityValue PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); + public QuantityValue PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); + public QuantityValue PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); + public QuantityValue TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); + public QuantityValue TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); + public QuantityValue TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); + public QuantityValue TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); #endregion @@ -448,7 +449,7 @@ public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider /// If value is NaN or Infinity. public static BitRate FromBitsPerSecond(QuantityValue bitspersecond) { - decimal value = (decimal) bitspersecond; + QuantityValue value = (QuantityValue) bitspersecond; return new BitRate(value, BitRateUnit.BitPerSecond); } @@ -458,7 +459,7 @@ public static BitRate FromBitsPerSecond(QuantityValue bitspersecond) /// If value is NaN or Infinity. public static BitRate FromBytesPerSecond(QuantityValue bytespersecond) { - decimal value = (decimal) bytespersecond; + QuantityValue value = (QuantityValue) bytespersecond; return new BitRate(value, BitRateUnit.BytePerSecond); } @@ -468,7 +469,7 @@ public static BitRate FromBytesPerSecond(QuantityValue bytespersecond) /// If value is NaN or Infinity. public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond) { - decimal value = (decimal) exabitspersecond; + QuantityValue value = (QuantityValue) exabitspersecond; return new BitRate(value, BitRateUnit.ExabitPerSecond); } @@ -478,7 +479,7 @@ public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond) /// If value is NaN or Infinity. public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond) { - decimal value = (decimal) exabytespersecond; + QuantityValue value = (QuantityValue) exabytespersecond; return new BitRate(value, BitRateUnit.ExabytePerSecond); } @@ -488,7 +489,7 @@ public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond) /// If value is NaN or Infinity. public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond) { - decimal value = (decimal) exbibitspersecond; + QuantityValue value = (QuantityValue) exbibitspersecond; return new BitRate(value, BitRateUnit.ExbibitPerSecond); } @@ -498,7 +499,7 @@ public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond) /// If value is NaN or Infinity. public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond) { - decimal value = (decimal) exbibytespersecond; + QuantityValue value = (QuantityValue) exbibytespersecond; return new BitRate(value, BitRateUnit.ExbibytePerSecond); } @@ -508,7 +509,7 @@ public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond) /// If value is NaN or Infinity. public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond) { - decimal value = (decimal) gibibitspersecond; + QuantityValue value = (QuantityValue) gibibitspersecond; return new BitRate(value, BitRateUnit.GibibitPerSecond); } @@ -518,7 +519,7 @@ public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond) /// If value is NaN or Infinity. public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond) { - decimal value = (decimal) gibibytespersecond; + QuantityValue value = (QuantityValue) gibibytespersecond; return new BitRate(value, BitRateUnit.GibibytePerSecond); } @@ -528,7 +529,7 @@ public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond) /// If value is NaN or Infinity. public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond) { - decimal value = (decimal) gigabitspersecond; + QuantityValue value = (QuantityValue) gigabitspersecond; return new BitRate(value, BitRateUnit.GigabitPerSecond); } @@ -538,7 +539,7 @@ public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond) /// If value is NaN or Infinity. public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond) { - decimal value = (decimal) gigabytespersecond; + QuantityValue value = (QuantityValue) gigabytespersecond; return new BitRate(value, BitRateUnit.GigabytePerSecond); } @@ -548,7 +549,7 @@ public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond) /// If value is NaN or Infinity. public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond) { - decimal value = (decimal) kibibitspersecond; + QuantityValue value = (QuantityValue) kibibitspersecond; return new BitRate(value, BitRateUnit.KibibitPerSecond); } @@ -558,7 +559,7 @@ public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond) /// If value is NaN or Infinity. public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond) { - decimal value = (decimal) kibibytespersecond; + QuantityValue value = (QuantityValue) kibibytespersecond; return new BitRate(value, BitRateUnit.KibibytePerSecond); } @@ -568,7 +569,7 @@ public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond) /// If value is NaN or Infinity. public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond) { - decimal value = (decimal) kilobitspersecond; + QuantityValue value = (QuantityValue) kilobitspersecond; return new BitRate(value, BitRateUnit.KilobitPerSecond); } @@ -578,7 +579,7 @@ public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond) /// If value is NaN or Infinity. public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond) { - decimal value = (decimal) kilobytespersecond; + QuantityValue value = (QuantityValue) kilobytespersecond; return new BitRate(value, BitRateUnit.KilobytePerSecond); } @@ -588,7 +589,7 @@ public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond) /// If value is NaN or Infinity. public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond) { - decimal value = (decimal) mebibitspersecond; + QuantityValue value = (QuantityValue) mebibitspersecond; return new BitRate(value, BitRateUnit.MebibitPerSecond); } @@ -598,7 +599,7 @@ public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond) /// If value is NaN or Infinity. public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond) { - decimal value = (decimal) mebibytespersecond; + QuantityValue value = (QuantityValue) mebibytespersecond; return new BitRate(value, BitRateUnit.MebibytePerSecond); } @@ -608,7 +609,7 @@ public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond) /// If value is NaN or Infinity. public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond) { - decimal value = (decimal) megabitspersecond; + QuantityValue value = (QuantityValue) megabitspersecond; return new BitRate(value, BitRateUnit.MegabitPerSecond); } @@ -618,7 +619,7 @@ public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond) /// If value is NaN or Infinity. public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond) { - decimal value = (decimal) megabytespersecond; + QuantityValue value = (QuantityValue) megabytespersecond; return new BitRate(value, BitRateUnit.MegabytePerSecond); } @@ -628,7 +629,7 @@ public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond) /// If value is NaN or Infinity. public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond) { - decimal value = (decimal) pebibitspersecond; + QuantityValue value = (QuantityValue) pebibitspersecond; return new BitRate(value, BitRateUnit.PebibitPerSecond); } @@ -638,7 +639,7 @@ public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond) /// If value is NaN or Infinity. public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond) { - decimal value = (decimal) pebibytespersecond; + QuantityValue value = (QuantityValue) pebibytespersecond; return new BitRate(value, BitRateUnit.PebibytePerSecond); } @@ -648,7 +649,7 @@ public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond) /// If value is NaN or Infinity. public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond) { - decimal value = (decimal) petabitspersecond; + QuantityValue value = (QuantityValue) petabitspersecond; return new BitRate(value, BitRateUnit.PetabitPerSecond); } @@ -658,7 +659,7 @@ public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond) /// If value is NaN or Infinity. public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond) { - decimal value = (decimal) petabytespersecond; + QuantityValue value = (QuantityValue) petabytespersecond; return new BitRate(value, BitRateUnit.PetabytePerSecond); } @@ -668,7 +669,7 @@ public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond) /// If value is NaN or Infinity. public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond) { - decimal value = (decimal) tebibitspersecond; + QuantityValue value = (QuantityValue) tebibitspersecond; return new BitRate(value, BitRateUnit.TebibitPerSecond); } @@ -678,7 +679,7 @@ public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond) /// If value is NaN or Infinity. public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond) { - decimal value = (decimal) tebibytespersecond; + QuantityValue value = (QuantityValue) tebibytespersecond; return new BitRate(value, BitRateUnit.TebibytePerSecond); } @@ -688,7 +689,7 @@ public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond) /// If value is NaN or Infinity. public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond) { - decimal value = (decimal) terabitspersecond; + QuantityValue value = (QuantityValue) terabitspersecond; return new BitRate(value, BitRateUnit.TerabitPerSecond); } @@ -698,7 +699,7 @@ public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond) /// If value is NaN or Infinity. public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond) { - decimal value = (decimal) terabytespersecond; + QuantityValue value = (QuantityValue) terabytespersecond; return new BitRate(value, BitRateUnit.TerabytePerSecond); } @@ -710,7 +711,7 @@ public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond) /// BitRate unit value. public static BitRate From(QuantityValue value, BitRateUnit fromUnit) { - return new BitRate((decimal)value, fromUnit); + return new BitRate((QuantityValue)value, fromUnit); } #endregion @@ -880,25 +881,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa } /// Get from multiplying value and . - public static BitRate operator *(decimal left, BitRate right) + public static BitRate operator *(QuantityValue left, BitRate right) { return new BitRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static BitRate operator *(BitRate left, decimal right) + public static BitRate operator *(BitRate left, QuantityValue right) { return new BitRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static BitRate operator /(BitRate left, decimal right) + public static BitRate operator /(BitRate left, QuantityValue right) { return new BitRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(BitRate left, BitRate right) + public static QuantityValue operator /(BitRate left, BitRate right) { return left.BitsPerSecond / right.BitsPerSecond; } @@ -931,6 +932,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(BitRate left, BitRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(BitRate left, BitRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -943,7 +957,29 @@ public int CompareTo(object obj) /// public int CompareTo(BitRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is BitRate objBitRate)) + return false; + return Equals(objBitRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(BitRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -986,13 +1022,13 @@ public int CompareTo(BitRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(BitRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1003,7 +1039,7 @@ public bool Equals(BitRate other, double tolerance, ComparisonType comparisonTyp /// A hash code for the current BitRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1014,17 +1050,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BitRateUnit unit) + public QuantityValue As(BitRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1039,12 +1074,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is BitRateUnit unitAsBitRateUnit)) + if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return As(unitAsBitRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1076,7 +1111,7 @@ public BitRate ToUnit(BitRateUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (BitRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(BitRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1084,17 +1119,17 @@ public BitRate ToUnit(BitRateUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BitRateUnit unitAsBitRateUnit)) + if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsBitRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1121,10 +1156,10 @@ public BitRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private decimal GetValueAs(BitRateUnit unit) + private QuantityValue GetValueAs(BitRateUnit unit) { var converted = ToUnit(unit); - return (decimal)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 22e36e45c1..7c05af6842 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. /// [DataContract] - public partial struct BrakeSpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static BrakeSpecificFuelConsumption() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) + public BrakeSpecificFuelConsumption(QuantityValue value, BrakeSpecificFuelConsumptionUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) + public BrakeSpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + public QuantityValue GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + public QuantityValue KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + public QuantityValue PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFor /// If value is NaN or Infinity. public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValue gramsperkilowatthour) { - double value = (double) gramsperkilowatthour; + QuantityValue value = (QuantityValue) gramsperkilowatthour; return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); } @@ -243,7 +246,7 @@ public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValu /// If value is NaN or Infinity. public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue kilogramsperjoule) { - double value = (double) kilogramsperjoule; + QuantityValue value = (QuantityValue) kilogramsperjoule; return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); } @@ -253,7 +256,7 @@ public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue k /// If value is NaN or Infinity. public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(QuantityValue poundspermechanicalhorsepowerhour) { - double value = (double) poundspermechanicalhorsepowerhour; + QuantityValue value = (QuantityValue) poundspermechanicalhorsepowerhour; return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); } @@ -265,7 +268,7 @@ public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour /// BrakeSpecificFuelConsumption unit value. public static BrakeSpecificFuelConsumption From(QuantityValue value, BrakeSpecificFuelConsumptionUnit fromUnit) { - return new BrakeSpecificFuelConsumption((double)value, fromUnit); + return new BrakeSpecificFuelConsumption((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake } /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(double left, BrakeSpecificFuelConsumption right) + public static BrakeSpecificFuelConsumption operator *(QuantityValue left, BrakeSpecificFuelConsumption right) { return new BrakeSpecificFuelConsumption(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, double right) + public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, QuantityValue right) { return new BrakeSpecificFuelConsumption(left.Value * right, left.Unit); } /// Get from dividing by value. - public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, double right) + public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, QuantityValue right) { return new BrakeSpecificFuelConsumption(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static QuantityValue operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.KilogramsPerJoule / right.KilogramsPerJoule; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(BrakeSpecificFuelConsumption other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) + return false; + return Equals(objBrakeSpecificFuelConsumption); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(BrakeSpecificFuelConsumption other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(BrakeSpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) + public bool Equals(BrakeSpecificFuelConsumption other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, Compari /// A hash code for the current BrakeSpecificFuelConsumption. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BrakeSpecificFuelConsumptionUnit unit) + public QuantityValue As(BrakeSpecificFuelConsumptionUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsBrakeSpecificFuelConsumptionUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit var converted = conversionFunction(this); return (BrakeSpecificFuelConsumption)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(BrakeSpecificFuelConsumptionUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsBrakeSpecificFuelConsumptionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) + private QuantityValue GetValueAs(BrakeSpecificFuelConsumptionUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index c049929b5a..5ed06c367e 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Capacitance /// [DataContract] - public partial struct Capacitance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static Capacitance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Capacitance(double value, CapacitanceUnit unit) + public Capacitance(QuantityValue value, CapacitanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -95,14 +95,14 @@ public Capacitance(double value, CapacitanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Capacitance(double value, UnitSystem unitSystem) + public Capacitance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,7 +143,10 @@ public Capacitance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -166,39 +169,39 @@ public Capacitance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Farads => As(CapacitanceUnit.Farad); + public QuantityValue Farads => As(CapacitanceUnit.Farad); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilofarads => As(CapacitanceUnit.Kilofarad); + public QuantityValue Kilofarads => As(CapacitanceUnit.Kilofarad); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megafarads => As(CapacitanceUnit.Megafarad); + public QuantityValue Megafarads => As(CapacitanceUnit.Megafarad); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microfarads => As(CapacitanceUnit.Microfarad); + public QuantityValue Microfarads => As(CapacitanceUnit.Microfarad); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millifarads => As(CapacitanceUnit.Millifarad); + public QuantityValue Millifarads => As(CapacitanceUnit.Millifarad); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanofarads => As(CapacitanceUnit.Nanofarad); + public QuantityValue Nanofarads => As(CapacitanceUnit.Nanofarad); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Picofarads => As(CapacitanceUnit.Picofarad); + public QuantityValue Picofarads => As(CapacitanceUnit.Picofarad); #endregion @@ -272,7 +275,7 @@ public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Capacitance FromFarads(QuantityValue farads) { - double value = (double) farads; + QuantityValue value = (QuantityValue) farads; return new Capacitance(value, CapacitanceUnit.Farad); } @@ -282,7 +285,7 @@ public static Capacitance FromFarads(QuantityValue farads) /// If value is NaN or Infinity. public static Capacitance FromKilofarads(QuantityValue kilofarads) { - double value = (double) kilofarads; + QuantityValue value = (QuantityValue) kilofarads; return new Capacitance(value, CapacitanceUnit.Kilofarad); } @@ -292,7 +295,7 @@ public static Capacitance FromKilofarads(QuantityValue kilofarads) /// If value is NaN or Infinity. public static Capacitance FromMegafarads(QuantityValue megafarads) { - double value = (double) megafarads; + QuantityValue value = (QuantityValue) megafarads; return new Capacitance(value, CapacitanceUnit.Megafarad); } @@ -302,7 +305,7 @@ public static Capacitance FromMegafarads(QuantityValue megafarads) /// If value is NaN or Infinity. public static Capacitance FromMicrofarads(QuantityValue microfarads) { - double value = (double) microfarads; + QuantityValue value = (QuantityValue) microfarads; return new Capacitance(value, CapacitanceUnit.Microfarad); } @@ -312,7 +315,7 @@ public static Capacitance FromMicrofarads(QuantityValue microfarads) /// If value is NaN or Infinity. public static Capacitance FromMillifarads(QuantityValue millifarads) { - double value = (double) millifarads; + QuantityValue value = (QuantityValue) millifarads; return new Capacitance(value, CapacitanceUnit.Millifarad); } @@ -322,7 +325,7 @@ public static Capacitance FromMillifarads(QuantityValue millifarads) /// If value is NaN or Infinity. public static Capacitance FromNanofarads(QuantityValue nanofarads) { - double value = (double) nanofarads; + QuantityValue value = (QuantityValue) nanofarads; return new Capacitance(value, CapacitanceUnit.Nanofarad); } @@ -332,7 +335,7 @@ public static Capacitance FromNanofarads(QuantityValue nanofarads) /// If value is NaN or Infinity. public static Capacitance FromPicofarads(QuantityValue picofarads) { - double value = (double) picofarads; + QuantityValue value = (QuantityValue) picofarads; return new Capacitance(value, CapacitanceUnit.Picofarad); } @@ -344,7 +347,7 @@ public static Capacitance FromPicofarads(QuantityValue picofarads) /// Capacitance unit value. public static Capacitance From(QuantityValue value, CapacitanceUnit fromUnit) { - return new Capacitance((double)value, fromUnit); + return new Capacitance((QuantityValue)value, fromUnit); } #endregion @@ -514,25 +517,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac } /// Get from multiplying value and . - public static Capacitance operator *(double left, Capacitance right) + public static Capacitance operator *(QuantityValue left, Capacitance right) { return new Capacitance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Capacitance operator *(Capacitance left, double right) + public static Capacitance operator *(Capacitance left, QuantityValue right) { return new Capacitance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Capacitance operator /(Capacitance left, double right) + public static Capacitance operator /(Capacitance left, QuantityValue right) { return new Capacitance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Capacitance left, Capacitance right) + public static QuantityValue operator /(Capacitance left, Capacitance right) { return left.Farads / right.Farads; } @@ -565,6 +568,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Capacitance left, Capacitance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Capacitance left, Capacitance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -577,7 +593,29 @@ public int CompareTo(object obj) /// public int CompareTo(Capacitance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Capacitance objCapacitance)) + return false; + return Equals(objCapacitance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Capacitance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -620,13 +658,13 @@ public int CompareTo(Capacitance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType) + public bool Equals(Capacitance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -637,7 +675,7 @@ public bool Equals(Capacitance other, double tolerance, ComparisonType compariso /// A hash code for the current Capacitance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -648,17 +686,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CapacitanceUnit unit) + public QuantityValue As(CapacitanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -673,12 +710,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) + if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return As(unitAsCapacitanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -710,7 +747,7 @@ public Capacitance ToUnit(CapacitanceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Capacitance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(CapacitanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -718,17 +755,17 @@ public Capacitance ToUnit(CapacitanceUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) + if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCapacitanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -755,10 +792,10 @@ public Capacitance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(CapacitanceUnit unit) + private QuantityValue GetValueAs(CapacitanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 1c980e9a81..c00ec02eed 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A unit that represents a fractional change in size in response to a change in temperature. /// [DataContract] - public partial struct CoefficientOfThermalExpansion : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static CoefficientOfThermalExpansion() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) + public CoefficientOfThermalExpansion(QuantityValue value, CoefficientOfThermalExpansionUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansion /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) + public CoefficientOfThermalExpansion(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); + public QuantityValue InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); + public QuantityValue InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); + public QuantityValue InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFo /// If value is NaN or Infinity. public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(QuantityValue inversedegreecelsius) { - double value = (double) inversedegreecelsius; + QuantityValue value = (QuantityValue) inversedegreecelsius; return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); } @@ -243,7 +246,7 @@ public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(QuantityVal /// If value is NaN or Infinity. public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(QuantityValue inversedegreefahrenheit) { - double value = (double) inversedegreefahrenheit; + QuantityValue value = (QuantityValue) inversedegreefahrenheit; return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); } @@ -253,7 +256,7 @@ public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(Quantity /// If value is NaN or Infinity. public static CoefficientOfThermalExpansion FromInverseKelvin(QuantityValue inversekelvin) { - double value = (double) inversekelvin; + QuantityValue value = (QuantityValue) inversekelvin; return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseKelvin); } @@ -265,7 +268,7 @@ public static CoefficientOfThermalExpansion FromInverseKelvin(QuantityValue inve /// CoefficientOfThermalExpansion unit value. public static CoefficientOfThermalExpansion From(QuantityValue value, CoefficientOfThermalExpansionUnit fromUnit) { - return new CoefficientOfThermalExpansion((double)value, fromUnit); + return new CoefficientOfThermalExpansion((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff } /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(double left, CoefficientOfThermalExpansion right) + public static CoefficientOfThermalExpansion operator *(QuantityValue left, CoefficientOfThermalExpansion right) { return new CoefficientOfThermalExpansion(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, double right) + public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, QuantityValue right) { return new CoefficientOfThermalExpansion(left.Value * right, left.Unit); } /// Get from dividing by value. - public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, double right) + public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, QuantityValue right) { return new CoefficientOfThermalExpansion(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static QuantityValue operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.InverseKelvin / right.InverseKelvin; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(CoefficientOfThermalExpansion other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) + return false; + return Equals(objCoefficientOfThermalExpansion); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(CoefficientOfThermalExpansion other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(CoefficientOfThermalExpansion other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType) + public bool Equals(CoefficientOfThermalExpansion other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(CoefficientOfThermalExpansion other, double tolerance, Compar /// A hash code for the current CoefficientOfThermalExpansion. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CoefficientOfThermalExpansionUnit unit) + public QuantityValue As(CoefficientOfThermalExpansionUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return As(unitAsCoefficientOfThermalExpansionUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un var converted = conversionFunction(this); return (CoefficientOfThermalExpansion)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(CoefficientOfThermalExpansionUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCoefficientOfThermalExpansionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(CoefficientOfThermalExpansionUnit unit) + private QuantityValue GetValueAs(CoefficientOfThermalExpansionUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 24755cc1db..c62b2ea809 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct Compressibility : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Compressibility : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static Compressibility() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Compressibility(double value, CompressibilityUnit unit) + public Compressibility(QuantityValue value, CompressibilityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public Compressibility(double value, CompressibilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Compressibility(double value, UnitSystem unitSystem) + public Compressibility(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public Compressibility(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,39 +166,39 @@ public Compressibility(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseAtmospheres => As(CompressibilityUnit.InverseAtmosphere); + public QuantityValue InverseAtmospheres => As(CompressibilityUnit.InverseAtmosphere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseBars => As(CompressibilityUnit.InverseBar); + public QuantityValue InverseBars => As(CompressibilityUnit.InverseBar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseKilopascals => As(CompressibilityUnit.InverseKilopascal); + public QuantityValue InverseKilopascals => As(CompressibilityUnit.InverseKilopascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMegapascals => As(CompressibilityUnit.InverseMegapascal); + public QuantityValue InverseMegapascals => As(CompressibilityUnit.InverseMegapascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMillibars => As(CompressibilityUnit.InverseMillibar); + public QuantityValue InverseMillibars => As(CompressibilityUnit.InverseMillibar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InversePascals => As(CompressibilityUnit.InversePascal); + public QuantityValue InversePascals => As(CompressibilityUnit.InversePascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InversePoundsForcePerSquareInch => As(CompressibilityUnit.InversePoundForcePerSquareInch); + public QuantityValue InversePoundsForcePerSquareInch => As(CompressibilityUnit.InversePoundForcePerSquareInch); #endregion @@ -269,7 +272,7 @@ public static string GetAbbreviation(CompressibilityUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static Compressibility FromInverseAtmospheres(QuantityValue inverseatmospheres) { - double value = (double) inverseatmospheres; + QuantityValue value = (QuantityValue) inverseatmospheres; return new Compressibility(value, CompressibilityUnit.InverseAtmosphere); } @@ -279,7 +282,7 @@ public static Compressibility FromInverseAtmospheres(QuantityValue inverseatmosp /// If value is NaN or Infinity. public static Compressibility FromInverseBars(QuantityValue inversebars) { - double value = (double) inversebars; + QuantityValue value = (QuantityValue) inversebars; return new Compressibility(value, CompressibilityUnit.InverseBar); } @@ -289,7 +292,7 @@ public static Compressibility FromInverseBars(QuantityValue inversebars) /// If value is NaN or Infinity. public static Compressibility FromInverseKilopascals(QuantityValue inversekilopascals) { - double value = (double) inversekilopascals; + QuantityValue value = (QuantityValue) inversekilopascals; return new Compressibility(value, CompressibilityUnit.InverseKilopascal); } @@ -299,7 +302,7 @@ public static Compressibility FromInverseKilopascals(QuantityValue inversekilopa /// If value is NaN or Infinity. public static Compressibility FromInverseMegapascals(QuantityValue inversemegapascals) { - double value = (double) inversemegapascals; + QuantityValue value = (QuantityValue) inversemegapascals; return new Compressibility(value, CompressibilityUnit.InverseMegapascal); } @@ -309,7 +312,7 @@ public static Compressibility FromInverseMegapascals(QuantityValue inversemegapa /// If value is NaN or Infinity. public static Compressibility FromInverseMillibars(QuantityValue inversemillibars) { - double value = (double) inversemillibars; + QuantityValue value = (QuantityValue) inversemillibars; return new Compressibility(value, CompressibilityUnit.InverseMillibar); } @@ -319,7 +322,7 @@ public static Compressibility FromInverseMillibars(QuantityValue inversemillibar /// If value is NaN or Infinity. public static Compressibility FromInversePascals(QuantityValue inversepascals) { - double value = (double) inversepascals; + QuantityValue value = (QuantityValue) inversepascals; return new Compressibility(value, CompressibilityUnit.InversePascal); } @@ -329,7 +332,7 @@ public static Compressibility FromInversePascals(QuantityValue inversepascals) /// If value is NaN or Infinity. public static Compressibility FromInversePoundsForcePerSquareInch(QuantityValue inversepoundsforcepersquareinch) { - double value = (double) inversepoundsforcepersquareinch; + QuantityValue value = (QuantityValue) inversepoundsforcepersquareinch; return new Compressibility(value, CompressibilityUnit.InversePoundForcePerSquareInch); } @@ -341,7 +344,7 @@ public static Compressibility FromInversePoundsForcePerSquareInch(QuantityValue /// Compressibility unit value. public static Compressibility From(QuantityValue value, CompressibilityUnit fromUnit) { - return new Compressibility((double)value, fromUnit); + return new Compressibility((QuantityValue)value, fromUnit); } #endregion @@ -511,25 +514,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr } /// Get from multiplying value and . - public static Compressibility operator *(double left, Compressibility right) + public static Compressibility operator *(QuantityValue left, Compressibility right) { return new Compressibility(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Compressibility operator *(Compressibility left, double right) + public static Compressibility operator *(Compressibility left, QuantityValue right) { return new Compressibility(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Compressibility operator /(Compressibility left, double right) + public static Compressibility operator /(Compressibility left, QuantityValue right) { return new Compressibility(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Compressibility left, Compressibility right) + public static QuantityValue operator /(Compressibility left, Compressibility right) { return left.InversePascals / right.InversePascals; } @@ -562,6 +565,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Compressibility left, Compressibility right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Compressibility left, Compressibility right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -574,7 +590,29 @@ public int CompareTo(object obj) /// public int CompareTo(Compressibility other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Compressibility objCompressibility)) + return false; + return Equals(objCompressibility); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Compressibility other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -617,13 +655,13 @@ public int CompareTo(Compressibility other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Compressibility other, double tolerance, ComparisonType comparisonType) + public bool Equals(Compressibility other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -634,7 +672,7 @@ public bool Equals(Compressibility other, double tolerance, ComparisonType compa /// A hash code for the current Compressibility. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -645,17 +683,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(CompressibilityUnit unit) + public QuantityValue As(CompressibilityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -670,12 +707,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) + if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return As(unitAsCompressibilityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -707,7 +744,7 @@ public Compressibility ToUnit(CompressibilityUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (Compressibility)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(CompressibilityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -715,17 +752,17 @@ public Compressibility ToUnit(CompressibilityUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) + if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCompressibilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -752,10 +789,10 @@ public Compressibility ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(CompressibilityUnit unit) + private QuantityValue GetValueAs(CompressibilityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 470717602d..f66631e323 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Density /// [DataContract] - public partial struct Density : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -125,9 +125,9 @@ static Density() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Density(double value, DensityUnit unit) + public Density(QuantityValue value, DensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -139,14 +139,14 @@ public Density(double value, DensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Density(double value, UnitSystem unitSystem) + public Density(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -187,7 +187,10 @@ public Density(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -210,259 +213,259 @@ public Density(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); + public QuantityValue CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); + public QuantityValue CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); + public QuantityValue CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); + public QuantityValue DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); + public QuantityValue DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); + public QuantityValue DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); + public QuantityValue GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicFoot => As(DensityUnit.GramPerCubicFoot); + public QuantityValue GramsPerCubicFoot => As(DensityUnit.GramPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicInch => As(DensityUnit.GramPerCubicInch); + public QuantityValue GramsPerCubicInch => As(DensityUnit.GramPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); + public QuantityValue GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); + public QuantityValue GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); + public QuantityValue GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerLiter => As(DensityUnit.GramPerLiter); + public QuantityValue GramsPerLiter => As(DensityUnit.GramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); + public QuantityValue GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); + public QuantityValue KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); + public QuantityValue KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); + public QuantityValue KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); + public QuantityValue KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); + public QuantityValue KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); + public QuantityValue KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); + public QuantityValue MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); + public QuantityValue MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); + public QuantityValue MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); + public QuantityValue MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); + public QuantityValue MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); + public QuantityValue MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); + public QuantityValue MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); + public QuantityValue MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); + public QuantityValue NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); + public QuantityValue NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); + public QuantityValue NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); + public QuantityValue PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); + public QuantityValue PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); + public QuantityValue PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicCentimeter => As(DensityUnit.PoundPerCubicCentimeter); + public QuantityValue PoundsPerCubicCentimeter => As(DensityUnit.PoundPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); + public QuantityValue PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); + public QuantityValue PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicMeter => As(DensityUnit.PoundPerCubicMeter); + public QuantityValue PoundsPerCubicMeter => As(DensityUnit.PoundPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicMillimeter => As(DensityUnit.PoundPerCubicMillimeter); + public QuantityValue PoundsPerCubicMillimeter => As(DensityUnit.PoundPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); + public QuantityValue PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); + public QuantityValue PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugsPerCubicCentimeter => As(DensityUnit.SlugPerCubicCentimeter); + public QuantityValue SlugsPerCubicCentimeter => As(DensityUnit.SlugPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); + public QuantityValue SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugsPerCubicInch => As(DensityUnit.SlugPerCubicInch); + public QuantityValue SlugsPerCubicInch => As(DensityUnit.SlugPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugsPerCubicMeter => As(DensityUnit.SlugPerCubicMeter); + public QuantityValue SlugsPerCubicMeter => As(DensityUnit.SlugPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugsPerCubicMillimeter => As(DensityUnit.SlugPerCubicMillimeter); + public QuantityValue SlugsPerCubicMillimeter => As(DensityUnit.SlugPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); + public QuantityValue TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicFoot => As(DensityUnit.TonnePerCubicFoot); + public QuantityValue TonnesPerCubicFoot => As(DensityUnit.TonnePerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicInch => As(DensityUnit.TonnePerCubicInch); + public QuantityValue TonnesPerCubicInch => As(DensityUnit.TonnePerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); + public QuantityValue TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); + public QuantityValue TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); #endregion @@ -672,7 +675,7 @@ public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider /// If value is NaN or Infinity. public static Density FromCentigramsPerDeciLiter(QuantityValue centigramsperdeciliter) { - double value = (double) centigramsperdeciliter; + QuantityValue value = (QuantityValue) centigramsperdeciliter; return new Density(value, DensityUnit.CentigramPerDeciliter); } @@ -682,7 +685,7 @@ public static Density FromCentigramsPerDeciLiter(QuantityValue centigramsperdeci /// If value is NaN or Infinity. public static Density FromCentigramsPerLiter(QuantityValue centigramsperliter) { - double value = (double) centigramsperliter; + QuantityValue value = (QuantityValue) centigramsperliter; return new Density(value, DensityUnit.CentigramPerLiter); } @@ -692,7 +695,7 @@ public static Density FromCentigramsPerLiter(QuantityValue centigramsperliter) /// If value is NaN or Infinity. public static Density FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter) { - double value = (double) centigramspermilliliter; + QuantityValue value = (QuantityValue) centigramspermilliliter; return new Density(value, DensityUnit.CentigramPerMilliliter); } @@ -702,7 +705,7 @@ public static Density FromCentigramsPerMilliliter(QuantityValue centigramspermil /// If value is NaN or Infinity. public static Density FromDecigramsPerDeciLiter(QuantityValue decigramsperdeciliter) { - double value = (double) decigramsperdeciliter; + QuantityValue value = (QuantityValue) decigramsperdeciliter; return new Density(value, DensityUnit.DecigramPerDeciliter); } @@ -712,7 +715,7 @@ public static Density FromDecigramsPerDeciLiter(QuantityValue decigramsperdecili /// If value is NaN or Infinity. public static Density FromDecigramsPerLiter(QuantityValue decigramsperliter) { - double value = (double) decigramsperliter; + QuantityValue value = (QuantityValue) decigramsperliter; return new Density(value, DensityUnit.DecigramPerLiter); } @@ -722,7 +725,7 @@ public static Density FromDecigramsPerLiter(QuantityValue decigramsperliter) /// If value is NaN or Infinity. public static Density FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter) { - double value = (double) decigramspermilliliter; + QuantityValue value = (QuantityValue) decigramspermilliliter; return new Density(value, DensityUnit.DecigramPerMilliliter); } @@ -732,7 +735,7 @@ public static Density FromDecigramsPerMilliliter(QuantityValue decigramspermilli /// If value is NaN or Infinity. public static Density FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter) { - double value = (double) gramspercubiccentimeter; + QuantityValue value = (QuantityValue) gramspercubiccentimeter; return new Density(value, DensityUnit.GramPerCubicCentimeter); } @@ -742,7 +745,7 @@ public static Density FromGramsPerCubicCentimeter(QuantityValue gramspercubiccen /// If value is NaN or Infinity. public static Density FromGramsPerCubicFoot(QuantityValue gramspercubicfoot) { - double value = (double) gramspercubicfoot; + QuantityValue value = (QuantityValue) gramspercubicfoot; return new Density(value, DensityUnit.GramPerCubicFoot); } @@ -752,7 +755,7 @@ public static Density FromGramsPerCubicFoot(QuantityValue gramspercubicfoot) /// If value is NaN or Infinity. public static Density FromGramsPerCubicInch(QuantityValue gramspercubicinch) { - double value = (double) gramspercubicinch; + QuantityValue value = (QuantityValue) gramspercubicinch; return new Density(value, DensityUnit.GramPerCubicInch); } @@ -762,7 +765,7 @@ public static Density FromGramsPerCubicInch(QuantityValue gramspercubicinch) /// If value is NaN or Infinity. public static Density FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) { - double value = (double) gramspercubicmeter; + QuantityValue value = (QuantityValue) gramspercubicmeter; return new Density(value, DensityUnit.GramPerCubicMeter); } @@ -772,7 +775,7 @@ public static Density FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) /// If value is NaN or Infinity. public static Density FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter) { - double value = (double) gramspercubicmillimeter; + QuantityValue value = (QuantityValue) gramspercubicmillimeter; return new Density(value, DensityUnit.GramPerCubicMillimeter); } @@ -782,7 +785,7 @@ public static Density FromGramsPerCubicMillimeter(QuantityValue gramspercubicmil /// If value is NaN or Infinity. public static Density FromGramsPerDeciLiter(QuantityValue gramsperdeciliter) { - double value = (double) gramsperdeciliter; + QuantityValue value = (QuantityValue) gramsperdeciliter; return new Density(value, DensityUnit.GramPerDeciliter); } @@ -792,7 +795,7 @@ public static Density FromGramsPerDeciLiter(QuantityValue gramsperdeciliter) /// If value is NaN or Infinity. public static Density FromGramsPerLiter(QuantityValue gramsperliter) { - double value = (double) gramsperliter; + QuantityValue value = (QuantityValue) gramsperliter; return new Density(value, DensityUnit.GramPerLiter); } @@ -802,7 +805,7 @@ public static Density FromGramsPerLiter(QuantityValue gramsperliter) /// If value is NaN or Infinity. public static Density FromGramsPerMilliliter(QuantityValue gramspermilliliter) { - double value = (double) gramspermilliliter; + QuantityValue value = (QuantityValue) gramspermilliliter; return new Density(value, DensityUnit.GramPerMilliliter); } @@ -812,7 +815,7 @@ public static Density FromGramsPerMilliliter(QuantityValue gramspermilliliter) /// If value is NaN or Infinity. public static Density FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter) { - double value = (double) kilogramspercubiccentimeter; + QuantityValue value = (QuantityValue) kilogramspercubiccentimeter; return new Density(value, DensityUnit.KilogramPerCubicCentimeter); } @@ -822,7 +825,7 @@ public static Density FromKilogramsPerCubicCentimeter(QuantityValue kilogramsper /// If value is NaN or Infinity. public static Density FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter) { - double value = (double) kilogramspercubicmeter; + QuantityValue value = (QuantityValue) kilogramspercubicmeter; return new Density(value, DensityUnit.KilogramPerCubicMeter); } @@ -832,7 +835,7 @@ public static Density FromKilogramsPerCubicMeter(QuantityValue kilogramspercubic /// If value is NaN or Infinity. public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter) { - double value = (double) kilogramspercubicmillimeter; + QuantityValue value = (QuantityValue) kilogramspercubicmillimeter; return new Density(value, DensityUnit.KilogramPerCubicMillimeter); } @@ -842,7 +845,7 @@ public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramsper /// If value is NaN or Infinity. public static Density FromKilogramsPerLiter(QuantityValue kilogramsperliter) { - double value = (double) kilogramsperliter; + QuantityValue value = (QuantityValue) kilogramsperliter; return new Density(value, DensityUnit.KilogramPerLiter); } @@ -852,7 +855,7 @@ public static Density FromKilogramsPerLiter(QuantityValue kilogramsperliter) /// If value is NaN or Infinity. public static Density FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot) { - double value = (double) kilopoundspercubicfoot; + QuantityValue value = (QuantityValue) kilopoundspercubicfoot; return new Density(value, DensityUnit.KilopoundPerCubicFoot); } @@ -862,7 +865,7 @@ public static Density FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubi /// If value is NaN or Infinity. public static Density FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch) { - double value = (double) kilopoundspercubicinch; + QuantityValue value = (QuantityValue) kilopoundspercubicinch; return new Density(value, DensityUnit.KilopoundPerCubicInch); } @@ -872,7 +875,7 @@ public static Density FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubi /// If value is NaN or Infinity. public static Density FromMicrogramsPerCubicMeter(QuantityValue microgramspercubicmeter) { - double value = (double) microgramspercubicmeter; + QuantityValue value = (QuantityValue) microgramspercubicmeter; return new Density(value, DensityUnit.MicrogramPerCubicMeter); } @@ -882,7 +885,7 @@ public static Density FromMicrogramsPerCubicMeter(QuantityValue microgramspercub /// If value is NaN or Infinity. public static Density FromMicrogramsPerDeciLiter(QuantityValue microgramsperdeciliter) { - double value = (double) microgramsperdeciliter; + QuantityValue value = (QuantityValue) microgramsperdeciliter; return new Density(value, DensityUnit.MicrogramPerDeciliter); } @@ -892,7 +895,7 @@ public static Density FromMicrogramsPerDeciLiter(QuantityValue microgramsperdeci /// If value is NaN or Infinity. public static Density FromMicrogramsPerLiter(QuantityValue microgramsperliter) { - double value = (double) microgramsperliter; + QuantityValue value = (QuantityValue) microgramsperliter; return new Density(value, DensityUnit.MicrogramPerLiter); } @@ -902,7 +905,7 @@ public static Density FromMicrogramsPerLiter(QuantityValue microgramsperliter) /// If value is NaN or Infinity. public static Density FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter) { - double value = (double) microgramspermilliliter; + QuantityValue value = (QuantityValue) microgramspermilliliter; return new Density(value, DensityUnit.MicrogramPerMilliliter); } @@ -912,7 +915,7 @@ public static Density FromMicrogramsPerMilliliter(QuantityValue microgramspermil /// If value is NaN or Infinity. public static Density FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter) { - double value = (double) milligramspercubicmeter; + QuantityValue value = (QuantityValue) milligramspercubicmeter; return new Density(value, DensityUnit.MilligramPerCubicMeter); } @@ -922,7 +925,7 @@ public static Density FromMilligramsPerCubicMeter(QuantityValue milligramspercub /// If value is NaN or Infinity. public static Density FromMilligramsPerDeciLiter(QuantityValue milligramsperdeciliter) { - double value = (double) milligramsperdeciliter; + QuantityValue value = (QuantityValue) milligramsperdeciliter; return new Density(value, DensityUnit.MilligramPerDeciliter); } @@ -932,7 +935,7 @@ public static Density FromMilligramsPerDeciLiter(QuantityValue milligramsperdeci /// If value is NaN or Infinity. public static Density FromMilligramsPerLiter(QuantityValue milligramsperliter) { - double value = (double) milligramsperliter; + QuantityValue value = (QuantityValue) milligramsperliter; return new Density(value, DensityUnit.MilligramPerLiter); } @@ -942,7 +945,7 @@ public static Density FromMilligramsPerLiter(QuantityValue milligramsperliter) /// If value is NaN or Infinity. public static Density FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter) { - double value = (double) milligramspermilliliter; + QuantityValue value = (QuantityValue) milligramspermilliliter; return new Density(value, DensityUnit.MilligramPerMilliliter); } @@ -952,7 +955,7 @@ public static Density FromMilligramsPerMilliliter(QuantityValue milligramspermil /// If value is NaN or Infinity. public static Density FromNanogramsPerDeciLiter(QuantityValue nanogramsperdeciliter) { - double value = (double) nanogramsperdeciliter; + QuantityValue value = (QuantityValue) nanogramsperdeciliter; return new Density(value, DensityUnit.NanogramPerDeciliter); } @@ -962,7 +965,7 @@ public static Density FromNanogramsPerDeciLiter(QuantityValue nanogramsperdecili /// If value is NaN or Infinity. public static Density FromNanogramsPerLiter(QuantityValue nanogramsperliter) { - double value = (double) nanogramsperliter; + QuantityValue value = (QuantityValue) nanogramsperliter; return new Density(value, DensityUnit.NanogramPerLiter); } @@ -972,7 +975,7 @@ public static Density FromNanogramsPerLiter(QuantityValue nanogramsperliter) /// If value is NaN or Infinity. public static Density FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter) { - double value = (double) nanogramspermilliliter; + QuantityValue value = (QuantityValue) nanogramspermilliliter; return new Density(value, DensityUnit.NanogramPerMilliliter); } @@ -982,7 +985,7 @@ public static Density FromNanogramsPerMilliliter(QuantityValue nanogramspermilli /// If value is NaN or Infinity. public static Density FromPicogramsPerDeciLiter(QuantityValue picogramsperdeciliter) { - double value = (double) picogramsperdeciliter; + QuantityValue value = (QuantityValue) picogramsperdeciliter; return new Density(value, DensityUnit.PicogramPerDeciliter); } @@ -992,7 +995,7 @@ public static Density FromPicogramsPerDeciLiter(QuantityValue picogramsperdecili /// If value is NaN or Infinity. public static Density FromPicogramsPerLiter(QuantityValue picogramsperliter) { - double value = (double) picogramsperliter; + QuantityValue value = (QuantityValue) picogramsperliter; return new Density(value, DensityUnit.PicogramPerLiter); } @@ -1002,7 +1005,7 @@ public static Density FromPicogramsPerLiter(QuantityValue picogramsperliter) /// If value is NaN or Infinity. public static Density FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter) { - double value = (double) picogramspermilliliter; + QuantityValue value = (QuantityValue) picogramspermilliliter; return new Density(value, DensityUnit.PicogramPerMilliliter); } @@ -1012,7 +1015,7 @@ public static Density FromPicogramsPerMilliliter(QuantityValue picogramspermilli /// If value is NaN or Infinity. public static Density FromPoundsPerCubicCentimeter(QuantityValue poundspercubiccentimeter) { - double value = (double) poundspercubiccentimeter; + QuantityValue value = (QuantityValue) poundspercubiccentimeter; return new Density(value, DensityUnit.PoundPerCubicCentimeter); } @@ -1022,7 +1025,7 @@ public static Density FromPoundsPerCubicCentimeter(QuantityValue poundspercubicc /// If value is NaN or Infinity. public static Density FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) { - double value = (double) poundspercubicfoot; + QuantityValue value = (QuantityValue) poundspercubicfoot; return new Density(value, DensityUnit.PoundPerCubicFoot); } @@ -1032,7 +1035,7 @@ public static Density FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) /// If value is NaN or Infinity. public static Density FromPoundsPerCubicInch(QuantityValue poundspercubicinch) { - double value = (double) poundspercubicinch; + QuantityValue value = (QuantityValue) poundspercubicinch; return new Density(value, DensityUnit.PoundPerCubicInch); } @@ -1042,7 +1045,7 @@ public static Density FromPoundsPerCubicInch(QuantityValue poundspercubicinch) /// If value is NaN or Infinity. public static Density FromPoundsPerCubicMeter(QuantityValue poundspercubicmeter) { - double value = (double) poundspercubicmeter; + QuantityValue value = (QuantityValue) poundspercubicmeter; return new Density(value, DensityUnit.PoundPerCubicMeter); } @@ -1052,7 +1055,7 @@ public static Density FromPoundsPerCubicMeter(QuantityValue poundspercubicmeter) /// If value is NaN or Infinity. public static Density FromPoundsPerCubicMillimeter(QuantityValue poundspercubicmillimeter) { - double value = (double) poundspercubicmillimeter; + QuantityValue value = (QuantityValue) poundspercubicmillimeter; return new Density(value, DensityUnit.PoundPerCubicMillimeter); } @@ -1062,7 +1065,7 @@ public static Density FromPoundsPerCubicMillimeter(QuantityValue poundspercubicm /// If value is NaN or Infinity. public static Density FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon) { - double value = (double) poundsperimperialgallon; + QuantityValue value = (QuantityValue) poundsperimperialgallon; return new Density(value, DensityUnit.PoundPerImperialGallon); } @@ -1072,7 +1075,7 @@ public static Density FromPoundsPerImperialGallon(QuantityValue poundsperimperia /// If value is NaN or Infinity. public static Density FromPoundsPerUSGallon(QuantityValue poundsperusgallon) { - double value = (double) poundsperusgallon; + QuantityValue value = (QuantityValue) poundsperusgallon; return new Density(value, DensityUnit.PoundPerUSGallon); } @@ -1082,7 +1085,7 @@ public static Density FromPoundsPerUSGallon(QuantityValue poundsperusgallon) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicCentimeter(QuantityValue slugspercubiccentimeter) { - double value = (double) slugspercubiccentimeter; + QuantityValue value = (QuantityValue) slugspercubiccentimeter; return new Density(value, DensityUnit.SlugPerCubicCentimeter); } @@ -1092,7 +1095,7 @@ public static Density FromSlugsPerCubicCentimeter(QuantityValue slugspercubiccen /// If value is NaN or Infinity. public static Density FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) { - double value = (double) slugspercubicfoot; + QuantityValue value = (QuantityValue) slugspercubicfoot; return new Density(value, DensityUnit.SlugPerCubicFoot); } @@ -1102,7 +1105,7 @@ public static Density FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicInch(QuantityValue slugspercubicinch) { - double value = (double) slugspercubicinch; + QuantityValue value = (QuantityValue) slugspercubicinch; return new Density(value, DensityUnit.SlugPerCubicInch); } @@ -1112,7 +1115,7 @@ public static Density FromSlugsPerCubicInch(QuantityValue slugspercubicinch) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicMeter(QuantityValue slugspercubicmeter) { - double value = (double) slugspercubicmeter; + QuantityValue value = (QuantityValue) slugspercubicmeter; return new Density(value, DensityUnit.SlugPerCubicMeter); } @@ -1122,7 +1125,7 @@ public static Density FromSlugsPerCubicMeter(QuantityValue slugspercubicmeter) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicMillimeter(QuantityValue slugspercubicmillimeter) { - double value = (double) slugspercubicmillimeter; + QuantityValue value = (QuantityValue) slugspercubicmillimeter; return new Density(value, DensityUnit.SlugPerCubicMillimeter); } @@ -1132,7 +1135,7 @@ public static Density FromSlugsPerCubicMillimeter(QuantityValue slugspercubicmil /// If value is NaN or Infinity. public static Density FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter) { - double value = (double) tonnespercubiccentimeter; + QuantityValue value = (QuantityValue) tonnespercubiccentimeter; return new Density(value, DensityUnit.TonnePerCubicCentimeter); } @@ -1142,7 +1145,7 @@ public static Density FromTonnesPerCubicCentimeter(QuantityValue tonnespercubicc /// If value is NaN or Infinity. public static Density FromTonnesPerCubicFoot(QuantityValue tonnespercubicfoot) { - double value = (double) tonnespercubicfoot; + QuantityValue value = (QuantityValue) tonnespercubicfoot; return new Density(value, DensityUnit.TonnePerCubicFoot); } @@ -1152,7 +1155,7 @@ public static Density FromTonnesPerCubicFoot(QuantityValue tonnespercubicfoot) /// If value is NaN or Infinity. public static Density FromTonnesPerCubicInch(QuantityValue tonnespercubicinch) { - double value = (double) tonnespercubicinch; + QuantityValue value = (QuantityValue) tonnespercubicinch; return new Density(value, DensityUnit.TonnePerCubicInch); } @@ -1162,7 +1165,7 @@ public static Density FromTonnesPerCubicInch(QuantityValue tonnespercubicinch) /// If value is NaN or Infinity. public static Density FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) { - double value = (double) tonnespercubicmeter; + QuantityValue value = (QuantityValue) tonnespercubicmeter; return new Density(value, DensityUnit.TonnePerCubicMeter); } @@ -1172,7 +1175,7 @@ public static Density FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) /// If value is NaN or Infinity. public static Density FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter) { - double value = (double) tonnespercubicmillimeter; + QuantityValue value = (QuantityValue) tonnespercubicmillimeter; return new Density(value, DensityUnit.TonnePerCubicMillimeter); } @@ -1184,7 +1187,7 @@ public static Density FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicm /// Density unit value. public static Density From(QuantityValue value, DensityUnit fromUnit) { - return new Density((double)value, fromUnit); + return new Density((QuantityValue)value, fromUnit); } #endregion @@ -1354,25 +1357,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi } /// Get from multiplying value and . - public static Density operator *(double left, Density right) + public static Density operator *(QuantityValue left, Density right) { return new Density(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Density operator *(Density left, double right) + public static Density operator *(Density left, QuantityValue right) { return new Density(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Density operator /(Density left, double right) + public static Density operator /(Density left, QuantityValue right) { return new Density(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Density left, Density right) + public static QuantityValue operator /(Density left, Density right) { return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; } @@ -1405,6 +1408,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Density left, Density right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Density left, Density right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1417,7 +1433,29 @@ public int CompareTo(object obj) /// public int CompareTo(Density other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Density objDensity)) + return false; + return Equals(objDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Density other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1460,13 +1498,13 @@ public int CompareTo(Density other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Density other, double tolerance, ComparisonType comparisonType) + public bool Equals(Density other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1477,7 +1515,7 @@ public bool Equals(Density other, double tolerance, ComparisonType comparisonTyp /// A hash code for the current Density. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1488,17 +1526,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DensityUnit unit) + public QuantityValue As(DensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1513,12 +1550,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is DensityUnit unitAsDensityUnit)) + if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return As(unitAsDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1550,7 +1587,7 @@ public Density ToUnit(DensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Density)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(DensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1558,17 +1595,17 @@ public Density ToUnit(DensityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DensityUnit unitAsDensityUnit)) + if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1595,10 +1632,10 @@ public Density ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(DensityUnit unit) + private QuantityValue GetValueAs(DensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 31dfb5c9b9..3119b90332 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. /// [DataContract] - public partial struct Duration : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,9 +82,9 @@ static Duration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Duration(double value, DurationUnit unit) + public Duration(QuantityValue value, DurationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -96,14 +96,14 @@ public Duration(double value, DurationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Duration(double value, UnitSystem unitSystem) + public Duration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,7 +144,10 @@ public Duration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -167,59 +170,59 @@ public Duration(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Days => As(DurationUnit.Day); + public QuantityValue Days => As(DurationUnit.Day); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hours => As(DurationUnit.Hour); + public QuantityValue Hours => As(DurationUnit.Hour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JulianYears => As(DurationUnit.JulianYear); + public QuantityValue JulianYears => As(DurationUnit.JulianYear); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microseconds => As(DurationUnit.Microsecond); + public QuantityValue Microseconds => As(DurationUnit.Microsecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliseconds => As(DurationUnit.Millisecond); + public QuantityValue Milliseconds => As(DurationUnit.Millisecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Minutes => As(DurationUnit.Minute); + public QuantityValue Minutes => As(DurationUnit.Minute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Months30 => As(DurationUnit.Month30); + public QuantityValue Months30 => As(DurationUnit.Month30); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanoseconds => As(DurationUnit.Nanosecond); + public QuantityValue Nanoseconds => As(DurationUnit.Nanosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Seconds => As(DurationUnit.Second); + public QuantityValue Seconds => As(DurationUnit.Second); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Weeks => As(DurationUnit.Week); + public QuantityValue Weeks => As(DurationUnit.Week); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Years365 => As(DurationUnit.Year365); + public QuantityValue Years365 => As(DurationUnit.Year365); #endregion @@ -315,7 +318,7 @@ public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static Duration FromDays(QuantityValue days) { - double value = (double) days; + QuantityValue value = (QuantityValue) days; return new Duration(value, DurationUnit.Day); } @@ -325,7 +328,7 @@ public static Duration FromDays(QuantityValue days) /// If value is NaN or Infinity. public static Duration FromHours(QuantityValue hours) { - double value = (double) hours; + QuantityValue value = (QuantityValue) hours; return new Duration(value, DurationUnit.Hour); } @@ -335,7 +338,7 @@ public static Duration FromHours(QuantityValue hours) /// If value is NaN or Infinity. public static Duration FromJulianYears(QuantityValue julianyears) { - double value = (double) julianyears; + QuantityValue value = (QuantityValue) julianyears; return new Duration(value, DurationUnit.JulianYear); } @@ -345,7 +348,7 @@ public static Duration FromJulianYears(QuantityValue julianyears) /// If value is NaN or Infinity. public static Duration FromMicroseconds(QuantityValue microseconds) { - double value = (double) microseconds; + QuantityValue value = (QuantityValue) microseconds; return new Duration(value, DurationUnit.Microsecond); } @@ -355,7 +358,7 @@ public static Duration FromMicroseconds(QuantityValue microseconds) /// If value is NaN or Infinity. public static Duration FromMilliseconds(QuantityValue milliseconds) { - double value = (double) milliseconds; + QuantityValue value = (QuantityValue) milliseconds; return new Duration(value, DurationUnit.Millisecond); } @@ -365,7 +368,7 @@ public static Duration FromMilliseconds(QuantityValue milliseconds) /// If value is NaN or Infinity. public static Duration FromMinutes(QuantityValue minutes) { - double value = (double) minutes; + QuantityValue value = (QuantityValue) minutes; return new Duration(value, DurationUnit.Minute); } @@ -375,7 +378,7 @@ public static Duration FromMinutes(QuantityValue minutes) /// If value is NaN or Infinity. public static Duration FromMonths30(QuantityValue months30) { - double value = (double) months30; + QuantityValue value = (QuantityValue) months30; return new Duration(value, DurationUnit.Month30); } @@ -385,7 +388,7 @@ public static Duration FromMonths30(QuantityValue months30) /// If value is NaN or Infinity. public static Duration FromNanoseconds(QuantityValue nanoseconds) { - double value = (double) nanoseconds; + QuantityValue value = (QuantityValue) nanoseconds; return new Duration(value, DurationUnit.Nanosecond); } @@ -395,7 +398,7 @@ public static Duration FromNanoseconds(QuantityValue nanoseconds) /// If value is NaN or Infinity. public static Duration FromSeconds(QuantityValue seconds) { - double value = (double) seconds; + QuantityValue value = (QuantityValue) seconds; return new Duration(value, DurationUnit.Second); } @@ -405,7 +408,7 @@ public static Duration FromSeconds(QuantityValue seconds) /// If value is NaN or Infinity. public static Duration FromWeeks(QuantityValue weeks) { - double value = (double) weeks; + QuantityValue value = (QuantityValue) weeks; return new Duration(value, DurationUnit.Week); } @@ -415,7 +418,7 @@ public static Duration FromWeeks(QuantityValue weeks) /// If value is NaN or Infinity. public static Duration FromYears365(QuantityValue years365) { - double value = (double) years365; + QuantityValue value = (QuantityValue) years365; return new Duration(value, DurationUnit.Year365); } @@ -427,7 +430,7 @@ public static Duration FromYears365(QuantityValue years365) /// Duration unit value. public static Duration From(QuantityValue value, DurationUnit fromUnit) { - return new Duration((double)value, fromUnit); + return new Duration((QuantityValue)value, fromUnit); } #endregion @@ -597,25 +600,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat } /// Get from multiplying value and . - public static Duration operator *(double left, Duration right) + public static Duration operator *(QuantityValue left, Duration right) { return new Duration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Duration operator *(Duration left, double right) + public static Duration operator *(Duration left, QuantityValue right) { return new Duration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Duration operator /(Duration left, double right) + public static Duration operator /(Duration left, QuantityValue right) { return new Duration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Duration left, Duration right) + public static QuantityValue operator /(Duration left, Duration right) { return left.Seconds / right.Seconds; } @@ -648,6 +651,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Duration left, Duration right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Duration left, Duration right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -660,7 +676,29 @@ public int CompareTo(object obj) /// public int CompareTo(Duration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Duration objDuration)) + return false; + return Equals(objDuration); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Duration other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -703,13 +741,13 @@ public int CompareTo(Duration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Duration other, double tolerance, ComparisonType comparisonType) + public bool Equals(Duration other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -720,7 +758,7 @@ public bool Equals(Duration other, double tolerance, ComparisonType comparisonTy /// A hash code for the current Duration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -731,17 +769,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DurationUnit unit) + public QuantityValue As(DurationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -756,12 +793,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is DurationUnit unitAsDurationUnit)) + if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return As(unitAsDurationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -793,7 +830,7 @@ public Duration ToUnit(DurationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Duration)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(DurationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -801,17 +838,17 @@ public Duration ToUnit(DurationUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DurationUnit unitAsDurationUnit)) + if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDurationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -838,10 +875,10 @@ public Duration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(DurationUnit unit) + private QuantityValue GetValueAs(DurationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index ec17be7043..90cee77932 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity /// [DataContract] - public partial struct DynamicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,9 +84,9 @@ static DynamicViscosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public DynamicViscosity(double value, DynamicViscosityUnit unit) + public DynamicViscosity(QuantityValue value, DynamicViscosityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -98,14 +98,14 @@ public DynamicViscosity(double value, DynamicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public DynamicViscosity(double value, UnitSystem unitSystem) + public DynamicViscosity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -146,7 +146,10 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -169,54 +172,54 @@ public DynamicViscosity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centipoise => As(DynamicViscosityUnit.Centipoise); + public QuantityValue Centipoise => As(DynamicViscosityUnit.Centipoise); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); + public QuantityValue MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); + public QuantityValue MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); + public QuantityValue NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PascalSeconds => As(DynamicViscosityUnit.PascalSecond); + public QuantityValue PascalSeconds => As(DynamicViscosityUnit.PascalSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Poise => As(DynamicViscosityUnit.Poise); + public QuantityValue Poise => As(DynamicViscosityUnit.Poise); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + public QuantityValue PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); + public QuantityValue PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); + public QuantityValue PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Reyns => As(DynamicViscosityUnit.Reyn); + public QuantityValue Reyns => As(DynamicViscosityUnit.Reyn); #endregion @@ -299,7 +302,7 @@ public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static DynamicViscosity FromCentipoise(QuantityValue centipoise) { - double value = (double) centipoise; + QuantityValue value = (QuantityValue) centipoise; return new DynamicViscosity(value, DynamicViscosityUnit.Centipoise); } @@ -309,7 +312,7 @@ public static DynamicViscosity FromCentipoise(QuantityValue centipoise) /// If value is NaN or Infinity. public static DynamicViscosity FromMicropascalSeconds(QuantityValue micropascalseconds) { - double value = (double) micropascalseconds; + QuantityValue value = (QuantityValue) micropascalseconds; return new DynamicViscosity(value, DynamicViscosityUnit.MicropascalSecond); } @@ -319,7 +322,7 @@ public static DynamicViscosity FromMicropascalSeconds(QuantityValue micropascals /// If value is NaN or Infinity. public static DynamicViscosity FromMillipascalSeconds(QuantityValue millipascalseconds) { - double value = (double) millipascalseconds; + QuantityValue value = (QuantityValue) millipascalseconds; return new DynamicViscosity(value, DynamicViscosityUnit.MillipascalSecond); } @@ -329,7 +332,7 @@ public static DynamicViscosity FromMillipascalSeconds(QuantityValue millipascals /// If value is NaN or Infinity. public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue newtonsecondspermetersquared) { - double value = (double) newtonsecondspermetersquared; + QuantityValue value = (QuantityValue) newtonsecondspermetersquared; return new DynamicViscosity(value, DynamicViscosityUnit.NewtonSecondPerMeterSquared); } @@ -339,7 +342,7 @@ public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue ne /// If value is NaN or Infinity. public static DynamicViscosity FromPascalSeconds(QuantityValue pascalseconds) { - double value = (double) pascalseconds; + QuantityValue value = (QuantityValue) pascalseconds; return new DynamicViscosity(value, DynamicViscosityUnit.PascalSecond); } @@ -349,7 +352,7 @@ public static DynamicViscosity FromPascalSeconds(QuantityValue pascalseconds) /// If value is NaN or Infinity. public static DynamicViscosity FromPoise(QuantityValue poise) { - double value = (double) poise; + QuantityValue value = (QuantityValue) poise; return new DynamicViscosity(value, DynamicViscosityUnit.Poise); } @@ -359,7 +362,7 @@ public static DynamicViscosity FromPoise(QuantityValue poise) /// If value is NaN or Infinity. public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(QuantityValue poundsforcesecondpersquarefoot) { - double value = (double) poundsforcesecondpersquarefoot; + QuantityValue value = (QuantityValue) poundsforcesecondpersquarefoot; return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); } @@ -369,7 +372,7 @@ public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(QuantityValue /// If value is NaN or Infinity. public static DynamicViscosity FromPoundsForceSecondPerSquareInch(QuantityValue poundsforcesecondpersquareinch) { - double value = (double) poundsforcesecondpersquareinch; + QuantityValue value = (QuantityValue) poundsforcesecondpersquareinch; return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareInch); } @@ -379,7 +382,7 @@ public static DynamicViscosity FromPoundsForceSecondPerSquareInch(QuantityValue /// If value is NaN or Infinity. public static DynamicViscosity FromPoundsPerFootSecond(QuantityValue poundsperfootsecond) { - double value = (double) poundsperfootsecond; + QuantityValue value = (QuantityValue) poundsperfootsecond; return new DynamicViscosity(value, DynamicViscosityUnit.PoundPerFootSecond); } @@ -389,7 +392,7 @@ public static DynamicViscosity FromPoundsPerFootSecond(QuantityValue poundsperfo /// If value is NaN or Infinity. public static DynamicViscosity FromReyns(QuantityValue reyns) { - double value = (double) reyns; + QuantityValue value = (QuantityValue) reyns; return new DynamicViscosity(value, DynamicViscosityUnit.Reyn); } @@ -401,7 +404,7 @@ public static DynamicViscosity FromReyns(QuantityValue reyns) /// DynamicViscosity unit value. public static DynamicViscosity From(QuantityValue value, DynamicViscosityUnit fromUnit) { - return new DynamicViscosity((double)value, fromUnit); + return new DynamicViscosity((QuantityValue)value, fromUnit); } #endregion @@ -571,25 +574,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam } /// Get from multiplying value and . - public static DynamicViscosity operator *(double left, DynamicViscosity right) + public static DynamicViscosity operator *(QuantityValue left, DynamicViscosity right) { return new DynamicViscosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static DynamicViscosity operator *(DynamicViscosity left, double right) + public static DynamicViscosity operator *(DynamicViscosity left, QuantityValue right) { return new DynamicViscosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static DynamicViscosity operator /(DynamicViscosity left, double right) + public static DynamicViscosity operator /(DynamicViscosity left, QuantityValue right) { return new DynamicViscosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(DynamicViscosity left, DynamicViscosity right) + public static QuantityValue operator /(DynamicViscosity left, DynamicViscosity right) { return left.NewtonSecondsPerMeterSquared / right.NewtonSecondsPerMeterSquared; } @@ -622,6 +625,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(DynamicViscosity left, DynamicViscosity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(DynamicViscosity left, DynamicViscosity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -634,7 +650,29 @@ public int CompareTo(object obj) /// public int CompareTo(DynamicViscosity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is DynamicViscosity objDynamicViscosity)) + return false; + return Equals(objDynamicViscosity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(DynamicViscosity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -677,13 +715,13 @@ public int CompareTo(DynamicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType) + public bool Equals(DynamicViscosity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -694,7 +732,7 @@ public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comp /// A hash code for the current DynamicViscosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -705,17 +743,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(DynamicViscosityUnit unit) + public QuantityValue As(DynamicViscosityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -730,12 +767,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) + if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsDynamicViscosityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -767,7 +804,7 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (DynamicViscosity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(DynamicViscosityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -775,17 +812,17 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit, UnitConverter unitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) + if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDynamicViscosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -812,10 +849,10 @@ public DynamicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(DynamicViscosityUnit unit) + private QuantityValue GetValueAs(DynamicViscosityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 5f6f688ac8..5cab50ab8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). /// [DataContract] - public partial struct ElectricAdmittance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricAdmittance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) + public ElectricAdmittance(QuantityValue value, ElectricAdmittanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricAdmittance(double value, UnitSystem unitSystem) + public ElectricAdmittance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); + public QuantityValue Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); + public QuantityValue Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); + public QuantityValue Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Siemens => As(ElectricAdmittanceUnit.Siemens); + public QuantityValue Siemens => As(ElectricAdmittanceUnit.Siemens); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvide /// If value is NaN or Infinity. public static ElectricAdmittance FromMicrosiemens(QuantityValue microsiemens) { - double value = (double) microsiemens; + QuantityValue value = (QuantityValue) microsiemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Microsiemens); } @@ -252,7 +255,7 @@ public static ElectricAdmittance FromMicrosiemens(QuantityValue microsiemens) /// If value is NaN or Infinity. public static ElectricAdmittance FromMillisiemens(QuantityValue millisiemens) { - double value = (double) millisiemens; + QuantityValue value = (QuantityValue) millisiemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Millisiemens); } @@ -262,7 +265,7 @@ public static ElectricAdmittance FromMillisiemens(QuantityValue millisiemens) /// If value is NaN or Infinity. public static ElectricAdmittance FromNanosiemens(QuantityValue nanosiemens) { - double value = (double) nanosiemens; + QuantityValue value = (QuantityValue) nanosiemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Nanosiemens); } @@ -272,7 +275,7 @@ public static ElectricAdmittance FromNanosiemens(QuantityValue nanosiemens) /// If value is NaN or Infinity. public static ElectricAdmittance FromSiemens(QuantityValue siemens) { - double value = (double) siemens; + QuantityValue value = (QuantityValue) siemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Siemens); } @@ -284,7 +287,7 @@ public static ElectricAdmittance FromSiemens(QuantityValue siemens) /// ElectricAdmittance unit value. public static ElectricAdmittance From(QuantityValue value, ElectricAdmittanceUnit fromUnit) { - return new ElectricAdmittance((double)value, fromUnit); + return new ElectricAdmittance((QuantityValue)value, fromUnit); } #endregion @@ -454,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricAdmittance operator *(double left, ElectricAdmittance right) + public static ElectricAdmittance operator *(QuantityValue left, ElectricAdmittance right) { return new ElectricAdmittance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricAdmittance operator *(ElectricAdmittance left, double right) + public static ElectricAdmittance operator *(ElectricAdmittance left, QuantityValue right) { return new ElectricAdmittance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricAdmittance operator /(ElectricAdmittance left, double right) + public static ElectricAdmittance operator /(ElectricAdmittance left, QuantityValue right) { return new ElectricAdmittance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricAdmittance left, ElectricAdmittance right) + public static QuantityValue operator /(ElectricAdmittance left, ElectricAdmittance right) { return left.Siemens / right.Siemens; } @@ -505,6 +508,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -517,7 +533,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricAdmittance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) + return false; + return Equals(objElectricAdmittance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricAdmittance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -560,13 +598,13 @@ public int CompareTo(ElectricAdmittance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricAdmittance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +615,7 @@ public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType co /// A hash code for the current ElectricAdmittance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -588,17 +626,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricAdmittanceUnit unit) + public QuantityValue As(ElectricAdmittanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,12 +650,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) + if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricAdmittanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -650,7 +687,7 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit, UnitConverter unit var converted = conversionFunction(this); return (ElectricAdmittance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricAdmittanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -658,17 +695,17 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) + if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricAdmittanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -695,10 +732,10 @@ public ElectricAdmittance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricAdmittanceUnit unit) + private QuantityValue GetValueAs(ElectricAdmittanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index efdcf152cd..088da970dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_charge /// [DataContract] - public partial struct ElectricCharge : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,9 +79,9 @@ static ElectricCharge() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCharge(double value, ElectricChargeUnit unit) + public ElectricCharge(QuantityValue value, ElectricChargeUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -93,14 +93,14 @@ public ElectricCharge(double value, ElectricChargeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCharge(double value, UnitSystem unitSystem) + public ElectricCharge(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -141,7 +141,10 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -164,29 +167,29 @@ public ElectricCharge(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmpereHours => As(ElectricChargeUnit.AmpereHour); + public QuantityValue AmpereHours => As(ElectricChargeUnit.AmpereHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Coulombs => As(ElectricChargeUnit.Coulomb); + public QuantityValue Coulombs => As(ElectricChargeUnit.Coulomb); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KiloampereHours => As(ElectricChargeUnit.KiloampereHour); + public QuantityValue KiloampereHours => As(ElectricChargeUnit.KiloampereHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); + public QuantityValue MegaampereHours => As(ElectricChargeUnit.MegaampereHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliampereHours => As(ElectricChargeUnit.MilliampereHour); + public QuantityValue MilliampereHours => As(ElectricChargeUnit.MilliampereHour); #endregion @@ -254,7 +257,7 @@ public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ElectricCharge FromAmpereHours(QuantityValue amperehours) { - double value = (double) amperehours; + QuantityValue value = (QuantityValue) amperehours; return new ElectricCharge(value, ElectricChargeUnit.AmpereHour); } @@ -264,7 +267,7 @@ public static ElectricCharge FromAmpereHours(QuantityValue amperehours) /// If value is NaN or Infinity. public static ElectricCharge FromCoulombs(QuantityValue coulombs) { - double value = (double) coulombs; + QuantityValue value = (QuantityValue) coulombs; return new ElectricCharge(value, ElectricChargeUnit.Coulomb); } @@ -274,7 +277,7 @@ public static ElectricCharge FromCoulombs(QuantityValue coulombs) /// If value is NaN or Infinity. public static ElectricCharge FromKiloampereHours(QuantityValue kiloamperehours) { - double value = (double) kiloamperehours; + QuantityValue value = (QuantityValue) kiloamperehours; return new ElectricCharge(value, ElectricChargeUnit.KiloampereHour); } @@ -284,7 +287,7 @@ public static ElectricCharge FromKiloampereHours(QuantityValue kiloamperehours) /// If value is NaN or Infinity. public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) { - double value = (double) megaamperehours; + QuantityValue value = (QuantityValue) megaamperehours; return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); } @@ -294,7 +297,7 @@ public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) /// If value is NaN or Infinity. public static ElectricCharge FromMilliampereHours(QuantityValue milliamperehours) { - double value = (double) milliamperehours; + QuantityValue value = (QuantityValue) milliamperehours; return new ElectricCharge(value, ElectricChargeUnit.MilliampereHour); } @@ -306,7 +309,7 @@ public static ElectricCharge FromMilliampereHours(QuantityValue milliamperehours /// ElectricCharge unit value. public static ElectricCharge From(QuantityValue value, ElectricChargeUnit fromUnit) { - return new ElectricCharge((double)value, fromUnit); + return new ElectricCharge((QuantityValue)value, fromUnit); } #endregion @@ -476,25 +479,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCharge operator *(double left, ElectricCharge right) + public static ElectricCharge operator *(QuantityValue left, ElectricCharge right) { return new ElectricCharge(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCharge operator *(ElectricCharge left, double right) + public static ElectricCharge operator *(ElectricCharge left, QuantityValue right) { return new ElectricCharge(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCharge operator /(ElectricCharge left, double right) + public static ElectricCharge operator /(ElectricCharge left, QuantityValue right) { return new ElectricCharge(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCharge left, ElectricCharge right) + public static QuantityValue operator /(ElectricCharge left, ElectricCharge right) { return left.Coulombs / right.Coulombs; } @@ -527,6 +530,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCharge left, ElectricCharge right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCharge left, ElectricCharge right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -539,7 +555,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCharge other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricCharge objElectricCharge)) + return false; + return Equals(objElectricCharge); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCharge other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -582,13 +620,13 @@ public int CompareTo(ElectricCharge other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCharge other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -599,7 +637,7 @@ public bool Equals(ElectricCharge other, double tolerance, ComparisonType compar /// A hash code for the current ElectricCharge. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -610,17 +648,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeUnit unit) + public QuantityValue As(ElectricChargeUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -635,12 +672,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) + if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeUnit); + return (QuantityValue)As(typedUnit); } /// @@ -672,7 +709,7 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ElectricCharge)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricChargeUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -680,17 +717,17 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) + if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricChargeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -717,10 +754,10 @@ public ElectricCharge ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricChargeUnit unit) + private QuantityValue GetValueAs(ElectricChargeUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 4538e7e215..470af68bd9 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricChargeDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) + public ElectricChargeDensity(QuantityValue value, ElectricChargeDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricChargeDensity(double value, UnitSystem unitSystem) + public ElectricChargeDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); + public QuantityValue CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProv /// If value is NaN or Infinity. public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue coulombspercubicmeter) { - double value = (double) coulombspercubicmeter; + QuantityValue value = (QuantityValue) coulombspercubicmeter; return new ElectricChargeDensity(value, ElectricChargeDensityUnit.CoulombPerCubicMeter); } @@ -230,7 +233,7 @@ public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue coul /// ElectricChargeDensity unit value. public static ElectricChargeDensity From(QuantityValue value, ElectricChargeDensityUnit fromUnit) { - return new ElectricChargeDensity((double)value, fromUnit); + return new ElectricChargeDensity((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricChargeDensity operator *(double left, ElectricChargeDensity right) + public static ElectricChargeDensity operator *(QuantityValue left, ElectricChargeDensity right) { return new ElectricChargeDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricChargeDensity operator *(ElectricChargeDensity left, double right) + public static ElectricChargeDensity operator *(ElectricChargeDensity left, QuantityValue right) { return new ElectricChargeDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricChargeDensity operator /(ElectricChargeDensity left, double right) + public static ElectricChargeDensity operator /(ElectricChargeDensity left, QuantityValue right) { return new ElectricChargeDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricChargeDensity left, ElectricChargeDensity right) + public static QuantityValue operator /(ElectricChargeDensity left, ElectricChargeDensity right) { return left.CoulombsPerCubicMeter / right.CoulombsPerCubicMeter; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricChargeDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) + return false; + return Equals(objElectricChargeDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricChargeDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(ElectricChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricChargeDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType /// A hash code for the current ElectricChargeDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricChargeDensityUnit unit) + public QuantityValue As(ElectricChargeDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) + if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit, UnitConverte var converted = conversionFunction(this); return (ElectricChargeDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricChargeDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit, UnitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) + if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricChargeDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public ElectricChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricChargeDensityUnit unit) + private QuantityValue GetValueAs(ElectricChargeDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index f9f766a99d..885748e77b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance /// [DataContract] - public partial struct ElectricConductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricConductance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricConductance(double value, ElectricConductanceUnit unit) + public ElectricConductance(QuantityValue value, ElectricConductanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public ElectricConductance(double value, ElectricConductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductance(double value, UnitSystem unitSystem) + public ElectricConductance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +165,19 @@ public ElectricConductance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microsiemens => As(ElectricConductanceUnit.Microsiemens); + public QuantityValue Microsiemens => As(ElectricConductanceUnit.Microsiemens); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millisiemens => As(ElectricConductanceUnit.Millisiemens); + public QuantityValue Millisiemens => As(ElectricConductanceUnit.Millisiemens); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Siemens => As(ElectricConductanceUnit.Siemens); + public QuantityValue Siemens => As(ElectricConductanceUnit.Siemens); #endregion @@ -236,7 +239,7 @@ public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricConductance FromMicrosiemens(QuantityValue microsiemens) { - double value = (double) microsiemens; + QuantityValue value = (QuantityValue) microsiemens; return new ElectricConductance(value, ElectricConductanceUnit.Microsiemens); } @@ -246,7 +249,7 @@ public static ElectricConductance FromMicrosiemens(QuantityValue microsiemens) /// If value is NaN or Infinity. public static ElectricConductance FromMillisiemens(QuantityValue millisiemens) { - double value = (double) millisiemens; + QuantityValue value = (QuantityValue) millisiemens; return new ElectricConductance(value, ElectricConductanceUnit.Millisiemens); } @@ -256,7 +259,7 @@ public static ElectricConductance FromMillisiemens(QuantityValue millisiemens) /// If value is NaN or Infinity. public static ElectricConductance FromSiemens(QuantityValue siemens) { - double value = (double) siemens; + QuantityValue value = (QuantityValue) siemens; return new ElectricConductance(value, ElectricConductanceUnit.Siemens); } @@ -268,7 +271,7 @@ public static ElectricConductance FromSiemens(QuantityValue siemens) /// ElectricConductance unit value. public static ElectricConductance From(QuantityValue value, ElectricConductanceUnit fromUnit) { - return new ElectricConductance((double)value, fromUnit); + return new ElectricConductance((QuantityValue)value, fromUnit); } #endregion @@ -438,25 +441,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricConductance operator *(double left, ElectricConductance right) + public static ElectricConductance operator *(QuantityValue left, ElectricConductance right) { return new ElectricConductance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricConductance operator *(ElectricConductance left, double right) + public static ElectricConductance operator *(ElectricConductance left, QuantityValue right) { return new ElectricConductance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricConductance operator /(ElectricConductance left, double right) + public static ElectricConductance operator /(ElectricConductance left, QuantityValue right) { return new ElectricConductance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricConductance left, ElectricConductance right) + public static QuantityValue operator /(ElectricConductance left, ElectricConductance right) { return left.Siemens / right.Siemens; } @@ -489,6 +492,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricConductance left, ElectricConductance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricConductance left, ElectricConductance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -501,7 +517,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricConductance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricConductance objElectricConductance)) + return false; + return Equals(objElectricConductance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricConductance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -544,13 +582,13 @@ public int CompareTo(ElectricConductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricConductance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +599,7 @@ public bool Equals(ElectricConductance other, double tolerance, ComparisonType c /// A hash code for the current ElectricConductance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -572,17 +610,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductanceUnit unit) + public QuantityValue As(ElectricConductanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -597,12 +634,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) + if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -634,7 +671,7 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricConductance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricConductanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -642,17 +679,17 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) + if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricConductanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -679,10 +716,10 @@ public ElectricConductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricConductanceUnit unit) + private QuantityValue GetValueAs(ElectricConductanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 8b7f49777a..50efdddf94 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricConductivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricConductivity(double value, ElectricConductivityUnit unit) + public ElectricConductivity(QuantityValue value, ElectricConductivityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public ElectricConductivity(double value, ElectricConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductivity(double value, UnitSystem unitSystem) + public ElectricConductivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +165,19 @@ public ElectricConductivity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); + public QuantityValue SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); + public QuantityValue SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); + public QuantityValue SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); #endregion @@ -236,7 +239,7 @@ public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvi /// If value is NaN or Infinity. public static ElectricConductivity FromSiemensPerFoot(QuantityValue siemensperfoot) { - double value = (double) siemensperfoot; + QuantityValue value = (QuantityValue) siemensperfoot; return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerFoot); } @@ -246,7 +249,7 @@ public static ElectricConductivity FromSiemensPerFoot(QuantityValue siemensperfo /// If value is NaN or Infinity. public static ElectricConductivity FromSiemensPerInch(QuantityValue siemensperinch) { - double value = (double) siemensperinch; + QuantityValue value = (QuantityValue) siemensperinch; return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerInch); } @@ -256,7 +259,7 @@ public static ElectricConductivity FromSiemensPerInch(QuantityValue siemensperin /// If value is NaN or Infinity. public static ElectricConductivity FromSiemensPerMeter(QuantityValue siemenspermeter) { - double value = (double) siemenspermeter; + QuantityValue value = (QuantityValue) siemenspermeter; return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerMeter); } @@ -268,7 +271,7 @@ public static ElectricConductivity FromSiemensPerMeter(QuantityValue siemensperm /// ElectricConductivity unit value. public static ElectricConductivity From(QuantityValue value, ElectricConductivityUnit fromUnit) { - return new ElectricConductivity((double)value, fromUnit); + return new ElectricConductivity((QuantityValue)value, fromUnit); } #endregion @@ -438,25 +441,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricConductivity operator *(double left, ElectricConductivity right) + public static ElectricConductivity operator *(QuantityValue left, ElectricConductivity right) { return new ElectricConductivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricConductivity operator *(ElectricConductivity left, double right) + public static ElectricConductivity operator *(ElectricConductivity left, QuantityValue right) { return new ElectricConductivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricConductivity operator /(ElectricConductivity left, double right) + public static ElectricConductivity operator /(ElectricConductivity left, QuantityValue right) { return new ElectricConductivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricConductivity left, ElectricConductivity right) + public static QuantityValue operator /(ElectricConductivity left, ElectricConductivity right) { return left.SiemensPerMeter / right.SiemensPerMeter; } @@ -489,6 +492,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricConductivity left, ElectricConductivity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricConductivity left, ElectricConductivity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -501,7 +517,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricConductivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricConductivity objElectricConductivity)) + return false; + return Equals(objElectricConductivity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricConductivity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -544,13 +582,13 @@ public int CompareTo(ElectricConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricConductivity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +599,7 @@ public bool Equals(ElectricConductivity other, double tolerance, ComparisonType /// A hash code for the current ElectricConductivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -572,17 +610,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricConductivityUnit unit) + public QuantityValue As(ElectricConductivityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -597,12 +634,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) + if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductivityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -634,7 +671,7 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit, UnitConverter var converted = conversionFunction(this); return (ElectricConductivity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricConductivityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -642,17 +679,17 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit, UnitConverter } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) + if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricConductivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -679,10 +716,10 @@ public ElectricConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricConductivityUnit unit) + private QuantityValue GetValueAs(ElectricConductivityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 0485881539..a370f87e7e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. /// [DataContract] - public partial struct ElectricCurrent : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,9 +79,9 @@ static ElectricCurrent() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrent(double value, ElectricCurrentUnit unit) + public ElectricCurrent(QuantityValue value, ElectricCurrentUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -93,14 +93,14 @@ public ElectricCurrent(double value, ElectricCurrentUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrent(double value, UnitSystem unitSystem) + public ElectricCurrent(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -141,7 +141,10 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -164,44 +167,44 @@ public ElectricCurrent(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Amperes => As(ElectricCurrentUnit.Ampere); + public QuantityValue Amperes => As(ElectricCurrentUnit.Ampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centiamperes => As(ElectricCurrentUnit.Centiampere); + public QuantityValue Centiamperes => As(ElectricCurrentUnit.Centiampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kiloamperes => As(ElectricCurrentUnit.Kiloampere); + public QuantityValue Kiloamperes => As(ElectricCurrentUnit.Kiloampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megaamperes => As(ElectricCurrentUnit.Megaampere); + public QuantityValue Megaamperes => As(ElectricCurrentUnit.Megaampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microamperes => As(ElectricCurrentUnit.Microampere); + public QuantityValue Microamperes => As(ElectricCurrentUnit.Microampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliamperes => As(ElectricCurrentUnit.Milliampere); + public QuantityValue Milliamperes => As(ElectricCurrentUnit.Milliampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanoamperes => As(ElectricCurrentUnit.Nanoampere); + public QuantityValue Nanoamperes => As(ElectricCurrentUnit.Nanoampere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Picoamperes => As(ElectricCurrentUnit.Picoampere); + public QuantityValue Picoamperes => As(ElectricCurrentUnit.Picoampere); #endregion @@ -278,7 +281,7 @@ public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static ElectricCurrent FromAmperes(QuantityValue amperes) { - double value = (double) amperes; + QuantityValue value = (QuantityValue) amperes; return new ElectricCurrent(value, ElectricCurrentUnit.Ampere); } @@ -288,7 +291,7 @@ public static ElectricCurrent FromAmperes(QuantityValue amperes) /// If value is NaN or Infinity. public static ElectricCurrent FromCentiamperes(QuantityValue centiamperes) { - double value = (double) centiamperes; + QuantityValue value = (QuantityValue) centiamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Centiampere); } @@ -298,7 +301,7 @@ public static ElectricCurrent FromCentiamperes(QuantityValue centiamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromKiloamperes(QuantityValue kiloamperes) { - double value = (double) kiloamperes; + QuantityValue value = (QuantityValue) kiloamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Kiloampere); } @@ -308,7 +311,7 @@ public static ElectricCurrent FromKiloamperes(QuantityValue kiloamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromMegaamperes(QuantityValue megaamperes) { - double value = (double) megaamperes; + QuantityValue value = (QuantityValue) megaamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Megaampere); } @@ -318,7 +321,7 @@ public static ElectricCurrent FromMegaamperes(QuantityValue megaamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromMicroamperes(QuantityValue microamperes) { - double value = (double) microamperes; + QuantityValue value = (QuantityValue) microamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Microampere); } @@ -328,7 +331,7 @@ public static ElectricCurrent FromMicroamperes(QuantityValue microamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromMilliamperes(QuantityValue milliamperes) { - double value = (double) milliamperes; + QuantityValue value = (QuantityValue) milliamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Milliampere); } @@ -338,7 +341,7 @@ public static ElectricCurrent FromMilliamperes(QuantityValue milliamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromNanoamperes(QuantityValue nanoamperes) { - double value = (double) nanoamperes; + QuantityValue value = (QuantityValue) nanoamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Nanoampere); } @@ -348,7 +351,7 @@ public static ElectricCurrent FromNanoamperes(QuantityValue nanoamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromPicoamperes(QuantityValue picoamperes) { - double value = (double) picoamperes; + QuantityValue value = (QuantityValue) picoamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Picoampere); } @@ -360,7 +363,7 @@ public static ElectricCurrent FromPicoamperes(QuantityValue picoamperes) /// ElectricCurrent unit value. public static ElectricCurrent From(QuantityValue value, ElectricCurrentUnit fromUnit) { - return new ElectricCurrent((double)value, fromUnit); + return new ElectricCurrent((QuantityValue)value, fromUnit); } #endregion @@ -530,25 +533,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrent operator *(double left, ElectricCurrent right) + public static ElectricCurrent operator *(QuantityValue left, ElectricCurrent right) { return new ElectricCurrent(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrent operator *(ElectricCurrent left, double right) + public static ElectricCurrent operator *(ElectricCurrent left, QuantityValue right) { return new ElectricCurrent(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrent operator /(ElectricCurrent left, double right) + public static ElectricCurrent operator /(ElectricCurrent left, QuantityValue right) { return new ElectricCurrent(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCurrent left, ElectricCurrent right) + public static QuantityValue operator /(ElectricCurrent left, ElectricCurrent right) { return left.Amperes / right.Amperes; } @@ -581,6 +584,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCurrent left, ElectricCurrent right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCurrent left, ElectricCurrent right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -593,7 +609,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCurrent other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricCurrent objElectricCurrent)) + return false; + return Equals(objElectricCurrent); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCurrent other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -636,13 +674,13 @@ public int CompareTo(ElectricCurrent other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrent other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -653,7 +691,7 @@ public bool Equals(ElectricCurrent other, double tolerance, ComparisonType compa /// A hash code for the current ElectricCurrent. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -664,17 +702,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentUnit unit) + public QuantityValue As(ElectricCurrentUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -689,12 +726,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) + if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentUnit); + return (QuantityValue)As(typedUnit); } /// @@ -726,7 +763,7 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (ElectricCurrent)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricCurrentUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -734,17 +771,17 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) + if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -771,10 +808,10 @@ public ElectricCurrent ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricCurrentUnit unit) + private QuantityValue GetValueAs(ElectricCurrentUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 8a8989cb79..52214a6462 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Current_density /// [DataContract] - public partial struct ElectricCurrentDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricCurrentDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) + public ElectricCurrentDensity(QuantityValue value, ElectricCurrentDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentDensity(double value, UnitSystem unitSystem) + public ElectricCurrentDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +165,19 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); + public QuantityValue AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); + public QuantityValue AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); + public QuantityValue AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); #endregion @@ -236,7 +239,7 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatPro /// If value is NaN or Infinity. public static ElectricCurrentDensity FromAmperesPerSquareFoot(QuantityValue amperespersquarefoot) { - double value = (double) amperespersquarefoot; + QuantityValue value = (QuantityValue) amperespersquarefoot; return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareFoot); } @@ -246,7 +249,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareFoot(QuantityValue ampe /// If value is NaN or Infinity. public static ElectricCurrentDensity FromAmperesPerSquareInch(QuantityValue amperespersquareinch) { - double value = (double) amperespersquareinch; + QuantityValue value = (QuantityValue) amperespersquareinch; return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareInch); } @@ -256,7 +259,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareInch(QuantityValue ampe /// If value is NaN or Infinity. public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue amperespersquaremeter) { - double value = (double) amperespersquaremeter; + QuantityValue value = (QuantityValue) amperespersquaremeter; return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareMeter); } @@ -268,7 +271,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue amp /// ElectricCurrentDensity unit value. public static ElectricCurrentDensity From(QuantityValue value, ElectricCurrentDensityUnit fromUnit) { - return new ElectricCurrentDensity((double)value, fromUnit); + return new ElectricCurrentDensity((QuantityValue)value, fromUnit); } #endregion @@ -438,25 +441,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(double left, ElectricCurrentDensity right) + public static ElectricCurrentDensity operator *(QuantityValue left, ElectricCurrentDensity right) { return new ElectricCurrentDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, double right) + public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, QuantityValue right) { return new ElectricCurrentDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, double right) + public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, QuantityValue right) { return new ElectricCurrentDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static QuantityValue operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.AmperesPerSquareMeter / right.AmperesPerSquareMeter; } @@ -489,6 +492,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -501,7 +517,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCurrentDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) + return false; + return Equals(objElectricCurrentDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCurrentDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -544,13 +582,13 @@ public int CompareTo(ElectricCurrentDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrentDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +599,7 @@ public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonTyp /// A hash code for the current ElectricCurrentDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -572,17 +610,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentDensityUnit unit) + public QuantityValue As(ElectricCurrentDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -597,12 +634,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) + if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -634,7 +671,7 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit, UnitConver var converted = conversionFunction(this); return (ElectricCurrentDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricCurrentDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -642,17 +679,17 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit, UnitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) + if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -679,10 +716,10 @@ public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricCurrentDensityUnit unit) + private QuantityValue GetValueAs(ElectricCurrentDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index c5b8587e27..7f2103c3e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In electromagnetism, the current gradient describes how the current changes in time. /// [DataContract] - public partial struct ElectricCurrentGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricCurrentGradient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) + public ElectricCurrentGradient(QuantityValue value, ElectricCurrentGradientUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentGradient(double value, UnitSystem unitSystem) + public ElectricCurrentGradient(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); + public QuantityValue AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); + public QuantityValue AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); + public QuantityValue AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); + public QuantityValue AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatPr /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerMicrosecond(QuantityValue amperespermicrosecond) { - double value = (double) amperespermicrosecond; + QuantityValue value = (QuantityValue) amperespermicrosecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMicrosecond); } @@ -252,7 +255,7 @@ public static ElectricCurrentGradient FromAmperesPerMicrosecond(QuantityValue am /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerMillisecond(QuantityValue amperespermillisecond) { - double value = (double) amperespermillisecond; + QuantityValue value = (QuantityValue) amperespermillisecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMillisecond); } @@ -262,7 +265,7 @@ public static ElectricCurrentGradient FromAmperesPerMillisecond(QuantityValue am /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerNanosecond(QuantityValue amperespernanosecond) { - double value = (double) amperespernanosecond; + QuantityValue value = (QuantityValue) amperespernanosecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerNanosecond); } @@ -272,7 +275,7 @@ public static ElectricCurrentGradient FromAmperesPerNanosecond(QuantityValue amp /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue amperespersecond) { - double value = (double) amperespersecond; + QuantityValue value = (QuantityValue) amperespersecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerSecond); } @@ -284,7 +287,7 @@ public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue amperes /// ElectricCurrentGradient unit value. public static ElectricCurrentGradient From(QuantityValue value, ElectricCurrentGradientUnit fromUnit) { - return new ElectricCurrentGradient((double)value, fromUnit); + return new ElectricCurrentGradient((QuantityValue)value, fromUnit); } #endregion @@ -454,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(double left, ElectricCurrentGradient right) + public static ElectricCurrentGradient operator *(QuantityValue left, ElectricCurrentGradient right) { return new ElectricCurrentGradient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, double right) + public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, QuantityValue right) { return new ElectricCurrentGradient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, double right) + public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, QuantityValue right) { return new ElectricCurrentGradient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static QuantityValue operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.AmperesPerSecond / right.AmperesPerSecond; } @@ -505,6 +508,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -517,7 +533,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCurrentGradient other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) + return false; + return Equals(objElectricCurrentGradient); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricCurrentGradient other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -560,13 +598,13 @@ public int CompareTo(ElectricCurrentGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrentGradient other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +615,7 @@ public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonTy /// A hash code for the current ElectricCurrentGradient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -588,17 +626,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricCurrentGradientUnit unit) + public QuantityValue As(ElectricCurrentGradientUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,12 +650,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) + if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentGradientUnit); + return (QuantityValue)As(typedUnit); } /// @@ -650,7 +687,7 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit, UnitConv var converted = conversionFunction(this); return (ElectricCurrentGradient)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricCurrentGradientUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -658,17 +695,17 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit, UnitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) + if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentGradientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -695,10 +732,10 @@ public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricCurrentGradientUnit unit) + private QuantityValue GetValueAs(ElectricCurrentGradientUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index d49e4be72a..29e68a9570 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_field /// [DataContract] - public partial struct ElectricField : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricField() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricField(double value, ElectricFieldUnit unit) + public ElectricField(QuantityValue value, ElectricFieldUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public ElectricField(double value, ElectricFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricField(double value, UnitSystem unitSystem) + public ElectricField(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public ElectricField(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public ElectricField(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); + public QuantityValue VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static ElectricField FromVoltsPerMeter(QuantityValue voltspermeter) { - double value = (double) voltspermeter; + QuantityValue value = (QuantityValue) voltspermeter; return new ElectricField(value, ElectricFieldUnit.VoltPerMeter); } @@ -230,7 +233,7 @@ public static ElectricField FromVoltsPerMeter(QuantityValue voltspermeter) /// ElectricField unit value. public static ElectricField From(QuantityValue value, ElectricFieldUnit fromUnit) { - return new ElectricField((double)value, fromUnit); + return new ElectricField((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricField operator *(double left, ElectricField right) + public static ElectricField operator *(QuantityValue left, ElectricField right) { return new ElectricField(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricField operator *(ElectricField left, double right) + public static ElectricField operator *(ElectricField left, QuantityValue right) { return new ElectricField(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricField operator /(ElectricField left, double right) + public static ElectricField operator /(ElectricField left, QuantityValue right) { return new ElectricField(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricField left, ElectricField right) + public static QuantityValue operator /(ElectricField left, ElectricField right) { return left.VoltsPerMeter / right.VoltsPerMeter; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricField left, ElectricField right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricField left, ElectricField right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricField other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricField objElectricField)) + return false; + return Equals(objElectricField); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricField other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(ElectricField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricField other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(ElectricField other, double tolerance, ComparisonType compari /// A hash code for the current ElectricField. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricFieldUnit unit) + public QuantityValue As(ElectricFieldUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) + if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return As(unitAsElectricFieldUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public ElectricField ToUnit(ElectricFieldUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (ElectricField)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricFieldUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public ElectricField ToUnit(ElectricFieldUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) + if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricFieldUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public ElectricField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricFieldUnit unit) + private QuantityValue GetValueAs(ElectricFieldUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index fb2435cdce..82eabf7fac 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inductance /// [DataContract] - public partial struct ElectricInductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static ElectricInductance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricInductance(double value, ElectricInductanceUnit unit) + public ElectricInductance(QuantityValue value, ElectricInductanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public ElectricInductance(double value, ElectricInductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricInductance(double value, UnitSystem unitSystem) + public ElectricInductance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +166,24 @@ public ElectricInductance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Henries => As(ElectricInductanceUnit.Henry); + public QuantityValue Henries => As(ElectricInductanceUnit.Henry); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microhenries => As(ElectricInductanceUnit.Microhenry); + public QuantityValue Microhenries => As(ElectricInductanceUnit.Microhenry); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millihenries => As(ElectricInductanceUnit.Millihenry); + public QuantityValue Millihenries => As(ElectricInductanceUnit.Millihenry); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanohenries => As(ElectricInductanceUnit.Nanohenry); + public QuantityValue Nanohenries => As(ElectricInductanceUnit.Nanohenry); #endregion @@ -245,7 +248,7 @@ public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvide /// If value is NaN or Infinity. public static ElectricInductance FromHenries(QuantityValue henries) { - double value = (double) henries; + QuantityValue value = (QuantityValue) henries; return new ElectricInductance(value, ElectricInductanceUnit.Henry); } @@ -255,7 +258,7 @@ public static ElectricInductance FromHenries(QuantityValue henries) /// If value is NaN or Infinity. public static ElectricInductance FromMicrohenries(QuantityValue microhenries) { - double value = (double) microhenries; + QuantityValue value = (QuantityValue) microhenries; return new ElectricInductance(value, ElectricInductanceUnit.Microhenry); } @@ -265,7 +268,7 @@ public static ElectricInductance FromMicrohenries(QuantityValue microhenries) /// If value is NaN or Infinity. public static ElectricInductance FromMillihenries(QuantityValue millihenries) { - double value = (double) millihenries; + QuantityValue value = (QuantityValue) millihenries; return new ElectricInductance(value, ElectricInductanceUnit.Millihenry); } @@ -275,7 +278,7 @@ public static ElectricInductance FromMillihenries(QuantityValue millihenries) /// If value is NaN or Infinity. public static ElectricInductance FromNanohenries(QuantityValue nanohenries) { - double value = (double) nanohenries; + QuantityValue value = (QuantityValue) nanohenries; return new ElectricInductance(value, ElectricInductanceUnit.Nanohenry); } @@ -287,7 +290,7 @@ public static ElectricInductance FromNanohenries(QuantityValue nanohenries) /// ElectricInductance unit value. public static ElectricInductance From(QuantityValue value, ElectricInductanceUnit fromUnit) { - return new ElectricInductance((double)value, fromUnit); + return new ElectricInductance((QuantityValue)value, fromUnit); } #endregion @@ -457,25 +460,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricInductance operator *(double left, ElectricInductance right) + public static ElectricInductance operator *(QuantityValue left, ElectricInductance right) { return new ElectricInductance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricInductance operator *(ElectricInductance left, double right) + public static ElectricInductance operator *(ElectricInductance left, QuantityValue right) { return new ElectricInductance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricInductance operator /(ElectricInductance left, double right) + public static ElectricInductance operator /(ElectricInductance left, QuantityValue right) { return new ElectricInductance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricInductance left, ElectricInductance right) + public static QuantityValue operator /(ElectricInductance left, ElectricInductance right) { return left.Henries / right.Henries; } @@ -508,6 +511,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricInductance left, ElectricInductance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricInductance left, ElectricInductance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -520,7 +536,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricInductance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricInductance objElectricInductance)) + return false; + return Equals(objElectricInductance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricInductance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -563,13 +601,13 @@ public int CompareTo(ElectricInductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricInductance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -580,7 +618,7 @@ public bool Equals(ElectricInductance other, double tolerance, ComparisonType co /// A hash code for the current ElectricInductance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -591,17 +629,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricInductanceUnit unit) + public QuantityValue As(ElectricInductanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,12 +653,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) + if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricInductanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -653,7 +690,7 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit, UnitConverter unit var converted = conversionFunction(this); return (ElectricInductance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricInductanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -661,17 +698,17 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) + if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricInductanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -698,10 +735,10 @@ public ElectricInductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricInductanceUnit unit) + private QuantityValue GetValueAs(ElectricInductanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3c413afc86..f549a30e62 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. /// [DataContract] - public partial struct ElectricPotential : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ElectricPotential() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotential(double value, ElectricPotentialUnit unit) + public ElectricPotential(QuantityValue value, ElectricPotentialUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -90,14 +90,14 @@ public ElectricPotential(double value, ElectricPotentialUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotential(double value, UnitSystem unitSystem) + public ElectricPotential(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,7 +138,10 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -161,29 +164,29 @@ public ElectricPotential(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilovolts => As(ElectricPotentialUnit.Kilovolt); + public QuantityValue Kilovolts => As(ElectricPotentialUnit.Kilovolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megavolts => As(ElectricPotentialUnit.Megavolt); + public QuantityValue Megavolts => As(ElectricPotentialUnit.Megavolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microvolts => As(ElectricPotentialUnit.Microvolt); + public QuantityValue Microvolts => As(ElectricPotentialUnit.Microvolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millivolts => As(ElectricPotentialUnit.Millivolt); + public QuantityValue Millivolts => As(ElectricPotentialUnit.Millivolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Volts => As(ElectricPotentialUnit.Volt); + public QuantityValue Volts => As(ElectricPotentialUnit.Volt); #endregion @@ -256,7 +259,7 @@ public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider /// If value is NaN or Infinity. public static ElectricPotential FromKilovolts(QuantityValue kilovolts) { - double value = (double) kilovolts; + QuantityValue value = (QuantityValue) kilovolts; return new ElectricPotential(value, ElectricPotentialUnit.Kilovolt); } @@ -266,7 +269,7 @@ public static ElectricPotential FromKilovolts(QuantityValue kilovolts) /// If value is NaN or Infinity. public static ElectricPotential FromMegavolts(QuantityValue megavolts) { - double value = (double) megavolts; + QuantityValue value = (QuantityValue) megavolts; return new ElectricPotential(value, ElectricPotentialUnit.Megavolt); } @@ -276,7 +279,7 @@ public static ElectricPotential FromMegavolts(QuantityValue megavolts) /// If value is NaN or Infinity. public static ElectricPotential FromMicrovolts(QuantityValue microvolts) { - double value = (double) microvolts; + QuantityValue value = (QuantityValue) microvolts; return new ElectricPotential(value, ElectricPotentialUnit.Microvolt); } @@ -286,7 +289,7 @@ public static ElectricPotential FromMicrovolts(QuantityValue microvolts) /// If value is NaN or Infinity. public static ElectricPotential FromMillivolts(QuantityValue millivolts) { - double value = (double) millivolts; + QuantityValue value = (QuantityValue) millivolts; return new ElectricPotential(value, ElectricPotentialUnit.Millivolt); } @@ -296,7 +299,7 @@ public static ElectricPotential FromMillivolts(QuantityValue millivolts) /// If value is NaN or Infinity. public static ElectricPotential FromVolts(QuantityValue volts) { - double value = (double) volts; + QuantityValue value = (QuantityValue) volts; return new ElectricPotential(value, ElectricPotentialUnit.Volt); } @@ -308,7 +311,7 @@ public static ElectricPotential FromVolts(QuantityValue volts) /// ElectricPotential unit value. public static ElectricPotential From(QuantityValue value, ElectricPotentialUnit fromUnit) { - return new ElectricPotential((double)value, fromUnit); + return new ElectricPotential((QuantityValue)value, fromUnit); } #endregion @@ -478,25 +481,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotential operator *(double left, ElectricPotential right) + public static ElectricPotential operator *(QuantityValue left, ElectricPotential right) { return new ElectricPotential(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotential operator *(ElectricPotential left, double right) + public static ElectricPotential operator *(ElectricPotential left, QuantityValue right) { return new ElectricPotential(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotential operator /(ElectricPotential left, double right) + public static ElectricPotential operator /(ElectricPotential left, QuantityValue right) { return new ElectricPotential(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotential left, ElectricPotential right) + public static QuantityValue operator /(ElectricPotential left, ElectricPotential right) { return left.Volts / right.Volts; } @@ -529,6 +532,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotential left, ElectricPotential right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotential left, ElectricPotential right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -541,7 +557,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotential other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricPotential objElectricPotential)) + return false; + return Equals(objElectricPotential); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotential other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -584,13 +622,13 @@ public int CompareTo(ElectricPotential other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotential other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -601,7 +639,7 @@ public bool Equals(ElectricPotential other, double tolerance, ComparisonType com /// A hash code for the current ElectricPotential. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -612,17 +650,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialUnit unit) + public QuantityValue As(ElectricPotentialUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -637,12 +674,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) + if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialUnit); + return (QuantityValue)As(typedUnit); } /// @@ -674,7 +711,7 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (ElectricPotential)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricPotentialUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -682,17 +719,17 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit, UnitConverter unitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) + if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -719,10 +756,10 @@ public ElectricPotential ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricPotentialUnit unit) + private QuantityValue GetValueAs(ElectricPotentialUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index fa988ad89a..bea9b49b8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The Electric Potential of a system known to use Alternating Current. /// [DataContract] - public partial struct ElectricPotentialAc : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ElectricPotentialAc() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) + public ElectricPotentialAc(QuantityValue value, ElectricPotentialAcUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -90,14 +90,14 @@ public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialAc(double value, UnitSystem unitSystem) + public ElectricPotentialAc(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,7 +138,10 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -161,29 +164,29 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); + public QuantityValue KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); + public QuantityValue MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); + public QuantityValue MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); + public QuantityValue MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsAc => As(ElectricPotentialAcUnit.VoltAc); + public QuantityValue VoltsAc => As(ElectricPotentialAcUnit.VoltAc); #endregion @@ -251,7 +254,7 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricPotentialAc FromKilovoltsAc(QuantityValue kilovoltsac) { - double value = (double) kilovoltsac; + QuantityValue value = (QuantityValue) kilovoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.KilovoltAc); } @@ -261,7 +264,7 @@ public static ElectricPotentialAc FromKilovoltsAc(QuantityValue kilovoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromMegavoltsAc(QuantityValue megavoltsac) { - double value = (double) megavoltsac; + QuantityValue value = (QuantityValue) megavoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MegavoltAc); } @@ -271,7 +274,7 @@ public static ElectricPotentialAc FromMegavoltsAc(QuantityValue megavoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue microvoltsac) { - double value = (double) microvoltsac; + QuantityValue value = (QuantityValue) microvoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MicrovoltAc); } @@ -281,7 +284,7 @@ public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue microvoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromMillivoltsAc(QuantityValue millivoltsac) { - double value = (double) millivoltsac; + QuantityValue value = (QuantityValue) millivoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MillivoltAc); } @@ -291,7 +294,7 @@ public static ElectricPotentialAc FromMillivoltsAc(QuantityValue millivoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromVoltsAc(QuantityValue voltsac) { - double value = (double) voltsac; + QuantityValue value = (QuantityValue) voltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.VoltAc); } @@ -303,7 +306,7 @@ public static ElectricPotentialAc FromVoltsAc(QuantityValue voltsac) /// ElectricPotentialAc unit value. public static ElectricPotentialAc From(QuantityValue value, ElectricPotentialAcUnit fromUnit) { - return new ElectricPotentialAc((double)value, fromUnit); + return new ElectricPotentialAc((QuantityValue)value, fromUnit); } #endregion @@ -473,25 +476,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialAc operator *(double left, ElectricPotentialAc right) + public static ElectricPotentialAc operator *(QuantityValue left, ElectricPotentialAc right) { return new ElectricPotentialAc(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialAc operator *(ElectricPotentialAc left, double right) + public static ElectricPotentialAc operator *(ElectricPotentialAc left, QuantityValue right) { return new ElectricPotentialAc(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialAc operator /(ElectricPotentialAc left, double right) + public static ElectricPotentialAc operator /(ElectricPotentialAc left, QuantityValue right) { return new ElectricPotentialAc(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialAc left, ElectricPotentialAc right) + public static QuantityValue operator /(ElectricPotentialAc left, ElectricPotentialAc right) { return left.VoltsAc / right.VoltsAc; } @@ -524,6 +527,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -536,7 +552,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotentialAc other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) + return false; + return Equals(objElectricPotentialAc); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotentialAc other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -579,13 +617,13 @@ public int CompareTo(ElectricPotentialAc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialAc other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +634,7 @@ public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType c /// A hash code for the current ElectricPotentialAc. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -607,17 +645,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialAcUnit unit) + public QuantityValue As(ElectricPotentialAcUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -632,12 +669,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) + if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialAcUnit); + return (QuantityValue)As(typedUnit); } /// @@ -669,7 +706,7 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricPotentialAc)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricPotentialAcUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -677,17 +714,17 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) + if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialAcUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -714,10 +751,10 @@ public ElectricPotentialAc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricPotentialAcUnit unit) + private QuantityValue GetValueAs(ElectricPotentialAcUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 9cc91d8d27..d35fd6041b 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). /// [DataContract] - public partial struct ElectricPotentialChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -91,9 +91,9 @@ static ElectricPotentialChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) + public ElectricPotentialChangeRate(QuantityValue value, ElectricPotentialChangeRateUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -105,14 +105,14 @@ public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) + public ElectricPotentialChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -153,7 +153,10 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,104 +179,104 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); + public QuantityValue KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); + public QuantityValue KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); + public QuantityValue KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); + public QuantityValue KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); + public QuantityValue MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); + public QuantityValue MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); + public QuantityValue MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); + public QuantityValue MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); + public QuantityValue MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); + public QuantityValue MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); + public QuantityValue MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); + public QuantityValue MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); + public QuantityValue MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); + public QuantityValue MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); + public QuantityValue MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); + public QuantityValue MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); + public QuantityValue VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); + public QuantityValue VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); + public QuantityValue VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); + public QuantityValue VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); #endregion @@ -386,7 +389,7 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IForm /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerHours(QuantityValue kilovoltsperhours) { - double value = (double) kilovoltsperhours; + QuantityValue value = (QuantityValue) kilovoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerHour); } @@ -396,7 +399,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerHours(QuantityValue ki /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(QuantityValue kilovoltspermicroseconds) { - double value = (double) kilovoltspermicroseconds; + QuantityValue value = (QuantityValue) kilovoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); } @@ -406,7 +409,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(QuantityV /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(QuantityValue kilovoltsperminutes) { - double value = (double) kilovoltsperminutes; + QuantityValue value = (QuantityValue) kilovoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMinute); } @@ -416,7 +419,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(QuantityValue kilovoltsperseconds) { - double value = (double) kilovoltsperseconds; + QuantityValue value = (QuantityValue) kilovoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerSecond); } @@ -426,7 +429,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerHours(QuantityValue megavoltsperhours) { - double value = (double) megavoltsperhours; + QuantityValue value = (QuantityValue) megavoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerHour); } @@ -436,7 +439,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerHours(QuantityValue me /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(QuantityValue megavoltspermicroseconds) { - double value = (double) megavoltspermicroseconds; + QuantityValue value = (QuantityValue) megavoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); } @@ -446,7 +449,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(QuantityV /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(QuantityValue megavoltsperminutes) { - double value = (double) megavoltsperminutes; + QuantityValue value = (QuantityValue) megavoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMinute); } @@ -456,7 +459,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(QuantityValue megavoltsperseconds) { - double value = (double) megavoltsperseconds; + QuantityValue value = (QuantityValue) megavoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerSecond); } @@ -466,7 +469,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerHours(QuantityValue microvoltsperhours) { - double value = (double) microvoltsperhours; + QuantityValue value = (QuantityValue) microvoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerHour); } @@ -476,7 +479,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerHours(QuantityValue m /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(QuantityValue microvoltspermicroseconds) { - double value = (double) microvoltspermicroseconds; + QuantityValue value = (QuantityValue) microvoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); } @@ -486,7 +489,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(Quantity /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(QuantityValue microvoltsperminutes) { - double value = (double) microvoltsperminutes; + QuantityValue value = (QuantityValue) microvoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); } @@ -496,7 +499,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(QuantityValue microvoltsperseconds) { - double value = (double) microvoltsperseconds; + QuantityValue value = (QuantityValue) microvoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); } @@ -506,7 +509,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerHours(QuantityValue millivoltsperhours) { - double value = (double) millivoltsperhours; + QuantityValue value = (QuantityValue) millivoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerHour); } @@ -516,7 +519,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerHours(QuantityValue m /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(QuantityValue millivoltspermicroseconds) { - double value = (double) millivoltspermicroseconds; + QuantityValue value = (QuantityValue) millivoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); } @@ -526,7 +529,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(Quantity /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(QuantityValue millivoltsperminutes) { - double value = (double) millivoltsperminutes; + QuantityValue value = (QuantityValue) millivoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMinute); } @@ -536,7 +539,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(QuantityValue millivoltsperseconds) { - double value = (double) millivoltsperseconds; + QuantityValue value = (QuantityValue) millivoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerSecond); } @@ -546,7 +549,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerHours(QuantityValue voltsperhours) { - double value = (double) voltsperhours; + QuantityValue value = (QuantityValue) voltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerHour); } @@ -556,7 +559,7 @@ public static ElectricPotentialChangeRate FromVoltsPerHours(QuantityValue voltsp /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(QuantityValue voltspermicroseconds) { - double value = (double) voltspermicroseconds; + QuantityValue value = (QuantityValue) voltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); } @@ -566,7 +569,7 @@ public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerMinutes(QuantityValue voltsperminutes) { - double value = (double) voltsperminutes; + QuantityValue value = (QuantityValue) voltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMinute); } @@ -576,7 +579,7 @@ public static ElectricPotentialChangeRate FromVoltsPerMinutes(QuantityValue volt /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerSeconds(QuantityValue voltsperseconds) { - double value = (double) voltsperseconds; + QuantityValue value = (QuantityValue) voltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerSecond); } @@ -588,7 +591,7 @@ public static ElectricPotentialChangeRate FromVoltsPerSeconds(QuantityValue volt /// ElectricPotentialChangeRate unit value. public static ElectricPotentialChangeRate From(QuantityValue value, ElectricPotentialChangeRateUnit fromUnit) { - return new ElectricPotentialChangeRate((double)value, fromUnit); + return new ElectricPotentialChangeRate((QuantityValue)value, fromUnit); } #endregion @@ -758,25 +761,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(double left, ElectricPotentialChangeRate right) + public static ElectricPotentialChangeRate operator *(QuantityValue left, ElectricPotentialChangeRate right) { return new ElectricPotentialChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, double right) + public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, QuantityValue right) { return new ElectricPotentialChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, double right) + public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, QuantityValue right) { return new ElectricPotentialChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static QuantityValue operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return left.VoltsPerSeconds / right.VoltsPerSeconds; } @@ -809,6 +812,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -821,7 +837,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotentialChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) + return false; + return Equals(objElectricPotentialChangeRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotentialChangeRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -864,13 +902,13 @@ public int CompareTo(ElectricPotentialChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -881,7 +919,7 @@ public bool Equals(ElectricPotentialChangeRate other, double tolerance, Comparis /// A hash code for the current ElectricPotentialChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -892,17 +930,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialChangeRateUnit unit) + public QuantityValue As(ElectricPotentialChangeRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -917,12 +954,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) + if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialChangeRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -954,7 +991,7 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit, var converted = conversionFunction(this); return (ElectricPotentialChangeRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricPotentialChangeRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -962,17 +999,17 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit, } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) + if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -999,10 +1036,10 @@ public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricPotentialChangeRateUnit unit) + private QuantityValue GetValueAs(ElectricPotentialChangeRateUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 787d8e5f5e..5f73469a2c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The Electric Potential of a system known to use Direct Current. /// [DataContract] - public partial struct ElectricPotentialDc : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ElectricPotentialDc() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) + public ElectricPotentialDc(QuantityValue value, ElectricPotentialDcUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -90,14 +90,14 @@ public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialDc(double value, UnitSystem unitSystem) + public ElectricPotentialDc(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,7 +138,10 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -161,29 +164,29 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); + public QuantityValue KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); + public QuantityValue MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); + public QuantityValue MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); + public QuantityValue MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltsDc => As(ElectricPotentialDcUnit.VoltDc); + public QuantityValue VoltsDc => As(ElectricPotentialDcUnit.VoltDc); #endregion @@ -251,7 +254,7 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricPotentialDc FromKilovoltsDc(QuantityValue kilovoltsdc) { - double value = (double) kilovoltsdc; + QuantityValue value = (QuantityValue) kilovoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.KilovoltDc); } @@ -261,7 +264,7 @@ public static ElectricPotentialDc FromKilovoltsDc(QuantityValue kilovoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromMegavoltsDc(QuantityValue megavoltsdc) { - double value = (double) megavoltsdc; + QuantityValue value = (QuantityValue) megavoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MegavoltDc); } @@ -271,7 +274,7 @@ public static ElectricPotentialDc FromMegavoltsDc(QuantityValue megavoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue microvoltsdc) { - double value = (double) microvoltsdc; + QuantityValue value = (QuantityValue) microvoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MicrovoltDc); } @@ -281,7 +284,7 @@ public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue microvoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromMillivoltsDc(QuantityValue millivoltsdc) { - double value = (double) millivoltsdc; + QuantityValue value = (QuantityValue) millivoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MillivoltDc); } @@ -291,7 +294,7 @@ public static ElectricPotentialDc FromMillivoltsDc(QuantityValue millivoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromVoltsDc(QuantityValue voltsdc) { - double value = (double) voltsdc; + QuantityValue value = (QuantityValue) voltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.VoltDc); } @@ -303,7 +306,7 @@ public static ElectricPotentialDc FromVoltsDc(QuantityValue voltsdc) /// ElectricPotentialDc unit value. public static ElectricPotentialDc From(QuantityValue value, ElectricPotentialDcUnit fromUnit) { - return new ElectricPotentialDc((double)value, fromUnit); + return new ElectricPotentialDc((QuantityValue)value, fromUnit); } #endregion @@ -473,25 +476,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialDc operator *(double left, ElectricPotentialDc right) + public static ElectricPotentialDc operator *(QuantityValue left, ElectricPotentialDc right) { return new ElectricPotentialDc(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialDc operator *(ElectricPotentialDc left, double right) + public static ElectricPotentialDc operator *(ElectricPotentialDc left, QuantityValue right) { return new ElectricPotentialDc(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialDc operator /(ElectricPotentialDc left, double right) + public static ElectricPotentialDc operator /(ElectricPotentialDc left, QuantityValue right) { return new ElectricPotentialDc(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricPotentialDc left, ElectricPotentialDc right) + public static QuantityValue operator /(ElectricPotentialDc left, ElectricPotentialDc right) { return left.VoltsDc / right.VoltsDc; } @@ -524,6 +527,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -536,7 +552,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotentialDc other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) + return false; + return Equals(objElectricPotentialDc); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricPotentialDc other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -579,13 +617,13 @@ public int CompareTo(ElectricPotentialDc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialDc other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +634,7 @@ public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType c /// A hash code for the current ElectricPotentialDc. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -607,17 +645,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricPotentialDcUnit unit) + public QuantityValue As(ElectricPotentialDcUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -632,12 +669,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) + if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialDcUnit); + return (QuantityValue)As(typedUnit); } /// @@ -669,7 +706,7 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricPotentialDc)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricPotentialDcUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -677,17 +714,17 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) + if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialDcUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -714,10 +751,10 @@ public ElectricPotentialDc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricPotentialDcUnit unit) + private QuantityValue GetValueAs(ElectricPotentialDcUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 29810c8529..a90307d171 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. /// [DataContract] - public partial struct ElectricResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricResistance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricResistance(double value, ElectricResistanceUnit unit) + public ElectricResistance(QuantityValue value, ElectricResistanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public ElectricResistance(double value, ElectricResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistance(double value, UnitSystem unitSystem) + public ElectricResistance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,34 +165,34 @@ public ElectricResistance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigaohms => As(ElectricResistanceUnit.Gigaohm); + public QuantityValue Gigaohms => As(ElectricResistanceUnit.Gigaohm); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kiloohms => As(ElectricResistanceUnit.Kiloohm); + public QuantityValue Kiloohms => As(ElectricResistanceUnit.Kiloohm); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megaohms => As(ElectricResistanceUnit.Megaohm); + public QuantityValue Megaohms => As(ElectricResistanceUnit.Megaohm); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microohms => As(ElectricResistanceUnit.Microohm); + public QuantityValue Microohms => As(ElectricResistanceUnit.Microohm); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliohms => As(ElectricResistanceUnit.Milliohm); + public QuantityValue Milliohms => As(ElectricResistanceUnit.Milliohm); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Ohms => As(ElectricResistanceUnit.Ohm); + public QuantityValue Ohms => As(ElectricResistanceUnit.Ohm); #endregion @@ -260,7 +263,7 @@ public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvide /// If value is NaN or Infinity. public static ElectricResistance FromGigaohms(QuantityValue gigaohms) { - double value = (double) gigaohms; + QuantityValue value = (QuantityValue) gigaohms; return new ElectricResistance(value, ElectricResistanceUnit.Gigaohm); } @@ -270,7 +273,7 @@ public static ElectricResistance FromGigaohms(QuantityValue gigaohms) /// If value is NaN or Infinity. public static ElectricResistance FromKiloohms(QuantityValue kiloohms) { - double value = (double) kiloohms; + QuantityValue value = (QuantityValue) kiloohms; return new ElectricResistance(value, ElectricResistanceUnit.Kiloohm); } @@ -280,7 +283,7 @@ public static ElectricResistance FromKiloohms(QuantityValue kiloohms) /// If value is NaN or Infinity. public static ElectricResistance FromMegaohms(QuantityValue megaohms) { - double value = (double) megaohms; + QuantityValue value = (QuantityValue) megaohms; return new ElectricResistance(value, ElectricResistanceUnit.Megaohm); } @@ -290,7 +293,7 @@ public static ElectricResistance FromMegaohms(QuantityValue megaohms) /// If value is NaN or Infinity. public static ElectricResistance FromMicroohms(QuantityValue microohms) { - double value = (double) microohms; + QuantityValue value = (QuantityValue) microohms; return new ElectricResistance(value, ElectricResistanceUnit.Microohm); } @@ -300,7 +303,7 @@ public static ElectricResistance FromMicroohms(QuantityValue microohms) /// If value is NaN or Infinity. public static ElectricResistance FromMilliohms(QuantityValue milliohms) { - double value = (double) milliohms; + QuantityValue value = (QuantityValue) milliohms; return new ElectricResistance(value, ElectricResistanceUnit.Milliohm); } @@ -310,7 +313,7 @@ public static ElectricResistance FromMilliohms(QuantityValue milliohms) /// If value is NaN or Infinity. public static ElectricResistance FromOhms(QuantityValue ohms) { - double value = (double) ohms; + QuantityValue value = (QuantityValue) ohms; return new ElectricResistance(value, ElectricResistanceUnit.Ohm); } @@ -322,7 +325,7 @@ public static ElectricResistance FromOhms(QuantityValue ohms) /// ElectricResistance unit value. public static ElectricResistance From(QuantityValue value, ElectricResistanceUnit fromUnit) { - return new ElectricResistance((double)value, fromUnit); + return new ElectricResistance((QuantityValue)value, fromUnit); } #endregion @@ -492,25 +495,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricResistance operator *(double left, ElectricResistance right) + public static ElectricResistance operator *(QuantityValue left, ElectricResistance right) { return new ElectricResistance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricResistance operator *(ElectricResistance left, double right) + public static ElectricResistance operator *(ElectricResistance left, QuantityValue right) { return new ElectricResistance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricResistance operator /(ElectricResistance left, double right) + public static ElectricResistance operator /(ElectricResistance left, QuantityValue right) { return new ElectricResistance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricResistance left, ElectricResistance right) + public static QuantityValue operator /(ElectricResistance left, ElectricResistance right) { return left.Ohms / right.Ohms; } @@ -543,6 +546,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricResistance left, ElectricResistance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricResistance left, ElectricResistance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -555,7 +571,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricResistance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricResistance objElectricResistance)) + return false; + return Equals(objElectricResistance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricResistance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -598,13 +636,13 @@ public int CompareTo(ElectricResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricResistance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +653,7 @@ public bool Equals(ElectricResistance other, double tolerance, ComparisonType co /// A hash code for the current ElectricResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -626,17 +664,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistanceUnit unit) + public QuantityValue As(ElectricResistanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -651,12 +688,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) + if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -688,7 +725,7 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit, UnitConverter unit var converted = conversionFunction(this); return (ElectricResistance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricResistanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -696,17 +733,17 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) + if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricResistanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -733,10 +770,10 @@ public ElectricResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricResistanceUnit unit) + private QuantityValue GetValueAs(ElectricResistanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 9fa380d492..4fb77ebee4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricResistivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -88,9 +88,9 @@ static ElectricResistivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricResistivity(double value, ElectricResistivityUnit unit) + public ElectricResistivity(QuantityValue value, ElectricResistivityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -102,14 +102,14 @@ public ElectricResistivity(double value, ElectricResistivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistivity(double value, UnitSystem unitSystem) + public ElectricResistivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -150,7 +150,10 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +176,74 @@ public ElectricResistivity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); + public QuantityValue KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); + public QuantityValue KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); + public QuantityValue MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); + public QuantityValue MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); + public QuantityValue MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); + public QuantityValue MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); + public QuantityValue MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); + public QuantityValue MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); + public QuantityValue NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); + public QuantityValue NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); + public QuantityValue OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OhmMeters => As(ElectricResistivityUnit.OhmMeter); + public QuantityValue OhmMeters => As(ElectricResistivityUnit.OhmMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); + public QuantityValue PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); + public QuantityValue PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); #endregion @@ -335,7 +338,7 @@ public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricResistivity FromKiloohmsCentimeter(QuantityValue kiloohmscentimeter) { - double value = (double) kiloohmscentimeter; + QuantityValue value = (QuantityValue) kiloohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmCentimeter); } @@ -345,7 +348,7 @@ public static ElectricResistivity FromKiloohmsCentimeter(QuantityValue kiloohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromKiloohmMeters(QuantityValue kiloohmmeters) { - double value = (double) kiloohmmeters; + QuantityValue value = (QuantityValue) kiloohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmMeter); } @@ -355,7 +358,7 @@ public static ElectricResistivity FromKiloohmMeters(QuantityValue kiloohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromMegaohmsCentimeter(QuantityValue megaohmscentimeter) { - double value = (double) megaohmscentimeter; + QuantityValue value = (QuantityValue) megaohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmCentimeter); } @@ -365,7 +368,7 @@ public static ElectricResistivity FromMegaohmsCentimeter(QuantityValue megaohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromMegaohmMeters(QuantityValue megaohmmeters) { - double value = (double) megaohmmeters; + QuantityValue value = (QuantityValue) megaohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmMeter); } @@ -375,7 +378,7 @@ public static ElectricResistivity FromMegaohmMeters(QuantityValue megaohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromMicroohmsCentimeter(QuantityValue microohmscentimeter) { - double value = (double) microohmscentimeter; + QuantityValue value = (QuantityValue) microohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmCentimeter); } @@ -385,7 +388,7 @@ public static ElectricResistivity FromMicroohmsCentimeter(QuantityValue microohm /// If value is NaN or Infinity. public static ElectricResistivity FromMicroohmMeters(QuantityValue microohmmeters) { - double value = (double) microohmmeters; + QuantityValue value = (QuantityValue) microohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmMeter); } @@ -395,7 +398,7 @@ public static ElectricResistivity FromMicroohmMeters(QuantityValue microohmmeter /// If value is NaN or Infinity. public static ElectricResistivity FromMilliohmsCentimeter(QuantityValue milliohmscentimeter) { - double value = (double) milliohmscentimeter; + QuantityValue value = (QuantityValue) milliohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmCentimeter); } @@ -405,7 +408,7 @@ public static ElectricResistivity FromMilliohmsCentimeter(QuantityValue milliohm /// If value is NaN or Infinity. public static ElectricResistivity FromMilliohmMeters(QuantityValue milliohmmeters) { - double value = (double) milliohmmeters; + QuantityValue value = (QuantityValue) milliohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmMeter); } @@ -415,7 +418,7 @@ public static ElectricResistivity FromMilliohmMeters(QuantityValue milliohmmeter /// If value is NaN or Infinity. public static ElectricResistivity FromNanoohmsCentimeter(QuantityValue nanoohmscentimeter) { - double value = (double) nanoohmscentimeter; + QuantityValue value = (QuantityValue) nanoohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmCentimeter); } @@ -425,7 +428,7 @@ public static ElectricResistivity FromNanoohmsCentimeter(QuantityValue nanoohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromNanoohmMeters(QuantityValue nanoohmmeters) { - double value = (double) nanoohmmeters; + QuantityValue value = (QuantityValue) nanoohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmMeter); } @@ -435,7 +438,7 @@ public static ElectricResistivity FromNanoohmMeters(QuantityValue nanoohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromOhmsCentimeter(QuantityValue ohmscentimeter) { - double value = (double) ohmscentimeter; + QuantityValue value = (QuantityValue) ohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.OhmCentimeter); } @@ -445,7 +448,7 @@ public static ElectricResistivity FromOhmsCentimeter(QuantityValue ohmscentimete /// If value is NaN or Infinity. public static ElectricResistivity FromOhmMeters(QuantityValue ohmmeters) { - double value = (double) ohmmeters; + QuantityValue value = (QuantityValue) ohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.OhmMeter); } @@ -455,7 +458,7 @@ public static ElectricResistivity FromOhmMeters(QuantityValue ohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromPicoohmsCentimeter(QuantityValue picoohmscentimeter) { - double value = (double) picoohmscentimeter; + QuantityValue value = (QuantityValue) picoohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmCentimeter); } @@ -465,7 +468,7 @@ public static ElectricResistivity FromPicoohmsCentimeter(QuantityValue picoohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromPicoohmMeters(QuantityValue picoohmmeters) { - double value = (double) picoohmmeters; + QuantityValue value = (QuantityValue) picoohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmMeter); } @@ -477,7 +480,7 @@ public static ElectricResistivity FromPicoohmMeters(QuantityValue picoohmmeters) /// ElectricResistivity unit value. public static ElectricResistivity From(QuantityValue value, ElectricResistivityUnit fromUnit) { - return new ElectricResistivity((double)value, fromUnit); + return new ElectricResistivity((QuantityValue)value, fromUnit); } #endregion @@ -647,25 +650,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricResistivity operator *(double left, ElectricResistivity right) + public static ElectricResistivity operator *(QuantityValue left, ElectricResistivity right) { return new ElectricResistivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricResistivity operator *(ElectricResistivity left, double right) + public static ElectricResistivity operator *(ElectricResistivity left, QuantityValue right) { return new ElectricResistivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricResistivity operator /(ElectricResistivity left, double right) + public static ElectricResistivity operator /(ElectricResistivity left, QuantityValue right) { return new ElectricResistivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricResistivity left, ElectricResistivity right) + public static QuantityValue operator /(ElectricResistivity left, ElectricResistivity right) { return left.OhmMeters / right.OhmMeters; } @@ -698,6 +701,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricResistivity left, ElectricResistivity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricResistivity left, ElectricResistivity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -710,7 +726,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricResistivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricResistivity objElectricResistivity)) + return false; + return Equals(objElectricResistivity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricResistivity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -753,13 +791,13 @@ public int CompareTo(ElectricResistivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricResistivity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -770,7 +808,7 @@ public bool Equals(ElectricResistivity other, double tolerance, ComparisonType c /// A hash code for the current ElectricResistivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -781,17 +819,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricResistivityUnit unit) + public QuantityValue As(ElectricResistivityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -806,12 +843,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) + if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistivityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -843,7 +880,7 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricResistivity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricResistivityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -851,17 +888,17 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) + if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricResistivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -888,10 +925,10 @@ public ElectricResistivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricResistivityUnit unit) + private QuantityValue GetValueAs(ElectricResistivityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index a5e94ca602..39a5166bad 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricSurfaceChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricSurfaceChargeDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) + public ElectricSurfaceChargeDensity(QuantityValue value, ElectricSurfaceChargeDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) + public ElectricSurfaceChargeDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +165,19 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + public QuantityValue CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + public QuantityValue CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + public QuantityValue CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); #endregion @@ -236,7 +239,7 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFor /// If value is NaN or Infinity. public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(QuantityValue coulombspersquarecentimeter) { - double value = (double) coulombspersquarecentimeter; + QuantityValue value = (QuantityValue) coulombspersquarecentimeter; return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); } @@ -246,7 +249,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(Quant /// If value is NaN or Infinity. public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(QuantityValue coulombspersquareinch) { - double value = (double) coulombspersquareinch; + QuantityValue value = (QuantityValue) coulombspersquareinch; return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); } @@ -256,7 +259,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(QuantityVal /// If value is NaN or Infinity. public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(QuantityValue coulombspersquaremeter) { - double value = (double) coulombspersquaremeter; + QuantityValue value = (QuantityValue) coulombspersquaremeter; return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); } @@ -268,7 +271,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(QuantityVa /// ElectricSurfaceChargeDensity unit value. public static ElectricSurfaceChargeDensity From(QuantityValue value, ElectricSurfaceChargeDensityUnit fromUnit) { - return new ElectricSurfaceChargeDensity((double)value, fromUnit); + return new ElectricSurfaceChargeDensity((QuantityValue)value, fromUnit); } #endregion @@ -438,25 +441,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(double left, ElectricSurfaceChargeDensity right) + public static ElectricSurfaceChargeDensity operator *(QuantityValue left, ElectricSurfaceChargeDensity right) { return new ElectricSurfaceChargeDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, double right) + public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, QuantityValue right) { return new ElectricSurfaceChargeDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, double right) + public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, QuantityValue right) { return new ElectricSurfaceChargeDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static QuantityValue operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return left.CoulombsPerSquareMeter / right.CoulombsPerSquareMeter; } @@ -489,6 +492,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -501,7 +517,29 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricSurfaceChargeDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) + return false; + return Equals(objElectricSurfaceChargeDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ElectricSurfaceChargeDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -544,13 +582,13 @@ public int CompareTo(ElectricSurfaceChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ElectricSurfaceChargeDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +599,7 @@ public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, Compari /// A hash code for the current ElectricSurfaceChargeDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -572,17 +610,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ElectricSurfaceChargeDensityUnit unit) + public QuantityValue As(ElectricSurfaceChargeDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -597,12 +634,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricSurfaceChargeDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -634,7 +671,7 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit var converted = conversionFunction(this); return (ElectricSurfaceChargeDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ElectricSurfaceChargeDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -642,17 +679,17 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricSurfaceChargeDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -679,10 +716,10 @@ public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) + private QuantityValue GetValueAs(ElectricSurfaceChargeDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index d8d04ae1af..60e31f0113 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. /// [DataContract] - public partial struct Energy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -107,9 +107,9 @@ static Energy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Energy(double value, EnergyUnit unit) + public Energy(QuantityValue value, EnergyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -121,14 +121,14 @@ public Energy(double value, EnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Energy(double value, UnitSystem unitSystem) + public Energy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -169,7 +169,10 @@ public Energy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -192,184 +195,184 @@ public Energy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); + public QuantityValue BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Calories => As(EnergyUnit.Calorie); + public QuantityValue Calories => As(EnergyUnit.Calorie); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecathermsEc => As(EnergyUnit.DecathermEc); + public QuantityValue DecathermsEc => As(EnergyUnit.DecathermEc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecathermsImperial => As(EnergyUnit.DecathermImperial); + public QuantityValue DecathermsImperial => As(EnergyUnit.DecathermImperial); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecathermsUs => As(EnergyUnit.DecathermUs); + public QuantityValue DecathermsUs => As(EnergyUnit.DecathermUs); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ElectronVolts => As(EnergyUnit.ElectronVolt); + public QuantityValue ElectronVolts => As(EnergyUnit.ElectronVolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Ergs => As(EnergyUnit.Erg); + public QuantityValue Ergs => As(EnergyUnit.Erg); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FootPounds => As(EnergyUnit.FootPound); + public QuantityValue FootPounds => As(EnergyUnit.FootPound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); + public QuantityValue GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); + public QuantityValue GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigajoules => As(EnergyUnit.Gigajoule); + public QuantityValue Gigajoules => As(EnergyUnit.Gigajoule); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattDays => As(EnergyUnit.GigawattDay); + public QuantityValue GigawattDays => As(EnergyUnit.GigawattDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattHours => As(EnergyUnit.GigawattHour); + public QuantityValue GigawattHours => As(EnergyUnit.GigawattHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HorsepowerHours => As(EnergyUnit.HorsepowerHour); + public QuantityValue HorsepowerHours => As(EnergyUnit.HorsepowerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Joules => As(EnergyUnit.Joule); + public QuantityValue Joules => As(EnergyUnit.Joule); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); + public QuantityValue KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilocalories => As(EnergyUnit.Kilocalorie); + public QuantityValue Kilocalories => As(EnergyUnit.Kilocalorie); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); + public QuantityValue KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilojoules => As(EnergyUnit.Kilojoule); + public QuantityValue Kilojoules => As(EnergyUnit.Kilojoule); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattDays => As(EnergyUnit.KilowattDay); + public QuantityValue KilowattDays => As(EnergyUnit.KilowattDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattHours => As(EnergyUnit.KilowattHour); + public QuantityValue KilowattHours => As(EnergyUnit.KilowattHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); + public QuantityValue MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megacalories => As(EnergyUnit.Megacalorie); + public QuantityValue Megacalories => As(EnergyUnit.Megacalorie); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); + public QuantityValue MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megajoules => As(EnergyUnit.Megajoule); + public QuantityValue Megajoules => As(EnergyUnit.Megajoule); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattDays => As(EnergyUnit.MegawattDay); + public QuantityValue MegawattDays => As(EnergyUnit.MegawattDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattHours => As(EnergyUnit.MegawattHour); + public QuantityValue MegawattHours => As(EnergyUnit.MegawattHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millijoules => As(EnergyUnit.Millijoule); + public QuantityValue Millijoules => As(EnergyUnit.Millijoule); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); + public QuantityValue TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattDays => As(EnergyUnit.TerawattDay); + public QuantityValue TerawattDays => As(EnergyUnit.TerawattDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattHours => As(EnergyUnit.TerawattHour); + public QuantityValue TerawattHours => As(EnergyUnit.TerawattHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ThermsEc => As(EnergyUnit.ThermEc); + public QuantityValue ThermsEc => As(EnergyUnit.ThermEc); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ThermsImperial => As(EnergyUnit.ThermImperial); + public QuantityValue ThermsImperial => As(EnergyUnit.ThermImperial); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ThermsUs => As(EnergyUnit.ThermUs); + public QuantityValue ThermsUs => As(EnergyUnit.ThermUs); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattDays => As(EnergyUnit.WattDay); + public QuantityValue WattDays => As(EnergyUnit.WattDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattHours => As(EnergyUnit.WattHour); + public QuantityValue WattHours => As(EnergyUnit.WattHour); #endregion @@ -551,7 +554,7 @@ public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Energy FromBritishThermalUnits(QuantityValue britishthermalunits) { - double value = (double) britishthermalunits; + QuantityValue value = (QuantityValue) britishthermalunits; return new Energy(value, EnergyUnit.BritishThermalUnit); } @@ -561,7 +564,7 @@ public static Energy FromBritishThermalUnits(QuantityValue britishthermalunits) /// If value is NaN or Infinity. public static Energy FromCalories(QuantityValue calories) { - double value = (double) calories; + QuantityValue value = (QuantityValue) calories; return new Energy(value, EnergyUnit.Calorie); } @@ -571,7 +574,7 @@ public static Energy FromCalories(QuantityValue calories) /// If value is NaN or Infinity. public static Energy FromDecathermsEc(QuantityValue decathermsec) { - double value = (double) decathermsec; + QuantityValue value = (QuantityValue) decathermsec; return new Energy(value, EnergyUnit.DecathermEc); } @@ -581,7 +584,7 @@ public static Energy FromDecathermsEc(QuantityValue decathermsec) /// If value is NaN or Infinity. public static Energy FromDecathermsImperial(QuantityValue decathermsimperial) { - double value = (double) decathermsimperial; + QuantityValue value = (QuantityValue) decathermsimperial; return new Energy(value, EnergyUnit.DecathermImperial); } @@ -591,7 +594,7 @@ public static Energy FromDecathermsImperial(QuantityValue decathermsimperial) /// If value is NaN or Infinity. public static Energy FromDecathermsUs(QuantityValue decathermsus) { - double value = (double) decathermsus; + QuantityValue value = (QuantityValue) decathermsus; return new Energy(value, EnergyUnit.DecathermUs); } @@ -601,7 +604,7 @@ public static Energy FromDecathermsUs(QuantityValue decathermsus) /// If value is NaN or Infinity. public static Energy FromElectronVolts(QuantityValue electronvolts) { - double value = (double) electronvolts; + QuantityValue value = (QuantityValue) electronvolts; return new Energy(value, EnergyUnit.ElectronVolt); } @@ -611,7 +614,7 @@ public static Energy FromElectronVolts(QuantityValue electronvolts) /// If value is NaN or Infinity. public static Energy FromErgs(QuantityValue ergs) { - double value = (double) ergs; + QuantityValue value = (QuantityValue) ergs; return new Energy(value, EnergyUnit.Erg); } @@ -621,7 +624,7 @@ public static Energy FromErgs(QuantityValue ergs) /// If value is NaN or Infinity. public static Energy FromFootPounds(QuantityValue footpounds) { - double value = (double) footpounds; + QuantityValue value = (QuantityValue) footpounds; return new Energy(value, EnergyUnit.FootPound); } @@ -631,7 +634,7 @@ public static Energy FromFootPounds(QuantityValue footpounds) /// If value is NaN or Infinity. public static Energy FromGigabritishThermalUnits(QuantityValue gigabritishthermalunits) { - double value = (double) gigabritishthermalunits; + QuantityValue value = (QuantityValue) gigabritishthermalunits; return new Energy(value, EnergyUnit.GigabritishThermalUnit); } @@ -641,7 +644,7 @@ public static Energy FromGigabritishThermalUnits(QuantityValue gigabritishtherma /// If value is NaN or Infinity. public static Energy FromGigaelectronVolts(QuantityValue gigaelectronvolts) { - double value = (double) gigaelectronvolts; + QuantityValue value = (QuantityValue) gigaelectronvolts; return new Energy(value, EnergyUnit.GigaelectronVolt); } @@ -651,7 +654,7 @@ public static Energy FromGigaelectronVolts(QuantityValue gigaelectronvolts) /// If value is NaN or Infinity. public static Energy FromGigajoules(QuantityValue gigajoules) { - double value = (double) gigajoules; + QuantityValue value = (QuantityValue) gigajoules; return new Energy(value, EnergyUnit.Gigajoule); } @@ -661,7 +664,7 @@ public static Energy FromGigajoules(QuantityValue gigajoules) /// If value is NaN or Infinity. public static Energy FromGigawattDays(QuantityValue gigawattdays) { - double value = (double) gigawattdays; + QuantityValue value = (QuantityValue) gigawattdays; return new Energy(value, EnergyUnit.GigawattDay); } @@ -671,7 +674,7 @@ public static Energy FromGigawattDays(QuantityValue gigawattdays) /// If value is NaN or Infinity. public static Energy FromGigawattHours(QuantityValue gigawatthours) { - double value = (double) gigawatthours; + QuantityValue value = (QuantityValue) gigawatthours; return new Energy(value, EnergyUnit.GigawattHour); } @@ -681,7 +684,7 @@ public static Energy FromGigawattHours(QuantityValue gigawatthours) /// If value is NaN or Infinity. public static Energy FromHorsepowerHours(QuantityValue horsepowerhours) { - double value = (double) horsepowerhours; + QuantityValue value = (QuantityValue) horsepowerhours; return new Energy(value, EnergyUnit.HorsepowerHour); } @@ -691,7 +694,7 @@ public static Energy FromHorsepowerHours(QuantityValue horsepowerhours) /// If value is NaN or Infinity. public static Energy FromJoules(QuantityValue joules) { - double value = (double) joules; + QuantityValue value = (QuantityValue) joules; return new Energy(value, EnergyUnit.Joule); } @@ -701,7 +704,7 @@ public static Energy FromJoules(QuantityValue joules) /// If value is NaN or Infinity. public static Energy FromKilobritishThermalUnits(QuantityValue kilobritishthermalunits) { - double value = (double) kilobritishthermalunits; + QuantityValue value = (QuantityValue) kilobritishthermalunits; return new Energy(value, EnergyUnit.KilobritishThermalUnit); } @@ -711,7 +714,7 @@ public static Energy FromKilobritishThermalUnits(QuantityValue kilobritishtherma /// If value is NaN or Infinity. public static Energy FromKilocalories(QuantityValue kilocalories) { - double value = (double) kilocalories; + QuantityValue value = (QuantityValue) kilocalories; return new Energy(value, EnergyUnit.Kilocalorie); } @@ -721,7 +724,7 @@ public static Energy FromKilocalories(QuantityValue kilocalories) /// If value is NaN or Infinity. public static Energy FromKiloelectronVolts(QuantityValue kiloelectronvolts) { - double value = (double) kiloelectronvolts; + QuantityValue value = (QuantityValue) kiloelectronvolts; return new Energy(value, EnergyUnit.KiloelectronVolt); } @@ -731,7 +734,7 @@ public static Energy FromKiloelectronVolts(QuantityValue kiloelectronvolts) /// If value is NaN or Infinity. public static Energy FromKilojoules(QuantityValue kilojoules) { - double value = (double) kilojoules; + QuantityValue value = (QuantityValue) kilojoules; return new Energy(value, EnergyUnit.Kilojoule); } @@ -741,7 +744,7 @@ public static Energy FromKilojoules(QuantityValue kilojoules) /// If value is NaN or Infinity. public static Energy FromKilowattDays(QuantityValue kilowattdays) { - double value = (double) kilowattdays; + QuantityValue value = (QuantityValue) kilowattdays; return new Energy(value, EnergyUnit.KilowattDay); } @@ -751,7 +754,7 @@ public static Energy FromKilowattDays(QuantityValue kilowattdays) /// If value is NaN or Infinity. public static Energy FromKilowattHours(QuantityValue kilowatthours) { - double value = (double) kilowatthours; + QuantityValue value = (QuantityValue) kilowatthours; return new Energy(value, EnergyUnit.KilowattHour); } @@ -761,7 +764,7 @@ public static Energy FromKilowattHours(QuantityValue kilowatthours) /// If value is NaN or Infinity. public static Energy FromMegabritishThermalUnits(QuantityValue megabritishthermalunits) { - double value = (double) megabritishthermalunits; + QuantityValue value = (QuantityValue) megabritishthermalunits; return new Energy(value, EnergyUnit.MegabritishThermalUnit); } @@ -771,7 +774,7 @@ public static Energy FromMegabritishThermalUnits(QuantityValue megabritishtherma /// If value is NaN or Infinity. public static Energy FromMegacalories(QuantityValue megacalories) { - double value = (double) megacalories; + QuantityValue value = (QuantityValue) megacalories; return new Energy(value, EnergyUnit.Megacalorie); } @@ -781,7 +784,7 @@ public static Energy FromMegacalories(QuantityValue megacalories) /// If value is NaN or Infinity. public static Energy FromMegaelectronVolts(QuantityValue megaelectronvolts) { - double value = (double) megaelectronvolts; + QuantityValue value = (QuantityValue) megaelectronvolts; return new Energy(value, EnergyUnit.MegaelectronVolt); } @@ -791,7 +794,7 @@ public static Energy FromMegaelectronVolts(QuantityValue megaelectronvolts) /// If value is NaN or Infinity. public static Energy FromMegajoules(QuantityValue megajoules) { - double value = (double) megajoules; + QuantityValue value = (QuantityValue) megajoules; return new Energy(value, EnergyUnit.Megajoule); } @@ -801,7 +804,7 @@ public static Energy FromMegajoules(QuantityValue megajoules) /// If value is NaN or Infinity. public static Energy FromMegawattDays(QuantityValue megawattdays) { - double value = (double) megawattdays; + QuantityValue value = (QuantityValue) megawattdays; return new Energy(value, EnergyUnit.MegawattDay); } @@ -811,7 +814,7 @@ public static Energy FromMegawattDays(QuantityValue megawattdays) /// If value is NaN or Infinity. public static Energy FromMegawattHours(QuantityValue megawatthours) { - double value = (double) megawatthours; + QuantityValue value = (QuantityValue) megawatthours; return new Energy(value, EnergyUnit.MegawattHour); } @@ -821,7 +824,7 @@ public static Energy FromMegawattHours(QuantityValue megawatthours) /// If value is NaN or Infinity. public static Energy FromMillijoules(QuantityValue millijoules) { - double value = (double) millijoules; + QuantityValue value = (QuantityValue) millijoules; return new Energy(value, EnergyUnit.Millijoule); } @@ -831,7 +834,7 @@ public static Energy FromMillijoules(QuantityValue millijoules) /// If value is NaN or Infinity. public static Energy FromTeraelectronVolts(QuantityValue teraelectronvolts) { - double value = (double) teraelectronvolts; + QuantityValue value = (QuantityValue) teraelectronvolts; return new Energy(value, EnergyUnit.TeraelectronVolt); } @@ -841,7 +844,7 @@ public static Energy FromTeraelectronVolts(QuantityValue teraelectronvolts) /// If value is NaN or Infinity. public static Energy FromTerawattDays(QuantityValue terawattdays) { - double value = (double) terawattdays; + QuantityValue value = (QuantityValue) terawattdays; return new Energy(value, EnergyUnit.TerawattDay); } @@ -851,7 +854,7 @@ public static Energy FromTerawattDays(QuantityValue terawattdays) /// If value is NaN or Infinity. public static Energy FromTerawattHours(QuantityValue terawatthours) { - double value = (double) terawatthours; + QuantityValue value = (QuantityValue) terawatthours; return new Energy(value, EnergyUnit.TerawattHour); } @@ -861,7 +864,7 @@ public static Energy FromTerawattHours(QuantityValue terawatthours) /// If value is NaN or Infinity. public static Energy FromThermsEc(QuantityValue thermsec) { - double value = (double) thermsec; + QuantityValue value = (QuantityValue) thermsec; return new Energy(value, EnergyUnit.ThermEc); } @@ -871,7 +874,7 @@ public static Energy FromThermsEc(QuantityValue thermsec) /// If value is NaN or Infinity. public static Energy FromThermsImperial(QuantityValue thermsimperial) { - double value = (double) thermsimperial; + QuantityValue value = (QuantityValue) thermsimperial; return new Energy(value, EnergyUnit.ThermImperial); } @@ -881,7 +884,7 @@ public static Energy FromThermsImperial(QuantityValue thermsimperial) /// If value is NaN or Infinity. public static Energy FromThermsUs(QuantityValue thermsus) { - double value = (double) thermsus; + QuantityValue value = (QuantityValue) thermsus; return new Energy(value, EnergyUnit.ThermUs); } @@ -891,7 +894,7 @@ public static Energy FromThermsUs(QuantityValue thermsus) /// If value is NaN or Infinity. public static Energy FromWattDays(QuantityValue wattdays) { - double value = (double) wattdays; + QuantityValue value = (QuantityValue) wattdays; return new Energy(value, EnergyUnit.WattDay); } @@ -901,7 +904,7 @@ public static Energy FromWattDays(QuantityValue wattdays) /// If value is NaN or Infinity. public static Energy FromWattHours(QuantityValue watthours) { - double value = (double) watthours; + QuantityValue value = (QuantityValue) watthours; return new Energy(value, EnergyUnit.WattHour); } @@ -913,7 +916,7 @@ public static Energy FromWattHours(QuantityValue watthours) /// Energy unit value. public static Energy From(QuantityValue value, EnergyUnit fromUnit) { - return new Energy((double)value, fromUnit); + return new Energy((QuantityValue)value, fromUnit); } #endregion @@ -1083,25 +1086,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ } /// Get from multiplying value and . - public static Energy operator *(double left, Energy right) + public static Energy operator *(QuantityValue left, Energy right) { return new Energy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Energy operator *(Energy left, double right) + public static Energy operator *(Energy left, QuantityValue right) { return new Energy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Energy operator /(Energy left, double right) + public static Energy operator /(Energy left, QuantityValue right) { return new Energy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Energy left, Energy right) + public static QuantityValue operator /(Energy left, Energy right) { return left.Joules / right.Joules; } @@ -1134,6 +1137,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Energy left, Energy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Energy left, Energy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1146,7 +1162,29 @@ public int CompareTo(object obj) /// public int CompareTo(Energy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Energy objEnergy)) + return false; + return Equals(objEnergy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Energy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1189,13 +1227,13 @@ public int CompareTo(Energy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Energy other, double tolerance, ComparisonType comparisonType) + public bool Equals(Energy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1206,7 +1244,7 @@ public bool Equals(Energy other, double tolerance, ComparisonType comparisonType /// A hash code for the current Energy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1217,17 +1255,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EnergyUnit unit) + public QuantityValue As(EnergyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1242,12 +1279,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is EnergyUnit unitAsEnergyUnit)) + if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return As(unitAsEnergyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1279,7 +1316,7 @@ public Energy ToUnit(EnergyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Energy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(EnergyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1287,17 +1324,17 @@ public Energy ToUnit(EnergyUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EnergyUnit unitAsEnergyUnit)) + if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1324,10 +1361,10 @@ public Energy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(EnergyUnit unit) + private QuantityValue GetValueAs(EnergyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 5a3eed83c2..125d9bac9c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units /// [DataContract] - public partial struct Entropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static Entropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Entropy(double value, EntropyUnit unit) + public Entropy(QuantityValue value, EntropyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public Entropy(double value, EntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Entropy(double value, UnitSystem unitSystem) + public Entropy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public Entropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,39 +166,39 @@ public Entropy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); + public QuantityValue CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); + public QuantityValue JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); + public QuantityValue JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); + public QuantityValue KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); + public QuantityValue KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); + public QuantityValue KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); + public QuantityValue MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); #endregion @@ -269,7 +272,7 @@ public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider /// If value is NaN or Infinity. public static Entropy FromCaloriesPerKelvin(QuantityValue caloriesperkelvin) { - double value = (double) caloriesperkelvin; + QuantityValue value = (QuantityValue) caloriesperkelvin; return new Entropy(value, EntropyUnit.CaloriePerKelvin); } @@ -279,7 +282,7 @@ public static Entropy FromCaloriesPerKelvin(QuantityValue caloriesperkelvin) /// If value is NaN or Infinity. public static Entropy FromJoulesPerDegreeCelsius(QuantityValue joulesperdegreecelsius) { - double value = (double) joulesperdegreecelsius; + QuantityValue value = (QuantityValue) joulesperdegreecelsius; return new Entropy(value, EntropyUnit.JoulePerDegreeCelsius); } @@ -289,7 +292,7 @@ public static Entropy FromJoulesPerDegreeCelsius(QuantityValue joulesperdegreece /// If value is NaN or Infinity. public static Entropy FromJoulesPerKelvin(QuantityValue joulesperkelvin) { - double value = (double) joulesperkelvin; + QuantityValue value = (QuantityValue) joulesperkelvin; return new Entropy(value, EntropyUnit.JoulePerKelvin); } @@ -299,7 +302,7 @@ public static Entropy FromJoulesPerKelvin(QuantityValue joulesperkelvin) /// If value is NaN or Infinity. public static Entropy FromKilocaloriesPerKelvin(QuantityValue kilocaloriesperkelvin) { - double value = (double) kilocaloriesperkelvin; + QuantityValue value = (QuantityValue) kilocaloriesperkelvin; return new Entropy(value, EntropyUnit.KilocaloriePerKelvin); } @@ -309,7 +312,7 @@ public static Entropy FromKilocaloriesPerKelvin(QuantityValue kilocaloriesperkel /// If value is NaN or Infinity. public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue kilojoulesperdegreecelsius) { - double value = (double) kilojoulesperdegreecelsius; + QuantityValue value = (QuantityValue) kilojoulesperdegreecelsius; return new Entropy(value, EntropyUnit.KilojoulePerDegreeCelsius); } @@ -319,7 +322,7 @@ public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue kilojoulesper /// If value is NaN or Infinity. public static Entropy FromKilojoulesPerKelvin(QuantityValue kilojoulesperkelvin) { - double value = (double) kilojoulesperkelvin; + QuantityValue value = (QuantityValue) kilojoulesperkelvin; return new Entropy(value, EntropyUnit.KilojoulePerKelvin); } @@ -329,7 +332,7 @@ public static Entropy FromKilojoulesPerKelvin(QuantityValue kilojoulesperkelvin) /// If value is NaN or Infinity. public static Entropy FromMegajoulesPerKelvin(QuantityValue megajoulesperkelvin) { - double value = (double) megajoulesperkelvin; + QuantityValue value = (QuantityValue) megajoulesperkelvin; return new Entropy(value, EntropyUnit.MegajoulePerKelvin); } @@ -341,7 +344,7 @@ public static Entropy FromMegajoulesPerKelvin(QuantityValue megajoulesperkelvin) /// Entropy unit value. public static Entropy From(QuantityValue value, EntropyUnit fromUnit) { - return new Entropy((double)value, fromUnit); + return new Entropy((QuantityValue)value, fromUnit); } #endregion @@ -511,25 +514,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro } /// Get from multiplying value and . - public static Entropy operator *(double left, Entropy right) + public static Entropy operator *(QuantityValue left, Entropy right) { return new Entropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Entropy operator *(Entropy left, double right) + public static Entropy operator *(Entropy left, QuantityValue right) { return new Entropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Entropy operator /(Entropy left, double right) + public static Entropy operator /(Entropy left, QuantityValue right) { return new Entropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Entropy left, Entropy right) + public static QuantityValue operator /(Entropy left, Entropy right) { return left.JoulesPerKelvin / right.JoulesPerKelvin; } @@ -562,6 +565,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Entropy left, Entropy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Entropy left, Entropy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -574,7 +590,29 @@ public int CompareTo(object obj) /// public int CompareTo(Entropy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Entropy objEntropy)) + return false; + return Equals(objEntropy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Entropy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -617,13 +655,13 @@ public int CompareTo(Entropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType) + public bool Equals(Entropy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -634,7 +672,7 @@ public bool Equals(Entropy other, double tolerance, ComparisonType comparisonTyp /// A hash code for the current Entropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -645,17 +683,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(EntropyUnit unit) + public QuantityValue As(EntropyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -670,12 +707,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is EntropyUnit unitAsEntropyUnit)) + if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return As(unitAsEntropyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -707,7 +744,7 @@ public Entropy ToUnit(EntropyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Entropy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(EntropyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -715,17 +752,17 @@ public Entropy ToUnit(EntropyUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EntropyUnit unitAsEntropyUnit)) + if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -752,10 +789,10 @@ public Entropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(EntropyUnit unit) + private QuantityValue GetValueAs(EntropyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 67478a3e16..08781f06c6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. /// [DataContract] - public partial struct Force : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,9 +86,9 @@ static Force() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Force(double value, ForceUnit unit) + public Force(QuantityValue value, ForceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -100,14 +100,14 @@ public Force(double value, ForceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Force(double value, UnitSystem unitSystem) + public Force(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -148,7 +148,10 @@ public Force(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -171,79 +174,79 @@ public Force(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decanewtons => As(ForceUnit.Decanewton); + public QuantityValue Decanewtons => As(ForceUnit.Decanewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Dyne => As(ForceUnit.Dyn); + public QuantityValue Dyne => As(ForceUnit.Dyn); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForce => As(ForceUnit.KilogramForce); + public QuantityValue KilogramsForce => As(ForceUnit.KilogramForce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilonewtons => As(ForceUnit.Kilonewton); + public QuantityValue Kilonewtons => As(ForceUnit.Kilonewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KiloPonds => As(ForceUnit.KiloPond); + public QuantityValue KiloPonds => As(ForceUnit.KiloPond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForce => As(ForceUnit.KilopoundForce); + public QuantityValue KilopoundsForce => As(ForceUnit.KilopoundForce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Meganewtons => As(ForceUnit.Meganewton); + public QuantityValue Meganewtons => As(ForceUnit.Meganewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Micronewtons => As(ForceUnit.Micronewton); + public QuantityValue Micronewtons => As(ForceUnit.Micronewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millinewtons => As(ForceUnit.Millinewton); + public QuantityValue Millinewtons => As(ForceUnit.Millinewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Newtons => As(ForceUnit.Newton); + public QuantityValue Newtons => As(ForceUnit.Newton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OunceForce => As(ForceUnit.OunceForce); + public QuantityValue OunceForce => As(ForceUnit.OunceForce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Poundals => As(ForceUnit.Poundal); + public QuantityValue Poundals => As(ForceUnit.Poundal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForce => As(ForceUnit.PoundForce); + public QuantityValue PoundsForce => As(ForceUnit.PoundForce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ShortTonsForce => As(ForceUnit.ShortTonForce); + public QuantityValue ShortTonsForce => As(ForceUnit.ShortTonForce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForce => As(ForceUnit.TonneForce); + public QuantityValue TonnesForce => As(ForceUnit.TonneForce); #endregion @@ -354,7 +357,7 @@ public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Force FromDecanewtons(QuantityValue decanewtons) { - double value = (double) decanewtons; + QuantityValue value = (QuantityValue) decanewtons; return new Force(value, ForceUnit.Decanewton); } @@ -364,7 +367,7 @@ public static Force FromDecanewtons(QuantityValue decanewtons) /// If value is NaN or Infinity. public static Force FromDyne(QuantityValue dyne) { - double value = (double) dyne; + QuantityValue value = (QuantityValue) dyne; return new Force(value, ForceUnit.Dyn); } @@ -374,7 +377,7 @@ public static Force FromDyne(QuantityValue dyne) /// If value is NaN or Infinity. public static Force FromKilogramsForce(QuantityValue kilogramsforce) { - double value = (double) kilogramsforce; + QuantityValue value = (QuantityValue) kilogramsforce; return new Force(value, ForceUnit.KilogramForce); } @@ -384,7 +387,7 @@ public static Force FromKilogramsForce(QuantityValue kilogramsforce) /// If value is NaN or Infinity. public static Force FromKilonewtons(QuantityValue kilonewtons) { - double value = (double) kilonewtons; + QuantityValue value = (QuantityValue) kilonewtons; return new Force(value, ForceUnit.Kilonewton); } @@ -394,7 +397,7 @@ public static Force FromKilonewtons(QuantityValue kilonewtons) /// If value is NaN or Infinity. public static Force FromKiloPonds(QuantityValue kiloponds) { - double value = (double) kiloponds; + QuantityValue value = (QuantityValue) kiloponds; return new Force(value, ForceUnit.KiloPond); } @@ -404,7 +407,7 @@ public static Force FromKiloPonds(QuantityValue kiloponds) /// If value is NaN or Infinity. public static Force FromKilopoundsForce(QuantityValue kilopoundsforce) { - double value = (double) kilopoundsforce; + QuantityValue value = (QuantityValue) kilopoundsforce; return new Force(value, ForceUnit.KilopoundForce); } @@ -414,7 +417,7 @@ public static Force FromKilopoundsForce(QuantityValue kilopoundsforce) /// If value is NaN or Infinity. public static Force FromMeganewtons(QuantityValue meganewtons) { - double value = (double) meganewtons; + QuantityValue value = (QuantityValue) meganewtons; return new Force(value, ForceUnit.Meganewton); } @@ -424,7 +427,7 @@ public static Force FromMeganewtons(QuantityValue meganewtons) /// If value is NaN or Infinity. public static Force FromMicronewtons(QuantityValue micronewtons) { - double value = (double) micronewtons; + QuantityValue value = (QuantityValue) micronewtons; return new Force(value, ForceUnit.Micronewton); } @@ -434,7 +437,7 @@ public static Force FromMicronewtons(QuantityValue micronewtons) /// If value is NaN or Infinity. public static Force FromMillinewtons(QuantityValue millinewtons) { - double value = (double) millinewtons; + QuantityValue value = (QuantityValue) millinewtons; return new Force(value, ForceUnit.Millinewton); } @@ -444,7 +447,7 @@ public static Force FromMillinewtons(QuantityValue millinewtons) /// If value is NaN or Infinity. public static Force FromNewtons(QuantityValue newtons) { - double value = (double) newtons; + QuantityValue value = (QuantityValue) newtons; return new Force(value, ForceUnit.Newton); } @@ -454,7 +457,7 @@ public static Force FromNewtons(QuantityValue newtons) /// If value is NaN or Infinity. public static Force FromOunceForce(QuantityValue ounceforce) { - double value = (double) ounceforce; + QuantityValue value = (QuantityValue) ounceforce; return new Force(value, ForceUnit.OunceForce); } @@ -464,7 +467,7 @@ public static Force FromOunceForce(QuantityValue ounceforce) /// If value is NaN or Infinity. public static Force FromPoundals(QuantityValue poundals) { - double value = (double) poundals; + QuantityValue value = (QuantityValue) poundals; return new Force(value, ForceUnit.Poundal); } @@ -474,7 +477,7 @@ public static Force FromPoundals(QuantityValue poundals) /// If value is NaN or Infinity. public static Force FromPoundsForce(QuantityValue poundsforce) { - double value = (double) poundsforce; + QuantityValue value = (QuantityValue) poundsforce; return new Force(value, ForceUnit.PoundForce); } @@ -484,7 +487,7 @@ public static Force FromPoundsForce(QuantityValue poundsforce) /// If value is NaN or Infinity. public static Force FromShortTonsForce(QuantityValue shorttonsforce) { - double value = (double) shorttonsforce; + QuantityValue value = (QuantityValue) shorttonsforce; return new Force(value, ForceUnit.ShortTonForce); } @@ -494,7 +497,7 @@ public static Force FromShortTonsForce(QuantityValue shorttonsforce) /// If value is NaN or Infinity. public static Force FromTonnesForce(QuantityValue tonnesforce) { - double value = (double) tonnesforce; + QuantityValue value = (QuantityValue) tonnesforce; return new Force(value, ForceUnit.TonneForce); } @@ -506,7 +509,7 @@ public static Force FromTonnesForce(QuantityValue tonnesforce) /// Force unit value. public static Force From(QuantityValue value, ForceUnit fromUnit) { - return new Force((double)value, fromUnit); + return new Force((QuantityValue)value, fromUnit); } #endregion @@ -676,25 +679,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static Force operator *(double left, Force right) + public static Force operator *(QuantityValue left, Force right) { return new Force(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Force operator *(Force left, double right) + public static Force operator *(Force left, QuantityValue right) { return new Force(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Force operator /(Force left, double right) + public static Force operator /(Force left, QuantityValue right) { return new Force(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Force left, Force right) + public static QuantityValue operator /(Force left, Force right) { return left.Newtons / right.Newtons; } @@ -727,6 +730,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Force left, Force right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Force left, Force right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -739,7 +755,29 @@ public int CompareTo(object obj) /// public int CompareTo(Force other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Force objForce)) + return false; + return Equals(objForce); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Force other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -782,13 +820,13 @@ public int CompareTo(Force other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Force other, double tolerance, ComparisonType comparisonType) + public bool Equals(Force other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -799,7 +837,7 @@ public bool Equals(Force other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Force. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -810,17 +848,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceUnit unit) + public QuantityValue As(ForceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -835,12 +872,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ForceUnit unitAsForceUnit)) + if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return As(unitAsForceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -872,7 +909,7 @@ public Force ToUnit(ForceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Force)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ForceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -880,17 +917,17 @@ public Force ToUnit(ForceUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceUnit unitAsForceUnit)) + if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -917,10 +954,10 @@ public Force ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ForceUnit unit) + private QuantityValue GetValueAs(ForceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 247b741b2a..8b897ef600 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). /// [DataContract] - public partial struct ForceChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -86,9 +86,9 @@ static ForceChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ForceChangeRate(double value, ForceChangeRateUnit unit) + public ForceChangeRate(QuantityValue value, ForceChangeRateUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -100,14 +100,14 @@ public ForceChangeRate(double value, ForceChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForceChangeRate(double value, UnitSystem unitSystem) + public ForceChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -148,7 +148,10 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -171,79 +174,79 @@ public ForceChangeRate(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); + public QuantityValue CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); + public QuantityValue DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); + public QuantityValue DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); + public QuantityValue DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); + public QuantityValue KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); + public QuantityValue KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); + public QuantityValue KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); + public QuantityValue KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); + public QuantityValue MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); + public QuantityValue MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); + public QuantityValue NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); + public QuantityValue NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); + public QuantityValue NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); + public QuantityValue PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); + public QuantityValue PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); #endregion @@ -341,7 +344,7 @@ public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue centinewtonspersecond) { - double value = (double) centinewtonspersecond; + QuantityValue value = (QuantityValue) centinewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.CentinewtonPerSecond); } @@ -351,7 +354,7 @@ public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue centinewto /// If value is NaN or Infinity. public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue decanewtonsperminute) { - double value = (double) decanewtonsperminute; + QuantityValue value = (QuantityValue) decanewtonsperminute; return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerMinute); } @@ -361,7 +364,7 @@ public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue decanewtons /// If value is NaN or Infinity. public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue decanewtonspersecond) { - double value = (double) decanewtonspersecond; + QuantityValue value = (QuantityValue) decanewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerSecond); } @@ -371,7 +374,7 @@ public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue decanewtons /// If value is NaN or Infinity. public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue decinewtonspersecond) { - double value = (double) decinewtonspersecond; + QuantityValue value = (QuantityValue) decinewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.DecinewtonPerSecond); } @@ -381,7 +384,7 @@ public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue decinewtons /// If value is NaN or Infinity. public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue kilonewtonsperminute) { - double value = (double) kilonewtonsperminute; + QuantityValue value = (QuantityValue) kilonewtonsperminute; return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerMinute); } @@ -391,7 +394,7 @@ public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue kilonewtons /// If value is NaN or Infinity. public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue kilonewtonspersecond) { - double value = (double) kilonewtonspersecond; + QuantityValue value = (QuantityValue) kilonewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerSecond); } @@ -401,7 +404,7 @@ public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue kilonewtons /// If value is NaN or Infinity. public static ForceChangeRate FromKilopoundsForcePerMinute(QuantityValue kilopoundsforceperminute) { - double value = (double) kilopoundsforceperminute; + QuantityValue value = (QuantityValue) kilopoundsforceperminute; return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerMinute); } @@ -411,7 +414,7 @@ public static ForceChangeRate FromKilopoundsForcePerMinute(QuantityValue kilopou /// If value is NaN or Infinity. public static ForceChangeRate FromKilopoundsForcePerSecond(QuantityValue kilopoundsforcepersecond) { - double value = (double) kilopoundsforcepersecond; + QuantityValue value = (QuantityValue) kilopoundsforcepersecond; return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerSecond); } @@ -421,7 +424,7 @@ public static ForceChangeRate FromKilopoundsForcePerSecond(QuantityValue kilopou /// If value is NaN or Infinity. public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue micronewtonspersecond) { - double value = (double) micronewtonspersecond; + QuantityValue value = (QuantityValue) micronewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.MicronewtonPerSecond); } @@ -431,7 +434,7 @@ public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue micronewto /// If value is NaN or Infinity. public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue millinewtonspersecond) { - double value = (double) millinewtonspersecond; + QuantityValue value = (QuantityValue) millinewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.MillinewtonPerSecond); } @@ -441,7 +444,7 @@ public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue millinewto /// If value is NaN or Infinity. public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue nanonewtonspersecond) { - double value = (double) nanonewtonspersecond; + QuantityValue value = (QuantityValue) nanonewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.NanonewtonPerSecond); } @@ -451,7 +454,7 @@ public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue nanonewtons /// If value is NaN or Infinity. public static ForceChangeRate FromNewtonsPerMinute(QuantityValue newtonsperminute) { - double value = (double) newtonsperminute; + QuantityValue value = (QuantityValue) newtonsperminute; return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerMinute); } @@ -461,7 +464,7 @@ public static ForceChangeRate FromNewtonsPerMinute(QuantityValue newtonsperminut /// If value is NaN or Infinity. public static ForceChangeRate FromNewtonsPerSecond(QuantityValue newtonspersecond) { - double value = (double) newtonspersecond; + QuantityValue value = (QuantityValue) newtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerSecond); } @@ -471,7 +474,7 @@ public static ForceChangeRate FromNewtonsPerSecond(QuantityValue newtonspersecon /// If value is NaN or Infinity. public static ForceChangeRate FromPoundsForcePerMinute(QuantityValue poundsforceperminute) { - double value = (double) poundsforceperminute; + QuantityValue value = (QuantityValue) poundsforceperminute; return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerMinute); } @@ -481,7 +484,7 @@ public static ForceChangeRate FromPoundsForcePerMinute(QuantityValue poundsforce /// If value is NaN or Infinity. public static ForceChangeRate FromPoundsForcePerSecond(QuantityValue poundsforcepersecond) { - double value = (double) poundsforcepersecond; + QuantityValue value = (QuantityValue) poundsforcepersecond; return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerSecond); } @@ -493,7 +496,7 @@ public static ForceChangeRate FromPoundsForcePerSecond(QuantityValue poundsforce /// ForceChangeRate unit value. public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit fromUnit) { - return new ForceChangeRate((double)value, fromUnit); + return new ForceChangeRate((QuantityValue)value, fromUnit); } #endregion @@ -663,25 +666,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static ForceChangeRate operator *(double left, ForceChangeRate right) + public static ForceChangeRate operator *(QuantityValue left, ForceChangeRate right) { return new ForceChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ForceChangeRate operator *(ForceChangeRate left, double right) + public static ForceChangeRate operator *(ForceChangeRate left, QuantityValue right) { return new ForceChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ForceChangeRate operator /(ForceChangeRate left, double right) + public static ForceChangeRate operator /(ForceChangeRate left, QuantityValue right) { return new ForceChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ForceChangeRate left, ForceChangeRate right) + public static QuantityValue operator /(ForceChangeRate left, ForceChangeRate right) { return left.NewtonsPerSecond / right.NewtonsPerSecond; } @@ -714,6 +717,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ForceChangeRate left, ForceChangeRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ForceChangeRate left, ForceChangeRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -726,7 +742,29 @@ public int CompareTo(object obj) /// public int CompareTo(ForceChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ForceChangeRate objForceChangeRate)) + return false; + return Equals(objForceChangeRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ForceChangeRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -769,13 +807,13 @@ public int CompareTo(ForceChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(ForceChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -786,7 +824,7 @@ public bool Equals(ForceChangeRate other, double tolerance, ComparisonType compa /// A hash code for the current ForceChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -797,17 +835,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForceChangeRateUnit unit) + public QuantityValue As(ForceChangeRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -822,12 +859,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) + if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsForceChangeRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -859,7 +896,7 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (ForceChangeRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ForceChangeRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -867,17 +904,17 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) + if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForceChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -904,10 +941,10 @@ public ForceChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ForceChangeRateUnit unit) + private QuantityValue GetValueAs(ForceChangeRateUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 820ff9473d..f937a368cf 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The magnitude of force per unit length. /// [DataContract] - public partial struct ForcePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -109,9 +109,9 @@ static ForcePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ForcePerLength(double value, ForcePerLengthUnit unit) + public ForcePerLength(QuantityValue value, ForcePerLengthUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -123,14 +123,14 @@ public ForcePerLength(double value, ForcePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForcePerLength(double value, UnitSystem unitSystem) + public ForcePerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -171,7 +171,10 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -194,194 +197,194 @@ public ForcePerLength(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); + public QuantityValue CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); + public QuantityValue CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); + public QuantityValue CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); + public QuantityValue DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); + public QuantityValue DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); + public QuantityValue DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); + public QuantityValue DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); + public QuantityValue DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); + public QuantityValue DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); + public QuantityValue KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); + public QuantityValue KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); + public QuantityValue KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); + public QuantityValue KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); + public QuantityValue KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); + public QuantityValue KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); + public QuantityValue KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); + public QuantityValue KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); + public QuantityValue MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); + public QuantityValue MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); + public QuantityValue MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); + public QuantityValue MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); + public QuantityValue MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); + public QuantityValue MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); + public QuantityValue MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); + public QuantityValue MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); + public QuantityValue MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); + public QuantityValue NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); + public QuantityValue NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); + public QuantityValue NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); + public QuantityValue NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); + public QuantityValue NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); + public QuantityValue NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); + public QuantityValue PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); + public QuantityValue PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); + public QuantityValue PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); + public QuantityValue TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); + public QuantityValue TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); + public QuantityValue TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); #endregion @@ -554,7 +557,7 @@ public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ForcePerLength FromCentinewtonsPerCentimeter(QuantityValue centinewtonspercentimeter) { - double value = (double) centinewtonspercentimeter; + QuantityValue value = (QuantityValue) centinewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerCentimeter); } @@ -564,7 +567,7 @@ public static ForcePerLength FromCentinewtonsPerCentimeter(QuantityValue centine /// If value is NaN or Infinity. public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue centinewtonspermeter) { - double value = (double) centinewtonspermeter; + QuantityValue value = (QuantityValue) centinewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter); } @@ -574,7 +577,7 @@ public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue centinewtons /// If value is NaN or Infinity. public static ForcePerLength FromCentinewtonsPerMillimeter(QuantityValue centinewtonspermillimeter) { - double value = (double) centinewtonspermillimeter; + QuantityValue value = (QuantityValue) centinewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMillimeter); } @@ -584,7 +587,7 @@ public static ForcePerLength FromCentinewtonsPerMillimeter(QuantityValue centine /// If value is NaN or Infinity. public static ForcePerLength FromDecanewtonsPerCentimeter(QuantityValue decanewtonspercentimeter) { - double value = (double) decanewtonspercentimeter; + QuantityValue value = (QuantityValue) decanewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerCentimeter); } @@ -594,7 +597,7 @@ public static ForcePerLength FromDecanewtonsPerCentimeter(QuantityValue decanewt /// If value is NaN or Infinity. public static ForcePerLength FromDecanewtonsPerMeter(QuantityValue decanewtonspermeter) { - double value = (double) decanewtonspermeter; + QuantityValue value = (QuantityValue) decanewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMeter); } @@ -604,7 +607,7 @@ public static ForcePerLength FromDecanewtonsPerMeter(QuantityValue decanewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromDecanewtonsPerMillimeter(QuantityValue decanewtonspermillimeter) { - double value = (double) decanewtonspermillimeter; + QuantityValue value = (QuantityValue) decanewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMillimeter); } @@ -614,7 +617,7 @@ public static ForcePerLength FromDecanewtonsPerMillimeter(QuantityValue decanewt /// If value is NaN or Infinity. public static ForcePerLength FromDecinewtonsPerCentimeter(QuantityValue decinewtonspercentimeter) { - double value = (double) decinewtonspercentimeter; + QuantityValue value = (QuantityValue) decinewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerCentimeter); } @@ -624,7 +627,7 @@ public static ForcePerLength FromDecinewtonsPerCentimeter(QuantityValue decinewt /// If value is NaN or Infinity. public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue decinewtonspermeter) { - double value = (double) decinewtonspermeter; + QuantityValue value = (QuantityValue) decinewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter); } @@ -634,7 +637,7 @@ public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue decinewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromDecinewtonsPerMillimeter(QuantityValue decinewtonspermillimeter) { - double value = (double) decinewtonspermillimeter; + QuantityValue value = (QuantityValue) decinewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMillimeter); } @@ -644,7 +647,7 @@ public static ForcePerLength FromDecinewtonsPerMillimeter(QuantityValue decinewt /// If value is NaN or Infinity. public static ForcePerLength FromKilogramsForcePerCentimeter(QuantityValue kilogramsforcepercentimeter) { - double value = (double) kilogramsforcepercentimeter; + QuantityValue value = (QuantityValue) kilogramsforcepercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerCentimeter); } @@ -654,7 +657,7 @@ public static ForcePerLength FromKilogramsForcePerCentimeter(QuantityValue kilog /// If value is NaN or Infinity. public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue kilogramsforcepermeter) { - double value = (double) kilogramsforcepermeter; + QuantityValue value = (QuantityValue) kilogramsforcepermeter; return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter); } @@ -664,7 +667,7 @@ public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue kilogramsf /// If value is NaN or Infinity. public static ForcePerLength FromKilogramsForcePerMillimeter(QuantityValue kilogramsforcepermillimeter) { - double value = (double) kilogramsforcepermillimeter; + QuantityValue value = (QuantityValue) kilogramsforcepermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMillimeter); } @@ -674,7 +677,7 @@ public static ForcePerLength FromKilogramsForcePerMillimeter(QuantityValue kilog /// If value is NaN or Infinity. public static ForcePerLength FromKilonewtonsPerCentimeter(QuantityValue kilonewtonspercentimeter) { - double value = (double) kilonewtonspercentimeter; + QuantityValue value = (QuantityValue) kilonewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerCentimeter); } @@ -684,7 +687,7 @@ public static ForcePerLength FromKilonewtonsPerCentimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue kilonewtonspermeter) { - double value = (double) kilonewtonspermeter; + QuantityValue value = (QuantityValue) kilonewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter); } @@ -694,7 +697,7 @@ public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue kilonewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromKilonewtonsPerMillimeter(QuantityValue kilonewtonspermillimeter) { - double value = (double) kilonewtonspermillimeter; + QuantityValue value = (QuantityValue) kilonewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMillimeter); } @@ -704,7 +707,7 @@ public static ForcePerLength FromKilonewtonsPerMillimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static ForcePerLength FromKilopoundsForcePerFoot(QuantityValue kilopoundsforceperfoot) { - double value = (double) kilopoundsforceperfoot; + QuantityValue value = (QuantityValue) kilopoundsforceperfoot; return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerFoot); } @@ -714,7 +717,7 @@ public static ForcePerLength FromKilopoundsForcePerFoot(QuantityValue kilopounds /// If value is NaN or Infinity. public static ForcePerLength FromKilopoundsForcePerInch(QuantityValue kilopoundsforceperinch) { - double value = (double) kilopoundsforceperinch; + QuantityValue value = (QuantityValue) kilopoundsforceperinch; return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerInch); } @@ -724,7 +727,7 @@ public static ForcePerLength FromKilopoundsForcePerInch(QuantityValue kilopounds /// If value is NaN or Infinity. public static ForcePerLength FromMeganewtonsPerCentimeter(QuantityValue meganewtonspercentimeter) { - double value = (double) meganewtonspercentimeter; + QuantityValue value = (QuantityValue) meganewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerCentimeter); } @@ -734,7 +737,7 @@ public static ForcePerLength FromMeganewtonsPerCentimeter(QuantityValue meganewt /// If value is NaN or Infinity. public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue meganewtonspermeter) { - double value = (double) meganewtonspermeter; + QuantityValue value = (QuantityValue) meganewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter); } @@ -744,7 +747,7 @@ public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue meganewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromMeganewtonsPerMillimeter(QuantityValue meganewtonspermillimeter) { - double value = (double) meganewtonspermillimeter; + QuantityValue value = (QuantityValue) meganewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMillimeter); } @@ -754,7 +757,7 @@ public static ForcePerLength FromMeganewtonsPerMillimeter(QuantityValue meganewt /// If value is NaN or Infinity. public static ForcePerLength FromMicronewtonsPerCentimeter(QuantityValue micronewtonspercentimeter) { - double value = (double) micronewtonspercentimeter; + QuantityValue value = (QuantityValue) micronewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerCentimeter); } @@ -764,7 +767,7 @@ public static ForcePerLength FromMicronewtonsPerCentimeter(QuantityValue microne /// If value is NaN or Infinity. public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue micronewtonspermeter) { - double value = (double) micronewtonspermeter; + QuantityValue value = (QuantityValue) micronewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter); } @@ -774,7 +777,7 @@ public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue micronewtons /// If value is NaN or Infinity. public static ForcePerLength FromMicronewtonsPerMillimeter(QuantityValue micronewtonspermillimeter) { - double value = (double) micronewtonspermillimeter; + QuantityValue value = (QuantityValue) micronewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMillimeter); } @@ -784,7 +787,7 @@ public static ForcePerLength FromMicronewtonsPerMillimeter(QuantityValue microne /// If value is NaN or Infinity. public static ForcePerLength FromMillinewtonsPerCentimeter(QuantityValue millinewtonspercentimeter) { - double value = (double) millinewtonspercentimeter; + QuantityValue value = (QuantityValue) millinewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerCentimeter); } @@ -794,7 +797,7 @@ public static ForcePerLength FromMillinewtonsPerCentimeter(QuantityValue milline /// If value is NaN or Infinity. public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue millinewtonspermeter) { - double value = (double) millinewtonspermeter; + QuantityValue value = (QuantityValue) millinewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter); } @@ -804,7 +807,7 @@ public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue millinewtons /// If value is NaN or Infinity. public static ForcePerLength FromMillinewtonsPerMillimeter(QuantityValue millinewtonspermillimeter) { - double value = (double) millinewtonspermillimeter; + QuantityValue value = (QuantityValue) millinewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMillimeter); } @@ -814,7 +817,7 @@ public static ForcePerLength FromMillinewtonsPerMillimeter(QuantityValue milline /// If value is NaN or Infinity. public static ForcePerLength FromNanonewtonsPerCentimeter(QuantityValue nanonewtonspercentimeter) { - double value = (double) nanonewtonspercentimeter; + QuantityValue value = (QuantityValue) nanonewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerCentimeter); } @@ -824,7 +827,7 @@ public static ForcePerLength FromNanonewtonsPerCentimeter(QuantityValue nanonewt /// If value is NaN or Infinity. public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue nanonewtonspermeter) { - double value = (double) nanonewtonspermeter; + QuantityValue value = (QuantityValue) nanonewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter); } @@ -834,7 +837,7 @@ public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue nanonewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromNanonewtonsPerMillimeter(QuantityValue nanonewtonspermillimeter) { - double value = (double) nanonewtonspermillimeter; + QuantityValue value = (QuantityValue) nanonewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMillimeter); } @@ -844,7 +847,7 @@ public static ForcePerLength FromNanonewtonsPerMillimeter(QuantityValue nanonewt /// If value is NaN or Infinity. public static ForcePerLength FromNewtonsPerCentimeter(QuantityValue newtonspercentimeter) { - double value = (double) newtonspercentimeter; + QuantityValue value = (QuantityValue) newtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerCentimeter); } @@ -854,7 +857,7 @@ public static ForcePerLength FromNewtonsPerCentimeter(QuantityValue newtonsperce /// If value is NaN or Infinity. public static ForcePerLength FromNewtonsPerMeter(QuantityValue newtonspermeter) { - double value = (double) newtonspermeter; + QuantityValue value = (QuantityValue) newtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter); } @@ -864,7 +867,7 @@ public static ForcePerLength FromNewtonsPerMeter(QuantityValue newtonspermeter) /// If value is NaN or Infinity. public static ForcePerLength FromNewtonsPerMillimeter(QuantityValue newtonspermillimeter) { - double value = (double) newtonspermillimeter; + QuantityValue value = (QuantityValue) newtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMillimeter); } @@ -874,7 +877,7 @@ public static ForcePerLength FromNewtonsPerMillimeter(QuantityValue newtonspermi /// If value is NaN or Infinity. public static ForcePerLength FromPoundsForcePerFoot(QuantityValue poundsforceperfoot) { - double value = (double) poundsforceperfoot; + QuantityValue value = (QuantityValue) poundsforceperfoot; return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerFoot); } @@ -884,7 +887,7 @@ public static ForcePerLength FromPoundsForcePerFoot(QuantityValue poundsforceper /// If value is NaN or Infinity. public static ForcePerLength FromPoundsForcePerInch(QuantityValue poundsforceperinch) { - double value = (double) poundsforceperinch; + QuantityValue value = (QuantityValue) poundsforceperinch; return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerInch); } @@ -894,7 +897,7 @@ public static ForcePerLength FromPoundsForcePerInch(QuantityValue poundsforceper /// If value is NaN or Infinity. public static ForcePerLength FromPoundsForcePerYard(QuantityValue poundsforceperyard) { - double value = (double) poundsforceperyard; + QuantityValue value = (QuantityValue) poundsforceperyard; return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerYard); } @@ -904,7 +907,7 @@ public static ForcePerLength FromPoundsForcePerYard(QuantityValue poundsforceper /// If value is NaN or Infinity. public static ForcePerLength FromTonnesForcePerCentimeter(QuantityValue tonnesforcepercentimeter) { - double value = (double) tonnesforcepercentimeter; + QuantityValue value = (QuantityValue) tonnesforcepercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerCentimeter); } @@ -914,7 +917,7 @@ public static ForcePerLength FromTonnesForcePerCentimeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static ForcePerLength FromTonnesForcePerMeter(QuantityValue tonnesforcepermeter) { - double value = (double) tonnesforcepermeter; + QuantityValue value = (QuantityValue) tonnesforcepermeter; return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMeter); } @@ -924,7 +927,7 @@ public static ForcePerLength FromTonnesForcePerMeter(QuantityValue tonnesforcepe /// If value is NaN or Infinity. public static ForcePerLength FromTonnesForcePerMillimeter(QuantityValue tonnesforcepermillimeter) { - double value = (double) tonnesforcepermillimeter; + QuantityValue value = (QuantityValue) tonnesforcepermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMillimeter); } @@ -936,7 +939,7 @@ public static ForcePerLength FromTonnesForcePerMillimeter(QuantityValue tonnesfo /// ForcePerLength unit value. public static ForcePerLength From(QuantityValue value, ForcePerLengthUnit fromUnit) { - return new ForcePerLength((double)value, fromUnit); + return new ForcePerLength((QuantityValue)value, fromUnit); } #endregion @@ -1106,25 +1109,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static ForcePerLength operator *(double left, ForcePerLength right) + public static ForcePerLength operator *(QuantityValue left, ForcePerLength right) { return new ForcePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ForcePerLength operator *(ForcePerLength left, double right) + public static ForcePerLength operator *(ForcePerLength left, QuantityValue right) { return new ForcePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ForcePerLength operator /(ForcePerLength left, double right) + public static ForcePerLength operator /(ForcePerLength left, QuantityValue right) { return new ForcePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ForcePerLength left, ForcePerLength right) + public static QuantityValue operator /(ForcePerLength left, ForcePerLength right) { return left.NewtonsPerMeter / right.NewtonsPerMeter; } @@ -1157,6 +1160,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ForcePerLength left, ForcePerLength right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ForcePerLength left, ForcePerLength right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1169,7 +1185,29 @@ public int CompareTo(object obj) /// public int CompareTo(ForcePerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ForcePerLength objForcePerLength)) + return false; + return Equals(objForcePerLength); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ForcePerLength other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1212,13 +1250,13 @@ public int CompareTo(ForcePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(ForcePerLength other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1229,7 +1267,7 @@ public bool Equals(ForcePerLength other, double tolerance, ComparisonType compar /// A hash code for the current ForcePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1240,17 +1278,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ForcePerLengthUnit unit) + public QuantityValue As(ForcePerLengthUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1265,12 +1302,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) + if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsForcePerLengthUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1302,7 +1339,7 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ForcePerLength)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ForcePerLengthUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1310,17 +1347,17 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) + if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForcePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1347,10 +1384,10 @@ public ForcePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ForcePerLengthUnit unit) + private QuantityValue GetValueAs(ForcePerLengthUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 695d03630d..190de13050 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The number of occurrences of a repeating event per unit time. /// [DataContract] - public partial struct Frequency : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,9 +82,9 @@ static Frequency() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Frequency(double value, FrequencyUnit unit) + public Frequency(QuantityValue value, FrequencyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -96,14 +96,14 @@ public Frequency(double value, FrequencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Frequency(double value, UnitSystem unitSystem) + public Frequency(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,7 +144,10 @@ public Frequency(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -167,59 +170,59 @@ public Frequency(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); + public QuantityValue BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BUnits => As(FrequencyUnit.BUnit); + public QuantityValue BUnits => As(FrequencyUnit.BUnit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CyclesPerHour => As(FrequencyUnit.CyclePerHour); + public QuantityValue CyclesPerHour => As(FrequencyUnit.CyclePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); + public QuantityValue CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigahertz => As(FrequencyUnit.Gigahertz); + public QuantityValue Gigahertz => As(FrequencyUnit.Gigahertz); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hertz => As(FrequencyUnit.Hertz); + public QuantityValue Hertz => As(FrequencyUnit.Hertz); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilohertz => As(FrequencyUnit.Kilohertz); + public QuantityValue Kilohertz => As(FrequencyUnit.Kilohertz); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megahertz => As(FrequencyUnit.Megahertz); + public QuantityValue Megahertz => As(FrequencyUnit.Megahertz); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PerSecond => As(FrequencyUnit.PerSecond); + public QuantityValue PerSecond => As(FrequencyUnit.PerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); + public QuantityValue RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Terahertz => As(FrequencyUnit.Terahertz); + public QuantityValue Terahertz => As(FrequencyUnit.Terahertz); #endregion @@ -248,7 +251,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: FrequencyUnit -> BaseUnit unitConverter.SetConversionFunction(FrequencyUnit.BeatPerMinute, FrequencyUnit.Hertz, quantity => new Frequency(quantity.Value / 60, FrequencyUnit.Hertz)); - unitConverter.SetConversionFunction(FrequencyUnit.BUnit, FrequencyUnit.Hertz, quantity => new Frequency(Math.Sqrt(quantity.Value * 1e3), FrequencyUnit.Hertz)); + unitConverter.SetConversionFunction(FrequencyUnit.BUnit, FrequencyUnit.Hertz, quantity => new Frequency(Math.Sqrt((double)quantity.Value * 1e3), FrequencyUnit.Hertz)); unitConverter.SetConversionFunction(FrequencyUnit.CyclePerHour, FrequencyUnit.Hertz, quantity => new Frequency(quantity.Value / 3600, FrequencyUnit.Hertz)); unitConverter.SetConversionFunction(FrequencyUnit.CyclePerMinute, FrequencyUnit.Hertz, quantity => new Frequency(quantity.Value / 60, FrequencyUnit.Hertz)); unitConverter.SetConversionFunction(FrequencyUnit.Gigahertz, FrequencyUnit.Hertz, quantity => new Frequency((quantity.Value) * 1e9d, FrequencyUnit.Hertz)); @@ -312,7 +315,7 @@ public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static Frequency FromBeatsPerMinute(QuantityValue beatsperminute) { - double value = (double) beatsperminute; + QuantityValue value = (QuantityValue) beatsperminute; return new Frequency(value, FrequencyUnit.BeatPerMinute); } @@ -322,7 +325,7 @@ public static Frequency FromBeatsPerMinute(QuantityValue beatsperminute) /// If value is NaN or Infinity. public static Frequency FromBUnits(QuantityValue bunits) { - double value = (double) bunits; + QuantityValue value = (QuantityValue) bunits; return new Frequency(value, FrequencyUnit.BUnit); } @@ -332,7 +335,7 @@ public static Frequency FromBUnits(QuantityValue bunits) /// If value is NaN or Infinity. public static Frequency FromCyclesPerHour(QuantityValue cyclesperhour) { - double value = (double) cyclesperhour; + QuantityValue value = (QuantityValue) cyclesperhour; return new Frequency(value, FrequencyUnit.CyclePerHour); } @@ -342,7 +345,7 @@ public static Frequency FromCyclesPerHour(QuantityValue cyclesperhour) /// If value is NaN or Infinity. public static Frequency FromCyclesPerMinute(QuantityValue cyclesperminute) { - double value = (double) cyclesperminute; + QuantityValue value = (QuantityValue) cyclesperminute; return new Frequency(value, FrequencyUnit.CyclePerMinute); } @@ -352,7 +355,7 @@ public static Frequency FromCyclesPerMinute(QuantityValue cyclesperminute) /// If value is NaN or Infinity. public static Frequency FromGigahertz(QuantityValue gigahertz) { - double value = (double) gigahertz; + QuantityValue value = (QuantityValue) gigahertz; return new Frequency(value, FrequencyUnit.Gigahertz); } @@ -362,7 +365,7 @@ public static Frequency FromGigahertz(QuantityValue gigahertz) /// If value is NaN or Infinity. public static Frequency FromHertz(QuantityValue hertz) { - double value = (double) hertz; + QuantityValue value = (QuantityValue) hertz; return new Frequency(value, FrequencyUnit.Hertz); } @@ -372,7 +375,7 @@ public static Frequency FromHertz(QuantityValue hertz) /// If value is NaN or Infinity. public static Frequency FromKilohertz(QuantityValue kilohertz) { - double value = (double) kilohertz; + QuantityValue value = (QuantityValue) kilohertz; return new Frequency(value, FrequencyUnit.Kilohertz); } @@ -382,7 +385,7 @@ public static Frequency FromKilohertz(QuantityValue kilohertz) /// If value is NaN or Infinity. public static Frequency FromMegahertz(QuantityValue megahertz) { - double value = (double) megahertz; + QuantityValue value = (QuantityValue) megahertz; return new Frequency(value, FrequencyUnit.Megahertz); } @@ -392,7 +395,7 @@ public static Frequency FromMegahertz(QuantityValue megahertz) /// If value is NaN or Infinity. public static Frequency FromPerSecond(QuantityValue persecond) { - double value = (double) persecond; + QuantityValue value = (QuantityValue) persecond; return new Frequency(value, FrequencyUnit.PerSecond); } @@ -402,7 +405,7 @@ public static Frequency FromPerSecond(QuantityValue persecond) /// If value is NaN or Infinity. public static Frequency FromRadiansPerSecond(QuantityValue radianspersecond) { - double value = (double) radianspersecond; + QuantityValue value = (QuantityValue) radianspersecond; return new Frequency(value, FrequencyUnit.RadianPerSecond); } @@ -412,7 +415,7 @@ public static Frequency FromRadiansPerSecond(QuantityValue radianspersecond) /// If value is NaN or Infinity. public static Frequency FromTerahertz(QuantityValue terahertz) { - double value = (double) terahertz; + QuantityValue value = (QuantityValue) terahertz; return new Frequency(value, FrequencyUnit.Terahertz); } @@ -424,7 +427,7 @@ public static Frequency FromTerahertz(QuantityValue terahertz) /// Frequency unit value. public static Frequency From(QuantityValue value, FrequencyUnit fromUnit) { - return new Frequency((double)value, fromUnit); + return new Frequency((QuantityValue)value, fromUnit); } #endregion @@ -594,25 +597,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ } /// Get from multiplying value and . - public static Frequency operator *(double left, Frequency right) + public static Frequency operator *(QuantityValue left, Frequency right) { return new Frequency(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Frequency operator *(Frequency left, double right) + public static Frequency operator *(Frequency left, QuantityValue right) { return new Frequency(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Frequency operator /(Frequency left, double right) + public static Frequency operator /(Frequency left, QuantityValue right) { return new Frequency(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Frequency left, Frequency right) + public static QuantityValue operator /(Frequency left, Frequency right) { return left.Hertz / right.Hertz; } @@ -645,6 +648,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Frequency left, Frequency right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Frequency left, Frequency right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -657,7 +673,29 @@ public int CompareTo(object obj) /// public int CompareTo(Frequency other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Frequency objFrequency)) + return false; + return Equals(objFrequency); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Frequency other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -700,13 +738,13 @@ public int CompareTo(Frequency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType) + public bool Equals(Frequency other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -717,7 +755,7 @@ public bool Equals(Frequency other, double tolerance, ComparisonType comparisonT /// A hash code for the current Frequency. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -728,17 +766,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FrequencyUnit unit) + public QuantityValue As(FrequencyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -753,12 +790,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is FrequencyUnit unitAsFrequencyUnit)) + if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return As(unitAsFrequencyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -790,7 +827,7 @@ public Frequency ToUnit(FrequencyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Frequency)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(FrequencyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -798,17 +835,17 @@ public Frequency ToUnit(FrequencyUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FrequencyUnit unitAsFrequencyUnit)) + if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsFrequencyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -835,10 +872,10 @@ public Frequency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(FrequencyUnit unit) + private QuantityValue GetValueAs(FrequencyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index c2a2cfcf02..279770ce94 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Fuel_efficiency /// [DataContract] - public partial struct FuelEfficiency : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static FuelEfficiency() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public FuelEfficiency(double value, FuelEfficiencyUnit unit) + public FuelEfficiency(QuantityValue value, FuelEfficiencyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public FuelEfficiency(double value, FuelEfficiencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public FuelEfficiency(double value, UnitSystem unitSystem) + public FuelEfficiency(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +166,24 @@ public FuelEfficiency(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); + public QuantityValue KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); + public QuantityValue LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); + public QuantityValue MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); + public QuantityValue MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); #endregion @@ -245,7 +248,7 @@ public static string GetAbbreviation(FuelEfficiencyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static FuelEfficiency FromKilometersPerLiters(QuantityValue kilometersperliters) { - double value = (double) kilometersperliters; + QuantityValue value = (QuantityValue) kilometersperliters; return new FuelEfficiency(value, FuelEfficiencyUnit.KilometerPerLiter); } @@ -255,7 +258,7 @@ public static FuelEfficiency FromKilometersPerLiters(QuantityValue kilometersper /// If value is NaN or Infinity. public static FuelEfficiency FromLitersPer100Kilometers(QuantityValue litersper100kilometers) { - double value = (double) litersper100kilometers; + QuantityValue value = (QuantityValue) litersper100kilometers; return new FuelEfficiency(value, FuelEfficiencyUnit.LiterPer100Kilometers); } @@ -265,7 +268,7 @@ public static FuelEfficiency FromLitersPer100Kilometers(QuantityValue litersper1 /// If value is NaN or Infinity. public static FuelEfficiency FromMilesPerUkGallon(QuantityValue milesperukgallon) { - double value = (double) milesperukgallon; + QuantityValue value = (QuantityValue) milesperukgallon; return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUkGallon); } @@ -275,7 +278,7 @@ public static FuelEfficiency FromMilesPerUkGallon(QuantityValue milesperukgallon /// If value is NaN or Infinity. public static FuelEfficiency FromMilesPerUsGallon(QuantityValue milesperusgallon) { - double value = (double) milesperusgallon; + QuantityValue value = (QuantityValue) milesperusgallon; return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUsGallon); } @@ -287,7 +290,7 @@ public static FuelEfficiency FromMilesPerUsGallon(QuantityValue milesperusgallon /// FuelEfficiency unit value. public static FuelEfficiency From(QuantityValue value, FuelEfficiencyUnit fromUnit) { - return new FuelEfficiency((double)value, fromUnit); + return new FuelEfficiency((QuantityValue)value, fromUnit); } #endregion @@ -457,25 +460,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE } /// Get from multiplying value and . - public static FuelEfficiency operator *(double left, FuelEfficiency right) + public static FuelEfficiency operator *(QuantityValue left, FuelEfficiency right) { return new FuelEfficiency(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static FuelEfficiency operator *(FuelEfficiency left, double right) + public static FuelEfficiency operator *(FuelEfficiency left, QuantityValue right) { return new FuelEfficiency(left.Value * right, left.Unit); } /// Get from dividing by value. - public static FuelEfficiency operator /(FuelEfficiency left, double right) + public static FuelEfficiency operator /(FuelEfficiency left, QuantityValue right) { return new FuelEfficiency(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(FuelEfficiency left, FuelEfficiency right) + public static QuantityValue operator /(FuelEfficiency left, FuelEfficiency right) { return left.LitersPer100Kilometers / right.LitersPer100Kilometers; } @@ -508,6 +511,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(FuelEfficiency left, FuelEfficiency right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(FuelEfficiency left, FuelEfficiency right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -520,7 +536,29 @@ public int CompareTo(object obj) /// public int CompareTo(FuelEfficiency other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is FuelEfficiency objFuelEfficiency)) + return false; + return Equals(objFuelEfficiency); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(FuelEfficiency other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -563,13 +601,13 @@ public int CompareTo(FuelEfficiency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(FuelEfficiency other, double tolerance, ComparisonType comparisonType) + public bool Equals(FuelEfficiency other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -580,7 +618,7 @@ public bool Equals(FuelEfficiency other, double tolerance, ComparisonType compar /// A hash code for the current FuelEfficiency. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -591,17 +629,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(FuelEfficiencyUnit unit) + public QuantityValue As(FuelEfficiencyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,12 +653,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) + if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return As(unitAsFuelEfficiencyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -653,7 +690,7 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (FuelEfficiency)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(FuelEfficiencyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -661,17 +698,17 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) + if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsFuelEfficiencyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -698,10 +735,10 @@ public FuelEfficiency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(FuelEfficiencyUnit unit) + private QuantityValue GetValueAs(FuelEfficiencyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 2b0f9a5278..be4d11404e 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Heat flux is the flow of energy per unit of area per unit of time /// [DataContract] - public partial struct HeatFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -89,9 +89,9 @@ static HeatFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public HeatFlux(double value, HeatFluxUnit unit) + public HeatFlux(QuantityValue value, HeatFluxUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -103,14 +103,14 @@ public HeatFlux(double value, HeatFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatFlux(double value, UnitSystem unitSystem) + public HeatFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -151,7 +151,10 @@ public HeatFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -174,94 +177,94 @@ public HeatFlux(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); + public QuantityValue BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); + public QuantityValue BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); + public QuantityValue BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); + public QuantityValue BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); + public QuantityValue CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); + public QuantityValue CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); + public QuantityValue DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); + public QuantityValue KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); + public QuantityValue KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); + public QuantityValue KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); + public QuantityValue MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); + public QuantityValue MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); + public QuantityValue NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); + public QuantityValue PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); + public QuantityValue PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); + public QuantityValue WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); + public QuantityValue WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); + public QuantityValue WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); #endregion @@ -368,7 +371,7 @@ public static string GetAbbreviation(HeatFluxUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue btusperhoursquarefoot) { - double value = (double) btusperhoursquarefoot; + QuantityValue value = (QuantityValue) btusperhoursquarefoot; return new HeatFlux(value, HeatFluxUnit.BtuPerHourSquareFoot); } @@ -378,7 +381,7 @@ public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue btusperhoursquare /// If value is NaN or Infinity. public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue btusperminutesquarefoot) { - double value = (double) btusperminutesquarefoot; + QuantityValue value = (QuantityValue) btusperminutesquarefoot; return new HeatFlux(value, HeatFluxUnit.BtuPerMinuteSquareFoot); } @@ -388,7 +391,7 @@ public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue btusperminutesq /// If value is NaN or Infinity. public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue btuspersecondsquarefoot) { - double value = (double) btuspersecondsquarefoot; + QuantityValue value = (QuantityValue) btuspersecondsquarefoot; return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareFoot); } @@ -398,7 +401,7 @@ public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue btuspersecondsq /// If value is NaN or Infinity. public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue btuspersecondsquareinch) { - double value = (double) btuspersecondsquareinch; + QuantityValue value = (QuantityValue) btuspersecondsquareinch; return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareInch); } @@ -408,7 +411,7 @@ public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue btuspersecondsq /// If value is NaN or Infinity. public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue caloriespersecondsquarecentimeter) { - double value = (double) caloriespersecondsquarecentimeter; + QuantityValue value = (QuantityValue) caloriespersecondsquarecentimeter; return new HeatFlux(value, HeatFluxUnit.CaloriePerSecondSquareCentimeter); } @@ -418,7 +421,7 @@ public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue calor /// If value is NaN or Infinity. public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue centiwattspersquaremeter) { - double value = (double) centiwattspersquaremeter; + QuantityValue value = (QuantityValue) centiwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.CentiwattPerSquareMeter); } @@ -428,7 +431,7 @@ public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue centiwattspers /// If value is NaN or Infinity. public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue deciwattspersquaremeter) { - double value = (double) deciwattspersquaremeter; + QuantityValue value = (QuantityValue) deciwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.DeciwattPerSquareMeter); } @@ -438,7 +441,7 @@ public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue deciwattspersqu /// If value is NaN or Infinity. public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue kilocaloriesperhoursquaremeter) { - double value = (double) kilocaloriesperhoursquaremeter; + QuantityValue value = (QuantityValue) kilocaloriesperhoursquaremeter; return new HeatFlux(value, HeatFluxUnit.KilocaloriePerHourSquareMeter); } @@ -448,7 +451,7 @@ public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue kilocalo /// If value is NaN or Infinity. public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue kilocaloriespersecondsquarecentimeter) { - double value = (double) kilocaloriespersecondsquarecentimeter; + QuantityValue value = (QuantityValue) kilocaloriespersecondsquarecentimeter; return new HeatFlux(value, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); } @@ -458,7 +461,7 @@ public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue k /// If value is NaN or Infinity. public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter) { - double value = (double) kilowattspersquaremeter; + QuantityValue value = (QuantityValue) kilowattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.KilowattPerSquareMeter); } @@ -468,7 +471,7 @@ public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue kilowattspersqu /// If value is NaN or Infinity. public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter) { - double value = (double) microwattspersquaremeter; + QuantityValue value = (QuantityValue) microwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.MicrowattPerSquareMeter); } @@ -478,7 +481,7 @@ public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue microwattspers /// If value is NaN or Infinity. public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter) { - double value = (double) milliwattspersquaremeter; + QuantityValue value = (QuantityValue) milliwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.MilliwattPerSquareMeter); } @@ -488,7 +491,7 @@ public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue milliwattspers /// If value is NaN or Infinity. public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter) { - double value = (double) nanowattspersquaremeter; + QuantityValue value = (QuantityValue) nanowattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.NanowattPerSquareMeter); } @@ -498,7 +501,7 @@ public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue nanowattspersqu /// If value is NaN or Infinity. public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue poundsforceperfootsecond) { - double value = (double) poundsforceperfootsecond; + QuantityValue value = (QuantityValue) poundsforceperfootsecond; return new HeatFlux(value, HeatFluxUnit.PoundForcePerFootSecond); } @@ -508,7 +511,7 @@ public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue poundsforceper /// If value is NaN or Infinity. public static HeatFlux FromPoundsPerSecondCubed(QuantityValue poundspersecondcubed) { - double value = (double) poundspersecondcubed; + QuantityValue value = (QuantityValue) poundspersecondcubed; return new HeatFlux(value, HeatFluxUnit.PoundPerSecondCubed); } @@ -518,7 +521,7 @@ public static HeatFlux FromPoundsPerSecondCubed(QuantityValue poundspersecondcub /// If value is NaN or Infinity. public static HeatFlux FromWattsPerSquareFoot(QuantityValue wattspersquarefoot) { - double value = (double) wattspersquarefoot; + QuantityValue value = (QuantityValue) wattspersquarefoot; return new HeatFlux(value, HeatFluxUnit.WattPerSquareFoot); } @@ -528,7 +531,7 @@ public static HeatFlux FromWattsPerSquareFoot(QuantityValue wattspersquarefoot) /// If value is NaN or Infinity. public static HeatFlux FromWattsPerSquareInch(QuantityValue wattspersquareinch) { - double value = (double) wattspersquareinch; + QuantityValue value = (QuantityValue) wattspersquareinch; return new HeatFlux(value, HeatFluxUnit.WattPerSquareInch); } @@ -538,7 +541,7 @@ public static HeatFlux FromWattsPerSquareInch(QuantityValue wattspersquareinch) /// If value is NaN or Infinity. public static HeatFlux FromWattsPerSquareMeter(QuantityValue wattspersquaremeter) { - double value = (double) wattspersquaremeter; + QuantityValue value = (QuantityValue) wattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.WattPerSquareMeter); } @@ -550,7 +553,7 @@ public static HeatFlux FromWattsPerSquareMeter(QuantityValue wattspersquaremeter /// HeatFlux unit value. public static HeatFlux From(QuantityValue value, HeatFluxUnit fromUnit) { - return new HeatFlux((double)value, fromUnit); + return new HeatFlux((QuantityValue)value, fromUnit); } #endregion @@ -720,25 +723,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF } /// Get from multiplying value and . - public static HeatFlux operator *(double left, HeatFlux right) + public static HeatFlux operator *(QuantityValue left, HeatFlux right) { return new HeatFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static HeatFlux operator *(HeatFlux left, double right) + public static HeatFlux operator *(HeatFlux left, QuantityValue right) { return new HeatFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static HeatFlux operator /(HeatFlux left, double right) + public static HeatFlux operator /(HeatFlux left, QuantityValue right) { return new HeatFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(HeatFlux left, HeatFlux right) + public static QuantityValue operator /(HeatFlux left, HeatFlux right) { return left.WattsPerSquareMeter / right.WattsPerSquareMeter; } @@ -771,6 +774,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(HeatFlux left, HeatFlux right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(HeatFlux left, HeatFlux right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -783,7 +799,29 @@ public int CompareTo(object obj) /// public int CompareTo(HeatFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is HeatFlux objHeatFlux)) + return false; + return Equals(objHeatFlux); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(HeatFlux other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -826,13 +864,13 @@ public int CompareTo(HeatFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(HeatFlux other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -843,7 +881,7 @@ public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonTy /// A hash code for the current HeatFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -854,17 +892,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatFluxUnit unit) + public QuantityValue As(HeatFluxUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -879,12 +916,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) + if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return As(unitAsHeatFluxUnit); + return (QuantityValue)As(typedUnit); } /// @@ -916,7 +953,7 @@ public HeatFlux ToUnit(HeatFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (HeatFlux)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(HeatFluxUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -924,17 +961,17 @@ public HeatFlux ToUnit(HeatFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) + if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsHeatFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -961,10 +998,10 @@ public HeatFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(HeatFluxUnit unit) + private QuantityValue GetValueAs(HeatFluxUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 2e7f448c7b..39919d552c 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) /// [DataContract] - public partial struct HeatTransferCoefficient : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static HeatTransferCoefficient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) + public HeatTransferCoefficient(QuantityValue value, HeatTransferCoefficientUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatTransferCoefficient(double value, UnitSystem unitSystem) + public HeatTransferCoefficient(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); + public QuantityValue BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + public QuantityValue WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + public QuantityValue WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(HeatTransferCoefficientUnit unit, IFormatPr /// If value is NaN or Infinity. public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(QuantityValue btuspersquarefootdegreefahrenheit) { - double value = (double) btuspersquarefootdegreefahrenheit; + QuantityValue value = (QuantityValue) btuspersquarefootdegreefahrenheit; return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); } @@ -243,7 +246,7 @@ public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(Quan /// If value is NaN or Infinity. public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityValue wattspersquaremetercelsius) { - double value = (double) wattspersquaremetercelsius; + QuantityValue value = (QuantityValue) wattspersquaremetercelsius; return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); } @@ -253,7 +256,7 @@ public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityVal /// If value is NaN or Infinity. public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValue wattspersquaremeterkelvin) { - double value = (double) wattspersquaremeterkelvin; + QuantityValue value = (QuantityValue) wattspersquaremeterkelvin; return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); } @@ -265,7 +268,7 @@ public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValu /// HeatTransferCoefficient unit value. public static HeatTransferCoefficient From(QuantityValue value, HeatTransferCoefficientUnit fromUnit) { - return new HeatTransferCoefficient((double)value, fromUnit); + return new HeatTransferCoefficient((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT } /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(double left, HeatTransferCoefficient right) + public static HeatTransferCoefficient operator *(QuantityValue left, HeatTransferCoefficient right) { return new HeatTransferCoefficient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, double right) + public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, QuantityValue right) { return new HeatTransferCoefficient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, double right) + public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, QuantityValue right) { return new HeatTransferCoefficient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static QuantityValue operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.WattsPerSquareMeterKelvin / right.WattsPerSquareMeterKelvin; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(HeatTransferCoefficient other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) + return false; + return Equals(objHeatTransferCoefficient); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(HeatTransferCoefficient other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(HeatTransferCoefficient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType) + public bool Equals(HeatTransferCoefficient other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonTy /// A hash code for the current HeatTransferCoefficient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(HeatTransferCoefficientUnit unit) + public QuantityValue As(HeatTransferCoefficientUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) + if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return As(unitAsHeatTransferCoefficientUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit, UnitConv var converted = conversionFunction(this); return (HeatTransferCoefficient)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(HeatTransferCoefficientUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit, UnitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) + if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsHeatTransferCoefficientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(HeatTransferCoefficientUnit unit) + private QuantityValue GetValueAs(HeatTransferCoefficientUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 304d11ab4d..66cc8c75f6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Illuminance /// [DataContract] - public partial struct Illuminance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static Illuminance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Illuminance(double value, IlluminanceUnit unit) + public Illuminance(QuantityValue value, IlluminanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public Illuminance(double value, IlluminanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Illuminance(double value, UnitSystem unitSystem) + public Illuminance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public Illuminance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +166,24 @@ public Illuminance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilolux => As(IlluminanceUnit.Kilolux); + public QuantityValue Kilolux => As(IlluminanceUnit.Kilolux); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Lux => As(IlluminanceUnit.Lux); + public QuantityValue Lux => As(IlluminanceUnit.Lux); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megalux => As(IlluminanceUnit.Megalux); + public QuantityValue Megalux => As(IlluminanceUnit.Megalux); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millilux => As(IlluminanceUnit.Millilux); + public QuantityValue Millilux => As(IlluminanceUnit.Millilux); #endregion @@ -245,7 +248,7 @@ public static string GetAbbreviation(IlluminanceUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Illuminance FromKilolux(QuantityValue kilolux) { - double value = (double) kilolux; + QuantityValue value = (QuantityValue) kilolux; return new Illuminance(value, IlluminanceUnit.Kilolux); } @@ -255,7 +258,7 @@ public static Illuminance FromKilolux(QuantityValue kilolux) /// If value is NaN or Infinity. public static Illuminance FromLux(QuantityValue lux) { - double value = (double) lux; + QuantityValue value = (QuantityValue) lux; return new Illuminance(value, IlluminanceUnit.Lux); } @@ -265,7 +268,7 @@ public static Illuminance FromLux(QuantityValue lux) /// If value is NaN or Infinity. public static Illuminance FromMegalux(QuantityValue megalux) { - double value = (double) megalux; + QuantityValue value = (QuantityValue) megalux; return new Illuminance(value, IlluminanceUnit.Megalux); } @@ -275,7 +278,7 @@ public static Illuminance FromMegalux(QuantityValue megalux) /// If value is NaN or Infinity. public static Illuminance FromMillilux(QuantityValue millilux) { - double value = (double) millilux; + QuantityValue value = (QuantityValue) millilux; return new Illuminance(value, IlluminanceUnit.Millilux); } @@ -287,7 +290,7 @@ public static Illuminance FromMillilux(QuantityValue millilux) /// Illuminance unit value. public static Illuminance From(QuantityValue value, IlluminanceUnit fromUnit) { - return new Illuminance((double)value, fromUnit); + return new Illuminance((QuantityValue)value, fromUnit); } #endregion @@ -457,25 +460,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum } /// Get from multiplying value and . - public static Illuminance operator *(double left, Illuminance right) + public static Illuminance operator *(QuantityValue left, Illuminance right) { return new Illuminance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Illuminance operator *(Illuminance left, double right) + public static Illuminance operator *(Illuminance left, QuantityValue right) { return new Illuminance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Illuminance operator /(Illuminance left, double right) + public static Illuminance operator /(Illuminance left, QuantityValue right) { return new Illuminance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Illuminance left, Illuminance right) + public static QuantityValue operator /(Illuminance left, Illuminance right) { return left.Lux / right.Lux; } @@ -508,6 +511,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Illuminance left, Illuminance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Illuminance left, Illuminance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -520,7 +536,29 @@ public int CompareTo(object obj) /// public int CompareTo(Illuminance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Illuminance objIlluminance)) + return false; + return Equals(objIlluminance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Illuminance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -563,13 +601,13 @@ public int CompareTo(Illuminance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType) + public bool Equals(Illuminance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -580,7 +618,7 @@ public bool Equals(Illuminance other, double tolerance, ComparisonType compariso /// A hash code for the current Illuminance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -591,17 +629,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IlluminanceUnit unit) + public QuantityValue As(IlluminanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,12 +653,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) + if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return As(unitAsIlluminanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -653,7 +690,7 @@ public Illuminance ToUnit(IlluminanceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Illuminance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(IlluminanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -661,17 +698,17 @@ public Illuminance ToUnit(IlluminanceUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) + if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIlluminanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -698,10 +735,10 @@ public Illuminance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(IlluminanceUnit unit) + private QuantityValue GetValueAs(IlluminanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 880f4a52fb..1c0f90b38f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. /// [DataContract] - public partial struct Information : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly decimal _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,7 +97,7 @@ static Information() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Information(decimal value, InformationUnit unit) + public Information(QuantityValue value, InformationUnit unit) { _value = value; _unit = unit; @@ -111,7 +111,7 @@ public Information(decimal value, InformationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Information(decimal value, UnitSystem unitSystem) + public Information(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,12 +159,13 @@ public Information(decimal value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public decimal Value => _value; + public QuantityValue Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// - decimal IDecimalQuantity.Value => _value; + decimal IDecimalQuantity.Value => (decimal)_value; Enum IQuantity.Unit => Unit; @@ -187,134 +188,134 @@ public Information(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Bits => As(InformationUnit.Bit); + public QuantityValue Bits => As(InformationUnit.Bit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Bytes => As(InformationUnit.Byte); + public QuantityValue Bytes => As(InformationUnit.Byte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Exabits => As(InformationUnit.Exabit); + public QuantityValue Exabits => As(InformationUnit.Exabit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Exabytes => As(InformationUnit.Exabyte); + public QuantityValue Exabytes => As(InformationUnit.Exabyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Exbibits => As(InformationUnit.Exbibit); + public QuantityValue Exbibits => As(InformationUnit.Exbibit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Exbibytes => As(InformationUnit.Exbibyte); + public QuantityValue Exbibytes => As(InformationUnit.Exbibyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gibibits => As(InformationUnit.Gibibit); + public QuantityValue Gibibits => As(InformationUnit.Gibibit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gibibytes => As(InformationUnit.Gibibyte); + public QuantityValue Gibibytes => As(InformationUnit.Gibibyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigabits => As(InformationUnit.Gigabit); + public QuantityValue Gigabits => As(InformationUnit.Gigabit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigabytes => As(InformationUnit.Gigabyte); + public QuantityValue Gigabytes => As(InformationUnit.Gigabyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kibibits => As(InformationUnit.Kibibit); + public QuantityValue Kibibits => As(InformationUnit.Kibibit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kibibytes => As(InformationUnit.Kibibyte); + public QuantityValue Kibibytes => As(InformationUnit.Kibibyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilobits => As(InformationUnit.Kilobit); + public QuantityValue Kilobits => As(InformationUnit.Kilobit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilobytes => As(InformationUnit.Kilobyte); + public QuantityValue Kilobytes => As(InformationUnit.Kilobyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Mebibits => As(InformationUnit.Mebibit); + public QuantityValue Mebibits => As(InformationUnit.Mebibit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Mebibytes => As(InformationUnit.Mebibyte); + public QuantityValue Mebibytes => As(InformationUnit.Mebibyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megabits => As(InformationUnit.Megabit); + public QuantityValue Megabits => As(InformationUnit.Megabit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megabytes => As(InformationUnit.Megabyte); + public QuantityValue Megabytes => As(InformationUnit.Megabyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Pebibits => As(InformationUnit.Pebibit); + public QuantityValue Pebibits => As(InformationUnit.Pebibit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Pebibytes => As(InformationUnit.Pebibyte); + public QuantityValue Pebibytes => As(InformationUnit.Pebibyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Petabits => As(InformationUnit.Petabit); + public QuantityValue Petabits => As(InformationUnit.Petabit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Petabytes => As(InformationUnit.Petabyte); + public QuantityValue Petabytes => As(InformationUnit.Petabyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Tebibits => As(InformationUnit.Tebibit); + public QuantityValue Tebibits => As(InformationUnit.Tebibit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Tebibytes => As(InformationUnit.Tebibyte); + public QuantityValue Tebibytes => As(InformationUnit.Tebibyte); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Terabits => As(InformationUnit.Terabit); + public QuantityValue Terabits => As(InformationUnit.Terabit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Terabytes => As(InformationUnit.Terabyte); + public QuantityValue Terabytes => As(InformationUnit.Terabyte); #endregion @@ -445,7 +446,7 @@ public static string GetAbbreviation(InformationUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Information FromBits(QuantityValue bits) { - decimal value = (decimal) bits; + QuantityValue value = (QuantityValue) bits; return new Information(value, InformationUnit.Bit); } @@ -455,7 +456,7 @@ public static Information FromBits(QuantityValue bits) /// If value is NaN or Infinity. public static Information FromBytes(QuantityValue bytes) { - decimal value = (decimal) bytes; + QuantityValue value = (QuantityValue) bytes; return new Information(value, InformationUnit.Byte); } @@ -465,7 +466,7 @@ public static Information FromBytes(QuantityValue bytes) /// If value is NaN or Infinity. public static Information FromExabits(QuantityValue exabits) { - decimal value = (decimal) exabits; + QuantityValue value = (QuantityValue) exabits; return new Information(value, InformationUnit.Exabit); } @@ -475,7 +476,7 @@ public static Information FromExabits(QuantityValue exabits) /// If value is NaN or Infinity. public static Information FromExabytes(QuantityValue exabytes) { - decimal value = (decimal) exabytes; + QuantityValue value = (QuantityValue) exabytes; return new Information(value, InformationUnit.Exabyte); } @@ -485,7 +486,7 @@ public static Information FromExabytes(QuantityValue exabytes) /// If value is NaN or Infinity. public static Information FromExbibits(QuantityValue exbibits) { - decimal value = (decimal) exbibits; + QuantityValue value = (QuantityValue) exbibits; return new Information(value, InformationUnit.Exbibit); } @@ -495,7 +496,7 @@ public static Information FromExbibits(QuantityValue exbibits) /// If value is NaN or Infinity. public static Information FromExbibytes(QuantityValue exbibytes) { - decimal value = (decimal) exbibytes; + QuantityValue value = (QuantityValue) exbibytes; return new Information(value, InformationUnit.Exbibyte); } @@ -505,7 +506,7 @@ public static Information FromExbibytes(QuantityValue exbibytes) /// If value is NaN or Infinity. public static Information FromGibibits(QuantityValue gibibits) { - decimal value = (decimal) gibibits; + QuantityValue value = (QuantityValue) gibibits; return new Information(value, InformationUnit.Gibibit); } @@ -515,7 +516,7 @@ public static Information FromGibibits(QuantityValue gibibits) /// If value is NaN or Infinity. public static Information FromGibibytes(QuantityValue gibibytes) { - decimal value = (decimal) gibibytes; + QuantityValue value = (QuantityValue) gibibytes; return new Information(value, InformationUnit.Gibibyte); } @@ -525,7 +526,7 @@ public static Information FromGibibytes(QuantityValue gibibytes) /// If value is NaN or Infinity. public static Information FromGigabits(QuantityValue gigabits) { - decimal value = (decimal) gigabits; + QuantityValue value = (QuantityValue) gigabits; return new Information(value, InformationUnit.Gigabit); } @@ -535,7 +536,7 @@ public static Information FromGigabits(QuantityValue gigabits) /// If value is NaN or Infinity. public static Information FromGigabytes(QuantityValue gigabytes) { - decimal value = (decimal) gigabytes; + QuantityValue value = (QuantityValue) gigabytes; return new Information(value, InformationUnit.Gigabyte); } @@ -545,7 +546,7 @@ public static Information FromGigabytes(QuantityValue gigabytes) /// If value is NaN or Infinity. public static Information FromKibibits(QuantityValue kibibits) { - decimal value = (decimal) kibibits; + QuantityValue value = (QuantityValue) kibibits; return new Information(value, InformationUnit.Kibibit); } @@ -555,7 +556,7 @@ public static Information FromKibibits(QuantityValue kibibits) /// If value is NaN or Infinity. public static Information FromKibibytes(QuantityValue kibibytes) { - decimal value = (decimal) kibibytes; + QuantityValue value = (QuantityValue) kibibytes; return new Information(value, InformationUnit.Kibibyte); } @@ -565,7 +566,7 @@ public static Information FromKibibytes(QuantityValue kibibytes) /// If value is NaN or Infinity. public static Information FromKilobits(QuantityValue kilobits) { - decimal value = (decimal) kilobits; + QuantityValue value = (QuantityValue) kilobits; return new Information(value, InformationUnit.Kilobit); } @@ -575,7 +576,7 @@ public static Information FromKilobits(QuantityValue kilobits) /// If value is NaN or Infinity. public static Information FromKilobytes(QuantityValue kilobytes) { - decimal value = (decimal) kilobytes; + QuantityValue value = (QuantityValue) kilobytes; return new Information(value, InformationUnit.Kilobyte); } @@ -585,7 +586,7 @@ public static Information FromKilobytes(QuantityValue kilobytes) /// If value is NaN or Infinity. public static Information FromMebibits(QuantityValue mebibits) { - decimal value = (decimal) mebibits; + QuantityValue value = (QuantityValue) mebibits; return new Information(value, InformationUnit.Mebibit); } @@ -595,7 +596,7 @@ public static Information FromMebibits(QuantityValue mebibits) /// If value is NaN or Infinity. public static Information FromMebibytes(QuantityValue mebibytes) { - decimal value = (decimal) mebibytes; + QuantityValue value = (QuantityValue) mebibytes; return new Information(value, InformationUnit.Mebibyte); } @@ -605,7 +606,7 @@ public static Information FromMebibytes(QuantityValue mebibytes) /// If value is NaN or Infinity. public static Information FromMegabits(QuantityValue megabits) { - decimal value = (decimal) megabits; + QuantityValue value = (QuantityValue) megabits; return new Information(value, InformationUnit.Megabit); } @@ -615,7 +616,7 @@ public static Information FromMegabits(QuantityValue megabits) /// If value is NaN or Infinity. public static Information FromMegabytes(QuantityValue megabytes) { - decimal value = (decimal) megabytes; + QuantityValue value = (QuantityValue) megabytes; return new Information(value, InformationUnit.Megabyte); } @@ -625,7 +626,7 @@ public static Information FromMegabytes(QuantityValue megabytes) /// If value is NaN or Infinity. public static Information FromPebibits(QuantityValue pebibits) { - decimal value = (decimal) pebibits; + QuantityValue value = (QuantityValue) pebibits; return new Information(value, InformationUnit.Pebibit); } @@ -635,7 +636,7 @@ public static Information FromPebibits(QuantityValue pebibits) /// If value is NaN or Infinity. public static Information FromPebibytes(QuantityValue pebibytes) { - decimal value = (decimal) pebibytes; + QuantityValue value = (QuantityValue) pebibytes; return new Information(value, InformationUnit.Pebibyte); } @@ -645,7 +646,7 @@ public static Information FromPebibytes(QuantityValue pebibytes) /// If value is NaN or Infinity. public static Information FromPetabits(QuantityValue petabits) { - decimal value = (decimal) petabits; + QuantityValue value = (QuantityValue) petabits; return new Information(value, InformationUnit.Petabit); } @@ -655,7 +656,7 @@ public static Information FromPetabits(QuantityValue petabits) /// If value is NaN or Infinity. public static Information FromPetabytes(QuantityValue petabytes) { - decimal value = (decimal) petabytes; + QuantityValue value = (QuantityValue) petabytes; return new Information(value, InformationUnit.Petabyte); } @@ -665,7 +666,7 @@ public static Information FromPetabytes(QuantityValue petabytes) /// If value is NaN or Infinity. public static Information FromTebibits(QuantityValue tebibits) { - decimal value = (decimal) tebibits; + QuantityValue value = (QuantityValue) tebibits; return new Information(value, InformationUnit.Tebibit); } @@ -675,7 +676,7 @@ public static Information FromTebibits(QuantityValue tebibits) /// If value is NaN or Infinity. public static Information FromTebibytes(QuantityValue tebibytes) { - decimal value = (decimal) tebibytes; + QuantityValue value = (QuantityValue) tebibytes; return new Information(value, InformationUnit.Tebibyte); } @@ -685,7 +686,7 @@ public static Information FromTebibytes(QuantityValue tebibytes) /// If value is NaN or Infinity. public static Information FromTerabits(QuantityValue terabits) { - decimal value = (decimal) terabits; + QuantityValue value = (QuantityValue) terabits; return new Information(value, InformationUnit.Terabit); } @@ -695,7 +696,7 @@ public static Information FromTerabits(QuantityValue terabits) /// If value is NaN or Infinity. public static Information FromTerabytes(QuantityValue terabytes) { - decimal value = (decimal) terabytes; + QuantityValue value = (QuantityValue) terabytes; return new Information(value, InformationUnit.Terabyte); } @@ -707,7 +708,7 @@ public static Information FromTerabytes(QuantityValue terabytes) /// Information unit value. public static Information From(QuantityValue value, InformationUnit fromUnit) { - return new Information((decimal)value, fromUnit); + return new Information((QuantityValue)value, fromUnit); } #endregion @@ -877,25 +878,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor } /// Get from multiplying value and . - public static Information operator *(decimal left, Information right) + public static Information operator *(QuantityValue left, Information right) { return new Information(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Information operator *(Information left, decimal right) + public static Information operator *(Information left, QuantityValue right) { return new Information(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Information operator /(Information left, decimal right) + public static Information operator /(Information left, QuantityValue right) { return new Information(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Information left, Information right) + public static QuantityValue operator /(Information left, Information right) { return left.Bits / right.Bits; } @@ -928,6 +929,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Information left, Information right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Information left, Information right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -940,7 +954,29 @@ public int CompareTo(object obj) /// public int CompareTo(Information other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Information objInformation)) + return false; + return Equals(objInformation); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Information other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -983,13 +1019,13 @@ public int CompareTo(Information other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Information other, double tolerance, ComparisonType comparisonType) + public bool Equals(Information other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1000,7 +1036,7 @@ public bool Equals(Information other, double tolerance, ComparisonType compariso /// A hash code for the current Information. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1011,17 +1047,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(InformationUnit unit) + public QuantityValue As(InformationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1036,12 +1071,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is InformationUnit unitAsInformationUnit)) + if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return As(unitAsInformationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1073,7 +1108,7 @@ public Information ToUnit(InformationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Information)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(InformationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1081,17 +1116,17 @@ public Information ToUnit(InformationUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is InformationUnit unitAsInformationUnit)) + if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsInformationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1118,10 +1153,10 @@ public Information ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private decimal GetValueAs(InformationUnit unit) + private QuantityValue GetValueAs(InformationUnit unit) { var converted = ToUnit(unit); - return (decimal)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index f395d39318..155555ecc5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. /// [DataContract] - public partial struct Irradiance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static Irradiance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Irradiance(double value, IrradianceUnit unit) + public Irradiance(QuantityValue value, IrradianceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -99,14 +99,14 @@ public Irradiance(double value, IrradianceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiance(double value, UnitSystem unitSystem) + public Irradiance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,7 +147,10 @@ public Irradiance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -170,74 +173,74 @@ public Irradiance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); + public QuantityValue KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); + public QuantityValue KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); + public QuantityValue MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); + public QuantityValue MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); + public QuantityValue MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); + public QuantityValue MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); + public QuantityValue MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); + public QuantityValue MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); + public QuantityValue NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); + public QuantityValue NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); + public QuantityValue PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); + public QuantityValue PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); + public QuantityValue WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); + public QuantityValue WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); #endregion @@ -332,7 +335,7 @@ public static string GetAbbreviation(IrradianceUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static Irradiance FromKilowattsPerSquareCentimeter(QuantityValue kilowattspersquarecentimeter) { - double value = (double) kilowattspersquarecentimeter; + QuantityValue value = (QuantityValue) kilowattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.KilowattPerSquareCentimeter); } @@ -342,7 +345,7 @@ public static Irradiance FromKilowattsPerSquareCentimeter(QuantityValue kilowatt /// If value is NaN or Infinity. public static Irradiance FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter) { - double value = (double) kilowattspersquaremeter; + QuantityValue value = (QuantityValue) kilowattspersquaremeter; return new Irradiance(value, IrradianceUnit.KilowattPerSquareMeter); } @@ -352,7 +355,7 @@ public static Irradiance FromKilowattsPerSquareMeter(QuantityValue kilowattspers /// If value is NaN or Infinity. public static Irradiance FromMegawattsPerSquareCentimeter(QuantityValue megawattspersquarecentimeter) { - double value = (double) megawattspersquarecentimeter; + QuantityValue value = (QuantityValue) megawattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.MegawattPerSquareCentimeter); } @@ -362,7 +365,7 @@ public static Irradiance FromMegawattsPerSquareCentimeter(QuantityValue megawatt /// If value is NaN or Infinity. public static Irradiance FromMegawattsPerSquareMeter(QuantityValue megawattspersquaremeter) { - double value = (double) megawattspersquaremeter; + QuantityValue value = (QuantityValue) megawattspersquaremeter; return new Irradiance(value, IrradianceUnit.MegawattPerSquareMeter); } @@ -372,7 +375,7 @@ public static Irradiance FromMegawattsPerSquareMeter(QuantityValue megawattspers /// If value is NaN or Infinity. public static Irradiance FromMicrowattsPerSquareCentimeter(QuantityValue microwattspersquarecentimeter) { - double value = (double) microwattspersquarecentimeter; + QuantityValue value = (QuantityValue) microwattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.MicrowattPerSquareCentimeter); } @@ -382,7 +385,7 @@ public static Irradiance FromMicrowattsPerSquareCentimeter(QuantityValue microwa /// If value is NaN or Infinity. public static Irradiance FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter) { - double value = (double) microwattspersquaremeter; + QuantityValue value = (QuantityValue) microwattspersquaremeter; return new Irradiance(value, IrradianceUnit.MicrowattPerSquareMeter); } @@ -392,7 +395,7 @@ public static Irradiance FromMicrowattsPerSquareMeter(QuantityValue microwattspe /// If value is NaN or Infinity. public static Irradiance FromMilliwattsPerSquareCentimeter(QuantityValue milliwattspersquarecentimeter) { - double value = (double) milliwattspersquarecentimeter; + QuantityValue value = (QuantityValue) milliwattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.MilliwattPerSquareCentimeter); } @@ -402,7 +405,7 @@ public static Irradiance FromMilliwattsPerSquareCentimeter(QuantityValue milliwa /// If value is NaN or Infinity. public static Irradiance FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter) { - double value = (double) milliwattspersquaremeter; + QuantityValue value = (QuantityValue) milliwattspersquaremeter; return new Irradiance(value, IrradianceUnit.MilliwattPerSquareMeter); } @@ -412,7 +415,7 @@ public static Irradiance FromMilliwattsPerSquareMeter(QuantityValue milliwattspe /// If value is NaN or Infinity. public static Irradiance FromNanowattsPerSquareCentimeter(QuantityValue nanowattspersquarecentimeter) { - double value = (double) nanowattspersquarecentimeter; + QuantityValue value = (QuantityValue) nanowattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.NanowattPerSquareCentimeter); } @@ -422,7 +425,7 @@ public static Irradiance FromNanowattsPerSquareCentimeter(QuantityValue nanowatt /// If value is NaN or Infinity. public static Irradiance FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter) { - double value = (double) nanowattspersquaremeter; + QuantityValue value = (QuantityValue) nanowattspersquaremeter; return new Irradiance(value, IrradianceUnit.NanowattPerSquareMeter); } @@ -432,7 +435,7 @@ public static Irradiance FromNanowattsPerSquareMeter(QuantityValue nanowattspers /// If value is NaN or Infinity. public static Irradiance FromPicowattsPerSquareCentimeter(QuantityValue picowattspersquarecentimeter) { - double value = (double) picowattspersquarecentimeter; + QuantityValue value = (QuantityValue) picowattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.PicowattPerSquareCentimeter); } @@ -442,7 +445,7 @@ public static Irradiance FromPicowattsPerSquareCentimeter(QuantityValue picowatt /// If value is NaN or Infinity. public static Irradiance FromPicowattsPerSquareMeter(QuantityValue picowattspersquaremeter) { - double value = (double) picowattspersquaremeter; + QuantityValue value = (QuantityValue) picowattspersquaremeter; return new Irradiance(value, IrradianceUnit.PicowattPerSquareMeter); } @@ -452,7 +455,7 @@ public static Irradiance FromPicowattsPerSquareMeter(QuantityValue picowattspers /// If value is NaN or Infinity. public static Irradiance FromWattsPerSquareCentimeter(QuantityValue wattspersquarecentimeter) { - double value = (double) wattspersquarecentimeter; + QuantityValue value = (QuantityValue) wattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.WattPerSquareCentimeter); } @@ -462,7 +465,7 @@ public static Irradiance FromWattsPerSquareCentimeter(QuantityValue wattspersqua /// If value is NaN or Infinity. public static Irradiance FromWattsPerSquareMeter(QuantityValue wattspersquaremeter) { - double value = (double) wattspersquaremeter; + QuantityValue value = (QuantityValue) wattspersquaremeter; return new Irradiance(value, IrradianceUnit.WattPerSquareMeter); } @@ -474,7 +477,7 @@ public static Irradiance FromWattsPerSquareMeter(QuantityValue wattspersquaremet /// Irradiance unit value. public static Irradiance From(QuantityValue value, IrradianceUnit fromUnit) { - return new Irradiance((double)value, fromUnit); + return new Irradiance((QuantityValue)value, fromUnit); } #endregion @@ -644,25 +647,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad } /// Get from multiplying value and . - public static Irradiance operator *(double left, Irradiance right) + public static Irradiance operator *(QuantityValue left, Irradiance right) { return new Irradiance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Irradiance operator *(Irradiance left, double right) + public static Irradiance operator *(Irradiance left, QuantityValue right) { return new Irradiance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Irradiance operator /(Irradiance left, double right) + public static Irradiance operator /(Irradiance left, QuantityValue right) { return new Irradiance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Irradiance left, Irradiance right) + public static QuantityValue operator /(Irradiance left, Irradiance right) { return left.WattsPerSquareMeter / right.WattsPerSquareMeter; } @@ -695,6 +698,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Irradiance left, Irradiance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Irradiance left, Irradiance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -707,7 +723,29 @@ public int CompareTo(object obj) /// public int CompareTo(Irradiance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Irradiance objIrradiance)) + return false; + return Equals(objIrradiance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Irradiance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -750,13 +788,13 @@ public int CompareTo(Irradiance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType) + public bool Equals(Irradiance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -767,7 +805,7 @@ public bool Equals(Irradiance other, double tolerance, ComparisonType comparison /// A hash code for the current Irradiance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -778,17 +816,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradianceUnit unit) + public QuantityValue As(IrradianceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -803,12 +840,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is IrradianceUnit unitAsIrradianceUnit)) + if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return As(unitAsIrradianceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -840,7 +877,7 @@ public Irradiance ToUnit(IrradianceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Irradiance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(IrradianceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -848,17 +885,17 @@ public Irradiance ToUnit(IrradianceUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradianceUnit unitAsIrradianceUnit)) + if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIrradianceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -885,10 +922,10 @@ public Irradiance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(IrradianceUnit unit) + private QuantityValue GetValueAs(IrradianceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 9ddd5731b6..943088a2af 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Irradiation /// [DataContract] - public partial struct Irradiation : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static Irradiation() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Irradiation(double value, IrradiationUnit unit) + public Irradiation(QuantityValue value, IrradiationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -95,14 +95,14 @@ public Irradiation(double value, IrradiationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiation(double value, UnitSystem unitSystem) + public Irradiation(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,7 +143,10 @@ public Irradiation(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -166,39 +169,39 @@ public Irradiation(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); + public QuantityValue JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); + public QuantityValue JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); + public QuantityValue JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); + public QuantityValue KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); + public QuantityValue KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); + public QuantityValue MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); + public QuantityValue WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); #endregion @@ -272,7 +275,7 @@ public static string GetAbbreviation(IrradiationUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Irradiation FromJoulesPerSquareCentimeter(QuantityValue joulespersquarecentimeter) { - double value = (double) joulespersquarecentimeter; + QuantityValue value = (QuantityValue) joulespersquarecentimeter; return new Irradiation(value, IrradiationUnit.JoulePerSquareCentimeter); } @@ -282,7 +285,7 @@ public static Irradiation FromJoulesPerSquareCentimeter(QuantityValue joulespers /// If value is NaN or Infinity. public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquaremeter) { - double value = (double) joulespersquaremeter; + QuantityValue value = (QuantityValue) joulespersquaremeter; return new Irradiation(value, IrradiationUnit.JoulePerSquareMeter); } @@ -292,7 +295,7 @@ public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquare /// If value is NaN or Infinity. public static Irradiation FromJoulesPerSquareMillimeter(QuantityValue joulespersquaremillimeter) { - double value = (double) joulespersquaremillimeter; + QuantityValue value = (QuantityValue) joulespersquaremillimeter; return new Irradiation(value, IrradiationUnit.JoulePerSquareMillimeter); } @@ -302,7 +305,7 @@ public static Irradiation FromJoulesPerSquareMillimeter(QuantityValue joulespers /// If value is NaN or Infinity. public static Irradiation FromKilojoulesPerSquareMeter(QuantityValue kilojoulespersquaremeter) { - double value = (double) kilojoulespersquaremeter; + QuantityValue value = (QuantityValue) kilojoulespersquaremeter; return new Irradiation(value, IrradiationUnit.KilojoulePerSquareMeter); } @@ -312,7 +315,7 @@ public static Irradiation FromKilojoulesPerSquareMeter(QuantityValue kilojoulesp /// If value is NaN or Infinity. public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatthourspersquaremeter) { - double value = (double) kilowatthourspersquaremeter; + QuantityValue value = (QuantityValue) kilowatthourspersquaremeter; return new Irradiation(value, IrradiationUnit.KilowattHourPerSquareMeter); } @@ -322,7 +325,7 @@ public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatt /// If value is NaN or Infinity. public static Irradiation FromMillijoulesPerSquareCentimeter(QuantityValue millijoulespersquarecentimeter) { - double value = (double) millijoulespersquarecentimeter; + QuantityValue value = (QuantityValue) millijoulespersquarecentimeter; return new Irradiation(value, IrradiationUnit.MillijoulePerSquareCentimeter); } @@ -332,7 +335,7 @@ public static Irradiation FromMillijoulesPerSquareCentimeter(QuantityValue milli /// If value is NaN or Infinity. public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthourspersquaremeter) { - double value = (double) watthourspersquaremeter; + QuantityValue value = (QuantityValue) watthourspersquaremeter; return new Irradiation(value, IrradiationUnit.WattHourPerSquareMeter); } @@ -344,7 +347,7 @@ public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthoursper /// Irradiation unit value. public static Irradiation From(QuantityValue value, IrradiationUnit fromUnit) { - return new Irradiation((double)value, fromUnit); + return new Irradiation((QuantityValue)value, fromUnit); } #endregion @@ -514,25 +517,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad } /// Get from multiplying value and . - public static Irradiation operator *(double left, Irradiation right) + public static Irradiation operator *(QuantityValue left, Irradiation right) { return new Irradiation(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Irradiation operator *(Irradiation left, double right) + public static Irradiation operator *(Irradiation left, QuantityValue right) { return new Irradiation(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Irradiation operator /(Irradiation left, double right) + public static Irradiation operator /(Irradiation left, QuantityValue right) { return new Irradiation(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Irradiation left, Irradiation right) + public static QuantityValue operator /(Irradiation left, Irradiation right) { return left.JoulesPerSquareMeter / right.JoulesPerSquareMeter; } @@ -565,6 +568,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Irradiation left, Irradiation right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Irradiation left, Irradiation right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -577,7 +593,29 @@ public int CompareTo(object obj) /// public int CompareTo(Irradiation other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Irradiation objIrradiation)) + return false; + return Equals(objIrradiation); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Irradiation other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -620,13 +658,13 @@ public int CompareTo(Irradiation other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType) + public bool Equals(Irradiation other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -637,7 +675,7 @@ public bool Equals(Irradiation other, double tolerance, ComparisonType compariso /// A hash code for the current Irradiation. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -648,17 +686,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(IrradiationUnit unit) + public QuantityValue As(IrradiationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -673,12 +710,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is IrradiationUnit unitAsIrradiationUnit)) + if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return As(unitAsIrradiationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -710,7 +747,7 @@ public Irradiation ToUnit(IrradiationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Irradiation)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(IrradiationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -718,17 +755,17 @@ public Irradiation ToUnit(IrradiationUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradiationUnit unitAsIrradiationUnit)) + if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIrradiationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -755,10 +792,10 @@ public Irradiation ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(IrradiationUnit unit) + private QuantityValue GetValueAs(IrradiationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 7c5b0cee06..d590a3b824 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct Jerk : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Jerk : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -82,9 +82,9 @@ static Jerk() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Jerk(double value, JerkUnit unit) + public Jerk(QuantityValue value, JerkUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -96,14 +96,14 @@ public Jerk(double value, JerkUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Jerk(double value, UnitSystem unitSystem) + public Jerk(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,7 +144,10 @@ public Jerk(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -167,59 +170,59 @@ public Jerk(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersPerSecondCubed => As(JerkUnit.CentimeterPerSecondCubed); + public QuantityValue CentimetersPerSecondCubed => As(JerkUnit.CentimeterPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimetersPerSecondCubed => As(JerkUnit.DecimeterPerSecondCubed); + public QuantityValue DecimetersPerSecondCubed => As(JerkUnit.DecimeterPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetPerSecondCubed => As(JerkUnit.FootPerSecondCubed); + public QuantityValue FeetPerSecondCubed => As(JerkUnit.FootPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesPerSecondCubed => As(JerkUnit.InchPerSecondCubed); + public QuantityValue InchesPerSecondCubed => As(JerkUnit.InchPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilometersPerSecondCubed => As(JerkUnit.KilometerPerSecondCubed); + public QuantityValue KilometersPerSecondCubed => As(JerkUnit.KilometerPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersPerSecondCubed => As(JerkUnit.MeterPerSecondCubed); + public QuantityValue MetersPerSecondCubed => As(JerkUnit.MeterPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrometersPerSecondCubed => As(JerkUnit.MicrometerPerSecondCubed); + public QuantityValue MicrometersPerSecondCubed => As(JerkUnit.MicrometerPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersPerSecondCubed => As(JerkUnit.MillimeterPerSecondCubed); + public QuantityValue MillimetersPerSecondCubed => As(JerkUnit.MillimeterPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillistandardGravitiesPerSecond => As(JerkUnit.MillistandardGravitiesPerSecond); + public QuantityValue MillistandardGravitiesPerSecond => As(JerkUnit.MillistandardGravitiesPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanometersPerSecondCubed => As(JerkUnit.NanometerPerSecondCubed); + public QuantityValue NanometersPerSecondCubed => As(JerkUnit.NanometerPerSecondCubed); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardGravitiesPerSecond => As(JerkUnit.StandardGravitiesPerSecond); + public QuantityValue StandardGravitiesPerSecond => As(JerkUnit.StandardGravitiesPerSecond); #endregion @@ -316,7 +319,7 @@ public static string GetAbbreviation(JerkUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Jerk FromCentimetersPerSecondCubed(QuantityValue centimeterspersecondcubed) { - double value = (double) centimeterspersecondcubed; + QuantityValue value = (QuantityValue) centimeterspersecondcubed; return new Jerk(value, JerkUnit.CentimeterPerSecondCubed); } @@ -326,7 +329,7 @@ public static Jerk FromCentimetersPerSecondCubed(QuantityValue centimeterspersec /// If value is NaN or Infinity. public static Jerk FromDecimetersPerSecondCubed(QuantityValue decimeterspersecondcubed) { - double value = (double) decimeterspersecondcubed; + QuantityValue value = (QuantityValue) decimeterspersecondcubed; return new Jerk(value, JerkUnit.DecimeterPerSecondCubed); } @@ -336,7 +339,7 @@ public static Jerk FromDecimetersPerSecondCubed(QuantityValue decimeterspersecon /// If value is NaN or Infinity. public static Jerk FromFeetPerSecondCubed(QuantityValue feetpersecondcubed) { - double value = (double) feetpersecondcubed; + QuantityValue value = (QuantityValue) feetpersecondcubed; return new Jerk(value, JerkUnit.FootPerSecondCubed); } @@ -346,7 +349,7 @@ public static Jerk FromFeetPerSecondCubed(QuantityValue feetpersecondcubed) /// If value is NaN or Infinity. public static Jerk FromInchesPerSecondCubed(QuantityValue inchespersecondcubed) { - double value = (double) inchespersecondcubed; + QuantityValue value = (QuantityValue) inchespersecondcubed; return new Jerk(value, JerkUnit.InchPerSecondCubed); } @@ -356,7 +359,7 @@ public static Jerk FromInchesPerSecondCubed(QuantityValue inchespersecondcubed) /// If value is NaN or Infinity. public static Jerk FromKilometersPerSecondCubed(QuantityValue kilometerspersecondcubed) { - double value = (double) kilometerspersecondcubed; + QuantityValue value = (QuantityValue) kilometerspersecondcubed; return new Jerk(value, JerkUnit.KilometerPerSecondCubed); } @@ -366,7 +369,7 @@ public static Jerk FromKilometersPerSecondCubed(QuantityValue kilometerspersecon /// If value is NaN or Infinity. public static Jerk FromMetersPerSecondCubed(QuantityValue meterspersecondcubed) { - double value = (double) meterspersecondcubed; + QuantityValue value = (QuantityValue) meterspersecondcubed; return new Jerk(value, JerkUnit.MeterPerSecondCubed); } @@ -376,7 +379,7 @@ public static Jerk FromMetersPerSecondCubed(QuantityValue meterspersecondcubed) /// If value is NaN or Infinity. public static Jerk FromMicrometersPerSecondCubed(QuantityValue micrometerspersecondcubed) { - double value = (double) micrometerspersecondcubed; + QuantityValue value = (QuantityValue) micrometerspersecondcubed; return new Jerk(value, JerkUnit.MicrometerPerSecondCubed); } @@ -386,7 +389,7 @@ public static Jerk FromMicrometersPerSecondCubed(QuantityValue micrometerspersec /// If value is NaN or Infinity. public static Jerk FromMillimetersPerSecondCubed(QuantityValue millimeterspersecondcubed) { - double value = (double) millimeterspersecondcubed; + QuantityValue value = (QuantityValue) millimeterspersecondcubed; return new Jerk(value, JerkUnit.MillimeterPerSecondCubed); } @@ -396,7 +399,7 @@ public static Jerk FromMillimetersPerSecondCubed(QuantityValue millimeterspersec /// If value is NaN or Infinity. public static Jerk FromMillistandardGravitiesPerSecond(QuantityValue millistandardgravitiespersecond) { - double value = (double) millistandardgravitiespersecond; + QuantityValue value = (QuantityValue) millistandardgravitiespersecond; return new Jerk(value, JerkUnit.MillistandardGravitiesPerSecond); } @@ -406,7 +409,7 @@ public static Jerk FromMillistandardGravitiesPerSecond(QuantityValue millistanda /// If value is NaN or Infinity. public static Jerk FromNanometersPerSecondCubed(QuantityValue nanometerspersecondcubed) { - double value = (double) nanometerspersecondcubed; + QuantityValue value = (QuantityValue) nanometerspersecondcubed; return new Jerk(value, JerkUnit.NanometerPerSecondCubed); } @@ -416,7 +419,7 @@ public static Jerk FromNanometersPerSecondCubed(QuantityValue nanometerspersecon /// If value is NaN or Infinity. public static Jerk FromStandardGravitiesPerSecond(QuantityValue standardgravitiespersecond) { - double value = (double) standardgravitiespersecond; + QuantityValue value = (QuantityValue) standardgravitiespersecond; return new Jerk(value, JerkUnit.StandardGravitiesPerSecond); } @@ -428,7 +431,7 @@ public static Jerk FromStandardGravitiesPerSecond(QuantityValue standardgravitie /// Jerk unit value. public static Jerk From(QuantityValue value, JerkUnit fromUnit) { - return new Jerk((double)value, fromUnit); + return new Jerk((QuantityValue)value, fromUnit); } #endregion @@ -598,25 +601,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU } /// Get from multiplying value and . - public static Jerk operator *(double left, Jerk right) + public static Jerk operator *(QuantityValue left, Jerk right) { return new Jerk(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Jerk operator *(Jerk left, double right) + public static Jerk operator *(Jerk left, QuantityValue right) { return new Jerk(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Jerk operator /(Jerk left, double right) + public static Jerk operator /(Jerk left, QuantityValue right) { return new Jerk(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Jerk left, Jerk right) + public static QuantityValue operator /(Jerk left, Jerk right) { return left.MetersPerSecondCubed / right.MetersPerSecondCubed; } @@ -649,6 +652,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Jerk left, Jerk right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Jerk left, Jerk right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -661,7 +677,29 @@ public int CompareTo(object obj) /// public int CompareTo(Jerk other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Jerk objJerk)) + return false; + return Equals(objJerk); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Jerk other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -704,13 +742,13 @@ public int CompareTo(Jerk other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) + public bool Equals(Jerk other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -721,7 +759,7 @@ public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Jerk. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -732,17 +770,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(JerkUnit unit) + public QuantityValue As(JerkUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -757,12 +794,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is JerkUnit unitAsJerkUnit)) + if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return As(unitAsJerkUnit); + return (QuantityValue)As(typedUnit); } /// @@ -794,7 +831,7 @@ public Jerk ToUnit(JerkUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Jerk)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(JerkUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -802,17 +839,17 @@ public Jerk ToUnit(JerkUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is JerkUnit unitAsJerkUnit)) + if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsJerkUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -839,10 +876,10 @@ public Jerk ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(JerkUnit unit) + private QuantityValue GetValueAs(JerkUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 35282f2c29..bb3d26a618 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Viscosity /// [DataContract] - public partial struct KinematicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static KinematicViscosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public KinematicViscosity(double value, KinematicViscosityUnit unit) + public KinematicViscosity(QuantityValue value, KinematicViscosityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -97,14 +97,14 @@ public KinematicViscosity(double value, KinematicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public KinematicViscosity(double value, UnitSystem unitSystem) + public KinematicViscosity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,7 +145,10 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -168,49 +171,49 @@ public KinematicViscosity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centistokes => As(KinematicViscosityUnit.Centistokes); + public QuantityValue Centistokes => As(KinematicViscosityUnit.Centistokes); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decistokes => As(KinematicViscosityUnit.Decistokes); + public QuantityValue Decistokes => As(KinematicViscosityUnit.Decistokes); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilostokes => As(KinematicViscosityUnit.Kilostokes); + public QuantityValue Kilostokes => As(KinematicViscosityUnit.Kilostokes); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microstokes => As(KinematicViscosityUnit.Microstokes); + public QuantityValue Microstokes => As(KinematicViscosityUnit.Microstokes); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millistokes => As(KinematicViscosityUnit.Millistokes); + public QuantityValue Millistokes => As(KinematicViscosityUnit.Millistokes); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanostokes => As(KinematicViscosityUnit.Nanostokes); + public QuantityValue Nanostokes => As(KinematicViscosityUnit.Nanostokes); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); + public QuantityValue SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); + public QuantityValue SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Stokes => As(KinematicViscosityUnit.Stokes); + public QuantityValue Stokes => As(KinematicViscosityUnit.Stokes); #endregion @@ -298,7 +301,7 @@ public static string GetAbbreviation(KinematicViscosityUnit unit, IFormatProvide /// If value is NaN or Infinity. public static KinematicViscosity FromCentistokes(QuantityValue centistokes) { - double value = (double) centistokes; + QuantityValue value = (QuantityValue) centistokes; return new KinematicViscosity(value, KinematicViscosityUnit.Centistokes); } @@ -308,7 +311,7 @@ public static KinematicViscosity FromCentistokes(QuantityValue centistokes) /// If value is NaN or Infinity. public static KinematicViscosity FromDecistokes(QuantityValue decistokes) { - double value = (double) decistokes; + QuantityValue value = (QuantityValue) decistokes; return new KinematicViscosity(value, KinematicViscosityUnit.Decistokes); } @@ -318,7 +321,7 @@ public static KinematicViscosity FromDecistokes(QuantityValue decistokes) /// If value is NaN or Infinity. public static KinematicViscosity FromKilostokes(QuantityValue kilostokes) { - double value = (double) kilostokes; + QuantityValue value = (QuantityValue) kilostokes; return new KinematicViscosity(value, KinematicViscosityUnit.Kilostokes); } @@ -328,7 +331,7 @@ public static KinematicViscosity FromKilostokes(QuantityValue kilostokes) /// If value is NaN or Infinity. public static KinematicViscosity FromMicrostokes(QuantityValue microstokes) { - double value = (double) microstokes; + QuantityValue value = (QuantityValue) microstokes; return new KinematicViscosity(value, KinematicViscosityUnit.Microstokes); } @@ -338,7 +341,7 @@ public static KinematicViscosity FromMicrostokes(QuantityValue microstokes) /// If value is NaN or Infinity. public static KinematicViscosity FromMillistokes(QuantityValue millistokes) { - double value = (double) millistokes; + QuantityValue value = (QuantityValue) millistokes; return new KinematicViscosity(value, KinematicViscosityUnit.Millistokes); } @@ -348,7 +351,7 @@ public static KinematicViscosity FromMillistokes(QuantityValue millistokes) /// If value is NaN or Infinity. public static KinematicViscosity FromNanostokes(QuantityValue nanostokes) { - double value = (double) nanostokes; + QuantityValue value = (QuantityValue) nanostokes; return new KinematicViscosity(value, KinematicViscosityUnit.Nanostokes); } @@ -358,7 +361,7 @@ public static KinematicViscosity FromNanostokes(QuantityValue nanostokes) /// If value is NaN or Infinity. public static KinematicViscosity FromSquareFeetPerSecond(QuantityValue squarefeetpersecond) { - double value = (double) squarefeetpersecond; + QuantityValue value = (QuantityValue) squarefeetpersecond; return new KinematicViscosity(value, KinematicViscosityUnit.SquareFootPerSecond); } @@ -368,7 +371,7 @@ public static KinematicViscosity FromSquareFeetPerSecond(QuantityValue squarefee /// If value is NaN or Infinity. public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue squaremeterspersecond) { - double value = (double) squaremeterspersecond; + QuantityValue value = (QuantityValue) squaremeterspersecond; return new KinematicViscosity(value, KinematicViscosityUnit.SquareMeterPerSecond); } @@ -378,7 +381,7 @@ public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue squarem /// If value is NaN or Infinity. public static KinematicViscosity FromStokes(QuantityValue stokes) { - double value = (double) stokes; + QuantityValue value = (QuantityValue) stokes; return new KinematicViscosity(value, KinematicViscosityUnit.Stokes); } @@ -390,7 +393,7 @@ public static KinematicViscosity FromStokes(QuantityValue stokes) /// KinematicViscosity unit value. public static KinematicViscosity From(QuantityValue value, KinematicViscosityUnit fromUnit) { - return new KinematicViscosity((double)value, fromUnit); + return new KinematicViscosity((QuantityValue)value, fromUnit); } #endregion @@ -560,25 +563,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem } /// Get from multiplying value and . - public static KinematicViscosity operator *(double left, KinematicViscosity right) + public static KinematicViscosity operator *(QuantityValue left, KinematicViscosity right) { return new KinematicViscosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static KinematicViscosity operator *(KinematicViscosity left, double right) + public static KinematicViscosity operator *(KinematicViscosity left, QuantityValue right) { return new KinematicViscosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static KinematicViscosity operator /(KinematicViscosity left, double right) + public static KinematicViscosity operator /(KinematicViscosity left, QuantityValue right) { return new KinematicViscosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(KinematicViscosity left, KinematicViscosity right) + public static QuantityValue operator /(KinematicViscosity left, KinematicViscosity right) { return left.SquareMetersPerSecond / right.SquareMetersPerSecond; } @@ -611,6 +614,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(KinematicViscosity left, KinematicViscosity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(KinematicViscosity left, KinematicViscosity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -623,7 +639,29 @@ public int CompareTo(object obj) /// public int CompareTo(KinematicViscosity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is KinematicViscosity objKinematicViscosity)) + return false; + return Equals(objKinematicViscosity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(KinematicViscosity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -666,13 +704,13 @@ public int CompareTo(KinematicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType) + public bool Equals(KinematicViscosity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -683,7 +721,7 @@ public bool Equals(KinematicViscosity other, double tolerance, ComparisonType co /// A hash code for the current KinematicViscosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -694,17 +732,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(KinematicViscosityUnit unit) + public QuantityValue As(KinematicViscosityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -719,12 +756,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) + if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsKinematicViscosityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -756,7 +793,7 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit, UnitConverter unit var converted = conversionFunction(this); return (KinematicViscosity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(KinematicViscosityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -764,17 +801,17 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) + if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsKinematicViscosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -801,10 +838,10 @@ public KinematicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(KinematicViscosityUnit unit) + private QuantityValue GetValueAs(KinematicViscosityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index fa9e8077ee..615c634f71 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -36,13 +36,13 @@ namespace UnitsNet /// [Obsolete("Use TemperatureGradient instead.")] [DataContract] - public partial struct LapseRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static LapseRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LapseRate(double value, LapseRateUnit unit) + public LapseRate(QuantityValue value, LapseRateUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -87,14 +87,14 @@ public LapseRate(double value, LapseRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LapseRate(double value, UnitSystem unitSystem) + public LapseRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,7 +135,10 @@ public LapseRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -158,9 +161,9 @@ public LapseRate(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); + public QuantityValue DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); #endregion @@ -216,7 +219,7 @@ public static string GetAbbreviation(LapseRateUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static LapseRate FromDegreesCelciusPerKilometer(QuantityValue degreescelciusperkilometer) { - double value = (double) degreescelciusperkilometer; + QuantityValue value = (QuantityValue) degreescelciusperkilometer; return new LapseRate(value, LapseRateUnit.DegreeCelsiusPerKilometer); } @@ -228,7 +231,7 @@ public static LapseRate FromDegreesCelciusPerKilometer(QuantityValue degreescelc /// LapseRate unit value. public static LapseRate From(QuantityValue value, LapseRateUnit fromUnit) { - return new LapseRate((double)value, fromUnit); + return new LapseRate((QuantityValue)value, fromUnit); } #endregion @@ -398,25 +401,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse } /// Get from multiplying value and . - public static LapseRate operator *(double left, LapseRate right) + public static LapseRate operator *(QuantityValue left, LapseRate right) { return new LapseRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LapseRate operator *(LapseRate left, double right) + public static LapseRate operator *(LapseRate left, QuantityValue right) { return new LapseRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LapseRate operator /(LapseRate left, double right) + public static LapseRate operator /(LapseRate left, QuantityValue right) { return new LapseRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LapseRate left, LapseRate right) + public static QuantityValue operator /(LapseRate left, LapseRate right) { return left.DegreesCelciusPerKilometer / right.DegreesCelciusPerKilometer; } @@ -449,6 +452,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(LapseRate left, LapseRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(LapseRate left, LapseRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -461,7 +477,29 @@ public int CompareTo(object obj) /// public int CompareTo(LapseRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is LapseRate objLapseRate)) + return false; + return Equals(objLapseRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(LapseRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -504,13 +542,13 @@ public int CompareTo(LapseRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(LapseRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -521,7 +559,7 @@ public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonT /// A hash code for the current LapseRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -532,17 +570,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LapseRateUnit unit) + public QuantityValue As(LapseRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -557,12 +594,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LapseRateUnit unitAsLapseRateUnit)) + if (!(unit is LapseRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return As(unitAsLapseRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -594,7 +631,7 @@ public LapseRate ToUnit(LapseRateUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (LapseRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LapseRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -602,17 +639,17 @@ public LapseRate ToUnit(LapseRateUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LapseRateUnit unitAsLapseRateUnit)) + if (!(unit is LapseRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLapseRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -639,10 +676,10 @@ public LapseRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LapseRateUnit unit) + private QuantityValue GetValueAs(LapseRateUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index ab1960b463..2d564bacc4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. /// [DataContract] - public partial struct Length : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -107,9 +107,9 @@ static Length() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Length(double value, LengthUnit unit) + public Length(QuantityValue value, LengthUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -121,14 +121,14 @@ public Length(double value, LengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Length(double value, UnitSystem unitSystem) + public Length(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -169,7 +169,10 @@ public Length(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -192,184 +195,184 @@ public Length(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Angstroms => As(LengthUnit.Angstrom); + public QuantityValue Angstroms => As(LengthUnit.Angstrom); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AstronomicalUnits => As(LengthUnit.AstronomicalUnit); + public QuantityValue AstronomicalUnits => As(LengthUnit.AstronomicalUnit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centimeters => As(LengthUnit.Centimeter); + public QuantityValue Centimeters => As(LengthUnit.Centimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Chains => As(LengthUnit.Chain); + public QuantityValue Chains => As(LengthUnit.Chain); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DataMiles => As(LengthUnit.DataMile); + public QuantityValue DataMiles => As(LengthUnit.DataMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decameters => As(LengthUnit.Decameter); + public QuantityValue Decameters => As(LengthUnit.Decameter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decimeters => As(LengthUnit.Decimeter); + public QuantityValue Decimeters => As(LengthUnit.Decimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DtpPicas => As(LengthUnit.DtpPica); + public QuantityValue DtpPicas => As(LengthUnit.DtpPica); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DtpPoints => As(LengthUnit.DtpPoint); + public QuantityValue DtpPoints => As(LengthUnit.DtpPoint); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Fathoms => As(LengthUnit.Fathom); + public QuantityValue Fathoms => As(LengthUnit.Fathom); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Feet => As(LengthUnit.Foot); + public QuantityValue Feet => As(LengthUnit.Foot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hands => As(LengthUnit.Hand); + public QuantityValue Hands => As(LengthUnit.Hand); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hectometers => As(LengthUnit.Hectometer); + public QuantityValue Hectometers => As(LengthUnit.Hectometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Inches => As(LengthUnit.Inch); + public QuantityValue Inches => As(LengthUnit.Inch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilolightYears => As(LengthUnit.KilolightYear); + public QuantityValue KilolightYears => As(LengthUnit.KilolightYear); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilometers => As(LengthUnit.Kilometer); + public QuantityValue Kilometers => As(LengthUnit.Kilometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kiloparsecs => As(LengthUnit.Kiloparsec); + public QuantityValue Kiloparsecs => As(LengthUnit.Kiloparsec); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LightYears => As(LengthUnit.LightYear); + public QuantityValue LightYears => As(LengthUnit.LightYear); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegalightYears => As(LengthUnit.MegalightYear); + public QuantityValue MegalightYears => As(LengthUnit.MegalightYear); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megaparsecs => As(LengthUnit.Megaparsec); + public QuantityValue Megaparsecs => As(LengthUnit.Megaparsec); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Meters => As(LengthUnit.Meter); + public QuantityValue Meters => As(LengthUnit.Meter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microinches => As(LengthUnit.Microinch); + public QuantityValue Microinches => As(LengthUnit.Microinch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Micrometers => As(LengthUnit.Micrometer); + public QuantityValue Micrometers => As(LengthUnit.Micrometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Mils => As(LengthUnit.Mil); + public QuantityValue Mils => As(LengthUnit.Mil); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Miles => As(LengthUnit.Mile); + public QuantityValue Miles => As(LengthUnit.Mile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millimeters => As(LengthUnit.Millimeter); + public QuantityValue Millimeters => As(LengthUnit.Millimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanometers => As(LengthUnit.Nanometer); + public QuantityValue Nanometers => As(LengthUnit.Nanometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NauticalMiles => As(LengthUnit.NauticalMile); + public QuantityValue NauticalMiles => As(LengthUnit.NauticalMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Parsecs => As(LengthUnit.Parsec); + public QuantityValue Parsecs => As(LengthUnit.Parsec); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PrinterPicas => As(LengthUnit.PrinterPica); + public QuantityValue PrinterPicas => As(LengthUnit.PrinterPica); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PrinterPoints => As(LengthUnit.PrinterPoint); + public QuantityValue PrinterPoints => As(LengthUnit.PrinterPoint); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Shackles => As(LengthUnit.Shackle); + public QuantityValue Shackles => As(LengthUnit.Shackle); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SolarRadiuses => As(LengthUnit.SolarRadius); + public QuantityValue SolarRadiuses => As(LengthUnit.SolarRadius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Twips => As(LengthUnit.Twip); + public QuantityValue Twips => As(LengthUnit.Twip); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsSurveyFeet => As(LengthUnit.UsSurveyFoot); + public QuantityValue UsSurveyFeet => As(LengthUnit.UsSurveyFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Yards => As(LengthUnit.Yard); + public QuantityValue Yards => As(LengthUnit.Yard); #endregion @@ -562,7 +565,7 @@ public static string GetAbbreviation(LengthUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Length FromAngstroms(QuantityValue angstroms) { - double value = (double) angstroms; + QuantityValue value = (QuantityValue) angstroms; return new Length(value, LengthUnit.Angstrom); } @@ -572,7 +575,7 @@ public static Length FromAngstroms(QuantityValue angstroms) /// If value is NaN or Infinity. public static Length FromAstronomicalUnits(QuantityValue astronomicalunits) { - double value = (double) astronomicalunits; + QuantityValue value = (QuantityValue) astronomicalunits; return new Length(value, LengthUnit.AstronomicalUnit); } @@ -582,7 +585,7 @@ public static Length FromAstronomicalUnits(QuantityValue astronomicalunits) /// If value is NaN or Infinity. public static Length FromCentimeters(QuantityValue centimeters) { - double value = (double) centimeters; + QuantityValue value = (QuantityValue) centimeters; return new Length(value, LengthUnit.Centimeter); } @@ -592,7 +595,7 @@ public static Length FromCentimeters(QuantityValue centimeters) /// If value is NaN or Infinity. public static Length FromChains(QuantityValue chains) { - double value = (double) chains; + QuantityValue value = (QuantityValue) chains; return new Length(value, LengthUnit.Chain); } @@ -602,7 +605,7 @@ public static Length FromChains(QuantityValue chains) /// If value is NaN or Infinity. public static Length FromDataMiles(QuantityValue datamiles) { - double value = (double) datamiles; + QuantityValue value = (QuantityValue) datamiles; return new Length(value, LengthUnit.DataMile); } @@ -612,7 +615,7 @@ public static Length FromDataMiles(QuantityValue datamiles) /// If value is NaN or Infinity. public static Length FromDecameters(QuantityValue decameters) { - double value = (double) decameters; + QuantityValue value = (QuantityValue) decameters; return new Length(value, LengthUnit.Decameter); } @@ -622,7 +625,7 @@ public static Length FromDecameters(QuantityValue decameters) /// If value is NaN or Infinity. public static Length FromDecimeters(QuantityValue decimeters) { - double value = (double) decimeters; + QuantityValue value = (QuantityValue) decimeters; return new Length(value, LengthUnit.Decimeter); } @@ -632,7 +635,7 @@ public static Length FromDecimeters(QuantityValue decimeters) /// If value is NaN or Infinity. public static Length FromDtpPicas(QuantityValue dtppicas) { - double value = (double) dtppicas; + QuantityValue value = (QuantityValue) dtppicas; return new Length(value, LengthUnit.DtpPica); } @@ -642,7 +645,7 @@ public static Length FromDtpPicas(QuantityValue dtppicas) /// If value is NaN or Infinity. public static Length FromDtpPoints(QuantityValue dtppoints) { - double value = (double) dtppoints; + QuantityValue value = (QuantityValue) dtppoints; return new Length(value, LengthUnit.DtpPoint); } @@ -652,7 +655,7 @@ public static Length FromDtpPoints(QuantityValue dtppoints) /// If value is NaN or Infinity. public static Length FromFathoms(QuantityValue fathoms) { - double value = (double) fathoms; + QuantityValue value = (QuantityValue) fathoms; return new Length(value, LengthUnit.Fathom); } @@ -662,7 +665,7 @@ public static Length FromFathoms(QuantityValue fathoms) /// If value is NaN or Infinity. public static Length FromFeet(QuantityValue feet) { - double value = (double) feet; + QuantityValue value = (QuantityValue) feet; return new Length(value, LengthUnit.Foot); } @@ -672,7 +675,7 @@ public static Length FromFeet(QuantityValue feet) /// If value is NaN or Infinity. public static Length FromHands(QuantityValue hands) { - double value = (double) hands; + QuantityValue value = (QuantityValue) hands; return new Length(value, LengthUnit.Hand); } @@ -682,7 +685,7 @@ public static Length FromHands(QuantityValue hands) /// If value is NaN or Infinity. public static Length FromHectometers(QuantityValue hectometers) { - double value = (double) hectometers; + QuantityValue value = (QuantityValue) hectometers; return new Length(value, LengthUnit.Hectometer); } @@ -692,7 +695,7 @@ public static Length FromHectometers(QuantityValue hectometers) /// If value is NaN or Infinity. public static Length FromInches(QuantityValue inches) { - double value = (double) inches; + QuantityValue value = (QuantityValue) inches; return new Length(value, LengthUnit.Inch); } @@ -702,7 +705,7 @@ public static Length FromInches(QuantityValue inches) /// If value is NaN or Infinity. public static Length FromKilolightYears(QuantityValue kilolightyears) { - double value = (double) kilolightyears; + QuantityValue value = (QuantityValue) kilolightyears; return new Length(value, LengthUnit.KilolightYear); } @@ -712,7 +715,7 @@ public static Length FromKilolightYears(QuantityValue kilolightyears) /// If value is NaN or Infinity. public static Length FromKilometers(QuantityValue kilometers) { - double value = (double) kilometers; + QuantityValue value = (QuantityValue) kilometers; return new Length(value, LengthUnit.Kilometer); } @@ -722,7 +725,7 @@ public static Length FromKilometers(QuantityValue kilometers) /// If value is NaN or Infinity. public static Length FromKiloparsecs(QuantityValue kiloparsecs) { - double value = (double) kiloparsecs; + QuantityValue value = (QuantityValue) kiloparsecs; return new Length(value, LengthUnit.Kiloparsec); } @@ -732,7 +735,7 @@ public static Length FromKiloparsecs(QuantityValue kiloparsecs) /// If value is NaN or Infinity. public static Length FromLightYears(QuantityValue lightyears) { - double value = (double) lightyears; + QuantityValue value = (QuantityValue) lightyears; return new Length(value, LengthUnit.LightYear); } @@ -742,7 +745,7 @@ public static Length FromLightYears(QuantityValue lightyears) /// If value is NaN or Infinity. public static Length FromMegalightYears(QuantityValue megalightyears) { - double value = (double) megalightyears; + QuantityValue value = (QuantityValue) megalightyears; return new Length(value, LengthUnit.MegalightYear); } @@ -752,7 +755,7 @@ public static Length FromMegalightYears(QuantityValue megalightyears) /// If value is NaN or Infinity. public static Length FromMegaparsecs(QuantityValue megaparsecs) { - double value = (double) megaparsecs; + QuantityValue value = (QuantityValue) megaparsecs; return new Length(value, LengthUnit.Megaparsec); } @@ -762,7 +765,7 @@ public static Length FromMegaparsecs(QuantityValue megaparsecs) /// If value is NaN or Infinity. public static Length FromMeters(QuantityValue meters) { - double value = (double) meters; + QuantityValue value = (QuantityValue) meters; return new Length(value, LengthUnit.Meter); } @@ -772,7 +775,7 @@ public static Length FromMeters(QuantityValue meters) /// If value is NaN or Infinity. public static Length FromMicroinches(QuantityValue microinches) { - double value = (double) microinches; + QuantityValue value = (QuantityValue) microinches; return new Length(value, LengthUnit.Microinch); } @@ -782,7 +785,7 @@ public static Length FromMicroinches(QuantityValue microinches) /// If value is NaN or Infinity. public static Length FromMicrometers(QuantityValue micrometers) { - double value = (double) micrometers; + QuantityValue value = (QuantityValue) micrometers; return new Length(value, LengthUnit.Micrometer); } @@ -792,7 +795,7 @@ public static Length FromMicrometers(QuantityValue micrometers) /// If value is NaN or Infinity. public static Length FromMils(QuantityValue mils) { - double value = (double) mils; + QuantityValue value = (QuantityValue) mils; return new Length(value, LengthUnit.Mil); } @@ -802,7 +805,7 @@ public static Length FromMils(QuantityValue mils) /// If value is NaN or Infinity. public static Length FromMiles(QuantityValue miles) { - double value = (double) miles; + QuantityValue value = (QuantityValue) miles; return new Length(value, LengthUnit.Mile); } @@ -812,7 +815,7 @@ public static Length FromMiles(QuantityValue miles) /// If value is NaN or Infinity. public static Length FromMillimeters(QuantityValue millimeters) { - double value = (double) millimeters; + QuantityValue value = (QuantityValue) millimeters; return new Length(value, LengthUnit.Millimeter); } @@ -822,7 +825,7 @@ public static Length FromMillimeters(QuantityValue millimeters) /// If value is NaN or Infinity. public static Length FromNanometers(QuantityValue nanometers) { - double value = (double) nanometers; + QuantityValue value = (QuantityValue) nanometers; return new Length(value, LengthUnit.Nanometer); } @@ -832,7 +835,7 @@ public static Length FromNanometers(QuantityValue nanometers) /// If value is NaN or Infinity. public static Length FromNauticalMiles(QuantityValue nauticalmiles) { - double value = (double) nauticalmiles; + QuantityValue value = (QuantityValue) nauticalmiles; return new Length(value, LengthUnit.NauticalMile); } @@ -842,7 +845,7 @@ public static Length FromNauticalMiles(QuantityValue nauticalmiles) /// If value is NaN or Infinity. public static Length FromParsecs(QuantityValue parsecs) { - double value = (double) parsecs; + QuantityValue value = (QuantityValue) parsecs; return new Length(value, LengthUnit.Parsec); } @@ -852,7 +855,7 @@ public static Length FromParsecs(QuantityValue parsecs) /// If value is NaN or Infinity. public static Length FromPrinterPicas(QuantityValue printerpicas) { - double value = (double) printerpicas; + QuantityValue value = (QuantityValue) printerpicas; return new Length(value, LengthUnit.PrinterPica); } @@ -862,7 +865,7 @@ public static Length FromPrinterPicas(QuantityValue printerpicas) /// If value is NaN or Infinity. public static Length FromPrinterPoints(QuantityValue printerpoints) { - double value = (double) printerpoints; + QuantityValue value = (QuantityValue) printerpoints; return new Length(value, LengthUnit.PrinterPoint); } @@ -872,7 +875,7 @@ public static Length FromPrinterPoints(QuantityValue printerpoints) /// If value is NaN or Infinity. public static Length FromShackles(QuantityValue shackles) { - double value = (double) shackles; + QuantityValue value = (QuantityValue) shackles; return new Length(value, LengthUnit.Shackle); } @@ -882,7 +885,7 @@ public static Length FromShackles(QuantityValue shackles) /// If value is NaN or Infinity. public static Length FromSolarRadiuses(QuantityValue solarradiuses) { - double value = (double) solarradiuses; + QuantityValue value = (QuantityValue) solarradiuses; return new Length(value, LengthUnit.SolarRadius); } @@ -892,7 +895,7 @@ public static Length FromSolarRadiuses(QuantityValue solarradiuses) /// If value is NaN or Infinity. public static Length FromTwips(QuantityValue twips) { - double value = (double) twips; + QuantityValue value = (QuantityValue) twips; return new Length(value, LengthUnit.Twip); } @@ -902,7 +905,7 @@ public static Length FromTwips(QuantityValue twips) /// If value is NaN or Infinity. public static Length FromUsSurveyFeet(QuantityValue ussurveyfeet) { - double value = (double) ussurveyfeet; + QuantityValue value = (QuantityValue) ussurveyfeet; return new Length(value, LengthUnit.UsSurveyFoot); } @@ -912,7 +915,7 @@ public static Length FromUsSurveyFeet(QuantityValue ussurveyfeet) /// If value is NaN or Infinity. public static Length FromYards(QuantityValue yards) { - double value = (double) yards; + QuantityValue value = (QuantityValue) yards; return new Length(value, LengthUnit.Yard); } @@ -924,7 +927,7 @@ public static Length FromYards(QuantityValue yards) /// Length unit value. public static Length From(QuantityValue value, LengthUnit fromUnit) { - return new Length((double)value, fromUnit); + return new Length((QuantityValue)value, fromUnit); } #endregion @@ -1094,25 +1097,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt } /// Get from multiplying value and . - public static Length operator *(double left, Length right) + public static Length operator *(QuantityValue left, Length right) { return new Length(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Length operator *(Length left, double right) + public static Length operator *(Length left, QuantityValue right) { return new Length(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Length operator /(Length left, double right) + public static Length operator /(Length left, QuantityValue right) { return new Length(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Length left, Length right) + public static QuantityValue operator /(Length left, Length right) { return left.Meters / right.Meters; } @@ -1145,6 +1148,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Length left, Length right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Length left, Length right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1157,7 +1173,29 @@ public int CompareTo(object obj) /// public int CompareTo(Length other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Length objLength)) + return false; + return Equals(objLength); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Length other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1200,13 +1238,13 @@ public int CompareTo(Length other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Length other, double tolerance, ComparisonType comparisonType) + public bool Equals(Length other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1217,7 +1255,7 @@ public bool Equals(Length other, double tolerance, ComparisonType comparisonType /// A hash code for the current Length. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1228,17 +1266,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LengthUnit unit) + public QuantityValue As(LengthUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1253,12 +1290,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LengthUnit unitAsLengthUnit)) + if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return As(unitAsLengthUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1290,7 +1327,7 @@ public Length ToUnit(LengthUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Length)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LengthUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1298,17 +1335,17 @@ public Length ToUnit(LengthUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LengthUnit unitAsLengthUnit)) + if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1335,10 +1372,10 @@ public Length ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LengthUnit unit) + private QuantityValue GetValueAs(LengthUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 16b78f3430..2610e6c6f9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. /// [DataContract] - public partial struct Level : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static Level() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Level(double value, LevelUnit unit) + public Level(QuantityValue value, LevelUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -87,14 +87,14 @@ public Level(double value, LevelUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Level(double value, UnitSystem unitSystem) + public Level(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,7 +135,10 @@ public Level(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -158,14 +161,14 @@ public Level(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decibels => As(LevelUnit.Decibel); + public QuantityValue Decibels => As(LevelUnit.Decibel); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nepers => As(LevelUnit.Neper); + public QuantityValue Nepers => As(LevelUnit.Neper); #endregion @@ -224,7 +227,7 @@ public static string GetAbbreviation(LevelUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Level FromDecibels(QuantityValue decibels) { - double value = (double) decibels; + QuantityValue value = (QuantityValue) decibels; return new Level(value, LevelUnit.Decibel); } @@ -234,7 +237,7 @@ public static Level FromDecibels(QuantityValue decibels) /// If value is NaN or Infinity. public static Level FromNepers(QuantityValue nepers) { - double value = (double) nepers; + QuantityValue value = (QuantityValue) nepers; return new Level(value, LevelUnit.Neper); } @@ -246,7 +249,7 @@ public static Level FromNepers(QuantityValue nepers) /// Level unit value. public static Level From(QuantityValue value, LevelUnit fromUnit) { - return new Level((double)value, fromUnit); + return new Level((QuantityValue)value, fromUnit); } #endregion @@ -408,7 +411,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level { // Logarithmic addition // Formula: 10 * log10(10^(x/10) + 10^(y/10)) - return new Level(10 * Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new Level(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic subtraction of two . @@ -416,11 +419,11 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level { // Logarithmic subtraction // Formula: 10 * log10(10^(x/10) - 10^(y/10)) - return new Level(10 * Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new Level(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic multiplication of value and . - public static Level operator *(double left, Level right) + public static Level operator *(QuantityValue left, Level right) { // Logarithmic multiplication = addition return new Level(left + right.Value, right.Unit); @@ -430,14 +433,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level public static Level operator *(Level left, double right) { // Logarithmic multiplication = addition - return new Level(left.Value + (double)right, left.Unit); + return new Level(left.Value + (QuantityValue)right, left.Unit); } /// Get from logarithmic division of by value. public static Level operator /(Level left, double right) { // Logarithmic division = subtraction - return new Level(left.Value - (double)right, left.Unit); + return new Level(left.Value - (QuantityValue)right, left.Unit); } /// Get ratio value from logarithmic division of by . @@ -475,6 +478,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Level left, Level right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Level left, Level right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -487,7 +503,29 @@ public int CompareTo(object obj) /// public int CompareTo(Level other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Level objLevel)) + return false; + return Equals(objLevel); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Level other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -530,13 +568,13 @@ public int CompareTo(Level other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Level other, double tolerance, ComparisonType comparisonType) + public bool Equals(Level other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -547,7 +585,7 @@ public bool Equals(Level other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Level. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -558,17 +596,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LevelUnit unit) + public QuantityValue As(LevelUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -583,12 +620,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LevelUnit unitAsLevelUnit)) + if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return As(unitAsLevelUnit); + return (QuantityValue)As(typedUnit); } /// @@ -620,7 +657,7 @@ public Level ToUnit(LevelUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Level)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LevelUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -628,17 +665,17 @@ public Level ToUnit(LevelUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LevelUnit unitAsLevelUnit)) + if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLevelUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -665,10 +702,10 @@ public Level ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LevelUnit unit) + private QuantityValue GetValueAs(LevelUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 659ad66f37..ceec19fbc9 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -88,9 +88,9 @@ static LinearDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LinearDensity(double value, LinearDensityUnit unit) + public LinearDensity(QuantityValue value, LinearDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -102,14 +102,14 @@ public LinearDensity(double value, LinearDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearDensity(double value, UnitSystem unitSystem) + public LinearDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -150,7 +150,10 @@ public LinearDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +176,74 @@ public LinearDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); + public QuantityValue GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerMeter => As(LinearDensityUnit.GramPerMeter); + public QuantityValue GramsPerMeter => As(LinearDensityUnit.GramPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); + public QuantityValue GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); + public QuantityValue KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); + public QuantityValue KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); + public QuantityValue KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); + public QuantityValue MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); + public QuantityValue MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); + public QuantityValue MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); + public QuantityValue MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); + public QuantityValue MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); + public QuantityValue MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); + public QuantityValue PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerInch => As(LinearDensityUnit.PoundPerInch); + public QuantityValue PoundsPerInch => As(LinearDensityUnit.PoundPerInch); #endregion @@ -335,7 +338,7 @@ public static string GetAbbreviation(LinearDensityUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static LinearDensity FromGramsPerCentimeter(QuantityValue gramspercentimeter) { - double value = (double) gramspercentimeter; + QuantityValue value = (QuantityValue) gramspercentimeter; return new LinearDensity(value, LinearDensityUnit.GramPerCentimeter); } @@ -345,7 +348,7 @@ public static LinearDensity FromGramsPerCentimeter(QuantityValue gramspercentime /// If value is NaN or Infinity. public static LinearDensity FromGramsPerMeter(QuantityValue gramspermeter) { - double value = (double) gramspermeter; + QuantityValue value = (QuantityValue) gramspermeter; return new LinearDensity(value, LinearDensityUnit.GramPerMeter); } @@ -355,7 +358,7 @@ public static LinearDensity FromGramsPerMeter(QuantityValue gramspermeter) /// If value is NaN or Infinity. public static LinearDensity FromGramsPerMillimeter(QuantityValue gramspermillimeter) { - double value = (double) gramspermillimeter; + QuantityValue value = (QuantityValue) gramspermillimeter; return new LinearDensity(value, LinearDensityUnit.GramPerMillimeter); } @@ -365,7 +368,7 @@ public static LinearDensity FromGramsPerMillimeter(QuantityValue gramspermillime /// If value is NaN or Infinity. public static LinearDensity FromKilogramsPerCentimeter(QuantityValue kilogramspercentimeter) { - double value = (double) kilogramspercentimeter; + QuantityValue value = (QuantityValue) kilogramspercentimeter; return new LinearDensity(value, LinearDensityUnit.KilogramPerCentimeter); } @@ -375,7 +378,7 @@ public static LinearDensity FromKilogramsPerCentimeter(QuantityValue kilogramspe /// If value is NaN or Infinity. public static LinearDensity FromKilogramsPerMeter(QuantityValue kilogramspermeter) { - double value = (double) kilogramspermeter; + QuantityValue value = (QuantityValue) kilogramspermeter; return new LinearDensity(value, LinearDensityUnit.KilogramPerMeter); } @@ -385,7 +388,7 @@ public static LinearDensity FromKilogramsPerMeter(QuantityValue kilogramspermete /// If value is NaN or Infinity. public static LinearDensity FromKilogramsPerMillimeter(QuantityValue kilogramspermillimeter) { - double value = (double) kilogramspermillimeter; + QuantityValue value = (QuantityValue) kilogramspermillimeter; return new LinearDensity(value, LinearDensityUnit.KilogramPerMillimeter); } @@ -395,7 +398,7 @@ public static LinearDensity FromKilogramsPerMillimeter(QuantityValue kilogramspe /// If value is NaN or Infinity. public static LinearDensity FromMicrogramsPerCentimeter(QuantityValue microgramspercentimeter) { - double value = (double) microgramspercentimeter; + QuantityValue value = (QuantityValue) microgramspercentimeter; return new LinearDensity(value, LinearDensityUnit.MicrogramPerCentimeter); } @@ -405,7 +408,7 @@ public static LinearDensity FromMicrogramsPerCentimeter(QuantityValue micrograms /// If value is NaN or Infinity. public static LinearDensity FromMicrogramsPerMeter(QuantityValue microgramspermeter) { - double value = (double) microgramspermeter; + QuantityValue value = (QuantityValue) microgramspermeter; return new LinearDensity(value, LinearDensityUnit.MicrogramPerMeter); } @@ -415,7 +418,7 @@ public static LinearDensity FromMicrogramsPerMeter(QuantityValue microgramsperme /// If value is NaN or Infinity. public static LinearDensity FromMicrogramsPerMillimeter(QuantityValue microgramspermillimeter) { - double value = (double) microgramspermillimeter; + QuantityValue value = (QuantityValue) microgramspermillimeter; return new LinearDensity(value, LinearDensityUnit.MicrogramPerMillimeter); } @@ -425,7 +428,7 @@ public static LinearDensity FromMicrogramsPerMillimeter(QuantityValue micrograms /// If value is NaN or Infinity. public static LinearDensity FromMilligramsPerCentimeter(QuantityValue milligramspercentimeter) { - double value = (double) milligramspercentimeter; + QuantityValue value = (QuantityValue) milligramspercentimeter; return new LinearDensity(value, LinearDensityUnit.MilligramPerCentimeter); } @@ -435,7 +438,7 @@ public static LinearDensity FromMilligramsPerCentimeter(QuantityValue milligrams /// If value is NaN or Infinity. public static LinearDensity FromMilligramsPerMeter(QuantityValue milligramspermeter) { - double value = (double) milligramspermeter; + QuantityValue value = (QuantityValue) milligramspermeter; return new LinearDensity(value, LinearDensityUnit.MilligramPerMeter); } @@ -445,7 +448,7 @@ public static LinearDensity FromMilligramsPerMeter(QuantityValue milligramsperme /// If value is NaN or Infinity. public static LinearDensity FromMilligramsPerMillimeter(QuantityValue milligramspermillimeter) { - double value = (double) milligramspermillimeter; + QuantityValue value = (QuantityValue) milligramspermillimeter; return new LinearDensity(value, LinearDensityUnit.MilligramPerMillimeter); } @@ -455,7 +458,7 @@ public static LinearDensity FromMilligramsPerMillimeter(QuantityValue milligrams /// If value is NaN or Infinity. public static LinearDensity FromPoundsPerFoot(QuantityValue poundsperfoot) { - double value = (double) poundsperfoot; + QuantityValue value = (QuantityValue) poundsperfoot; return new LinearDensity(value, LinearDensityUnit.PoundPerFoot); } @@ -465,7 +468,7 @@ public static LinearDensity FromPoundsPerFoot(QuantityValue poundsperfoot) /// If value is NaN or Infinity. public static LinearDensity FromPoundsPerInch(QuantityValue poundsperinch) { - double value = (double) poundsperinch; + QuantityValue value = (QuantityValue) poundsperinch; return new LinearDensity(value, LinearDensityUnit.PoundPerInch); } @@ -477,7 +480,7 @@ public static LinearDensity FromPoundsPerInch(QuantityValue poundsperinch) /// LinearDensity unit value. public static LinearDensity From(QuantityValue value, LinearDensityUnit fromUnit) { - return new LinearDensity((double)value, fromUnit); + return new LinearDensity((QuantityValue)value, fromUnit); } #endregion @@ -647,25 +650,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea } /// Get from multiplying value and . - public static LinearDensity operator *(double left, LinearDensity right) + public static LinearDensity operator *(QuantityValue left, LinearDensity right) { return new LinearDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LinearDensity operator *(LinearDensity left, double right) + public static LinearDensity operator *(LinearDensity left, QuantityValue right) { return new LinearDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LinearDensity operator /(LinearDensity left, double right) + public static LinearDensity operator /(LinearDensity left, QuantityValue right) { return new LinearDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LinearDensity left, LinearDensity right) + public static QuantityValue operator /(LinearDensity left, LinearDensity right) { return left.KilogramsPerMeter / right.KilogramsPerMeter; } @@ -698,6 +701,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(LinearDensity left, LinearDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(LinearDensity left, LinearDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -710,7 +726,29 @@ public int CompareTo(object obj) /// public int CompareTo(LinearDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is LinearDensity objLinearDensity)) + return false; + return Equals(objLinearDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(LinearDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -753,13 +791,13 @@ public int CompareTo(LinearDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(LinearDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -770,7 +808,7 @@ public bool Equals(LinearDensity other, double tolerance, ComparisonType compari /// A hash code for the current LinearDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -781,17 +819,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearDensityUnit unit) + public QuantityValue As(LinearDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -806,12 +843,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) + if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -843,7 +880,7 @@ public LinearDensity ToUnit(LinearDensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (LinearDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LinearDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -851,17 +888,17 @@ public LinearDensity ToUnit(LinearDensityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) + if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLinearDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -888,10 +925,10 @@ public LinearDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LinearDensityUnit unit) + private QuantityValue GetValueAs(LinearDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 20a484724a..5500223a41 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearPowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -99,9 +99,9 @@ static LinearPowerDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LinearPowerDensity(double value, LinearPowerDensityUnit unit) + public LinearPowerDensity(QuantityValue value, LinearPowerDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -113,14 +113,14 @@ public LinearPowerDensity(double value, LinearPowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearPowerDensity(double value, UnitSystem unitSystem) + public LinearPowerDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -161,7 +161,10 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -184,129 +187,129 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); + public QuantityValue GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); + public QuantityValue GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); + public QuantityValue GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); + public QuantityValue GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); + public QuantityValue GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); + public QuantityValue KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); + public QuantityValue KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); + public QuantityValue KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); + public QuantityValue KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); + public QuantityValue KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); + public QuantityValue MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); + public QuantityValue MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); + public QuantityValue MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); + public QuantityValue MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); + public QuantityValue MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); + public QuantityValue MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); + public QuantityValue MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); + public QuantityValue MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); + public QuantityValue MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); + public QuantityValue MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); + public QuantityValue WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); + public QuantityValue WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); + public QuantityValue WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); + public QuantityValue WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); + public QuantityValue WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); #endregion @@ -434,7 +437,7 @@ public static string GetAbbreviation(LinearPowerDensityUnit unit, IFormatProvide /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerCentimeter(QuantityValue gigawattspercentimeter) { - double value = (double) gigawattspercentimeter; + QuantityValue value = (QuantityValue) gigawattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerCentimeter); } @@ -444,7 +447,7 @@ public static LinearPowerDensity FromGigawattsPerCentimeter(QuantityValue gigawa /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerFoot(QuantityValue gigawattsperfoot) { - double value = (double) gigawattsperfoot; + QuantityValue value = (QuantityValue) gigawattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerFoot); } @@ -454,7 +457,7 @@ public static LinearPowerDensity FromGigawattsPerFoot(QuantityValue gigawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerInch(QuantityValue gigawattsperinch) { - double value = (double) gigawattsperinch; + QuantityValue value = (QuantityValue) gigawattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerInch); } @@ -464,7 +467,7 @@ public static LinearPowerDensity FromGigawattsPerInch(QuantityValue gigawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerMeter(QuantityValue gigawattspermeter) { - double value = (double) gigawattspermeter; + QuantityValue value = (QuantityValue) gigawattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMeter); } @@ -474,7 +477,7 @@ public static LinearPowerDensity FromGigawattsPerMeter(QuantityValue gigawattspe /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerMillimeter(QuantityValue gigawattspermillimeter) { - double value = (double) gigawattspermillimeter; + QuantityValue value = (QuantityValue) gigawattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMillimeter); } @@ -484,7 +487,7 @@ public static LinearPowerDensity FromGigawattsPerMillimeter(QuantityValue gigawa /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerCentimeter(QuantityValue kilowattspercentimeter) { - double value = (double) kilowattspercentimeter; + QuantityValue value = (QuantityValue) kilowattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerCentimeter); } @@ -494,7 +497,7 @@ public static LinearPowerDensity FromKilowattsPerCentimeter(QuantityValue kilowa /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerFoot(QuantityValue kilowattsperfoot) { - double value = (double) kilowattsperfoot; + QuantityValue value = (QuantityValue) kilowattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerFoot); } @@ -504,7 +507,7 @@ public static LinearPowerDensity FromKilowattsPerFoot(QuantityValue kilowattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerInch(QuantityValue kilowattsperinch) { - double value = (double) kilowattsperinch; + QuantityValue value = (QuantityValue) kilowattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerInch); } @@ -514,7 +517,7 @@ public static LinearPowerDensity FromKilowattsPerInch(QuantityValue kilowattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerMeter(QuantityValue kilowattspermeter) { - double value = (double) kilowattspermeter; + QuantityValue value = (QuantityValue) kilowattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMeter); } @@ -524,7 +527,7 @@ public static LinearPowerDensity FromKilowattsPerMeter(QuantityValue kilowattspe /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerMillimeter(QuantityValue kilowattspermillimeter) { - double value = (double) kilowattspermillimeter; + QuantityValue value = (QuantityValue) kilowattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMillimeter); } @@ -534,7 +537,7 @@ public static LinearPowerDensity FromKilowattsPerMillimeter(QuantityValue kilowa /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerCentimeter(QuantityValue megawattspercentimeter) { - double value = (double) megawattspercentimeter; + QuantityValue value = (QuantityValue) megawattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerCentimeter); } @@ -544,7 +547,7 @@ public static LinearPowerDensity FromMegawattsPerCentimeter(QuantityValue megawa /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerFoot(QuantityValue megawattsperfoot) { - double value = (double) megawattsperfoot; + QuantityValue value = (QuantityValue) megawattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerFoot); } @@ -554,7 +557,7 @@ public static LinearPowerDensity FromMegawattsPerFoot(QuantityValue megawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerInch(QuantityValue megawattsperinch) { - double value = (double) megawattsperinch; + QuantityValue value = (QuantityValue) megawattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerInch); } @@ -564,7 +567,7 @@ public static LinearPowerDensity FromMegawattsPerInch(QuantityValue megawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerMeter(QuantityValue megawattspermeter) { - double value = (double) megawattspermeter; + QuantityValue value = (QuantityValue) megawattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMeter); } @@ -574,7 +577,7 @@ public static LinearPowerDensity FromMegawattsPerMeter(QuantityValue megawattspe /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerMillimeter(QuantityValue megawattspermillimeter) { - double value = (double) megawattspermillimeter; + QuantityValue value = (QuantityValue) megawattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMillimeter); } @@ -584,7 +587,7 @@ public static LinearPowerDensity FromMegawattsPerMillimeter(QuantityValue megawa /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerCentimeter(QuantityValue milliwattspercentimeter) { - double value = (double) milliwattspercentimeter; + QuantityValue value = (QuantityValue) milliwattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerCentimeter); } @@ -594,7 +597,7 @@ public static LinearPowerDensity FromMilliwattsPerCentimeter(QuantityValue milli /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerFoot(QuantityValue milliwattsperfoot) { - double value = (double) milliwattsperfoot; + QuantityValue value = (QuantityValue) milliwattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerFoot); } @@ -604,7 +607,7 @@ public static LinearPowerDensity FromMilliwattsPerFoot(QuantityValue milliwattsp /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerInch(QuantityValue milliwattsperinch) { - double value = (double) milliwattsperinch; + QuantityValue value = (QuantityValue) milliwattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerInch); } @@ -614,7 +617,7 @@ public static LinearPowerDensity FromMilliwattsPerInch(QuantityValue milliwattsp /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerMeter(QuantityValue milliwattspermeter) { - double value = (double) milliwattspermeter; + QuantityValue value = (QuantityValue) milliwattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMeter); } @@ -624,7 +627,7 @@ public static LinearPowerDensity FromMilliwattsPerMeter(QuantityValue milliwatts /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerMillimeter(QuantityValue milliwattspermillimeter) { - double value = (double) milliwattspermillimeter; + QuantityValue value = (QuantityValue) milliwattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMillimeter); } @@ -634,7 +637,7 @@ public static LinearPowerDensity FromMilliwattsPerMillimeter(QuantityValue milli /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerCentimeter(QuantityValue wattspercentimeter) { - double value = (double) wattspercentimeter; + QuantityValue value = (QuantityValue) wattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerCentimeter); } @@ -644,7 +647,7 @@ public static LinearPowerDensity FromWattsPerCentimeter(QuantityValue wattsperce /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerFoot(QuantityValue wattsperfoot) { - double value = (double) wattsperfoot; + QuantityValue value = (QuantityValue) wattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerFoot); } @@ -654,7 +657,7 @@ public static LinearPowerDensity FromWattsPerFoot(QuantityValue wattsperfoot) /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerInch(QuantityValue wattsperinch) { - double value = (double) wattsperinch; + QuantityValue value = (QuantityValue) wattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerInch); } @@ -664,7 +667,7 @@ public static LinearPowerDensity FromWattsPerInch(QuantityValue wattsperinch) /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerMeter(QuantityValue wattspermeter) { - double value = (double) wattspermeter; + QuantityValue value = (QuantityValue) wattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMeter); } @@ -674,7 +677,7 @@ public static LinearPowerDensity FromWattsPerMeter(QuantityValue wattspermeter) /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerMillimeter(QuantityValue wattspermillimeter) { - double value = (double) wattspermillimeter; + QuantityValue value = (QuantityValue) wattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMillimeter); } @@ -686,7 +689,7 @@ public static LinearPowerDensity FromWattsPerMillimeter(QuantityValue wattspermi /// LinearPowerDensity unit value. public static LinearPowerDensity From(QuantityValue value, LinearPowerDensityUnit fromUnit) { - return new LinearPowerDensity((double)value, fromUnit); + return new LinearPowerDensity((QuantityValue)value, fromUnit); } #endregion @@ -856,25 +859,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea } /// Get from multiplying value and . - public static LinearPowerDensity operator *(double left, LinearPowerDensity right) + public static LinearPowerDensity operator *(QuantityValue left, LinearPowerDensity right) { return new LinearPowerDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LinearPowerDensity operator *(LinearPowerDensity left, double right) + public static LinearPowerDensity operator *(LinearPowerDensity left, QuantityValue right) { return new LinearPowerDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LinearPowerDensity operator /(LinearPowerDensity left, double right) + public static LinearPowerDensity operator /(LinearPowerDensity left, QuantityValue right) { return new LinearPowerDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LinearPowerDensity left, LinearPowerDensity right) + public static QuantityValue operator /(LinearPowerDensity left, LinearPowerDensity right) { return left.WattsPerMeter / right.WattsPerMeter; } @@ -907,6 +910,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -919,7 +935,29 @@ public int CompareTo(object obj) /// public int CompareTo(LinearPowerDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) + return false; + return Equals(objLinearPowerDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(LinearPowerDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -962,13 +1000,13 @@ public int CompareTo(LinearPowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(LinearPowerDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -979,7 +1017,7 @@ public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType co /// A hash code for the current LinearPowerDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -990,17 +1028,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LinearPowerDensityUnit unit) + public QuantityValue As(LinearPowerDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1015,12 +1052,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) + if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearPowerDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1052,7 +1089,7 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit, UnitConverter unit var converted = conversionFunction(this); return (LinearPowerDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LinearPowerDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1060,17 +1097,17 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) + if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLinearPowerDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1097,10 +1134,10 @@ public LinearPowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LinearPowerDensityUnit unit) + private QuantityValue GetValueAs(LinearPowerDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index d78acbfd8c..0f8d6b6604 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminosity /// [DataContract] - public partial struct Luminosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -88,9 +88,9 @@ static Luminosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Luminosity(double value, LuminosityUnit unit) + public Luminosity(QuantityValue value, LuminosityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -102,14 +102,14 @@ public Luminosity(double value, LuminosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Luminosity(double value, UnitSystem unitSystem) + public Luminosity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -150,7 +150,10 @@ public Luminosity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +176,74 @@ public Luminosity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decawatts => As(LuminosityUnit.Decawatt); + public QuantityValue Decawatts => As(LuminosityUnit.Decawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Deciwatts => As(LuminosityUnit.Deciwatt); + public QuantityValue Deciwatts => As(LuminosityUnit.Deciwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Femtowatts => As(LuminosityUnit.Femtowatt); + public QuantityValue Femtowatts => As(LuminosityUnit.Femtowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigawatts => As(LuminosityUnit.Gigawatt); + public QuantityValue Gigawatts => As(LuminosityUnit.Gigawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilowatts => As(LuminosityUnit.Kilowatt); + public QuantityValue Kilowatts => As(LuminosityUnit.Kilowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megawatts => As(LuminosityUnit.Megawatt); + public QuantityValue Megawatts => As(LuminosityUnit.Megawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microwatts => As(LuminosityUnit.Microwatt); + public QuantityValue Microwatts => As(LuminosityUnit.Microwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliwatts => As(LuminosityUnit.Milliwatt); + public QuantityValue Milliwatts => As(LuminosityUnit.Milliwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanowatts => As(LuminosityUnit.Nanowatt); + public QuantityValue Nanowatts => As(LuminosityUnit.Nanowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Petawatts => As(LuminosityUnit.Petawatt); + public QuantityValue Petawatts => As(LuminosityUnit.Petawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Picowatts => As(LuminosityUnit.Picowatt); + public QuantityValue Picowatts => As(LuminosityUnit.Picowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SolarLuminosities => As(LuminosityUnit.SolarLuminosity); + public QuantityValue SolarLuminosities => As(LuminosityUnit.SolarLuminosity); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Terawatts => As(LuminosityUnit.Terawatt); + public QuantityValue Terawatts => As(LuminosityUnit.Terawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Watts => As(LuminosityUnit.Watt); + public QuantityValue Watts => As(LuminosityUnit.Watt); #endregion @@ -335,7 +338,7 @@ public static string GetAbbreviation(LuminosityUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static Luminosity FromDecawatts(QuantityValue decawatts) { - double value = (double) decawatts; + QuantityValue value = (QuantityValue) decawatts; return new Luminosity(value, LuminosityUnit.Decawatt); } @@ -345,7 +348,7 @@ public static Luminosity FromDecawatts(QuantityValue decawatts) /// If value is NaN or Infinity. public static Luminosity FromDeciwatts(QuantityValue deciwatts) { - double value = (double) deciwatts; + QuantityValue value = (QuantityValue) deciwatts; return new Luminosity(value, LuminosityUnit.Deciwatt); } @@ -355,7 +358,7 @@ public static Luminosity FromDeciwatts(QuantityValue deciwatts) /// If value is NaN or Infinity. public static Luminosity FromFemtowatts(QuantityValue femtowatts) { - double value = (double) femtowatts; + QuantityValue value = (QuantityValue) femtowatts; return new Luminosity(value, LuminosityUnit.Femtowatt); } @@ -365,7 +368,7 @@ public static Luminosity FromFemtowatts(QuantityValue femtowatts) /// If value is NaN or Infinity. public static Luminosity FromGigawatts(QuantityValue gigawatts) { - double value = (double) gigawatts; + QuantityValue value = (QuantityValue) gigawatts; return new Luminosity(value, LuminosityUnit.Gigawatt); } @@ -375,7 +378,7 @@ public static Luminosity FromGigawatts(QuantityValue gigawatts) /// If value is NaN or Infinity. public static Luminosity FromKilowatts(QuantityValue kilowatts) { - double value = (double) kilowatts; + QuantityValue value = (QuantityValue) kilowatts; return new Luminosity(value, LuminosityUnit.Kilowatt); } @@ -385,7 +388,7 @@ public static Luminosity FromKilowatts(QuantityValue kilowatts) /// If value is NaN or Infinity. public static Luminosity FromMegawatts(QuantityValue megawatts) { - double value = (double) megawatts; + QuantityValue value = (QuantityValue) megawatts; return new Luminosity(value, LuminosityUnit.Megawatt); } @@ -395,7 +398,7 @@ public static Luminosity FromMegawatts(QuantityValue megawatts) /// If value is NaN or Infinity. public static Luminosity FromMicrowatts(QuantityValue microwatts) { - double value = (double) microwatts; + QuantityValue value = (QuantityValue) microwatts; return new Luminosity(value, LuminosityUnit.Microwatt); } @@ -405,7 +408,7 @@ public static Luminosity FromMicrowatts(QuantityValue microwatts) /// If value is NaN or Infinity. public static Luminosity FromMilliwatts(QuantityValue milliwatts) { - double value = (double) milliwatts; + QuantityValue value = (QuantityValue) milliwatts; return new Luminosity(value, LuminosityUnit.Milliwatt); } @@ -415,7 +418,7 @@ public static Luminosity FromMilliwatts(QuantityValue milliwatts) /// If value is NaN or Infinity. public static Luminosity FromNanowatts(QuantityValue nanowatts) { - double value = (double) nanowatts; + QuantityValue value = (QuantityValue) nanowatts; return new Luminosity(value, LuminosityUnit.Nanowatt); } @@ -425,7 +428,7 @@ public static Luminosity FromNanowatts(QuantityValue nanowatts) /// If value is NaN or Infinity. public static Luminosity FromPetawatts(QuantityValue petawatts) { - double value = (double) petawatts; + QuantityValue value = (QuantityValue) petawatts; return new Luminosity(value, LuminosityUnit.Petawatt); } @@ -435,7 +438,7 @@ public static Luminosity FromPetawatts(QuantityValue petawatts) /// If value is NaN or Infinity. public static Luminosity FromPicowatts(QuantityValue picowatts) { - double value = (double) picowatts; + QuantityValue value = (QuantityValue) picowatts; return new Luminosity(value, LuminosityUnit.Picowatt); } @@ -445,7 +448,7 @@ public static Luminosity FromPicowatts(QuantityValue picowatts) /// If value is NaN or Infinity. public static Luminosity FromSolarLuminosities(QuantityValue solarluminosities) { - double value = (double) solarluminosities; + QuantityValue value = (QuantityValue) solarluminosities; return new Luminosity(value, LuminosityUnit.SolarLuminosity); } @@ -455,7 +458,7 @@ public static Luminosity FromSolarLuminosities(QuantityValue solarluminosities) /// If value is NaN or Infinity. public static Luminosity FromTerawatts(QuantityValue terawatts) { - double value = (double) terawatts; + QuantityValue value = (QuantityValue) terawatts; return new Luminosity(value, LuminosityUnit.Terawatt); } @@ -465,7 +468,7 @@ public static Luminosity FromTerawatts(QuantityValue terawatts) /// If value is NaN or Infinity. public static Luminosity FromWatts(QuantityValue watts) { - double value = (double) watts; + QuantityValue value = (QuantityValue) watts; return new Luminosity(value, LuminosityUnit.Watt); } @@ -477,7 +480,7 @@ public static Luminosity FromWatts(QuantityValue watts) /// Luminosity unit value. public static Luminosity From(QuantityValue value, LuminosityUnit fromUnit) { - return new Luminosity((double)value, fromUnit); + return new Luminosity((QuantityValue)value, fromUnit); } #endregion @@ -647,25 +650,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static Luminosity operator *(double left, Luminosity right) + public static Luminosity operator *(QuantityValue left, Luminosity right) { return new Luminosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Luminosity operator *(Luminosity left, double right) + public static Luminosity operator *(Luminosity left, QuantityValue right) { return new Luminosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Luminosity operator /(Luminosity left, double right) + public static Luminosity operator /(Luminosity left, QuantityValue right) { return new Luminosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Luminosity left, Luminosity right) + public static QuantityValue operator /(Luminosity left, Luminosity right) { return left.Watts / right.Watts; } @@ -698,6 +701,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Luminosity left, Luminosity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Luminosity left, Luminosity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -710,7 +726,29 @@ public int CompareTo(object obj) /// public int CompareTo(Luminosity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Luminosity objLuminosity)) + return false; + return Equals(objLuminosity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Luminosity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -753,13 +791,13 @@ public int CompareTo(Luminosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Luminosity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Luminosity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -770,7 +808,7 @@ public bool Equals(Luminosity other, double tolerance, ComparisonType comparison /// A hash code for the current Luminosity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -781,17 +819,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminosityUnit unit) + public QuantityValue As(LuminosityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -806,12 +843,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LuminosityUnit unitAsLuminosityUnit)) + if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminosityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -843,7 +880,7 @@ public Luminosity ToUnit(LuminosityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Luminosity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LuminosityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -851,17 +888,17 @@ public Luminosity ToUnit(LuminosityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminosityUnit unitAsLuminosityUnit)) + if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -888,10 +925,10 @@ public Luminosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LuminosityUnit unit) + private QuantityValue GetValueAs(LuminosityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index debe7b5dd7..815f8a24de 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_flux /// [DataContract] - public partial struct LuminousFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static LuminousFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LuminousFlux(double value, LuminousFluxUnit unit) + public LuminousFlux(QuantityValue value, LuminousFluxUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public LuminousFlux(double value, LuminousFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousFlux(double value, UnitSystem unitSystem) + public LuminousFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public LuminousFlux(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Lumens => As(LuminousFluxUnit.Lumen); + public QuantityValue Lumens => As(LuminousFluxUnit.Lumen); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(LuminousFluxUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static LuminousFlux FromLumens(QuantityValue lumens) { - double value = (double) lumens; + QuantityValue value = (QuantityValue) lumens; return new LuminousFlux(value, LuminousFluxUnit.Lumen); } @@ -230,7 +233,7 @@ public static LuminousFlux FromLumens(QuantityValue lumens) /// LuminousFlux unit value. public static LuminousFlux From(QuantityValue value, LuminousFluxUnit fromUnit) { - return new LuminousFlux((double)value, fromUnit); + return new LuminousFlux((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static LuminousFlux operator *(double left, LuminousFlux right) + public static LuminousFlux operator *(QuantityValue left, LuminousFlux right) { return new LuminousFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LuminousFlux operator *(LuminousFlux left, double right) + public static LuminousFlux operator *(LuminousFlux left, QuantityValue right) { return new LuminousFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LuminousFlux operator /(LuminousFlux left, double right) + public static LuminousFlux operator /(LuminousFlux left, QuantityValue right) { return new LuminousFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LuminousFlux left, LuminousFlux right) + public static QuantityValue operator /(LuminousFlux left, LuminousFlux right) { return left.Lumens / right.Lumens; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(LuminousFlux left, LuminousFlux right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(LuminousFlux left, LuminousFlux right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(LuminousFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is LuminousFlux objLuminousFlux)) + return false; + return Equals(objLuminousFlux); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(LuminousFlux other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(LuminousFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(LuminousFlux other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparis /// A hash code for the current LuminousFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousFluxUnit unit) + public QuantityValue As(LuminousFluxUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) + if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousFluxUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (LuminousFlux)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LuminousFluxUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) + if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminousFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public LuminousFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LuminousFluxUnit unit) + private QuantityValue GetValueAs(LuminousFluxUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 82199274f5..0e338c9e86 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_intensity /// [DataContract] - public partial struct LuminousIntensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static LuminousIntensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LuminousIntensity(double value, LuminousIntensityUnit unit) + public LuminousIntensity(QuantityValue value, LuminousIntensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public LuminousIntensity(double value, LuminousIntensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousIntensity(double value, UnitSystem unitSystem) + public LuminousIntensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public LuminousIntensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Candela => As(LuminousIntensityUnit.Candela); + public QuantityValue Candela => As(LuminousIntensityUnit.Candela); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(LuminousIntensityUnit unit, IFormatProvider /// If value is NaN or Infinity. public static LuminousIntensity FromCandela(QuantityValue candela) { - double value = (double) candela; + QuantityValue value = (QuantityValue) candela; return new LuminousIntensity(value, LuminousIntensityUnit.Candela); } @@ -230,7 +233,7 @@ public static LuminousIntensity FromCandela(QuantityValue candela) /// LuminousIntensity unit value. public static LuminousIntensity From(QuantityValue value, LuminousIntensityUnit fromUnit) { - return new LuminousIntensity((double)value, fromUnit); + return new LuminousIntensity((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static LuminousIntensity operator *(double left, LuminousIntensity right) + public static LuminousIntensity operator *(QuantityValue left, LuminousIntensity right) { return new LuminousIntensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LuminousIntensity operator *(LuminousIntensity left, double right) + public static LuminousIntensity operator *(LuminousIntensity left, QuantityValue right) { return new LuminousIntensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LuminousIntensity operator /(LuminousIntensity left, double right) + public static LuminousIntensity operator /(LuminousIntensity left, QuantityValue right) { return new LuminousIntensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(LuminousIntensity left, LuminousIntensity right) + public static QuantityValue operator /(LuminousIntensity left, LuminousIntensity right) { return left.Candela / right.Candela; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(LuminousIntensity left, LuminousIntensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(LuminousIntensity left, LuminousIntensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(LuminousIntensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is LuminousIntensity objLuminousIntensity)) + return false; + return Equals(objLuminousIntensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(LuminousIntensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(LuminousIntensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(LuminousIntensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(LuminousIntensity other, double tolerance, ComparisonType com /// A hash code for the current LuminousIntensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(LuminousIntensityUnit unit) + public QuantityValue As(LuminousIntensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) + if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousIntensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (LuminousIntensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(LuminousIntensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit, UnitConverter unitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) + if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminousIntensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public LuminousIntensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(LuminousIntensityUnit unit) + private QuantityValue GetValueAs(LuminousIntensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 6103ff0bc9..11250ee88c 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_field /// [DataContract] - public partial struct MagneticField : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static MagneticField() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MagneticField(double value, MagneticFieldUnit unit) + public MagneticField(QuantityValue value, MagneticFieldUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -94,14 +94,14 @@ public MagneticField(double value, MagneticFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticField(double value, UnitSystem unitSystem) + public MagneticField(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,7 +142,10 @@ public MagneticField(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -165,34 +168,34 @@ public MagneticField(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gausses => As(MagneticFieldUnit.Gauss); + public QuantityValue Gausses => As(MagneticFieldUnit.Gauss); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microteslas => As(MagneticFieldUnit.Microtesla); + public QuantityValue Microteslas => As(MagneticFieldUnit.Microtesla); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milligausses => As(MagneticFieldUnit.Milligauss); + public QuantityValue Milligausses => As(MagneticFieldUnit.Milligauss); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliteslas => As(MagneticFieldUnit.Millitesla); + public QuantityValue Milliteslas => As(MagneticFieldUnit.Millitesla); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanoteslas => As(MagneticFieldUnit.Nanotesla); + public QuantityValue Nanoteslas => As(MagneticFieldUnit.Nanotesla); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Teslas => As(MagneticFieldUnit.Tesla); + public QuantityValue Teslas => As(MagneticFieldUnit.Tesla); #endregion @@ -263,7 +266,7 @@ public static string GetAbbreviation(MagneticFieldUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static MagneticField FromGausses(QuantityValue gausses) { - double value = (double) gausses; + QuantityValue value = (QuantityValue) gausses; return new MagneticField(value, MagneticFieldUnit.Gauss); } @@ -273,7 +276,7 @@ public static MagneticField FromGausses(QuantityValue gausses) /// If value is NaN or Infinity. public static MagneticField FromMicroteslas(QuantityValue microteslas) { - double value = (double) microteslas; + QuantityValue value = (QuantityValue) microteslas; return new MagneticField(value, MagneticFieldUnit.Microtesla); } @@ -283,7 +286,7 @@ public static MagneticField FromMicroteslas(QuantityValue microteslas) /// If value is NaN or Infinity. public static MagneticField FromMilligausses(QuantityValue milligausses) { - double value = (double) milligausses; + QuantityValue value = (QuantityValue) milligausses; return new MagneticField(value, MagneticFieldUnit.Milligauss); } @@ -293,7 +296,7 @@ public static MagneticField FromMilligausses(QuantityValue milligausses) /// If value is NaN or Infinity. public static MagneticField FromMilliteslas(QuantityValue milliteslas) { - double value = (double) milliteslas; + QuantityValue value = (QuantityValue) milliteslas; return new MagneticField(value, MagneticFieldUnit.Millitesla); } @@ -303,7 +306,7 @@ public static MagneticField FromMilliteslas(QuantityValue milliteslas) /// If value is NaN or Infinity. public static MagneticField FromNanoteslas(QuantityValue nanoteslas) { - double value = (double) nanoteslas; + QuantityValue value = (QuantityValue) nanoteslas; return new MagneticField(value, MagneticFieldUnit.Nanotesla); } @@ -313,7 +316,7 @@ public static MagneticField FromNanoteslas(QuantityValue nanoteslas) /// If value is NaN or Infinity. public static MagneticField FromTeslas(QuantityValue teslas) { - double value = (double) teslas; + QuantityValue value = (QuantityValue) teslas; return new MagneticField(value, MagneticFieldUnit.Tesla); } @@ -325,7 +328,7 @@ public static MagneticField FromTeslas(QuantityValue teslas) /// MagneticField unit value. public static MagneticField From(QuantityValue value, MagneticFieldUnit fromUnit) { - return new MagneticField((double)value, fromUnit); + return new MagneticField((QuantityValue)value, fromUnit); } #endregion @@ -495,25 +498,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static MagneticField operator *(double left, MagneticField right) + public static MagneticField operator *(QuantityValue left, MagneticField right) { return new MagneticField(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MagneticField operator *(MagneticField left, double right) + public static MagneticField operator *(MagneticField left, QuantityValue right) { return new MagneticField(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MagneticField operator /(MagneticField left, double right) + public static MagneticField operator /(MagneticField left, QuantityValue right) { return new MagneticField(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MagneticField left, MagneticField right) + public static QuantityValue operator /(MagneticField left, MagneticField right) { return left.Teslas / right.Teslas; } @@ -546,6 +549,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MagneticField left, MagneticField right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MagneticField left, MagneticField right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -558,7 +574,29 @@ public int CompareTo(object obj) /// public int CompareTo(MagneticField other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MagneticField objMagneticField)) + return false; + return Equals(objMagneticField); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MagneticField other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -601,13 +639,13 @@ public int CompareTo(MagneticField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType) + public bool Equals(MagneticField other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -618,7 +656,7 @@ public bool Equals(MagneticField other, double tolerance, ComparisonType compari /// A hash code for the current MagneticField. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -629,17 +667,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFieldUnit unit) + public QuantityValue As(MagneticFieldUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -654,12 +691,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) + if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFieldUnit); + return (QuantityValue)As(typedUnit); } /// @@ -691,7 +728,7 @@ public MagneticField ToUnit(MagneticFieldUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MagneticField)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MagneticFieldUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -699,17 +736,17 @@ public MagneticField ToUnit(MagneticFieldUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) + if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagneticFieldUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -736,10 +773,10 @@ public MagneticField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MagneticFieldUnit unit) + private QuantityValue GetValueAs(MagneticFieldUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 4be6d9f2f7..d5bd23d80a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_flux /// [DataContract] - public partial struct MagneticFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static MagneticFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MagneticFlux(double value, MagneticFluxUnit unit) + public MagneticFlux(QuantityValue value, MagneticFluxUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public MagneticFlux(double value, MagneticFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticFlux(double value, UnitSystem unitSystem) + public MagneticFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public MagneticFlux(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Webers => As(MagneticFluxUnit.Weber); + public QuantityValue Webers => As(MagneticFluxUnit.Weber); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(MagneticFluxUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static MagneticFlux FromWebers(QuantityValue webers) { - double value = (double) webers; + QuantityValue value = (QuantityValue) webers; return new MagneticFlux(value, MagneticFluxUnit.Weber); } @@ -230,7 +233,7 @@ public static MagneticFlux FromWebers(QuantityValue webers) /// MagneticFlux unit value. public static MagneticFlux From(QuantityValue value, MagneticFluxUnit fromUnit) { - return new MagneticFlux((double)value, fromUnit); + return new MagneticFlux((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static MagneticFlux operator *(double left, MagneticFlux right) + public static MagneticFlux operator *(QuantityValue left, MagneticFlux right) { return new MagneticFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MagneticFlux operator *(MagneticFlux left, double right) + public static MagneticFlux operator *(MagneticFlux left, QuantityValue right) { return new MagneticFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MagneticFlux operator /(MagneticFlux left, double right) + public static MagneticFlux operator /(MagneticFlux left, QuantityValue right) { return new MagneticFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MagneticFlux left, MagneticFlux right) + public static QuantityValue operator /(MagneticFlux left, MagneticFlux right) { return left.Webers / right.Webers; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MagneticFlux left, MagneticFlux right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MagneticFlux left, MagneticFlux right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(MagneticFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MagneticFlux objMagneticFlux)) + return false; + return Equals(objMagneticFlux); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MagneticFlux other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(MagneticFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(MagneticFlux other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparis /// A hash code for the current MagneticFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagneticFluxUnit unit) + public QuantityValue As(MagneticFluxUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) + if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFluxUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MagneticFlux)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MagneticFluxUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) + if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagneticFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public MagneticFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MagneticFluxUnit unit) + private QuantityValue GetValueAs(MagneticFluxUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index f9a7bc0f03..1696417a38 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetization /// [DataContract] - public partial struct Magnetization : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Magnetization() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Magnetization(double value, MagnetizationUnit unit) + public Magnetization(QuantityValue value, MagnetizationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public Magnetization(double value, MagnetizationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Magnetization(double value, UnitSystem unitSystem) + public Magnetization(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public Magnetization(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public Magnetization(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); + public QuantityValue AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(MagnetizationUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static Magnetization FromAmperesPerMeter(QuantityValue amperespermeter) { - double value = (double) amperespermeter; + QuantityValue value = (QuantityValue) amperespermeter; return new Magnetization(value, MagnetizationUnit.AmperePerMeter); } @@ -230,7 +233,7 @@ public static Magnetization FromAmperesPerMeter(QuantityValue amperespermeter) /// Magnetization unit value. public static Magnetization From(QuantityValue value, MagnetizationUnit fromUnit) { - return new Magnetization((double)value, fromUnit); + return new Magnetization((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static Magnetization operator *(double left, Magnetization right) + public static Magnetization operator *(QuantityValue left, Magnetization right) { return new Magnetization(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Magnetization operator *(Magnetization left, double right) + public static Magnetization operator *(Magnetization left, QuantityValue right) { return new Magnetization(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Magnetization operator /(Magnetization left, double right) + public static Magnetization operator /(Magnetization left, QuantityValue right) { return new Magnetization(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Magnetization left, Magnetization right) + public static QuantityValue operator /(Magnetization left, Magnetization right) { return left.AmperesPerMeter / right.AmperesPerMeter; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Magnetization left, Magnetization right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Magnetization left, Magnetization right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(Magnetization other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Magnetization objMagnetization)) + return false; + return Equals(objMagnetization); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Magnetization other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(Magnetization other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType) + public bool Equals(Magnetization other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(Magnetization other, double tolerance, ComparisonType compari /// A hash code for the current Magnetization. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MagnetizationUnit unit) + public QuantityValue As(MagnetizationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) + if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return As(unitAsMagnetizationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public Magnetization ToUnit(MagnetizationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Magnetization)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MagnetizationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public Magnetization ToUnit(MagnetizationUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) + if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagnetizationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public Magnetization ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MagnetizationUnit unit) + private QuantityValue GetValueAs(MagnetizationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 16ecf48781..968a692d08 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). /// [DataContract] - public partial struct Mass : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -96,9 +96,9 @@ static Mass() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Mass(double value, MassUnit unit) + public Mass(QuantityValue value, MassUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -110,14 +110,14 @@ public Mass(double value, MassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Mass(double value, UnitSystem unitSystem) + public Mass(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -158,7 +158,10 @@ public Mass(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -181,129 +184,129 @@ public Mass(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centigrams => As(MassUnit.Centigram); + public QuantityValue Centigrams => As(MassUnit.Centigram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decagrams => As(MassUnit.Decagram); + public QuantityValue Decagrams => As(MassUnit.Decagram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decigrams => As(MassUnit.Decigram); + public QuantityValue Decigrams => As(MassUnit.Decigram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double EarthMasses => As(MassUnit.EarthMass); + public QuantityValue EarthMasses => As(MassUnit.EarthMass); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Grains => As(MassUnit.Grain); + public QuantityValue Grains => As(MassUnit.Grain); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Grams => As(MassUnit.Gram); + public QuantityValue Grams => As(MassUnit.Gram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hectograms => As(MassUnit.Hectogram); + public QuantityValue Hectograms => As(MassUnit.Hectogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilograms => As(MassUnit.Kilogram); + public QuantityValue Kilograms => As(MassUnit.Kilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilopounds => As(MassUnit.Kilopound); + public QuantityValue Kilopounds => As(MassUnit.Kilopound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilotonnes => As(MassUnit.Kilotonne); + public QuantityValue Kilotonnes => As(MassUnit.Kilotonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LongHundredweight => As(MassUnit.LongHundredweight); + public QuantityValue LongHundredweight => As(MassUnit.LongHundredweight); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LongTons => As(MassUnit.LongTon); + public QuantityValue LongTons => As(MassUnit.LongTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megapounds => As(MassUnit.Megapound); + public QuantityValue Megapounds => As(MassUnit.Megapound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megatonnes => As(MassUnit.Megatonne); + public QuantityValue Megatonnes => As(MassUnit.Megatonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Micrograms => As(MassUnit.Microgram); + public QuantityValue Micrograms => As(MassUnit.Microgram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milligrams => As(MassUnit.Milligram); + public QuantityValue Milligrams => As(MassUnit.Milligram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanograms => As(MassUnit.Nanogram); + public QuantityValue Nanograms => As(MassUnit.Nanogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Ounces => As(MassUnit.Ounce); + public QuantityValue Ounces => As(MassUnit.Ounce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Pounds => As(MassUnit.Pound); + public QuantityValue Pounds => As(MassUnit.Pound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ShortHundredweight => As(MassUnit.ShortHundredweight); + public QuantityValue ShortHundredweight => As(MassUnit.ShortHundredweight); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ShortTons => As(MassUnit.ShortTon); + public QuantityValue ShortTons => As(MassUnit.ShortTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Slugs => As(MassUnit.Slug); + public QuantityValue Slugs => As(MassUnit.Slug); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SolarMasses => As(MassUnit.SolarMass); + public QuantityValue SolarMasses => As(MassUnit.SolarMass); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Stone => As(MassUnit.Stone); + public QuantityValue Stone => As(MassUnit.Stone); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Tonnes => As(MassUnit.Tonne); + public QuantityValue Tonnes => As(MassUnit.Tonne); #endregion @@ -466,7 +469,7 @@ public static string GetAbbreviation(MassUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Mass FromCentigrams(QuantityValue centigrams) { - double value = (double) centigrams; + QuantityValue value = (QuantityValue) centigrams; return new Mass(value, MassUnit.Centigram); } @@ -476,7 +479,7 @@ public static Mass FromCentigrams(QuantityValue centigrams) /// If value is NaN or Infinity. public static Mass FromDecagrams(QuantityValue decagrams) { - double value = (double) decagrams; + QuantityValue value = (QuantityValue) decagrams; return new Mass(value, MassUnit.Decagram); } @@ -486,7 +489,7 @@ public static Mass FromDecagrams(QuantityValue decagrams) /// If value is NaN or Infinity. public static Mass FromDecigrams(QuantityValue decigrams) { - double value = (double) decigrams; + QuantityValue value = (QuantityValue) decigrams; return new Mass(value, MassUnit.Decigram); } @@ -496,7 +499,7 @@ public static Mass FromDecigrams(QuantityValue decigrams) /// If value is NaN or Infinity. public static Mass FromEarthMasses(QuantityValue earthmasses) { - double value = (double) earthmasses; + QuantityValue value = (QuantityValue) earthmasses; return new Mass(value, MassUnit.EarthMass); } @@ -506,7 +509,7 @@ public static Mass FromEarthMasses(QuantityValue earthmasses) /// If value is NaN or Infinity. public static Mass FromGrains(QuantityValue grains) { - double value = (double) grains; + QuantityValue value = (QuantityValue) grains; return new Mass(value, MassUnit.Grain); } @@ -516,7 +519,7 @@ public static Mass FromGrains(QuantityValue grains) /// If value is NaN or Infinity. public static Mass FromGrams(QuantityValue grams) { - double value = (double) grams; + QuantityValue value = (QuantityValue) grams; return new Mass(value, MassUnit.Gram); } @@ -526,7 +529,7 @@ public static Mass FromGrams(QuantityValue grams) /// If value is NaN or Infinity. public static Mass FromHectograms(QuantityValue hectograms) { - double value = (double) hectograms; + QuantityValue value = (QuantityValue) hectograms; return new Mass(value, MassUnit.Hectogram); } @@ -536,7 +539,7 @@ public static Mass FromHectograms(QuantityValue hectograms) /// If value is NaN or Infinity. public static Mass FromKilograms(QuantityValue kilograms) { - double value = (double) kilograms; + QuantityValue value = (QuantityValue) kilograms; return new Mass(value, MassUnit.Kilogram); } @@ -546,7 +549,7 @@ public static Mass FromKilograms(QuantityValue kilograms) /// If value is NaN or Infinity. public static Mass FromKilopounds(QuantityValue kilopounds) { - double value = (double) kilopounds; + QuantityValue value = (QuantityValue) kilopounds; return new Mass(value, MassUnit.Kilopound); } @@ -556,7 +559,7 @@ public static Mass FromKilopounds(QuantityValue kilopounds) /// If value is NaN or Infinity. public static Mass FromKilotonnes(QuantityValue kilotonnes) { - double value = (double) kilotonnes; + QuantityValue value = (QuantityValue) kilotonnes; return new Mass(value, MassUnit.Kilotonne); } @@ -566,7 +569,7 @@ public static Mass FromKilotonnes(QuantityValue kilotonnes) /// If value is NaN or Infinity. public static Mass FromLongHundredweight(QuantityValue longhundredweight) { - double value = (double) longhundredweight; + QuantityValue value = (QuantityValue) longhundredweight; return new Mass(value, MassUnit.LongHundredweight); } @@ -576,7 +579,7 @@ public static Mass FromLongHundredweight(QuantityValue longhundredweight) /// If value is NaN or Infinity. public static Mass FromLongTons(QuantityValue longtons) { - double value = (double) longtons; + QuantityValue value = (QuantityValue) longtons; return new Mass(value, MassUnit.LongTon); } @@ -586,7 +589,7 @@ public static Mass FromLongTons(QuantityValue longtons) /// If value is NaN or Infinity. public static Mass FromMegapounds(QuantityValue megapounds) { - double value = (double) megapounds; + QuantityValue value = (QuantityValue) megapounds; return new Mass(value, MassUnit.Megapound); } @@ -596,7 +599,7 @@ public static Mass FromMegapounds(QuantityValue megapounds) /// If value is NaN or Infinity. public static Mass FromMegatonnes(QuantityValue megatonnes) { - double value = (double) megatonnes; + QuantityValue value = (QuantityValue) megatonnes; return new Mass(value, MassUnit.Megatonne); } @@ -606,7 +609,7 @@ public static Mass FromMegatonnes(QuantityValue megatonnes) /// If value is NaN or Infinity. public static Mass FromMicrograms(QuantityValue micrograms) { - double value = (double) micrograms; + QuantityValue value = (QuantityValue) micrograms; return new Mass(value, MassUnit.Microgram); } @@ -616,7 +619,7 @@ public static Mass FromMicrograms(QuantityValue micrograms) /// If value is NaN or Infinity. public static Mass FromMilligrams(QuantityValue milligrams) { - double value = (double) milligrams; + QuantityValue value = (QuantityValue) milligrams; return new Mass(value, MassUnit.Milligram); } @@ -626,7 +629,7 @@ public static Mass FromMilligrams(QuantityValue milligrams) /// If value is NaN or Infinity. public static Mass FromNanograms(QuantityValue nanograms) { - double value = (double) nanograms; + QuantityValue value = (QuantityValue) nanograms; return new Mass(value, MassUnit.Nanogram); } @@ -636,7 +639,7 @@ public static Mass FromNanograms(QuantityValue nanograms) /// If value is NaN or Infinity. public static Mass FromOunces(QuantityValue ounces) { - double value = (double) ounces; + QuantityValue value = (QuantityValue) ounces; return new Mass(value, MassUnit.Ounce); } @@ -646,7 +649,7 @@ public static Mass FromOunces(QuantityValue ounces) /// If value is NaN or Infinity. public static Mass FromPounds(QuantityValue pounds) { - double value = (double) pounds; + QuantityValue value = (QuantityValue) pounds; return new Mass(value, MassUnit.Pound); } @@ -656,7 +659,7 @@ public static Mass FromPounds(QuantityValue pounds) /// If value is NaN or Infinity. public static Mass FromShortHundredweight(QuantityValue shorthundredweight) { - double value = (double) shorthundredweight; + QuantityValue value = (QuantityValue) shorthundredweight; return new Mass(value, MassUnit.ShortHundredweight); } @@ -666,7 +669,7 @@ public static Mass FromShortHundredweight(QuantityValue shorthundredweight) /// If value is NaN or Infinity. public static Mass FromShortTons(QuantityValue shorttons) { - double value = (double) shorttons; + QuantityValue value = (QuantityValue) shorttons; return new Mass(value, MassUnit.ShortTon); } @@ -676,7 +679,7 @@ public static Mass FromShortTons(QuantityValue shorttons) /// If value is NaN or Infinity. public static Mass FromSlugs(QuantityValue slugs) { - double value = (double) slugs; + QuantityValue value = (QuantityValue) slugs; return new Mass(value, MassUnit.Slug); } @@ -686,7 +689,7 @@ public static Mass FromSlugs(QuantityValue slugs) /// If value is NaN or Infinity. public static Mass FromSolarMasses(QuantityValue solarmasses) { - double value = (double) solarmasses; + QuantityValue value = (QuantityValue) solarmasses; return new Mass(value, MassUnit.SolarMass); } @@ -696,7 +699,7 @@ public static Mass FromSolarMasses(QuantityValue solarmasses) /// If value is NaN or Infinity. public static Mass FromStone(QuantityValue stone) { - double value = (double) stone; + QuantityValue value = (QuantityValue) stone; return new Mass(value, MassUnit.Stone); } @@ -706,7 +709,7 @@ public static Mass FromStone(QuantityValue stone) /// If value is NaN or Infinity. public static Mass FromTonnes(QuantityValue tonnes) { - double value = (double) tonnes; + QuantityValue value = (QuantityValue) tonnes; return new Mass(value, MassUnit.Tonne); } @@ -718,7 +721,7 @@ public static Mass FromTonnes(QuantityValue tonnes) /// Mass unit value. public static Mass From(QuantityValue value, MassUnit fromUnit) { - return new Mass((double)value, fromUnit); + return new Mass((QuantityValue)value, fromUnit); } #endregion @@ -888,25 +891,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU } /// Get from multiplying value and . - public static Mass operator *(double left, Mass right) + public static Mass operator *(QuantityValue left, Mass right) { return new Mass(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Mass operator *(Mass left, double right) + public static Mass operator *(Mass left, QuantityValue right) { return new Mass(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Mass operator /(Mass left, double right) + public static Mass operator /(Mass left, QuantityValue right) { return new Mass(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Mass left, Mass right) + public static QuantityValue operator /(Mass left, Mass right) { return left.Kilograms / right.Kilograms; } @@ -939,6 +942,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Mass left, Mass right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Mass left, Mass right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -951,7 +967,29 @@ public int CompareTo(object obj) /// public int CompareTo(Mass other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Mass objMass)) + return false; + return Equals(objMass); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Mass other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -994,13 +1032,13 @@ public int CompareTo(Mass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) + public bool Equals(Mass other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1011,7 +1049,7 @@ public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Mass. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1022,17 +1060,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassUnit unit) + public QuantityValue As(MassUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1047,12 +1084,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MassUnit unitAsMassUnit)) + if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return As(unitAsMassUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1084,7 +1121,7 @@ public Mass ToUnit(MassUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Mass)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MassUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1092,17 +1129,17 @@ public Mass ToUnit(MassUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassUnit unitAsMassUnit)) + if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1129,10 +1166,10 @@ public Mass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MassUnit unit) + private QuantityValue GetValueAs(MassUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 4e0adad314..23e88d2caa 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) /// [DataContract] - public partial struct MassConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -123,9 +123,9 @@ static MassConcentration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassConcentration(double value, MassConcentrationUnit unit) + public MassConcentration(QuantityValue value, MassConcentrationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -137,14 +137,14 @@ public MassConcentration(double value, MassConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassConcentration(double value, UnitSystem unitSystem) + public MassConcentration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -185,7 +185,10 @@ public MassConcentration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -208,249 +211,249 @@ public MassConcentration(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); + public QuantityValue CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); + public QuantityValue CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); + public QuantityValue CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); + public QuantityValue CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); + public QuantityValue DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); + public QuantityValue DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); + public QuantityValue DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); + public QuantityValue DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); + public QuantityValue GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); + public QuantityValue GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); + public QuantityValue GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); + public QuantityValue GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); + public QuantityValue GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); + public QuantityValue GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); + public QuantityValue GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); + public QuantityValue KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); + public QuantityValue KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); + public QuantityValue KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); + public QuantityValue KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); + public QuantityValue KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); + public QuantityValue KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); + public QuantityValue MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); + public QuantityValue MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); + public QuantityValue MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); + public QuantityValue MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); + public QuantityValue MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); + public QuantityValue MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); + public QuantityValue MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); + public QuantityValue MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); + public QuantityValue MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); + public QuantityValue MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); + public QuantityValue NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); + public QuantityValue NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); + public QuantityValue NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); + public QuantityValue NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); + public QuantityValue OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); + public QuantityValue OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); + public QuantityValue PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); + public QuantityValue PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); + public QuantityValue PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); + public QuantityValue PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); + public QuantityValue PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); + public QuantityValue PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); + public QuantityValue PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); + public QuantityValue PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); + public QuantityValue SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); + public QuantityValue TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); + public QuantityValue TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); + public QuantityValue TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); #endregion @@ -654,7 +657,7 @@ public static string GetAbbreviation(MassConcentrationUnit unit, IFormatProvider /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerDeciliter(QuantityValue centigramsperdeciliter) { - double value = (double) centigramsperdeciliter; + QuantityValue value = (QuantityValue) centigramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerDeciliter); } @@ -664,7 +667,7 @@ public static MassConcentration FromCentigramsPerDeciliter(QuantityValue centigr /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerLiter(QuantityValue centigramsperliter) { - double value = (double) centigramsperliter; + QuantityValue value = (QuantityValue) centigramsperliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerLiter); } @@ -674,7 +677,7 @@ public static MassConcentration FromCentigramsPerLiter(QuantityValue centigramsp /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerMicroliter(QuantityValue centigramspermicroliter) { - double value = (double) centigramspermicroliter; + QuantityValue value = (QuantityValue) centigramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerMicroliter); } @@ -684,7 +687,7 @@ public static MassConcentration FromCentigramsPerMicroliter(QuantityValue centig /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter) { - double value = (double) centigramspermilliliter; + QuantityValue value = (QuantityValue) centigramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerMilliliter); } @@ -694,7 +697,7 @@ public static MassConcentration FromCentigramsPerMilliliter(QuantityValue centig /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerDeciliter(QuantityValue decigramsperdeciliter) { - double value = (double) decigramsperdeciliter; + QuantityValue value = (QuantityValue) decigramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerDeciliter); } @@ -704,7 +707,7 @@ public static MassConcentration FromDecigramsPerDeciliter(QuantityValue decigram /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerLiter(QuantityValue decigramsperliter) { - double value = (double) decigramsperliter; + QuantityValue value = (QuantityValue) decigramsperliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerLiter); } @@ -714,7 +717,7 @@ public static MassConcentration FromDecigramsPerLiter(QuantityValue decigramsper /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerMicroliter(QuantityValue decigramspermicroliter) { - double value = (double) decigramspermicroliter; + QuantityValue value = (QuantityValue) decigramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerMicroliter); } @@ -724,7 +727,7 @@ public static MassConcentration FromDecigramsPerMicroliter(QuantityValue decigra /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter) { - double value = (double) decigramspermilliliter; + QuantityValue value = (QuantityValue) decigramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerMilliliter); } @@ -734,7 +737,7 @@ public static MassConcentration FromDecigramsPerMilliliter(QuantityValue decigra /// If value is NaN or Infinity. public static MassConcentration FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter) { - double value = (double) gramspercubiccentimeter; + QuantityValue value = (QuantityValue) gramspercubiccentimeter; return new MassConcentration(value, MassConcentrationUnit.GramPerCubicCentimeter); } @@ -744,7 +747,7 @@ public static MassConcentration FromGramsPerCubicCentimeter(QuantityValue gramsp /// If value is NaN or Infinity. public static MassConcentration FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) { - double value = (double) gramspercubicmeter; + QuantityValue value = (QuantityValue) gramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMeter); } @@ -754,7 +757,7 @@ public static MassConcentration FromGramsPerCubicMeter(QuantityValue gramspercub /// If value is NaN or Infinity. public static MassConcentration FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter) { - double value = (double) gramspercubicmillimeter; + QuantityValue value = (QuantityValue) gramspercubicmillimeter; return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMillimeter); } @@ -764,7 +767,7 @@ public static MassConcentration FromGramsPerCubicMillimeter(QuantityValue gramsp /// If value is NaN or Infinity. public static MassConcentration FromGramsPerDeciliter(QuantityValue gramsperdeciliter) { - double value = (double) gramsperdeciliter; + QuantityValue value = (QuantityValue) gramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.GramPerDeciliter); } @@ -774,7 +777,7 @@ public static MassConcentration FromGramsPerDeciliter(QuantityValue gramsperdeci /// If value is NaN or Infinity. public static MassConcentration FromGramsPerLiter(QuantityValue gramsperliter) { - double value = (double) gramsperliter; + QuantityValue value = (QuantityValue) gramsperliter; return new MassConcentration(value, MassConcentrationUnit.GramPerLiter); } @@ -784,7 +787,7 @@ public static MassConcentration FromGramsPerLiter(QuantityValue gramsperliter) /// If value is NaN or Infinity. public static MassConcentration FromGramsPerMicroliter(QuantityValue gramspermicroliter) { - double value = (double) gramspermicroliter; + QuantityValue value = (QuantityValue) gramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.GramPerMicroliter); } @@ -794,7 +797,7 @@ public static MassConcentration FromGramsPerMicroliter(QuantityValue gramspermic /// If value is NaN or Infinity. public static MassConcentration FromGramsPerMilliliter(QuantityValue gramspermilliliter) { - double value = (double) gramspermilliliter; + QuantityValue value = (QuantityValue) gramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.GramPerMilliliter); } @@ -804,7 +807,7 @@ public static MassConcentration FromGramsPerMilliliter(QuantityValue gramspermil /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter) { - double value = (double) kilogramspercubiccentimeter; + QuantityValue value = (QuantityValue) kilogramspercubiccentimeter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicCentimeter); } @@ -814,7 +817,7 @@ public static MassConcentration FromKilogramsPerCubicCentimeter(QuantityValue ki /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter) { - double value = (double) kilogramspercubicmeter; + QuantityValue value = (QuantityValue) kilogramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMeter); } @@ -824,7 +827,7 @@ public static MassConcentration FromKilogramsPerCubicMeter(QuantityValue kilogra /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter) { - double value = (double) kilogramspercubicmillimeter; + QuantityValue value = (QuantityValue) kilogramspercubicmillimeter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMillimeter); } @@ -834,7 +837,7 @@ public static MassConcentration FromKilogramsPerCubicMillimeter(QuantityValue ki /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerLiter(QuantityValue kilogramsperliter) { - double value = (double) kilogramsperliter; + QuantityValue value = (QuantityValue) kilogramsperliter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerLiter); } @@ -844,7 +847,7 @@ public static MassConcentration FromKilogramsPerLiter(QuantityValue kilogramsper /// If value is NaN or Infinity. public static MassConcentration FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot) { - double value = (double) kilopoundspercubicfoot; + QuantityValue value = (QuantityValue) kilopoundspercubicfoot; return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicFoot); } @@ -854,7 +857,7 @@ public static MassConcentration FromKilopoundsPerCubicFoot(QuantityValue kilopou /// If value is NaN or Infinity. public static MassConcentration FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch) { - double value = (double) kilopoundspercubicinch; + QuantityValue value = (QuantityValue) kilopoundspercubicinch; return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicInch); } @@ -864,7 +867,7 @@ public static MassConcentration FromKilopoundsPerCubicInch(QuantityValue kilopou /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerCubicMeter(QuantityValue microgramspercubicmeter) { - double value = (double) microgramspercubicmeter; + QuantityValue value = (QuantityValue) microgramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerCubicMeter); } @@ -874,7 +877,7 @@ public static MassConcentration FromMicrogramsPerCubicMeter(QuantityValue microg /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerDeciliter(QuantityValue microgramsperdeciliter) { - double value = (double) microgramsperdeciliter; + QuantityValue value = (QuantityValue) microgramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerDeciliter); } @@ -884,7 +887,7 @@ public static MassConcentration FromMicrogramsPerDeciliter(QuantityValue microgr /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerLiter(QuantityValue microgramsperliter) { - double value = (double) microgramsperliter; + QuantityValue value = (QuantityValue) microgramsperliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerLiter); } @@ -894,7 +897,7 @@ public static MassConcentration FromMicrogramsPerLiter(QuantityValue microgramsp /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerMicroliter(QuantityValue microgramspermicroliter) { - double value = (double) microgramspermicroliter; + QuantityValue value = (QuantityValue) microgramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMicroliter); } @@ -904,7 +907,7 @@ public static MassConcentration FromMicrogramsPerMicroliter(QuantityValue microg /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter) { - double value = (double) microgramspermilliliter; + QuantityValue value = (QuantityValue) microgramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMilliliter); } @@ -914,7 +917,7 @@ public static MassConcentration FromMicrogramsPerMilliliter(QuantityValue microg /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter) { - double value = (double) milligramspercubicmeter; + QuantityValue value = (QuantityValue) milligramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerCubicMeter); } @@ -924,7 +927,7 @@ public static MassConcentration FromMilligramsPerCubicMeter(QuantityValue millig /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerDeciliter(QuantityValue milligramsperdeciliter) { - double value = (double) milligramsperdeciliter; + QuantityValue value = (QuantityValue) milligramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerDeciliter); } @@ -934,7 +937,7 @@ public static MassConcentration FromMilligramsPerDeciliter(QuantityValue milligr /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerLiter(QuantityValue milligramsperliter) { - double value = (double) milligramsperliter; + QuantityValue value = (QuantityValue) milligramsperliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerLiter); } @@ -944,7 +947,7 @@ public static MassConcentration FromMilligramsPerLiter(QuantityValue milligramsp /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerMicroliter(QuantityValue milligramspermicroliter) { - double value = (double) milligramspermicroliter; + QuantityValue value = (QuantityValue) milligramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerMicroliter); } @@ -954,7 +957,7 @@ public static MassConcentration FromMilligramsPerMicroliter(QuantityValue millig /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter) { - double value = (double) milligramspermilliliter; + QuantityValue value = (QuantityValue) milligramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerMilliliter); } @@ -964,7 +967,7 @@ public static MassConcentration FromMilligramsPerMilliliter(QuantityValue millig /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerDeciliter(QuantityValue nanogramsperdeciliter) { - double value = (double) nanogramsperdeciliter; + QuantityValue value = (QuantityValue) nanogramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerDeciliter); } @@ -974,7 +977,7 @@ public static MassConcentration FromNanogramsPerDeciliter(QuantityValue nanogram /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerLiter(QuantityValue nanogramsperliter) { - double value = (double) nanogramsperliter; + QuantityValue value = (QuantityValue) nanogramsperliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerLiter); } @@ -984,7 +987,7 @@ public static MassConcentration FromNanogramsPerLiter(QuantityValue nanogramsper /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerMicroliter(QuantityValue nanogramspermicroliter) { - double value = (double) nanogramspermicroliter; + QuantityValue value = (QuantityValue) nanogramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerMicroliter); } @@ -994,7 +997,7 @@ public static MassConcentration FromNanogramsPerMicroliter(QuantityValue nanogra /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter) { - double value = (double) nanogramspermilliliter; + QuantityValue value = (QuantityValue) nanogramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerMilliliter); } @@ -1004,7 +1007,7 @@ public static MassConcentration FromNanogramsPerMilliliter(QuantityValue nanogra /// If value is NaN or Infinity. public static MassConcentration FromOuncesPerImperialGallon(QuantityValue ouncesperimperialgallon) { - double value = (double) ouncesperimperialgallon; + QuantityValue value = (QuantityValue) ouncesperimperialgallon; return new MassConcentration(value, MassConcentrationUnit.OuncePerImperialGallon); } @@ -1014,7 +1017,7 @@ public static MassConcentration FromOuncesPerImperialGallon(QuantityValue ounces /// If value is NaN or Infinity. public static MassConcentration FromOuncesPerUSGallon(QuantityValue ouncesperusgallon) { - double value = (double) ouncesperusgallon; + QuantityValue value = (QuantityValue) ouncesperusgallon; return new MassConcentration(value, MassConcentrationUnit.OuncePerUSGallon); } @@ -1024,7 +1027,7 @@ public static MassConcentration FromOuncesPerUSGallon(QuantityValue ouncesperusg /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerDeciliter(QuantityValue picogramsperdeciliter) { - double value = (double) picogramsperdeciliter; + QuantityValue value = (QuantityValue) picogramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerDeciliter); } @@ -1034,7 +1037,7 @@ public static MassConcentration FromPicogramsPerDeciliter(QuantityValue picogram /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerLiter(QuantityValue picogramsperliter) { - double value = (double) picogramsperliter; + QuantityValue value = (QuantityValue) picogramsperliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerLiter); } @@ -1044,7 +1047,7 @@ public static MassConcentration FromPicogramsPerLiter(QuantityValue picogramsper /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerMicroliter(QuantityValue picogramspermicroliter) { - double value = (double) picogramspermicroliter; + QuantityValue value = (QuantityValue) picogramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerMicroliter); } @@ -1054,7 +1057,7 @@ public static MassConcentration FromPicogramsPerMicroliter(QuantityValue picogra /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter) { - double value = (double) picogramspermilliliter; + QuantityValue value = (QuantityValue) picogramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerMilliliter); } @@ -1064,7 +1067,7 @@ public static MassConcentration FromPicogramsPerMilliliter(QuantityValue picogra /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) { - double value = (double) poundspercubicfoot; + QuantityValue value = (QuantityValue) poundspercubicfoot; return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicFoot); } @@ -1074,7 +1077,7 @@ public static MassConcentration FromPoundsPerCubicFoot(QuantityValue poundspercu /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerCubicInch(QuantityValue poundspercubicinch) { - double value = (double) poundspercubicinch; + QuantityValue value = (QuantityValue) poundspercubicinch; return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicInch); } @@ -1084,7 +1087,7 @@ public static MassConcentration FromPoundsPerCubicInch(QuantityValue poundspercu /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon) { - double value = (double) poundsperimperialgallon; + QuantityValue value = (QuantityValue) poundsperimperialgallon; return new MassConcentration(value, MassConcentrationUnit.PoundPerImperialGallon); } @@ -1094,7 +1097,7 @@ public static MassConcentration FromPoundsPerImperialGallon(QuantityValue pounds /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerUSGallon(QuantityValue poundsperusgallon) { - double value = (double) poundsperusgallon; + QuantityValue value = (QuantityValue) poundsperusgallon; return new MassConcentration(value, MassConcentrationUnit.PoundPerUSGallon); } @@ -1104,7 +1107,7 @@ public static MassConcentration FromPoundsPerUSGallon(QuantityValue poundsperusg /// If value is NaN or Infinity. public static MassConcentration FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) { - double value = (double) slugspercubicfoot; + QuantityValue value = (QuantityValue) slugspercubicfoot; return new MassConcentration(value, MassConcentrationUnit.SlugPerCubicFoot); } @@ -1114,7 +1117,7 @@ public static MassConcentration FromSlugsPerCubicFoot(QuantityValue slugspercubi /// If value is NaN or Infinity. public static MassConcentration FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter) { - double value = (double) tonnespercubiccentimeter; + QuantityValue value = (QuantityValue) tonnespercubiccentimeter; return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicCentimeter); } @@ -1124,7 +1127,7 @@ public static MassConcentration FromTonnesPerCubicCentimeter(QuantityValue tonne /// If value is NaN or Infinity. public static MassConcentration FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) { - double value = (double) tonnespercubicmeter; + QuantityValue value = (QuantityValue) tonnespercubicmeter; return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMeter); } @@ -1134,7 +1137,7 @@ public static MassConcentration FromTonnesPerCubicMeter(QuantityValue tonnesperc /// If value is NaN or Infinity. public static MassConcentration FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter) { - double value = (double) tonnespercubicmillimeter; + QuantityValue value = (QuantityValue) tonnespercubicmillimeter; return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMillimeter); } @@ -1146,7 +1149,7 @@ public static MassConcentration FromTonnesPerCubicMillimeter(QuantityValue tonne /// MassConcentration unit value. public static MassConcentration From(QuantityValue value, MassConcentrationUnit fromUnit) { - return new MassConcentration((double)value, fromUnit); + return new MassConcentration((QuantityValue)value, fromUnit); } #endregion @@ -1316,25 +1319,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC } /// Get from multiplying value and . - public static MassConcentration operator *(double left, MassConcentration right) + public static MassConcentration operator *(QuantityValue left, MassConcentration right) { return new MassConcentration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassConcentration operator *(MassConcentration left, double right) + public static MassConcentration operator *(MassConcentration left, QuantityValue right) { return new MassConcentration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassConcentration operator /(MassConcentration left, double right) + public static MassConcentration operator /(MassConcentration left, QuantityValue right) { return new MassConcentration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassConcentration left, MassConcentration right) + public static QuantityValue operator /(MassConcentration left, MassConcentration right) { return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; } @@ -1367,6 +1370,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassConcentration left, MassConcentration right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassConcentration left, MassConcentration right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1379,7 +1395,29 @@ public int CompareTo(object obj) /// public int CompareTo(MassConcentration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MassConcentration objMassConcentration)) + return false; + return Equals(objMassConcentration); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MassConcentration other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1422,13 +1460,13 @@ public int CompareTo(MassConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassConcentration other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassConcentration other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1439,7 +1477,7 @@ public bool Equals(MassConcentration other, double tolerance, ComparisonType com /// A hash code for the current MassConcentration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1450,17 +1488,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassConcentrationUnit unit) + public QuantityValue As(MassConcentrationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1475,12 +1512,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) + if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsMassConcentrationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1512,7 +1549,7 @@ public MassConcentration ToUnit(MassConcentrationUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (MassConcentration)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MassConcentrationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1520,17 +1557,17 @@ public MassConcentration ToUnit(MassConcentrationUnit unit, UnitConverter unitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) + if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassConcentrationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1557,10 +1594,10 @@ public MassConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MassConcentrationUnit unit) + private QuantityValue GetValueAs(MassConcentrationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 30ce043051..e20dfffc3b 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). /// [DataContract] - public partial struct MassFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -104,9 +104,9 @@ static MassFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFlow(double value, MassFlowUnit unit) + public MassFlow(QuantityValue value, MassFlowUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -118,14 +118,14 @@ public MassFlow(double value, MassFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlow(double value, UnitSystem unitSystem) + public MassFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -166,7 +166,10 @@ public MassFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -189,169 +192,169 @@ public MassFlow(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); + public QuantityValue CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); + public QuantityValue CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); + public QuantityValue DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); + public QuantityValue DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); + public QuantityValue DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); + public QuantityValue DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerDay => As(MassFlowUnit.GramPerDay); + public QuantityValue GramsPerDay => As(MassFlowUnit.GramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerHour => As(MassFlowUnit.GramPerHour); + public QuantityValue GramsPerHour => As(MassFlowUnit.GramPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerSecond => As(MassFlowUnit.GramPerSecond); + public QuantityValue GramsPerSecond => As(MassFlowUnit.GramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); + public QuantityValue HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); + public QuantityValue HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); + public QuantityValue KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); + public QuantityValue KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); + public QuantityValue KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); + public QuantityValue KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); + public QuantityValue MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); + public QuantityValue MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); + public QuantityValue MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); + public QuantityValue MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); + public QuantityValue MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); + public QuantityValue MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); + public QuantityValue MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); + public QuantityValue MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); + public QuantityValue MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); + public QuantityValue NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); + public QuantityValue NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerDay => As(MassFlowUnit.PoundPerDay); + public QuantityValue PoundsPerDay => As(MassFlowUnit.PoundPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerHour => As(MassFlowUnit.PoundPerHour); + public QuantityValue PoundsPerHour => As(MassFlowUnit.PoundPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); + public QuantityValue PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); + public QuantityValue PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); + public QuantityValue ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerDay => As(MassFlowUnit.TonnePerDay); + public QuantityValue TonnesPerDay => As(MassFlowUnit.TonnePerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesPerHour => As(MassFlowUnit.TonnePerHour); + public QuantityValue TonnesPerHour => As(MassFlowUnit.TonnePerHour); #endregion @@ -505,7 +508,7 @@ public static string GetAbbreviation(MassFlowUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static MassFlow FromCentigramsPerDay(QuantityValue centigramsperday) { - double value = (double) centigramsperday; + QuantityValue value = (QuantityValue) centigramsperday; return new MassFlow(value, MassFlowUnit.CentigramPerDay); } @@ -515,7 +518,7 @@ public static MassFlow FromCentigramsPerDay(QuantityValue centigramsperday) /// If value is NaN or Infinity. public static MassFlow FromCentigramsPerSecond(QuantityValue centigramspersecond) { - double value = (double) centigramspersecond; + QuantityValue value = (QuantityValue) centigramspersecond; return new MassFlow(value, MassFlowUnit.CentigramPerSecond); } @@ -525,7 +528,7 @@ public static MassFlow FromCentigramsPerSecond(QuantityValue centigramspersecond /// If value is NaN or Infinity. public static MassFlow FromDecagramsPerDay(QuantityValue decagramsperday) { - double value = (double) decagramsperday; + QuantityValue value = (QuantityValue) decagramsperday; return new MassFlow(value, MassFlowUnit.DecagramPerDay); } @@ -535,7 +538,7 @@ public static MassFlow FromDecagramsPerDay(QuantityValue decagramsperday) /// If value is NaN or Infinity. public static MassFlow FromDecagramsPerSecond(QuantityValue decagramspersecond) { - double value = (double) decagramspersecond; + QuantityValue value = (QuantityValue) decagramspersecond; return new MassFlow(value, MassFlowUnit.DecagramPerSecond); } @@ -545,7 +548,7 @@ public static MassFlow FromDecagramsPerSecond(QuantityValue decagramspersecond) /// If value is NaN or Infinity. public static MassFlow FromDecigramsPerDay(QuantityValue decigramsperday) { - double value = (double) decigramsperday; + QuantityValue value = (QuantityValue) decigramsperday; return new MassFlow(value, MassFlowUnit.DecigramPerDay); } @@ -555,7 +558,7 @@ public static MassFlow FromDecigramsPerDay(QuantityValue decigramsperday) /// If value is NaN or Infinity. public static MassFlow FromDecigramsPerSecond(QuantityValue decigramspersecond) { - double value = (double) decigramspersecond; + QuantityValue value = (QuantityValue) decigramspersecond; return new MassFlow(value, MassFlowUnit.DecigramPerSecond); } @@ -565,7 +568,7 @@ public static MassFlow FromDecigramsPerSecond(QuantityValue decigramspersecond) /// If value is NaN or Infinity. public static MassFlow FromGramsPerDay(QuantityValue gramsperday) { - double value = (double) gramsperday; + QuantityValue value = (QuantityValue) gramsperday; return new MassFlow(value, MassFlowUnit.GramPerDay); } @@ -575,7 +578,7 @@ public static MassFlow FromGramsPerDay(QuantityValue gramsperday) /// If value is NaN or Infinity. public static MassFlow FromGramsPerHour(QuantityValue gramsperhour) { - double value = (double) gramsperhour; + QuantityValue value = (QuantityValue) gramsperhour; return new MassFlow(value, MassFlowUnit.GramPerHour); } @@ -585,7 +588,7 @@ public static MassFlow FromGramsPerHour(QuantityValue gramsperhour) /// If value is NaN or Infinity. public static MassFlow FromGramsPerSecond(QuantityValue gramspersecond) { - double value = (double) gramspersecond; + QuantityValue value = (QuantityValue) gramspersecond; return new MassFlow(value, MassFlowUnit.GramPerSecond); } @@ -595,7 +598,7 @@ public static MassFlow FromGramsPerSecond(QuantityValue gramspersecond) /// If value is NaN or Infinity. public static MassFlow FromHectogramsPerDay(QuantityValue hectogramsperday) { - double value = (double) hectogramsperday; + QuantityValue value = (QuantityValue) hectogramsperday; return new MassFlow(value, MassFlowUnit.HectogramPerDay); } @@ -605,7 +608,7 @@ public static MassFlow FromHectogramsPerDay(QuantityValue hectogramsperday) /// If value is NaN or Infinity. public static MassFlow FromHectogramsPerSecond(QuantityValue hectogramspersecond) { - double value = (double) hectogramspersecond; + QuantityValue value = (QuantityValue) hectogramspersecond; return new MassFlow(value, MassFlowUnit.HectogramPerSecond); } @@ -615,7 +618,7 @@ public static MassFlow FromHectogramsPerSecond(QuantityValue hectogramspersecond /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerDay(QuantityValue kilogramsperday) { - double value = (double) kilogramsperday; + QuantityValue value = (QuantityValue) kilogramsperday; return new MassFlow(value, MassFlowUnit.KilogramPerDay); } @@ -625,7 +628,7 @@ public static MassFlow FromKilogramsPerDay(QuantityValue kilogramsperday) /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerHour(QuantityValue kilogramsperhour) { - double value = (double) kilogramsperhour; + QuantityValue value = (QuantityValue) kilogramsperhour; return new MassFlow(value, MassFlowUnit.KilogramPerHour); } @@ -635,7 +638,7 @@ public static MassFlow FromKilogramsPerHour(QuantityValue kilogramsperhour) /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerMinute(QuantityValue kilogramsperminute) { - double value = (double) kilogramsperminute; + QuantityValue value = (QuantityValue) kilogramsperminute; return new MassFlow(value, MassFlowUnit.KilogramPerMinute); } @@ -645,7 +648,7 @@ public static MassFlow FromKilogramsPerMinute(QuantityValue kilogramsperminute) /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerSecond(QuantityValue kilogramspersecond) { - double value = (double) kilogramspersecond; + QuantityValue value = (QuantityValue) kilogramspersecond; return new MassFlow(value, MassFlowUnit.KilogramPerSecond); } @@ -655,7 +658,7 @@ public static MassFlow FromKilogramsPerSecond(QuantityValue kilogramspersecond) /// If value is NaN or Infinity. public static MassFlow FromMegagramsPerDay(QuantityValue megagramsperday) { - double value = (double) megagramsperday; + QuantityValue value = (QuantityValue) megagramsperday; return new MassFlow(value, MassFlowUnit.MegagramPerDay); } @@ -665,7 +668,7 @@ public static MassFlow FromMegagramsPerDay(QuantityValue megagramsperday) /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerDay(QuantityValue megapoundsperday) { - double value = (double) megapoundsperday; + QuantityValue value = (QuantityValue) megapoundsperday; return new MassFlow(value, MassFlowUnit.MegapoundPerDay); } @@ -675,7 +678,7 @@ public static MassFlow FromMegapoundsPerDay(QuantityValue megapoundsperday) /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerHour(QuantityValue megapoundsperhour) { - double value = (double) megapoundsperhour; + QuantityValue value = (QuantityValue) megapoundsperhour; return new MassFlow(value, MassFlowUnit.MegapoundPerHour); } @@ -685,7 +688,7 @@ public static MassFlow FromMegapoundsPerHour(QuantityValue megapoundsperhour) /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerMinute(QuantityValue megapoundsperminute) { - double value = (double) megapoundsperminute; + QuantityValue value = (QuantityValue) megapoundsperminute; return new MassFlow(value, MassFlowUnit.MegapoundPerMinute); } @@ -695,7 +698,7 @@ public static MassFlow FromMegapoundsPerMinute(QuantityValue megapoundsperminute /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerSecond(QuantityValue megapoundspersecond) { - double value = (double) megapoundspersecond; + QuantityValue value = (QuantityValue) megapoundspersecond; return new MassFlow(value, MassFlowUnit.MegapoundPerSecond); } @@ -705,7 +708,7 @@ public static MassFlow FromMegapoundsPerSecond(QuantityValue megapoundspersecond /// If value is NaN or Infinity. public static MassFlow FromMicrogramsPerDay(QuantityValue microgramsperday) { - double value = (double) microgramsperday; + QuantityValue value = (QuantityValue) microgramsperday; return new MassFlow(value, MassFlowUnit.MicrogramPerDay); } @@ -715,7 +718,7 @@ public static MassFlow FromMicrogramsPerDay(QuantityValue microgramsperday) /// If value is NaN or Infinity. public static MassFlow FromMicrogramsPerSecond(QuantityValue microgramspersecond) { - double value = (double) microgramspersecond; + QuantityValue value = (QuantityValue) microgramspersecond; return new MassFlow(value, MassFlowUnit.MicrogramPerSecond); } @@ -725,7 +728,7 @@ public static MassFlow FromMicrogramsPerSecond(QuantityValue microgramspersecond /// If value is NaN or Infinity. public static MassFlow FromMilligramsPerDay(QuantityValue milligramsperday) { - double value = (double) milligramsperday; + QuantityValue value = (QuantityValue) milligramsperday; return new MassFlow(value, MassFlowUnit.MilligramPerDay); } @@ -735,7 +738,7 @@ public static MassFlow FromMilligramsPerDay(QuantityValue milligramsperday) /// If value is NaN or Infinity. public static MassFlow FromMilligramsPerSecond(QuantityValue milligramspersecond) { - double value = (double) milligramspersecond; + QuantityValue value = (QuantityValue) milligramspersecond; return new MassFlow(value, MassFlowUnit.MilligramPerSecond); } @@ -745,7 +748,7 @@ public static MassFlow FromMilligramsPerSecond(QuantityValue milligramspersecond /// If value is NaN or Infinity. public static MassFlow FromNanogramsPerDay(QuantityValue nanogramsperday) { - double value = (double) nanogramsperday; + QuantityValue value = (QuantityValue) nanogramsperday; return new MassFlow(value, MassFlowUnit.NanogramPerDay); } @@ -755,7 +758,7 @@ public static MassFlow FromNanogramsPerDay(QuantityValue nanogramsperday) /// If value is NaN or Infinity. public static MassFlow FromNanogramsPerSecond(QuantityValue nanogramspersecond) { - double value = (double) nanogramspersecond; + QuantityValue value = (QuantityValue) nanogramspersecond; return new MassFlow(value, MassFlowUnit.NanogramPerSecond); } @@ -765,7 +768,7 @@ public static MassFlow FromNanogramsPerSecond(QuantityValue nanogramspersecond) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerDay(QuantityValue poundsperday) { - double value = (double) poundsperday; + QuantityValue value = (QuantityValue) poundsperday; return new MassFlow(value, MassFlowUnit.PoundPerDay); } @@ -775,7 +778,7 @@ public static MassFlow FromPoundsPerDay(QuantityValue poundsperday) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerHour(QuantityValue poundsperhour) { - double value = (double) poundsperhour; + QuantityValue value = (QuantityValue) poundsperhour; return new MassFlow(value, MassFlowUnit.PoundPerHour); } @@ -785,7 +788,7 @@ public static MassFlow FromPoundsPerHour(QuantityValue poundsperhour) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerMinute(QuantityValue poundsperminute) { - double value = (double) poundsperminute; + QuantityValue value = (QuantityValue) poundsperminute; return new MassFlow(value, MassFlowUnit.PoundPerMinute); } @@ -795,7 +798,7 @@ public static MassFlow FromPoundsPerMinute(QuantityValue poundsperminute) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerSecond(QuantityValue poundspersecond) { - double value = (double) poundspersecond; + QuantityValue value = (QuantityValue) poundspersecond; return new MassFlow(value, MassFlowUnit.PoundPerSecond); } @@ -805,7 +808,7 @@ public static MassFlow FromPoundsPerSecond(QuantityValue poundspersecond) /// If value is NaN or Infinity. public static MassFlow FromShortTonsPerHour(QuantityValue shorttonsperhour) { - double value = (double) shorttonsperhour; + QuantityValue value = (QuantityValue) shorttonsperhour; return new MassFlow(value, MassFlowUnit.ShortTonPerHour); } @@ -815,7 +818,7 @@ public static MassFlow FromShortTonsPerHour(QuantityValue shorttonsperhour) /// If value is NaN or Infinity. public static MassFlow FromTonnesPerDay(QuantityValue tonnesperday) { - double value = (double) tonnesperday; + QuantityValue value = (QuantityValue) tonnesperday; return new MassFlow(value, MassFlowUnit.TonnePerDay); } @@ -825,7 +828,7 @@ public static MassFlow FromTonnesPerDay(QuantityValue tonnesperday) /// If value is NaN or Infinity. public static MassFlow FromTonnesPerHour(QuantityValue tonnesperhour) { - double value = (double) tonnesperhour; + QuantityValue value = (QuantityValue) tonnesperhour; return new MassFlow(value, MassFlowUnit.TonnePerHour); } @@ -837,7 +840,7 @@ public static MassFlow FromTonnesPerHour(QuantityValue tonnesperhour) /// MassFlow unit value. public static MassFlow From(QuantityValue value, MassFlowUnit fromUnit) { - return new MassFlow((double)value, fromUnit); + return new MassFlow((QuantityValue)value, fromUnit); } #endregion @@ -1007,25 +1010,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFlow operator *(double left, MassFlow right) + public static MassFlow operator *(QuantityValue left, MassFlow right) { return new MassFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFlow operator *(MassFlow left, double right) + public static MassFlow operator *(MassFlow left, QuantityValue right) { return new MassFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFlow operator /(MassFlow left, double right) + public static MassFlow operator /(MassFlow left, QuantityValue right) { return new MassFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassFlow left, MassFlow right) + public static QuantityValue operator /(MassFlow left, MassFlow right) { return left.GramsPerSecond / right.GramsPerSecond; } @@ -1058,6 +1061,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassFlow left, MassFlow right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassFlow left, MassFlow right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1070,7 +1086,29 @@ public int CompareTo(object obj) /// public int CompareTo(MassFlow other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MassFlow objMassFlow)) + return false; + return Equals(objMassFlow); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MassFlow other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1113,13 +1151,13 @@ public int CompareTo(MassFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassFlow other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1130,7 +1168,7 @@ public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonTy /// A hash code for the current MassFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1141,17 +1179,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFlowUnit unit) + public QuantityValue As(MassFlowUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1166,12 +1203,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MassFlowUnit unitAsMassFlowUnit)) + if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return As(unitAsMassFlowUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1203,7 +1240,7 @@ public MassFlow ToUnit(MassFlowUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MassFlow)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MassFlowUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1211,17 +1248,17 @@ public MassFlow ToUnit(MassFlowUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFlowUnit unitAsMassFlowUnit)) + if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1248,10 +1285,10 @@ public MassFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MassFlowUnit unit) + private QuantityValue GetValueAs(MassFlowUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 48a6bb8a9a..b4836741f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Mass flux is the mass flow rate per unit area. /// [DataContract] - public partial struct MassFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static MassFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFlux(double value, MassFluxUnit unit) + public MassFlux(QuantityValue value, MassFluxUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -97,14 +97,14 @@ public MassFlux(double value, MassFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlux(double value, UnitSystem unitSystem) + public MassFlux(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,7 +145,10 @@ public MassFlux(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -168,64 +171,64 @@ public MassFlux(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); + public QuantityValue GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); + public QuantityValue GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); + public QuantityValue GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); + public QuantityValue GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); + public QuantityValue GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); + public QuantityValue GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); + public QuantityValue KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); + public QuantityValue KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); + public QuantityValue KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); + public QuantityValue KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); + public QuantityValue KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); + public QuantityValue KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); #endregion @@ -314,7 +317,7 @@ public static string GetAbbreviation(MassFluxUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static MassFlux FromGramsPerHourPerSquareCentimeter(QuantityValue gramsperhourpersquarecentimeter) { - double value = (double) gramsperhourpersquarecentimeter; + QuantityValue value = (QuantityValue) gramsperhourpersquarecentimeter; return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareCentimeter); } @@ -324,7 +327,7 @@ public static MassFlux FromGramsPerHourPerSquareCentimeter(QuantityValue gramspe /// If value is NaN or Infinity. public static MassFlux FromGramsPerHourPerSquareMeter(QuantityValue gramsperhourpersquaremeter) { - double value = (double) gramsperhourpersquaremeter; + QuantityValue value = (QuantityValue) gramsperhourpersquaremeter; return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMeter); } @@ -334,7 +337,7 @@ public static MassFlux FromGramsPerHourPerSquareMeter(QuantityValue gramsperhour /// If value is NaN or Infinity. public static MassFlux FromGramsPerHourPerSquareMillimeter(QuantityValue gramsperhourpersquaremillimeter) { - double value = (double) gramsperhourpersquaremillimeter; + QuantityValue value = (QuantityValue) gramsperhourpersquaremillimeter; return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMillimeter); } @@ -344,7 +347,7 @@ public static MassFlux FromGramsPerHourPerSquareMillimeter(QuantityValue gramspe /// If value is NaN or Infinity. public static MassFlux FromGramsPerSecondPerSquareCentimeter(QuantityValue gramspersecondpersquarecentimeter) { - double value = (double) gramspersecondpersquarecentimeter; + QuantityValue value = (QuantityValue) gramspersecondpersquarecentimeter; return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareCentimeter); } @@ -354,7 +357,7 @@ public static MassFlux FromGramsPerSecondPerSquareCentimeter(QuantityValue grams /// If value is NaN or Infinity. public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue gramspersecondpersquaremeter) { - double value = (double) gramspersecondpersquaremeter; + QuantityValue value = (QuantityValue) gramspersecondpersquaremeter; return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMeter); } @@ -364,7 +367,7 @@ public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue gramsperse /// If value is NaN or Infinity. public static MassFlux FromGramsPerSecondPerSquareMillimeter(QuantityValue gramspersecondpersquaremillimeter) { - double value = (double) gramspersecondpersquaremillimeter; + QuantityValue value = (QuantityValue) gramspersecondpersquaremillimeter; return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMillimeter); } @@ -374,7 +377,7 @@ public static MassFlux FromGramsPerSecondPerSquareMillimeter(QuantityValue grams /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerHourPerSquareCentimeter(QuantityValue kilogramsperhourpersquarecentimeter) { - double value = (double) kilogramsperhourpersquarecentimeter; + QuantityValue value = (QuantityValue) kilogramsperhourpersquarecentimeter; return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareCentimeter); } @@ -384,7 +387,7 @@ public static MassFlux FromKilogramsPerHourPerSquareCentimeter(QuantityValue kil /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerHourPerSquareMeter(QuantityValue kilogramsperhourpersquaremeter) { - double value = (double) kilogramsperhourpersquaremeter; + QuantityValue value = (QuantityValue) kilogramsperhourpersquaremeter; return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMeter); } @@ -394,7 +397,7 @@ public static MassFlux FromKilogramsPerHourPerSquareMeter(QuantityValue kilogram /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerHourPerSquareMillimeter(QuantityValue kilogramsperhourpersquaremillimeter) { - double value = (double) kilogramsperhourpersquaremillimeter; + QuantityValue value = (QuantityValue) kilogramsperhourpersquaremillimeter; return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMillimeter); } @@ -404,7 +407,7 @@ public static MassFlux FromKilogramsPerHourPerSquareMillimeter(QuantityValue kil /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(QuantityValue kilogramspersecondpersquarecentimeter) { - double value = (double) kilogramspersecondpersquarecentimeter; + QuantityValue value = (QuantityValue) kilogramspersecondpersquarecentimeter; return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); } @@ -414,7 +417,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(QuantityValue k /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue kilogramspersecondpersquaremeter) { - double value = (double) kilogramspersecondpersquaremeter; + QuantityValue value = (QuantityValue) kilogramspersecondpersquaremeter; return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMeter); } @@ -424,7 +427,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue kilogr /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(QuantityValue kilogramspersecondpersquaremillimeter) { - double value = (double) kilogramspersecondpersquaremillimeter; + QuantityValue value = (QuantityValue) kilogramspersecondpersquaremillimeter; return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); } @@ -436,7 +439,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(QuantityValue k /// MassFlux unit value. public static MassFlux From(QuantityValue value, MassFluxUnit fromUnit) { - return new MassFlux((double)value, fromUnit); + return new MassFlux((QuantityValue)value, fromUnit); } #endregion @@ -606,25 +609,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFlux operator *(double left, MassFlux right) + public static MassFlux operator *(QuantityValue left, MassFlux right) { return new MassFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFlux operator *(MassFlux left, double right) + public static MassFlux operator *(MassFlux left, QuantityValue right) { return new MassFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFlux operator /(MassFlux left, double right) + public static MassFlux operator /(MassFlux left, QuantityValue right) { return new MassFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassFlux left, MassFlux right) + public static QuantityValue operator /(MassFlux left, MassFlux right) { return left.KilogramsPerSecondPerSquareMeter / right.KilogramsPerSecondPerSquareMeter; } @@ -657,6 +660,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassFlux left, MassFlux right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassFlux left, MassFlux right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -669,7 +685,29 @@ public int CompareTo(object obj) /// public int CompareTo(MassFlux other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MassFlux objMassFlux)) + return false; + return Equals(objMassFlux); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MassFlux other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -712,13 +750,13 @@ public int CompareTo(MassFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassFlux other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -729,7 +767,7 @@ public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonTy /// A hash code for the current MassFlux. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -740,17 +778,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFluxUnit unit) + public QuantityValue As(MassFluxUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -765,12 +802,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MassFluxUnit unitAsMassFluxUnit)) + if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMassFluxUnit); + return (QuantityValue)As(typedUnit); } /// @@ -802,7 +839,7 @@ public MassFlux ToUnit(MassFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MassFlux)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MassFluxUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -810,17 +847,17 @@ public MassFlux ToUnit(MassFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFluxUnit unitAsMassFluxUnit)) + if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -847,10 +884,10 @@ public MassFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MassFluxUnit unit) + private QuantityValue GetValueAs(MassFluxUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 2f4b8fe473..56da91983a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) /// [DataContract] - public partial struct MassFraction : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -98,9 +98,9 @@ static MassFraction() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFraction(double value, MassFractionUnit unit) + public MassFraction(QuantityValue value, MassFractionUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -112,14 +112,14 @@ public MassFraction(double value, MassFractionUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFraction(double value, UnitSystem unitSystem) + public MassFraction(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -160,7 +160,10 @@ public MassFraction(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -183,124 +186,124 @@ public MassFraction(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); + public QuantityValue CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); + public QuantityValue CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); + public QuantityValue DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); + public QuantityValue DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); + public QuantityValue DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); + public QuantityValue DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimalFractions => As(MassFractionUnit.DecimalFraction); + public QuantityValue DecimalFractions => As(MassFractionUnit.DecimalFraction); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerGram => As(MassFractionUnit.GramPerGram); + public QuantityValue GramsPerGram => As(MassFractionUnit.GramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); + public QuantityValue GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); + public QuantityValue HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); + public QuantityValue HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); + public QuantityValue KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); + public QuantityValue KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); + public QuantityValue MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); + public QuantityValue MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); + public QuantityValue MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); + public QuantityValue MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); + public QuantityValue NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); + public QuantityValue NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerBillion => As(MassFractionUnit.PartPerBillion); + public QuantityValue PartsPerBillion => As(MassFractionUnit.PartPerBillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerMillion => As(MassFractionUnit.PartPerMillion); + public QuantityValue PartsPerMillion => As(MassFractionUnit.PartPerMillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerThousand => As(MassFractionUnit.PartPerThousand); + public QuantityValue PartsPerThousand => As(MassFractionUnit.PartPerThousand); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); + public QuantityValue PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Percent => As(MassFractionUnit.Percent); + public QuantityValue Percent => As(MassFractionUnit.Percent); #endregion @@ -425,7 +428,7 @@ public static string GetAbbreviation(MassFractionUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static MassFraction FromCentigramsPerGram(QuantityValue centigramspergram) { - double value = (double) centigramspergram; + QuantityValue value = (QuantityValue) centigramspergram; return new MassFraction(value, MassFractionUnit.CentigramPerGram); } @@ -435,7 +438,7 @@ public static MassFraction FromCentigramsPerGram(QuantityValue centigramspergram /// If value is NaN or Infinity. public static MassFraction FromCentigramsPerKilogram(QuantityValue centigramsperkilogram) { - double value = (double) centigramsperkilogram; + QuantityValue value = (QuantityValue) centigramsperkilogram; return new MassFraction(value, MassFractionUnit.CentigramPerKilogram); } @@ -445,7 +448,7 @@ public static MassFraction FromCentigramsPerKilogram(QuantityValue centigramsper /// If value is NaN or Infinity. public static MassFraction FromDecagramsPerGram(QuantityValue decagramspergram) { - double value = (double) decagramspergram; + QuantityValue value = (QuantityValue) decagramspergram; return new MassFraction(value, MassFractionUnit.DecagramPerGram); } @@ -455,7 +458,7 @@ public static MassFraction FromDecagramsPerGram(QuantityValue decagramspergram) /// If value is NaN or Infinity. public static MassFraction FromDecagramsPerKilogram(QuantityValue decagramsperkilogram) { - double value = (double) decagramsperkilogram; + QuantityValue value = (QuantityValue) decagramsperkilogram; return new MassFraction(value, MassFractionUnit.DecagramPerKilogram); } @@ -465,7 +468,7 @@ public static MassFraction FromDecagramsPerKilogram(QuantityValue decagramsperki /// If value is NaN or Infinity. public static MassFraction FromDecigramsPerGram(QuantityValue decigramspergram) { - double value = (double) decigramspergram; + QuantityValue value = (QuantityValue) decigramspergram; return new MassFraction(value, MassFractionUnit.DecigramPerGram); } @@ -475,7 +478,7 @@ public static MassFraction FromDecigramsPerGram(QuantityValue decigramspergram) /// If value is NaN or Infinity. public static MassFraction FromDecigramsPerKilogram(QuantityValue decigramsperkilogram) { - double value = (double) decigramsperkilogram; + QuantityValue value = (QuantityValue) decigramsperkilogram; return new MassFraction(value, MassFractionUnit.DecigramPerKilogram); } @@ -485,7 +488,7 @@ public static MassFraction FromDecigramsPerKilogram(QuantityValue decigramsperki /// If value is NaN or Infinity. public static MassFraction FromDecimalFractions(QuantityValue decimalfractions) { - double value = (double) decimalfractions; + QuantityValue value = (QuantityValue) decimalfractions; return new MassFraction(value, MassFractionUnit.DecimalFraction); } @@ -495,7 +498,7 @@ public static MassFraction FromDecimalFractions(QuantityValue decimalfractions) /// If value is NaN or Infinity. public static MassFraction FromGramsPerGram(QuantityValue gramspergram) { - double value = (double) gramspergram; + QuantityValue value = (QuantityValue) gramspergram; return new MassFraction(value, MassFractionUnit.GramPerGram); } @@ -505,7 +508,7 @@ public static MassFraction FromGramsPerGram(QuantityValue gramspergram) /// If value is NaN or Infinity. public static MassFraction FromGramsPerKilogram(QuantityValue gramsperkilogram) { - double value = (double) gramsperkilogram; + QuantityValue value = (QuantityValue) gramsperkilogram; return new MassFraction(value, MassFractionUnit.GramPerKilogram); } @@ -515,7 +518,7 @@ public static MassFraction FromGramsPerKilogram(QuantityValue gramsperkilogram) /// If value is NaN or Infinity. public static MassFraction FromHectogramsPerGram(QuantityValue hectogramspergram) { - double value = (double) hectogramspergram; + QuantityValue value = (QuantityValue) hectogramspergram; return new MassFraction(value, MassFractionUnit.HectogramPerGram); } @@ -525,7 +528,7 @@ public static MassFraction FromHectogramsPerGram(QuantityValue hectogramspergram /// If value is NaN or Infinity. public static MassFraction FromHectogramsPerKilogram(QuantityValue hectogramsperkilogram) { - double value = (double) hectogramsperkilogram; + QuantityValue value = (QuantityValue) hectogramsperkilogram; return new MassFraction(value, MassFractionUnit.HectogramPerKilogram); } @@ -535,7 +538,7 @@ public static MassFraction FromHectogramsPerKilogram(QuantityValue hectogramsper /// If value is NaN or Infinity. public static MassFraction FromKilogramsPerGram(QuantityValue kilogramspergram) { - double value = (double) kilogramspergram; + QuantityValue value = (QuantityValue) kilogramspergram; return new MassFraction(value, MassFractionUnit.KilogramPerGram); } @@ -545,7 +548,7 @@ public static MassFraction FromKilogramsPerGram(QuantityValue kilogramspergram) /// If value is NaN or Infinity. public static MassFraction FromKilogramsPerKilogram(QuantityValue kilogramsperkilogram) { - double value = (double) kilogramsperkilogram; + QuantityValue value = (QuantityValue) kilogramsperkilogram; return new MassFraction(value, MassFractionUnit.KilogramPerKilogram); } @@ -555,7 +558,7 @@ public static MassFraction FromKilogramsPerKilogram(QuantityValue kilogramsperki /// If value is NaN or Infinity. public static MassFraction FromMicrogramsPerGram(QuantityValue microgramspergram) { - double value = (double) microgramspergram; + QuantityValue value = (QuantityValue) microgramspergram; return new MassFraction(value, MassFractionUnit.MicrogramPerGram); } @@ -565,7 +568,7 @@ public static MassFraction FromMicrogramsPerGram(QuantityValue microgramspergram /// If value is NaN or Infinity. public static MassFraction FromMicrogramsPerKilogram(QuantityValue microgramsperkilogram) { - double value = (double) microgramsperkilogram; + QuantityValue value = (QuantityValue) microgramsperkilogram; return new MassFraction(value, MassFractionUnit.MicrogramPerKilogram); } @@ -575,7 +578,7 @@ public static MassFraction FromMicrogramsPerKilogram(QuantityValue microgramsper /// If value is NaN or Infinity. public static MassFraction FromMilligramsPerGram(QuantityValue milligramspergram) { - double value = (double) milligramspergram; + QuantityValue value = (QuantityValue) milligramspergram; return new MassFraction(value, MassFractionUnit.MilligramPerGram); } @@ -585,7 +588,7 @@ public static MassFraction FromMilligramsPerGram(QuantityValue milligramspergram /// If value is NaN or Infinity. public static MassFraction FromMilligramsPerKilogram(QuantityValue milligramsperkilogram) { - double value = (double) milligramsperkilogram; + QuantityValue value = (QuantityValue) milligramsperkilogram; return new MassFraction(value, MassFractionUnit.MilligramPerKilogram); } @@ -595,7 +598,7 @@ public static MassFraction FromMilligramsPerKilogram(QuantityValue milligramsper /// If value is NaN or Infinity. public static MassFraction FromNanogramsPerGram(QuantityValue nanogramspergram) { - double value = (double) nanogramspergram; + QuantityValue value = (QuantityValue) nanogramspergram; return new MassFraction(value, MassFractionUnit.NanogramPerGram); } @@ -605,7 +608,7 @@ public static MassFraction FromNanogramsPerGram(QuantityValue nanogramspergram) /// If value is NaN or Infinity. public static MassFraction FromNanogramsPerKilogram(QuantityValue nanogramsperkilogram) { - double value = (double) nanogramsperkilogram; + QuantityValue value = (QuantityValue) nanogramsperkilogram; return new MassFraction(value, MassFractionUnit.NanogramPerKilogram); } @@ -615,7 +618,7 @@ public static MassFraction FromNanogramsPerKilogram(QuantityValue nanogramsperki /// If value is NaN or Infinity. public static MassFraction FromPartsPerBillion(QuantityValue partsperbillion) { - double value = (double) partsperbillion; + QuantityValue value = (QuantityValue) partsperbillion; return new MassFraction(value, MassFractionUnit.PartPerBillion); } @@ -625,7 +628,7 @@ public static MassFraction FromPartsPerBillion(QuantityValue partsperbillion) /// If value is NaN or Infinity. public static MassFraction FromPartsPerMillion(QuantityValue partspermillion) { - double value = (double) partspermillion; + QuantityValue value = (QuantityValue) partspermillion; return new MassFraction(value, MassFractionUnit.PartPerMillion); } @@ -635,7 +638,7 @@ public static MassFraction FromPartsPerMillion(QuantityValue partspermillion) /// If value is NaN or Infinity. public static MassFraction FromPartsPerThousand(QuantityValue partsperthousand) { - double value = (double) partsperthousand; + QuantityValue value = (QuantityValue) partsperthousand; return new MassFraction(value, MassFractionUnit.PartPerThousand); } @@ -645,7 +648,7 @@ public static MassFraction FromPartsPerThousand(QuantityValue partsperthousand) /// If value is NaN or Infinity. public static MassFraction FromPartsPerTrillion(QuantityValue partspertrillion) { - double value = (double) partspertrillion; + QuantityValue value = (QuantityValue) partspertrillion; return new MassFraction(value, MassFractionUnit.PartPerTrillion); } @@ -655,7 +658,7 @@ public static MassFraction FromPartsPerTrillion(QuantityValue partspertrillion) /// If value is NaN or Infinity. public static MassFraction FromPercent(QuantityValue percent) { - double value = (double) percent; + QuantityValue value = (QuantityValue) percent; return new MassFraction(value, MassFractionUnit.Percent); } @@ -667,7 +670,7 @@ public static MassFraction FromPercent(QuantityValue percent) /// MassFraction unit value. public static MassFraction From(QuantityValue value, MassFractionUnit fromUnit) { - return new MassFraction((double)value, fromUnit); + return new MassFraction((QuantityValue)value, fromUnit); } #endregion @@ -837,25 +840,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFraction operator *(double left, MassFraction right) + public static MassFraction operator *(QuantityValue left, MassFraction right) { return new MassFraction(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFraction operator *(MassFraction left, double right) + public static MassFraction operator *(MassFraction left, QuantityValue right) { return new MassFraction(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFraction operator /(MassFraction left, double right) + public static MassFraction operator /(MassFraction left, QuantityValue right) { return new MassFraction(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassFraction left, MassFraction right) + public static QuantityValue operator /(MassFraction left, MassFraction right) { return left.DecimalFractions / right.DecimalFractions; } @@ -888,6 +891,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassFraction left, MassFraction right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassFraction left, MassFraction right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -900,7 +916,29 @@ public int CompareTo(object obj) /// public int CompareTo(MassFraction other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MassFraction objMassFraction)) + return false; + return Equals(objMassFraction); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MassFraction other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -943,13 +981,13 @@ public int CompareTo(MassFraction other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFraction other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassFraction other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -960,7 +998,7 @@ public bool Equals(MassFraction other, double tolerance, ComparisonType comparis /// A hash code for the current MassFraction. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -971,17 +1009,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassFractionUnit unit) + public QuantityValue As(MassFractionUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -996,12 +1033,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MassFractionUnit unitAsMassFractionUnit)) + if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return As(unitAsMassFractionUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1033,7 +1070,7 @@ public MassFraction ToUnit(MassFractionUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MassFraction)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MassFractionUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1041,17 +1078,17 @@ public MassFraction ToUnit(MassFractionUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFractionUnit unitAsMassFractionUnit)) + if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFractionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1078,10 +1115,10 @@ public MassFraction ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MassFractionUnit unit) + private QuantityValue GetValueAs(MassFractionUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 50edc3fea1..5af13e39b5 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A property of body reflects how its mass is distributed with regard to an axis. /// [DataContract] - public partial struct MassMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -99,9 +99,9 @@ static MassMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) + public MassMomentOfInertia(QuantityValue value, MassMomentOfInertiaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -113,14 +113,14 @@ public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassMomentOfInertia(double value, UnitSystem unitSystem) + public MassMomentOfInertia(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -161,7 +161,10 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -184,144 +187,144 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); + public QuantityValue GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); + public QuantityValue GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); + public QuantityValue GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); + public QuantityValue GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); + public QuantityValue KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); + public QuantityValue KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); + public QuantityValue KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); + public QuantityValue KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); + public QuantityValue KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); + public QuantityValue KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); + public QuantityValue KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); + public QuantityValue KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); + public QuantityValue MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); + public QuantityValue MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); + public QuantityValue MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); + public QuantityValue MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); + public QuantityValue MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); + public QuantityValue MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); + public QuantityValue MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); + public QuantityValue MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); + public QuantityValue PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); + public QuantityValue PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); + public QuantityValue SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); + public QuantityValue SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); + public QuantityValue TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); + public QuantityValue TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); + public QuantityValue TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); + public QuantityValue TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); #endregion @@ -458,7 +461,7 @@ public static string GetAbbreviation(MassMomentOfInertiaUnit unit, IFormatProvid /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue gramsquarecentimeters) { - double value = (double) gramsquarecentimeters; + QuantityValue value = (QuantityValue) gramsquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareCentimeter); } @@ -468,7 +471,7 @@ public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue gramsq /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue gramsquaredecimeters) { - double value = (double) gramsquaredecimeters; + QuantityValue value = (QuantityValue) gramsquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareDecimeter); } @@ -478,7 +481,7 @@ public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue gramsqu /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareMeters(QuantityValue gramsquaremeters) { - double value = (double) gramsquaremeters; + QuantityValue value = (QuantityValue) gramsquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMeter); } @@ -488,7 +491,7 @@ public static MassMomentOfInertia FromGramSquareMeters(QuantityValue gramsquarem /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue gramsquaremillimeters) { - double value = (double) gramsquaremillimeters; + QuantityValue value = (QuantityValue) gramsquaremillimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMillimeter); } @@ -498,7 +501,7 @@ public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue gramsq /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue kilogramsquarecentimeters) { - double value = (double) kilogramsquarecentimeters; + QuantityValue value = (QuantityValue) kilogramsquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareCentimeter); } @@ -508,7 +511,7 @@ public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue kilogramsquaredecimeters) { - double value = (double) kilogramsquaredecimeters; + QuantityValue value = (QuantityValue) kilogramsquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareDecimeter); } @@ -518,7 +521,7 @@ public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue kil /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue kilogramsquaremeters) { - double value = (double) kilogramsquaremeters; + QuantityValue value = (QuantityValue) kilogramsquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMeter); } @@ -528,7 +531,7 @@ public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue kilogra /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue kilogramsquaremillimeters) { - double value = (double) kilogramsquaremillimeters; + QuantityValue value = (QuantityValue) kilogramsquaremillimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMillimeter); } @@ -538,7 +541,7 @@ public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue kilotonnesquarecentimeters) { - double value = (double) kilotonnesquarecentimeters; + QuantityValue value = (QuantityValue) kilotonnesquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); } @@ -548,7 +551,7 @@ public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue k /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue kilotonnesquaredecimeters) { - double value = (double) kilotonnesquaredecimeters; + QuantityValue value = (QuantityValue) kilotonnesquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); } @@ -558,7 +561,7 @@ public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue kilotonnesquaremeters) { - double value = (double) kilotonnesquaremeters; + QuantityValue value = (QuantityValue) kilotonnesquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMeter); } @@ -568,7 +571,7 @@ public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue kiloto /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue kilotonnesquaremilimeters) { - double value = (double) kilotonnesquaremilimeters; + QuantityValue value = (QuantityValue) kilotonnesquaremilimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); } @@ -578,7 +581,7 @@ public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue megatonnesquarecentimeters) { - double value = (double) megatonnesquarecentimeters; + QuantityValue value = (QuantityValue) megatonnesquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); } @@ -588,7 +591,7 @@ public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue m /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue megatonnesquaredecimeters) { - double value = (double) megatonnesquaredecimeters; + QuantityValue value = (QuantityValue) megatonnesquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); } @@ -598,7 +601,7 @@ public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue me /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue megatonnesquaremeters) { - double value = (double) megatonnesquaremeters; + QuantityValue value = (QuantityValue) megatonnesquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMeter); } @@ -608,7 +611,7 @@ public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue megato /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue megatonnesquaremilimeters) { - double value = (double) megatonnesquaremilimeters; + QuantityValue value = (QuantityValue) megatonnesquaremilimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); } @@ -618,7 +621,7 @@ public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue me /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue milligramsquarecentimeters) { - double value = (double) milligramsquarecentimeters; + QuantityValue value = (QuantityValue) milligramsquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareCentimeter); } @@ -628,7 +631,7 @@ public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue m /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue milligramsquaredecimeters) { - double value = (double) milligramsquaredecimeters; + QuantityValue value = (QuantityValue) milligramsquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareDecimeter); } @@ -638,7 +641,7 @@ public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue mi /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue milligramsquaremeters) { - double value = (double) milligramsquaremeters; + QuantityValue value = (QuantityValue) milligramsquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMeter); } @@ -648,7 +651,7 @@ public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue millig /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue milligramsquaremillimeters) { - double value = (double) milligramsquaremillimeters; + QuantityValue value = (QuantityValue) milligramsquaremillimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMillimeter); } @@ -658,7 +661,7 @@ public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue m /// If value is NaN or Infinity. public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue poundsquarefeet) { - double value = (double) poundsquarefeet; + QuantityValue value = (QuantityValue) poundsquarefeet; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareFoot); } @@ -668,7 +671,7 @@ public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue poundsquaref /// If value is NaN or Infinity. public static MassMomentOfInertia FromPoundSquareInches(QuantityValue poundsquareinches) { - double value = (double) poundsquareinches; + QuantityValue value = (QuantityValue) poundsquareinches; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareInch); } @@ -678,7 +681,7 @@ public static MassMomentOfInertia FromPoundSquareInches(QuantityValue poundsquar /// If value is NaN or Infinity. public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue slugsquarefeet) { - double value = (double) slugsquarefeet; + QuantityValue value = (QuantityValue) slugsquarefeet; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareFoot); } @@ -688,7 +691,7 @@ public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue slugsquarefee /// If value is NaN or Infinity. public static MassMomentOfInertia FromSlugSquareInches(QuantityValue slugsquareinches) { - double value = (double) slugsquareinches; + QuantityValue value = (QuantityValue) slugsquareinches; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareInch); } @@ -698,7 +701,7 @@ public static MassMomentOfInertia FromSlugSquareInches(QuantityValue slugsquarei /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue tonnesquarecentimeters) { - double value = (double) tonnesquarecentimeters; + QuantityValue value = (QuantityValue) tonnesquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareCentimeter); } @@ -708,7 +711,7 @@ public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue tonne /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue tonnesquaredecimeters) { - double value = (double) tonnesquaredecimeters; + QuantityValue value = (QuantityValue) tonnesquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareDecimeter); } @@ -718,7 +721,7 @@ public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue tonnes /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue tonnesquaremeters) { - double value = (double) tonnesquaremeters; + QuantityValue value = (QuantityValue) tonnesquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMeter); } @@ -728,7 +731,7 @@ public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue tonnesquar /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue tonnesquaremilimeters) { - double value = (double) tonnesquaremilimeters; + QuantityValue value = (QuantityValue) tonnesquaremilimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMilimeter); } @@ -740,7 +743,7 @@ public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue tonnes /// MassMomentOfInertia unit value. public static MassMomentOfInertia From(QuantityValue value, MassMomentOfInertiaUnit fromUnit) { - return new MassMomentOfInertia((double)value, fromUnit); + return new MassMomentOfInertia((QuantityValue)value, fromUnit); } #endregion @@ -910,25 +913,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM } /// Get from multiplying value and . - public static MassMomentOfInertia operator *(double left, MassMomentOfInertia right) + public static MassMomentOfInertia operator *(QuantityValue left, MassMomentOfInertia right) { return new MassMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassMomentOfInertia operator *(MassMomentOfInertia left, double right) + public static MassMomentOfInertia operator *(MassMomentOfInertia left, QuantityValue right) { return new MassMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassMomentOfInertia operator /(MassMomentOfInertia left, double right) + public static MassMomentOfInertia operator /(MassMomentOfInertia left, QuantityValue right) { return new MassMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MassMomentOfInertia left, MassMomentOfInertia right) + public static QuantityValue operator /(MassMomentOfInertia left, MassMomentOfInertia right) { return left.KilogramSquareMeters / right.KilogramSquareMeters; } @@ -961,6 +964,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -973,7 +989,29 @@ public int CompareTo(object obj) /// public int CompareTo(MassMomentOfInertia other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) + return false; + return Equals(objMassMomentOfInertia); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MassMomentOfInertia other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1016,13 +1054,13 @@ public int CompareTo(MassMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType) + public bool Equals(MassMomentOfInertia other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1033,7 +1071,7 @@ public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType c /// A hash code for the current MassMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1044,17 +1082,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MassMomentOfInertiaUnit unit) + public QuantityValue As(MassMomentOfInertiaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1069,12 +1106,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) + if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsMassMomentOfInertiaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1106,7 +1143,7 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit, UnitConverter un var converted = conversionFunction(this); return (MassMomentOfInertia)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MassMomentOfInertiaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1114,17 +1151,17 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) + if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1151,10 +1188,10 @@ public MassMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MassMomentOfInertiaUnit unit) + private QuantityValue GetValueAs(MassMomentOfInertiaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 3b11d29f12..4979bd2a8d 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Molar energy is the amount of energy stored in 1 mole of a substance. /// [DataContract] - public partial struct MolarEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static MolarEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarEnergy(double value, MolarEnergyUnit unit) + public MolarEnergy(QuantityValue value, MolarEnergyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public MolarEnergy(double value, MolarEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEnergy(double value, UnitSystem unitSystem) + public MolarEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public MolarEnergy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); + public QuantityValue JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); + public QuantityValue KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); + public QuantityValue MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(MolarEnergyUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static MolarEnergy FromJoulesPerMole(QuantityValue joulespermole) { - double value = (double) joulespermole; + QuantityValue value = (QuantityValue) joulespermole; return new MolarEnergy(value, MolarEnergyUnit.JoulePerMole); } @@ -243,7 +246,7 @@ public static MolarEnergy FromJoulesPerMole(QuantityValue joulespermole) /// If value is NaN or Infinity. public static MolarEnergy FromKilojoulesPerMole(QuantityValue kilojoulespermole) { - double value = (double) kilojoulespermole; + QuantityValue value = (QuantityValue) kilojoulespermole; return new MolarEnergy(value, MolarEnergyUnit.KilojoulePerMole); } @@ -253,7 +256,7 @@ public static MolarEnergy FromKilojoulesPerMole(QuantityValue kilojoulespermole) /// If value is NaN or Infinity. public static MolarEnergy FromMegajoulesPerMole(QuantityValue megajoulespermole) { - double value = (double) megajoulespermole; + QuantityValue value = (QuantityValue) megajoulespermole; return new MolarEnergy(value, MolarEnergyUnit.MegajoulePerMole); } @@ -265,7 +268,7 @@ public static MolarEnergy FromMegajoulesPerMole(QuantityValue megajoulespermole) /// MolarEnergy unit value. public static MolarEnergy From(QuantityValue value, MolarEnergyUnit fromUnit) { - return new MolarEnergy((double)value, fromUnit); + return new MolarEnergy((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarEnergy operator *(double left, MolarEnergy right) + public static MolarEnergy operator *(QuantityValue left, MolarEnergy right) { return new MolarEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarEnergy operator *(MolarEnergy left, double right) + public static MolarEnergy operator *(MolarEnergy left, QuantityValue right) { return new MolarEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarEnergy operator /(MolarEnergy left, double right) + public static MolarEnergy operator /(MolarEnergy left, QuantityValue right) { return new MolarEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarEnergy left, MolarEnergy right) + public static QuantityValue operator /(MolarEnergy left, MolarEnergy right) { return left.JoulesPerMole / right.JoulesPerMole; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MolarEnergy left, MolarEnergy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MolarEnergy left, MolarEnergy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(MolarEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MolarEnergy objMolarEnergy)) + return false; + return Equals(objMolarEnergy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MolarEnergy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(MolarEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(MolarEnergy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(MolarEnergy other, double tolerance, ComparisonType compariso /// A hash code for the current MolarEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEnergyUnit unit) + public QuantityValue As(MolarEnergyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) + if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEnergyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MolarEnergy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MolarEnergyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) + if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public MolarEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MolarEnergyUnit unit) + private QuantityValue GetValueAs(MolarEnergyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 857fcdaf4a..c11e95ba80 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// [DataContract] - public partial struct MolarEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static MolarEntropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarEntropy(double value, MolarEntropyUnit unit) + public MolarEntropy(QuantityValue value, MolarEntropyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public MolarEntropy(double value, MolarEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEntropy(double value, UnitSystem unitSystem) + public MolarEntropy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public MolarEntropy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); + public QuantityValue JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); + public QuantityValue KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); + public QuantityValue MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(MolarEntropyUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue joulespermolekelvin) { - double value = (double) joulespermolekelvin; + QuantityValue value = (QuantityValue) joulespermolekelvin; return new MolarEntropy(value, MolarEntropyUnit.JoulePerMoleKelvin); } @@ -243,7 +246,7 @@ public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue joulespermoleke /// If value is NaN or Infinity. public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue kilojoulespermolekelvin) { - double value = (double) kilojoulespermolekelvin; + QuantityValue value = (QuantityValue) kilojoulespermolekelvin; return new MolarEntropy(value, MolarEntropyUnit.KilojoulePerMoleKelvin); } @@ -253,7 +256,7 @@ public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue kilojoulesp /// If value is NaN or Infinity. public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue megajoulespermolekelvin) { - double value = (double) megajoulespermolekelvin; + QuantityValue value = (QuantityValue) megajoulespermolekelvin; return new MolarEntropy(value, MolarEntropyUnit.MegajoulePerMoleKelvin); } @@ -265,7 +268,7 @@ public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue megajoulesp /// MolarEntropy unit value. public static MolarEntropy From(QuantityValue value, MolarEntropyUnit fromUnit) { - return new MolarEntropy((double)value, fromUnit); + return new MolarEntropy((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarEntropy operator *(double left, MolarEntropy right) + public static MolarEntropy operator *(QuantityValue left, MolarEntropy right) { return new MolarEntropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarEntropy operator *(MolarEntropy left, double right) + public static MolarEntropy operator *(MolarEntropy left, QuantityValue right) { return new MolarEntropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarEntropy operator /(MolarEntropy left, double right) + public static MolarEntropy operator /(MolarEntropy left, QuantityValue right) { return new MolarEntropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarEntropy left, MolarEntropy right) + public static QuantityValue operator /(MolarEntropy left, MolarEntropy right) { return left.JoulesPerMoleKelvin / right.JoulesPerMoleKelvin; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MolarEntropy left, MolarEntropy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MolarEntropy left, MolarEntropy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(MolarEntropy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MolarEntropy objMolarEntropy)) + return false; + return Equals(objMolarEntropy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MolarEntropy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(MolarEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType) + public bool Equals(MolarEntropy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparis /// A hash code for the current MolarEntropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarEntropyUnit unit) + public QuantityValue As(MolarEntropyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) + if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEntropyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MolarEntropy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MolarEntropyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) + if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public MolarEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MolarEntropyUnit unit) + private QuantityValue GetValueAs(MolarEntropyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 1bc540caa7..94f91b9b40 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. /// [DataContract] - public partial struct MolarMass : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static MolarMass() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarMass(double value, MolarMassUnit unit) + public MolarMass(QuantityValue value, MolarMassUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -97,14 +97,14 @@ public MolarMass(double value, MolarMassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarMass(double value, UnitSystem unitSystem) + public MolarMass(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,7 +145,10 @@ public MolarMass(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -168,64 +171,64 @@ public MolarMass(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); + public QuantityValue CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); + public QuantityValue DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); + public QuantityValue DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerMole => As(MolarMassUnit.GramPerMole); + public QuantityValue GramsPerMole => As(MolarMassUnit.GramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); + public QuantityValue HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); + public QuantityValue KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); + public QuantityValue KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); + public QuantityValue MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); + public QuantityValue MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); + public QuantityValue MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); + public QuantityValue NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerMole => As(MolarMassUnit.PoundPerMole); + public QuantityValue PoundsPerMole => As(MolarMassUnit.PoundPerMole); #endregion @@ -326,7 +329,7 @@ public static string GetAbbreviation(MolarMassUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static MolarMass FromCentigramsPerMole(QuantityValue centigramspermole) { - double value = (double) centigramspermole; + QuantityValue value = (QuantityValue) centigramspermole; return new MolarMass(value, MolarMassUnit.CentigramPerMole); } @@ -336,7 +339,7 @@ public static MolarMass FromCentigramsPerMole(QuantityValue centigramspermole) /// If value is NaN or Infinity. public static MolarMass FromDecagramsPerMole(QuantityValue decagramspermole) { - double value = (double) decagramspermole; + QuantityValue value = (QuantityValue) decagramspermole; return new MolarMass(value, MolarMassUnit.DecagramPerMole); } @@ -346,7 +349,7 @@ public static MolarMass FromDecagramsPerMole(QuantityValue decagramspermole) /// If value is NaN or Infinity. public static MolarMass FromDecigramsPerMole(QuantityValue decigramspermole) { - double value = (double) decigramspermole; + QuantityValue value = (QuantityValue) decigramspermole; return new MolarMass(value, MolarMassUnit.DecigramPerMole); } @@ -356,7 +359,7 @@ public static MolarMass FromDecigramsPerMole(QuantityValue decigramspermole) /// If value is NaN or Infinity. public static MolarMass FromGramsPerMole(QuantityValue gramspermole) { - double value = (double) gramspermole; + QuantityValue value = (QuantityValue) gramspermole; return new MolarMass(value, MolarMassUnit.GramPerMole); } @@ -366,7 +369,7 @@ public static MolarMass FromGramsPerMole(QuantityValue gramspermole) /// If value is NaN or Infinity. public static MolarMass FromHectogramsPerMole(QuantityValue hectogramspermole) { - double value = (double) hectogramspermole; + QuantityValue value = (QuantityValue) hectogramspermole; return new MolarMass(value, MolarMassUnit.HectogramPerMole); } @@ -376,7 +379,7 @@ public static MolarMass FromHectogramsPerMole(QuantityValue hectogramspermole) /// If value is NaN or Infinity. public static MolarMass FromKilogramsPerMole(QuantityValue kilogramspermole) { - double value = (double) kilogramspermole; + QuantityValue value = (QuantityValue) kilogramspermole; return new MolarMass(value, MolarMassUnit.KilogramPerMole); } @@ -386,7 +389,7 @@ public static MolarMass FromKilogramsPerMole(QuantityValue kilogramspermole) /// If value is NaN or Infinity. public static MolarMass FromKilopoundsPerMole(QuantityValue kilopoundspermole) { - double value = (double) kilopoundspermole; + QuantityValue value = (QuantityValue) kilopoundspermole; return new MolarMass(value, MolarMassUnit.KilopoundPerMole); } @@ -396,7 +399,7 @@ public static MolarMass FromKilopoundsPerMole(QuantityValue kilopoundspermole) /// If value is NaN or Infinity. public static MolarMass FromMegapoundsPerMole(QuantityValue megapoundspermole) { - double value = (double) megapoundspermole; + QuantityValue value = (QuantityValue) megapoundspermole; return new MolarMass(value, MolarMassUnit.MegapoundPerMole); } @@ -406,7 +409,7 @@ public static MolarMass FromMegapoundsPerMole(QuantityValue megapoundspermole) /// If value is NaN or Infinity. public static MolarMass FromMicrogramsPerMole(QuantityValue microgramspermole) { - double value = (double) microgramspermole; + QuantityValue value = (QuantityValue) microgramspermole; return new MolarMass(value, MolarMassUnit.MicrogramPerMole); } @@ -416,7 +419,7 @@ public static MolarMass FromMicrogramsPerMole(QuantityValue microgramspermole) /// If value is NaN or Infinity. public static MolarMass FromMilligramsPerMole(QuantityValue milligramspermole) { - double value = (double) milligramspermole; + QuantityValue value = (QuantityValue) milligramspermole; return new MolarMass(value, MolarMassUnit.MilligramPerMole); } @@ -426,7 +429,7 @@ public static MolarMass FromMilligramsPerMole(QuantityValue milligramspermole) /// If value is NaN or Infinity. public static MolarMass FromNanogramsPerMole(QuantityValue nanogramspermole) { - double value = (double) nanogramspermole; + QuantityValue value = (QuantityValue) nanogramspermole; return new MolarMass(value, MolarMassUnit.NanogramPerMole); } @@ -436,7 +439,7 @@ public static MolarMass FromNanogramsPerMole(QuantityValue nanogramspermole) /// If value is NaN or Infinity. public static MolarMass FromPoundsPerMole(QuantityValue poundspermole) { - double value = (double) poundspermole; + QuantityValue value = (QuantityValue) poundspermole; return new MolarMass(value, MolarMassUnit.PoundPerMole); } @@ -448,7 +451,7 @@ public static MolarMass FromPoundsPerMole(QuantityValue poundspermole) /// MolarMass unit value. public static MolarMass From(QuantityValue value, MolarMassUnit fromUnit) { - return new MolarMass((double)value, fromUnit); + return new MolarMass((QuantityValue)value, fromUnit); } #endregion @@ -618,25 +621,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarMass operator *(double left, MolarMass right) + public static MolarMass operator *(QuantityValue left, MolarMass right) { return new MolarMass(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarMass operator *(MolarMass left, double right) + public static MolarMass operator *(MolarMass left, QuantityValue right) { return new MolarMass(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarMass operator /(MolarMass left, double right) + public static MolarMass operator /(MolarMass left, QuantityValue right) { return new MolarMass(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(MolarMass left, MolarMass right) + public static QuantityValue operator /(MolarMass left, MolarMass right) { return left.KilogramsPerMole / right.KilogramsPerMole; } @@ -669,6 +672,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(MolarMass left, MolarMass right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(MolarMass left, MolarMass right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -681,7 +697,29 @@ public int CompareTo(object obj) /// public int CompareTo(MolarMass other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is MolarMass objMolarMass)) + return false; + return Equals(objMolarMass); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(MolarMass other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -724,13 +762,13 @@ public int CompareTo(MolarMass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType) + public bool Equals(MolarMass other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -741,7 +779,7 @@ public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonT /// A hash code for the current MolarMass. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -752,17 +790,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarMassUnit unit) + public QuantityValue As(MolarMassUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -777,12 +814,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MolarMassUnit unitAsMolarMassUnit)) + if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return As(unitAsMolarMassUnit); + return (QuantityValue)As(typedUnit); } /// @@ -814,7 +851,7 @@ public MolarMass ToUnit(MolarMassUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MolarMass)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MolarMassUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -822,17 +859,17 @@ public MolarMass ToUnit(MolarMassUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarMassUnit unitAsMolarMassUnit)) + if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarMassUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -859,10 +896,10 @@ public MolarMass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MolarMassUnit unit) + private QuantityValue GetValueAs(MolarMassUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 0403f2c28f..e654cdedfc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Molar_concentration /// [DataContract] - public partial struct Molarity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -91,9 +91,9 @@ static Molarity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Molarity(double value, MolarityUnit unit) + public Molarity(QuantityValue value, MolarityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -105,14 +105,14 @@ public Molarity(double value, MolarityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Molarity(double value, UnitSystem unitSystem) + public Molarity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -153,7 +153,10 @@ public Molarity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,49 +179,49 @@ public Molarity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimolesPerLiter => As(MolarityUnit.CentimolePerLiter); + public QuantityValue CentimolesPerLiter => As(MolarityUnit.CentimolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimolesPerLiter => As(MolarityUnit.DecimolePerLiter); + public QuantityValue DecimolesPerLiter => As(MolarityUnit.DecimolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FemtomolesPerLiter => As(MolarityUnit.FemtomolePerLiter); + public QuantityValue FemtomolesPerLiter => As(MolarityUnit.FemtomolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicromolesPerLiter => As(MolarityUnit.MicromolePerLiter); + public QuantityValue MicromolesPerLiter => As(MolarityUnit.MicromolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimolesPerLiter => As(MolarityUnit.MillimolePerLiter); + public QuantityValue MillimolesPerLiter => As(MolarityUnit.MillimolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MolesPerCubicMeter => As(MolarityUnit.MolePerCubicMeter); + public QuantityValue MolesPerCubicMeter => As(MolarityUnit.MolePerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MolesPerLiter => As(MolarityUnit.MolePerLiter); + public QuantityValue MolesPerLiter => As(MolarityUnit.MolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanomolesPerLiter => As(MolarityUnit.NanomolePerLiter); + public QuantityValue NanomolesPerLiter => As(MolarityUnit.NanomolePerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicomolesPerLiter => As(MolarityUnit.PicomolePerLiter); + public QuantityValue PicomolesPerLiter => As(MolarityUnit.PicomolePerLiter); #endregion @@ -322,7 +325,7 @@ public static string GetAbbreviation(MolarityUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static Molarity FromCentimolesPerLiter(QuantityValue centimolesperliter) { - double value = (double) centimolesperliter; + QuantityValue value = (QuantityValue) centimolesperliter; return new Molarity(value, MolarityUnit.CentimolePerLiter); } @@ -332,7 +335,7 @@ public static Molarity FromCentimolesPerLiter(QuantityValue centimolesperliter) /// If value is NaN or Infinity. public static Molarity FromDecimolesPerLiter(QuantityValue decimolesperliter) { - double value = (double) decimolesperliter; + QuantityValue value = (QuantityValue) decimolesperliter; return new Molarity(value, MolarityUnit.DecimolePerLiter); } @@ -342,7 +345,7 @@ public static Molarity FromDecimolesPerLiter(QuantityValue decimolesperliter) /// If value is NaN or Infinity. public static Molarity FromFemtomolesPerLiter(QuantityValue femtomolesperliter) { - double value = (double) femtomolesperliter; + QuantityValue value = (QuantityValue) femtomolesperliter; return new Molarity(value, MolarityUnit.FemtomolePerLiter); } @@ -352,7 +355,7 @@ public static Molarity FromFemtomolesPerLiter(QuantityValue femtomolesperliter) /// If value is NaN or Infinity. public static Molarity FromMicromolesPerLiter(QuantityValue micromolesperliter) { - double value = (double) micromolesperliter; + QuantityValue value = (QuantityValue) micromolesperliter; return new Molarity(value, MolarityUnit.MicromolePerLiter); } @@ -362,7 +365,7 @@ public static Molarity FromMicromolesPerLiter(QuantityValue micromolesperliter) /// If value is NaN or Infinity. public static Molarity FromMillimolesPerLiter(QuantityValue millimolesperliter) { - double value = (double) millimolesperliter; + QuantityValue value = (QuantityValue) millimolesperliter; return new Molarity(value, MolarityUnit.MillimolePerLiter); } @@ -372,7 +375,7 @@ public static Molarity FromMillimolesPerLiter(QuantityValue millimolesperliter) /// If value is NaN or Infinity. public static Molarity FromMolesPerCubicMeter(QuantityValue molespercubicmeter) { - double value = (double) molespercubicmeter; + QuantityValue value = (QuantityValue) molespercubicmeter; return new Molarity(value, MolarityUnit.MolePerCubicMeter); } @@ -382,7 +385,7 @@ public static Molarity FromMolesPerCubicMeter(QuantityValue molespercubicmeter) /// If value is NaN or Infinity. public static Molarity FromMolesPerLiter(QuantityValue molesperliter) { - double value = (double) molesperliter; + QuantityValue value = (QuantityValue) molesperliter; return new Molarity(value, MolarityUnit.MolePerLiter); } @@ -392,7 +395,7 @@ public static Molarity FromMolesPerLiter(QuantityValue molesperliter) /// If value is NaN or Infinity. public static Molarity FromNanomolesPerLiter(QuantityValue nanomolesperliter) { - double value = (double) nanomolesperliter; + QuantityValue value = (QuantityValue) nanomolesperliter; return new Molarity(value, MolarityUnit.NanomolePerLiter); } @@ -402,7 +405,7 @@ public static Molarity FromNanomolesPerLiter(QuantityValue nanomolesperliter) /// If value is NaN or Infinity. public static Molarity FromPicomolesPerLiter(QuantityValue picomolesperliter) { - double value = (double) picomolesperliter; + QuantityValue value = (QuantityValue) picomolesperliter; return new Molarity(value, MolarityUnit.PicomolePerLiter); } @@ -414,7 +417,7 @@ public static Molarity FromPicomolesPerLiter(QuantityValue picomolesperliter) /// Molarity unit value. public static Molarity From(QuantityValue value, MolarityUnit fromUnit) { - return new Molarity((double)value, fromUnit); + return new Molarity((QuantityValue)value, fromUnit); } #endregion @@ -584,25 +587,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static Molarity operator *(double left, Molarity right) + public static Molarity operator *(QuantityValue left, Molarity right) { return new Molarity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Molarity operator *(Molarity left, double right) + public static Molarity operator *(Molarity left, QuantityValue right) { return new Molarity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Molarity operator /(Molarity left, double right) + public static Molarity operator /(Molarity left, QuantityValue right) { return new Molarity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Molarity left, Molarity right) + public static QuantityValue operator /(Molarity left, Molarity right) { return left.MolesPerCubicMeter / right.MolesPerCubicMeter; } @@ -635,6 +638,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Molarity left, Molarity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Molarity left, Molarity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -647,7 +663,29 @@ public int CompareTo(object obj) /// public int CompareTo(Molarity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Molarity objMolarity)) + return false; + return Equals(objMolarity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Molarity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -690,13 +728,13 @@ public int CompareTo(Molarity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Molarity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -707,7 +745,7 @@ public bool Equals(Molarity other, double tolerance, ComparisonType comparisonTy /// A hash code for the current Molarity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -718,17 +756,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(MolarityUnit unit) + public QuantityValue As(MolarityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -743,12 +780,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is MolarityUnit unitAsMolarityUnit)) + if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return As(unitAsMolarityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -780,7 +817,7 @@ public Molarity ToUnit(MolarityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Molarity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(MolarityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -788,17 +825,17 @@ public Molarity ToUnit(MolarityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarityUnit unitAsMolarityUnit)) + if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -825,10 +862,10 @@ public Molarity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(MolarityUnit unit) + private QuantityValue GetValueAs(MolarityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 8f4f597901..859e80a650 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) /// [DataContract] - public partial struct Permeability : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Permeability() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Permeability(double value, PermeabilityUnit unit) + public Permeability(QuantityValue value, PermeabilityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public Permeability(double value, PermeabilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permeability(double value, UnitSystem unitSystem) + public Permeability(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public Permeability(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public Permeability(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); + public QuantityValue HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(PermeabilityUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static Permeability FromHenriesPerMeter(QuantityValue henriespermeter) { - double value = (double) henriespermeter; + QuantityValue value = (QuantityValue) henriespermeter; return new Permeability(value, PermeabilityUnit.HenryPerMeter); } @@ -230,7 +233,7 @@ public static Permeability FromHenriesPerMeter(QuantityValue henriespermeter) /// Permeability unit value. public static Permeability From(QuantityValue value, PermeabilityUnit fromUnit) { - return new Permeability((double)value, fromUnit); + return new Permeability((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme } /// Get from multiplying value and . - public static Permeability operator *(double left, Permeability right) + public static Permeability operator *(QuantityValue left, Permeability right) { return new Permeability(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Permeability operator *(Permeability left, double right) + public static Permeability operator *(Permeability left, QuantityValue right) { return new Permeability(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Permeability operator /(Permeability left, double right) + public static Permeability operator /(Permeability left, QuantityValue right) { return new Permeability(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Permeability left, Permeability right) + public static QuantityValue operator /(Permeability left, Permeability right) { return left.HenriesPerMeter / right.HenriesPerMeter; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Permeability left, Permeability right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Permeability left, Permeability right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(Permeability other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Permeability objPermeability)) + return false; + return Equals(objPermeability); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Permeability other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(Permeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType) + public bool Equals(Permeability other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(Permeability other, double tolerance, ComparisonType comparis /// A hash code for the current Permeability. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermeabilityUnit unit) + public QuantityValue As(PermeabilityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) + if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPermeabilityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public Permeability ToUnit(PermeabilityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Permeability)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PermeabilityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public Permeability ToUnit(PermeabilityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) + if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPermeabilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public Permeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PermeabilityUnit unit) + private QuantityValue GetValueAs(PermeabilityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a375f49800..666aeab093 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permittivity /// [DataContract] - public partial struct Permittivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Permittivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Permittivity(double value, PermittivityUnit unit) + public Permittivity(QuantityValue value, PermittivityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public Permittivity(double value, PermittivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permittivity(double value, UnitSystem unitSystem) + public Permittivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public Permittivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public Permittivity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); + public QuantityValue FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(PermittivityUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static Permittivity FromFaradsPerMeter(QuantityValue faradspermeter) { - double value = (double) faradspermeter; + QuantityValue value = (QuantityValue) faradspermeter; return new Permittivity(value, PermittivityUnit.FaradPerMeter); } @@ -230,7 +233,7 @@ public static Permittivity FromFaradsPerMeter(QuantityValue faradspermeter) /// Permittivity unit value. public static Permittivity From(QuantityValue value, PermittivityUnit fromUnit) { - return new Permittivity((double)value, fromUnit); + return new Permittivity((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi } /// Get from multiplying value and . - public static Permittivity operator *(double left, Permittivity right) + public static Permittivity operator *(QuantityValue left, Permittivity right) { return new Permittivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Permittivity operator *(Permittivity left, double right) + public static Permittivity operator *(Permittivity left, QuantityValue right) { return new Permittivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Permittivity operator /(Permittivity left, double right) + public static Permittivity operator /(Permittivity left, QuantityValue right) { return new Permittivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Permittivity left, Permittivity right) + public static QuantityValue operator /(Permittivity left, Permittivity right) { return left.FaradsPerMeter / right.FaradsPerMeter; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Permittivity left, Permittivity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Permittivity left, Permittivity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(Permittivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Permittivity objPermittivity)) + return false; + return Equals(objPermittivity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Permittivity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(Permittivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Permittivity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(Permittivity other, double tolerance, ComparisonType comparis /// A hash code for the current Permittivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PermittivityUnit unit) + public QuantityValue As(PermittivityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PermittivityUnit unitAsPermittivityUnit)) + if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return As(unitAsPermittivityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public Permittivity ToUnit(PermittivityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Permittivity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PermittivityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public Permittivity ToUnit(PermittivityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermittivityUnit unitAsPermittivityUnit)) + if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPermittivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public Permittivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PermittivityUnit unit) + private QuantityValue GetValueAs(PermittivityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 3bf7765d64..0ed6169e45 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permeability_(Earth_sciences) /// [DataContract] - public partial struct PorousMediumPermeability : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct PorousMediumPermeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -79,9 +79,9 @@ static PorousMediumPermeability() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PorousMediumPermeability(double value, PorousMediumPermeabilityUnit unit) + public PorousMediumPermeability(QuantityValue value, PorousMediumPermeabilityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -93,14 +93,14 @@ public PorousMediumPermeability(double value, PorousMediumPermeabilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PorousMediumPermeability(double value, UnitSystem unitSystem) + public PorousMediumPermeability(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -141,7 +141,10 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -164,29 +167,29 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Darcys => As(PorousMediumPermeabilityUnit.Darcy); + public QuantityValue Darcys => As(PorousMediumPermeabilityUnit.Darcy); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microdarcys => As(PorousMediumPermeabilityUnit.Microdarcy); + public QuantityValue Microdarcys => As(PorousMediumPermeabilityUnit.Microdarcy); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millidarcys => As(PorousMediumPermeabilityUnit.Millidarcy); + public QuantityValue Millidarcys => As(PorousMediumPermeabilityUnit.Millidarcy); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareCentimeters => As(PorousMediumPermeabilityUnit.SquareCentimeter); + public QuantityValue SquareCentimeters => As(PorousMediumPermeabilityUnit.SquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMeters => As(PorousMediumPermeabilityUnit.SquareMeter); + public QuantityValue SquareMeters => As(PorousMediumPermeabilityUnit.SquareMeter); #endregion @@ -254,7 +257,7 @@ public static string GetAbbreviation(PorousMediumPermeabilityUnit unit, IFormatP /// If value is NaN or Infinity. public static PorousMediumPermeability FromDarcys(QuantityValue darcys) { - double value = (double) darcys; + QuantityValue value = (QuantityValue) darcys; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Darcy); } @@ -264,7 +267,7 @@ public static PorousMediumPermeability FromDarcys(QuantityValue darcys) /// If value is NaN or Infinity. public static PorousMediumPermeability FromMicrodarcys(QuantityValue microdarcys) { - double value = (double) microdarcys; + QuantityValue value = (QuantityValue) microdarcys; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Microdarcy); } @@ -274,7 +277,7 @@ public static PorousMediumPermeability FromMicrodarcys(QuantityValue microdarcys /// If value is NaN or Infinity. public static PorousMediumPermeability FromMillidarcys(QuantityValue millidarcys) { - double value = (double) millidarcys; + QuantityValue value = (QuantityValue) millidarcys; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Millidarcy); } @@ -284,7 +287,7 @@ public static PorousMediumPermeability FromMillidarcys(QuantityValue millidarcys /// If value is NaN or Infinity. public static PorousMediumPermeability FromSquareCentimeters(QuantityValue squarecentimeters) { - double value = (double) squarecentimeters; + QuantityValue value = (QuantityValue) squarecentimeters; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.SquareCentimeter); } @@ -294,7 +297,7 @@ public static PorousMediumPermeability FromSquareCentimeters(QuantityValue squar /// If value is NaN or Infinity. public static PorousMediumPermeability FromSquareMeters(QuantityValue squaremeters) { - double value = (double) squaremeters; + QuantityValue value = (QuantityValue) squaremeters; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.SquareMeter); } @@ -306,7 +309,7 @@ public static PorousMediumPermeability FromSquareMeters(QuantityValue squaremete /// PorousMediumPermeability unit value. public static PorousMediumPermeability From(QuantityValue value, PorousMediumPermeabilityUnit fromUnit) { - return new PorousMediumPermeability((double)value, fromUnit); + return new PorousMediumPermeability((QuantityValue)value, fromUnit); } #endregion @@ -476,25 +479,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou } /// Get from multiplying value and . - public static PorousMediumPermeability operator *(double left, PorousMediumPermeability right) + public static PorousMediumPermeability operator *(QuantityValue left, PorousMediumPermeability right) { return new PorousMediumPermeability(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PorousMediumPermeability operator *(PorousMediumPermeability left, double right) + public static PorousMediumPermeability operator *(PorousMediumPermeability left, QuantityValue right) { return new PorousMediumPermeability(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PorousMediumPermeability operator /(PorousMediumPermeability left, double right) + public static PorousMediumPermeability operator /(PorousMediumPermeability left, QuantityValue right) { return new PorousMediumPermeability(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(PorousMediumPermeability left, PorousMediumPermeability right) + public static QuantityValue operator /(PorousMediumPermeability left, PorousMediumPermeability right) { return left.SquareMeters / right.SquareMeters; } @@ -527,6 +530,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(PorousMediumPermeability left, PorousMediumPermeability right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(PorousMediumPermeability left, PorousMediumPermeability right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -539,7 +555,29 @@ public int CompareTo(object obj) /// public int CompareTo(PorousMediumPermeability other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is PorousMediumPermeability objPorousMediumPermeability)) + return false; + return Equals(objPorousMediumPermeability); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(PorousMediumPermeability other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -582,13 +620,13 @@ public int CompareTo(PorousMediumPermeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonType comparisonType) + public bool Equals(PorousMediumPermeability other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -599,7 +637,7 @@ public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonT /// A hash code for the current PorousMediumPermeability. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -610,17 +648,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PorousMediumPermeabilityUnit unit) + public QuantityValue As(PorousMediumPermeabilityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -635,12 +672,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) + if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPorousMediumPermeabilityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -672,7 +709,7 @@ public PorousMediumPermeability ToUnit(PorousMediumPermeabilityUnit unit, UnitCo var converted = conversionFunction(this); return (PorousMediumPermeability)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PorousMediumPermeabilityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -680,17 +717,17 @@ public PorousMediumPermeability ToUnit(PorousMediumPermeabilityUnit unit, UnitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) + if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPorousMediumPermeabilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -717,10 +754,10 @@ public PorousMediumPermeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PorousMediumPermeabilityUnit unit) + private QuantityValue GetValueAs(PorousMediumPermeabilityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 843092f2dc..fd569d371d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. /// [DataContract] - public partial struct Power : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Power : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly decimal _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -97,7 +97,7 @@ static Power() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Power(decimal value, PowerUnit unit) + public Power(QuantityValue value, PowerUnit unit) { _value = value; _unit = unit; @@ -111,7 +111,7 @@ public Power(decimal value, PowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Power(decimal value, UnitSystem unitSystem) + public Power(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,12 +159,13 @@ public Power(decimal value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public decimal Value => _value; + public QuantityValue Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// - decimal IDecimalQuantity.Value => _value; + decimal IDecimalQuantity.Value => (decimal)_value; Enum IQuantity.Unit => Unit; @@ -187,134 +188,134 @@ public Power(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); + public QuantityValue BoilerHorsepower => As(PowerUnit.BoilerHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); + public QuantityValue BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decawatts => As(PowerUnit.Decawatt); + public QuantityValue Decawatts => As(PowerUnit.Decawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Deciwatts => As(PowerUnit.Deciwatt); + public QuantityValue Deciwatts => As(PowerUnit.Deciwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); + public QuantityValue ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Femtowatts => As(PowerUnit.Femtowatt); + public QuantityValue Femtowatts => As(PowerUnit.Femtowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); + public QuantityValue GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigawatts => As(PowerUnit.Gigawatt); + public QuantityValue Gigawatts => As(PowerUnit.Gigawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); + public QuantityValue HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerHour => As(PowerUnit.JoulePerHour); + public QuantityValue JoulesPerHour => As(PowerUnit.JoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); + public QuantityValue KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); + public QuantityValue KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilowatts => As(PowerUnit.Kilowatt); + public QuantityValue Kilowatts => As(PowerUnit.Kilowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); + public QuantityValue MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); + public QuantityValue MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); + public QuantityValue MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megawatts => As(PowerUnit.Megawatt); + public QuantityValue Megawatts => As(PowerUnit.Megawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetricHorsepower => As(PowerUnit.MetricHorsepower); + public QuantityValue MetricHorsepower => As(PowerUnit.MetricHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microwatts => As(PowerUnit.Microwatt); + public QuantityValue Microwatts => As(PowerUnit.Microwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); + public QuantityValue MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliwatts => As(PowerUnit.Milliwatt); + public QuantityValue Milliwatts => As(PowerUnit.Milliwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Nanowatts => As(PowerUnit.Nanowatt); + public QuantityValue Nanowatts => As(PowerUnit.Nanowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Petawatts => As(PowerUnit.Petawatt); + public QuantityValue Petawatts => As(PowerUnit.Petawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Picowatts => As(PowerUnit.Picowatt); + public QuantityValue Picowatts => As(PowerUnit.Picowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Terawatts => As(PowerUnit.Terawatt); + public QuantityValue Terawatts => As(PowerUnit.Terawatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Watts => As(PowerUnit.Watt); + public QuantityValue Watts => As(PowerUnit.Watt); #endregion @@ -328,7 +329,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PowerUnit unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BoilerHorsepower, quantity => new Power(quantity.Value / 9812.5m, PowerUnit.BoilerHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.293071m, PowerUnit.BritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.29307107017m, PowerUnit.BritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Decawatt, quantity => new Power((quantity.Value) / 1e1m, PowerUnit.Decawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Deciwatt, quantity => new Power((quantity.Value) / 1e-1m, PowerUnit.Deciwatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.ElectricalHorsepower, quantity => new Power(quantity.Value / 746m, PowerUnit.ElectricalHorsepower)); @@ -337,11 +338,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Gigawatt, quantity => new Power((quantity.Value) / 1e9m, PowerUnit.Gigawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.HydraulicHorsepower, quantity => new Power(quantity.Value / 745.69988145m, PowerUnit.HydraulicHorsepower)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.JoulePerHour, quantity => new Power(quantity.Value * 3600m, PowerUnit.JoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilojoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e3m, PowerUnit.KilojoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Kilowatt, quantity => new Power((quantity.Value) / 1e3m, PowerUnit.Kilowatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MechanicalHorsepower, quantity => new Power(quantity.Value / 745.69m, PowerUnit.MechanicalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegajoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e6m, PowerUnit.MegajoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Megawatt, quantity => new Power((quantity.Value) / 1e6m, PowerUnit.Megawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MetricHorsepower, quantity => new Power(quantity.Value / 735.49875m, PowerUnit.MetricHorsepower)); @@ -358,7 +359,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: PowerUnit -> BaseUnit unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 9812.5m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.293071m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.29307107017m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Decawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Deciwatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e-1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 746m, PowerUnit.Watt)); @@ -367,11 +368,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Gigawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e9m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69988145m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, PowerUnit.Watt, quantity => new Power(quantity.Value / 3600m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e3m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Kilowatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e6m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Megawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 735.49875m, PowerUnit.Watt)); @@ -445,7 +446,7 @@ public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower) { - decimal value = (decimal) boilerhorsepower; + QuantityValue value = (QuantityValue) boilerhorsepower; return new Power(value, PowerUnit.BoilerHorsepower); } @@ -455,7 +456,7 @@ public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower) /// If value is NaN or Infinity. public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalunitsperhour) { - decimal value = (decimal) britishthermalunitsperhour; + QuantityValue value = (QuantityValue) britishthermalunitsperhour; return new Power(value, PowerUnit.BritishThermalUnitPerHour); } @@ -465,7 +466,7 @@ public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalu /// If value is NaN or Infinity. public static Power FromDecawatts(QuantityValue decawatts) { - decimal value = (decimal) decawatts; + QuantityValue value = (QuantityValue) decawatts; return new Power(value, PowerUnit.Decawatt); } @@ -475,7 +476,7 @@ public static Power FromDecawatts(QuantityValue decawatts) /// If value is NaN or Infinity. public static Power FromDeciwatts(QuantityValue deciwatts) { - decimal value = (decimal) deciwatts; + QuantityValue value = (QuantityValue) deciwatts; return new Power(value, PowerUnit.Deciwatt); } @@ -485,7 +486,7 @@ public static Power FromDeciwatts(QuantityValue deciwatts) /// If value is NaN or Infinity. public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower) { - decimal value = (decimal) electricalhorsepower; + QuantityValue value = (QuantityValue) electricalhorsepower; return new Power(value, PowerUnit.ElectricalHorsepower); } @@ -495,7 +496,7 @@ public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower) /// If value is NaN or Infinity. public static Power FromFemtowatts(QuantityValue femtowatts) { - decimal value = (decimal) femtowatts; + QuantityValue value = (QuantityValue) femtowatts; return new Power(value, PowerUnit.Femtowatt); } @@ -505,7 +506,7 @@ public static Power FromFemtowatts(QuantityValue femtowatts) /// If value is NaN or Infinity. public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour) { - decimal value = (decimal) gigajoulesperhour; + QuantityValue value = (QuantityValue) gigajoulesperhour; return new Power(value, PowerUnit.GigajoulePerHour); } @@ -515,7 +516,7 @@ public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour) /// If value is NaN or Infinity. public static Power FromGigawatts(QuantityValue gigawatts) { - decimal value = (decimal) gigawatts; + QuantityValue value = (QuantityValue) gigawatts; return new Power(value, PowerUnit.Gigawatt); } @@ -525,7 +526,7 @@ public static Power FromGigawatts(QuantityValue gigawatts) /// If value is NaN or Infinity. public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower) { - decimal value = (decimal) hydraulichorsepower; + QuantityValue value = (QuantityValue) hydraulichorsepower; return new Power(value, PowerUnit.HydraulicHorsepower); } @@ -535,7 +536,7 @@ public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower) /// If value is NaN or Infinity. public static Power FromJoulesPerHour(QuantityValue joulesperhour) { - decimal value = (decimal) joulesperhour; + QuantityValue value = (QuantityValue) joulesperhour; return new Power(value, PowerUnit.JoulePerHour); } @@ -545,7 +546,7 @@ public static Power FromJoulesPerHour(QuantityValue joulesperhour) /// If value is NaN or Infinity. public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritishthermalunitsperhour) { - decimal value = (decimal) kilobritishthermalunitsperhour; + QuantityValue value = (QuantityValue) kilobritishthermalunitsperhour; return new Power(value, PowerUnit.KilobritishThermalUnitPerHour); } @@ -555,7 +556,7 @@ public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritish /// If value is NaN or Infinity. public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour) { - decimal value = (decimal) kilojoulesperhour; + QuantityValue value = (QuantityValue) kilojoulesperhour; return new Power(value, PowerUnit.KilojoulePerHour); } @@ -565,7 +566,7 @@ public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour) /// If value is NaN or Infinity. public static Power FromKilowatts(QuantityValue kilowatts) { - decimal value = (decimal) kilowatts; + QuantityValue value = (QuantityValue) kilowatts; return new Power(value, PowerUnit.Kilowatt); } @@ -575,7 +576,7 @@ public static Power FromKilowatts(QuantityValue kilowatts) /// If value is NaN or Infinity. public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower) { - decimal value = (decimal) mechanicalhorsepower; + QuantityValue value = (QuantityValue) mechanicalhorsepower; return new Power(value, PowerUnit.MechanicalHorsepower); } @@ -585,7 +586,7 @@ public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower) /// If value is NaN or Infinity. public static Power FromMegabritishThermalUnitsPerHour(QuantityValue megabritishthermalunitsperhour) { - decimal value = (decimal) megabritishthermalunitsperhour; + QuantityValue value = (QuantityValue) megabritishthermalunitsperhour; return new Power(value, PowerUnit.MegabritishThermalUnitPerHour); } @@ -595,7 +596,7 @@ public static Power FromMegabritishThermalUnitsPerHour(QuantityValue megabritish /// If value is NaN or Infinity. public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour) { - decimal value = (decimal) megajoulesperhour; + QuantityValue value = (QuantityValue) megajoulesperhour; return new Power(value, PowerUnit.MegajoulePerHour); } @@ -605,7 +606,7 @@ public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour) /// If value is NaN or Infinity. public static Power FromMegawatts(QuantityValue megawatts) { - decimal value = (decimal) megawatts; + QuantityValue value = (QuantityValue) megawatts; return new Power(value, PowerUnit.Megawatt); } @@ -615,7 +616,7 @@ public static Power FromMegawatts(QuantityValue megawatts) /// If value is NaN or Infinity. public static Power FromMetricHorsepower(QuantityValue metrichorsepower) { - decimal value = (decimal) metrichorsepower; + QuantityValue value = (QuantityValue) metrichorsepower; return new Power(value, PowerUnit.MetricHorsepower); } @@ -625,7 +626,7 @@ public static Power FromMetricHorsepower(QuantityValue metrichorsepower) /// If value is NaN or Infinity. public static Power FromMicrowatts(QuantityValue microwatts) { - decimal value = (decimal) microwatts; + QuantityValue value = (QuantityValue) microwatts; return new Power(value, PowerUnit.Microwatt); } @@ -635,7 +636,7 @@ public static Power FromMicrowatts(QuantityValue microwatts) /// If value is NaN or Infinity. public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour) { - decimal value = (decimal) millijoulesperhour; + QuantityValue value = (QuantityValue) millijoulesperhour; return new Power(value, PowerUnit.MillijoulePerHour); } @@ -645,7 +646,7 @@ public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour) /// If value is NaN or Infinity. public static Power FromMilliwatts(QuantityValue milliwatts) { - decimal value = (decimal) milliwatts; + QuantityValue value = (QuantityValue) milliwatts; return new Power(value, PowerUnit.Milliwatt); } @@ -655,7 +656,7 @@ public static Power FromMilliwatts(QuantityValue milliwatts) /// If value is NaN or Infinity. public static Power FromNanowatts(QuantityValue nanowatts) { - decimal value = (decimal) nanowatts; + QuantityValue value = (QuantityValue) nanowatts; return new Power(value, PowerUnit.Nanowatt); } @@ -665,7 +666,7 @@ public static Power FromNanowatts(QuantityValue nanowatts) /// If value is NaN or Infinity. public static Power FromPetawatts(QuantityValue petawatts) { - decimal value = (decimal) petawatts; + QuantityValue value = (QuantityValue) petawatts; return new Power(value, PowerUnit.Petawatt); } @@ -675,7 +676,7 @@ public static Power FromPetawatts(QuantityValue petawatts) /// If value is NaN or Infinity. public static Power FromPicowatts(QuantityValue picowatts) { - decimal value = (decimal) picowatts; + QuantityValue value = (QuantityValue) picowatts; return new Power(value, PowerUnit.Picowatt); } @@ -685,7 +686,7 @@ public static Power FromPicowatts(QuantityValue picowatts) /// If value is NaN or Infinity. public static Power FromTerawatts(QuantityValue terawatts) { - decimal value = (decimal) terawatts; + QuantityValue value = (QuantityValue) terawatts; return new Power(value, PowerUnit.Terawatt); } @@ -695,7 +696,7 @@ public static Power FromTerawatts(QuantityValue terawatts) /// If value is NaN or Infinity. public static Power FromWatts(QuantityValue watts) { - decimal value = (decimal) watts; + QuantityValue value = (QuantityValue) watts; return new Power(value, PowerUnit.Watt); } @@ -707,7 +708,7 @@ public static Power FromWatts(QuantityValue watts) /// Power unit value. public static Power From(QuantityValue value, PowerUnit fromUnit) { - return new Power((decimal)value, fromUnit); + return new Power((QuantityValue)value, fromUnit); } #endregion @@ -877,25 +878,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get from multiplying value and . - public static Power operator *(decimal left, Power right) + public static Power operator *(QuantityValue left, Power right) { return new Power(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Power operator *(Power left, decimal right) + public static Power operator *(Power left, QuantityValue right) { return new Power(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Power operator /(Power left, decimal right) + public static Power operator /(Power left, QuantityValue right) { return new Power(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Power left, Power right) + public static QuantityValue operator /(Power left, Power right) { return left.Watts / right.Watts; } @@ -928,6 +929,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Power left, Power right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Power left, Power right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -940,7 +954,29 @@ public int CompareTo(object obj) /// public int CompareTo(Power other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Power objPower)) + return false; + return Equals(objPower); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Power other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -983,13 +1019,13 @@ public int CompareTo(Power other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Power other, double tolerance, ComparisonType comparisonType) + public bool Equals(Power other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1000,7 +1036,7 @@ public bool Equals(Power other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Power. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1011,17 +1047,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerUnit unit) + public QuantityValue As(PowerUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1036,12 +1071,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PowerUnit unitAsPowerUnit)) + if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return As(unitAsPowerUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1073,7 +1108,7 @@ public Power ToUnit(PowerUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Power)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PowerUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1081,17 +1116,17 @@ public Power ToUnit(PowerUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerUnit unitAsPowerUnit)) + if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1118,10 +1153,10 @@ public Power ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private decimal GetValueAs(PowerUnit unit) + private QuantityValue GetValueAs(PowerUnit unit) { var converted = ToUnit(unit); - return (decimal)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index a13b01eef5..e35dfe4767 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The amount of power in a volume. /// [DataContract] - public partial struct PowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -115,9 +115,9 @@ static PowerDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PowerDensity(double value, PowerDensityUnit unit) + public PowerDensity(QuantityValue value, PowerDensityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -129,14 +129,14 @@ public PowerDensity(double value, PowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerDensity(double value, UnitSystem unitSystem) + public PowerDensity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -177,7 +177,10 @@ public PowerDensity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -200,224 +203,224 @@ public PowerDensity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); + public QuantityValue DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); + public QuantityValue DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); + public QuantityValue DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); + public QuantityValue DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); + public QuantityValue DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); + public QuantityValue DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); + public QuantityValue DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); + public QuantityValue DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); + public QuantityValue GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); + public QuantityValue GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); + public QuantityValue GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); + public QuantityValue GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); + public QuantityValue KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); + public QuantityValue KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); + public QuantityValue KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); + public QuantityValue KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); + public QuantityValue MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); + public QuantityValue MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); + public QuantityValue MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); + public QuantityValue MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); + public QuantityValue MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); + public QuantityValue MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); + public QuantityValue MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); + public QuantityValue MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); + public QuantityValue MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); + public QuantityValue MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); + public QuantityValue MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); + public QuantityValue MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); + public QuantityValue NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); + public QuantityValue NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); + public QuantityValue NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); + public QuantityValue NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); + public QuantityValue PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); + public QuantityValue PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); + public QuantityValue PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); + public QuantityValue PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); + public QuantityValue TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); + public QuantityValue TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); + public QuantityValue TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); + public QuantityValue TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); + public QuantityValue WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); + public QuantityValue WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); + public QuantityValue WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerLiter => As(PowerDensityUnit.WattPerLiter); + public QuantityValue WattsPerLiter => As(PowerDensityUnit.WattPerLiter); #endregion @@ -602,7 +605,7 @@ public static string GetAbbreviation(PowerDensityUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue decawattspercubicfoot) { - double value = (double) decawattspercubicfoot; + QuantityValue value = (QuantityValue) decawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicFoot); } @@ -612,7 +615,7 @@ public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue decawattsperc /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerCubicInch(QuantityValue decawattspercubicinch) { - double value = (double) decawattspercubicinch; + QuantityValue value = (QuantityValue) decawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicInch); } @@ -622,7 +625,7 @@ public static PowerDensity FromDecawattsPerCubicInch(QuantityValue decawattsperc /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue decawattspercubicmeter) { - double value = (double) decawattspercubicmeter; + QuantityValue value = (QuantityValue) decawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicMeter); } @@ -632,7 +635,7 @@ public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue decawattsper /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerLiter(QuantityValue decawattsperliter) { - double value = (double) decawattsperliter; + QuantityValue value = (QuantityValue) decawattsperliter; return new PowerDensity(value, PowerDensityUnit.DecawattPerLiter); } @@ -642,7 +645,7 @@ public static PowerDensity FromDecawattsPerLiter(QuantityValue decawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue deciwattspercubicfoot) { - double value = (double) deciwattspercubicfoot; + QuantityValue value = (QuantityValue) deciwattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicFoot); } @@ -652,7 +655,7 @@ public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue deciwattsperc /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue deciwattspercubicinch) { - double value = (double) deciwattspercubicinch; + QuantityValue value = (QuantityValue) deciwattspercubicinch; return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicInch); } @@ -662,7 +665,7 @@ public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue deciwattsperc /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue deciwattspercubicmeter) { - double value = (double) deciwattspercubicmeter; + QuantityValue value = (QuantityValue) deciwattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicMeter); } @@ -672,7 +675,7 @@ public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue deciwattsper /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerLiter(QuantityValue deciwattsperliter) { - double value = (double) deciwattsperliter; + QuantityValue value = (QuantityValue) deciwattsperliter; return new PowerDensity(value, PowerDensityUnit.DeciwattPerLiter); } @@ -682,7 +685,7 @@ public static PowerDensity FromDeciwattsPerLiter(QuantityValue deciwattsperliter /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue gigawattspercubicfoot) { - double value = (double) gigawattspercubicfoot; + QuantityValue value = (QuantityValue) gigawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicFoot); } @@ -692,7 +695,7 @@ public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue gigawattsperc /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerCubicInch(QuantityValue gigawattspercubicinch) { - double value = (double) gigawattspercubicinch; + QuantityValue value = (QuantityValue) gigawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicInch); } @@ -702,7 +705,7 @@ public static PowerDensity FromGigawattsPerCubicInch(QuantityValue gigawattsperc /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue gigawattspercubicmeter) { - double value = (double) gigawattspercubicmeter; + QuantityValue value = (QuantityValue) gigawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicMeter); } @@ -712,7 +715,7 @@ public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue gigawattsper /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerLiter(QuantityValue gigawattsperliter) { - double value = (double) gigawattsperliter; + QuantityValue value = (QuantityValue) gigawattsperliter; return new PowerDensity(value, PowerDensityUnit.GigawattPerLiter); } @@ -722,7 +725,7 @@ public static PowerDensity FromGigawattsPerLiter(QuantityValue gigawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue kilowattspercubicfoot) { - double value = (double) kilowattspercubicfoot; + QuantityValue value = (QuantityValue) kilowattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicFoot); } @@ -732,7 +735,7 @@ public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue kilowattsperc /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerCubicInch(QuantityValue kilowattspercubicinch) { - double value = (double) kilowattspercubicinch; + QuantityValue value = (QuantityValue) kilowattspercubicinch; return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicInch); } @@ -742,7 +745,7 @@ public static PowerDensity FromKilowattsPerCubicInch(QuantityValue kilowattsperc /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue kilowattspercubicmeter) { - double value = (double) kilowattspercubicmeter; + QuantityValue value = (QuantityValue) kilowattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicMeter); } @@ -752,7 +755,7 @@ public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue kilowattsper /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerLiter(QuantityValue kilowattsperliter) { - double value = (double) kilowattsperliter; + QuantityValue value = (QuantityValue) kilowattsperliter; return new PowerDensity(value, PowerDensityUnit.KilowattPerLiter); } @@ -762,7 +765,7 @@ public static PowerDensity FromKilowattsPerLiter(QuantityValue kilowattsperliter /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue megawattspercubicfoot) { - double value = (double) megawattspercubicfoot; + QuantityValue value = (QuantityValue) megawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicFoot); } @@ -772,7 +775,7 @@ public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue megawattsperc /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerCubicInch(QuantityValue megawattspercubicinch) { - double value = (double) megawattspercubicinch; + QuantityValue value = (QuantityValue) megawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicInch); } @@ -782,7 +785,7 @@ public static PowerDensity FromMegawattsPerCubicInch(QuantityValue megawattsperc /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue megawattspercubicmeter) { - double value = (double) megawattspercubicmeter; + QuantityValue value = (QuantityValue) megawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicMeter); } @@ -792,7 +795,7 @@ public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue megawattsper /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerLiter(QuantityValue megawattsperliter) { - double value = (double) megawattsperliter; + QuantityValue value = (QuantityValue) megawattsperliter; return new PowerDensity(value, PowerDensityUnit.MegawattPerLiter); } @@ -802,7 +805,7 @@ public static PowerDensity FromMegawattsPerLiter(QuantityValue megawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue microwattspercubicfoot) { - double value = (double) microwattspercubicfoot; + QuantityValue value = (QuantityValue) microwattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicFoot); } @@ -812,7 +815,7 @@ public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue microwattspe /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue microwattspercubicinch) { - double value = (double) microwattspercubicinch; + QuantityValue value = (QuantityValue) microwattspercubicinch; return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicInch); } @@ -822,7 +825,7 @@ public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue microwattspe /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue microwattspercubicmeter) { - double value = (double) microwattspercubicmeter; + QuantityValue value = (QuantityValue) microwattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicMeter); } @@ -832,7 +835,7 @@ public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue microwattsp /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerLiter(QuantityValue microwattsperliter) { - double value = (double) microwattsperliter; + QuantityValue value = (QuantityValue) microwattsperliter; return new PowerDensity(value, PowerDensityUnit.MicrowattPerLiter); } @@ -842,7 +845,7 @@ public static PowerDensity FromMicrowattsPerLiter(QuantityValue microwattsperlit /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue milliwattspercubicfoot) { - double value = (double) milliwattspercubicfoot; + QuantityValue value = (QuantityValue) milliwattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicFoot); } @@ -852,7 +855,7 @@ public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue milliwattspe /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue milliwattspercubicinch) { - double value = (double) milliwattspercubicinch; + QuantityValue value = (QuantityValue) milliwattspercubicinch; return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicInch); } @@ -862,7 +865,7 @@ public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue milliwattspe /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue milliwattspercubicmeter) { - double value = (double) milliwattspercubicmeter; + QuantityValue value = (QuantityValue) milliwattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicMeter); } @@ -872,7 +875,7 @@ public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue milliwattsp /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerLiter(QuantityValue milliwattsperliter) { - double value = (double) milliwattsperliter; + QuantityValue value = (QuantityValue) milliwattsperliter; return new PowerDensity(value, PowerDensityUnit.MilliwattPerLiter); } @@ -882,7 +885,7 @@ public static PowerDensity FromMilliwattsPerLiter(QuantityValue milliwattsperlit /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue nanowattspercubicfoot) { - double value = (double) nanowattspercubicfoot; + QuantityValue value = (QuantityValue) nanowattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicFoot); } @@ -892,7 +895,7 @@ public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue nanowattsperc /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerCubicInch(QuantityValue nanowattspercubicinch) { - double value = (double) nanowattspercubicinch; + QuantityValue value = (QuantityValue) nanowattspercubicinch; return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicInch); } @@ -902,7 +905,7 @@ public static PowerDensity FromNanowattsPerCubicInch(QuantityValue nanowattsperc /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue nanowattspercubicmeter) { - double value = (double) nanowattspercubicmeter; + QuantityValue value = (QuantityValue) nanowattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicMeter); } @@ -912,7 +915,7 @@ public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue nanowattsper /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerLiter(QuantityValue nanowattsperliter) { - double value = (double) nanowattsperliter; + QuantityValue value = (QuantityValue) nanowattsperliter; return new PowerDensity(value, PowerDensityUnit.NanowattPerLiter); } @@ -922,7 +925,7 @@ public static PowerDensity FromNanowattsPerLiter(QuantityValue nanowattsperliter /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue picowattspercubicfoot) { - double value = (double) picowattspercubicfoot; + QuantityValue value = (QuantityValue) picowattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicFoot); } @@ -932,7 +935,7 @@ public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue picowattsperc /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerCubicInch(QuantityValue picowattspercubicinch) { - double value = (double) picowattspercubicinch; + QuantityValue value = (QuantityValue) picowattspercubicinch; return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicInch); } @@ -942,7 +945,7 @@ public static PowerDensity FromPicowattsPerCubicInch(QuantityValue picowattsperc /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue picowattspercubicmeter) { - double value = (double) picowattspercubicmeter; + QuantityValue value = (QuantityValue) picowattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicMeter); } @@ -952,7 +955,7 @@ public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue picowattsper /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerLiter(QuantityValue picowattsperliter) { - double value = (double) picowattsperliter; + QuantityValue value = (QuantityValue) picowattsperliter; return new PowerDensity(value, PowerDensityUnit.PicowattPerLiter); } @@ -962,7 +965,7 @@ public static PowerDensity FromPicowattsPerLiter(QuantityValue picowattsperliter /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue terawattspercubicfoot) { - double value = (double) terawattspercubicfoot; + QuantityValue value = (QuantityValue) terawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicFoot); } @@ -972,7 +975,7 @@ public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue terawattsperc /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerCubicInch(QuantityValue terawattspercubicinch) { - double value = (double) terawattspercubicinch; + QuantityValue value = (QuantityValue) terawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicInch); } @@ -982,7 +985,7 @@ public static PowerDensity FromTerawattsPerCubicInch(QuantityValue terawattsperc /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue terawattspercubicmeter) { - double value = (double) terawattspercubicmeter; + QuantityValue value = (QuantityValue) terawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicMeter); } @@ -992,7 +995,7 @@ public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue terawattsper /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerLiter(QuantityValue terawattsperliter) { - double value = (double) terawattsperliter; + QuantityValue value = (QuantityValue) terawattsperliter; return new PowerDensity(value, PowerDensityUnit.TerawattPerLiter); } @@ -1002,7 +1005,7 @@ public static PowerDensity FromTerawattsPerLiter(QuantityValue terawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromWattsPerCubicFoot(QuantityValue wattspercubicfoot) { - double value = (double) wattspercubicfoot; + QuantityValue value = (QuantityValue) wattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.WattPerCubicFoot); } @@ -1012,7 +1015,7 @@ public static PowerDensity FromWattsPerCubicFoot(QuantityValue wattspercubicfoot /// If value is NaN or Infinity. public static PowerDensity FromWattsPerCubicInch(QuantityValue wattspercubicinch) { - double value = (double) wattspercubicinch; + QuantityValue value = (QuantityValue) wattspercubicinch; return new PowerDensity(value, PowerDensityUnit.WattPerCubicInch); } @@ -1022,7 +1025,7 @@ public static PowerDensity FromWattsPerCubicInch(QuantityValue wattspercubicinch /// If value is NaN or Infinity. public static PowerDensity FromWattsPerCubicMeter(QuantityValue wattspercubicmeter) { - double value = (double) wattspercubicmeter; + QuantityValue value = (QuantityValue) wattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.WattPerCubicMeter); } @@ -1032,7 +1035,7 @@ public static PowerDensity FromWattsPerCubicMeter(QuantityValue wattspercubicmet /// If value is NaN or Infinity. public static PowerDensity FromWattsPerLiter(QuantityValue wattsperliter) { - double value = (double) wattsperliter; + QuantityValue value = (QuantityValue) wattsperliter; return new PowerDensity(value, PowerDensityUnit.WattPerLiter); } @@ -1044,7 +1047,7 @@ public static PowerDensity FromWattsPerLiter(QuantityValue wattsperliter) /// PowerDensity unit value. public static PowerDensity From(QuantityValue value, PowerDensityUnit fromUnit) { - return new PowerDensity((double)value, fromUnit); + return new PowerDensity((QuantityValue)value, fromUnit); } #endregion @@ -1214,25 +1217,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get from multiplying value and . - public static PowerDensity operator *(double left, PowerDensity right) + public static PowerDensity operator *(QuantityValue left, PowerDensity right) { return new PowerDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PowerDensity operator *(PowerDensity left, double right) + public static PowerDensity operator *(PowerDensity left, QuantityValue right) { return new PowerDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PowerDensity operator /(PowerDensity left, double right) + public static PowerDensity operator /(PowerDensity left, QuantityValue right) { return new PowerDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(PowerDensity left, PowerDensity right) + public static QuantityValue operator /(PowerDensity left, PowerDensity right) { return left.WattsPerCubicMeter / right.WattsPerCubicMeter; } @@ -1265,6 +1268,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(PowerDensity left, PowerDensity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(PowerDensity left, PowerDensity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1277,7 +1293,29 @@ public int CompareTo(object obj) /// public int CompareTo(PowerDensity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is PowerDensity objPowerDensity)) + return false; + return Equals(objPowerDensity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(PowerDensity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1320,13 +1358,13 @@ public int CompareTo(PowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType) + public bool Equals(PowerDensity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1337,7 +1375,7 @@ public bool Equals(PowerDensity other, double tolerance, ComparisonType comparis /// A hash code for the current PowerDensity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1348,17 +1386,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerDensityUnit unit) + public QuantityValue As(PowerDensityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1373,12 +1410,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) + if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsPowerDensityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1410,7 +1447,7 @@ public PowerDensity ToUnit(PowerDensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (PowerDensity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PowerDensityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1418,17 +1455,17 @@ public PowerDensity ToUnit(PowerDensityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) + if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1455,10 +1492,10 @@ public PowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PowerDensityUnit unit) + private QuantityValue GetValueAs(PowerDensityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index e2297bd8ec..b76f6f4e1f 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one watt. /// [DataContract] - public partial struct PowerRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static PowerRatio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PowerRatio(double value, PowerRatioUnit unit) + public PowerRatio(QuantityValue value, PowerRatioUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -87,14 +87,14 @@ public PowerRatio(double value, PowerRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerRatio(double value, UnitSystem unitSystem) + public PowerRatio(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,7 +135,10 @@ public PowerRatio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -158,14 +161,14 @@ public PowerRatio(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); + public QuantityValue DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecibelWatts => As(PowerRatioUnit.DecibelWatt); + public QuantityValue DecibelWatts => As(PowerRatioUnit.DecibelWatt); #endregion @@ -224,7 +227,7 @@ public static string GetAbbreviation(PowerRatioUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static PowerRatio FromDecibelMilliwatts(QuantityValue decibelmilliwatts) { - double value = (double) decibelmilliwatts; + QuantityValue value = (QuantityValue) decibelmilliwatts; return new PowerRatio(value, PowerRatioUnit.DecibelMilliwatt); } @@ -234,7 +237,7 @@ public static PowerRatio FromDecibelMilliwatts(QuantityValue decibelmilliwatts) /// If value is NaN or Infinity. public static PowerRatio FromDecibelWatts(QuantityValue decibelwatts) { - double value = (double) decibelwatts; + QuantityValue value = (QuantityValue) decibelwatts; return new PowerRatio(value, PowerRatioUnit.DecibelWatt); } @@ -246,7 +249,7 @@ public static PowerRatio FromDecibelWatts(QuantityValue decibelwatts) /// PowerRatio unit value. public static PowerRatio From(QuantityValue value, PowerRatioUnit fromUnit) { - return new PowerRatio((double)value, fromUnit); + return new PowerRatio((QuantityValue)value, fromUnit); } #endregion @@ -408,7 +411,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power { // Logarithmic addition // Formula: 10 * log10(10^(x/10) + 10^(y/10)) - return new PowerRatio(10 * Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new PowerRatio(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic subtraction of two . @@ -416,11 +419,11 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power { // Logarithmic subtraction // Formula: 10 * log10(10^(x/10) - 10^(y/10)) - return new PowerRatio(10 * Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); + return new PowerRatio(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic multiplication of value and . - public static PowerRatio operator *(double left, PowerRatio right) + public static PowerRatio operator *(QuantityValue left, PowerRatio right) { // Logarithmic multiplication = addition return new PowerRatio(left + right.Value, right.Unit); @@ -430,14 +433,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power public static PowerRatio operator *(PowerRatio left, double right) { // Logarithmic multiplication = addition - return new PowerRatio(left.Value + (double)right, left.Unit); + return new PowerRatio(left.Value + (QuantityValue)right, left.Unit); } /// Get from logarithmic division of by value. public static PowerRatio operator /(PowerRatio left, double right) { // Logarithmic division = subtraction - return new PowerRatio(left.Value - (double)right, left.Unit); + return new PowerRatio(left.Value - (QuantityValue)right, left.Unit); } /// Get ratio value from logarithmic division of by . @@ -475,6 +478,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(PowerRatio left, PowerRatio right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(PowerRatio left, PowerRatio right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -487,7 +503,29 @@ public int CompareTo(object obj) /// public int CompareTo(PowerRatio other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is PowerRatio objPowerRatio)) + return false; + return Equals(objPowerRatio); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(PowerRatio other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -530,13 +568,13 @@ public int CompareTo(PowerRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType) + public bool Equals(PowerRatio other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -547,7 +585,7 @@ public bool Equals(PowerRatio other, double tolerance, ComparisonType comparison /// A hash code for the current PowerRatio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -558,17 +596,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerRatioUnit unit) + public QuantityValue As(PowerRatioUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -583,12 +620,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) + if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return As(unitAsPowerRatioUnit); + return (QuantityValue)As(typedUnit); } /// @@ -620,7 +657,7 @@ public PowerRatio ToUnit(PowerRatioUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (PowerRatio)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PowerRatioUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -628,17 +665,17 @@ public PowerRatio ToUnit(PowerRatioUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) + if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -665,10 +702,10 @@ public PowerRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PowerRatioUnit unit) + private QuantityValue GetValueAs(PowerRatioUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 12ab6f58c5..cd4dcfda52 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). /// [DataContract] - public partial struct Pressure : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Pressure : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -118,9 +118,9 @@ static Pressure() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Pressure(double value, PressureUnit unit) + public Pressure(QuantityValue value, PressureUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -132,14 +132,14 @@ public Pressure(double value, PressureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Pressure(double value, UnitSystem unitSystem) + public Pressure(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -180,7 +180,10 @@ public Pressure(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -203,239 +206,239 @@ public Pressure(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Atmospheres => As(PressureUnit.Atmosphere); + public QuantityValue Atmospheres => As(PressureUnit.Atmosphere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Bars => As(PressureUnit.Bar); + public QuantityValue Bars => As(PressureUnit.Bar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centibars => As(PressureUnit.Centibar); + public QuantityValue Centibars => As(PressureUnit.Centibar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decapascals => As(PressureUnit.Decapascal); + public QuantityValue Decapascals => As(PressureUnit.Decapascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decibars => As(PressureUnit.Decibar); + public QuantityValue Decibars => As(PressureUnit.Decibar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); + public QuantityValue DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetOfElevation => As(PressureUnit.FootOfElevation); + public QuantityValue FeetOfElevation => As(PressureUnit.FootOfElevation); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetOfHead => As(PressureUnit.FootOfHead); + public QuantityValue FeetOfHead => As(PressureUnit.FootOfHead); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Gigapascals => As(PressureUnit.Gigapascal); + public QuantityValue Gigapascals => As(PressureUnit.Gigapascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hectopascals => As(PressureUnit.Hectopascal); + public QuantityValue Hectopascals => As(PressureUnit.Hectopascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesOfMercury => As(PressureUnit.InchOfMercury); + public QuantityValue InchesOfMercury => As(PressureUnit.InchOfMercury); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); + public QuantityValue InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilobars => As(PressureUnit.Kilobar); + public QuantityValue Kilobars => As(PressureUnit.Kilobar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); + public QuantityValue KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); + public QuantityValue KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); + public QuantityValue KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); + public QuantityValue KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); + public QuantityValue KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); + public QuantityValue KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kilopascals => As(PressureUnit.Kilopascal); + public QuantityValue Kilopascals => As(PressureUnit.Kilopascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); + public QuantityValue KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); + public QuantityValue KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil); + public QuantityValue KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megabars => As(PressureUnit.Megabar); + public QuantityValue Megabars => As(PressureUnit.Megabar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); + public QuantityValue MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megapascals => As(PressureUnit.Megapascal); + public QuantityValue Megapascals => As(PressureUnit.Megapascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersOfElevation => As(PressureUnit.MeterOfElevation); + public QuantityValue MetersOfElevation => As(PressureUnit.MeterOfElevation); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersOfHead => As(PressureUnit.MeterOfHead); + public QuantityValue MetersOfHead => As(PressureUnit.MeterOfHead); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microbars => As(PressureUnit.Microbar); + public QuantityValue Microbars => As(PressureUnit.Microbar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Micropascals => As(PressureUnit.Micropascal); + public QuantityValue Micropascals => As(PressureUnit.Micropascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millibars => As(PressureUnit.Millibar); + public QuantityValue Millibars => As(PressureUnit.Millibar); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); + public QuantityValue MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimeterOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn); + public QuantityValue MillimeterOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Millipascals => As(PressureUnit.Millipascal); + public QuantityValue Millipascals => As(PressureUnit.Millipascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); + public QuantityValue NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); + public QuantityValue NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); + public QuantityValue NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Pascals => As(PressureUnit.Pascal); + public QuantityValue Pascals => As(PressureUnit.Pascal); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); + public QuantityValue PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); + public QuantityValue PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil); + public QuantityValue PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); + public QuantityValue PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); + public QuantityValue TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); + public QuantityValue TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); + public QuantityValue TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); + public QuantityValue TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Torrs => As(PressureUnit.Torr); + public QuantityValue Torrs => As(PressureUnit.Torr); #endregion @@ -454,7 +457,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Decapascal, quantity => new Pressure((quantity.Value) / 1e1d, PressureUnit.Decapascal)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Decibar, quantity => new Pressure((quantity.Value / 1e5) / 1e-1d, PressureUnit.Decibar)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.DynePerSquareCentimeter, quantity => new Pressure(quantity.Value / 1.0e-1, PressureUnit.DynePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.FootOfElevation, quantity => new Pressure((1.0 - Math.Pow(quantity.Value / 101325.0, 0.190284)) * 145366.45, PressureUnit.FootOfElevation)); + unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.FootOfElevation, quantity => new Pressure((1.0 - Math.Pow((double)quantity.Value / 101325.0, 0.190284)) * 145366.45, PressureUnit.FootOfElevation)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.FootOfHead, quantity => new Pressure(quantity.Value * 0.000334552565551, PressureUnit.FootOfHead)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Gigapascal, quantity => new Pressure((quantity.Value) / 1e9d, PressureUnit.Gigapascal)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Hectopascal, quantity => new Pressure((quantity.Value) / 1e2d, PressureUnit.Hectopascal)); @@ -474,7 +477,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Megabar, quantity => new Pressure((quantity.Value / 1e5) / 1e6d, PressureUnit.Megabar)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeganewtonPerSquareMeter, quantity => new Pressure((quantity.Value) / 1e6d, PressureUnit.MeganewtonPerSquareMeter)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Megapascal, quantity => new Pressure((quantity.Value) / 1e6d, PressureUnit.Megapascal)); - unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeterOfElevation, quantity => new Pressure((1.0 - Math.Pow(quantity.Value / 101325.0, 0.190284)) * 44307.69396, PressureUnit.MeterOfElevation)); + unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeterOfElevation, quantity => new Pressure((1.0 - Math.Pow((double)quantity.Value / 101325.0, 0.190284)) * 44307.69396, PressureUnit.MeterOfElevation)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeterOfHead, quantity => new Pressure(quantity.Value * 0.0001019977334, PressureUnit.MeterOfHead)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Microbar, quantity => new Pressure((quantity.Value / 1e5) / 1e-6d, PressureUnit.Microbar)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Micropascal, quantity => new Pressure((quantity.Value) / 1e-6d, PressureUnit.Micropascal)); @@ -505,7 +508,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Decapascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e1d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Decibar, PressureUnit.Pascal, quantity => new Pressure((quantity.Value * 1e5) * 1e-1d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.DynePerSquareCentimeter, PressureUnit.Pascal, quantity => new Pressure(quantity.Value * 1.0e-1, PressureUnit.Pascal)); - unitConverter.SetConversionFunction(PressureUnit.FootOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - (quantity.Value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); + unitConverter.SetConversionFunction(PressureUnit.FootOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - ((double)quantity.Value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.FootOfHead, PressureUnit.Pascal, quantity => new Pressure(quantity.Value * 2989.0669, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Gigapascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e9d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Hectopascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e2d, PressureUnit.Pascal)); @@ -525,7 +528,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Megabar, PressureUnit.Pascal, quantity => new Pressure((quantity.Value * 1e5) * 1e6d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.MeganewtonPerSquareMeter, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e6d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Megapascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e6d, PressureUnit.Pascal)); - unitConverter.SetConversionFunction(PressureUnit.MeterOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - (quantity.Value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); + unitConverter.SetConversionFunction(PressureUnit.MeterOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - ((double)quantity.Value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.MeterOfHead, PressureUnit.Pascal, quantity => new Pressure(quantity.Value * 9804.139432, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Microbar, PressureUnit.Pascal, quantity => new Pressure((quantity.Value * 1e5) * 1e-6d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Micropascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e-6d, PressureUnit.Pascal)); @@ -660,7 +663,7 @@ public static string GetAbbreviation(PressureUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static Pressure FromAtmospheres(QuantityValue atmospheres) { - double value = (double) atmospheres; + QuantityValue value = (QuantityValue) atmospheres; return new Pressure(value, PressureUnit.Atmosphere); } @@ -670,7 +673,7 @@ public static Pressure FromAtmospheres(QuantityValue atmospheres) /// If value is NaN or Infinity. public static Pressure FromBars(QuantityValue bars) { - double value = (double) bars; + QuantityValue value = (QuantityValue) bars; return new Pressure(value, PressureUnit.Bar); } @@ -680,7 +683,7 @@ public static Pressure FromBars(QuantityValue bars) /// If value is NaN or Infinity. public static Pressure FromCentibars(QuantityValue centibars) { - double value = (double) centibars; + QuantityValue value = (QuantityValue) centibars; return new Pressure(value, PressureUnit.Centibar); } @@ -690,7 +693,7 @@ public static Pressure FromCentibars(QuantityValue centibars) /// If value is NaN or Infinity. public static Pressure FromDecapascals(QuantityValue decapascals) { - double value = (double) decapascals; + QuantityValue value = (QuantityValue) decapascals; return new Pressure(value, PressureUnit.Decapascal); } @@ -700,7 +703,7 @@ public static Pressure FromDecapascals(QuantityValue decapascals) /// If value is NaN or Infinity. public static Pressure FromDecibars(QuantityValue decibars) { - double value = (double) decibars; + QuantityValue value = (QuantityValue) decibars; return new Pressure(value, PressureUnit.Decibar); } @@ -710,7 +713,7 @@ public static Pressure FromDecibars(QuantityValue decibars) /// If value is NaN or Infinity. public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquarecentimeter) { - double value = (double) dynespersquarecentimeter; + QuantityValue value = (QuantityValue) dynespersquarecentimeter; return new Pressure(value, PressureUnit.DynePerSquareCentimeter); } @@ -720,7 +723,7 @@ public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquare /// If value is NaN or Infinity. public static Pressure FromFeetOfElevation(QuantityValue feetofelevation) { - double value = (double) feetofelevation; + QuantityValue value = (QuantityValue) feetofelevation; return new Pressure(value, PressureUnit.FootOfElevation); } @@ -730,7 +733,7 @@ public static Pressure FromFeetOfElevation(QuantityValue feetofelevation) /// If value is NaN or Infinity. public static Pressure FromFeetOfHead(QuantityValue feetofhead) { - double value = (double) feetofhead; + QuantityValue value = (QuantityValue) feetofhead; return new Pressure(value, PressureUnit.FootOfHead); } @@ -740,7 +743,7 @@ public static Pressure FromFeetOfHead(QuantityValue feetofhead) /// If value is NaN or Infinity. public static Pressure FromGigapascals(QuantityValue gigapascals) { - double value = (double) gigapascals; + QuantityValue value = (QuantityValue) gigapascals; return new Pressure(value, PressureUnit.Gigapascal); } @@ -750,7 +753,7 @@ public static Pressure FromGigapascals(QuantityValue gigapascals) /// If value is NaN or Infinity. public static Pressure FromHectopascals(QuantityValue hectopascals) { - double value = (double) hectopascals; + QuantityValue value = (QuantityValue) hectopascals; return new Pressure(value, PressureUnit.Hectopascal); } @@ -760,7 +763,7 @@ public static Pressure FromHectopascals(QuantityValue hectopascals) /// If value is NaN or Infinity. public static Pressure FromInchesOfMercury(QuantityValue inchesofmercury) { - double value = (double) inchesofmercury; + QuantityValue value = (QuantityValue) inchesofmercury; return new Pressure(value, PressureUnit.InchOfMercury); } @@ -770,7 +773,7 @@ public static Pressure FromInchesOfMercury(QuantityValue inchesofmercury) /// If value is NaN or Infinity. public static Pressure FromInchesOfWaterColumn(QuantityValue inchesofwatercolumn) { - double value = (double) inchesofwatercolumn; + QuantityValue value = (QuantityValue) inchesofwatercolumn; return new Pressure(value, PressureUnit.InchOfWaterColumn); } @@ -780,7 +783,7 @@ public static Pressure FromInchesOfWaterColumn(QuantityValue inchesofwatercolumn /// If value is NaN or Infinity. public static Pressure FromKilobars(QuantityValue kilobars) { - double value = (double) kilobars; + QuantityValue value = (QuantityValue) kilobars; return new Pressure(value, PressureUnit.Kilobar); } @@ -790,7 +793,7 @@ public static Pressure FromKilobars(QuantityValue kilobars) /// If value is NaN or Infinity. public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue kilogramsforcepersquarecentimeter) { - double value = (double) kilogramsforcepersquarecentimeter; + QuantityValue value = (QuantityValue) kilogramsforcepersquarecentimeter; return new Pressure(value, PressureUnit.KilogramForcePerSquareCentimeter); } @@ -800,7 +803,7 @@ public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue kilog /// If value is NaN or Infinity. public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue kilogramsforcepersquaremeter) { - double value = (double) kilogramsforcepersquaremeter; + QuantityValue value = (QuantityValue) kilogramsforcepersquaremeter; return new Pressure(value, PressureUnit.KilogramForcePerSquareMeter); } @@ -810,7 +813,7 @@ public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue kilogramsf /// If value is NaN or Infinity. public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue kilogramsforcepersquaremillimeter) { - double value = (double) kilogramsforcepersquaremillimeter; + QuantityValue value = (QuantityValue) kilogramsforcepersquaremillimeter; return new Pressure(value, PressureUnit.KilogramForcePerSquareMillimeter); } @@ -820,7 +823,7 @@ public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue kilog /// If value is NaN or Infinity. public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue kilonewtonspersquarecentimeter) { - double value = (double) kilonewtonspersquarecentimeter; + QuantityValue value = (QuantityValue) kilonewtonspersquarecentimeter; return new Pressure(value, PressureUnit.KilonewtonPerSquareCentimeter); } @@ -830,7 +833,7 @@ public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue kilonewtonspersquaremeter) { - double value = (double) kilonewtonspersquaremeter; + QuantityValue value = (QuantityValue) kilonewtonspersquaremeter; return new Pressure(value, PressureUnit.KilonewtonPerSquareMeter); } @@ -840,7 +843,7 @@ public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue kilonewtonspe /// If value is NaN or Infinity. public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue kilonewtonspersquaremillimeter) { - double value = (double) kilonewtonspersquaremillimeter; + QuantityValue value = (QuantityValue) kilonewtonspersquaremillimeter; return new Pressure(value, PressureUnit.KilonewtonPerSquareMillimeter); } @@ -850,7 +853,7 @@ public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static Pressure FromKilopascals(QuantityValue kilopascals) { - double value = (double) kilopascals; + QuantityValue value = (QuantityValue) kilopascals; return new Pressure(value, PressureUnit.Kilopascal); } @@ -860,7 +863,7 @@ public static Pressure FromKilopascals(QuantityValue kilopascals) /// If value is NaN or Infinity. public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue kilopoundsforcepersquarefoot) { - double value = (double) kilopoundsforcepersquarefoot; + QuantityValue value = (QuantityValue) kilopoundsforcepersquarefoot; return new Pressure(value, PressureUnit.KilopoundForcePerSquareFoot); } @@ -870,7 +873,7 @@ public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue kilopounds /// If value is NaN or Infinity. public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue kilopoundsforcepersquareinch) { - double value = (double) kilopoundsforcepersquareinch; + QuantityValue value = (QuantityValue) kilopoundsforcepersquareinch; return new Pressure(value, PressureUnit.KilopoundForcePerSquareInch); } @@ -880,7 +883,7 @@ public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue kilopounds /// If value is NaN or Infinity. public static Pressure FromKilopoundsForcePerSquareMil(QuantityValue kilopoundsforcepersquaremil) { - double value = (double) kilopoundsforcepersquaremil; + QuantityValue value = (QuantityValue) kilopoundsforcepersquaremil; return new Pressure(value, PressureUnit.KilopoundForcePerSquareMil); } @@ -890,7 +893,7 @@ public static Pressure FromKilopoundsForcePerSquareMil(QuantityValue kilopoundsf /// If value is NaN or Infinity. public static Pressure FromMegabars(QuantityValue megabars) { - double value = (double) megabars; + QuantityValue value = (QuantityValue) megabars; return new Pressure(value, PressureUnit.Megabar); } @@ -900,7 +903,7 @@ public static Pressure FromMegabars(QuantityValue megabars) /// If value is NaN or Infinity. public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue meganewtonspersquaremeter) { - double value = (double) meganewtonspersquaremeter; + QuantityValue value = (QuantityValue) meganewtonspersquaremeter; return new Pressure(value, PressureUnit.MeganewtonPerSquareMeter); } @@ -910,7 +913,7 @@ public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue meganewtonspe /// If value is NaN or Infinity. public static Pressure FromMegapascals(QuantityValue megapascals) { - double value = (double) megapascals; + QuantityValue value = (QuantityValue) megapascals; return new Pressure(value, PressureUnit.Megapascal); } @@ -920,7 +923,7 @@ public static Pressure FromMegapascals(QuantityValue megapascals) /// If value is NaN or Infinity. public static Pressure FromMetersOfElevation(QuantityValue metersofelevation) { - double value = (double) metersofelevation; + QuantityValue value = (QuantityValue) metersofelevation; return new Pressure(value, PressureUnit.MeterOfElevation); } @@ -930,7 +933,7 @@ public static Pressure FromMetersOfElevation(QuantityValue metersofelevation) /// If value is NaN or Infinity. public static Pressure FromMetersOfHead(QuantityValue metersofhead) { - double value = (double) metersofhead; + QuantityValue value = (QuantityValue) metersofhead; return new Pressure(value, PressureUnit.MeterOfHead); } @@ -940,7 +943,7 @@ public static Pressure FromMetersOfHead(QuantityValue metersofhead) /// If value is NaN or Infinity. public static Pressure FromMicrobars(QuantityValue microbars) { - double value = (double) microbars; + QuantityValue value = (QuantityValue) microbars; return new Pressure(value, PressureUnit.Microbar); } @@ -950,7 +953,7 @@ public static Pressure FromMicrobars(QuantityValue microbars) /// If value is NaN or Infinity. public static Pressure FromMicropascals(QuantityValue micropascals) { - double value = (double) micropascals; + QuantityValue value = (QuantityValue) micropascals; return new Pressure(value, PressureUnit.Micropascal); } @@ -960,7 +963,7 @@ public static Pressure FromMicropascals(QuantityValue micropascals) /// If value is NaN or Infinity. public static Pressure FromMillibars(QuantityValue millibars) { - double value = (double) millibars; + QuantityValue value = (QuantityValue) millibars; return new Pressure(value, PressureUnit.Millibar); } @@ -970,7 +973,7 @@ public static Pressure FromMillibars(QuantityValue millibars) /// If value is NaN or Infinity. public static Pressure FromMillimetersOfMercury(QuantityValue millimetersofmercury) { - double value = (double) millimetersofmercury; + QuantityValue value = (QuantityValue) millimetersofmercury; return new Pressure(value, PressureUnit.MillimeterOfMercury); } @@ -980,7 +983,7 @@ public static Pressure FromMillimetersOfMercury(QuantityValue millimetersofmercu /// If value is NaN or Infinity. public static Pressure FromMillimeterOfWaterColumn(QuantityValue millimeterofwatercolumn) { - double value = (double) millimeterofwatercolumn; + QuantityValue value = (QuantityValue) millimeterofwatercolumn; return new Pressure(value, PressureUnit.MillimeterOfWaterColumn); } @@ -990,7 +993,7 @@ public static Pressure FromMillimeterOfWaterColumn(QuantityValue millimeterofwat /// If value is NaN or Infinity. public static Pressure FromMillipascals(QuantityValue millipascals) { - double value = (double) millipascals; + QuantityValue value = (QuantityValue) millipascals; return new Pressure(value, PressureUnit.Millipascal); } @@ -1000,7 +1003,7 @@ public static Pressure FromMillipascals(QuantityValue millipascals) /// If value is NaN or Infinity. public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue newtonspersquarecentimeter) { - double value = (double) newtonspersquarecentimeter; + QuantityValue value = (QuantityValue) newtonspersquarecentimeter; return new Pressure(value, PressureUnit.NewtonPerSquareCentimeter); } @@ -1010,7 +1013,7 @@ public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue newtonspersq /// If value is NaN or Infinity. public static Pressure FromNewtonsPerSquareMeter(QuantityValue newtonspersquaremeter) { - double value = (double) newtonspersquaremeter; + QuantityValue value = (QuantityValue) newtonspersquaremeter; return new Pressure(value, PressureUnit.NewtonPerSquareMeter); } @@ -1020,7 +1023,7 @@ public static Pressure FromNewtonsPerSquareMeter(QuantityValue newtonspersquarem /// If value is NaN or Infinity. public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue newtonspersquaremillimeter) { - double value = (double) newtonspersquaremillimeter; + QuantityValue value = (QuantityValue) newtonspersquaremillimeter; return new Pressure(value, PressureUnit.NewtonPerSquareMillimeter); } @@ -1030,7 +1033,7 @@ public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue newtonspersq /// If value is NaN or Infinity. public static Pressure FromPascals(QuantityValue pascals) { - double value = (double) pascals; + QuantityValue value = (QuantityValue) pascals; return new Pressure(value, PressureUnit.Pascal); } @@ -1040,7 +1043,7 @@ public static Pressure FromPascals(QuantityValue pascals) /// If value is NaN or Infinity. public static Pressure FromPoundsForcePerSquareFoot(QuantityValue poundsforcepersquarefoot) { - double value = (double) poundsforcepersquarefoot; + QuantityValue value = (QuantityValue) poundsforcepersquarefoot; return new Pressure(value, PressureUnit.PoundForcePerSquareFoot); } @@ -1050,7 +1053,7 @@ public static Pressure FromPoundsForcePerSquareFoot(QuantityValue poundsforceper /// If value is NaN or Infinity. public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforcepersquareinch) { - double value = (double) poundsforcepersquareinch; + QuantityValue value = (QuantityValue) poundsforcepersquareinch; return new Pressure(value, PressureUnit.PoundForcePerSquareInch); } @@ -1060,7 +1063,7 @@ public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforceper /// If value is NaN or Infinity. public static Pressure FromPoundsForcePerSquareMil(QuantityValue poundsforcepersquaremil) { - double value = (double) poundsforcepersquaremil; + QuantityValue value = (QuantityValue) poundsforcepersquaremil; return new Pressure(value, PressureUnit.PoundForcePerSquareMil); } @@ -1070,7 +1073,7 @@ public static Pressure FromPoundsForcePerSquareMil(QuantityValue poundsforcepers /// If value is NaN or Infinity. public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinchsecondsquared) { - double value = (double) poundsperinchsecondsquared; + QuantityValue value = (QuantityValue) poundsperinchsecondsquared; return new Pressure(value, PressureUnit.PoundPerInchSecondSquared); } @@ -1080,7 +1083,7 @@ public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinc /// If value is NaN or Infinity. public static Pressure FromTechnicalAtmospheres(QuantityValue technicalatmospheres) { - double value = (double) technicalatmospheres; + QuantityValue value = (QuantityValue) technicalatmospheres; return new Pressure(value, PressureUnit.TechnicalAtmosphere); } @@ -1090,7 +1093,7 @@ public static Pressure FromTechnicalAtmospheres(QuantityValue technicalatmospher /// If value is NaN or Infinity. public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue tonnesforcepersquarecentimeter) { - double value = (double) tonnesforcepersquarecentimeter; + QuantityValue value = (QuantityValue) tonnesforcepersquarecentimeter; return new Pressure(value, PressureUnit.TonneForcePerSquareCentimeter); } @@ -1100,7 +1103,7 @@ public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static Pressure FromTonnesForcePerSquareMeter(QuantityValue tonnesforcepersquaremeter) { - double value = (double) tonnesforcepersquaremeter; + QuantityValue value = (QuantityValue) tonnesforcepersquaremeter; return new Pressure(value, PressureUnit.TonneForcePerSquareMeter); } @@ -1110,7 +1113,7 @@ public static Pressure FromTonnesForcePerSquareMeter(QuantityValue tonnesforcepe /// If value is NaN or Infinity. public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue tonnesforcepersquaremillimeter) { - double value = (double) tonnesforcepersquaremillimeter; + QuantityValue value = (QuantityValue) tonnesforcepersquaremillimeter; return new Pressure(value, PressureUnit.TonneForcePerSquareMillimeter); } @@ -1120,7 +1123,7 @@ public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static Pressure FromTorrs(QuantityValue torrs) { - double value = (double) torrs; + QuantityValue value = (QuantityValue) torrs; return new Pressure(value, PressureUnit.Torr); } @@ -1132,7 +1135,7 @@ public static Pressure FromTorrs(QuantityValue torrs) /// Pressure unit value. public static Pressure From(QuantityValue value, PressureUnit fromUnit) { - return new Pressure((double)value, fromUnit); + return new Pressure((QuantityValue)value, fromUnit); } #endregion @@ -1302,25 +1305,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press } /// Get from multiplying value and . - public static Pressure operator *(double left, Pressure right) + public static Pressure operator *(QuantityValue left, Pressure right) { return new Pressure(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Pressure operator *(Pressure left, double right) + public static Pressure operator *(Pressure left, QuantityValue right) { return new Pressure(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Pressure operator /(Pressure left, double right) + public static Pressure operator /(Pressure left, QuantityValue right) { return new Pressure(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Pressure left, Pressure right) + public static QuantityValue operator /(Pressure left, Pressure right) { return left.Pascals / right.Pascals; } @@ -1353,6 +1356,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Pressure left, Pressure right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Pressure left, Pressure right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1365,7 +1381,29 @@ public int CompareTo(object obj) /// public int CompareTo(Pressure other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Pressure objPressure)) + return false; + return Equals(objPressure); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Pressure other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1408,13 +1446,13 @@ public int CompareTo(Pressure other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType) + public bool Equals(Pressure other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1425,7 +1463,7 @@ public bool Equals(Pressure other, double tolerance, ComparisonType comparisonTy /// A hash code for the current Pressure. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1436,17 +1474,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureUnit unit) + public QuantityValue As(PressureUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1461,12 +1498,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PressureUnit unitAsPressureUnit)) + if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return As(unitAsPressureUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1498,7 +1535,7 @@ public Pressure ToUnit(PressureUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Pressure)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PressureUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1506,17 +1543,17 @@ public Pressure ToUnit(PressureUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureUnit unitAsPressureUnit)) + if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPressureUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1543,10 +1580,10 @@ public Pressure ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PressureUnit unit) + private QuantityValue GetValueAs(PressureUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 7ee7d7f344..06d14aeaa6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). /// [DataContract] - public partial struct PressureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct PressureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static PressureChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PressureChangeRate(double value, PressureChangeRateUnit unit) + public PressureChangeRate(QuantityValue value, PressureChangeRateUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -99,14 +99,14 @@ public PressureChangeRate(double value, PressureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PressureChangeRate(double value, UnitSystem unitSystem) + public PressureChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,7 +147,10 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -170,74 +173,74 @@ public PressureChangeRate(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); + public QuantityValue AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); + public QuantityValue KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); + public QuantityValue KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); + public QuantityValue KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); + public QuantityValue KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); + public QuantityValue MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); + public QuantityValue MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); + public QuantityValue MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); + public QuantityValue MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersOfMercuryPerSecond => As(PressureChangeRateUnit.MillimeterOfMercuryPerSecond); + public QuantityValue MillimetersOfMercuryPerSecond => As(PressureChangeRateUnit.MillimeterOfMercuryPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); + public QuantityValue PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); + public QuantityValue PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); + public QuantityValue PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); + public QuantityValue PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); #endregion @@ -346,7 +349,7 @@ public static string GetAbbreviation(PressureChangeRateUnit unit, IFormatProvide /// If value is NaN or Infinity. public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue atmospherespersecond) { - double value = (double) atmospherespersecond; + QuantityValue value = (QuantityValue) atmospherespersecond; return new PressureChangeRate(value, PressureChangeRateUnit.AtmospherePerSecond); } @@ -356,7 +359,7 @@ public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue atmosphe /// If value is NaN or Infinity. public static PressureChangeRate FromKilopascalsPerMinute(QuantityValue kilopascalsperminute) { - double value = (double) kilopascalsperminute; + QuantityValue value = (QuantityValue) kilopascalsperminute; return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerMinute); } @@ -366,7 +369,7 @@ public static PressureChangeRate FromKilopascalsPerMinute(QuantityValue kilopasc /// If value is NaN or Infinity. public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue kilopascalspersecond) { - double value = (double) kilopascalspersecond; + QuantityValue value = (QuantityValue) kilopascalspersecond; return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerSecond); } @@ -376,7 +379,7 @@ public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue kilopasc /// If value is NaN or Infinity. public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(QuantityValue kilopoundsforcepersquareinchperminute) { - double value = (double) kilopoundsforcepersquareinchperminute; + QuantityValue value = (QuantityValue) kilopoundsforcepersquareinchperminute; return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); } @@ -386,7 +389,7 @@ public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(QuantityValue kilopoundsforcepersquareinchpersecond) { - double value = (double) kilopoundsforcepersquareinchpersecond; + QuantityValue value = (QuantityValue) kilopoundsforcepersquareinchpersecond; return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); } @@ -396,7 +399,7 @@ public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromMegapascalsPerMinute(QuantityValue megapascalsperminute) { - double value = (double) megapascalsperminute; + QuantityValue value = (QuantityValue) megapascalsperminute; return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerMinute); } @@ -406,7 +409,7 @@ public static PressureChangeRate FromMegapascalsPerMinute(QuantityValue megapasc /// If value is NaN or Infinity. public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue megapascalspersecond) { - double value = (double) megapascalspersecond; + QuantityValue value = (QuantityValue) megapascalspersecond; return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerSecond); } @@ -416,7 +419,7 @@ public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue megapasc /// If value is NaN or Infinity. public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(QuantityValue megapoundsforcepersquareinchperminute) { - double value = (double) megapoundsforcepersquareinchperminute; + QuantityValue value = (QuantityValue) megapoundsforcepersquareinchperminute; return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); } @@ -426,7 +429,7 @@ public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(QuantityValue megapoundsforcepersquareinchpersecond) { - double value = (double) megapoundsforcepersquareinchpersecond; + QuantityValue value = (QuantityValue) megapoundsforcepersquareinchpersecond; return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); } @@ -436,7 +439,7 @@ public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromMillimetersOfMercuryPerSecond(QuantityValue millimetersofmercurypersecond) { - double value = (double) millimetersofmercurypersecond; + QuantityValue value = (QuantityValue) millimetersofmercurypersecond; return new PressureChangeRate(value, PressureChangeRateUnit.MillimeterOfMercuryPerSecond); } @@ -446,7 +449,7 @@ public static PressureChangeRate FromMillimetersOfMercuryPerSecond(QuantityValue /// If value is NaN or Infinity. public static PressureChangeRate FromPascalsPerMinute(QuantityValue pascalsperminute) { - double value = (double) pascalsperminute; + QuantityValue value = (QuantityValue) pascalsperminute; return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerMinute); } @@ -456,7 +459,7 @@ public static PressureChangeRate FromPascalsPerMinute(QuantityValue pascalspermi /// If value is NaN or Infinity. public static PressureChangeRate FromPascalsPerSecond(QuantityValue pascalspersecond) { - double value = (double) pascalspersecond; + QuantityValue value = (QuantityValue) pascalspersecond; return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerSecond); } @@ -466,7 +469,7 @@ public static PressureChangeRate FromPascalsPerSecond(QuantityValue pascalsperse /// If value is NaN or Infinity. public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(QuantityValue poundsforcepersquareinchperminute) { - double value = (double) poundsforcepersquareinchperminute; + QuantityValue value = (QuantityValue) poundsforcepersquareinchperminute; return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); } @@ -476,7 +479,7 @@ public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(QuantityV /// If value is NaN or Infinity. public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(QuantityValue poundsforcepersquareinchpersecond) { - double value = (double) poundsforcepersquareinchpersecond; + QuantityValue value = (QuantityValue) poundsforcepersquareinchpersecond; return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); } @@ -488,7 +491,7 @@ public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(QuantityV /// PressureChangeRate unit value. public static PressureChangeRate From(QuantityValue value, PressureChangeRateUnit fromUnit) { - return new PressureChangeRate((double)value, fromUnit); + return new PressureChangeRate((QuantityValue)value, fromUnit); } #endregion @@ -658,25 +661,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press } /// Get from multiplying value and . - public static PressureChangeRate operator *(double left, PressureChangeRate right) + public static PressureChangeRate operator *(QuantityValue left, PressureChangeRate right) { return new PressureChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PressureChangeRate operator *(PressureChangeRate left, double right) + public static PressureChangeRate operator *(PressureChangeRate left, QuantityValue right) { return new PressureChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PressureChangeRate operator /(PressureChangeRate left, double right) + public static PressureChangeRate operator /(PressureChangeRate left, QuantityValue right) { return new PressureChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(PressureChangeRate left, PressureChangeRate right) + public static QuantityValue operator /(PressureChangeRate left, PressureChangeRate right) { return left.PascalsPerSecond / right.PascalsPerSecond; } @@ -709,6 +712,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(PressureChangeRate left, PressureChangeRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(PressureChangeRate left, PressureChangeRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -721,7 +737,29 @@ public int CompareTo(object obj) /// public int CompareTo(PressureChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is PressureChangeRate objPressureChangeRate)) + return false; + return Equals(objPressureChangeRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(PressureChangeRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -764,13 +802,13 @@ public int CompareTo(PressureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(PressureChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -781,7 +819,7 @@ public bool Equals(PressureChangeRate other, double tolerance, ComparisonType co /// A hash code for the current PressureChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -792,17 +830,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PressureChangeRateUnit unit) + public QuantityValue As(PressureChangeRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -817,12 +854,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) + if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsPressureChangeRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -854,7 +891,7 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit, UnitConverter unit var converted = conversionFunction(this); return (PressureChangeRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(PressureChangeRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -862,17 +899,17 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) + if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPressureChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -899,10 +936,10 @@ public PressureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(PressureChangeRateUnit unit) + private QuantityValue GetValueAs(PressureChangeRateUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 4477fbdf39..5cd1baf2d0 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). /// [DataContract] - public partial struct Ratio : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Ratio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static Ratio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Ratio(double value, RatioUnit unit) + public Ratio(QuantityValue value, RatioUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public Ratio(double value, RatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Ratio(double value, UnitSystem unitSystem) + public Ratio(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public Ratio(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,34 +165,34 @@ public Ratio(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimalFractions => As(RatioUnit.DecimalFraction); + public QuantityValue DecimalFractions => As(RatioUnit.DecimalFraction); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerBillion => As(RatioUnit.PartPerBillion); + public QuantityValue PartsPerBillion => As(RatioUnit.PartPerBillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerMillion => As(RatioUnit.PartPerMillion); + public QuantityValue PartsPerMillion => As(RatioUnit.PartPerMillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerThousand => As(RatioUnit.PartPerThousand); + public QuantityValue PartsPerThousand => As(RatioUnit.PartPerThousand); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerTrillion => As(RatioUnit.PartPerTrillion); + public QuantityValue PartsPerTrillion => As(RatioUnit.PartPerTrillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Percent => As(RatioUnit.Percent); + public QuantityValue Percent => As(RatioUnit.Percent); #endregion @@ -260,7 +263,7 @@ public static string GetAbbreviation(RatioUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Ratio FromDecimalFractions(QuantityValue decimalfractions) { - double value = (double) decimalfractions; + QuantityValue value = (QuantityValue) decimalfractions; return new Ratio(value, RatioUnit.DecimalFraction); } @@ -270,7 +273,7 @@ public static Ratio FromDecimalFractions(QuantityValue decimalfractions) /// If value is NaN or Infinity. public static Ratio FromPartsPerBillion(QuantityValue partsperbillion) { - double value = (double) partsperbillion; + QuantityValue value = (QuantityValue) partsperbillion; return new Ratio(value, RatioUnit.PartPerBillion); } @@ -280,7 +283,7 @@ public static Ratio FromPartsPerBillion(QuantityValue partsperbillion) /// If value is NaN or Infinity. public static Ratio FromPartsPerMillion(QuantityValue partspermillion) { - double value = (double) partspermillion; + QuantityValue value = (QuantityValue) partspermillion; return new Ratio(value, RatioUnit.PartPerMillion); } @@ -290,7 +293,7 @@ public static Ratio FromPartsPerMillion(QuantityValue partspermillion) /// If value is NaN or Infinity. public static Ratio FromPartsPerThousand(QuantityValue partsperthousand) { - double value = (double) partsperthousand; + QuantityValue value = (QuantityValue) partsperthousand; return new Ratio(value, RatioUnit.PartPerThousand); } @@ -300,7 +303,7 @@ public static Ratio FromPartsPerThousand(QuantityValue partsperthousand) /// If value is NaN or Infinity. public static Ratio FromPartsPerTrillion(QuantityValue partspertrillion) { - double value = (double) partspertrillion; + QuantityValue value = (QuantityValue) partspertrillion; return new Ratio(value, RatioUnit.PartPerTrillion); } @@ -310,7 +313,7 @@ public static Ratio FromPartsPerTrillion(QuantityValue partspertrillion) /// If value is NaN or Infinity. public static Ratio FromPercent(QuantityValue percent) { - double value = (double) percent; + QuantityValue value = (QuantityValue) percent; return new Ratio(value, RatioUnit.Percent); } @@ -322,7 +325,7 @@ public static Ratio FromPercent(QuantityValue percent) /// Ratio unit value. public static Ratio From(QuantityValue value, RatioUnit fromUnit) { - return new Ratio((double)value, fromUnit); + return new Ratio((QuantityValue)value, fromUnit); } #endregion @@ -492,25 +495,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio } /// Get from multiplying value and . - public static Ratio operator *(double left, Ratio right) + public static Ratio operator *(QuantityValue left, Ratio right) { return new Ratio(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Ratio operator *(Ratio left, double right) + public static Ratio operator *(Ratio left, QuantityValue right) { return new Ratio(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Ratio operator /(Ratio left, double right) + public static Ratio operator /(Ratio left, QuantityValue right) { return new Ratio(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Ratio left, Ratio right) + public static QuantityValue operator /(Ratio left, Ratio right) { return left.DecimalFractions / right.DecimalFractions; } @@ -543,6 +546,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Ratio left, Ratio right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Ratio left, Ratio right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -555,7 +571,29 @@ public int CompareTo(object obj) /// public int CompareTo(Ratio other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Ratio objRatio)) + return false; + return Equals(objRatio); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Ratio other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -598,13 +636,13 @@ public int CompareTo(Ratio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) + public bool Equals(Ratio other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +653,7 @@ public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Ratio. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -626,17 +664,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioUnit unit) + public QuantityValue As(RatioUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -651,12 +688,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RatioUnit unitAsRatioUnit)) + if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return As(unitAsRatioUnit); + return (QuantityValue)As(typedUnit); } /// @@ -688,7 +725,7 @@ public Ratio ToUnit(RatioUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Ratio)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RatioUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -696,17 +733,17 @@ public Ratio ToUnit(RatioUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioUnit unitAsRatioUnit)) + if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -733,10 +770,10 @@ public Ratio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RatioUnit unit) + private QuantityValue GetValueAs(RatioUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 9a19832e06..55d191ea6c 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The change in ratio per unit of time. /// [DataContract] - public partial struct RatioChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct RatioChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static RatioChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RatioChangeRate(double value, RatioChangeRateUnit unit) + public RatioChangeRate(QuantityValue value, RatioChangeRateUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -87,14 +87,14 @@ public RatioChangeRate(double value, RatioChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RatioChangeRate(double value, UnitSystem unitSystem) + public RatioChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,7 +135,10 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -158,14 +161,14 @@ public RatioChangeRate(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); + public QuantityValue DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); + public QuantityValue PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); #endregion @@ -224,7 +227,7 @@ public static string GetAbbreviation(RatioChangeRateUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static RatioChangeRate FromDecimalFractionsPerSecond(QuantityValue decimalfractionspersecond) { - double value = (double) decimalfractionspersecond; + QuantityValue value = (QuantityValue) decimalfractionspersecond; return new RatioChangeRate(value, RatioChangeRateUnit.DecimalFractionPerSecond); } @@ -234,7 +237,7 @@ public static RatioChangeRate FromDecimalFractionsPerSecond(QuantityValue decima /// If value is NaN or Infinity. public static RatioChangeRate FromPercentsPerSecond(QuantityValue percentspersecond) { - double value = (double) percentspersecond; + QuantityValue value = (QuantityValue) percentspersecond; return new RatioChangeRate(value, RatioChangeRateUnit.PercentPerSecond); } @@ -246,7 +249,7 @@ public static RatioChangeRate FromPercentsPerSecond(QuantityValue percentspersec /// RatioChangeRate unit value. public static RatioChangeRate From(QuantityValue value, RatioChangeRateUnit fromUnit) { - return new RatioChangeRate((double)value, fromUnit); + return new RatioChangeRate((QuantityValue)value, fromUnit); } #endregion @@ -416,25 +419,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio } /// Get from multiplying value and . - public static RatioChangeRate operator *(double left, RatioChangeRate right) + public static RatioChangeRate operator *(QuantityValue left, RatioChangeRate right) { return new RatioChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RatioChangeRate operator *(RatioChangeRate left, double right) + public static RatioChangeRate operator *(RatioChangeRate left, QuantityValue right) { return new RatioChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RatioChangeRate operator /(RatioChangeRate left, double right) + public static RatioChangeRate operator /(RatioChangeRate left, QuantityValue right) { return new RatioChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RatioChangeRate left, RatioChangeRate right) + public static QuantityValue operator /(RatioChangeRate left, RatioChangeRate right) { return left.DecimalFractionsPerSecond / right.DecimalFractionsPerSecond; } @@ -467,6 +470,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(RatioChangeRate left, RatioChangeRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(RatioChangeRate left, RatioChangeRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -479,7 +495,29 @@ public int CompareTo(object obj) /// public int CompareTo(RatioChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is RatioChangeRate objRatioChangeRate)) + return false; + return Equals(objRatioChangeRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(RatioChangeRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -522,13 +560,13 @@ public int CompareTo(RatioChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RatioChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(RatioChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -539,7 +577,7 @@ public bool Equals(RatioChangeRate other, double tolerance, ComparisonType compa /// A hash code for the current RatioChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -550,17 +588,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RatioChangeRateUnit unit) + public QuantityValue As(RatioChangeRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -575,12 +612,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) + if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsRatioChangeRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -612,7 +649,7 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (RatioChangeRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RatioChangeRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -620,17 +657,17 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) + if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRatioChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -657,10 +694,10 @@ public RatioChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RatioChangeRateUnit unit) + private QuantityValue GetValueAs(RatioChangeRateUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index b46c2e5303..bcb82d37ff 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. /// [DataContract] - public partial struct ReactiveEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactiveEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static ReactiveEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReactiveEnergy(double value, ReactiveEnergyUnit unit) + public ReactiveEnergy(QuantityValue value, ReactiveEnergyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public ReactiveEnergy(double value, ReactiveEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactiveEnergy(double value, UnitSystem unitSystem) + public ReactiveEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); + public QuantityValue KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); + public QuantityValue MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); + public QuantityValue VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(ReactiveEnergyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue kilovoltamperereactivehours) { - double value = (double) kilovoltamperereactivehours; + QuantityValue value = (QuantityValue) kilovoltamperereactivehours; return new ReactiveEnergy(value, ReactiveEnergyUnit.KilovoltampereReactiveHour); } @@ -243,7 +246,7 @@ public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue kilov /// If value is NaN or Infinity. public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue megavoltamperereactivehours) { - double value = (double) megavoltamperereactivehours; + QuantityValue value = (QuantityValue) megavoltamperereactivehours; return new ReactiveEnergy(value, ReactiveEnergyUnit.MegavoltampereReactiveHour); } @@ -253,7 +256,7 @@ public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue megav /// If value is NaN or Infinity. public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue voltamperereactivehours) { - double value = (double) voltamperereactivehours; + QuantityValue value = (QuantityValue) voltamperereactivehours; return new ReactiveEnergy(value, ReactiveEnergyUnit.VoltampereReactiveHour); } @@ -265,7 +268,7 @@ public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue voltamper /// ReactiveEnergy unit value. public static ReactiveEnergy From(QuantityValue value, ReactiveEnergyUnit fromUnit) { - return new ReactiveEnergy((double)value, fromUnit); + return new ReactiveEnergy((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React } /// Get from multiplying value and . - public static ReactiveEnergy operator *(double left, ReactiveEnergy right) + public static ReactiveEnergy operator *(QuantityValue left, ReactiveEnergy right) { return new ReactiveEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReactiveEnergy operator *(ReactiveEnergy left, double right) + public static ReactiveEnergy operator *(ReactiveEnergy left, QuantityValue right) { return new ReactiveEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReactiveEnergy operator /(ReactiveEnergy left, double right) + public static ReactiveEnergy operator /(ReactiveEnergy left, QuantityValue right) { return new ReactiveEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReactiveEnergy left, ReactiveEnergy right) + public static QuantityValue operator /(ReactiveEnergy left, ReactiveEnergy right) { return left.VoltampereReactiveHours / right.VoltampereReactiveHours; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(ReactiveEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) + return false; + return Equals(objReactiveEnergy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ReactiveEnergy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(ReactiveEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(ReactiveEnergy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType compar /// A hash code for the current ReactiveEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactiveEnergyUnit unit) + public QuantityValue As(ReactiveEnergyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) + if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsReactiveEnergyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ReactiveEnergy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ReactiveEnergyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) + if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReactiveEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public ReactiveEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ReactiveEnergyUnit unit) + private QuantityValue GetValueAs(ReactiveEnergyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 12ba60dcba..0a4d9cb603 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. /// [DataContract] - public partial struct ReactivePower : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactivePower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ReactivePower() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReactivePower(double value, ReactivePowerUnit unit) + public ReactivePower(QuantityValue value, ReactivePowerUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public ReactivePower(double value, ReactivePowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactivePower(double value, UnitSystem unitSystem) + public ReactivePower(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public ReactivePower(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public ReactivePower(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); + public QuantityValue GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); + public QuantityValue KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); + public QuantityValue MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); + public QuantityValue VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(ReactivePowerUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static ReactivePower FromGigavoltamperesReactive(QuantityValue gigavoltamperesreactive) { - double value = (double) gigavoltamperesreactive; + QuantityValue value = (QuantityValue) gigavoltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.GigavoltampereReactive); } @@ -252,7 +255,7 @@ public static ReactivePower FromGigavoltamperesReactive(QuantityValue gigavoltam /// If value is NaN or Infinity. public static ReactivePower FromKilovoltamperesReactive(QuantityValue kilovoltamperesreactive) { - double value = (double) kilovoltamperesreactive; + QuantityValue value = (QuantityValue) kilovoltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.KilovoltampereReactive); } @@ -262,7 +265,7 @@ public static ReactivePower FromKilovoltamperesReactive(QuantityValue kilovoltam /// If value is NaN or Infinity. public static ReactivePower FromMegavoltamperesReactive(QuantityValue megavoltamperesreactive) { - double value = (double) megavoltamperesreactive; + QuantityValue value = (QuantityValue) megavoltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.MegavoltampereReactive); } @@ -272,7 +275,7 @@ public static ReactivePower FromMegavoltamperesReactive(QuantityValue megavoltam /// If value is NaN or Infinity. public static ReactivePower FromVoltamperesReactive(QuantityValue voltamperesreactive) { - double value = (double) voltamperesreactive; + QuantityValue value = (QuantityValue) voltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.VoltampereReactive); } @@ -284,7 +287,7 @@ public static ReactivePower FromVoltamperesReactive(QuantityValue voltamperesrea /// ReactivePower unit value. public static ReactivePower From(QuantityValue value, ReactivePowerUnit fromUnit) { - return new ReactivePower((double)value, fromUnit); + return new ReactivePower((QuantityValue)value, fromUnit); } #endregion @@ -454,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React } /// Get from multiplying value and . - public static ReactivePower operator *(double left, ReactivePower right) + public static ReactivePower operator *(QuantityValue left, ReactivePower right) { return new ReactivePower(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReactivePower operator *(ReactivePower left, double right) + public static ReactivePower operator *(ReactivePower left, QuantityValue right) { return new ReactivePower(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReactivePower operator /(ReactivePower left, double right) + public static ReactivePower operator /(ReactivePower left, QuantityValue right) { return new ReactivePower(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReactivePower left, ReactivePower right) + public static QuantityValue operator /(ReactivePower left, ReactivePower right) { return left.VoltamperesReactive / right.VoltamperesReactive; } @@ -505,6 +508,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ReactivePower left, ReactivePower right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ReactivePower left, ReactivePower right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -517,7 +533,29 @@ public int CompareTo(object obj) /// public int CompareTo(ReactivePower other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ReactivePower objReactivePower)) + return false; + return Equals(objReactivePower); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ReactivePower other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -560,13 +598,13 @@ public int CompareTo(ReactivePower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType) + public bool Equals(ReactivePower other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +615,7 @@ public bool Equals(ReactivePower other, double tolerance, ComparisonType compari /// A hash code for the current ReactivePower. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -588,17 +626,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReactivePowerUnit unit) + public QuantityValue As(ReactivePowerUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,12 +650,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) + if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return As(unitAsReactivePowerUnit); + return (QuantityValue)As(typedUnit); } /// @@ -650,7 +687,7 @@ public ReactivePower ToUnit(ReactivePowerUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (ReactivePower)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ReactivePowerUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -658,17 +695,17 @@ public ReactivePower ToUnit(ReactivePowerUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) + if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReactivePowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -695,10 +732,10 @@ public ReactivePower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ReactivePowerUnit unit) + private QuantityValue GetValueAs(ReactivePowerUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index fa18c54017..f0756bf8c4 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inverse-square_law /// [DataContract] - public partial struct ReciprocalArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static ReciprocalArea() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReciprocalArea(double value, ReciprocalAreaUnit unit) + public ReciprocalArea(QuantityValue value, ReciprocalAreaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -99,14 +99,14 @@ public ReciprocalArea(double value, ReciprocalAreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReciprocalArea(double value, UnitSystem unitSystem) + public ReciprocalArea(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,7 +147,10 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -170,59 +173,59 @@ public ReciprocalArea(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); + public QuantityValue InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); + public QuantityValue InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); + public QuantityValue InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); + public QuantityValue InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); + public QuantityValue InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); + public QuantityValue InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); + public QuantityValue InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); + public QuantityValue InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); + public QuantityValue InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); + public QuantityValue InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); + public QuantityValue InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); #endregion @@ -308,7 +311,7 @@ public static string GetAbbreviation(ReciprocalAreaUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareCentimeters(QuantityValue inversesquarecentimeters) { - double value = (double) inversesquarecentimeters; + QuantityValue value = (QuantityValue) inversesquarecentimeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareCentimeter); } @@ -318,7 +321,7 @@ public static ReciprocalArea FromInverseSquareCentimeters(QuantityValue inverses /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareDecimeters(QuantityValue inversesquaredecimeters) { - double value = (double) inversesquaredecimeters; + QuantityValue value = (QuantityValue) inversesquaredecimeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareDecimeter); } @@ -328,7 +331,7 @@ public static ReciprocalArea FromInverseSquareDecimeters(QuantityValue inversesq /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareFeet(QuantityValue inversesquarefeet) { - double value = (double) inversesquarefeet; + QuantityValue value = (QuantityValue) inversesquarefeet; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareFoot); } @@ -338,7 +341,7 @@ public static ReciprocalArea FromInverseSquareFeet(QuantityValue inversesquarefe /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareInches(QuantityValue inversesquareinches) { - double value = (double) inversesquareinches; + QuantityValue value = (QuantityValue) inversesquareinches; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareInch); } @@ -348,7 +351,7 @@ public static ReciprocalArea FromInverseSquareInches(QuantityValue inversesquare /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareKilometers(QuantityValue inversesquarekilometers) { - double value = (double) inversesquarekilometers; + QuantityValue value = (QuantityValue) inversesquarekilometers; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareKilometer); } @@ -358,7 +361,7 @@ public static ReciprocalArea FromInverseSquareKilometers(QuantityValue inversesq /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMeters(QuantityValue inversesquaremeters) { - double value = (double) inversesquaremeters; + QuantityValue value = (QuantityValue) inversesquaremeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMeter); } @@ -368,7 +371,7 @@ public static ReciprocalArea FromInverseSquareMeters(QuantityValue inversesquare /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMicrometers(QuantityValue inversesquaremicrometers) { - double value = (double) inversesquaremicrometers; + QuantityValue value = (QuantityValue) inversesquaremicrometers; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMicrometer); } @@ -378,7 +381,7 @@ public static ReciprocalArea FromInverseSquareMicrometers(QuantityValue inverses /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMiles(QuantityValue inversesquaremiles) { - double value = (double) inversesquaremiles; + QuantityValue value = (QuantityValue) inversesquaremiles; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMile); } @@ -388,7 +391,7 @@ public static ReciprocalArea FromInverseSquareMiles(QuantityValue inversesquarem /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMillimeters(QuantityValue inversesquaremillimeters) { - double value = (double) inversesquaremillimeters; + QuantityValue value = (QuantityValue) inversesquaremillimeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMillimeter); } @@ -398,7 +401,7 @@ public static ReciprocalArea FromInverseSquareMillimeters(QuantityValue inverses /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareYards(QuantityValue inversesquareyards) { - double value = (double) inversesquareyards; + QuantityValue value = (QuantityValue) inversesquareyards; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareYard); } @@ -408,7 +411,7 @@ public static ReciprocalArea FromInverseSquareYards(QuantityValue inversesquarey /// If value is NaN or Infinity. public static ReciprocalArea FromInverseUsSurveySquareFeet(QuantityValue inverseussurveysquarefeet) { - double value = (double) inverseussurveysquarefeet; + QuantityValue value = (QuantityValue) inverseussurveysquarefeet; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseUsSurveySquareFoot); } @@ -420,7 +423,7 @@ public static ReciprocalArea FromInverseUsSurveySquareFeet(QuantityValue inverse /// ReciprocalArea unit value. public static ReciprocalArea From(QuantityValue value, ReciprocalAreaUnit fromUnit) { - return new ReciprocalArea((double)value, fromUnit); + return new ReciprocalArea((QuantityValue)value, fromUnit); } #endregion @@ -590,25 +593,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip } /// Get from multiplying value and . - public static ReciprocalArea operator *(double left, ReciprocalArea right) + public static ReciprocalArea operator *(QuantityValue left, ReciprocalArea right) { return new ReciprocalArea(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReciprocalArea operator *(ReciprocalArea left, double right) + public static ReciprocalArea operator *(ReciprocalArea left, QuantityValue right) { return new ReciprocalArea(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReciprocalArea operator /(ReciprocalArea left, double right) + public static ReciprocalArea operator /(ReciprocalArea left, QuantityValue right) { return new ReciprocalArea(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReciprocalArea left, ReciprocalArea right) + public static QuantityValue operator /(ReciprocalArea left, ReciprocalArea right) { return left.InverseSquareMeters / right.InverseSquareMeters; } @@ -641,6 +644,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ReciprocalArea left, ReciprocalArea right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ReciprocalArea left, ReciprocalArea right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -653,7 +669,29 @@ public int CompareTo(object obj) /// public int CompareTo(ReciprocalArea other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ReciprocalArea objReciprocalArea)) + return false; + return Equals(objReciprocalArea); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ReciprocalArea other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -696,13 +734,13 @@ public int CompareTo(ReciprocalArea other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReciprocalArea other, double tolerance, ComparisonType comparisonType) + public bool Equals(ReciprocalArea other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -713,7 +751,7 @@ public bool Equals(ReciprocalArea other, double tolerance, ComparisonType compar /// A hash code for the current ReciprocalArea. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -724,17 +762,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReciprocalAreaUnit unit) + public QuantityValue As(ReciprocalAreaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -749,12 +786,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) + if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return As(unitAsReciprocalAreaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -786,7 +823,7 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ReciprocalArea)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ReciprocalAreaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -794,17 +831,17 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) + if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReciprocalAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -831,10 +868,10 @@ public ReciprocalArea ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ReciprocalAreaUnit unit) + private QuantityValue GetValueAs(ReciprocalAreaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index db5125af45..80d8b7d8e3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Reciprocal_length /// [DataContract] - public partial struct ReciprocalLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,9 +84,9 @@ static ReciprocalLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReciprocalLength(double value, ReciprocalLengthUnit unit) + public ReciprocalLength(QuantityValue value, ReciprocalLengthUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -98,14 +98,14 @@ public ReciprocalLength(double value, ReciprocalLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReciprocalLength(double value, UnitSystem unitSystem) + public ReciprocalLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -146,7 +146,10 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -169,54 +172,54 @@ public ReciprocalLength(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); + public QuantityValue InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseFeet => As(ReciprocalLengthUnit.InverseFoot); + public QuantityValue InverseFeet => As(ReciprocalLengthUnit.InverseFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseInches => As(ReciprocalLengthUnit.InverseInch); + public QuantityValue InverseInches => As(ReciprocalLengthUnit.InverseInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMeters => As(ReciprocalLengthUnit.InverseMeter); + public QuantityValue InverseMeters => As(ReciprocalLengthUnit.InverseMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); + public QuantityValue InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMils => As(ReciprocalLengthUnit.InverseMil); + public QuantityValue InverseMils => As(ReciprocalLengthUnit.InverseMil); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMiles => As(ReciprocalLengthUnit.InverseMile); + public QuantityValue InverseMiles => As(ReciprocalLengthUnit.InverseMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); + public QuantityValue InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); + public QuantityValue InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InverseYards => As(ReciprocalLengthUnit.InverseYard); + public QuantityValue InverseYards => As(ReciprocalLengthUnit.InverseYard); #endregion @@ -299,7 +302,7 @@ public static string GetAbbreviation(ReciprocalLengthUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static ReciprocalLength FromInverseCentimeters(QuantityValue inversecentimeters) { - double value = (double) inversecentimeters; + QuantityValue value = (QuantityValue) inversecentimeters; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseCentimeter); } @@ -309,7 +312,7 @@ public static ReciprocalLength FromInverseCentimeters(QuantityValue inversecenti /// If value is NaN or Infinity. public static ReciprocalLength FromInverseFeet(QuantityValue inversefeet) { - double value = (double) inversefeet; + QuantityValue value = (QuantityValue) inversefeet; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseFoot); } @@ -319,7 +322,7 @@ public static ReciprocalLength FromInverseFeet(QuantityValue inversefeet) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseInches(QuantityValue inverseinches) { - double value = (double) inverseinches; + QuantityValue value = (QuantityValue) inverseinches; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseInch); } @@ -329,7 +332,7 @@ public static ReciprocalLength FromInverseInches(QuantityValue inverseinches) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMeters(QuantityValue inversemeters) { - double value = (double) inversemeters; + QuantityValue value = (QuantityValue) inversemeters; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMeter); } @@ -339,7 +342,7 @@ public static ReciprocalLength FromInverseMeters(QuantityValue inversemeters) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMicroinches(QuantityValue inversemicroinches) { - double value = (double) inversemicroinches; + QuantityValue value = (QuantityValue) inversemicroinches; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMicroinch); } @@ -349,7 +352,7 @@ public static ReciprocalLength FromInverseMicroinches(QuantityValue inversemicro /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMils(QuantityValue inversemils) { - double value = (double) inversemils; + QuantityValue value = (QuantityValue) inversemils; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMil); } @@ -359,7 +362,7 @@ public static ReciprocalLength FromInverseMils(QuantityValue inversemils) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMiles(QuantityValue inversemiles) { - double value = (double) inversemiles; + QuantityValue value = (QuantityValue) inversemiles; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMile); } @@ -369,7 +372,7 @@ public static ReciprocalLength FromInverseMiles(QuantityValue inversemiles) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMillimeters(QuantityValue inversemillimeters) { - double value = (double) inversemillimeters; + QuantityValue value = (QuantityValue) inversemillimeters; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMillimeter); } @@ -379,7 +382,7 @@ public static ReciprocalLength FromInverseMillimeters(QuantityValue inversemilli /// If value is NaN or Infinity. public static ReciprocalLength FromInverseUsSurveyFeet(QuantityValue inverseussurveyfeet) { - double value = (double) inverseussurveyfeet; + QuantityValue value = (QuantityValue) inverseussurveyfeet; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseUsSurveyFoot); } @@ -389,7 +392,7 @@ public static ReciprocalLength FromInverseUsSurveyFeet(QuantityValue inverseussu /// If value is NaN or Infinity. public static ReciprocalLength FromInverseYards(QuantityValue inverseyards) { - double value = (double) inverseyards; + QuantityValue value = (QuantityValue) inverseyards; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseYard); } @@ -401,7 +404,7 @@ public static ReciprocalLength FromInverseYards(QuantityValue inverseyards) /// ReciprocalLength unit value. public static ReciprocalLength From(QuantityValue value, ReciprocalLengthUnit fromUnit) { - return new ReciprocalLength((double)value, fromUnit); + return new ReciprocalLength((QuantityValue)value, fromUnit); } #endregion @@ -571,25 +574,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip } /// Get from multiplying value and . - public static ReciprocalLength operator *(double left, ReciprocalLength right) + public static ReciprocalLength operator *(QuantityValue left, ReciprocalLength right) { return new ReciprocalLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReciprocalLength operator *(ReciprocalLength left, double right) + public static ReciprocalLength operator *(ReciprocalLength left, QuantityValue right) { return new ReciprocalLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReciprocalLength operator /(ReciprocalLength left, double right) + public static ReciprocalLength operator /(ReciprocalLength left, QuantityValue right) { return new ReciprocalLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ReciprocalLength left, ReciprocalLength right) + public static QuantityValue operator /(ReciprocalLength left, ReciprocalLength right) { return left.InverseMeters / right.InverseMeters; } @@ -622,6 +625,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ReciprocalLength left, ReciprocalLength right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ReciprocalLength left, ReciprocalLength right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -634,7 +650,29 @@ public int CompareTo(object obj) /// public int CompareTo(ReciprocalLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ReciprocalLength objReciprocalLength)) + return false; + return Equals(objReciprocalLength); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ReciprocalLength other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -677,13 +715,13 @@ public int CompareTo(ReciprocalLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(ReciprocalLength other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -694,7 +732,7 @@ public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comp /// A hash code for the current ReciprocalLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -705,17 +743,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ReciprocalLengthUnit unit) + public QuantityValue As(ReciprocalLengthUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -730,12 +767,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) + if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return As(unitAsReciprocalLengthUnit); + return (QuantityValue)As(typedUnit); } /// @@ -767,7 +804,7 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (ReciprocalLength)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ReciprocalLengthUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -775,17 +812,17 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit, UnitConverter unitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) + if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReciprocalLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -812,10 +849,10 @@ public ReciprocalLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ReciprocalLengthUnit unit) + private QuantityValue GetValueAs(ReciprocalLengthUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index b91d29a949..42045a858b 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. /// [DataContract] - public partial struct RelativeHumidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct RelativeHumidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static RelativeHumidity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RelativeHumidity(double value, RelativeHumidityUnit unit) + public RelativeHumidity(QuantityValue value, RelativeHumidityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -86,14 +86,14 @@ public RelativeHumidity(double value, RelativeHumidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RelativeHumidity(double value, UnitSystem unitSystem) + public RelativeHumidity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,7 +134,10 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -157,9 +160,9 @@ public RelativeHumidity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Percent => As(RelativeHumidityUnit.Percent); + public QuantityValue Percent => As(RelativeHumidityUnit.Percent); #endregion @@ -215,7 +218,7 @@ public static string GetAbbreviation(RelativeHumidityUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static RelativeHumidity FromPercent(QuantityValue percent) { - double value = (double) percent; + QuantityValue value = (QuantityValue) percent; return new RelativeHumidity(value, RelativeHumidityUnit.Percent); } @@ -227,7 +230,7 @@ public static RelativeHumidity FromPercent(QuantityValue percent) /// RelativeHumidity unit value. public static RelativeHumidity From(QuantityValue value, RelativeHumidityUnit fromUnit) { - return new RelativeHumidity((double)value, fromUnit); + return new RelativeHumidity((QuantityValue)value, fromUnit); } #endregion @@ -397,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat } /// Get from multiplying value and . - public static RelativeHumidity operator *(double left, RelativeHumidity right) + public static RelativeHumidity operator *(QuantityValue left, RelativeHumidity right) { return new RelativeHumidity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RelativeHumidity operator *(RelativeHumidity left, double right) + public static RelativeHumidity operator *(RelativeHumidity left, QuantityValue right) { return new RelativeHumidity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RelativeHumidity operator /(RelativeHumidity left, double right) + public static RelativeHumidity operator /(RelativeHumidity left, QuantityValue right) { return new RelativeHumidity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RelativeHumidity left, RelativeHumidity right) + public static QuantityValue operator /(RelativeHumidity left, RelativeHumidity right) { return left.Percent / right.Percent; } @@ -448,6 +451,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(RelativeHumidity left, RelativeHumidity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(RelativeHumidity left, RelativeHumidity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -460,7 +476,29 @@ public int CompareTo(object obj) /// public int CompareTo(RelativeHumidity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is RelativeHumidity objRelativeHumidity)) + return false; + return Equals(objRelativeHumidity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(RelativeHumidity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -503,13 +541,13 @@ public int CompareTo(RelativeHumidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comparisonType) + public bool Equals(RelativeHumidity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -520,7 +558,7 @@ public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comp /// A hash code for the current RelativeHumidity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -531,17 +569,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RelativeHumidityUnit unit) + public QuantityValue As(RelativeHumidityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -556,12 +593,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) + if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return As(unitAsRelativeHumidityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -593,7 +630,7 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (RelativeHumidity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RelativeHumidityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -601,17 +638,17 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit, UnitConverter unitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) + if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRelativeHumidityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -638,10 +675,10 @@ public RelativeHumidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RelativeHumidityUnit unit) + private QuantityValue GetValueAs(RelativeHumidityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 82e5e89d70..4f2c933aca 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Angular acceleration is the rate of change of rotational speed. /// [DataContract] - public partial struct RotationalAcceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalAcceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static RotationalAcceleration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalAcceleration(double value, RotationalAccelerationUnit unit) + public RotationalAcceleration(QuantityValue value, RotationalAccelerationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public RotationalAcceleration(double value, RotationalAccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalAcceleration(double value, UnitSystem unitSystem) + public RotationalAcceleration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); + public QuantityValue DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); + public QuantityValue RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + public QuantityValue RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); + public QuantityValue RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(RotationalAccelerationUnit unit, IFormatPro /// If value is NaN or Infinity. public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue degreespersecondsquared) { - double value = (double) degreespersecondsquared; + QuantityValue value = (QuantityValue) degreespersecondsquared; return new RotationalAcceleration(value, RotationalAccelerationUnit.DegreePerSecondSquared); } @@ -252,7 +255,7 @@ public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue d /// If value is NaN or Infinity. public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue radianspersecondsquared) { - double value = (double) radianspersecondsquared; + QuantityValue value = (QuantityValue) radianspersecondsquared; return new RotationalAcceleration(value, RotationalAccelerationUnit.RadianPerSecondSquared); } @@ -262,7 +265,7 @@ public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue r /// If value is NaN or Infinity. public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityValue revolutionsperminutepersecond) { - double value = (double) revolutionsperminutepersecond; + QuantityValue value = (QuantityValue) revolutionsperminutepersecond; return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); } @@ -272,7 +275,7 @@ public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityV /// If value is NaN or Infinity. public static RotationalAcceleration FromRevolutionsPerSecondSquared(QuantityValue revolutionspersecondsquared) { - double value = (double) revolutionspersecondsquared; + QuantityValue value = (QuantityValue) revolutionspersecondsquared; return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerSecondSquared); } @@ -284,7 +287,7 @@ public static RotationalAcceleration FromRevolutionsPerSecondSquared(QuantityVal /// RotationalAcceleration unit value. public static RotationalAcceleration From(QuantityValue value, RotationalAccelerationUnit fromUnit) { - return new RotationalAcceleration((double)value, fromUnit); + return new RotationalAcceleration((QuantityValue)value, fromUnit); } #endregion @@ -454,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalAcceleration operator *(double left, RotationalAcceleration right) + public static RotationalAcceleration operator *(QuantityValue left, RotationalAcceleration right) { return new RotationalAcceleration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalAcceleration operator *(RotationalAcceleration left, double right) + public static RotationalAcceleration operator *(RotationalAcceleration left, QuantityValue right) { return new RotationalAcceleration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalAcceleration operator /(RotationalAcceleration left, double right) + public static RotationalAcceleration operator /(RotationalAcceleration left, QuantityValue right) { return new RotationalAcceleration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalAcceleration left, RotationalAcceleration right) + public static QuantityValue operator /(RotationalAcceleration left, RotationalAcceleration right) { return left.RadiansPerSecondSquared / right.RadiansPerSecondSquared; } @@ -505,6 +508,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -517,7 +533,29 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalAcceleration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) + return false; + return Equals(objRotationalAcceleration); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalAcceleration other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -560,13 +598,13 @@ public int CompareTo(RotationalAcceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalAcceleration other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +615,7 @@ public bool Equals(RotationalAcceleration other, double tolerance, ComparisonTyp /// A hash code for the current RotationalAcceleration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -588,17 +626,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalAccelerationUnit unit) + public QuantityValue As(RotationalAccelerationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,12 +650,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) + if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalAccelerationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -650,7 +687,7 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit, UnitConver var converted = conversionFunction(this); return (RotationalAcceleration)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RotationalAccelerationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -658,17 +695,17 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit, UnitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) + if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalAccelerationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -695,10 +732,10 @@ public RotationalAcceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RotationalAccelerationUnit unit) + private QuantityValue GetValueAs(RotationalAccelerationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 85e4e1cff9..fe07f1048a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). /// [DataContract] - public partial struct RotationalSpeed : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalSpeed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -84,9 +84,9 @@ static RotationalSpeed() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalSpeed(double value, RotationalSpeedUnit unit) + public RotationalSpeed(QuantityValue value, RotationalSpeedUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -98,14 +98,14 @@ public RotationalSpeed(double value, RotationalSpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalSpeed(double value, UnitSystem unitSystem) + public RotationalSpeed(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -146,7 +146,10 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -169,69 +172,69 @@ public RotationalSpeed(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); + public QuantityValue CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); + public QuantityValue DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); + public QuantityValue DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); + public QuantityValue DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); + public QuantityValue MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); + public QuantityValue MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); + public QuantityValue MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); + public QuantityValue MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); + public QuantityValue NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); + public QuantityValue NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); + public QuantityValue RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); + public QuantityValue RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); + public QuantityValue RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); #endregion @@ -335,7 +338,7 @@ public static string GetAbbreviation(RotationalSpeedUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue centiradianspersecond) { - double value = (double) centiradianspersecond; + QuantityValue value = (QuantityValue) centiradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.CentiradianPerSecond); } @@ -345,7 +348,7 @@ public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue centiradia /// If value is NaN or Infinity. public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue deciradianspersecond) { - double value = (double) deciradianspersecond; + QuantityValue value = (QuantityValue) deciradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.DeciradianPerSecond); } @@ -355,7 +358,7 @@ public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue deciradians /// If value is NaN or Infinity. public static RotationalSpeed FromDegreesPerMinute(QuantityValue degreesperminute) { - double value = (double) degreesperminute; + QuantityValue value = (QuantityValue) degreesperminute; return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerMinute); } @@ -365,7 +368,7 @@ public static RotationalSpeed FromDegreesPerMinute(QuantityValue degreesperminut /// If value is NaN or Infinity. public static RotationalSpeed FromDegreesPerSecond(QuantityValue degreespersecond) { - double value = (double) degreespersecond; + QuantityValue value = (QuantityValue) degreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerSecond); } @@ -375,7 +378,7 @@ public static RotationalSpeed FromDegreesPerSecond(QuantityValue degreespersecon /// If value is NaN or Infinity. public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue microdegreespersecond) { - double value = (double) microdegreespersecond; + QuantityValue value = (QuantityValue) microdegreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MicrodegreePerSecond); } @@ -385,7 +388,7 @@ public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue microdegre /// If value is NaN or Infinity. public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue microradianspersecond) { - double value = (double) microradianspersecond; + QuantityValue value = (QuantityValue) microradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MicroradianPerSecond); } @@ -395,7 +398,7 @@ public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue microradia /// If value is NaN or Infinity. public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue millidegreespersecond) { - double value = (double) millidegreespersecond; + QuantityValue value = (QuantityValue) millidegreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MillidegreePerSecond); } @@ -405,7 +408,7 @@ public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue millidegre /// If value is NaN or Infinity. public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue milliradianspersecond) { - double value = (double) milliradianspersecond; + QuantityValue value = (QuantityValue) milliradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MilliradianPerSecond); } @@ -415,7 +418,7 @@ public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue milliradia /// If value is NaN or Infinity. public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue nanodegreespersecond) { - double value = (double) nanodegreespersecond; + QuantityValue value = (QuantityValue) nanodegreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.NanodegreePerSecond); } @@ -425,7 +428,7 @@ public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue nanodegrees /// If value is NaN or Infinity. public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue nanoradianspersecond) { - double value = (double) nanoradianspersecond; + QuantityValue value = (QuantityValue) nanoradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.NanoradianPerSecond); } @@ -435,7 +438,7 @@ public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue nanoradians /// If value is NaN or Infinity. public static RotationalSpeed FromRadiansPerSecond(QuantityValue radianspersecond) { - double value = (double) radianspersecond; + QuantityValue value = (QuantityValue) radianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.RadianPerSecond); } @@ -445,7 +448,7 @@ public static RotationalSpeed FromRadiansPerSecond(QuantityValue radianspersecon /// If value is NaN or Infinity. public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue revolutionsperminute) { - double value = (double) revolutionsperminute; + QuantityValue value = (QuantityValue) revolutionsperminute; return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerMinute); } @@ -455,7 +458,7 @@ public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue revolutions /// If value is NaN or Infinity. public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue revolutionspersecond) { - double value = (double) revolutionspersecond; + QuantityValue value = (QuantityValue) revolutionspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerSecond); } @@ -467,7 +470,7 @@ public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue revolutions /// RotationalSpeed unit value. public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit) { - return new RotationalSpeed((double)value, fromUnit); + return new RotationalSpeed((QuantityValue)value, fromUnit); } #endregion @@ -637,25 +640,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalSpeed operator *(double left, RotationalSpeed right) + public static RotationalSpeed operator *(QuantityValue left, RotationalSpeed right) { return new RotationalSpeed(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalSpeed operator *(RotationalSpeed left, double right) + public static RotationalSpeed operator *(RotationalSpeed left, QuantityValue right) { return new RotationalSpeed(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalSpeed operator /(RotationalSpeed left, double right) + public static RotationalSpeed operator /(RotationalSpeed left, QuantityValue right) { return new RotationalSpeed(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalSpeed left, RotationalSpeed right) + public static QuantityValue operator /(RotationalSpeed left, RotationalSpeed right) { return left.RadiansPerSecond / right.RadiansPerSecond; } @@ -688,6 +691,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalSpeed left, RotationalSpeed right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalSpeed left, RotationalSpeed right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -700,7 +716,29 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalSpeed other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is RotationalSpeed objRotationalSpeed)) + return false; + return Equals(objRotationalSpeed); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalSpeed other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -743,13 +781,13 @@ public int CompareTo(RotationalSpeed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalSpeed other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -760,7 +798,7 @@ public bool Equals(RotationalSpeed other, double tolerance, ComparisonType compa /// A hash code for the current RotationalSpeed. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -771,17 +809,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalSpeedUnit unit) + public QuantityValue As(RotationalSpeedUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -796,12 +833,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) + if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalSpeedUnit); + return (QuantityValue)As(typedUnit); } /// @@ -833,7 +870,7 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (RotationalSpeed)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RotationalSpeedUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -841,17 +878,17 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) + if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalSpeedUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -878,10 +915,10 @@ public RotationalSpeed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RotationalSpeedUnit unit) + private QuantityValue GetValueAs(RotationalSpeedUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index dd3526719d..566185aa51 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffness : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffness : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -104,9 +104,9 @@ static RotationalStiffness() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalStiffness(double value, RotationalStiffnessUnit unit) + public RotationalStiffness(QuantityValue value, RotationalStiffnessUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -118,14 +118,14 @@ public RotationalStiffness(double value, RotationalStiffnessUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffness(double value, UnitSystem unitSystem) + public RotationalStiffness(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -166,7 +166,10 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -189,169 +192,169 @@ public RotationalStiffness(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); + public QuantityValue CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); + public QuantityValue CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); + public QuantityValue CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); + public QuantityValue DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); + public QuantityValue DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); + public QuantityValue DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); + public QuantityValue DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); + public QuantityValue DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); + public QuantityValue DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); + public QuantityValue KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); + public QuantityValue KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); + public QuantityValue KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); + public QuantityValue KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); + public QuantityValue KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); + public QuantityValue MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); + public QuantityValue MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); + public QuantityValue MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); + public QuantityValue MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); + public QuantityValue MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); + public QuantityValue MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); + public QuantityValue MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); + public QuantityValue MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); + public QuantityValue MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); + public QuantityValue MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); + public QuantityValue NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); + public QuantityValue NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); + public QuantityValue NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); + public QuantityValue NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); + public QuantityValue NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); + public QuantityValue NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); + public QuantityValue NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); + public QuantityValue PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); + public QuantityValue PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); #endregion @@ -503,7 +506,7 @@ public static string GetAbbreviation(RotationalStiffnessUnit unit, IFormatProvid /// If value is NaN or Infinity. public static RotationalStiffness FromCentinewtonMetersPerDegree(QuantityValue centinewtonmetersperdegree) { - double value = (double) centinewtonmetersperdegree; + QuantityValue value = (QuantityValue) centinewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMeterPerDegree); } @@ -513,7 +516,7 @@ public static RotationalStiffness FromCentinewtonMetersPerDegree(QuantityValue c /// If value is NaN or Infinity. public static RotationalStiffness FromCentinewtonMillimetersPerDegree(QuantityValue centinewtonmillimetersperdegree) { - double value = (double) centinewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) centinewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); } @@ -523,7 +526,7 @@ public static RotationalStiffness FromCentinewtonMillimetersPerDegree(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromCentinewtonMillimetersPerRadian(QuantityValue centinewtonmillimetersperradian) { - double value = (double) centinewtonmillimetersperradian; + QuantityValue value = (QuantityValue) centinewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); } @@ -533,7 +536,7 @@ public static RotationalStiffness FromCentinewtonMillimetersPerRadian(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromDecanewtonMetersPerDegree(QuantityValue decanewtonmetersperdegree) { - double value = (double) decanewtonmetersperdegree; + QuantityValue value = (QuantityValue) decanewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMeterPerDegree); } @@ -543,7 +546,7 @@ public static RotationalStiffness FromDecanewtonMetersPerDegree(QuantityValue de /// If value is NaN or Infinity. public static RotationalStiffness FromDecanewtonMillimetersPerDegree(QuantityValue decanewtonmillimetersperdegree) { - double value = (double) decanewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) decanewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); } @@ -553,7 +556,7 @@ public static RotationalStiffness FromDecanewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromDecanewtonMillimetersPerRadian(QuantityValue decanewtonmillimetersperradian) { - double value = (double) decanewtonmillimetersperradian; + QuantityValue value = (QuantityValue) decanewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); } @@ -563,7 +566,7 @@ public static RotationalStiffness FromDecanewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromDecinewtonMetersPerDegree(QuantityValue decinewtonmetersperdegree) { - double value = (double) decinewtonmetersperdegree; + QuantityValue value = (QuantityValue) decinewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMeterPerDegree); } @@ -573,7 +576,7 @@ public static RotationalStiffness FromDecinewtonMetersPerDegree(QuantityValue de /// If value is NaN or Infinity. public static RotationalStiffness FromDecinewtonMillimetersPerDegree(QuantityValue decinewtonmillimetersperdegree) { - double value = (double) decinewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) decinewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); } @@ -583,7 +586,7 @@ public static RotationalStiffness FromDecinewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromDecinewtonMillimetersPerRadian(QuantityValue decinewtonmillimetersperradian) { - double value = (double) decinewtonmillimetersperradian; + QuantityValue value = (QuantityValue) decinewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); } @@ -593,7 +596,7 @@ public static RotationalStiffness FromDecinewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMetersPerDegree(QuantityValue kilonewtonmetersperdegree) { - double value = (double) kilonewtonmetersperdegree; + QuantityValue value = (QuantityValue) kilonewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerDegree); } @@ -603,7 +606,7 @@ public static RotationalStiffness FromKilonewtonMetersPerDegree(QuantityValue ki /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue kilonewtonmetersperradian) { - double value = (double) kilonewtonmetersperradian; + QuantityValue value = (QuantityValue) kilonewtonmetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerRadian); } @@ -613,7 +616,7 @@ public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue ki /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMillimetersPerDegree(QuantityValue kilonewtonmillimetersperdegree) { - double value = (double) kilonewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) kilonewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); } @@ -623,7 +626,7 @@ public static RotationalStiffness FromKilonewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMillimetersPerRadian(QuantityValue kilonewtonmillimetersperradian) { - double value = (double) kilonewtonmillimetersperradian; + QuantityValue value = (QuantityValue) kilonewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); } @@ -633,7 +636,7 @@ public static RotationalStiffness FromKilonewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromKilopoundForceFeetPerDegrees(QuantityValue kilopoundforcefeetperdegrees) { - double value = (double) kilopoundforcefeetperdegrees; + QuantityValue value = (QuantityValue) kilopoundforcefeetperdegrees; return new RotationalStiffness(value, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); } @@ -643,7 +646,7 @@ public static RotationalStiffness FromKilopoundForceFeetPerDegrees(QuantityValue /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMetersPerDegree(QuantityValue meganewtonmetersperdegree) { - double value = (double) meganewtonmetersperdegree; + QuantityValue value = (QuantityValue) meganewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerDegree); } @@ -653,7 +656,7 @@ public static RotationalStiffness FromMeganewtonMetersPerDegree(QuantityValue me /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue meganewtonmetersperradian) { - double value = (double) meganewtonmetersperradian; + QuantityValue value = (QuantityValue) meganewtonmetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerRadian); } @@ -663,7 +666,7 @@ public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue me /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMillimetersPerDegree(QuantityValue meganewtonmillimetersperdegree) { - double value = (double) meganewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) meganewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); } @@ -673,7 +676,7 @@ public static RotationalStiffness FromMeganewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMillimetersPerRadian(QuantityValue meganewtonmillimetersperradian) { - double value = (double) meganewtonmillimetersperradian; + QuantityValue value = (QuantityValue) meganewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); } @@ -683,7 +686,7 @@ public static RotationalStiffness FromMeganewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromMicronewtonMetersPerDegree(QuantityValue micronewtonmetersperdegree) { - double value = (double) micronewtonmetersperdegree; + QuantityValue value = (QuantityValue) micronewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMeterPerDegree); } @@ -693,7 +696,7 @@ public static RotationalStiffness FromMicronewtonMetersPerDegree(QuantityValue m /// If value is NaN or Infinity. public static RotationalStiffness FromMicronewtonMillimetersPerDegree(QuantityValue micronewtonmillimetersperdegree) { - double value = (double) micronewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) micronewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); } @@ -703,7 +706,7 @@ public static RotationalStiffness FromMicronewtonMillimetersPerDegree(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromMicronewtonMillimetersPerRadian(QuantityValue micronewtonmillimetersperradian) { - double value = (double) micronewtonmillimetersperradian; + QuantityValue value = (QuantityValue) micronewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); } @@ -713,7 +716,7 @@ public static RotationalStiffness FromMicronewtonMillimetersPerRadian(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromMillinewtonMetersPerDegree(QuantityValue millinewtonmetersperdegree) { - double value = (double) millinewtonmetersperdegree; + QuantityValue value = (QuantityValue) millinewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMeterPerDegree); } @@ -723,7 +726,7 @@ public static RotationalStiffness FromMillinewtonMetersPerDegree(QuantityValue m /// If value is NaN or Infinity. public static RotationalStiffness FromMillinewtonMillimetersPerDegree(QuantityValue millinewtonmillimetersperdegree) { - double value = (double) millinewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) millinewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); } @@ -733,7 +736,7 @@ public static RotationalStiffness FromMillinewtonMillimetersPerDegree(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromMillinewtonMillimetersPerRadian(QuantityValue millinewtonmillimetersperradian) { - double value = (double) millinewtonmillimetersperradian; + QuantityValue value = (QuantityValue) millinewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); } @@ -743,7 +746,7 @@ public static RotationalStiffness FromMillinewtonMillimetersPerRadian(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromNanonewtonMetersPerDegree(QuantityValue nanonewtonmetersperdegree) { - double value = (double) nanonewtonmetersperdegree; + QuantityValue value = (QuantityValue) nanonewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMeterPerDegree); } @@ -753,7 +756,7 @@ public static RotationalStiffness FromNanonewtonMetersPerDegree(QuantityValue na /// If value is NaN or Infinity. public static RotationalStiffness FromNanonewtonMillimetersPerDegree(QuantityValue nanonewtonmillimetersperdegree) { - double value = (double) nanonewtonmillimetersperdegree; + QuantityValue value = (QuantityValue) nanonewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); } @@ -763,7 +766,7 @@ public static RotationalStiffness FromNanonewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromNanonewtonMillimetersPerRadian(QuantityValue nanonewtonmillimetersperradian) { - double value = (double) nanonewtonmillimetersperradian; + QuantityValue value = (QuantityValue) nanonewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); } @@ -773,7 +776,7 @@ public static RotationalStiffness FromNanonewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMetersPerDegree(QuantityValue newtonmetersperdegree) { - double value = (double) newtonmetersperdegree; + QuantityValue value = (QuantityValue) newtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerDegree); } @@ -783,7 +786,7 @@ public static RotationalStiffness FromNewtonMetersPerDegree(QuantityValue newton /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue newtonmetersperradian) { - double value = (double) newtonmetersperradian; + QuantityValue value = (QuantityValue) newtonmetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerRadian); } @@ -793,7 +796,7 @@ public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue newton /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMillimetersPerDegree(QuantityValue newtonmillimetersperdegree) { - double value = (double) newtonmillimetersperdegree; + QuantityValue value = (QuantityValue) newtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerDegree); } @@ -803,7 +806,7 @@ public static RotationalStiffness FromNewtonMillimetersPerDegree(QuantityValue n /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMillimetersPerRadian(QuantityValue newtonmillimetersperradian) { - double value = (double) newtonmillimetersperradian; + QuantityValue value = (QuantityValue) newtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerRadian); } @@ -813,7 +816,7 @@ public static RotationalStiffness FromNewtonMillimetersPerRadian(QuantityValue n /// If value is NaN or Infinity. public static RotationalStiffness FromPoundForceFeetPerRadian(QuantityValue poundforcefeetperradian) { - double value = (double) poundforcefeetperradian; + QuantityValue value = (QuantityValue) poundforcefeetperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFeetPerRadian); } @@ -823,7 +826,7 @@ public static RotationalStiffness FromPoundForceFeetPerRadian(QuantityValue poun /// If value is NaN or Infinity. public static RotationalStiffness FromPoundForceFeetPerDegrees(QuantityValue poundforcefeetperdegrees) { - double value = (double) poundforcefeetperdegrees; + QuantityValue value = (QuantityValue) poundforcefeetperdegrees; return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFootPerDegrees); } @@ -835,7 +838,7 @@ public static RotationalStiffness FromPoundForceFeetPerDegrees(QuantityValue pou /// RotationalStiffness unit value. public static RotationalStiffness From(QuantityValue value, RotationalStiffnessUnit fromUnit) { - return new RotationalStiffness((double)value, fromUnit); + return new RotationalStiffness((QuantityValue)value, fromUnit); } #endregion @@ -1005,25 +1008,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalStiffness operator *(double left, RotationalStiffness right) + public static RotationalStiffness operator *(QuantityValue left, RotationalStiffness right) { return new RotationalStiffness(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalStiffness operator *(RotationalStiffness left, double right) + public static RotationalStiffness operator *(RotationalStiffness left, QuantityValue right) { return new RotationalStiffness(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalStiffness operator /(RotationalStiffness left, double right) + public static RotationalStiffness operator /(RotationalStiffness left, QuantityValue right) { return new RotationalStiffness(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalStiffness left, RotationalStiffness right) + public static QuantityValue operator /(RotationalStiffness left, RotationalStiffness right) { return left.NewtonMetersPerRadian / right.NewtonMetersPerRadian; } @@ -1056,6 +1059,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalStiffness left, RotationalStiffness right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalStiffness left, RotationalStiffness right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1068,7 +1084,29 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalStiffness other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is RotationalStiffness objRotationalStiffness)) + return false; + return Equals(objRotationalStiffness); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalStiffness other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1111,13 +1149,13 @@ public int CompareTo(RotationalStiffness other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalStiffness other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1128,7 +1166,7 @@ public bool Equals(RotationalStiffness other, double tolerance, ComparisonType c /// A hash code for the current RotationalStiffness. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1139,17 +1177,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessUnit unit) + public QuantityValue As(RotationalStiffnessUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1164,12 +1201,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) + if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1201,7 +1238,7 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit, UnitConverter un var converted = conversionFunction(this); return (RotationalStiffness)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RotationalStiffnessUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1209,17 +1246,17 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) + if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalStiffnessUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1246,10 +1283,10 @@ public RotationalStiffness ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RotationalStiffnessUnit unit) + private QuantityValue GetValueAs(RotationalStiffnessUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 603b45d53a..891a7f8e9d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffnessPerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffnessPerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static RotationalStiffnessPerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) + public RotationalStiffnessPerLength(QuantityValue value, RotationalStiffnessPerLengthUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -90,14 +90,14 @@ public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUn /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) + public RotationalStiffnessPerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,7 +138,10 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -161,29 +164,29 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + public QuantityValue KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); + public QuantityValue KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + public QuantityValue MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + public QuantityValue NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); + public QuantityValue PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); #endregion @@ -251,7 +254,7 @@ public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, IFor /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(QuantityValue kilonewtonmetersperradianpermeter) { - double value = (double) kilonewtonmetersperradianpermeter; + QuantityValue value = (QuantityValue) kilonewtonmetersperradianpermeter; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); } @@ -261,7 +264,7 @@ public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(QuantityValue kilopoundforcefeetperdegreesperfeet) { - double value = (double) kilopoundforcefeetperdegreesperfeet; + QuantityValue value = (QuantityValue) kilopoundforcefeetperdegreesperfeet; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); } @@ -271,7 +274,7 @@ public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFe /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(QuantityValue meganewtonmetersperradianpermeter) { - double value = (double) meganewtonmetersperradianpermeter; + QuantityValue value = (QuantityValue) meganewtonmetersperradianpermeter; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); } @@ -281,7 +284,7 @@ public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(QuantityValue newtonmetersperradianpermeter) { - double value = (double) newtonmetersperradianpermeter; + QuantityValue value = (QuantityValue) newtonmetersperradianpermeter; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); } @@ -291,7 +294,7 @@ public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(Qua /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(QuantityValue poundforcefeetperdegreesperfeet) { - double value = (double) poundforcefeetperdegreesperfeet; + QuantityValue value = (QuantityValue) poundforcefeetperdegreesperfeet; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); } @@ -303,7 +306,7 @@ public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(Q /// RotationalStiffnessPerLength unit value. public static RotationalStiffnessPerLength From(QuantityValue value, RotationalStiffnessPerLengthUnit fromUnit) { - return new RotationalStiffnessPerLength((double)value, fromUnit); + return new RotationalStiffnessPerLength((QuantityValue)value, fromUnit); } #endregion @@ -473,25 +476,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(double left, RotationalStiffnessPerLength right) + public static RotationalStiffnessPerLength operator *(QuantityValue left, RotationalStiffnessPerLength right) { return new RotationalStiffnessPerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, double right) + public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, QuantityValue right) { return new RotationalStiffnessPerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, double right) + public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, QuantityValue right) { return new RotationalStiffnessPerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static QuantityValue operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.NewtonMetersPerRadianPerMeter / right.NewtonMetersPerRadianPerMeter; } @@ -524,6 +527,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -536,7 +552,29 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalStiffnessPerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) + return false; + return Equals(objRotationalStiffnessPerLength); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(RotationalStiffnessPerLength other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -579,13 +617,13 @@ public int CompareTo(RotationalStiffnessPerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(RotationalStiffnessPerLength other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +634,7 @@ public bool Equals(RotationalStiffnessPerLength other, double tolerance, Compari /// A hash code for the current RotationalStiffnessPerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -607,17 +645,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(RotationalStiffnessPerLengthUnit unit) + public QuantityValue As(RotationalStiffnessPerLengthUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -632,12 +669,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessPerLengthUnit); + return (QuantityValue)As(typedUnit); } /// @@ -669,7 +706,7 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit var converted = conversionFunction(this); return (RotationalStiffnessPerLength)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(RotationalStiffnessPerLengthUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -677,17 +714,17 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalStiffnessPerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -714,10 +751,10 @@ public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(RotationalStiffnessPerLengthUnit unit) + private QuantityValue GetValueAs(RotationalStiffnessPerLengthUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 4b70a95229..f6d4428b4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A way of representing a number of items. /// [DataContract] - public partial struct Scalar : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Scalar : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static Scalar() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Scalar(double value, ScalarUnit unit) + public Scalar(QuantityValue value, ScalarUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -86,14 +86,14 @@ public Scalar(double value, ScalarUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Scalar(double value, UnitSystem unitSystem) + public Scalar(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,7 +134,10 @@ public Scalar(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -157,9 +160,9 @@ public Scalar(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Amount => As(ScalarUnit.Amount); + public QuantityValue Amount => As(ScalarUnit.Amount); #endregion @@ -215,7 +218,7 @@ public static string GetAbbreviation(ScalarUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Scalar FromAmount(QuantityValue amount) { - double value = (double) amount; + QuantityValue value = (QuantityValue) amount; return new Scalar(value, ScalarUnit.Amount); } @@ -227,7 +230,7 @@ public static Scalar FromAmount(QuantityValue amount) /// Scalar unit value. public static Scalar From(QuantityValue value, ScalarUnit fromUnit) { - return new Scalar((double)value, fromUnit); + return new Scalar((QuantityValue)value, fromUnit); } #endregion @@ -397,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala } /// Get from multiplying value and . - public static Scalar operator *(double left, Scalar right) + public static Scalar operator *(QuantityValue left, Scalar right) { return new Scalar(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Scalar operator *(Scalar left, double right) + public static Scalar operator *(Scalar left, QuantityValue right) { return new Scalar(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Scalar operator /(Scalar left, double right) + public static Scalar operator /(Scalar left, QuantityValue right) { return new Scalar(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Scalar left, Scalar right) + public static QuantityValue operator /(Scalar left, Scalar right) { return left.Amount / right.Amount; } @@ -448,6 +451,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Scalar left, Scalar right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Scalar left, Scalar right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -460,7 +476,29 @@ public int CompareTo(object obj) /// public int CompareTo(Scalar other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Scalar objScalar)) + return false; + return Equals(objScalar); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Scalar other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -503,13 +541,13 @@ public int CompareTo(Scalar other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType) + public bool Equals(Scalar other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -520,7 +558,7 @@ public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType /// A hash code for the current Scalar. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -531,17 +569,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ScalarUnit unit) + public QuantityValue As(ScalarUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -556,12 +593,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ScalarUnit unitAsScalarUnit)) + if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return As(unitAsScalarUnit); + return (QuantityValue)As(typedUnit); } /// @@ -593,7 +630,7 @@ public Scalar ToUnit(ScalarUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Scalar)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ScalarUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -601,17 +638,17 @@ public Scalar ToUnit(ScalarUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ScalarUnit unitAsScalarUnit)) + if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsScalarUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -638,10 +675,10 @@ public Scalar ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ScalarUnit unit) + private QuantityValue GetValueAs(ScalarUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 9a4b65cb3d..dd664f80ca 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Solid_angle /// [DataContract] - public partial struct SolidAngle : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct SolidAngle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static SolidAngle() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SolidAngle(double value, SolidAngleUnit unit) + public SolidAngle(QuantityValue value, SolidAngleUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public SolidAngle(double value, SolidAngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SolidAngle(double value, UnitSystem unitSystem) + public SolidAngle(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public SolidAngle(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public SolidAngle(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Steradians => As(SolidAngleUnit.Steradian); + public QuantityValue Steradians => As(SolidAngleUnit.Steradian); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(SolidAngleUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static SolidAngle FromSteradians(QuantityValue steradians) { - double value = (double) steradians; + QuantityValue value = (QuantityValue) steradians; return new SolidAngle(value, SolidAngleUnit.Steradian); } @@ -230,7 +233,7 @@ public static SolidAngle FromSteradians(QuantityValue steradians) /// SolidAngle unit value. public static SolidAngle From(QuantityValue value, SolidAngleUnit fromUnit) { - return new SolidAngle((double)value, fromUnit); + return new SolidAngle((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid } /// Get from multiplying value and . - public static SolidAngle operator *(double left, SolidAngle right) + public static SolidAngle operator *(QuantityValue left, SolidAngle right) { return new SolidAngle(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SolidAngle operator *(SolidAngle left, double right) + public static SolidAngle operator *(SolidAngle left, QuantityValue right) { return new SolidAngle(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SolidAngle operator /(SolidAngle left, double right) + public static SolidAngle operator /(SolidAngle left, QuantityValue right) { return new SolidAngle(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SolidAngle left, SolidAngle right) + public static QuantityValue operator /(SolidAngle left, SolidAngle right) { return left.Steradians / right.Steradians; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(SolidAngle left, SolidAngle right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(SolidAngle left, SolidAngle right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(SolidAngle other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is SolidAngle objSolidAngle)) + return false; + return Equals(objSolidAngle); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(SolidAngle other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(SolidAngle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType) + public bool Equals(SolidAngle other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(SolidAngle other, double tolerance, ComparisonType comparison /// A hash code for the current SolidAngle. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SolidAngleUnit unit) + public QuantityValue As(SolidAngleUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) + if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return As(unitAsSolidAngleUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public SolidAngle ToUnit(SolidAngleUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (SolidAngle)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SolidAngleUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public SolidAngle ToUnit(SolidAngleUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) + if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSolidAngleUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public SolidAngle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SolidAngleUnit unit) + private QuantityValue GetValueAs(SolidAngleUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 454fa20918..e5f236b1cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Specific_energy /// [DataContract] - public partial struct SpecificEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -103,9 +103,9 @@ static SpecificEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificEnergy(double value, SpecificEnergyUnit unit) + public SpecificEnergy(QuantityValue value, SpecificEnergyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -117,14 +117,14 @@ public SpecificEnergy(double value, SpecificEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEnergy(double value, UnitSystem unitSystem) + public SpecificEnergy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -165,7 +165,10 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -188,149 +191,149 @@ public SpecificEnergy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); + public QuantityValue BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); + public QuantityValue CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); + public QuantityValue GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); + public QuantityValue GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); + public QuantityValue GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); + public QuantityValue GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GigawattHoursPerPound => As(SpecificEnergyUnit.GigawattHourPerPound); + public QuantityValue GigawattHoursPerPound => As(SpecificEnergyUnit.GigawattHourPerPound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); + public QuantityValue JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); + public QuantityValue KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); + public QuantityValue KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); + public QuantityValue KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); + public QuantityValue KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); + public QuantityValue KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); + public QuantityValue KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilowattHoursPerPound => As(SpecificEnergyUnit.KilowattHourPerPound); + public QuantityValue KilowattHoursPerPound => As(SpecificEnergyUnit.KilowattHourPerPound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); + public QuantityValue MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); + public QuantityValue MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); + public QuantityValue MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); + public QuantityValue MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); + public QuantityValue MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegawattHoursPerPound => As(SpecificEnergyUnit.MegawattHourPerPound); + public QuantityValue MegawattHoursPerPound => As(SpecificEnergyUnit.MegawattHourPerPound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); + public QuantityValue TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); + public QuantityValue TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); + public QuantityValue TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); + public QuantityValue WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); + public QuantityValue WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); + public QuantityValue WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); + public QuantityValue WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattHoursPerPound => As(SpecificEnergyUnit.WattHourPerPound); + public QuantityValue WattHoursPerPound => As(SpecificEnergyUnit.WattHourPerPound); #endregion @@ -470,7 +473,7 @@ public static string GetAbbreviation(SpecificEnergyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static SpecificEnergy FromBtuPerPound(QuantityValue btuperpound) { - double value = (double) btuperpound; + QuantityValue value = (QuantityValue) btuperpound; return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound); } @@ -480,7 +483,7 @@ public static SpecificEnergy FromBtuPerPound(QuantityValue btuperpound) /// If value is NaN or Infinity. public static SpecificEnergy FromCaloriesPerGram(QuantityValue caloriespergram) { - double value = (double) caloriespergram; + QuantityValue value = (QuantityValue) caloriespergram; return new SpecificEnergy(value, SpecificEnergyUnit.CaloriePerGram); } @@ -490,7 +493,7 @@ public static SpecificEnergy FromCaloriesPerGram(QuantityValue caloriespergram) /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattDaysPerKilogram(QuantityValue gigawattdaysperkilogram) { - double value = (double) gigawattdaysperkilogram; + QuantityValue value = (QuantityValue) gigawattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerKilogram); } @@ -500,7 +503,7 @@ public static SpecificEnergy FromGigawattDaysPerKilogram(QuantityValue gigawattd /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattDaysPerShortTon(QuantityValue gigawattdayspershortton) { - double value = (double) gigawattdayspershortton; + QuantityValue value = (QuantityValue) gigawattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerShortTon); } @@ -510,7 +513,7 @@ public static SpecificEnergy FromGigawattDaysPerShortTon(QuantityValue gigawattd /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattDaysPerTonne(QuantityValue gigawattdayspertonne) { - double value = (double) gigawattdayspertonne; + QuantityValue value = (QuantityValue) gigawattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerTonne); } @@ -520,7 +523,7 @@ public static SpecificEnergy FromGigawattDaysPerTonne(QuantityValue gigawattdays /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattHoursPerKilogram(QuantityValue gigawatthoursperkilogram) { - double value = (double) gigawatthoursperkilogram; + QuantityValue value = (QuantityValue) gigawatthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerKilogram); } @@ -530,7 +533,7 @@ public static SpecificEnergy FromGigawattHoursPerKilogram(QuantityValue gigawatt /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattHoursPerPound(QuantityValue gigawatthoursperpound) { - double value = (double) gigawatthoursperpound; + QuantityValue value = (QuantityValue) gigawatthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerPound); } @@ -540,7 +543,7 @@ public static SpecificEnergy FromGigawattHoursPerPound(QuantityValue gigawatthou /// If value is NaN or Infinity. public static SpecificEnergy FromJoulesPerKilogram(QuantityValue joulesperkilogram) { - double value = (double) joulesperkilogram; + QuantityValue value = (QuantityValue) joulesperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.JoulePerKilogram); } @@ -550,7 +553,7 @@ public static SpecificEnergy FromJoulesPerKilogram(QuantityValue joulesperkilogr /// If value is NaN or Infinity. public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue kilocaloriespergram) { - double value = (double) kilocaloriespergram; + QuantityValue value = (QuantityValue) kilocaloriespergram; return new SpecificEnergy(value, SpecificEnergyUnit.KilocaloriePerGram); } @@ -560,7 +563,7 @@ public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue kilocaloriesp /// If value is NaN or Infinity. public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue kilojoulesperkilogram) { - double value = (double) kilojoulesperkilogram; + QuantityValue value = (QuantityValue) kilojoulesperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.KilojoulePerKilogram); } @@ -570,7 +573,7 @@ public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue kilojoulesp /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattDaysPerKilogram(QuantityValue kilowattdaysperkilogram) { - double value = (double) kilowattdaysperkilogram; + QuantityValue value = (QuantityValue) kilowattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerKilogram); } @@ -580,7 +583,7 @@ public static SpecificEnergy FromKilowattDaysPerKilogram(QuantityValue kilowattd /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattDaysPerShortTon(QuantityValue kilowattdayspershortton) { - double value = (double) kilowattdayspershortton; + QuantityValue value = (QuantityValue) kilowattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerShortTon); } @@ -590,7 +593,7 @@ public static SpecificEnergy FromKilowattDaysPerShortTon(QuantityValue kilowattd /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattDaysPerTonne(QuantityValue kilowattdayspertonne) { - double value = (double) kilowattdayspertonne; + QuantityValue value = (QuantityValue) kilowattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerTonne); } @@ -600,7 +603,7 @@ public static SpecificEnergy FromKilowattDaysPerTonne(QuantityValue kilowattdays /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue kilowatthoursperkilogram) { - double value = (double) kilowatthoursperkilogram; + QuantityValue value = (QuantityValue) kilowatthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerKilogram); } @@ -610,7 +613,7 @@ public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue kilowatt /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattHoursPerPound(QuantityValue kilowatthoursperpound) { - double value = (double) kilowatthoursperpound; + QuantityValue value = (QuantityValue) kilowatthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerPound); } @@ -620,7 +623,7 @@ public static SpecificEnergy FromKilowattHoursPerPound(QuantityValue kilowatthou /// If value is NaN or Infinity. public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue megajoulesperkilogram) { - double value = (double) megajoulesperkilogram; + QuantityValue value = (QuantityValue) megajoulesperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.MegajoulePerKilogram); } @@ -630,7 +633,7 @@ public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue megajoulesp /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattDaysPerKilogram(QuantityValue megawattdaysperkilogram) { - double value = (double) megawattdaysperkilogram; + QuantityValue value = (QuantityValue) megawattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerKilogram); } @@ -640,7 +643,7 @@ public static SpecificEnergy FromMegawattDaysPerKilogram(QuantityValue megawattd /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattDaysPerShortTon(QuantityValue megawattdayspershortton) { - double value = (double) megawattdayspershortton; + QuantityValue value = (QuantityValue) megawattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerShortTon); } @@ -650,7 +653,7 @@ public static SpecificEnergy FromMegawattDaysPerShortTon(QuantityValue megawattd /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattDaysPerTonne(QuantityValue megawattdayspertonne) { - double value = (double) megawattdayspertonne; + QuantityValue value = (QuantityValue) megawattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerTonne); } @@ -660,7 +663,7 @@ public static SpecificEnergy FromMegawattDaysPerTonne(QuantityValue megawattdays /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue megawatthoursperkilogram) { - double value = (double) megawatthoursperkilogram; + QuantityValue value = (QuantityValue) megawatthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerKilogram); } @@ -670,7 +673,7 @@ public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue megawatt /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattHoursPerPound(QuantityValue megawatthoursperpound) { - double value = (double) megawatthoursperpound; + QuantityValue value = (QuantityValue) megawatthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerPound); } @@ -680,7 +683,7 @@ public static SpecificEnergy FromMegawattHoursPerPound(QuantityValue megawatthou /// If value is NaN or Infinity. public static SpecificEnergy FromTerawattDaysPerKilogram(QuantityValue terawattdaysperkilogram) { - double value = (double) terawattdaysperkilogram; + QuantityValue value = (QuantityValue) terawattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerKilogram); } @@ -690,7 +693,7 @@ public static SpecificEnergy FromTerawattDaysPerKilogram(QuantityValue terawattd /// If value is NaN or Infinity. public static SpecificEnergy FromTerawattDaysPerShortTon(QuantityValue terawattdayspershortton) { - double value = (double) terawattdayspershortton; + QuantityValue value = (QuantityValue) terawattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerShortTon); } @@ -700,7 +703,7 @@ public static SpecificEnergy FromTerawattDaysPerShortTon(QuantityValue terawattd /// If value is NaN or Infinity. public static SpecificEnergy FromTerawattDaysPerTonne(QuantityValue terawattdayspertonne) { - double value = (double) terawattdayspertonne; + QuantityValue value = (QuantityValue) terawattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerTonne); } @@ -710,7 +713,7 @@ public static SpecificEnergy FromTerawattDaysPerTonne(QuantityValue terawattdays /// If value is NaN or Infinity. public static SpecificEnergy FromWattDaysPerKilogram(QuantityValue wattdaysperkilogram) { - double value = (double) wattdaysperkilogram; + QuantityValue value = (QuantityValue) wattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerKilogram); } @@ -720,7 +723,7 @@ public static SpecificEnergy FromWattDaysPerKilogram(QuantityValue wattdaysperki /// If value is NaN or Infinity. public static SpecificEnergy FromWattDaysPerShortTon(QuantityValue wattdayspershortton) { - double value = (double) wattdayspershortton; + QuantityValue value = (QuantityValue) wattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerShortTon); } @@ -730,7 +733,7 @@ public static SpecificEnergy FromWattDaysPerShortTon(QuantityValue wattdayspersh /// If value is NaN or Infinity. public static SpecificEnergy FromWattDaysPerTonne(QuantityValue wattdayspertonne) { - double value = (double) wattdayspertonne; + QuantityValue value = (QuantityValue) wattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerTonne); } @@ -740,7 +743,7 @@ public static SpecificEnergy FromWattDaysPerTonne(QuantityValue wattdayspertonne /// If value is NaN or Infinity. public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue watthoursperkilogram) { - double value = (double) watthoursperkilogram; + QuantityValue value = (QuantityValue) watthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerKilogram); } @@ -750,7 +753,7 @@ public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue watthoursper /// If value is NaN or Infinity. public static SpecificEnergy FromWattHoursPerPound(QuantityValue watthoursperpound) { - double value = (double) watthoursperpound; + QuantityValue value = (QuantityValue) watthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerPound); } @@ -762,7 +765,7 @@ public static SpecificEnergy FromWattHoursPerPound(QuantityValue watthoursperpou /// SpecificEnergy unit value. public static SpecificEnergy From(QuantityValue value, SpecificEnergyUnit fromUnit) { - return new SpecificEnergy((double)value, fromUnit); + return new SpecificEnergy((QuantityValue)value, fromUnit); } #endregion @@ -932,25 +935,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificEnergy operator *(double left, SpecificEnergy right) + public static SpecificEnergy operator *(QuantityValue left, SpecificEnergy right) { return new SpecificEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificEnergy operator *(SpecificEnergy left, double right) + public static SpecificEnergy operator *(SpecificEnergy left, QuantityValue right) { return new SpecificEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificEnergy operator /(SpecificEnergy left, double right) + public static SpecificEnergy operator /(SpecificEnergy left, QuantityValue right) { return new SpecificEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificEnergy left, SpecificEnergy right) + public static QuantityValue operator /(SpecificEnergy left, SpecificEnergy right) { return left.JoulesPerKilogram / right.JoulesPerKilogram; } @@ -983,6 +986,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificEnergy left, SpecificEnergy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificEnergy left, SpecificEnergy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -995,7 +1011,29 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificEnergy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is SpecificEnergy objSpecificEnergy)) + return false; + return Equals(objSpecificEnergy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificEnergy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1038,13 +1076,13 @@ public int CompareTo(SpecificEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificEnergy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1055,7 +1093,7 @@ public bool Equals(SpecificEnergy other, double tolerance, ComparisonType compar /// A hash code for the current SpecificEnergy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1066,17 +1104,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEnergyUnit unit) + public QuantityValue As(SpecificEnergyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1091,12 +1128,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) + if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEnergyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1128,7 +1165,7 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (SpecificEnergy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SpecificEnergyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1136,17 +1173,17 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) + if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1173,10 +1210,10 @@ public SpecificEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SpecificEnergyUnit unit) + private QuantityValue GetValueAs(SpecificEnergyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 26c1ea1e6f..7e4bdf3c92 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. /// [DataContract] - public partial struct SpecificEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static SpecificEntropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificEntropy(double value, SpecificEntropyUnit unit) + public SpecificEntropy(QuantityValue value, SpecificEntropyUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -94,14 +94,14 @@ public SpecificEntropy(double value, SpecificEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEntropy(double value, UnitSystem unitSystem) + public SpecificEntropy(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,7 +142,10 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -165,49 +168,49 @@ public SpecificEntropy(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); + public QuantityValue BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); + public QuantityValue CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); + public QuantityValue JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); + public QuantityValue JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); + public QuantityValue KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); + public QuantityValue KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); + public QuantityValue KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); + public QuantityValue MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); + public QuantityValue MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); #endregion @@ -287,7 +290,7 @@ public static string GetAbbreviation(SpecificEntropyUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static SpecificEntropy FromBtusPerPoundFahrenheit(QuantityValue btusperpoundfahrenheit) { - double value = (double) btusperpoundfahrenheit; + QuantityValue value = (QuantityValue) btusperpoundfahrenheit; return new SpecificEntropy(value, SpecificEntropyUnit.BtuPerPoundFahrenheit); } @@ -297,7 +300,7 @@ public static SpecificEntropy FromBtusPerPoundFahrenheit(QuantityValue btusperpo /// If value is NaN or Infinity. public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue caloriespergramkelvin) { - double value = (double) caloriespergramkelvin; + QuantityValue value = (QuantityValue) caloriespergramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.CaloriePerGramKelvin); } @@ -307,7 +310,7 @@ public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue caloriespe /// If value is NaN or Infinity. public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue joulesperkilogramdegreecelsius) { - double value = (double) joulesperkilogramdegreecelsius; + QuantityValue value = (QuantityValue) joulesperkilogramdegreecelsius; return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); } @@ -317,7 +320,7 @@ public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue j /// If value is NaN or Infinity. public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue joulesperkilogramkelvin) { - double value = (double) joulesperkilogramkelvin; + QuantityValue value = (QuantityValue) joulesperkilogramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramKelvin); } @@ -327,7 +330,7 @@ public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue joulespe /// If value is NaN or Infinity. public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue kilocaloriespergramkelvin) { - double value = (double) kilocaloriespergramkelvin; + QuantityValue value = (QuantityValue) kilocaloriespergramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.KilocaloriePerGramKelvin); } @@ -337,7 +340,7 @@ public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue kiloca /// If value is NaN or Infinity. public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityValue kilojoulesperkilogramdegreecelsius) { - double value = (double) kilojoulesperkilogramdegreecelsius; + QuantityValue value = (QuantityValue) kilojoulesperkilogramdegreecelsius; return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); } @@ -347,7 +350,7 @@ public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityVal /// If value is NaN or Infinity. public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue kilojoulesperkilogramkelvin) { - double value = (double) kilojoulesperkilogramkelvin; + QuantityValue value = (QuantityValue) kilojoulesperkilogramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramKelvin); } @@ -357,7 +360,7 @@ public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue kilo /// If value is NaN or Infinity. public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityValue megajoulesperkilogramdegreecelsius) { - double value = (double) megajoulesperkilogramdegreecelsius; + QuantityValue value = (QuantityValue) megajoulesperkilogramdegreecelsius; return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); } @@ -367,7 +370,7 @@ public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityVal /// If value is NaN or Infinity. public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue megajoulesperkilogramkelvin) { - double value = (double) megajoulesperkilogramkelvin; + QuantityValue value = (QuantityValue) megajoulesperkilogramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramKelvin); } @@ -379,7 +382,7 @@ public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue mega /// SpecificEntropy unit value. public static SpecificEntropy From(QuantityValue value, SpecificEntropyUnit fromUnit) { - return new SpecificEntropy((double)value, fromUnit); + return new SpecificEntropy((QuantityValue)value, fromUnit); } #endregion @@ -549,25 +552,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificEntropy operator *(double left, SpecificEntropy right) + public static SpecificEntropy operator *(QuantityValue left, SpecificEntropy right) { return new SpecificEntropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificEntropy operator *(SpecificEntropy left, double right) + public static SpecificEntropy operator *(SpecificEntropy left, QuantityValue right) { return new SpecificEntropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificEntropy operator /(SpecificEntropy left, double right) + public static SpecificEntropy operator /(SpecificEntropy left, QuantityValue right) { return new SpecificEntropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificEntropy left, SpecificEntropy right) + public static QuantityValue operator /(SpecificEntropy left, SpecificEntropy right) { return left.JoulesPerKilogramKelvin / right.JoulesPerKilogramKelvin; } @@ -600,6 +603,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificEntropy left, SpecificEntropy right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificEntropy left, SpecificEntropy right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -612,7 +628,29 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificEntropy other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is SpecificEntropy objSpecificEntropy)) + return false; + return Equals(objSpecificEntropy); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificEntropy other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -655,13 +693,13 @@ public int CompareTo(SpecificEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificEntropy other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -672,7 +710,7 @@ public bool Equals(SpecificEntropy other, double tolerance, ComparisonType compa /// A hash code for the current SpecificEntropy. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -683,17 +721,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificEntropyUnit unit) + public QuantityValue As(SpecificEntropyUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -708,12 +745,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) + if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEntropyUnit); + return (QuantityValue)As(typedUnit); } /// @@ -745,7 +782,7 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (SpecificEntropy)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SpecificEntropyUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -753,17 +790,17 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) + if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -790,10 +827,10 @@ public SpecificEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SpecificEntropyUnit unit) + private QuantityValue GetValueAs(SpecificEntropyUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index e295f67c8e..96cd5c2aee 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption /// [DataContract] - public partial struct SpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static SpecificFuelConsumption() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) + public SpecificFuelConsumption(QuantityValue value, SpecificFuelConsumptionUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificFuelConsumption(double value, UnitSystem unitSystem) + public SpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +166,24 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); + public QuantityValue GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); + public QuantityValue KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); + public QuantityValue KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); + public QuantityValue PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); #endregion @@ -245,7 +248,7 @@ public static string GetAbbreviation(SpecificFuelConsumptionUnit unit, IFormatPr /// If value is NaN or Infinity. public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(QuantityValue gramsperkilonewtonsecond) { - double value = (double) gramsperkilonewtonsecond; + QuantityValue value = (QuantityValue) gramsperkilonewtonsecond; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); } @@ -255,7 +258,7 @@ public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(QuantityValue /// If value is NaN or Infinity. public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(QuantityValue kilogramsperkilogramforcehour) { - double value = (double) kilogramsperkilogramforcehour; + QuantityValue value = (QuantityValue) kilogramsperkilogramforcehour; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); } @@ -265,7 +268,7 @@ public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(Quantity /// If value is NaN or Infinity. public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(QuantityValue kilogramsperkilonewtonsecond) { - double value = (double) kilogramsperkilonewtonsecond; + QuantityValue value = (QuantityValue) kilogramsperkilonewtonsecond; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); } @@ -275,7 +278,7 @@ public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(QuantityV /// If value is NaN or Infinity. public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(QuantityValue poundsmassperpoundforcehour) { - double value = (double) poundsmassperpoundforcehour; + QuantityValue value = (QuantityValue) poundsmassperpoundforcehour; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); } @@ -287,7 +290,7 @@ public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(QuantityVa /// SpecificFuelConsumption unit value. public static SpecificFuelConsumption From(QuantityValue value, SpecificFuelConsumptionUnit fromUnit) { - return new SpecificFuelConsumption((double)value, fromUnit); + return new SpecificFuelConsumption((QuantityValue)value, fromUnit); } #endregion @@ -457,25 +460,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificFuelConsumption operator *(double left, SpecificFuelConsumption right) + public static SpecificFuelConsumption operator *(QuantityValue left, SpecificFuelConsumption right) { return new SpecificFuelConsumption(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificFuelConsumption operator *(SpecificFuelConsumption left, double right) + public static SpecificFuelConsumption operator *(SpecificFuelConsumption left, QuantityValue right) { return new SpecificFuelConsumption(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificFuelConsumption operator /(SpecificFuelConsumption left, double right) + public static SpecificFuelConsumption operator /(SpecificFuelConsumption left, QuantityValue right) { return new SpecificFuelConsumption(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificFuelConsumption left, SpecificFuelConsumption right) + public static QuantityValue operator /(SpecificFuelConsumption left, SpecificFuelConsumption right) { return left.GramsPerKiloNewtonSecond / right.GramsPerKiloNewtonSecond; } @@ -508,6 +511,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificFuelConsumption left, SpecificFuelConsumption right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificFuelConsumption left, SpecificFuelConsumption right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -520,7 +536,29 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificFuelConsumption other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is SpecificFuelConsumption objSpecificFuelConsumption)) + return false; + return Equals(objSpecificFuelConsumption); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificFuelConsumption other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -563,13 +601,13 @@ public int CompareTo(SpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificFuelConsumption other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -580,7 +618,7 @@ public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonTy /// A hash code for the current SpecificFuelConsumption. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -591,17 +629,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificFuelConsumptionUnit unit) + public QuantityValue As(SpecificFuelConsumptionUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -616,12 +653,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) + if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificFuelConsumptionUnit); + return (QuantityValue)As(typedUnit); } /// @@ -653,7 +690,7 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit, UnitConv var converted = conversionFunction(this); return (SpecificFuelConsumption)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SpecificFuelConsumptionUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -661,17 +698,17 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit, UnitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) + if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificFuelConsumptionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -698,10 +735,10 @@ public SpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SpecificFuelConsumptionUnit unit) + private QuantityValue GetValueAs(SpecificFuelConsumptionUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index f15fc45a52..4a7f1dbd7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. /// [DataContract] - public partial struct SpecificVolume : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificVolume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static SpecificVolume() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificVolume(double value, SpecificVolumeUnit unit) + public SpecificVolume(QuantityValue value, SpecificVolumeUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -88,14 +88,14 @@ public SpecificVolume(double value, SpecificVolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificVolume(double value, UnitSystem unitSystem) + public SpecificVolume(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,7 +136,10 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -159,19 +162,19 @@ public SpecificVolume(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); + public QuantityValue CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); + public QuantityValue CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); + public QuantityValue MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); #endregion @@ -233,7 +236,7 @@ public static string GetAbbreviation(SpecificVolumeUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static SpecificVolume FromCubicFeetPerPound(QuantityValue cubicfeetperpound) { - double value = (double) cubicfeetperpound; + QuantityValue value = (QuantityValue) cubicfeetperpound; return new SpecificVolume(value, SpecificVolumeUnit.CubicFootPerPound); } @@ -243,7 +246,7 @@ public static SpecificVolume FromCubicFeetPerPound(QuantityValue cubicfeetperpou /// If value is NaN or Infinity. public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue cubicmetersperkilogram) { - double value = (double) cubicmetersperkilogram; + QuantityValue value = (QuantityValue) cubicmetersperkilogram; return new SpecificVolume(value, SpecificVolumeUnit.CubicMeterPerKilogram); } @@ -253,7 +256,7 @@ public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue cubicmeter /// If value is NaN or Infinity. public static SpecificVolume FromMillicubicMetersPerKilogram(QuantityValue millicubicmetersperkilogram) { - double value = (double) millicubicmetersperkilogram; + QuantityValue value = (QuantityValue) millicubicmetersperkilogram; return new SpecificVolume(value, SpecificVolumeUnit.MillicubicMeterPerKilogram); } @@ -265,7 +268,7 @@ public static SpecificVolume FromMillicubicMetersPerKilogram(QuantityValue milli /// SpecificVolume unit value. public static SpecificVolume From(QuantityValue value, SpecificVolumeUnit fromUnit) { - return new SpecificVolume((double)value, fromUnit); + return new SpecificVolume((QuantityValue)value, fromUnit); } #endregion @@ -435,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificVolume operator *(double left, SpecificVolume right) + public static SpecificVolume operator *(QuantityValue left, SpecificVolume right) { return new SpecificVolume(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificVolume operator *(SpecificVolume left, double right) + public static SpecificVolume operator *(SpecificVolume left, QuantityValue right) { return new SpecificVolume(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificVolume operator /(SpecificVolume left, double right) + public static SpecificVolume operator /(SpecificVolume left, QuantityValue right) { return new SpecificVolume(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificVolume left, SpecificVolume right) + public static QuantityValue operator /(SpecificVolume left, SpecificVolume right) { return left.CubicMetersPerKilogram / right.CubicMetersPerKilogram; } @@ -486,6 +489,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificVolume left, SpecificVolume right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificVolume left, SpecificVolume right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -498,7 +514,29 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificVolume other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is SpecificVolume objSpecificVolume)) + return false; + return Equals(objSpecificVolume); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificVolume other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -541,13 +579,13 @@ public int CompareTo(SpecificVolume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificVolume other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +596,7 @@ public bool Equals(SpecificVolume other, double tolerance, ComparisonType compar /// A hash code for the current SpecificVolume. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -569,17 +607,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificVolumeUnit unit) + public QuantityValue As(SpecificVolumeUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +631,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) + if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificVolumeUnit); + return (QuantityValue)As(typedUnit); } /// @@ -631,7 +668,7 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (SpecificVolume)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SpecificVolumeUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +676,17 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) + if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificVolumeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -676,10 +713,10 @@ public SpecificVolume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SpecificVolumeUnit unit) + private QuantityValue GetValueAs(SpecificVolumeUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 1698dbf5e8..e00a8d857d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Specificweight /// [DataContract] - public partial struct SpecificWeight : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificWeight : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -91,9 +91,9 @@ static SpecificWeight() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificWeight(double value, SpecificWeightUnit unit) + public SpecificWeight(QuantityValue value, SpecificWeightUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -105,14 +105,14 @@ public SpecificWeight(double value, SpecificWeightUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificWeight(double value, UnitSystem unitSystem) + public SpecificWeight(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -153,7 +153,10 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -176,89 +179,89 @@ public SpecificWeight(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); + public QuantityValue KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); + public QuantityValue KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); + public QuantityValue KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); + public QuantityValue KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); + public QuantityValue KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); + public QuantityValue KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); + public QuantityValue KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); + public QuantityValue KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); + public QuantityValue MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); + public QuantityValue NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); + public QuantityValue NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); + public QuantityValue NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); + public QuantityValue PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); + public QuantityValue PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); + public QuantityValue TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); + public QuantityValue TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); + public QuantityValue TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); #endregion @@ -362,7 +365,7 @@ public static string GetAbbreviation(SpecificWeightUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue kilogramsforcepercubiccentimeter) { - double value = (double) kilogramsforcepercubiccentimeter; + QuantityValue value = (QuantityValue) kilogramsforcepercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicCentimeter); } @@ -372,7 +375,7 @@ public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue /// If value is NaN or Infinity. public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue kilogramsforcepercubicmeter) { - double value = (double) kilogramsforcepercubicmeter; + QuantityValue value = (QuantityValue) kilogramsforcepercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMeter); } @@ -382,7 +385,7 @@ public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue kilog /// If value is NaN or Infinity. public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue kilogramsforcepercubicmillimeter) { - double value = (double) kilogramsforcepercubicmillimeter; + QuantityValue value = (QuantityValue) kilogramsforcepercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMillimeter); } @@ -392,7 +395,7 @@ public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue /// If value is NaN or Infinity. public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue kilonewtonspercubiccentimeter) { - double value = (double) kilonewtonspercubiccentimeter; + QuantityValue value = (QuantityValue) kilonewtonspercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicCentimeter); } @@ -402,7 +405,7 @@ public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue kil /// If value is NaN or Infinity. public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue kilonewtonspercubicmeter) { - double value = (double) kilonewtonspercubicmeter; + QuantityValue value = (QuantityValue) kilonewtonspercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMeter); } @@ -412,7 +415,7 @@ public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue kilonewtonspercubicmillimeter) { - double value = (double) kilonewtonspercubicmillimeter; + QuantityValue value = (QuantityValue) kilonewtonspercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMillimeter); } @@ -422,7 +425,7 @@ public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue kil /// If value is NaN or Infinity. public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue kilopoundsforcepercubicfoot) { - double value = (double) kilopoundsforcepercubicfoot; + QuantityValue value = (QuantityValue) kilopoundsforcepercubicfoot; return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicFoot); } @@ -432,7 +435,7 @@ public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue kilop /// If value is NaN or Infinity. public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue kilopoundsforcepercubicinch) { - double value = (double) kilopoundsforcepercubicinch; + QuantityValue value = (QuantityValue) kilopoundsforcepercubicinch; return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicInch); } @@ -442,7 +445,7 @@ public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue kilop /// If value is NaN or Infinity. public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue meganewtonspercubicmeter) { - double value = (double) meganewtonspercubicmeter; + QuantityValue value = (QuantityValue) meganewtonspercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.MeganewtonPerCubicMeter); } @@ -452,7 +455,7 @@ public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue meganewt /// If value is NaN or Infinity. public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue newtonspercubiccentimeter) { - double value = (double) newtonspercubiccentimeter; + QuantityValue value = (QuantityValue) newtonspercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicCentimeter); } @@ -462,7 +465,7 @@ public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue newtons /// If value is NaN or Infinity. public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue newtonspercubicmeter) { - double value = (double) newtonspercubicmeter; + QuantityValue value = (QuantityValue) newtonspercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMeter); } @@ -472,7 +475,7 @@ public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue newtonspercu /// If value is NaN or Infinity. public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue newtonspercubicmillimeter) { - double value = (double) newtonspercubicmillimeter; + QuantityValue value = (QuantityValue) newtonspercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMillimeter); } @@ -482,7 +485,7 @@ public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue newtons /// If value is NaN or Infinity. public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue poundsforcepercubicfoot) { - double value = (double) poundsforcepercubicfoot; + QuantityValue value = (QuantityValue) poundsforcepercubicfoot; return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicFoot); } @@ -492,7 +495,7 @@ public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue poundsfor /// If value is NaN or Infinity. public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue poundsforcepercubicinch) { - double value = (double) poundsforcepercubicinch; + QuantityValue value = (QuantityValue) poundsforcepercubicinch; return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicInch); } @@ -502,7 +505,7 @@ public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue poundsfor /// If value is NaN or Infinity. public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue tonnesforcepercubiccentimeter) { - double value = (double) tonnesforcepercubiccentimeter; + QuantityValue value = (QuantityValue) tonnesforcepercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicCentimeter); } @@ -512,7 +515,7 @@ public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue ton /// If value is NaN or Infinity. public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue tonnesforcepercubicmeter) { - double value = (double) tonnesforcepercubicmeter; + QuantityValue value = (QuantityValue) tonnesforcepercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMeter); } @@ -522,7 +525,7 @@ public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue tonnesforcepercubicmillimeter) { - double value = (double) tonnesforcepercubicmillimeter; + QuantityValue value = (QuantityValue) tonnesforcepercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMillimeter); } @@ -534,7 +537,7 @@ public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue ton /// SpecificWeight unit value. public static SpecificWeight From(QuantityValue value, SpecificWeightUnit fromUnit) { - return new SpecificWeight((double)value, fromUnit); + return new SpecificWeight((QuantityValue)value, fromUnit); } #endregion @@ -704,25 +707,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificWeight operator *(double left, SpecificWeight right) + public static SpecificWeight operator *(QuantityValue left, SpecificWeight right) { return new SpecificWeight(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificWeight operator *(SpecificWeight left, double right) + public static SpecificWeight operator *(SpecificWeight left, QuantityValue right) { return new SpecificWeight(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificWeight operator /(SpecificWeight left, double right) + public static SpecificWeight operator /(SpecificWeight left, QuantityValue right) { return new SpecificWeight(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(SpecificWeight left, SpecificWeight right) + public static QuantityValue operator /(SpecificWeight left, SpecificWeight right) { return left.NewtonsPerCubicMeter / right.NewtonsPerCubicMeter; } @@ -755,6 +758,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(SpecificWeight left, SpecificWeight right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(SpecificWeight left, SpecificWeight right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -767,7 +783,29 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificWeight other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is SpecificWeight objSpecificWeight)) + return false; + return Equals(objSpecificWeight); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(SpecificWeight other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -810,13 +848,13 @@ public int CompareTo(SpecificWeight other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType) + public bool Equals(SpecificWeight other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -827,7 +865,7 @@ public bool Equals(SpecificWeight other, double tolerance, ComparisonType compar /// A hash code for the current SpecificWeight. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -838,17 +876,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpecificWeightUnit unit) + public QuantityValue As(SpecificWeightUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -863,12 +900,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) + if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificWeightUnit); + return (QuantityValue)As(typedUnit); } /// @@ -900,7 +937,7 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (SpecificWeight)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SpecificWeightUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -908,17 +945,17 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit, UnitConverter unitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) + if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificWeightUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -945,10 +982,10 @@ public SpecificWeight ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SpecificWeightUnit unit) + private QuantityValue GetValueAs(SpecificWeightUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index f064d928b9..e28ac87c05 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. /// [DataContract] - public partial struct Speed : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Speed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -103,9 +103,9 @@ static Speed() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Speed(double value, SpeedUnit unit) + public Speed(QuantityValue value, SpeedUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -117,14 +117,14 @@ public Speed(double value, SpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Speed(double value, UnitSystem unitSystem) + public Speed(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -165,7 +165,10 @@ public Speed(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -188,164 +191,164 @@ public Speed(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); + public QuantityValue CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); + public QuantityValue CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); + public QuantityValue CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); + public QuantityValue DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); + public QuantityValue DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetPerHour => As(SpeedUnit.FootPerHour); + public QuantityValue FeetPerHour => As(SpeedUnit.FootPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetPerMinute => As(SpeedUnit.FootPerMinute); + public QuantityValue FeetPerMinute => As(SpeedUnit.FootPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetPerSecond => As(SpeedUnit.FootPerSecond); + public QuantityValue FeetPerSecond => As(SpeedUnit.FootPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesPerHour => As(SpeedUnit.InchPerHour); + public QuantityValue InchesPerHour => As(SpeedUnit.InchPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesPerMinute => As(SpeedUnit.InchPerMinute); + public QuantityValue InchesPerMinute => As(SpeedUnit.InchPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesPerSecond => As(SpeedUnit.InchPerSecond); + public QuantityValue InchesPerSecond => As(SpeedUnit.InchPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilometersPerHour => As(SpeedUnit.KilometerPerHour); + public QuantityValue KilometersPerHour => As(SpeedUnit.KilometerPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); + public QuantityValue KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); + public QuantityValue KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Knots => As(SpeedUnit.Knot); + public QuantityValue Knots => As(SpeedUnit.Knot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersPerHour => As(SpeedUnit.MeterPerHour); + public QuantityValue MetersPerHour => As(SpeedUnit.MeterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersPerMinutes => As(SpeedUnit.MeterPerMinute); + public QuantityValue MetersPerMinutes => As(SpeedUnit.MeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersPerSecond => As(SpeedUnit.MeterPerSecond); + public QuantityValue MetersPerSecond => As(SpeedUnit.MeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); + public QuantityValue MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); + public QuantityValue MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MilesPerHour => As(SpeedUnit.MilePerHour); + public QuantityValue MilesPerHour => As(SpeedUnit.MilePerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); + public QuantityValue MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); + public QuantityValue MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); + public QuantityValue MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); + public QuantityValue NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); + public QuantityValue NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); + public QuantityValue UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); + public QuantityValue UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); + public QuantityValue UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double YardsPerHour => As(SpeedUnit.YardPerHour); + public QuantityValue YardsPerHour => As(SpeedUnit.YardPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double YardsPerMinute => As(SpeedUnit.YardPerMinute); + public QuantityValue YardsPerMinute => As(SpeedUnit.YardPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double YardsPerSecond => As(SpeedUnit.YardPerSecond); + public QuantityValue YardsPerSecond => As(SpeedUnit.YardPerSecond); #endregion @@ -517,7 +520,7 @@ public static string GetAbbreviation(SpeedUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Speed FromCentimetersPerHour(QuantityValue centimetersperhour) { - double value = (double) centimetersperhour; + QuantityValue value = (QuantityValue) centimetersperhour; return new Speed(value, SpeedUnit.CentimeterPerHour); } @@ -527,7 +530,7 @@ public static Speed FromCentimetersPerHour(QuantityValue centimetersperhour) /// If value is NaN or Infinity. public static Speed FromCentimetersPerMinutes(QuantityValue centimetersperminutes) { - double value = (double) centimetersperminutes; + QuantityValue value = (QuantityValue) centimetersperminutes; return new Speed(value, SpeedUnit.CentimeterPerMinute); } @@ -537,7 +540,7 @@ public static Speed FromCentimetersPerMinutes(QuantityValue centimetersperminute /// If value is NaN or Infinity. public static Speed FromCentimetersPerSecond(QuantityValue centimeterspersecond) { - double value = (double) centimeterspersecond; + QuantityValue value = (QuantityValue) centimeterspersecond; return new Speed(value, SpeedUnit.CentimeterPerSecond); } @@ -547,7 +550,7 @@ public static Speed FromCentimetersPerSecond(QuantityValue centimeterspersecond) /// If value is NaN or Infinity. public static Speed FromDecimetersPerMinutes(QuantityValue decimetersperminutes) { - double value = (double) decimetersperminutes; + QuantityValue value = (QuantityValue) decimetersperminutes; return new Speed(value, SpeedUnit.DecimeterPerMinute); } @@ -557,7 +560,7 @@ public static Speed FromDecimetersPerMinutes(QuantityValue decimetersperminutes) /// If value is NaN or Infinity. public static Speed FromDecimetersPerSecond(QuantityValue decimeterspersecond) { - double value = (double) decimeterspersecond; + QuantityValue value = (QuantityValue) decimeterspersecond; return new Speed(value, SpeedUnit.DecimeterPerSecond); } @@ -567,7 +570,7 @@ public static Speed FromDecimetersPerSecond(QuantityValue decimeterspersecond) /// If value is NaN or Infinity. public static Speed FromFeetPerHour(QuantityValue feetperhour) { - double value = (double) feetperhour; + QuantityValue value = (QuantityValue) feetperhour; return new Speed(value, SpeedUnit.FootPerHour); } @@ -577,7 +580,7 @@ public static Speed FromFeetPerHour(QuantityValue feetperhour) /// If value is NaN or Infinity. public static Speed FromFeetPerMinute(QuantityValue feetperminute) { - double value = (double) feetperminute; + QuantityValue value = (QuantityValue) feetperminute; return new Speed(value, SpeedUnit.FootPerMinute); } @@ -587,7 +590,7 @@ public static Speed FromFeetPerMinute(QuantityValue feetperminute) /// If value is NaN or Infinity. public static Speed FromFeetPerSecond(QuantityValue feetpersecond) { - double value = (double) feetpersecond; + QuantityValue value = (QuantityValue) feetpersecond; return new Speed(value, SpeedUnit.FootPerSecond); } @@ -597,7 +600,7 @@ public static Speed FromFeetPerSecond(QuantityValue feetpersecond) /// If value is NaN or Infinity. public static Speed FromInchesPerHour(QuantityValue inchesperhour) { - double value = (double) inchesperhour; + QuantityValue value = (QuantityValue) inchesperhour; return new Speed(value, SpeedUnit.InchPerHour); } @@ -607,7 +610,7 @@ public static Speed FromInchesPerHour(QuantityValue inchesperhour) /// If value is NaN or Infinity. public static Speed FromInchesPerMinute(QuantityValue inchesperminute) { - double value = (double) inchesperminute; + QuantityValue value = (QuantityValue) inchesperminute; return new Speed(value, SpeedUnit.InchPerMinute); } @@ -617,7 +620,7 @@ public static Speed FromInchesPerMinute(QuantityValue inchesperminute) /// If value is NaN or Infinity. public static Speed FromInchesPerSecond(QuantityValue inchespersecond) { - double value = (double) inchespersecond; + QuantityValue value = (QuantityValue) inchespersecond; return new Speed(value, SpeedUnit.InchPerSecond); } @@ -627,7 +630,7 @@ public static Speed FromInchesPerSecond(QuantityValue inchespersecond) /// If value is NaN or Infinity. public static Speed FromKilometersPerHour(QuantityValue kilometersperhour) { - double value = (double) kilometersperhour; + QuantityValue value = (QuantityValue) kilometersperhour; return new Speed(value, SpeedUnit.KilometerPerHour); } @@ -637,7 +640,7 @@ public static Speed FromKilometersPerHour(QuantityValue kilometersperhour) /// If value is NaN or Infinity. public static Speed FromKilometersPerMinutes(QuantityValue kilometersperminutes) { - double value = (double) kilometersperminutes; + QuantityValue value = (QuantityValue) kilometersperminutes; return new Speed(value, SpeedUnit.KilometerPerMinute); } @@ -647,7 +650,7 @@ public static Speed FromKilometersPerMinutes(QuantityValue kilometersperminutes) /// If value is NaN or Infinity. public static Speed FromKilometersPerSecond(QuantityValue kilometerspersecond) { - double value = (double) kilometerspersecond; + QuantityValue value = (QuantityValue) kilometerspersecond; return new Speed(value, SpeedUnit.KilometerPerSecond); } @@ -657,7 +660,7 @@ public static Speed FromKilometersPerSecond(QuantityValue kilometerspersecond) /// If value is NaN or Infinity. public static Speed FromKnots(QuantityValue knots) { - double value = (double) knots; + QuantityValue value = (QuantityValue) knots; return new Speed(value, SpeedUnit.Knot); } @@ -667,7 +670,7 @@ public static Speed FromKnots(QuantityValue knots) /// If value is NaN or Infinity. public static Speed FromMetersPerHour(QuantityValue metersperhour) { - double value = (double) metersperhour; + QuantityValue value = (QuantityValue) metersperhour; return new Speed(value, SpeedUnit.MeterPerHour); } @@ -677,7 +680,7 @@ public static Speed FromMetersPerHour(QuantityValue metersperhour) /// If value is NaN or Infinity. public static Speed FromMetersPerMinutes(QuantityValue metersperminutes) { - double value = (double) metersperminutes; + QuantityValue value = (QuantityValue) metersperminutes; return new Speed(value, SpeedUnit.MeterPerMinute); } @@ -687,7 +690,7 @@ public static Speed FromMetersPerMinutes(QuantityValue metersperminutes) /// If value is NaN or Infinity. public static Speed FromMetersPerSecond(QuantityValue meterspersecond) { - double value = (double) meterspersecond; + QuantityValue value = (QuantityValue) meterspersecond; return new Speed(value, SpeedUnit.MeterPerSecond); } @@ -697,7 +700,7 @@ public static Speed FromMetersPerSecond(QuantityValue meterspersecond) /// If value is NaN or Infinity. public static Speed FromMicrometersPerMinutes(QuantityValue micrometersperminutes) { - double value = (double) micrometersperminutes; + QuantityValue value = (QuantityValue) micrometersperminutes; return new Speed(value, SpeedUnit.MicrometerPerMinute); } @@ -707,7 +710,7 @@ public static Speed FromMicrometersPerMinutes(QuantityValue micrometersperminute /// If value is NaN or Infinity. public static Speed FromMicrometersPerSecond(QuantityValue micrometerspersecond) { - double value = (double) micrometerspersecond; + QuantityValue value = (QuantityValue) micrometerspersecond; return new Speed(value, SpeedUnit.MicrometerPerSecond); } @@ -717,7 +720,7 @@ public static Speed FromMicrometersPerSecond(QuantityValue micrometerspersecond) /// If value is NaN or Infinity. public static Speed FromMilesPerHour(QuantityValue milesperhour) { - double value = (double) milesperhour; + QuantityValue value = (QuantityValue) milesperhour; return new Speed(value, SpeedUnit.MilePerHour); } @@ -727,7 +730,7 @@ public static Speed FromMilesPerHour(QuantityValue milesperhour) /// If value is NaN or Infinity. public static Speed FromMillimetersPerHour(QuantityValue millimetersperhour) { - double value = (double) millimetersperhour; + QuantityValue value = (QuantityValue) millimetersperhour; return new Speed(value, SpeedUnit.MillimeterPerHour); } @@ -737,7 +740,7 @@ public static Speed FromMillimetersPerHour(QuantityValue millimetersperhour) /// If value is NaN or Infinity. public static Speed FromMillimetersPerMinutes(QuantityValue millimetersperminutes) { - double value = (double) millimetersperminutes; + QuantityValue value = (QuantityValue) millimetersperminutes; return new Speed(value, SpeedUnit.MillimeterPerMinute); } @@ -747,7 +750,7 @@ public static Speed FromMillimetersPerMinutes(QuantityValue millimetersperminute /// If value is NaN or Infinity. public static Speed FromMillimetersPerSecond(QuantityValue millimeterspersecond) { - double value = (double) millimeterspersecond; + QuantityValue value = (QuantityValue) millimeterspersecond; return new Speed(value, SpeedUnit.MillimeterPerSecond); } @@ -757,7 +760,7 @@ public static Speed FromMillimetersPerSecond(QuantityValue millimeterspersecond) /// If value is NaN or Infinity. public static Speed FromNanometersPerMinutes(QuantityValue nanometersperminutes) { - double value = (double) nanometersperminutes; + QuantityValue value = (QuantityValue) nanometersperminutes; return new Speed(value, SpeedUnit.NanometerPerMinute); } @@ -767,7 +770,7 @@ public static Speed FromNanometersPerMinutes(QuantityValue nanometersperminutes) /// If value is NaN or Infinity. public static Speed FromNanometersPerSecond(QuantityValue nanometerspersecond) { - double value = (double) nanometerspersecond; + QuantityValue value = (QuantityValue) nanometerspersecond; return new Speed(value, SpeedUnit.NanometerPerSecond); } @@ -777,7 +780,7 @@ public static Speed FromNanometersPerSecond(QuantityValue nanometerspersecond) /// If value is NaN or Infinity. public static Speed FromUsSurveyFeetPerHour(QuantityValue ussurveyfeetperhour) { - double value = (double) ussurveyfeetperhour; + QuantityValue value = (QuantityValue) ussurveyfeetperhour; return new Speed(value, SpeedUnit.UsSurveyFootPerHour); } @@ -787,7 +790,7 @@ public static Speed FromUsSurveyFeetPerHour(QuantityValue ussurveyfeetperhour) /// If value is NaN or Infinity. public static Speed FromUsSurveyFeetPerMinute(QuantityValue ussurveyfeetperminute) { - double value = (double) ussurveyfeetperminute; + QuantityValue value = (QuantityValue) ussurveyfeetperminute; return new Speed(value, SpeedUnit.UsSurveyFootPerMinute); } @@ -797,7 +800,7 @@ public static Speed FromUsSurveyFeetPerMinute(QuantityValue ussurveyfeetperminut /// If value is NaN or Infinity. public static Speed FromUsSurveyFeetPerSecond(QuantityValue ussurveyfeetpersecond) { - double value = (double) ussurveyfeetpersecond; + QuantityValue value = (QuantityValue) ussurveyfeetpersecond; return new Speed(value, SpeedUnit.UsSurveyFootPerSecond); } @@ -807,7 +810,7 @@ public static Speed FromUsSurveyFeetPerSecond(QuantityValue ussurveyfeetpersecon /// If value is NaN or Infinity. public static Speed FromYardsPerHour(QuantityValue yardsperhour) { - double value = (double) yardsperhour; + QuantityValue value = (QuantityValue) yardsperhour; return new Speed(value, SpeedUnit.YardPerHour); } @@ -817,7 +820,7 @@ public static Speed FromYardsPerHour(QuantityValue yardsperhour) /// If value is NaN or Infinity. public static Speed FromYardsPerMinute(QuantityValue yardsperminute) { - double value = (double) yardsperminute; + QuantityValue value = (QuantityValue) yardsperminute; return new Speed(value, SpeedUnit.YardPerMinute); } @@ -827,7 +830,7 @@ public static Speed FromYardsPerMinute(QuantityValue yardsperminute) /// If value is NaN or Infinity. public static Speed FromYardsPerSecond(QuantityValue yardspersecond) { - double value = (double) yardspersecond; + QuantityValue value = (QuantityValue) yardspersecond; return new Speed(value, SpeedUnit.YardPerSecond); } @@ -839,7 +842,7 @@ public static Speed FromYardsPerSecond(QuantityValue yardspersecond) /// Speed unit value. public static Speed From(QuantityValue value, SpeedUnit fromUnit) { - return new Speed((double)value, fromUnit); + return new Speed((QuantityValue)value, fromUnit); } #endregion @@ -1009,25 +1012,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed } /// Get from multiplying value and . - public static Speed operator *(double left, Speed right) + public static Speed operator *(QuantityValue left, Speed right) { return new Speed(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Speed operator *(Speed left, double right) + public static Speed operator *(Speed left, QuantityValue right) { return new Speed(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Speed operator /(Speed left, double right) + public static Speed operator /(Speed left, QuantityValue right) { return new Speed(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Speed left, Speed right) + public static QuantityValue operator /(Speed left, Speed right) { return left.MetersPerSecond / right.MetersPerSecond; } @@ -1060,6 +1063,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Speed left, Speed right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Speed left, Speed right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1072,7 +1088,29 @@ public int CompareTo(object obj) /// public int CompareTo(Speed other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Speed objSpeed)) + return false; + return Equals(objSpeed); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Speed other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1115,13 +1153,13 @@ public int CompareTo(Speed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) + public bool Equals(Speed other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1132,7 +1170,7 @@ public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) /// A hash code for the current Speed. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1143,17 +1181,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(SpeedUnit unit) + public QuantityValue As(SpeedUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1168,12 +1205,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is SpeedUnit unitAsSpeedUnit)) + if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return As(unitAsSpeedUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1205,7 +1242,7 @@ public Speed ToUnit(SpeedUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Speed)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(SpeedUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1213,17 +1250,17 @@ public Speed ToUnit(SpeedUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpeedUnit unitAsSpeedUnit)) + if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpeedUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1250,10 +1287,10 @@ public Speed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(SpeedUnit unit) + private QuantityValue GetValueAs(SpeedUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 9267650cd1..9cc738ec93 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions. /// [DataContract] - public partial struct StandardVolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct StandardVolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static StandardVolumeFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) + public StandardVolumeFlow(QuantityValue value, StandardVolumeFlowUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -94,14 +94,14 @@ public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public StandardVolumeFlow(double value, UnitSystem unitSystem) + public StandardVolumeFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,7 +142,10 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -165,49 +168,49 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); + public QuantityValue StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); + public QuantityValue StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); + public QuantityValue StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); + public QuantityValue StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); + public QuantityValue StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); + public QuantityValue StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); + public QuantityValue StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); + public QuantityValue StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); + public QuantityValue StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); #endregion @@ -287,7 +290,7 @@ public static string GetAbbreviation(StandardVolumeFlowUnit unit, IFormatProvide /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(QuantityValue standardcubiccentimetersperminute) { - double value = (double) standardcubiccentimetersperminute; + QuantityValue value = (QuantityValue) standardcubiccentimetersperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); } @@ -297,7 +300,7 @@ public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(QuantityV /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicFeetPerHour(QuantityValue standardcubicfeetperhour) { - double value = (double) standardcubicfeetperhour; + QuantityValue value = (QuantityValue) standardcubicfeetperhour; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerHour); } @@ -307,7 +310,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerHour(QuantityValue stan /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicFeetPerMinute(QuantityValue standardcubicfeetperminute) { - double value = (double) standardcubicfeetperminute; + QuantityValue value = (QuantityValue) standardcubicfeetperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerMinute); } @@ -317,7 +320,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerMinute(QuantityValue st /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicFeetPerSecond(QuantityValue standardcubicfeetpersecond) { - double value = (double) standardcubicfeetpersecond; + QuantityValue value = (QuantityValue) standardcubicfeetpersecond; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerSecond); } @@ -327,7 +330,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerSecond(QuantityValue st /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerDay(QuantityValue standardcubicmetersperday) { - double value = (double) standardcubicmetersperday; + QuantityValue value = (QuantityValue) standardcubicmetersperday; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerDay); } @@ -337,7 +340,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerDay(QuantityValue sta /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerHour(QuantityValue standardcubicmetersperhour) { - double value = (double) standardcubicmetersperhour; + QuantityValue value = (QuantityValue) standardcubicmetersperhour; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerHour); } @@ -347,7 +350,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerHour(QuantityValue st /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerMinute(QuantityValue standardcubicmetersperminute) { - double value = (double) standardcubicmetersperminute; + QuantityValue value = (QuantityValue) standardcubicmetersperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerMinute); } @@ -357,7 +360,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerMinute(QuantityValue /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerSecond(QuantityValue standardcubicmeterspersecond) { - double value = (double) standardcubicmeterspersecond; + QuantityValue value = (QuantityValue) standardcubicmeterspersecond; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerSecond); } @@ -367,7 +370,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerSecond(QuantityValue /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardLitersPerMinute(QuantityValue standardlitersperminute) { - double value = (double) standardlitersperminute; + QuantityValue value = (QuantityValue) standardlitersperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardLiterPerMinute); } @@ -379,7 +382,7 @@ public static StandardVolumeFlow FromStandardLitersPerMinute(QuantityValue stand /// StandardVolumeFlow unit value. public static StandardVolumeFlow From(QuantityValue value, StandardVolumeFlowUnit fromUnit) { - return new StandardVolumeFlow((double)value, fromUnit); + return new StandardVolumeFlow((QuantityValue)value, fromUnit); } #endregion @@ -549,25 +552,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand } /// Get from multiplying value and . - public static StandardVolumeFlow operator *(double left, StandardVolumeFlow right) + public static StandardVolumeFlow operator *(QuantityValue left, StandardVolumeFlow right) { return new StandardVolumeFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static StandardVolumeFlow operator *(StandardVolumeFlow left, double right) + public static StandardVolumeFlow operator *(StandardVolumeFlow left, QuantityValue right) { return new StandardVolumeFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static StandardVolumeFlow operator /(StandardVolumeFlow left, double right) + public static StandardVolumeFlow operator /(StandardVolumeFlow left, QuantityValue right) { return new StandardVolumeFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(StandardVolumeFlow left, StandardVolumeFlow right) + public static QuantityValue operator /(StandardVolumeFlow left, StandardVolumeFlow right) { return left.StandardCubicMetersPerSecond / right.StandardCubicMetersPerSecond; } @@ -600,6 +603,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(StandardVolumeFlow left, StandardVolumeFlow right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(StandardVolumeFlow left, StandardVolumeFlow right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -612,7 +628,29 @@ public int CompareTo(object obj) /// public int CompareTo(StandardVolumeFlow other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is StandardVolumeFlow objStandardVolumeFlow)) + return false; + return Equals(objStandardVolumeFlow); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(StandardVolumeFlow other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -655,13 +693,13 @@ public int CompareTo(StandardVolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType comparisonType) + public bool Equals(StandardVolumeFlow other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -672,7 +710,7 @@ public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType co /// A hash code for the current StandardVolumeFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -683,17 +721,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(StandardVolumeFlowUnit unit) + public QuantityValue As(StandardVolumeFlowUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -708,12 +745,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) + if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsStandardVolumeFlowUnit); + return (QuantityValue)As(typedUnit); } /// @@ -745,7 +782,7 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit, UnitConverter unit var converted = conversionFunction(this); return (StandardVolumeFlow)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(StandardVolumeFlowUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -753,17 +790,17 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit, UnitConverter unit } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) + if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsStandardVolumeFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -790,10 +827,10 @@ public StandardVolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(StandardVolumeFlowUnit unit) + private QuantityValue GetValueAs(StandardVolumeFlowUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 9b314a7349..82d5b8ebe8 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. /// [DataContract] - public partial struct Temperature : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Temperature : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static Temperature() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Temperature(double value, TemperatureUnit unit) + public Temperature(QuantityValue value, TemperatureUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -95,14 +95,14 @@ public Temperature(double value, TemperatureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Temperature(double value, UnitSystem unitSystem) + public Temperature(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,7 +143,10 @@ public Temperature(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -166,54 +169,54 @@ public Temperature(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelsius => As(TemperatureUnit.DegreeCelsius); + public QuantityValue DegreesCelsius => As(TemperatureUnit.DegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesDelisle => As(TemperatureUnit.DegreeDelisle); + public QuantityValue DegreesDelisle => As(TemperatureUnit.DegreeDelisle); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); + public QuantityValue DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesNewton => As(TemperatureUnit.DegreeNewton); + public QuantityValue DegreesNewton => As(TemperatureUnit.DegreeNewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesRankine => As(TemperatureUnit.DegreeRankine); + public QuantityValue DegreesRankine => As(TemperatureUnit.DegreeRankine); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesReaumur => As(TemperatureUnit.DegreeReaumur); + public QuantityValue DegreesReaumur => As(TemperatureUnit.DegreeReaumur); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesRoemer => As(TemperatureUnit.DegreeRoemer); + public QuantityValue DegreesRoemer => As(TemperatureUnit.DegreeRoemer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kelvins => As(TemperatureUnit.Kelvin); + public QuantityValue Kelvins => As(TemperatureUnit.Kelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); + public QuantityValue MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SolarTemperatures => As(TemperatureUnit.SolarTemperature); + public QuantityValue SolarTemperatures => As(TemperatureUnit.SolarTemperature); #endregion @@ -296,7 +299,7 @@ public static string GetAbbreviation(TemperatureUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Temperature FromDegreesCelsius(QuantityValue degreescelsius) { - double value = (double) degreescelsius; + QuantityValue value = (QuantityValue) degreescelsius; return new Temperature(value, TemperatureUnit.DegreeCelsius); } @@ -306,7 +309,7 @@ public static Temperature FromDegreesCelsius(QuantityValue degreescelsius) /// If value is NaN or Infinity. public static Temperature FromDegreesDelisle(QuantityValue degreesdelisle) { - double value = (double) degreesdelisle; + QuantityValue value = (QuantityValue) degreesdelisle; return new Temperature(value, TemperatureUnit.DegreeDelisle); } @@ -316,7 +319,7 @@ public static Temperature FromDegreesDelisle(QuantityValue degreesdelisle) /// If value is NaN or Infinity. public static Temperature FromDegreesFahrenheit(QuantityValue degreesfahrenheit) { - double value = (double) degreesfahrenheit; + QuantityValue value = (QuantityValue) degreesfahrenheit; return new Temperature(value, TemperatureUnit.DegreeFahrenheit); } @@ -326,7 +329,7 @@ public static Temperature FromDegreesFahrenheit(QuantityValue degreesfahrenheit) /// If value is NaN or Infinity. public static Temperature FromDegreesNewton(QuantityValue degreesnewton) { - double value = (double) degreesnewton; + QuantityValue value = (QuantityValue) degreesnewton; return new Temperature(value, TemperatureUnit.DegreeNewton); } @@ -336,7 +339,7 @@ public static Temperature FromDegreesNewton(QuantityValue degreesnewton) /// If value is NaN or Infinity. public static Temperature FromDegreesRankine(QuantityValue degreesrankine) { - double value = (double) degreesrankine; + QuantityValue value = (QuantityValue) degreesrankine; return new Temperature(value, TemperatureUnit.DegreeRankine); } @@ -346,7 +349,7 @@ public static Temperature FromDegreesRankine(QuantityValue degreesrankine) /// If value is NaN or Infinity. public static Temperature FromDegreesReaumur(QuantityValue degreesreaumur) { - double value = (double) degreesreaumur; + QuantityValue value = (QuantityValue) degreesreaumur; return new Temperature(value, TemperatureUnit.DegreeReaumur); } @@ -356,7 +359,7 @@ public static Temperature FromDegreesReaumur(QuantityValue degreesreaumur) /// If value is NaN or Infinity. public static Temperature FromDegreesRoemer(QuantityValue degreesroemer) { - double value = (double) degreesroemer; + QuantityValue value = (QuantityValue) degreesroemer; return new Temperature(value, TemperatureUnit.DegreeRoemer); } @@ -366,7 +369,7 @@ public static Temperature FromDegreesRoemer(QuantityValue degreesroemer) /// If value is NaN or Infinity. public static Temperature FromKelvins(QuantityValue kelvins) { - double value = (double) kelvins; + QuantityValue value = (QuantityValue) kelvins; return new Temperature(value, TemperatureUnit.Kelvin); } @@ -376,7 +379,7 @@ public static Temperature FromKelvins(QuantityValue kelvins) /// If value is NaN or Infinity. public static Temperature FromMillidegreesCelsius(QuantityValue millidegreescelsius) { - double value = (double) millidegreescelsius; + QuantityValue value = (QuantityValue) millidegreescelsius; return new Temperature(value, TemperatureUnit.MillidegreeCelsius); } @@ -386,7 +389,7 @@ public static Temperature FromMillidegreesCelsius(QuantityValue millidegreescels /// If value is NaN or Infinity. public static Temperature FromSolarTemperatures(QuantityValue solartemperatures) { - double value = (double) solartemperatures; + QuantityValue value = (QuantityValue) solartemperatures; return new Temperature(value, TemperatureUnit.SolarTemperature); } @@ -398,7 +401,7 @@ public static Temperature FromSolarTemperatures(QuantityValue solartemperatures) /// Temperature unit value. public static Temperature From(QuantityValue value, TemperatureUnit fromUnit) { - return new Temperature((double)value, fromUnit); + return new Temperature((QuantityValue)value, fromUnit); } #endregion @@ -573,6 +576,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Temperature left, Temperature right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Temperature left, Temperature right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -585,7 +601,29 @@ public int CompareTo(object obj) /// public int CompareTo(Temperature other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Temperature objTemperature)) + return false; + return Equals(objTemperature); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Temperature other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -628,13 +666,13 @@ public int CompareTo(Temperature other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType) + public bool Equals(Temperature other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -645,7 +683,7 @@ public bool Equals(Temperature other, double tolerance, ComparisonType compariso /// A hash code for the current Temperature. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -656,17 +694,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureUnit unit) + public QuantityValue As(TemperatureUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -681,12 +718,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TemperatureUnit unitAsTemperatureUnit)) + if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureUnit); + return (QuantityValue)As(typedUnit); } /// @@ -718,7 +755,7 @@ public Temperature ToUnit(TemperatureUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Temperature)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TemperatureUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -726,17 +763,17 @@ public Temperature ToUnit(TemperatureUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureUnit unitAsTemperatureUnit)) + if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -763,10 +800,10 @@ public Temperature ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TemperatureUnit unit) + private QuantityValue GetValueAs(TemperatureUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 0f3704b67e..a832939860 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). /// [DataContract] - public partial struct TemperatureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static TemperatureChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) + public TemperatureChangeRate(QuantityValue value, TemperatureChangeRateUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -95,14 +95,14 @@ public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureChangeRate(double value, UnitSystem unitSystem) + public TemperatureChangeRate(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,7 +143,10 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -166,54 +169,54 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); + public QuantityValue CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); + public QuantityValue DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); + public QuantityValue DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); + public QuantityValue DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + public QuantityValue DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + public QuantityValue HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + public QuantityValue KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + public QuantityValue MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + public QuantityValue MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + public QuantityValue NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); #endregion @@ -296,7 +299,7 @@ public static string GetAbbreviation(TemperatureChangeRateUnit unit, IFormatProv /// If value is NaN or Infinity. public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityValue centidegreescelsiuspersecond) { - double value = (double) centidegreescelsiuspersecond; + QuantityValue value = (QuantityValue) centidegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); } @@ -306,7 +309,7 @@ public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValue decadegreescelsiuspersecond) { - double value = (double) decadegreescelsiuspersecond; + QuantityValue value = (QuantityValue) decadegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); } @@ -316,7 +319,7 @@ public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValu /// If value is NaN or Infinity. public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValue decidegreescelsiuspersecond) { - double value = (double) decidegreescelsiuspersecond; + QuantityValue value = (QuantityValue) decidegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); } @@ -326,7 +329,7 @@ public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValu /// If value is NaN or Infinity. public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue degreescelsiusperminute) { - double value = (double) degreescelsiusperminute; + QuantityValue value = (QuantityValue) degreescelsiusperminute; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); } @@ -336,7 +339,7 @@ public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue de /// If value is NaN or Infinity. public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue degreescelsiuspersecond) { - double value = (double) degreescelsiuspersecond; + QuantityValue value = (QuantityValue) degreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); } @@ -346,7 +349,7 @@ public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue de /// If value is NaN or Infinity. public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityValue hectodegreescelsiuspersecond) { - double value = (double) hectodegreescelsiuspersecond; + QuantityValue value = (QuantityValue) hectodegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); } @@ -356,7 +359,7 @@ public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValue kilodegreescelsiuspersecond) { - double value = (double) kilodegreescelsiuspersecond; + QuantityValue value = (QuantityValue) kilodegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); } @@ -366,7 +369,7 @@ public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValu /// If value is NaN or Infinity. public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityValue microdegreescelsiuspersecond) { - double value = (double) microdegreescelsiuspersecond; + QuantityValue value = (QuantityValue) microdegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); } @@ -376,7 +379,7 @@ public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityValue millidegreescelsiuspersecond) { - double value = (double) millidegreescelsiuspersecond; + QuantityValue value = (QuantityValue) millidegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); } @@ -386,7 +389,7 @@ public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValue nanodegreescelsiuspersecond) { - double value = (double) nanodegreescelsiuspersecond; + QuantityValue value = (QuantityValue) nanodegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); } @@ -398,7 +401,7 @@ public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValu /// TemperatureChangeRate unit value. public static TemperatureChangeRate From(QuantityValue value, TemperatureChangeRateUnit fromUnit) { - return new TemperatureChangeRate((double)value, fromUnit); + return new TemperatureChangeRate((QuantityValue)value, fromUnit); } #endregion @@ -568,25 +571,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureChangeRate operator *(double left, TemperatureChangeRate right) + public static TemperatureChangeRate operator *(QuantityValue left, TemperatureChangeRate right) { return new TemperatureChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureChangeRate operator *(TemperatureChangeRate left, double right) + public static TemperatureChangeRate operator *(TemperatureChangeRate left, QuantityValue right) { return new TemperatureChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureChangeRate operator /(TemperatureChangeRate left, double right) + public static TemperatureChangeRate operator /(TemperatureChangeRate left, QuantityValue right) { return new TemperatureChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TemperatureChangeRate left, TemperatureChangeRate right) + public static QuantityValue operator /(TemperatureChangeRate left, TemperatureChangeRate right) { return left.DegreesCelsiusPerSecond / right.DegreesCelsiusPerSecond; } @@ -619,6 +622,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -631,7 +647,29 @@ public int CompareTo(object obj) /// public int CompareTo(TemperatureChangeRate other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) + return false; + return Equals(objTemperatureChangeRate); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(TemperatureChangeRate other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -674,13 +712,13 @@ public int CompareTo(TemperatureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -691,7 +729,7 @@ public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType /// A hash code for the current TemperatureChangeRate. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -702,17 +740,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureChangeRateUnit unit) + public QuantityValue As(TemperatureChangeRateUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -727,12 +764,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) + if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureChangeRateUnit); + return (QuantityValue)As(typedUnit); } /// @@ -764,7 +801,7 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit, UnitConverte var converted = conversionFunction(this); return (TemperatureChangeRate)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TemperatureChangeRateUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -772,17 +809,17 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit, UnitConverte } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) + if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -809,10 +846,10 @@ public TemperatureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TemperatureChangeRateUnit unit) + private QuantityValue GetValueAs(TemperatureChangeRateUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 5fb8eaf2ac..94d9813fe9 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Difference between two temperatures. The conversions are different than for Temperature. /// [DataContract] - public partial struct TemperatureDelta : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureDelta : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static TemperatureDelta() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureDelta(double value, TemperatureDeltaUnit unit) + public TemperatureDelta(QuantityValue value, TemperatureDeltaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -94,14 +94,14 @@ public TemperatureDelta(double value, TemperatureDeltaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureDelta(double value, UnitSystem unitSystem) + public TemperatureDelta(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,7 +142,10 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -165,49 +168,49 @@ public TemperatureDelta(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); + public QuantityValue DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); + public QuantityValue DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); + public QuantityValue DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); + public QuantityValue DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); + public QuantityValue DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); + public QuantityValue DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); + public QuantityValue DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kelvins => As(TemperatureDeltaUnit.Kelvin); + public QuantityValue Kelvins => As(TemperatureDeltaUnit.Kelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); + public QuantityValue MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); #endregion @@ -287,7 +290,7 @@ public static string GetAbbreviation(TemperatureDeltaUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesCelsius(QuantityValue degreescelsius) { - double value = (double) degreescelsius; + QuantityValue value = (QuantityValue) degreescelsius; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsius); } @@ -297,7 +300,7 @@ public static TemperatureDelta FromDegreesCelsius(QuantityValue degreescelsius) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesDelisle(QuantityValue degreesdelisle) { - double value = (double) degreesdelisle; + QuantityValue value = (QuantityValue) degreesdelisle; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisle); } @@ -307,7 +310,7 @@ public static TemperatureDelta FromDegreesDelisle(QuantityValue degreesdelisle) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesFahrenheit(QuantityValue degreesfahrenheit) { - double value = (double) degreesfahrenheit; + QuantityValue value = (QuantityValue) degreesfahrenheit; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheit); } @@ -317,7 +320,7 @@ public static TemperatureDelta FromDegreesFahrenheit(QuantityValue degreesfahren /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesNewton(QuantityValue degreesnewton) { - double value = (double) degreesnewton; + QuantityValue value = (QuantityValue) degreesnewton; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewton); } @@ -327,7 +330,7 @@ public static TemperatureDelta FromDegreesNewton(QuantityValue degreesnewton) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesRankine(QuantityValue degreesrankine) { - double value = (double) degreesrankine; + QuantityValue value = (QuantityValue) degreesrankine; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankine); } @@ -337,7 +340,7 @@ public static TemperatureDelta FromDegreesRankine(QuantityValue degreesrankine) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesReaumur(QuantityValue degreesreaumur) { - double value = (double) degreesreaumur; + QuantityValue value = (QuantityValue) degreesreaumur; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumur); } @@ -347,7 +350,7 @@ public static TemperatureDelta FromDegreesReaumur(QuantityValue degreesreaumur) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesRoemer(QuantityValue degreesroemer) { - double value = (double) degreesroemer; + QuantityValue value = (QuantityValue) degreesroemer; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemer); } @@ -357,7 +360,7 @@ public static TemperatureDelta FromDegreesRoemer(QuantityValue degreesroemer) /// If value is NaN or Infinity. public static TemperatureDelta FromKelvins(QuantityValue kelvins) { - double value = (double) kelvins; + QuantityValue value = (QuantityValue) kelvins; return new TemperatureDelta(value, TemperatureDeltaUnit.Kelvin); } @@ -367,7 +370,7 @@ public static TemperatureDelta FromKelvins(QuantityValue kelvins) /// If value is NaN or Infinity. public static TemperatureDelta FromMillidegreesCelsius(QuantityValue millidegreescelsius) { - double value = (double) millidegreescelsius; + QuantityValue value = (QuantityValue) millidegreescelsius; return new TemperatureDelta(value, TemperatureDeltaUnit.MillidegreeCelsius); } @@ -379,7 +382,7 @@ public static TemperatureDelta FromMillidegreesCelsius(QuantityValue millidegree /// TemperatureDelta unit value. public static TemperatureDelta From(QuantityValue value, TemperatureDeltaUnit fromUnit) { - return new TemperatureDelta((double)value, fromUnit); + return new TemperatureDelta((QuantityValue)value, fromUnit); } #endregion @@ -549,25 +552,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureDelta operator *(double left, TemperatureDelta right) + public static TemperatureDelta operator *(QuantityValue left, TemperatureDelta right) { return new TemperatureDelta(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureDelta operator *(TemperatureDelta left, double right) + public static TemperatureDelta operator *(TemperatureDelta left, QuantityValue right) { return new TemperatureDelta(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureDelta operator /(TemperatureDelta left, double right) + public static TemperatureDelta operator /(TemperatureDelta left, QuantityValue right) { return new TemperatureDelta(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TemperatureDelta left, TemperatureDelta right) + public static QuantityValue operator /(TemperatureDelta left, TemperatureDelta right) { return left.Kelvins / right.Kelvins; } @@ -600,6 +603,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(TemperatureDelta left, TemperatureDelta right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(TemperatureDelta left, TemperatureDelta right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -612,7 +628,29 @@ public int CompareTo(object obj) /// public int CompareTo(TemperatureDelta other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is TemperatureDelta objTemperatureDelta)) + return false; + return Equals(objTemperatureDelta); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(TemperatureDelta other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -655,13 +693,13 @@ public int CompareTo(TemperatureDelta other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureDelta other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -672,7 +710,7 @@ public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comp /// A hash code for the current TemperatureDelta. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -683,17 +721,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureDeltaUnit unit) + public QuantityValue As(TemperatureDeltaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -708,12 +745,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) + if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureDeltaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -745,7 +782,7 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (TemperatureDelta)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TemperatureDeltaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -753,17 +790,17 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit, UnitConverter unitConv } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) + if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureDeltaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -790,10 +827,10 @@ public TemperatureDelta ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TemperatureDeltaUnit unit) + private QuantityValue GetValueAs(TemperatureDeltaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index aaff14abca..1d2405a4e2 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct TemperatureGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static TemperatureGradient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureGradient(double value, TemperatureGradientUnit unit) + public TemperatureGradient(QuantityValue value, TemperatureGradientUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public TemperatureGradient(double value, TemperatureGradientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureGradient(double value, UnitSystem unitSystem) + public TemperatureGradient(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,24 +163,24 @@ public TemperatureGradient(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelciusPerKilometer => As(TemperatureGradientUnit.DegreeCelsiusPerKilometer); + public QuantityValue DegreesCelciusPerKilometer => As(TemperatureGradientUnit.DegreeCelsiusPerKilometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesCelciusPerMeter => As(TemperatureGradientUnit.DegreeCelsiusPerMeter); + public QuantityValue DegreesCelciusPerMeter => As(TemperatureGradientUnit.DegreeCelsiusPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DegreesFahrenheitPerFoot => As(TemperatureGradientUnit.DegreeFahrenheitPerFoot); + public QuantityValue DegreesFahrenheitPerFoot => As(TemperatureGradientUnit.DegreeFahrenheitPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KelvinsPerMeter => As(TemperatureGradientUnit.KelvinPerMeter); + public QuantityValue KelvinsPerMeter => As(TemperatureGradientUnit.KelvinPerMeter); #endregion @@ -242,7 +245,7 @@ public static string GetAbbreviation(TemperatureGradientUnit unit, IFormatProvid /// If value is NaN or Infinity. public static TemperatureGradient FromDegreesCelciusPerKilometer(QuantityValue degreescelciusperkilometer) { - double value = (double) degreescelciusperkilometer; + QuantityValue value = (QuantityValue) degreescelciusperkilometer; return new TemperatureGradient(value, TemperatureGradientUnit.DegreeCelsiusPerKilometer); } @@ -252,7 +255,7 @@ public static TemperatureGradient FromDegreesCelciusPerKilometer(QuantityValue d /// If value is NaN or Infinity. public static TemperatureGradient FromDegreesCelciusPerMeter(QuantityValue degreescelciuspermeter) { - double value = (double) degreescelciuspermeter; + QuantityValue value = (QuantityValue) degreescelciuspermeter; return new TemperatureGradient(value, TemperatureGradientUnit.DegreeCelsiusPerMeter); } @@ -262,7 +265,7 @@ public static TemperatureGradient FromDegreesCelciusPerMeter(QuantityValue degre /// If value is NaN or Infinity. public static TemperatureGradient FromDegreesFahrenheitPerFoot(QuantityValue degreesfahrenheitperfoot) { - double value = (double) degreesfahrenheitperfoot; + QuantityValue value = (QuantityValue) degreesfahrenheitperfoot; return new TemperatureGradient(value, TemperatureGradientUnit.DegreeFahrenheitPerFoot); } @@ -272,7 +275,7 @@ public static TemperatureGradient FromDegreesFahrenheitPerFoot(QuantityValue deg /// If value is NaN or Infinity. public static TemperatureGradient FromKelvinsPerMeter(QuantityValue kelvinspermeter) { - double value = (double) kelvinspermeter; + QuantityValue value = (QuantityValue) kelvinspermeter; return new TemperatureGradient(value, TemperatureGradientUnit.KelvinPerMeter); } @@ -284,7 +287,7 @@ public static TemperatureGradient FromKelvinsPerMeter(QuantityValue kelvinsperme /// TemperatureGradient unit value. public static TemperatureGradient From(QuantityValue value, TemperatureGradientUnit fromUnit) { - return new TemperatureGradient((double)value, fromUnit); + return new TemperatureGradient((QuantityValue)value, fromUnit); } #endregion @@ -454,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureGradient operator *(double left, TemperatureGradient right) + public static TemperatureGradient operator *(QuantityValue left, TemperatureGradient right) { return new TemperatureGradient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureGradient operator *(TemperatureGradient left, double right) + public static TemperatureGradient operator *(TemperatureGradient left, QuantityValue right) { return new TemperatureGradient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureGradient operator /(TemperatureGradient left, double right) + public static TemperatureGradient operator /(TemperatureGradient left, QuantityValue right) { return new TemperatureGradient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TemperatureGradient left, TemperatureGradient right) + public static QuantityValue operator /(TemperatureGradient left, TemperatureGradient right) { return left.KelvinsPerMeter / right.KelvinsPerMeter; } @@ -505,6 +508,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(TemperatureGradient left, TemperatureGradient right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(TemperatureGradient left, TemperatureGradient right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -517,7 +533,29 @@ public int CompareTo(object obj) /// public int CompareTo(TemperatureGradient other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is TemperatureGradient objTemperatureGradient)) + return false; + return Equals(objTemperatureGradient); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(TemperatureGradient other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -560,13 +598,13 @@ public int CompareTo(TemperatureGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureGradient other, double tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureGradient other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +615,7 @@ public bool Equals(TemperatureGradient other, double tolerance, ComparisonType c /// A hash code for the current TemperatureGradient. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -588,17 +626,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TemperatureGradientUnit unit) + public QuantityValue As(TemperatureGradientUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -613,12 +650,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) + if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureGradientUnit); + return (QuantityValue)As(typedUnit); } /// @@ -650,7 +687,7 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit, UnitConverter un var converted = conversionFunction(this); return (TemperatureGradient)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TemperatureGradientUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -658,17 +695,17 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) + if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureGradientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -695,10 +732,10 @@ public TemperatureGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TemperatureGradientUnit unit) + private QuantityValue GetValueAs(TemperatureGradientUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 0da7968b47..2dea56e22d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thermal_Conductivity /// [DataContract] - public partial struct ThermalConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ThermalConductivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ThermalConductivity(double value, ThermalConductivityUnit unit) + public ThermalConductivity(QuantityValue value, ThermalConductivityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -90,14 +90,14 @@ public ThermalConductivity(double value, ThermalConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalConductivity(double value, UnitSystem unitSystem) + public ThermalConductivity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,7 +138,10 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -161,14 +164,14 @@ public ThermalConductivity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); + public QuantityValue BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); + public QuantityValue WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); #endregion @@ -227,7 +230,7 @@ public static string GetAbbreviation(ThermalConductivityUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue btusperhourfootfahrenheit) { - double value = (double) btusperhourfootfahrenheit; + QuantityValue value = (QuantityValue) btusperhourfootfahrenheit; return new ThermalConductivity(value, ThermalConductivityUnit.BtuPerHourFootFahrenheit); } @@ -237,7 +240,7 @@ public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue bt /// If value is NaN or Infinity. public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue wattspermeterkelvin) { - double value = (double) wattspermeterkelvin; + QuantityValue value = (QuantityValue) wattspermeterkelvin; return new ThermalConductivity(value, ThermalConductivityUnit.WattPerMeterKelvin); } @@ -249,7 +252,7 @@ public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue wattsper /// ThermalConductivity unit value. public static ThermalConductivity From(QuantityValue value, ThermalConductivityUnit fromUnit) { - return new ThermalConductivity((double)value, fromUnit); + return new ThermalConductivity((QuantityValue)value, fromUnit); } #endregion @@ -419,25 +422,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm } /// Get from multiplying value and . - public static ThermalConductivity operator *(double left, ThermalConductivity right) + public static ThermalConductivity operator *(QuantityValue left, ThermalConductivity right) { return new ThermalConductivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ThermalConductivity operator *(ThermalConductivity left, double right) + public static ThermalConductivity operator *(ThermalConductivity left, QuantityValue right) { return new ThermalConductivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ThermalConductivity operator /(ThermalConductivity left, double right) + public static ThermalConductivity operator /(ThermalConductivity left, QuantityValue right) { return new ThermalConductivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ThermalConductivity left, ThermalConductivity right) + public static QuantityValue operator /(ThermalConductivity left, ThermalConductivity right) { return left.WattsPerMeterKelvin / right.WattsPerMeterKelvin; } @@ -470,6 +473,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ThermalConductivity left, ThermalConductivity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ThermalConductivity left, ThermalConductivity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -482,7 +498,29 @@ public int CompareTo(object obj) /// public int CompareTo(ThermalConductivity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ThermalConductivity objThermalConductivity)) + return false; + return Equals(objThermalConductivity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ThermalConductivity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -525,13 +563,13 @@ public int CompareTo(ThermalConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType) + public bool Equals(ThermalConductivity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -542,7 +580,7 @@ public bool Equals(ThermalConductivity other, double tolerance, ComparisonType c /// A hash code for the current ThermalConductivity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -553,17 +591,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalConductivityUnit unit) + public QuantityValue As(ThermalConductivityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -578,12 +615,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) + if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsThermalConductivityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -615,7 +652,7 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit, UnitConverter un var converted = conversionFunction(this); return (ThermalConductivity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ThermalConductivityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -623,17 +660,17 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) + if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsThermalConductivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -660,10 +697,10 @@ public ThermalConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ThermalConductivityUnit unit) + private QuantityValue GetValueAs(ThermalConductivityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 7ab40b994c..520040cd26 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. /// [DataContract] - public partial struct ThermalResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ThermalResistance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ThermalResistance(double value, ThermalResistanceUnit unit) + public ThermalResistance(QuantityValue value, ThermalResistanceUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public ThermalResistance(double value, ThermalResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalResistance(double value, UnitSystem unitSystem) + public ThermalResistance(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,34 +165,34 @@ public ThermalResistance(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + public QuantityValue HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + public QuantityValue SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + public QuantityValue SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + public QuantityValue SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + public QuantityValue SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double SquareMeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareMeterKelvinPerWatt); + public QuantityValue SquareMeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareMeterKelvinPerWatt); #endregion @@ -260,7 +263,7 @@ public static string GetAbbreviation(ThermalResistanceUnit unit, IFormatProvider /// If value is NaN or Infinity. public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(QuantityValue hoursquarefeetdegreesfahrenheitperbtu) { - double value = (double) hoursquarefeetdegreesfahrenheitperbtu; + QuantityValue value = (QuantityValue) hoursquarefeetdegreesfahrenheitperbtu; return new ThermalResistance(value, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); } @@ -270,7 +273,7 @@ public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(Quanti /// If value is NaN or Infinity. public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(QuantityValue squarecentimeterhourdegreescelsiusperkilocalorie) { - double value = (double) squarecentimeterhourdegreescelsiusperkilocalorie; + QuantityValue value = (QuantityValue) squarecentimeterhourdegreescelsiusperkilocalorie; return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); } @@ -280,7 +283,7 @@ public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocal /// If value is NaN or Infinity. public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue squarecentimeterkelvinsperwatt) { - double value = (double) squarecentimeterkelvinsperwatt; + QuantityValue value = (QuantityValue) squarecentimeterkelvinsperwatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); } @@ -290,7 +293,7 @@ public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue /// If value is NaN or Infinity. public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityValue squaremeterdegreescelsiusperwatt) { - double value = (double) squaremeterdegreescelsiusperwatt; + QuantityValue value = (QuantityValue) squaremeterdegreescelsiusperwatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); } @@ -300,7 +303,7 @@ public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityVal /// If value is NaN or Infinity. public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue squaremeterkelvinsperkilowatt) { - double value = (double) squaremeterkelvinsperkilowatt; + QuantityValue value = (QuantityValue) squaremeterkelvinsperkilowatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); } @@ -310,7 +313,7 @@ public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue /// If value is NaN or Infinity. public static ThermalResistance FromSquareMeterKelvinsPerWatt(QuantityValue squaremeterkelvinsperwatt) { - double value = (double) squaremeterkelvinsperwatt; + QuantityValue value = (QuantityValue) squaremeterkelvinsperwatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerWatt); } @@ -322,7 +325,7 @@ public static ThermalResistance FromSquareMeterKelvinsPerWatt(QuantityValue squa /// ThermalResistance unit value. public static ThermalResistance From(QuantityValue value, ThermalResistanceUnit fromUnit) { - return new ThermalResistance((double)value, fromUnit); + return new ThermalResistance((QuantityValue)value, fromUnit); } #endregion @@ -492,25 +495,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm } /// Get from multiplying value and . - public static ThermalResistance operator *(double left, ThermalResistance right) + public static ThermalResistance operator *(QuantityValue left, ThermalResistance right) { return new ThermalResistance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ThermalResistance operator *(ThermalResistance left, double right) + public static ThermalResistance operator *(ThermalResistance left, QuantityValue right) { return new ThermalResistance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ThermalResistance operator /(ThermalResistance left, double right) + public static ThermalResistance operator /(ThermalResistance left, QuantityValue right) { return new ThermalResistance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(ThermalResistance left, ThermalResistance right) + public static QuantityValue operator /(ThermalResistance left, ThermalResistance right) { return left.SquareMeterKelvinsPerKilowatt / right.SquareMeterKelvinsPerKilowatt; } @@ -543,6 +546,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(ThermalResistance left, ThermalResistance right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(ThermalResistance left, ThermalResistance right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -555,7 +571,29 @@ public int CompareTo(object obj) /// public int CompareTo(ThermalResistance other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is ThermalResistance objThermalResistance)) + return false; + return Equals(objThermalResistance); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(ThermalResistance other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -598,13 +636,13 @@ public int CompareTo(ThermalResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType) + public bool Equals(ThermalResistance other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +653,7 @@ public bool Equals(ThermalResistance other, double tolerance, ComparisonType com /// A hash code for the current ThermalResistance. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -626,17 +664,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(ThermalResistanceUnit unit) + public QuantityValue As(ThermalResistanceUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -651,12 +688,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) + if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsThermalResistanceUnit); + return (QuantityValue)As(typedUnit); } /// @@ -688,7 +725,7 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (ThermalResistance)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(ThermalResistanceUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -696,17 +733,17 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit, UnitConverter unitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) + if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsThermalResistanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -733,10 +770,10 @@ public ThermalResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(ThermalResistanceUnit unit) + private QuantityValue GetValueAs(ThermalResistanceUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 2a512729ec..de02228368 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. /// [DataContract] - public partial struct Torque : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Torque : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -96,9 +96,9 @@ static Torque() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Torque(double value, TorqueUnit unit) + public Torque(QuantityValue value, TorqueUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -110,14 +110,14 @@ public Torque(double value, TorqueUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Torque(double value, UnitSystem unitSystem) + public Torque(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -158,7 +158,10 @@ public Torque(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -181,129 +184,129 @@ public Torque(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramForceCentimeters => As(TorqueUnit.GramForceCentimeter); + public QuantityValue GramForceCentimeters => As(TorqueUnit.GramForceCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramForceMeters => As(TorqueUnit.GramForceMeter); + public QuantityValue GramForceMeters => As(TorqueUnit.GramForceMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double GramForceMillimeters => As(TorqueUnit.GramForceMillimeter); + public QuantityValue GramForceMillimeters => As(TorqueUnit.GramForceMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); + public QuantityValue KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); + public QuantityValue KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); + public QuantityValue KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); + public QuantityValue KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); + public QuantityValue KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); + public QuantityValue KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); + public QuantityValue KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); + public QuantityValue KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); + public QuantityValue MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); + public QuantityValue MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); + public QuantityValue MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); + public QuantityValue MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); + public QuantityValue MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); + public QuantityValue NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMeters => As(TorqueUnit.NewtonMeter); + public QuantityValue NewtonMeters => As(TorqueUnit.NewtonMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); + public QuantityValue NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundalFeet => As(TorqueUnit.PoundalFoot); + public QuantityValue PoundalFeet => As(TorqueUnit.PoundalFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceFeet => As(TorqueUnit.PoundForceFoot); + public QuantityValue PoundForceFeet => As(TorqueUnit.PoundForceFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceInches => As(TorqueUnit.PoundForceInch); + public QuantityValue PoundForceInches => As(TorqueUnit.PoundForceInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); + public QuantityValue TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneForceMeters => As(TorqueUnit.TonneForceMeter); + public QuantityValue TonneForceMeters => As(TorqueUnit.TonneForceMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); + public QuantityValue TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); #endregion @@ -434,7 +437,7 @@ public static string GetAbbreviation(TorqueUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Torque FromGramForceCentimeters(QuantityValue gramforcecentimeters) { - double value = (double) gramforcecentimeters; + QuantityValue value = (QuantityValue) gramforcecentimeters; return new Torque(value, TorqueUnit.GramForceCentimeter); } @@ -444,7 +447,7 @@ public static Torque FromGramForceCentimeters(QuantityValue gramforcecentimeters /// If value is NaN or Infinity. public static Torque FromGramForceMeters(QuantityValue gramforcemeters) { - double value = (double) gramforcemeters; + QuantityValue value = (QuantityValue) gramforcemeters; return new Torque(value, TorqueUnit.GramForceMeter); } @@ -454,7 +457,7 @@ public static Torque FromGramForceMeters(QuantityValue gramforcemeters) /// If value is NaN or Infinity. public static Torque FromGramForceMillimeters(QuantityValue gramforcemillimeters) { - double value = (double) gramforcemillimeters; + QuantityValue value = (QuantityValue) gramforcemillimeters; return new Torque(value, TorqueUnit.GramForceMillimeter); } @@ -464,7 +467,7 @@ public static Torque FromGramForceMillimeters(QuantityValue gramforcemillimeters /// If value is NaN or Infinity. public static Torque FromKilogramForceCentimeters(QuantityValue kilogramforcecentimeters) { - double value = (double) kilogramforcecentimeters; + QuantityValue value = (QuantityValue) kilogramforcecentimeters; return new Torque(value, TorqueUnit.KilogramForceCentimeter); } @@ -474,7 +477,7 @@ public static Torque FromKilogramForceCentimeters(QuantityValue kilogramforcecen /// If value is NaN or Infinity. public static Torque FromKilogramForceMeters(QuantityValue kilogramforcemeters) { - double value = (double) kilogramforcemeters; + QuantityValue value = (QuantityValue) kilogramforcemeters; return new Torque(value, TorqueUnit.KilogramForceMeter); } @@ -484,7 +487,7 @@ public static Torque FromKilogramForceMeters(QuantityValue kilogramforcemeters) /// If value is NaN or Infinity. public static Torque FromKilogramForceMillimeters(QuantityValue kilogramforcemillimeters) { - double value = (double) kilogramforcemillimeters; + QuantityValue value = (QuantityValue) kilogramforcemillimeters; return new Torque(value, TorqueUnit.KilogramForceMillimeter); } @@ -494,7 +497,7 @@ public static Torque FromKilogramForceMillimeters(QuantityValue kilogramforcemil /// If value is NaN or Infinity. public static Torque FromKilonewtonCentimeters(QuantityValue kilonewtoncentimeters) { - double value = (double) kilonewtoncentimeters; + QuantityValue value = (QuantityValue) kilonewtoncentimeters; return new Torque(value, TorqueUnit.KilonewtonCentimeter); } @@ -504,7 +507,7 @@ public static Torque FromKilonewtonCentimeters(QuantityValue kilonewtoncentimete /// If value is NaN or Infinity. public static Torque FromKilonewtonMeters(QuantityValue kilonewtonmeters) { - double value = (double) kilonewtonmeters; + QuantityValue value = (QuantityValue) kilonewtonmeters; return new Torque(value, TorqueUnit.KilonewtonMeter); } @@ -514,7 +517,7 @@ public static Torque FromKilonewtonMeters(QuantityValue kilonewtonmeters) /// If value is NaN or Infinity. public static Torque FromKilonewtonMillimeters(QuantityValue kilonewtonmillimeters) { - double value = (double) kilonewtonmillimeters; + QuantityValue value = (QuantityValue) kilonewtonmillimeters; return new Torque(value, TorqueUnit.KilonewtonMillimeter); } @@ -524,7 +527,7 @@ public static Torque FromKilonewtonMillimeters(QuantityValue kilonewtonmillimete /// If value is NaN or Infinity. public static Torque FromKilopoundForceFeet(QuantityValue kilopoundforcefeet) { - double value = (double) kilopoundforcefeet; + QuantityValue value = (QuantityValue) kilopoundforcefeet; return new Torque(value, TorqueUnit.KilopoundForceFoot); } @@ -534,7 +537,7 @@ public static Torque FromKilopoundForceFeet(QuantityValue kilopoundforcefeet) /// If value is NaN or Infinity. public static Torque FromKilopoundForceInches(QuantityValue kilopoundforceinches) { - double value = (double) kilopoundforceinches; + QuantityValue value = (QuantityValue) kilopoundforceinches; return new Torque(value, TorqueUnit.KilopoundForceInch); } @@ -544,7 +547,7 @@ public static Torque FromKilopoundForceInches(QuantityValue kilopoundforceinches /// If value is NaN or Infinity. public static Torque FromMeganewtonCentimeters(QuantityValue meganewtoncentimeters) { - double value = (double) meganewtoncentimeters; + QuantityValue value = (QuantityValue) meganewtoncentimeters; return new Torque(value, TorqueUnit.MeganewtonCentimeter); } @@ -554,7 +557,7 @@ public static Torque FromMeganewtonCentimeters(QuantityValue meganewtoncentimete /// If value is NaN or Infinity. public static Torque FromMeganewtonMeters(QuantityValue meganewtonmeters) { - double value = (double) meganewtonmeters; + QuantityValue value = (QuantityValue) meganewtonmeters; return new Torque(value, TorqueUnit.MeganewtonMeter); } @@ -564,7 +567,7 @@ public static Torque FromMeganewtonMeters(QuantityValue meganewtonmeters) /// If value is NaN or Infinity. public static Torque FromMeganewtonMillimeters(QuantityValue meganewtonmillimeters) { - double value = (double) meganewtonmillimeters; + QuantityValue value = (QuantityValue) meganewtonmillimeters; return new Torque(value, TorqueUnit.MeganewtonMillimeter); } @@ -574,7 +577,7 @@ public static Torque FromMeganewtonMillimeters(QuantityValue meganewtonmillimete /// If value is NaN or Infinity. public static Torque FromMegapoundForceFeet(QuantityValue megapoundforcefeet) { - double value = (double) megapoundforcefeet; + QuantityValue value = (QuantityValue) megapoundforcefeet; return new Torque(value, TorqueUnit.MegapoundForceFoot); } @@ -584,7 +587,7 @@ public static Torque FromMegapoundForceFeet(QuantityValue megapoundforcefeet) /// If value is NaN or Infinity. public static Torque FromMegapoundForceInches(QuantityValue megapoundforceinches) { - double value = (double) megapoundforceinches; + QuantityValue value = (QuantityValue) megapoundforceinches; return new Torque(value, TorqueUnit.MegapoundForceInch); } @@ -594,7 +597,7 @@ public static Torque FromMegapoundForceInches(QuantityValue megapoundforceinches /// If value is NaN or Infinity. public static Torque FromNewtonCentimeters(QuantityValue newtoncentimeters) { - double value = (double) newtoncentimeters; + QuantityValue value = (QuantityValue) newtoncentimeters; return new Torque(value, TorqueUnit.NewtonCentimeter); } @@ -604,7 +607,7 @@ public static Torque FromNewtonCentimeters(QuantityValue newtoncentimeters) /// If value is NaN or Infinity. public static Torque FromNewtonMeters(QuantityValue newtonmeters) { - double value = (double) newtonmeters; + QuantityValue value = (QuantityValue) newtonmeters; return new Torque(value, TorqueUnit.NewtonMeter); } @@ -614,7 +617,7 @@ public static Torque FromNewtonMeters(QuantityValue newtonmeters) /// If value is NaN or Infinity. public static Torque FromNewtonMillimeters(QuantityValue newtonmillimeters) { - double value = (double) newtonmillimeters; + QuantityValue value = (QuantityValue) newtonmillimeters; return new Torque(value, TorqueUnit.NewtonMillimeter); } @@ -624,7 +627,7 @@ public static Torque FromNewtonMillimeters(QuantityValue newtonmillimeters) /// If value is NaN or Infinity. public static Torque FromPoundalFeet(QuantityValue poundalfeet) { - double value = (double) poundalfeet; + QuantityValue value = (QuantityValue) poundalfeet; return new Torque(value, TorqueUnit.PoundalFoot); } @@ -634,7 +637,7 @@ public static Torque FromPoundalFeet(QuantityValue poundalfeet) /// If value is NaN or Infinity. public static Torque FromPoundForceFeet(QuantityValue poundforcefeet) { - double value = (double) poundforcefeet; + QuantityValue value = (QuantityValue) poundforcefeet; return new Torque(value, TorqueUnit.PoundForceFoot); } @@ -644,7 +647,7 @@ public static Torque FromPoundForceFeet(QuantityValue poundforcefeet) /// If value is NaN or Infinity. public static Torque FromPoundForceInches(QuantityValue poundforceinches) { - double value = (double) poundforceinches; + QuantityValue value = (QuantityValue) poundforceinches; return new Torque(value, TorqueUnit.PoundForceInch); } @@ -654,7 +657,7 @@ public static Torque FromPoundForceInches(QuantityValue poundforceinches) /// If value is NaN or Infinity. public static Torque FromTonneForceCentimeters(QuantityValue tonneforcecentimeters) { - double value = (double) tonneforcecentimeters; + QuantityValue value = (QuantityValue) tonneforcecentimeters; return new Torque(value, TorqueUnit.TonneForceCentimeter); } @@ -664,7 +667,7 @@ public static Torque FromTonneForceCentimeters(QuantityValue tonneforcecentimete /// If value is NaN or Infinity. public static Torque FromTonneForceMeters(QuantityValue tonneforcemeters) { - double value = (double) tonneforcemeters; + QuantityValue value = (QuantityValue) tonneforcemeters; return new Torque(value, TorqueUnit.TonneForceMeter); } @@ -674,7 +677,7 @@ public static Torque FromTonneForceMeters(QuantityValue tonneforcemeters) /// If value is NaN or Infinity. public static Torque FromTonneForceMillimeters(QuantityValue tonneforcemillimeters) { - double value = (double) tonneforcemillimeters; + QuantityValue value = (QuantityValue) tonneforcemillimeters; return new Torque(value, TorqueUnit.TonneForceMillimeter); } @@ -686,7 +689,7 @@ public static Torque FromTonneForceMillimeters(QuantityValue tonneforcemillimete /// Torque unit value. public static Torque From(QuantityValue value, TorqueUnit fromUnit) { - return new Torque((double)value, fromUnit); + return new Torque((QuantityValue)value, fromUnit); } #endregion @@ -856,25 +859,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu } /// Get from multiplying value and . - public static Torque operator *(double left, Torque right) + public static Torque operator *(QuantityValue left, Torque right) { return new Torque(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Torque operator *(Torque left, double right) + public static Torque operator *(Torque left, QuantityValue right) { return new Torque(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Torque operator /(Torque left, double right) + public static Torque operator /(Torque left, QuantityValue right) { return new Torque(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Torque left, Torque right) + public static QuantityValue operator /(Torque left, Torque right) { return left.NewtonMeters / right.NewtonMeters; } @@ -907,6 +910,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Torque left, Torque right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Torque left, Torque right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -919,7 +935,29 @@ public int CompareTo(object obj) /// public int CompareTo(Torque other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Torque objTorque)) + return false; + return Equals(objTorque); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Torque other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -962,13 +1000,13 @@ public int CompareTo(Torque other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Torque other, double tolerance, ComparisonType comparisonType) + public bool Equals(Torque other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -979,7 +1017,7 @@ public bool Equals(Torque other, double tolerance, ComparisonType comparisonType /// A hash code for the current Torque. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -990,17 +1028,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorqueUnit unit) + public QuantityValue As(TorqueUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1015,12 +1052,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TorqueUnit unitAsTorqueUnit)) + if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return As(unitAsTorqueUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1052,7 +1089,7 @@ public Torque ToUnit(TorqueUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Torque)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TorqueUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1060,17 +1097,17 @@ public Torque ToUnit(TorqueUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorqueUnit unitAsTorqueUnit)) + if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTorqueUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1097,10 +1134,10 @@ public Torque ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TorqueUnit unit) + private QuantityValue GetValueAs(TorqueUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 4fd2f5f8ef..534f572aef 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The magnitude of torque per unit length. /// [DataContract] - public partial struct TorquePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct TorquePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -92,9 +92,9 @@ static TorquePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TorquePerLength(double value, TorquePerLengthUnit unit) + public TorquePerLength(QuantityValue value, TorquePerLengthUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -106,14 +106,14 @@ public TorquePerLength(double value, TorquePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TorquePerLength(double value, UnitSystem unitSystem) + public TorquePerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -154,7 +154,10 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -177,109 +180,109 @@ public TorquePerLength(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); + public QuantityValue KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); + public QuantityValue KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); + public QuantityValue KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); + public QuantityValue KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); + public QuantityValue KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); + public QuantityValue KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); + public QuantityValue KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); + public QuantityValue KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); + public QuantityValue MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); + public QuantityValue MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); + public QuantityValue MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); + public QuantityValue MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); + public QuantityValue MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); + public QuantityValue NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); + public QuantityValue NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); + public QuantityValue NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); + public QuantityValue PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); + public QuantityValue PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); + public QuantityValue TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); + public QuantityValue TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); + public QuantityValue TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); #endregion @@ -398,7 +401,7 @@ public static string GetAbbreviation(TorquePerLengthUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static TorquePerLength FromKilogramForceCentimetersPerMeter(QuantityValue kilogramforcecentimeterspermeter) { - double value = (double) kilogramforcecentimeterspermeter; + QuantityValue value = (QuantityValue) kilogramforcecentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); } @@ -408,7 +411,7 @@ public static TorquePerLength FromKilogramForceCentimetersPerMeter(QuantityValue /// If value is NaN or Infinity. public static TorquePerLength FromKilogramForceMetersPerMeter(QuantityValue kilogramforcemeterspermeter) { - double value = (double) kilogramforcemeterspermeter; + QuantityValue value = (QuantityValue) kilogramforcemeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMeterPerMeter); } @@ -418,7 +421,7 @@ public static TorquePerLength FromKilogramForceMetersPerMeter(QuantityValue kilo /// If value is NaN or Infinity. public static TorquePerLength FromKilogramForceMillimetersPerMeter(QuantityValue kilogramforcemillimeterspermeter) { - double value = (double) kilogramforcemillimeterspermeter; + QuantityValue value = (QuantityValue) kilogramforcemillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); } @@ -428,7 +431,7 @@ public static TorquePerLength FromKilogramForceMillimetersPerMeter(QuantityValue /// If value is NaN or Infinity. public static TorquePerLength FromKilonewtonCentimetersPerMeter(QuantityValue kilonewtoncentimeterspermeter) { - double value = (double) kilonewtoncentimeterspermeter; + QuantityValue value = (QuantityValue) kilonewtoncentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); } @@ -438,7 +441,7 @@ public static TorquePerLength FromKilonewtonCentimetersPerMeter(QuantityValue ki /// If value is NaN or Infinity. public static TorquePerLength FromKilonewtonMetersPerMeter(QuantityValue kilonewtonmeterspermeter) { - double value = (double) kilonewtonmeterspermeter; + QuantityValue value = (QuantityValue) kilonewtonmeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMeterPerMeter); } @@ -448,7 +451,7 @@ public static TorquePerLength FromKilonewtonMetersPerMeter(QuantityValue kilonew /// If value is NaN or Infinity. public static TorquePerLength FromKilonewtonMillimetersPerMeter(QuantityValue kilonewtonmillimeterspermeter) { - double value = (double) kilonewtonmillimeterspermeter; + QuantityValue value = (QuantityValue) kilonewtonmillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); } @@ -458,7 +461,7 @@ public static TorquePerLength FromKilonewtonMillimetersPerMeter(QuantityValue ki /// If value is NaN or Infinity. public static TorquePerLength FromKilopoundForceFeetPerFoot(QuantityValue kilopoundforcefeetperfoot) { - double value = (double) kilopoundforcefeetperfoot; + QuantityValue value = (QuantityValue) kilopoundforcefeetperfoot; return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceFootPerFoot); } @@ -468,7 +471,7 @@ public static TorquePerLength FromKilopoundForceFeetPerFoot(QuantityValue kilopo /// If value is NaN or Infinity. public static TorquePerLength FromKilopoundForceInchesPerFoot(QuantityValue kilopoundforceinchesperfoot) { - double value = (double) kilopoundforceinchesperfoot; + QuantityValue value = (QuantityValue) kilopoundforceinchesperfoot; return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceInchPerFoot); } @@ -478,7 +481,7 @@ public static TorquePerLength FromKilopoundForceInchesPerFoot(QuantityValue kilo /// If value is NaN or Infinity. public static TorquePerLength FromMeganewtonCentimetersPerMeter(QuantityValue meganewtoncentimeterspermeter) { - double value = (double) meganewtoncentimeterspermeter; + QuantityValue value = (QuantityValue) meganewtoncentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); } @@ -488,7 +491,7 @@ public static TorquePerLength FromMeganewtonCentimetersPerMeter(QuantityValue me /// If value is NaN or Infinity. public static TorquePerLength FromMeganewtonMetersPerMeter(QuantityValue meganewtonmeterspermeter) { - double value = (double) meganewtonmeterspermeter; + QuantityValue value = (QuantityValue) meganewtonmeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMeterPerMeter); } @@ -498,7 +501,7 @@ public static TorquePerLength FromMeganewtonMetersPerMeter(QuantityValue meganew /// If value is NaN or Infinity. public static TorquePerLength FromMeganewtonMillimetersPerMeter(QuantityValue meganewtonmillimeterspermeter) { - double value = (double) meganewtonmillimeterspermeter; + QuantityValue value = (QuantityValue) meganewtonmillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); } @@ -508,7 +511,7 @@ public static TorquePerLength FromMeganewtonMillimetersPerMeter(QuantityValue me /// If value is NaN or Infinity. public static TorquePerLength FromMegapoundForceFeetPerFoot(QuantityValue megapoundforcefeetperfoot) { - double value = (double) megapoundforcefeetperfoot; + QuantityValue value = (QuantityValue) megapoundforcefeetperfoot; return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceFootPerFoot); } @@ -518,7 +521,7 @@ public static TorquePerLength FromMegapoundForceFeetPerFoot(QuantityValue megapo /// If value is NaN or Infinity. public static TorquePerLength FromMegapoundForceInchesPerFoot(QuantityValue megapoundforceinchesperfoot) { - double value = (double) megapoundforceinchesperfoot; + QuantityValue value = (QuantityValue) megapoundforceinchesperfoot; return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceInchPerFoot); } @@ -528,7 +531,7 @@ public static TorquePerLength FromMegapoundForceInchesPerFoot(QuantityValue mega /// If value is NaN or Infinity. public static TorquePerLength FromNewtonCentimetersPerMeter(QuantityValue newtoncentimeterspermeter) { - double value = (double) newtoncentimeterspermeter; + QuantityValue value = (QuantityValue) newtoncentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.NewtonCentimeterPerMeter); } @@ -538,7 +541,7 @@ public static TorquePerLength FromNewtonCentimetersPerMeter(QuantityValue newton /// If value is NaN or Infinity. public static TorquePerLength FromNewtonMetersPerMeter(QuantityValue newtonmeterspermeter) { - double value = (double) newtonmeterspermeter; + QuantityValue value = (QuantityValue) newtonmeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.NewtonMeterPerMeter); } @@ -548,7 +551,7 @@ public static TorquePerLength FromNewtonMetersPerMeter(QuantityValue newtonmeter /// If value is NaN or Infinity. public static TorquePerLength FromNewtonMillimetersPerMeter(QuantityValue newtonmillimeterspermeter) { - double value = (double) newtonmillimeterspermeter; + QuantityValue value = (QuantityValue) newtonmillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.NewtonMillimeterPerMeter); } @@ -558,7 +561,7 @@ public static TorquePerLength FromNewtonMillimetersPerMeter(QuantityValue newton /// If value is NaN or Infinity. public static TorquePerLength FromPoundForceFeetPerFoot(QuantityValue poundforcefeetperfoot) { - double value = (double) poundforcefeetperfoot; + QuantityValue value = (QuantityValue) poundforcefeetperfoot; return new TorquePerLength(value, TorquePerLengthUnit.PoundForceFootPerFoot); } @@ -568,7 +571,7 @@ public static TorquePerLength FromPoundForceFeetPerFoot(QuantityValue poundforce /// If value is NaN or Infinity. public static TorquePerLength FromPoundForceInchesPerFoot(QuantityValue poundforceinchesperfoot) { - double value = (double) poundforceinchesperfoot; + QuantityValue value = (QuantityValue) poundforceinchesperfoot; return new TorquePerLength(value, TorquePerLengthUnit.PoundForceInchPerFoot); } @@ -578,7 +581,7 @@ public static TorquePerLength FromPoundForceInchesPerFoot(QuantityValue poundfor /// If value is NaN or Infinity. public static TorquePerLength FromTonneForceCentimetersPerMeter(QuantityValue tonneforcecentimeterspermeter) { - double value = (double) tonneforcecentimeterspermeter; + QuantityValue value = (QuantityValue) tonneforcecentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.TonneForceCentimeterPerMeter); } @@ -588,7 +591,7 @@ public static TorquePerLength FromTonneForceCentimetersPerMeter(QuantityValue to /// If value is NaN or Infinity. public static TorquePerLength FromTonneForceMetersPerMeter(QuantityValue tonneforcemeterspermeter) { - double value = (double) tonneforcemeterspermeter; + QuantityValue value = (QuantityValue) tonneforcemeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMeterPerMeter); } @@ -598,7 +601,7 @@ public static TorquePerLength FromTonneForceMetersPerMeter(QuantityValue tonnefo /// If value is NaN or Infinity. public static TorquePerLength FromTonneForceMillimetersPerMeter(QuantityValue tonneforcemillimeterspermeter) { - double value = (double) tonneforcemillimeterspermeter; + QuantityValue value = (QuantityValue) tonneforcemillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMillimeterPerMeter); } @@ -610,7 +613,7 @@ public static TorquePerLength FromTonneForceMillimetersPerMeter(QuantityValue to /// TorquePerLength unit value. public static TorquePerLength From(QuantityValue value, TorquePerLengthUnit fromUnit) { - return new TorquePerLength((double)value, fromUnit); + return new TorquePerLength((QuantityValue)value, fromUnit); } #endregion @@ -780,25 +783,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu } /// Get from multiplying value and . - public static TorquePerLength operator *(double left, TorquePerLength right) + public static TorquePerLength operator *(QuantityValue left, TorquePerLength right) { return new TorquePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TorquePerLength operator *(TorquePerLength left, double right) + public static TorquePerLength operator *(TorquePerLength left, QuantityValue right) { return new TorquePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TorquePerLength operator /(TorquePerLength left, double right) + public static TorquePerLength operator /(TorquePerLength left, QuantityValue right) { return new TorquePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(TorquePerLength left, TorquePerLength right) + public static QuantityValue operator /(TorquePerLength left, TorquePerLength right) { return left.NewtonMetersPerMeter / right.NewtonMetersPerMeter; } @@ -831,6 +834,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(TorquePerLength left, TorquePerLength right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(TorquePerLength left, TorquePerLength right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -843,7 +859,29 @@ public int CompareTo(object obj) /// public int CompareTo(TorquePerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is TorquePerLength objTorquePerLength)) + return false; + return Equals(objTorquePerLength); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(TorquePerLength other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -886,13 +924,13 @@ public int CompareTo(TorquePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TorquePerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(TorquePerLength other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -903,7 +941,7 @@ public bool Equals(TorquePerLength other, double tolerance, ComparisonType compa /// A hash code for the current TorquePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -914,17 +952,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TorquePerLengthUnit unit) + public QuantityValue As(TorquePerLengthUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -939,12 +976,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) + if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsTorquePerLengthUnit); + return (QuantityValue)As(typedUnit); } /// @@ -976,7 +1013,7 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (TorquePerLength)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TorquePerLengthUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -984,17 +1021,17 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) + if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTorquePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1021,10 +1058,10 @@ public TorquePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TorquePerLengthUnit unit) + private QuantityValue GetValueAs(TorquePerLengthUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index f94f7592e1..0e87ea313b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Turbidity /// [DataContract] - public partial struct Turbidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Turbidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Turbidity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Turbidity(double value, TurbidityUnit unit) + public Turbidity(QuantityValue value, TurbidityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -89,14 +89,14 @@ public Turbidity(double value, TurbidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Turbidity(double value, UnitSystem unitSystem) + public Turbidity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,7 +137,10 @@ public Turbidity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +163,9 @@ public Turbidity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NTU => As(TurbidityUnit.NTU); + public QuantityValue NTU => As(TurbidityUnit.NTU); #endregion @@ -218,7 +221,7 @@ public static string GetAbbreviation(TurbidityUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static Turbidity FromNTU(QuantityValue ntu) { - double value = (double) ntu; + QuantityValue value = (QuantityValue) ntu; return new Turbidity(value, TurbidityUnit.NTU); } @@ -230,7 +233,7 @@ public static Turbidity FromNTU(QuantityValue ntu) /// Turbidity unit value. public static Turbidity From(QuantityValue value, TurbidityUnit fromUnit) { - return new Turbidity((double)value, fromUnit); + return new Turbidity((QuantityValue)value, fromUnit); } #endregion @@ -400,25 +403,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi } /// Get from multiplying value and . - public static Turbidity operator *(double left, Turbidity right) + public static Turbidity operator *(QuantityValue left, Turbidity right) { return new Turbidity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Turbidity operator *(Turbidity left, double right) + public static Turbidity operator *(Turbidity left, QuantityValue right) { return new Turbidity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Turbidity operator /(Turbidity left, double right) + public static Turbidity operator /(Turbidity left, QuantityValue right) { return new Turbidity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Turbidity left, Turbidity right) + public static QuantityValue operator /(Turbidity left, Turbidity right) { return left.NTU / right.NTU; } @@ -451,6 +454,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Turbidity left, Turbidity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Turbidity left, Turbidity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -463,7 +479,29 @@ public int CompareTo(object obj) /// public int CompareTo(Turbidity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Turbidity objTurbidity)) + return false; + return Equals(objTurbidity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Turbidity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -506,13 +544,13 @@ public int CompareTo(Turbidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonType) + public bool Equals(Turbidity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -523,7 +561,7 @@ public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonT /// A hash code for the current Turbidity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -534,17 +572,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(TurbidityUnit unit) + public QuantityValue As(TurbidityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -559,12 +596,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is TurbidityUnit unitAsTurbidityUnit)) + if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return As(unitAsTurbidityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -596,7 +633,7 @@ public Turbidity ToUnit(TurbidityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Turbidity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(TurbidityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -604,17 +641,17 @@ public Turbidity ToUnit(TurbidityUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TurbidityUnit unitAsTurbidityUnit)) + if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTurbidityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -641,10 +678,10 @@ public Turbidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(TurbidityUnit unit) + private QuantityValue GetValueAs(TurbidityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 454db0c919..2bedd85d64 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. /// [DataContract] - public partial struct VitaminA : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct VitaminA : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static VitaminA() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VitaminA(double value, VitaminAUnit unit) + public VitaminA(QuantityValue value, VitaminAUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -86,14 +86,14 @@ public VitaminA(double value, VitaminAUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VitaminA(double value, UnitSystem unitSystem) + public VitaminA(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,7 +134,10 @@ public VitaminA(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -157,9 +160,9 @@ public VitaminA(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InternationalUnits => As(VitaminAUnit.InternationalUnit); + public QuantityValue InternationalUnits => As(VitaminAUnit.InternationalUnit); #endregion @@ -215,7 +218,7 @@ public static string GetAbbreviation(VitaminAUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static VitaminA FromInternationalUnits(QuantityValue internationalunits) { - double value = (double) internationalunits; + QuantityValue value = (QuantityValue) internationalunits; return new VitaminA(value, VitaminAUnit.InternationalUnit); } @@ -227,7 +230,7 @@ public static VitaminA FromInternationalUnits(QuantityValue internationalunits) /// VitaminA unit value. public static VitaminA From(QuantityValue value, VitaminAUnit fromUnit) { - return new VitaminA((double)value, fromUnit); + return new VitaminA((QuantityValue)value, fromUnit); } #endregion @@ -397,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam } /// Get from multiplying value and . - public static VitaminA operator *(double left, VitaminA right) + public static VitaminA operator *(QuantityValue left, VitaminA right) { return new VitaminA(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VitaminA operator *(VitaminA left, double right) + public static VitaminA operator *(VitaminA left, QuantityValue right) { return new VitaminA(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VitaminA operator /(VitaminA left, double right) + public static VitaminA operator /(VitaminA left, QuantityValue right) { return new VitaminA(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VitaminA left, VitaminA right) + public static QuantityValue operator /(VitaminA left, VitaminA right) { return left.InternationalUnits / right.InternationalUnits; } @@ -448,6 +451,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(VitaminA left, VitaminA right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(VitaminA left, VitaminA right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -460,7 +476,29 @@ public int CompareTo(object obj) /// public int CompareTo(VitaminA other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is VitaminA objVitaminA)) + return false; + return Equals(objVitaminA); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(VitaminA other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -503,13 +541,13 @@ public int CompareTo(VitaminA other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType) + public bool Equals(VitaminA other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -520,7 +558,7 @@ public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonTy /// A hash code for the current VitaminA. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -531,17 +569,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VitaminAUnit unit) + public QuantityValue As(VitaminAUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -556,12 +593,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VitaminAUnit unitAsVitaminAUnit)) + if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return As(unitAsVitaminAUnit); + return (QuantityValue)As(typedUnit); } /// @@ -593,7 +630,7 @@ public VitaminA ToUnit(VitaminAUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (VitaminA)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VitaminAUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -601,17 +638,17 @@ public VitaminA ToUnit(VitaminAUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VitaminAUnit unitAsVitaminAUnit)) + if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVitaminAUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -638,10 +675,10 @@ public VitaminA ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VitaminAUnit unit) + private QuantityValue GetValueAs(VitaminAUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 2d54789723..80f0571e29 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. /// [DataContract] - public partial struct Volume : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct Volume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -123,9 +123,9 @@ static Volume() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Volume(double value, VolumeUnit unit) + public Volume(QuantityValue value, VolumeUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -137,14 +137,14 @@ public Volume(double value, VolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Volume(double value, UnitSystem unitSystem) + public Volume(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -185,7 +185,10 @@ public Volume(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -208,264 +211,264 @@ public Volume(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AcreFeet => As(VolumeUnit.AcreFoot); + public QuantityValue AcreFeet => As(VolumeUnit.AcreFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AuTablespoons => As(VolumeUnit.AuTablespoon); + public QuantityValue AuTablespoons => As(VolumeUnit.AuTablespoon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BoardFeet => As(VolumeUnit.BoardFoot); + public QuantityValue BoardFeet => As(VolumeUnit.BoardFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Centiliters => As(VolumeUnit.Centiliter); + public QuantityValue Centiliters => As(VolumeUnit.Centiliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicCentimeters => As(VolumeUnit.CubicCentimeter); + public QuantityValue CubicCentimeters => As(VolumeUnit.CubicCentimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicDecimeters => As(VolumeUnit.CubicDecimeter); + public QuantityValue CubicDecimeters => As(VolumeUnit.CubicDecimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicFeet => As(VolumeUnit.CubicFoot); + public QuantityValue CubicFeet => As(VolumeUnit.CubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicHectometers => As(VolumeUnit.CubicHectometer); + public QuantityValue CubicHectometers => As(VolumeUnit.CubicHectometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicInches => As(VolumeUnit.CubicInch); + public QuantityValue CubicInches => As(VolumeUnit.CubicInch); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicKilometers => As(VolumeUnit.CubicKilometer); + public QuantityValue CubicKilometers => As(VolumeUnit.CubicKilometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMeters => As(VolumeUnit.CubicMeter); + public QuantityValue CubicMeters => As(VolumeUnit.CubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMicrometers => As(VolumeUnit.CubicMicrometer); + public QuantityValue CubicMicrometers => As(VolumeUnit.CubicMicrometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMiles => As(VolumeUnit.CubicMile); + public QuantityValue CubicMiles => As(VolumeUnit.CubicMile); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMillimeters => As(VolumeUnit.CubicMillimeter); + public QuantityValue CubicMillimeters => As(VolumeUnit.CubicMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYards => As(VolumeUnit.CubicYard); + public QuantityValue CubicYards => As(VolumeUnit.CubicYard); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Decaliters => As(VolumeUnit.Decaliter); + public QuantityValue Decaliters => As(VolumeUnit.Decaliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecausGallons => As(VolumeUnit.DecausGallon); + public QuantityValue DecausGallons => As(VolumeUnit.DecausGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Deciliters => As(VolumeUnit.Deciliter); + public QuantityValue Deciliters => As(VolumeUnit.Deciliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DeciusGallons => As(VolumeUnit.DeciusGallon); + public QuantityValue DeciusGallons => As(VolumeUnit.DeciusGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectocubicFeet => As(VolumeUnit.HectocubicFoot); + public QuantityValue HectocubicFeet => As(VolumeUnit.HectocubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectocubicMeters => As(VolumeUnit.HectocubicMeter); + public QuantityValue HectocubicMeters => As(VolumeUnit.HectocubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Hectoliters => As(VolumeUnit.Hectoliter); + public QuantityValue Hectoliters => As(VolumeUnit.Hectoliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double HectousGallons => As(VolumeUnit.HectousGallon); + public QuantityValue HectousGallons => As(VolumeUnit.HectousGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); + public QuantityValue ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ImperialGallons => As(VolumeUnit.ImperialGallon); + public QuantityValue ImperialGallons => As(VolumeUnit.ImperialGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ImperialOunces => As(VolumeUnit.ImperialOunce); + public QuantityValue ImperialOunces => As(VolumeUnit.ImperialOunce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double ImperialPints => As(VolumeUnit.ImperialPint); + public QuantityValue ImperialPints => As(VolumeUnit.ImperialPint); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocubicFeet => As(VolumeUnit.KilocubicFoot); + public QuantityValue KilocubicFeet => As(VolumeUnit.KilocubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocubicMeters => As(VolumeUnit.KilocubicMeter); + public QuantityValue KilocubicMeters => As(VolumeUnit.KilocubicMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); + public QuantityValue KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Kiloliters => As(VolumeUnit.Kiloliter); + public QuantityValue Kiloliters => As(VolumeUnit.Kiloliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilousGallons => As(VolumeUnit.KilousGallon); + public QuantityValue KilousGallons => As(VolumeUnit.KilousGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Liters => As(VolumeUnit.Liter); + public QuantityValue Liters => As(VolumeUnit.Liter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegacubicFeet => As(VolumeUnit.MegacubicFoot); + public QuantityValue MegacubicFeet => As(VolumeUnit.MegacubicFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); + public QuantityValue MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Megaliters => As(VolumeUnit.Megaliter); + public QuantityValue Megaliters => As(VolumeUnit.Megaliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegausGallons => As(VolumeUnit.MegausGallon); + public QuantityValue MegausGallons => As(VolumeUnit.MegausGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetricCups => As(VolumeUnit.MetricCup); + public QuantityValue MetricCups => As(VolumeUnit.MetricCup); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); + public QuantityValue MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Microliters => As(VolumeUnit.Microliter); + public QuantityValue Microliters => As(VolumeUnit.Microliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Milliliters => As(VolumeUnit.Milliliter); + public QuantityValue Milliliters => As(VolumeUnit.Milliliter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OilBarrels => As(VolumeUnit.OilBarrel); + public QuantityValue OilBarrels => As(VolumeUnit.OilBarrel); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UkTablespoons => As(VolumeUnit.UkTablespoon); + public QuantityValue UkTablespoons => As(VolumeUnit.UkTablespoon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); + public QuantityValue UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); + public QuantityValue UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsGallons => As(VolumeUnit.UsGallon); + public QuantityValue UsGallons => As(VolumeUnit.UsGallon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsLegalCups => As(VolumeUnit.UsLegalCup); + public QuantityValue UsLegalCups => As(VolumeUnit.UsLegalCup); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsOunces => As(VolumeUnit.UsOunce); + public QuantityValue UsOunces => As(VolumeUnit.UsOunce); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsPints => As(VolumeUnit.UsPint); + public QuantityValue UsPints => As(VolumeUnit.UsPint); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsQuarts => As(VolumeUnit.UsQuart); + public QuantityValue UsQuarts => As(VolumeUnit.UsQuart); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsTablespoons => As(VolumeUnit.UsTablespoon); + public QuantityValue UsTablespoons => As(VolumeUnit.UsTablespoon); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsTeaspoons => As(VolumeUnit.UsTeaspoon); + public QuantityValue UsTeaspoons => As(VolumeUnit.UsTeaspoon); #endregion @@ -721,7 +724,7 @@ public static string GetAbbreviation(VolumeUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Volume FromAcreFeet(QuantityValue acrefeet) { - double value = (double) acrefeet; + QuantityValue value = (QuantityValue) acrefeet; return new Volume(value, VolumeUnit.AcreFoot); } @@ -731,7 +734,7 @@ public static Volume FromAcreFeet(QuantityValue acrefeet) /// If value is NaN or Infinity. public static Volume FromAuTablespoons(QuantityValue autablespoons) { - double value = (double) autablespoons; + QuantityValue value = (QuantityValue) autablespoons; return new Volume(value, VolumeUnit.AuTablespoon); } @@ -741,7 +744,7 @@ public static Volume FromAuTablespoons(QuantityValue autablespoons) /// If value is NaN or Infinity. public static Volume FromBoardFeet(QuantityValue boardfeet) { - double value = (double) boardfeet; + QuantityValue value = (QuantityValue) boardfeet; return new Volume(value, VolumeUnit.BoardFoot); } @@ -751,7 +754,7 @@ public static Volume FromBoardFeet(QuantityValue boardfeet) /// If value is NaN or Infinity. public static Volume FromCentiliters(QuantityValue centiliters) { - double value = (double) centiliters; + QuantityValue value = (QuantityValue) centiliters; return new Volume(value, VolumeUnit.Centiliter); } @@ -761,7 +764,7 @@ public static Volume FromCentiliters(QuantityValue centiliters) /// If value is NaN or Infinity. public static Volume FromCubicCentimeters(QuantityValue cubiccentimeters) { - double value = (double) cubiccentimeters; + QuantityValue value = (QuantityValue) cubiccentimeters; return new Volume(value, VolumeUnit.CubicCentimeter); } @@ -771,7 +774,7 @@ public static Volume FromCubicCentimeters(QuantityValue cubiccentimeters) /// If value is NaN or Infinity. public static Volume FromCubicDecimeters(QuantityValue cubicdecimeters) { - double value = (double) cubicdecimeters; + QuantityValue value = (QuantityValue) cubicdecimeters; return new Volume(value, VolumeUnit.CubicDecimeter); } @@ -781,7 +784,7 @@ public static Volume FromCubicDecimeters(QuantityValue cubicdecimeters) /// If value is NaN or Infinity. public static Volume FromCubicFeet(QuantityValue cubicfeet) { - double value = (double) cubicfeet; + QuantityValue value = (QuantityValue) cubicfeet; return new Volume(value, VolumeUnit.CubicFoot); } @@ -791,7 +794,7 @@ public static Volume FromCubicFeet(QuantityValue cubicfeet) /// If value is NaN or Infinity. public static Volume FromCubicHectometers(QuantityValue cubichectometers) { - double value = (double) cubichectometers; + QuantityValue value = (QuantityValue) cubichectometers; return new Volume(value, VolumeUnit.CubicHectometer); } @@ -801,7 +804,7 @@ public static Volume FromCubicHectometers(QuantityValue cubichectometers) /// If value is NaN or Infinity. public static Volume FromCubicInches(QuantityValue cubicinches) { - double value = (double) cubicinches; + QuantityValue value = (QuantityValue) cubicinches; return new Volume(value, VolumeUnit.CubicInch); } @@ -811,7 +814,7 @@ public static Volume FromCubicInches(QuantityValue cubicinches) /// If value is NaN or Infinity. public static Volume FromCubicKilometers(QuantityValue cubickilometers) { - double value = (double) cubickilometers; + QuantityValue value = (QuantityValue) cubickilometers; return new Volume(value, VolumeUnit.CubicKilometer); } @@ -821,7 +824,7 @@ public static Volume FromCubicKilometers(QuantityValue cubickilometers) /// If value is NaN or Infinity. public static Volume FromCubicMeters(QuantityValue cubicmeters) { - double value = (double) cubicmeters; + QuantityValue value = (QuantityValue) cubicmeters; return new Volume(value, VolumeUnit.CubicMeter); } @@ -831,7 +834,7 @@ public static Volume FromCubicMeters(QuantityValue cubicmeters) /// If value is NaN or Infinity. public static Volume FromCubicMicrometers(QuantityValue cubicmicrometers) { - double value = (double) cubicmicrometers; + QuantityValue value = (QuantityValue) cubicmicrometers; return new Volume(value, VolumeUnit.CubicMicrometer); } @@ -841,7 +844,7 @@ public static Volume FromCubicMicrometers(QuantityValue cubicmicrometers) /// If value is NaN or Infinity. public static Volume FromCubicMiles(QuantityValue cubicmiles) { - double value = (double) cubicmiles; + QuantityValue value = (QuantityValue) cubicmiles; return new Volume(value, VolumeUnit.CubicMile); } @@ -851,7 +854,7 @@ public static Volume FromCubicMiles(QuantityValue cubicmiles) /// If value is NaN or Infinity. public static Volume FromCubicMillimeters(QuantityValue cubicmillimeters) { - double value = (double) cubicmillimeters; + QuantityValue value = (QuantityValue) cubicmillimeters; return new Volume(value, VolumeUnit.CubicMillimeter); } @@ -861,7 +864,7 @@ public static Volume FromCubicMillimeters(QuantityValue cubicmillimeters) /// If value is NaN or Infinity. public static Volume FromCubicYards(QuantityValue cubicyards) { - double value = (double) cubicyards; + QuantityValue value = (QuantityValue) cubicyards; return new Volume(value, VolumeUnit.CubicYard); } @@ -871,7 +874,7 @@ public static Volume FromCubicYards(QuantityValue cubicyards) /// If value is NaN or Infinity. public static Volume FromDecaliters(QuantityValue decaliters) { - double value = (double) decaliters; + QuantityValue value = (QuantityValue) decaliters; return new Volume(value, VolumeUnit.Decaliter); } @@ -881,7 +884,7 @@ public static Volume FromDecaliters(QuantityValue decaliters) /// If value is NaN or Infinity. public static Volume FromDecausGallons(QuantityValue decausgallons) { - double value = (double) decausgallons; + QuantityValue value = (QuantityValue) decausgallons; return new Volume(value, VolumeUnit.DecausGallon); } @@ -891,7 +894,7 @@ public static Volume FromDecausGallons(QuantityValue decausgallons) /// If value is NaN or Infinity. public static Volume FromDeciliters(QuantityValue deciliters) { - double value = (double) deciliters; + QuantityValue value = (QuantityValue) deciliters; return new Volume(value, VolumeUnit.Deciliter); } @@ -901,7 +904,7 @@ public static Volume FromDeciliters(QuantityValue deciliters) /// If value is NaN or Infinity. public static Volume FromDeciusGallons(QuantityValue deciusgallons) { - double value = (double) deciusgallons; + QuantityValue value = (QuantityValue) deciusgallons; return new Volume(value, VolumeUnit.DeciusGallon); } @@ -911,7 +914,7 @@ public static Volume FromDeciusGallons(QuantityValue deciusgallons) /// If value is NaN or Infinity. public static Volume FromHectocubicFeet(QuantityValue hectocubicfeet) { - double value = (double) hectocubicfeet; + QuantityValue value = (QuantityValue) hectocubicfeet; return new Volume(value, VolumeUnit.HectocubicFoot); } @@ -921,7 +924,7 @@ public static Volume FromHectocubicFeet(QuantityValue hectocubicfeet) /// If value is NaN or Infinity. public static Volume FromHectocubicMeters(QuantityValue hectocubicmeters) { - double value = (double) hectocubicmeters; + QuantityValue value = (QuantityValue) hectocubicmeters; return new Volume(value, VolumeUnit.HectocubicMeter); } @@ -931,7 +934,7 @@ public static Volume FromHectocubicMeters(QuantityValue hectocubicmeters) /// If value is NaN or Infinity. public static Volume FromHectoliters(QuantityValue hectoliters) { - double value = (double) hectoliters; + QuantityValue value = (QuantityValue) hectoliters; return new Volume(value, VolumeUnit.Hectoliter); } @@ -941,7 +944,7 @@ public static Volume FromHectoliters(QuantityValue hectoliters) /// If value is NaN or Infinity. public static Volume FromHectousGallons(QuantityValue hectousgallons) { - double value = (double) hectousgallons; + QuantityValue value = (QuantityValue) hectousgallons; return new Volume(value, VolumeUnit.HectousGallon); } @@ -951,7 +954,7 @@ public static Volume FromHectousGallons(QuantityValue hectousgallons) /// If value is NaN or Infinity. public static Volume FromImperialBeerBarrels(QuantityValue imperialbeerbarrels) { - double value = (double) imperialbeerbarrels; + QuantityValue value = (QuantityValue) imperialbeerbarrels; return new Volume(value, VolumeUnit.ImperialBeerBarrel); } @@ -961,7 +964,7 @@ public static Volume FromImperialBeerBarrels(QuantityValue imperialbeerbarrels) /// If value is NaN or Infinity. public static Volume FromImperialGallons(QuantityValue imperialgallons) { - double value = (double) imperialgallons; + QuantityValue value = (QuantityValue) imperialgallons; return new Volume(value, VolumeUnit.ImperialGallon); } @@ -971,7 +974,7 @@ public static Volume FromImperialGallons(QuantityValue imperialgallons) /// If value is NaN or Infinity. public static Volume FromImperialOunces(QuantityValue imperialounces) { - double value = (double) imperialounces; + QuantityValue value = (QuantityValue) imperialounces; return new Volume(value, VolumeUnit.ImperialOunce); } @@ -981,7 +984,7 @@ public static Volume FromImperialOunces(QuantityValue imperialounces) /// If value is NaN or Infinity. public static Volume FromImperialPints(QuantityValue imperialpints) { - double value = (double) imperialpints; + QuantityValue value = (QuantityValue) imperialpints; return new Volume(value, VolumeUnit.ImperialPint); } @@ -991,7 +994,7 @@ public static Volume FromImperialPints(QuantityValue imperialpints) /// If value is NaN or Infinity. public static Volume FromKilocubicFeet(QuantityValue kilocubicfeet) { - double value = (double) kilocubicfeet; + QuantityValue value = (QuantityValue) kilocubicfeet; return new Volume(value, VolumeUnit.KilocubicFoot); } @@ -1001,7 +1004,7 @@ public static Volume FromKilocubicFeet(QuantityValue kilocubicfeet) /// If value is NaN or Infinity. public static Volume FromKilocubicMeters(QuantityValue kilocubicmeters) { - double value = (double) kilocubicmeters; + QuantityValue value = (QuantityValue) kilocubicmeters; return new Volume(value, VolumeUnit.KilocubicMeter); } @@ -1011,7 +1014,7 @@ public static Volume FromKilocubicMeters(QuantityValue kilocubicmeters) /// If value is NaN or Infinity. public static Volume FromKiloimperialGallons(QuantityValue kiloimperialgallons) { - double value = (double) kiloimperialgallons; + QuantityValue value = (QuantityValue) kiloimperialgallons; return new Volume(value, VolumeUnit.KiloimperialGallon); } @@ -1021,7 +1024,7 @@ public static Volume FromKiloimperialGallons(QuantityValue kiloimperialgallons) /// If value is NaN or Infinity. public static Volume FromKiloliters(QuantityValue kiloliters) { - double value = (double) kiloliters; + QuantityValue value = (QuantityValue) kiloliters; return new Volume(value, VolumeUnit.Kiloliter); } @@ -1031,7 +1034,7 @@ public static Volume FromKiloliters(QuantityValue kiloliters) /// If value is NaN or Infinity. public static Volume FromKilousGallons(QuantityValue kilousgallons) { - double value = (double) kilousgallons; + QuantityValue value = (QuantityValue) kilousgallons; return new Volume(value, VolumeUnit.KilousGallon); } @@ -1041,7 +1044,7 @@ public static Volume FromKilousGallons(QuantityValue kilousgallons) /// If value is NaN or Infinity. public static Volume FromLiters(QuantityValue liters) { - double value = (double) liters; + QuantityValue value = (QuantityValue) liters; return new Volume(value, VolumeUnit.Liter); } @@ -1051,7 +1054,7 @@ public static Volume FromLiters(QuantityValue liters) /// If value is NaN or Infinity. public static Volume FromMegacubicFeet(QuantityValue megacubicfeet) { - double value = (double) megacubicfeet; + QuantityValue value = (QuantityValue) megacubicfeet; return new Volume(value, VolumeUnit.MegacubicFoot); } @@ -1061,7 +1064,7 @@ public static Volume FromMegacubicFeet(QuantityValue megacubicfeet) /// If value is NaN or Infinity. public static Volume FromMegaimperialGallons(QuantityValue megaimperialgallons) { - double value = (double) megaimperialgallons; + QuantityValue value = (QuantityValue) megaimperialgallons; return new Volume(value, VolumeUnit.MegaimperialGallon); } @@ -1071,7 +1074,7 @@ public static Volume FromMegaimperialGallons(QuantityValue megaimperialgallons) /// If value is NaN or Infinity. public static Volume FromMegaliters(QuantityValue megaliters) { - double value = (double) megaliters; + QuantityValue value = (QuantityValue) megaliters; return new Volume(value, VolumeUnit.Megaliter); } @@ -1081,7 +1084,7 @@ public static Volume FromMegaliters(QuantityValue megaliters) /// If value is NaN or Infinity. public static Volume FromMegausGallons(QuantityValue megausgallons) { - double value = (double) megausgallons; + QuantityValue value = (QuantityValue) megausgallons; return new Volume(value, VolumeUnit.MegausGallon); } @@ -1091,7 +1094,7 @@ public static Volume FromMegausGallons(QuantityValue megausgallons) /// If value is NaN or Infinity. public static Volume FromMetricCups(QuantityValue metriccups) { - double value = (double) metriccups; + QuantityValue value = (QuantityValue) metriccups; return new Volume(value, VolumeUnit.MetricCup); } @@ -1101,7 +1104,7 @@ public static Volume FromMetricCups(QuantityValue metriccups) /// If value is NaN or Infinity. public static Volume FromMetricTeaspoons(QuantityValue metricteaspoons) { - double value = (double) metricteaspoons; + QuantityValue value = (QuantityValue) metricteaspoons; return new Volume(value, VolumeUnit.MetricTeaspoon); } @@ -1111,7 +1114,7 @@ public static Volume FromMetricTeaspoons(QuantityValue metricteaspoons) /// If value is NaN or Infinity. public static Volume FromMicroliters(QuantityValue microliters) { - double value = (double) microliters; + QuantityValue value = (QuantityValue) microliters; return new Volume(value, VolumeUnit.Microliter); } @@ -1121,7 +1124,7 @@ public static Volume FromMicroliters(QuantityValue microliters) /// If value is NaN or Infinity. public static Volume FromMilliliters(QuantityValue milliliters) { - double value = (double) milliliters; + QuantityValue value = (QuantityValue) milliliters; return new Volume(value, VolumeUnit.Milliliter); } @@ -1131,7 +1134,7 @@ public static Volume FromMilliliters(QuantityValue milliliters) /// If value is NaN or Infinity. public static Volume FromOilBarrels(QuantityValue oilbarrels) { - double value = (double) oilbarrels; + QuantityValue value = (QuantityValue) oilbarrels; return new Volume(value, VolumeUnit.OilBarrel); } @@ -1141,7 +1144,7 @@ public static Volume FromOilBarrels(QuantityValue oilbarrels) /// If value is NaN or Infinity. public static Volume FromUkTablespoons(QuantityValue uktablespoons) { - double value = (double) uktablespoons; + QuantityValue value = (QuantityValue) uktablespoons; return new Volume(value, VolumeUnit.UkTablespoon); } @@ -1151,7 +1154,7 @@ public static Volume FromUkTablespoons(QuantityValue uktablespoons) /// If value is NaN or Infinity. public static Volume FromUsBeerBarrels(QuantityValue usbeerbarrels) { - double value = (double) usbeerbarrels; + QuantityValue value = (QuantityValue) usbeerbarrels; return new Volume(value, VolumeUnit.UsBeerBarrel); } @@ -1161,7 +1164,7 @@ public static Volume FromUsBeerBarrels(QuantityValue usbeerbarrels) /// If value is NaN or Infinity. public static Volume FromUsCustomaryCups(QuantityValue uscustomarycups) { - double value = (double) uscustomarycups; + QuantityValue value = (QuantityValue) uscustomarycups; return new Volume(value, VolumeUnit.UsCustomaryCup); } @@ -1171,7 +1174,7 @@ public static Volume FromUsCustomaryCups(QuantityValue uscustomarycups) /// If value is NaN or Infinity. public static Volume FromUsGallons(QuantityValue usgallons) { - double value = (double) usgallons; + QuantityValue value = (QuantityValue) usgallons; return new Volume(value, VolumeUnit.UsGallon); } @@ -1181,7 +1184,7 @@ public static Volume FromUsGallons(QuantityValue usgallons) /// If value is NaN or Infinity. public static Volume FromUsLegalCups(QuantityValue uslegalcups) { - double value = (double) uslegalcups; + QuantityValue value = (QuantityValue) uslegalcups; return new Volume(value, VolumeUnit.UsLegalCup); } @@ -1191,7 +1194,7 @@ public static Volume FromUsLegalCups(QuantityValue uslegalcups) /// If value is NaN or Infinity. public static Volume FromUsOunces(QuantityValue usounces) { - double value = (double) usounces; + QuantityValue value = (QuantityValue) usounces; return new Volume(value, VolumeUnit.UsOunce); } @@ -1201,7 +1204,7 @@ public static Volume FromUsOunces(QuantityValue usounces) /// If value is NaN or Infinity. public static Volume FromUsPints(QuantityValue uspints) { - double value = (double) uspints; + QuantityValue value = (QuantityValue) uspints; return new Volume(value, VolumeUnit.UsPint); } @@ -1211,7 +1214,7 @@ public static Volume FromUsPints(QuantityValue uspints) /// If value is NaN or Infinity. public static Volume FromUsQuarts(QuantityValue usquarts) { - double value = (double) usquarts; + QuantityValue value = (QuantityValue) usquarts; return new Volume(value, VolumeUnit.UsQuart); } @@ -1221,7 +1224,7 @@ public static Volume FromUsQuarts(QuantityValue usquarts) /// If value is NaN or Infinity. public static Volume FromUsTablespoons(QuantityValue ustablespoons) { - double value = (double) ustablespoons; + QuantityValue value = (QuantityValue) ustablespoons; return new Volume(value, VolumeUnit.UsTablespoon); } @@ -1231,7 +1234,7 @@ public static Volume FromUsTablespoons(QuantityValue ustablespoons) /// If value is NaN or Infinity. public static Volume FromUsTeaspoons(QuantityValue usteaspoons) { - double value = (double) usteaspoons; + QuantityValue value = (QuantityValue) usteaspoons; return new Volume(value, VolumeUnit.UsTeaspoon); } @@ -1243,7 +1246,7 @@ public static Volume FromUsTeaspoons(QuantityValue usteaspoons) /// Volume unit value. public static Volume From(QuantityValue value, VolumeUnit fromUnit) { - return new Volume((double)value, fromUnit); + return new Volume((QuantityValue)value, fromUnit); } #endregion @@ -1413,25 +1416,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static Volume operator *(double left, Volume right) + public static Volume operator *(QuantityValue left, Volume right) { return new Volume(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Volume operator *(Volume left, double right) + public static Volume operator *(Volume left, QuantityValue right) { return new Volume(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Volume operator /(Volume left, double right) + public static Volume operator /(Volume left, QuantityValue right) { return new Volume(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(Volume left, Volume right) + public static QuantityValue operator /(Volume left, Volume right) { return left.CubicMeters / right.CubicMeters; } @@ -1464,6 +1467,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(Volume left, Volume right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(Volume left, Volume right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1476,7 +1492,29 @@ public int CompareTo(object obj) /// public int CompareTo(Volume other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is Volume objVolume)) + return false; + return Equals(objVolume); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(Volume other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1519,13 +1557,13 @@ public int CompareTo(Volume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Volume other, double tolerance, ComparisonType comparisonType) + public bool Equals(Volume other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1536,7 +1574,7 @@ public bool Equals(Volume other, double tolerance, ComparisonType comparisonType /// A hash code for the current Volume. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1547,17 +1585,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeUnit unit) + public QuantityValue As(VolumeUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1572,12 +1609,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VolumeUnit unitAsVolumeUnit)) + if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1609,7 +1646,7 @@ public Volume ToUnit(VolumeUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Volume)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VolumeUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1617,17 +1654,17 @@ public Volume ToUnit(VolumeUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeUnit unitAsVolumeUnit)) + if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1654,10 +1691,10 @@ public Volume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VolumeUnit unit) + private QuantityValue GetValueAs(VolumeUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 26d1de1beb..4f81ca2c36 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration /// [DataContract] - public partial struct VolumeConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -94,9 +94,9 @@ static VolumeConcentration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeConcentration(double value, VolumeConcentrationUnit unit) + public VolumeConcentration(QuantityValue value, VolumeConcentrationUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -108,14 +108,14 @@ public VolumeConcentration(double value, VolumeConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeConcentration(double value, UnitSystem unitSystem) + public VolumeConcentration(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -156,7 +156,10 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -179,104 +182,104 @@ public VolumeConcentration(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); + public QuantityValue CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); + public QuantityValue CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); + public QuantityValue DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); + public QuantityValue DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); + public QuantityValue DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); + public QuantityValue LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); + public QuantityValue LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); + public QuantityValue MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); + public QuantityValue MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); + public QuantityValue MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); + public QuantityValue MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); + public QuantityValue NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); + public QuantityValue NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); + public QuantityValue PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); + public QuantityValue PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); + public QuantityValue PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); + public QuantityValue PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double Percent => As(VolumeConcentrationUnit.Percent); + public QuantityValue Percent => As(VolumeConcentrationUnit.Percent); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); + public QuantityValue PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); + public QuantityValue PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); #endregion @@ -389,7 +392,7 @@ public static string GetAbbreviation(VolumeConcentrationUnit unit, IFormatProvid /// If value is NaN or Infinity. public static VolumeConcentration FromCentilitersPerLiter(QuantityValue centilitersperliter) { - double value = (double) centilitersperliter; + QuantityValue value = (QuantityValue) centilitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerLiter); } @@ -399,7 +402,7 @@ public static VolumeConcentration FromCentilitersPerLiter(QuantityValue centilit /// If value is NaN or Infinity. public static VolumeConcentration FromCentilitersPerMililiter(QuantityValue centiliterspermililiter) { - double value = (double) centiliterspermililiter; + QuantityValue value = (QuantityValue) centiliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerMililiter); } @@ -409,7 +412,7 @@ public static VolumeConcentration FromCentilitersPerMililiter(QuantityValue cent /// If value is NaN or Infinity. public static VolumeConcentration FromDecilitersPerLiter(QuantityValue decilitersperliter) { - double value = (double) decilitersperliter; + QuantityValue value = (QuantityValue) decilitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerLiter); } @@ -419,7 +422,7 @@ public static VolumeConcentration FromDecilitersPerLiter(QuantityValue deciliter /// If value is NaN or Infinity. public static VolumeConcentration FromDecilitersPerMililiter(QuantityValue deciliterspermililiter) { - double value = (double) deciliterspermililiter; + QuantityValue value = (QuantityValue) deciliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerMililiter); } @@ -429,7 +432,7 @@ public static VolumeConcentration FromDecilitersPerMililiter(QuantityValue decil /// If value is NaN or Infinity. public static VolumeConcentration FromDecimalFractions(QuantityValue decimalfractions) { - double value = (double) decimalfractions; + QuantityValue value = (QuantityValue) decimalfractions; return new VolumeConcentration(value, VolumeConcentrationUnit.DecimalFraction); } @@ -439,7 +442,7 @@ public static VolumeConcentration FromDecimalFractions(QuantityValue decimalfrac /// If value is NaN or Infinity. public static VolumeConcentration FromLitersPerLiter(QuantityValue litersperliter) { - double value = (double) litersperliter; + QuantityValue value = (QuantityValue) litersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerLiter); } @@ -449,7 +452,7 @@ public static VolumeConcentration FromLitersPerLiter(QuantityValue litersperlite /// If value is NaN or Infinity. public static VolumeConcentration FromLitersPerMililiter(QuantityValue literspermililiter) { - double value = (double) literspermililiter; + QuantityValue value = (QuantityValue) literspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerMililiter); } @@ -459,7 +462,7 @@ public static VolumeConcentration FromLitersPerMililiter(QuantityValue litersper /// If value is NaN or Infinity. public static VolumeConcentration FromMicrolitersPerLiter(QuantityValue microlitersperliter) { - double value = (double) microlitersperliter; + QuantityValue value = (QuantityValue) microlitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerLiter); } @@ -469,7 +472,7 @@ public static VolumeConcentration FromMicrolitersPerLiter(QuantityValue microlit /// If value is NaN or Infinity. public static VolumeConcentration FromMicrolitersPerMililiter(QuantityValue microliterspermililiter) { - double value = (double) microliterspermililiter; + QuantityValue value = (QuantityValue) microliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerMililiter); } @@ -479,7 +482,7 @@ public static VolumeConcentration FromMicrolitersPerMililiter(QuantityValue micr /// If value is NaN or Infinity. public static VolumeConcentration FromMillilitersPerLiter(QuantityValue millilitersperliter) { - double value = (double) millilitersperliter; + QuantityValue value = (QuantityValue) millilitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerLiter); } @@ -489,7 +492,7 @@ public static VolumeConcentration FromMillilitersPerLiter(QuantityValue millilit /// If value is NaN or Infinity. public static VolumeConcentration FromMillilitersPerMililiter(QuantityValue milliliterspermililiter) { - double value = (double) milliliterspermililiter; + QuantityValue value = (QuantityValue) milliliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerMililiter); } @@ -499,7 +502,7 @@ public static VolumeConcentration FromMillilitersPerMililiter(QuantityValue mill /// If value is NaN or Infinity. public static VolumeConcentration FromNanolitersPerLiter(QuantityValue nanolitersperliter) { - double value = (double) nanolitersperliter; + QuantityValue value = (QuantityValue) nanolitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerLiter); } @@ -509,7 +512,7 @@ public static VolumeConcentration FromNanolitersPerLiter(QuantityValue nanoliter /// If value is NaN or Infinity. public static VolumeConcentration FromNanolitersPerMililiter(QuantityValue nanoliterspermililiter) { - double value = (double) nanoliterspermililiter; + QuantityValue value = (QuantityValue) nanoliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerMililiter); } @@ -519,7 +522,7 @@ public static VolumeConcentration FromNanolitersPerMililiter(QuantityValue nanol /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerBillion(QuantityValue partsperbillion) { - double value = (double) partsperbillion; + QuantityValue value = (QuantityValue) partsperbillion; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerBillion); } @@ -529,7 +532,7 @@ public static VolumeConcentration FromPartsPerBillion(QuantityValue partsperbill /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerMillion(QuantityValue partspermillion) { - double value = (double) partspermillion; + QuantityValue value = (QuantityValue) partspermillion; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerMillion); } @@ -539,7 +542,7 @@ public static VolumeConcentration FromPartsPerMillion(QuantityValue partspermill /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerThousand(QuantityValue partsperthousand) { - double value = (double) partsperthousand; + QuantityValue value = (QuantityValue) partsperthousand; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerThousand); } @@ -549,7 +552,7 @@ public static VolumeConcentration FromPartsPerThousand(QuantityValue partspertho /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerTrillion(QuantityValue partspertrillion) { - double value = (double) partspertrillion; + QuantityValue value = (QuantityValue) partspertrillion; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerTrillion); } @@ -559,7 +562,7 @@ public static VolumeConcentration FromPartsPerTrillion(QuantityValue partspertri /// If value is NaN or Infinity. public static VolumeConcentration FromPercent(QuantityValue percent) { - double value = (double) percent; + QuantityValue value = (QuantityValue) percent; return new VolumeConcentration(value, VolumeConcentrationUnit.Percent); } @@ -569,7 +572,7 @@ public static VolumeConcentration FromPercent(QuantityValue percent) /// If value is NaN or Infinity. public static VolumeConcentration FromPicolitersPerLiter(QuantityValue picolitersperliter) { - double value = (double) picolitersperliter; + QuantityValue value = (QuantityValue) picolitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerLiter); } @@ -579,7 +582,7 @@ public static VolumeConcentration FromPicolitersPerLiter(QuantityValue picoliter /// If value is NaN or Infinity. public static VolumeConcentration FromPicolitersPerMililiter(QuantityValue picoliterspermililiter) { - double value = (double) picoliterspermililiter; + QuantityValue value = (QuantityValue) picoliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerMililiter); } @@ -591,7 +594,7 @@ public static VolumeConcentration FromPicolitersPerMililiter(QuantityValue picol /// VolumeConcentration unit value. public static VolumeConcentration From(QuantityValue value, VolumeConcentrationUnit fromUnit) { - return new VolumeConcentration((double)value, fromUnit); + return new VolumeConcentration((QuantityValue)value, fromUnit); } #endregion @@ -761,25 +764,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeConcentration operator *(double left, VolumeConcentration right) + public static VolumeConcentration operator *(QuantityValue left, VolumeConcentration right) { return new VolumeConcentration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeConcentration operator *(VolumeConcentration left, double right) + public static VolumeConcentration operator *(VolumeConcentration left, QuantityValue right) { return new VolumeConcentration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeConcentration operator /(VolumeConcentration left, double right) + public static VolumeConcentration operator /(VolumeConcentration left, QuantityValue right) { return new VolumeConcentration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumeConcentration left, VolumeConcentration right) + public static QuantityValue operator /(VolumeConcentration left, VolumeConcentration right) { return left.DecimalFractions / right.DecimalFractions; } @@ -812,6 +815,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumeConcentration left, VolumeConcentration right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumeConcentration left, VolumeConcentration right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -824,7 +840,29 @@ public int CompareTo(object obj) /// public int CompareTo(VolumeConcentration other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is VolumeConcentration objVolumeConcentration)) + return false; + return Equals(objVolumeConcentration); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(VolumeConcentration other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -867,13 +905,13 @@ public int CompareTo(VolumeConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeConcentration other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumeConcentration other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -884,7 +922,7 @@ public bool Equals(VolumeConcentration other, double tolerance, ComparisonType c /// A hash code for the current VolumeConcentration. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -895,17 +933,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeConcentrationUnit unit) + public QuantityValue As(VolumeConcentrationUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -920,12 +957,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) + if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeConcentrationUnit); + return (QuantityValue)As(typedUnit); } /// @@ -957,7 +994,7 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit, UnitConverter un var converted = conversionFunction(this); return (VolumeConcentration)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VolumeConcentrationUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -965,17 +1002,17 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit, UnitConverter un } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) + if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeConcentrationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1002,10 +1039,10 @@ public VolumeConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VolumeConcentrationUnit unit) + private QuantityValue GetValueAs(VolumeConcentrationUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 14cecc5941..db17809849 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. /// [DataContract] - public partial struct VolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -133,9 +133,9 @@ static VolumeFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeFlow(double value, VolumeFlowUnit unit) + public VolumeFlow(QuantityValue value, VolumeFlowUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -147,14 +147,14 @@ public VolumeFlow(double value, VolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlow(double value, UnitSystem unitSystem) + public VolumeFlow(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -195,7 +195,10 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -218,314 +221,314 @@ public VolumeFlow(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); + public QuantityValue AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); + public QuantityValue AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); + public QuantityValue AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); + public QuantityValue AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); + public QuantityValue CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentilitersPerHour => As(VolumeFlowUnit.CentiliterPerHour); + public QuantityValue CentilitersPerHour => As(VolumeFlowUnit.CentiliterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); + public QuantityValue CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); + public QuantityValue CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); + public QuantityValue CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); + public QuantityValue CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); + public QuantityValue CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); + public QuantityValue CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); + public QuantityValue CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); + public QuantityValue CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); + public QuantityValue CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); + public QuantityValue CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); + public QuantityValue CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); + public QuantityValue CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); + public QuantityValue CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); + public QuantityValue CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); + public QuantityValue CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); + public QuantityValue CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); + public QuantityValue DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecilitersPerHour => As(VolumeFlowUnit.DeciliterPerHour); + public QuantityValue DecilitersPerHour => As(VolumeFlowUnit.DeciliterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); + public QuantityValue DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); + public QuantityValue DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); + public QuantityValue KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilolitersPerHour => As(VolumeFlowUnit.KiloliterPerHour); + public QuantityValue KilolitersPerHour => As(VolumeFlowUnit.KiloliterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); + public QuantityValue KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); + public QuantityValue KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); + public QuantityValue KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerDay => As(VolumeFlowUnit.LiterPerDay); + public QuantityValue LitersPerDay => As(VolumeFlowUnit.LiterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerHour => As(VolumeFlowUnit.LiterPerHour); + public QuantityValue LitersPerHour => As(VolumeFlowUnit.LiterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); + public QuantityValue LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); + public QuantityValue LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); + public QuantityValue MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); + public QuantityValue MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); + public QuantityValue MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrolitersPerHour => As(VolumeFlowUnit.MicroliterPerHour); + public QuantityValue MicrolitersPerHour => As(VolumeFlowUnit.MicroliterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); + public QuantityValue MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); + public QuantityValue MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); + public QuantityValue MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillilitersPerHour => As(VolumeFlowUnit.MilliliterPerHour); + public QuantityValue MillilitersPerHour => As(VolumeFlowUnit.MilliliterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); + public QuantityValue MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); + public QuantityValue MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); + public QuantityValue MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); + public QuantityValue NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanolitersPerHour => As(VolumeFlowUnit.NanoliterPerHour); + public QuantityValue NanolitersPerHour => As(VolumeFlowUnit.NanoliterPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); + public QuantityValue NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); + public QuantityValue NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); + public QuantityValue OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); + public QuantityValue OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); + public QuantityValue OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); + public QuantityValue OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); + public QuantityValue UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); + public QuantityValue UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); + public QuantityValue UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); + public QuantityValue UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); + public QuantityValue UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); + public QuantityValue UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); + public QuantityValue UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); + public QuantityValue UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); #endregion @@ -791,7 +794,7 @@ public static string GetAbbreviation(VolumeFlowUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerDay(QuantityValue acrefeetperday) { - double value = (double) acrefeetperday; + QuantityValue value = (QuantityValue) acrefeetperday; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerDay); } @@ -801,7 +804,7 @@ public static VolumeFlow FromAcreFeetPerDay(QuantityValue acrefeetperday) /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerHour(QuantityValue acrefeetperhour) { - double value = (double) acrefeetperhour; + QuantityValue value = (QuantityValue) acrefeetperhour; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerHour); } @@ -811,7 +814,7 @@ public static VolumeFlow FromAcreFeetPerHour(QuantityValue acrefeetperhour) /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerMinute(QuantityValue acrefeetperminute) { - double value = (double) acrefeetperminute; + QuantityValue value = (QuantityValue) acrefeetperminute; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerMinute); } @@ -821,7 +824,7 @@ public static VolumeFlow FromAcreFeetPerMinute(QuantityValue acrefeetperminute) /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerSecond(QuantityValue acrefeetpersecond) { - double value = (double) acrefeetpersecond; + QuantityValue value = (QuantityValue) acrefeetpersecond; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerSecond); } @@ -831,7 +834,7 @@ public static VolumeFlow FromAcreFeetPerSecond(QuantityValue acrefeetpersecond) /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerDay(QuantityValue centilitersperday) { - double value = (double) centilitersperday; + QuantityValue value = (QuantityValue) centilitersperday; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerDay); } @@ -841,7 +844,7 @@ public static VolumeFlow FromCentilitersPerDay(QuantityValue centilitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerHour(QuantityValue centilitersperhour) { - double value = (double) centilitersperhour; + QuantityValue value = (QuantityValue) centilitersperhour; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerHour); } @@ -851,7 +854,7 @@ public static VolumeFlow FromCentilitersPerHour(QuantityValue centilitersperhour /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerMinute(QuantityValue centilitersperminute) { - double value = (double) centilitersperminute; + QuantityValue value = (QuantityValue) centilitersperminute; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerMinute); } @@ -861,7 +864,7 @@ public static VolumeFlow FromCentilitersPerMinute(QuantityValue centiliterspermi /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerSecond(QuantityValue centiliterspersecond) { - double value = (double) centiliterspersecond; + QuantityValue value = (QuantityValue) centiliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerSecond); } @@ -871,7 +874,7 @@ public static VolumeFlow FromCentilitersPerSecond(QuantityValue centilitersperse /// If value is NaN or Infinity. public static VolumeFlow FromCubicCentimetersPerMinute(QuantityValue cubiccentimetersperminute) { - double value = (double) cubiccentimetersperminute; + QuantityValue value = (QuantityValue) cubiccentimetersperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicCentimeterPerMinute); } @@ -881,7 +884,7 @@ public static VolumeFlow FromCubicCentimetersPerMinute(QuantityValue cubiccentim /// If value is NaN or Infinity. public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue cubicdecimetersperminute) { - double value = (double) cubicdecimetersperminute; + QuantityValue value = (QuantityValue) cubicdecimetersperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicDecimeterPerMinute); } @@ -891,7 +894,7 @@ public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue cubicdecimet /// If value is NaN or Infinity. public static VolumeFlow FromCubicFeetPerHour(QuantityValue cubicfeetperhour) { - double value = (double) cubicfeetperhour; + QuantityValue value = (QuantityValue) cubicfeetperhour; return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerHour); } @@ -901,7 +904,7 @@ public static VolumeFlow FromCubicFeetPerHour(QuantityValue cubicfeetperhour) /// If value is NaN or Infinity. public static VolumeFlow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute) { - double value = (double) cubicfeetperminute; + QuantityValue value = (QuantityValue) cubicfeetperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerMinute); } @@ -911,7 +914,7 @@ public static VolumeFlow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute /// If value is NaN or Infinity. public static VolumeFlow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond) { - double value = (double) cubicfeetpersecond; + QuantityValue value = (QuantityValue) cubicfeetpersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerSecond); } @@ -921,7 +924,7 @@ public static VolumeFlow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerDay(QuantityValue cubicmetersperday) { - double value = (double) cubicmetersperday; + QuantityValue value = (QuantityValue) cubicmetersperday; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerDay); } @@ -931,7 +934,7 @@ public static VolumeFlow FromCubicMetersPerDay(QuantityValue cubicmetersperday) /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerHour(QuantityValue cubicmetersperhour) { - double value = (double) cubicmetersperhour; + QuantityValue value = (QuantityValue) cubicmetersperhour; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerHour); } @@ -941,7 +944,7 @@ public static VolumeFlow FromCubicMetersPerHour(QuantityValue cubicmetersperhour /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerMinute(QuantityValue cubicmetersperminute) { - double value = (double) cubicmetersperminute; + QuantityValue value = (QuantityValue) cubicmetersperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerMinute); } @@ -951,7 +954,7 @@ public static VolumeFlow FromCubicMetersPerMinute(QuantityValue cubicmeterspermi /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmeterspersecond) { - double value = (double) cubicmeterspersecond; + QuantityValue value = (QuantityValue) cubicmeterspersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond); } @@ -961,7 +964,7 @@ public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmetersperse /// If value is NaN or Infinity. public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillimeterspersecond) { - double value = (double) cubicmillimeterspersecond; + QuantityValue value = (QuantityValue) cubicmillimeterspersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond); } @@ -971,7 +974,7 @@ public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillim /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerDay(QuantityValue cubicyardsperday) { - double value = (double) cubicyardsperday; + QuantityValue value = (QuantityValue) cubicyardsperday; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerDay); } @@ -981,7 +984,7 @@ public static VolumeFlow FromCubicYardsPerDay(QuantityValue cubicyardsperday) /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerHour(QuantityValue cubicyardsperhour) { - double value = (double) cubicyardsperhour; + QuantityValue value = (QuantityValue) cubicyardsperhour; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerHour); } @@ -991,7 +994,7 @@ public static VolumeFlow FromCubicYardsPerHour(QuantityValue cubicyardsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerMinute(QuantityValue cubicyardsperminute) { - double value = (double) cubicyardsperminute; + QuantityValue value = (QuantityValue) cubicyardsperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerMinute); } @@ -1001,7 +1004,7 @@ public static VolumeFlow FromCubicYardsPerMinute(QuantityValue cubicyardsperminu /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerSecond(QuantityValue cubicyardspersecond) { - double value = (double) cubicyardspersecond; + QuantityValue value = (QuantityValue) cubicyardspersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerSecond); } @@ -1011,7 +1014,7 @@ public static VolumeFlow FromCubicYardsPerSecond(QuantityValue cubicyardsperseco /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerDay(QuantityValue decilitersperday) { - double value = (double) decilitersperday; + QuantityValue value = (QuantityValue) decilitersperday; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerDay); } @@ -1021,7 +1024,7 @@ public static VolumeFlow FromDecilitersPerDay(QuantityValue decilitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerHour(QuantityValue decilitersperhour) { - double value = (double) decilitersperhour; + QuantityValue value = (QuantityValue) decilitersperhour; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerHour); } @@ -1031,7 +1034,7 @@ public static VolumeFlow FromDecilitersPerHour(QuantityValue decilitersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerMinute(QuantityValue decilitersperminute) { - double value = (double) decilitersperminute; + QuantityValue value = (QuantityValue) decilitersperminute; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerMinute); } @@ -1041,7 +1044,7 @@ public static VolumeFlow FromDecilitersPerMinute(QuantityValue decilitersperminu /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerSecond(QuantityValue deciliterspersecond) { - double value = (double) deciliterspersecond; + QuantityValue value = (QuantityValue) deciliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerSecond); } @@ -1051,7 +1054,7 @@ public static VolumeFlow FromDecilitersPerSecond(QuantityValue decilitersperseco /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerDay(QuantityValue kilolitersperday) { - double value = (double) kilolitersperday; + QuantityValue value = (QuantityValue) kilolitersperday; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerDay); } @@ -1061,7 +1064,7 @@ public static VolumeFlow FromKilolitersPerDay(QuantityValue kilolitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerHour(QuantityValue kilolitersperhour) { - double value = (double) kilolitersperhour; + QuantityValue value = (QuantityValue) kilolitersperhour; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerHour); } @@ -1071,7 +1074,7 @@ public static VolumeFlow FromKilolitersPerHour(QuantityValue kilolitersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerMinute(QuantityValue kilolitersperminute) { - double value = (double) kilolitersperminute; + QuantityValue value = (QuantityValue) kilolitersperminute; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerMinute); } @@ -1081,7 +1084,7 @@ public static VolumeFlow FromKilolitersPerMinute(QuantityValue kilolitersperminu /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerSecond(QuantityValue kiloliterspersecond) { - double value = (double) kiloliterspersecond; + QuantityValue value = (QuantityValue) kiloliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerSecond); } @@ -1091,7 +1094,7 @@ public static VolumeFlow FromKilolitersPerSecond(QuantityValue kilolitersperseco /// If value is NaN or Infinity. public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue kilousgallonsperminute) { - double value = (double) kilousgallonsperminute; + QuantityValue value = (QuantityValue) kilousgallonsperminute; return new VolumeFlow(value, VolumeFlowUnit.KilousGallonPerMinute); } @@ -1101,7 +1104,7 @@ public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue kilousgallonsp /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerDay(QuantityValue litersperday) { - double value = (double) litersperday; + QuantityValue value = (QuantityValue) litersperday; return new VolumeFlow(value, VolumeFlowUnit.LiterPerDay); } @@ -1111,7 +1114,7 @@ public static VolumeFlow FromLitersPerDay(QuantityValue litersperday) /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerHour(QuantityValue litersperhour) { - double value = (double) litersperhour; + QuantityValue value = (QuantityValue) litersperhour; return new VolumeFlow(value, VolumeFlowUnit.LiterPerHour); } @@ -1121,7 +1124,7 @@ public static VolumeFlow FromLitersPerHour(QuantityValue litersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerMinute(QuantityValue litersperminute) { - double value = (double) litersperminute; + QuantityValue value = (QuantityValue) litersperminute; return new VolumeFlow(value, VolumeFlowUnit.LiterPerMinute); } @@ -1131,7 +1134,7 @@ public static VolumeFlow FromLitersPerMinute(QuantityValue litersperminute) /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerSecond(QuantityValue literspersecond) { - double value = (double) literspersecond; + QuantityValue value = (QuantityValue) literspersecond; return new VolumeFlow(value, VolumeFlowUnit.LiterPerSecond); } @@ -1141,7 +1144,7 @@ public static VolumeFlow FromLitersPerSecond(QuantityValue literspersecond) /// If value is NaN or Infinity. public static VolumeFlow FromMegalitersPerDay(QuantityValue megalitersperday) { - double value = (double) megalitersperday; + QuantityValue value = (QuantityValue) megalitersperday; return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerDay); } @@ -1151,7 +1154,7 @@ public static VolumeFlow FromMegalitersPerDay(QuantityValue megalitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromMegaukGallonsPerSecond(QuantityValue megaukgallonspersecond) { - double value = (double) megaukgallonspersecond; + QuantityValue value = (QuantityValue) megaukgallonspersecond; return new VolumeFlow(value, VolumeFlowUnit.MegaukGallonPerSecond); } @@ -1161,7 +1164,7 @@ public static VolumeFlow FromMegaukGallonsPerSecond(QuantityValue megaukgallonsp /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerDay(QuantityValue microlitersperday) { - double value = (double) microlitersperday; + QuantityValue value = (QuantityValue) microlitersperday; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerDay); } @@ -1171,7 +1174,7 @@ public static VolumeFlow FromMicrolitersPerDay(QuantityValue microlitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerHour(QuantityValue microlitersperhour) { - double value = (double) microlitersperhour; + QuantityValue value = (QuantityValue) microlitersperhour; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerHour); } @@ -1181,7 +1184,7 @@ public static VolumeFlow FromMicrolitersPerHour(QuantityValue microlitersperhour /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerMinute(QuantityValue microlitersperminute) { - double value = (double) microlitersperminute; + QuantityValue value = (QuantityValue) microlitersperminute; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerMinute); } @@ -1191,7 +1194,7 @@ public static VolumeFlow FromMicrolitersPerMinute(QuantityValue microliterspermi /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerSecond(QuantityValue microliterspersecond) { - double value = (double) microliterspersecond; + QuantityValue value = (QuantityValue) microliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerSecond); } @@ -1201,7 +1204,7 @@ public static VolumeFlow FromMicrolitersPerSecond(QuantityValue microlitersperse /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerDay(QuantityValue millilitersperday) { - double value = (double) millilitersperday; + QuantityValue value = (QuantityValue) millilitersperday; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerDay); } @@ -1211,7 +1214,7 @@ public static VolumeFlow FromMillilitersPerDay(QuantityValue millilitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerHour(QuantityValue millilitersperhour) { - double value = (double) millilitersperhour; + QuantityValue value = (QuantityValue) millilitersperhour; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerHour); } @@ -1221,7 +1224,7 @@ public static VolumeFlow FromMillilitersPerHour(QuantityValue millilitersperhour /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerMinute(QuantityValue millilitersperminute) { - double value = (double) millilitersperminute; + QuantityValue value = (QuantityValue) millilitersperminute; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerMinute); } @@ -1231,7 +1234,7 @@ public static VolumeFlow FromMillilitersPerMinute(QuantityValue milliliterspermi /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerSecond(QuantityValue milliliterspersecond) { - double value = (double) milliliterspersecond; + QuantityValue value = (QuantityValue) milliliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerSecond); } @@ -1241,7 +1244,7 @@ public static VolumeFlow FromMillilitersPerSecond(QuantityValue millilitersperse /// If value is NaN or Infinity. public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday) { - double value = (double) millionusgallonsperday; + QuantityValue value = (QuantityValue) millionusgallonsperday; return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonPerDay); } @@ -1251,7 +1254,7 @@ public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallo /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerDay(QuantityValue nanolitersperday) { - double value = (double) nanolitersperday; + QuantityValue value = (QuantityValue) nanolitersperday; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerDay); } @@ -1261,7 +1264,7 @@ public static VolumeFlow FromNanolitersPerDay(QuantityValue nanolitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerHour(QuantityValue nanolitersperhour) { - double value = (double) nanolitersperhour; + QuantityValue value = (QuantityValue) nanolitersperhour; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerHour); } @@ -1271,7 +1274,7 @@ public static VolumeFlow FromNanolitersPerHour(QuantityValue nanolitersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerMinute(QuantityValue nanolitersperminute) { - double value = (double) nanolitersperminute; + QuantityValue value = (QuantityValue) nanolitersperminute; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerMinute); } @@ -1281,7 +1284,7 @@ public static VolumeFlow FromNanolitersPerMinute(QuantityValue nanolitersperminu /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerSecond(QuantityValue nanoliterspersecond) { - double value = (double) nanoliterspersecond; + QuantityValue value = (QuantityValue) nanoliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerSecond); } @@ -1291,7 +1294,7 @@ public static VolumeFlow FromNanolitersPerSecond(QuantityValue nanolitersperseco /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday) { - double value = (double) oilbarrelsperday; + QuantityValue value = (QuantityValue) oilbarrelsperday; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerDay); } @@ -1301,7 +1304,7 @@ public static VolumeFlow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday) /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerHour(QuantityValue oilbarrelsperhour) { - double value = (double) oilbarrelsperhour; + QuantityValue value = (QuantityValue) oilbarrelsperhour; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerHour); } @@ -1311,7 +1314,7 @@ public static VolumeFlow FromOilBarrelsPerHour(QuantityValue oilbarrelsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue oilbarrelsperminute) { - double value = (double) oilbarrelsperminute; + QuantityValue value = (QuantityValue) oilbarrelsperminute; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerMinute); } @@ -1321,7 +1324,7 @@ public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue oilbarrelsperminu /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerSecond(QuantityValue oilbarrelspersecond) { - double value = (double) oilbarrelspersecond; + QuantityValue value = (QuantityValue) oilbarrelspersecond; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerSecond); } @@ -1331,7 +1334,7 @@ public static VolumeFlow FromOilBarrelsPerSecond(QuantityValue oilbarrelsperseco /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerDay(QuantityValue ukgallonsperday) { - double value = (double) ukgallonsperday; + QuantityValue value = (QuantityValue) ukgallonsperday; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerDay); } @@ -1341,7 +1344,7 @@ public static VolumeFlow FromUkGallonsPerDay(QuantityValue ukgallonsperday) /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerHour(QuantityValue ukgallonsperhour) { - double value = (double) ukgallonsperhour; + QuantityValue value = (QuantityValue) ukgallonsperhour; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerHour); } @@ -1351,7 +1354,7 @@ public static VolumeFlow FromUkGallonsPerHour(QuantityValue ukgallonsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerMinute(QuantityValue ukgallonsperminute) { - double value = (double) ukgallonsperminute; + QuantityValue value = (QuantityValue) ukgallonsperminute; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerMinute); } @@ -1361,7 +1364,7 @@ public static VolumeFlow FromUkGallonsPerMinute(QuantityValue ukgallonsperminute /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerSecond(QuantityValue ukgallonspersecond) { - double value = (double) ukgallonspersecond; + QuantityValue value = (QuantityValue) ukgallonspersecond; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerSecond); } @@ -1371,7 +1374,7 @@ public static VolumeFlow FromUkGallonsPerSecond(QuantityValue ukgallonspersecond /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerDay(QuantityValue usgallonsperday) { - double value = (double) usgallonsperday; + QuantityValue value = (QuantityValue) usgallonsperday; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerDay); } @@ -1381,7 +1384,7 @@ public static VolumeFlow FromUsGallonsPerDay(QuantityValue usgallonsperday) /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerHour(QuantityValue usgallonsperhour) { - double value = (double) usgallonsperhour; + QuantityValue value = (QuantityValue) usgallonsperhour; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerHour); } @@ -1391,7 +1394,7 @@ public static VolumeFlow FromUsGallonsPerHour(QuantityValue usgallonsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerMinute(QuantityValue usgallonsperminute) { - double value = (double) usgallonsperminute; + QuantityValue value = (QuantityValue) usgallonsperminute; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerMinute); } @@ -1401,7 +1404,7 @@ public static VolumeFlow FromUsGallonsPerMinute(QuantityValue usgallonsperminute /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerSecond(QuantityValue usgallonspersecond) { - double value = (double) usgallonspersecond; + QuantityValue value = (QuantityValue) usgallonspersecond; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerSecond); } @@ -1413,7 +1416,7 @@ public static VolumeFlow FromUsGallonsPerSecond(QuantityValue usgallonspersecond /// VolumeFlow unit value. public static VolumeFlow From(QuantityValue value, VolumeFlowUnit fromUnit) { - return new VolumeFlow((double)value, fromUnit); + return new VolumeFlow((QuantityValue)value, fromUnit); } #endregion @@ -1583,25 +1586,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeFlow operator *(double left, VolumeFlow right) + public static VolumeFlow operator *(QuantityValue left, VolumeFlow right) { return new VolumeFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeFlow operator *(VolumeFlow left, double right) + public static VolumeFlow operator *(VolumeFlow left, QuantityValue right) { return new VolumeFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeFlow operator /(VolumeFlow left, double right) + public static VolumeFlow operator /(VolumeFlow left, QuantityValue right) { return new VolumeFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumeFlow left, VolumeFlow right) + public static QuantityValue operator /(VolumeFlow left, VolumeFlow right) { return left.CubicMetersPerSecond / right.CubicMetersPerSecond; } @@ -1634,6 +1637,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumeFlow left, VolumeFlow right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumeFlow left, VolumeFlow right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -1646,7 +1662,29 @@ public int CompareTo(object obj) /// public int CompareTo(VolumeFlow other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is VolumeFlow objVolumeFlow)) + return false; + return Equals(objVolumeFlow); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(VolumeFlow other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -1689,13 +1727,13 @@ public int CompareTo(VolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumeFlow other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1706,7 +1744,7 @@ public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparison /// A hash code for the current VolumeFlow. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -1717,17 +1755,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowUnit unit) + public QuantityValue As(VolumeFlowUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1742,12 +1779,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) + if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowUnit); + return (QuantityValue)As(typedUnit); } /// @@ -1779,7 +1816,7 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (VolumeFlow)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VolumeFlowUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1787,17 +1824,17 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit, UnitConverter unitConverter) } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) + if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -1824,10 +1861,10 @@ public VolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VolumeFlowUnit unit) + private QuantityValue GetValueAs(VolumeFlowUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 93e98d1704..4f27c89490 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct VolumeFlowPerArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlowPerArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static VolumeFlowPerArea() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeFlowPerArea(double value, VolumeFlowPerAreaUnit unit) + public VolumeFlowPerArea(QuantityValue value, VolumeFlowPerAreaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -87,14 +87,14 @@ public VolumeFlowPerArea(double value, VolumeFlowPerAreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlowPerArea(double value, UnitSystem unitSystem) + public VolumeFlowPerArea(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,7 +135,10 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -158,14 +161,14 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicFeetPerMinutePerSquareFoot => As(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); + public QuantityValue CubicFeetPerMinutePerSquareFoot => As(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerSecondPerSquareMeter => As(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); + public QuantityValue CubicMetersPerSecondPerSquareMeter => As(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); #endregion @@ -224,7 +227,7 @@ public static string GetAbbreviation(VolumeFlowPerAreaUnit unit, IFormatProvider /// If value is NaN or Infinity. public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(QuantityValue cubicfeetperminutepersquarefoot) { - double value = (double) cubicfeetperminutepersquarefoot; + QuantityValue value = (QuantityValue) cubicfeetperminutepersquarefoot; return new VolumeFlowPerArea(value, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); } @@ -234,7 +237,7 @@ public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(QuantityValu /// If value is NaN or Infinity. public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(QuantityValue cubicmeterspersecondpersquaremeter) { - double value = (double) cubicmeterspersecondpersquaremeter; + QuantityValue value = (QuantityValue) cubicmeterspersecondpersquaremeter; return new VolumeFlowPerArea(value, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); } @@ -246,7 +249,7 @@ public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(QuantityV /// VolumeFlowPerArea unit value. public static VolumeFlowPerArea From(QuantityValue value, VolumeFlowPerAreaUnit fromUnit) { - return new VolumeFlowPerArea((double)value, fromUnit); + return new VolumeFlowPerArea((QuantityValue)value, fromUnit); } #endregion @@ -416,25 +419,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeFlowPerArea operator *(double left, VolumeFlowPerArea right) + public static VolumeFlowPerArea operator *(QuantityValue left, VolumeFlowPerArea right) { return new VolumeFlowPerArea(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeFlowPerArea operator *(VolumeFlowPerArea left, double right) + public static VolumeFlowPerArea operator *(VolumeFlowPerArea left, QuantityValue right) { return new VolumeFlowPerArea(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeFlowPerArea operator /(VolumeFlowPerArea left, double right) + public static VolumeFlowPerArea operator /(VolumeFlowPerArea left, QuantityValue right) { return new VolumeFlowPerArea(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumeFlowPerArea left, VolumeFlowPerArea right) + public static QuantityValue operator /(VolumeFlowPerArea left, VolumeFlowPerArea right) { return left.CubicMetersPerSecondPerSquareMeter / right.CubicMetersPerSecondPerSquareMeter; } @@ -467,6 +470,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumeFlowPerArea left, VolumeFlowPerArea right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumeFlowPerArea left, VolumeFlowPerArea right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -479,7 +495,29 @@ public int CompareTo(object obj) /// public int CompareTo(VolumeFlowPerArea other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is VolumeFlowPerArea objVolumeFlowPerArea)) + return false; + return Equals(objVolumeFlowPerArea); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(VolumeFlowPerArea other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -522,13 +560,13 @@ public int CompareTo(VolumeFlowPerArea other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumeFlowPerArea other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -539,7 +577,7 @@ public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType com /// A hash code for the current VolumeFlowPerArea. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -550,17 +588,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumeFlowPerAreaUnit unit) + public QuantityValue As(VolumeFlowPerAreaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -575,12 +612,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) + if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowPerAreaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -612,7 +649,7 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (VolumeFlowPerArea)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VolumeFlowPerAreaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -620,17 +657,17 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit, UnitConverter unitCo } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) + if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeFlowPerAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -657,10 +694,10 @@ public VolumeFlowPerArea ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VolumeFlowPerAreaUnit unit) + private QuantityValue GetValueAs(VolumeFlowPerAreaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index d07460ee38..3b401ddbe6 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Volume, typically of fluid, that a container can hold within a unit of length. /// [DataContract] - public partial struct VolumePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static VolumePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumePerLength(double value, VolumePerLengthUnit unit) + public VolumePerLength(QuantityValue value, VolumePerLengthUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -92,14 +92,14 @@ public VolumePerLength(double value, VolumePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumePerLength(double value, UnitSystem unitSystem) + public VolumePerLength(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,7 +140,10 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -163,39 +166,39 @@ public VolumePerLength(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); + public QuantityValue CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); + public QuantityValue CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); + public QuantityValue CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); + public QuantityValue LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); + public QuantityValue LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); + public QuantityValue LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); + public QuantityValue OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); #endregion @@ -269,7 +272,7 @@ public static string GetAbbreviation(VolumePerLengthUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static VolumePerLength FromCubicMetersPerMeter(QuantityValue cubicmeterspermeter) { - double value = (double) cubicmeterspermeter; + QuantityValue value = (QuantityValue) cubicmeterspermeter; return new VolumePerLength(value, VolumePerLengthUnit.CubicMeterPerMeter); } @@ -279,7 +282,7 @@ public static VolumePerLength FromCubicMetersPerMeter(QuantityValue cubicmetersp /// If value is NaN or Infinity. public static VolumePerLength FromCubicYardsPerFoot(QuantityValue cubicyardsperfoot) { - double value = (double) cubicyardsperfoot; + QuantityValue value = (QuantityValue) cubicyardsperfoot; return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerFoot); } @@ -289,7 +292,7 @@ public static VolumePerLength FromCubicYardsPerFoot(QuantityValue cubicyardsperf /// If value is NaN or Infinity. public static VolumePerLength FromCubicYardsPerUsSurveyFoot(QuantityValue cubicyardsperussurveyfoot) { - double value = (double) cubicyardsperussurveyfoot; + QuantityValue value = (QuantityValue) cubicyardsperussurveyfoot; return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); } @@ -299,7 +302,7 @@ public static VolumePerLength FromCubicYardsPerUsSurveyFoot(QuantityValue cubicy /// If value is NaN or Infinity. public static VolumePerLength FromLitersPerKilometer(QuantityValue litersperkilometer) { - double value = (double) litersperkilometer; + QuantityValue value = (QuantityValue) litersperkilometer; return new VolumePerLength(value, VolumePerLengthUnit.LiterPerKilometer); } @@ -309,7 +312,7 @@ public static VolumePerLength FromLitersPerKilometer(QuantityValue litersperkilo /// If value is NaN or Infinity. public static VolumePerLength FromLitersPerMeter(QuantityValue literspermeter) { - double value = (double) literspermeter; + QuantityValue value = (QuantityValue) literspermeter; return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMeter); } @@ -319,7 +322,7 @@ public static VolumePerLength FromLitersPerMeter(QuantityValue literspermeter) /// If value is NaN or Infinity. public static VolumePerLength FromLitersPerMillimeter(QuantityValue literspermillimeter) { - double value = (double) literspermillimeter; + QuantityValue value = (QuantityValue) literspermillimeter; return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMillimeter); } @@ -329,7 +332,7 @@ public static VolumePerLength FromLitersPerMillimeter(QuantityValue literspermil /// If value is NaN or Infinity. public static VolumePerLength FromOilBarrelsPerFoot(QuantityValue oilbarrelsperfoot) { - double value = (double) oilbarrelsperfoot; + QuantityValue value = (QuantityValue) oilbarrelsperfoot; return new VolumePerLength(value, VolumePerLengthUnit.OilBarrelPerFoot); } @@ -341,7 +344,7 @@ public static VolumePerLength FromOilBarrelsPerFoot(QuantityValue oilbarrelsperf /// VolumePerLength unit value. public static VolumePerLength From(QuantityValue value, VolumePerLengthUnit fromUnit) { - return new VolumePerLength((double)value, fromUnit); + return new VolumePerLength((QuantityValue)value, fromUnit); } #endregion @@ -511,25 +514,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumePerLength operator *(double left, VolumePerLength right) + public static VolumePerLength operator *(QuantityValue left, VolumePerLength right) { return new VolumePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumePerLength operator *(VolumePerLength left, double right) + public static VolumePerLength operator *(VolumePerLength left, QuantityValue right) { return new VolumePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumePerLength operator /(VolumePerLength left, double right) + public static VolumePerLength operator /(VolumePerLength left, QuantityValue right) { return new VolumePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumePerLength left, VolumePerLength right) + public static QuantityValue operator /(VolumePerLength left, VolumePerLength right) { return left.CubicMetersPerMeter / right.CubicMetersPerMeter; } @@ -562,6 +565,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumePerLength left, VolumePerLength right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumePerLength left, VolumePerLength right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -574,7 +590,29 @@ public int CompareTo(object obj) /// public int CompareTo(VolumePerLength other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is VolumePerLength objVolumePerLength)) + return false; + return Equals(objVolumePerLength); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(VolumePerLength other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -617,13 +655,13 @@ public int CompareTo(VolumePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumePerLength other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumePerLength other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -634,7 +672,7 @@ public bool Equals(VolumePerLength other, double tolerance, ComparisonType compa /// A hash code for the current VolumePerLength. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -645,17 +683,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumePerLengthUnit unit) + public QuantityValue As(VolumePerLengthUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -670,12 +707,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) + if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsVolumePerLengthUnit); + return (QuantityValue)As(typedUnit); } /// @@ -707,7 +744,7 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (VolumePerLength)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VolumePerLengthUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -715,17 +752,17 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit, UnitConverter unitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) + if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -752,10 +789,10 @@ public VolumePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VolumePerLengthUnit unit) + private QuantityValue GetValueAs(VolumePerLengthUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 3ca758cbc0..efcc549362 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Volumetric_heat_capacity /// [DataContract] - public partial struct VolumetricHeatCapacity : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumetricHeatCapacity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static VolumetricHeatCapacity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) + public VolumetricHeatCapacity(QuantityValue value, VolumetricHeatCapacityUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -97,14 +97,14 @@ public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumetricHeatCapacity(double value, UnitSystem unitSystem) + public VolumetricHeatCapacity(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,7 +145,10 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -168,49 +171,49 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); + public QuantityValue BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); + public QuantityValue CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); + public QuantityValue JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); + public QuantityValue JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); + public QuantityValue KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); + public QuantityValue KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); + public QuantityValue KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); + public QuantityValue MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); + public QuantityValue MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); #endregion @@ -290,7 +293,7 @@ public static string GetAbbreviation(VolumetricHeatCapacityUnit unit, IFormatPro /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(QuantityValue btuspercubicfootdegreefahrenheit) { - double value = (double) btuspercubicfootdegreefahrenheit; + QuantityValue value = (QuantityValue) btuspercubicfootdegreefahrenheit; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); } @@ -300,7 +303,7 @@ public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(Quanti /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius(QuantityValue caloriespercubiccentimeterdegreecelsius) { - double value = (double) caloriespercubiccentimeterdegreecelsius; + QuantityValue value = (QuantityValue) caloriespercubiccentimeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); } @@ -310,7 +313,7 @@ public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(QuantityValue joulespercubicmeterdegreecelsius) { - double value = (double) joulespercubicmeterdegreecelsius; + QuantityValue value = (QuantityValue) joulespercubicmeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); } @@ -320,7 +323,7 @@ public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(Quanti /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(QuantityValue joulespercubicmeterkelvin) { - double value = (double) joulespercubicmeterkelvin; + QuantityValue value = (QuantityValue) joulespercubicmeterkelvin; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); } @@ -330,7 +333,7 @@ public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(QuantityValue /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCelsius(QuantityValue kilocaloriespercubiccentimeterdegreecelsius) { - double value = (double) kilocaloriespercubiccentimeterdegreecelsius; + QuantityValue value = (QuantityValue) kilocaloriespercubiccentimeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); } @@ -340,7 +343,7 @@ public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCel /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(QuantityValue kilojoulespercubicmeterdegreecelsius) { - double value = (double) kilojoulespercubicmeterdegreecelsius; + QuantityValue value = (QuantityValue) kilojoulespercubicmeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); } @@ -350,7 +353,7 @@ public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(Qu /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(QuantityValue kilojoulespercubicmeterkelvin) { - double value = (double) kilojoulespercubicmeterkelvin; + QuantityValue value = (QuantityValue) kilojoulespercubicmeterkelvin; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); } @@ -360,7 +363,7 @@ public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(QuantityV /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(QuantityValue megajoulespercubicmeterdegreecelsius) { - double value = (double) megajoulespercubicmeterdegreecelsius; + QuantityValue value = (QuantityValue) megajoulespercubicmeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); } @@ -370,7 +373,7 @@ public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(Qu /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(QuantityValue megajoulespercubicmeterkelvin) { - double value = (double) megajoulespercubicmeterkelvin; + QuantityValue value = (QuantityValue) megajoulespercubicmeterkelvin; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); } @@ -382,7 +385,7 @@ public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(QuantityV /// VolumetricHeatCapacity unit value. public static VolumetricHeatCapacity From(QuantityValue value, VolumetricHeatCapacityUnit fromUnit) { - return new VolumetricHeatCapacity((double)value, fromUnit); + return new VolumetricHeatCapacity((QuantityValue)value, fromUnit); } #endregion @@ -552,25 +555,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumetricHeatCapacity operator *(double left, VolumetricHeatCapacity right) + public static VolumetricHeatCapacity operator *(QuantityValue left, VolumetricHeatCapacity right) { return new VolumetricHeatCapacity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumetricHeatCapacity operator *(VolumetricHeatCapacity left, double right) + public static VolumetricHeatCapacity operator *(VolumetricHeatCapacity left, QuantityValue right) { return new VolumetricHeatCapacity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumetricHeatCapacity operator /(VolumetricHeatCapacity left, double right) + public static VolumetricHeatCapacity operator /(VolumetricHeatCapacity left, QuantityValue right) { return new VolumetricHeatCapacity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(VolumetricHeatCapacity left, VolumetricHeatCapacity right) + public static QuantityValue operator /(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return left.JoulesPerCubicMeterKelvin / right.JoulesPerCubicMeterKelvin; } @@ -603,6 +606,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(VolumetricHeatCapacity left, VolumetricHeatCapacity right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(VolumetricHeatCapacity left, VolumetricHeatCapacity right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -615,7 +631,29 @@ public int CompareTo(object obj) /// public int CompareTo(VolumetricHeatCapacity other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is VolumetricHeatCapacity objVolumetricHeatCapacity)) + return false; + return Equals(objVolumetricHeatCapacity); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(VolumetricHeatCapacity other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -658,13 +696,13 @@ public int CompareTo(VolumetricHeatCapacity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonType comparisonType) + public bool Equals(VolumetricHeatCapacity other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -675,7 +713,7 @@ public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonTyp /// A hash code for the current VolumetricHeatCapacity. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -686,17 +724,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(VolumetricHeatCapacityUnit unit) + public QuantityValue As(VolumetricHeatCapacityUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -711,12 +748,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) + if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return As(unitAsVolumetricHeatCapacityUnit); + return (QuantityValue)As(typedUnit); } /// @@ -748,7 +785,7 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit, UnitConver var converted = conversionFunction(this); return (VolumetricHeatCapacity)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(VolumetricHeatCapacityUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -756,17 +793,17 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit, UnitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) + if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumetricHeatCapacityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -793,10 +830,10 @@ public VolumetricHeatCapacity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(VolumetricHeatCapacityUnit unit) + private QuantityValue GetValueAs(VolumetricHeatCapacityUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 2ef276467a..5bc210e52b 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A geometric property of an area that is used to determine the warping stress. /// [DataContract] - public partial struct WarpingMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable + public partial struct WarpingMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly double _value; + private readonly QuantityValue _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static WarpingMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) + public WarpingMomentOfInertia(QuantityValue value, WarpingMomentOfInertiaUnit unit) { - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = unit; } @@ -91,14 +91,14 @@ public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public WarpingMomentOfInertia(double value, UnitSystem unitSystem) + public WarpingMomentOfInertia(QuantityValue value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = Guard.EnsureValidNumber(value, nameof(value)); + _value = value; _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,7 +139,10 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public double Value => _value; + public QuantityValue Value => _value; + + /// + QuantityValue IQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -162,34 +165,34 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); + public QuantityValue CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); + public QuantityValue DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); + public QuantityValue FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); + public QuantityValue InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); + public QuantityValue MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); /// - /// Gets a value of this quantity converted into + /// Gets the numeric value of this quantity converted into /// - public double MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); + public QuantityValue MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); #endregion @@ -260,7 +263,7 @@ public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, IFormatPro /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromCentimetersToTheSixth(QuantityValue centimeterstothesixth) { - double value = (double) centimeterstothesixth; + QuantityValue value = (QuantityValue) centimeterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); } @@ -270,7 +273,7 @@ public static WarpingMomentOfInertia FromCentimetersToTheSixth(QuantityValue cen /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromDecimetersToTheSixth(QuantityValue decimeterstothesixth) { - double value = (double) decimeterstothesixth; + QuantityValue value = (QuantityValue) decimeterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); } @@ -280,7 +283,7 @@ public static WarpingMomentOfInertia FromDecimetersToTheSixth(QuantityValue deci /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromFeetToTheSixth(QuantityValue feettothesixth) { - double value = (double) feettothesixth; + QuantityValue value = (QuantityValue) feettothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.FootToTheSixth); } @@ -290,7 +293,7 @@ public static WarpingMomentOfInertia FromFeetToTheSixth(QuantityValue feettothes /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromInchesToTheSixth(QuantityValue inchestothesixth) { - double value = (double) inchestothesixth; + QuantityValue value = (QuantityValue) inchestothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.InchToTheSixth); } @@ -300,7 +303,7 @@ public static WarpingMomentOfInertia FromInchesToTheSixth(QuantityValue inchesto /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromMetersToTheSixth(QuantityValue meterstothesixth) { - double value = (double) meterstothesixth; + QuantityValue value = (QuantityValue) meterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MeterToTheSixth); } @@ -310,7 +313,7 @@ public static WarpingMomentOfInertia FromMetersToTheSixth(QuantityValue metersto /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromMillimetersToTheSixth(QuantityValue millimeterstothesixth) { - double value = (double) millimeterstothesixth; + QuantityValue value = (QuantityValue) millimeterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); } @@ -322,7 +325,7 @@ public static WarpingMomentOfInertia FromMillimetersToTheSixth(QuantityValue mil /// WarpingMomentOfInertia unit value. public static WarpingMomentOfInertia From(QuantityValue value, WarpingMomentOfInertiaUnit fromUnit) { - return new WarpingMomentOfInertia((double)value, fromUnit); + return new WarpingMomentOfInertia((QuantityValue)value, fromUnit); } #endregion @@ -492,25 +495,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi } /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(double left, WarpingMomentOfInertia right) + public static WarpingMomentOfInertia operator *(QuantityValue left, WarpingMomentOfInertia right) { return new WarpingMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, double right) + public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, QuantityValue right) { return new WarpingMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, double right) + public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, QuantityValue right) { return new WarpingMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static double operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static QuantityValue operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return left.MetersToTheSixth / right.MetersToTheSixth; } @@ -543,6 +546,19 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi return left.Value > right.GetValueAs(left.Unit); } + /// Returns true if exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + { + return left.Equals(right); + } + /// Returns true if not exactly equal. + /// Consider using for safely comparing floating point values. + public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + { + return !(left == right); + } + /// public int CompareTo(object obj) { @@ -555,7 +571,29 @@ public int CompareTo(object obj) /// public int CompareTo(WarpingMomentOfInertia other) { - return _value.CompareTo(other.GetValueAs(this.Unit)); + var asFirstUnit = other.GetValueAs(this.Unit); + var asSecondUnit = GetValueAs(other.Unit); + return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; + } + + /// + /// Consider using for safely comparing floating point values. + public override bool Equals(object obj) + { + if (obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) + return false; + return Equals(objWarpingMomentOfInertia); + } + + /// + /// Consider using for safely comparing floating point values. + public bool Equals(WarpingMomentOfInertia other) + { + if (Value.IsDecimal) + return other.Value.Equals(this.GetValueAs(other.Unit)); + if (other.Value.IsDecimal) + return Value.Equals(other.GetValueAs(this.Unit)); + return this.Unit == other.Unit && this.Value.Equals(other.Value); } /// @@ -598,13 +636,13 @@ public int CompareTo(WarpingMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonType comparisonType) + public bool Equals(WarpingMomentOfInertia other, QuantityValue tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + QuantityValue thisValue = this.Value; + QuantityValue otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +653,7 @@ public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonTyp /// A hash code for the current WarpingMomentOfInertia. public override int GetHashCode() { - return new { Info.Name, Value, Unit }.GetHashCode(); + return Info.Name.GetHashCode(); } #endregion @@ -626,17 +664,16 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(WarpingMomentOfInertiaUnit unit) + public QuantityValue As(WarpingMomentOfInertiaUnit unit) { - if (Unit == unit) - return Convert.ToDouble(Value); + if(Unit == unit) + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// - public double As(UnitSystem unitSystem) + public QuantityValue As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -651,12 +688,12 @@ public double As(UnitSystem unitSystem) } /// - double IQuantity.As(Enum unit) + QuantityValue IQuantity.As(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) + if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsWarpingMomentOfInertiaUnit); + return (QuantityValue)As(typedUnit); } /// @@ -688,7 +725,7 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit, UnitConver var converted = conversionFunction(this); return (WarpingMomentOfInertia)converted; } - else if (Unit != BaseUnit) + else if (Enum.IsDefined(typeof(WarpingMomentOfInertiaUnit), unit)) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -696,17 +733,17 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit, UnitConver } else { - throw new NotImplementedException($"Can not convert {Unit} to {unit}."); + throw new NotSupportedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) + if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsWarpingMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// @@ -733,10 +770,10 @@ public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private double GetValueAs(WarpingMomentOfInertiaUnit unit) + private QuantityValue GetValueAs(WarpingMomentOfInertiaUnit unit) { var converted = ToUnit(unit); - return (double)converted.Value; + return (QuantityValue)converted.Value; } #endregion diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 48445422fb..c65a61d0dd 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -28,7 +28,7 @@ public interface IQuantity : IFormattable /// The unit enum value. The unit must be compatible, so for you should provide a value. /// Value converted to the specified unit. /// Wrong unit enum type was given. - double As(Enum unit); + QuantityValue As(Enum unit); /// /// Gets the value in the unit determined by the given . If multiple units were found for the given , @@ -36,7 +36,7 @@ public interface IQuantity : IFormattable /// /// The to convert the quantity value to. /// The converted value. - double As(UnitSystem unitSystem); + QuantityValue As(UnitSystem unitSystem); /// /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. @@ -46,7 +46,7 @@ public interface IQuantity : IFormattable /// /// The value this quantity was constructed with. See also . /// - double Value { get; } + QuantityValue Value { get; } /// /// Converts this to an in the given . @@ -89,7 +89,7 @@ public interface IQuantity : IQuantity where TUnitType : Enum /// Convert to a unit representation . /// /// Value converted to the specified unit. - double As(TUnitType unit); + QuantityValue As(TUnitType unit); /// new TUnitType Unit { get; } diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index 8c7fdeb613..b1f52accff 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -180,8 +180,9 @@ private static string FormatUntrimmed(IQuantity quantity, private static string ToStringWithSignificantDigitsAfterRadix(IQuantity quantity, IFormatProvider formatProvider, int number) where TUnitType : Enum { - string formatForSignificantDigits = UnitFormatter.GetFormat(quantity.Value, number); - object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, quantity.Value, formatProvider, Enumerable.Empty()); + // When a fixed number of digits after the dot is expected, double and decimal behave the same + string formatForSignificantDigits = UnitFormatter.GetFormat((double)quantity.Value, number); + object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, (double)quantity.Value, formatProvider, Enumerable.Empty()); return string.Format(formatProvider, formatForSignificantDigits, formatArgs); } } diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index d25d184e98..0fe4d6169f 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -5,6 +5,8 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; +using System.Globalization; +using System.Runtime.Serialization; using UnitsNet.InternalHelpers; namespace UnitsNet @@ -27,15 +29,36 @@ namespace UnitsNet /// This allows for adding support for smaller data types without increasing the overall size. /// [StructLayout(LayoutKind.Explicit)] - [DebuggerDisplay("{GetDebugRepresentation()}")] - public readonly struct QuantityValue + // [DebuggerDisplay("{GetDebugRepresentation()}")] // TODO replace with a DebuggerTypeProxy? + [DataContract] + public readonly struct QuantityValue : IFormattable, IEquatable, IComparable, IComparable, IConvertible { + private const decimal MinPrecision = 1E-6m; // min number of decimals reserved: as to avoid values that just barely fit the decimal range + private const double DecimalMin = (double)(decimal.MinValue * MinPrecision); + private const double DecimalMax = (double)(decimal.MaxValue * MinPrecision); + + private static bool InDecimalRange(double value) + { + if (value == 0) + { + return true; + } + + return value is >= DecimalMin and <= DecimalMax && 1 / value is >= DecimalMin and <= DecimalMax; + } + + /// + /// The value 0 + /// + public static readonly QuantityValue Zero = default; + /// /// Value assigned when implicitly casting from all numeric types except , since /// has the greatest range. /// - [FieldOffset(8)] // so that it does not interfere with the Type field - private readonly double _doubleValue; + [FieldOffset(4)] // so that it does not interfere with the Nullable // TODO please review this + [DataMember(Name = "Double", Order = 0, EmitDefaultValue = false)] + private readonly double? _doubleValue; /// /// Value assigned when implicitly casting from type, since it has a greater precision than @@ -44,39 +67,59 @@ public readonly struct QuantityValue /// [FieldOffset(0)] // bytes layout: 0-1 unused, 2 exponent, 3 sign (only highest bit), 4-15 number - private readonly decimal _decimalValue; + [DataMember(Name = "Decimal", Order = 1, EmitDefaultValue = false)] + private readonly decimal? _decimalValue; + /// /// Determines the underlying type of this . /// - [FieldOffset(0)] // using unused byte for storing type - public readonly UnderlyingDataType Type; + public QuantityValueType Type => IsDecimal ? QuantityValueType.Decimal : QuantityValueType.Double; private QuantityValue(double val) : this() { _doubleValue = Guard.EnsureValidNumber(val, nameof(val)); - Type = UnderlyingDataType.Double; } private QuantityValue(decimal val) : this() { _decimalValue = val; - Type = UnderlyingDataType.Decimal; } - #region To QuantityValue + /// + /// Returns true if the underlying value is stored as a decimal + /// + /// True for default(QuantityValue) and QuantityValue.Zero + public bool IsDecimal => !_doubleValue.HasValue; + + /// + /// Value assigned when implicitly casting from all numeric types except , since + /// has the greatest range. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private double DoubleValue => _doubleValue.GetValueOrDefault(); + + /// + /// Value assigned when implicitly casting from type, since it has a greater precision than + /// and we want to preserve that when constructing quantities that use + /// as their value type. + /// + [DebuggerBrowsable(DebuggerBrowsableState.Never)] + private decimal DecimalValue => _decimalValue.GetValueOrDefault(); + + #region Implicit cast to QuantityValue // Prefer double for integer types, since most quantities use that type as of now and // that avoids unnecessary casts back and forth. // If we later change to use decimal more, we should revisit this. /// Implicit cast from to . - public static implicit operator QuantityValue(byte val) => new QuantityValue((double) val); + public static implicit operator QuantityValue(byte val) => new QuantityValue((decimal) val); /// Implicit cast from to . - public static implicit operator QuantityValue(short val) => new QuantityValue((double) val); + public static implicit operator QuantityValue(short val) => new QuantityValue((decimal) val); /// Implicit cast from to . - public static implicit operator QuantityValue(int val) => new QuantityValue((double) val); + public static implicit operator QuantityValue(int val) => new QuantityValue((decimal) val); /// Implicit cast from to . - public static implicit operator QuantityValue(long val) => new QuantityValue((double) val); + public static implicit operator QuantityValue(long val) => new QuantityValue((decimal) val); /// Implicit cast from to . public static implicit operator QuantityValue(float val) => new QuantityValue(val); // double /// Implicit cast from to . @@ -85,42 +128,309 @@ private QuantityValue(decimal val) : this() public static implicit operator QuantityValue(decimal val) => new QuantityValue(val); // decimal #endregion - #region To double + #region Explicit cast to double - /// Explicit cast from to . + /// Explicit cast from to . public static explicit operator double(QuantityValue number) - => number.Type switch - { - UnderlyingDataType.Decimal => (double)number._decimalValue, - UnderlyingDataType.Double => number._doubleValue, - _ => throw new NotImplementedException() - }; + { + return number.IsDecimal ? (double)number.DecimalValue : number.DoubleValue; + } #endregion - #region To decimal + #region Explicit cast to decimal - /// Explicit cast from to . + /// Explicit cast from to . public static explicit operator decimal(QuantityValue number) - => number.Type switch + { + return number.IsDecimal ? number.DecimalValue : (decimal)number.DoubleValue; + } + + #endregion + + #region Operators and Comparators + + /// + public int CompareTo(QuantityValue other) + { + if (IsDecimal && other.IsDecimal) { - UnderlyingDataType.Decimal => number._decimalValue, - UnderlyingDataType.Double => (decimal)number._doubleValue, - _ => throw new NotImplementedException() - }; + return DecimalValue.CompareTo(other.DecimalValue); + } + + if (IsDecimal) + { + var otherValue = other.DoubleValue; + return InDecimalRange(otherValue) ? DecimalValue.CompareTo((decimal)otherValue) : ((double)DecimalValue).CompareTo(otherValue); + } + + if (other.IsDecimal) + { + var thisValue = DoubleValue; + return InDecimalRange(thisValue) ? ((decimal)thisValue).CompareTo(other.DecimalValue) : thisValue.CompareTo((double)other.DecimalValue); + } + + // Both are double + return DoubleValue.CompareTo(other.DoubleValue); + } + + + /// + public int CompareTo(object? obj) + { + return obj is QuantityValue other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(QuantityValue)}"); + } + + /// + public override bool Equals(object other) + { + if (other is QuantityValue qv) + { + return Equals(qv); + } + + return false; + } + + /// + public override int GetHashCode() + { + if (IsDecimal) + { + return DecimalValue.GetHashCode(); + } + else + { + return DoubleValue.GetHashCode(); + } + } + + /// + /// Performs an equality comparison on two instances of . + /// Note that rounding might occur if the two values don't use the same base type. + /// + /// The value to compare to + /// True on exact equality, false otherwise + public bool Equals(QuantityValue other) + { + if (IsDecimal && other.IsDecimal) + { + return DecimalValue == other.DecimalValue; + } + + if (IsDecimal) + { + var otherValue = other.DoubleValue; + return InDecimalRange(otherValue) && DecimalValue == (decimal)otherValue; + } + + if (other.IsDecimal) + { + var thisValue = DoubleValue; + return InDecimalRange(thisValue) && (decimal)DoubleValue == other.DecimalValue; + } + + return DoubleValue.Equals(other.DoubleValue); + } + + /// Equality comparator + public static bool operator ==(QuantityValue a, QuantityValue b) + { + return a.Equals(b); + } + + /// Inequality comparator + public static bool operator !=(QuantityValue a, QuantityValue b) + { + return !a.Equals(b); + } + + /// + /// Greater-than operator + /// + public static bool operator >(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) == 1; + } + + /// + /// Less-than operator + /// + public static bool operator <(QuantityValue a, QuantityValue b) + { + + return a.CompareTo(b) == -1; + } + + /// + /// Greater-than-or-equal operator + /// + public static bool operator >=(QuantityValue a, QuantityValue b) + { + + return a.CompareTo(b) >= 0; + } + + /// + /// Less-than-or-equal operator + /// + public static bool operator <=(QuantityValue a, QuantityValue b) + { + + return a.CompareTo(b) <= 0; + } + + /// + /// Returns the negated value of the operand + /// + /// Value to negate + /// -v + public static QuantityValue operator -(QuantityValue v) + { + if (v.IsDecimal) + { + return new QuantityValue(-v.DecimalValue); + } + else + { + return new QuantityValue(-v.DoubleValue); + } + } + + /// + /// Addition operator. + /// + /// + /// This performs an operation on the numeric value of a quantity, clamping the decimal representation as necessary. + /// + public static QuantityValue operator +(QuantityValue a, QuantityValue b) + { + if (a.IsDecimal && b.IsDecimal) + { + var doubleResult = (double)a.DecimalValue + (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue + b.DecimalValue) : new QuantityValue(doubleResult); + } + else if (a.IsDecimal) + { + var doubleResult = (double)a.DecimalValue + b.DoubleValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue + (decimal)b.DoubleValue): new QuantityValue(doubleResult); + } + else if (b.IsDecimal) + { + var doubleResult = a.DoubleValue + (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue + b.DecimalValue): new QuantityValue(doubleResult); + } + else + { + // Both are double + return new QuantityValue(a.DoubleValue + b.DoubleValue); + } + } + + /// + /// Subtraction operator. + /// + /// + /// This performs an operation on the numeric value of a quantity, there is no unit or conversions involved. + /// + public static QuantityValue operator -(QuantityValue a, QuantityValue b) + { + if (a.IsDecimal && b.IsDecimal) + { + var doubleResult = (double)a.DecimalValue - (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue - b.DecimalValue) : new QuantityValue(doubleResult); + } + else if (a.IsDecimal) + { + var doubleResult = (double)a.DecimalValue - b.DoubleValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue - (decimal)b.DoubleValue): new QuantityValue(doubleResult); + } + else if (b.IsDecimal) + { + var doubleResult = a.DoubleValue - (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue - b.DecimalValue): new QuantityValue(doubleResult); + } + else + { + // Both are double + return new QuantityValue(a.DoubleValue - b.DoubleValue); + } + } + + /// + /// Multiplication operator. + /// + /// + /// This performs an operation on the numeric value of a quantity, there is no unit or conversions involved. + /// + public static QuantityValue operator *(QuantityValue a, QuantityValue b) + { + if (a.IsDecimal && b.IsDecimal) + { + var doubleResult = (double)a.DecimalValue * (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue * b.DecimalValue) : new QuantityValue(doubleResult); + } + else if (a.IsDecimal) + { + var doubleResult = (double)a.DecimalValue * b.DoubleValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue * (decimal)b.DoubleValue): new QuantityValue(doubleResult); + } + else if (b.IsDecimal) + { + var doubleResult = a.DoubleValue * (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue * b.DecimalValue): new QuantityValue(doubleResult); + } + else + { + // Both are double + return new QuantityValue(a.DoubleValue * b.DoubleValue); + } + } + + /// + /// Division operator. + /// + /// + /// This performs an operation on the numeric value of a quantity, there is no unit or conversions involved. + /// + public static QuantityValue operator /(QuantityValue a, QuantityValue b) + { + if (a.IsDecimal && b.IsDecimal) + { + var doubleResult = (double)a.DecimalValue / (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue / b.DecimalValue) : new QuantityValue(doubleResult); + } + else if (a.IsDecimal) + { + var doubleResult = (double)a.DecimalValue / b.DoubleValue; + return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue / (decimal)b.DoubleValue): new QuantityValue(doubleResult); + } + else if (b.IsDecimal) + { + var doubleResult = a.DoubleValue / (double)b.DecimalValue; + return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue / b.DecimalValue): new QuantityValue(doubleResult); + } + else + { + // Both are double + return new QuantityValue(a.DoubleValue / b.DoubleValue); + } + } #endregion + #region ToString + /// Returns the string representation of the numeric value. public override string ToString() => Type switch { - UnderlyingDataType.Decimal => _decimalValue.ToString(), - UnderlyingDataType.Double => _doubleValue.ToString(), + QuantityValueType.Decimal => DecimalValue.ToString(), + QuantityValueType.Double => DoubleValue.ToString(), _ => throw new NotImplementedException() }; - private string GetDebugRepresentation() + private string GetDebugRepresentation() // TODO replace by DebuggerTypeProxy? { StringBuilder builder = new($"{Type} {ToString()} Hex:"); @@ -133,10 +443,132 @@ private string GetDebugRepresentation() return builder.ToString(); } + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// A standard numeric format string (must be valid for either double or decimal, depending on the base type) + /// The string representation + public string ToString(string format) + { + return ToString(format, CultureInfo.CurrentCulture); + } + + /// + /// Returns the string representation of the underlying value + /// + /// Standard format specifiers. Because the underlying value can be double or decimal, the meaning can vary + /// Culture specific settings + /// A string representation of the number + public string ToString(string format, IFormatProvider formatProvider) + { + if (IsDecimal) + { + return DecimalValue.ToString(format, formatProvider); + } + else + { + return DoubleValue.ToString(format, formatProvider); + } + } + + #endregion + + #region IConvertiable interface implmentation + + TypeCode IConvertible.GetTypeCode() + { + return IsDecimal ? TypeCode.Decimal : TypeCode.Double; + } + + bool IConvertible.ToBoolean(IFormatProvider provider) + { + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to Boolean is not supported."); + } + + byte IConvertible.ToByte(IFormatProvider provider) + { + return IsDecimal ? Convert.ToByte(DecimalValue) : Convert.ToByte(DoubleValue); + } + + char IConvertible.ToChar(IFormatProvider provider) + { + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to Char is not supported."); + } + + DateTime IConvertible.ToDateTime(IFormatProvider provider) + { + throw new InvalidCastException($"Converting {typeof(QuantityValue)} to DateTime is not supported."); + } + + decimal IConvertible.ToDecimal(IFormatProvider provider) + { + return IsDecimal ? DecimalValue : Convert.ToDecimal(DoubleValue); + } + + double IConvertible.ToDouble(IFormatProvider provider) + { + return IsDecimal ? Convert.ToDouble(DecimalValue) : DoubleValue; + } + + short IConvertible.ToInt16(IFormatProvider provider) + { + return IsDecimal ? Convert.ToInt16(DecimalValue) : Convert.ToInt16(DoubleValue); + } + + int IConvertible.ToInt32(IFormatProvider provider) + { + return IsDecimal ? Convert.ToInt16(DecimalValue) : Convert.ToInt16(DoubleValue); + } + + long IConvertible.ToInt64(IFormatProvider provider) + { + return IsDecimal ? Convert.ToInt16(DecimalValue) : Convert.ToInt16(DoubleValue); + } + + sbyte IConvertible.ToSByte(IFormatProvider provider) + { + return IsDecimal ? Convert.ToSByte(DecimalValue) : Convert.ToSByte(DoubleValue); + } + + float IConvertible.ToSingle(IFormatProvider provider) + { + return IsDecimal ? Convert.ToSingle(DecimalValue) : Convert.ToSingle(DoubleValue); + } + + /// Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. + /// An object that supplies culture-specific formatting information. + /// The string representation of the value of this instance as specified by . + public string ToString(IFormatProvider provider) + { + return IsDecimal ? Convert.ToString(DecimalValue, provider) : Convert.ToString(DoubleValue, provider); + } + + ushort IConvertible.ToUInt16(IFormatProvider provider) + { + return IsDecimal ? Convert.ToUInt16(DecimalValue) : Convert.ToUInt16(DoubleValue); + } + + uint IConvertible.ToUInt32(IFormatProvider provider) + { + return IsDecimal ? Convert.ToUInt32(DecimalValue) : Convert.ToUInt32(DoubleValue); + } + + ulong IConvertible.ToUInt64(IFormatProvider provider) + { + return IsDecimal ? Convert.ToUInt64(DecimalValue) : Convert.ToUInt64(DoubleValue); + } + + object IConvertible.ToType(Type conversionType, IFormatProvider provider) + { + return IsDecimal ? ((IConvertible)DecimalValue).ToType(conversionType, provider) : ((IConvertible)DoubleValue).ToType(conversionType, provider); + } + + #endregion + /// /// Describes the underlying type of a . /// - public enum UnderlyingDataType : byte + public enum QuantityValueType : byte { /// must have the value 0 due to the bit structure of . Decimal = 0, diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index 7b5a93eb0f..b7f639f24d 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -270,7 +270,7 @@ public bool TryGetConversionFunction(ConversionFunctionLookupKey lookupKey, out /// From unit enum value. /// To unit enum value, must be compatible with . /// The converted value in the new unit representation. - public static double Convert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue) + public static QuantityValue Convert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue) { return Quantity .From(fromValue, fromUnitValue) @@ -285,7 +285,7 @@ public static double Convert(QuantityValue fromValue, Enum fromUnitValue, Enum t /// To unit enum value, must be compatible with . /// The converted value, if successful. Otherwise default. /// True if successful. - public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue) + public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue, out QuantityValue convertedValue) { convertedValue = 0; if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity? fromQuantity)) @@ -331,7 +331,7 @@ public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum /// Output value as the result of converting to . /// No units match the abbreviation. /// More than one unit matches the abbreviation. - public static double ConvertByName(QuantityValue fromValue, string quantityName, string fromUnit, string toUnit) + public static QuantityValue ConvertByName(QuantityValue fromValue, string quantityName, string fromUnit, string toUnit) { if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); @@ -380,7 +380,7 @@ public static double ConvertByName(QuantityValue fromValue, string quantityName, /// Result if conversion was successful, 0 if not. /// bool ok = TryConvertByName(5, "Length", "Meter", "Centimeter", out double centimeters); // 500 /// True if conversion was successful. - public static bool TryConvertByName(QuantityValue inputValue, string quantityName, string fromUnit, string toUnit, out double result) + public static bool TryConvertByName(QuantityValue inputValue, string quantityName, string fromUnit, string toUnit, out QuantityValue result) { result = 0d; @@ -423,7 +423,7 @@ public static bool TryConvertByName(QuantityValue inputValue, string quantityNam /// /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// Output value as the result of converting to . - public static double ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) + public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) { return ConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, null); } @@ -460,7 +460,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant /// are mapped to the abbreviation. /// /// More than one unit matches the abbreviation. - public static double ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string? culture) + public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string? culture) { if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); @@ -501,7 +501,7 @@ public static double ConvertByAbbreviation(QuantityValue fromValue, string quant /// Result if conversion was successful, 0 if not. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// True if conversion was successful. - public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result) + public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out QuantityValue result) { return TryConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, out result, null); } @@ -534,7 +534,7 @@ public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quan /// Result if conversion was successful, 0 if not. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// True if conversion was successful. - public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result, + public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out QuantityValue result, string? culture) { result = 0d; diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index d684c77e66..b69087b62e 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -17,7 +17,7 @@ public static class UnitMath /// A quantity with a value, such that 0 ≤ value ≤ . public static TQuantity Abs(this TQuantity value) where TQuantity : IQuantity { - return value.Value >= 0 ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); + return value.Value >= QuantityValue.Zero ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); } /// Computes the sum of a sequence of values. @@ -33,7 +33,7 @@ public static TQuantity Abs(this TQuantity value) where TQuantity : I public static TQuantity Sum(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Sum(x => x.As(unitType)), unitType); + return (TQuantity) Quantity.From(source.Aggregate(QuantityValue.Zero, (current, quantity) => current + quantity.As(unitType)), unitType); } /// @@ -172,7 +172,20 @@ public static TQuantity Max(this IEnumerable source public static TQuantity Average(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Average(x => x.As(unitType)), unitType); + var count = 0; + var total = QuantityValue.Zero; + foreach (var quantity in source) + { + count++; + total += quantity.As(unitType); + } + + if (count == 0) + { + throw new InvalidOperationException($"{nameof(source)} contains no elements."); + } + + return (TQuantity) Quantity.From(total / count, unitType); } /// @@ -197,5 +210,25 @@ public static TQuantity Average(this IEnumerable so { return source.Select(selector).Average(unitType); } + + /// + /// Explicitly create a instance from a double + /// + /// The input value + /// An instance of + public static QuantityValue ToQuantityValue(this double value) + { + return value; // Implicit cast + } + + /// + /// Explicitly create a instance from a decimal + /// + /// The input value + /// An instance of + public static QuantityValue ToQuantityValue(this decimal value) + { + return value; // Implicit cast + } } } From 1a16ddb46dac294887df19e8bc5af95fcb3f1755 Mon Sep 17 00:00:00 2001 From: lipchev Date: Tue, 23 Aug 2022 04:17:56 +0300 Subject: [PATCH 62/66] Revert "IQuantity with QuantityValue as Value type (PoC)" This reverts commit eae2fd55f6366514b016172a3417e43b8f071123. --- CodeGen/CodeGen.csproj | 2 +- .../UnitsNetGen/QuantityGenerator.cs | 131 ++--- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 74 +-- Common/UnitDefinitions/Angle.json | 4 +- Common/UnitDefinitions/Frequency.json | 2 +- Common/UnitDefinitions/Power.json | 4 +- Common/UnitDefinitions/Pressure.json | 8 +- .../UnitDefinitions/PressureChangeRate.json | 4 +- UnitsNet.Benchmark/Program.cs | 10 +- .../GeneratedCode/Quantities/Angle.g.cs | 4 +- .../GeneratedCode/Quantities/Frequency.g.cs | 2 +- .../GeneratedCode/Quantities/Power.g.cs | 12 +- .../GeneratedCode/Quantities/Pressure.g.cs | 8 +- .../UnitsNet.NumberExtensions.Tests.csproj | 4 +- ...lization.JsonNet.CompatibilityTests.csproj | 32 ++ .../UnitsNetJsonConverterTests.cs | 464 ++++++++++++++++ ...nitsNet.Serialization.JsonNet.Tests.csproj | 4 +- .../UnitsNetBaseJsonConverterTest.cs | 2 +- .../UnitsNetIComparableJsonConverterTest.cs | 2 +- .../UnitsNetIQuantityJsonConverterTest.cs | 2 +- .../AbbreviatedUnitsConverter.cs | 2 +- .../UnitsNetBaseJsonConverter.cs | 5 +- UnitsNet.Tests/AssertEx.cs | 30 -- .../CustomCode/AmplitudeRatioTests.cs | 10 +- UnitsNet.Tests/CustomCode/AreaTests.cs | 4 +- UnitsNet.Tests/CustomCode/BitRateTests.cs | 52 +- .../BrakeSpecificFuelConsumptionTests.cs | 4 +- UnitsNet.Tests/CustomCode/InformationTests.cs | 52 +- UnitsNet.Tests/CustomCode/MassFlowTests.cs | 2 +- UnitsNet.Tests/CustomCode/ParseTests.cs | 12 +- UnitsNet.Tests/CustomCode/PowerRatioTests.cs | 11 +- UnitsNet.Tests/CustomCode/PowerTests.cs | 52 +- .../CustomCode/SpecificEnergyTests.cs | 4 +- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 8 +- UnitsNet.Tests/DecimalOverloadTests.cs | 2 +- UnitsNet.Tests/DummyIQuantity.cs | 6 +- .../TestsBase/AccelerationTestsBase.g.cs | 94 ++-- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 96 ++-- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 74 +-- .../TestsBase/AngleTestsBase.g.cs | 98 ++-- .../TestsBase/ApparentEnergyTestsBase.g.cs | 72 +-- .../TestsBase/ApparentPowerTestsBase.g.cs | 74 +-- .../TestsBase/AreaDensityTestsBase.g.cs | 70 +-- .../AreaMomentOfInertiaTestsBase.g.cs | 78 ++- .../TestsBase/AreaTestsBase.g.cs | 94 ++-- .../TestsBase/BitRateTestsBase.g.cs | 172 +++--- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 72 +-- .../TestsBase/CapacitanceTestsBase.g.cs | 80 ++- ...oefficientOfThermalExpansionTestsBase.g.cs | 72 +-- .../TestsBase/CompressibilityTestsBase.g.cs | 80 ++- .../TestsBase/DensityTestsBase.g.cs | 168 +++--- .../TestsBase/DurationTestsBase.g.cs | 88 ++-- .../TestsBase/DynamicViscosityTestsBase.g.cs | 86 ++- .../ElectricAdmittanceTestsBase.g.cs | 74 +-- .../ElectricChargeDensityTestsBase.g.cs | 70 +-- .../TestsBase/ElectricChargeTestsBase.g.cs | 76 ++- .../ElectricConductanceTestsBase.g.cs | 72 +-- .../ElectricConductivityTestsBase.g.cs | 72 +-- .../ElectricCurrentDensityTestsBase.g.cs | 72 +-- .../ElectricCurrentGradientTestsBase.g.cs | 74 +-- .../TestsBase/ElectricCurrentTestsBase.g.cs | 82 ++- .../TestsBase/ElectricFieldTestsBase.g.cs | 70 +-- .../ElectricInductanceTestsBase.g.cs | 74 +-- .../ElectricPotentialAcTestsBase.g.cs | 76 ++- .../ElectricPotentialChangeRateTestsBase.g.cs | 106 ++-- .../ElectricPotentialDcTestsBase.g.cs | 76 ++- .../TestsBase/ElectricPotentialTestsBase.g.cs | 76 ++- .../ElectricResistanceTestsBase.g.cs | 78 ++- .../ElectricResistivityTestsBase.g.cs | 94 ++-- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 72 +-- .../TestsBase/EnergyTestsBase.g.cs | 138 +++-- .../TestsBase/EntropyTestsBase.g.cs | 80 ++- .../TestsBase/ForceChangeRateTestsBase.g.cs | 96 ++-- .../TestsBase/ForcePerLengthTestsBase.g.cs | 142 +++-- .../TestsBase/ForceTestsBase.g.cs | 96 ++-- .../TestsBase/FrequencyTestsBase.g.cs | 88 ++-- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 74 +-- .../TestsBase/HeatFluxTestsBase.g.cs | 102 ++-- .../HeatTransferCoefficientTestsBase.g.cs | 72 +-- .../TestsBase/IlluminanceTestsBase.g.cs | 74 +-- .../TestsBase/InformationTestsBase.g.cs | 172 +++--- .../TestsBase/IrradianceTestsBase.g.cs | 94 ++-- .../TestsBase/IrradiationTestsBase.g.cs | 80 ++- .../TestsBase/JerkTestsBase.g.cs | 88 ++-- .../KinematicViscosityTestsBase.g.cs | 84 ++- .../TestsBase/LapseRateTestsBase.g.cs | 70 +-- .../TestsBase/LengthTestsBase.g.cs | 138 +++-- .../TestsBase/LevelTestsBase.g.cs | 70 +-- .../TestsBase/LinearDensityTestsBase.g.cs | 94 ++-- .../LinearPowerDensityTestsBase.g.cs | 116 ++-- .../TestsBase/LuminosityTestsBase.g.cs | 94 ++-- .../TestsBase/LuminousFluxTestsBase.g.cs | 70 +-- .../TestsBase/LuminousIntensityTestsBase.g.cs | 70 +-- .../TestsBase/MagneticFieldTestsBase.g.cs | 78 ++- .../TestsBase/MagneticFluxTestsBase.g.cs | 70 +-- .../TestsBase/MagnetizationTestsBase.g.cs | 70 +-- .../TestsBase/MassConcentrationTestsBase.g.cs | 164 +++--- .../TestsBase/MassFlowTestsBase.g.cs | 132 ++--- .../TestsBase/MassFluxTestsBase.g.cs | 90 ++-- .../TestsBase/MassFractionTestsBase.g.cs | 114 ++-- .../MassMomentOfInertiaTestsBase.g.cs | 122 ++--- .../TestsBase/MassTestsBase.g.cs | 116 ++-- .../TestsBase/MolarEnergyTestsBase.g.cs | 72 +-- .../TestsBase/MolarEntropyTestsBase.g.cs | 72 +-- .../TestsBase/MolarMassTestsBase.g.cs | 90 ++-- .../TestsBase/MolarityTestsBase.g.cs | 84 ++- .../TestsBase/PermeabilityTestsBase.g.cs | 70 +-- .../TestsBase/PermittivityTestsBase.g.cs | 70 +-- .../PorousMediumPermeabilityTestsBase.g.cs | 76 ++- .../TestsBase/PowerDensityTestsBase.g.cs | 154 +++--- .../TestsBase/PowerRatioTestsBase.g.cs | 70 +-- .../TestsBase/PowerTestsBase.g.cs | 172 +++--- .../PressureChangeRateTestsBase.g.cs | 94 ++-- .../TestsBase/PressureTestsBase.g.cs | 160 +++--- .../TestsBase/RatioChangeRateTestsBase.g.cs | 70 +-- .../TestsBase/RatioTestsBase.g.cs | 78 ++- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 72 +-- .../TestsBase/ReactivePowerTestsBase.g.cs | 74 +-- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 88 ++-- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 86 ++- .../TestsBase/RelativeHumidityTestsBase.g.cs | 70 +-- .../RotationalAccelerationTestsBase.g.cs | 74 +-- .../TestsBase/RotationalSpeedTestsBase.g.cs | 92 ++-- ...RotationalStiffnessPerLengthTestsBase.g.cs | 76 ++- .../RotationalStiffnessTestsBase.g.cs | 132 ++--- .../TestsBase/ScalarTestsBase.g.cs | 70 +-- .../TestsBase/SolidAngleTestsBase.g.cs | 70 +-- .../TestsBase/SpecificEnergyTestsBase.g.cs | 124 ++--- .../TestsBase/SpecificEntropyTestsBase.g.cs | 84 ++- .../SpecificFuelConsumptionTestsBase.g.cs | 74 +-- .../TestsBase/SpecificVolumeTestsBase.g.cs | 72 +-- .../TestsBase/SpecificWeightTestsBase.g.cs | 100 ++-- .../TestsBase/SpeedTestsBase.g.cs | 130 ++--- .../StandardVolumeFlowTestsBase.g.cs | 84 ++- .../TemperatureChangeRateTestsBase.g.cs | 86 ++- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 84 ++- .../TemperatureGradientTestsBase.g.cs | 74 +-- .../TestsBase/TemperatureTestsBase.g.cs | 86 ++- .../ThermalConductivityTestsBase.g.cs | 70 +-- .../TestsBase/ThermalResistanceTestsBase.g.cs | 78 ++- .../TestsBase/TorquePerLengthTestsBase.g.cs | 108 ++-- .../TestsBase/TorqueTestsBase.g.cs | 116 ++-- .../TestsBase/TurbidityTestsBase.g.cs | 70 +-- .../TestsBase/VitaminATestsBase.g.cs | 70 +-- .../VolumeConcentrationTestsBase.g.cs | 106 ++-- .../TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 70 +-- .../TestsBase/VolumeFlowTestsBase.g.cs | 190 +++---- .../TestsBase/VolumePerLengthTestsBase.g.cs | 80 ++- .../TestsBase/VolumeTestsBase.g.cs | 170 +++--- .../VolumetricHeatCapacityTestsBase.g.cs | 84 ++- .../WarpingMomentOfInertiaTestsBase.g.cs | 78 ++- UnitsNet.Tests/GeneratedQuantityCodeTests.cs | 2 +- UnitsNet.Tests/IntOverloadTests.cs | 2 +- UnitsNet.Tests/LongOverloadTests.cs | 2 +- UnitsNet.Tests/QuantityComparisonTests.cs | 194 ------- UnitsNet.Tests/QuantityValueTests.cs | 150 ------ .../DefaultDataContractJsonSerializerTests.cs | 40 +- .../Serialization/SerializationTestsBase.cs | 2 +- .../Xml/DataContractSerializerTests.cs | 6 +- UnitsNet.Tests/UnitConverterTest.cs | 20 +- UnitsNet.Tests/UnitsNet.Tests.csproj | 4 +- UnitsNet.sln | 52 +- UnitsNet/Comparison.cs | 118 +---- .../Quantities/AmountOfSubstance.extra.cs | 2 +- .../Quantities/AmplitudeRatio.extra.cs | 6 +- .../BrakeSpecificFuelConsumption.extra.cs | 8 +- .../CustomCode/Quantities/Duration.extra.cs | 6 +- UnitsNet/CustomCode/Quantities/Force.extra.cs | 2 +- .../CustomCode/Quantities/Length.extra.cs | 2 +- UnitsNet/CustomCode/Quantities/Mass.extra.cs | 2 +- .../CustomCode/Quantities/MassFlow.extra.cs | 1 - UnitsNet/CustomCode/Quantities/Power.extra.cs | 3 +- .../CustomCode/Quantities/PowerRatio.extra.cs | 6 +- .../Quantities/SpecificEnergy.extra.cs | 2 +- .../Quantities/Temperature.extra.cs | 4 +- .../CustomCode/Quantities/Volume.extra.cs | 2 +- .../CustomCode/Wrappers/ReferencePressure.cs | 4 +- .../Quantities/Acceleration.g.cs | 185 +++---- .../Quantities/AmountOfSubstance.g.cs | 191 +++---- .../Quantities/AmplitudeRatio.g.cs | 127 ++--- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 201 +++---- .../Quantities/ApparentEnergy.g.cs | 119 ++--- .../Quantities/ApparentPower.g.cs | 125 ++--- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 185 +++---- .../GeneratedCode/Quantities/AreaDensity.g.cs | 107 ++-- .../Quantities/AreaMomentOfInertia.g.cs | 137 ++--- .../GeneratedCode/Quantities/BitRate.g.cs | 255 ++++----- .../BrakeSpecificFuelConsumption.g.cs | 119 ++--- .../GeneratedCode/Quantities/Capacitance.g.cs | 143 ++--- .../CoefficientOfThermalExpansion.g.cs | 119 ++--- .../Quantities/Compressibility.g.cs | 143 ++--- .../GeneratedCode/Quantities/Density.g.cs | 407 +++++++------- .../GeneratedCode/Quantities/Duration.g.cs | 167 +++--- .../Quantities/DynamicViscosity.g.cs | 161 +++--- .../Quantities/ElectricAdmittance.g.cs | 125 ++--- .../Quantities/ElectricCharge.g.cs | 131 ++--- .../Quantities/ElectricChargeDensity.g.cs | 107 ++-- .../Quantities/ElectricConductance.g.cs | 119 ++--- .../Quantities/ElectricConductivity.g.cs | 119 ++--- .../Quantities/ElectricCurrent.g.cs | 149 ++---- .../Quantities/ElectricCurrentDensity.g.cs | 119 ++--- .../Quantities/ElectricCurrentGradient.g.cs | 125 ++--- .../Quantities/ElectricField.g.cs | 107 ++-- .../Quantities/ElectricInductance.g.cs | 125 ++--- .../Quantities/ElectricPotential.g.cs | 131 ++--- .../Quantities/ElectricPotentialAc.g.cs | 131 ++--- .../ElectricPotentialChangeRate.g.cs | 221 ++++---- .../Quantities/ElectricPotentialDc.g.cs | 131 ++--- .../Quantities/ElectricResistance.g.cs | 137 ++--- .../Quantities/ElectricResistivity.g.cs | 185 +++---- .../ElectricSurfaceChargeDensity.g.cs | 119 ++--- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 317 +++++------ .../GeneratedCode/Quantities/Entropy.g.cs | 143 ++--- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 191 +++---- .../Quantities/ForceChangeRate.g.cs | 191 +++---- .../Quantities/ForcePerLength.g.cs | 329 +++++------- .../GeneratedCode/Quantities/Frequency.g.cs | 169 +++--- .../Quantities/FuelEfficiency.g.cs | 125 ++--- .../GeneratedCode/Quantities/HeatFlux.g.cs | 209 +++----- .../Quantities/HeatTransferCoefficient.g.cs | 119 ++--- .../GeneratedCode/Quantities/Illuminance.g.cs | 125 ++--- .../GeneratedCode/Quantities/Information.g.cs | 255 ++++----- .../GeneratedCode/Quantities/Irradiance.g.cs | 185 +++---- .../GeneratedCode/Quantities/Irradiation.g.cs | 143 ++--- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 167 +++--- .../Quantities/KinematicViscosity.g.cs | 155 +++--- .../GeneratedCode/Quantities/LapseRate.g.cs | 107 ++-- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 317 +++++------ UnitsNet/GeneratedCode/Quantities/Level.g.cs | 115 ++-- .../Quantities/LinearDensity.g.cs | 185 +++---- .../Quantities/LinearPowerDensity.g.cs | 251 ++++----- .../GeneratedCode/Quantities/Luminosity.g.cs | 185 +++---- .../Quantities/LuminousFlux.g.cs | 107 ++-- .../Quantities/LuminousIntensity.g.cs | 107 ++-- .../Quantities/MagneticField.g.cs | 137 ++--- .../Quantities/MagneticFlux.g.cs | 107 ++-- .../Quantities/Magnetization.g.cs | 107 ++-- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 251 ++++----- .../Quantities/MassConcentration.g.cs | 395 +++++++------- .../GeneratedCode/Quantities/MassFlow.g.cs | 299 +++++------ .../GeneratedCode/Quantities/MassFlux.g.cs | 173 +++--- .../Quantities/MassFraction.g.cs | 245 ++++----- .../Quantities/MassMomentOfInertia.g.cs | 269 ++++------ .../GeneratedCode/Quantities/MolarEnergy.g.cs | 119 ++--- .../Quantities/MolarEntropy.g.cs | 119 ++--- .../GeneratedCode/Quantities/MolarMass.g.cs | 173 +++--- .../GeneratedCode/Quantities/Molarity.g.cs | 155 +++--- .../Quantities/Permeability.g.cs | 107 ++-- .../Quantities/Permittivity.g.cs | 107 ++-- .../Quantities/PorousMediumPermeability.g.cs | 131 ++--- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 267 ++++------ .../Quantities/PowerDensity.g.cs | 365 ++++++------- .../GeneratedCode/Quantities/PowerRatio.g.cs | 115 ++-- .../GeneratedCode/Quantities/Pressure.g.cs | 391 +++++++------- .../Quantities/PressureChangeRate.g.cs | 185 +++---- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 137 ++--- .../Quantities/RatioChangeRate.g.cs | 113 ++-- .../Quantities/ReactiveEnergy.g.cs | 119 ++--- .../Quantities/ReactivePower.g.cs | 125 ++--- .../Quantities/ReciprocalArea.g.cs | 167 +++--- .../Quantities/ReciprocalLength.g.cs | 161 +++--- .../Quantities/RelativeHumidity.g.cs | 107 ++-- .../Quantities/RotationalAcceleration.g.cs | 125 ++--- .../Quantities/RotationalSpeed.g.cs | 179 +++---- .../Quantities/RotationalStiffness.g.cs | 299 +++++------ .../RotationalStiffnessPerLength.g.cs | 131 ++--- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 107 ++-- .../GeneratedCode/Quantities/SolidAngle.g.cs | 107 ++-- .../Quantities/SpecificEnergy.g.cs | 275 +++++----- .../Quantities/SpecificEntropy.g.cs | 155 +++--- .../Quantities/SpecificFuelConsumption.g.cs | 125 ++--- .../Quantities/SpecificVolume.g.cs | 119 ++--- .../Quantities/SpecificWeight.g.cs | 203 +++---- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 293 +++++------ .../Quantities/StandardVolumeFlow.g.cs | 155 +++--- .../GeneratedCode/Quantities/Temperature.g.cs | 153 ++---- .../Quantities/TemperatureChangeRate.g.cs | 161 +++--- .../Quantities/TemperatureDelta.g.cs | 155 +++--- .../Quantities/TemperatureGradient.g.cs | 125 ++--- .../Quantities/ThermalConductivity.g.cs | 113 ++-- .../Quantities/ThermalResistance.g.cs | 137 ++--- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 251 ++++----- .../Quantities/TorquePerLength.g.cs | 227 ++++---- .../GeneratedCode/Quantities/Turbidity.g.cs | 107 ++-- .../GeneratedCode/Quantities/VitaminA.g.cs | 107 ++-- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 413 +++++++-------- .../Quantities/VolumeConcentration.g.cs | 221 ++++---- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 473 ++++++++--------- .../Quantities/VolumeFlowPerArea.g.cs | 113 ++-- .../Quantities/VolumePerLength.g.cs | 143 ++--- .../Quantities/VolumetricHeatCapacity.g.cs | 155 +++--- .../Quantities/WarpingMomentOfInertia.g.cs | 137 ++--- UnitsNet/IQuantity.cs | 8 +- UnitsNet/QuantityFormatter.cs | 5 +- UnitsNet/QuantityValue.cs | 498 ++---------------- UnitsNet/UnitConverter.cs | 16 +- UnitsNet/UnitMath.cs | 39 +- 297 files changed, 13077 insertions(+), 19705 deletions(-) create mode 100644 UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj create mode 100644 UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs delete mode 100644 UnitsNet.Tests/QuantityComparisonTests.cs delete mode 100644 UnitsNet.Tests/QuantityValueTests.cs diff --git a/CodeGen/CodeGen.csproj b/CodeGen/CodeGen.csproj index 091df14572..8e71a7f710 100644 --- a/CodeGen/CodeGen.csproj +++ b/CodeGen/CodeGen.csproj @@ -11,7 +11,7 @@ - + diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index edebcc1281..cf48ef7b4d 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -25,7 +25,7 @@ public QuantityGenerator(Quantity quantity) throw new ArgumentException($"No unit found with SingularName equal to BaseUnit [{_quantity.BaseUnit}]. This unit must be defined.", nameof(quantity)); - _valueType = "QuantityValue";// quantity.ValueType; + _valueType = quantity.ValueType; _unitEnumName = $"{quantity.Name}Unit"; BaseDimensions baseDimensions = quantity.BaseDimensions; @@ -77,14 +77,14 @@ public partial struct {_quantity.Name} : IQuantity<{_unitEnumName}>, "); Writer.W("IDecimalQuantity, "); } - Writer.WL($"IEquatable<{_quantity.Name}>, IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); + Writer.WL($"IComparable, IComparable<{_quantity.Name}>, IConvertible, IFormattable"); Writer.WL($@" {{ /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = ""Value"", Order = 0)] - private readonly {_valueType} _value; + private readonly {_quantity.ValueType} _value; /// /// The unit this quantity was constructed with. @@ -176,9 +176,9 @@ private void GenerateInstanceConstructors() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public {_quantity.Name}({_valueType} value, {_unitEnumName} unit) + public {_quantity.Name}({_quantity.ValueType} value, {_unitEnumName} unit) {{"); - Writer.WL(_valueType == "double" + Writer.WL(_quantity.ValueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" : @" @@ -203,7 +203,7 @@ private void GenerateInstanceConstructors() var firstUnitInfo = unitInfos.FirstOrDefault(); "); - Writer.WL(_valueType == "double" + Writer.WL(_quantity.ValueType == "double" ? @" _value = Guard.EnsureValidNumber(value, nameof(value));" : @" @@ -262,15 +262,15 @@ private void GenerateProperties() public {_valueType} Value => _value; "); - Writer.WL($@" - /// - {_valueType} IQuantity.Value => _value; -"); // Need to provide explicit interface implementation for decimal quantities like Information + if (_quantity.ValueType != "double") + Writer.WL(@" + double IQuantity.Value => (double) _value; +"); if (_quantity.ValueType == "decimal") Writer.WL(@" /// - decimal IDecimalQuantity.Value => (decimal)_value; + decimal IDecimalQuantity.Value => _value; "); Writer.WL($@" @@ -306,11 +306,11 @@ private void GenerateConversionProperties() Writer.WL($@" /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public {_valueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -426,7 +426,7 @@ private void GenerateStaticFactoryMethods() /// If value is NaN or Infinity."); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public static {_quantity.Name} From{unit.PluralName}({_valueType} {valueParamName}) + public static {_quantity.Name} From{unit.PluralName}(QuantityValue {valueParamName}) {{ {_valueType} value = ({_valueType}) {valueParamName}; return new {_quantity.Name}(value, {_unitEnumName}.{unit.SingularName}); @@ -651,7 +651,7 @@ private void GenerateArithmeticOperators() }} /// Get ratio value from dividing by . - public static {_valueType} operator /({_quantity.Name} left, {_quantity.Name} right) + public static double operator /({_quantity.Name} left, {_quantity.Name} right) {{ return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; }} @@ -679,7 +679,7 @@ private void GenerateLogarithmicArithmeticOperators() {{ // Logarithmic addition // Formula: {x} * log10(10^(x/{x}) + 10^(y/{x})) - return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, (double)left.Value/{x}) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/{x})), left.Unit); + return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value/{x}) + Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); }} /// Get from logarithmic subtraction of two . @@ -687,7 +687,7 @@ private void GenerateLogarithmicArithmeticOperators() {{ // Logarithmic subtraction // Formula: {x} * log10(10^(x/{x}) - 10^(y/{x})) - return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, (double)left.Value/{x}) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/{x})), left.Unit); + return new {_quantity.Name}({x} * Math.Log10(Math.Pow(10, left.Value/{x}) - Math.Pow(10, right.GetValueAs(left.Unit)/{x})), left.Unit); }} /// Get from logarithmic multiplication of value and . @@ -751,19 +751,6 @@ private void GenerateEqualityAndComparison() return left.Value > right.GetValueAs(left.Unit); }} - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==({_quantity.Name} left, {_quantity.Name} right) - {{ - return left.Equals(right); - }} - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=({_quantity.Name} left, {_quantity.Name} right) - {{ - return !(left == right); - }} - /// public int CompareTo(object obj) {{ @@ -776,29 +763,7 @@ public int CompareTo(object obj) /// public int CompareTo({_quantity.Name} other) {{ - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - }} - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - {{ - if (obj is null || !(obj is {_quantity.Name} obj{_quantity.Name})) - return false; - return Equals(obj{_quantity.Name}); - }} - - /// - /// Consider using for safely comparing floating point values. - public bool Equals({_quantity.Name} other) - {{ - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); }} /// @@ -841,13 +806,13 @@ public bool Equals({_quantity.Name} other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals({_quantity.Name} other, {_valueType} tolerance, ComparisonType comparisonType) + public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) {{ if (tolerance < 0) throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); - {_valueType} thisValue = this.Value; - {_valueType} otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); }} @@ -858,7 +823,7 @@ public bool Equals({_quantity.Name} other, {_valueType} tolerance, ComparisonTyp /// A hash code for the current {_quantity.Name}. public override int GetHashCode() {{ - return Info.Name.GetHashCode(); + return new {{ Info.Name, Value, Unit }}.GetHashCode(); }} #endregion @@ -874,30 +839,17 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public {_valueType} As({_unitEnumName} unit) + public double As({_unitEnumName} unit) {{ - if(Unit == unit) - return Value; - - return GetValueAs(unit); - }} -"); - - if (_valueType == "decimal") - { - Writer.WL($@" + if (Unit == unit) + return Convert.ToDouble(Value); - {_valueType} IQuantity<{_unitEnumName}>.As({_unitEnumName} unit) - {{ - return ({_valueType})As(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); }} -"); - } - - Writer.WL($@" /// - public {_valueType} As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) {{ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -910,27 +862,14 @@ private void GenerateConversionMethods() return As(firstUnitInfo.Value); }} -"); - - if (_valueType == "decimal") - { - Writer.WL($@" - /// - {_valueType} IQuantity.As(UnitSystem unitSystem) - {{ - return ({_valueType})As(unitSystem); - }} -"); - } - Writer.WL($@" /// - {_valueType} IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) {{ - if (!(unit is {_unitEnumName} typedUnit)) + if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ({_valueType})As(typedUnit); + return As(unitAs{_unitEnumName}); }} /// @@ -962,7 +901,7 @@ private void GenerateConversionMethods() var converted = conversionFunction(this); return ({_quantity.Name})converted; }} - else if (Enum.IsDefined(typeof({_unitEnumName}), unit)) + else if (Unit != BaseUnit) {{ // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -970,17 +909,17 @@ private void GenerateConversionMethods() }} else {{ - throw new NotSupportedException($""Can not convert {{Unit}} to {{unit}}.""); + throw new NotImplementedException($""Can not convert {{Unit}} to {{unit}}.""); }} }} /// IQuantity IQuantity.ToUnit(Enum unit) {{ - if (!(unit is {_unitEnumName} typedUnit)) + if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAs{_unitEnumName}, DefaultConversionFunctions); }} /// diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index 2c7d1a3d8a..b9a4f2db68 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -102,7 +102,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected abstract {_quantity.ValueType} {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); + protected abstract double {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); } Writer.WL(""); @@ -114,12 +114,12 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected virtual {_quantity.ValueType} {unit.PluralName}Tolerance {{ get {{ return { (_quantity.ValueType == "decimal" ? "1E-9m" : "1E-5") }; }} }}"); + protected virtual double {unit.PluralName}Tolerance {{ get {{ return 1e-5; }} }}"); } Writer.WL($@" // ReSharper restore VirtualMemberNeverOverriden.Global - protected ({_quantity.ValueType} UnitsInBaseUnit, {_quantity.ValueType} Tolerence) GetConversionFactor({_unitEnumName} unit) + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor({_unitEnumName} unit) {{ return unit switch {{"); @@ -260,7 +260,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) {{ - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); }} else @@ -351,21 +351,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit({_unitEnumName} unit) {{ - var inBaseUnit = {_quantity.Name}.From(1.0, {_quantity.Name}.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = {_quantity.Name}.From(1.0, {_quantity.Name}.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); }} - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - {{ - var inBaseUnit = {_quantity.Name}.From(1.0, {_quantity.Name}.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default({_unitEnumName}))); - }} - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) @@ -375,12 +368,12 @@ public void ToUnit_WithSameUnits_AreEqual({_unitEnumName} unit) Assert.Equal(quantity, toUnitWithSameUnit); }} - [Theory{(_quantity.Units.Length == 1 ? "(Skip = \"Multiple units required\")" : string.Empty)}] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit({_unitEnumName} unit) {{ - // This test is only available for quantities with more than one units. - var fromUnit = {_quantity.Name}.Units.First(u => u != {_quantity.Name}.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = {_quantity.Name}.Units.Where(u => u != {_quantity.Name}.BaseUnit).DefaultIfEmpty({_quantity.Name}.BaseUnit).FirstOrDefault(); var quantity = {_quantity.Name}.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -619,9 +612,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); }} [Fact] @@ -655,41 +647,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); }} [Fact] public void Convert_ToInt32_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); }} [Fact] public void Convert_ToInt64_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); }} [Fact] public void Convert_ToSByte_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); }} [Fact] public void Convert_ToSingle_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); }} [Fact] @@ -702,25 +689,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); }} [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); }} [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() {{ - var value = 1.0; - var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); }} [Fact] @@ -762,7 +746,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() {{ var quantity = {_quantity.Name}.From{_baseUnit.PluralName}(1.0); - Assert.Equal({_quantity.Name}.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {{{_quantity.Name}.Info.Name, quantity.Value, quantity.Unit}}.GetHashCode(), quantity.GetHashCode()); }} "); diff --git a/Common/UnitDefinitions/Angle.json b/Common/UnitDefinitions/Angle.json index 2b240f025d..1f7b908af1 100644 --- a/Common/UnitDefinitions/Angle.json +++ b/Common/UnitDefinitions/Angle.json @@ -108,8 +108,8 @@ { "SingularName": "Tilt", "PluralName": "Tilt", - "FromUnitToBaseFunc": "Math.Asin((double){x}) * 180 / Math.PI", - "FromBaseToUnitFunc": "Math.Sin((double){x} / 180 * Math.PI)", + "FromUnitToBaseFunc": "Math.Asin({x}) * 180 / Math.PI", + "FromBaseToUnitFunc": "Math.Sin({x} / 180 * Math.PI)", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/Frequency.json b/Common/UnitDefinitions/Frequency.json index eb901b4740..400a4f7f87 100644 --- a/Common/UnitDefinitions/Frequency.json +++ b/Common/UnitDefinitions/Frequency.json @@ -95,7 +95,7 @@ { "SingularName": "BUnit", "PluralName": "BUnits", - "FromUnitToBaseFunc": "Math.Sqrt((double){x} * 1e3)", + "FromUnitToBaseFunc": "Math.Sqrt({x} * 1e3)", "FromBaseToUnitFunc": "{x} * {x} * 1e-3", "Localization": [ { diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index ce491fa507..89f98458eb 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -85,8 +85,8 @@ { "SingularName": "BritishThermalUnitPerHour", "PluralName": "BritishThermalUnitsPerHour", - "FromUnitToBaseFunc": "{x} * 0.29307107017m", - "FromBaseToUnitFunc": "{x} / 0.29307107017m", + "FromUnitToBaseFunc": "{x} * 0.293071m", + "FromBaseToUnitFunc": "{x} / 0.293071m", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { diff --git a/Common/UnitDefinitions/Pressure.json b/Common/UnitDefinitions/Pressure.json index 86f5bd3018..89b22e4e3c 100644 --- a/Common/UnitDefinitions/Pressure.json +++ b/Common/UnitDefinitions/Pressure.json @@ -380,8 +380,8 @@ { "SingularName": "MeterOfElevation", "PluralName": "MetersOfElevation", - "FromUnitToBaseFunc": "Math.Pow(1.0 - ((double){x} / 44307.69396), 5.2553026003237266401799415610351) * 101325.0", - "FromBaseToUnitFunc": "(1.0 - Math.Pow((double){x} / 101325.0, 0.190284)) * 44307.69396", + "FromUnitToBaseFunc": "Math.Pow(1.0 - ({x} / 44307.69396), 5.2553026003237266401799415610351) * 101325.0", + "FromBaseToUnitFunc": "(1.0 - Math.Pow({x} / 101325.0, 0.190284)) * 44307.69396", "Localization": [ { "Culture": "en-US", @@ -392,8 +392,8 @@ { "SingularName": "FootOfElevation", "PluralName": "FeetOfElevation", - "FromUnitToBaseFunc": "Math.Pow(1.0 - ((double){x} / 145366.45), 5.2553026003237266401799415610351) * 101325.0", - "FromBaseToUnitFunc": "(1.0 - Math.Pow((double){x} / 101325.0, 0.190284)) * 145366.45", + "FromUnitToBaseFunc": "Math.Pow(1.0 - ({x} / 145366.45), 5.2553026003237266401799415610351) * 101325.0", + "FromBaseToUnitFunc": "(1.0 - Math.Pow({x} / 101325.0, 0.190284)) * 145366.45", "Localization": [ { "Culture": "en-US", diff --git a/Common/UnitDefinitions/PressureChangeRate.json b/Common/UnitDefinitions/PressureChangeRate.json index 6f60ee8d25..befcc49275 100644 --- a/Common/UnitDefinitions/PressureChangeRate.json +++ b/Common/UnitDefinitions/PressureChangeRate.json @@ -50,11 +50,11 @@ "Localization": [ { "Culture": "en-US", - "Abbreviations": [ "mmHg/s" ] + "Abbreviations": [ "mmHg/s" ], }, { "Culture": "ru-RU", - "Abbreviations": [ "mmHg/с" ] + "Abbreviations": [ "mmHg/с" ], } ] }, diff --git a/UnitsNet.Benchmark/Program.cs b/UnitsNet.Benchmark/Program.cs index 7cbd986157..25d32af6e7 100644 --- a/UnitsNet.Benchmark/Program.cs +++ b/UnitsNet.Benchmark/Program.cs @@ -24,15 +24,15 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Transformation")] - public QuantityValue ToProperty() => _length.Centimeters; + public double ToProperty() => _length.Centimeters; [Benchmark] [BenchmarkCategory("Transformation, Value")] - public QuantityValue As() => _length.As(LengthUnit.Centimeter); + public double As() => _length.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public QuantityValue As_SI() => _length.As(UnitSystem.SI); + public double As_SI() => _length.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] @@ -64,11 +64,11 @@ public class UnitsNetBenchmarks [Benchmark] [BenchmarkCategory("Transformation, Value")] - public QuantityValue IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); + public double IQuantity_As() => _lengthIQuantity.As(LengthUnit.Centimeter); [Benchmark] [BenchmarkCategory("Transformation, Value")] - public QuantityValue IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); + public double IQuantity_As_SI() => _lengthIQuantity.As(UnitSystem.SI); [Benchmark] [BenchmarkCategory("Transformation, Quantity")] diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs index 07fcb9af0b..1305cad4f6 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Angle.g.cs @@ -314,7 +314,7 @@ private double GetValueInBaseUnit() AngleUnit.NatoMil => _value * 9 / 160, AngleUnit.Radian => _value * 180 / 3.1415926535897931, AngleUnit.Revolution => _value * 360, - AngleUnit.Tilt => Math.Asin((double)_value) * 180 / 3.1415926535897931, + AngleUnit.Tilt => Math.Asin(_value) * 180 / 3.1415926535897931, _ => throw new NotImplementedException($"Can not convert {Unit} to base units.") }; } @@ -343,7 +343,7 @@ private double GetValueAs(AngleUnit unit) AngleUnit.NatoMil => baseUnitValue * 160 / 9, AngleUnit.Radian => baseUnitValue / 180 * 3.1415926535897931, AngleUnit.Revolution => baseUnitValue / 360, - AngleUnit.Tilt => Math.Sin((double)baseUnitValue / 180 * 3.1415926535897931), + AngleUnit.Tilt => Math.Sin(baseUnitValue / 180 * 3.1415926535897931), _ => throw new NotImplementedException($"Can not convert {Unit} to {unit}.") }; } diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs index 805a01cbe5..735e48489b 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Frequency.g.cs @@ -245,7 +245,7 @@ private double GetValueInBaseUnit() return Unit switch { FrequencyUnit.BeatPerMinute => _value / 60, - FrequencyUnit.BUnit => Math.Sqrt((double)_value * 1e3), + FrequencyUnit.BUnit => Math.Sqrt(_value * 1e3), FrequencyUnit.CyclePerHour => _value / 3600, FrequencyUnit.CyclePerMinute => _value / 60, FrequencyUnit.Gigahertz => (_value) * 1e9d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index e10cb3d208..5c25292799 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -410,7 +410,7 @@ private double GetValueInBaseUnit() return Unit switch { PowerUnit.BoilerHorsepower => _value * 9812.5d, - PowerUnit.BritishThermalUnitPerHour => _value * 0.29307107017d, + PowerUnit.BritishThermalUnitPerHour => _value * 0.293071d, PowerUnit.Decawatt => (_value) * 1e1d, PowerUnit.Deciwatt => (_value) * 1e-1d, PowerUnit.ElectricalHorsepower => _value * 746d, @@ -419,11 +419,11 @@ private double GetValueInBaseUnit() PowerUnit.Gigawatt => (_value) * 1e9d, PowerUnit.HydraulicHorsepower => _value * 745.69988145d, PowerUnit.JoulePerHour => _value / 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.293071d) * 1e3d, PowerUnit.KilojoulePerHour => (_value / 3600d) * 1e3d, PowerUnit.Kilowatt => (_value) * 1e3d, PowerUnit.MechanicalHorsepower => _value * 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.293071d) * 1e6d, PowerUnit.MegajoulePerHour => (_value / 3600d) * 1e6d, PowerUnit.Megawatt => (_value) * 1e6d, PowerUnit.MetricHorsepower => _value * 735.49875d, @@ -449,7 +449,7 @@ private double GetValueAs(PowerUnit unit) return unit switch { PowerUnit.BoilerHorsepower => baseUnitValue / 9812.5d, - PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.29307107017d, + PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.293071d, PowerUnit.Decawatt => (baseUnitValue) / 1e1d, PowerUnit.Deciwatt => (baseUnitValue) / 1e-1d, PowerUnit.ElectricalHorsepower => baseUnitValue / 746d, @@ -458,11 +458,11 @@ private double GetValueAs(PowerUnit unit) PowerUnit.Gigawatt => (baseUnitValue) / 1e9d, PowerUnit.HydraulicHorsepower => baseUnitValue / 745.69988145d, PowerUnit.JoulePerHour => baseUnitValue * 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e3d, PowerUnit.KilojoulePerHour => (baseUnitValue * 3600d) / 1e3d, PowerUnit.Kilowatt => (baseUnitValue) / 1e3d, PowerUnit.MechanicalHorsepower => baseUnitValue / 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e6d, PowerUnit.MegajoulePerHour => (baseUnitValue * 3600d) / 1e6d, PowerUnit.Megawatt => (baseUnitValue) / 1e6d, PowerUnit.MetricHorsepower => baseUnitValue / 735.49875d, diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs index 2e773ff8a1..fe89149b52 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Pressure.g.cs @@ -646,7 +646,7 @@ private double GetValueInBaseUnit() PressureUnit.Decapascal => (_value) * 1e1d, PressureUnit.Decibar => (_value * 1e5) * 1e-1d, PressureUnit.DynePerSquareCentimeter => _value * 1.0e-1, - PressureUnit.FootOfElevation => Math.Pow(1.0 - ((double)_value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, + 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, @@ -666,7 +666,7 @@ private double GetValueInBaseUnit() PressureUnit.Megabar => (_value * 1e5) * 1e6d, PressureUnit.MeganewtonPerSquareMeter => (_value) * 1e6d, PressureUnit.Megapascal => (_value) * 1e6d, - PressureUnit.MeterOfElevation => Math.Pow(1.0 - ((double)_value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, + 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, @@ -706,7 +706,7 @@ private double GetValueAs(PressureUnit unit) PressureUnit.Decapascal => (baseUnitValue) / 1e1d, PressureUnit.Decibar => (baseUnitValue / 1e5) / 1e-1d, PressureUnit.DynePerSquareCentimeter => baseUnitValue / 1.0e-1, - PressureUnit.FootOfElevation => (1.0 - Math.Pow((double)baseUnitValue / 101325.0, 0.190284)) * 145366.45, + 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, @@ -726,7 +726,7 @@ private double GetValueAs(PressureUnit unit) PressureUnit.Megabar => (baseUnitValue / 1e5) / 1e6d, PressureUnit.MeganewtonPerSquareMeter => (baseUnitValue) / 1e6d, PressureUnit.Megapascal => (baseUnitValue) / 1e6d, - PressureUnit.MeterOfElevation => (1.0 - Math.Pow((double)baseUnitValue / 101325.0, 0.190284)) * 44307.69396, + 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, diff --git a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj index f0c5f3c1d4..0d09ca57fd 100644 --- a/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj +++ b/UnitsNet.NumberExtensions.Tests/UnitsNet.NumberExtensions.Tests.csproj @@ -25,8 +25,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj new file mode 100644 index 0000000000..8bcee805f8 --- /dev/null +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj @@ -0,0 +1,32 @@ + + + + net6.0 + UnitsNet.Serialization.JsonNet.CompatibilityTests + latest + true + + + + + + + + + + + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + + + + diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs new file mode 100644 index 0000000000..6775d8769d --- /dev/null +++ b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs @@ -0,0 +1,464 @@ +// Licensed under MIT No Attribution, see LICENSE file at the root. +// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. + +using System; +using Newtonsoft.Json; +using Xunit; + +namespace UnitsNet.Serialization.JsonNet.CompatibilityTests +{ + public class UnitsNetJsonConverterTests + { + private readonly JsonSerializerSettings _jsonSerializerSettings; + + protected UnitsNetJsonConverterTests() + { + _jsonSerializerSettings = new JsonSerializerSettings {Formatting = Formatting.Indented}; + _jsonSerializerSettings.Converters.Add(new UnitsNetJsonConverter()); + } + + private string SerializeObject(object obj) + { + return JsonConvert.SerializeObject(obj, _jsonSerializerSettings).Replace("\r\n", "\n"); + } + + private T DeserializeObject(string json) + { + return JsonConvert.DeserializeObject(json, _jsonSerializerSettings); + } + + public class Serialize : UnitsNetJsonConverterTests + { + [Fact] + public void Information_CanSerializeVeryLargeValues() + { + Information i = Information.FromExabytes(1E+9); + var expectedJson = "{\n \"Unit\": \"InformationUnit.Exabyte\",\n \"Value\": 1000000000.0\n}"; + + string json = SerializeObject(i); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void Mass_ExpectConstructedValueAndUnit() + { + Mass mass = Mass.FromPounds(200); + var expectedJson = "{\n \"Unit\": \"MassUnit.Pound\",\n \"Value\": 200.0\n}"; + + string json = SerializeObject(mass); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void Information_ExpectConstructedValueAndUnit() + { + Information quantity = Information.FromKilobytes(54); + var expectedJson = "{\n \"Unit\": \"InformationUnit.Kilobyte\",\n \"Value\": 54.0\n}"; + + string json = SerializeObject(quantity); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void NonNullNullableValue_ExpectJsonUnaffected() + { + Mass? nullableMass = Mass.FromKilograms(10); + var expectedJson = "{\n \"Unit\": \"MassUnit.Kilogram\",\n \"Value\": 10.0\n}"; + + string json = SerializeObject(nullableMass); + + // There shouldn't be any change in the JSON for the non-null nullable value. + Assert.Equal(expectedJson, json); + } + + [Fact] + public void NonNullNullableValueNestedInObject_ExpectJsonUnaffected() + { + var testObj = new TestObj + { + NullableFrequency = Frequency.FromHertz(10), + NonNullableFrequency = Frequency.FromHertz(10) + }; + // Ugly manually formatted JSON string is used because string literals with newlines are rendered differently + // on the build server (i.e. the build server uses '\r' instead of '\n') + string expectedJson = "{\n" + + " \"NullableFrequency\": {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " },\n" + + " \"NonNullableFrequency\": {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " }\n" + + "}"; + + string json = SerializeObject(testObj); + + Assert.Equal(expectedJson, json); + } + + [Fact] + public void NullValue_ExpectJsonContainsNullString() + { + string json = SerializeObject(null); + Assert.Equal("null", json); + } + + [Fact] + public void Ratio_ExpectDecimalFractionsUsedAsBaseValueAndUnit() + { + Ratio ratio = Ratio.FromPartsPerThousand(250); + var expectedJson = "{\n \"Unit\": \"RatioUnit.PartPerThousand\",\n \"Value\": 250.0\n}"; + + string json = SerializeObject(ratio); + + Assert.Equal(expectedJson, json); + } + + [Fact(Skip = "Not supported in older versions of serialization")] + public void ArrayValue_ExpectJsonArray() + { + Frequency[] testObj = new Frequency[] { Frequency.FromHertz(10), Frequency.FromHertz(10) }; + + string expectedJson = "[\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " },\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " }\n" + + "]"; + + string json = SerializeObject(testObj); + + Assert.Equal(expectedJson, json); + } + + [Fact(Skip = "Not supported in older versions of serialization")] + public void EmptyArrayValue_ExpectJsonArray() + { + Frequency[] testObj = { }; + + string expectedJson = "[]"; + + string json = SerializeObject(testObj); + Assert.Equal(expectedJson, json); + } + } + + public class Deserialize : UnitsNetJsonConverterTests + { + [Fact] + public void Information_CanDeserializeVeryLargeValues() + { + Information original = Information.FromExabytes(1E+9); + string json = SerializeObject(original); + var deserialized = DeserializeObject(json); + + Assert.Equal(original, deserialized); + } + + [Fact] + public void Mass_ExpectJsonCorrectlyDeserialized() + { + Mass originalMass = Mass.FromKilograms(33.33); + string json = SerializeObject(originalMass); + + var deserializedMass = DeserializeObject(json); + + Assert.Equal(originalMass, deserializedMass); + } + + [Fact] + public void NonNullNullableValue_ExpectValueDeserializedCorrectly() + { + Mass? nullableMass = Mass.FromKilograms(10); + string json = SerializeObject(nullableMass); + + Mass? deserializedNullableMass = DeserializeObject(json); + + Assert.Equal(nullableMass.Value, deserializedNullableMass); + } + + [Fact] + public void NonNullNullableValueNestedInObject_ExpectValueDeserializedCorrectly() + { + var testObj = new TestObj + { + NullableFrequency = Frequency.FromHertz(10), + NonNullableFrequency = Frequency.FromHertz(10) + }; + string json = SerializeObject(testObj); + + var deserializedTestObj = DeserializeObject(json); + + Assert.Equal(testObj.NullableFrequency, deserializedTestObj.NullableFrequency); + } + + [Fact] + public void NullValue_ExpectNullReturned() + { + string json = SerializeObject(null); + var deserializedNullMass = DeserializeObject(json); + + Assert.Null(deserializedNullMass); + } + + [Fact] + public void NullValueNestedInObject_ExpectValueDeserializedToNullCorrectly() + { + var testObj = new TestObj + { + NullableFrequency = null, + NonNullableFrequency = Frequency.FromHertz(10) + }; + string json = SerializeObject(testObj); + + var deserializedTestObj = DeserializeObject(json); + + Assert.Null(deserializedTestObj.NullableFrequency); + } + + [Fact] + public void UnitEnumChangedAfterSerialization_ExpectUnitCorrectlyDeserialized() + { + Mass originalMass = Mass.FromKilograms(33.33); + string json = SerializeObject(originalMass); + // Someone manually changed the serialized JSON string to 1000 grams. + json = json.Replace("33.33", "1000"); + json = json.Replace("MassUnit.Kilogram", "MassUnit.Gram"); + + var deserializedMass = DeserializeObject(json); + + // The original value serialized was 33.33 kg, but someone edited the JSON to be 1000 g. We expect the JSON is + // still deserializable, and the correct value of 1000 g is obtained. + Assert.Equal(1000, deserializedMass.Grams); + } + + [Fact] + public void UnitInIComparable_ExpectUnitCorrectlyDeserialized() + { + TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() + { + Value = Power.FromWatts(10) + }; + JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); + + string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); + + var deserializedTestObject = JsonConvert.DeserializeObject(json,jsonSerializerSettings); + + Assert.Equal(typeof(Power), deserializedTestObject.Value.GetType()); + Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value); + } + + [Fact] + public void DoubleInIComparable_ExpectUnitCorrectlyDeserialized() + { + TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() + { + Value = 10.0 + }; + JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); + + string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); + + var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); + + Assert.Equal(typeof(double), deserializedTestObject.Value.GetType()); + Assert.Equal(10d, (double)deserializedTestObject.Value); + } + + [Fact] + public void ClassInIComparable_ExpectUnitCorrectlyDeserialized() + { + TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() + { + Value = new ComparableClass() { Value = 10 } + }; + JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); + + string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); + var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); + + Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value.GetType()); + Assert.Equal(10d, ((ComparableClass) deserializedTestObject.Value).Value); + } + + [Fact] + public void OtherObjectWithUnitAndValue_ExpectCorrectResturnValues() + { + TestObjWithValueAndUnit testObjWithValueAndUnit = new TestObjWithValueAndUnit() + { + Value = 5, + Unit = "Test", + }; + JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); + + string json = JsonConvert.SerializeObject(testObjWithValueAndUnit, jsonSerializerSettings); + TestObjWithValueAndUnit deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); + + Assert.Equal(typeof(double), deserializedTestObject.Value.GetType()); + Assert.Equal(5d, deserializedTestObject.Value); + Assert.Equal("Test", deserializedTestObject.Unit); + } + + [Fact] + public void ThreeObjectsInIComparableWithDifferentValues_ExpectAllCorrectlyDeserialized() + { + TestObjWithThreeIComparable testObjWithIComparable = new TestObjWithThreeIComparable() + { + Value1 = 10.0, + Value2 = Power.FromWatts(19), + Value3 = new ComparableClass() { Value = 10 }, + }; + JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); + + string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); + var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); + + Assert.Equal(typeof(double), deserializedTestObject.Value1.GetType()); + Assert.Equal(10d, deserializedTestObject.Value1); + Assert.Equal(typeof(Power), deserializedTestObject.Value2.GetType()); + Assert.Equal(Power.FromWatts(19), deserializedTestObject.Value2); + Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value3.GetType()); + Assert.Equal(testObjWithIComparable.Value3, deserializedTestObject.Value3); + } + + [Fact(Skip = "Not supported in older versions of serialization")] + public void ArrayOfUnits_ExpectCorrectlyDeserialized() + { + Frequency[] expected = new Frequency[] { Frequency.FromHertz(10), Frequency.FromHertz(10) }; + + string json = "[\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " },\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " }\n" + + "]"; + + Frequency[] result = DeserializeObject(json); + + Assert.Equal(expected, result); + } + + [Fact(Skip = "Not supported in older versions of serialization")] + public void MultiDimArrayOfUnits_ExpectCorrectlyDeserialized() + { + Frequency[,] expected = { { Frequency.FromHertz(10), Frequency.FromHertz(10) }, { Frequency.FromHertz(10), Frequency.FromHertz(10) } }; + + string json = "[\n" + + " [\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " },\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " }\n" + + " ],\n" + + " [\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " },\n" + + " {\n" + + " \"Unit\": \"FrequencyUnit.Hertz\",\n" + + " \"Value\": 10.0\n" + + " }\n" + + " ]\n" + + "]"; + + Frequency[,] result = DeserializeObject(json); + + Assert.Equal(expected, result); + } + + [Fact(Skip = "Not supported in older versions of serialization")] + public void EmptyArray_ExpectCorrectlyDeserialized() + { + string json = "[]"; + + Frequency[] result = DeserializeObject(json); + + Assert.Empty(result); + } + + private static JsonSerializerSettings CreateJsonSerializerSettings() + { + var jsonSerializerSettings = new JsonSerializerSettings() + { + Formatting = Formatting.Indented, + TypeNameHandling = TypeNameHandling.Auto + }; + jsonSerializerSettings.Converters.Add(new UnitsNetJsonConverter()); + return jsonSerializerSettings; + } + } + + private class TestObj + { + public Frequency? NullableFrequency { get; set; } + public Frequency NonNullableFrequency { get; set; } + } + + private class TestObjWithValueAndUnit : IComparable + { + public double Value { get; set; } + public string Unit { get; set; } + + public int CompareTo(object obj) + { + return ((IComparable)Value).CompareTo(obj); + } + } + + private class ComparableClass : IComparable + { + public int Value { get; set; } + public int CompareTo(object obj) + { + return ((IComparable)Value).CompareTo(obj); + } + + // Needed for virfying that the deserialized object is the same, should not affect the serilization code + public override bool Equals(object obj) + { + if (obj == null || GetType() != obj.GetType()) + { + return false; + } + return Value.Equals(((ComparableClass)obj).Value); + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + } + + private class TestObjWithIComparable + { + public IComparable Value { get; set; } + } + + private class TestObjWithThreeIComparable + { + public IComparable Value1 { get; set; } + + public IComparable Value2 { get; set; } + + public IComparable Value3 { get; set; } + } + } +} diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj index b9176c0e6b..8dbc78c305 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNet.Serialization.JsonNet.Tests.csproj @@ -14,8 +14,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index 76e82be109..9aa3d59239 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -54,7 +54,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5m, ComparisonType.Absolute)); + Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5, ComparisonType.Absolute)); } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs index bbe5522852..f8053607da 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs @@ -117,7 +117,7 @@ public void UnitsNetIComparableJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(120M, ((Power)result).Watts); + Assert.Equal(120D, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs index 8ed7de7c29..ea87af940d 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs @@ -135,7 +135,7 @@ public void UnitsNetIQuantityJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(10.3654M, ((Power)result).Watts); + Assert.Equal(10.3654D, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs index 2b89bee8df..b7a150b944 100644 --- a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs +++ b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs @@ -85,7 +85,7 @@ public override void WriteJson(JsonWriter writer, IQuantity? quantity, JsonSeria } else { - writer.WriteValue((double)quantity.Value); + writer.WriteValue(quantity.Value); } // write the 'Unit' abbreviation diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index 3373b27b26..2e804182c7 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -186,14 +186,13 @@ protected ValueUnit ConvertIQuantity(IQuantity quantity) return new ExtendedValueUnit { Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}", - // The type of "Value" is still double - Value = (double)quantity.Value, + Value = quantity.Value, ValueString = d.Value.ToString(CultureInfo.InvariantCulture), ValueType = "decimal" }; } - return new ValueUnit {Value = (double)quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; + return new ValueUnit {Value = quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; } /// diff --git a/UnitsNet.Tests/AssertEx.cs b/UnitsNet.Tests/AssertEx.cs index 34f270251c..d052adfeec 100644 --- a/UnitsNet.Tests/AssertEx.cs +++ b/UnitsNet.Tests/AssertEx.cs @@ -25,35 +25,5 @@ public static void EqualTolerance(double expected, double actual, double toleran Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" ); } } - - public static void EqualTolerance(decimal expected, decimal actual, decimal tolerance, ComparisonType comparisonType = ComparisonType.Relative) - { - if (comparisonType == ComparisonType.Relative) - { - bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance); - - decimal difference = Math.Abs(expected - actual); - decimal relativeDifference = difference / expected; - - Assert.True(areEqual, $"Values are not equal within relative tolerance: {tolerance:P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}"); - } - else if (comparisonType == ComparisonType.Absolute) - { - bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance); - Assert.True(areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}"); - } - } - - public static void EqualTolerance(QuantityValue expected, QuantityValue actual, double tolerance, - ComparisonType comparisonType = ComparisonType.Relative) - { - EqualTolerance((double)expected, (double)actual, tolerance, comparisonType); - } - - public static void EqualTolerance(QuantityValue expected, QuantityValue actual, decimal tolerance, - ComparisonType comparisonType = ComparisonType.Relative) - { - EqualTolerance((decimal)expected, (decimal)actual, tolerance, comparisonType); - } } } diff --git a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs index 92960b547a..726457cbe1 100644 --- a/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/AmplitudeRatioTests.cs @@ -51,7 +51,7 @@ public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, doub // Amplitude ratio increases linearly by 20 dBV with power-of-10 increases of voltage. ElectricPotential v = ElectricPotential.FromVolts(voltage); - double actual = (double)AmplitudeRatio.FromElectricPotential(v).DecibelVolts; + double actual = AmplitudeRatio.FromElectricPotential(v).DecibelVolts; Assert.Equal(expected, actual); } @@ -61,12 +61,12 @@ public void ExpectVoltageConvertedToAmplitudeRatioCorrectly(double voltage, doub [InlineData(0, 1)] [InlineData(20, 10)] [InlineData(40, 100)] - public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(QuantityValue amplitudeRatio, QuantityValue expected) + public void ExpectAmplitudeRatioConvertedToVoltageCorrectly(double amplitudeRatio, double expected) { // Voltage increases by powers of 10 for every 20 dBV increase in amplitude ratio. AmplitudeRatio ar = AmplitudeRatio.FromDecibelVolts(amplitudeRatio); - QuantityValue actual = ar.ToElectricPotential().Volts; + double actual = ar.ToElectricPotential().Volts; Assert.Equal(expected, actual); } @@ -81,7 +81,7 @@ public void AmplitudeRatioToPowerRatio_50OhmImpedance(double dBmV, double expect { AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - double actual = Math.Round((double)ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); + double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(50)).DecibelMilliwatts, 2); Assert.Equal(expected, actual); } @@ -94,7 +94,7 @@ public void AmplitudeRatioToPowerRatio_75OhmImpedance(double dBmV, double expect { AmplitudeRatio ampRatio = AmplitudeRatio.FromDecibelMillivolts(dBmV); - double actual = Math.Round((double)ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); + double actual = Math.Round(ampRatio.ToPowerRatio(ElectricResistance.FromOhms(75)).DecibelMilliwatts, 2); Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/AreaTests.cs b/UnitsNet.Tests/CustomCode/AreaTests.cs index 966fc50aca..5cea83c962 100644 --- a/UnitsNet.Tests/CustomCode/AreaTests.cs +++ b/UnitsNet.Tests/CustomCode/AreaTests.cs @@ -68,7 +68,7 @@ public void AreaFromCicleDiameterCalculatedCorrectly(double diameterMeters, doub { Length diameter = Length.FromMeters(diameterMeters); - double actual = (double)Area.FromCircleDiameter(diameter).SquareMeters; + double actual = Area.FromCircleDiameter(diameter).SquareMeters; Assert.Equal(expected, actual); } @@ -82,7 +82,7 @@ public void AreaFromCicleRadiusCalculatedCorrectly(double radiusMeters, double e { Length radius = Length.FromMeters(radiusMeters); - double actual = (double)Area.FromCircleRadius(radius).SquareMeters; + double actual = Area.FromCircleRadius(radius).SquareMeters; Assert.Equal(expected, actual); } diff --git a/UnitsNet.Tests/CustomCode/BitRateTests.cs b/UnitsNet.Tests/CustomCode/BitRateTests.cs index 5e49dc8ad3..2afe11ae27 100644 --- a/UnitsNet.Tests/CustomCode/BitRateTests.cs +++ b/UnitsNet.Tests/CustomCode/BitRateTests.cs @@ -29,37 +29,37 @@ public class BitRateTests : BitRateTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override decimal BitsPerSecondInOneBitPerSecond => 1m; - protected override decimal BytesPerSecondInOneBitPerSecond => 1.25E-1m; + protected override double BitsPerSecondInOneBitPerSecond => 1d; + protected override double BytesPerSecondInOneBitPerSecond => 1.25E-1d; - protected override decimal KilobitsPerSecondInOneBitPerSecond => 1E-3m; - protected override decimal KilobytesPerSecondInOneBitPerSecond => 1.25E-4m; - protected override decimal KibibitsPerSecondInOneBitPerSecond => 0.0009765625m; - protected override decimal KibibytesPerSecondInOneBitPerSecond => 0.0001220703125m; + protected override double KilobitsPerSecondInOneBitPerSecond => 1E-3d; + protected override double KilobytesPerSecondInOneBitPerSecond => 1.25E-4d; + protected override double KibibitsPerSecondInOneBitPerSecond => 0.0009765625d; + protected override double KibibytesPerSecondInOneBitPerSecond => 0.0001220703125d; - protected override decimal MegabitsPerSecondInOneBitPerSecond => 1E-6m; - protected override decimal MegabytesPerSecondInOneBitPerSecond => 1.25E-07m; - protected override decimal MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07m; - protected override decimal MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07m; + protected override double MegabitsPerSecondInOneBitPerSecond => 1E-6d; + protected override double MegabytesPerSecondInOneBitPerSecond => 1.25E-07d; + protected override double MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07d; + protected override double MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07d; - protected override decimal GigabitsPerSecondInOneBitPerSecond => 1E-9m; - protected override decimal GigabytesPerSecondInOneBitPerSecond => 1.25E-10m; - protected override decimal GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10m; - protected override decimal GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10m; + protected override double GigabitsPerSecondInOneBitPerSecond => 1E-9d; + protected override double GigabytesPerSecondInOneBitPerSecond => 1.25E-10d; + protected override double GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10d; + protected override double GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10d; - protected override decimal TerabitsPerSecondInOneBitPerSecond => 1E-12m; - protected override decimal TerabytesPerSecondInOneBitPerSecond => 1.25E-13m; - protected override decimal TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13m; - protected override decimal TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13m; + protected override double TerabitsPerSecondInOneBitPerSecond => 1E-12d; + protected override double TerabytesPerSecondInOneBitPerSecond => 1.25E-13d; + protected override double TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13d; + protected override double TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13d; - protected override decimal PetabitsPerSecondInOneBitPerSecond => 1E-15m; - protected override decimal PetabytesPerSecondInOneBitPerSecond => 1.25E-16m; - protected override decimal PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16m; - protected override decimal PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16m; + protected override double PetabitsPerSecondInOneBitPerSecond => 1E-15d; + protected override double PetabytesPerSecondInOneBitPerSecond => 1.25E-16d; + protected override double PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16d; + protected override double PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16d; - protected override decimal ExabitsPerSecondInOneBitPerSecond => 1E-18m; - protected override decimal ExabytesPerSecondInOneBitPerSecond => 1.25E-19m; - protected override decimal ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19m; - protected override decimal ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19m; + protected override double ExabitsPerSecondInOneBitPerSecond => 1E-18d; + protected override double ExabytesPerSecondInOneBitPerSecond => 1.25E-19d; + protected override double ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19d; + protected override double ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19d; } } diff --git a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs index 77ec95385c..3079c5d0d6 100644 --- a/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs +++ b/UnitsNet.Tests/CustomCode/BrakeSpecificFuelConsumptionTests.cs @@ -33,8 +33,8 @@ public void DoubleDividedByBrakeSpecificFuelConsumptionEqualsSpecificEnergy() [Fact] public void BrakeSpecificFuelConsumptionTimesSpecificEnergyEqualsEnergy() { - decimal value = (decimal)(BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0)); - Assert.Equal(200.0m, value); + double value = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0) * SpecificEnergy.FromJoulesPerKilogram(10.0); + Assert.Equal(200.0, value); } } } diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs index 4e2b1fa474..dc0dbfd879 100644 --- a/UnitsNet.Tests/CustomCode/InformationTests.cs +++ b/UnitsNet.Tests/CustomCode/InformationTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class InformationTests : InformationTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override decimal BitsInOneBit => 1m; + protected override double BitsInOneBit => 1d; - protected override decimal BytesInOneBit => 0.125m; + protected override double BytesInOneBit => 0.125d; - protected override decimal ExabitsInOneBit => 1e-18m; + protected override double ExabitsInOneBit => 1e-18d; - protected override decimal ExabytesInOneBit => 0.125m*1e-18m; + protected override double ExabytesInOneBit => 0.125d*1e-18d; - protected override decimal ExbibitsInOneBit => 1m/(decimal)Math.Pow(1024, 6); + protected override double ExbibitsInOneBit => 1d/Math.Pow(1024, 6); - protected override decimal ExbibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 6); + protected override double ExbibytesInOneBit => 1/8d/Math.Pow(1024, 6); - protected override decimal GibibitsInOneBit => 1m/(decimal)Math.Pow(1024, 3); + protected override double GibibitsInOneBit => 1d/Math.Pow(1024, 3); - protected override decimal GibibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 3); + protected override double GibibytesInOneBit => 1d/8/Math.Pow(1024, 3); - protected override decimal GigabitsInOneBit => 1e-9m; + protected override double GigabitsInOneBit => 1e-9d; - protected override decimal GigabytesInOneBit => 0.125m*1e-9m; + protected override double GigabytesInOneBit => 0.125d*1e-9d; - protected override decimal KibibitsInOneBit => 1m/1024m; + protected override double KibibitsInOneBit => 1d/1024d; - protected override decimal KibibytesInOneBit => 1m/8/1024m; + protected override double KibibytesInOneBit => 1d/8/1024d; - protected override decimal KilobitsInOneBit => 0.001m; + protected override double KilobitsInOneBit => 0.001d; - protected override decimal KilobytesInOneBit => 0.000125m; + protected override double KilobytesInOneBit => 0.000125d; - protected override decimal MebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 2); + protected override double MebibitsInOneBit => 1d/Math.Pow(1024, 2); - protected override decimal MebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 2); + protected override double MebibytesInOneBit => 1d/8/Math.Pow(1024, 2); - protected override decimal MegabitsInOneBit => 1e-6m; + protected override double MegabitsInOneBit => 1e-6d; - protected override decimal MegabytesInOneBit => 0.125m*1e-6m; + protected override double MegabytesInOneBit => 0.125d*1e-6d; - protected override decimal PebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 5); + protected override double PebibitsInOneBit => 1d/Math.Pow(1024, 5); - protected override decimal PebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 5); + protected override double PebibytesInOneBit => 1d/8/Math.Pow(1024, 5); - protected override decimal PetabitsInOneBit => 1e-15m; + protected override double PetabitsInOneBit => 1e-15d; - protected override decimal PetabytesInOneBit => 0.125m*1e-15m; + protected override double PetabytesInOneBit => 0.125d*1e-15d; - protected override decimal TebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 4); + protected override double TebibitsInOneBit => 1d/Math.Pow(1024, 4); - protected override decimal TebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 4); + protected override double TebibytesInOneBit => 1d/8/Math.Pow(1024, 4); - protected override decimal TerabitsInOneBit => 1e-12m; + protected override double TerabitsInOneBit => 1e-12d; - protected override decimal TerabytesInOneBit => 0.125m*1e-12m; + protected override double TerabytesInOneBit => 0.125d*1e-12d; [Fact] public void OneKBHas1000Bytes() diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index 711f82b28d..9d7cb97f2d 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -108,7 +108,7 @@ public void TimeSpanTimesMassFlowEqualsMass() public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower() { Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); - AssertEx.EqualTolerance(20.0m / 24.0m * 1e6m / 180.0m, power.Kilowatts, 1E-11m); + Assert.Equal(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/ParseTests.cs b/UnitsNet.Tests/CustomCode/ParseTests.cs index ccf4c2ec56..06a1f7cdc9 100644 --- a/UnitsNet.Tests/CustomCode/ParseTests.cs +++ b/UnitsNet.Tests/CustomCode/ParseTests.cs @@ -25,10 +25,10 @@ public class ParseTests [InlineData("1e-3 km", 1)] [InlineData("5.5 m", 5.5)] [InlineData("500,005 m", 500005)] - public void ParseLengthToMetersUsEnglish(string s, QuantityValue expected) + public void ParseLengthToMetersUsEnglish(string s, double expected) { CultureInfo usEnglish = new CultureInfo("en-US"); - QuantityValue actual = Length.Parse(s, usEnglish).Meters; + double actual = Length.Parse(s, usEnglish).Meters; Assert.Equal(expected, actual); } @@ -50,7 +50,7 @@ public void ParseLength_InvalidString_USEnglish_ThrowsException(string s, Type e [InlineData("5.5 m", 5.5)] [InlineData("500 005 m", 500005)] // quantity doesn't match number format - public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, QuantityValue expected) + public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, double expected) { var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone(); numberFormat.NumberGroupSeparator = " "; @@ -58,7 +58,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators(string s, QuantityVal numberFormat.NumberDecimalSeparator = "."; numberFormat.CurrencyDecimalSeparator = "."; - QuantityValue actual = Length.Parse(s, numberFormat).Meters; + double actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } @@ -81,7 +81,7 @@ public void ParseWithCultureUsingSpaceAsThousandSeparators_ThrowsExceptionOnInva [InlineData("5,5 m", 5.5)] [InlineData("500.005.050,001 m", 500005050.001)] [InlineData("5.555 m", 5555)] // Dot is group separator not decimal - public void ParseWithCultureUsingDotAsThousandSeparators(string s, QuantityValue expected) + public void ParseWithCultureUsingDotAsThousandSeparators(string s, double expected) { var numberFormat = (NumberFormatInfo) CultureInfo.InvariantCulture.NumberFormat.Clone(); numberFormat.NumberGroupSeparator = "."; @@ -89,7 +89,7 @@ public void ParseWithCultureUsingDotAsThousandSeparators(string s, QuantityValue numberFormat.NumberDecimalSeparator = ","; numberFormat.CurrencyDecimalSeparator = ","; - QuantityValue actual = Length.Parse(s, numberFormat).Meters; + double actual = Length.Parse(s, numberFormat).Meters; Assert.Equal(expected, actual); } diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs index f34ed66db4..e6820ea023 100644 --- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs @@ -41,12 +41,11 @@ public void InvalidPower_ExpectArgumentOutOfRangeException(double power) public void ExpectPowerConvertedCorrectly(double power, double expected) { Power p = Power.FromWatts(power); - double actual = (double)PowerRatio.FromPower(p).DecibelWatts; + double actual = PowerRatio.FromPower(p).DecibelWatts; Assert.Equal(expected, actual); } [Theory] - // Note: Attribute arguments cannot be of type decimal. [InlineData(-20, 0.01)] [InlineData(-10, 0.1)] [InlineData(0, 1)] @@ -55,8 +54,8 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected) { PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio); - decimal actual = (decimal)pr.ToPower().Watts; - Assert.Equal((decimal)expected, actual); + double actual = pr.ToPower().Watts; + Assert.Equal(expected, actual); } // http://www.maximintegrated.com/en/app-notes/index.mvp/id/808 @@ -70,7 +69,7 @@ public void PowerRatioToAmplitudeRatio_50OhmImpedance(double dBmW, double expect { PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round((double)powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); + double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(50)).DecibelMillivolts, 2); Assert.Equal(expected, actual); } @@ -83,7 +82,7 @@ public void PowerRatioToAmplitudeRatio_75OhmImpedance(double dBmW, double expect { PowerRatio powerRatio = PowerRatio.FromDecibelMilliwatts(dBmW); - double actual = Math.Round((double)powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); + double actual = Math.Round(powerRatio.ToAmplitudeRatio(ElectricResistance.FromOhms(75)).DecibelMillivolts, 2); Assert.Equal(expected, actual); } } diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs index 8161a50849..b965e8fa83 100644 --- a/UnitsNet.Tests/CustomCode/PowerTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class PowerTests : PowerTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override decimal FemtowattsInOneWatt => 1e15m; + protected override double FemtowattsInOneWatt => 1e15; - protected override decimal GigajoulesPerHourInOneWatt => 3600e-9m; + protected override double GigajoulesPerHourInOneWatt => 3600e-9; - protected override decimal PicowattsInOneWatt => 1e12m; + protected override double PicowattsInOneWatt => 1e12; - protected override decimal NanowattsInOneWatt => 1e9m; + protected override double NanowattsInOneWatt => 1e9; - protected override decimal MicrowattsInOneWatt => 1e6m; + protected override double MicrowattsInOneWatt => 1e6; - protected override decimal MillijoulesPerHourInOneWatt => 3600e3m; + protected override double MillijoulesPerHourInOneWatt => 3600e3; - protected override decimal MilliwattsInOneWatt => 1e3m; + protected override double MilliwattsInOneWatt => 1e3; - protected override decimal DeciwattsInOneWatt => 1e1m; + protected override double DeciwattsInOneWatt => 1e1; - protected override decimal WattsInOneWatt => 1; + protected override double WattsInOneWatt => 1; - protected override decimal DecawattsInOneWatt => 1e-1m; + protected override double DecawattsInOneWatt => 1e-1; - protected override decimal KilojoulesPerHourInOneWatt => 3600e-3m; + protected override double KilojoulesPerHourInOneWatt => 3600e-3; - protected override decimal KilowattsInOneWatt => 1e-3m; + protected override double KilowattsInOneWatt => 1e-3; - protected override decimal MegajoulesPerHourInOneWatt => 3600e-6m; + protected override double MegajoulesPerHourInOneWatt => 3600e-6; - protected override decimal MegawattsInOneWatt => 1e-6m; + protected override double MegawattsInOneWatt => 1e-6; - protected override decimal GigawattsInOneWatt => 1e-9m; + protected override double GigawattsInOneWatt => 1e-9; - protected override decimal TerawattsInOneWatt => 1e-12m; + protected override double TerawattsInOneWatt => 1e-12; - protected override decimal PetawattsInOneWatt => 1e-15m; + protected override double PetawattsInOneWatt => 1e-15; - protected override decimal JoulesPerHourInOneWatt => 3600; + protected override double JoulesPerHourInOneWatt => 3600; - protected override decimal KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3m; + protected override double KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3; - protected override decimal BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4m; + protected override double MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6; - protected override decimal MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6m; + protected override double BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4; - protected override decimal BritishThermalUnitsPerHourInOneWatt => 3.412141633m; + protected override double BritishThermalUnitsPerHourInOneWatt => 3.412141633; - protected override decimal ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279m; + protected override double ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279; - protected override decimal HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719m; + protected override double HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719; - protected override decimal MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992m; + protected override double MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992; - protected override decimal MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425m; + protected override double MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425; [Fact] public void DurationTimesPowerEqualsEnergy() diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index 4da3858304..15fb16bb45 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -70,13 +70,13 @@ public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption() public void SpecificEnergyTimesMassFlowEqualsPower() { Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0); - Assert.Equal(200m, power.Watts); + Assert.Equal(200d, power.Watts); } [Fact] public void SpecificEnergyTimesBrakeSpecificFuelConsumptionEqualsEnergy() { - double value = (double)(SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0)); + double value = SpecificEnergy.FromJoulesPerKilogram(10.0) * BrakeSpecificFuelConsumption.FromKilogramsPerJoule(20.0); Assert.Equal(200d, value); } } diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index c64a1af059..cafdfc75ae 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -17,7 +17,7 @@ public HowMuch(double value, HowMuchUnit unit) Enum IQuantity.Unit => Unit; public HowMuchUnit Unit { get; } - public QuantityValue Value { get; } + public double Value { get; } #region IQuantity @@ -38,13 +38,13 @@ public HowMuch(double value, HowMuchUnit unit) Zero, BaseDimensions.Dimensionless); - public QuantityValue As(Enum unit) => Convert.ToDouble(unit); + public double As(Enum unit) => Convert.ToDouble(unit); - public QuantityValue As(UnitSystem unitSystem) => throw new NotImplementedException(); + public double As(UnitSystem unitSystem) => throw new NotImplementedException(); public IQuantity ToUnit(Enum unit) { - if (unit is HowMuchUnit howMuchUnit) return new HowMuch((double)As(unit), howMuchUnit); + if (unit is HowMuchUnit howMuchUnit) return new HowMuch(As(unit), howMuchUnit); throw new ArgumentException("Must be of type HowMuchUnit.", nameof(unit)); } diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs index 6b9842d0aa..841c9b162b 100644 --- a/UnitsNet.Tests/DecimalOverloadTests.cs +++ b/UnitsNet.Tests/DecimalOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorre public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue() { Power power = Power.FromWatts(1m); - Assert.Equal(1.0m, power.Watts); + Assert.Equal(1.0, power.Watts); } } } diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index 95bebe55e5..cda0f506b1 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -11,11 +11,11 @@ internal class DummyIQuantity : IQuantity public Enum Unit => throw new NotImplementedException(); - public QuantityValue Value => throw new NotImplementedException(); + public double Value => throw new NotImplementedException(); - public QuantityValue As(Enum unit ) => throw new NotImplementedException(); + public double As(Enum unit ) => throw new NotImplementedException(); - public QuantityValue As(UnitSystem unitSystem ) => throw new NotImplementedException(); + public double As(UnitSystem unitSystem ) => throw new NotImplementedException(); public string ToString(IFormatProvider? provider) => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index a525d6afba..f70180cba6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class AccelerationTestsBase : QuantityTestsBase protected abstract double StandardGravityInOneMeterPerSecondSquared { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double DecimetersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double FeetPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double InchesPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double KilometersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double KnotsPerHourTolerance { get { return 1E-5; } } - protected virtual double KnotsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double KnotsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MetersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double MicrometersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double MillimetersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double MillistandardGravityTolerance { get { return 1E-5; } } - protected virtual double NanometersPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double StandardGravityTolerance { get { return 1E-5; } } + protected virtual double CentimetersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double DecimetersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double FeetPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double InchesPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double KilometersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double KnotsPerHourTolerance { get { return 1e-5; } } + protected virtual double KnotsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KnotsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MetersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double MicrometersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double MillimetersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double MillistandardGravityTolerance { get { return 1e-5; } } + protected virtual double NanometersPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double StandardGravityTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AccelerationUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -993,21 +993,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AccelerationUnit unit) { - var inBaseUnit = Acceleration.From(1.0, Acceleration.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Acceleration.From(1.0, Acceleration.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Acceleration.From(1.0, Acceleration.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AccelerationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AccelerationUnit unit) @@ -1021,8 +1014,8 @@ public void ToUnit_WithSameUnits_AreEqual(AccelerationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AccelerationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Acceleration.Units.First(u => u != Acceleration.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Acceleration.Units.Where(u => u != Acceleration.BaseUnit).DefaultIfEmpty(Acceleration.BaseUnit).FirstOrDefault(); var quantity = Acceleration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1256,9 +1249,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1292,41 +1284,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1339,25 +1326,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Acceleration.FromMetersPerSecondSquared(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Acceleration.FromMetersPerSecondSquared(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1399,7 +1383,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Acceleration.FromMetersPerSecondSquared(1.0); - Assert.Equal(Acceleration.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Acceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 5d469e8a46..52cc5fa708 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -55,21 +55,21 @@ public abstract partial class AmountOfSubstanceTestsBase : QuantityTestsBase protected abstract double PoundMolesInOneMole { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimolesTolerance { get { return 1E-5; } } - protected virtual double CentipoundMolesTolerance { get { return 1E-5; } } - protected virtual double DecimolesTolerance { get { return 1E-5; } } - protected virtual double DecipoundMolesTolerance { get { return 1E-5; } } - protected virtual double KilomolesTolerance { get { return 1E-5; } } - protected virtual double KilopoundMolesTolerance { get { return 1E-5; } } - protected virtual double MegamolesTolerance { get { return 1E-5; } } - protected virtual double MicromolesTolerance { get { return 1E-5; } } - protected virtual double MicropoundMolesTolerance { get { return 1E-5; } } - protected virtual double MillimolesTolerance { get { return 1E-5; } } - protected virtual double MillipoundMolesTolerance { get { return 1E-5; } } - protected virtual double MolesTolerance { get { return 1E-5; } } - protected virtual double NanomolesTolerance { get { return 1E-5; } } - protected virtual double NanopoundMolesTolerance { get { return 1E-5; } } - protected virtual double PoundMolesTolerance { get { return 1E-5; } } + protected virtual double CentimolesTolerance { get { return 1e-5; } } + protected virtual double CentipoundMolesTolerance { get { return 1e-5; } } + protected virtual double DecimolesTolerance { get { return 1e-5; } } + protected virtual double DecipoundMolesTolerance { get { return 1e-5; } } + protected virtual double KilomolesTolerance { get { return 1e-5; } } + protected virtual double KilopoundMolesTolerance { get { return 1e-5; } } + protected virtual double MegamolesTolerance { get { return 1e-5; } } + protected virtual double MicromolesTolerance { get { return 1e-5; } } + protected virtual double MicropoundMolesTolerance { get { return 1e-5; } } + protected virtual double MillimolesTolerance { get { return 1e-5; } } + protected virtual double MillipoundMolesTolerance { get { return 1e-5; } } + protected virtual double MolesTolerance { get { return 1e-5; } } + protected virtual double NanomolesTolerance { get { return 1e-5; } } + protected virtual double NanopoundMolesTolerance { get { return 1e-5; } } + protected virtual double PoundMolesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AmountOfSubstanceUnit unit) @@ -298,7 +298,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -669,21 +669,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AmountOfSubstanceUnit unit) { - var inBaseUnit = AmountOfSubstance.From(1.0, AmountOfSubstance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = AmountOfSubstance.From(1.0, AmountOfSubstance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = AmountOfSubstance.From(1.0, AmountOfSubstance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AmountOfSubstanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AmountOfSubstanceUnit unit) @@ -697,8 +690,8 @@ public void ToUnit_WithSameUnits_AreEqual(AmountOfSubstanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AmountOfSubstanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = AmountOfSubstance.Units.First(u => u != AmountOfSubstance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = AmountOfSubstance.Units.Where(u => u != AmountOfSubstance.BaseUnit).DefaultIfEmpty(AmountOfSubstance.BaseUnit).FirstOrDefault(); var quantity = AmountOfSubstance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -935,9 +928,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -971,41 +963,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1018,25 +1005,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmountOfSubstance.FromMoles(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = AmountOfSubstance.FromMoles(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1078,7 +1062,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AmountOfSubstance.FromMoles(1.0); - Assert.Equal(AmountOfSubstance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {AmountOfSubstance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 20d580e082..53181b282b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class AmplitudeRatioTestsBase : QuantityTestsBase protected abstract double DecibelVoltsInOneDecibelVolt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecibelMicrovoltsTolerance { get { return 1E-5; } } - protected virtual double DecibelMillivoltsTolerance { get { return 1E-5; } } - protected virtual double DecibelsUnloadedTolerance { get { return 1E-5; } } - protected virtual double DecibelVoltsTolerance { get { return 1E-5; } } + protected virtual double DecibelMicrovoltsTolerance { get { return 1e-5; } } + protected virtual double DecibelMillivoltsTolerance { get { return 1e-5; } } + protected virtual double DecibelsUnloadedTolerance { get { return 1e-5; } } + protected virtual double DecibelVoltsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AmplitudeRatioUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AmplitudeRatioUnit unit) { - var inBaseUnit = AmplitudeRatio.From(1.0, AmplitudeRatio.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = AmplitudeRatio.From(1.0, AmplitudeRatio.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = AmplitudeRatio.From(1.0, AmplitudeRatio.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AmplitudeRatioUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AmplitudeRatioUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(AmplitudeRatioUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AmplitudeRatioUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = AmplitudeRatio.Units.First(u => u != AmplitudeRatio.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = AmplitudeRatio.Units.Where(u => u != AmplitudeRatio.BaseUnit).DefaultIfEmpty(AmplitudeRatio.BaseUnit).FirstOrDefault(); var quantity = AmplitudeRatio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -554,9 +547,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -590,41 +582,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -637,25 +624,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AmplitudeRatio.FromDecibelVolts(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = AmplitudeRatio.FromDecibelVolts(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -697,7 +681,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AmplitudeRatio.FromDecibelVolts(1.0); - Assert.Equal(AmplitudeRatio.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {AmplitudeRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index 8d1a7c53f7..b6f83dd254 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -56,22 +56,22 @@ public abstract partial class AngleTestsBase : QuantityTestsBase protected abstract double TiltInOneDegree { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double ArcminutesTolerance { get { return 1E-5; } } - protected virtual double ArcsecondsTolerance { get { return 1E-5; } } - protected virtual double CentiradiansTolerance { get { return 1E-5; } } - protected virtual double DeciradiansTolerance { get { return 1E-5; } } - protected virtual double DegreesTolerance { get { return 1E-5; } } - protected virtual double GradiansTolerance { get { return 1E-5; } } - protected virtual double MicrodegreesTolerance { get { return 1E-5; } } - protected virtual double MicroradiansTolerance { get { return 1E-5; } } - protected virtual double MillidegreesTolerance { get { return 1E-5; } } - protected virtual double MilliradiansTolerance { get { return 1E-5; } } - protected virtual double NanodegreesTolerance { get { return 1E-5; } } - protected virtual double NanoradiansTolerance { get { return 1E-5; } } - protected virtual double NatoMilsTolerance { get { return 1E-5; } } - protected virtual double RadiansTolerance { get { return 1E-5; } } - protected virtual double RevolutionsTolerance { get { return 1E-5; } } - protected virtual double TiltTolerance { get { return 1E-5; } } + protected virtual double ArcminutesTolerance { get { return 1e-5; } } + protected virtual double ArcsecondsTolerance { get { return 1e-5; } } + protected virtual double CentiradiansTolerance { get { return 1e-5; } } + protected virtual double DeciradiansTolerance { get { return 1e-5; } } + protected virtual double DegreesTolerance { get { return 1e-5; } } + protected virtual double GradiansTolerance { get { return 1e-5; } } + protected virtual double MicrodegreesTolerance { get { return 1e-5; } } + protected virtual double MicroradiansTolerance { get { return 1e-5; } } + protected virtual double MillidegreesTolerance { get { return 1e-5; } } + protected virtual double MilliradiansTolerance { get { return 1e-5; } } + protected virtual double NanodegreesTolerance { get { return 1e-5; } } + protected virtual double NanoradiansTolerance { get { return 1e-5; } } + protected virtual double NatoMilsTolerance { get { return 1e-5; } } + protected virtual double RadiansTolerance { get { return 1e-5; } } + protected virtual double RevolutionsTolerance { get { return 1e-5; } } + protected virtual double TiltTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AngleUnit unit) @@ -308,7 +308,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1253,21 +1253,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AngleUnit unit) { - var inBaseUnit = Angle.From(1.0, Angle.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Angle.From(1.0, Angle.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Angle.From(1.0, Angle.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AngleUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AngleUnit unit) @@ -1281,8 +1274,8 @@ public void ToUnit_WithSameUnits_AreEqual(AngleUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AngleUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Angle.Units.First(u => u != Angle.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Angle.Units.Where(u => u != Angle.BaseUnit).DefaultIfEmpty(Angle.BaseUnit).FirstOrDefault(); var quantity = Angle.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1522,9 +1515,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1558,41 +1550,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1605,25 +1592,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Angle.FromDegrees(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Angle.FromDegrees(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1665,7 +1649,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Angle.FromDegrees(1.0); - Assert.Equal(Angle.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Angle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index 14687f0e3a..e84c7b0aad 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ApparentEnergyTestsBase : QuantityTestsBase protected abstract double VoltampereHoursInOneVoltampereHour { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltampereHoursTolerance { get { return 1E-5; } } - protected virtual double MegavoltampereHoursTolerance { get { return 1E-5; } } - protected virtual double VoltampereHoursTolerance { get { return 1E-5; } } + protected virtual double KilovoltampereHoursTolerance { get { return 1e-5; } } + protected virtual double MegavoltampereHoursTolerance { get { return 1e-5; } } + protected virtual double VoltampereHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ApparentEnergyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ApparentEnergyUnit unit) { - var inBaseUnit = ApparentEnergy.From(1.0, ApparentEnergy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ApparentEnergy.From(1.0, ApparentEnergy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ApparentEnergy.From(1.0, ApparentEnergy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ApparentEnergyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ApparentEnergyUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(ApparentEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ApparentEnergyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ApparentEnergy.Units.First(u => u != ApparentEnergy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ApparentEnergy.Units.Where(u => u != ApparentEnergy.BaseUnit).DefaultIfEmpty(ApparentEnergy.BaseUnit).FirstOrDefault(); var quantity = ApparentEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentEnergy.FromVoltampereHours(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ApparentEnergy.FromVoltampereHours(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ApparentEnergy.FromVoltampereHours(1.0); - Assert.Equal(ApparentEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ApparentEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index 38ce76774c..b650b9bcd9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ApparentPowerTestsBase : QuantityTestsBase protected abstract double VoltamperesInOneVoltampere { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigavoltamperesTolerance { get { return 1E-5; } } - protected virtual double KilovoltamperesTolerance { get { return 1E-5; } } - protected virtual double MegavoltamperesTolerance { get { return 1E-5; } } - protected virtual double VoltamperesTolerance { get { return 1E-5; } } + protected virtual double GigavoltamperesTolerance { get { return 1e-5; } } + protected virtual double KilovoltamperesTolerance { get { return 1e-5; } } + protected virtual double MegavoltamperesTolerance { get { return 1e-5; } } + protected virtual double VoltamperesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ApparentPowerUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ApparentPowerUnit unit) { - var inBaseUnit = ApparentPower.From(1.0, ApparentPower.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ApparentPower.From(1.0, ApparentPower.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ApparentPower.From(1.0, ApparentPower.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ApparentPowerUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ApparentPowerUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(ApparentPowerUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ApparentPowerUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ApparentPower.Units.First(u => u != ApparentPower.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ApparentPower.Units.Where(u => u != ApparentPower.BaseUnit).DefaultIfEmpty(ApparentPower.BaseUnit).FirstOrDefault(); var quantity = ApparentPower.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ApparentPower.FromVoltamperes(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ApparentPower.FromVoltamperes(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ApparentPower.FromVoltamperes(1.0); - Assert.Equal(ApparentPower.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ApparentPower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index 6dcc5c0bc3..a9585c99c0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class AreaDensityTestsBase : QuantityTestsBase protected abstract double KilogramsPerSquareMeterInOneKilogramPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaDensityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AreaDensityUnit unit) { - var inBaseUnit = AreaDensity.From(1.0, AreaDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = AreaDensity.From(1.0, AreaDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = AreaDensity.From(1.0, AreaDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AreaDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AreaDensityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(AreaDensityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = AreaDensity.Units.First(u => u != AreaDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = AreaDensity.Units.Where(u => u != AreaDensity.BaseUnit).DefaultIfEmpty(AreaDensity.BaseUnit).FirstOrDefault(); var quantity = AreaDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaDensity.FromKilogramsPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AreaDensity.FromKilogramsPerSquareMeter(1.0); - Assert.Equal(AreaDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {AreaDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index e511ec6831..2321a0aadf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class AreaMomentOfInertiaTestsBase : QuantityTestsBase protected abstract double MillimetersToTheFourthInOneMeterToTheFourth { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersToTheFourthTolerance { get { return 1E-5; } } - protected virtual double DecimetersToTheFourthTolerance { get { return 1E-5; } } - protected virtual double FeetToTheFourthTolerance { get { return 1E-5; } } - protected virtual double InchesToTheFourthTolerance { get { return 1E-5; } } - protected virtual double MetersToTheFourthTolerance { get { return 1E-5; } } - protected virtual double MillimetersToTheFourthTolerance { get { return 1E-5; } } + protected virtual double CentimetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double DecimetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double FeetToTheFourthTolerance { get { return 1e-5; } } + protected virtual double InchesToTheFourthTolerance { get { return 1e-5; } } + protected virtual double MetersToTheFourthTolerance { get { return 1e-5; } } + protected virtual double MillimetersToTheFourthTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaMomentOfInertiaUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -529,21 +529,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AreaMomentOfInertiaUnit unit) { - var inBaseUnit = AreaMomentOfInertia.From(1.0, AreaMomentOfInertia.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = AreaMomentOfInertia.From(1.0, AreaMomentOfInertia.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = AreaMomentOfInertia.From(1.0, AreaMomentOfInertia.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AreaMomentOfInertiaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AreaMomentOfInertiaUnit unit) @@ -557,8 +550,8 @@ public void ToUnit_WithSameUnits_AreEqual(AreaMomentOfInertiaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaMomentOfInertiaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = AreaMomentOfInertia.Units.First(u => u != AreaMomentOfInertia.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = AreaMomentOfInertia.Units.Where(u => u != AreaMomentOfInertia.BaseUnit).DefaultIfEmpty(AreaMomentOfInertia.BaseUnit).FirstOrDefault(); var quantity = AreaMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -768,9 +761,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -804,41 +796,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -851,25 +838,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = AreaMomentOfInertia.FromMetersToTheFourth(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -911,7 +895,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = AreaMomentOfInertia.FromMetersToTheFourth(1.0); - Assert.Equal(AreaMomentOfInertia.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {AreaMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 5d06c6612e..39bffa73de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class AreaTestsBase : QuantityTestsBase protected abstract double UsSurveySquareFeetInOneSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AcresTolerance { get { return 1E-5; } } - protected virtual double HectaresTolerance { get { return 1E-5; } } - protected virtual double SquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double SquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double SquareFeetTolerance { get { return 1E-5; } } - protected virtual double SquareInchesTolerance { get { return 1E-5; } } - protected virtual double SquareKilometersTolerance { get { return 1E-5; } } - protected virtual double SquareMetersTolerance { get { return 1E-5; } } - protected virtual double SquareMicrometersTolerance { get { return 1E-5; } } - protected virtual double SquareMilesTolerance { get { return 1E-5; } } - protected virtual double SquareMillimetersTolerance { get { return 1E-5; } } - protected virtual double SquareNauticalMilesTolerance { get { return 1E-5; } } - protected virtual double SquareYardsTolerance { get { return 1E-5; } } - protected virtual double UsSurveySquareFeetTolerance { get { return 1E-5; } } + protected virtual double AcresTolerance { get { return 1e-5; } } + protected virtual double HectaresTolerance { get { return 1e-5; } } + protected virtual double SquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double SquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double SquareFeetTolerance { get { return 1e-5; } } + protected virtual double SquareInchesTolerance { get { return 1e-5; } } + protected virtual double SquareKilometersTolerance { get { return 1e-5; } } + protected virtual double SquareMetersTolerance { get { return 1e-5; } } + protected virtual double SquareMicrometersTolerance { get { return 1e-5; } } + protected virtual double SquareMilesTolerance { get { return 1e-5; } } + protected virtual double SquareMillimetersTolerance { get { return 1e-5; } } + protected virtual double SquareNauticalMilesTolerance { get { return 1e-5; } } + protected virtual double SquareYardsTolerance { get { return 1e-5; } } + protected virtual double UsSurveySquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(AreaUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1283,21 +1283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(AreaUnit unit) { - var inBaseUnit = Area.From(1.0, Area.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Area.From(1.0, Area.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Area.From(1.0, Area.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(AreaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(AreaUnit unit) @@ -1311,8 +1304,8 @@ public void ToUnit_WithSameUnits_AreEqual(AreaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(AreaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Area.Units.First(u => u != Area.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Area.Units.Where(u => u != Area.BaseUnit).DefaultIfEmpty(Area.BaseUnit).FirstOrDefault(); var quantity = Area.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1546,9 +1539,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1582,41 +1574,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1629,25 +1616,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Area.FromSquareMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Area.FromSquareMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1689,7 +1673,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Area.FromSquareMeters(1.0); - Assert.Equal(Area.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Area.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index 756eab3893..a26e942ea8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class BitRateTestsBase : QuantityTestsBase { - protected abstract decimal BitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal BytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal ExabitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal ExabytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal ExbibitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal ExbibytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal GibibitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal GibibytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal GigabitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal GigabytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal KibibitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal KibibytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal KilobitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal KilobytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal MebibitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal MebibytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal MegabitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal MegabytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal PebibitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal PebibytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal PetabitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal PetabytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal TebibitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal TebibytesPerSecondInOneBitPerSecond { get; } - protected abstract decimal TerabitsPerSecondInOneBitPerSecond { get; } - protected abstract decimal TerabytesPerSecondInOneBitPerSecond { get; } + protected abstract double BitsPerSecondInOneBitPerSecond { get; } + protected abstract double BytesPerSecondInOneBitPerSecond { get; } + protected abstract double ExabitsPerSecondInOneBitPerSecond { get; } + protected abstract double ExabytesPerSecondInOneBitPerSecond { get; } + protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; } + protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; } + protected abstract double GibibitsPerSecondInOneBitPerSecond { get; } + protected abstract double GibibytesPerSecondInOneBitPerSecond { get; } + protected abstract double GigabitsPerSecondInOneBitPerSecond { get; } + protected abstract double GigabytesPerSecondInOneBitPerSecond { get; } + protected abstract double KibibitsPerSecondInOneBitPerSecond { get; } + protected abstract double KibibytesPerSecondInOneBitPerSecond { get; } + protected abstract double KilobitsPerSecondInOneBitPerSecond { get; } + protected abstract double KilobytesPerSecondInOneBitPerSecond { get; } + protected abstract double MebibitsPerSecondInOneBitPerSecond { get; } + protected abstract double MebibytesPerSecondInOneBitPerSecond { get; } + protected abstract double MegabitsPerSecondInOneBitPerSecond { get; } + protected abstract double MegabytesPerSecondInOneBitPerSecond { get; } + protected abstract double PebibitsPerSecondInOneBitPerSecond { get; } + protected abstract double PebibytesPerSecondInOneBitPerSecond { get; } + protected abstract double PetabitsPerSecondInOneBitPerSecond { get; } + protected abstract double PetabytesPerSecondInOneBitPerSecond { get; } + protected abstract double TebibitsPerSecondInOneBitPerSecond { get; } + protected abstract double TebibytesPerSecondInOneBitPerSecond { get; } + protected abstract double TerabitsPerSecondInOneBitPerSecond { get; } + protected abstract double TerabytesPerSecondInOneBitPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual decimal BitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal BytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal ExabitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal ExabytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal ExbibitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal ExbibytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal GibibitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal GibibytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal GigabitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal GigabytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal KibibitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal KibibytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal KilobitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal KilobytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal MebibitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal MebibytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal MegabitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal MegabytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal PebibitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal PebibytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal PetabitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal PetabytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal TebibitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal TebibytesPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal TerabitsPerSecondTolerance { get { return 1E-9m; } } - protected virtual decimal TerabytesPerSecondTolerance { get { return 1E-9m; } } + protected virtual double BitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double BytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } } + protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } } + protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(BitRateUnit unit) + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BitRateUnit unit) { return unit switch { @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1352,21 +1352,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(BitRateUnit unit) { - var inBaseUnit = BitRate.From(1.0, BitRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = BitRate.From(1.0, BitRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = BitRate.From(1.0, BitRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(BitRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(BitRateUnit unit) @@ -1380,8 +1373,8 @@ public void ToUnit_WithSameUnits_AreEqual(BitRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(BitRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = BitRate.Units.First(u => u != BitRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = BitRate.Units.Where(u => u != BitRate.BaseUnit).DefaultIfEmpty(BitRate.BaseUnit).FirstOrDefault(); var quantity = BitRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1651,9 +1644,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1687,41 +1679,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1734,25 +1721,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BitRate.FromBitsPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = BitRate.FromBitsPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1794,7 +1778,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = BitRate.FromBitsPerSecond(1.0); - Assert.Equal(BitRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {BitRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 3a3de29b37..6e1bc6b653 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class BrakeSpecificFuelConsumptionTestsBase : QuantityTe protected abstract double PoundsPerMechanicalHorsepowerHourInOneKilogramPerJoule { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerKiloWattHourTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerJouleTolerance { get { return 1E-5; } } - protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1E-5; } } + protected virtual double GramsPerKiloWattHourTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerJouleTolerance { get { return 1e-5; } } + protected virtual double PoundsPerMechanicalHorsepowerHourTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BrakeSpecificFuelConsumptionUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(BrakeSpecificFuelConsumptionUnit unit) { - var inBaseUnit = BrakeSpecificFuelConsumption.From(1.0, BrakeSpecificFuelConsumption.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = BrakeSpecificFuelConsumption.From(1.0, BrakeSpecificFuelConsumption.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = BrakeSpecificFuelConsumption.From(1.0, BrakeSpecificFuelConsumption.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(BrakeSpecificFuelConsumptionUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(BrakeSpecificFuelConsumptionUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(BrakeSpecificFuelConsumptionUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(BrakeSpecificFuelConsumptionUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = BrakeSpecificFuelConsumption.Units.First(u => u != BrakeSpecificFuelConsumption.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = BrakeSpecificFuelConsumption.Units.Where(u => u != BrakeSpecificFuelConsumption.BaseUnit).DefaultIfEmpty(BrakeSpecificFuelConsumption.BaseUnit).FirstOrDefault(); var quantity = BrakeSpecificFuelConsumption.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = BrakeSpecificFuelConsumption.FromKilogramsPerJoule(1.0); - Assert.Equal(BrakeSpecificFuelConsumption.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {BrakeSpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index f3e59bbd3b..e6d03a76dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class CapacitanceTestsBase : QuantityTestsBase protected abstract double PicofaradsInOneFarad { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double FaradsTolerance { get { return 1E-5; } } - protected virtual double KilofaradsTolerance { get { return 1E-5; } } - protected virtual double MegafaradsTolerance { get { return 1E-5; } } - protected virtual double MicrofaradsTolerance { get { return 1E-5; } } - protected virtual double MillifaradsTolerance { get { return 1E-5; } } - protected virtual double NanofaradsTolerance { get { return 1E-5; } } - protected virtual double PicofaradsTolerance { get { return 1E-5; } } + protected virtual double FaradsTolerance { get { return 1e-5; } } + protected virtual double KilofaradsTolerance { get { return 1e-5; } } + protected virtual double MegafaradsTolerance { get { return 1e-5; } } + protected virtual double MicrofaradsTolerance { get { return 1e-5; } } + protected virtual double MillifaradsTolerance { get { return 1e-5; } } + protected virtual double NanofaradsTolerance { get { return 1e-5; } } + protected virtual double PicofaradsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(CapacitanceUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -397,21 +397,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(CapacitanceUnit unit) { - var inBaseUnit = Capacitance.From(1.0, Capacitance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Capacitance.From(1.0, Capacitance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Capacitance.From(1.0, Capacitance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(CapacitanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(CapacitanceUnit unit) @@ -425,8 +418,8 @@ public void ToUnit_WithSameUnits_AreEqual(CapacitanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CapacitanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Capacitance.Units.First(u => u != Capacitance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Capacitance.Units.Where(u => u != Capacitance.BaseUnit).DefaultIfEmpty(Capacitance.BaseUnit).FirstOrDefault(); var quantity = Capacitance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -639,9 +632,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -675,41 +667,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -722,25 +709,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Capacitance.FromFarads(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Capacitance.FromFarads(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -782,7 +766,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Capacitance.FromFarads(1.0); - Assert.Equal(Capacitance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Capacitance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 8cb26ee1e6..01b59f24d5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class CoefficientOfThermalExpansionTestsBase : QuantityT protected abstract double InverseKelvinInOneInverseKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double InverseDegreeFahrenheitTolerance { get { return 1E-5; } } - protected virtual double InverseKelvinTolerance { get { return 1E-5; } } + protected virtual double InverseDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double InverseDegreeFahrenheitTolerance { get { return 1e-5; } } + protected virtual double InverseKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(CoefficientOfThermalExpansionUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -355,21 +355,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(CoefficientOfThermalExpansionUnit unit) { - var inBaseUnit = CoefficientOfThermalExpansion.From(1.0, CoefficientOfThermalExpansion.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = CoefficientOfThermalExpansion.From(1.0, CoefficientOfThermalExpansion.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = CoefficientOfThermalExpansion.From(1.0, CoefficientOfThermalExpansion.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(CoefficientOfThermalExpansionUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(CoefficientOfThermalExpansionUnit unit) @@ -383,8 +376,8 @@ public void ToUnit_WithSameUnits_AreEqual(CoefficientOfThermalExpansionUnit unit [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CoefficientOfThermalExpansionUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = CoefficientOfThermalExpansion.Units.First(u => u != CoefficientOfThermalExpansion.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = CoefficientOfThermalExpansion.Units.Where(u => u != CoefficientOfThermalExpansion.BaseUnit).DefaultIfEmpty(CoefficientOfThermalExpansion.BaseUnit).FirstOrDefault(); var quantity = CoefficientOfThermalExpansion.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -585,9 +578,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -621,41 +613,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -668,25 +655,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -728,7 +712,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = CoefficientOfThermalExpansion.FromInverseKelvin(1.0); - Assert.Equal(CoefficientOfThermalExpansion.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {CoefficientOfThermalExpansion.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index 32d816d194..aaf1331202 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class CompressibilityTestsBase : QuantityTestsBase protected abstract double InversePoundsForcePerSquareInchInOneInversePascal { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseAtmospheresTolerance { get { return 1E-5; } } - protected virtual double InverseBarsTolerance { get { return 1E-5; } } - protected virtual double InverseKilopascalsTolerance { get { return 1E-5; } } - protected virtual double InverseMegapascalsTolerance { get { return 1E-5; } } - protected virtual double InverseMillibarsTolerance { get { return 1E-5; } } - protected virtual double InversePascalsTolerance { get { return 1E-5; } } - protected virtual double InversePoundsForcePerSquareInchTolerance { get { return 1E-5; } } + protected virtual double InverseAtmospheresTolerance { get { return 1e-5; } } + protected virtual double InverseBarsTolerance { get { return 1e-5; } } + protected virtual double InverseKilopascalsTolerance { get { return 1e-5; } } + protected virtual double InverseMegapascalsTolerance { get { return 1e-5; } } + protected virtual double InverseMillibarsTolerance { get { return 1e-5; } } + protected virtual double InversePascalsTolerance { get { return 1e-5; } } + protected virtual double InversePoundsForcePerSquareInchTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(CompressibilityUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -587,21 +587,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(CompressibilityUnit unit) { - var inBaseUnit = Compressibility.From(1.0, Compressibility.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Compressibility.From(1.0, Compressibility.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Compressibility.From(1.0, Compressibility.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(CompressibilityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(CompressibilityUnit unit) @@ -615,8 +608,8 @@ public void ToUnit_WithSameUnits_AreEqual(CompressibilityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(CompressibilityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Compressibility.Units.First(u => u != Compressibility.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Compressibility.Units.Where(u => u != Compressibility.BaseUnit).DefaultIfEmpty(Compressibility.BaseUnit).FirstOrDefault(); var quantity = Compressibility.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -829,9 +822,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -865,41 +857,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -912,25 +899,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Compressibility.FromInversePascals(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Compressibility.FromInversePascals(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -972,7 +956,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Compressibility.FromInversePascals(1.0); - Assert.Equal(Compressibility.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Compressibility.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index 4533308beb..a37f498d85 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -91,57 +91,57 @@ public abstract partial class DensityTestsBase : QuantityTestsBase protected abstract double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double GramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double GramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double KilopoundsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double KilopoundsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerDeciLiterTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double PoundsPerImperialGallonTolerance { get { return 1E-5; } } - protected virtual double PoundsPerUSGallonTolerance { get { return 1E-5; } } - protected virtual double SlugsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double SlugsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double SlugsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double SlugsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double SlugsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double GramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double GramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double KilopoundsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double KilopoundsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerDeciLiterTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerImperialGallonTolerance { get { return 1e-5; } } + protected virtual double PoundsPerUSGallonTolerance { get { return 1e-5; } } + protected virtual double SlugsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double SlugsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double SlugsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double SlugsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double SlugsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(DensityUnit unit) @@ -658,7 +658,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2011,21 +2011,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(DensityUnit unit) { - var inBaseUnit = Density.From(1.0, Density.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Density.From(1.0, Density.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Density.From(1.0, Density.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(DensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(DensityUnit unit) @@ -2039,8 +2032,8 @@ public void ToUnit_WithSameUnits_AreEqual(DensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Density.Units.First(u => u != Density.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Density.Units.Where(u => u != Density.BaseUnit).DefaultIfEmpty(Density.BaseUnit).FirstOrDefault(); var quantity = Density.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2385,9 +2378,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2421,41 +2413,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2468,25 +2455,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Density.FromKilogramsPerCubicMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Density.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2528,7 +2512,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Density.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(Density.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Density.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 3868ee2b75..528fb07f8f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class DurationTestsBase : QuantityTestsBase protected abstract double Years365InOneSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DaysTolerance { get { return 1E-5; } } - protected virtual double HoursTolerance { get { return 1E-5; } } - protected virtual double JulianYearsTolerance { get { return 1E-5; } } - protected virtual double MicrosecondsTolerance { get { return 1E-5; } } - protected virtual double MillisecondsTolerance { get { return 1E-5; } } - protected virtual double MinutesTolerance { get { return 1E-5; } } - protected virtual double Months30Tolerance { get { return 1E-5; } } - protected virtual double NanosecondsTolerance { get { return 1E-5; } } - protected virtual double SecondsTolerance { get { return 1E-5; } } - protected virtual double WeeksTolerance { get { return 1E-5; } } - protected virtual double Years365Tolerance { get { return 1E-5; } } + protected virtual double DaysTolerance { get { return 1e-5; } } + protected virtual double HoursTolerance { get { return 1e-5; } } + protected virtual double JulianYearsTolerance { get { return 1e-5; } } + protected virtual double MicrosecondsTolerance { get { return 1e-5; } } + protected virtual double MillisecondsTolerance { get { return 1e-5; } } + protected virtual double MinutesTolerance { get { return 1e-5; } } + protected virtual double Months30Tolerance { get { return 1e-5; } } + protected virtual double NanosecondsTolerance { get { return 1e-5; } } + protected virtual double SecondsTolerance { get { return 1e-5; } } + protected virtual double WeeksTolerance { get { return 1e-5; } } + protected virtual double Years365Tolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(DurationUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1731,21 +1731,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(DurationUnit unit) { - var inBaseUnit = Duration.From(1.0, Duration.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Duration.From(1.0, Duration.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Duration.From(1.0, Duration.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(DurationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(DurationUnit unit) @@ -1759,8 +1752,8 @@ public void ToUnit_WithSameUnits_AreEqual(DurationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DurationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Duration.Units.First(u => u != Duration.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Duration.Units.Where(u => u != Duration.BaseUnit).DefaultIfEmpty(Duration.BaseUnit).FirstOrDefault(); var quantity = Duration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1985,9 +1978,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2021,41 +2013,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2068,25 +2055,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Duration.FromSeconds(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Duration.FromSeconds(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2128,7 +2112,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Duration.FromSeconds(1.0); - Assert.Equal(Duration.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Duration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index 6cf20a34dc..ee6a1a3d95 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class DynamicViscosityTestsBase : QuantityTestsBase protected abstract double ReynsInOneNewtonSecondPerMeterSquared { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentipoiseTolerance { get { return 1E-5; } } - protected virtual double MicropascalSecondsTolerance { get { return 1E-5; } } - protected virtual double MillipascalSecondsTolerance { get { return 1E-5; } } - protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1E-5; } } - protected virtual double PascalSecondsTolerance { get { return 1E-5; } } - protected virtual double PoiseTolerance { get { return 1E-5; } } - protected virtual double PoundsForceSecondPerSquareFootTolerance { get { return 1E-5; } } - protected virtual double PoundsForceSecondPerSquareInchTolerance { get { return 1E-5; } } - protected virtual double PoundsPerFootSecondTolerance { get { return 1E-5; } } - protected virtual double ReynsTolerance { get { return 1E-5; } } + protected virtual double CentipoiseTolerance { get { return 1e-5; } } + protected virtual double MicropascalSecondsTolerance { get { return 1e-5; } } + protected virtual double MillipascalSecondsTolerance { get { return 1e-5; } } + protected virtual double NewtonSecondsPerMeterSquaredTolerance { get { return 1e-5; } } + protected virtual double PascalSecondsTolerance { get { return 1e-5; } } + protected virtual double PoiseTolerance { get { return 1e-5; } } + protected virtual double PoundsForceSecondPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double PoundsForceSecondPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double PoundsPerFootSecondTolerance { get { return 1e-5; } } + protected virtual double ReynsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(DynamicViscosityUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -593,21 +593,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(DynamicViscosityUnit unit) { - var inBaseUnit = DynamicViscosity.From(1.0, DynamicViscosity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = DynamicViscosity.From(1.0, DynamicViscosity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = DynamicViscosity.From(1.0, DynamicViscosity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(DynamicViscosityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(DynamicViscosityUnit unit) @@ -621,8 +614,8 @@ public void ToUnit_WithSameUnits_AreEqual(DynamicViscosityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(DynamicViscosityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = DynamicViscosity.Units.First(u => u != DynamicViscosity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = DynamicViscosity.Units.Where(u => u != DynamicViscosity.BaseUnit).DefaultIfEmpty(DynamicViscosity.BaseUnit).FirstOrDefault(); var quantity = DynamicViscosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -844,9 +837,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -880,41 +872,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -927,25 +914,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -987,7 +971,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = DynamicViscosity.FromNewtonSecondsPerMeterSquared(1.0); - Assert.Equal(DynamicViscosity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {DynamicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index 13bcf04bc8..baf2955386 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ElectricAdmittanceTestsBase : QuantityTestsBase protected abstract double SiemensInOneSiemens { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double MicrosiemensTolerance { get { return 1E-5; } } - protected virtual double MillisiemensTolerance { get { return 1E-5; } } - protected virtual double NanosiemensTolerance { get { return 1E-5; } } - protected virtual double SiemensTolerance { get { return 1E-5; } } + protected virtual double MicrosiemensTolerance { get { return 1e-5; } } + protected virtual double MillisiemensTolerance { get { return 1e-5; } } + protected virtual double NanosiemensTolerance { get { return 1e-5; } } + protected virtual double SiemensTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricAdmittanceUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricAdmittanceUnit unit) { - var inBaseUnit = ElectricAdmittance.From(1.0, ElectricAdmittance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricAdmittance.From(1.0, ElectricAdmittance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricAdmittance.From(1.0, ElectricAdmittance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricAdmittanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricAdmittanceUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricAdmittanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricAdmittanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricAdmittance.Units.First(u => u != ElectricAdmittance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricAdmittance.Units.Where(u => u != ElectricAdmittance.BaseUnit).DefaultIfEmpty(ElectricAdmittance.BaseUnit).FirstOrDefault(); var quantity = ElectricAdmittance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricAdmittance.FromSiemens(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricAdmittance.FromSiemens(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricAdmittance.FromSiemens(1.0); - Assert.Equal(ElectricAdmittance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricAdmittance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index 97fc662ca0..e5f237ac25 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class ElectricChargeDensityTestsBase : QuantityTestsBase protected abstract double CoulombsPerCubicMeterInOneCoulombPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CoulombsPerCubicMeterTolerance { get { return 1E-5; } } + protected virtual double CoulombsPerCubicMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricChargeDensityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricChargeDensityUnit unit) { - var inBaseUnit = ElectricChargeDensity.From(1.0, ElectricChargeDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricChargeDensity.From(1.0, ElectricChargeDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricChargeDensity.From(1.0, ElectricChargeDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricChargeDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricChargeDensityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricChargeDensityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricChargeDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricChargeDensity.Units.First(u => u != ElectricChargeDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricChargeDensity.Units.Where(u => u != ElectricChargeDensity.BaseUnit).DefaultIfEmpty(ElectricChargeDensity.BaseUnit).FirstOrDefault(); var quantity = ElectricChargeDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricChargeDensity.FromCoulombsPerCubicMeter(1.0); - Assert.Equal(ElectricChargeDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index b1583f9a0e..ffd6b25293 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricChargeTestsBase : QuantityTestsBase protected abstract double MilliampereHoursInOneCoulomb { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmpereHoursTolerance { get { return 1E-5; } } - protected virtual double CoulombsTolerance { get { return 1E-5; } } - protected virtual double KiloampereHoursTolerance { get { return 1E-5; } } - protected virtual double MegaampereHoursTolerance { get { return 1E-5; } } - protected virtual double MilliampereHoursTolerance { get { return 1E-5; } } + protected virtual double AmpereHoursTolerance { get { return 1e-5; } } + protected virtual double CoulombsTolerance { get { return 1e-5; } } + protected virtual double KiloampereHoursTolerance { get { return 1e-5; } } + protected virtual double MegaampereHoursTolerance { get { return 1e-5; } } + protected virtual double MilliampereHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricChargeUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -403,21 +403,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricChargeUnit unit) { - var inBaseUnit = ElectricCharge.From(1.0, ElectricCharge.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricCharge.From(1.0, ElectricCharge.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricCharge.From(1.0, ElectricCharge.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricChargeUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricChargeUnit unit) @@ -431,8 +424,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricChargeUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricChargeUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricCharge.Units.First(u => u != ElectricCharge.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricCharge.Units.Where(u => u != ElectricCharge.BaseUnit).DefaultIfEmpty(ElectricCharge.BaseUnit).FirstOrDefault(); var quantity = ElectricCharge.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -639,9 +632,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -675,41 +667,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -722,25 +709,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCharge.FromCoulombs(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricCharge.FromCoulombs(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -782,7 +766,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCharge.FromCoulombs(1.0); - Assert.Equal(ElectricCharge.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricCharge.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index 45c97940ed..d7e199bded 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricConductanceTestsBase : QuantityTestsBase protected abstract double SiemensInOneSiemens { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double MicrosiemensTolerance { get { return 1E-5; } } - protected virtual double MillisiemensTolerance { get { return 1E-5; } } - protected virtual double SiemensTolerance { get { return 1E-5; } } + protected virtual double MicrosiemensTolerance { get { return 1e-5; } } + protected virtual double MillisiemensTolerance { get { return 1e-5; } } + protected virtual double SiemensTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricConductanceUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricConductanceUnit unit) { - var inBaseUnit = ElectricConductance.From(1.0, ElectricConductance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricConductance.From(1.0, ElectricConductance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricConductance.From(1.0, ElectricConductance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricConductanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricConductanceUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricConductanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricConductance.Units.First(u => u != ElectricConductance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricConductance.Units.Where(u => u != ElectricConductance.BaseUnit).DefaultIfEmpty(ElectricConductance.BaseUnit).FirstOrDefault(); var quantity = ElectricConductance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductance.FromSiemens(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricConductance.FromSiemens(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricConductance.FromSiemens(1.0); - Assert.Equal(ElectricConductance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricConductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 07497ee847..1819849908 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricConductivityTestsBase : QuantityTestsBase protected abstract double SiemensPerMeterInOneSiemensPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double SiemensPerFootTolerance { get { return 1E-5; } } - protected virtual double SiemensPerInchTolerance { get { return 1E-5; } } - protected virtual double SiemensPerMeterTolerance { get { return 1E-5; } } + protected virtual double SiemensPerFootTolerance { get { return 1e-5; } } + protected virtual double SiemensPerInchTolerance { get { return 1e-5; } } + protected virtual double SiemensPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricConductivityUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricConductivityUnit unit) { - var inBaseUnit = ElectricConductivity.From(1.0, ElectricConductivity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricConductivity.From(1.0, ElectricConductivity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricConductivity.From(1.0, ElectricConductivity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricConductivityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricConductivityUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricConductivityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricConductivityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricConductivity.Units.First(u => u != ElectricConductivity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricConductivity.Units.Where(u => u != ElectricConductivity.BaseUnit).DefaultIfEmpty(ElectricConductivity.BaseUnit).FirstOrDefault(); var quantity = ElectricConductivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricConductivity.FromSiemensPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricConductivity.FromSiemensPerMeter(1.0); - Assert.Equal(ElectricConductivity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 23c9af5e3b..8269cdcded 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricCurrentDensityTestsBase : QuantityTestsBas protected abstract double AmperesPerSquareMeterInOneAmperePerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesPerSquareFootTolerance { get { return 1E-5; } } - protected virtual double AmperesPerSquareInchTolerance { get { return 1E-5; } } - protected virtual double AmperesPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double AmperesPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double AmperesPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double AmperesPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricCurrentDensityUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricCurrentDensityUnit unit) { - var inBaseUnit = ElectricCurrentDensity.From(1.0, ElectricCurrentDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricCurrentDensity.From(1.0, ElectricCurrentDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricCurrentDensity.From(1.0, ElectricCurrentDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricCurrentDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentDensityUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricCurrentDensity.Units.First(u => u != ElectricCurrentDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricCurrentDensity.Units.Where(u => u != ElectricCurrentDensity.BaseUnit).DefaultIfEmpty(ElectricCurrentDensity.BaseUnit).FirstOrDefault(); var quantity = ElectricCurrentDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrentDensity.FromAmperesPerSquareMeter(1.0); - Assert.Equal(ElectricCurrentDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricCurrentDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index dacad49bc8..415f793b1c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ElectricCurrentGradientTestsBase : QuantityTestsBa protected abstract double AmperesPerSecondInOneAmperePerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesPerMicrosecondTolerance { get { return 1E-5; } } - protected virtual double AmperesPerMillisecondTolerance { get { return 1E-5; } } - protected virtual double AmperesPerNanosecondTolerance { get { return 1E-5; } } - protected virtual double AmperesPerSecondTolerance { get { return 1E-5; } } + protected virtual double AmperesPerMicrosecondTolerance { get { return 1e-5; } } + protected virtual double AmperesPerMillisecondTolerance { get { return 1e-5; } } + protected virtual double AmperesPerNanosecondTolerance { get { return 1e-5; } } + protected virtual double AmperesPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricCurrentGradientUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricCurrentGradientUnit unit) { - var inBaseUnit = ElectricCurrentGradient.From(1.0, ElectricCurrentGradient.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricCurrentGradient.From(1.0, ElectricCurrentGradient.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricCurrentGradient.From(1.0, ElectricCurrentGradient.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricCurrentGradientUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentGradientUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentGradientUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentGradientUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricCurrentGradient.Units.First(u => u != ElectricCurrentGradient.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricCurrentGradient.Units.Where(u => u != ElectricCurrentGradient.BaseUnit).DefaultIfEmpty(ElectricCurrentGradient.BaseUnit).FirstOrDefault(); var quantity = ElectricCurrentGradient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrentGradient.FromAmperesPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrentGradient.FromAmperesPerSecond(1.0); - Assert.Equal(ElectricCurrentGradient.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricCurrentGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 0c602d7e0f..14be5a3b96 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -48,14 +48,14 @@ public abstract partial class ElectricCurrentTestsBase : QuantityTestsBase protected abstract double PicoamperesInOneAmpere { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesTolerance { get { return 1E-5; } } - protected virtual double CentiamperesTolerance { get { return 1E-5; } } - protected virtual double KiloamperesTolerance { get { return 1E-5; } } - protected virtual double MegaamperesTolerance { get { return 1E-5; } } - protected virtual double MicroamperesTolerance { get { return 1E-5; } } - protected virtual double MilliamperesTolerance { get { return 1E-5; } } - protected virtual double NanoamperesTolerance { get { return 1E-5; } } - protected virtual double PicoamperesTolerance { get { return 1E-5; } } + protected virtual double AmperesTolerance { get { return 1e-5; } } + protected virtual double CentiamperesTolerance { get { return 1e-5; } } + protected virtual double KiloamperesTolerance { get { return 1e-5; } } + protected virtual double MegaamperesTolerance { get { return 1e-5; } } + protected virtual double MicroamperesTolerance { get { return 1e-5; } } + protected virtual double MilliamperesTolerance { get { return 1e-5; } } + protected virtual double NanoamperesTolerance { get { return 1e-5; } } + protected virtual double PicoamperesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricCurrentUnit unit) @@ -228,7 +228,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -431,21 +431,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricCurrentUnit unit) { - var inBaseUnit = ElectricCurrent.From(1.0, ElectricCurrent.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricCurrent.From(1.0, ElectricCurrent.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricCurrent.From(1.0, ElectricCurrent.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricCurrentUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentUnit unit) @@ -459,8 +452,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricCurrentUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricCurrentUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricCurrent.Units.First(u => u != ElectricCurrent.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricCurrent.Units.Where(u => u != ElectricCurrent.BaseUnit).DefaultIfEmpty(ElectricCurrent.BaseUnit).FirstOrDefault(); var quantity = ElectricCurrent.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -676,9 +669,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -712,41 +704,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -759,25 +746,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricCurrent.FromAmperes(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricCurrent.FromAmperes(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -819,7 +803,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricCurrent.FromAmperes(1.0); - Assert.Equal(ElectricCurrent.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricCurrent.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index 07ad008f4f..e75dc3285b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class ElectricFieldTestsBase : QuantityTestsBase protected abstract double VoltsPerMeterInOneVoltPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double VoltsPerMeterTolerance { get { return 1E-5; } } + protected virtual double VoltsPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricFieldUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricFieldUnit unit) { - var inBaseUnit = ElectricField.From(1.0, ElectricField.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricField.From(1.0, ElectricField.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricField.From(1.0, ElectricField.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricFieldUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricFieldUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricFieldUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricFieldUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricField.Units.First(u => u != ElectricField.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricField.Units.Where(u => u != ElectricField.BaseUnit).DefaultIfEmpty(ElectricField.BaseUnit).FirstOrDefault(); var quantity = ElectricField.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricField.FromVoltsPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricField.FromVoltsPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricField.FromVoltsPerMeter(1.0); - Assert.Equal(ElectricField.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index 1df0aaa724..b436a94c0d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ElectricInductanceTestsBase : QuantityTestsBase protected abstract double NanohenriesInOneHenry { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double HenriesTolerance { get { return 1E-5; } } - protected virtual double MicrohenriesTolerance { get { return 1E-5; } } - protected virtual double MillihenriesTolerance { get { return 1E-5; } } - protected virtual double NanohenriesTolerance { get { return 1E-5; } } + protected virtual double HenriesTolerance { get { return 1e-5; } } + protected virtual double MicrohenriesTolerance { get { return 1e-5; } } + protected virtual double MillihenriesTolerance { get { return 1e-5; } } + protected virtual double NanohenriesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricInductanceUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricInductanceUnit unit) { - var inBaseUnit = ElectricInductance.From(1.0, ElectricInductance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricInductance.From(1.0, ElectricInductance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricInductance.From(1.0, ElectricInductance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricInductanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricInductanceUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricInductanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricInductanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricInductance.Units.First(u => u != ElectricInductance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricInductance.Units.Where(u => u != ElectricInductance.BaseUnit).DefaultIfEmpty(ElectricInductance.BaseUnit).FirstOrDefault(); var quantity = ElectricInductance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricInductance.FromHenries(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricInductance.FromHenries(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricInductance.FromHenries(1.0); - Assert.Equal(ElectricInductance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricInductance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 18ff2da9ff..54413cf013 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricPotentialAcTestsBase : QuantityTestsBase protected abstract double VoltsAcInOneVoltAc { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsAcTolerance { get { return 1E-5; } } - protected virtual double MegavoltsAcTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsAcTolerance { get { return 1E-5; } } - protected virtual double MillivoltsAcTolerance { get { return 1E-5; } } - protected virtual double VoltsAcTolerance { get { return 1E-5; } } + protected virtual double KilovoltsAcTolerance { get { return 1e-5; } } + protected virtual double MegavoltsAcTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsAcTolerance { get { return 1e-5; } } + protected virtual double MillivoltsAcTolerance { get { return 1e-5; } } + protected virtual double VoltsAcTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialAcUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -329,21 +329,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialAcUnit unit) { - var inBaseUnit = ElectricPotentialAc.From(1.0, ElectricPotentialAc.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricPotentialAc.From(1.0, ElectricPotentialAc.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricPotentialAc.From(1.0, ElectricPotentialAc.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialAcUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialAcUnit unit) @@ -357,8 +350,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialAcUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialAcUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricPotentialAc.Units.First(u => u != ElectricPotentialAc.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricPotentialAc.Units.Where(u => u != ElectricPotentialAc.BaseUnit).DefaultIfEmpty(ElectricPotentialAc.BaseUnit).FirstOrDefault(); var quantity = ElectricPotentialAc.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -565,9 +558,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -601,41 +593,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -648,25 +635,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialAc.FromVoltsAc(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricPotentialAc.FromVoltsAc(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -708,7 +692,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialAc.FromVoltsAc(1.0); - Assert.Equal(ElectricPotentialAc.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricPotentialAc.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 90068daab5..11f38843a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -60,26 +60,26 @@ public abstract partial class ElectricPotentialChangeRateTestsBase : QuantityTes protected abstract double VoltsPerSecondsInOneVoltPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsPerHoursTolerance { get { return 1E-5; } } - protected virtual double KilovoltsPerMicrosecondsTolerance { get { return 1E-5; } } - protected virtual double KilovoltsPerMinutesTolerance { get { return 1E-5; } } - protected virtual double KilovoltsPerSecondsTolerance { get { return 1E-5; } } - protected virtual double MegavoltsPerHoursTolerance { get { return 1E-5; } } - protected virtual double MegavoltsPerMicrosecondsTolerance { get { return 1E-5; } } - protected virtual double MegavoltsPerMinutesTolerance { get { return 1E-5; } } - protected virtual double MegavoltsPerSecondsTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsPerHoursTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsPerMicrosecondsTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsPerMinutesTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsPerSecondsTolerance { get { return 1E-5; } } - protected virtual double MillivoltsPerHoursTolerance { get { return 1E-5; } } - protected virtual double MillivoltsPerMicrosecondsTolerance { get { return 1E-5; } } - protected virtual double MillivoltsPerMinutesTolerance { get { return 1E-5; } } - protected virtual double MillivoltsPerSecondsTolerance { get { return 1E-5; } } - protected virtual double VoltsPerHoursTolerance { get { return 1E-5; } } - protected virtual double VoltsPerMicrosecondsTolerance { get { return 1E-5; } } - protected virtual double VoltsPerMinutesTolerance { get { return 1E-5; } } - protected virtual double VoltsPerSecondsTolerance { get { return 1E-5; } } + protected virtual double KilovoltsPerHoursTolerance { get { return 1e-5; } } + protected virtual double KilovoltsPerMicrosecondsTolerance { get { return 1e-5; } } + protected virtual double KilovoltsPerMinutesTolerance { get { return 1e-5; } } + protected virtual double KilovoltsPerSecondsTolerance { get { return 1e-5; } } + protected virtual double MegavoltsPerHoursTolerance { get { return 1e-5; } } + protected virtual double MegavoltsPerMicrosecondsTolerance { get { return 1e-5; } } + protected virtual double MegavoltsPerMinutesTolerance { get { return 1e-5; } } + protected virtual double MegavoltsPerSecondsTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsPerHoursTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsPerMicrosecondsTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsPerMinutesTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsPerSecondsTolerance { get { return 1e-5; } } + protected virtual double MillivoltsPerHoursTolerance { get { return 1e-5; } } + protected virtual double MillivoltsPerMicrosecondsTolerance { get { return 1e-5; } } + protected virtual double MillivoltsPerMinutesTolerance { get { return 1e-5; } } + protected virtual double MillivoltsPerSecondsTolerance { get { return 1e-5; } } + protected virtual double VoltsPerHoursTolerance { get { return 1e-5; } } + protected virtual double VoltsPerMicrosecondsTolerance { get { return 1e-5; } } + protected virtual double VoltsPerMinutesTolerance { get { return 1e-5; } } + protected virtual double VoltsPerSecondsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialChangeRateUnit unit) @@ -348,7 +348,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -773,21 +773,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialChangeRateUnit unit) { - var inBaseUnit = ElectricPotentialChangeRate.From(1.0, ElectricPotentialChangeRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricPotentialChangeRate.From(1.0, ElectricPotentialChangeRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricPotentialChangeRate.From(1.0, ElectricPotentialChangeRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialChangeRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialChangeRateUnit unit) @@ -801,8 +794,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialChangeRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricPotentialChangeRate.Units.First(u => u != ElectricPotentialChangeRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricPotentialChangeRate.Units.Where(u => u != ElectricPotentialChangeRate.BaseUnit).DefaultIfEmpty(ElectricPotentialChangeRate.BaseUnit).FirstOrDefault(); var quantity = ElectricPotentialChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1054,9 +1047,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1090,41 +1082,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1137,25 +1124,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1197,7 +1181,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialChangeRate.FromVoltsPerSeconds(1.0); - Assert.Equal(ElectricPotentialChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricPotentialChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index f2b5dfedca..d7b84a15dc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricPotentialDcTestsBase : QuantityTestsBase protected abstract double VoltsDcInOneVoltDc { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsDcTolerance { get { return 1E-5; } } - protected virtual double MegavoltsDcTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsDcTolerance { get { return 1E-5; } } - protected virtual double MillivoltsDcTolerance { get { return 1E-5; } } - protected virtual double VoltsDcTolerance { get { return 1E-5; } } + protected virtual double KilovoltsDcTolerance { get { return 1e-5; } } + protected virtual double MegavoltsDcTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsDcTolerance { get { return 1e-5; } } + protected virtual double MillivoltsDcTolerance { get { return 1e-5; } } + protected virtual double VoltsDcTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialDcUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -329,21 +329,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialDcUnit unit) { - var inBaseUnit = ElectricPotentialDc.From(1.0, ElectricPotentialDc.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricPotentialDc.From(1.0, ElectricPotentialDc.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricPotentialDc.From(1.0, ElectricPotentialDc.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialDcUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialDcUnit unit) @@ -357,8 +350,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialDcUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialDcUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricPotentialDc.Units.First(u => u != ElectricPotentialDc.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricPotentialDc.Units.Where(u => u != ElectricPotentialDc.BaseUnit).DefaultIfEmpty(ElectricPotentialDc.BaseUnit).FirstOrDefault(); var quantity = ElectricPotentialDc.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -565,9 +558,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -601,41 +593,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -648,25 +635,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotentialDc.FromVoltsDc(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricPotentialDc.FromVoltsDc(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -708,7 +692,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotentialDc.FromVoltsDc(1.0); - Assert.Equal(ElectricPotentialDc.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricPotentialDc.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index c9ad5757af..85c888287a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class ElectricPotentialTestsBase : QuantityTestsBase protected abstract double VoltsInOneVolt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltsTolerance { get { return 1E-5; } } - protected virtual double MegavoltsTolerance { get { return 1E-5; } } - protected virtual double MicrovoltsTolerance { get { return 1E-5; } } - protected virtual double MillivoltsTolerance { get { return 1E-5; } } - protected virtual double VoltsTolerance { get { return 1E-5; } } + protected virtual double KilovoltsTolerance { get { return 1e-5; } } + protected virtual double MegavoltsTolerance { get { return 1e-5; } } + protected virtual double MicrovoltsTolerance { get { return 1e-5; } } + protected virtual double MillivoltsTolerance { get { return 1e-5; } } + protected virtual double VoltsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricPotentialUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -427,21 +427,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricPotentialUnit unit) { - var inBaseUnit = ElectricPotential.From(1.0, ElectricPotential.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricPotential.From(1.0, ElectricPotential.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricPotential.From(1.0, ElectricPotential.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricPotentialUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialUnit unit) @@ -455,8 +448,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricPotentialUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricPotentialUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricPotential.Units.First(u => u != ElectricPotential.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricPotential.Units.Where(u => u != ElectricPotential.BaseUnit).DefaultIfEmpty(ElectricPotential.BaseUnit).FirstOrDefault(); var quantity = ElectricPotential.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -663,9 +656,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -699,41 +691,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -746,25 +733,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricPotential.FromVolts(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricPotential.FromVolts(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -806,7 +790,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricPotential.FromVolts(1.0); - Assert.Equal(ElectricPotential.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricPotential.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index bb80d8cfb3..2f5ab2b600 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class ElectricResistanceTestsBase : QuantityTestsBase protected abstract double OhmsInOneOhm { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigaohmsTolerance { get { return 1E-5; } } - protected virtual double KiloohmsTolerance { get { return 1E-5; } } - protected virtual double MegaohmsTolerance { get { return 1E-5; } } - protected virtual double MicroohmsTolerance { get { return 1E-5; } } - protected virtual double MilliohmsTolerance { get { return 1E-5; } } - protected virtual double OhmsTolerance { get { return 1E-5; } } + protected virtual double GigaohmsTolerance { get { return 1e-5; } } + protected virtual double KiloohmsTolerance { get { return 1e-5; } } + protected virtual double MegaohmsTolerance { get { return 1e-5; } } + protected virtual double MicroohmsTolerance { get { return 1e-5; } } + protected virtual double MilliohmsTolerance { get { return 1e-5; } } + protected virtual double OhmsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricResistanceUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -363,21 +363,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricResistanceUnit unit) { - var inBaseUnit = ElectricResistance.From(1.0, ElectricResistance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricResistance.From(1.0, ElectricResistance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricResistance.From(1.0, ElectricResistance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricResistanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricResistanceUnit unit) @@ -391,8 +384,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricResistanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricResistanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricResistance.Units.First(u => u != ElectricResistance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricResistance.Units.Where(u => u != ElectricResistance.BaseUnit).DefaultIfEmpty(ElectricResistance.BaseUnit).FirstOrDefault(); var quantity = ElectricResistance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -602,9 +595,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -638,41 +630,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -685,25 +672,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistance.FromOhms(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricResistance.FromOhms(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -745,7 +729,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricResistance.FromOhms(1.0); - Assert.Equal(ElectricResistance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index e6c2c14fab..061188ed83 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class ElectricResistivityTestsBase : QuantityTestsBase protected abstract double PicoohmMetersInOneOhmMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KiloohmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double KiloohmMetersTolerance { get { return 1E-5; } } - protected virtual double MegaohmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double MegaohmMetersTolerance { get { return 1E-5; } } - protected virtual double MicroohmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double MicroohmMetersTolerance { get { return 1E-5; } } - protected virtual double MilliohmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double MilliohmMetersTolerance { get { return 1E-5; } } - protected virtual double NanoohmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double NanoohmMetersTolerance { get { return 1E-5; } } - protected virtual double OhmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double OhmMetersTolerance { get { return 1E-5; } } - protected virtual double PicoohmsCentimeterTolerance { get { return 1E-5; } } - protected virtual double PicoohmMetersTolerance { get { return 1E-5; } } + protected virtual double KiloohmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double KiloohmMetersTolerance { get { return 1e-5; } } + protected virtual double MegaohmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double MegaohmMetersTolerance { get { return 1e-5; } } + protected virtual double MicroohmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double MicroohmMetersTolerance { get { return 1e-5; } } + protected virtual double MilliohmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double MilliohmMetersTolerance { get { return 1e-5; } } + protected virtual double NanoohmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double NanoohmMetersTolerance { get { return 1e-5; } } + protected virtual double OhmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double OhmMetersTolerance { get { return 1e-5; } } + protected virtual double PicoohmsCentimeterTolerance { get { return 1e-5; } } + protected virtual double PicoohmMetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricResistivityUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -613,21 +613,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricResistivityUnit unit) { - var inBaseUnit = ElectricResistivity.From(1.0, ElectricResistivity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricResistivity.From(1.0, ElectricResistivity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricResistivity.From(1.0, ElectricResistivity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricResistivityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricResistivityUnit unit) @@ -641,8 +634,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricResistivityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricResistivityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricResistivity.Units.First(u => u != ElectricResistivity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricResistivity.Units.Where(u => u != ElectricResistivity.BaseUnit).DefaultIfEmpty(ElectricResistivity.BaseUnit).FirstOrDefault(); var quantity = ElectricResistivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -876,9 +869,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -912,41 +904,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -959,25 +946,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricResistivity.FromOhmMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricResistivity.FromOhmMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1019,7 +1003,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricResistivity.FromOhmMeters(1.0); - Assert.Equal(ElectricResistivity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricResistivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index ffd7ee2f84..50650f67de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ElectricSurfaceChargeDensityTestsBase : QuantityTe protected abstract double CoulombsPerSquareMeterInOneCoulombPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CoulombsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double CoulombsPerSquareInchTolerance { get { return 1E-5; } } - protected virtual double CoulombsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double CoulombsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double CoulombsPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double CoulombsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ElectricSurfaceChargeDensityUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ElectricSurfaceChargeDensityUnit unit) { - var inBaseUnit = ElectricSurfaceChargeDensity.From(1.0, ElectricSurfaceChargeDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ElectricSurfaceChargeDensity.From(1.0, ElectricSurfaceChargeDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ElectricSurfaceChargeDensity.From(1.0, ElectricSurfaceChargeDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ElectricSurfaceChargeDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ElectricSurfaceChargeDensityUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(ElectricSurfaceChargeDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ElectricSurfaceChargeDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ElectricSurfaceChargeDensity.Units.First(u => u != ElectricSurfaceChargeDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ElectricSurfaceChargeDensity.Units.Where(u => u != ElectricSurfaceChargeDensity.BaseUnit).DefaultIfEmpty(ElectricSurfaceChargeDensity.BaseUnit).FirstOrDefault(); var quantity = ElectricSurfaceChargeDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ElectricSurfaceChargeDensity.FromCoulombsPerSquareMeter(1.0); - Assert.Equal(ElectricSurfaceChargeDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ElectricSurfaceChargeDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 37c8e3730f..22b563d859 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -76,42 +76,42 @@ public abstract partial class EnergyTestsBase : QuantityTestsBase protected abstract double WattHoursInOneJoule { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BritishThermalUnitsTolerance { get { return 1E-5; } } - protected virtual double CaloriesTolerance { get { return 1E-5; } } - protected virtual double DecathermsEcTolerance { get { return 1E-5; } } - protected virtual double DecathermsImperialTolerance { get { return 1E-5; } } - protected virtual double DecathermsUsTolerance { get { return 1E-5; } } - protected virtual double ElectronVoltsTolerance { get { return 1E-5; } } - protected virtual double ErgsTolerance { get { return 1E-5; } } - protected virtual double FootPoundsTolerance { get { return 1E-5; } } - protected virtual double GigabritishThermalUnitsTolerance { get { return 1E-5; } } - protected virtual double GigaelectronVoltsTolerance { get { return 1E-5; } } - protected virtual double GigajoulesTolerance { get { return 1E-5; } } - protected virtual double GigawattDaysTolerance { get { return 1E-5; } } - protected virtual double GigawattHoursTolerance { get { return 1E-5; } } - protected virtual double HorsepowerHoursTolerance { get { return 1E-5; } } - protected virtual double JoulesTolerance { get { return 1E-5; } } - protected virtual double KilobritishThermalUnitsTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesTolerance { get { return 1E-5; } } - protected virtual double KiloelectronVoltsTolerance { get { return 1E-5; } } - protected virtual double KilojoulesTolerance { get { return 1E-5; } } - protected virtual double KilowattDaysTolerance { get { return 1E-5; } } - protected virtual double KilowattHoursTolerance { get { return 1E-5; } } - protected virtual double MegabritishThermalUnitsTolerance { get { return 1E-5; } } - protected virtual double MegacaloriesTolerance { get { return 1E-5; } } - protected virtual double MegaelectronVoltsTolerance { get { return 1E-5; } } - protected virtual double MegajoulesTolerance { get { return 1E-5; } } - protected virtual double MegawattDaysTolerance { get { return 1E-5; } } - protected virtual double MegawattHoursTolerance { get { return 1E-5; } } - protected virtual double MillijoulesTolerance { get { return 1E-5; } } - protected virtual double TeraelectronVoltsTolerance { get { return 1E-5; } } - protected virtual double TerawattDaysTolerance { get { return 1E-5; } } - protected virtual double TerawattHoursTolerance { get { return 1E-5; } } - protected virtual double ThermsEcTolerance { get { return 1E-5; } } - protected virtual double ThermsImperialTolerance { get { return 1E-5; } } - protected virtual double ThermsUsTolerance { get { return 1E-5; } } - protected virtual double WattDaysTolerance { get { return 1E-5; } } - protected virtual double WattHoursTolerance { get { return 1E-5; } } + protected virtual double BritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double CaloriesTolerance { get { return 1e-5; } } + protected virtual double DecathermsEcTolerance { get { return 1e-5; } } + protected virtual double DecathermsImperialTolerance { get { return 1e-5; } } + protected virtual double DecathermsUsTolerance { get { return 1e-5; } } + protected virtual double ElectronVoltsTolerance { get { return 1e-5; } } + protected virtual double ErgsTolerance { get { return 1e-5; } } + protected virtual double FootPoundsTolerance { get { return 1e-5; } } + protected virtual double GigabritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double GigaelectronVoltsTolerance { get { return 1e-5; } } + protected virtual double GigajoulesTolerance { get { return 1e-5; } } + protected virtual double GigawattDaysTolerance { get { return 1e-5; } } + protected virtual double GigawattHoursTolerance { get { return 1e-5; } } + protected virtual double HorsepowerHoursTolerance { get { return 1e-5; } } + protected virtual double JoulesTolerance { get { return 1e-5; } } + protected virtual double KilobritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesTolerance { get { return 1e-5; } } + protected virtual double KiloelectronVoltsTolerance { get { return 1e-5; } } + protected virtual double KilojoulesTolerance { get { return 1e-5; } } + protected virtual double KilowattDaysTolerance { get { return 1e-5; } } + protected virtual double KilowattHoursTolerance { get { return 1e-5; } } + protected virtual double MegabritishThermalUnitsTolerance { get { return 1e-5; } } + protected virtual double MegacaloriesTolerance { get { return 1e-5; } } + protected virtual double MegaelectronVoltsTolerance { get { return 1e-5; } } + protected virtual double MegajoulesTolerance { get { return 1e-5; } } + protected virtual double MegawattDaysTolerance { get { return 1e-5; } } + protected virtual double MegawattHoursTolerance { get { return 1e-5; } } + protected virtual double MillijoulesTolerance { get { return 1e-5; } } + protected virtual double TeraelectronVoltsTolerance { get { return 1e-5; } } + protected virtual double TerawattDaysTolerance { get { return 1e-5; } } + protected virtual double TerawattHoursTolerance { get { return 1e-5; } } + protected virtual double ThermsEcTolerance { get { return 1e-5; } } + protected virtual double ThermsImperialTolerance { get { return 1e-5; } } + protected virtual double ThermsUsTolerance { get { return 1e-5; } } + protected virtual double WattDaysTolerance { get { return 1e-5; } } + protected virtual double WattHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(EnergyUnit unit) @@ -508,7 +508,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1887,21 +1887,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(EnergyUnit unit) { - var inBaseUnit = Energy.From(1.0, Energy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Energy.From(1.0, Energy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Energy.From(1.0, Energy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(EnergyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(EnergyUnit unit) @@ -1915,8 +1908,8 @@ public void ToUnit_WithSameUnits_AreEqual(EnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(EnergyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Energy.Units.First(u => u != Energy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Energy.Units.Where(u => u != Energy.BaseUnit).DefaultIfEmpty(Energy.BaseUnit).FirstOrDefault(); var quantity = Energy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2216,9 +2209,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2252,41 +2244,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2299,25 +2286,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Energy.FromJoules(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Energy.FromJoules(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2359,7 +2343,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Energy.FromJoules(1.0); - Assert.Equal(Energy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Energy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index acfce61703..06ae0fd4e5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class EntropyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerKelvinInOneJoulePerKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CaloriesPerKelvinTolerance { get { return 1E-5; } } - protected virtual double JoulesPerDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double JoulesPerKelvinTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesPerKelvinTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerKelvinTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerKelvinTolerance { get { return 1E-5; } } + protected virtual double CaloriesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double JoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(EntropyUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -419,21 +419,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(EntropyUnit unit) { - var inBaseUnit = Entropy.From(1.0, Entropy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Entropy.From(1.0, Entropy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Entropy.From(1.0, Entropy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(EntropyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(EntropyUnit unit) @@ -447,8 +440,8 @@ public void ToUnit_WithSameUnits_AreEqual(EntropyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(EntropyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Entropy.Units.First(u => u != Entropy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Entropy.Units.Where(u => u != Entropy.BaseUnit).DefaultIfEmpty(Entropy.BaseUnit).FirstOrDefault(); var quantity = Entropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -661,9 +654,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -697,41 +689,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -744,25 +731,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Entropy.FromJoulesPerKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Entropy.FromJoulesPerKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -804,7 +788,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Entropy.FromJoulesPerKelvin(1.0); - Assert.Equal(Entropy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Entropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index e0e2d9473f..6e46e12a28 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -55,21 +55,21 @@ public abstract partial class ForceChangeRateTestsBase : QuantityTestsBase protected abstract double PoundsForcePerSecondInOneNewtonPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentinewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecanewtonsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double DecanewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecinewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerMinuteTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerSecondTolerance { get { return 1E-5; } } - protected virtual double MicronewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MillinewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanonewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerMinuteTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerSecondTolerance { get { return 1E-5; } } + protected virtual double CentinewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecanewtonsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double DecanewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecinewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerSecondTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanonewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerMinuteTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ForceChangeRateUnit unit) @@ -298,7 +298,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -787,21 +787,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ForceChangeRateUnit unit) { - var inBaseUnit = ForceChangeRate.From(1.0, ForceChangeRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ForceChangeRate.From(1.0, ForceChangeRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ForceChangeRate.From(1.0, ForceChangeRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ForceChangeRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ForceChangeRateUnit unit) @@ -815,8 +808,8 @@ public void ToUnit_WithSameUnits_AreEqual(ForceChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForceChangeRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ForceChangeRate.Units.First(u => u != ForceChangeRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ForceChangeRate.Units.Where(u => u != ForceChangeRate.BaseUnit).DefaultIfEmpty(ForceChangeRate.BaseUnit).FirstOrDefault(); var quantity = ForceChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1053,9 +1046,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1089,41 +1081,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1136,25 +1123,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForceChangeRate.FromNewtonsPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1196,7 +1180,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ForceChangeRate.FromNewtonsPerSecond(1.0); - Assert.Equal(ForceChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ForceChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index 2b2a3554ad..c9979db3cf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -78,44 +78,44 @@ public abstract partial class ForcePerLengthTestsBase : QuantityTestsBase protected abstract double TonnesForcePerMillimeterInOneNewtonPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentinewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double CentinewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double CentinewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double DecanewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double DecanewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double DecanewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double DecinewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double DecinewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double DecinewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerFootTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerInchTolerance { get { return 1E-5; } } - protected virtual double MeganewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MeganewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MeganewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double MicronewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MicronewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MicronewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double MillinewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MillinewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MillinewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double NanonewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double NanonewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double NanonewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerFootTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerInchTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerYardTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerCentimeterTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerMeterTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerMillimeterTolerance { get { return 1E-5; } } + protected virtual double CentinewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double CentinewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double CentinewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double DecanewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double DecanewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double DecanewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double DecinewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double DecinewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double DecinewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerFootTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerInchTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double NanonewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double NanonewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double NanonewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerFootTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerInchTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerYardTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerCentimeterTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerMeterTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ForcePerLengthUnit unit) @@ -528,7 +528,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1647,21 +1647,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ForcePerLengthUnit unit) { - var inBaseUnit = ForcePerLength.From(1.0, ForcePerLength.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ForcePerLength.From(1.0, ForcePerLength.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ForcePerLength.From(1.0, ForcePerLength.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ForcePerLengthUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ForcePerLengthUnit unit) @@ -1675,8 +1668,8 @@ public void ToUnit_WithSameUnits_AreEqual(ForcePerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForcePerLengthUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ForcePerLength.Units.First(u => u != ForcePerLength.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ForcePerLength.Units.Where(u => u != ForcePerLength.BaseUnit).DefaultIfEmpty(ForcePerLength.BaseUnit).FirstOrDefault(); var quantity = ForcePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1982,9 +1975,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2018,41 +2010,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2065,25 +2052,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ForcePerLength.FromNewtonsPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2125,7 +2109,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ForcePerLength.FromNewtonsPerMeter(1.0); - Assert.Equal(ForcePerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ForcePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index cd8251764d..28a015c7a7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -55,21 +55,21 @@ public abstract partial class ForceTestsBase : QuantityTestsBase protected abstract double TonnesForceInOneNewton { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecanewtonsTolerance { get { return 1E-5; } } - protected virtual double DyneTolerance { get { return 1E-5; } } - protected virtual double KilogramsForceTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsTolerance { get { return 1E-5; } } - protected virtual double KiloPondsTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForceTolerance { get { return 1E-5; } } - protected virtual double MeganewtonsTolerance { get { return 1E-5; } } - protected virtual double MicronewtonsTolerance { get { return 1E-5; } } - protected virtual double MillinewtonsTolerance { get { return 1E-5; } } - protected virtual double NewtonsTolerance { get { return 1E-5; } } - protected virtual double OunceForceTolerance { get { return 1E-5; } } - protected virtual double PoundalsTolerance { get { return 1E-5; } } - protected virtual double PoundsForceTolerance { get { return 1E-5; } } - protected virtual double ShortTonsForceTolerance { get { return 1E-5; } } - protected virtual double TonnesForceTolerance { get { return 1E-5; } } + protected virtual double DecanewtonsTolerance { get { return 1e-5; } } + protected virtual double DyneTolerance { get { return 1e-5; } } + protected virtual double KilogramsForceTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsTolerance { get { return 1e-5; } } + protected virtual double KiloPondsTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForceTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsTolerance { get { return 1e-5; } } + protected virtual double MicronewtonsTolerance { get { return 1e-5; } } + protected virtual double MillinewtonsTolerance { get { return 1e-5; } } + protected virtual double NewtonsTolerance { get { return 1e-5; } } + protected virtual double OunceForceTolerance { get { return 1e-5; } } + protected virtual double PoundalsTolerance { get { return 1e-5; } } + protected virtual double PoundsForceTolerance { get { return 1e-5; } } + protected virtual double ShortTonsForceTolerance { get { return 1e-5; } } + protected virtual double TonnesForceTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ForceUnit unit) @@ -298,7 +298,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1105,21 +1105,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ForceUnit unit) { - var inBaseUnit = Force.From(1.0, Force.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Force.From(1.0, Force.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Force.From(1.0, Force.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ForceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ForceUnit unit) @@ -1133,8 +1126,8 @@ public void ToUnit_WithSameUnits_AreEqual(ForceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ForceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Force.Units.First(u => u != Force.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Force.Units.Where(u => u != Force.BaseUnit).DefaultIfEmpty(Force.BaseUnit).FirstOrDefault(); var quantity = Force.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1371,9 +1364,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1407,41 +1399,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1454,25 +1441,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Force.FromNewtons(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Force.FromNewtons(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1514,7 +1498,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Force.FromNewtons(1.0); - Assert.Equal(Force.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Force.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 1cd5ef04d7..6235036d30 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class FrequencyTestsBase : QuantityTestsBase protected abstract double TerahertzInOneHertz { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BeatsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double BUnitsTolerance { get { return 1E-5; } } - protected virtual double CyclesPerHourTolerance { get { return 1E-5; } } - protected virtual double CyclesPerMinuteTolerance { get { return 1E-5; } } - protected virtual double GigahertzTolerance { get { return 1E-5; } } - protected virtual double HertzTolerance { get { return 1E-5; } } - protected virtual double KilohertzTolerance { get { return 1E-5; } } - protected virtual double MegahertzTolerance { get { return 1E-5; } } - protected virtual double PerSecondTolerance { get { return 1E-5; } } - protected virtual double RadiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double TerahertzTolerance { get { return 1E-5; } } + protected virtual double BeatsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double BUnitsTolerance { get { return 1e-5; } } + protected virtual double CyclesPerHourTolerance { get { return 1e-5; } } + protected virtual double CyclesPerMinuteTolerance { get { return 1e-5; } } + protected virtual double GigahertzTolerance { get { return 1e-5; } } + protected virtual double HertzTolerance { get { return 1e-5; } } + protected virtual double KilohertzTolerance { get { return 1e-5; } } + protected virtual double MegahertzTolerance { get { return 1e-5; } } + protected virtual double PerSecondTolerance { get { return 1e-5; } } + protected virtual double RadiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double TerahertzTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(FrequencyUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -723,21 +723,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(FrequencyUnit unit) { - var inBaseUnit = Frequency.From(1.0, Frequency.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Frequency.From(1.0, Frequency.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Frequency.From(1.0, Frequency.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(FrequencyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(FrequencyUnit unit) @@ -751,8 +744,8 @@ public void ToUnit_WithSameUnits_AreEqual(FrequencyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FrequencyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Frequency.Units.First(u => u != Frequency.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Frequency.Units.Where(u => u != Frequency.BaseUnit).DefaultIfEmpty(Frequency.BaseUnit).FirstOrDefault(); var quantity = Frequency.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -977,9 +970,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1013,41 +1005,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1060,25 +1047,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Frequency.FromHertz(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Frequency.FromHertz(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1120,7 +1104,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Frequency.FromHertz(1.0); - Assert.Equal(Frequency.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Frequency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 188d454a36..267c73802f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class FuelEfficiencyTestsBase : QuantityTestsBase protected abstract double MilesPerUsGallonInOneLiterPer100Kilometers { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilometersPerLitersTolerance { get { return 1E-5; } } - protected virtual double LitersPer100KilometersTolerance { get { return 1E-5; } } - protected virtual double MilesPerUkGallonTolerance { get { return 1E-5; } } - protected virtual double MilesPerUsGallonTolerance { get { return 1E-5; } } + protected virtual double KilometersPerLitersTolerance { get { return 1e-5; } } + protected virtual double LitersPer100KilometersTolerance { get { return 1e-5; } } + protected virtual double MilesPerUkGallonTolerance { get { return 1e-5; } } + protected virtual double MilesPerUsGallonTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(FuelEfficiencyUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(FuelEfficiencyUnit unit) { - var inBaseUnit = FuelEfficiency.From(1.0, FuelEfficiency.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = FuelEfficiency.From(1.0, FuelEfficiency.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = FuelEfficiency.From(1.0, FuelEfficiency.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(FuelEfficiencyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(FuelEfficiencyUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(FuelEfficiencyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(FuelEfficiencyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = FuelEfficiency.Units.First(u => u != FuelEfficiency.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = FuelEfficiency.Units.Where(u => u != FuelEfficiency.BaseUnit).DefaultIfEmpty(FuelEfficiency.BaseUnit).FirstOrDefault(); var quantity = FuelEfficiency.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = FuelEfficiency.FromLitersPer100Kilometers(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = FuelEfficiency.FromLitersPer100Kilometers(1.0); - Assert.Equal(FuelEfficiency.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {FuelEfficiency.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index a4d2ec5d11..d894f51294 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -58,24 +58,24 @@ public abstract partial class HeatFluxTestsBase : QuantityTestsBase protected abstract double WattsPerSquareMeterInOneWattPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerHourSquareFootTolerance { get { return 1E-5; } } - protected virtual double BtusPerMinuteSquareFootTolerance { get { return 1E-5; } } - protected virtual double BtusPerSecondSquareFootTolerance { get { return 1E-5; } } - protected virtual double BtusPerSecondSquareInchTolerance { get { return 1E-5; } } - protected virtual double CaloriesPerSecondSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double CentiwattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double DeciwattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesPerHourSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesPerSecondSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerFootSecondTolerance { get { return 1E-5; } } - protected virtual double PoundsPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareFootTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareInchTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double BtusPerHourSquareFootTolerance { get { return 1e-5; } } + protected virtual double BtusPerMinuteSquareFootTolerance { get { return 1e-5; } } + protected virtual double BtusPerSecondSquareFootTolerance { get { return 1e-5; } } + protected virtual double BtusPerSecondSquareInchTolerance { get { return 1e-5; } } + protected virtual double CaloriesPerSecondSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double CentiwattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double DeciwattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerHourSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerSecondSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerFootSecondTolerance { get { return 1e-5; } } + protected virtual double PoundsPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareFootTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareInchTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(HeatFluxUnit unit) @@ -328,7 +328,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -817,21 +817,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(HeatFluxUnit unit) { - var inBaseUnit = HeatFlux.From(1.0, HeatFlux.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = HeatFlux.From(1.0, HeatFlux.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = HeatFlux.From(1.0, HeatFlux.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(HeatFluxUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(HeatFluxUnit unit) @@ -845,8 +838,8 @@ public void ToUnit_WithSameUnits_AreEqual(HeatFluxUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(HeatFluxUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = HeatFlux.Units.First(u => u != HeatFlux.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = HeatFlux.Units.Where(u => u != HeatFlux.BaseUnit).DefaultIfEmpty(HeatFlux.BaseUnit).FirstOrDefault(); var quantity = HeatFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1092,9 +1085,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1128,41 +1120,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1175,25 +1162,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatFlux.FromWattsPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1235,7 +1219,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = HeatFlux.FromWattsPerSquareMeter(1.0); - Assert.Equal(HeatFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {HeatFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 4c041ee287..0050e1ba0e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class HeatTransferCoefficientTestsBase : QuantityTestsBa protected abstract double WattsPerSquareMeterKelvinInOneWattPerSquareMeterKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerSquareFootDegreeFahrenheitTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareMeterCelsiusTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareMeterKelvinTolerance { get { return 1E-5; } } + protected virtual double BtusPerSquareFootDegreeFahrenheitTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareMeterCelsiusTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareMeterKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(HeatTransferCoefficientUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(HeatTransferCoefficientUnit unit) { - var inBaseUnit = HeatTransferCoefficient.From(1.0, HeatTransferCoefficient.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = HeatTransferCoefficient.From(1.0, HeatTransferCoefficient.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = HeatTransferCoefficient.From(1.0, HeatTransferCoefficient.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(HeatTransferCoefficientUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(HeatTransferCoefficientUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(HeatTransferCoefficientUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(HeatTransferCoefficientUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = HeatTransferCoefficient.Units.First(u => u != HeatTransferCoefficient.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = HeatTransferCoefficient.Units.Where(u => u != HeatTransferCoefficient.BaseUnit).DefaultIfEmpty(HeatTransferCoefficient.BaseUnit).FirstOrDefault(); var quantity = HeatTransferCoefficient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = HeatTransferCoefficient.FromWattsPerSquareMeterKelvin(1.0); - Assert.Equal(HeatTransferCoefficient.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {HeatTransferCoefficient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index 112256392c..d53ecaf4e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class IlluminanceTestsBase : QuantityTestsBase protected abstract double MilliluxInOneLux { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KiloluxTolerance { get { return 1E-5; } } - protected virtual double LuxTolerance { get { return 1E-5; } } - protected virtual double MegaluxTolerance { get { return 1E-5; } } - protected virtual double MilliluxTolerance { get { return 1E-5; } } + protected virtual double KiloluxTolerance { get { return 1e-5; } } + protected virtual double LuxTolerance { get { return 1e-5; } } + protected virtual double MegaluxTolerance { get { return 1e-5; } } + protected virtual double MilliluxTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(IlluminanceUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -295,21 +295,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(IlluminanceUnit unit) { - var inBaseUnit = Illuminance.From(1.0, Illuminance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Illuminance.From(1.0, Illuminance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Illuminance.From(1.0, Illuminance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(IlluminanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(IlluminanceUnit unit) @@ -323,8 +316,8 @@ public void ToUnit_WithSameUnits_AreEqual(IlluminanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IlluminanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Illuminance.Units.First(u => u != Illuminance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Illuminance.Units.Where(u => u != Illuminance.BaseUnit).DefaultIfEmpty(Illuminance.BaseUnit).FirstOrDefault(); var quantity = Illuminance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -528,9 +521,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -564,41 +556,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -611,25 +598,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Illuminance.FromLux(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Illuminance.FromLux(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -671,7 +655,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Illuminance.FromLux(1.0); - Assert.Equal(Illuminance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Illuminance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index 4224811b4b..f48c5b7434 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class InformationTestsBase : QuantityTestsBase { - protected abstract decimal BitsInOneBit { get; } - protected abstract decimal BytesInOneBit { get; } - protected abstract decimal ExabitsInOneBit { get; } - protected abstract decimal ExabytesInOneBit { get; } - protected abstract decimal ExbibitsInOneBit { get; } - protected abstract decimal ExbibytesInOneBit { get; } - protected abstract decimal GibibitsInOneBit { get; } - protected abstract decimal GibibytesInOneBit { get; } - protected abstract decimal GigabitsInOneBit { get; } - protected abstract decimal GigabytesInOneBit { get; } - protected abstract decimal KibibitsInOneBit { get; } - protected abstract decimal KibibytesInOneBit { get; } - protected abstract decimal KilobitsInOneBit { get; } - protected abstract decimal KilobytesInOneBit { get; } - protected abstract decimal MebibitsInOneBit { get; } - protected abstract decimal MebibytesInOneBit { get; } - protected abstract decimal MegabitsInOneBit { get; } - protected abstract decimal MegabytesInOneBit { get; } - protected abstract decimal PebibitsInOneBit { get; } - protected abstract decimal PebibytesInOneBit { get; } - protected abstract decimal PetabitsInOneBit { get; } - protected abstract decimal PetabytesInOneBit { get; } - protected abstract decimal TebibitsInOneBit { get; } - protected abstract decimal TebibytesInOneBit { get; } - protected abstract decimal TerabitsInOneBit { get; } - protected abstract decimal TerabytesInOneBit { get; } + protected abstract double BitsInOneBit { get; } + protected abstract double BytesInOneBit { get; } + protected abstract double ExabitsInOneBit { get; } + protected abstract double ExabytesInOneBit { get; } + protected abstract double ExbibitsInOneBit { get; } + protected abstract double ExbibytesInOneBit { get; } + protected abstract double GibibitsInOneBit { get; } + protected abstract double GibibytesInOneBit { get; } + protected abstract double GigabitsInOneBit { get; } + protected abstract double GigabytesInOneBit { get; } + protected abstract double KibibitsInOneBit { get; } + protected abstract double KibibytesInOneBit { get; } + protected abstract double KilobitsInOneBit { get; } + protected abstract double KilobytesInOneBit { get; } + protected abstract double MebibitsInOneBit { get; } + protected abstract double MebibytesInOneBit { get; } + protected abstract double MegabitsInOneBit { get; } + protected abstract double MegabytesInOneBit { get; } + protected abstract double PebibitsInOneBit { get; } + protected abstract double PebibytesInOneBit { get; } + protected abstract double PetabitsInOneBit { get; } + protected abstract double PetabytesInOneBit { get; } + protected abstract double TebibitsInOneBit { get; } + protected abstract double TebibytesInOneBit { get; } + protected abstract double TerabitsInOneBit { get; } + protected abstract double TerabytesInOneBit { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual decimal BitsTolerance { get { return 1E-9m; } } - protected virtual decimal BytesTolerance { get { return 1E-9m; } } - protected virtual decimal ExabitsTolerance { get { return 1E-9m; } } - protected virtual decimal ExabytesTolerance { get { return 1E-9m; } } - protected virtual decimal ExbibitsTolerance { get { return 1E-9m; } } - protected virtual decimal ExbibytesTolerance { get { return 1E-9m; } } - protected virtual decimal GibibitsTolerance { get { return 1E-9m; } } - protected virtual decimal GibibytesTolerance { get { return 1E-9m; } } - protected virtual decimal GigabitsTolerance { get { return 1E-9m; } } - protected virtual decimal GigabytesTolerance { get { return 1E-9m; } } - protected virtual decimal KibibitsTolerance { get { return 1E-9m; } } - protected virtual decimal KibibytesTolerance { get { return 1E-9m; } } - protected virtual decimal KilobitsTolerance { get { return 1E-9m; } } - protected virtual decimal KilobytesTolerance { get { return 1E-9m; } } - protected virtual decimal MebibitsTolerance { get { return 1E-9m; } } - protected virtual decimal MebibytesTolerance { get { return 1E-9m; } } - protected virtual decimal MegabitsTolerance { get { return 1E-9m; } } - protected virtual decimal MegabytesTolerance { get { return 1E-9m; } } - protected virtual decimal PebibitsTolerance { get { return 1E-9m; } } - protected virtual decimal PebibytesTolerance { get { return 1E-9m; } } - protected virtual decimal PetabitsTolerance { get { return 1E-9m; } } - protected virtual decimal PetabytesTolerance { get { return 1E-9m; } } - protected virtual decimal TebibitsTolerance { get { return 1E-9m; } } - protected virtual decimal TebibytesTolerance { get { return 1E-9m; } } - protected virtual decimal TerabitsTolerance { get { return 1E-9m; } } - protected virtual decimal TerabytesTolerance { get { return 1E-9m; } } + protected virtual double BitsTolerance { get { return 1e-5; } } + protected virtual double BytesTolerance { get { return 1e-5; } } + protected virtual double ExabitsTolerance { get { return 1e-5; } } + protected virtual double ExabytesTolerance { get { return 1e-5; } } + protected virtual double ExbibitsTolerance { get { return 1e-5; } } + protected virtual double ExbibytesTolerance { get { return 1e-5; } } + protected virtual double GibibitsTolerance { get { return 1e-5; } } + protected virtual double GibibytesTolerance { get { return 1e-5; } } + protected virtual double GigabitsTolerance { get { return 1e-5; } } + protected virtual double GigabytesTolerance { get { return 1e-5; } } + protected virtual double KibibitsTolerance { get { return 1e-5; } } + protected virtual double KibibytesTolerance { get { return 1e-5; } } + protected virtual double KilobitsTolerance { get { return 1e-5; } } + protected virtual double KilobytesTolerance { get { return 1e-5; } } + protected virtual double MebibitsTolerance { get { return 1e-5; } } + protected virtual double MebibytesTolerance { get { return 1e-5; } } + protected virtual double MegabitsTolerance { get { return 1e-5; } } + protected virtual double MegabytesTolerance { get { return 1e-5; } } + protected virtual double PebibitsTolerance { get { return 1e-5; } } + protected virtual double PebibytesTolerance { get { return 1e-5; } } + protected virtual double PetabitsTolerance { get { return 1e-5; } } + protected virtual double PetabytesTolerance { get { return 1e-5; } } + protected virtual double TebibitsTolerance { get { return 1e-5; } } + protected virtual double TebibytesTolerance { get { return 1e-5; } } + protected virtual double TerabitsTolerance { get { return 1e-5; } } + protected virtual double TerabytesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(InformationUnit unit) + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(InformationUnit unit) { return unit switch { @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -754,21 +754,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(InformationUnit unit) { - var inBaseUnit = Information.From(1.0, Information.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Information.From(1.0, Information.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Information.From(1.0, Information.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(InformationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(InformationUnit unit) @@ -782,8 +775,8 @@ public void ToUnit_WithSameUnits_AreEqual(InformationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(InformationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Information.Units.First(u => u != Information.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Information.Units.Where(u => u != Information.BaseUnit).DefaultIfEmpty(Information.BaseUnit).FirstOrDefault(); var quantity = Information.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1053,9 +1046,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1089,41 +1081,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1136,25 +1123,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Information.FromBits(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Information.FromBits(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1196,7 +1180,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Information.FromBits(1.0); - Assert.Equal(Information.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Information.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index 48f79afd6c..c0d10394f7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class IrradianceTestsBase : QuantityTestsBase protected abstract double WattsPerSquareMeterInOneWattPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilowattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double PicowattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double PicowattsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double WattsPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double KilowattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double PicowattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double PicowattsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double WattsPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(IrradianceUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -613,21 +613,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(IrradianceUnit unit) { - var inBaseUnit = Irradiance.From(1.0, Irradiance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Irradiance.From(1.0, Irradiance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Irradiance.From(1.0, Irradiance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(IrradianceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(IrradianceUnit unit) @@ -641,8 +634,8 @@ public void ToUnit_WithSameUnits_AreEqual(IrradianceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IrradianceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Irradiance.Units.First(u => u != Irradiance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Irradiance.Units.Where(u => u != Irradiance.BaseUnit).DefaultIfEmpty(Irradiance.BaseUnit).FirstOrDefault(); var quantity = Irradiance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -876,9 +869,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -912,41 +904,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -959,25 +946,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiance.FromWattsPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Irradiance.FromWattsPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1019,7 +1003,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Irradiance.FromWattsPerSquareMeter(1.0); - Assert.Equal(Irradiance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Irradiance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index 63fe8c16a7..db173e10e8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class IrradiationTestsBase : QuantityTestsBase protected abstract double WattHoursPerSquareMeterInOneJoulePerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double JoulesPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double JoulesPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double JoulesPerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilowattHoursPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MillijoulesPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double WattHoursPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double JoulesPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double JoulesPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double JoulesPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilowattHoursPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MillijoulesPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double WattHoursPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(IrradiationUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -419,21 +419,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(IrradiationUnit unit) { - var inBaseUnit = Irradiation.From(1.0, Irradiation.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Irradiation.From(1.0, Irradiation.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Irradiation.From(1.0, Irradiation.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(IrradiationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(IrradiationUnit unit) @@ -447,8 +440,8 @@ public void ToUnit_WithSameUnits_AreEqual(IrradiationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(IrradiationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Irradiation.Units.First(u => u != Irradiation.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Irradiation.Units.Where(u => u != Irradiation.BaseUnit).DefaultIfEmpty(Irradiation.BaseUnit).FirstOrDefault(); var quantity = Irradiation.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -661,9 +654,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -697,41 +689,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -744,25 +731,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Irradiation.FromJoulesPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -804,7 +788,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Irradiation.FromJoulesPerSquareMeter(1.0); - Assert.Equal(Irradiation.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Irradiation.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index d1d835449e..4b8961c1d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class JerkTestsBase : QuantityTestsBase protected abstract double StandardGravitiesPerSecondInOneMeterPerSecondCubed { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double DecimetersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double FeetPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double InchesPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double KilometersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double MetersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double MicrometersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double MillimetersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double MillistandardGravitiesPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanometersPerSecondCubedTolerance { get { return 1E-5; } } - protected virtual double StandardGravitiesPerSecondTolerance { get { return 1E-5; } } + protected virtual double CentimetersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double DecimetersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double FeetPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double InchesPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double KilometersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double MetersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double MicrometersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double MillimetersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double MillistandardGravitiesPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanometersPerSecondCubedTolerance { get { return 1e-5; } } + protected virtual double StandardGravitiesPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(JerkUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -819,21 +819,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(JerkUnit unit) { - var inBaseUnit = Jerk.From(1.0, Jerk.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Jerk.From(1.0, Jerk.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Jerk.From(1.0, Jerk.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(JerkUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(JerkUnit unit) @@ -847,8 +840,8 @@ public void ToUnit_WithSameUnits_AreEqual(JerkUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(JerkUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Jerk.Units.First(u => u != Jerk.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Jerk.Units.Where(u => u != Jerk.BaseUnit).DefaultIfEmpty(Jerk.BaseUnit).FirstOrDefault(); var quantity = Jerk.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1073,9 +1066,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1109,41 +1101,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1156,25 +1143,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Jerk.FromMetersPerSecondCubed(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Jerk.FromMetersPerSecondCubed(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1216,7 +1200,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Jerk.FromMetersPerSecondCubed(1.0); - Assert.Equal(Jerk.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Jerk.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index 113c50e125..aad81609de 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class KinematicViscosityTestsBase : QuantityTestsBase protected abstract double StokesInOneSquareMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentistokesTolerance { get { return 1E-5; } } - protected virtual double DecistokesTolerance { get { return 1E-5; } } - protected virtual double KilostokesTolerance { get { return 1E-5; } } - protected virtual double MicrostokesTolerance { get { return 1E-5; } } - protected virtual double MillistokesTolerance { get { return 1E-5; } } - protected virtual double NanostokesTolerance { get { return 1E-5; } } - protected virtual double SquareFeetPerSecondTolerance { get { return 1E-5; } } - protected virtual double SquareMetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double StokesTolerance { get { return 1E-5; } } + protected virtual double CentistokesTolerance { get { return 1e-5; } } + protected virtual double DecistokesTolerance { get { return 1e-5; } } + protected virtual double KilostokesTolerance { get { return 1e-5; } } + protected virtual double MicrostokesTolerance { get { return 1e-5; } } + protected virtual double MillistokesTolerance { get { return 1e-5; } } + protected virtual double NanostokesTolerance { get { return 1e-5; } } + protected virtual double SquareFeetPerSecondTolerance { get { return 1e-5; } } + protected virtual double SquareMetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double StokesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(KinematicViscosityUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -679,21 +679,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(KinematicViscosityUnit unit) { - var inBaseUnit = KinematicViscosity.From(1.0, KinematicViscosity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = KinematicViscosity.From(1.0, KinematicViscosity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = KinematicViscosity.From(1.0, KinematicViscosity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(KinematicViscosityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(KinematicViscosityUnit unit) @@ -707,8 +700,8 @@ public void ToUnit_WithSameUnits_AreEqual(KinematicViscosityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(KinematicViscosityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = KinematicViscosity.Units.First(u => u != KinematicViscosity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = KinematicViscosity.Units.Where(u => u != KinematicViscosity.BaseUnit).DefaultIfEmpty(KinematicViscosity.BaseUnit).FirstOrDefault(); var quantity = KinematicViscosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -927,9 +920,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -963,41 +955,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1010,25 +997,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = KinematicViscosity.FromSquareMetersPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1070,7 +1054,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = KinematicViscosity.FromSquareMetersPerSecond(1.0); - Assert.Equal(KinematicViscosity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {KinematicViscosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 6402bac337..840ff97042 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class LapseRateTestsBase : QuantityTestsBase protected abstract double DegreesCelciusPerKilometerInOneDegreeCelsiusPerKilometer { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1E-5; } } + protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LapseRateUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LapseRateUnit unit) { - var inBaseUnit = LapseRate.From(1.0, LapseRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = LapseRate.From(1.0, LapseRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = LapseRate.From(1.0, LapseRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LapseRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LapseRateUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(LapseRateUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LapseRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = LapseRate.Units.First(u => u != LapseRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = LapseRate.Units.Where(u => u != LapseRate.BaseUnit).DefaultIfEmpty(LapseRate.BaseUnit).FirstOrDefault(); var quantity = LapseRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LapseRate.FromDegreesCelciusPerKilometer(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LapseRate.FromDegreesCelciusPerKilometer(1.0); - Assert.Equal(LapseRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {LapseRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index cd116fb5be..b063af3c1d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -76,42 +76,42 @@ public abstract partial class LengthTestsBase : QuantityTestsBase protected abstract double YardsInOneMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AngstromsTolerance { get { return 1E-5; } } - protected virtual double AstronomicalUnitsTolerance { get { return 1E-5; } } - protected virtual double CentimetersTolerance { get { return 1E-5; } } - protected virtual double ChainsTolerance { get { return 1E-5; } } - protected virtual double DataMilesTolerance { get { return 1E-5; } } - protected virtual double DecametersTolerance { get { return 1E-5; } } - protected virtual double DecimetersTolerance { get { return 1E-5; } } - protected virtual double DtpPicasTolerance { get { return 1E-5; } } - protected virtual double DtpPointsTolerance { get { return 1E-5; } } - protected virtual double FathomsTolerance { get { return 1E-5; } } - protected virtual double FeetTolerance { get { return 1E-5; } } - protected virtual double HandsTolerance { get { return 1E-5; } } - protected virtual double HectometersTolerance { get { return 1E-5; } } - protected virtual double InchesTolerance { get { return 1E-5; } } - protected virtual double KilolightYearsTolerance { get { return 1E-5; } } - protected virtual double KilometersTolerance { get { return 1E-5; } } - protected virtual double KiloparsecsTolerance { get { return 1E-5; } } - protected virtual double LightYearsTolerance { get { return 1E-5; } } - protected virtual double MegalightYearsTolerance { get { return 1E-5; } } - protected virtual double MegaparsecsTolerance { get { return 1E-5; } } - protected virtual double MetersTolerance { get { return 1E-5; } } - protected virtual double MicroinchesTolerance { get { return 1E-5; } } - protected virtual double MicrometersTolerance { get { return 1E-5; } } - protected virtual double MilsTolerance { get { return 1E-5; } } - protected virtual double MilesTolerance { get { return 1E-5; } } - protected virtual double MillimetersTolerance { get { return 1E-5; } } - protected virtual double NanometersTolerance { get { return 1E-5; } } - protected virtual double NauticalMilesTolerance { get { return 1E-5; } } - protected virtual double ParsecsTolerance { get { return 1E-5; } } - protected virtual double PrinterPicasTolerance { get { return 1E-5; } } - protected virtual double PrinterPointsTolerance { get { return 1E-5; } } - protected virtual double ShacklesTolerance { get { return 1E-5; } } - protected virtual double SolarRadiusesTolerance { get { return 1E-5; } } - protected virtual double TwipsTolerance { get { return 1E-5; } } - protected virtual double UsSurveyFeetTolerance { get { return 1E-5; } } - protected virtual double YardsTolerance { get { return 1E-5; } } + protected virtual double AngstromsTolerance { get { return 1e-5; } } + protected virtual double AstronomicalUnitsTolerance { get { return 1e-5; } } + protected virtual double CentimetersTolerance { get { return 1e-5; } } + protected virtual double ChainsTolerance { get { return 1e-5; } } + protected virtual double DataMilesTolerance { get { return 1e-5; } } + protected virtual double DecametersTolerance { get { return 1e-5; } } + protected virtual double DecimetersTolerance { get { return 1e-5; } } + protected virtual double DtpPicasTolerance { get { return 1e-5; } } + protected virtual double DtpPointsTolerance { get { return 1e-5; } } + protected virtual double FathomsTolerance { get { return 1e-5; } } + protected virtual double FeetTolerance { get { return 1e-5; } } + protected virtual double HandsTolerance { get { return 1e-5; } } + protected virtual double HectometersTolerance { get { return 1e-5; } } + protected virtual double InchesTolerance { get { return 1e-5; } } + protected virtual double KilolightYearsTolerance { get { return 1e-5; } } + protected virtual double KilometersTolerance { get { return 1e-5; } } + protected virtual double KiloparsecsTolerance { get { return 1e-5; } } + protected virtual double LightYearsTolerance { get { return 1e-5; } } + protected virtual double MegalightYearsTolerance { get { return 1e-5; } } + protected virtual double MegaparsecsTolerance { get { return 1e-5; } } + protected virtual double MetersTolerance { get { return 1e-5; } } + protected virtual double MicroinchesTolerance { get { return 1e-5; } } + protected virtual double MicrometersTolerance { get { return 1e-5; } } + protected virtual double MilsTolerance { get { return 1e-5; } } + protected virtual double MilesTolerance { get { return 1e-5; } } + protected virtual double MillimetersTolerance { get { return 1e-5; } } + protected virtual double NanometersTolerance { get { return 1e-5; } } + protected virtual double NauticalMilesTolerance { get { return 1e-5; } } + protected virtual double ParsecsTolerance { get { return 1e-5; } } + protected virtual double PrinterPicasTolerance { get { return 1e-5; } } + protected virtual double PrinterPointsTolerance { get { return 1e-5; } } + protected virtual double ShacklesTolerance { get { return 1e-5; } } + protected virtual double SolarRadiusesTolerance { get { return 1e-5; } } + protected virtual double TwipsTolerance { get { return 1e-5; } } + protected virtual double UsSurveyFeetTolerance { get { return 1e-5; } } + protected virtual double YardsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LengthUnit unit) @@ -508,7 +508,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2209,21 +2209,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LengthUnit unit) { - var inBaseUnit = Length.From(1.0, Length.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Length.From(1.0, Length.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Length.From(1.0, Length.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LengthUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LengthUnit unit) @@ -2237,8 +2230,8 @@ public void ToUnit_WithSameUnits_AreEqual(LengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LengthUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Length.Units.First(u => u != Length.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Length.Units.Where(u => u != Length.BaseUnit).DefaultIfEmpty(Length.BaseUnit).FirstOrDefault(); var quantity = Length.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2538,9 +2531,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2574,41 +2566,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2621,25 +2608,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Length.FromMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Length.FromMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2681,7 +2665,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Length.FromMeters(1.0); - Assert.Equal(Length.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Length.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index db6fd2269e..aa977dc3e4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class LevelTestsBase : QuantityTestsBase protected abstract double NepersInOneDecibel { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecibelsTolerance { get { return 1E-5; } } - protected virtual double NepersTolerance { get { return 1E-5; } } + protected virtual double DecibelsTolerance { get { return 1e-5; } } + protected virtual double NepersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LevelUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,21 +249,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LevelUnit unit) { - var inBaseUnit = Level.From(1.0, Level.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Level.From(1.0, Level.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Level.From(1.0, Level.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LevelUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LevelUnit unit) @@ -277,8 +270,8 @@ public void ToUnit_WithSameUnits_AreEqual(LevelUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LevelUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Level.Units.First(u => u != Level.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Level.Units.Where(u => u != Level.BaseUnit).DefaultIfEmpty(Level.BaseUnit).FirstOrDefault(); var quantity = Level.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -480,9 +473,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -516,41 +508,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -563,25 +550,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Level.FromDecibels(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Level.FromDecibels(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -623,7 +607,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Level.FromDecibels(1.0); - Assert.Equal(Level.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Level.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index dc31e147c1..da6d13e43c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class LinearDensityTestsBase : QuantityTestsBase protected abstract double PoundsPerInchInOneKilogramPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerMeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double PoundsPerFootTolerance { get { return 1E-5; } } - protected virtual double PoundsPerInchTolerance { get { return 1E-5; } } + protected virtual double GramsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerMeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerFootTolerance { get { return 1e-5; } } + protected virtual double PoundsPerInchTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LinearDensityUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -657,21 +657,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LinearDensityUnit unit) { - var inBaseUnit = LinearDensity.From(1.0, LinearDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = LinearDensity.From(1.0, LinearDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = LinearDensity.From(1.0, LinearDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LinearDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LinearDensityUnit unit) @@ -685,8 +678,8 @@ public void ToUnit_WithSameUnits_AreEqual(LinearDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LinearDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = LinearDensity.Units.First(u => u != LinearDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = LinearDensity.Units.Where(u => u != LinearDensity.BaseUnit).DefaultIfEmpty(LinearDensity.BaseUnit).FirstOrDefault(); var quantity = LinearDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -920,9 +913,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -956,41 +948,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1003,25 +990,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearDensity.FromKilogramsPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = LinearDensity.FromKilogramsPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1063,7 +1047,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LinearDensity.FromKilogramsPerMeter(1.0); - Assert.Equal(LinearDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {LinearDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 457cb71019..89f251de69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -65,31 +65,31 @@ public abstract partial class LinearPowerDensityTestsBase : QuantityTestsBase protected abstract double WattsPerMillimeterInOneWattPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigawattsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerFootTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerInchTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerMeterTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerFootTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerInchTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerFootTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerInchTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerFootTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerInchTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerMeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double WattsPerCentimeterTolerance { get { return 1E-5; } } - protected virtual double WattsPerFootTolerance { get { return 1E-5; } } - protected virtual double WattsPerInchTolerance { get { return 1E-5; } } - protected virtual double WattsPerMeterTolerance { get { return 1E-5; } } - protected virtual double WattsPerMillimeterTolerance { get { return 1E-5; } } + protected virtual double GigawattsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerFootTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerInchTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerMeterTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerFootTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerInchTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerFootTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerInchTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerFootTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerInchTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerMeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double WattsPerCentimeterTolerance { get { return 1e-5; } } + protected virtual double WattsPerFootTolerance { get { return 1e-5; } } + protected virtual double WattsPerInchTolerance { get { return 1e-5; } } + protected virtual double WattsPerMeterTolerance { get { return 1e-5; } } + protected virtual double WattsPerMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LinearPowerDensityUnit unit) @@ -398,7 +398,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -921,21 +921,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LinearPowerDensityUnit unit) { - var inBaseUnit = LinearPowerDensity.From(1.0, LinearPowerDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = LinearPowerDensity.From(1.0, LinearPowerDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = LinearPowerDensity.From(1.0, LinearPowerDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LinearPowerDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LinearPowerDensityUnit unit) @@ -949,8 +942,8 @@ public void ToUnit_WithSameUnits_AreEqual(LinearPowerDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LinearPowerDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = LinearPowerDensity.Units.First(u => u != LinearPowerDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = LinearPowerDensity.Units.Where(u => u != LinearPowerDensity.BaseUnit).DefaultIfEmpty(LinearPowerDensity.BaseUnit).FirstOrDefault(); var quantity = LinearPowerDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1217,9 +1210,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1253,41 +1245,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1300,25 +1287,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LinearPowerDensity.FromWattsPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1360,7 +1344,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LinearPowerDensity.FromWattsPerMeter(1.0); - Assert.Equal(LinearPowerDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {LinearPowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 8849176e7d..007e99449e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class LuminosityTestsBase : QuantityTestsBase protected abstract double WattsInOneWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecawattsTolerance { get { return 1E-5; } } - protected virtual double DeciwattsTolerance { get { return 1E-5; } } - protected virtual double FemtowattsTolerance { get { return 1E-5; } } - protected virtual double GigawattsTolerance { get { return 1E-5; } } - protected virtual double KilowattsTolerance { get { return 1E-5; } } - protected virtual double MegawattsTolerance { get { return 1E-5; } } - protected virtual double MicrowattsTolerance { get { return 1E-5; } } - protected virtual double MilliwattsTolerance { get { return 1E-5; } } - protected virtual double NanowattsTolerance { get { return 1E-5; } } - protected virtual double PetawattsTolerance { get { return 1E-5; } } - protected virtual double PicowattsTolerance { get { return 1E-5; } } - protected virtual double SolarLuminositiesTolerance { get { return 1E-5; } } - protected virtual double TerawattsTolerance { get { return 1E-5; } } - protected virtual double WattsTolerance { get { return 1E-5; } } + protected virtual double DecawattsTolerance { get { return 1e-5; } } + protected virtual double DeciwattsTolerance { get { return 1e-5; } } + protected virtual double FemtowattsTolerance { get { return 1e-5; } } + protected virtual double GigawattsTolerance { get { return 1e-5; } } + protected virtual double KilowattsTolerance { get { return 1e-5; } } + protected virtual double MegawattsTolerance { get { return 1e-5; } } + protected virtual double MicrowattsTolerance { get { return 1e-5; } } + protected virtual double MilliwattsTolerance { get { return 1e-5; } } + protected virtual double NanowattsTolerance { get { return 1e-5; } } + protected virtual double PetawattsTolerance { get { return 1e-5; } } + protected virtual double PicowattsTolerance { get { return 1e-5; } } + protected virtual double SolarLuminositiesTolerance { get { return 1e-5; } } + protected virtual double TerawattsTolerance { get { return 1e-5; } } + protected virtual double WattsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LuminosityUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -613,21 +613,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LuminosityUnit unit) { - var inBaseUnit = Luminosity.From(1.0, Luminosity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Luminosity.From(1.0, Luminosity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Luminosity.From(1.0, Luminosity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LuminosityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LuminosityUnit unit) @@ -641,8 +634,8 @@ public void ToUnit_WithSameUnits_AreEqual(LuminosityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminosityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Luminosity.Units.First(u => u != Luminosity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Luminosity.Units.Where(u => u != Luminosity.BaseUnit).DefaultIfEmpty(Luminosity.BaseUnit).FirstOrDefault(); var quantity = Luminosity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -876,9 +869,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -912,41 +904,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -959,25 +946,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Luminosity.FromWatts(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Luminosity.FromWatts(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1019,7 +1003,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Luminosity.FromWatts(1.0); - Assert.Equal(Luminosity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Luminosity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index ad27f5af83..dcb107c35f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class LuminousFluxTestsBase : QuantityTestsBase protected abstract double LumensInOneLumen { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double LumensTolerance { get { return 1E-5; } } + protected virtual double LumensTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LuminousFluxUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LuminousFluxUnit unit) { - var inBaseUnit = LuminousFlux.From(1.0, LuminousFlux.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = LuminousFlux.From(1.0, LuminousFlux.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = LuminousFlux.From(1.0, LuminousFlux.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LuminousFluxUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LuminousFluxUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(LuminousFluxUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminousFluxUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = LuminousFlux.Units.First(u => u != LuminousFlux.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = LuminousFlux.Units.Where(u => u != LuminousFlux.BaseUnit).DefaultIfEmpty(LuminousFlux.BaseUnit).FirstOrDefault(); var quantity = LuminousFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousFlux.FromLumens(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = LuminousFlux.FromLumens(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LuminousFlux.FromLumens(1.0); - Assert.Equal(LuminousFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {LuminousFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index 04ec63b13a..fcd3954377 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class LuminousIntensityTestsBase : QuantityTestsBase protected abstract double CandelaInOneCandela { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CandelaTolerance { get { return 1E-5; } } + protected virtual double CandelaTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(LuminousIntensityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(LuminousIntensityUnit unit) { - var inBaseUnit = LuminousIntensity.From(1.0, LuminousIntensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = LuminousIntensity.From(1.0, LuminousIntensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = LuminousIntensity.From(1.0, LuminousIntensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(LuminousIntensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(LuminousIntensityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(LuminousIntensityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(LuminousIntensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = LuminousIntensity.Units.First(u => u != LuminousIntensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = LuminousIntensity.Units.Where(u => u != LuminousIntensity.BaseUnit).DefaultIfEmpty(LuminousIntensity.BaseUnit).FirstOrDefault(); var quantity = LuminousIntensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = LuminousIntensity.FromCandela(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = LuminousIntensity.FromCandela(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = LuminousIntensity.FromCandela(1.0); - Assert.Equal(LuminousIntensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {LuminousIntensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index f0e1ec76db..174b05b5bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class MagneticFieldTestsBase : QuantityTestsBase protected abstract double TeslasInOneTesla { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GaussesTolerance { get { return 1E-5; } } - protected virtual double MicroteslasTolerance { get { return 1E-5; } } - protected virtual double MilligaussesTolerance { get { return 1E-5; } } - protected virtual double MilliteslasTolerance { get { return 1E-5; } } - protected virtual double NanoteslasTolerance { get { return 1E-5; } } - protected virtual double TeslasTolerance { get { return 1E-5; } } + protected virtual double GaussesTolerance { get { return 1e-5; } } + protected virtual double MicroteslasTolerance { get { return 1e-5; } } + protected virtual double MilligaussesTolerance { get { return 1e-5; } } + protected virtual double MilliteslasTolerance { get { return 1e-5; } } + protected virtual double NanoteslasTolerance { get { return 1e-5; } } + protected virtual double TeslasTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MagneticFieldUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -385,21 +385,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MagneticFieldUnit unit) { - var inBaseUnit = MagneticField.From(1.0, MagneticField.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MagneticField.From(1.0, MagneticField.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MagneticField.From(1.0, MagneticField.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MagneticFieldUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MagneticFieldUnit unit) @@ -413,8 +406,8 @@ public void ToUnit_WithSameUnits_AreEqual(MagneticFieldUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagneticFieldUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MagneticField.Units.First(u => u != MagneticField.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MagneticField.Units.Where(u => u != MagneticField.BaseUnit).DefaultIfEmpty(MagneticField.BaseUnit).FirstOrDefault(); var quantity = MagneticField.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -624,9 +617,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -660,41 +652,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -707,25 +694,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticField.FromTeslas(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MagneticField.FromTeslas(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -767,7 +751,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MagneticField.FromTeslas(1.0); - Assert.Equal(MagneticField.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MagneticField.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index d76291cc93..acee8f296b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class MagneticFluxTestsBase : QuantityTestsBase protected abstract double WebersInOneWeber { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double WebersTolerance { get { return 1E-5; } } + protected virtual double WebersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MagneticFluxUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MagneticFluxUnit unit) { - var inBaseUnit = MagneticFlux.From(1.0, MagneticFlux.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MagneticFlux.From(1.0, MagneticFlux.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MagneticFlux.From(1.0, MagneticFlux.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MagneticFluxUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MagneticFluxUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(MagneticFluxUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagneticFluxUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MagneticFlux.Units.First(u => u != MagneticFlux.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MagneticFlux.Units.Where(u => u != MagneticFlux.BaseUnit).DefaultIfEmpty(MagneticFlux.BaseUnit).FirstOrDefault(); var quantity = MagneticFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MagneticFlux.FromWebers(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MagneticFlux.FromWebers(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MagneticFlux.FromWebers(1.0); - Assert.Equal(MagneticFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MagneticFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index ea30c1f26e..b6e2f93739 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class MagnetizationTestsBase : QuantityTestsBase protected abstract double AmperesPerMeterInOneAmperePerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmperesPerMeterTolerance { get { return 1E-5; } } + protected virtual double AmperesPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MagnetizationUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MagnetizationUnit unit) { - var inBaseUnit = Magnetization.From(1.0, Magnetization.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Magnetization.From(1.0, Magnetization.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Magnetization.From(1.0, Magnetization.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MagnetizationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MagnetizationUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(MagnetizationUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MagnetizationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Magnetization.Units.First(u => u != Magnetization.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Magnetization.Units.Where(u => u != Magnetization.BaseUnit).DefaultIfEmpty(Magnetization.BaseUnit).FirstOrDefault(); var quantity = Magnetization.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Magnetization.FromAmperesPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Magnetization.FromAmperesPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Magnetization.FromAmperesPerMeter(1.0); - Assert.Equal(Magnetization.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Magnetization.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 9fceb48029..4f1778b29c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -89,55 +89,55 @@ public abstract partial class MassConcentrationTestsBase : QuantityTestsBase protected abstract double TonnesPerCubicMillimeterInOneKilogramPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double GramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double GramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double GramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double KilopoundsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double KilopoundsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double OuncesPerImperialGallonTolerance { get { return 1E-5; } } - protected virtual double OuncesPerUSGallonTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerDeciliterTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerLiterTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerMicroliterTolerance { get { return 1E-5; } } - protected virtual double PicogramsPerMilliliterTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double PoundsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double PoundsPerImperialGallonTolerance { get { return 1E-5; } } - protected virtual double PoundsPerUSGallonTolerance { get { return 1E-5; } } - protected virtual double SlugsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double GramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double GramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double GramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double KilopoundsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double KilopoundsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double OuncesPerImperialGallonTolerance { get { return 1e-5; } } + protected virtual double OuncesPerUSGallonTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerDeciliterTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerLiterTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerMicroliterTolerance { get { return 1e-5; } } + protected virtual double PicogramsPerMilliliterTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double PoundsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double PoundsPerImperialGallonTolerance { get { return 1e-5; } } + protected virtual double PoundsPerUSGallonTolerance { get { return 1e-5; } } + protected virtual double SlugsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double TonnesPerCubicMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassConcentrationUnit unit) @@ -638,7 +638,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1943,21 +1943,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassConcentrationUnit unit) { - var inBaseUnit = MassConcentration.From(1.0, MassConcentration.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MassConcentration.From(1.0, MassConcentration.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MassConcentration.From(1.0, MassConcentration.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MassConcentrationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassConcentrationUnit unit) @@ -1971,8 +1964,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassConcentrationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassConcentrationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MassConcentration.Units.First(u => u != MassConcentration.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MassConcentration.Units.Where(u => u != MassConcentration.BaseUnit).DefaultIfEmpty(MassConcentration.BaseUnit).FirstOrDefault(); var quantity = MassConcentration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2311,9 +2304,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2347,41 +2339,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2394,25 +2381,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassConcentration.FromKilogramsPerCubicMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2454,7 +2438,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassConcentration.FromKilogramsPerCubicMeter(1.0); - Assert.Equal(MassConcentration.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MassConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index 93648bfbf7..d4696be3d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -73,39 +73,39 @@ public abstract partial class MassFlowTestsBase : QuantityTestsBase protected abstract double TonnesPerHourInOneGramPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerDayTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecagramsPerDayTolerance { get { return 1E-5; } } - protected virtual double DecagramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerDayTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double GramsPerDayTolerance { get { return 1E-5; } } - protected virtual double GramsPerHourTolerance { get { return 1E-5; } } - protected virtual double GramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double HectogramsPerDayTolerance { get { return 1E-5; } } - protected virtual double HectogramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerDayTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerHourTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MegagramsPerDayTolerance { get { return 1E-5; } } - protected virtual double MegapoundsPerDayTolerance { get { return 1E-5; } } - protected virtual double MegapoundsPerHourTolerance { get { return 1E-5; } } - protected virtual double MegapoundsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double MegapoundsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerDayTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerDayTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerDayTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerSecondTolerance { get { return 1E-5; } } - protected virtual double PoundsPerDayTolerance { get { return 1E-5; } } - protected virtual double PoundsPerHourTolerance { get { return 1E-5; } } - protected virtual double PoundsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double PoundsPerSecondTolerance { get { return 1E-5; } } - protected virtual double ShortTonsPerHourTolerance { get { return 1E-5; } } - protected virtual double TonnesPerDayTolerance { get { return 1E-5; } } - protected virtual double TonnesPerHourTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerDayTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecagramsPerDayTolerance { get { return 1e-5; } } + protected virtual double DecagramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerDayTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double GramsPerDayTolerance { get { return 1e-5; } } + protected virtual double GramsPerHourTolerance { get { return 1e-5; } } + protected virtual double GramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double HectogramsPerDayTolerance { get { return 1e-5; } } + protected virtual double HectogramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerDayTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerHourTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegagramsPerDayTolerance { get { return 1e-5; } } + protected virtual double MegapoundsPerDayTolerance { get { return 1e-5; } } + protected virtual double MegapoundsPerHourTolerance { get { return 1e-5; } } + protected virtual double MegapoundsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double MegapoundsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerDayTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerDayTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerDayTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PoundsPerDayTolerance { get { return 1e-5; } } + protected virtual double PoundsPerHourTolerance { get { return 1e-5; } } + protected virtual double PoundsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double PoundsPerSecondTolerance { get { return 1e-5; } } + protected virtual double ShortTonsPerHourTolerance { get { return 1e-5; } } + protected virtual double TonnesPerDayTolerance { get { return 1e-5; } } + protected virtual double TonnesPerHourTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassFlowUnit unit) @@ -478,7 +478,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1545,21 +1545,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassFlowUnit unit) { - var inBaseUnit = MassFlow.From(1.0, MassFlow.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MassFlow.From(1.0, MassFlow.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MassFlow.From(1.0, MassFlow.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MassFlowUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassFlowUnit unit) @@ -1573,8 +1566,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassFlowUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFlowUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MassFlow.Units.First(u => u != MassFlow.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MassFlow.Units.Where(u => u != MassFlow.BaseUnit).DefaultIfEmpty(MassFlow.BaseUnit).FirstOrDefault(); var quantity = MassFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1865,9 +1858,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1901,41 +1893,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1948,25 +1935,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlow.FromGramsPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MassFlow.FromGramsPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2008,7 +1992,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFlow.FromGramsPerSecond(1.0); - Assert.Equal(MassFlow.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MassFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 629a37cbb0..54a6e654cf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -52,18 +52,18 @@ public abstract partial class MassFluxTestsBase : QuantityTestsBase protected abstract double KilogramsPerSecondPerSquareMillimeterInOneKilogramPerSecondPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerHourPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerHourPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerHourPerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerSecondPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerSecondPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double GramsPerSecondPerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerHourPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerHourPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerHourPerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerSecondPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerSecondPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerSecondPerSquareMillimeterTolerance { get { return 1E-5; } } + protected virtual double GramsPerHourPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerHourPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerHourPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerSecondPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerSecondPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double GramsPerSecondPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerHourPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerHourPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerHourPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerSecondPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerSecondPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerSecondPerSquareMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassFluxUnit unit) @@ -268,7 +268,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -589,21 +589,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassFluxUnit unit) { - var inBaseUnit = MassFlux.From(1.0, MassFlux.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MassFlux.From(1.0, MassFlux.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MassFlux.From(1.0, MassFlux.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MassFluxUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassFluxUnit unit) @@ -617,8 +610,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassFluxUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFluxUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MassFlux.Units.First(u => u != MassFlux.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MassFlux.Units.Where(u => u != MassFlux.BaseUnit).DefaultIfEmpty(MassFlux.BaseUnit).FirstOrDefault(); var quantity = MassFlux.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -846,9 +839,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -882,41 +874,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -929,25 +916,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -989,7 +973,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFlux.FromKilogramsPerSecondPerSquareMeter(1.0); - Assert.Equal(MassFlux.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MassFlux.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 00b3490646..1cdfeb11b5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -64,30 +64,30 @@ public abstract partial class MassFractionTestsBase : QuantityTestsBase protected abstract double PercentInOneDecimalFraction { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerGramTolerance { get { return 1E-5; } } - protected virtual double CentigramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double DecagramsPerGramTolerance { get { return 1E-5; } } - protected virtual double DecagramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerGramTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double DecimalFractionsTolerance { get { return 1E-5; } } - protected virtual double GramsPerGramTolerance { get { return 1E-5; } } - protected virtual double GramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double HectogramsPerGramTolerance { get { return 1E-5; } } - protected virtual double HectogramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerGramTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerGramTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerGramTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerGramTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerKilogramTolerance { get { return 1E-5; } } - protected virtual double PartsPerBillionTolerance { get { return 1E-5; } } - protected virtual double PartsPerMillionTolerance { get { return 1E-5; } } - protected virtual double PartsPerThousandTolerance { get { return 1E-5; } } - protected virtual double PartsPerTrillionTolerance { get { return 1E-5; } } - protected virtual double PercentTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerGramTolerance { get { return 1e-5; } } + protected virtual double CentigramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double DecagramsPerGramTolerance { get { return 1e-5; } } + protected virtual double DecagramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerGramTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } + protected virtual double GramsPerGramTolerance { get { return 1e-5; } } + protected virtual double GramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double HectogramsPerGramTolerance { get { return 1e-5; } } + protected virtual double HectogramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerGramTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerGramTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerGramTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerGramTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerKilogramTolerance { get { return 1e-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } + protected virtual double PercentTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassFractionUnit unit) @@ -388,7 +388,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1021,21 +1021,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassFractionUnit unit) { - var inBaseUnit = MassFraction.From(1.0, MassFraction.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MassFraction.From(1.0, MassFraction.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MassFraction.From(1.0, MassFraction.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MassFractionUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassFractionUnit unit) @@ -1049,8 +1042,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassFractionUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassFractionUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MassFraction.Units.First(u => u != MassFraction.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MassFraction.Units.Where(u => u != MassFraction.BaseUnit).DefaultIfEmpty(MassFraction.BaseUnit).FirstOrDefault(); var quantity = MassFraction.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1314,9 +1307,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1350,41 +1342,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1397,25 +1384,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassFraction.FromDecimalFractions(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MassFraction.FromDecimalFractions(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1457,7 +1441,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassFraction.FromDecimalFractions(1.0); - Assert.Equal(MassFraction.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MassFraction.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index ae4900fe18..12f6d91b6e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -68,34 +68,34 @@ public abstract partial class MassMomentOfInertiaTestsBase : QuantityTestsBase protected abstract double TonneSquareMilimetersInOneKilogramSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double GramSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double GramSquareMetersTolerance { get { return 1E-5; } } - protected virtual double GramSquareMillimetersTolerance { get { return 1E-5; } } - protected virtual double KilogramSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double KilogramSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double KilogramSquareMetersTolerance { get { return 1E-5; } } - protected virtual double KilogramSquareMillimetersTolerance { get { return 1E-5; } } - protected virtual double KilotonneSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double KilotonneSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double KilotonneSquareMetersTolerance { get { return 1E-5; } } - protected virtual double KilotonneSquareMilimetersTolerance { get { return 1E-5; } } - protected virtual double MegatonneSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double MegatonneSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double MegatonneSquareMetersTolerance { get { return 1E-5; } } - protected virtual double MegatonneSquareMilimetersTolerance { get { return 1E-5; } } - protected virtual double MilligramSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double MilligramSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double MilligramSquareMetersTolerance { get { return 1E-5; } } - protected virtual double MilligramSquareMillimetersTolerance { get { return 1E-5; } } - protected virtual double PoundSquareFeetTolerance { get { return 1E-5; } } - protected virtual double PoundSquareInchesTolerance { get { return 1E-5; } } - protected virtual double SlugSquareFeetTolerance { get { return 1E-5; } } - protected virtual double SlugSquareInchesTolerance { get { return 1E-5; } } - protected virtual double TonneSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double TonneSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double TonneSquareMetersTolerance { get { return 1E-5; } } - protected virtual double TonneSquareMilimetersTolerance { get { return 1E-5; } } + protected virtual double GramSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double GramSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double GramSquareMetersTolerance { get { return 1e-5; } } + protected virtual double GramSquareMillimetersTolerance { get { return 1e-5; } } + protected virtual double KilogramSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double KilogramSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double KilogramSquareMetersTolerance { get { return 1e-5; } } + protected virtual double KilogramSquareMillimetersTolerance { get { return 1e-5; } } + protected virtual double KilotonneSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double KilotonneSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double KilotonneSquareMetersTolerance { get { return 1e-5; } } + protected virtual double KilotonneSquareMilimetersTolerance { get { return 1e-5; } } + protected virtual double MegatonneSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double MegatonneSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double MegatonneSquareMetersTolerance { get { return 1e-5; } } + protected virtual double MegatonneSquareMilimetersTolerance { get { return 1e-5; } } + protected virtual double MilligramSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double MilligramSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double MilligramSquareMetersTolerance { get { return 1e-5; } } + protected virtual double MilligramSquareMillimetersTolerance { get { return 1e-5; } } + protected virtual double PoundSquareFeetTolerance { get { return 1e-5; } } + protected virtual double PoundSquareInchesTolerance { get { return 1e-5; } } + protected virtual double SlugSquareFeetTolerance { get { return 1e-5; } } + protected virtual double SlugSquareInchesTolerance { get { return 1e-5; } } + protected virtual double TonneSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double TonneSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double TonneSquareMetersTolerance { get { return 1e-5; } } + protected virtual double TonneSquareMilimetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassMomentOfInertiaUnit unit) @@ -428,7 +428,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1133,21 +1133,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassMomentOfInertiaUnit unit) { - var inBaseUnit = MassMomentOfInertia.From(1.0, MassMomentOfInertia.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MassMomentOfInertia.From(1.0, MassMomentOfInertia.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MassMomentOfInertia.From(1.0, MassMomentOfInertia.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MassMomentOfInertiaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassMomentOfInertiaUnit unit) @@ -1161,8 +1154,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassMomentOfInertiaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassMomentOfInertiaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MassMomentOfInertia.Units.First(u => u != MassMomentOfInertia.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MassMomentOfInertia.Units.Where(u => u != MassMomentOfInertia.BaseUnit).DefaultIfEmpty(MassMomentOfInertia.BaseUnit).FirstOrDefault(); var quantity = MassMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1438,9 +1431,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1474,41 +1466,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1521,25 +1508,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MassMomentOfInertia.FromKilogramSquareMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1581,7 +1565,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MassMomentOfInertia.FromKilogramSquareMeters(1.0); - Assert.Equal(MassMomentOfInertia.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MassMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index 53bbe5b415..aee8d32ea4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -65,31 +65,31 @@ public abstract partial class MassTestsBase : QuantityTestsBase protected abstract double TonnesInOneKilogram { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsTolerance { get { return 1E-5; } } - protected virtual double DecagramsTolerance { get { return 1E-5; } } - protected virtual double DecigramsTolerance { get { return 1E-5; } } - protected virtual double EarthMassesTolerance { get { return 1E-5; } } - protected virtual double GrainsTolerance { get { return 1E-5; } } - protected virtual double GramsTolerance { get { return 1E-5; } } - protected virtual double HectogramsTolerance { get { return 1E-5; } } - protected virtual double KilogramsTolerance { get { return 1E-5; } } - protected virtual double KilopoundsTolerance { get { return 1E-5; } } - protected virtual double KilotonnesTolerance { get { return 1E-5; } } - protected virtual double LongHundredweightTolerance { get { return 1E-5; } } - protected virtual double LongTonsTolerance { get { return 1E-5; } } - protected virtual double MegapoundsTolerance { get { return 1E-5; } } - protected virtual double MegatonnesTolerance { get { return 1E-5; } } - protected virtual double MicrogramsTolerance { get { return 1E-5; } } - protected virtual double MilligramsTolerance { get { return 1E-5; } } - protected virtual double NanogramsTolerance { get { return 1E-5; } } - protected virtual double OuncesTolerance { get { return 1E-5; } } - protected virtual double PoundsTolerance { get { return 1E-5; } } - protected virtual double ShortHundredweightTolerance { get { return 1E-5; } } - protected virtual double ShortTonsTolerance { get { return 1E-5; } } - protected virtual double SlugsTolerance { get { return 1E-5; } } - protected virtual double SolarMassesTolerance { get { return 1E-5; } } - protected virtual double StoneTolerance { get { return 1E-5; } } - protected virtual double TonnesTolerance { get { return 1E-5; } } + protected virtual double CentigramsTolerance { get { return 1e-5; } } + protected virtual double DecagramsTolerance { get { return 1e-5; } } + protected virtual double DecigramsTolerance { get { return 1e-5; } } + protected virtual double EarthMassesTolerance { get { return 1e-5; } } + protected virtual double GrainsTolerance { get { return 1e-5; } } + protected virtual double GramsTolerance { get { return 1e-5; } } + protected virtual double HectogramsTolerance { get { return 1e-5; } } + protected virtual double KilogramsTolerance { get { return 1e-5; } } + protected virtual double KilopoundsTolerance { get { return 1e-5; } } + protected virtual double KilotonnesTolerance { get { return 1e-5; } } + protected virtual double LongHundredweightTolerance { get { return 1e-5; } } + protected virtual double LongTonsTolerance { get { return 1e-5; } } + protected virtual double MegapoundsTolerance { get { return 1e-5; } } + protected virtual double MegatonnesTolerance { get { return 1e-5; } } + protected virtual double MicrogramsTolerance { get { return 1e-5; } } + protected virtual double MilligramsTolerance { get { return 1e-5; } } + protected virtual double NanogramsTolerance { get { return 1e-5; } } + protected virtual double OuncesTolerance { get { return 1e-5; } } + protected virtual double PoundsTolerance { get { return 1e-5; } } + protected virtual double ShortHundredweightTolerance { get { return 1e-5; } } + protected virtual double ShortTonsTolerance { get { return 1e-5; } } + protected virtual double SlugsTolerance { get { return 1e-5; } } + protected virtual double SolarMassesTolerance { get { return 1e-5; } } + protected virtual double StoneTolerance { get { return 1e-5; } } + protected virtual double TonnesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MassUnit unit) @@ -398,7 +398,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2019,21 +2019,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MassUnit unit) { - var inBaseUnit = Mass.From(1.0, Mass.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Mass.From(1.0, Mass.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Mass.From(1.0, Mass.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MassUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MassUnit unit) @@ -2047,8 +2040,8 @@ public void ToUnit_WithSameUnits_AreEqual(MassUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MassUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Mass.Units.First(u => u != Mass.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Mass.Units.Where(u => u != Mass.BaseUnit).DefaultIfEmpty(Mass.BaseUnit).FirstOrDefault(); var quantity = Mass.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2315,9 +2308,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2351,41 +2343,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2398,25 +2385,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Mass.FromKilograms(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Mass.FromKilograms(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2458,7 +2442,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Mass.FromKilograms(1.0); - Assert.Equal(Mass.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Mass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index 67173dd576..d02524f56e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class MolarEnergyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerMoleInOneJoulePerMole { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double JoulesPerMoleTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerMoleTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerMoleTolerance { get { return 1E-5; } } + protected virtual double JoulesPerMoleTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerMoleTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerMoleTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarEnergyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarEnergyUnit unit) { - var inBaseUnit = MolarEnergy.From(1.0, MolarEnergy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MolarEnergy.From(1.0, MolarEnergy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MolarEnergy.From(1.0, MolarEnergy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MolarEnergyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarEnergyUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarEnergyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MolarEnergy.Units.First(u => u != MolarEnergy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MolarEnergy.Units.Where(u => u != MolarEnergy.BaseUnit).DefaultIfEmpty(MolarEnergy.BaseUnit).FirstOrDefault(); var quantity = MolarEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEnergy.FromJoulesPerMole(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MolarEnergy.FromJoulesPerMole(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarEnergy.FromJoulesPerMole(1.0); - Assert.Equal(MolarEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MolarEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 27d2a3f3ef..78a88ecb39 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class MolarEntropyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerMoleKelvinInOneJoulePerMoleKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double JoulesPerMoleKelvinTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1E-5; } } + protected virtual double JoulesPerMoleKelvinTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerMoleKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerMoleKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarEntropyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarEntropyUnit unit) { - var inBaseUnit = MolarEntropy.From(1.0, MolarEntropy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MolarEntropy.From(1.0, MolarEntropy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MolarEntropy.From(1.0, MolarEntropy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MolarEntropyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarEntropyUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarEntropyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarEntropyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MolarEntropy.Units.First(u => u != MolarEntropy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MolarEntropy.Units.Where(u => u != MolarEntropy.BaseUnit).DefaultIfEmpty(MolarEntropy.BaseUnit).FirstOrDefault(); var quantity = MolarEntropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarEntropy.FromJoulesPerMoleKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarEntropy.FromJoulesPerMoleKelvin(1.0); - Assert.Equal(MolarEntropy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MolarEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index 1386699ba0..ffe0f30f77 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -52,18 +52,18 @@ public abstract partial class MolarMassTestsBase : QuantityTestsBase protected abstract double PoundsPerMoleInOneKilogramPerMole { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentigramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double DecagramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double DecigramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double GramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double HectogramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double KilopoundsPerMoleTolerance { get { return 1E-5; } } - protected virtual double MegapoundsPerMoleTolerance { get { return 1E-5; } } - protected virtual double MicrogramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double MilligramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double NanogramsPerMoleTolerance { get { return 1E-5; } } - protected virtual double PoundsPerMoleTolerance { get { return 1E-5; } } + protected virtual double CentigramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double DecagramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double DecigramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double GramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double HectogramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double KilopoundsPerMoleTolerance { get { return 1e-5; } } + protected virtual double MegapoundsPerMoleTolerance { get { return 1e-5; } } + protected virtual double MicrogramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double MilligramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double NanogramsPerMoleTolerance { get { return 1e-5; } } + protected virtual double PoundsPerMoleTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarMassUnit unit) @@ -268,7 +268,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -877,21 +877,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarMassUnit unit) { - var inBaseUnit = MolarMass.From(1.0, MolarMass.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = MolarMass.From(1.0, MolarMass.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = MolarMass.From(1.0, MolarMass.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MolarMassUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarMassUnit unit) @@ -905,8 +898,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarMassUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarMassUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = MolarMass.Units.First(u => u != MolarMass.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = MolarMass.Units.Where(u => u != MolarMass.BaseUnit).DefaultIfEmpty(MolarMass.BaseUnit).FirstOrDefault(); var quantity = MolarMass.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1134,9 +1127,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1170,41 +1162,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1217,25 +1204,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = MolarMass.FromKilogramsPerMole(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = MolarMass.FromKilogramsPerMole(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1277,7 +1261,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = MolarMass.FromKilogramsPerMole(1.0); - Assert.Equal(MolarMass.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {MolarMass.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 960cddfa8f..923b01a6b3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class MolarityTestsBase : QuantityTestsBase protected abstract double PicomolesPerLiterInOneMolesPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double DecimolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double FemtomolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double MicromolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double MillimolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double MolesPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double NanomolesPerLiterTolerance { get { return 1E-5; } } - protected virtual double PicomolesPerLiterTolerance { get { return 1E-5; } } + protected virtual double CentimolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double DecimolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double FemtomolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MicromolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MillimolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double MolesPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double NanomolesPerLiterTolerance { get { return 1e-5; } } + protected virtual double PicomolesPerLiterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(MolarityUnit unit) @@ -302,7 +302,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -578,21 +578,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(MolarityUnit unit) { - var inBaseUnit = Molarity.From(1.0, Molarity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Molarity.From(1.0, Molarity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Molarity.From(1.0, Molarity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(MolarityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(MolarityUnit unit) @@ -606,8 +599,8 @@ public void ToUnit_WithSameUnits_AreEqual(MolarityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(MolarityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Molarity.Units.First(u => u != Molarity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Molarity.Units.Where(u => u != Molarity.BaseUnit).DefaultIfEmpty(Molarity.BaseUnit).FirstOrDefault(); var quantity = Molarity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -850,9 +843,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -886,41 +878,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -933,25 +920,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Molarity.FromMolesPerCubicMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Molarity.FromMolesPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -993,7 +977,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Molarity.FromMolesPerCubicMeter(1.0); - Assert.Equal(Molarity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Molarity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index 748184a20e..af5bee7872 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class PermeabilityTestsBase : QuantityTestsBase protected abstract double HenriesPerMeterInOneHenryPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double HenriesPerMeterTolerance { get { return 1E-5; } } + protected virtual double HenriesPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PermeabilityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PermeabilityUnit unit) { - var inBaseUnit = Permeability.From(1.0, Permeability.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Permeability.From(1.0, Permeability.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Permeability.From(1.0, Permeability.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PermeabilityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PermeabilityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(PermeabilityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PermeabilityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Permeability.Units.First(u => u != Permeability.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Permeability.Units.Where(u => u != Permeability.BaseUnit).DefaultIfEmpty(Permeability.BaseUnit).FirstOrDefault(); var quantity = Permeability.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permeability.FromHenriesPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Permeability.FromHenriesPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Permeability.FromHenriesPerMeter(1.0); - Assert.Equal(Permeability.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Permeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 4e6467c7df..1a1aa929fa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class PermittivityTestsBase : QuantityTestsBase protected abstract double FaradsPerMeterInOneFaradPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double FaradsPerMeterTolerance { get { return 1E-5; } } + protected virtual double FaradsPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PermittivityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PermittivityUnit unit) { - var inBaseUnit = Permittivity.From(1.0, Permittivity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Permittivity.From(1.0, Permittivity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Permittivity.From(1.0, Permittivity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PermittivityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PermittivityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(PermittivityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PermittivityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Permittivity.Units.First(u => u != Permittivity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Permittivity.Units.Where(u => u != Permittivity.BaseUnit).DefaultIfEmpty(Permittivity.BaseUnit).FirstOrDefault(); var quantity = Permittivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Permittivity.FromFaradsPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Permittivity.FromFaradsPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Permittivity.FromFaradsPerMeter(1.0); - Assert.Equal(Permittivity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Permittivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 414490e545..88b7bcfa81 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class PorousMediumPermeabilityTestsBase : QuantityTestsB protected abstract double SquareMetersInOneSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DarcysTolerance { get { return 1E-5; } } - protected virtual double MicrodarcysTolerance { get { return 1E-5; } } - protected virtual double MillidarcysTolerance { get { return 1E-5; } } - protected virtual double SquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double SquareMetersTolerance { get { return 1E-5; } } + protected virtual double DarcysTolerance { get { return 1e-5; } } + protected virtual double MicrodarcysTolerance { get { return 1e-5; } } + protected virtual double MillidarcysTolerance { get { return 1e-5; } } + protected virtual double SquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double SquareMetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PorousMediumPermeabilityUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -351,21 +351,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PorousMediumPermeabilityUnit unit) { - var inBaseUnit = PorousMediumPermeability.From(1.0, PorousMediumPermeability.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = PorousMediumPermeability.From(1.0, PorousMediumPermeability.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = PorousMediumPermeability.From(1.0, PorousMediumPermeability.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PorousMediumPermeabilityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PorousMediumPermeabilityUnit unit) @@ -379,8 +372,8 @@ public void ToUnit_WithSameUnits_AreEqual(PorousMediumPermeabilityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PorousMediumPermeabilityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = PorousMediumPermeability.Units.First(u => u != PorousMediumPermeability.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = PorousMediumPermeability.Units.Where(u => u != PorousMediumPermeability.BaseUnit).DefaultIfEmpty(PorousMediumPermeability.BaseUnit).FirstOrDefault(); var quantity = PorousMediumPermeability.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -587,9 +580,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -623,41 +615,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -670,25 +657,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PorousMediumPermeability.FromSquareMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = PorousMediumPermeability.FromSquareMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -730,7 +714,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PorousMediumPermeability.FromSquareMeters(1.0); - Assert.Equal(PorousMediumPermeability.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {PorousMediumPermeability.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 82d5a94817..9888200c48 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -84,50 +84,50 @@ public abstract partial class PowerDensityTestsBase : QuantityTestsBase protected abstract double WattsPerLiterInOneWattPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecawattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double DecawattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double DecawattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double DecawattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double DeciwattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double DeciwattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double DeciwattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double DeciwattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double GigawattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double KilowattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MegawattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MicrowattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double MilliwattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double NanowattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double PicowattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double PicowattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double PicowattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double PicowattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double TerawattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double TerawattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double TerawattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double TerawattsPerLiterTolerance { get { return 1E-5; } } - protected virtual double WattsPerCubicFootTolerance { get { return 1E-5; } } - protected virtual double WattsPerCubicInchTolerance { get { return 1E-5; } } - protected virtual double WattsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double WattsPerLiterTolerance { get { return 1E-5; } } + protected virtual double DecawattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double DecawattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double DecawattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double DecawattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double DeciwattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double DeciwattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double DeciwattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double DeciwattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double GigawattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double KilowattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MegawattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MicrowattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double MilliwattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double NanowattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double PicowattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double PicowattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double PicowattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double PicowattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double TerawattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double TerawattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double TerawattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double TerawattsPerLiterTolerance { get { return 1e-5; } } + protected virtual double WattsPerCubicFootTolerance { get { return 1e-5; } } + protected virtual double WattsPerCubicInchTolerance { get { return 1e-5; } } + protected virtual double WattsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double WattsPerLiterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerDensityUnit unit) @@ -588,7 +588,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1589,21 +1589,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PowerDensityUnit unit) { - var inBaseUnit = PowerDensity.From(1.0, PowerDensity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = PowerDensity.From(1.0, PowerDensity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = PowerDensity.From(1.0, PowerDensity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PowerDensityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PowerDensityUnit unit) @@ -1617,8 +1610,8 @@ public void ToUnit_WithSameUnits_AreEqual(PowerDensityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerDensityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = PowerDensity.Units.First(u => u != PowerDensity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = PowerDensity.Units.Where(u => u != PowerDensity.BaseUnit).DefaultIfEmpty(PowerDensity.BaseUnit).FirstOrDefault(); var quantity = PowerDensity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1942,9 +1935,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1978,41 +1970,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2025,25 +2012,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerDensity.FromWattsPerCubicMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2085,7 +2069,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PowerDensity.FromWattsPerCubicMeter(1.0); - Assert.Equal(PowerDensity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {PowerDensity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 42ab82780f..3cd613b917 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class PowerRatioTestsBase : QuantityTestsBase protected abstract double DecibelWattsInOneDecibelWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecibelMilliwattsTolerance { get { return 1E-5; } } - protected virtual double DecibelWattsTolerance { get { return 1E-5; } } + protected virtual double DecibelMilliwattsTolerance { get { return 1e-5; } } + protected virtual double DecibelWattsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerRatioUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -273,21 +273,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PowerRatioUnit unit) { - var inBaseUnit = PowerRatio.From(1.0, PowerRatio.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = PowerRatio.From(1.0, PowerRatio.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = PowerRatio.From(1.0, PowerRatio.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PowerRatioUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PowerRatioUnit unit) @@ -301,8 +294,8 @@ public void ToUnit_WithSameUnits_AreEqual(PowerRatioUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerRatioUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = PowerRatio.Units.First(u => u != PowerRatio.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = PowerRatio.Units.Where(u => u != PowerRatio.BaseUnit).DefaultIfEmpty(PowerRatio.BaseUnit).FirstOrDefault(); var quantity = PowerRatio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -504,9 +497,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -540,41 +532,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -587,25 +574,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PowerRatio.FromDecibelWatts(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = PowerRatio.FromDecibelWatts(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -647,7 +631,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PowerRatio.FromDecibelWatts(1.0); - Assert.Equal(PowerRatio.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {PowerRatio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 99130bf8c2..84e4e66f28 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class PowerTestsBase : QuantityTestsBase { - protected abstract decimal BoilerHorsepowerInOneWatt { get; } - protected abstract decimal BritishThermalUnitsPerHourInOneWatt { get; } - protected abstract decimal DecawattsInOneWatt { get; } - protected abstract decimal DeciwattsInOneWatt { get; } - protected abstract decimal ElectricalHorsepowerInOneWatt { get; } - protected abstract decimal FemtowattsInOneWatt { get; } - protected abstract decimal GigajoulesPerHourInOneWatt { get; } - protected abstract decimal GigawattsInOneWatt { get; } - protected abstract decimal HydraulicHorsepowerInOneWatt { get; } - protected abstract decimal JoulesPerHourInOneWatt { get; } - protected abstract decimal KilobritishThermalUnitsPerHourInOneWatt { get; } - protected abstract decimal KilojoulesPerHourInOneWatt { get; } - protected abstract decimal KilowattsInOneWatt { get; } - protected abstract decimal MechanicalHorsepowerInOneWatt { get; } - protected abstract decimal MegabritishThermalUnitsPerHourInOneWatt { get; } - protected abstract decimal MegajoulesPerHourInOneWatt { get; } - protected abstract decimal MegawattsInOneWatt { get; } - protected abstract decimal MetricHorsepowerInOneWatt { get; } - protected abstract decimal MicrowattsInOneWatt { get; } - protected abstract decimal MillijoulesPerHourInOneWatt { get; } - protected abstract decimal MilliwattsInOneWatt { get; } - protected abstract decimal NanowattsInOneWatt { get; } - protected abstract decimal PetawattsInOneWatt { get; } - protected abstract decimal PicowattsInOneWatt { get; } - protected abstract decimal TerawattsInOneWatt { get; } - protected abstract decimal WattsInOneWatt { get; } + protected abstract double BoilerHorsepowerInOneWatt { get; } + protected abstract double BritishThermalUnitsPerHourInOneWatt { get; } + protected abstract double DecawattsInOneWatt { get; } + protected abstract double DeciwattsInOneWatt { get; } + protected abstract double ElectricalHorsepowerInOneWatt { get; } + protected abstract double FemtowattsInOneWatt { get; } + protected abstract double GigajoulesPerHourInOneWatt { get; } + protected abstract double GigawattsInOneWatt { get; } + protected abstract double HydraulicHorsepowerInOneWatt { get; } + protected abstract double JoulesPerHourInOneWatt { get; } + protected abstract double KilobritishThermalUnitsPerHourInOneWatt { get; } + protected abstract double KilojoulesPerHourInOneWatt { get; } + protected abstract double KilowattsInOneWatt { get; } + protected abstract double MechanicalHorsepowerInOneWatt { get; } + protected abstract double MegabritishThermalUnitsPerHourInOneWatt { get; } + protected abstract double MegajoulesPerHourInOneWatt { get; } + protected abstract double MegawattsInOneWatt { get; } + protected abstract double MetricHorsepowerInOneWatt { get; } + protected abstract double MicrowattsInOneWatt { get; } + protected abstract double MillijoulesPerHourInOneWatt { get; } + protected abstract double MilliwattsInOneWatt { get; } + protected abstract double NanowattsInOneWatt { get; } + protected abstract double PetawattsInOneWatt { get; } + protected abstract double PicowattsInOneWatt { get; } + protected abstract double TerawattsInOneWatt { get; } + protected abstract double WattsInOneWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual decimal BoilerHorsepowerTolerance { get { return 1E-9m; } } - protected virtual decimal BritishThermalUnitsPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal DecawattsTolerance { get { return 1E-9m; } } - protected virtual decimal DeciwattsTolerance { get { return 1E-9m; } } - protected virtual decimal ElectricalHorsepowerTolerance { get { return 1E-9m; } } - protected virtual decimal FemtowattsTolerance { get { return 1E-9m; } } - protected virtual decimal GigajoulesPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal GigawattsTolerance { get { return 1E-9m; } } - protected virtual decimal HydraulicHorsepowerTolerance { get { return 1E-9m; } } - protected virtual decimal JoulesPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal KilobritishThermalUnitsPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal KilojoulesPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal KilowattsTolerance { get { return 1E-9m; } } - protected virtual decimal MechanicalHorsepowerTolerance { get { return 1E-9m; } } - protected virtual decimal MegabritishThermalUnitsPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal MegajoulesPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal MegawattsTolerance { get { return 1E-9m; } } - protected virtual decimal MetricHorsepowerTolerance { get { return 1E-9m; } } - protected virtual decimal MicrowattsTolerance { get { return 1E-9m; } } - protected virtual decimal MillijoulesPerHourTolerance { get { return 1E-9m; } } - protected virtual decimal MilliwattsTolerance { get { return 1E-9m; } } - protected virtual decimal NanowattsTolerance { get { return 1E-9m; } } - protected virtual decimal PetawattsTolerance { get { return 1E-9m; } } - protected virtual decimal PicowattsTolerance { get { return 1E-9m; } } - protected virtual decimal TerawattsTolerance { get { return 1E-9m; } } - protected virtual decimal WattsTolerance { get { return 1E-9m; } } + protected virtual double BoilerHorsepowerTolerance { get { return 1e-5; } } + protected virtual double BritishThermalUnitsPerHourTolerance { get { return 1e-5; } } + protected virtual double DecawattsTolerance { get { return 1e-5; } } + protected virtual double DeciwattsTolerance { get { return 1e-5; } } + protected virtual double ElectricalHorsepowerTolerance { get { return 1e-5; } } + protected virtual double FemtowattsTolerance { get { return 1e-5; } } + protected virtual double GigajoulesPerHourTolerance { get { return 1e-5; } } + protected virtual double GigawattsTolerance { get { return 1e-5; } } + protected virtual double HydraulicHorsepowerTolerance { get { return 1e-5; } } + protected virtual double JoulesPerHourTolerance { get { return 1e-5; } } + protected virtual double KilobritishThermalUnitsPerHourTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerHourTolerance { get { return 1e-5; } } + protected virtual double KilowattsTolerance { get { return 1e-5; } } + protected virtual double MechanicalHorsepowerTolerance { get { return 1e-5; } } + protected virtual double MegabritishThermalUnitsPerHourTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerHourTolerance { get { return 1e-5; } } + protected virtual double MegawattsTolerance { get { return 1e-5; } } + protected virtual double MetricHorsepowerTolerance { get { return 1e-5; } } + protected virtual double MicrowattsTolerance { get { return 1e-5; } } + protected virtual double MillijoulesPerHourTolerance { get { return 1e-5; } } + protected virtual double MilliwattsTolerance { get { return 1e-5; } } + protected virtual double NanowattsTolerance { get { return 1e-5; } } + protected virtual double PetawattsTolerance { get { return 1e-5; } } + protected virtual double PicowattsTolerance { get { return 1e-5; } } + protected virtual double TerawattsTolerance { get { return 1e-5; } } + protected virtual double WattsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(PowerUnit unit) + protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerUnit unit) { return unit switch { @@ -383,7 +383,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1046,21 +1046,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PowerUnit unit) { - var inBaseUnit = Power.From(1.0, Power.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Power.From(1.0, Power.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Power.From(1.0, Power.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PowerUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PowerUnit unit) @@ -1074,8 +1067,8 @@ public void ToUnit_WithSameUnits_AreEqual(PowerUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PowerUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Power.Units.First(u => u != Power.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Power.Units.Where(u => u != Power.BaseUnit).DefaultIfEmpty(Power.BaseUnit).FirstOrDefault(); var quantity = Power.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1345,9 +1338,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1381,41 +1373,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1428,25 +1415,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Power.FromWatts(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Power.FromWatts(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1488,7 +1472,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Power.FromWatts(1.0); - Assert.Equal(Power.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Power.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index cbd23636df..c489b22624 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -54,20 +54,20 @@ public abstract partial class PressureChangeRateTestsBase : QuantityTestsBase protected abstract double PoundsForcePerSquareInchPerSecondInOnePascalPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AtmospheresPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilopascalsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double KilopascalsPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerSquareInchPerMinuteTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerSquareInchPerSecondTolerance { get { return 1E-5; } } - protected virtual double MegapascalsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double MegapascalsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MegapoundsForcePerSquareInchPerMinuteTolerance { get { return 1E-5; } } - protected virtual double MegapoundsForcePerSquareInchPerSecondTolerance { get { return 1E-5; } } - protected virtual double MillimetersOfMercuryPerSecondTolerance { get { return 1E-5; } } - protected virtual double PascalsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double PascalsPerSecondTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerSquareInchPerMinuteTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerSquareInchPerSecondTolerance { get { return 1E-5; } } + protected virtual double AtmospheresPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilopascalsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilopascalsPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerSquareInchPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegapascalsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double MegapascalsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegapoundsForcePerSquareInchPerMinuteTolerance { get { return 1e-5; } } + protected virtual double MegapoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } + protected virtual double MillimetersOfMercuryPerSecondTolerance { get { return 1e-5; } } + protected virtual double PascalsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double PascalsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerSquareInchPerMinuteTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerSquareInchPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PressureChangeRateUnit unit) @@ -288,7 +288,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1281,21 +1281,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PressureChangeRateUnit unit) { - var inBaseUnit = PressureChangeRate.From(1.0, PressureChangeRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = PressureChangeRate.From(1.0, PressureChangeRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = PressureChangeRate.From(1.0, PressureChangeRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PressureChangeRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PressureChangeRateUnit unit) @@ -1309,8 +1302,8 @@ public void ToUnit_WithSameUnits_AreEqual(PressureChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PressureChangeRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = PressureChangeRate.Units.First(u => u != PressureChangeRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = PressureChangeRate.Units.Where(u => u != PressureChangeRate.BaseUnit).DefaultIfEmpty(PressureChangeRate.BaseUnit).FirstOrDefault(); var quantity = PressureChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1544,9 +1537,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1580,41 +1572,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1627,25 +1614,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = PressureChangeRate.FromPascalsPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1687,7 +1671,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = PressureChangeRate.FromPascalsPerSecond(1.0); - Assert.Equal(PressureChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {PressureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 7d21a9bb4a..3db47ed7e7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -87,53 +87,53 @@ public abstract partial class PressureTestsBase : QuantityTestsBase protected abstract double TorrsInOnePascal { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AtmospheresTolerance { get { return 1E-5; } } - protected virtual double BarsTolerance { get { return 1E-5; } } - protected virtual double CentibarsTolerance { get { return 1E-5; } } - protected virtual double DecapascalsTolerance { get { return 1E-5; } } - protected virtual double DecibarsTolerance { get { return 1E-5; } } - protected virtual double DynesPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double FeetOfElevationTolerance { get { return 1E-5; } } - protected virtual double FeetOfHeadTolerance { get { return 1E-5; } } - protected virtual double GigapascalsTolerance { get { return 1E-5; } } - protected virtual double HectopascalsTolerance { get { return 1E-5; } } - protected virtual double InchesOfMercuryTolerance { get { return 1E-5; } } - protected virtual double InchesOfWaterColumnTolerance { get { return 1E-5; } } - protected virtual double KilobarsTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilopascalsTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerSquareFootTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerSquareInchTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerSquareMilTolerance { get { return 1E-5; } } - protected virtual double MegabarsTolerance { get { return 1E-5; } } - protected virtual double MeganewtonsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double MegapascalsTolerance { get { return 1E-5; } } - protected virtual double MetersOfElevationTolerance { get { return 1E-5; } } - protected virtual double MetersOfHeadTolerance { get { return 1E-5; } } - protected virtual double MicrobarsTolerance { get { return 1E-5; } } - protected virtual double MicropascalsTolerance { get { return 1E-5; } } - protected virtual double MillibarsTolerance { get { return 1E-5; } } - protected virtual double MillimetersOfMercuryTolerance { get { return 1E-5; } } - protected virtual double MillimeterOfWaterColumnTolerance { get { return 1E-5; } } - protected virtual double MillipascalsTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double PascalsTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerSquareFootTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerSquareInchTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerSquareMilTolerance { get { return 1E-5; } } - protected virtual double PoundsPerInchSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double TechnicalAtmospheresTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerSquareCentimeterTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerSquareMeterTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerSquareMillimeterTolerance { get { return 1E-5; } } - protected virtual double TorrsTolerance { get { return 1E-5; } } + protected virtual double AtmospheresTolerance { get { return 1e-5; } } + protected virtual double BarsTolerance { get { return 1e-5; } } + protected virtual double CentibarsTolerance { get { return 1e-5; } } + protected virtual double DecapascalsTolerance { get { return 1e-5; } } + protected virtual double DecibarsTolerance { get { return 1e-5; } } + protected virtual double DynesPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double FeetOfElevationTolerance { get { return 1e-5; } } + protected virtual double FeetOfHeadTolerance { get { return 1e-5; } } + protected virtual double GigapascalsTolerance { get { return 1e-5; } } + protected virtual double HectopascalsTolerance { get { return 1e-5; } } + protected virtual double InchesOfMercuryTolerance { get { return 1e-5; } } + protected virtual double InchesOfWaterColumnTolerance { get { return 1e-5; } } + protected virtual double KilobarsTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilopascalsTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerSquareFootTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerSquareInchTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerSquareMilTolerance { get { return 1e-5; } } + protected virtual double MegabarsTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double MegapascalsTolerance { get { return 1e-5; } } + protected virtual double MetersOfElevationTolerance { get { return 1e-5; } } + protected virtual double MetersOfHeadTolerance { get { return 1e-5; } } + protected virtual double MicrobarsTolerance { get { return 1e-5; } } + protected virtual double MicropascalsTolerance { get { return 1e-5; } } + protected virtual double MillibarsTolerance { get { return 1e-5; } } + protected virtual double MillimetersOfMercuryTolerance { get { return 1e-5; } } + protected virtual double MillimeterOfWaterColumnTolerance { get { return 1e-5; } } + protected virtual double MillipascalsTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double PascalsTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerSquareFootTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerSquareInchTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerSquareMilTolerance { get { return 1e-5; } } + protected virtual double PoundsPerInchSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double TechnicalAtmospheresTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerSquareCentimeterTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerSquareMeterTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerSquareMillimeterTolerance { get { return 1e-5; } } + protected virtual double TorrsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PressureUnit unit) @@ -618,7 +618,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2629,21 +2629,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(PressureUnit unit) { - var inBaseUnit = Pressure.From(1.0, Pressure.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Pressure.From(1.0, Pressure.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Pressure.From(1.0, Pressure.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(PressureUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(PressureUnit unit) @@ -2657,8 +2650,8 @@ public void ToUnit_WithSameUnits_AreEqual(PressureUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(PressureUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Pressure.Units.First(u => u != Pressure.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Pressure.Units.Where(u => u != Pressure.BaseUnit).DefaultIfEmpty(Pressure.BaseUnit).FirstOrDefault(); var quantity = Pressure.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2991,9 +2984,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -3027,41 +3019,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -3074,25 +3061,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Pressure.FromPascals(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Pressure.FromPascals(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -3134,7 +3118,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Pressure.FromPascals(1.0); - Assert.Equal(Pressure.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Pressure.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 3978af69d0..989c017044 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class RatioChangeRateTestsBase : QuantityTestsBase protected abstract double PercentsPerSecondInOneDecimalFractionPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecimalFractionsPerSecondTolerance { get { return 1E-5; } } - protected virtual double PercentsPerSecondTolerance { get { return 1E-5; } } + protected virtual double DecimalFractionsPerSecondTolerance { get { return 1e-5; } } + protected virtual double PercentsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RatioChangeRateUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,21 +249,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RatioChangeRateUnit unit) { - var inBaseUnit = RatioChangeRate.From(1.0, RatioChangeRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = RatioChangeRate.From(1.0, RatioChangeRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = RatioChangeRate.From(1.0, RatioChangeRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RatioChangeRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RatioChangeRateUnit unit) @@ -277,8 +270,8 @@ public void ToUnit_WithSameUnits_AreEqual(RatioChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RatioChangeRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = RatioChangeRate.Units.First(u => u != RatioChangeRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RatioChangeRate.Units.Where(u => u != RatioChangeRate.BaseUnit).DefaultIfEmpty(RatioChangeRate.BaseUnit).FirstOrDefault(); var quantity = RatioChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -476,9 +469,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -512,41 +504,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -559,25 +546,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -619,7 +603,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RatioChangeRate.FromDecimalFractionsPerSecond(1.0); - Assert.Equal(RatioChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {RatioChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 4c84253dd5..8714c6f6a3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class RatioTestsBase : QuantityTestsBase protected abstract double PercentInOneDecimalFraction { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DecimalFractionsTolerance { get { return 1E-5; } } - protected virtual double PartsPerBillionTolerance { get { return 1E-5; } } - protected virtual double PartsPerMillionTolerance { get { return 1E-5; } } - protected virtual double PartsPerThousandTolerance { get { return 1E-5; } } - protected virtual double PartsPerTrillionTolerance { get { return 1E-5; } } - protected virtual double PercentTolerance { get { return 1E-5; } } + protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } + protected virtual double PercentTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RatioUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -385,21 +385,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RatioUnit unit) { - var inBaseUnit = Ratio.From(1.0, Ratio.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Ratio.From(1.0, Ratio.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Ratio.From(1.0, Ratio.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RatioUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RatioUnit unit) @@ -413,8 +406,8 @@ public void ToUnit_WithSameUnits_AreEqual(RatioUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RatioUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Ratio.Units.First(u => u != Ratio.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Ratio.Units.Where(u => u != Ratio.BaseUnit).DefaultIfEmpty(Ratio.BaseUnit).FirstOrDefault(); var quantity = Ratio.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -624,9 +617,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -660,41 +652,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -707,25 +694,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Ratio.FromDecimalFractions(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Ratio.FromDecimalFractions(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -767,7 +751,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Ratio.FromDecimalFractions(1.0); - Assert.Equal(Ratio.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Ratio.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index be05f748b3..8c4ddb264c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class ReactiveEnergyTestsBase : QuantityTestsBase protected abstract double VoltampereReactiveHoursInOneVoltampereReactiveHour { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilovoltampereReactiveHoursTolerance { get { return 1E-5; } } - protected virtual double MegavoltampereReactiveHoursTolerance { get { return 1E-5; } } - protected virtual double VoltampereReactiveHoursTolerance { get { return 1E-5; } } + protected virtual double KilovoltampereReactiveHoursTolerance { get { return 1e-5; } } + protected virtual double MegavoltampereReactiveHoursTolerance { get { return 1e-5; } } + protected virtual double VoltampereReactiveHoursTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReactiveEnergyUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReactiveEnergyUnit unit) { - var inBaseUnit = ReactiveEnergy.From(1.0, ReactiveEnergy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ReactiveEnergy.From(1.0, ReactiveEnergy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ReactiveEnergy.From(1.0, ReactiveEnergy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ReactiveEnergyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReactiveEnergyUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReactiveEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReactiveEnergyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ReactiveEnergy.Units.First(u => u != ReactiveEnergy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ReactiveEnergy.Units.Where(u => u != ReactiveEnergy.BaseUnit).DefaultIfEmpty(ReactiveEnergy.BaseUnit).FirstOrDefault(); var quantity = ReactiveEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactiveEnergy.FromVoltampereReactiveHours(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReactiveEnergy.FromVoltampereReactiveHours(1.0); - Assert.Equal(ReactiveEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ReactiveEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index ef116e631d..807b553fda 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class ReactivePowerTestsBase : QuantityTestsBase protected abstract double VoltamperesReactiveInOneVoltampereReactive { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GigavoltamperesReactiveTolerance { get { return 1E-5; } } - protected virtual double KilovoltamperesReactiveTolerance { get { return 1E-5; } } - protected virtual double MegavoltamperesReactiveTolerance { get { return 1E-5; } } - protected virtual double VoltamperesReactiveTolerance { get { return 1E-5; } } + protected virtual double GigavoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double KilovoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double MegavoltamperesReactiveTolerance { get { return 1e-5; } } + protected virtual double VoltamperesReactiveTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReactivePowerUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReactivePowerUnit unit) { - var inBaseUnit = ReactivePower.From(1.0, ReactivePower.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ReactivePower.From(1.0, ReactivePower.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ReactivePower.From(1.0, ReactivePower.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ReactivePowerUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReactivePowerUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReactivePowerUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReactivePowerUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ReactivePower.Units.First(u => u != ReactivePower.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ReactivePower.Units.Where(u => u != ReactivePower.BaseUnit).DefaultIfEmpty(ReactivePower.BaseUnit).FirstOrDefault(); var quantity = ReactivePower.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReactivePower.FromVoltamperesReactive(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ReactivePower.FromVoltamperesReactive(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReactivePower.FromVoltamperesReactive(1.0); - Assert.Equal(ReactivePower.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ReactivePower.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 3b7ffb3eb6..93590fd301 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -51,17 +51,17 @@ public abstract partial class ReciprocalAreaTestsBase : QuantityTestsBase protected abstract double InverseUsSurveySquareFeetInOneInverseSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseSquareCentimetersTolerance { get { return 1E-5; } } - protected virtual double InverseSquareDecimetersTolerance { get { return 1E-5; } } - protected virtual double InverseSquareFeetTolerance { get { return 1E-5; } } - protected virtual double InverseSquareInchesTolerance { get { return 1E-5; } } - protected virtual double InverseSquareKilometersTolerance { get { return 1E-5; } } - protected virtual double InverseSquareMetersTolerance { get { return 1E-5; } } - protected virtual double InverseSquareMicrometersTolerance { get { return 1E-5; } } - protected virtual double InverseSquareMilesTolerance { get { return 1E-5; } } - protected virtual double InverseSquareMillimetersTolerance { get { return 1E-5; } } - protected virtual double InverseSquareYardsTolerance { get { return 1E-5; } } - protected virtual double InverseUsSurveySquareFeetTolerance { get { return 1E-5; } } + protected virtual double InverseSquareCentimetersTolerance { get { return 1e-5; } } + protected virtual double InverseSquareDecimetersTolerance { get { return 1e-5; } } + protected virtual double InverseSquareFeetTolerance { get { return 1e-5; } } + protected virtual double InverseSquareInchesTolerance { get { return 1e-5; } } + protected virtual double InverseSquareKilometersTolerance { get { return 1e-5; } } + protected virtual double InverseSquareMetersTolerance { get { return 1e-5; } } + protected virtual double InverseSquareMicrometersTolerance { get { return 1e-5; } } + protected virtual double InverseSquareMilesTolerance { get { return 1e-5; } } + protected virtual double InverseSquareMillimetersTolerance { get { return 1e-5; } } + protected virtual double InverseSquareYardsTolerance { get { return 1e-5; } } + protected virtual double InverseUsSurveySquareFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReciprocalAreaUnit unit) @@ -258,7 +258,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -555,21 +555,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReciprocalAreaUnit unit) { - var inBaseUnit = ReciprocalArea.From(1.0, ReciprocalArea.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ReciprocalArea.From(1.0, ReciprocalArea.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ReciprocalArea.From(1.0, ReciprocalArea.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ReciprocalAreaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReciprocalAreaUnit unit) @@ -583,8 +576,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReciprocalAreaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReciprocalAreaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ReciprocalArea.Units.First(u => u != ReciprocalArea.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ReciprocalArea.Units.Where(u => u != ReciprocalArea.BaseUnit).DefaultIfEmpty(ReciprocalArea.BaseUnit).FirstOrDefault(); var quantity = ReciprocalArea.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -809,9 +802,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -845,41 +837,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -892,25 +879,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalArea.FromInverseSquareMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -952,7 +936,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReciprocalArea.FromInverseSquareMeters(1.0); - Assert.Equal(ReciprocalArea.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ReciprocalArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index a4292f5bdb..3de7afaf9e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class ReciprocalLengthTestsBase : QuantityTestsBase protected abstract double InverseYardsInOneInverseMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InverseCentimetersTolerance { get { return 1E-5; } } - protected virtual double InverseFeetTolerance { get { return 1E-5; } } - protected virtual double InverseInchesTolerance { get { return 1E-5; } } - protected virtual double InverseMetersTolerance { get { return 1E-5; } } - protected virtual double InverseMicroinchesTolerance { get { return 1E-5; } } - protected virtual double InverseMilsTolerance { get { return 1E-5; } } - protected virtual double InverseMilesTolerance { get { return 1E-5; } } - protected virtual double InverseMillimetersTolerance { get { return 1E-5; } } - protected virtual double InverseUsSurveyFeetTolerance { get { return 1E-5; } } - protected virtual double InverseYardsTolerance { get { return 1E-5; } } + protected virtual double InverseCentimetersTolerance { get { return 1e-5; } } + protected virtual double InverseFeetTolerance { get { return 1e-5; } } + protected virtual double InverseInchesTolerance { get { return 1e-5; } } + protected virtual double InverseMetersTolerance { get { return 1e-5; } } + protected virtual double InverseMicroinchesTolerance { get { return 1e-5; } } + protected virtual double InverseMilsTolerance { get { return 1e-5; } } + protected virtual double InverseMilesTolerance { get { return 1e-5; } } + protected virtual double InverseMillimetersTolerance { get { return 1e-5; } } + protected virtual double InverseUsSurveyFeetTolerance { get { return 1e-5; } } + protected virtual double InverseYardsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ReciprocalLengthUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -761,21 +761,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ReciprocalLengthUnit unit) { - var inBaseUnit = ReciprocalLength.From(1.0, ReciprocalLength.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ReciprocalLength.From(1.0, ReciprocalLength.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ReciprocalLength.From(1.0, ReciprocalLength.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ReciprocalLengthUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ReciprocalLengthUnit unit) @@ -789,8 +782,8 @@ public void ToUnit_WithSameUnits_AreEqual(ReciprocalLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ReciprocalLengthUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ReciprocalLength.Units.First(u => u != ReciprocalLength.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ReciprocalLength.Units.Where(u => u != ReciprocalLength.BaseUnit).DefaultIfEmpty(ReciprocalLength.BaseUnit).FirstOrDefault(); var quantity = ReciprocalLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1012,9 +1005,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1048,41 +1040,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1095,25 +1082,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ReciprocalLength.FromInverseMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ReciprocalLength.FromInverseMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1155,7 +1139,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ReciprocalLength.FromInverseMeters(1.0); - Assert.Equal(ReciprocalLength.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ReciprocalLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index cd282ea216..60f67c7468 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class RelativeHumidityTestsBase : QuantityTestsBase protected abstract double PercentInOnePercent { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double PercentTolerance { get { return 1E-5; } } + protected virtual double PercentTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RelativeHumidityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RelativeHumidityUnit unit) { - var inBaseUnit = RelativeHumidity.From(1.0, RelativeHumidity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = RelativeHumidity.From(1.0, RelativeHumidity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = RelativeHumidity.From(1.0, RelativeHumidity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RelativeHumidityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RelativeHumidityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(RelativeHumidityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RelativeHumidityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = RelativeHumidity.Units.First(u => u != RelativeHumidity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RelativeHumidity.Units.Where(u => u != RelativeHumidity.BaseUnit).DefaultIfEmpty(RelativeHumidity.BaseUnit).FirstOrDefault(); var quantity = RelativeHumidity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RelativeHumidity.FromPercent(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = RelativeHumidity.FromPercent(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RelativeHumidity.FromPercent(1.0); - Assert.Equal(RelativeHumidity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {RelativeHumidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index 1b6e0489a5..f0cc297b7e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class RotationalAccelerationTestsBase : QuantityTestsBas protected abstract double RevolutionsPerSecondSquaredInOneRadianPerSecondSquared { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double RadiansPerSecondSquaredTolerance { get { return 1E-5; } } - protected virtual double RevolutionsPerMinutePerSecondTolerance { get { return 1E-5; } } - protected virtual double RevolutionsPerSecondSquaredTolerance { get { return 1E-5; } } + protected virtual double DegreesPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double RadiansPerSecondSquaredTolerance { get { return 1e-5; } } + protected virtual double RevolutionsPerMinutePerSecondTolerance { get { return 1e-5; } } + protected virtual double RevolutionsPerSecondSquaredTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalAccelerationUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -341,21 +341,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalAccelerationUnit unit) { - var inBaseUnit = RotationalAcceleration.From(1.0, RotationalAcceleration.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = RotationalAcceleration.From(1.0, RotationalAcceleration.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = RotationalAcceleration.From(1.0, RotationalAcceleration.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalAccelerationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalAccelerationUnit unit) @@ -369,8 +362,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalAccelerationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalAccelerationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = RotationalAcceleration.Units.First(u => u != RotationalAcceleration.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RotationalAcceleration.Units.Where(u => u != RotationalAcceleration.BaseUnit).DefaultIfEmpty(RotationalAcceleration.BaseUnit).FirstOrDefault(); var quantity = RotationalAcceleration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -574,9 +567,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -610,41 +602,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -657,25 +644,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -717,7 +701,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalAcceleration.FromRadiansPerSecondSquared(1.0); - Assert.Equal(RotationalAcceleration.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {RotationalAcceleration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index 084fe1f460..a2df678911 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -53,19 +53,19 @@ public abstract partial class RotationalSpeedTestsBase : QuantityTestsBase protected abstract double RevolutionsPerSecondInOneRadianPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentiradiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double DeciradiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double DegreesPerMinuteTolerance { get { return 1E-5; } } - protected virtual double DegreesPerSecondTolerance { get { return 1E-5; } } - protected virtual double MicrodegreesPerSecondTolerance { get { return 1E-5; } } - protected virtual double MicroradiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double MillidegreesPerSecondTolerance { get { return 1E-5; } } - protected virtual double MilliradiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanodegreesPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanoradiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double RadiansPerSecondTolerance { get { return 1E-5; } } - protected virtual double RevolutionsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double RevolutionsPerSecondTolerance { get { return 1E-5; } } + protected virtual double CentiradiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double DeciradiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double DegreesPerMinuteTolerance { get { return 1e-5; } } + protected virtual double DegreesPerSecondTolerance { get { return 1e-5; } } + protected virtual double MicrodegreesPerSecondTolerance { get { return 1e-5; } } + protected virtual double MicroradiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double MillidegreesPerSecondTolerance { get { return 1e-5; } } + protected virtual double MilliradiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanodegreesPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanoradiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double RadiansPerSecondTolerance { get { return 1e-5; } } + protected virtual double RevolutionsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double RevolutionsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalSpeedUnit unit) @@ -278,7 +278,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1055,21 +1055,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalSpeedUnit unit) { - var inBaseUnit = RotationalSpeed.From(1.0, RotationalSpeed.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = RotationalSpeed.From(1.0, RotationalSpeed.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = RotationalSpeed.From(1.0, RotationalSpeed.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalSpeedUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalSpeedUnit unit) @@ -1083,8 +1076,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalSpeedUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalSpeedUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = RotationalSpeed.Units.First(u => u != RotationalSpeed.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RotationalSpeed.Units.Where(u => u != RotationalSpeed.BaseUnit).DefaultIfEmpty(RotationalSpeed.BaseUnit).FirstOrDefault(); var quantity = RotationalSpeed.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1315,9 +1308,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1351,41 +1343,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1398,25 +1385,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalSpeed.FromRadiansPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1458,7 +1442,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalSpeed.FromRadiansPerSecond(1.0); - Assert.Equal(RotationalSpeed.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {RotationalSpeed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 02d476b09e..7880b8d001 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -45,11 +45,11 @@ public abstract partial class RotationalStiffnessPerLengthTestsBase : QuantityTe protected abstract double PoundForceFeetPerDegreesPerFeetInOneNewtonMeterPerRadianPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilonewtonMetersPerRadianPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilopoundForceFeetPerDegreesPerFeetTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMetersPerRadianPerMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonMetersPerRadianPerMeterTolerance { get { return 1E-5; } } - protected virtual double PoundForceFeetPerDegreesPerFeetTolerance { get { return 1E-5; } } + protected virtual double KilonewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilopoundForceFeetPerDegreesPerFeetTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersPerRadianPerMeterTolerance { get { return 1e-5; } } + protected virtual double PoundForceFeetPerDegreesPerFeetTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalStiffnessPerLengthUnit unit) @@ -198,7 +198,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -543,21 +543,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalStiffnessPerLengthUnit unit) { - var inBaseUnit = RotationalStiffnessPerLength.From(1.0, RotationalStiffnessPerLength.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = RotationalStiffnessPerLength.From(1.0, RotationalStiffnessPerLength.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = RotationalStiffnessPerLength.From(1.0, RotationalStiffnessPerLength.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalStiffnessPerLengthUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessPerLengthUnit unit) @@ -571,8 +564,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessPerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalStiffnessPerLengthUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = RotationalStiffnessPerLength.Units.First(u => u != RotationalStiffnessPerLength.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RotationalStiffnessPerLength.Units.Where(u => u != RotationalStiffnessPerLength.BaseUnit).DefaultIfEmpty(RotationalStiffnessPerLength.BaseUnit).FirstOrDefault(); var quantity = RotationalStiffnessPerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -779,9 +772,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -815,41 +807,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -862,25 +849,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -922,7 +906,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalStiffnessPerLength.FromNewtonMetersPerRadianPerMeter(1.0); - Assert.Equal(RotationalStiffnessPerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {RotationalStiffnessPerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index afc2d9ab68..8557dab512 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -73,39 +73,39 @@ public abstract partial class RotationalStiffnessTestsBase : QuantityTestsBase protected abstract double PoundForceFeetPerDegreesInOneNewtonMeterPerRadian { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentinewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double CentinewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double CentinewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double DecanewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double DecanewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double DecanewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double DecinewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double DecinewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double DecinewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double KilopoundForceFeetPerDegreesTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double MicronewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double MicronewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double MicronewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double MillinewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double MillinewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double MillinewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double NanonewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double NanonewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double NanonewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double NewtonMetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double NewtonMetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double NewtonMillimetersPerDegreeTolerance { get { return 1E-5; } } - protected virtual double NewtonMillimetersPerRadianTolerance { get { return 1E-5; } } - protected virtual double PoundForceFeetPerRadianTolerance { get { return 1E-5; } } - protected virtual double PoundForceFeetPerDegreesTolerance { get { return 1E-5; } } + protected virtual double CentinewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double CentinewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double CentinewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double DecanewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double DecanewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double DecanewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double DecinewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double DecinewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double DecinewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double KilopoundForceFeetPerDegreesTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double MicronewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double MicronewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double MicronewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double MillinewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double MillinewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double MillinewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double NanonewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double NanonewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double NanonewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double NewtonMillimetersPerDegreeTolerance { get { return 1e-5; } } + protected virtual double NewtonMillimetersPerRadianTolerance { get { return 1e-5; } } + protected virtual double PoundForceFeetPerRadianTolerance { get { return 1e-5; } } + protected virtual double PoundForceFeetPerDegreesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(RotationalStiffnessUnit unit) @@ -478,7 +478,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2787,21 +2787,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(RotationalStiffnessUnit unit) { - var inBaseUnit = RotationalStiffness.From(1.0, RotationalStiffness.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = RotationalStiffness.From(1.0, RotationalStiffness.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = RotationalStiffness.From(1.0, RotationalStiffness.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(RotationalStiffnessUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessUnit unit) @@ -2815,8 +2808,8 @@ public void ToUnit_WithSameUnits_AreEqual(RotationalStiffnessUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(RotationalStiffnessUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = RotationalStiffness.Units.First(u => u != RotationalStiffness.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = RotationalStiffness.Units.Where(u => u != RotationalStiffness.BaseUnit).DefaultIfEmpty(RotationalStiffness.BaseUnit).FirstOrDefault(); var quantity = RotationalStiffness.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -3107,9 +3100,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -3143,41 +3135,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -3190,25 +3177,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = RotationalStiffness.FromNewtonMetersPerRadian(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -3250,7 +3234,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = RotationalStiffness.FromNewtonMetersPerRadian(1.0); - Assert.Equal(RotationalStiffness.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {RotationalStiffness.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index ed5f413d32..427c4da867 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class ScalarTestsBase : QuantityTestsBase protected abstract double AmountInOneAmount { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AmountTolerance { get { return 1E-5; } } + protected virtual double AmountTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ScalarUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ScalarUnit unit) { - var inBaseUnit = Scalar.From(1.0, Scalar.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Scalar.From(1.0, Scalar.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Scalar.From(1.0, Scalar.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ScalarUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ScalarUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(ScalarUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ScalarUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Scalar.Units.First(u => u != Scalar.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Scalar.Units.Where(u => u != Scalar.BaseUnit).DefaultIfEmpty(Scalar.BaseUnit).FirstOrDefault(); var quantity = Scalar.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Scalar.FromAmount(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Scalar.FromAmount(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Scalar.FromAmount(1.0); - Assert.Equal(Scalar.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Scalar.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 3785ea8be3..6fe1a3602c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class SolidAngleTestsBase : QuantityTestsBase protected abstract double SteradiansInOneSteradian { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double SteradiansTolerance { get { return 1E-5; } } + protected virtual double SteradiansTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SolidAngleUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SolidAngleUnit unit) { - var inBaseUnit = SolidAngle.From(1.0, SolidAngle.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = SolidAngle.From(1.0, SolidAngle.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = SolidAngle.From(1.0, SolidAngle.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SolidAngleUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SolidAngleUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(SolidAngleUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SolidAngleUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = SolidAngle.Units.First(u => u != SolidAngle.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = SolidAngle.Units.Where(u => u != SolidAngle.BaseUnit).DefaultIfEmpty(SolidAngle.BaseUnit).FirstOrDefault(); var quantity = SolidAngle.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SolidAngle.FromSteradians(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = SolidAngle.FromSteradians(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SolidAngle.FromSteradians(1.0); - Assert.Equal(SolidAngle.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {SolidAngle.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 0c2e9defed..32be1e830a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -69,35 +69,35 @@ public abstract partial class SpecificEnergyTestsBase : QuantityTestsBase protected abstract double WattHoursPerPoundInOneJoulePerKilogram { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtuPerPoundTolerance { get { return 1E-5; } } - protected virtual double CaloriesPerGramTolerance { get { return 1E-5; } } - protected virtual double GigawattDaysPerKilogramTolerance { get { return 1E-5; } } - protected virtual double GigawattDaysPerShortTonTolerance { get { return 1E-5; } } - protected virtual double GigawattDaysPerTonneTolerance { get { return 1E-5; } } - protected virtual double GigawattHoursPerKilogramTolerance { get { return 1E-5; } } - protected virtual double GigawattHoursPerPoundTolerance { get { return 1E-5; } } - protected virtual double JoulesPerKilogramTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesPerGramTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerKilogramTolerance { get { return 1E-5; } } - protected virtual double KilowattDaysPerKilogramTolerance { get { return 1E-5; } } - protected virtual double KilowattDaysPerShortTonTolerance { get { return 1E-5; } } - protected virtual double KilowattDaysPerTonneTolerance { get { return 1E-5; } } - protected virtual double KilowattHoursPerKilogramTolerance { get { return 1E-5; } } - protected virtual double KilowattHoursPerPoundTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerKilogramTolerance { get { return 1E-5; } } - protected virtual double MegawattDaysPerKilogramTolerance { get { return 1E-5; } } - protected virtual double MegawattDaysPerShortTonTolerance { get { return 1E-5; } } - protected virtual double MegawattDaysPerTonneTolerance { get { return 1E-5; } } - protected virtual double MegawattHoursPerKilogramTolerance { get { return 1E-5; } } - protected virtual double MegawattHoursPerPoundTolerance { get { return 1E-5; } } - protected virtual double TerawattDaysPerKilogramTolerance { get { return 1E-5; } } - protected virtual double TerawattDaysPerShortTonTolerance { get { return 1E-5; } } - protected virtual double TerawattDaysPerTonneTolerance { get { return 1E-5; } } - protected virtual double WattDaysPerKilogramTolerance { get { return 1E-5; } } - protected virtual double WattDaysPerShortTonTolerance { get { return 1E-5; } } - protected virtual double WattDaysPerTonneTolerance { get { return 1E-5; } } - protected virtual double WattHoursPerKilogramTolerance { get { return 1E-5; } } - protected virtual double WattHoursPerPoundTolerance { get { return 1E-5; } } + protected virtual double BtuPerPoundTolerance { get { return 1e-5; } } + protected virtual double CaloriesPerGramTolerance { get { return 1e-5; } } + protected virtual double GigawattDaysPerKilogramTolerance { get { return 1e-5; } } + protected virtual double GigawattDaysPerShortTonTolerance { get { return 1e-5; } } + protected virtual double GigawattDaysPerTonneTolerance { get { return 1e-5; } } + protected virtual double GigawattHoursPerKilogramTolerance { get { return 1e-5; } } + protected virtual double GigawattHoursPerPoundTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerGramTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilowattDaysPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilowattDaysPerShortTonTolerance { get { return 1e-5; } } + protected virtual double KilowattDaysPerTonneTolerance { get { return 1e-5; } } + protected virtual double KilowattHoursPerKilogramTolerance { get { return 1e-5; } } + protected virtual double KilowattHoursPerPoundTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MegawattDaysPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MegawattDaysPerShortTonTolerance { get { return 1e-5; } } + protected virtual double MegawattDaysPerTonneTolerance { get { return 1e-5; } } + protected virtual double MegawattHoursPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MegawattHoursPerPoundTolerance { get { return 1e-5; } } + protected virtual double TerawattDaysPerKilogramTolerance { get { return 1e-5; } } + protected virtual double TerawattDaysPerShortTonTolerance { get { return 1e-5; } } + protected virtual double TerawattDaysPerTonneTolerance { get { return 1e-5; } } + protected virtual double WattDaysPerKilogramTolerance { get { return 1e-5; } } + protected virtual double WattDaysPerShortTonTolerance { get { return 1e-5; } } + protected virtual double WattDaysPerTonneTolerance { get { return 1e-5; } } + protected virtual double WattHoursPerKilogramTolerance { get { return 1e-5; } } + protected virtual double WattHoursPerPoundTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificEnergyUnit unit) @@ -438,7 +438,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1167,21 +1167,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificEnergyUnit unit) { - var inBaseUnit = SpecificEnergy.From(1.0, SpecificEnergy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = SpecificEnergy.From(1.0, SpecificEnergy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = SpecificEnergy.From(1.0, SpecificEnergy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificEnergyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificEnergyUnit unit) @@ -1195,8 +1188,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificEnergyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificEnergyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = SpecificEnergy.Units.First(u => u != SpecificEnergy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = SpecificEnergy.Units.Where(u => u != SpecificEnergy.BaseUnit).DefaultIfEmpty(SpecificEnergy.BaseUnit).FirstOrDefault(); var quantity = SpecificEnergy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1475,9 +1468,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1511,41 +1503,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1558,25 +1545,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEnergy.FromJoulesPerKilogram(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1618,7 +1602,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificEnergy.FromJoulesPerKilogram(1.0); - Assert.Equal(SpecificEnergy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {SpecificEnergy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index 751acae18f..b58e37b641 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class SpecificEntropyTestsBase : QuantityTestsBase protected abstract double MegajoulesPerKilogramKelvinInOneJoulePerKilogramKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerPoundFahrenheitTolerance { get { return 1E-5; } } - protected virtual double CaloriesPerGramKelvinTolerance { get { return 1E-5; } } - protected virtual double JoulesPerKilogramDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double JoulesPerKilogramKelvinTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesPerGramKelvinTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerKilogramDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerKilogramKelvinTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerKilogramDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerKilogramKelvinTolerance { get { return 1E-5; } } + protected virtual double BtusPerPoundFahrenheitTolerance { get { return 1e-5; } } + protected virtual double CaloriesPerGramKelvinTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKilogramDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double JoulesPerKilogramKelvinTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerGramKelvinTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKilogramDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerKilogramKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKilogramDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerKilogramKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificEntropyUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -511,21 +511,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificEntropyUnit unit) { - var inBaseUnit = SpecificEntropy.From(1.0, SpecificEntropy.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = SpecificEntropy.From(1.0, SpecificEntropy.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = SpecificEntropy.From(1.0, SpecificEntropy.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificEntropyUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificEntropyUnit unit) @@ -539,8 +532,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificEntropyUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificEntropyUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = SpecificEntropy.Units.First(u => u != SpecificEntropy.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = SpecificEntropy.Units.Where(u => u != SpecificEntropy.BaseUnit).DefaultIfEmpty(SpecificEntropy.BaseUnit).FirstOrDefault(); var quantity = SpecificEntropy.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -759,9 +752,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -795,41 +787,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -842,25 +829,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -902,7 +886,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificEntropy.FromJoulesPerKilogramKelvin(1.0); - Assert.Equal(SpecificEntropy.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {SpecificEntropy.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index b3b875a146..e0e7e9e8cc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class SpecificFuelConsumptionTestsBase : QuantityTestsBa protected abstract double PoundsMassPerPoundForceHourInOneGramPerKiloNewtonSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramsPerKiloNewtonSecondTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerKilogramForceHourTolerance { get { return 1E-5; } } - protected virtual double KilogramsPerKiloNewtonSecondTolerance { get { return 1E-5; } } - protected virtual double PoundsMassPerPoundForceHourTolerance { get { return 1E-5; } } + protected virtual double GramsPerKiloNewtonSecondTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerKilogramForceHourTolerance { get { return 1e-5; } } + protected virtual double KilogramsPerKiloNewtonSecondTolerance { get { return 1e-5; } } + protected virtual double PoundsMassPerPoundForceHourTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificFuelConsumptionUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificFuelConsumptionUnit unit) { - var inBaseUnit = SpecificFuelConsumption.From(1.0, SpecificFuelConsumption.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = SpecificFuelConsumption.From(1.0, SpecificFuelConsumption.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = SpecificFuelConsumption.From(1.0, SpecificFuelConsumption.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificFuelConsumptionUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificFuelConsumptionUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificFuelConsumptionUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificFuelConsumptionUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = SpecificFuelConsumption.Units.First(u => u != SpecificFuelConsumption.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = SpecificFuelConsumption.Units.Where(u => u != SpecificFuelConsumption.BaseUnit).DefaultIfEmpty(SpecificFuelConsumption.BaseUnit).FirstOrDefault(); var quantity = SpecificFuelConsumption.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificFuelConsumption.FromGramsPerKiloNewtonSecond(1.0); - Assert.Equal(SpecificFuelConsumption.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {SpecificFuelConsumption.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 770ffe6f5d..44c9025100 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -43,9 +43,9 @@ public abstract partial class SpecificVolumeTestsBase : QuantityTestsBase protected abstract double MillicubicMetersPerKilogramInOneCubicMeterPerKilogram { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CubicFeetPerPoundTolerance { get { return 1E-5; } } - protected virtual double CubicMetersPerKilogramTolerance { get { return 1E-5; } } - protected virtual double MillicubicMetersPerKilogramTolerance { get { return 1E-5; } } + protected virtual double CubicFeetPerPoundTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerKilogramTolerance { get { return 1e-5; } } + protected virtual double MillicubicMetersPerKilogramTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificVolumeUnit unit) @@ -178,7 +178,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -283,21 +283,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificVolumeUnit unit) { - var inBaseUnit = SpecificVolume.From(1.0, SpecificVolume.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = SpecificVolume.From(1.0, SpecificVolume.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = SpecificVolume.From(1.0, SpecificVolume.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificVolumeUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificVolumeUnit unit) @@ -311,8 +304,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificVolumeUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificVolumeUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = SpecificVolume.Units.First(u => u != SpecificVolume.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = SpecificVolume.Units.Where(u => u != SpecificVolume.BaseUnit).DefaultIfEmpty(SpecificVolume.BaseUnit).FirstOrDefault(); var quantity = SpecificVolume.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -513,9 +506,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -549,41 +541,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -596,25 +583,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificVolume.FromCubicMetersPerKilogram(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -656,7 +640,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificVolume.FromCubicMetersPerKilogram(1.0); - Assert.Equal(SpecificVolume.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {SpecificVolume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index 300b216a12..daf5cffeae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -57,23 +57,23 @@ public abstract partial class SpecificWeightTestsBase : QuantityTestsBase protected abstract double TonnesForcePerCubicMillimeterInOneNewtonPerCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramsForcePerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramsForcePerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerCubicFootTolerance { get { return 1E-5; } } - protected virtual double KilopoundsForcePerCubicInchTolerance { get { return 1E-5; } } - protected virtual double MeganewtonsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonsPerCubicMillimeterTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerCubicFootTolerance { get { return 1E-5; } } - protected virtual double PoundsForcePerCubicInchTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerCubicCentimeterTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerCubicMeterTolerance { get { return 1E-5; } } - protected virtual double TonnesForcePerCubicMillimeterTolerance { get { return 1E-5; } } + protected virtual double KilogramsForcePerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramsForcePerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerCubicFootTolerance { get { return 1e-5; } } + protected virtual double KilopoundsForcePerCubicInchTolerance { get { return 1e-5; } } + protected virtual double MeganewtonsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonsPerCubicMillimeterTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerCubicFootTolerance { get { return 1e-5; } } + protected virtual double PoundsForcePerCubicInchTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerCubicCentimeterTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerCubicMeterTolerance { get { return 1e-5; } } + protected virtual double TonnesForcePerCubicMillimeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpecificWeightUnit unit) @@ -318,7 +318,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -759,21 +759,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpecificWeightUnit unit) { - var inBaseUnit = SpecificWeight.From(1.0, SpecificWeight.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = SpecificWeight.From(1.0, SpecificWeight.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = SpecificWeight.From(1.0, SpecificWeight.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SpecificWeightUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpecificWeightUnit unit) @@ -787,8 +780,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpecificWeightUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpecificWeightUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = SpecificWeight.Units.First(u => u != SpecificWeight.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = SpecificWeight.Units.Where(u => u != SpecificWeight.BaseUnit).DefaultIfEmpty(SpecificWeight.BaseUnit).FirstOrDefault(); var quantity = SpecificWeight.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1031,9 +1024,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1067,41 +1059,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1114,25 +1101,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = SpecificWeight.FromNewtonsPerCubicMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1174,7 +1158,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = SpecificWeight.FromNewtonsPerCubicMeter(1.0); - Assert.Equal(SpecificWeight.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {SpecificWeight.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 6f91fa89b4..9ef94f5cab 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -72,38 +72,38 @@ public abstract partial class SpeedTestsBase : QuantityTestsBase protected abstract double YardsPerSecondInOneMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersPerHourTolerance { get { return 1E-5; } } - protected virtual double CentimetersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double CentimetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecimetersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double DecimetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double FeetPerHourTolerance { get { return 1E-5; } } - protected virtual double FeetPerMinuteTolerance { get { return 1E-5; } } - protected virtual double FeetPerSecondTolerance { get { return 1E-5; } } - protected virtual double InchesPerHourTolerance { get { return 1E-5; } } - protected virtual double InchesPerMinuteTolerance { get { return 1E-5; } } - protected virtual double InchesPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilometersPerHourTolerance { get { return 1E-5; } } - protected virtual double KilometersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double KilometersPerSecondTolerance { get { return 1E-5; } } - protected virtual double KnotsTolerance { get { return 1E-5; } } - protected virtual double MetersPerHourTolerance { get { return 1E-5; } } - protected virtual double MetersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double MetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double MicrometersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double MicrometersPerSecondTolerance { get { return 1E-5; } } - protected virtual double MilesPerHourTolerance { get { return 1E-5; } } - protected virtual double MillimetersPerHourTolerance { get { return 1E-5; } } - protected virtual double MillimetersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double MillimetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanometersPerMinutesTolerance { get { return 1E-5; } } - protected virtual double NanometersPerSecondTolerance { get { return 1E-5; } } - protected virtual double UsSurveyFeetPerHourTolerance { get { return 1E-5; } } - protected virtual double UsSurveyFeetPerMinuteTolerance { get { return 1E-5; } } - protected virtual double UsSurveyFeetPerSecondTolerance { get { return 1E-5; } } - protected virtual double YardsPerHourTolerance { get { return 1E-5; } } - protected virtual double YardsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double YardsPerSecondTolerance { get { return 1E-5; } } + protected virtual double CentimetersPerHourTolerance { get { return 1e-5; } } + protected virtual double CentimetersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double CentimetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecimetersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double DecimetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double FeetPerHourTolerance { get { return 1e-5; } } + protected virtual double FeetPerMinuteTolerance { get { return 1e-5; } } + protected virtual double FeetPerSecondTolerance { get { return 1e-5; } } + protected virtual double InchesPerHourTolerance { get { return 1e-5; } } + protected virtual double InchesPerMinuteTolerance { get { return 1e-5; } } + protected virtual double InchesPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilometersPerHourTolerance { get { return 1e-5; } } + protected virtual double KilometersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double KilometersPerSecondTolerance { get { return 1e-5; } } + protected virtual double KnotsTolerance { get { return 1e-5; } } + protected virtual double MetersPerHourTolerance { get { return 1e-5; } } + protected virtual double MetersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double MetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double MicrometersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double MicrometersPerSecondTolerance { get { return 1e-5; } } + protected virtual double MilesPerHourTolerance { get { return 1e-5; } } + protected virtual double MillimetersPerHourTolerance { get { return 1e-5; } } + protected virtual double MillimetersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double MillimetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanometersPerMinutesTolerance { get { return 1e-5; } } + protected virtual double NanometersPerSecondTolerance { get { return 1e-5; } } + protected virtual double UsSurveyFeetPerHourTolerance { get { return 1e-5; } } + protected virtual double UsSurveyFeetPerMinuteTolerance { get { return 1e-5; } } + protected virtual double UsSurveyFeetPerSecondTolerance { get { return 1e-5; } } + protected virtual double YardsPerHourTolerance { get { return 1e-5; } } + protected virtual double YardsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double YardsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(SpeedUnit unit) @@ -468,7 +468,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1893,21 +1893,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(SpeedUnit unit) { - var inBaseUnit = Speed.From(1.0, Speed.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Speed.From(1.0, Speed.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Speed.From(1.0, Speed.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(SpeedUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(SpeedUnit unit) @@ -1921,8 +1914,8 @@ public void ToUnit_WithSameUnits_AreEqual(SpeedUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(SpeedUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Speed.Units.First(u => u != Speed.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Speed.Units.Where(u => u != Speed.BaseUnit).DefaultIfEmpty(Speed.BaseUnit).FirstOrDefault(); var quantity = Speed.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -2210,9 +2203,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -2246,41 +2238,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -2293,25 +2280,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Speed.FromMetersPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Speed.FromMetersPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -2353,7 +2337,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Speed.FromMetersPerSecond(1.0); - Assert.Equal(Speed.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Speed.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 29b28819d8..7dfaf4c928 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class StandardVolumeFlowTestsBase : QuantityTestsBase protected abstract double StandardLitersPerMinuteInOneStandardCubicMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double StandardCubicCentimetersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double StandardCubicFeetPerHourTolerance { get { return 1E-5; } } - protected virtual double StandardCubicFeetPerMinuteTolerance { get { return 1E-5; } } - protected virtual double StandardCubicFeetPerSecondTolerance { get { return 1E-5; } } - protected virtual double StandardCubicMetersPerDayTolerance { get { return 1E-5; } } - protected virtual double StandardCubicMetersPerHourTolerance { get { return 1E-5; } } - protected virtual double StandardCubicMetersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double StandardCubicMetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double StandardLitersPerMinuteTolerance { get { return 1E-5; } } + protected virtual double StandardCubicCentimetersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double StandardCubicFeetPerHourTolerance { get { return 1e-5; } } + protected virtual double StandardCubicFeetPerMinuteTolerance { get { return 1e-5; } } + protected virtual double StandardCubicFeetPerSecondTolerance { get { return 1e-5; } } + protected virtual double StandardCubicMetersPerDayTolerance { get { return 1e-5; } } + protected virtual double StandardCubicMetersPerHourTolerance { get { return 1e-5; } } + protected virtual double StandardCubicMetersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double StandardCubicMetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double StandardLitersPerMinuteTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(StandardVolumeFlowUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -487,21 +487,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(StandardVolumeFlowUnit unit) { - var inBaseUnit = StandardVolumeFlow.From(1.0, StandardVolumeFlow.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = StandardVolumeFlow.From(1.0, StandardVolumeFlow.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = StandardVolumeFlow.From(1.0, StandardVolumeFlow.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(StandardVolumeFlowUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(StandardVolumeFlowUnit unit) @@ -515,8 +508,8 @@ public void ToUnit_WithSameUnits_AreEqual(StandardVolumeFlowUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(StandardVolumeFlowUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = StandardVolumeFlow.Units.First(u => u != StandardVolumeFlow.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = StandardVolumeFlow.Units.Where(u => u != StandardVolumeFlow.BaseUnit).DefaultIfEmpty(StandardVolumeFlow.BaseUnit).FirstOrDefault(); var quantity = StandardVolumeFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -735,9 +728,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -771,41 +763,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -818,25 +805,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -878,7 +862,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = StandardVolumeFlow.FromStandardCubicMetersPerSecond(1.0); - Assert.Equal(StandardVolumeFlow.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {StandardVolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 1126f1cbf4..6e8098579d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class TemperatureChangeRateTestsBase : QuantityTestsBase protected abstract double NanodegreesCelsiusPerSecondInOneDegreeCelsiusPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentidegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecadegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecidegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double DegreesCelsiusPerMinuteTolerance { get { return 1E-5; } } - protected virtual double DegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double HectodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double MicrodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double MillidegreesCelsiusPerSecondTolerance { get { return 1E-5; } } - protected virtual double NanodegreesCelsiusPerSecondTolerance { get { return 1E-5; } } + protected virtual double CentidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecadegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double DegreesCelsiusPerMinuteTolerance { get { return 1e-5; } } + protected virtual double DegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double HectodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double MicrodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double MillidegreesCelsiusPerSecondTolerance { get { return 1e-5; } } + protected virtual double NanodegreesCelsiusPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureChangeRateUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -521,21 +521,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureChangeRateUnit unit) { - var inBaseUnit = TemperatureChangeRate.From(1.0, TemperatureChangeRate.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = TemperatureChangeRate.From(1.0, TemperatureChangeRate.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = TemperatureChangeRate.From(1.0, TemperatureChangeRate.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureChangeRateUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureChangeRateUnit unit) @@ -549,8 +542,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureChangeRateUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureChangeRateUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = TemperatureChangeRate.Units.First(u => u != TemperatureChangeRate.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = TemperatureChangeRate.Units.Where(u => u != TemperatureChangeRate.BaseUnit).DefaultIfEmpty(TemperatureChangeRate.BaseUnit).FirstOrDefault(); var quantity = TemperatureChangeRate.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -772,9 +765,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -808,41 +800,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -855,25 +842,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -915,7 +899,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureChangeRate.FromDegreesCelsiusPerSecond(1.0); - Assert.Equal(TemperatureChangeRate.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {TemperatureChangeRate.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 888100c7d5..7febab8e92 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class TemperatureDeltaTestsBase : QuantityTestsBase protected abstract double MillidegreesCelsiusInOneKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelsiusTolerance { get { return 1E-5; } } - protected virtual double DegreesDelisleTolerance { get { return 1E-5; } } - protected virtual double DegreesFahrenheitTolerance { get { return 1E-5; } } - protected virtual double DegreesNewtonTolerance { get { return 1E-5; } } - protected virtual double DegreesRankineTolerance { get { return 1E-5; } } - protected virtual double DegreesReaumurTolerance { get { return 1E-5; } } - protected virtual double DegreesRoemerTolerance { get { return 1E-5; } } - protected virtual double KelvinsTolerance { get { return 1E-5; } } - protected virtual double MillidegreesCelsiusTolerance { get { return 1E-5; } } + protected virtual double DegreesCelsiusTolerance { get { return 1e-5; } } + protected virtual double DegreesDelisleTolerance { get { return 1e-5; } } + protected virtual double DegreesFahrenheitTolerance { get { return 1e-5; } } + protected virtual double DegreesNewtonTolerance { get { return 1e-5; } } + protected virtual double DegreesRankineTolerance { get { return 1e-5; } } + protected virtual double DegreesReaumurTolerance { get { return 1e-5; } } + protected virtual double DegreesRoemerTolerance { get { return 1e-5; } } + protected virtual double KelvinsTolerance { get { return 1e-5; } } + protected virtual double MillidegreesCelsiusTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureDeltaUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -487,21 +487,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureDeltaUnit unit) { - var inBaseUnit = TemperatureDelta.From(1.0, TemperatureDelta.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = TemperatureDelta.From(1.0, TemperatureDelta.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = TemperatureDelta.From(1.0, TemperatureDelta.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureDeltaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureDeltaUnit unit) @@ -515,8 +508,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureDeltaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureDeltaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = TemperatureDelta.Units.First(u => u != TemperatureDelta.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = TemperatureDelta.Units.Where(u => u != TemperatureDelta.BaseUnit).DefaultIfEmpty(TemperatureDelta.BaseUnit).FirstOrDefault(); var quantity = TemperatureDelta.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -735,9 +728,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -771,41 +763,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -818,25 +805,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureDelta.FromKelvins(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = TemperatureDelta.FromKelvins(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -878,7 +862,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureDelta.FromKelvins(1.0); - Assert.Equal(TemperatureDelta.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {TemperatureDelta.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index 6ba368aafa..e0a6f79454 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -44,10 +44,10 @@ public abstract partial class TemperatureGradientTestsBase : QuantityTestsBase protected abstract double KelvinsPerMeterInOneKelvinPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1E-5; } } - protected virtual double DegreesCelciusPerMeterTolerance { get { return 1E-5; } } - protected virtual double DegreesFahrenheitPerFootTolerance { get { return 1E-5; } } - protected virtual double KelvinsPerMeterTolerance { get { return 1E-5; } } + protected virtual double DegreesCelciusPerKilometerTolerance { get { return 1e-5; } } + protected virtual double DegreesCelciusPerMeterTolerance { get { return 1e-5; } } + protected virtual double DegreesFahrenheitPerFootTolerance { get { return 1e-5; } } + protected virtual double KelvinsPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureGradientUnit unit) @@ -188,7 +188,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -317,21 +317,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureGradientUnit unit) { - var inBaseUnit = TemperatureGradient.From(1.0, TemperatureGradient.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = TemperatureGradient.From(1.0, TemperatureGradient.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = TemperatureGradient.From(1.0, TemperatureGradient.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureGradientUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureGradientUnit unit) @@ -345,8 +338,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureGradientUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureGradientUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = TemperatureGradient.Units.First(u => u != TemperatureGradient.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = TemperatureGradient.Units.Where(u => u != TemperatureGradient.BaseUnit).DefaultIfEmpty(TemperatureGradient.BaseUnit).FirstOrDefault(); var quantity = TemperatureGradient.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -550,9 +543,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -586,41 +578,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -633,25 +620,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TemperatureGradient.FromKelvinsPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -693,7 +677,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TemperatureGradient.FromKelvinsPerMeter(1.0); - Assert.Equal(TemperatureGradient.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {TemperatureGradient.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index 17da2c0e60..fe54557914 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -50,16 +50,16 @@ public abstract partial class TemperatureTestsBase : QuantityTestsBase protected abstract double SolarTemperaturesInOneKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double DegreesCelsiusTolerance { get { return 1E-5; } } - protected virtual double DegreesDelisleTolerance { get { return 1E-5; } } - protected virtual double DegreesFahrenheitTolerance { get { return 1E-5; } } - protected virtual double DegreesNewtonTolerance { get { return 1E-5; } } - protected virtual double DegreesRankineTolerance { get { return 1E-5; } } - protected virtual double DegreesReaumurTolerance { get { return 1E-5; } } - protected virtual double DegreesRoemerTolerance { get { return 1E-5; } } - protected virtual double KelvinsTolerance { get { return 1E-5; } } - protected virtual double MillidegreesCelsiusTolerance { get { return 1E-5; } } - protected virtual double SolarTemperaturesTolerance { get { return 1E-5; } } + protected virtual double DegreesCelsiusTolerance { get { return 1e-5; } } + protected virtual double DegreesDelisleTolerance { get { return 1e-5; } } + protected virtual double DegreesFahrenheitTolerance { get { return 1e-5; } } + protected virtual double DegreesNewtonTolerance { get { return 1e-5; } } + protected virtual double DegreesRankineTolerance { get { return 1e-5; } } + protected virtual double DegreesReaumurTolerance { get { return 1e-5; } } + protected virtual double DegreesRoemerTolerance { get { return 1e-5; } } + protected virtual double KelvinsTolerance { get { return 1e-5; } } + protected virtual double MillidegreesCelsiusTolerance { get { return 1e-5; } } + protected virtual double SolarTemperaturesTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TemperatureUnit unit) @@ -248,7 +248,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -521,21 +521,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TemperatureUnit unit) { - var inBaseUnit = Temperature.From(1.0, Temperature.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Temperature.From(1.0, Temperature.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Temperature.From(1.0, Temperature.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TemperatureUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TemperatureUnit unit) @@ -549,8 +542,8 @@ public void ToUnit_WithSameUnits_AreEqual(TemperatureUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TemperatureUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Temperature.Units.First(u => u != Temperature.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Temperature.Units.Where(u => u != Temperature.BaseUnit).DefaultIfEmpty(Temperature.BaseUnit).FirstOrDefault(); var quantity = Temperature.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -760,9 +753,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -796,41 +788,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -843,25 +830,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Temperature.FromKelvins(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Temperature.FromKelvins(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -903,7 +887,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Temperature.FromKelvins(1.0); - Assert.Equal(Temperature.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Temperature.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index a1e2152df9..f9ba3e2d05 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class ThermalConductivityTestsBase : QuantityTestsBase protected abstract double WattsPerMeterKelvinInOneWattPerMeterKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerHourFootFahrenheitTolerance { get { return 1E-5; } } - protected virtual double WattsPerMeterKelvinTolerance { get { return 1E-5; } } + protected virtual double BtusPerHourFootFahrenheitTolerance { get { return 1e-5; } } + protected virtual double WattsPerMeterKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ThermalConductivityUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,21 +249,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ThermalConductivityUnit unit) { - var inBaseUnit = ThermalConductivity.From(1.0, ThermalConductivity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ThermalConductivity.From(1.0, ThermalConductivity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ThermalConductivity.From(1.0, ThermalConductivity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ThermalConductivityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ThermalConductivityUnit unit) @@ -277,8 +270,8 @@ public void ToUnit_WithSameUnits_AreEqual(ThermalConductivityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ThermalConductivityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ThermalConductivity.Units.First(u => u != ThermalConductivity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ThermalConductivity.Units.Where(u => u != ThermalConductivity.BaseUnit).DefaultIfEmpty(ThermalConductivity.BaseUnit).FirstOrDefault(); var quantity = ThermalConductivity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -476,9 +469,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -512,41 +504,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -559,25 +546,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalConductivity.FromWattsPerMeterKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -619,7 +603,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ThermalConductivity.FromWattsPerMeterKelvin(1.0); - Assert.Equal(ThermalConductivity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ThermalConductivity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 00b775c402..00f985ad3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class ThermalResistanceTestsBase : QuantityTestsBase protected abstract double SquareMeterKelvinsPerWattInOneSquareMeterKelvinPerKilowatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double HourSquareFeetDegreesFahrenheitPerBtuTolerance { get { return 1E-5; } } - protected virtual double SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance { get { return 1E-5; } } - protected virtual double SquareCentimeterKelvinsPerWattTolerance { get { return 1E-5; } } - protected virtual double SquareMeterDegreesCelsiusPerWattTolerance { get { return 1E-5; } } - protected virtual double SquareMeterKelvinsPerKilowattTolerance { get { return 1E-5; } } - protected virtual double SquareMeterKelvinsPerWattTolerance { get { return 1E-5; } } + protected virtual double HourSquareFeetDegreesFahrenheitPerBtuTolerance { get { return 1e-5; } } + protected virtual double SquareCentimeterHourDegreesCelsiusPerKilocalorieTolerance { get { return 1e-5; } } + protected virtual double SquareCentimeterKelvinsPerWattTolerance { get { return 1e-5; } } + protected virtual double SquareMeterDegreesCelsiusPerWattTolerance { get { return 1e-5; } } + protected virtual double SquareMeterKelvinsPerKilowattTolerance { get { return 1e-5; } } + protected virtual double SquareMeterKelvinsPerWattTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(ThermalResistanceUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -385,21 +385,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(ThermalResistanceUnit unit) { - var inBaseUnit = ThermalResistance.From(1.0, ThermalResistance.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = ThermalResistance.From(1.0, ThermalResistance.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = ThermalResistance.From(1.0, ThermalResistance.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(ThermalResistanceUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(ThermalResistanceUnit unit) @@ -413,8 +406,8 @@ public void ToUnit_WithSameUnits_AreEqual(ThermalResistanceUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(ThermalResistanceUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = ThermalResistance.Units.First(u => u != ThermalResistance.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = ThermalResistance.Units.Where(u => u != ThermalResistance.BaseUnit).DefaultIfEmpty(ThermalResistance.BaseUnit).FirstOrDefault(); var quantity = ThermalResistance.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -624,9 +617,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -660,41 +652,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -707,25 +694,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -767,7 +751,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = ThermalResistance.FromSquareMeterKelvinsPerKilowatt(1.0); - Assert.Equal(ThermalResistance.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {ThermalResistance.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index ca4ffc8708..4d7495ee03 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -61,27 +61,27 @@ public abstract partial class TorquePerLengthTestsBase : QuantityTestsBase protected abstract double TonneForceMillimetersPerMeterInOneNewtonMeterPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double KilogramForceCentimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramForceMetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilogramForceMillimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonCentimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMillimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double KilopoundForceFeetPerFootTolerance { get { return 1E-5; } } - protected virtual double KilopoundForceInchesPerFootTolerance { get { return 1E-5; } } - protected virtual double MeganewtonCentimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMillimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double MegapoundForceFeetPerFootTolerance { get { return 1E-5; } } - protected virtual double MegapoundForceInchesPerFootTolerance { get { return 1E-5; } } - protected virtual double NewtonCentimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonMetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double NewtonMillimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double PoundForceFeetPerFootTolerance { get { return 1E-5; } } - protected virtual double PoundForceInchesPerFootTolerance { get { return 1E-5; } } - protected virtual double TonneForceCentimetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double TonneForceMetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double TonneForceMillimetersPerMeterTolerance { get { return 1E-5; } } + protected virtual double KilogramForceCentimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramForceMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilogramForceMillimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonCentimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMillimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double KilopoundForceFeetPerFootTolerance { get { return 1e-5; } } + protected virtual double KilopoundForceInchesPerFootTolerance { get { return 1e-5; } } + protected virtual double MeganewtonCentimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMillimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double MegapoundForceFeetPerFootTolerance { get { return 1e-5; } } + protected virtual double MegapoundForceInchesPerFootTolerance { get { return 1e-5; } } + protected virtual double NewtonCentimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double NewtonMillimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double PoundForceFeetPerFootTolerance { get { return 1e-5; } } + protected virtual double PoundForceInchesPerFootTolerance { get { return 1e-5; } } + protected virtual double TonneForceCentimetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double TonneForceMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double TonneForceMillimetersPerMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TorquePerLengthUnit unit) @@ -358,7 +358,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -967,21 +967,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TorquePerLengthUnit unit) { - var inBaseUnit = TorquePerLength.From(1.0, TorquePerLength.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = TorquePerLength.From(1.0, TorquePerLength.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = TorquePerLength.From(1.0, TorquePerLength.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TorquePerLengthUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TorquePerLengthUnit unit) @@ -995,8 +988,8 @@ public void ToUnit_WithSameUnits_AreEqual(TorquePerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorquePerLengthUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = TorquePerLength.Units.First(u => u != TorquePerLength.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = TorquePerLength.Units.Where(u => u != TorquePerLength.BaseUnit).DefaultIfEmpty(TorquePerLength.BaseUnit).FirstOrDefault(); var quantity = TorquePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1251,9 +1244,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1287,41 +1279,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1334,25 +1321,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = TorquePerLength.FromNewtonMetersPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1394,7 +1378,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = TorquePerLength.FromNewtonMetersPerMeter(1.0); - Assert.Equal(TorquePerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {TorquePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 803d7bce5a..322306450f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -65,31 +65,31 @@ public abstract partial class TorqueTestsBase : QuantityTestsBase protected abstract double TonneForceMillimetersInOneNewtonMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double GramForceCentimetersTolerance { get { return 1E-5; } } - protected virtual double GramForceMetersTolerance { get { return 1E-5; } } - protected virtual double GramForceMillimetersTolerance { get { return 1E-5; } } - protected virtual double KilogramForceCentimetersTolerance { get { return 1E-5; } } - protected virtual double KilogramForceMetersTolerance { get { return 1E-5; } } - protected virtual double KilogramForceMillimetersTolerance { get { return 1E-5; } } - protected virtual double KilonewtonCentimetersTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMetersTolerance { get { return 1E-5; } } - protected virtual double KilonewtonMillimetersTolerance { get { return 1E-5; } } - protected virtual double KilopoundForceFeetTolerance { get { return 1E-5; } } - protected virtual double KilopoundForceInchesTolerance { get { return 1E-5; } } - protected virtual double MeganewtonCentimetersTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMetersTolerance { get { return 1E-5; } } - protected virtual double MeganewtonMillimetersTolerance { get { return 1E-5; } } - protected virtual double MegapoundForceFeetTolerance { get { return 1E-5; } } - protected virtual double MegapoundForceInchesTolerance { get { return 1E-5; } } - protected virtual double NewtonCentimetersTolerance { get { return 1E-5; } } - protected virtual double NewtonMetersTolerance { get { return 1E-5; } } - protected virtual double NewtonMillimetersTolerance { get { return 1E-5; } } - protected virtual double PoundalFeetTolerance { get { return 1E-5; } } - protected virtual double PoundForceFeetTolerance { get { return 1E-5; } } - protected virtual double PoundForceInchesTolerance { get { return 1E-5; } } - protected virtual double TonneForceCentimetersTolerance { get { return 1E-5; } } - protected virtual double TonneForceMetersTolerance { get { return 1E-5; } } - protected virtual double TonneForceMillimetersTolerance { get { return 1E-5; } } + protected virtual double GramForceCentimetersTolerance { get { return 1e-5; } } + protected virtual double GramForceMetersTolerance { get { return 1e-5; } } + protected virtual double GramForceMillimetersTolerance { get { return 1e-5; } } + protected virtual double KilogramForceCentimetersTolerance { get { return 1e-5; } } + protected virtual double KilogramForceMetersTolerance { get { return 1e-5; } } + protected virtual double KilogramForceMillimetersTolerance { get { return 1e-5; } } + protected virtual double KilonewtonCentimetersTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMetersTolerance { get { return 1e-5; } } + protected virtual double KilonewtonMillimetersTolerance { get { return 1e-5; } } + protected virtual double KilopoundForceFeetTolerance { get { return 1e-5; } } + protected virtual double KilopoundForceInchesTolerance { get { return 1e-5; } } + protected virtual double MeganewtonCentimetersTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMetersTolerance { get { return 1e-5; } } + protected virtual double MeganewtonMillimetersTolerance { get { return 1e-5; } } + protected virtual double MegapoundForceFeetTolerance { get { return 1e-5; } } + protected virtual double MegapoundForceInchesTolerance { get { return 1e-5; } } + protected virtual double NewtonCentimetersTolerance { get { return 1e-5; } } + protected virtual double NewtonMetersTolerance { get { return 1e-5; } } + protected virtual double NewtonMillimetersTolerance { get { return 1e-5; } } + protected virtual double PoundalFeetTolerance { get { return 1e-5; } } + protected virtual double PoundForceFeetTolerance { get { return 1e-5; } } + protected virtual double PoundForceInchesTolerance { get { return 1e-5; } } + protected virtual double TonneForceCentimetersTolerance { get { return 1e-5; } } + protected virtual double TonneForceMetersTolerance { get { return 1e-5; } } + protected virtual double TonneForceMillimetersTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TorqueUnit unit) @@ -398,7 +398,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -1103,21 +1103,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TorqueUnit unit) { - var inBaseUnit = Torque.From(1.0, Torque.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Torque.From(1.0, Torque.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Torque.From(1.0, Torque.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TorqueUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TorqueUnit unit) @@ -1131,8 +1124,8 @@ public void ToUnit_WithSameUnits_AreEqual(TorqueUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TorqueUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Torque.Units.First(u => u != Torque.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Torque.Units.Where(u => u != Torque.BaseUnit).DefaultIfEmpty(Torque.BaseUnit).FirstOrDefault(); var quantity = Torque.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1399,9 +1392,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1435,41 +1427,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1482,25 +1469,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Torque.FromNewtonMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Torque.FromNewtonMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1542,7 +1526,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Torque.FromNewtonMeters(1.0); - Assert.Equal(Torque.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Torque.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index c7fec73200..65fd4b5012 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class TurbidityTestsBase : QuantityTestsBase protected abstract double NTUInOneNTU { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double NTUTolerance { get { return 1E-5; } } + protected virtual double NTUTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(TurbidityUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(TurbidityUnit unit) { - var inBaseUnit = Turbidity.From(1.0, Turbidity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Turbidity.From(1.0, Turbidity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Turbidity.From(1.0, Turbidity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(TurbidityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(TurbidityUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(TurbidityUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(TurbidityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Turbidity.Units.First(u => u != Turbidity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Turbidity.Units.Where(u => u != Turbidity.BaseUnit).DefaultIfEmpty(Turbidity.BaseUnit).FirstOrDefault(); var quantity = Turbidity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Turbidity.FromNTU(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Turbidity.FromNTU(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Turbidity.FromNTU(1.0); - Assert.Equal(Turbidity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Turbidity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index b08943ff4b..36661f561c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -41,7 +41,7 @@ public abstract partial class VitaminATestsBase : QuantityTestsBase protected abstract double InternationalUnitsInOneInternationalUnit { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double InternationalUnitsTolerance { get { return 1E-5; } } + protected virtual double InternationalUnitsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VitaminAUnit unit) @@ -158,7 +158,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -215,21 +215,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VitaminAUnit unit) { - var inBaseUnit = VitaminA.From(1.0, VitaminA.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = VitaminA.From(1.0, VitaminA.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = VitaminA.From(1.0, VitaminA.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VitaminAUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VitaminAUnit unit) @@ -239,12 +232,12 @@ public void ToUnit_WithSameUnits_AreEqual(VitaminAUnit unit) Assert.Equal(quantity, toUnitWithSameUnit); } - [Theory(Skip = "Multiple units required")] + [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VitaminAUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = VitaminA.Units.First(u => u != VitaminA.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = VitaminA.Units.Where(u => u != VitaminA.BaseUnit).DefaultIfEmpty(VitaminA.BaseUnit).FirstOrDefault(); var quantity = VitaminA.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -439,9 +432,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -475,41 +467,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -522,25 +509,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VitaminA.FromInternationalUnits(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = VitaminA.FromInternationalUnits(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -582,7 +566,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VitaminA.FromInternationalUnits(1.0); - Assert.Equal(VitaminA.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {VitaminA.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index 4367e649aa..d807ec47aa 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -60,26 +60,26 @@ public abstract partial class VolumeConcentrationTestsBase : QuantityTestsBase protected abstract double PicolitersPerMililiterInOneDecimalFraction { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentilitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double CentilitersPerMililiterTolerance { get { return 1E-5; } } - protected virtual double DecilitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double DecilitersPerMililiterTolerance { get { return 1E-5; } } - protected virtual double DecimalFractionsTolerance { get { return 1E-5; } } - protected virtual double LitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double LitersPerMililiterTolerance { get { return 1E-5; } } - protected virtual double MicrolitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double MicrolitersPerMililiterTolerance { get { return 1E-5; } } - protected virtual double MillilitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double MillilitersPerMililiterTolerance { get { return 1E-5; } } - protected virtual double NanolitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double NanolitersPerMililiterTolerance { get { return 1E-5; } } - protected virtual double PartsPerBillionTolerance { get { return 1E-5; } } - protected virtual double PartsPerMillionTolerance { get { return 1E-5; } } - protected virtual double PartsPerThousandTolerance { get { return 1E-5; } } - protected virtual double PartsPerTrillionTolerance { get { return 1E-5; } } - protected virtual double PercentTolerance { get { return 1E-5; } } - protected virtual double PicolitersPerLiterTolerance { get { return 1E-5; } } - protected virtual double PicolitersPerMililiterTolerance { get { return 1E-5; } } + protected virtual double CentilitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double CentilitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double DecilitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double DecilitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double DecimalFractionsTolerance { get { return 1e-5; } } + protected virtual double LitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double LitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double MicrolitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double MicrolitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double MillilitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double MillilitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double NanolitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double NanolitersPerMililiterTolerance { get { return 1e-5; } } + protected virtual double PartsPerBillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerMillionTolerance { get { return 1e-5; } } + protected virtual double PartsPerThousandTolerance { get { return 1e-5; } } + protected virtual double PartsPerTrillionTolerance { get { return 1e-5; } } + protected virtual double PercentTolerance { get { return 1e-5; } } + protected virtual double PicolitersPerLiterTolerance { get { return 1e-5; } } + protected virtual double PicolitersPerMililiterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeConcentrationUnit unit) @@ -348,7 +348,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -885,21 +885,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeConcentrationUnit unit) { - var inBaseUnit = VolumeConcentration.From(1.0, VolumeConcentration.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = VolumeConcentration.From(1.0, VolumeConcentration.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = VolumeConcentration.From(1.0, VolumeConcentration.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeConcentrationUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeConcentrationUnit unit) @@ -913,8 +906,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeConcentrationUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeConcentrationUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = VolumeConcentration.Units.First(u => u != VolumeConcentration.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = VolumeConcentration.Units.Where(u => u != VolumeConcentration.BaseUnit).DefaultIfEmpty(VolumeConcentration.BaseUnit).FirstOrDefault(); var quantity = VolumeConcentration.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -1166,9 +1159,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -1202,41 +1194,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -1249,25 +1236,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeConcentration.FromDecimalFractions(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = VolumeConcentration.FromDecimalFractions(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -1309,7 +1293,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeConcentration.FromDecimalFractions(1.0); - Assert.Equal(VolumeConcentration.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {VolumeConcentration.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 918eab8558..722f63a1d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -42,8 +42,8 @@ public abstract partial class VolumeFlowPerAreaTestsBase : QuantityTestsBase protected abstract double CubicMetersPerSecondPerSquareMeterInOneCubicMeterPerSecondPerSquareMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CubicFeetPerMinutePerSquareFootTolerance { get { return 1E-5; } } - protected virtual double CubicMetersPerSecondPerSquareMeterTolerance { get { return 1E-5; } } + protected virtual double CubicFeetPerMinutePerSquareFootTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerSecondPerSquareMeterTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeFlowPerAreaUnit unit) @@ -168,7 +168,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -249,21 +249,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeFlowPerAreaUnit unit) { - var inBaseUnit = VolumeFlowPerArea.From(1.0, VolumeFlowPerArea.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = VolumeFlowPerArea.From(1.0, VolumeFlowPerArea.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = VolumeFlowPerArea.From(1.0, VolumeFlowPerArea.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeFlowPerAreaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeFlowPerAreaUnit unit) @@ -277,8 +270,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeFlowPerAreaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeFlowPerAreaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = VolumeFlowPerArea.Units.First(u => u != VolumeFlowPerArea.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = VolumeFlowPerArea.Units.Where(u => u != VolumeFlowPerArea.BaseUnit).DefaultIfEmpty(VolumeFlowPerArea.BaseUnit).FirstOrDefault(); var quantity = VolumeFlowPerArea.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -476,9 +469,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -512,41 +504,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -559,25 +546,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -619,7 +603,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeFlowPerArea.FromCubicMetersPerSecondPerSquareMeter(1.0); - Assert.Equal(VolumeFlowPerArea.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {VolumeFlowPerArea.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index 7a84a2581a..caf0e209b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -102,68 +102,68 @@ public abstract partial class VolumeFlowTestsBase : QuantityTestsBase protected abstract double UsGallonsPerSecondInOneCubicMeterPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AcreFeetPerDayTolerance { get { return 1E-5; } } - protected virtual double AcreFeetPerHourTolerance { get { return 1E-5; } } - protected virtual double AcreFeetPerMinuteTolerance { get { return 1E-5; } } - protected virtual double AcreFeetPerSecondTolerance { get { return 1E-5; } } - protected virtual double CentilitersPerDayTolerance { get { return 1E-5; } } - protected virtual double CentilitersPerHourTolerance { get { return 1E-5; } } - protected virtual double CentilitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double CentilitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double CubicCentimetersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double CubicDecimetersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double CubicFeetPerHourTolerance { get { return 1E-5; } } - protected virtual double CubicFeetPerMinuteTolerance { get { return 1E-5; } } - protected virtual double CubicFeetPerSecondTolerance { get { return 1E-5; } } - protected virtual double CubicMetersPerDayTolerance { get { return 1E-5; } } - protected virtual double CubicMetersPerHourTolerance { get { return 1E-5; } } - protected virtual double CubicMetersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double CubicMetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double CubicMillimetersPerSecondTolerance { get { return 1E-5; } } - protected virtual double CubicYardsPerDayTolerance { get { return 1E-5; } } - protected virtual double CubicYardsPerHourTolerance { get { return 1E-5; } } - protected virtual double CubicYardsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double CubicYardsPerSecondTolerance { get { return 1E-5; } } - protected virtual double DecilitersPerDayTolerance { get { return 1E-5; } } - protected virtual double DecilitersPerHourTolerance { get { return 1E-5; } } - protected virtual double DecilitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double DecilitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilolitersPerDayTolerance { get { return 1E-5; } } - protected virtual double KilolitersPerHourTolerance { get { return 1E-5; } } - protected virtual double KilolitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double KilolitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double KilousGallonsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double LitersPerDayTolerance { get { return 1E-5; } } - protected virtual double LitersPerHourTolerance { get { return 1E-5; } } - protected virtual double LitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double LitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double MegalitersPerDayTolerance { get { return 1E-5; } } - protected virtual double MegaukGallonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double MicrolitersPerDayTolerance { get { return 1E-5; } } - protected virtual double MicrolitersPerHourTolerance { get { return 1E-5; } } - protected virtual double MicrolitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double MicrolitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double MillilitersPerDayTolerance { get { return 1E-5; } } - protected virtual double MillilitersPerHourTolerance { get { return 1E-5; } } - protected virtual double MillilitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double MillilitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double MillionUsGallonsPerDayTolerance { get { return 1E-5; } } - protected virtual double NanolitersPerDayTolerance { get { return 1E-5; } } - protected virtual double NanolitersPerHourTolerance { get { return 1E-5; } } - protected virtual double NanolitersPerMinuteTolerance { get { return 1E-5; } } - protected virtual double NanolitersPerSecondTolerance { get { return 1E-5; } } - protected virtual double OilBarrelsPerDayTolerance { get { return 1E-5; } } - protected virtual double OilBarrelsPerHourTolerance { get { return 1E-5; } } - protected virtual double OilBarrelsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double OilBarrelsPerSecondTolerance { get { return 1E-5; } } - protected virtual double UkGallonsPerDayTolerance { get { return 1E-5; } } - protected virtual double UkGallonsPerHourTolerance { get { return 1E-5; } } - protected virtual double UkGallonsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double UkGallonsPerSecondTolerance { get { return 1E-5; } } - protected virtual double UsGallonsPerDayTolerance { get { return 1E-5; } } - protected virtual double UsGallonsPerHourTolerance { get { return 1E-5; } } - protected virtual double UsGallonsPerMinuteTolerance { get { return 1E-5; } } - protected virtual double UsGallonsPerSecondTolerance { get { return 1E-5; } } + protected virtual double AcreFeetPerDayTolerance { get { return 1e-5; } } + protected virtual double AcreFeetPerHourTolerance { get { return 1e-5; } } + protected virtual double AcreFeetPerMinuteTolerance { get { return 1e-5; } } + protected virtual double AcreFeetPerSecondTolerance { get { return 1e-5; } } + protected virtual double CentilitersPerDayTolerance { get { return 1e-5; } } + protected virtual double CentilitersPerHourTolerance { get { return 1e-5; } } + protected virtual double CentilitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CentilitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double CubicCentimetersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CubicDecimetersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CubicFeetPerHourTolerance { get { return 1e-5; } } + protected virtual double CubicFeetPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CubicFeetPerSecondTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerDayTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerHourTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CubicMetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double CubicMillimetersPerSecondTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerDayTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerHourTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerSecondTolerance { get { return 1e-5; } } + protected virtual double DecilitersPerDayTolerance { get { return 1e-5; } } + protected virtual double DecilitersPerHourTolerance { get { return 1e-5; } } + protected virtual double DecilitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double DecilitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilolitersPerDayTolerance { get { return 1e-5; } } + protected virtual double KilolitersPerHourTolerance { get { return 1e-5; } } + protected virtual double KilolitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double KilolitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double KilousGallonsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double LitersPerDayTolerance { get { return 1e-5; } } + protected virtual double LitersPerHourTolerance { get { return 1e-5; } } + protected virtual double LitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double LitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double MegalitersPerDayTolerance { get { return 1e-5; } } + protected virtual double MegaukGallonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double MicrolitersPerDayTolerance { get { return 1e-5; } } + protected virtual double MicrolitersPerHourTolerance { get { return 1e-5; } } + protected virtual double MicrolitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double MicrolitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double MillilitersPerDayTolerance { get { return 1e-5; } } + protected virtual double MillilitersPerHourTolerance { get { return 1e-5; } } + protected virtual double MillilitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double MillilitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double MillionUsGallonsPerDayTolerance { get { return 1e-5; } } + protected virtual double NanolitersPerDayTolerance { get { return 1e-5; } } + protected virtual double NanolitersPerHourTolerance { get { return 1e-5; } } + protected virtual double NanolitersPerMinuteTolerance { get { return 1e-5; } } + protected virtual double NanolitersPerSecondTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsPerDayTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsPerHourTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsPerSecondTolerance { get { return 1e-5; } } + protected virtual double UkGallonsPerDayTolerance { get { return 1e-5; } } + protected virtual double UkGallonsPerHourTolerance { get { return 1e-5; } } + protected virtual double UkGallonsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double UkGallonsPerSecondTolerance { get { return 1e-5; } } + protected virtual double UsGallonsPerDayTolerance { get { return 1e-5; } } + protected virtual double UsGallonsPerHourTolerance { get { return 1e-5; } } + protected virtual double UsGallonsPerMinuteTolerance { get { return 1e-5; } } + protected virtual double UsGallonsPerSecondTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeFlowUnit unit) @@ -768,7 +768,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -3951,21 +3951,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeFlowUnit unit) { - var inBaseUnit = VolumeFlow.From(1.0, VolumeFlow.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = VolumeFlow.From(1.0, VolumeFlow.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = VolumeFlow.From(1.0, VolumeFlow.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeFlowUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeFlowUnit unit) @@ -3979,8 +3972,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeFlowUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeFlowUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = VolumeFlow.Units.First(u => u != VolumeFlow.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = VolumeFlow.Units.Where(u => u != VolumeFlow.BaseUnit).DefaultIfEmpty(VolumeFlow.BaseUnit).FirstOrDefault(); var quantity = VolumeFlow.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -4358,9 +4351,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -4394,41 +4386,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -4441,25 +4428,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumeFlow.FromCubicMetersPerSecond(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -4501,7 +4485,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumeFlow.FromCubicMetersPerSecond(1.0); - Assert.Equal(VolumeFlow.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {VolumeFlow.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index ca1a1da646..98f4ce00c7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -47,13 +47,13 @@ public abstract partial class VolumePerLengthTestsBase : QuantityTestsBase protected abstract double OilBarrelsPerFootInOneCubicMeterPerMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CubicMetersPerMeterTolerance { get { return 1E-5; } } - protected virtual double CubicYardsPerFootTolerance { get { return 1E-5; } } - protected virtual double CubicYardsPerUsSurveyFootTolerance { get { return 1E-5; } } - protected virtual double LitersPerKilometerTolerance { get { return 1E-5; } } - protected virtual double LitersPerMeterTolerance { get { return 1E-5; } } - protected virtual double LitersPerMillimeterTolerance { get { return 1E-5; } } - protected virtual double OilBarrelsPerFootTolerance { get { return 1E-5; } } + protected virtual double CubicMetersPerMeterTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerFootTolerance { get { return 1e-5; } } + protected virtual double CubicYardsPerUsSurveyFootTolerance { get { return 1e-5; } } + protected virtual double LitersPerKilometerTolerance { get { return 1e-5; } } + protected virtual double LitersPerMeterTolerance { get { return 1e-5; } } + protected virtual double LitersPerMillimeterTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsPerFootTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumePerLengthUnit unit) @@ -218,7 +218,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -419,21 +419,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumePerLengthUnit unit) { - var inBaseUnit = VolumePerLength.From(1.0, VolumePerLength.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = VolumePerLength.From(1.0, VolumePerLength.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = VolumePerLength.From(1.0, VolumePerLength.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VolumePerLengthUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumePerLengthUnit unit) @@ -447,8 +440,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumePerLengthUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumePerLengthUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = VolumePerLength.Units.First(u => u != VolumePerLength.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = VolumePerLength.Units.Where(u => u != VolumePerLength.BaseUnit).DefaultIfEmpty(VolumePerLength.BaseUnit).FirstOrDefault(); var quantity = VolumePerLength.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -661,9 +654,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -697,41 +689,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -744,25 +731,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumePerLength.FromCubicMetersPerMeter(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -804,7 +788,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumePerLength.FromCubicMetersPerMeter(1.0); - Assert.Equal(VolumePerLength.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {VolumePerLength.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 2828a5de16..4447d491b4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -92,58 +92,58 @@ public abstract partial class VolumeTestsBase : QuantityTestsBase protected abstract double UsTeaspoonsInOneCubicMeter { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double AcreFeetTolerance { get { return 1E-5; } } - protected virtual double AuTablespoonsTolerance { get { return 1E-5; } } - protected virtual double BoardFeetTolerance { get { return 1E-5; } } - protected virtual double CentilitersTolerance { get { return 1E-5; } } - protected virtual double CubicCentimetersTolerance { get { return 1E-5; } } - protected virtual double CubicDecimetersTolerance { get { return 1E-5; } } - protected virtual double CubicFeetTolerance { get { return 1E-5; } } - protected virtual double CubicHectometersTolerance { get { return 1E-5; } } - protected virtual double CubicInchesTolerance { get { return 1E-5; } } - protected virtual double CubicKilometersTolerance { get { return 1E-5; } } - protected virtual double CubicMetersTolerance { get { return 1E-5; } } - protected virtual double CubicMicrometersTolerance { get { return 1E-5; } } - protected virtual double CubicMilesTolerance { get { return 1E-5; } } - protected virtual double CubicMillimetersTolerance { get { return 1E-5; } } - protected virtual double CubicYardsTolerance { get { return 1E-5; } } - protected virtual double DecalitersTolerance { get { return 1E-5; } } - protected virtual double DecausGallonsTolerance { get { return 1E-5; } } - protected virtual double DecilitersTolerance { get { return 1E-5; } } - protected virtual double DeciusGallonsTolerance { get { return 1E-5; } } - protected virtual double HectocubicFeetTolerance { get { return 1E-5; } } - protected virtual double HectocubicMetersTolerance { get { return 1E-5; } } - protected virtual double HectolitersTolerance { get { return 1E-5; } } - protected virtual double HectousGallonsTolerance { get { return 1E-5; } } - protected virtual double ImperialBeerBarrelsTolerance { get { return 1E-5; } } - protected virtual double ImperialGallonsTolerance { get { return 1E-5; } } - protected virtual double ImperialOuncesTolerance { get { return 1E-5; } } - protected virtual double ImperialPintsTolerance { get { return 1E-5; } } - protected virtual double KilocubicFeetTolerance { get { return 1E-5; } } - protected virtual double KilocubicMetersTolerance { get { return 1E-5; } } - protected virtual double KiloimperialGallonsTolerance { get { return 1E-5; } } - protected virtual double KilolitersTolerance { get { return 1E-5; } } - protected virtual double KilousGallonsTolerance { get { return 1E-5; } } - protected virtual double LitersTolerance { get { return 1E-5; } } - protected virtual double MegacubicFeetTolerance { get { return 1E-5; } } - protected virtual double MegaimperialGallonsTolerance { get { return 1E-5; } } - protected virtual double MegalitersTolerance { get { return 1E-5; } } - protected virtual double MegausGallonsTolerance { get { return 1E-5; } } - protected virtual double MetricCupsTolerance { get { return 1E-5; } } - protected virtual double MetricTeaspoonsTolerance { get { return 1E-5; } } - protected virtual double MicrolitersTolerance { get { return 1E-5; } } - protected virtual double MillilitersTolerance { get { return 1E-5; } } - protected virtual double OilBarrelsTolerance { get { return 1E-5; } } - protected virtual double UkTablespoonsTolerance { get { return 1E-5; } } - protected virtual double UsBeerBarrelsTolerance { get { return 1E-5; } } - protected virtual double UsCustomaryCupsTolerance { get { return 1E-5; } } - protected virtual double UsGallonsTolerance { get { return 1E-5; } } - protected virtual double UsLegalCupsTolerance { get { return 1E-5; } } - protected virtual double UsOuncesTolerance { get { return 1E-5; } } - protected virtual double UsPintsTolerance { get { return 1E-5; } } - protected virtual double UsQuartsTolerance { get { return 1E-5; } } - protected virtual double UsTablespoonsTolerance { get { return 1E-5; } } - protected virtual double UsTeaspoonsTolerance { get { return 1E-5; } } + protected virtual double AcreFeetTolerance { get { return 1e-5; } } + protected virtual double AuTablespoonsTolerance { get { return 1e-5; } } + protected virtual double BoardFeetTolerance { get { return 1e-5; } } + protected virtual double CentilitersTolerance { get { return 1e-5; } } + protected virtual double CubicCentimetersTolerance { get { return 1e-5; } } + protected virtual double CubicDecimetersTolerance { get { return 1e-5; } } + protected virtual double CubicFeetTolerance { get { return 1e-5; } } + protected virtual double CubicHectometersTolerance { get { return 1e-5; } } + protected virtual double CubicInchesTolerance { get { return 1e-5; } } + protected virtual double CubicKilometersTolerance { get { return 1e-5; } } + protected virtual double CubicMetersTolerance { get { return 1e-5; } } + protected virtual double CubicMicrometersTolerance { get { return 1e-5; } } + protected virtual double CubicMilesTolerance { get { return 1e-5; } } + protected virtual double CubicMillimetersTolerance { get { return 1e-5; } } + protected virtual double CubicYardsTolerance { get { return 1e-5; } } + protected virtual double DecalitersTolerance { get { return 1e-5; } } + protected virtual double DecausGallonsTolerance { get { return 1e-5; } } + protected virtual double DecilitersTolerance { get { return 1e-5; } } + protected virtual double DeciusGallonsTolerance { get { return 1e-5; } } + protected virtual double HectocubicFeetTolerance { get { return 1e-5; } } + protected virtual double HectocubicMetersTolerance { get { return 1e-5; } } + protected virtual double HectolitersTolerance { get { return 1e-5; } } + protected virtual double HectousGallonsTolerance { get { return 1e-5; } } + protected virtual double ImperialBeerBarrelsTolerance { get { return 1e-5; } } + protected virtual double ImperialGallonsTolerance { get { return 1e-5; } } + protected virtual double ImperialOuncesTolerance { get { return 1e-5; } } + protected virtual double ImperialPintsTolerance { get { return 1e-5; } } + protected virtual double KilocubicFeetTolerance { get { return 1e-5; } } + protected virtual double KilocubicMetersTolerance { get { return 1e-5; } } + protected virtual double KiloimperialGallonsTolerance { get { return 1e-5; } } + protected virtual double KilolitersTolerance { get { return 1e-5; } } + protected virtual double KilousGallonsTolerance { get { return 1e-5; } } + protected virtual double LitersTolerance { get { return 1e-5; } } + protected virtual double MegacubicFeetTolerance { get { return 1e-5; } } + protected virtual double MegaimperialGallonsTolerance { get { return 1e-5; } } + protected virtual double MegalitersTolerance { get { return 1e-5; } } + protected virtual double MegausGallonsTolerance { get { return 1e-5; } } + protected virtual double MetricCupsTolerance { get { return 1e-5; } } + protected virtual double MetricTeaspoonsTolerance { get { return 1e-5; } } + protected virtual double MicrolitersTolerance { get { return 1e-5; } } + protected virtual double MillilitersTolerance { get { return 1e-5; } } + protected virtual double OilBarrelsTolerance { get { return 1e-5; } } + protected virtual double UkTablespoonsTolerance { get { return 1e-5; } } + protected virtual double UsBeerBarrelsTolerance { get { return 1e-5; } } + protected virtual double UsCustomaryCupsTolerance { get { return 1e-5; } } + protected virtual double UsGallonsTolerance { get { return 1e-5; } } + protected virtual double UsLegalCupsTolerance { get { return 1e-5; } } + protected virtual double UsOuncesTolerance { get { return 1e-5; } } + protected virtual double UsPintsTolerance { get { return 1e-5; } } + protected virtual double UsQuartsTolerance { get { return 1e-5; } } + protected virtual double UsTablespoonsTolerance { get { return 1e-5; } } + protected virtual double UsTeaspoonsTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumeUnit unit) @@ -668,7 +668,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -2945,21 +2945,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumeUnit unit) { - var inBaseUnit = Volume.From(1.0, Volume.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = Volume.From(1.0, Volume.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = Volume.From(1.0, Volume.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VolumeUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumeUnit unit) @@ -2973,8 +2966,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumeUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumeUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = Volume.Units.First(u => u != Volume.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = Volume.Units.Where(u => u != Volume.BaseUnit).DefaultIfEmpty(Volume.BaseUnit).FirstOrDefault(); var quantity = Volume.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -3322,9 +3315,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -3358,41 +3350,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -3405,25 +3392,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = Volume.FromCubicMeters(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = Volume.FromCubicMeters(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -3465,7 +3449,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = Volume.FromCubicMeters(1.0); - Assert.Equal(Volume.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {Volume.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 6c205dcb92..030c251bde 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -49,15 +49,15 @@ public abstract partial class VolumetricHeatCapacityTestsBase : QuantityTestsBas protected abstract double MegajoulesPerCubicMeterKelvinInOneJoulePerCubicMeterKelvin { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BtusPerCubicFootDegreeFahrenheitTolerance { get { return 1E-5; } } - protected virtual double CaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double JoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double JoulesPerCubicMeterKelvinTolerance { get { return 1E-5; } } - protected virtual double KilocaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double KilojoulesPerCubicMeterKelvinTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1E-5; } } - protected virtual double MegajoulesPerCubicMeterKelvinTolerance { get { return 1E-5; } } + protected virtual double BtusPerCubicFootDegreeFahrenheitTolerance { get { return 1e-5; } } + protected virtual double CaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double JoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double JoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } + protected virtual double KilocaloriesPerCubicCentimeterDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double KilojoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerCubicMeterDegreeCelsiusTolerance { get { return 1e-5; } } + protected virtual double MegajoulesPerCubicMeterKelvinTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(VolumetricHeatCapacityUnit unit) @@ -238,7 +238,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -487,21 +487,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(VolumetricHeatCapacityUnit unit) { - var inBaseUnit = VolumetricHeatCapacity.From(1.0, VolumetricHeatCapacity.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = VolumetricHeatCapacity.From(1.0, VolumetricHeatCapacity.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = VolumetricHeatCapacity.From(1.0, VolumetricHeatCapacity.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(VolumetricHeatCapacityUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(VolumetricHeatCapacityUnit unit) @@ -515,8 +508,8 @@ public void ToUnit_WithSameUnits_AreEqual(VolumetricHeatCapacityUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(VolumetricHeatCapacityUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = VolumetricHeatCapacity.Units.First(u => u != VolumetricHeatCapacity.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = VolumetricHeatCapacity.Units.Where(u => u != VolumetricHeatCapacity.BaseUnit).DefaultIfEmpty(VolumetricHeatCapacity.BaseUnit).FirstOrDefault(); var quantity = VolumetricHeatCapacity.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -735,9 +728,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -771,41 +763,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -818,25 +805,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -878,7 +862,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = VolumetricHeatCapacity.FromJoulesPerCubicMeterKelvin(1.0); - Assert.Equal(VolumetricHeatCapacity.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {VolumetricHeatCapacity.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 216a8b4dd8..683a9313ae 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -46,12 +46,12 @@ public abstract partial class WarpingMomentOfInertiaTestsBase : QuantityTestsBas protected abstract double MillimetersToTheSixthInOneMeterToTheSixth { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double CentimetersToTheSixthTolerance { get { return 1E-5; } } - protected virtual double DecimetersToTheSixthTolerance { get { return 1E-5; } } - protected virtual double FeetToTheSixthTolerance { get { return 1E-5; } } - protected virtual double InchesToTheSixthTolerance { get { return 1E-5; } } - protected virtual double MetersToTheSixthTolerance { get { return 1E-5; } } - protected virtual double MillimetersToTheSixthTolerance { get { return 1E-5; } } + protected virtual double CentimetersToTheSixthTolerance { get { return 1e-5; } } + protected virtual double DecimetersToTheSixthTolerance { get { return 1e-5; } } + protected virtual double FeetToTheSixthTolerance { get { return 1e-5; } } + protected virtual double InchesToTheSixthTolerance { get { return 1e-5; } } + protected virtual double MetersToTheSixthTolerance { get { return 1e-5; } } + protected virtual double MillimetersToTheSixthTolerance { get { return 1e-5; } } // ReSharper restore VirtualMemberNeverOverriden.Global protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(WarpingMomentOfInertiaUnit unit) @@ -208,7 +208,7 @@ public void As_SIUnitSystem_ThrowsArgumentExceptionIfNotSupported() if (SupportsSIUnitSystem) { - var value = (double) (QuantityValue) AsWithSIUnitSystem(); + var value = (double) AsWithSIUnitSystem(); Assert.Equal(1, value); } else @@ -529,21 +529,14 @@ public void TryParseUnit() [MemberData(nameof(UnitTypes))] public void ToUnit(WarpingMomentOfInertiaUnit unit) { - var inBaseUnit = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); - var converted = inBaseUnit.ToUnit(unit); + var inBaseUnits = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); + var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } - [Fact] - public void ToUnit_FromNonExistingUnit_ThrowsNotSupportedException() - { - var inBaseUnit = WarpingMomentOfInertia.From(1.0, WarpingMomentOfInertia.BaseUnit); - Assert.Throws(() => inBaseUnit.ToUnit(default(WarpingMomentOfInertiaUnit))); - } - [Theory] [MemberData(nameof(UnitTypes))] public void ToUnit_WithSameUnits_AreEqual(WarpingMomentOfInertiaUnit unit) @@ -557,8 +550,8 @@ public void ToUnit_WithSameUnits_AreEqual(WarpingMomentOfInertiaUnit unit) [MemberData(nameof(UnitTypes))] public void ToUnit_FromNonBaseUnit_ReturnsQuantityWithGivenUnit(WarpingMomentOfInertiaUnit unit) { - // This test is only available for quantities with more than one units. - var fromUnit = WarpingMomentOfInertia.Units.First(u => u != WarpingMomentOfInertia.BaseUnit); + // See if there is a unit available that is not the base unit, fallback to base unit if it has only a single unit. + var fromUnit = WarpingMomentOfInertia.Units.Where(u => u != WarpingMomentOfInertia.BaseUnit).DefaultIfEmpty(WarpingMomentOfInertia.BaseUnit).FirstOrDefault(); var quantity = WarpingMomentOfInertia.From(3.0, fromUnit); var converted = quantity.ToUnit(unit); @@ -768,9 +761,8 @@ public void Convert_ToBool_ThrowsInvalidCastException() [Fact] public void Convert_ToByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((byte)value, Convert.ToByte(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((byte)quantity.Value, Convert.ToByte(quantity)); } [Fact] @@ -804,41 +796,36 @@ public void Convert_ToDouble_EqualsValueAsSameType() [Fact] public void Convert_ToInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((short)value, Convert.ToInt16(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((short)quantity.Value, Convert.ToInt16(quantity)); } [Fact] public void Convert_ToInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((int)value, Convert.ToInt32(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((int)quantity.Value, Convert.ToInt32(quantity)); } [Fact] public void Convert_ToInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((long)value, Convert.ToInt64(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((long)quantity.Value, Convert.ToInt64(quantity)); } [Fact] public void Convert_ToSByte_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((sbyte)value, Convert.ToSByte(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((sbyte)quantity.Value, Convert.ToSByte(quantity)); } [Fact] public void Convert_ToSingle_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((float)value, Convert.ToSingle(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((float)quantity.Value, Convert.ToSingle(quantity)); } [Fact] @@ -851,25 +838,22 @@ public void Convert_ToString_EqualsToString() [Fact] public void Convert_ToUInt16_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((ushort)value, Convert.ToUInt16(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((ushort)quantity.Value, Convert.ToUInt16(quantity)); } [Fact] public void Convert_ToUInt32_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((uint)value, Convert.ToUInt32(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((uint)quantity.Value, Convert.ToUInt32(quantity)); } [Fact] public void Convert_ToUInt64_EqualsValueAsSameType() { - var value = 1.0; - var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(value); - Assert.Equal((ulong)value, Convert.ToUInt64(quantity)); + var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); + Assert.Equal((ulong)quantity.Value, Convert.ToUInt64(quantity)); } [Fact] @@ -911,7 +895,7 @@ public void Convert_ChangeType_InvalidType_ThrowsInvalidCastException() public void GetHashCode_Equals() { var quantity = WarpingMomentOfInertia.FromMetersToTheSixth(1.0); - Assert.Equal(WarpingMomentOfInertia.Info.Name.GetHashCode(), quantity.GetHashCode()); + Assert.Equal(new {WarpingMomentOfInertia.Info.Name, quantity.Value, quantity.Unit}.GetHashCode(), quantity.GetHashCode()); } [Theory] diff --git a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs index 87882f3ad3..d02428161f 100644 --- a/UnitsNet.Tests/GeneratedQuantityCodeTests.cs +++ b/UnitsNet.Tests/GeneratedQuantityCodeTests.cs @@ -26,7 +26,7 @@ public void LengthEquals_GivenMaxError_ReturnsTrueIfWithinError() Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), 0, ComparisonType.Relative), "Integer values have zero difference."); Assert.True(Length.FromMeters(1).Equals(Length.FromMeters(1), smallError, ComparisonType.Relative), "Using a max difference value should not change that fact."); - Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0.0, ComparisonType.Relative), + Assert.False(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), 0, ComparisonType.Relative), "Example of floating precision arithmetic that produces slightly different results."); Assert.True(Length.FromMeters(1 + 0.39).Equals(Length.FromMeters(1.39), smallError, ComparisonType.Relative), "But the difference is very small"); } diff --git a/UnitsNet.Tests/IntOverloadTests.cs b/UnitsNet.Tests/IntOverloadTests.cs index 9d059dcc46..bf63007ba7 100644 --- a/UnitsNet.Tests/IntOverloadTests.cs +++ b/UnitsNet.Tests/IntOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromIntReturnsCorrectVa public static void CreatingQuantityWithIntBackingFieldFromIntReturnsCorrectValue() { Power power = Power.FromWatts(1); - Assert.Equal(1.0m, power.Watts); + Assert.Equal(1.0, power.Watts); } } } diff --git a/UnitsNet.Tests/LongOverloadTests.cs b/UnitsNet.Tests/LongOverloadTests.cs index ba5c00a538..fd54377f08 100644 --- a/UnitsNet.Tests/LongOverloadTests.cs +++ b/UnitsNet.Tests/LongOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromLongReturnsCorrectV public static void CreatingQuantityWithLongBackingFieldFromLongReturnsCorrectValue() { Power power = Power.FromWatts(1L); - Assert.Equal(1.0m, power.Watts); + Assert.Equal(1.0, power.Watts); } } } diff --git a/UnitsNet.Tests/QuantityComparisonTests.cs b/UnitsNet.Tests/QuantityComparisonTests.cs deleted file mode 100644 index 2947c2c251..0000000000 --- a/UnitsNet.Tests/QuantityComparisonTests.cs +++ /dev/null @@ -1,194 +0,0 @@ -using System; -using System.Collections.Generic; -using UnitsNet.Units; -using Xunit; - -namespace UnitsNet.Tests -{ - public class QuantityComparisonTests - { - private static readonly decimal DecimalEpsilon = new decimal(1, 0, 0, false, 28); //1e-28m; - - #region IComparable - - [Fact] - public void CompareTo_DoubleQuantityWithSameQuantityInAnotherUnit_ReturnsZero() - { - var firstMass = Mass.FromGrams(0.001); - var secondMass = firstMass.ToUnit(MassUnit.Microgram); - - Assert.Equal(0, firstMass.CompareTo(secondMass)); - Assert.Equal(0, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DecimalQuantityWithSameQuantityInAnotherUnit_ReturnsZero() - { - var firstMass = Mass.FromGrams(0.001m); - var secondMass = firstMass.ToUnit(MassUnit.Microgram); - - Assert.Equal(0, firstMass.CompareTo(secondMass)); - Assert.Equal(0, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DoubleQuantityWithVeryCloseDoubleQuantity_ReturnsNonZero() - { - var firstMass = Mass.FromGrams(0.0); - var secondMass = Mass.FromGrams(double.Epsilon); - - Assert.Equal(-1, firstMass.CompareTo(secondMass)); - Assert.Equal(1, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DecimalQuantityWithVeryCloseDecimalQuantity_ReturnsNonZero() - { - var firstMass = Mass.FromGrams(0m); - var secondMass = Mass.FromGrams(DecimalEpsilon); - - Assert.Equal(-1, firstMass.CompareTo(secondMass)); - Assert.Equal(1, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DoubleQuantityWithVeryCloseDecimalQuantity_ReturnsNonZero() - { - var firstMass = Mass.FromGrams(-double.Epsilon); - var secondMass = Mass.FromGrams(0m); - - Assert.Equal(-1, firstMass.CompareTo(secondMass)); - Assert.Equal(1, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DecimalQuantityWithVeryCloseDoubleQuantity_ReturnsNonZero() - { - var firstMass = Mass.FromGrams(0m); - var secondMass = Mass.FromGrams(double.Epsilon); - - Assert.Equal(-1, firstMass.CompareTo(secondMass)); - Assert.Equal(1, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DecimalQuantityWithVeryLargeDoubleQuantity_ReturnsNonZero() - { - var firstMass = Mass.FromGrams(0m); - var secondMass = Mass.FromGrams(double.MaxValue); - - Assert.Equal(-1, firstMass.CompareTo(secondMass)); - Assert.Equal(1, secondMass.CompareTo(firstMass)); - } - - [Fact] - public void CompareTo_DecimalQuantityWithVerySmallDoubleQuantity_ReturnsNonZero() - { - var firstMass = Mass.FromGrams(0m); - var secondMass = Mass.FromGrams(double.MinValue); - - Assert.Equal(1, firstMass.CompareTo(secondMass)); - Assert.Equal(-1, secondMass.CompareTo(firstMass)); - } - - #endregion - - [Fact] - public void Equals_DoubleQuantityWithSameQuantityInAnotherUnit_ReturnsFalse() - { - var firstMass = Mass.FromGrams(0.001); - var secondMass = firstMass.ToUnit(MassUnit.Microgram); - - Assert.NotEqual(firstMass, secondMass); - Assert.NotEqual(secondMass, firstMass); - } - - [Fact] - public void Equals_DecimalQuantityWithSameQuantityInAnotherUnit_ReturnsTrue() - { - var firstMass = Mass.FromGrams(0.001m); - var secondMass = firstMass.ToUnit(MassUnit.Microgram); - - Assert.Equal(firstMass, secondMass); - Assert.Equal(secondMass, firstMass); - } - - [Fact] - public void Equals_DecimalQuantityWithVeryCloseDoubleQuantityInSameUnit_ReturnsFalse() - { - var firstMass = Mass.FromGrams(0m); - var secondMass = Mass.FromGrams(double.Epsilon); - - Assert.NotEqual(firstMass, secondMass); - Assert.NotEqual(secondMass, firstMass); - } - - [Fact] - public void GetHashCode_WithSameQuantityInAnotherUnit_ReturnsSameValue() - { - var firstMass = Mass.FromGrams(0.001); - var secondMass = firstMass.ToUnit(MassUnit.Microgram); - - Assert.Equal(firstMass.GetHashCode(), secondMass.GetHashCode()); - } - - [Fact] - public void GetHashCode_WithVeryCloseQuantities_ReturnsSameValue() - { - var firstMass = Mass.FromGrams(0); - var secondMass = Mass.FromGrams(double.Epsilon); - - Assert.Equal(firstMass.GetHashCode(), secondMass.GetHashCode()); - } - - [Fact] - public void Contains_CollectionWithMixedUnits_DependsOnTheOrderOfInsertion() - { - var firstMass = Mass.FromGrams(0.001); - var secondMass = firstMass.ToUnit(MassUnit.Microgram); - - var collectionWithFirst = new HashSet {firstMass}; - var collectionWithSecond = new HashSet {secondMass}; - - Assert.Contains(firstMass, collectionWithFirst); - Assert.DoesNotContain(secondMass, collectionWithFirst); - - Assert.DoesNotContain(firstMass, collectionWithSecond); - Assert.Contains(secondMass, collectionWithSecond); - } - - [Fact] - public void Contains_CollectionWithVeryCloseQuantities_ReturnsTrueIfValuesAreStrictlyEqual() - { - var firstMass = Mass.FromGrams(0); - var secondMass = Mass.FromGrams(double.Epsilon); - - var collection = new HashSet {firstMass}; - - // equal hash codes do not imply object equality - Assert.Equal(firstMass.GetHashCode(), secondMass.GetHashCode()); - Assert.NotEqual(firstMass, secondMass); - - // Contains first checks HashCode, followed by Equals check - Assert.Contains(firstMass, collection); - Assert.DoesNotContain(secondMass, collection); - } - - [Fact] - public void Sort_CollectionWithMixedUnits_SortedByNaturalOrder() - { - var firstMass = Mass.FromGrams(0); - var secondMass = Mass.FromGrams(double.Epsilon); - var thirdMass = Mass.FromGrams(0.001); - var fourthMass = thirdMass.ToUnit(MassUnit.Microgram); - - var collection = new[] {thirdMass, firstMass, fourthMass, secondMass}; - Array.Sort(collection); - - Assert.Equal(firstMass, collection[0]); - Assert.Equal(secondMass, collection[1]); - Assert.Equal(thirdMass, collection[2]); - Assert.Equal(fourthMass, collection[3]); - } - } -} diff --git a/UnitsNet.Tests/QuantityValueTests.cs b/UnitsNet.Tests/QuantityValueTests.cs deleted file mode 100644 index 8df8cfb717..0000000000 --- a/UnitsNet.Tests/QuantityValueTests.cs +++ /dev/null @@ -1,150 +0,0 @@ -using System; -using Xunit; - -namespace UnitsNet.Tests; - -public class QuantityValueTests -{ - [Fact] - public void QuantityValue_FromDouble_ContainsDouble() - { - QuantityValue value = 1.0; - - Assert.False(value.IsDecimal); - Assert.Equal(1.0, (double)value); - } - - [Fact] - public void QuantityValue_FromDecimal_ContainsDecimal() - { - QuantityValue value = 1.0m; - - Assert.True(value.IsDecimal); - Assert.Equal(1.0m, (decimal)value); - } - - [Fact] - public void QuantityValue_FromInteger_ContainsDecimal() - { - QuantityValue value = 1; - - Assert.True(value.IsDecimal); - Assert.Equal(1m, (decimal)value); - } - - [Fact] - public void QuantityValue_FromNaN_ThrowsException() - { - Assert.Throws(() => (QuantityValue)double.NaN); - } - - [Fact] - public void QuantityValue_FromInfinity_ThrowsException() - { - Assert.Throws(() => (QuantityValue)double.PositiveInfinity); - Assert.Throws(() => (QuantityValue)double.NegativeInfinity); - } - - [Fact] - public void Operations_WithDoubles_ReturnDoubles() - { - QuantityValue two = 2.0; - - QuantityValue twoPlusTwo = two + two; - QuantityValue twoMinusTwo = two - two; - QuantityValue twoTimesTwo = two * two; - QuantityValue twoDividedByTwo = two / two; - - Assert.False(twoPlusTwo.IsDecimal); - Assert.False(twoMinusTwo.IsDecimal); - Assert.False(twoTimesTwo.IsDecimal); - Assert.False(twoDividedByTwo.IsDecimal); - - Assert.Equal(4.0, (double)twoPlusTwo); - Assert.Equal(0.0, (double)twoMinusTwo); - Assert.Equal(4.0, (double)twoTimesTwo); - Assert.Equal(1.0, (double)twoDividedByTwo); - } - - [Fact] - public void Operations_WithDecimal_ReturnDecimals() - { - QuantityValue two = 2.0m; - - QuantityValue twoPlusTwo = two + two; - QuantityValue twoMinusTwo = two - two; - QuantityValue twoTimesTwo = two * two; - QuantityValue twoDividedByTwo = two / two; - - Assert.True(twoPlusTwo.IsDecimal); - Assert.True(twoMinusTwo.IsDecimal); - Assert.True(twoTimesTwo.IsDecimal); - Assert.True(twoDividedByTwo.IsDecimal); - - Assert.Equal(4.0m, (decimal)twoPlusTwo); - Assert.Equal(0.0m, (decimal)twoMinusTwo); - Assert.Equal(4.0m, (decimal)twoTimesTwo); - Assert.Equal(1.0m, (decimal)twoDividedByTwo); - } - - [Fact] - public void Operations_WithDoubleAndDecimal_ReturnDecimals() - { - QuantityValue twoFromDouble = 2.0; - QuantityValue twoFromDecimal = 2.0m; - - QuantityValue twoPlusTwo = twoFromDouble + twoFromDecimal; - QuantityValue twoMinusTwo = twoFromDouble - twoFromDecimal; - QuantityValue twoTimesTwo = twoFromDouble * twoFromDecimal; - QuantityValue twoDividedByTwo = twoFromDouble / twoFromDecimal; - - Assert.True(twoPlusTwo.IsDecimal); - Assert.True(twoMinusTwo.IsDecimal); - Assert.True(twoTimesTwo.IsDecimal); - Assert.True(twoDividedByTwo.IsDecimal); - - Assert.Equal(4.0m, (decimal)twoPlusTwo); - Assert.Equal(0.0m, (decimal)twoMinusTwo); - Assert.Equal(4.0m, (decimal)twoTimesTwo); - Assert.Equal(1.0m, (decimal)twoDividedByTwo); - } - - [Fact] - public void OverflowingOperations_WithDecimal_ReturnDoubles() - { - // TODO see about exposing a QuantityValue.MaxDecimal constant - const decimal maxDecimalValue = decimal.MaxValue * 1E-6m; // the clamping value is actual smaller than the decimal.MaxValue (ensuring the minimal conversion precision) - QuantityValue maxDecimal = maxDecimalValue; - - QuantityValue twoTimesMax = maxDecimal + maxDecimal; - QuantityValue twoTimesMin = -maxDecimal - maxDecimal; - QuantityValue maxSquared = maxDecimal * maxDecimal; - QuantityValue oneOverMax = 0.1 / maxDecimal; - - Assert.True(maxDecimal.IsDecimal); - Assert.False(twoTimesMax.IsDecimal); - Assert.False(twoTimesMin.IsDecimal); - Assert.False(maxSquared.IsDecimal); - Assert.False(oneOverMax.IsDecimal); - - const double max = (double)maxDecimalValue; - Assert.Equal(max + max, (double)twoTimesMax); - Assert.Equal(-max - max, (double)twoTimesMin); - Assert.Equal(max * max, (double)maxSquared); - Assert.Equal(0.1 / max, (double)oneOverMax); - } - - [Fact] - public void OverflowingOperations_WithDouble_ThrowArgumentException() - { - // TODO see about supporting Positive/Negative infinity - QuantityValue maxDouble = double.MaxValue; - - Assert.Throws(() => maxDouble + maxDouble); - Assert.Throws(() => -maxDouble - maxDouble); - Assert.Throws(() => maxDouble * maxDouble); - Assert.Throws(() => maxDouble / 0); - } - - // TODO add tests for IEquatable / IComparable (decimal comparison when both values are in the decimal range) -} diff --git a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs index ea9fdf9429..d556757893 100644 --- a/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Json/DefaultDataContractJsonSerializerTests.cs @@ -1,5 +1,4 @@ -using System; -using System.Globalization; +using System.Globalization; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Json; @@ -42,13 +41,12 @@ protected override T DeserializeObject(string xml) #region Serialization tests - [Fact] - public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit() + public void DoubleQuantity_SerializedWithDoubleValueAndunitInt() { var quantity = new Mass(1.20, MassUnit.Milligram); var unitInt = (int)quantity.Unit; - var expectedJson = $"{{\"Value\":{{\"Double\":1.2}},\"Unit\":{unitInt}}}"; + var expectedJson = $"{{\"Value\":1.2,\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); @@ -56,14 +54,14 @@ public void DoubleQuantity_SerializedWithDoubleValueAndIntegerUnit() } [Fact] - public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit() + public void DecimalQuantity_SerializedWithDecimalValueValueAndunitInt() { var quantity = new Information(1.20m, InformationUnit.Exabyte); var unitInt = (int)InformationUnit.Exabyte; - var expectedJson = $"{{\"Value\":{{\"Decimal\":1.20}},\"Unit\":{unitInt}}}"; + var expectedJson = $"{{\"Value\":1.20,\"Unit\":{unitInt}}}"; var json = SerializeObject(quantity); - + Assert.Equal(expectedJson, json); } @@ -72,11 +70,11 @@ public void DecimalQuantity_SerializedWithDecimalValueValueAndIntegerUnit() #region Deserialization tests [Fact] - public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit() + public void DoubleQuantity_DeserializedFromDoubleValueAndunitInt() { var expectedUnit = MassUnit.Milligram; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":{{\"Double\":1.2}},\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":1.2,\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -85,11 +83,11 @@ public void DoubleQuantity_DeserializedFromDoubleValueAndIntegerUnit() } [Fact] - public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() + public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndunitInt() { var expectedUnit = MassUnit.Milligram; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":{{\"Double\":\"1.2\"}},\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":\"1.2\",\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -98,7 +96,7 @@ public void DoubleQuantity_DeserializedFromQuotedDoubleValueAndIntegerUnit() } [Fact] - public void DoubleZeroQuantity_DeserializedFromIntegerUnitAndNoValue() + public void DoubleZeroQuantity_DeserializedFromunitIntAndNoValue() { var expectedUnit = MassUnit.Milligram; var unitInt = (int)expectedUnit; @@ -116,7 +114,7 @@ public void InterfaceObject_IncludesTypeInformation() var unit = InformationUnit.Exabyte; var unitInt = (int)unit; var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, unit) }; - var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":{{\"Decimal\":1.20}},\"Unit\":{unitInt}}}}}"; + var expectedJson = $"{{\"Quantity\":{{\"__type\":\"Information:#UnitsNet\",\"Value\":1.20,\"Unit\":{unitInt}}}}}"; var json = SerializeObject(testObject); @@ -126,7 +124,7 @@ public void InterfaceObject_IncludesTypeInformation() [Fact] public void DoubleBaseUnitQuantity_DeserializedFromValueAndNoUnit() { - var json = "{\"Value\":{\"Double\":1.2}}"; + var json = "{\"Value\":1.2}"; var quantity = DeserializeObject(json); @@ -146,11 +144,11 @@ public void DoubleZeroBaseQuantity_DeserializedFromEmptyInput() } [Fact] - public void DecimalQuantity_DeserializedFromDecimalValueAndIntegerUnit() + public void DecimalQuantity_DeserializedFromDecimalValueAndunitInt() { var expectedUnit = InformationUnit.Exabyte; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":{{\"Decimal\":1.200}},\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":1.200,\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -168,11 +166,11 @@ public void InterfaceObject_WithMissingKnownTypeInformation_ThrowsSerializationE } [Fact] - public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndDecimalUnit() + public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndunitInt() { var expectedUnit = InformationUnit.Exabyte; var unitInt = (int)expectedUnit; - var json = $"{{\"Value\":{{\"Decimal\":\"1.200\"}},\"Unit\":{unitInt}}}"; + var json = $"{{\"Value\":\"1.200\",\"Unit\":{unitInt}}}"; var quantity = DeserializeObject(json); @@ -182,7 +180,7 @@ public void DecimalQuantity_DeserializedFromQuotedDecimalValueAndDecimalUnit() } [Fact] - public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue() + public void DecimalZeroQuantity_DeserializedFromunitIntAndNoValue() { var expectedUnit = InformationUnit.Exabyte; var unitInt = (int)expectedUnit; @@ -197,7 +195,7 @@ public void DecimalZeroQuantity_DeserializedFromIntegerUnitAndNoValue() [Fact] public void DecimalBaseUnitQuantity_DeserializedFromDecimalValueAndNoUnit() { - var json = "{\"Value\":{\"Decimal\":1.200}}"; + var json = "{\"Value\":1.200}"; var quantity = DeserializeObject(json); diff --git a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs index 83f468bd41..d2a4f6d6b8 100644 --- a/UnitsNet.Tests/Serialization/SerializationTestsBase.cs +++ b/UnitsNet.Tests/Serialization/SerializationTestsBase.cs @@ -64,7 +64,7 @@ public void DecimalValueQuantity_SerializationRoundTrips() [Fact] public void LargeDecimalValueQuantity_SerializationRoundTrips() { - var quantity = Information.FromExabytes(1E+24m); + var quantity = Information.FromExabytes(1E+24); var payload = SerializeObject(quantity); var result = DeserializeObject(payload); diff --git a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs index 21d4c6d989..ca45df9395 100644 --- a/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs +++ b/UnitsNet.Tests/Serialization/Xml/DataContractSerializerTests.cs @@ -39,7 +39,7 @@ protected override T DeserializeObject(string xml) public void DoubleQuantity_SerializedWithValueAndMemberName() { var quantity = new Mass(1.20, MassUnit.Milligram); - var expectedXml = $"1.2Milligram"; + var expectedXml = $"1.2Milligram"; var xml = SerializeObject(quantity); @@ -50,7 +50,7 @@ public void DoubleQuantity_SerializedWithValueAndMemberName() public void DecimalQuantity_SerializedWithValueAndMemberName() { var quantity = new Information(1.20m, InformationUnit.Exabyte); - var expectedXml = $"1.20Exabyte"; + var expectedXml = $"1.20Exabyte"; var xml = SerializeObject(quantity); @@ -63,7 +63,7 @@ public void InterfaceObject_IncludesTypeInformation() var testObject = new TestInterfaceObject { Quantity = new Information(1.20m, InformationUnit.Exabyte) }; var quantityNamespace = "xmlns:a=\"http://schemas.datacontract.org/2004/07/UnitsNet\""; // there is an extra 'a' compared to Namespace - var expectedQuantityXml = $"1.20Exabyte"; + var expectedQuantityXml = $"1.20Exabyte"; var expectedXml = $"{expectedQuantityXml}"; var xml = SerializeObject(testObject); diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index b58f13a258..421d7fef23 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -112,8 +112,8 @@ public void ConversionForUnitsOfCustomQuantity(double fromValue, HowMuchUnit fro { // Intentionally don't map conversion Some->Some, it is not necessary var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch((double)x.Value * 2, HowMuchUnit.ATon)); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch((double)x.Value * 10, HowMuchUnit.AShitTon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch(x.Value * 2, HowMuchUnit.ATon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch(x.Value * 10, HowMuchUnit.AShitTon)); var foundConversionFunction = unitConverter.GetConversionFunction(fromUnit, toUnit); var converted = foundConversionFunction(new HowMuch(fromValue, fromUnit)); @@ -164,9 +164,9 @@ public void ConvertByName_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUnit(doubl [InlineData(1, "UnknownQuantity", "Meter", "Centimeter")] [InlineData(1, "Length", "UnknownFromUnit", "Centimeter")] [InlineData(1, "Length", "Meter", "UnknownToUnit")] - public void TryConvertByName_ReturnsFalseForInvalidInput(QuantityValue inputValue, string quantityTypeName, string fromUnit, string toUnit) + public void TryConvertByName_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out var result)); + Assert.False(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); Assert.Equal(0, result); } @@ -175,10 +175,10 @@ public void TryConvertByName_ReturnsFalseForInvalidInput(QuantityValue inputValu [InlineData(100, 1, "Length", "Meter", "Centimeter")] [InlineData(1, 1000, "Mass", "Gram", "Kilogram")] [InlineData(1000, 1, "ElectricCurrent", "Kiloampere", "Ampere")] - public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(QuantityValue expectedValue, double inputValue, string quantityTypeName, string fromUnit, + public void TryConvertByName_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out var result), "TryConvertByName() return value."); + Assert.True(UnitConverter.TryConvertByName(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByName() return value."); Assert.Equal(expectedValue, result); } @@ -211,9 +211,9 @@ public void ConvertByAbbreviation_ThrowsUnitNotFoundExceptionOnUnknownFromOrToUn [InlineData(1, "UnknownQuantity", "m", "cm")] [InlineData(1, "Length", "UnknownFromUnit", "cm")] [InlineData(1, "Length", "m", "UnknownToUnit")] - public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(QuantityValue inputValue, string quantityTypeName, string fromUnit, string toUnit) + public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out var result)); + Assert.False(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result)); Assert.Equal(0, result); } @@ -222,10 +222,10 @@ public void TryConvertByAbbreviation_ReturnsFalseForInvalidInput(QuantityValue i [InlineData(100, 1, "Length", "m", "cm")] [InlineData(1, 1000, "Mass", "g", "kg")] [InlineData(1000, 1, "ElectricCurrent", "kA", "A")] - public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(QuantityValue expectedValue, double inputValue, string quantityTypeName, string fromUnit, + public void TryConvertByAbbreviation_ReturnsTrueOnSuccessAndOutputsResult(double expectedValue, double inputValue, string quantityTypeName, string fromUnit, string toUnit) { - Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out var result), "TryConvertByAbbreviation() return value."); + Assert.True(UnitConverter.TryConvertByAbbreviation(inputValue, quantityTypeName, fromUnit, toUnit, out double result), "TryConvertByAbbreviation() return value."); Assert.Equal(expectedValue, result); } } diff --git a/UnitsNet.Tests/UnitsNet.Tests.csproj b/UnitsNet.Tests/UnitsNet.Tests.csproj index 5bc5c3cf63..1d79559af7 100644 --- a/UnitsNet.Tests/UnitsNet.Tests.csproj +++ b/UnitsNet.Tests/UnitsNet.Tests.csproj @@ -24,8 +24,8 @@ - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/UnitsNet.sln b/UnitsNet.sln index 4b402d54ec..6ae0d3d8b3 100644 --- a/UnitsNet.sln +++ b/UnitsNet.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.3.32811.315 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29609.76 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet", "UnitsNet\UnitsNet.csproj", "{CBEAD842-07BC-4B08-9D9D-D6659813776F}" EndProject @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.Json EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Tests", "UnitsNet.Tests\UnitsNet.Tests.csproj", "{0E3B7567-5DF2-44BD-88DB-CCF050D3F943}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.JsonNet.CompatibilityTests", "UnitsNet.Serialization.JsonNet.CompatibilityTests\UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj", "{21F2FFAC-BF39-487F-9ADE-37100162F955}" +EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Benchmark", "UnitsNet.Benchmark\UnitsNet.Benchmark.csproj", "{76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeGen", "CodeGen\CodeGen.csproj", "{078E3D44-4F60-46B3-9099-91A7CBF0B213}" @@ -20,27 +22,27 @@ EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.NumberExtensions.Tests", "UnitsNet.NumberExtensions.Tests\UnitsNet.NumberExtensions.Tests.csproj", "{B4996AF5-9A8B-481A-9018-EC7F5B1605FF}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Files", "_Files", "{B92B01BE-243E-4CCB-B5E5-AF469ADB1F54}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - .gitattributes = .gitattributes - .gitignore = .gitignore - appveyor.yml = appveyor.yml - build-all-targets.bat = build-all-targets.bat - build.bat = build.bat - clean.bat = clean.bat - CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md - CONTRIBUTING.md = CONTRIBUTING.md - Directory.Build.props = Directory.Build.props - generate-code.bat = generate-code.bat - init.bat = init.bat - LICENSE = LICENSE - nuget.config = nuget.config - publish-unitsnet.bat = publish-unitsnet.bat - README.md = README.md - test.bat = test.bat - UnitsNet.sln.DotSettings = UnitsNet.sln.DotSettings - UnitsNet.snk = UnitsNet.snk - EndProjectSection +ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + .gitattributes = .gitattributes + .gitignore = .gitignore + appveyor.yml = appveyor.yml + build.bat = build.bat + build-all-targets.bat = build-all-targets.bat + clean.bat = clean.bat + CODE_OF_CONDUCT.md = CODE_OF_CONDUCT.md + CONTRIBUTING.md = CONTRIBUTING.md + Directory.Build.props = Directory.Build.props + generate-code.bat = generate-code.bat + init.bat = init.bat + LICENSE = LICENSE + nuget.config = nuget.config + publish-unitsnet.bat = publish-unitsnet.bat + README.md = README.md + test.bat = test.bat + UnitsNet.sln.DotSettings = UnitsNet.sln.DotSettings + UnitsNet.snk = UnitsNet.snk +EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -64,6 +66,10 @@ Global {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.Build.0 = Release|Any CPU + {21F2FFAC-BF39-487F-9ADE-37100162F955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {21F2FFAC-BF39-487F-9ADE-37100162F955}.Debug|Any CPU.Build.0 = Debug|Any CPU + {21F2FFAC-BF39-487F-9ADE-37100162F955}.Release|Any CPU.ActiveCfg = Release|Any CPU + {21F2FFAC-BF39-487F-9ADE-37100162F955}.Release|Any CPU.Build.0 = Release|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index 7a448f9b89..575707e6b5 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -49,66 +49,7 @@ public static class Comparison /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// Whether the tolerance is absolute or relative. /// - public static bool Equals(QuantityValue referenceValue, QuantityValue otherValue, QuantityValue tolerance, ComparisonType comparisonType) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); - - switch (comparisonType) - { - case ComparisonType.Relative: - return referenceValue.IsDecimal || otherValue.IsDecimal || tolerance.IsDecimal - ? EqualsRelative((decimal)referenceValue, (decimal)otherValue, (decimal)tolerance) - : EqualsRelative((double)referenceValue, (double)otherValue, (double)tolerance); - case ComparisonType.Absolute: - return referenceValue.IsDecimal || otherValue.IsDecimal || tolerance.IsDecimal - ? EqualsAbsolute((decimal)referenceValue, (decimal)otherValue, (decimal)tolerance) - : EqualsAbsolute((double)referenceValue, (double)otherValue, (double)tolerance); - default: - throw new InvalidOperationException("The given ComparisonType is not supported."); - } - } - - /// - /// - /// Checks if two values are equal with a given relative or absolute tolerance. - /// - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a percentage of . A relative tolerance of - /// 0.01 means the - /// absolute difference of and must be within +/- - /// 1%. - /// - /// In this example, the two values will be equal if the value of b is within +/- 1% of a. - /// - /// Equals(a, b, 0.01, ComparisonType.Relative); - /// - /// - /// - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a fixed number. - /// - /// In this example, the two values will be equal if abs( - - /// ) <= 0.01 - /// - /// Equals(a, b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// - /// The reference value. If using relative tolerance, it is the value which the relative - /// tolerance will be calculated against. - /// - /// The value to compare to. - /// The absolute or relative tolerance value. Must be greater than or equal to 0. - /// Whether the tolerance is absolute or relative. - /// - public static bool Equals(decimal referenceValue, decimal otherValue, decimal tolerance, ComparisonType comparisonType) + public static bool Equals(double referenceValue, double otherValue, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); @@ -154,36 +95,6 @@ public static bool EqualsRelative(double referenceValue, double otherValue, doub return Math.Abs(referenceValue - otherValue) <= maxVariation; } - /// - /// Checks if two values are equal with a given relative tolerance. - /// - /// Relative tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a percentage of . A relative tolerance of - /// 0.01 means the - /// absolute difference of and must be within +/- - /// 1%. - /// - /// In this example, the two values will be equal if the value of b is within +/- 1% of a. - /// - /// EqualsRelative(a, b, 0.01); - /// - /// - /// - /// - /// The reference value which the tolerance will be calculated against. - /// The value to compare to. - /// The relative tolerance. Must be greater than or equal to 0. - /// True if the two values are equal within the given relative tolerance, otherwise false. - public static bool EqualsRelative(decimal referenceValue, decimal otherValue, decimal tolerance) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); - - var maxVariation = Math.Abs(referenceValue * tolerance); - return Math.Abs(referenceValue - otherValue) <= maxVariation; - } - /// /// Checks if two values are equal with a given absolute tolerance. /// @@ -210,32 +121,5 @@ public static bool EqualsAbsolute(double value1, double value2, double tolerance return Math.Abs(value1 - value2) <= tolerance; } - - /// - /// Checks if two values are equal with a given absolute tolerance. - /// - /// Absolute tolerance is defined as the maximum allowable absolute difference between - /// and - /// as a fixed number. - /// - /// In this example, the two values will be equal if abs( - - /// ) <= 0.01 - /// - /// Equals(a, b, 0.01, ComparisonType.Absolute); - /// - /// - /// - /// - /// The first value. - /// The second value. - /// The absolute tolerance. Must be greater than or equal to 0. - /// True if the two values are equal within the given absolute tolerance, otherwise false. - public static bool EqualsAbsolute(decimal value1, decimal value2, decimal tolerance) - { - if (tolerance < 0) - throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); - - return Math.Abs(value1 - value2) <= tolerance; - } } } diff --git a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs index 8b88ed6197..5d486417ec 100644 --- a/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmountOfSubstance.extra.cs @@ -31,7 +31,7 @@ public partial struct AmountOfSubstance public double NumberOfParticles() { var moles = GetValueAs(AmountOfSubstanceUnit.Mole); - return AvogadroConstant * (double) moles; + return AvogadroConstant * moles; } /// Get from and a given . diff --git a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs index b67402cd73..cc0a3cfcdf 100644 --- a/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/AmplitudeRatio.extra.cs @@ -24,7 +24,7 @@ public AmplitudeRatio(ElectricPotential voltage) "The base-10 logarithm of a number ≤ 0 is undefined. Voltage must be greater than 0 V."); // E(dBV) = 20*log10(value(V)/reference(V)) - _value = 20 * Math.Log10((double)(voltage.Volts / 1)); + _value = 20 * Math.Log10(voltage.Volts / 1); _unit = AmplitudeRatioUnit.DecibelVolt; } @@ -40,7 +40,7 @@ public AmplitudeRatio(ElectricPotential voltage) public ElectricPotential ToElectricPotential() { // E(V) = 1V * 10^(E(dBV)/20) - return ElectricPotential.FromVolts( Math.Pow( 10, (double)(DecibelVolts / 20) ) ); + return ElectricPotential.FromVolts( Math.Pow( 10, DecibelVolts / 20 ) ); } /// @@ -51,7 +51,7 @@ public ElectricPotential ToElectricPotential() public PowerRatio ToPowerRatio( ElectricResistance impedance ) { // P(dBW) = E(dBV) - 10*log10(Z(Ω)/1) - return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( (double)(impedance.Ohms / 1) ) ); + return PowerRatio.FromDecibelWatts( DecibelVolts - 10 * Math.Log10( impedance.Ohms / 1 ) ); } #region Static Methods diff --git a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs index 46785cd29a..5bd29a877a 100644 --- a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs +++ b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs @@ -1,8 +1,6 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. -using UnitsNet.Units; - namespace UnitsNet { public partial struct BrakeSpecificFuelConsumption @@ -10,7 +8,7 @@ public partial struct BrakeSpecificFuelConsumption /// Get from times . public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule*power.Watts); } /// Get from divided by . @@ -20,9 +18,9 @@ public partial struct BrakeSpecificFuelConsumption } /// Get constant from times . - public static QuantityValue operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy) + public static double operator *(BrakeSpecificFuelConsumption bsfc, SpecificEnergy specificEnergy) { - return specificEnergy.JoulesPerKilogram * bsfc.KilogramsPerJoule; + return specificEnergy.JoulesPerKilogram*bsfc.KilogramsPerJoule; } } } diff --git a/UnitsNet/CustomCode/Quantities/Duration.extra.cs b/UnitsNet/CustomCode/Quantities/Duration.extra.cs index 537a5d619d..e1e898c62d 100644 --- a/UnitsNet/CustomCode/Quantities/Duration.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Duration.extra.cs @@ -18,19 +18,19 @@ public TimeSpan ToTimeSpan() if ( Seconds > TimeSpan.MaxValue.TotalSeconds || Seconds < TimeSpan.MinValue.TotalSeconds ) throw new ArgumentOutOfRangeException( nameof( Duration ), "The duration is too large or small to fit in a TimeSpan" ); - return TimeSpan.FromTicks((long)((double)Seconds * TimeSpan.TicksPerSecond)); + return TimeSpan.FromTicks((long)(Seconds * TimeSpan.TicksPerSecond)); } /// Get from plus . public static DateTime operator +(DateTime time, Duration duration) { - return time.AddSeconds((double)duration.Seconds); + return time.AddSeconds(duration.Seconds); } /// Get from minus . public static DateTime operator -(DateTime time, Duration duration) { - return time.AddSeconds(-(double)duration.Seconds); + return time.AddSeconds(-duration.Seconds); } /// Explicitly cast to . diff --git a/UnitsNet/CustomCode/Quantities/Force.extra.cs b/UnitsNet/CustomCode/Quantities/Force.extra.cs index 38f3742e71..7972c0f412 100644 --- a/UnitsNet/CustomCode/Quantities/Force.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Force.extra.cs @@ -10,7 +10,7 @@ public partial struct Force /// Get from divided by . public static Force FromPressureByArea(Pressure p, Area area) { - var newtons = p.Pascals * area.SquareMeters; + double newtons = p.Pascals * area.SquareMeters; return new Force(newtons, ForceUnit.Newton); } diff --git a/UnitsNet/CustomCode/Quantities/Length.extra.cs b/UnitsNet/CustomCode/Quantities/Length.extra.cs index ae8e78eb01..5bb37e2562 100644 --- a/UnitsNet/CustomCode/Quantities/Length.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Length.extra.cs @@ -32,7 +32,7 @@ public FeetInches FeetInches { get { - var inInches = (double)Inches; + var inInches = Inches; var feet = Math.Truncate(inInches / InchesInOneFoot); var inches = inInches % InchesInOneFoot; diff --git a/UnitsNet/CustomCode/Quantities/Mass.extra.cs b/UnitsNet/CustomCode/Quantities/Mass.extra.cs index f87d867b48..3b8f101e7e 100644 --- a/UnitsNet/CustomCode/Quantities/Mass.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Mass.extra.cs @@ -29,7 +29,7 @@ public StonePounds StonePounds { get { - var inPounds = (double)Pounds; + var inPounds = Pounds; var stones = Math.Truncate(inPounds / StonesInOnePound); var pounds = inPounds % StonesInOnePound; diff --git a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs index dd552aa937..e60c5c75d8 100644 --- a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using UnitsNet.Units; namespace UnitsNet { diff --git a/UnitsNet/CustomCode/Quantities/Power.extra.cs b/UnitsNet/CustomCode/Quantities/Power.extra.cs index 024c4f44e9..187c2740fc 100644 --- a/UnitsNet/CustomCode/Quantities/Power.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Power.extra.cs @@ -2,7 +2,6 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; -using UnitsNet.Units; namespace UnitsNet { @@ -91,7 +90,7 @@ public PowerRatio ToPowerRatio() /// Get from divided by . public static Area operator /(Power power, HeatFlux heatFlux) { - return Area.FromSquareMeters(power.Watts / heatFlux.WattsPerSquareMeter ); + return Area.FromSquareMeters( power.Watts / heatFlux.WattsPerSquareMeter ); } /// Calculate from divided by . diff --git a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs index 3cbc0d9e10..f563f720ae 100644 --- a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs @@ -21,7 +21,7 @@ public PowerRatio(Power power) nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10((double)power.Watts); + _value = 10 * Math.Log10(power.Watts / 1); _unit = PowerRatioUnit.DecibelWatt; } @@ -37,7 +37,7 @@ public PowerRatio(Power power) public Power ToPower() { // P(W) = 1W * 10^(P(dBW)/10) - return Power.FromWatts(Math.Pow(10, (double)(DecibelWatts / 10))); + return Power.FromWatts(Math.Pow(10, DecibelWatts / 10)); } /// @@ -47,7 +47,7 @@ public Power ToPower() public AmplitudeRatio ToAmplitudeRatio(ElectricResistance impedance) { // E(dBV) = 10*log10(Z(Ω)/1) + P(dBW) - return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10((double)(impedance.Ohms / 1)) + DecibelWatts); + return AmplitudeRatio.FromDecibelVolts(10 * Math.Log10(impedance.Ohms / 1) + DecibelWatts); } #region Static Methods diff --git a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs index c6d0c172ad..45f4473f80 100644 --- a/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs +++ b/UnitsNet/CustomCode/Quantities/SpecificEnergy.extra.cs @@ -24,7 +24,7 @@ public partial struct SpecificEnergy } /// Get from times . - public static QuantityValue operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc) + public static double operator *(SpecificEnergy specificEnergy, BrakeSpecificFuelConsumption bsfc) { return specificEnergy.JoulesPerKilogram * bsfc.KilogramsPerJoule; } diff --git a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs index 60b411f358..4556009fc6 100644 --- a/UnitsNet/CustomCode/Quantities/Temperature.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Temperature.extra.cs @@ -60,7 +60,7 @@ public partial struct Temperature /// The resulting . public Temperature Multiply(double factor, TemperatureUnit unit) { - var resultInUnit = As(unit) * factor; + double resultInUnit = As(unit) * factor; return From(resultInUnit, unit); } @@ -77,7 +77,7 @@ public Temperature Multiply(double factor, TemperatureUnit unit) /// The resulting . public Temperature Divide(double divisor, TemperatureUnit unit) { - var resultInUnit = As(unit) / divisor; + double resultInUnit = As(unit) / divisor; return From(resultInUnit, unit); } } diff --git a/UnitsNet/CustomCode/Quantities/Volume.extra.cs b/UnitsNet/CustomCode/Quantities/Volume.extra.cs index 1debb193e1..aab43915a4 100644 --- a/UnitsNet/CustomCode/Quantities/Volume.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Volume.extra.cs @@ -34,7 +34,7 @@ public partial struct Volume /// Get from divided by . public static TimeSpan operator /(Volume volume, VolumeFlow volumeFlow) { - return TimeSpan.FromSeconds((double)(volume.CubicMeters / volumeFlow.CubicMetersPerSecond)); + return TimeSpan.FromSeconds(volume.CubicMeters / volumeFlow.CubicMetersPerSecond); } } } diff --git a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs index dea64fb637..5291b7d77b 100644 --- a/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs +++ b/UnitsNet/CustomCode/Wrappers/ReferencePressure.cs @@ -130,7 +130,7 @@ private Pressure As(PressureReference reference) /// /// The to convert to. /// The value of pressure at - private QuantityValue AsBaseNumericType(PressureReference reference) + private double AsBaseNumericType(PressureReference reference) { var baseReferenceValue = AsBaseReference(); @@ -156,7 +156,7 @@ private QuantityValue AsBaseNumericType(PressureReference reference) /// /// /// The value of pressure at the - private QuantityValue AsBaseReference() + private double AsBaseReference() { switch (Reference) { diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 082b101238..820cb3a395 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Acceleration, in physics, is the rate at which the velocity of an object changes over time. An object's acceleration is the net result of any and all forces acting on the object, as described by Newton's Second Law. The SI unit for acceleration is the Meter per second squared (m/s²). Accelerations are vector quantities (they have magnitude and direction) and add according to the parallelogram law. As a vector, the calculated net force is equal to the product of the object's mass (a scalar quantity) and the acceleration. /// [DataContract] - public partial struct Acceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Acceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static Acceleration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Acceleration(QuantityValue value, AccelerationUnit unit) + public Acceleration(double value, AccelerationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -99,14 +99,14 @@ public Acceleration(QuantityValue value, AccelerationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Acceleration(QuantityValue value, UnitSystem unitSystem) + public Acceleration(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,10 +147,7 @@ public Acceleration(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +170,74 @@ public Acceleration(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); + public double CentimetersPerSecondSquared => As(AccelerationUnit.CentimeterPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); + public double DecimetersPerSecondSquared => As(AccelerationUnit.DecimeterPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); + public double FeetPerSecondSquared => As(AccelerationUnit.FootPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); + public double InchesPerSecondSquared => As(AccelerationUnit.InchPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); + public double KilometersPerSecondSquared => As(AccelerationUnit.KilometerPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KnotsPerHour => As(AccelerationUnit.KnotPerHour); + public double KnotsPerHour => As(AccelerationUnit.KnotPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); + public double KnotsPerMinute => As(AccelerationUnit.KnotPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); + public double KnotsPerSecond => As(AccelerationUnit.KnotPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); + public double MetersPerSecondSquared => As(AccelerationUnit.MeterPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); + public double MicrometersPerSecondSquared => As(AccelerationUnit.MicrometerPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); + public double MillimetersPerSecondSquared => As(AccelerationUnit.MillimeterPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillistandardGravity => As(AccelerationUnit.MillistandardGravity); + public double MillistandardGravity => As(AccelerationUnit.MillistandardGravity); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); + public double NanometersPerSecondSquared => As(AccelerationUnit.NanometerPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardGravity => As(AccelerationUnit.StandardGravity); + public double StandardGravity => As(AccelerationUnit.StandardGravity); #endregion @@ -349,7 +346,7 @@ public static string GetAbbreviation(AccelerationUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static Acceleration FromCentimetersPerSecondSquared(QuantityValue centimeterspersecondsquared) { - QuantityValue value = (QuantityValue) centimeterspersecondsquared; + double value = (double) centimeterspersecondsquared; return new Acceleration(value, AccelerationUnit.CentimeterPerSecondSquared); } @@ -359,7 +356,7 @@ public static Acceleration FromCentimetersPerSecondSquared(QuantityValue centime /// If value is NaN or Infinity. public static Acceleration FromDecimetersPerSecondSquared(QuantityValue decimeterspersecondsquared) { - QuantityValue value = (QuantityValue) decimeterspersecondsquared; + double value = (double) decimeterspersecondsquared; return new Acceleration(value, AccelerationUnit.DecimeterPerSecondSquared); } @@ -369,7 +366,7 @@ public static Acceleration FromDecimetersPerSecondSquared(QuantityValue decimete /// If value is NaN or Infinity. public static Acceleration FromFeetPerSecondSquared(QuantityValue feetpersecondsquared) { - QuantityValue value = (QuantityValue) feetpersecondsquared; + double value = (double) feetpersecondsquared; return new Acceleration(value, AccelerationUnit.FootPerSecondSquared); } @@ -379,7 +376,7 @@ public static Acceleration FromFeetPerSecondSquared(QuantityValue feetperseconds /// If value is NaN or Infinity. public static Acceleration FromInchesPerSecondSquared(QuantityValue inchespersecondsquared) { - QuantityValue value = (QuantityValue) inchespersecondsquared; + double value = (double) inchespersecondsquared; return new Acceleration(value, AccelerationUnit.InchPerSecondSquared); } @@ -389,7 +386,7 @@ public static Acceleration FromInchesPerSecondSquared(QuantityValue inchespersec /// If value is NaN or Infinity. public static Acceleration FromKilometersPerSecondSquared(QuantityValue kilometerspersecondsquared) { - QuantityValue value = (QuantityValue) kilometerspersecondsquared; + double value = (double) kilometerspersecondsquared; return new Acceleration(value, AccelerationUnit.KilometerPerSecondSquared); } @@ -399,7 +396,7 @@ public static Acceleration FromKilometersPerSecondSquared(QuantityValue kilomete /// If value is NaN or Infinity. public static Acceleration FromKnotsPerHour(QuantityValue knotsperhour) { - QuantityValue value = (QuantityValue) knotsperhour; + double value = (double) knotsperhour; return new Acceleration(value, AccelerationUnit.KnotPerHour); } @@ -409,7 +406,7 @@ public static Acceleration FromKnotsPerHour(QuantityValue knotsperhour) /// If value is NaN or Infinity. public static Acceleration FromKnotsPerMinute(QuantityValue knotsperminute) { - QuantityValue value = (QuantityValue) knotsperminute; + double value = (double) knotsperminute; return new Acceleration(value, AccelerationUnit.KnotPerMinute); } @@ -419,7 +416,7 @@ public static Acceleration FromKnotsPerMinute(QuantityValue knotsperminute) /// If value is NaN or Infinity. public static Acceleration FromKnotsPerSecond(QuantityValue knotspersecond) { - QuantityValue value = (QuantityValue) knotspersecond; + double value = (double) knotspersecond; return new Acceleration(value, AccelerationUnit.KnotPerSecond); } @@ -429,7 +426,7 @@ public static Acceleration FromKnotsPerSecond(QuantityValue knotspersecond) /// If value is NaN or Infinity. public static Acceleration FromMetersPerSecondSquared(QuantityValue meterspersecondsquared) { - QuantityValue value = (QuantityValue) meterspersecondsquared; + double value = (double) meterspersecondsquared; return new Acceleration(value, AccelerationUnit.MeterPerSecondSquared); } @@ -439,7 +436,7 @@ public static Acceleration FromMetersPerSecondSquared(QuantityValue meterspersec /// If value is NaN or Infinity. public static Acceleration FromMicrometersPerSecondSquared(QuantityValue micrometerspersecondsquared) { - QuantityValue value = (QuantityValue) micrometerspersecondsquared; + double value = (double) micrometerspersecondsquared; return new Acceleration(value, AccelerationUnit.MicrometerPerSecondSquared); } @@ -449,7 +446,7 @@ public static Acceleration FromMicrometersPerSecondSquared(QuantityValue microme /// If value is NaN or Infinity. public static Acceleration FromMillimetersPerSecondSquared(QuantityValue millimeterspersecondsquared) { - QuantityValue value = (QuantityValue) millimeterspersecondsquared; + double value = (double) millimeterspersecondsquared; return new Acceleration(value, AccelerationUnit.MillimeterPerSecondSquared); } @@ -459,7 +456,7 @@ public static Acceleration FromMillimetersPerSecondSquared(QuantityValue millime /// If value is NaN or Infinity. public static Acceleration FromMillistandardGravity(QuantityValue millistandardgravity) { - QuantityValue value = (QuantityValue) millistandardgravity; + double value = (double) millistandardgravity; return new Acceleration(value, AccelerationUnit.MillistandardGravity); } @@ -469,7 +466,7 @@ public static Acceleration FromMillistandardGravity(QuantityValue millistandardg /// If value is NaN or Infinity. public static Acceleration FromNanometersPerSecondSquared(QuantityValue nanometerspersecondsquared) { - QuantityValue value = (QuantityValue) nanometerspersecondsquared; + double value = (double) nanometerspersecondsquared; return new Acceleration(value, AccelerationUnit.NanometerPerSecondSquared); } @@ -479,7 +476,7 @@ public static Acceleration FromNanometersPerSecondSquared(QuantityValue nanomete /// If value is NaN or Infinity. public static Acceleration FromStandardGravity(QuantityValue standardgravity) { - QuantityValue value = (QuantityValue) standardgravity; + double value = (double) standardgravity; return new Acceleration(value, AccelerationUnit.StandardGravity); } @@ -491,7 +488,7 @@ public static Acceleration FromStandardGravity(QuantityValue standardgravity) /// Acceleration unit value. public static Acceleration From(QuantityValue value, AccelerationUnit fromUnit) { - return new Acceleration((QuantityValue)value, fromUnit); + return new Acceleration((double)value, fromUnit); } #endregion @@ -661,25 +658,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel } /// Get from multiplying value and . - public static Acceleration operator *(QuantityValue left, Acceleration right) + public static Acceleration operator *(double left, Acceleration right) { return new Acceleration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Acceleration operator *(Acceleration left, QuantityValue right) + public static Acceleration operator *(Acceleration left, double right) { return new Acceleration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Acceleration operator /(Acceleration left, QuantityValue right) + public static Acceleration operator /(Acceleration left, double right) { return new Acceleration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Acceleration left, Acceleration right) + public static double operator /(Acceleration left, Acceleration right) { return left.MetersPerSecondSquared / right.MetersPerSecondSquared; } @@ -712,19 +709,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Accel return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Acceleration left, Acceleration right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Acceleration left, Acceleration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -737,29 +721,7 @@ public int CompareTo(object obj) /// public int CompareTo(Acceleration other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Acceleration objAcceleration)) - return false; - return Equals(objAcceleration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Acceleration other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -802,13 +764,13 @@ public bool Equals(Acceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Acceleration other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Acceleration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -819,7 +781,7 @@ public bool Equals(Acceleration other, QuantityValue tolerance, ComparisonType c /// A hash code for the current Acceleration. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -830,16 +792,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AccelerationUnit unit) + public double As(AccelerationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -854,12 +817,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AccelerationUnit typedUnit)) + if (!(unit is AccelerationUnit unitAsAccelerationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAccelerationUnit); } /// @@ -891,7 +854,7 @@ public Acceleration ToUnit(AccelerationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Acceleration)converted; } - else if (Enum.IsDefined(typeof(AccelerationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -899,17 +862,17 @@ public Acceleration ToUnit(AccelerationUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AccelerationUnit typedUnit)) + if (!(unit is AccelerationUnit unitAsAccelerationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAccelerationUnit, DefaultConversionFunctions); } /// @@ -936,10 +899,10 @@ public Acceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AccelerationUnit unit) + private double GetValueAs(AccelerationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 31197dbed3..6b796bdd8a 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Mole is the amount of substance containing Avagadro's Number (6.02 x 10 ^ 23) of real particles such as molecules,atoms, ions or radicals. /// [DataContract] - public partial struct AmountOfSubstance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmountOfSubstance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -86,9 +86,9 @@ static AmountOfSubstance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AmountOfSubstance(QuantityValue value, AmountOfSubstanceUnit unit) + public AmountOfSubstance(double value, AmountOfSubstanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -100,14 +100,14 @@ public AmountOfSubstance(QuantityValue value, AmountOfSubstanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmountOfSubstance(QuantityValue value, UnitSystem unitSystem) + public AmountOfSubstance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -148,10 +148,7 @@ public AmountOfSubstance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -174,79 +171,79 @@ public AmountOfSubstance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centimoles => As(AmountOfSubstanceUnit.Centimole); + public double Centimoles => As(AmountOfSubstanceUnit.Centimole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); + public double CentipoundMoles => As(AmountOfSubstanceUnit.CentipoundMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decimoles => As(AmountOfSubstanceUnit.Decimole); + public double Decimoles => As(AmountOfSubstanceUnit.Decimole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); + public double DecipoundMoles => As(AmountOfSubstanceUnit.DecipoundMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilomoles => As(AmountOfSubstanceUnit.Kilomole); + public double Kilomoles => As(AmountOfSubstanceUnit.Kilomole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); + public double KilopoundMoles => As(AmountOfSubstanceUnit.KilopoundMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megamoles => As(AmountOfSubstanceUnit.Megamole); + public double Megamoles => As(AmountOfSubstanceUnit.Megamole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Micromoles => As(AmountOfSubstanceUnit.Micromole); + public double Micromoles => As(AmountOfSubstanceUnit.Micromole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); + public double MicropoundMoles => As(AmountOfSubstanceUnit.MicropoundMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millimoles => As(AmountOfSubstanceUnit.Millimole); + public double Millimoles => As(AmountOfSubstanceUnit.Millimole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); + public double MillipoundMoles => As(AmountOfSubstanceUnit.MillipoundMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Moles => As(AmountOfSubstanceUnit.Mole); + public double Moles => As(AmountOfSubstanceUnit.Mole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanomoles => As(AmountOfSubstanceUnit.Nanomole); + public double Nanomoles => As(AmountOfSubstanceUnit.Nanomole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); + public double NanopoundMoles => As(AmountOfSubstanceUnit.NanopoundMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundMoles => As(AmountOfSubstanceUnit.PoundMole); + public double PoundMoles => As(AmountOfSubstanceUnit.PoundMole); #endregion @@ -344,7 +341,7 @@ public static string GetAbbreviation(AmountOfSubstanceUnit unit, IFormatProvider /// If value is NaN or Infinity. public static AmountOfSubstance FromCentimoles(QuantityValue centimoles) { - QuantityValue value = (QuantityValue) centimoles; + double value = (double) centimoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Centimole); } @@ -354,7 +351,7 @@ public static AmountOfSubstance FromCentimoles(QuantityValue centimoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmoles) { - QuantityValue value = (QuantityValue) centipoundmoles; + double value = (double) centipoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.CentipoundMole); } @@ -364,7 +361,7 @@ public static AmountOfSubstance FromCentipoundMoles(QuantityValue centipoundmole /// If value is NaN or Infinity. public static AmountOfSubstance FromDecimoles(QuantityValue decimoles) { - QuantityValue value = (QuantityValue) decimoles; + double value = (double) decimoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Decimole); } @@ -374,7 +371,7 @@ public static AmountOfSubstance FromDecimoles(QuantityValue decimoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles) { - QuantityValue value = (QuantityValue) decipoundmoles; + double value = (double) decipoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.DecipoundMole); } @@ -384,7 +381,7 @@ public static AmountOfSubstance FromDecipoundMoles(QuantityValue decipoundmoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles) { - QuantityValue value = (QuantityValue) kilomoles; + double value = (double) kilomoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Kilomole); } @@ -394,7 +391,7 @@ public static AmountOfSubstance FromKilomoles(QuantityValue kilomoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles) { - QuantityValue value = (QuantityValue) kilopoundmoles; + double value = (double) kilopoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.KilopoundMole); } @@ -404,7 +401,7 @@ public static AmountOfSubstance FromKilopoundMoles(QuantityValue kilopoundmoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMegamoles(QuantityValue megamoles) { - QuantityValue value = (QuantityValue) megamoles; + double value = (double) megamoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Megamole); } @@ -414,7 +411,7 @@ public static AmountOfSubstance FromMegamoles(QuantityValue megamoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMicromoles(QuantityValue micromoles) { - QuantityValue value = (QuantityValue) micromoles; + double value = (double) micromoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Micromole); } @@ -424,7 +421,7 @@ public static AmountOfSubstance FromMicromoles(QuantityValue micromoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmoles) { - QuantityValue value = (QuantityValue) micropoundmoles; + double value = (double) micropoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.MicropoundMole); } @@ -434,7 +431,7 @@ public static AmountOfSubstance FromMicropoundMoles(QuantityValue micropoundmole /// If value is NaN or Infinity. public static AmountOfSubstance FromMillimoles(QuantityValue millimoles) { - QuantityValue value = (QuantityValue) millimoles; + double value = (double) millimoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Millimole); } @@ -444,7 +441,7 @@ public static AmountOfSubstance FromMillimoles(QuantityValue millimoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmoles) { - QuantityValue value = (QuantityValue) millipoundmoles; + double value = (double) millipoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.MillipoundMole); } @@ -454,7 +451,7 @@ public static AmountOfSubstance FromMillipoundMoles(QuantityValue millipoundmole /// If value is NaN or Infinity. public static AmountOfSubstance FromMoles(QuantityValue moles) { - QuantityValue value = (QuantityValue) moles; + double value = (double) moles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Mole); } @@ -464,7 +461,7 @@ public static AmountOfSubstance FromMoles(QuantityValue moles) /// If value is NaN or Infinity. public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles) { - QuantityValue value = (QuantityValue) nanomoles; + double value = (double) nanomoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.Nanomole); } @@ -474,7 +471,7 @@ public static AmountOfSubstance FromNanomoles(QuantityValue nanomoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles) { - QuantityValue value = (QuantityValue) nanopoundmoles; + double value = (double) nanopoundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.NanopoundMole); } @@ -484,7 +481,7 @@ public static AmountOfSubstance FromNanopoundMoles(QuantityValue nanopoundmoles) /// If value is NaN or Infinity. public static AmountOfSubstance FromPoundMoles(QuantityValue poundmoles) { - QuantityValue value = (QuantityValue) poundmoles; + double value = (double) poundmoles; return new AmountOfSubstance(value, AmountOfSubstanceUnit.PoundMole); } @@ -496,7 +493,7 @@ public static AmountOfSubstance FromPoundMoles(QuantityValue poundmoles) /// AmountOfSubstance unit value. public static AmountOfSubstance From(QuantityValue value, AmountOfSubstanceUnit fromUnit) { - return new AmountOfSubstance((QuantityValue)value, fromUnit); + return new AmountOfSubstance((double)value, fromUnit); } #endregion @@ -666,25 +663,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun } /// Get from multiplying value and . - public static AmountOfSubstance operator *(QuantityValue left, AmountOfSubstance right) + public static AmountOfSubstance operator *(double left, AmountOfSubstance right) { return new AmountOfSubstance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AmountOfSubstance operator *(AmountOfSubstance left, QuantityValue right) + public static AmountOfSubstance operator *(AmountOfSubstance left, double right) { return new AmountOfSubstance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AmountOfSubstance operator /(AmountOfSubstance left, QuantityValue right) + public static AmountOfSubstance operator /(AmountOfSubstance left, double right) { return new AmountOfSubstance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(AmountOfSubstance left, AmountOfSubstance right) + public static double operator /(AmountOfSubstance left, AmountOfSubstance right) { return left.Moles / right.Moles; } @@ -717,19 +714,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Amoun return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmountOfSubstance left, AmountOfSubstance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmountOfSubstance left, AmountOfSubstance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -742,29 +726,7 @@ public int CompareTo(object obj) /// public int CompareTo(AmountOfSubstance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is AmountOfSubstance objAmountOfSubstance)) - return false; - return Equals(objAmountOfSubstance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmountOfSubstance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -807,13 +769,13 @@ public bool Equals(AmountOfSubstance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmountOfSubstance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -824,7 +786,7 @@ public bool Equals(AmountOfSubstance other, QuantityValue tolerance, ComparisonT /// A hash code for the current AmountOfSubstance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -835,16 +797,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AmountOfSubstanceUnit unit) + public double As(AmountOfSubstanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -859,12 +822,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AmountOfSubstanceUnit typedUnit)) + if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAmountOfSubstanceUnit); } /// @@ -896,7 +859,7 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (AmountOfSubstance)converted; } - else if (Enum.IsDefined(typeof(AmountOfSubstanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -904,17 +867,17 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit, UnitConverter unitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmountOfSubstanceUnit typedUnit)) + if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAmountOfSubstanceUnit, DefaultConversionFunctions); } /// @@ -941,10 +904,10 @@ public AmountOfSubstance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AmountOfSubstanceUnit unit) + private double GetValueAs(AmountOfSubstanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 1a13590478..05d7dfc95a 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one volt RMS. /// [DataContract] - public partial struct AmplitudeRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AmplitudeRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static AmplitudeRatio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AmplitudeRatio(QuantityValue value, AmplitudeRatioUnit unit) + public AmplitudeRatio(double value, AmplitudeRatioUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public AmplitudeRatio(QuantityValue value, AmplitudeRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AmplitudeRatio(QuantityValue value, UnitSystem unitSystem) + public AmplitudeRatio(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public AmplitudeRatio(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public AmplitudeRatio(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); + public double DecibelMicrovolts => As(AmplitudeRatioUnit.DecibelMicrovolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); + public double DecibelMillivolts => As(AmplitudeRatioUnit.DecibelMillivolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); + public double DecibelsUnloaded => As(AmplitudeRatioUnit.DecibelUnloaded); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); + public double DecibelVolts => As(AmplitudeRatioUnit.DecibelVolt); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(AmplitudeRatioUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue decibelmicrovolts) { - QuantityValue value = (QuantityValue) decibelmicrovolts; + double value = (double) decibelmicrovolts; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMicrovolt); } @@ -255,7 +252,7 @@ public static AmplitudeRatio FromDecibelMicrovolts(QuantityValue decibelmicrovol /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelMillivolts(QuantityValue decibelmillivolts) { - QuantityValue value = (QuantityValue) decibelmillivolts; + double value = (double) decibelmillivolts; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelMillivolt); } @@ -265,7 +262,7 @@ public static AmplitudeRatio FromDecibelMillivolts(QuantityValue decibelmillivol /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue decibelsunloaded) { - QuantityValue value = (QuantityValue) decibelsunloaded; + double value = (double) decibelsunloaded; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelUnloaded); } @@ -275,7 +272,7 @@ public static AmplitudeRatio FromDecibelsUnloaded(QuantityValue decibelsunloaded /// If value is NaN or Infinity. public static AmplitudeRatio FromDecibelVolts(QuantityValue decibelvolts) { - QuantityValue value = (QuantityValue) decibelvolts; + double value = (double) decibelvolts; return new AmplitudeRatio(value, AmplitudeRatioUnit.DecibelVolt); } @@ -287,7 +284,7 @@ public static AmplitudeRatio FromDecibelVolts(QuantityValue decibelvolts) /// AmplitudeRatio unit value. public static AmplitudeRatio From(QuantityValue value, AmplitudeRatioUnit fromUnit) { - return new AmplitudeRatio((QuantityValue)value, fromUnit); + return new AmplitudeRatio((double)value, fromUnit); } #endregion @@ -449,7 +446,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli { // Logarithmic addition // Formula: 20 * log10(10^(x/20) + 10^(y/20)) - return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, (double)left.Value/20) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/20)), left.Unit); + return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, left.Value/20) + Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); } /// Get from logarithmic subtraction of two . @@ -457,11 +454,11 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli { // Logarithmic subtraction // Formula: 20 * log10(10^(x/20) - 10^(y/20)) - return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, (double)left.Value/20) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/20)), left.Unit); + return new AmplitudeRatio(20 * Math.Log10(Math.Pow(10, left.Value/20) - Math.Pow(10, right.GetValueAs(left.Unit)/20)), left.Unit); } /// Get from logarithmic multiplication of value and . - public static AmplitudeRatio operator *(QuantityValue left, AmplitudeRatio right) + public static AmplitudeRatio operator *(double left, AmplitudeRatio right) { // Logarithmic multiplication = addition return new AmplitudeRatio(left + right.Value, right.Unit); @@ -471,14 +468,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli public static AmplitudeRatio operator *(AmplitudeRatio left, double right) { // Logarithmic multiplication = addition - return new AmplitudeRatio(left.Value + (QuantityValue)right, left.Unit); + return new AmplitudeRatio(left.Value + (double)right, left.Unit); } /// Get from logarithmic division of by value. public static AmplitudeRatio operator /(AmplitudeRatio left, double right) { // Logarithmic division = subtraction - return new AmplitudeRatio(left.Value - (QuantityValue)right, left.Unit); + return new AmplitudeRatio(left.Value - (double)right, left.Unit); } /// Get ratio value from logarithmic division of by . @@ -516,19 +513,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ampli return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AmplitudeRatio left, AmplitudeRatio right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AmplitudeRatio left, AmplitudeRatio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -541,29 +525,7 @@ public int CompareTo(object obj) /// public int CompareTo(AmplitudeRatio other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is AmplitudeRatio objAmplitudeRatio)) - return false; - return Equals(objAmplitudeRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AmplitudeRatio other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -606,13 +568,13 @@ public bool Equals(AmplitudeRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AmplitudeRatio other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -623,7 +585,7 @@ public bool Equals(AmplitudeRatio other, QuantityValue tolerance, ComparisonType /// A hash code for the current AmplitudeRatio. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -634,16 +596,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AmplitudeRatioUnit unit) + public double As(AmplitudeRatioUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -658,12 +621,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AmplitudeRatioUnit typedUnit)) + if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAmplitudeRatioUnit); } /// @@ -695,7 +658,7 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (AmplitudeRatio)converted; } - else if (Enum.IsDefined(typeof(AmplitudeRatioUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -703,17 +666,17 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmplitudeRatioUnit typedUnit)) + if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAmplitudeRatioUnit, DefaultConversionFunctions); } /// @@ -740,10 +703,10 @@ public AmplitudeRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AmplitudeRatioUnit unit) + private double GetValueAs(AmplitudeRatioUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 210b47270f..55d9a88517 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In geometry, an angle is the figure formed by two rays, called the sides of the angle, sharing a common endpoint, called the vertex of the angle. /// [DataContract] - public partial struct Angle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Angle : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -87,9 +87,9 @@ static Angle() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Angle(QuantityValue value, AngleUnit unit) + public Angle(double value, AngleUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -101,14 +101,14 @@ public Angle(QuantityValue value, AngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Angle(QuantityValue value, UnitSystem unitSystem) + public Angle(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -149,10 +149,7 @@ public Angle(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -175,84 +172,84 @@ public Angle(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Arcminutes => As(AngleUnit.Arcminute); + public double Arcminutes => As(AngleUnit.Arcminute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Arcseconds => As(AngleUnit.Arcsecond); + public double Arcseconds => As(AngleUnit.Arcsecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centiradians => As(AngleUnit.Centiradian); + public double Centiradians => As(AngleUnit.Centiradian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Deciradians => As(AngleUnit.Deciradian); + public double Deciradians => As(AngleUnit.Deciradian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Degrees => As(AngleUnit.Degree); + public double Degrees => As(AngleUnit.Degree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gradians => As(AngleUnit.Gradian); + public double Gradians => As(AngleUnit.Gradian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microdegrees => As(AngleUnit.Microdegree); + public double Microdegrees => As(AngleUnit.Microdegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microradians => As(AngleUnit.Microradian); + public double Microradians => As(AngleUnit.Microradian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millidegrees => As(AngleUnit.Millidegree); + public double Millidegrees => As(AngleUnit.Millidegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliradians => As(AngleUnit.Milliradian); + public double Milliradians => As(AngleUnit.Milliradian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanodegrees => As(AngleUnit.Nanodegree); + public double Nanodegrees => As(AngleUnit.Nanodegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanoradians => As(AngleUnit.Nanoradian); + public double Nanoradians => As(AngleUnit.Nanoradian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NatoMils => As(AngleUnit.NatoMil); + public double NatoMils => As(AngleUnit.NatoMil); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Radians => As(AngleUnit.Radian); + public double Radians => As(AngleUnit.Radian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Revolutions => As(AngleUnit.Revolution); + public double Revolutions => As(AngleUnit.Revolution); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Tilt => As(AngleUnit.Tilt); + public double Tilt => As(AngleUnit.Tilt); #endregion @@ -279,7 +276,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.NatoMil, quantity => new Angle(quantity.Value * 160 / 9, AngleUnit.NatoMil)); unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Radian, quantity => new Angle(quantity.Value / 180 * Math.PI, AngleUnit.Radian)); unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Revolution, quantity => new Angle(quantity.Value / 360, AngleUnit.Revolution)); - unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Tilt, quantity => new Angle(Math.Sin((double)quantity.Value / 180 * Math.PI), AngleUnit.Tilt)); + unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Tilt, quantity => new Angle(Math.Sin(quantity.Value / 180 * Math.PI), AngleUnit.Tilt)); // Register in unit converter: BaseUnit <-> BaseUnit unitConverter.SetConversionFunction(AngleUnit.Degree, AngleUnit.Degree, quantity => quantity); @@ -299,7 +296,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(AngleUnit.NatoMil, AngleUnit.Degree, quantity => new Angle(quantity.Value * 9 / 160, AngleUnit.Degree)); unitConverter.SetConversionFunction(AngleUnit.Radian, AngleUnit.Degree, quantity => new Angle(quantity.Value * 180 / Math.PI, AngleUnit.Degree)); unitConverter.SetConversionFunction(AngleUnit.Revolution, AngleUnit.Degree, quantity => new Angle(quantity.Value * 360, AngleUnit.Degree)); - unitConverter.SetConversionFunction(AngleUnit.Tilt, AngleUnit.Degree, quantity => new Angle(Math.Asin((double)quantity.Value) * 180 / Math.PI, AngleUnit.Degree)); + unitConverter.SetConversionFunction(AngleUnit.Tilt, AngleUnit.Degree, quantity => new Angle(Math.Asin(quantity.Value) * 180 / Math.PI, AngleUnit.Degree)); } internal static void MapGeneratedLocalizations(UnitAbbreviationsCache unitAbbreviationsCache) @@ -365,7 +362,7 @@ public static string GetAbbreviation(AngleUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Angle FromArcminutes(QuantityValue arcminutes) { - QuantityValue value = (QuantityValue) arcminutes; + double value = (double) arcminutes; return new Angle(value, AngleUnit.Arcminute); } @@ -375,7 +372,7 @@ public static Angle FromArcminutes(QuantityValue arcminutes) /// If value is NaN or Infinity. public static Angle FromArcseconds(QuantityValue arcseconds) { - QuantityValue value = (QuantityValue) arcseconds; + double value = (double) arcseconds; return new Angle(value, AngleUnit.Arcsecond); } @@ -385,7 +382,7 @@ public static Angle FromArcseconds(QuantityValue arcseconds) /// If value is NaN or Infinity. public static Angle FromCentiradians(QuantityValue centiradians) { - QuantityValue value = (QuantityValue) centiradians; + double value = (double) centiradians; return new Angle(value, AngleUnit.Centiradian); } @@ -395,7 +392,7 @@ public static Angle FromCentiradians(QuantityValue centiradians) /// If value is NaN or Infinity. public static Angle FromDeciradians(QuantityValue deciradians) { - QuantityValue value = (QuantityValue) deciradians; + double value = (double) deciradians; return new Angle(value, AngleUnit.Deciradian); } @@ -405,7 +402,7 @@ public static Angle FromDeciradians(QuantityValue deciradians) /// If value is NaN or Infinity. public static Angle FromDegrees(QuantityValue degrees) { - QuantityValue value = (QuantityValue) degrees; + double value = (double) degrees; return new Angle(value, AngleUnit.Degree); } @@ -415,7 +412,7 @@ public static Angle FromDegrees(QuantityValue degrees) /// If value is NaN or Infinity. public static Angle FromGradians(QuantityValue gradians) { - QuantityValue value = (QuantityValue) gradians; + double value = (double) gradians; return new Angle(value, AngleUnit.Gradian); } @@ -425,7 +422,7 @@ public static Angle FromGradians(QuantityValue gradians) /// If value is NaN or Infinity. public static Angle FromMicrodegrees(QuantityValue microdegrees) { - QuantityValue value = (QuantityValue) microdegrees; + double value = (double) microdegrees; return new Angle(value, AngleUnit.Microdegree); } @@ -435,7 +432,7 @@ public static Angle FromMicrodegrees(QuantityValue microdegrees) /// If value is NaN or Infinity. public static Angle FromMicroradians(QuantityValue microradians) { - QuantityValue value = (QuantityValue) microradians; + double value = (double) microradians; return new Angle(value, AngleUnit.Microradian); } @@ -445,7 +442,7 @@ public static Angle FromMicroradians(QuantityValue microradians) /// If value is NaN or Infinity. public static Angle FromMillidegrees(QuantityValue millidegrees) { - QuantityValue value = (QuantityValue) millidegrees; + double value = (double) millidegrees; return new Angle(value, AngleUnit.Millidegree); } @@ -455,7 +452,7 @@ public static Angle FromMillidegrees(QuantityValue millidegrees) /// If value is NaN or Infinity. public static Angle FromMilliradians(QuantityValue milliradians) { - QuantityValue value = (QuantityValue) milliradians; + double value = (double) milliradians; return new Angle(value, AngleUnit.Milliradian); } @@ -465,7 +462,7 @@ public static Angle FromMilliradians(QuantityValue milliradians) /// If value is NaN or Infinity. public static Angle FromNanodegrees(QuantityValue nanodegrees) { - QuantityValue value = (QuantityValue) nanodegrees; + double value = (double) nanodegrees; return new Angle(value, AngleUnit.Nanodegree); } @@ -475,7 +472,7 @@ public static Angle FromNanodegrees(QuantityValue nanodegrees) /// If value is NaN or Infinity. public static Angle FromNanoradians(QuantityValue nanoradians) { - QuantityValue value = (QuantityValue) nanoradians; + double value = (double) nanoradians; return new Angle(value, AngleUnit.Nanoradian); } @@ -485,7 +482,7 @@ public static Angle FromNanoradians(QuantityValue nanoradians) /// If value is NaN or Infinity. public static Angle FromNatoMils(QuantityValue natomils) { - QuantityValue value = (QuantityValue) natomils; + double value = (double) natomils; return new Angle(value, AngleUnit.NatoMil); } @@ -495,7 +492,7 @@ public static Angle FromNatoMils(QuantityValue natomils) /// If value is NaN or Infinity. public static Angle FromRadians(QuantityValue radians) { - QuantityValue value = (QuantityValue) radians; + double value = (double) radians; return new Angle(value, AngleUnit.Radian); } @@ -505,7 +502,7 @@ public static Angle FromRadians(QuantityValue radians) /// If value is NaN or Infinity. public static Angle FromRevolutions(QuantityValue revolutions) { - QuantityValue value = (QuantityValue) revolutions; + double value = (double) revolutions; return new Angle(value, AngleUnit.Revolution); } @@ -515,7 +512,7 @@ public static Angle FromRevolutions(QuantityValue revolutions) /// If value is NaN or Infinity. public static Angle FromTilt(QuantityValue tilt) { - QuantityValue value = (QuantityValue) tilt; + double value = (double) tilt; return new Angle(value, AngleUnit.Tilt); } @@ -527,7 +524,7 @@ public static Angle FromTilt(QuantityValue tilt) /// Angle unit value. public static Angle From(QuantityValue value, AngleUnit fromUnit) { - return new Angle((QuantityValue)value, fromUnit); + return new Angle((double)value, fromUnit); } #endregion @@ -697,25 +694,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle } /// Get from multiplying value and . - public static Angle operator *(QuantityValue left, Angle right) + public static Angle operator *(double left, Angle right) { return new Angle(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Angle operator *(Angle left, QuantityValue right) + public static Angle operator *(Angle left, double right) { return new Angle(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Angle operator /(Angle left, QuantityValue right) + public static Angle operator /(Angle left, double right) { return new Angle(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Angle left, Angle right) + public static double operator /(Angle left, Angle right) { return left.Degrees / right.Degrees; } @@ -748,19 +745,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Angle return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Angle left, Angle right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Angle left, Angle right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -773,29 +757,7 @@ public int CompareTo(object obj) /// public int CompareTo(Angle other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Angle objAngle)) - return false; - return Equals(objAngle); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Angle other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -838,13 +800,13 @@ public bool Equals(Angle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Angle other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -855,7 +817,7 @@ public bool Equals(Angle other, QuantityValue tolerance, ComparisonType comparis /// A hash code for the current Angle. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -866,16 +828,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AngleUnit unit) + public double As(AngleUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -890,12 +853,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AngleUnit typedUnit)) + if (!(unit is AngleUnit unitAsAngleUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAngleUnit); } /// @@ -927,7 +890,7 @@ public Angle ToUnit(AngleUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Angle)converted; } - else if (Enum.IsDefined(typeof(AngleUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -935,17 +898,17 @@ public Angle ToUnit(AngleUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AngleUnit typedUnit)) + if (!(unit is AngleUnit unitAsAngleUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAngleUnit, DefaultConversionFunctions); } /// @@ -972,10 +935,10 @@ public Angle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AngleUnit unit) + private double GetValueAs(AngleUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index fc7df3950d..db89646bfd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A unit for expressing the integral of apparent power over time, equal to the product of 1 volt-ampere and 1 hour, or to 3600 joules. /// [DataContract] - public partial struct ApparentEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static ApparentEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ApparentEnergy(QuantityValue value, ApparentEnergyUnit unit) + public ApparentEnergy(double value, ApparentEnergyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public ApparentEnergy(QuantityValue value, ApparentEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentEnergy(QuantityValue value, UnitSystem unitSystem) + public ApparentEnergy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public ApparentEnergy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public ApparentEnergy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); + public double KilovoltampereHours => As(ApparentEnergyUnit.KilovoltampereHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); + public double MegavoltampereHours => As(ApparentEnergyUnit.MegavoltampereHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); + public double VoltampereHours => As(ApparentEnergyUnit.VoltampereHour); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(ApparentEnergyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ApparentEnergy FromKilovoltampereHours(QuantityValue kilovoltamperehours) { - QuantityValue value = (QuantityValue) kilovoltamperehours; + double value = (double) kilovoltamperehours; return new ApparentEnergy(value, ApparentEnergyUnit.KilovoltampereHour); } @@ -246,7 +243,7 @@ public static ApparentEnergy FromKilovoltampereHours(QuantityValue kilovoltamper /// If value is NaN or Infinity. public static ApparentEnergy FromMegavoltampereHours(QuantityValue megavoltamperehours) { - QuantityValue value = (QuantityValue) megavoltamperehours; + double value = (double) megavoltamperehours; return new ApparentEnergy(value, ApparentEnergyUnit.MegavoltampereHour); } @@ -256,7 +253,7 @@ public static ApparentEnergy FromMegavoltampereHours(QuantityValue megavoltamper /// If value is NaN or Infinity. public static ApparentEnergy FromVoltampereHours(QuantityValue voltamperehours) { - QuantityValue value = (QuantityValue) voltamperehours; + double value = (double) voltamperehours; return new ApparentEnergy(value, ApparentEnergyUnit.VoltampereHour); } @@ -268,7 +265,7 @@ public static ApparentEnergy FromVoltampereHours(QuantityValue voltamperehours) /// ApparentEnergy unit value. public static ApparentEnergy From(QuantityValue value, ApparentEnergyUnit fromUnit) { - return new ApparentEnergy((QuantityValue)value, fromUnit); + return new ApparentEnergy((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar } /// Get from multiplying value and . - public static ApparentEnergy operator *(QuantityValue left, ApparentEnergy right) + public static ApparentEnergy operator *(double left, ApparentEnergy right) { return new ApparentEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ApparentEnergy operator *(ApparentEnergy left, QuantityValue right) + public static ApparentEnergy operator *(ApparentEnergy left, double right) { return new ApparentEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ApparentEnergy operator /(ApparentEnergy left, QuantityValue right) + public static ApparentEnergy operator /(ApparentEnergy left, double right) { return new ApparentEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ApparentEnergy left, ApparentEnergy right) + public static double operator /(ApparentEnergy left, ApparentEnergy right) { return left.VoltampereHours / right.VoltampereHours; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentEnergy left, ApparentEnergy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentEnergy left, ApparentEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(ApparentEnergy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ApparentEnergy objApparentEnergy)) - return false; - return Equals(objApparentEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentEnergy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(ApparentEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentEnergy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ApparentEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(ApparentEnergy other, QuantityValue tolerance, ComparisonType /// A hash code for the current ApparentEnergy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ApparentEnergyUnit unit) + public double As(ApparentEnergyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ApparentEnergyUnit typedUnit)) + if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsApparentEnergyUnit); } /// @@ -668,7 +631,7 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ApparentEnergy)converted; } - else if (Enum.IsDefined(typeof(ApparentEnergyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentEnergyUnit typedUnit)) + if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsApparentEnergyUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public ApparentEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ApparentEnergyUnit unit) + private double GetValueAs(ApparentEnergyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index b39709e9b2..403251e02c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Power engineers measure apparent power as the magnitude of the vector sum of active and reactive power. Apparent power is the product of the root-mean-square of voltage and current. /// [DataContract] - public partial struct ApparentPower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ApparentPower : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ApparentPower() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ApparentPower(QuantityValue value, ApparentPowerUnit unit) + public ApparentPower(double value, ApparentPowerUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public ApparentPower(QuantityValue value, ApparentPowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ApparentPower(QuantityValue value, UnitSystem unitSystem) + public ApparentPower(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public ApparentPower(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public ApparentPower(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); + public double Gigavoltamperes => As(ApparentPowerUnit.Gigavoltampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); + public double Kilovoltamperes => As(ApparentPowerUnit.Kilovoltampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); + public double Megavoltamperes => As(ApparentPowerUnit.Megavoltampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Voltamperes => As(ApparentPowerUnit.Voltampere); + public double Voltamperes => As(ApparentPowerUnit.Voltampere); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(ApparentPowerUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static ApparentPower FromGigavoltamperes(QuantityValue gigavoltamperes) { - QuantityValue value = (QuantityValue) gigavoltamperes; + double value = (double) gigavoltamperes; return new ApparentPower(value, ApparentPowerUnit.Gigavoltampere); } @@ -255,7 +252,7 @@ public static ApparentPower FromGigavoltamperes(QuantityValue gigavoltamperes) /// If value is NaN or Infinity. public static ApparentPower FromKilovoltamperes(QuantityValue kilovoltamperes) { - QuantityValue value = (QuantityValue) kilovoltamperes; + double value = (double) kilovoltamperes; return new ApparentPower(value, ApparentPowerUnit.Kilovoltampere); } @@ -265,7 +262,7 @@ public static ApparentPower FromKilovoltamperes(QuantityValue kilovoltamperes) /// If value is NaN or Infinity. public static ApparentPower FromMegavoltamperes(QuantityValue megavoltamperes) { - QuantityValue value = (QuantityValue) megavoltamperes; + double value = (double) megavoltamperes; return new ApparentPower(value, ApparentPowerUnit.Megavoltampere); } @@ -275,7 +272,7 @@ public static ApparentPower FromMegavoltamperes(QuantityValue megavoltamperes) /// If value is NaN or Infinity. public static ApparentPower FromVoltamperes(QuantityValue voltamperes) { - QuantityValue value = (QuantityValue) voltamperes; + double value = (double) voltamperes; return new ApparentPower(value, ApparentPowerUnit.Voltampere); } @@ -287,7 +284,7 @@ public static ApparentPower FromVoltamperes(QuantityValue voltamperes) /// ApparentPower unit value. public static ApparentPower From(QuantityValue value, ApparentPowerUnit fromUnit) { - return new ApparentPower((QuantityValue)value, fromUnit); + return new ApparentPower((double)value, fromUnit); } #endregion @@ -457,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar } /// Get from multiplying value and . - public static ApparentPower operator *(QuantityValue left, ApparentPower right) + public static ApparentPower operator *(double left, ApparentPower right) { return new ApparentPower(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ApparentPower operator *(ApparentPower left, QuantityValue right) + public static ApparentPower operator *(ApparentPower left, double right) { return new ApparentPower(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ApparentPower operator /(ApparentPower left, QuantityValue right) + public static ApparentPower operator /(ApparentPower left, double right) { return new ApparentPower(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ApparentPower left, ApparentPower right) + public static double operator /(ApparentPower left, ApparentPower right) { return left.Voltamperes / right.Voltamperes; } @@ -508,19 +505,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Appar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ApparentPower left, ApparentPower right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ApparentPower left, ApparentPower right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -533,29 +517,7 @@ public int CompareTo(object obj) /// public int CompareTo(ApparentPower other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ApparentPower objApparentPower)) - return false; - return Equals(objApparentPower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ApparentPower other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -598,13 +560,13 @@ public bool Equals(ApparentPower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ApparentPower other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ApparentPower other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +577,7 @@ public bool Equals(ApparentPower other, QuantityValue tolerance, ComparisonType /// A hash code for the current ApparentPower. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -626,16 +588,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ApparentPowerUnit unit) + public double As(ApparentPowerUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -650,12 +613,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ApparentPowerUnit typedUnit)) + if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsApparentPowerUnit); } /// @@ -687,7 +650,7 @@ public ApparentPower ToUnit(ApparentPowerUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (ApparentPower)converted; } - else if (Enum.IsDefined(typeof(ApparentPowerUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -695,17 +658,17 @@ public ApparentPower ToUnit(ApparentPowerUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentPowerUnit typedUnit)) + if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsApparentPowerUnit, DefaultConversionFunctions); } /// @@ -732,10 +695,10 @@ public ApparentPower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ApparentPowerUnit unit) + private double GetValueAs(ApparentPowerUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index b09d112214..e7b786a82d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Area is a quantity that expresses the extent of a two-dimensional surface or shape, or planar lamina, in the plane. Area can be understood as the amount of material with a given thickness that would be necessary to fashion a model of the shape, or the amount of paint necessary to cover the surface with a single coat.[1] It is the two-dimensional analog of the length of a curve (a one-dimensional concept) or the volume of a solid (a three-dimensional concept). /// [DataContract] - public partial struct Area : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Area : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static Area() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Area(QuantityValue value, AreaUnit unit) + public Area(double value, AreaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -99,14 +99,14 @@ public Area(QuantityValue value, AreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Area(QuantityValue value, UnitSystem unitSystem) + public Area(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,10 +147,7 @@ public Area(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +170,74 @@ public Area(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Acres => As(AreaUnit.Acre); + public double Acres => As(AreaUnit.Acre); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hectares => As(AreaUnit.Hectare); + public double Hectares => As(AreaUnit.Hectare); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareCentimeters => As(AreaUnit.SquareCentimeter); + public double SquareCentimeters => As(AreaUnit.SquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareDecimeters => As(AreaUnit.SquareDecimeter); + public double SquareDecimeters => As(AreaUnit.SquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareFeet => As(AreaUnit.SquareFoot); + public double SquareFeet => As(AreaUnit.SquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareInches => As(AreaUnit.SquareInch); + public double SquareInches => As(AreaUnit.SquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareKilometers => As(AreaUnit.SquareKilometer); + public double SquareKilometers => As(AreaUnit.SquareKilometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMeters => As(AreaUnit.SquareMeter); + public double SquareMeters => As(AreaUnit.SquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMicrometers => As(AreaUnit.SquareMicrometer); + public double SquareMicrometers => As(AreaUnit.SquareMicrometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMiles => As(AreaUnit.SquareMile); + public double SquareMiles => As(AreaUnit.SquareMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMillimeters => As(AreaUnit.SquareMillimeter); + public double SquareMillimeters => As(AreaUnit.SquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); + public double SquareNauticalMiles => As(AreaUnit.SquareNauticalMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareYards => As(AreaUnit.SquareYard); + public double SquareYards => As(AreaUnit.SquareYard); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); + public double UsSurveySquareFeet => As(AreaUnit.UsSurveySquareFoot); #endregion @@ -362,7 +359,7 @@ public static string GetAbbreviation(AreaUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Area FromAcres(QuantityValue acres) { - QuantityValue value = (QuantityValue) acres; + double value = (double) acres; return new Area(value, AreaUnit.Acre); } @@ -372,7 +369,7 @@ public static Area FromAcres(QuantityValue acres) /// If value is NaN or Infinity. public static Area FromHectares(QuantityValue hectares) { - QuantityValue value = (QuantityValue) hectares; + double value = (double) hectares; return new Area(value, AreaUnit.Hectare); } @@ -382,7 +379,7 @@ public static Area FromHectares(QuantityValue hectares) /// If value is NaN or Infinity. public static Area FromSquareCentimeters(QuantityValue squarecentimeters) { - QuantityValue value = (QuantityValue) squarecentimeters; + double value = (double) squarecentimeters; return new Area(value, AreaUnit.SquareCentimeter); } @@ -392,7 +389,7 @@ public static Area FromSquareCentimeters(QuantityValue squarecentimeters) /// If value is NaN or Infinity. public static Area FromSquareDecimeters(QuantityValue squaredecimeters) { - QuantityValue value = (QuantityValue) squaredecimeters; + double value = (double) squaredecimeters; return new Area(value, AreaUnit.SquareDecimeter); } @@ -402,7 +399,7 @@ public static Area FromSquareDecimeters(QuantityValue squaredecimeters) /// If value is NaN or Infinity. public static Area FromSquareFeet(QuantityValue squarefeet) { - QuantityValue value = (QuantityValue) squarefeet; + double value = (double) squarefeet; return new Area(value, AreaUnit.SquareFoot); } @@ -412,7 +409,7 @@ public static Area FromSquareFeet(QuantityValue squarefeet) /// If value is NaN or Infinity. public static Area FromSquareInches(QuantityValue squareinches) { - QuantityValue value = (QuantityValue) squareinches; + double value = (double) squareinches; return new Area(value, AreaUnit.SquareInch); } @@ -422,7 +419,7 @@ public static Area FromSquareInches(QuantityValue squareinches) /// If value is NaN or Infinity. public static Area FromSquareKilometers(QuantityValue squarekilometers) { - QuantityValue value = (QuantityValue) squarekilometers; + double value = (double) squarekilometers; return new Area(value, AreaUnit.SquareKilometer); } @@ -432,7 +429,7 @@ public static Area FromSquareKilometers(QuantityValue squarekilometers) /// If value is NaN or Infinity. public static Area FromSquareMeters(QuantityValue squaremeters) { - QuantityValue value = (QuantityValue) squaremeters; + double value = (double) squaremeters; return new Area(value, AreaUnit.SquareMeter); } @@ -442,7 +439,7 @@ public static Area FromSquareMeters(QuantityValue squaremeters) /// If value is NaN or Infinity. public static Area FromSquareMicrometers(QuantityValue squaremicrometers) { - QuantityValue value = (QuantityValue) squaremicrometers; + double value = (double) squaremicrometers; return new Area(value, AreaUnit.SquareMicrometer); } @@ -452,7 +449,7 @@ public static Area FromSquareMicrometers(QuantityValue squaremicrometers) /// If value is NaN or Infinity. public static Area FromSquareMiles(QuantityValue squaremiles) { - QuantityValue value = (QuantityValue) squaremiles; + double value = (double) squaremiles; return new Area(value, AreaUnit.SquareMile); } @@ -462,7 +459,7 @@ public static Area FromSquareMiles(QuantityValue squaremiles) /// If value is NaN or Infinity. public static Area FromSquareMillimeters(QuantityValue squaremillimeters) { - QuantityValue value = (QuantityValue) squaremillimeters; + double value = (double) squaremillimeters; return new Area(value, AreaUnit.SquareMillimeter); } @@ -472,7 +469,7 @@ public static Area FromSquareMillimeters(QuantityValue squaremillimeters) /// If value is NaN or Infinity. public static Area FromSquareNauticalMiles(QuantityValue squarenauticalmiles) { - QuantityValue value = (QuantityValue) squarenauticalmiles; + double value = (double) squarenauticalmiles; return new Area(value, AreaUnit.SquareNauticalMile); } @@ -482,7 +479,7 @@ public static Area FromSquareNauticalMiles(QuantityValue squarenauticalmiles) /// If value is NaN or Infinity. public static Area FromSquareYards(QuantityValue squareyards) { - QuantityValue value = (QuantityValue) squareyards; + double value = (double) squareyards; return new Area(value, AreaUnit.SquareYard); } @@ -492,7 +489,7 @@ public static Area FromSquareYards(QuantityValue squareyards) /// If value is NaN or Infinity. public static Area FromUsSurveySquareFeet(QuantityValue ussurveysquarefeet) { - QuantityValue value = (QuantityValue) ussurveysquarefeet; + double value = (double) ussurveysquarefeet; return new Area(value, AreaUnit.UsSurveySquareFoot); } @@ -504,7 +501,7 @@ public static Area FromUsSurveySquareFeet(QuantityValue ussurveysquarefeet) /// Area unit value. public static Area From(QuantityValue value, AreaUnit fromUnit) { - return new Area((QuantityValue)value, fromUnit); + return new Area((double)value, fromUnit); } #endregion @@ -674,25 +671,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU } /// Get from multiplying value and . - public static Area operator *(QuantityValue left, Area right) + public static Area operator *(double left, Area right) { return new Area(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Area operator *(Area left, QuantityValue right) + public static Area operator *(Area left, double right) { return new Area(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Area operator /(Area left, QuantityValue right) + public static Area operator /(Area left, double right) { return new Area(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Area left, Area right) + public static double operator /(Area left, Area right) { return left.SquareMeters / right.SquareMeters; } @@ -725,19 +722,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Area left, Area right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Area left, Area right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -750,29 +734,7 @@ public int CompareTo(object obj) /// public int CompareTo(Area other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Area objArea)) - return false; - return Equals(objArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Area other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -815,13 +777,13 @@ public bool Equals(Area other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Area other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Area other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -832,7 +794,7 @@ public bool Equals(Area other, QuantityValue tolerance, ComparisonType compariso /// A hash code for the current Area. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -843,16 +805,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AreaUnit unit) + public double As(AreaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -867,12 +830,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AreaUnit typedUnit)) + if (!(unit is AreaUnit unitAsAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAreaUnit); } /// @@ -904,7 +867,7 @@ public Area ToUnit(AreaUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Area)converted; } - else if (Enum.IsDefined(typeof(AreaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -912,17 +875,17 @@ public Area ToUnit(AreaUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaUnit typedUnit)) + if (!(unit is AreaUnit unitAsAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAreaUnit, DefaultConversionFunctions); } /// @@ -949,10 +912,10 @@ public Area ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AreaUnit unit) + private double GetValueAs(AreaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 9258a2c16d..76e73b46b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The area density of a two-dimensional object is calculated as the mass per unit area. /// [DataContract] - public partial struct AreaDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static AreaDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AreaDensity(QuantityValue value, AreaDensityUnit unit) + public AreaDensity(double value, AreaDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -86,14 +86,14 @@ public AreaDensity(QuantityValue value, AreaDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaDensity(QuantityValue value, UnitSystem unitSystem) + public AreaDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,10 +134,7 @@ public AreaDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +157,9 @@ public AreaDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); + public double KilogramsPerSquareMeter => As(AreaDensityUnit.KilogramPerSquareMeter); #endregion @@ -218,7 +215,7 @@ public static string GetAbbreviation(AreaDensityUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue kilogramspersquaremeter) { - QuantityValue value = (QuantityValue) kilogramspersquaremeter; + double value = (double) kilogramspersquaremeter; return new AreaDensity(value, AreaDensityUnit.KilogramPerSquareMeter); } @@ -230,7 +227,7 @@ public static AreaDensity FromKilogramsPerSquareMeter(QuantityValue kilogramsper /// AreaDensity unit value. public static AreaDensity From(QuantityValue value, AreaDensityUnit fromUnit) { - return new AreaDensity((QuantityValue)value, fromUnit); + return new AreaDensity((double)value, fromUnit); } #endregion @@ -400,25 +397,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD } /// Get from multiplying value and . - public static AreaDensity operator *(QuantityValue left, AreaDensity right) + public static AreaDensity operator *(double left, AreaDensity right) { return new AreaDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AreaDensity operator *(AreaDensity left, QuantityValue right) + public static AreaDensity operator *(AreaDensity left, double right) { return new AreaDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AreaDensity operator /(AreaDensity left, QuantityValue right) + public static AreaDensity operator /(AreaDensity left, double right) { return new AreaDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(AreaDensity left, AreaDensity right) + public static double operator /(AreaDensity left, AreaDensity right) { return left.KilogramsPerSquareMeter / right.KilogramsPerSquareMeter; } @@ -451,19 +448,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaD return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaDensity left, AreaDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaDensity left, AreaDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -476,29 +460,7 @@ public int CompareTo(object obj) /// public int CompareTo(AreaDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is AreaDensity objAreaDensity)) - return false; - return Equals(objAreaDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -541,13 +503,13 @@ public bool Equals(AreaDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(AreaDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +520,7 @@ public bool Equals(AreaDensity other, QuantityValue tolerance, ComparisonType co /// A hash code for the current AreaDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -569,16 +531,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AreaDensityUnit unit) + public double As(AreaDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -593,12 +556,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AreaDensityUnit typedUnit)) + if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAreaDensityUnit); } /// @@ -630,7 +593,7 @@ public AreaDensity ToUnit(AreaDensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (AreaDensity)converted; } - else if (Enum.IsDefined(typeof(AreaDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -638,17 +601,17 @@ public AreaDensity ToUnit(AreaDensityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaDensityUnit typedUnit)) + if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAreaDensityUnit, DefaultConversionFunctions); } /// @@ -675,10 +638,10 @@ public AreaDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AreaDensityUnit unit) + private double GetValueAs(AreaDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 80dedcc912..26632ad748 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A geometric property of an area that reflects how its points are distributed with regard to an axis. /// [DataContract] - public partial struct AreaMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct AreaMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static AreaMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public AreaMomentOfInertia(QuantityValue value, AreaMomentOfInertiaUnit unit) + public AreaMomentOfInertia(double value, AreaMomentOfInertiaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public AreaMomentOfInertia(QuantityValue value, AreaMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public AreaMomentOfInertia(QuantityValue value, UnitSystem unitSystem) + public AreaMomentOfInertia(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public AreaMomentOfInertia(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,34 +162,34 @@ public AreaMomentOfInertia(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); + public double CentimetersToTheFourth => As(AreaMomentOfInertiaUnit.CentimeterToTheFourth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); + public double DecimetersToTheFourth => As(AreaMomentOfInertiaUnit.DecimeterToTheFourth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); + public double FeetToTheFourth => As(AreaMomentOfInertiaUnit.FootToTheFourth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); + public double InchesToTheFourth => As(AreaMomentOfInertiaUnit.InchToTheFourth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); + public double MetersToTheFourth => As(AreaMomentOfInertiaUnit.MeterToTheFourth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); + public double MillimetersToTheFourth => As(AreaMomentOfInertiaUnit.MillimeterToTheFourth); #endregion @@ -263,7 +260,7 @@ public static string GetAbbreviation(AreaMomentOfInertiaUnit unit, IFormatProvid /// If value is NaN or Infinity. public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue centimeterstothefourth) { - QuantityValue value = (QuantityValue) centimeterstothefourth; + double value = (double) centimeterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.CentimeterToTheFourth); } @@ -273,7 +270,7 @@ public static AreaMomentOfInertia FromCentimetersToTheFourth(QuantityValue centi /// If value is NaN or Infinity. public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue decimeterstothefourth) { - QuantityValue value = (QuantityValue) decimeterstothefourth; + double value = (double) decimeterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.DecimeterToTheFourth); } @@ -283,7 +280,7 @@ public static AreaMomentOfInertia FromDecimetersToTheFourth(QuantityValue decime /// If value is NaN or Infinity. public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue feettothefourth) { - QuantityValue value = (QuantityValue) feettothefourth; + double value = (double) feettothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.FootToTheFourth); } @@ -293,7 +290,7 @@ public static AreaMomentOfInertia FromFeetToTheFourth(QuantityValue feettothefou /// If value is NaN or Infinity. public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue inchestothefourth) { - QuantityValue value = (QuantityValue) inchestothefourth; + double value = (double) inchestothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.InchToTheFourth); } @@ -303,7 +300,7 @@ public static AreaMomentOfInertia FromInchesToTheFourth(QuantityValue inchestoth /// If value is NaN or Infinity. public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue meterstothefourth) { - QuantityValue value = (QuantityValue) meterstothefourth; + double value = (double) meterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MeterToTheFourth); } @@ -313,7 +310,7 @@ public static AreaMomentOfInertia FromMetersToTheFourth(QuantityValue meterstoth /// If value is NaN or Infinity. public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue millimeterstothefourth) { - QuantityValue value = (QuantityValue) millimeterstothefourth; + double value = (double) millimeterstothefourth; return new AreaMomentOfInertia(value, AreaMomentOfInertiaUnit.MillimeterToTheFourth); } @@ -325,7 +322,7 @@ public static AreaMomentOfInertia FromMillimetersToTheFourth(QuantityValue milli /// AreaMomentOfInertia unit value. public static AreaMomentOfInertia From(QuantityValue value, AreaMomentOfInertiaUnit fromUnit) { - return new AreaMomentOfInertia((QuantityValue)value, fromUnit); + return new AreaMomentOfInertia((double)value, fromUnit); } #endregion @@ -495,25 +492,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM } /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(QuantityValue left, AreaMomentOfInertia right) + public static AreaMomentOfInertia operator *(double left, AreaMomentOfInertia right) { return new AreaMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, QuantityValue right) + public static AreaMomentOfInertia operator *(AreaMomentOfInertia left, double right) { return new AreaMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, QuantityValue right) + public static AreaMomentOfInertia operator /(AreaMomentOfInertia left, double right) { return new AreaMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) + public static double operator /(AreaMomentOfInertia left, AreaMomentOfInertia right) { return left.MetersToTheFourth / right.MetersToTheFourth; } @@ -546,19 +543,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out AreaM return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(AreaMomentOfInertia left, AreaMomentOfInertia right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(AreaMomentOfInertia left, AreaMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -571,29 +555,7 @@ public int CompareTo(object obj) /// public int CompareTo(AreaMomentOfInertia other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is AreaMomentOfInertia objAreaMomentOfInertia)) - return false; - return Equals(objAreaMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(AreaMomentOfInertia other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -636,13 +598,13 @@ public bool Equals(AreaMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(AreaMomentOfInertia other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -653,7 +615,7 @@ public bool Equals(AreaMomentOfInertia other, QuantityValue tolerance, Compariso /// A hash code for the current AreaMomentOfInertia. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -664,16 +626,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(AreaMomentOfInertiaUnit unit) + public double As(AreaMomentOfInertiaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -688,12 +651,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit typedUnit)) + if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsAreaMomentOfInertiaUnit); } /// @@ -725,7 +688,7 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit, UnitConverter un var converted = conversionFunction(this); return (AreaMomentOfInertia)converted; } - else if (Enum.IsDefined(typeof(AreaMomentOfInertiaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -733,17 +696,17 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit typedUnit)) + if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsAreaMomentOfInertiaUnit, DefaultConversionFunctions); } /// @@ -770,10 +733,10 @@ public AreaMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(AreaMomentOfInertiaUnit unit) + private double GetValueAs(AreaMomentOfInertiaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index cbb22d9243..1ce28dd1dd 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Bit_rate /// [DataContract] - public partial struct BitRate : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BitRate : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly decimal _value; /// /// The unit this quantity was constructed with. @@ -100,7 +100,7 @@ static BitRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public BitRate(QuantityValue value, BitRateUnit unit) + public BitRate(decimal value, BitRateUnit unit) { _value = value; _unit = unit; @@ -114,7 +114,7 @@ public BitRate(QuantityValue value, BitRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BitRate(QuantityValue value, UnitSystem unitSystem) + public BitRate(decimal value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -162,13 +162,12 @@ public BitRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; + public decimal Value => _value; - /// - QuantityValue IQuantity.Value => _value; + double IQuantity.Value => (double) _value; /// - decimal IDecimalQuantity.Value => (decimal)_value; + decimal IDecimalQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -191,134 +190,134 @@ public BitRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BitsPerSecond => As(BitRateUnit.BitPerSecond); + public double BitsPerSecond => As(BitRateUnit.BitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BytesPerSecond => As(BitRateUnit.BytePerSecond); + public double BytesPerSecond => As(BitRateUnit.BytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); + public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); + public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); + public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); + public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); + public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); + public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); + public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); + public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); + public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); + public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); + public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); + public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); + public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); + public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); + public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); + public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); + public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); + public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); + public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); + public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); + public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); + public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); + public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); + public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); #endregion @@ -449,7 +448,7 @@ public static string GetAbbreviation(BitRateUnit unit, IFormatProvider? provider /// If value is NaN or Infinity. public static BitRate FromBitsPerSecond(QuantityValue bitspersecond) { - QuantityValue value = (QuantityValue) bitspersecond; + decimal value = (decimal) bitspersecond; return new BitRate(value, BitRateUnit.BitPerSecond); } @@ -459,7 +458,7 @@ public static BitRate FromBitsPerSecond(QuantityValue bitspersecond) /// If value is NaN or Infinity. public static BitRate FromBytesPerSecond(QuantityValue bytespersecond) { - QuantityValue value = (QuantityValue) bytespersecond; + decimal value = (decimal) bytespersecond; return new BitRate(value, BitRateUnit.BytePerSecond); } @@ -469,7 +468,7 @@ public static BitRate FromBytesPerSecond(QuantityValue bytespersecond) /// If value is NaN or Infinity. public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond) { - QuantityValue value = (QuantityValue) exabitspersecond; + decimal value = (decimal) exabitspersecond; return new BitRate(value, BitRateUnit.ExabitPerSecond); } @@ -479,7 +478,7 @@ public static BitRate FromExabitsPerSecond(QuantityValue exabitspersecond) /// If value is NaN or Infinity. public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond) { - QuantityValue value = (QuantityValue) exabytespersecond; + decimal value = (decimal) exabytespersecond; return new BitRate(value, BitRateUnit.ExabytePerSecond); } @@ -489,7 +488,7 @@ public static BitRate FromExabytesPerSecond(QuantityValue exabytespersecond) /// If value is NaN or Infinity. public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond) { - QuantityValue value = (QuantityValue) exbibitspersecond; + decimal value = (decimal) exbibitspersecond; return new BitRate(value, BitRateUnit.ExbibitPerSecond); } @@ -499,7 +498,7 @@ public static BitRate FromExbibitsPerSecond(QuantityValue exbibitspersecond) /// If value is NaN or Infinity. public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond) { - QuantityValue value = (QuantityValue) exbibytespersecond; + decimal value = (decimal) exbibytespersecond; return new BitRate(value, BitRateUnit.ExbibytePerSecond); } @@ -509,7 +508,7 @@ public static BitRate FromExbibytesPerSecond(QuantityValue exbibytespersecond) /// If value is NaN or Infinity. public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond) { - QuantityValue value = (QuantityValue) gibibitspersecond; + decimal value = (decimal) gibibitspersecond; return new BitRate(value, BitRateUnit.GibibitPerSecond); } @@ -519,7 +518,7 @@ public static BitRate FromGibibitsPerSecond(QuantityValue gibibitspersecond) /// If value is NaN or Infinity. public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond) { - QuantityValue value = (QuantityValue) gibibytespersecond; + decimal value = (decimal) gibibytespersecond; return new BitRate(value, BitRateUnit.GibibytePerSecond); } @@ -529,7 +528,7 @@ public static BitRate FromGibibytesPerSecond(QuantityValue gibibytespersecond) /// If value is NaN or Infinity. public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond) { - QuantityValue value = (QuantityValue) gigabitspersecond; + decimal value = (decimal) gigabitspersecond; return new BitRate(value, BitRateUnit.GigabitPerSecond); } @@ -539,7 +538,7 @@ public static BitRate FromGigabitsPerSecond(QuantityValue gigabitspersecond) /// If value is NaN or Infinity. public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond) { - QuantityValue value = (QuantityValue) gigabytespersecond; + decimal value = (decimal) gigabytespersecond; return new BitRate(value, BitRateUnit.GigabytePerSecond); } @@ -549,7 +548,7 @@ public static BitRate FromGigabytesPerSecond(QuantityValue gigabytespersecond) /// If value is NaN or Infinity. public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond) { - QuantityValue value = (QuantityValue) kibibitspersecond; + decimal value = (decimal) kibibitspersecond; return new BitRate(value, BitRateUnit.KibibitPerSecond); } @@ -559,7 +558,7 @@ public static BitRate FromKibibitsPerSecond(QuantityValue kibibitspersecond) /// If value is NaN or Infinity. public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond) { - QuantityValue value = (QuantityValue) kibibytespersecond; + decimal value = (decimal) kibibytespersecond; return new BitRate(value, BitRateUnit.KibibytePerSecond); } @@ -569,7 +568,7 @@ public static BitRate FromKibibytesPerSecond(QuantityValue kibibytespersecond) /// If value is NaN or Infinity. public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond) { - QuantityValue value = (QuantityValue) kilobitspersecond; + decimal value = (decimal) kilobitspersecond; return new BitRate(value, BitRateUnit.KilobitPerSecond); } @@ -579,7 +578,7 @@ public static BitRate FromKilobitsPerSecond(QuantityValue kilobitspersecond) /// If value is NaN or Infinity. public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond) { - QuantityValue value = (QuantityValue) kilobytespersecond; + decimal value = (decimal) kilobytespersecond; return new BitRate(value, BitRateUnit.KilobytePerSecond); } @@ -589,7 +588,7 @@ public static BitRate FromKilobytesPerSecond(QuantityValue kilobytespersecond) /// If value is NaN or Infinity. public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond) { - QuantityValue value = (QuantityValue) mebibitspersecond; + decimal value = (decimal) mebibitspersecond; return new BitRate(value, BitRateUnit.MebibitPerSecond); } @@ -599,7 +598,7 @@ public static BitRate FromMebibitsPerSecond(QuantityValue mebibitspersecond) /// If value is NaN or Infinity. public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond) { - QuantityValue value = (QuantityValue) mebibytespersecond; + decimal value = (decimal) mebibytespersecond; return new BitRate(value, BitRateUnit.MebibytePerSecond); } @@ -609,7 +608,7 @@ public static BitRate FromMebibytesPerSecond(QuantityValue mebibytespersecond) /// If value is NaN or Infinity. public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond) { - QuantityValue value = (QuantityValue) megabitspersecond; + decimal value = (decimal) megabitspersecond; return new BitRate(value, BitRateUnit.MegabitPerSecond); } @@ -619,7 +618,7 @@ public static BitRate FromMegabitsPerSecond(QuantityValue megabitspersecond) /// If value is NaN or Infinity. public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond) { - QuantityValue value = (QuantityValue) megabytespersecond; + decimal value = (decimal) megabytespersecond; return new BitRate(value, BitRateUnit.MegabytePerSecond); } @@ -629,7 +628,7 @@ public static BitRate FromMegabytesPerSecond(QuantityValue megabytespersecond) /// If value is NaN or Infinity. public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond) { - QuantityValue value = (QuantityValue) pebibitspersecond; + decimal value = (decimal) pebibitspersecond; return new BitRate(value, BitRateUnit.PebibitPerSecond); } @@ -639,7 +638,7 @@ public static BitRate FromPebibitsPerSecond(QuantityValue pebibitspersecond) /// If value is NaN or Infinity. public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond) { - QuantityValue value = (QuantityValue) pebibytespersecond; + decimal value = (decimal) pebibytespersecond; return new BitRate(value, BitRateUnit.PebibytePerSecond); } @@ -649,7 +648,7 @@ public static BitRate FromPebibytesPerSecond(QuantityValue pebibytespersecond) /// If value is NaN or Infinity. public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond) { - QuantityValue value = (QuantityValue) petabitspersecond; + decimal value = (decimal) petabitspersecond; return new BitRate(value, BitRateUnit.PetabitPerSecond); } @@ -659,7 +658,7 @@ public static BitRate FromPetabitsPerSecond(QuantityValue petabitspersecond) /// If value is NaN or Infinity. public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond) { - QuantityValue value = (QuantityValue) petabytespersecond; + decimal value = (decimal) petabytespersecond; return new BitRate(value, BitRateUnit.PetabytePerSecond); } @@ -669,7 +668,7 @@ public static BitRate FromPetabytesPerSecond(QuantityValue petabytespersecond) /// If value is NaN or Infinity. public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond) { - QuantityValue value = (QuantityValue) tebibitspersecond; + decimal value = (decimal) tebibitspersecond; return new BitRate(value, BitRateUnit.TebibitPerSecond); } @@ -679,7 +678,7 @@ public static BitRate FromTebibitsPerSecond(QuantityValue tebibitspersecond) /// If value is NaN or Infinity. public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond) { - QuantityValue value = (QuantityValue) tebibytespersecond; + decimal value = (decimal) tebibytespersecond; return new BitRate(value, BitRateUnit.TebibytePerSecond); } @@ -689,7 +688,7 @@ public static BitRate FromTebibytesPerSecond(QuantityValue tebibytespersecond) /// If value is NaN or Infinity. public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond) { - QuantityValue value = (QuantityValue) terabitspersecond; + decimal value = (decimal) terabitspersecond; return new BitRate(value, BitRateUnit.TerabitPerSecond); } @@ -699,7 +698,7 @@ public static BitRate FromTerabitsPerSecond(QuantityValue terabitspersecond) /// If value is NaN or Infinity. public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond) { - QuantityValue value = (QuantityValue) terabytespersecond; + decimal value = (decimal) terabytespersecond; return new BitRate(value, BitRateUnit.TerabytePerSecond); } @@ -711,7 +710,7 @@ public static BitRate FromTerabytesPerSecond(QuantityValue terabytespersecond) /// BitRate unit value. public static BitRate From(QuantityValue value, BitRateUnit fromUnit) { - return new BitRate((QuantityValue)value, fromUnit); + return new BitRate((decimal)value, fromUnit); } #endregion @@ -881,25 +880,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa } /// Get from multiplying value and . - public static BitRate operator *(QuantityValue left, BitRate right) + public static BitRate operator *(decimal left, BitRate right) { return new BitRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static BitRate operator *(BitRate left, QuantityValue right) + public static BitRate operator *(BitRate left, decimal right) { return new BitRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static BitRate operator /(BitRate left, QuantityValue right) + public static BitRate operator /(BitRate left, decimal right) { return new BitRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(BitRate left, BitRate right) + public static double operator /(BitRate left, BitRate right) { return left.BitsPerSecond / right.BitsPerSecond; } @@ -932,19 +931,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BitRate left, BitRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BitRate left, BitRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -957,29 +943,7 @@ public int CompareTo(object obj) /// public int CompareTo(BitRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is BitRate objBitRate)) - return false; - return Equals(objBitRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(BitRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1022,13 +986,13 @@ public bool Equals(BitRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BitRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1039,7 +1003,7 @@ public bool Equals(BitRate other, QuantityValue tolerance, ComparisonType compar /// A hash code for the current BitRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1050,16 +1014,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(BitRateUnit unit) + public double As(BitRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1074,12 +1039,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is BitRateUnit typedUnit)) + if (!(unit is BitRateUnit unitAsBitRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsBitRateUnit); } /// @@ -1111,7 +1076,7 @@ public BitRate ToUnit(BitRateUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (BitRate)converted; } - else if (Enum.IsDefined(typeof(BitRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1119,17 +1084,17 @@ public BitRate ToUnit(BitRateUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BitRateUnit typedUnit)) + if (!(unit is BitRateUnit unitAsBitRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsBitRateUnit, DefaultConversionFunctions); } /// @@ -1156,10 +1121,10 @@ public BitRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(BitRateUnit unit) + private decimal GetValueAs(BitRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (decimal)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 7c05af6842..22e36e45c1 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Brake specific fuel consumption (BSFC) is a measure of the fuel efficiency of any prime mover that burns fuel and produces rotational, or shaft, power. It is typically used for comparing the efficiency of internal combustion engines with a shaft output. /// [DataContract] - public partial struct BrakeSpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct BrakeSpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static BrakeSpecificFuelConsumption() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public BrakeSpecificFuelConsumption(QuantityValue value, BrakeSpecificFuelConsumptionUnit unit) + public BrakeSpecificFuelConsumption(double value, BrakeSpecificFuelConsumptionUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public BrakeSpecificFuelConsumption(QuantityValue value, BrakeSpecificFuelConsum /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public BrakeSpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) + public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public BrakeSpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public BrakeSpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); + public double GramsPerKiloWattHour => As(BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); + public double KilogramsPerJoule => As(BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); + public double PoundsPerMechanicalHorsepowerHour => As(BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(BrakeSpecificFuelConsumptionUnit unit, IFor /// If value is NaN or Infinity. public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValue gramsperkilowatthour) { - QuantityValue value = (QuantityValue) gramsperkilowatthour; + double value = (double) gramsperkilowatthour; return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.GramPerKiloWattHour); } @@ -246,7 +243,7 @@ public static BrakeSpecificFuelConsumption FromGramsPerKiloWattHour(QuantityValu /// If value is NaN or Infinity. public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue kilogramsperjoule) { - QuantityValue value = (QuantityValue) kilogramsperjoule; + double value = (double) kilogramsperjoule; return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.KilogramPerJoule); } @@ -256,7 +253,7 @@ public static BrakeSpecificFuelConsumption FromKilogramsPerJoule(QuantityValue k /// If value is NaN or Infinity. public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour(QuantityValue poundspermechanicalhorsepowerhour) { - QuantityValue value = (QuantityValue) poundspermechanicalhorsepowerhour; + double value = (double) poundspermechanicalhorsepowerhour; return new BrakeSpecificFuelConsumption(value, BrakeSpecificFuelConsumptionUnit.PoundPerMechanicalHorsepowerHour); } @@ -268,7 +265,7 @@ public static BrakeSpecificFuelConsumption FromPoundsPerMechanicalHorsepowerHour /// BrakeSpecificFuelConsumption unit value. public static BrakeSpecificFuelConsumption From(QuantityValue value, BrakeSpecificFuelConsumptionUnit fromUnit) { - return new BrakeSpecificFuelConsumption((QuantityValue)value, fromUnit); + return new BrakeSpecificFuelConsumption((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake } /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(QuantityValue left, BrakeSpecificFuelConsumption right) + public static BrakeSpecificFuelConsumption operator *(double left, BrakeSpecificFuelConsumption right) { return new BrakeSpecificFuelConsumption(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, QuantityValue right) + public static BrakeSpecificFuelConsumption operator *(BrakeSpecificFuelConsumption left, double right) { return new BrakeSpecificFuelConsumption(left.Value * right, left.Unit); } /// Get from dividing by value. - public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, QuantityValue right) + public static BrakeSpecificFuelConsumption operator /(BrakeSpecificFuelConsumption left, double right) { return new BrakeSpecificFuelConsumption(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) + public static double operator /(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) { return left.KilogramsPerJoule / right.KilogramsPerJoule; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Brake return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(BrakeSpecificFuelConsumption left, BrakeSpecificFuelConsumption right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(BrakeSpecificFuelConsumption other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is BrakeSpecificFuelConsumption objBrakeSpecificFuelConsumption)) - return false; - return Equals(objBrakeSpecificFuelConsumption); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(BrakeSpecificFuelConsumption other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(BrakeSpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BrakeSpecificFuelConsumption other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(BrakeSpecificFuelConsumption other, QuantityValue tolerance, /// A hash code for the current BrakeSpecificFuelConsumption. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(BrakeSpecificFuelConsumptionUnit unit) + public double As(BrakeSpecificFuelConsumptionUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsBrakeSpecificFuelConsumptionUnit); } /// @@ -668,7 +631,7 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit var converted = conversionFunction(this); return (BrakeSpecificFuelConsumption)converted; } - else if (Enum.IsDefined(typeof(BrakeSpecificFuelConsumptionUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsBrakeSpecificFuelConsumptionUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public BrakeSpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(BrakeSpecificFuelConsumptionUnit unit) + private double GetValueAs(BrakeSpecificFuelConsumptionUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index 5ed06c367e..c049929b5a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Capacitance /// [DataContract] - public partial struct Capacitance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Capacitance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static Capacitance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Capacitance(QuantityValue value, CapacitanceUnit unit) + public Capacitance(double value, CapacitanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -95,14 +95,14 @@ public Capacitance(QuantityValue value, CapacitanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Capacitance(QuantityValue value, UnitSystem unitSystem) + public Capacitance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,10 +143,7 @@ public Capacitance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -169,39 +166,39 @@ public Capacitance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Farads => As(CapacitanceUnit.Farad); + public double Farads => As(CapacitanceUnit.Farad); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilofarads => As(CapacitanceUnit.Kilofarad); + public double Kilofarads => As(CapacitanceUnit.Kilofarad); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megafarads => As(CapacitanceUnit.Megafarad); + public double Megafarads => As(CapacitanceUnit.Megafarad); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microfarads => As(CapacitanceUnit.Microfarad); + public double Microfarads => As(CapacitanceUnit.Microfarad); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millifarads => As(CapacitanceUnit.Millifarad); + public double Millifarads => As(CapacitanceUnit.Millifarad); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanofarads => As(CapacitanceUnit.Nanofarad); + public double Nanofarads => As(CapacitanceUnit.Nanofarad); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Picofarads => As(CapacitanceUnit.Picofarad); + public double Picofarads => As(CapacitanceUnit.Picofarad); #endregion @@ -275,7 +272,7 @@ public static string GetAbbreviation(CapacitanceUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Capacitance FromFarads(QuantityValue farads) { - QuantityValue value = (QuantityValue) farads; + double value = (double) farads; return new Capacitance(value, CapacitanceUnit.Farad); } @@ -285,7 +282,7 @@ public static Capacitance FromFarads(QuantityValue farads) /// If value is NaN or Infinity. public static Capacitance FromKilofarads(QuantityValue kilofarads) { - QuantityValue value = (QuantityValue) kilofarads; + double value = (double) kilofarads; return new Capacitance(value, CapacitanceUnit.Kilofarad); } @@ -295,7 +292,7 @@ public static Capacitance FromKilofarads(QuantityValue kilofarads) /// If value is NaN or Infinity. public static Capacitance FromMegafarads(QuantityValue megafarads) { - QuantityValue value = (QuantityValue) megafarads; + double value = (double) megafarads; return new Capacitance(value, CapacitanceUnit.Megafarad); } @@ -305,7 +302,7 @@ public static Capacitance FromMegafarads(QuantityValue megafarads) /// If value is NaN or Infinity. public static Capacitance FromMicrofarads(QuantityValue microfarads) { - QuantityValue value = (QuantityValue) microfarads; + double value = (double) microfarads; return new Capacitance(value, CapacitanceUnit.Microfarad); } @@ -315,7 +312,7 @@ public static Capacitance FromMicrofarads(QuantityValue microfarads) /// If value is NaN or Infinity. public static Capacitance FromMillifarads(QuantityValue millifarads) { - QuantityValue value = (QuantityValue) millifarads; + double value = (double) millifarads; return new Capacitance(value, CapacitanceUnit.Millifarad); } @@ -325,7 +322,7 @@ public static Capacitance FromMillifarads(QuantityValue millifarads) /// If value is NaN or Infinity. public static Capacitance FromNanofarads(QuantityValue nanofarads) { - QuantityValue value = (QuantityValue) nanofarads; + double value = (double) nanofarads; return new Capacitance(value, CapacitanceUnit.Nanofarad); } @@ -335,7 +332,7 @@ public static Capacitance FromNanofarads(QuantityValue nanofarads) /// If value is NaN or Infinity. public static Capacitance FromPicofarads(QuantityValue picofarads) { - QuantityValue value = (QuantityValue) picofarads; + double value = (double) picofarads; return new Capacitance(value, CapacitanceUnit.Picofarad); } @@ -347,7 +344,7 @@ public static Capacitance FromPicofarads(QuantityValue picofarads) /// Capacitance unit value. public static Capacitance From(QuantityValue value, CapacitanceUnit fromUnit) { - return new Capacitance((QuantityValue)value, fromUnit); + return new Capacitance((double)value, fromUnit); } #endregion @@ -517,25 +514,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac } /// Get from multiplying value and . - public static Capacitance operator *(QuantityValue left, Capacitance right) + public static Capacitance operator *(double left, Capacitance right) { return new Capacitance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Capacitance operator *(Capacitance left, QuantityValue right) + public static Capacitance operator *(Capacitance left, double right) { return new Capacitance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Capacitance operator /(Capacitance left, QuantityValue right) + public static Capacitance operator /(Capacitance left, double right) { return new Capacitance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Capacitance left, Capacitance right) + public static double operator /(Capacitance left, Capacitance right) { return left.Farads / right.Farads; } @@ -568,19 +565,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Capac return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Capacitance left, Capacitance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Capacitance left, Capacitance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -593,29 +577,7 @@ public int CompareTo(object obj) /// public int CompareTo(Capacitance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Capacitance objCapacitance)) - return false; - return Equals(objCapacitance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Capacitance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -658,13 +620,13 @@ public bool Equals(Capacitance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Capacitance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Capacitance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -675,7 +637,7 @@ public bool Equals(Capacitance other, QuantityValue tolerance, ComparisonType co /// A hash code for the current Capacitance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -686,16 +648,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(CapacitanceUnit unit) + public double As(CapacitanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -710,12 +673,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is CapacitanceUnit typedUnit)) + if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsCapacitanceUnit); } /// @@ -747,7 +710,7 @@ public Capacitance ToUnit(CapacitanceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Capacitance)converted; } - else if (Enum.IsDefined(typeof(CapacitanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -755,17 +718,17 @@ public Capacitance ToUnit(CapacitanceUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CapacitanceUnit typedUnit)) + if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsCapacitanceUnit, DefaultConversionFunctions); } /// @@ -792,10 +755,10 @@ public Capacitance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(CapacitanceUnit unit) + private double GetValueAs(CapacitanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index c00ec02eed..1c980e9a81 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A unit that represents a fractional change in size in response to a change in temperature. /// [DataContract] - public partial struct CoefficientOfThermalExpansion : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct CoefficientOfThermalExpansion : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static CoefficientOfThermalExpansion() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public CoefficientOfThermalExpansion(QuantityValue value, CoefficientOfThermalExpansionUnit unit) + public CoefficientOfThermalExpansion(double value, CoefficientOfThermalExpansionUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public CoefficientOfThermalExpansion(QuantityValue value, CoefficientOfThermalEx /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public CoefficientOfThermalExpansion(QuantityValue value, UnitSystem unitSystem) + public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public CoefficientOfThermalExpansion(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public CoefficientOfThermalExpansion(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); + public double InverseDegreeCelsius => As(CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); + public double InverseDegreeFahrenheit => As(CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); + public double InverseKelvin => As(CoefficientOfThermalExpansionUnit.InverseKelvin); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(CoefficientOfThermalExpansionUnit unit, IFo /// If value is NaN or Infinity. public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(QuantityValue inversedegreecelsius) { - QuantityValue value = (QuantityValue) inversedegreecelsius; + double value = (double) inversedegreecelsius; return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeCelsius); } @@ -246,7 +243,7 @@ public static CoefficientOfThermalExpansion FromInverseDegreeCelsius(QuantityVal /// If value is NaN or Infinity. public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(QuantityValue inversedegreefahrenheit) { - QuantityValue value = (QuantityValue) inversedegreefahrenheit; + double value = (double) inversedegreefahrenheit; return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseDegreeFahrenheit); } @@ -256,7 +253,7 @@ public static CoefficientOfThermalExpansion FromInverseDegreeFahrenheit(Quantity /// If value is NaN or Infinity. public static CoefficientOfThermalExpansion FromInverseKelvin(QuantityValue inversekelvin) { - QuantityValue value = (QuantityValue) inversekelvin; + double value = (double) inversekelvin; return new CoefficientOfThermalExpansion(value, CoefficientOfThermalExpansionUnit.InverseKelvin); } @@ -268,7 +265,7 @@ public static CoefficientOfThermalExpansion FromInverseKelvin(QuantityValue inve /// CoefficientOfThermalExpansion unit value. public static CoefficientOfThermalExpansion From(QuantityValue value, CoefficientOfThermalExpansionUnit fromUnit) { - return new CoefficientOfThermalExpansion((QuantityValue)value, fromUnit); + return new CoefficientOfThermalExpansion((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff } /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(QuantityValue left, CoefficientOfThermalExpansion right) + public static CoefficientOfThermalExpansion operator *(double left, CoefficientOfThermalExpansion right) { return new CoefficientOfThermalExpansion(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, QuantityValue right) + public static CoefficientOfThermalExpansion operator *(CoefficientOfThermalExpansion left, double right) { return new CoefficientOfThermalExpansion(left.Value * right, left.Unit); } /// Get from dividing by value. - public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, QuantityValue right) + public static CoefficientOfThermalExpansion operator /(CoefficientOfThermalExpansion left, double right) { return new CoefficientOfThermalExpansion(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) + public static double operator /(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) { return left.InverseKelvin / right.InverseKelvin; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Coeff return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(CoefficientOfThermalExpansion left, CoefficientOfThermalExpansion right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(CoefficientOfThermalExpansion other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is CoefficientOfThermalExpansion objCoefficientOfThermalExpansion)) - return false; - return Equals(objCoefficientOfThermalExpansion); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(CoefficientOfThermalExpansion other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(CoefficientOfThermalExpansion other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(CoefficientOfThermalExpansion other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(CoefficientOfThermalExpansion other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(CoefficientOfThermalExpansion other, QuantityValue tolerance, /// A hash code for the current CoefficientOfThermalExpansion. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(CoefficientOfThermalExpansionUnit unit) + public double As(CoefficientOfThermalExpansionUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsCoefficientOfThermalExpansionUnit); } /// @@ -668,7 +631,7 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un var converted = conversionFunction(this); return (CoefficientOfThermalExpansion)converted; } - else if (Enum.IsDefined(typeof(CoefficientOfThermalExpansionUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsCoefficientOfThermalExpansionUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public CoefficientOfThermalExpansion ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(CoefficientOfThermalExpansionUnit unit) + private double GetValueAs(CoefficientOfThermalExpansionUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index c62b2ea809..24755cc1db 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct Compressibility : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Compressibility : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static Compressibility() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Compressibility(QuantityValue value, CompressibilityUnit unit) + public Compressibility(double value, CompressibilityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public Compressibility(QuantityValue value, CompressibilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Compressibility(QuantityValue value, UnitSystem unitSystem) + public Compressibility(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public Compressibility(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,39 +163,39 @@ public Compressibility(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseAtmospheres => As(CompressibilityUnit.InverseAtmosphere); + public double InverseAtmospheres => As(CompressibilityUnit.InverseAtmosphere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseBars => As(CompressibilityUnit.InverseBar); + public double InverseBars => As(CompressibilityUnit.InverseBar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseKilopascals => As(CompressibilityUnit.InverseKilopascal); + public double InverseKilopascals => As(CompressibilityUnit.InverseKilopascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMegapascals => As(CompressibilityUnit.InverseMegapascal); + public double InverseMegapascals => As(CompressibilityUnit.InverseMegapascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMillibars => As(CompressibilityUnit.InverseMillibar); + public double InverseMillibars => As(CompressibilityUnit.InverseMillibar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InversePascals => As(CompressibilityUnit.InversePascal); + public double InversePascals => As(CompressibilityUnit.InversePascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InversePoundsForcePerSquareInch => As(CompressibilityUnit.InversePoundForcePerSquareInch); + public double InversePoundsForcePerSquareInch => As(CompressibilityUnit.InversePoundForcePerSquareInch); #endregion @@ -272,7 +269,7 @@ public static string GetAbbreviation(CompressibilityUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static Compressibility FromInverseAtmospheres(QuantityValue inverseatmospheres) { - QuantityValue value = (QuantityValue) inverseatmospheres; + double value = (double) inverseatmospheres; return new Compressibility(value, CompressibilityUnit.InverseAtmosphere); } @@ -282,7 +279,7 @@ public static Compressibility FromInverseAtmospheres(QuantityValue inverseatmosp /// If value is NaN or Infinity. public static Compressibility FromInverseBars(QuantityValue inversebars) { - QuantityValue value = (QuantityValue) inversebars; + double value = (double) inversebars; return new Compressibility(value, CompressibilityUnit.InverseBar); } @@ -292,7 +289,7 @@ public static Compressibility FromInverseBars(QuantityValue inversebars) /// If value is NaN or Infinity. public static Compressibility FromInverseKilopascals(QuantityValue inversekilopascals) { - QuantityValue value = (QuantityValue) inversekilopascals; + double value = (double) inversekilopascals; return new Compressibility(value, CompressibilityUnit.InverseKilopascal); } @@ -302,7 +299,7 @@ public static Compressibility FromInverseKilopascals(QuantityValue inversekilopa /// If value is NaN or Infinity. public static Compressibility FromInverseMegapascals(QuantityValue inversemegapascals) { - QuantityValue value = (QuantityValue) inversemegapascals; + double value = (double) inversemegapascals; return new Compressibility(value, CompressibilityUnit.InverseMegapascal); } @@ -312,7 +309,7 @@ public static Compressibility FromInverseMegapascals(QuantityValue inversemegapa /// If value is NaN or Infinity. public static Compressibility FromInverseMillibars(QuantityValue inversemillibars) { - QuantityValue value = (QuantityValue) inversemillibars; + double value = (double) inversemillibars; return new Compressibility(value, CompressibilityUnit.InverseMillibar); } @@ -322,7 +319,7 @@ public static Compressibility FromInverseMillibars(QuantityValue inversemillibar /// If value is NaN or Infinity. public static Compressibility FromInversePascals(QuantityValue inversepascals) { - QuantityValue value = (QuantityValue) inversepascals; + double value = (double) inversepascals; return new Compressibility(value, CompressibilityUnit.InversePascal); } @@ -332,7 +329,7 @@ public static Compressibility FromInversePascals(QuantityValue inversepascals) /// If value is NaN or Infinity. public static Compressibility FromInversePoundsForcePerSquareInch(QuantityValue inversepoundsforcepersquareinch) { - QuantityValue value = (QuantityValue) inversepoundsforcepersquareinch; + double value = (double) inversepoundsforcepersquareinch; return new Compressibility(value, CompressibilityUnit.InversePoundForcePerSquareInch); } @@ -344,7 +341,7 @@ public static Compressibility FromInversePoundsForcePerSquareInch(QuantityValue /// Compressibility unit value. public static Compressibility From(QuantityValue value, CompressibilityUnit fromUnit) { - return new Compressibility((QuantityValue)value, fromUnit); + return new Compressibility((double)value, fromUnit); } #endregion @@ -514,25 +511,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr } /// Get from multiplying value and . - public static Compressibility operator *(QuantityValue left, Compressibility right) + public static Compressibility operator *(double left, Compressibility right) { return new Compressibility(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Compressibility operator *(Compressibility left, QuantityValue right) + public static Compressibility operator *(Compressibility left, double right) { return new Compressibility(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Compressibility operator /(Compressibility left, QuantityValue right) + public static Compressibility operator /(Compressibility left, double right) { return new Compressibility(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Compressibility left, Compressibility right) + public static double operator /(Compressibility left, Compressibility right) { return left.InversePascals / right.InversePascals; } @@ -565,19 +562,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Compr return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Compressibility left, Compressibility right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Compressibility left, Compressibility right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -590,29 +574,7 @@ public int CompareTo(object obj) /// public int CompareTo(Compressibility other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Compressibility objCompressibility)) - return false; - return Equals(objCompressibility); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Compressibility other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -655,13 +617,13 @@ public bool Equals(Compressibility other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Compressibility other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Compressibility other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -672,7 +634,7 @@ public bool Equals(Compressibility other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current Compressibility. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -683,16 +645,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(CompressibilityUnit unit) + public double As(CompressibilityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -707,12 +670,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is CompressibilityUnit typedUnit)) + if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsCompressibilityUnit); } /// @@ -744,7 +707,7 @@ public Compressibility ToUnit(CompressibilityUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (Compressibility)converted; } - else if (Enum.IsDefined(typeof(CompressibilityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -752,17 +715,17 @@ public Compressibility ToUnit(CompressibilityUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CompressibilityUnit typedUnit)) + if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsCompressibilityUnit, DefaultConversionFunctions); } /// @@ -789,10 +752,10 @@ public Compressibility ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(CompressibilityUnit unit) + private double GetValueAs(CompressibilityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index f66631e323..470717602d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Density /// [DataContract] - public partial struct Density : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Density : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -125,9 +125,9 @@ static Density() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Density(QuantityValue value, DensityUnit unit) + public Density(double value, DensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -139,14 +139,14 @@ public Density(QuantityValue value, DensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Density(QuantityValue value, UnitSystem unitSystem) + public Density(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -187,10 +187,7 @@ public Density(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -213,259 +210,259 @@ public Density(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); + public double CentigramsPerDeciLiter => As(DensityUnit.CentigramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); + public double CentigramsPerLiter => As(DensityUnit.CentigramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); + public double CentigramsPerMilliliter => As(DensityUnit.CentigramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); + public double DecigramsPerDeciLiter => As(DensityUnit.DecigramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); + public double DecigramsPerLiter => As(DensityUnit.DecigramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); + public double DecigramsPerMilliliter => As(DensityUnit.DecigramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); + public double GramsPerCubicCentimeter => As(DensityUnit.GramPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicFoot => As(DensityUnit.GramPerCubicFoot); + public double GramsPerCubicFoot => As(DensityUnit.GramPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicInch => As(DensityUnit.GramPerCubicInch); + public double GramsPerCubicInch => As(DensityUnit.GramPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); + public double GramsPerCubicMeter => As(DensityUnit.GramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); + public double GramsPerCubicMillimeter => As(DensityUnit.GramPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); + public double GramsPerDeciLiter => As(DensityUnit.GramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerLiter => As(DensityUnit.GramPerLiter); + public double GramsPerLiter => As(DensityUnit.GramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); + public double GramsPerMilliliter => As(DensityUnit.GramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); + public double KilogramsPerCubicCentimeter => As(DensityUnit.KilogramPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); + public double KilogramsPerCubicMeter => As(DensityUnit.KilogramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); + public double KilogramsPerCubicMillimeter => As(DensityUnit.KilogramPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); + public double KilogramsPerLiter => As(DensityUnit.KilogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); + public double KilopoundsPerCubicFoot => As(DensityUnit.KilopoundPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); + public double KilopoundsPerCubicInch => As(DensityUnit.KilopoundPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); + public double MicrogramsPerCubicMeter => As(DensityUnit.MicrogramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); + public double MicrogramsPerDeciLiter => As(DensityUnit.MicrogramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); + public double MicrogramsPerLiter => As(DensityUnit.MicrogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); + public double MicrogramsPerMilliliter => As(DensityUnit.MicrogramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); + public double MilligramsPerCubicMeter => As(DensityUnit.MilligramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); + public double MilligramsPerDeciLiter => As(DensityUnit.MilligramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); + public double MilligramsPerLiter => As(DensityUnit.MilligramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); + public double MilligramsPerMilliliter => As(DensityUnit.MilligramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); + public double NanogramsPerDeciLiter => As(DensityUnit.NanogramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); + public double NanogramsPerLiter => As(DensityUnit.NanogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); + public double NanogramsPerMilliliter => As(DensityUnit.NanogramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); + public double PicogramsPerDeciLiter => As(DensityUnit.PicogramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); + public double PicogramsPerLiter => As(DensityUnit.PicogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); + public double PicogramsPerMilliliter => As(DensityUnit.PicogramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicCentimeter => As(DensityUnit.PoundPerCubicCentimeter); + public double PoundsPerCubicCentimeter => As(DensityUnit.PoundPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); + public double PoundsPerCubicFoot => As(DensityUnit.PoundPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); + public double PoundsPerCubicInch => As(DensityUnit.PoundPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicMeter => As(DensityUnit.PoundPerCubicMeter); + public double PoundsPerCubicMeter => As(DensityUnit.PoundPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicMillimeter => As(DensityUnit.PoundPerCubicMillimeter); + public double PoundsPerCubicMillimeter => As(DensityUnit.PoundPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); + public double PoundsPerImperialGallon => As(DensityUnit.PoundPerImperialGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); + public double PoundsPerUSGallon => As(DensityUnit.PoundPerUSGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugsPerCubicCentimeter => As(DensityUnit.SlugPerCubicCentimeter); + public double SlugsPerCubicCentimeter => As(DensityUnit.SlugPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); + public double SlugsPerCubicFoot => As(DensityUnit.SlugPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugsPerCubicInch => As(DensityUnit.SlugPerCubicInch); + public double SlugsPerCubicInch => As(DensityUnit.SlugPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugsPerCubicMeter => As(DensityUnit.SlugPerCubicMeter); + public double SlugsPerCubicMeter => As(DensityUnit.SlugPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugsPerCubicMillimeter => As(DensityUnit.SlugPerCubicMillimeter); + public double SlugsPerCubicMillimeter => As(DensityUnit.SlugPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); + public double TonnesPerCubicCentimeter => As(DensityUnit.TonnePerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicFoot => As(DensityUnit.TonnePerCubicFoot); + public double TonnesPerCubicFoot => As(DensityUnit.TonnePerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicInch => As(DensityUnit.TonnePerCubicInch); + public double TonnesPerCubicInch => As(DensityUnit.TonnePerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); + public double TonnesPerCubicMeter => As(DensityUnit.TonnePerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); + public double TonnesPerCubicMillimeter => As(DensityUnit.TonnePerCubicMillimeter); #endregion @@ -675,7 +672,7 @@ public static string GetAbbreviation(DensityUnit unit, IFormatProvider? provider /// If value is NaN or Infinity. public static Density FromCentigramsPerDeciLiter(QuantityValue centigramsperdeciliter) { - QuantityValue value = (QuantityValue) centigramsperdeciliter; + double value = (double) centigramsperdeciliter; return new Density(value, DensityUnit.CentigramPerDeciliter); } @@ -685,7 +682,7 @@ public static Density FromCentigramsPerDeciLiter(QuantityValue centigramsperdeci /// If value is NaN or Infinity. public static Density FromCentigramsPerLiter(QuantityValue centigramsperliter) { - QuantityValue value = (QuantityValue) centigramsperliter; + double value = (double) centigramsperliter; return new Density(value, DensityUnit.CentigramPerLiter); } @@ -695,7 +692,7 @@ public static Density FromCentigramsPerLiter(QuantityValue centigramsperliter) /// If value is NaN or Infinity. public static Density FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter) { - QuantityValue value = (QuantityValue) centigramspermilliliter; + double value = (double) centigramspermilliliter; return new Density(value, DensityUnit.CentigramPerMilliliter); } @@ -705,7 +702,7 @@ public static Density FromCentigramsPerMilliliter(QuantityValue centigramspermil /// If value is NaN or Infinity. public static Density FromDecigramsPerDeciLiter(QuantityValue decigramsperdeciliter) { - QuantityValue value = (QuantityValue) decigramsperdeciliter; + double value = (double) decigramsperdeciliter; return new Density(value, DensityUnit.DecigramPerDeciliter); } @@ -715,7 +712,7 @@ public static Density FromDecigramsPerDeciLiter(QuantityValue decigramsperdecili /// If value is NaN or Infinity. public static Density FromDecigramsPerLiter(QuantityValue decigramsperliter) { - QuantityValue value = (QuantityValue) decigramsperliter; + double value = (double) decigramsperliter; return new Density(value, DensityUnit.DecigramPerLiter); } @@ -725,7 +722,7 @@ public static Density FromDecigramsPerLiter(QuantityValue decigramsperliter) /// If value is NaN or Infinity. public static Density FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter) { - QuantityValue value = (QuantityValue) decigramspermilliliter; + double value = (double) decigramspermilliliter; return new Density(value, DensityUnit.DecigramPerMilliliter); } @@ -735,7 +732,7 @@ public static Density FromDecigramsPerMilliliter(QuantityValue decigramspermilli /// If value is NaN or Infinity. public static Density FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter) { - QuantityValue value = (QuantityValue) gramspercubiccentimeter; + double value = (double) gramspercubiccentimeter; return new Density(value, DensityUnit.GramPerCubicCentimeter); } @@ -745,7 +742,7 @@ public static Density FromGramsPerCubicCentimeter(QuantityValue gramspercubiccen /// If value is NaN or Infinity. public static Density FromGramsPerCubicFoot(QuantityValue gramspercubicfoot) { - QuantityValue value = (QuantityValue) gramspercubicfoot; + double value = (double) gramspercubicfoot; return new Density(value, DensityUnit.GramPerCubicFoot); } @@ -755,7 +752,7 @@ public static Density FromGramsPerCubicFoot(QuantityValue gramspercubicfoot) /// If value is NaN or Infinity. public static Density FromGramsPerCubicInch(QuantityValue gramspercubicinch) { - QuantityValue value = (QuantityValue) gramspercubicinch; + double value = (double) gramspercubicinch; return new Density(value, DensityUnit.GramPerCubicInch); } @@ -765,7 +762,7 @@ public static Density FromGramsPerCubicInch(QuantityValue gramspercubicinch) /// If value is NaN or Infinity. public static Density FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) { - QuantityValue value = (QuantityValue) gramspercubicmeter; + double value = (double) gramspercubicmeter; return new Density(value, DensityUnit.GramPerCubicMeter); } @@ -775,7 +772,7 @@ public static Density FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) /// If value is NaN or Infinity. public static Density FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter) { - QuantityValue value = (QuantityValue) gramspercubicmillimeter; + double value = (double) gramspercubicmillimeter; return new Density(value, DensityUnit.GramPerCubicMillimeter); } @@ -785,7 +782,7 @@ public static Density FromGramsPerCubicMillimeter(QuantityValue gramspercubicmil /// If value is NaN or Infinity. public static Density FromGramsPerDeciLiter(QuantityValue gramsperdeciliter) { - QuantityValue value = (QuantityValue) gramsperdeciliter; + double value = (double) gramsperdeciliter; return new Density(value, DensityUnit.GramPerDeciliter); } @@ -795,7 +792,7 @@ public static Density FromGramsPerDeciLiter(QuantityValue gramsperdeciliter) /// If value is NaN or Infinity. public static Density FromGramsPerLiter(QuantityValue gramsperliter) { - QuantityValue value = (QuantityValue) gramsperliter; + double value = (double) gramsperliter; return new Density(value, DensityUnit.GramPerLiter); } @@ -805,7 +802,7 @@ public static Density FromGramsPerLiter(QuantityValue gramsperliter) /// If value is NaN or Infinity. public static Density FromGramsPerMilliliter(QuantityValue gramspermilliliter) { - QuantityValue value = (QuantityValue) gramspermilliliter; + double value = (double) gramspermilliliter; return new Density(value, DensityUnit.GramPerMilliliter); } @@ -815,7 +812,7 @@ public static Density FromGramsPerMilliliter(QuantityValue gramspermilliliter) /// If value is NaN or Infinity. public static Density FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter) { - QuantityValue value = (QuantityValue) kilogramspercubiccentimeter; + double value = (double) kilogramspercubiccentimeter; return new Density(value, DensityUnit.KilogramPerCubicCentimeter); } @@ -825,7 +822,7 @@ public static Density FromKilogramsPerCubicCentimeter(QuantityValue kilogramsper /// If value is NaN or Infinity. public static Density FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter) { - QuantityValue value = (QuantityValue) kilogramspercubicmeter; + double value = (double) kilogramspercubicmeter; return new Density(value, DensityUnit.KilogramPerCubicMeter); } @@ -835,7 +832,7 @@ public static Density FromKilogramsPerCubicMeter(QuantityValue kilogramspercubic /// If value is NaN or Infinity. public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter) { - QuantityValue value = (QuantityValue) kilogramspercubicmillimeter; + double value = (double) kilogramspercubicmillimeter; return new Density(value, DensityUnit.KilogramPerCubicMillimeter); } @@ -845,7 +842,7 @@ public static Density FromKilogramsPerCubicMillimeter(QuantityValue kilogramsper /// If value is NaN or Infinity. public static Density FromKilogramsPerLiter(QuantityValue kilogramsperliter) { - QuantityValue value = (QuantityValue) kilogramsperliter; + double value = (double) kilogramsperliter; return new Density(value, DensityUnit.KilogramPerLiter); } @@ -855,7 +852,7 @@ public static Density FromKilogramsPerLiter(QuantityValue kilogramsperliter) /// If value is NaN or Infinity. public static Density FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot) { - QuantityValue value = (QuantityValue) kilopoundspercubicfoot; + double value = (double) kilopoundspercubicfoot; return new Density(value, DensityUnit.KilopoundPerCubicFoot); } @@ -865,7 +862,7 @@ public static Density FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubi /// If value is NaN or Infinity. public static Density FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch) { - QuantityValue value = (QuantityValue) kilopoundspercubicinch; + double value = (double) kilopoundspercubicinch; return new Density(value, DensityUnit.KilopoundPerCubicInch); } @@ -875,7 +872,7 @@ public static Density FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubi /// If value is NaN or Infinity. public static Density FromMicrogramsPerCubicMeter(QuantityValue microgramspercubicmeter) { - QuantityValue value = (QuantityValue) microgramspercubicmeter; + double value = (double) microgramspercubicmeter; return new Density(value, DensityUnit.MicrogramPerCubicMeter); } @@ -885,7 +882,7 @@ public static Density FromMicrogramsPerCubicMeter(QuantityValue microgramspercub /// If value is NaN or Infinity. public static Density FromMicrogramsPerDeciLiter(QuantityValue microgramsperdeciliter) { - QuantityValue value = (QuantityValue) microgramsperdeciliter; + double value = (double) microgramsperdeciliter; return new Density(value, DensityUnit.MicrogramPerDeciliter); } @@ -895,7 +892,7 @@ public static Density FromMicrogramsPerDeciLiter(QuantityValue microgramsperdeci /// If value is NaN or Infinity. public static Density FromMicrogramsPerLiter(QuantityValue microgramsperliter) { - QuantityValue value = (QuantityValue) microgramsperliter; + double value = (double) microgramsperliter; return new Density(value, DensityUnit.MicrogramPerLiter); } @@ -905,7 +902,7 @@ public static Density FromMicrogramsPerLiter(QuantityValue microgramsperliter) /// If value is NaN or Infinity. public static Density FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter) { - QuantityValue value = (QuantityValue) microgramspermilliliter; + double value = (double) microgramspermilliliter; return new Density(value, DensityUnit.MicrogramPerMilliliter); } @@ -915,7 +912,7 @@ public static Density FromMicrogramsPerMilliliter(QuantityValue microgramspermil /// If value is NaN or Infinity. public static Density FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter) { - QuantityValue value = (QuantityValue) milligramspercubicmeter; + double value = (double) milligramspercubicmeter; return new Density(value, DensityUnit.MilligramPerCubicMeter); } @@ -925,7 +922,7 @@ public static Density FromMilligramsPerCubicMeter(QuantityValue milligramspercub /// If value is NaN or Infinity. public static Density FromMilligramsPerDeciLiter(QuantityValue milligramsperdeciliter) { - QuantityValue value = (QuantityValue) milligramsperdeciliter; + double value = (double) milligramsperdeciliter; return new Density(value, DensityUnit.MilligramPerDeciliter); } @@ -935,7 +932,7 @@ public static Density FromMilligramsPerDeciLiter(QuantityValue milligramsperdeci /// If value is NaN or Infinity. public static Density FromMilligramsPerLiter(QuantityValue milligramsperliter) { - QuantityValue value = (QuantityValue) milligramsperliter; + double value = (double) milligramsperliter; return new Density(value, DensityUnit.MilligramPerLiter); } @@ -945,7 +942,7 @@ public static Density FromMilligramsPerLiter(QuantityValue milligramsperliter) /// If value is NaN or Infinity. public static Density FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter) { - QuantityValue value = (QuantityValue) milligramspermilliliter; + double value = (double) milligramspermilliliter; return new Density(value, DensityUnit.MilligramPerMilliliter); } @@ -955,7 +952,7 @@ public static Density FromMilligramsPerMilliliter(QuantityValue milligramspermil /// If value is NaN or Infinity. public static Density FromNanogramsPerDeciLiter(QuantityValue nanogramsperdeciliter) { - QuantityValue value = (QuantityValue) nanogramsperdeciliter; + double value = (double) nanogramsperdeciliter; return new Density(value, DensityUnit.NanogramPerDeciliter); } @@ -965,7 +962,7 @@ public static Density FromNanogramsPerDeciLiter(QuantityValue nanogramsperdecili /// If value is NaN or Infinity. public static Density FromNanogramsPerLiter(QuantityValue nanogramsperliter) { - QuantityValue value = (QuantityValue) nanogramsperliter; + double value = (double) nanogramsperliter; return new Density(value, DensityUnit.NanogramPerLiter); } @@ -975,7 +972,7 @@ public static Density FromNanogramsPerLiter(QuantityValue nanogramsperliter) /// If value is NaN or Infinity. public static Density FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter) { - QuantityValue value = (QuantityValue) nanogramspermilliliter; + double value = (double) nanogramspermilliliter; return new Density(value, DensityUnit.NanogramPerMilliliter); } @@ -985,7 +982,7 @@ public static Density FromNanogramsPerMilliliter(QuantityValue nanogramspermilli /// If value is NaN or Infinity. public static Density FromPicogramsPerDeciLiter(QuantityValue picogramsperdeciliter) { - QuantityValue value = (QuantityValue) picogramsperdeciliter; + double value = (double) picogramsperdeciliter; return new Density(value, DensityUnit.PicogramPerDeciliter); } @@ -995,7 +992,7 @@ public static Density FromPicogramsPerDeciLiter(QuantityValue picogramsperdecili /// If value is NaN or Infinity. public static Density FromPicogramsPerLiter(QuantityValue picogramsperliter) { - QuantityValue value = (QuantityValue) picogramsperliter; + double value = (double) picogramsperliter; return new Density(value, DensityUnit.PicogramPerLiter); } @@ -1005,7 +1002,7 @@ public static Density FromPicogramsPerLiter(QuantityValue picogramsperliter) /// If value is NaN or Infinity. public static Density FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter) { - QuantityValue value = (QuantityValue) picogramspermilliliter; + double value = (double) picogramspermilliliter; return new Density(value, DensityUnit.PicogramPerMilliliter); } @@ -1015,7 +1012,7 @@ public static Density FromPicogramsPerMilliliter(QuantityValue picogramspermilli /// If value is NaN or Infinity. public static Density FromPoundsPerCubicCentimeter(QuantityValue poundspercubiccentimeter) { - QuantityValue value = (QuantityValue) poundspercubiccentimeter; + double value = (double) poundspercubiccentimeter; return new Density(value, DensityUnit.PoundPerCubicCentimeter); } @@ -1025,7 +1022,7 @@ public static Density FromPoundsPerCubicCentimeter(QuantityValue poundspercubicc /// If value is NaN or Infinity. public static Density FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) { - QuantityValue value = (QuantityValue) poundspercubicfoot; + double value = (double) poundspercubicfoot; return new Density(value, DensityUnit.PoundPerCubicFoot); } @@ -1035,7 +1032,7 @@ public static Density FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) /// If value is NaN or Infinity. public static Density FromPoundsPerCubicInch(QuantityValue poundspercubicinch) { - QuantityValue value = (QuantityValue) poundspercubicinch; + double value = (double) poundspercubicinch; return new Density(value, DensityUnit.PoundPerCubicInch); } @@ -1045,7 +1042,7 @@ public static Density FromPoundsPerCubicInch(QuantityValue poundspercubicinch) /// If value is NaN or Infinity. public static Density FromPoundsPerCubicMeter(QuantityValue poundspercubicmeter) { - QuantityValue value = (QuantityValue) poundspercubicmeter; + double value = (double) poundspercubicmeter; return new Density(value, DensityUnit.PoundPerCubicMeter); } @@ -1055,7 +1052,7 @@ public static Density FromPoundsPerCubicMeter(QuantityValue poundspercubicmeter) /// If value is NaN or Infinity. public static Density FromPoundsPerCubicMillimeter(QuantityValue poundspercubicmillimeter) { - QuantityValue value = (QuantityValue) poundspercubicmillimeter; + double value = (double) poundspercubicmillimeter; return new Density(value, DensityUnit.PoundPerCubicMillimeter); } @@ -1065,7 +1062,7 @@ public static Density FromPoundsPerCubicMillimeter(QuantityValue poundspercubicm /// If value is NaN or Infinity. public static Density FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon) { - QuantityValue value = (QuantityValue) poundsperimperialgallon; + double value = (double) poundsperimperialgallon; return new Density(value, DensityUnit.PoundPerImperialGallon); } @@ -1075,7 +1072,7 @@ public static Density FromPoundsPerImperialGallon(QuantityValue poundsperimperia /// If value is NaN or Infinity. public static Density FromPoundsPerUSGallon(QuantityValue poundsperusgallon) { - QuantityValue value = (QuantityValue) poundsperusgallon; + double value = (double) poundsperusgallon; return new Density(value, DensityUnit.PoundPerUSGallon); } @@ -1085,7 +1082,7 @@ public static Density FromPoundsPerUSGallon(QuantityValue poundsperusgallon) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicCentimeter(QuantityValue slugspercubiccentimeter) { - QuantityValue value = (QuantityValue) slugspercubiccentimeter; + double value = (double) slugspercubiccentimeter; return new Density(value, DensityUnit.SlugPerCubicCentimeter); } @@ -1095,7 +1092,7 @@ public static Density FromSlugsPerCubicCentimeter(QuantityValue slugspercubiccen /// If value is NaN or Infinity. public static Density FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) { - QuantityValue value = (QuantityValue) slugspercubicfoot; + double value = (double) slugspercubicfoot; return new Density(value, DensityUnit.SlugPerCubicFoot); } @@ -1105,7 +1102,7 @@ public static Density FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicInch(QuantityValue slugspercubicinch) { - QuantityValue value = (QuantityValue) slugspercubicinch; + double value = (double) slugspercubicinch; return new Density(value, DensityUnit.SlugPerCubicInch); } @@ -1115,7 +1112,7 @@ public static Density FromSlugsPerCubicInch(QuantityValue slugspercubicinch) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicMeter(QuantityValue slugspercubicmeter) { - QuantityValue value = (QuantityValue) slugspercubicmeter; + double value = (double) slugspercubicmeter; return new Density(value, DensityUnit.SlugPerCubicMeter); } @@ -1125,7 +1122,7 @@ public static Density FromSlugsPerCubicMeter(QuantityValue slugspercubicmeter) /// If value is NaN or Infinity. public static Density FromSlugsPerCubicMillimeter(QuantityValue slugspercubicmillimeter) { - QuantityValue value = (QuantityValue) slugspercubicmillimeter; + double value = (double) slugspercubicmillimeter; return new Density(value, DensityUnit.SlugPerCubicMillimeter); } @@ -1135,7 +1132,7 @@ public static Density FromSlugsPerCubicMillimeter(QuantityValue slugspercubicmil /// If value is NaN or Infinity. public static Density FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter) { - QuantityValue value = (QuantityValue) tonnespercubiccentimeter; + double value = (double) tonnespercubiccentimeter; return new Density(value, DensityUnit.TonnePerCubicCentimeter); } @@ -1145,7 +1142,7 @@ public static Density FromTonnesPerCubicCentimeter(QuantityValue tonnespercubicc /// If value is NaN or Infinity. public static Density FromTonnesPerCubicFoot(QuantityValue tonnespercubicfoot) { - QuantityValue value = (QuantityValue) tonnespercubicfoot; + double value = (double) tonnespercubicfoot; return new Density(value, DensityUnit.TonnePerCubicFoot); } @@ -1155,7 +1152,7 @@ public static Density FromTonnesPerCubicFoot(QuantityValue tonnespercubicfoot) /// If value is NaN or Infinity. public static Density FromTonnesPerCubicInch(QuantityValue tonnespercubicinch) { - QuantityValue value = (QuantityValue) tonnespercubicinch; + double value = (double) tonnespercubicinch; return new Density(value, DensityUnit.TonnePerCubicInch); } @@ -1165,7 +1162,7 @@ public static Density FromTonnesPerCubicInch(QuantityValue tonnespercubicinch) /// If value is NaN or Infinity. public static Density FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) { - QuantityValue value = (QuantityValue) tonnespercubicmeter; + double value = (double) tonnespercubicmeter; return new Density(value, DensityUnit.TonnePerCubicMeter); } @@ -1175,7 +1172,7 @@ public static Density FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) /// If value is NaN or Infinity. public static Density FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter) { - QuantityValue value = (QuantityValue) tonnespercubicmillimeter; + double value = (double) tonnespercubicmillimeter; return new Density(value, DensityUnit.TonnePerCubicMillimeter); } @@ -1187,7 +1184,7 @@ public static Density FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicm /// Density unit value. public static Density From(QuantityValue value, DensityUnit fromUnit) { - return new Density((QuantityValue)value, fromUnit); + return new Density((double)value, fromUnit); } #endregion @@ -1357,25 +1354,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi } /// Get from multiplying value and . - public static Density operator *(QuantityValue left, Density right) + public static Density operator *(double left, Density right) { return new Density(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Density operator *(Density left, QuantityValue right) + public static Density operator *(Density left, double right) { return new Density(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Density operator /(Density left, QuantityValue right) + public static Density operator /(Density left, double right) { return new Density(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Density left, Density right) + public static double operator /(Density left, Density right) { return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; } @@ -1408,19 +1405,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Densi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Density left, Density right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Density left, Density right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1433,29 +1417,7 @@ public int CompareTo(object obj) /// public int CompareTo(Density other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Density objDensity)) - return false; - return Equals(objDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Density other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1498,13 +1460,13 @@ public bool Equals(Density other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Density other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Density other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1515,7 +1477,7 @@ public bool Equals(Density other, QuantityValue tolerance, ComparisonType compar /// A hash code for the current Density. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1526,16 +1488,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(DensityUnit unit) + public double As(DensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1550,12 +1513,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is DensityUnit typedUnit)) + if (!(unit is DensityUnit unitAsDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsDensityUnit); } /// @@ -1587,7 +1550,7 @@ public Density ToUnit(DensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Density)converted; } - else if (Enum.IsDefined(typeof(DensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1595,17 +1558,17 @@ public Density ToUnit(DensityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DensityUnit typedUnit)) + if (!(unit is DensityUnit unitAsDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsDensityUnit, DefaultConversionFunctions); } /// @@ -1632,10 +1595,10 @@ public Density ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(DensityUnit unit) + private double GetValueAs(DensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 3119b90332..31dfb5c9b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Time is a dimension in which events can be ordered from the past through the present into the future, and also the measure of durations of events and the intervals between them. /// [DataContract] - public partial struct Duration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Duration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -82,9 +82,9 @@ static Duration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Duration(QuantityValue value, DurationUnit unit) + public Duration(double value, DurationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -96,14 +96,14 @@ public Duration(QuantityValue value, DurationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Duration(QuantityValue value, UnitSystem unitSystem) + public Duration(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,10 +144,7 @@ public Duration(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -170,59 +167,59 @@ public Duration(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Days => As(DurationUnit.Day); + public double Days => As(DurationUnit.Day); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hours => As(DurationUnit.Hour); + public double Hours => As(DurationUnit.Hour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JulianYears => As(DurationUnit.JulianYear); + public double JulianYears => As(DurationUnit.JulianYear); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microseconds => As(DurationUnit.Microsecond); + public double Microseconds => As(DurationUnit.Microsecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliseconds => As(DurationUnit.Millisecond); + public double Milliseconds => As(DurationUnit.Millisecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Minutes => As(DurationUnit.Minute); + public double Minutes => As(DurationUnit.Minute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Months30 => As(DurationUnit.Month30); + public double Months30 => As(DurationUnit.Month30); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanoseconds => As(DurationUnit.Nanosecond); + public double Nanoseconds => As(DurationUnit.Nanosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Seconds => As(DurationUnit.Second); + public double Seconds => As(DurationUnit.Second); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Weeks => As(DurationUnit.Week); + public double Weeks => As(DurationUnit.Week); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Years365 => As(DurationUnit.Year365); + public double Years365 => As(DurationUnit.Year365); #endregion @@ -318,7 +315,7 @@ public static string GetAbbreviation(DurationUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static Duration FromDays(QuantityValue days) { - QuantityValue value = (QuantityValue) days; + double value = (double) days; return new Duration(value, DurationUnit.Day); } @@ -328,7 +325,7 @@ public static Duration FromDays(QuantityValue days) /// If value is NaN or Infinity. public static Duration FromHours(QuantityValue hours) { - QuantityValue value = (QuantityValue) hours; + double value = (double) hours; return new Duration(value, DurationUnit.Hour); } @@ -338,7 +335,7 @@ public static Duration FromHours(QuantityValue hours) /// If value is NaN or Infinity. public static Duration FromJulianYears(QuantityValue julianyears) { - QuantityValue value = (QuantityValue) julianyears; + double value = (double) julianyears; return new Duration(value, DurationUnit.JulianYear); } @@ -348,7 +345,7 @@ public static Duration FromJulianYears(QuantityValue julianyears) /// If value is NaN or Infinity. public static Duration FromMicroseconds(QuantityValue microseconds) { - QuantityValue value = (QuantityValue) microseconds; + double value = (double) microseconds; return new Duration(value, DurationUnit.Microsecond); } @@ -358,7 +355,7 @@ public static Duration FromMicroseconds(QuantityValue microseconds) /// If value is NaN or Infinity. public static Duration FromMilliseconds(QuantityValue milliseconds) { - QuantityValue value = (QuantityValue) milliseconds; + double value = (double) milliseconds; return new Duration(value, DurationUnit.Millisecond); } @@ -368,7 +365,7 @@ public static Duration FromMilliseconds(QuantityValue milliseconds) /// If value is NaN or Infinity. public static Duration FromMinutes(QuantityValue minutes) { - QuantityValue value = (QuantityValue) minutes; + double value = (double) minutes; return new Duration(value, DurationUnit.Minute); } @@ -378,7 +375,7 @@ public static Duration FromMinutes(QuantityValue minutes) /// If value is NaN or Infinity. public static Duration FromMonths30(QuantityValue months30) { - QuantityValue value = (QuantityValue) months30; + double value = (double) months30; return new Duration(value, DurationUnit.Month30); } @@ -388,7 +385,7 @@ public static Duration FromMonths30(QuantityValue months30) /// If value is NaN or Infinity. public static Duration FromNanoseconds(QuantityValue nanoseconds) { - QuantityValue value = (QuantityValue) nanoseconds; + double value = (double) nanoseconds; return new Duration(value, DurationUnit.Nanosecond); } @@ -398,7 +395,7 @@ public static Duration FromNanoseconds(QuantityValue nanoseconds) /// If value is NaN or Infinity. public static Duration FromSeconds(QuantityValue seconds) { - QuantityValue value = (QuantityValue) seconds; + double value = (double) seconds; return new Duration(value, DurationUnit.Second); } @@ -408,7 +405,7 @@ public static Duration FromSeconds(QuantityValue seconds) /// If value is NaN or Infinity. public static Duration FromWeeks(QuantityValue weeks) { - QuantityValue value = (QuantityValue) weeks; + double value = (double) weeks; return new Duration(value, DurationUnit.Week); } @@ -418,7 +415,7 @@ public static Duration FromWeeks(QuantityValue weeks) /// If value is NaN or Infinity. public static Duration FromYears365(QuantityValue years365) { - QuantityValue value = (QuantityValue) years365; + double value = (double) years365; return new Duration(value, DurationUnit.Year365); } @@ -430,7 +427,7 @@ public static Duration FromYears365(QuantityValue years365) /// Duration unit value. public static Duration From(QuantityValue value, DurationUnit fromUnit) { - return new Duration((QuantityValue)value, fromUnit); + return new Duration((double)value, fromUnit); } #endregion @@ -600,25 +597,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat } /// Get from multiplying value and . - public static Duration operator *(QuantityValue left, Duration right) + public static Duration operator *(double left, Duration right) { return new Duration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Duration operator *(Duration left, QuantityValue right) + public static Duration operator *(Duration left, double right) { return new Duration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Duration operator /(Duration left, QuantityValue right) + public static Duration operator /(Duration left, double right) { return new Duration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Duration left, Duration right) + public static double operator /(Duration left, Duration right) { return left.Seconds / right.Seconds; } @@ -651,19 +648,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Durat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Duration left, Duration right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Duration left, Duration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -676,29 +660,7 @@ public int CompareTo(object obj) /// public int CompareTo(Duration other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Duration objDuration)) - return false; - return Equals(objDuration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Duration other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -741,13 +703,13 @@ public bool Equals(Duration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Duration other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Duration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -758,7 +720,7 @@ public bool Equals(Duration other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current Duration. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -769,16 +731,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(DurationUnit unit) + public double As(DurationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -793,12 +756,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is DurationUnit typedUnit)) + if (!(unit is DurationUnit unitAsDurationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsDurationUnit); } /// @@ -830,7 +793,7 @@ public Duration ToUnit(DurationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Duration)converted; } - else if (Enum.IsDefined(typeof(DurationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -838,17 +801,17 @@ public Duration ToUnit(DurationUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DurationUnit typedUnit)) + if (!(unit is DurationUnit unitAsDurationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsDurationUnit, DefaultConversionFunctions); } /// @@ -875,10 +838,10 @@ public Duration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(DurationUnit unit) + private double GetValueAs(DurationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index 90cee77932..ec17be7043 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Viscosity#Dynamic_.28shear.29_viscosity /// [DataContract] - public partial struct DynamicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct DynamicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -84,9 +84,9 @@ static DynamicViscosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public DynamicViscosity(QuantityValue value, DynamicViscosityUnit unit) + public DynamicViscosity(double value, DynamicViscosityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -98,14 +98,14 @@ public DynamicViscosity(QuantityValue value, DynamicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public DynamicViscosity(QuantityValue value, UnitSystem unitSystem) + public DynamicViscosity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -146,10 +146,7 @@ public DynamicViscosity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -172,54 +169,54 @@ public DynamicViscosity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centipoise => As(DynamicViscosityUnit.Centipoise); + public double Centipoise => As(DynamicViscosityUnit.Centipoise); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); + public double MicropascalSeconds => As(DynamicViscosityUnit.MicropascalSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); + public double MillipascalSeconds => As(DynamicViscosityUnit.MillipascalSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); + public double NewtonSecondsPerMeterSquared => As(DynamicViscosityUnit.NewtonSecondPerMeterSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PascalSeconds => As(DynamicViscosityUnit.PascalSecond); + public double PascalSeconds => As(DynamicViscosityUnit.PascalSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Poise => As(DynamicViscosityUnit.Poise); + public double Poise => As(DynamicViscosityUnit.Poise); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); + public double PoundsForceSecondPerSquareFoot => As(DynamicViscosityUnit.PoundForceSecondPerSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); + public double PoundsForceSecondPerSquareInch => As(DynamicViscosityUnit.PoundForceSecondPerSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); + public double PoundsPerFootSecond => As(DynamicViscosityUnit.PoundPerFootSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Reyns => As(DynamicViscosityUnit.Reyn); + public double Reyns => As(DynamicViscosityUnit.Reyn); #endregion @@ -302,7 +299,7 @@ public static string GetAbbreviation(DynamicViscosityUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static DynamicViscosity FromCentipoise(QuantityValue centipoise) { - QuantityValue value = (QuantityValue) centipoise; + double value = (double) centipoise; return new DynamicViscosity(value, DynamicViscosityUnit.Centipoise); } @@ -312,7 +309,7 @@ public static DynamicViscosity FromCentipoise(QuantityValue centipoise) /// If value is NaN or Infinity. public static DynamicViscosity FromMicropascalSeconds(QuantityValue micropascalseconds) { - QuantityValue value = (QuantityValue) micropascalseconds; + double value = (double) micropascalseconds; return new DynamicViscosity(value, DynamicViscosityUnit.MicropascalSecond); } @@ -322,7 +319,7 @@ public static DynamicViscosity FromMicropascalSeconds(QuantityValue micropascals /// If value is NaN or Infinity. public static DynamicViscosity FromMillipascalSeconds(QuantityValue millipascalseconds) { - QuantityValue value = (QuantityValue) millipascalseconds; + double value = (double) millipascalseconds; return new DynamicViscosity(value, DynamicViscosityUnit.MillipascalSecond); } @@ -332,7 +329,7 @@ public static DynamicViscosity FromMillipascalSeconds(QuantityValue millipascals /// If value is NaN or Infinity. public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue newtonsecondspermetersquared) { - QuantityValue value = (QuantityValue) newtonsecondspermetersquared; + double value = (double) newtonsecondspermetersquared; return new DynamicViscosity(value, DynamicViscosityUnit.NewtonSecondPerMeterSquared); } @@ -342,7 +339,7 @@ public static DynamicViscosity FromNewtonSecondsPerMeterSquared(QuantityValue ne /// If value is NaN or Infinity. public static DynamicViscosity FromPascalSeconds(QuantityValue pascalseconds) { - QuantityValue value = (QuantityValue) pascalseconds; + double value = (double) pascalseconds; return new DynamicViscosity(value, DynamicViscosityUnit.PascalSecond); } @@ -352,7 +349,7 @@ public static DynamicViscosity FromPascalSeconds(QuantityValue pascalseconds) /// If value is NaN or Infinity. public static DynamicViscosity FromPoise(QuantityValue poise) { - QuantityValue value = (QuantityValue) poise; + double value = (double) poise; return new DynamicViscosity(value, DynamicViscosityUnit.Poise); } @@ -362,7 +359,7 @@ public static DynamicViscosity FromPoise(QuantityValue poise) /// If value is NaN or Infinity. public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(QuantityValue poundsforcesecondpersquarefoot) { - QuantityValue value = (QuantityValue) poundsforcesecondpersquarefoot; + double value = (double) poundsforcesecondpersquarefoot; return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareFoot); } @@ -372,7 +369,7 @@ public static DynamicViscosity FromPoundsForceSecondPerSquareFoot(QuantityValue /// If value is NaN or Infinity. public static DynamicViscosity FromPoundsForceSecondPerSquareInch(QuantityValue poundsforcesecondpersquareinch) { - QuantityValue value = (QuantityValue) poundsforcesecondpersquareinch; + double value = (double) poundsforcesecondpersquareinch; return new DynamicViscosity(value, DynamicViscosityUnit.PoundForceSecondPerSquareInch); } @@ -382,7 +379,7 @@ public static DynamicViscosity FromPoundsForceSecondPerSquareInch(QuantityValue /// If value is NaN or Infinity. public static DynamicViscosity FromPoundsPerFootSecond(QuantityValue poundsperfootsecond) { - QuantityValue value = (QuantityValue) poundsperfootsecond; + double value = (double) poundsperfootsecond; return new DynamicViscosity(value, DynamicViscosityUnit.PoundPerFootSecond); } @@ -392,7 +389,7 @@ public static DynamicViscosity FromPoundsPerFootSecond(QuantityValue poundsperfo /// If value is NaN or Infinity. public static DynamicViscosity FromReyns(QuantityValue reyns) { - QuantityValue value = (QuantityValue) reyns; + double value = (double) reyns; return new DynamicViscosity(value, DynamicViscosityUnit.Reyn); } @@ -404,7 +401,7 @@ public static DynamicViscosity FromReyns(QuantityValue reyns) /// DynamicViscosity unit value. public static DynamicViscosity From(QuantityValue value, DynamicViscosityUnit fromUnit) { - return new DynamicViscosity((QuantityValue)value, fromUnit); + return new DynamicViscosity((double)value, fromUnit); } #endregion @@ -574,25 +571,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam } /// Get from multiplying value and . - public static DynamicViscosity operator *(QuantityValue left, DynamicViscosity right) + public static DynamicViscosity operator *(double left, DynamicViscosity right) { return new DynamicViscosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static DynamicViscosity operator *(DynamicViscosity left, QuantityValue right) + public static DynamicViscosity operator *(DynamicViscosity left, double right) { return new DynamicViscosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static DynamicViscosity operator /(DynamicViscosity left, QuantityValue right) + public static DynamicViscosity operator /(DynamicViscosity left, double right) { return new DynamicViscosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(DynamicViscosity left, DynamicViscosity right) + public static double operator /(DynamicViscosity left, DynamicViscosity right) { return left.NewtonSecondsPerMeterSquared / right.NewtonSecondsPerMeterSquared; } @@ -625,19 +622,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Dynam return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(DynamicViscosity left, DynamicViscosity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(DynamicViscosity left, DynamicViscosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -650,29 +634,7 @@ public int CompareTo(object obj) /// public int CompareTo(DynamicViscosity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is DynamicViscosity objDynamicViscosity)) - return false; - return Equals(objDynamicViscosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(DynamicViscosity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -715,13 +677,13 @@ public bool Equals(DynamicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(DynamicViscosity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -732,7 +694,7 @@ public bool Equals(DynamicViscosity other, QuantityValue tolerance, ComparisonTy /// A hash code for the current DynamicViscosity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -743,16 +705,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(DynamicViscosityUnit unit) + public double As(DynamicViscosityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -767,12 +730,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is DynamicViscosityUnit typedUnit)) + if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsDynamicViscosityUnit); } /// @@ -804,7 +767,7 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (DynamicViscosity)converted; } - else if (Enum.IsDefined(typeof(DynamicViscosityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -812,17 +775,17 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit, UnitConverter unitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DynamicViscosityUnit typedUnit)) + if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsDynamicViscosityUnit, DefaultConversionFunctions); } /// @@ -849,10 +812,10 @@ public DynamicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(DynamicViscosityUnit unit) + private double GetValueAs(DynamicViscosityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 5cab50ab8c..5f6f688ac8 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Electric admittance is a measure of how easily a circuit or device will allow a current to flow. It is defined as the inverse of impedance. The SI unit of admittance is the siemens (symbol S). /// [DataContract] - public partial struct ElectricAdmittance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricAdmittance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricAdmittance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricAdmittance(QuantityValue value, ElectricAdmittanceUnit unit) + public ElectricAdmittance(double value, ElectricAdmittanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public ElectricAdmittance(QuantityValue value, ElectricAdmittanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricAdmittance(QuantityValue value, UnitSystem unitSystem) + public ElectricAdmittance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public ElectricAdmittance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public ElectricAdmittance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); + public double Microsiemens => As(ElectricAdmittanceUnit.Microsiemens); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); + public double Millisiemens => As(ElectricAdmittanceUnit.Millisiemens); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); + public double Nanosiemens => As(ElectricAdmittanceUnit.Nanosiemens); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Siemens => As(ElectricAdmittanceUnit.Siemens); + public double Siemens => As(ElectricAdmittanceUnit.Siemens); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(ElectricAdmittanceUnit unit, IFormatProvide /// If value is NaN or Infinity. public static ElectricAdmittance FromMicrosiemens(QuantityValue microsiemens) { - QuantityValue value = (QuantityValue) microsiemens; + double value = (double) microsiemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Microsiemens); } @@ -255,7 +252,7 @@ public static ElectricAdmittance FromMicrosiemens(QuantityValue microsiemens) /// If value is NaN or Infinity. public static ElectricAdmittance FromMillisiemens(QuantityValue millisiemens) { - QuantityValue value = (QuantityValue) millisiemens; + double value = (double) millisiemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Millisiemens); } @@ -265,7 +262,7 @@ public static ElectricAdmittance FromMillisiemens(QuantityValue millisiemens) /// If value is NaN or Infinity. public static ElectricAdmittance FromNanosiemens(QuantityValue nanosiemens) { - QuantityValue value = (QuantityValue) nanosiemens; + double value = (double) nanosiemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Nanosiemens); } @@ -275,7 +272,7 @@ public static ElectricAdmittance FromNanosiemens(QuantityValue nanosiemens) /// If value is NaN or Infinity. public static ElectricAdmittance FromSiemens(QuantityValue siemens) { - QuantityValue value = (QuantityValue) siemens; + double value = (double) siemens; return new ElectricAdmittance(value, ElectricAdmittanceUnit.Siemens); } @@ -287,7 +284,7 @@ public static ElectricAdmittance FromSiemens(QuantityValue siemens) /// ElectricAdmittance unit value. public static ElectricAdmittance From(QuantityValue value, ElectricAdmittanceUnit fromUnit) { - return new ElectricAdmittance((QuantityValue)value, fromUnit); + return new ElectricAdmittance((double)value, fromUnit); } #endregion @@ -457,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricAdmittance operator *(QuantityValue left, ElectricAdmittance right) + public static ElectricAdmittance operator *(double left, ElectricAdmittance right) { return new ElectricAdmittance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricAdmittance operator *(ElectricAdmittance left, QuantityValue right) + public static ElectricAdmittance operator *(ElectricAdmittance left, double right) { return new ElectricAdmittance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricAdmittance operator /(ElectricAdmittance left, QuantityValue right) + public static ElectricAdmittance operator /(ElectricAdmittance left, double right) { return new ElectricAdmittance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricAdmittance left, ElectricAdmittance right) + public static double operator /(ElectricAdmittance left, ElectricAdmittance right) { return left.Siemens / right.Siemens; } @@ -508,19 +505,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricAdmittance left, ElectricAdmittance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricAdmittance left, ElectricAdmittance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -533,29 +517,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricAdmittance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricAdmittance objElectricAdmittance)) - return false; - return Equals(objElectricAdmittance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricAdmittance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -598,13 +560,13 @@ public bool Equals(ElectricAdmittance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricAdmittance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +577,7 @@ public bool Equals(ElectricAdmittance other, QuantityValue tolerance, Comparison /// A hash code for the current ElectricAdmittance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -626,16 +588,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricAdmittanceUnit unit) + public double As(ElectricAdmittanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -650,12 +613,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricAdmittanceUnit typedUnit)) + if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricAdmittanceUnit); } /// @@ -687,7 +650,7 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit, UnitConverter unit var converted = conversionFunction(this); return (ElectricAdmittance)converted; } - else if (Enum.IsDefined(typeof(ElectricAdmittanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -695,17 +658,17 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricAdmittanceUnit typedUnit)) + if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricAdmittanceUnit, DefaultConversionFunctions); } /// @@ -732,10 +695,10 @@ public ElectricAdmittance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricAdmittanceUnit unit) + private double GetValueAs(ElectricAdmittanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index 088da970dd..efdcf152cd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_charge /// [DataContract] - public partial struct ElectricCharge : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCharge : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -79,9 +79,9 @@ static ElectricCharge() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCharge(QuantityValue value, ElectricChargeUnit unit) + public ElectricCharge(double value, ElectricChargeUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -93,14 +93,14 @@ public ElectricCharge(QuantityValue value, ElectricChargeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCharge(QuantityValue value, UnitSystem unitSystem) + public ElectricCharge(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -141,10 +141,7 @@ public ElectricCharge(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -167,29 +164,29 @@ public ElectricCharge(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmpereHours => As(ElectricChargeUnit.AmpereHour); + public double AmpereHours => As(ElectricChargeUnit.AmpereHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Coulombs => As(ElectricChargeUnit.Coulomb); + public double Coulombs => As(ElectricChargeUnit.Coulomb); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KiloampereHours => As(ElectricChargeUnit.KiloampereHour); + public double KiloampereHours => As(ElectricChargeUnit.KiloampereHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegaampereHours => As(ElectricChargeUnit.MegaampereHour); + public double MegaampereHours => As(ElectricChargeUnit.MegaampereHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliampereHours => As(ElectricChargeUnit.MilliampereHour); + public double MilliampereHours => As(ElectricChargeUnit.MilliampereHour); #endregion @@ -257,7 +254,7 @@ public static string GetAbbreviation(ElectricChargeUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ElectricCharge FromAmpereHours(QuantityValue amperehours) { - QuantityValue value = (QuantityValue) amperehours; + double value = (double) amperehours; return new ElectricCharge(value, ElectricChargeUnit.AmpereHour); } @@ -267,7 +264,7 @@ public static ElectricCharge FromAmpereHours(QuantityValue amperehours) /// If value is NaN or Infinity. public static ElectricCharge FromCoulombs(QuantityValue coulombs) { - QuantityValue value = (QuantityValue) coulombs; + double value = (double) coulombs; return new ElectricCharge(value, ElectricChargeUnit.Coulomb); } @@ -277,7 +274,7 @@ public static ElectricCharge FromCoulombs(QuantityValue coulombs) /// If value is NaN or Infinity. public static ElectricCharge FromKiloampereHours(QuantityValue kiloamperehours) { - QuantityValue value = (QuantityValue) kiloamperehours; + double value = (double) kiloamperehours; return new ElectricCharge(value, ElectricChargeUnit.KiloampereHour); } @@ -287,7 +284,7 @@ public static ElectricCharge FromKiloampereHours(QuantityValue kiloamperehours) /// If value is NaN or Infinity. public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) { - QuantityValue value = (QuantityValue) megaamperehours; + double value = (double) megaamperehours; return new ElectricCharge(value, ElectricChargeUnit.MegaampereHour); } @@ -297,7 +294,7 @@ public static ElectricCharge FromMegaampereHours(QuantityValue megaamperehours) /// If value is NaN or Infinity. public static ElectricCharge FromMilliampereHours(QuantityValue milliamperehours) { - QuantityValue value = (QuantityValue) milliamperehours; + double value = (double) milliamperehours; return new ElectricCharge(value, ElectricChargeUnit.MilliampereHour); } @@ -309,7 +306,7 @@ public static ElectricCharge FromMilliampereHours(QuantityValue milliamperehours /// ElectricCharge unit value. public static ElectricCharge From(QuantityValue value, ElectricChargeUnit fromUnit) { - return new ElectricCharge((QuantityValue)value, fromUnit); + return new ElectricCharge((double)value, fromUnit); } #endregion @@ -479,25 +476,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCharge operator *(QuantityValue left, ElectricCharge right) + public static ElectricCharge operator *(double left, ElectricCharge right) { return new ElectricCharge(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCharge operator *(ElectricCharge left, QuantityValue right) + public static ElectricCharge operator *(ElectricCharge left, double right) { return new ElectricCharge(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCharge operator /(ElectricCharge left, QuantityValue right) + public static ElectricCharge operator /(ElectricCharge left, double right) { return new ElectricCharge(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricCharge left, ElectricCharge right) + public static double operator /(ElectricCharge left, ElectricCharge right) { return left.Coulombs / right.Coulombs; } @@ -530,19 +527,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCharge left, ElectricCharge right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCharge left, ElectricCharge right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -555,29 +539,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCharge other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricCharge objElectricCharge)) - return false; - return Equals(objElectricCharge); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCharge other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -620,13 +582,13 @@ public bool Equals(ElectricCharge other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCharge other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCharge other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -637,7 +599,7 @@ public bool Equals(ElectricCharge other, QuantityValue tolerance, ComparisonType /// A hash code for the current ElectricCharge. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -648,16 +610,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricChargeUnit unit) + public double As(ElectricChargeUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -672,12 +635,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeUnit typedUnit)) + if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricChargeUnit); } /// @@ -709,7 +672,7 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ElectricCharge)converted; } - else if (Enum.IsDefined(typeof(ElectricChargeUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -717,17 +680,17 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeUnit typedUnit)) + if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricChargeUnit, DefaultConversionFunctions); } /// @@ -754,10 +717,10 @@ public ElectricCharge ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricChargeUnit unit) + private double GetValueAs(ElectricChargeUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 470af68bd9..4538e7e215 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricChargeDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricChargeDensity(QuantityValue value, ElectricChargeDensityUnit unit) + public ElectricChargeDensity(double value, ElectricChargeDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public ElectricChargeDensity(QuantityValue value, ElectricChargeDensityUnit unit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricChargeDensity(QuantityValue value, UnitSystem unitSystem) + public ElectricChargeDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public ElectricChargeDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public ElectricChargeDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); + public double CoulombsPerCubicMeter => As(ElectricChargeDensityUnit.CoulombPerCubicMeter); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(ElectricChargeDensityUnit unit, IFormatProv /// If value is NaN or Infinity. public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue coulombspercubicmeter) { - QuantityValue value = (QuantityValue) coulombspercubicmeter; + double value = (double) coulombspercubicmeter; return new ElectricChargeDensity(value, ElectricChargeDensityUnit.CoulombPerCubicMeter); } @@ -233,7 +230,7 @@ public static ElectricChargeDensity FromCoulombsPerCubicMeter(QuantityValue coul /// ElectricChargeDensity unit value. public static ElectricChargeDensity From(QuantityValue value, ElectricChargeDensityUnit fromUnit) { - return new ElectricChargeDensity((QuantityValue)value, fromUnit); + return new ElectricChargeDensity((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricChargeDensity operator *(QuantityValue left, ElectricChargeDensity right) + public static ElectricChargeDensity operator *(double left, ElectricChargeDensity right) { return new ElectricChargeDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricChargeDensity operator *(ElectricChargeDensity left, QuantityValue right) + public static ElectricChargeDensity operator *(ElectricChargeDensity left, double right) { return new ElectricChargeDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricChargeDensity operator /(ElectricChargeDensity left, QuantityValue right) + public static ElectricChargeDensity operator /(ElectricChargeDensity left, double right) { return new ElectricChargeDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricChargeDensity left, ElectricChargeDensity right) + public static double operator /(ElectricChargeDensity left, ElectricChargeDensity right) { return left.CoulombsPerCubicMeter / right.CoulombsPerCubicMeter; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricChargeDensity left, ElectricChargeDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricChargeDensity left, ElectricChargeDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricChargeDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricChargeDensity objElectricChargeDensity)) - return false; - return Equals(objElectricChargeDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricChargeDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(ElectricChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricChargeDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(ElectricChargeDensity other, QuantityValue tolerance, Compari /// A hash code for the current ElectricChargeDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricChargeDensityUnit unit) + public double As(ElectricChargeDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeDensityUnit typedUnit)) + if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricChargeDensityUnit); } /// @@ -633,7 +596,7 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit, UnitConverte var converted = conversionFunction(this); return (ElectricChargeDensity)converted; } - else if (Enum.IsDefined(typeof(ElectricChargeDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit, UnitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeDensityUnit typedUnit)) + if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricChargeDensityUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public ElectricChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricChargeDensityUnit unit) + private double GetValueAs(ElectricChargeDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index 885748e77b..f9f766a99d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistance_and_conductance /// [DataContract] - public partial struct ElectricConductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricConductance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricConductance(QuantityValue value, ElectricConductanceUnit unit) + public ElectricConductance(double value, ElectricConductanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public ElectricConductance(QuantityValue value, ElectricConductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductance(QuantityValue value, UnitSystem unitSystem) + public ElectricConductance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public ElectricConductance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,19 +162,19 @@ public ElectricConductance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microsiemens => As(ElectricConductanceUnit.Microsiemens); + public double Microsiemens => As(ElectricConductanceUnit.Microsiemens); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millisiemens => As(ElectricConductanceUnit.Millisiemens); + public double Millisiemens => As(ElectricConductanceUnit.Millisiemens); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Siemens => As(ElectricConductanceUnit.Siemens); + public double Siemens => As(ElectricConductanceUnit.Siemens); #endregion @@ -239,7 +236,7 @@ public static string GetAbbreviation(ElectricConductanceUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricConductance FromMicrosiemens(QuantityValue microsiemens) { - QuantityValue value = (QuantityValue) microsiemens; + double value = (double) microsiemens; return new ElectricConductance(value, ElectricConductanceUnit.Microsiemens); } @@ -249,7 +246,7 @@ public static ElectricConductance FromMicrosiemens(QuantityValue microsiemens) /// If value is NaN or Infinity. public static ElectricConductance FromMillisiemens(QuantityValue millisiemens) { - QuantityValue value = (QuantityValue) millisiemens; + double value = (double) millisiemens; return new ElectricConductance(value, ElectricConductanceUnit.Millisiemens); } @@ -259,7 +256,7 @@ public static ElectricConductance FromMillisiemens(QuantityValue millisiemens) /// If value is NaN or Infinity. public static ElectricConductance FromSiemens(QuantityValue siemens) { - QuantityValue value = (QuantityValue) siemens; + double value = (double) siemens; return new ElectricConductance(value, ElectricConductanceUnit.Siemens); } @@ -271,7 +268,7 @@ public static ElectricConductance FromSiemens(QuantityValue siemens) /// ElectricConductance unit value. public static ElectricConductance From(QuantityValue value, ElectricConductanceUnit fromUnit) { - return new ElectricConductance((QuantityValue)value, fromUnit); + return new ElectricConductance((double)value, fromUnit); } #endregion @@ -441,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricConductance operator *(QuantityValue left, ElectricConductance right) + public static ElectricConductance operator *(double left, ElectricConductance right) { return new ElectricConductance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricConductance operator *(ElectricConductance left, QuantityValue right) + public static ElectricConductance operator *(ElectricConductance left, double right) { return new ElectricConductance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricConductance operator /(ElectricConductance left, QuantityValue right) + public static ElectricConductance operator /(ElectricConductance left, double right) { return new ElectricConductance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricConductance left, ElectricConductance right) + public static double operator /(ElectricConductance left, ElectricConductance right) { return left.Siemens / right.Siemens; } @@ -492,19 +489,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductance left, ElectricConductance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductance left, ElectricConductance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -517,29 +501,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricConductance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricConductance objElectricConductance)) - return false; - return Equals(objElectricConductance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -582,13 +544,13 @@ public bool Equals(ElectricConductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricConductance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -599,7 +561,7 @@ public bool Equals(ElectricConductance other, QuantityValue tolerance, Compariso /// A hash code for the current ElectricConductance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -610,16 +572,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricConductanceUnit unit) + public double As(ElectricConductanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -634,12 +597,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricConductanceUnit typedUnit)) + if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricConductanceUnit); } /// @@ -671,7 +634,7 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricConductance)converted; } - else if (Enum.IsDefined(typeof(ElectricConductanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -679,17 +642,17 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductanceUnit typedUnit)) + if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricConductanceUnit, DefaultConversionFunctions); } /// @@ -716,10 +679,10 @@ public ElectricConductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricConductanceUnit unit) + private double GetValueAs(ElectricConductanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 50efdddf94..8b7f49777a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricConductivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricConductivity(QuantityValue value, ElectricConductivityUnit unit) + public ElectricConductivity(double value, ElectricConductivityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public ElectricConductivity(QuantityValue value, ElectricConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricConductivity(QuantityValue value, UnitSystem unitSystem) + public ElectricConductivity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public ElectricConductivity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,19 +162,19 @@ public ElectricConductivity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); + public double SiemensPerFoot => As(ElectricConductivityUnit.SiemensPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); + public double SiemensPerInch => As(ElectricConductivityUnit.SiemensPerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); + public double SiemensPerMeter => As(ElectricConductivityUnit.SiemensPerMeter); #endregion @@ -239,7 +236,7 @@ public static string GetAbbreviation(ElectricConductivityUnit unit, IFormatProvi /// If value is NaN or Infinity. public static ElectricConductivity FromSiemensPerFoot(QuantityValue siemensperfoot) { - QuantityValue value = (QuantityValue) siemensperfoot; + double value = (double) siemensperfoot; return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerFoot); } @@ -249,7 +246,7 @@ public static ElectricConductivity FromSiemensPerFoot(QuantityValue siemensperfo /// If value is NaN or Infinity. public static ElectricConductivity FromSiemensPerInch(QuantityValue siemensperinch) { - QuantityValue value = (QuantityValue) siemensperinch; + double value = (double) siemensperinch; return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerInch); } @@ -259,7 +256,7 @@ public static ElectricConductivity FromSiemensPerInch(QuantityValue siemensperin /// If value is NaN or Infinity. public static ElectricConductivity FromSiemensPerMeter(QuantityValue siemenspermeter) { - QuantityValue value = (QuantityValue) siemenspermeter; + double value = (double) siemenspermeter; return new ElectricConductivity(value, ElectricConductivityUnit.SiemensPerMeter); } @@ -271,7 +268,7 @@ public static ElectricConductivity FromSiemensPerMeter(QuantityValue siemensperm /// ElectricConductivity unit value. public static ElectricConductivity From(QuantityValue value, ElectricConductivityUnit fromUnit) { - return new ElectricConductivity((QuantityValue)value, fromUnit); + return new ElectricConductivity((double)value, fromUnit); } #endregion @@ -441,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricConductivity operator *(QuantityValue left, ElectricConductivity right) + public static ElectricConductivity operator *(double left, ElectricConductivity right) { return new ElectricConductivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricConductivity operator *(ElectricConductivity left, QuantityValue right) + public static ElectricConductivity operator *(ElectricConductivity left, double right) { return new ElectricConductivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricConductivity operator /(ElectricConductivity left, QuantityValue right) + public static ElectricConductivity operator /(ElectricConductivity left, double right) { return new ElectricConductivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricConductivity left, ElectricConductivity right) + public static double operator /(ElectricConductivity left, ElectricConductivity right) { return left.SiemensPerMeter / right.SiemensPerMeter; } @@ -492,19 +489,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricConductivity left, ElectricConductivity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricConductivity left, ElectricConductivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -517,29 +501,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricConductivity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricConductivity objElectricConductivity)) - return false; - return Equals(objElectricConductivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricConductivity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -582,13 +544,13 @@ public bool Equals(ElectricConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricConductivity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricConductivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -599,7 +561,7 @@ public bool Equals(ElectricConductivity other, QuantityValue tolerance, Comparis /// A hash code for the current ElectricConductivity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -610,16 +572,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricConductivityUnit unit) + public double As(ElectricConductivityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -634,12 +597,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricConductivityUnit typedUnit)) + if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricConductivityUnit); } /// @@ -671,7 +634,7 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit, UnitConverter var converted = conversionFunction(this); return (ElectricConductivity)converted; } - else if (Enum.IsDefined(typeof(ElectricConductivityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -679,17 +642,17 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit, UnitConverter } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductivityUnit typedUnit)) + if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricConductivityUnit, DefaultConversionFunctions); } /// @@ -716,10 +679,10 @@ public ElectricConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricConductivityUnit unit) + private double GetValueAs(ElectricConductivityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index a370f87e7e..0485881539 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// An electric current is a flow of electric charge. In electric circuits this charge is often carried by moving electrons in a wire. It can also be carried by ions in an electrolyte, or by both ions and electrons such as in a plasma. /// [DataContract] - public partial struct ElectricCurrent : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrent : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -79,9 +79,9 @@ static ElectricCurrent() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrent(QuantityValue value, ElectricCurrentUnit unit) + public ElectricCurrent(double value, ElectricCurrentUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -93,14 +93,14 @@ public ElectricCurrent(QuantityValue value, ElectricCurrentUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrent(QuantityValue value, UnitSystem unitSystem) + public ElectricCurrent(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -141,10 +141,7 @@ public ElectricCurrent(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -167,44 +164,44 @@ public ElectricCurrent(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Amperes => As(ElectricCurrentUnit.Ampere); + public double Amperes => As(ElectricCurrentUnit.Ampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centiamperes => As(ElectricCurrentUnit.Centiampere); + public double Centiamperes => As(ElectricCurrentUnit.Centiampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kiloamperes => As(ElectricCurrentUnit.Kiloampere); + public double Kiloamperes => As(ElectricCurrentUnit.Kiloampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megaamperes => As(ElectricCurrentUnit.Megaampere); + public double Megaamperes => As(ElectricCurrentUnit.Megaampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microamperes => As(ElectricCurrentUnit.Microampere); + public double Microamperes => As(ElectricCurrentUnit.Microampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliamperes => As(ElectricCurrentUnit.Milliampere); + public double Milliamperes => As(ElectricCurrentUnit.Milliampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanoamperes => As(ElectricCurrentUnit.Nanoampere); + public double Nanoamperes => As(ElectricCurrentUnit.Nanoampere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Picoamperes => As(ElectricCurrentUnit.Picoampere); + public double Picoamperes => As(ElectricCurrentUnit.Picoampere); #endregion @@ -281,7 +278,7 @@ public static string GetAbbreviation(ElectricCurrentUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static ElectricCurrent FromAmperes(QuantityValue amperes) { - QuantityValue value = (QuantityValue) amperes; + double value = (double) amperes; return new ElectricCurrent(value, ElectricCurrentUnit.Ampere); } @@ -291,7 +288,7 @@ public static ElectricCurrent FromAmperes(QuantityValue amperes) /// If value is NaN or Infinity. public static ElectricCurrent FromCentiamperes(QuantityValue centiamperes) { - QuantityValue value = (QuantityValue) centiamperes; + double value = (double) centiamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Centiampere); } @@ -301,7 +298,7 @@ public static ElectricCurrent FromCentiamperes(QuantityValue centiamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromKiloamperes(QuantityValue kiloamperes) { - QuantityValue value = (QuantityValue) kiloamperes; + double value = (double) kiloamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Kiloampere); } @@ -311,7 +308,7 @@ public static ElectricCurrent FromKiloamperes(QuantityValue kiloamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromMegaamperes(QuantityValue megaamperes) { - QuantityValue value = (QuantityValue) megaamperes; + double value = (double) megaamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Megaampere); } @@ -321,7 +318,7 @@ public static ElectricCurrent FromMegaamperes(QuantityValue megaamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromMicroamperes(QuantityValue microamperes) { - QuantityValue value = (QuantityValue) microamperes; + double value = (double) microamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Microampere); } @@ -331,7 +328,7 @@ public static ElectricCurrent FromMicroamperes(QuantityValue microamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromMilliamperes(QuantityValue milliamperes) { - QuantityValue value = (QuantityValue) milliamperes; + double value = (double) milliamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Milliampere); } @@ -341,7 +338,7 @@ public static ElectricCurrent FromMilliamperes(QuantityValue milliamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromNanoamperes(QuantityValue nanoamperes) { - QuantityValue value = (QuantityValue) nanoamperes; + double value = (double) nanoamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Nanoampere); } @@ -351,7 +348,7 @@ public static ElectricCurrent FromNanoamperes(QuantityValue nanoamperes) /// If value is NaN or Infinity. public static ElectricCurrent FromPicoamperes(QuantityValue picoamperes) { - QuantityValue value = (QuantityValue) picoamperes; + double value = (double) picoamperes; return new ElectricCurrent(value, ElectricCurrentUnit.Picoampere); } @@ -363,7 +360,7 @@ public static ElectricCurrent FromPicoamperes(QuantityValue picoamperes) /// ElectricCurrent unit value. public static ElectricCurrent From(QuantityValue value, ElectricCurrentUnit fromUnit) { - return new ElectricCurrent((QuantityValue)value, fromUnit); + return new ElectricCurrent((double)value, fromUnit); } #endregion @@ -533,25 +530,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrent operator *(QuantityValue left, ElectricCurrent right) + public static ElectricCurrent operator *(double left, ElectricCurrent right) { return new ElectricCurrent(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrent operator *(ElectricCurrent left, QuantityValue right) + public static ElectricCurrent operator *(ElectricCurrent left, double right) { return new ElectricCurrent(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrent operator /(ElectricCurrent left, QuantityValue right) + public static ElectricCurrent operator /(ElectricCurrent left, double right) { return new ElectricCurrent(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricCurrent left, ElectricCurrent right) + public static double operator /(ElectricCurrent left, ElectricCurrent right) { return left.Amperes / right.Amperes; } @@ -584,19 +581,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrent left, ElectricCurrent right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrent left, ElectricCurrent right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -609,29 +593,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCurrent other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricCurrent objElectricCurrent)) - return false; - return Equals(objElectricCurrent); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrent other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -674,13 +636,13 @@ public bool Equals(ElectricCurrent other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrent other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrent other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -691,7 +653,7 @@ public bool Equals(ElectricCurrent other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current ElectricCurrent. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -702,16 +664,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricCurrentUnit unit) + public double As(ElectricCurrentUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -726,12 +689,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentUnit typedUnit)) + if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricCurrentUnit); } /// @@ -763,7 +726,7 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (ElectricCurrent)converted; } - else if (Enum.IsDefined(typeof(ElectricCurrentUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -771,17 +734,17 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentUnit typedUnit)) + if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricCurrentUnit, DefaultConversionFunctions); } /// @@ -808,10 +771,10 @@ public ElectricCurrent ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricCurrentUnit unit) + private double GetValueAs(ElectricCurrentUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 52214a6462..8a8989cb79 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Current_density /// [DataContract] - public partial struct ElectricCurrentDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricCurrentDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrentDensity(QuantityValue value, ElectricCurrentDensityUnit unit) + public ElectricCurrentDensity(double value, ElectricCurrentDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public ElectricCurrentDensity(QuantityValue value, ElectricCurrentDensityUnit un /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentDensity(QuantityValue value, UnitSystem unitSystem) + public ElectricCurrentDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public ElectricCurrentDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,19 +162,19 @@ public ElectricCurrentDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); + public double AmperesPerSquareFoot => As(ElectricCurrentDensityUnit.AmperePerSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); + public double AmperesPerSquareInch => As(ElectricCurrentDensityUnit.AmperePerSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); + public double AmperesPerSquareMeter => As(ElectricCurrentDensityUnit.AmperePerSquareMeter); #endregion @@ -239,7 +236,7 @@ public static string GetAbbreviation(ElectricCurrentDensityUnit unit, IFormatPro /// If value is NaN or Infinity. public static ElectricCurrentDensity FromAmperesPerSquareFoot(QuantityValue amperespersquarefoot) { - QuantityValue value = (QuantityValue) amperespersquarefoot; + double value = (double) amperespersquarefoot; return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareFoot); } @@ -249,7 +246,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareFoot(QuantityValue ampe /// If value is NaN or Infinity. public static ElectricCurrentDensity FromAmperesPerSquareInch(QuantityValue amperespersquareinch) { - QuantityValue value = (QuantityValue) amperespersquareinch; + double value = (double) amperespersquareinch; return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareInch); } @@ -259,7 +256,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareInch(QuantityValue ampe /// If value is NaN or Infinity. public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue amperespersquaremeter) { - QuantityValue value = (QuantityValue) amperespersquaremeter; + double value = (double) amperespersquaremeter; return new ElectricCurrentDensity(value, ElectricCurrentDensityUnit.AmperePerSquareMeter); } @@ -271,7 +268,7 @@ public static ElectricCurrentDensity FromAmperesPerSquareMeter(QuantityValue amp /// ElectricCurrentDensity unit value. public static ElectricCurrentDensity From(QuantityValue value, ElectricCurrentDensityUnit fromUnit) { - return new ElectricCurrentDensity((QuantityValue)value, fromUnit); + return new ElectricCurrentDensity((double)value, fromUnit); } #endregion @@ -441,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(QuantityValue left, ElectricCurrentDensity right) + public static ElectricCurrentDensity operator *(double left, ElectricCurrentDensity right) { return new ElectricCurrentDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, QuantityValue right) + public static ElectricCurrentDensity operator *(ElectricCurrentDensity left, double right) { return new ElectricCurrentDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, QuantityValue right) + public static ElectricCurrentDensity operator /(ElectricCurrentDensity left, double right) { return new ElectricCurrentDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) + public static double operator /(ElectricCurrentDensity left, ElectricCurrentDensity right) { return left.AmperesPerSquareMeter / right.AmperesPerSquareMeter; } @@ -492,19 +489,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentDensity left, ElectricCurrentDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentDensity left, ElectricCurrentDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -517,29 +501,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCurrentDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricCurrentDensity objElectricCurrentDensity)) - return false; - return Equals(objElectricCurrentDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -582,13 +544,13 @@ public bool Equals(ElectricCurrentDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -599,7 +561,7 @@ public bool Equals(ElectricCurrentDensity other, QuantityValue tolerance, Compar /// A hash code for the current ElectricCurrentDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -610,16 +572,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricCurrentDensityUnit unit) + public double As(ElectricCurrentDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -634,12 +597,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit typedUnit)) + if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricCurrentDensityUnit); } /// @@ -671,7 +634,7 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit, UnitConver var converted = conversionFunction(this); return (ElectricCurrentDensity)converted; } - else if (Enum.IsDefined(typeof(ElectricCurrentDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -679,17 +642,17 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit, UnitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit typedUnit)) + if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricCurrentDensityUnit, DefaultConversionFunctions); } /// @@ -716,10 +679,10 @@ public ElectricCurrentDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricCurrentDensityUnit unit) + private double GetValueAs(ElectricCurrentDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index 7f2103c3e8..c5b8587e27 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In electromagnetism, the current gradient describes how the current changes in time. /// [DataContract] - public partial struct ElectricCurrentGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricCurrentGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricCurrentGradient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricCurrentGradient(QuantityValue value, ElectricCurrentGradientUnit unit) + public ElectricCurrentGradient(double value, ElectricCurrentGradientUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public ElectricCurrentGradient(QuantityValue value, ElectricCurrentGradientUnit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricCurrentGradient(QuantityValue value, UnitSystem unitSystem) + public ElectricCurrentGradient(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public ElectricCurrentGradient(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public ElectricCurrentGradient(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); + public double AmperesPerMicrosecond => As(ElectricCurrentGradientUnit.AmperePerMicrosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); + public double AmperesPerMillisecond => As(ElectricCurrentGradientUnit.AmperePerMillisecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); + public double AmperesPerNanosecond => As(ElectricCurrentGradientUnit.AmperePerNanosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); + public double AmperesPerSecond => As(ElectricCurrentGradientUnit.AmperePerSecond); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(ElectricCurrentGradientUnit unit, IFormatPr /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerMicrosecond(QuantityValue amperespermicrosecond) { - QuantityValue value = (QuantityValue) amperespermicrosecond; + double value = (double) amperespermicrosecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMicrosecond); } @@ -255,7 +252,7 @@ public static ElectricCurrentGradient FromAmperesPerMicrosecond(QuantityValue am /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerMillisecond(QuantityValue amperespermillisecond) { - QuantityValue value = (QuantityValue) amperespermillisecond; + double value = (double) amperespermillisecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerMillisecond); } @@ -265,7 +262,7 @@ public static ElectricCurrentGradient FromAmperesPerMillisecond(QuantityValue am /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerNanosecond(QuantityValue amperespernanosecond) { - QuantityValue value = (QuantityValue) amperespernanosecond; + double value = (double) amperespernanosecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerNanosecond); } @@ -275,7 +272,7 @@ public static ElectricCurrentGradient FromAmperesPerNanosecond(QuantityValue amp /// If value is NaN or Infinity. public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue amperespersecond) { - QuantityValue value = (QuantityValue) amperespersecond; + double value = (double) amperespersecond; return new ElectricCurrentGradient(value, ElectricCurrentGradientUnit.AmperePerSecond); } @@ -287,7 +284,7 @@ public static ElectricCurrentGradient FromAmperesPerSecond(QuantityValue amperes /// ElectricCurrentGradient unit value. public static ElectricCurrentGradient From(QuantityValue value, ElectricCurrentGradientUnit fromUnit) { - return new ElectricCurrentGradient((QuantityValue)value, fromUnit); + return new ElectricCurrentGradient((double)value, fromUnit); } #endregion @@ -457,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(QuantityValue left, ElectricCurrentGradient right) + public static ElectricCurrentGradient operator *(double left, ElectricCurrentGradient right) { return new ElectricCurrentGradient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, QuantityValue right) + public static ElectricCurrentGradient operator *(ElectricCurrentGradient left, double right) { return new ElectricCurrentGradient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, QuantityValue right) + public static ElectricCurrentGradient operator /(ElectricCurrentGradient left, double right) { return new ElectricCurrentGradient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) + public static double operator /(ElectricCurrentGradient left, ElectricCurrentGradient right) { return left.AmperesPerSecond / right.AmperesPerSecond; } @@ -508,19 +505,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricCurrentGradient left, ElectricCurrentGradient right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricCurrentGradient left, ElectricCurrentGradient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -533,29 +517,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricCurrentGradient other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricCurrentGradient objElectricCurrentGradient)) - return false; - return Equals(objElectricCurrentGradient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricCurrentGradient other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -598,13 +560,13 @@ public bool Equals(ElectricCurrentGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricCurrentGradient other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +577,7 @@ public bool Equals(ElectricCurrentGradient other, QuantityValue tolerance, Compa /// A hash code for the current ElectricCurrentGradient. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -626,16 +588,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricCurrentGradientUnit unit) + public double As(ElectricCurrentGradientUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -650,12 +613,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit typedUnit)) + if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricCurrentGradientUnit); } /// @@ -687,7 +650,7 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit, UnitConv var converted = conversionFunction(this); return (ElectricCurrentGradient)converted; } - else if (Enum.IsDefined(typeof(ElectricCurrentGradientUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -695,17 +658,17 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit, UnitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit typedUnit)) + if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricCurrentGradientUnit, DefaultConversionFunctions); } /// @@ -732,10 +695,10 @@ public ElectricCurrentGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricCurrentGradientUnit unit) + private double GetValueAs(ElectricCurrentGradientUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index 29e68a9570..d49e4be72a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electric_field /// [DataContract] - public partial struct ElectricField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricField : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ElectricField() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricField(QuantityValue value, ElectricFieldUnit unit) + public ElectricField(double value, ElectricFieldUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public ElectricField(QuantityValue value, ElectricFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricField(QuantityValue value, UnitSystem unitSystem) + public ElectricField(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public ElectricField(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public ElectricField(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); + public double VoltsPerMeter => As(ElectricFieldUnit.VoltPerMeter); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(ElectricFieldUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static ElectricField FromVoltsPerMeter(QuantityValue voltspermeter) { - QuantityValue value = (QuantityValue) voltspermeter; + double value = (double) voltspermeter; return new ElectricField(value, ElectricFieldUnit.VoltPerMeter); } @@ -233,7 +230,7 @@ public static ElectricField FromVoltsPerMeter(QuantityValue voltspermeter) /// ElectricField unit value. public static ElectricField From(QuantityValue value, ElectricFieldUnit fromUnit) { - return new ElectricField((QuantityValue)value, fromUnit); + return new ElectricField((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricField operator *(QuantityValue left, ElectricField right) + public static ElectricField operator *(double left, ElectricField right) { return new ElectricField(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricField operator *(ElectricField left, QuantityValue right) + public static ElectricField operator *(ElectricField left, double right) { return new ElectricField(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricField operator /(ElectricField left, QuantityValue right) + public static ElectricField operator /(ElectricField left, double right) { return new ElectricField(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricField left, ElectricField right) + public static double operator /(ElectricField left, ElectricField right) { return left.VoltsPerMeter / right.VoltsPerMeter; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricField left, ElectricField right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricField left, ElectricField right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricField other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricField objElectricField)) - return false; - return Equals(objElectricField); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricField other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(ElectricField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricField other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricField other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(ElectricField other, QuantityValue tolerance, ComparisonType /// A hash code for the current ElectricField. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricFieldUnit unit) + public double As(ElectricFieldUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricFieldUnit typedUnit)) + if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricFieldUnit); } /// @@ -633,7 +596,7 @@ public ElectricField ToUnit(ElectricFieldUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (ElectricField)converted; } - else if (Enum.IsDefined(typeof(ElectricFieldUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public ElectricField ToUnit(ElectricFieldUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricFieldUnit typedUnit)) + if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricFieldUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public ElectricField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricFieldUnit unit) + private double GetValueAs(ElectricFieldUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index 82eabf7fac..fb2435cdce 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inductance /// [DataContract] - public partial struct ElectricInductance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricInductance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static ElectricInductance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricInductance(QuantityValue value, ElectricInductanceUnit unit) + public ElectricInductance(double value, ElectricInductanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public ElectricInductance(QuantityValue value, ElectricInductanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricInductance(QuantityValue value, UnitSystem unitSystem) + public ElectricInductance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public ElectricInductance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,24 +163,24 @@ public ElectricInductance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Henries => As(ElectricInductanceUnit.Henry); + public double Henries => As(ElectricInductanceUnit.Henry); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microhenries => As(ElectricInductanceUnit.Microhenry); + public double Microhenries => As(ElectricInductanceUnit.Microhenry); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millihenries => As(ElectricInductanceUnit.Millihenry); + public double Millihenries => As(ElectricInductanceUnit.Millihenry); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanohenries => As(ElectricInductanceUnit.Nanohenry); + public double Nanohenries => As(ElectricInductanceUnit.Nanohenry); #endregion @@ -248,7 +245,7 @@ public static string GetAbbreviation(ElectricInductanceUnit unit, IFormatProvide /// If value is NaN or Infinity. public static ElectricInductance FromHenries(QuantityValue henries) { - QuantityValue value = (QuantityValue) henries; + double value = (double) henries; return new ElectricInductance(value, ElectricInductanceUnit.Henry); } @@ -258,7 +255,7 @@ public static ElectricInductance FromHenries(QuantityValue henries) /// If value is NaN or Infinity. public static ElectricInductance FromMicrohenries(QuantityValue microhenries) { - QuantityValue value = (QuantityValue) microhenries; + double value = (double) microhenries; return new ElectricInductance(value, ElectricInductanceUnit.Microhenry); } @@ -268,7 +265,7 @@ public static ElectricInductance FromMicrohenries(QuantityValue microhenries) /// If value is NaN or Infinity. public static ElectricInductance FromMillihenries(QuantityValue millihenries) { - QuantityValue value = (QuantityValue) millihenries; + double value = (double) millihenries; return new ElectricInductance(value, ElectricInductanceUnit.Millihenry); } @@ -278,7 +275,7 @@ public static ElectricInductance FromMillihenries(QuantityValue millihenries) /// If value is NaN or Infinity. public static ElectricInductance FromNanohenries(QuantityValue nanohenries) { - QuantityValue value = (QuantityValue) nanohenries; + double value = (double) nanohenries; return new ElectricInductance(value, ElectricInductanceUnit.Nanohenry); } @@ -290,7 +287,7 @@ public static ElectricInductance FromNanohenries(QuantityValue nanohenries) /// ElectricInductance unit value. public static ElectricInductance From(QuantityValue value, ElectricInductanceUnit fromUnit) { - return new ElectricInductance((QuantityValue)value, fromUnit); + return new ElectricInductance((double)value, fromUnit); } #endregion @@ -460,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricInductance operator *(QuantityValue left, ElectricInductance right) + public static ElectricInductance operator *(double left, ElectricInductance right) { return new ElectricInductance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricInductance operator *(ElectricInductance left, QuantityValue right) + public static ElectricInductance operator *(ElectricInductance left, double right) { return new ElectricInductance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricInductance operator /(ElectricInductance left, QuantityValue right) + public static ElectricInductance operator /(ElectricInductance left, double right) { return new ElectricInductance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricInductance left, ElectricInductance right) + public static double operator /(ElectricInductance left, ElectricInductance right) { return left.Henries / right.Henries; } @@ -511,19 +508,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricInductance left, ElectricInductance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricInductance left, ElectricInductance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,29 +520,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricInductance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricInductance objElectricInductance)) - return false; - return Equals(objElectricInductance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricInductance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -601,13 +563,13 @@ public bool Equals(ElectricInductance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricInductance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricInductance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -618,7 +580,7 @@ public bool Equals(ElectricInductance other, QuantityValue tolerance, Comparison /// A hash code for the current ElectricInductance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -629,16 +591,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricInductanceUnit unit) + public double As(ElectricInductanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -653,12 +616,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricInductanceUnit typedUnit)) + if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricInductanceUnit); } /// @@ -690,7 +653,7 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit, UnitConverter unit var converted = conversionFunction(this); return (ElectricInductance)converted; } - else if (Enum.IsDefined(typeof(ElectricInductanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -698,17 +661,17 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricInductanceUnit typedUnit)) + if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricInductanceUnit, DefaultConversionFunctions); } /// @@ -735,10 +698,10 @@ public ElectricInductance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricInductanceUnit unit) + private double GetValueAs(ElectricInductanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index f549a30e62..3c413afc86 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In classical electromagnetism, the electric potential (a scalar quantity denoted by Φ, ΦE or V and also called the electric field potential or the electrostatic potential) at a point is the amount of electric potential energy that a unitary point charge would have when located at that point. /// [DataContract] - public partial struct ElectricPotential : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotential : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ElectricPotential() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotential(QuantityValue value, ElectricPotentialUnit unit) + public ElectricPotential(double value, ElectricPotentialUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -90,14 +90,14 @@ public ElectricPotential(QuantityValue value, ElectricPotentialUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotential(QuantityValue value, UnitSystem unitSystem) + public ElectricPotential(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,10 +138,7 @@ public ElectricPotential(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -164,29 +161,29 @@ public ElectricPotential(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilovolts => As(ElectricPotentialUnit.Kilovolt); + public double Kilovolts => As(ElectricPotentialUnit.Kilovolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megavolts => As(ElectricPotentialUnit.Megavolt); + public double Megavolts => As(ElectricPotentialUnit.Megavolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microvolts => As(ElectricPotentialUnit.Microvolt); + public double Microvolts => As(ElectricPotentialUnit.Microvolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millivolts => As(ElectricPotentialUnit.Millivolt); + public double Millivolts => As(ElectricPotentialUnit.Millivolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Volts => As(ElectricPotentialUnit.Volt); + public double Volts => As(ElectricPotentialUnit.Volt); #endregion @@ -259,7 +256,7 @@ public static string GetAbbreviation(ElectricPotentialUnit unit, IFormatProvider /// If value is NaN or Infinity. public static ElectricPotential FromKilovolts(QuantityValue kilovolts) { - QuantityValue value = (QuantityValue) kilovolts; + double value = (double) kilovolts; return new ElectricPotential(value, ElectricPotentialUnit.Kilovolt); } @@ -269,7 +266,7 @@ public static ElectricPotential FromKilovolts(QuantityValue kilovolts) /// If value is NaN or Infinity. public static ElectricPotential FromMegavolts(QuantityValue megavolts) { - QuantityValue value = (QuantityValue) megavolts; + double value = (double) megavolts; return new ElectricPotential(value, ElectricPotentialUnit.Megavolt); } @@ -279,7 +276,7 @@ public static ElectricPotential FromMegavolts(QuantityValue megavolts) /// If value is NaN or Infinity. public static ElectricPotential FromMicrovolts(QuantityValue microvolts) { - QuantityValue value = (QuantityValue) microvolts; + double value = (double) microvolts; return new ElectricPotential(value, ElectricPotentialUnit.Microvolt); } @@ -289,7 +286,7 @@ public static ElectricPotential FromMicrovolts(QuantityValue microvolts) /// If value is NaN or Infinity. public static ElectricPotential FromMillivolts(QuantityValue millivolts) { - QuantityValue value = (QuantityValue) millivolts; + double value = (double) millivolts; return new ElectricPotential(value, ElectricPotentialUnit.Millivolt); } @@ -299,7 +296,7 @@ public static ElectricPotential FromMillivolts(QuantityValue millivolts) /// If value is NaN or Infinity. public static ElectricPotential FromVolts(QuantityValue volts) { - QuantityValue value = (QuantityValue) volts; + double value = (double) volts; return new ElectricPotential(value, ElectricPotentialUnit.Volt); } @@ -311,7 +308,7 @@ public static ElectricPotential FromVolts(QuantityValue volts) /// ElectricPotential unit value. public static ElectricPotential From(QuantityValue value, ElectricPotentialUnit fromUnit) { - return new ElectricPotential((QuantityValue)value, fromUnit); + return new ElectricPotential((double)value, fromUnit); } #endregion @@ -481,25 +478,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotential operator *(QuantityValue left, ElectricPotential right) + public static ElectricPotential operator *(double left, ElectricPotential right) { return new ElectricPotential(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotential operator *(ElectricPotential left, QuantityValue right) + public static ElectricPotential operator *(ElectricPotential left, double right) { return new ElectricPotential(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotential operator /(ElectricPotential left, QuantityValue right) + public static ElectricPotential operator /(ElectricPotential left, double right) { return new ElectricPotential(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricPotential left, ElectricPotential right) + public static double operator /(ElectricPotential left, ElectricPotential right) { return left.Volts / right.Volts; } @@ -532,19 +529,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotential left, ElectricPotential right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotential left, ElectricPotential right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -557,29 +541,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotential other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricPotential objElectricPotential)) - return false; - return Equals(objElectricPotential); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotential other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -622,13 +584,13 @@ public bool Equals(ElectricPotential other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotential other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotential other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -639,7 +601,7 @@ public bool Equals(ElectricPotential other, QuantityValue tolerance, ComparisonT /// A hash code for the current ElectricPotential. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -650,16 +612,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricPotentialUnit unit) + public double As(ElectricPotentialUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -674,12 +637,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialUnit typedUnit)) + if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricPotentialUnit); } /// @@ -711,7 +674,7 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (ElectricPotential)converted; } - else if (Enum.IsDefined(typeof(ElectricPotentialUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -719,17 +682,17 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit, UnitConverter unitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialUnit typedUnit)) + if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricPotentialUnit, DefaultConversionFunctions); } /// @@ -756,10 +719,10 @@ public ElectricPotential ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricPotentialUnit unit) + private double GetValueAs(ElectricPotentialUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index bea9b49b8a..fa988ad89a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The Electric Potential of a system known to use Alternating Current. /// [DataContract] - public partial struct ElectricPotentialAc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialAc : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ElectricPotentialAc() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialAc(QuantityValue value, ElectricPotentialAcUnit unit) + public ElectricPotentialAc(double value, ElectricPotentialAcUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -90,14 +90,14 @@ public ElectricPotentialAc(QuantityValue value, ElectricPotentialAcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialAc(QuantityValue value, UnitSystem unitSystem) + public ElectricPotentialAc(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,10 +138,7 @@ public ElectricPotentialAc(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -164,29 +161,29 @@ public ElectricPotentialAc(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); + public double KilovoltsAc => As(ElectricPotentialAcUnit.KilovoltAc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); + public double MegavoltsAc => As(ElectricPotentialAcUnit.MegavoltAc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); + public double MicrovoltsAc => As(ElectricPotentialAcUnit.MicrovoltAc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); + public double MillivoltsAc => As(ElectricPotentialAcUnit.MillivoltAc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsAc => As(ElectricPotentialAcUnit.VoltAc); + public double VoltsAc => As(ElectricPotentialAcUnit.VoltAc); #endregion @@ -254,7 +251,7 @@ public static string GetAbbreviation(ElectricPotentialAcUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricPotentialAc FromKilovoltsAc(QuantityValue kilovoltsac) { - QuantityValue value = (QuantityValue) kilovoltsac; + double value = (double) kilovoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.KilovoltAc); } @@ -264,7 +261,7 @@ public static ElectricPotentialAc FromKilovoltsAc(QuantityValue kilovoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromMegavoltsAc(QuantityValue megavoltsac) { - QuantityValue value = (QuantityValue) megavoltsac; + double value = (double) megavoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MegavoltAc); } @@ -274,7 +271,7 @@ public static ElectricPotentialAc FromMegavoltsAc(QuantityValue megavoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue microvoltsac) { - QuantityValue value = (QuantityValue) microvoltsac; + double value = (double) microvoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MicrovoltAc); } @@ -284,7 +281,7 @@ public static ElectricPotentialAc FromMicrovoltsAc(QuantityValue microvoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromMillivoltsAc(QuantityValue millivoltsac) { - QuantityValue value = (QuantityValue) millivoltsac; + double value = (double) millivoltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.MillivoltAc); } @@ -294,7 +291,7 @@ public static ElectricPotentialAc FromMillivoltsAc(QuantityValue millivoltsac) /// If value is NaN or Infinity. public static ElectricPotentialAc FromVoltsAc(QuantityValue voltsac) { - QuantityValue value = (QuantityValue) voltsac; + double value = (double) voltsac; return new ElectricPotentialAc(value, ElectricPotentialAcUnit.VoltAc); } @@ -306,7 +303,7 @@ public static ElectricPotentialAc FromVoltsAc(QuantityValue voltsac) /// ElectricPotentialAc unit value. public static ElectricPotentialAc From(QuantityValue value, ElectricPotentialAcUnit fromUnit) { - return new ElectricPotentialAc((QuantityValue)value, fromUnit); + return new ElectricPotentialAc((double)value, fromUnit); } #endregion @@ -476,25 +473,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialAc operator *(QuantityValue left, ElectricPotentialAc right) + public static ElectricPotentialAc operator *(double left, ElectricPotentialAc right) { return new ElectricPotentialAc(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialAc operator *(ElectricPotentialAc left, QuantityValue right) + public static ElectricPotentialAc operator *(ElectricPotentialAc left, double right) { return new ElectricPotentialAc(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialAc operator /(ElectricPotentialAc left, QuantityValue right) + public static ElectricPotentialAc operator /(ElectricPotentialAc left, double right) { return new ElectricPotentialAc(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricPotentialAc left, ElectricPotentialAc right) + public static double operator /(ElectricPotentialAc left, ElectricPotentialAc right) { return left.VoltsAc / right.VoltsAc; } @@ -527,19 +524,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialAc left, ElectricPotentialAc right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialAc left, ElectricPotentialAc right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -552,29 +536,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotentialAc other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricPotentialAc objElectricPotentialAc)) - return false; - return Equals(objElectricPotentialAc); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialAc other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -617,13 +579,13 @@ public bool Equals(ElectricPotentialAc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialAc other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -634,7 +596,7 @@ public bool Equals(ElectricPotentialAc other, QuantityValue tolerance, Compariso /// A hash code for the current ElectricPotentialAc. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -645,16 +607,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricPotentialAcUnit unit) + public double As(ElectricPotentialAcUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -669,12 +632,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialAcUnit typedUnit)) + if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricPotentialAcUnit); } /// @@ -706,7 +669,7 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricPotentialAc)converted; } - else if (Enum.IsDefined(typeof(ElectricPotentialAcUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -714,17 +677,17 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialAcUnit typedUnit)) + if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricPotentialAcUnit, DefaultConversionFunctions); } /// @@ -751,10 +714,10 @@ public ElectricPotentialAc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricPotentialAcUnit unit) + private double GetValueAs(ElectricPotentialAcUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index d35fd6041b..9cc91d8d27 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// ElectricPotential change rate is the ratio of the electric potential change to the time during which the change occurred (value of electric potential changes per unit time). /// [DataContract] - public partial struct ElectricPotentialChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -91,9 +91,9 @@ static ElectricPotentialChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialChangeRate(QuantityValue value, ElectricPotentialChangeRateUnit unit) + public ElectricPotentialChangeRate(double value, ElectricPotentialChangeRateUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -105,14 +105,14 @@ public ElectricPotentialChangeRate(QuantityValue value, ElectricPotentialChangeR /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialChangeRate(QuantityValue value, UnitSystem unitSystem) + public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -153,10 +153,7 @@ public ElectricPotentialChangeRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -179,104 +176,104 @@ public ElectricPotentialChangeRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); + public double KilovoltsPerHours => As(ElectricPotentialChangeRateUnit.KilovoltPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); + public double KilovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); + public double KilovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.KilovoltPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); + public double KilovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.KilovoltPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); + public double MegavoltsPerHours => As(ElectricPotentialChangeRateUnit.MegavoltPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); + public double MegavoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); + public double MegavoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MegavoltPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); + public double MegavoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MegavoltPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); + public double MicrovoltsPerHours => As(ElectricPotentialChangeRateUnit.MicrovoltPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); + public double MicrovoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); + public double MicrovoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MicrovoltPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); + public double MicrovoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MicrovoltPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); + public double MillivoltsPerHours => As(ElectricPotentialChangeRateUnit.MillivoltPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); + public double MillivoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); + public double MillivoltsPerMinutes => As(ElectricPotentialChangeRateUnit.MillivoltPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); + public double MillivoltsPerSeconds => As(ElectricPotentialChangeRateUnit.MillivoltPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); + public double VoltsPerHours => As(ElectricPotentialChangeRateUnit.VoltPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); + public double VoltsPerMicroseconds => As(ElectricPotentialChangeRateUnit.VoltPerMicrosecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); + public double VoltsPerMinutes => As(ElectricPotentialChangeRateUnit.VoltPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); + public double VoltsPerSeconds => As(ElectricPotentialChangeRateUnit.VoltPerSecond); #endregion @@ -389,7 +386,7 @@ public static string GetAbbreviation(ElectricPotentialChangeRateUnit unit, IForm /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerHours(QuantityValue kilovoltsperhours) { - QuantityValue value = (QuantityValue) kilovoltsperhours; + double value = (double) kilovoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerHour); } @@ -399,7 +396,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerHours(QuantityValue ki /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(QuantityValue kilovoltspermicroseconds) { - QuantityValue value = (QuantityValue) kilovoltspermicroseconds; + double value = (double) kilovoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMicrosecond); } @@ -409,7 +406,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerMicroseconds(QuantityV /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(QuantityValue kilovoltsperminutes) { - QuantityValue value = (QuantityValue) kilovoltsperminutes; + double value = (double) kilovoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerMinute); } @@ -419,7 +416,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(QuantityValue kilovoltsperseconds) { - QuantityValue value = (QuantityValue) kilovoltsperseconds; + double value = (double) kilovoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.KilovoltPerSecond); } @@ -429,7 +426,7 @@ public static ElectricPotentialChangeRate FromKilovoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerHours(QuantityValue megavoltsperhours) { - QuantityValue value = (QuantityValue) megavoltsperhours; + double value = (double) megavoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerHour); } @@ -439,7 +436,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerHours(QuantityValue me /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(QuantityValue megavoltspermicroseconds) { - QuantityValue value = (QuantityValue) megavoltspermicroseconds; + double value = (double) megavoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMicrosecond); } @@ -449,7 +446,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerMicroseconds(QuantityV /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(QuantityValue megavoltsperminutes) { - QuantityValue value = (QuantityValue) megavoltsperminutes; + double value = (double) megavoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerMinute); } @@ -459,7 +456,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(QuantityValue megavoltsperseconds) { - QuantityValue value = (QuantityValue) megavoltsperseconds; + double value = (double) megavoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MegavoltPerSecond); } @@ -469,7 +466,7 @@ public static ElectricPotentialChangeRate FromMegavoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerHours(QuantityValue microvoltsperhours) { - QuantityValue value = (QuantityValue) microvoltsperhours; + double value = (double) microvoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerHour); } @@ -479,7 +476,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerHours(QuantityValue m /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(QuantityValue microvoltspermicroseconds) { - QuantityValue value = (QuantityValue) microvoltspermicroseconds; + double value = (double) microvoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMicrosecond); } @@ -489,7 +486,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerMicroseconds(Quantity /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(QuantityValue microvoltsperminutes) { - QuantityValue value = (QuantityValue) microvoltsperminutes; + double value = (double) microvoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerMinute); } @@ -499,7 +496,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(QuantityValue microvoltsperseconds) { - QuantityValue value = (QuantityValue) microvoltsperseconds; + double value = (double) microvoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MicrovoltPerSecond); } @@ -509,7 +506,7 @@ public static ElectricPotentialChangeRate FromMicrovoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerHours(QuantityValue millivoltsperhours) { - QuantityValue value = (QuantityValue) millivoltsperhours; + double value = (double) millivoltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerHour); } @@ -519,7 +516,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerHours(QuantityValue m /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(QuantityValue millivoltspermicroseconds) { - QuantityValue value = (QuantityValue) millivoltspermicroseconds; + double value = (double) millivoltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMicrosecond); } @@ -529,7 +526,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerMicroseconds(Quantity /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(QuantityValue millivoltsperminutes) { - QuantityValue value = (QuantityValue) millivoltsperminutes; + double value = (double) millivoltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerMinute); } @@ -539,7 +536,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerMinutes(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(QuantityValue millivoltsperseconds) { - QuantityValue value = (QuantityValue) millivoltsperseconds; + double value = (double) millivoltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.MillivoltPerSecond); } @@ -549,7 +546,7 @@ public static ElectricPotentialChangeRate FromMillivoltsPerSeconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerHours(QuantityValue voltsperhours) { - QuantityValue value = (QuantityValue) voltsperhours; + double value = (double) voltsperhours; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerHour); } @@ -559,7 +556,7 @@ public static ElectricPotentialChangeRate FromVoltsPerHours(QuantityValue voltsp /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(QuantityValue voltspermicroseconds) { - QuantityValue value = (QuantityValue) voltspermicroseconds; + double value = (double) voltspermicroseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMicrosecond); } @@ -569,7 +566,7 @@ public static ElectricPotentialChangeRate FromVoltsPerMicroseconds(QuantityValue /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerMinutes(QuantityValue voltsperminutes) { - QuantityValue value = (QuantityValue) voltsperminutes; + double value = (double) voltsperminutes; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerMinute); } @@ -579,7 +576,7 @@ public static ElectricPotentialChangeRate FromVoltsPerMinutes(QuantityValue volt /// If value is NaN or Infinity. public static ElectricPotentialChangeRate FromVoltsPerSeconds(QuantityValue voltsperseconds) { - QuantityValue value = (QuantityValue) voltsperseconds; + double value = (double) voltsperseconds; return new ElectricPotentialChangeRate(value, ElectricPotentialChangeRateUnit.VoltPerSecond); } @@ -591,7 +588,7 @@ public static ElectricPotentialChangeRate FromVoltsPerSeconds(QuantityValue volt /// ElectricPotentialChangeRate unit value. public static ElectricPotentialChangeRate From(QuantityValue value, ElectricPotentialChangeRateUnit fromUnit) { - return new ElectricPotentialChangeRate((QuantityValue)value, fromUnit); + return new ElectricPotentialChangeRate((double)value, fromUnit); } #endregion @@ -761,25 +758,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(QuantityValue left, ElectricPotentialChangeRate right) + public static ElectricPotentialChangeRate operator *(double left, ElectricPotentialChangeRate right) { return new ElectricPotentialChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, QuantityValue right) + public static ElectricPotentialChangeRate operator *(ElectricPotentialChangeRate left, double right) { return new ElectricPotentialChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, QuantityValue right) + public static ElectricPotentialChangeRate operator /(ElectricPotentialChangeRate left, double right) { return new ElectricPotentialChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) + public static double operator /(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) { return left.VoltsPerSeconds / right.VoltsPerSeconds; } @@ -812,19 +809,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialChangeRate left, ElectricPotentialChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -837,29 +821,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotentialChangeRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricPotentialChangeRate objElectricPotentialChangeRate)) - return false; - return Equals(objElectricPotentialChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialChangeRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -902,13 +864,13 @@ public bool Equals(ElectricPotentialChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -919,7 +881,7 @@ public bool Equals(ElectricPotentialChangeRate other, QuantityValue tolerance, C /// A hash code for the current ElectricPotentialChangeRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -930,16 +892,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricPotentialChangeRateUnit unit) + public double As(ElectricPotentialChangeRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -954,12 +917,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) + if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricPotentialChangeRateUnit); } /// @@ -991,7 +954,7 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit, var converted = conversionFunction(this); return (ElectricPotentialChangeRate)converted; } - else if (Enum.IsDefined(typeof(ElectricPotentialChangeRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -999,17 +962,17 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit, } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) + if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricPotentialChangeRateUnit, DefaultConversionFunctions); } /// @@ -1036,10 +999,10 @@ public ElectricPotentialChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricPotentialChangeRateUnit unit) + private double GetValueAs(ElectricPotentialChangeRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 5f73469a2c..787d8e5f5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The Electric Potential of a system known to use Direct Current. /// [DataContract] - public partial struct ElectricPotentialDc : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricPotentialDc : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ElectricPotentialDc() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricPotentialDc(QuantityValue value, ElectricPotentialDcUnit unit) + public ElectricPotentialDc(double value, ElectricPotentialDcUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -90,14 +90,14 @@ public ElectricPotentialDc(QuantityValue value, ElectricPotentialDcUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricPotentialDc(QuantityValue value, UnitSystem unitSystem) + public ElectricPotentialDc(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,10 +138,7 @@ public ElectricPotentialDc(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -164,29 +161,29 @@ public ElectricPotentialDc(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); + public double KilovoltsDc => As(ElectricPotentialDcUnit.KilovoltDc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); + public double MegavoltsDc => As(ElectricPotentialDcUnit.MegavoltDc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); + public double MicrovoltsDc => As(ElectricPotentialDcUnit.MicrovoltDc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); + public double MillivoltsDc => As(ElectricPotentialDcUnit.MillivoltDc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltsDc => As(ElectricPotentialDcUnit.VoltDc); + public double VoltsDc => As(ElectricPotentialDcUnit.VoltDc); #endregion @@ -254,7 +251,7 @@ public static string GetAbbreviation(ElectricPotentialDcUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricPotentialDc FromKilovoltsDc(QuantityValue kilovoltsdc) { - QuantityValue value = (QuantityValue) kilovoltsdc; + double value = (double) kilovoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.KilovoltDc); } @@ -264,7 +261,7 @@ public static ElectricPotentialDc FromKilovoltsDc(QuantityValue kilovoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromMegavoltsDc(QuantityValue megavoltsdc) { - QuantityValue value = (QuantityValue) megavoltsdc; + double value = (double) megavoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MegavoltDc); } @@ -274,7 +271,7 @@ public static ElectricPotentialDc FromMegavoltsDc(QuantityValue megavoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue microvoltsdc) { - QuantityValue value = (QuantityValue) microvoltsdc; + double value = (double) microvoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MicrovoltDc); } @@ -284,7 +281,7 @@ public static ElectricPotentialDc FromMicrovoltsDc(QuantityValue microvoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromMillivoltsDc(QuantityValue millivoltsdc) { - QuantityValue value = (QuantityValue) millivoltsdc; + double value = (double) millivoltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.MillivoltDc); } @@ -294,7 +291,7 @@ public static ElectricPotentialDc FromMillivoltsDc(QuantityValue millivoltsdc) /// If value is NaN or Infinity. public static ElectricPotentialDc FromVoltsDc(QuantityValue voltsdc) { - QuantityValue value = (QuantityValue) voltsdc; + double value = (double) voltsdc; return new ElectricPotentialDc(value, ElectricPotentialDcUnit.VoltDc); } @@ -306,7 +303,7 @@ public static ElectricPotentialDc FromVoltsDc(QuantityValue voltsdc) /// ElectricPotentialDc unit value. public static ElectricPotentialDc From(QuantityValue value, ElectricPotentialDcUnit fromUnit) { - return new ElectricPotentialDc((QuantityValue)value, fromUnit); + return new ElectricPotentialDc((double)value, fromUnit); } #endregion @@ -476,25 +473,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricPotentialDc operator *(QuantityValue left, ElectricPotentialDc right) + public static ElectricPotentialDc operator *(double left, ElectricPotentialDc right) { return new ElectricPotentialDc(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricPotentialDc operator *(ElectricPotentialDc left, QuantityValue right) + public static ElectricPotentialDc operator *(ElectricPotentialDc left, double right) { return new ElectricPotentialDc(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricPotentialDc operator /(ElectricPotentialDc left, QuantityValue right) + public static ElectricPotentialDc operator /(ElectricPotentialDc left, double right) { return new ElectricPotentialDc(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricPotentialDc left, ElectricPotentialDc right) + public static double operator /(ElectricPotentialDc left, ElectricPotentialDc right) { return left.VoltsDc / right.VoltsDc; } @@ -527,19 +524,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricPotentialDc left, ElectricPotentialDc right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricPotentialDc left, ElectricPotentialDc right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -552,29 +536,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricPotentialDc other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricPotentialDc objElectricPotentialDc)) - return false; - return Equals(objElectricPotentialDc); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricPotentialDc other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -617,13 +579,13 @@ public bool Equals(ElectricPotentialDc other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricPotentialDc other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -634,7 +596,7 @@ public bool Equals(ElectricPotentialDc other, QuantityValue tolerance, Compariso /// A hash code for the current ElectricPotentialDc. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -645,16 +607,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricPotentialDcUnit unit) + public double As(ElectricPotentialDcUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -669,12 +632,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialDcUnit typedUnit)) + if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricPotentialDcUnit); } /// @@ -706,7 +669,7 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricPotentialDc)converted; } - else if (Enum.IsDefined(typeof(ElectricPotentialDcUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -714,17 +677,17 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialDcUnit typedUnit)) + if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricPotentialDcUnit, DefaultConversionFunctions); } /// @@ -751,10 +714,10 @@ public ElectricPotentialDc ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricPotentialDcUnit unit) + private double GetValueAs(ElectricPotentialDcUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index a90307d171..29810c8529 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The electrical resistance of an electrical conductor is the opposition to the passage of an electric current through that conductor. /// [DataContract] - public partial struct ElectricResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricResistance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricResistance(QuantityValue value, ElectricResistanceUnit unit) + public ElectricResistance(double value, ElectricResistanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public ElectricResistance(QuantityValue value, ElectricResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistance(QuantityValue value, UnitSystem unitSystem) + public ElectricResistance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public ElectricResistance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,34 +162,34 @@ public ElectricResistance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigaohms => As(ElectricResistanceUnit.Gigaohm); + public double Gigaohms => As(ElectricResistanceUnit.Gigaohm); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kiloohms => As(ElectricResistanceUnit.Kiloohm); + public double Kiloohms => As(ElectricResistanceUnit.Kiloohm); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megaohms => As(ElectricResistanceUnit.Megaohm); + public double Megaohms => As(ElectricResistanceUnit.Megaohm); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microohms => As(ElectricResistanceUnit.Microohm); + public double Microohms => As(ElectricResistanceUnit.Microohm); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliohms => As(ElectricResistanceUnit.Milliohm); + public double Milliohms => As(ElectricResistanceUnit.Milliohm); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Ohms => As(ElectricResistanceUnit.Ohm); + public double Ohms => As(ElectricResistanceUnit.Ohm); #endregion @@ -263,7 +260,7 @@ public static string GetAbbreviation(ElectricResistanceUnit unit, IFormatProvide /// If value is NaN or Infinity. public static ElectricResistance FromGigaohms(QuantityValue gigaohms) { - QuantityValue value = (QuantityValue) gigaohms; + double value = (double) gigaohms; return new ElectricResistance(value, ElectricResistanceUnit.Gigaohm); } @@ -273,7 +270,7 @@ public static ElectricResistance FromGigaohms(QuantityValue gigaohms) /// If value is NaN or Infinity. public static ElectricResistance FromKiloohms(QuantityValue kiloohms) { - QuantityValue value = (QuantityValue) kiloohms; + double value = (double) kiloohms; return new ElectricResistance(value, ElectricResistanceUnit.Kiloohm); } @@ -283,7 +280,7 @@ public static ElectricResistance FromKiloohms(QuantityValue kiloohms) /// If value is NaN or Infinity. public static ElectricResistance FromMegaohms(QuantityValue megaohms) { - QuantityValue value = (QuantityValue) megaohms; + double value = (double) megaohms; return new ElectricResistance(value, ElectricResistanceUnit.Megaohm); } @@ -293,7 +290,7 @@ public static ElectricResistance FromMegaohms(QuantityValue megaohms) /// If value is NaN or Infinity. public static ElectricResistance FromMicroohms(QuantityValue microohms) { - QuantityValue value = (QuantityValue) microohms; + double value = (double) microohms; return new ElectricResistance(value, ElectricResistanceUnit.Microohm); } @@ -303,7 +300,7 @@ public static ElectricResistance FromMicroohms(QuantityValue microohms) /// If value is NaN or Infinity. public static ElectricResistance FromMilliohms(QuantityValue milliohms) { - QuantityValue value = (QuantityValue) milliohms; + double value = (double) milliohms; return new ElectricResistance(value, ElectricResistanceUnit.Milliohm); } @@ -313,7 +310,7 @@ public static ElectricResistance FromMilliohms(QuantityValue milliohms) /// If value is NaN or Infinity. public static ElectricResistance FromOhms(QuantityValue ohms) { - QuantityValue value = (QuantityValue) ohms; + double value = (double) ohms; return new ElectricResistance(value, ElectricResistanceUnit.Ohm); } @@ -325,7 +322,7 @@ public static ElectricResistance FromOhms(QuantityValue ohms) /// ElectricResistance unit value. public static ElectricResistance From(QuantityValue value, ElectricResistanceUnit fromUnit) { - return new ElectricResistance((QuantityValue)value, fromUnit); + return new ElectricResistance((double)value, fromUnit); } #endregion @@ -495,25 +492,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricResistance operator *(QuantityValue left, ElectricResistance right) + public static ElectricResistance operator *(double left, ElectricResistance right) { return new ElectricResistance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricResistance operator *(ElectricResistance left, QuantityValue right) + public static ElectricResistance operator *(ElectricResistance left, double right) { return new ElectricResistance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricResistance operator /(ElectricResistance left, QuantityValue right) + public static ElectricResistance operator /(ElectricResistance left, double right) { return new ElectricResistance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricResistance left, ElectricResistance right) + public static double operator /(ElectricResistance left, ElectricResistance right) { return left.Ohms / right.Ohms; } @@ -546,19 +543,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistance left, ElectricResistance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistance left, ElectricResistance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -571,29 +555,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricResistance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricResistance objElectricResistance)) - return false; - return Equals(objElectricResistance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -636,13 +598,13 @@ public bool Equals(ElectricResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricResistance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -653,7 +615,7 @@ public bool Equals(ElectricResistance other, QuantityValue tolerance, Comparison /// A hash code for the current ElectricResistance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -664,16 +626,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricResistanceUnit unit) + public double As(ElectricResistanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -688,12 +651,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricResistanceUnit typedUnit)) + if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricResistanceUnit); } /// @@ -725,7 +688,7 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit, UnitConverter unit var converted = conversionFunction(this); return (ElectricResistance)converted; } - else if (Enum.IsDefined(typeof(ElectricResistanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -733,17 +696,17 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistanceUnit typedUnit)) + if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricResistanceUnit, DefaultConversionFunctions); } /// @@ -770,10 +733,10 @@ public ElectricResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricResistanceUnit unit) + private double GetValueAs(ElectricResistanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 4fb77ebee4..9fa380d492 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Electrical_resistivity_and_conductivity /// [DataContract] - public partial struct ElectricResistivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricResistivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -88,9 +88,9 @@ static ElectricResistivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricResistivity(QuantityValue value, ElectricResistivityUnit unit) + public ElectricResistivity(double value, ElectricResistivityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -102,14 +102,14 @@ public ElectricResistivity(QuantityValue value, ElectricResistivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricResistivity(QuantityValue value, UnitSystem unitSystem) + public ElectricResistivity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -150,10 +150,7 @@ public ElectricResistivity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -176,74 +173,74 @@ public ElectricResistivity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); + public double KiloohmsCentimeter => As(ElectricResistivityUnit.KiloohmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); + public double KiloohmMeters => As(ElectricResistivityUnit.KiloohmMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); + public double MegaohmsCentimeter => As(ElectricResistivityUnit.MegaohmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); + public double MegaohmMeters => As(ElectricResistivityUnit.MegaohmMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); + public double MicroohmsCentimeter => As(ElectricResistivityUnit.MicroohmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); + public double MicroohmMeters => As(ElectricResistivityUnit.MicroohmMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); + public double MilliohmsCentimeter => As(ElectricResistivityUnit.MilliohmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); + public double MilliohmMeters => As(ElectricResistivityUnit.MilliohmMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); + public double NanoohmsCentimeter => As(ElectricResistivityUnit.NanoohmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); + public double NanoohmMeters => As(ElectricResistivityUnit.NanoohmMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); + public double OhmsCentimeter => As(ElectricResistivityUnit.OhmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OhmMeters => As(ElectricResistivityUnit.OhmMeter); + public double OhmMeters => As(ElectricResistivityUnit.OhmMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); + public double PicoohmsCentimeter => As(ElectricResistivityUnit.PicoohmCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); + public double PicoohmMeters => As(ElectricResistivityUnit.PicoohmMeter); #endregion @@ -338,7 +335,7 @@ public static string GetAbbreviation(ElectricResistivityUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ElectricResistivity FromKiloohmsCentimeter(QuantityValue kiloohmscentimeter) { - QuantityValue value = (QuantityValue) kiloohmscentimeter; + double value = (double) kiloohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmCentimeter); } @@ -348,7 +345,7 @@ public static ElectricResistivity FromKiloohmsCentimeter(QuantityValue kiloohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromKiloohmMeters(QuantityValue kiloohmmeters) { - QuantityValue value = (QuantityValue) kiloohmmeters; + double value = (double) kiloohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.KiloohmMeter); } @@ -358,7 +355,7 @@ public static ElectricResistivity FromKiloohmMeters(QuantityValue kiloohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromMegaohmsCentimeter(QuantityValue megaohmscentimeter) { - QuantityValue value = (QuantityValue) megaohmscentimeter; + double value = (double) megaohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmCentimeter); } @@ -368,7 +365,7 @@ public static ElectricResistivity FromMegaohmsCentimeter(QuantityValue megaohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromMegaohmMeters(QuantityValue megaohmmeters) { - QuantityValue value = (QuantityValue) megaohmmeters; + double value = (double) megaohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.MegaohmMeter); } @@ -378,7 +375,7 @@ public static ElectricResistivity FromMegaohmMeters(QuantityValue megaohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromMicroohmsCentimeter(QuantityValue microohmscentimeter) { - QuantityValue value = (QuantityValue) microohmscentimeter; + double value = (double) microohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmCentimeter); } @@ -388,7 +385,7 @@ public static ElectricResistivity FromMicroohmsCentimeter(QuantityValue microohm /// If value is NaN or Infinity. public static ElectricResistivity FromMicroohmMeters(QuantityValue microohmmeters) { - QuantityValue value = (QuantityValue) microohmmeters; + double value = (double) microohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.MicroohmMeter); } @@ -398,7 +395,7 @@ public static ElectricResistivity FromMicroohmMeters(QuantityValue microohmmeter /// If value is NaN or Infinity. public static ElectricResistivity FromMilliohmsCentimeter(QuantityValue milliohmscentimeter) { - QuantityValue value = (QuantityValue) milliohmscentimeter; + double value = (double) milliohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmCentimeter); } @@ -408,7 +405,7 @@ public static ElectricResistivity FromMilliohmsCentimeter(QuantityValue milliohm /// If value is NaN or Infinity. public static ElectricResistivity FromMilliohmMeters(QuantityValue milliohmmeters) { - QuantityValue value = (QuantityValue) milliohmmeters; + double value = (double) milliohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.MilliohmMeter); } @@ -418,7 +415,7 @@ public static ElectricResistivity FromMilliohmMeters(QuantityValue milliohmmeter /// If value is NaN or Infinity. public static ElectricResistivity FromNanoohmsCentimeter(QuantityValue nanoohmscentimeter) { - QuantityValue value = (QuantityValue) nanoohmscentimeter; + double value = (double) nanoohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmCentimeter); } @@ -428,7 +425,7 @@ public static ElectricResistivity FromNanoohmsCentimeter(QuantityValue nanoohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromNanoohmMeters(QuantityValue nanoohmmeters) { - QuantityValue value = (QuantityValue) nanoohmmeters; + double value = (double) nanoohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.NanoohmMeter); } @@ -438,7 +435,7 @@ public static ElectricResistivity FromNanoohmMeters(QuantityValue nanoohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromOhmsCentimeter(QuantityValue ohmscentimeter) { - QuantityValue value = (QuantityValue) ohmscentimeter; + double value = (double) ohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.OhmCentimeter); } @@ -448,7 +445,7 @@ public static ElectricResistivity FromOhmsCentimeter(QuantityValue ohmscentimete /// If value is NaN or Infinity. public static ElectricResistivity FromOhmMeters(QuantityValue ohmmeters) { - QuantityValue value = (QuantityValue) ohmmeters; + double value = (double) ohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.OhmMeter); } @@ -458,7 +455,7 @@ public static ElectricResistivity FromOhmMeters(QuantityValue ohmmeters) /// If value is NaN or Infinity. public static ElectricResistivity FromPicoohmsCentimeter(QuantityValue picoohmscentimeter) { - QuantityValue value = (QuantityValue) picoohmscentimeter; + double value = (double) picoohmscentimeter; return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmCentimeter); } @@ -468,7 +465,7 @@ public static ElectricResistivity FromPicoohmsCentimeter(QuantityValue picoohmsc /// If value is NaN or Infinity. public static ElectricResistivity FromPicoohmMeters(QuantityValue picoohmmeters) { - QuantityValue value = (QuantityValue) picoohmmeters; + double value = (double) picoohmmeters; return new ElectricResistivity(value, ElectricResistivityUnit.PicoohmMeter); } @@ -480,7 +477,7 @@ public static ElectricResistivity FromPicoohmMeters(QuantityValue picoohmmeters) /// ElectricResistivity unit value. public static ElectricResistivity From(QuantityValue value, ElectricResistivityUnit fromUnit) { - return new ElectricResistivity((QuantityValue)value, fromUnit); + return new ElectricResistivity((double)value, fromUnit); } #endregion @@ -650,25 +647,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricResistivity operator *(QuantityValue left, ElectricResistivity right) + public static ElectricResistivity operator *(double left, ElectricResistivity right) { return new ElectricResistivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricResistivity operator *(ElectricResistivity left, QuantityValue right) + public static ElectricResistivity operator *(ElectricResistivity left, double right) { return new ElectricResistivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricResistivity operator /(ElectricResistivity left, QuantityValue right) + public static ElectricResistivity operator /(ElectricResistivity left, double right) { return new ElectricResistivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricResistivity left, ElectricResistivity right) + public static double operator /(ElectricResistivity left, ElectricResistivity right) { return left.OhmMeters / right.OhmMeters; } @@ -701,19 +698,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricResistivity left, ElectricResistivity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricResistivity left, ElectricResistivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -726,29 +710,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricResistivity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricResistivity objElectricResistivity)) - return false; - return Equals(objElectricResistivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricResistivity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -791,13 +753,13 @@ public bool Equals(ElectricResistivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricResistivity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricResistivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -808,7 +770,7 @@ public bool Equals(ElectricResistivity other, QuantityValue tolerance, Compariso /// A hash code for the current ElectricResistivity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -819,16 +781,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricResistivityUnit unit) + public double As(ElectricResistivityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -843,12 +806,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricResistivityUnit typedUnit)) + if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricResistivityUnit); } /// @@ -880,7 +843,7 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit, UnitConverter un var converted = conversionFunction(this); return (ElectricResistivity)converted; } - else if (Enum.IsDefined(typeof(ElectricResistivityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -888,17 +851,17 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistivityUnit typedUnit)) + if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricResistivityUnit, DefaultConversionFunctions); } /// @@ -925,10 +888,10 @@ public ElectricResistivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricResistivityUnit unit) + private double GetValueAs(ElectricResistivityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index 39a5166bad..a5e94ca602 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Charge_density /// [DataContract] - public partial struct ElectricSurfaceChargeDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ElectricSurfaceChargeDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ElectricSurfaceChargeDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ElectricSurfaceChargeDensity(QuantityValue value, ElectricSurfaceChargeDensityUnit unit) + public ElectricSurfaceChargeDensity(double value, ElectricSurfaceChargeDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public ElectricSurfaceChargeDensity(QuantityValue value, ElectricSurfaceChargeDe /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ElectricSurfaceChargeDensity(QuantityValue value, UnitSystem unitSystem) + public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public ElectricSurfaceChargeDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,19 +162,19 @@ public ElectricSurfaceChargeDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); + public double CoulombsPerSquareCentimeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); + public double CoulombsPerSquareInch => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); + public double CoulombsPerSquareMeter => As(ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); #endregion @@ -239,7 +236,7 @@ public static string GetAbbreviation(ElectricSurfaceChargeDensityUnit unit, IFor /// If value is NaN or Infinity. public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(QuantityValue coulombspersquarecentimeter) { - QuantityValue value = (QuantityValue) coulombspersquarecentimeter; + double value = (double) coulombspersquarecentimeter; return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareCentimeter); } @@ -249,7 +246,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareCentimeter(Quant /// If value is NaN or Infinity. public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(QuantityValue coulombspersquareinch) { - QuantityValue value = (QuantityValue) coulombspersquareinch; + double value = (double) coulombspersquareinch; return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareInch); } @@ -259,7 +256,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareInch(QuantityVal /// If value is NaN or Infinity. public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(QuantityValue coulombspersquaremeter) { - QuantityValue value = (QuantityValue) coulombspersquaremeter; + double value = (double) coulombspersquaremeter; return new ElectricSurfaceChargeDensity(value, ElectricSurfaceChargeDensityUnit.CoulombPerSquareMeter); } @@ -271,7 +268,7 @@ public static ElectricSurfaceChargeDensity FromCoulombsPerSquareMeter(QuantityVa /// ElectricSurfaceChargeDensity unit value. public static ElectricSurfaceChargeDensity From(QuantityValue value, ElectricSurfaceChargeDensityUnit fromUnit) { - return new ElectricSurfaceChargeDensity((QuantityValue)value, fromUnit); + return new ElectricSurfaceChargeDensity((double)value, fromUnit); } #endregion @@ -441,25 +438,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect } /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(QuantityValue left, ElectricSurfaceChargeDensity right) + public static ElectricSurfaceChargeDensity operator *(double left, ElectricSurfaceChargeDensity right) { return new ElectricSurfaceChargeDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, QuantityValue right) + public static ElectricSurfaceChargeDensity operator *(ElectricSurfaceChargeDensity left, double right) { return new ElectricSurfaceChargeDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, QuantityValue right) + public static ElectricSurfaceChargeDensity operator /(ElectricSurfaceChargeDensity left, double right) { return new ElectricSurfaceChargeDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) + public static double operator /(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) { return left.CoulombsPerSquareMeter / right.CoulombsPerSquareMeter; } @@ -492,19 +489,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Elect return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ElectricSurfaceChargeDensity left, ElectricSurfaceChargeDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -517,29 +501,7 @@ public int CompareTo(object obj) /// public int CompareTo(ElectricSurfaceChargeDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ElectricSurfaceChargeDensity objElectricSurfaceChargeDensity)) - return false; - return Equals(objElectricSurfaceChargeDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ElectricSurfaceChargeDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -582,13 +544,13 @@ public bool Equals(ElectricSurfaceChargeDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ElectricSurfaceChargeDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -599,7 +561,7 @@ public bool Equals(ElectricSurfaceChargeDensity other, QuantityValue tolerance, /// A hash code for the current ElectricSurfaceChargeDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -610,16 +572,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ElectricSurfaceChargeDensityUnit unit) + public double As(ElectricSurfaceChargeDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -634,12 +597,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsElectricSurfaceChargeDensityUnit); } /// @@ -671,7 +634,7 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit var converted = conversionFunction(this); return (ElectricSurfaceChargeDensity)converted; } - else if (Enum.IsDefined(typeof(ElectricSurfaceChargeDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -679,17 +642,17 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsElectricSurfaceChargeDensityUnit, DefaultConversionFunctions); } /// @@ -716,10 +679,10 @@ public ElectricSurfaceChargeDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ElectricSurfaceChargeDensityUnit unit) + private double GetValueAs(ElectricSurfaceChargeDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index 60e31f0113..d8d04ae1af 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The joule, symbol J, is a derived unit of energy, work, or amount of heat in the International System of Units. It is equal to the energy transferred (or work done) when applying a force of one newton through a distance of one metre (1 newton metre or N·m), or in passing an electric current of one ampere through a resistance of one ohm for one second. Many other units of energy are included. Please do not confuse this definition of the calorie with the one colloquially used by the food industry, the large calorie, which is equivalent to 1 kcal. Thermochemical definition of the calorie is used. For BTU, the IT definition is used. /// [DataContract] - public partial struct Energy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Energy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -107,9 +107,9 @@ static Energy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Energy(QuantityValue value, EnergyUnit unit) + public Energy(double value, EnergyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,14 +121,14 @@ public Energy(QuantityValue value, EnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Energy(QuantityValue value, UnitSystem unitSystem) + public Energy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -169,10 +169,7 @@ public Energy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -195,184 +192,184 @@ public Energy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); + public double BritishThermalUnits => As(EnergyUnit.BritishThermalUnit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Calories => As(EnergyUnit.Calorie); + public double Calories => As(EnergyUnit.Calorie); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecathermsEc => As(EnergyUnit.DecathermEc); + public double DecathermsEc => As(EnergyUnit.DecathermEc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecathermsImperial => As(EnergyUnit.DecathermImperial); + public double DecathermsImperial => As(EnergyUnit.DecathermImperial); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecathermsUs => As(EnergyUnit.DecathermUs); + public double DecathermsUs => As(EnergyUnit.DecathermUs); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ElectronVolts => As(EnergyUnit.ElectronVolt); + public double ElectronVolts => As(EnergyUnit.ElectronVolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Ergs => As(EnergyUnit.Erg); + public double Ergs => As(EnergyUnit.Erg); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FootPounds => As(EnergyUnit.FootPound); + public double FootPounds => As(EnergyUnit.FootPound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); + public double GigabritishThermalUnits => As(EnergyUnit.GigabritishThermalUnit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); + public double GigaelectronVolts => As(EnergyUnit.GigaelectronVolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigajoules => As(EnergyUnit.Gigajoule); + public double Gigajoules => As(EnergyUnit.Gigajoule); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattDays => As(EnergyUnit.GigawattDay); + public double GigawattDays => As(EnergyUnit.GigawattDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattHours => As(EnergyUnit.GigawattHour); + public double GigawattHours => As(EnergyUnit.GigawattHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HorsepowerHours => As(EnergyUnit.HorsepowerHour); + public double HorsepowerHours => As(EnergyUnit.HorsepowerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Joules => As(EnergyUnit.Joule); + public double Joules => As(EnergyUnit.Joule); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); + public double KilobritishThermalUnits => As(EnergyUnit.KilobritishThermalUnit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilocalories => As(EnergyUnit.Kilocalorie); + public double Kilocalories => As(EnergyUnit.Kilocalorie); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); + public double KiloelectronVolts => As(EnergyUnit.KiloelectronVolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilojoules => As(EnergyUnit.Kilojoule); + public double Kilojoules => As(EnergyUnit.Kilojoule); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattDays => As(EnergyUnit.KilowattDay); + public double KilowattDays => As(EnergyUnit.KilowattDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattHours => As(EnergyUnit.KilowattHour); + public double KilowattHours => As(EnergyUnit.KilowattHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); + public double MegabritishThermalUnits => As(EnergyUnit.MegabritishThermalUnit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megacalories => As(EnergyUnit.Megacalorie); + public double Megacalories => As(EnergyUnit.Megacalorie); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); + public double MegaelectronVolts => As(EnergyUnit.MegaelectronVolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megajoules => As(EnergyUnit.Megajoule); + public double Megajoules => As(EnergyUnit.Megajoule); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattDays => As(EnergyUnit.MegawattDay); + public double MegawattDays => As(EnergyUnit.MegawattDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattHours => As(EnergyUnit.MegawattHour); + public double MegawattHours => As(EnergyUnit.MegawattHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millijoules => As(EnergyUnit.Millijoule); + public double Millijoules => As(EnergyUnit.Millijoule); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); + public double TeraelectronVolts => As(EnergyUnit.TeraelectronVolt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattDays => As(EnergyUnit.TerawattDay); + public double TerawattDays => As(EnergyUnit.TerawattDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattHours => As(EnergyUnit.TerawattHour); + public double TerawattHours => As(EnergyUnit.TerawattHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ThermsEc => As(EnergyUnit.ThermEc); + public double ThermsEc => As(EnergyUnit.ThermEc); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ThermsImperial => As(EnergyUnit.ThermImperial); + public double ThermsImperial => As(EnergyUnit.ThermImperial); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ThermsUs => As(EnergyUnit.ThermUs); + public double ThermsUs => As(EnergyUnit.ThermUs); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattDays => As(EnergyUnit.WattDay); + public double WattDays => As(EnergyUnit.WattDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattHours => As(EnergyUnit.WattHour); + public double WattHours => As(EnergyUnit.WattHour); #endregion @@ -554,7 +551,7 @@ public static string GetAbbreviation(EnergyUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Energy FromBritishThermalUnits(QuantityValue britishthermalunits) { - QuantityValue value = (QuantityValue) britishthermalunits; + double value = (double) britishthermalunits; return new Energy(value, EnergyUnit.BritishThermalUnit); } @@ -564,7 +561,7 @@ public static Energy FromBritishThermalUnits(QuantityValue britishthermalunits) /// If value is NaN or Infinity. public static Energy FromCalories(QuantityValue calories) { - QuantityValue value = (QuantityValue) calories; + double value = (double) calories; return new Energy(value, EnergyUnit.Calorie); } @@ -574,7 +571,7 @@ public static Energy FromCalories(QuantityValue calories) /// If value is NaN or Infinity. public static Energy FromDecathermsEc(QuantityValue decathermsec) { - QuantityValue value = (QuantityValue) decathermsec; + double value = (double) decathermsec; return new Energy(value, EnergyUnit.DecathermEc); } @@ -584,7 +581,7 @@ public static Energy FromDecathermsEc(QuantityValue decathermsec) /// If value is NaN or Infinity. public static Energy FromDecathermsImperial(QuantityValue decathermsimperial) { - QuantityValue value = (QuantityValue) decathermsimperial; + double value = (double) decathermsimperial; return new Energy(value, EnergyUnit.DecathermImperial); } @@ -594,7 +591,7 @@ public static Energy FromDecathermsImperial(QuantityValue decathermsimperial) /// If value is NaN or Infinity. public static Energy FromDecathermsUs(QuantityValue decathermsus) { - QuantityValue value = (QuantityValue) decathermsus; + double value = (double) decathermsus; return new Energy(value, EnergyUnit.DecathermUs); } @@ -604,7 +601,7 @@ public static Energy FromDecathermsUs(QuantityValue decathermsus) /// If value is NaN or Infinity. public static Energy FromElectronVolts(QuantityValue electronvolts) { - QuantityValue value = (QuantityValue) electronvolts; + double value = (double) electronvolts; return new Energy(value, EnergyUnit.ElectronVolt); } @@ -614,7 +611,7 @@ public static Energy FromElectronVolts(QuantityValue electronvolts) /// If value is NaN or Infinity. public static Energy FromErgs(QuantityValue ergs) { - QuantityValue value = (QuantityValue) ergs; + double value = (double) ergs; return new Energy(value, EnergyUnit.Erg); } @@ -624,7 +621,7 @@ public static Energy FromErgs(QuantityValue ergs) /// If value is NaN or Infinity. public static Energy FromFootPounds(QuantityValue footpounds) { - QuantityValue value = (QuantityValue) footpounds; + double value = (double) footpounds; return new Energy(value, EnergyUnit.FootPound); } @@ -634,7 +631,7 @@ public static Energy FromFootPounds(QuantityValue footpounds) /// If value is NaN or Infinity. public static Energy FromGigabritishThermalUnits(QuantityValue gigabritishthermalunits) { - QuantityValue value = (QuantityValue) gigabritishthermalunits; + double value = (double) gigabritishthermalunits; return new Energy(value, EnergyUnit.GigabritishThermalUnit); } @@ -644,7 +641,7 @@ public static Energy FromGigabritishThermalUnits(QuantityValue gigabritishtherma /// If value is NaN or Infinity. public static Energy FromGigaelectronVolts(QuantityValue gigaelectronvolts) { - QuantityValue value = (QuantityValue) gigaelectronvolts; + double value = (double) gigaelectronvolts; return new Energy(value, EnergyUnit.GigaelectronVolt); } @@ -654,7 +651,7 @@ public static Energy FromGigaelectronVolts(QuantityValue gigaelectronvolts) /// If value is NaN or Infinity. public static Energy FromGigajoules(QuantityValue gigajoules) { - QuantityValue value = (QuantityValue) gigajoules; + double value = (double) gigajoules; return new Energy(value, EnergyUnit.Gigajoule); } @@ -664,7 +661,7 @@ public static Energy FromGigajoules(QuantityValue gigajoules) /// If value is NaN or Infinity. public static Energy FromGigawattDays(QuantityValue gigawattdays) { - QuantityValue value = (QuantityValue) gigawattdays; + double value = (double) gigawattdays; return new Energy(value, EnergyUnit.GigawattDay); } @@ -674,7 +671,7 @@ public static Energy FromGigawattDays(QuantityValue gigawattdays) /// If value is NaN or Infinity. public static Energy FromGigawattHours(QuantityValue gigawatthours) { - QuantityValue value = (QuantityValue) gigawatthours; + double value = (double) gigawatthours; return new Energy(value, EnergyUnit.GigawattHour); } @@ -684,7 +681,7 @@ public static Energy FromGigawattHours(QuantityValue gigawatthours) /// If value is NaN or Infinity. public static Energy FromHorsepowerHours(QuantityValue horsepowerhours) { - QuantityValue value = (QuantityValue) horsepowerhours; + double value = (double) horsepowerhours; return new Energy(value, EnergyUnit.HorsepowerHour); } @@ -694,7 +691,7 @@ public static Energy FromHorsepowerHours(QuantityValue horsepowerhours) /// If value is NaN or Infinity. public static Energy FromJoules(QuantityValue joules) { - QuantityValue value = (QuantityValue) joules; + double value = (double) joules; return new Energy(value, EnergyUnit.Joule); } @@ -704,7 +701,7 @@ public static Energy FromJoules(QuantityValue joules) /// If value is NaN or Infinity. public static Energy FromKilobritishThermalUnits(QuantityValue kilobritishthermalunits) { - QuantityValue value = (QuantityValue) kilobritishthermalunits; + double value = (double) kilobritishthermalunits; return new Energy(value, EnergyUnit.KilobritishThermalUnit); } @@ -714,7 +711,7 @@ public static Energy FromKilobritishThermalUnits(QuantityValue kilobritishtherma /// If value is NaN or Infinity. public static Energy FromKilocalories(QuantityValue kilocalories) { - QuantityValue value = (QuantityValue) kilocalories; + double value = (double) kilocalories; return new Energy(value, EnergyUnit.Kilocalorie); } @@ -724,7 +721,7 @@ public static Energy FromKilocalories(QuantityValue kilocalories) /// If value is NaN or Infinity. public static Energy FromKiloelectronVolts(QuantityValue kiloelectronvolts) { - QuantityValue value = (QuantityValue) kiloelectronvolts; + double value = (double) kiloelectronvolts; return new Energy(value, EnergyUnit.KiloelectronVolt); } @@ -734,7 +731,7 @@ public static Energy FromKiloelectronVolts(QuantityValue kiloelectronvolts) /// If value is NaN or Infinity. public static Energy FromKilojoules(QuantityValue kilojoules) { - QuantityValue value = (QuantityValue) kilojoules; + double value = (double) kilojoules; return new Energy(value, EnergyUnit.Kilojoule); } @@ -744,7 +741,7 @@ public static Energy FromKilojoules(QuantityValue kilojoules) /// If value is NaN or Infinity. public static Energy FromKilowattDays(QuantityValue kilowattdays) { - QuantityValue value = (QuantityValue) kilowattdays; + double value = (double) kilowattdays; return new Energy(value, EnergyUnit.KilowattDay); } @@ -754,7 +751,7 @@ public static Energy FromKilowattDays(QuantityValue kilowattdays) /// If value is NaN or Infinity. public static Energy FromKilowattHours(QuantityValue kilowatthours) { - QuantityValue value = (QuantityValue) kilowatthours; + double value = (double) kilowatthours; return new Energy(value, EnergyUnit.KilowattHour); } @@ -764,7 +761,7 @@ public static Energy FromKilowattHours(QuantityValue kilowatthours) /// If value is NaN or Infinity. public static Energy FromMegabritishThermalUnits(QuantityValue megabritishthermalunits) { - QuantityValue value = (QuantityValue) megabritishthermalunits; + double value = (double) megabritishthermalunits; return new Energy(value, EnergyUnit.MegabritishThermalUnit); } @@ -774,7 +771,7 @@ public static Energy FromMegabritishThermalUnits(QuantityValue megabritishtherma /// If value is NaN or Infinity. public static Energy FromMegacalories(QuantityValue megacalories) { - QuantityValue value = (QuantityValue) megacalories; + double value = (double) megacalories; return new Energy(value, EnergyUnit.Megacalorie); } @@ -784,7 +781,7 @@ public static Energy FromMegacalories(QuantityValue megacalories) /// If value is NaN or Infinity. public static Energy FromMegaelectronVolts(QuantityValue megaelectronvolts) { - QuantityValue value = (QuantityValue) megaelectronvolts; + double value = (double) megaelectronvolts; return new Energy(value, EnergyUnit.MegaelectronVolt); } @@ -794,7 +791,7 @@ public static Energy FromMegaelectronVolts(QuantityValue megaelectronvolts) /// If value is NaN or Infinity. public static Energy FromMegajoules(QuantityValue megajoules) { - QuantityValue value = (QuantityValue) megajoules; + double value = (double) megajoules; return new Energy(value, EnergyUnit.Megajoule); } @@ -804,7 +801,7 @@ public static Energy FromMegajoules(QuantityValue megajoules) /// If value is NaN or Infinity. public static Energy FromMegawattDays(QuantityValue megawattdays) { - QuantityValue value = (QuantityValue) megawattdays; + double value = (double) megawattdays; return new Energy(value, EnergyUnit.MegawattDay); } @@ -814,7 +811,7 @@ public static Energy FromMegawattDays(QuantityValue megawattdays) /// If value is NaN or Infinity. public static Energy FromMegawattHours(QuantityValue megawatthours) { - QuantityValue value = (QuantityValue) megawatthours; + double value = (double) megawatthours; return new Energy(value, EnergyUnit.MegawattHour); } @@ -824,7 +821,7 @@ public static Energy FromMegawattHours(QuantityValue megawatthours) /// If value is NaN or Infinity. public static Energy FromMillijoules(QuantityValue millijoules) { - QuantityValue value = (QuantityValue) millijoules; + double value = (double) millijoules; return new Energy(value, EnergyUnit.Millijoule); } @@ -834,7 +831,7 @@ public static Energy FromMillijoules(QuantityValue millijoules) /// If value is NaN or Infinity. public static Energy FromTeraelectronVolts(QuantityValue teraelectronvolts) { - QuantityValue value = (QuantityValue) teraelectronvolts; + double value = (double) teraelectronvolts; return new Energy(value, EnergyUnit.TeraelectronVolt); } @@ -844,7 +841,7 @@ public static Energy FromTeraelectronVolts(QuantityValue teraelectronvolts) /// If value is NaN or Infinity. public static Energy FromTerawattDays(QuantityValue terawattdays) { - QuantityValue value = (QuantityValue) terawattdays; + double value = (double) terawattdays; return new Energy(value, EnergyUnit.TerawattDay); } @@ -854,7 +851,7 @@ public static Energy FromTerawattDays(QuantityValue terawattdays) /// If value is NaN or Infinity. public static Energy FromTerawattHours(QuantityValue terawatthours) { - QuantityValue value = (QuantityValue) terawatthours; + double value = (double) terawatthours; return new Energy(value, EnergyUnit.TerawattHour); } @@ -864,7 +861,7 @@ public static Energy FromTerawattHours(QuantityValue terawatthours) /// If value is NaN or Infinity. public static Energy FromThermsEc(QuantityValue thermsec) { - QuantityValue value = (QuantityValue) thermsec; + double value = (double) thermsec; return new Energy(value, EnergyUnit.ThermEc); } @@ -874,7 +871,7 @@ public static Energy FromThermsEc(QuantityValue thermsec) /// If value is NaN or Infinity. public static Energy FromThermsImperial(QuantityValue thermsimperial) { - QuantityValue value = (QuantityValue) thermsimperial; + double value = (double) thermsimperial; return new Energy(value, EnergyUnit.ThermImperial); } @@ -884,7 +881,7 @@ public static Energy FromThermsImperial(QuantityValue thermsimperial) /// If value is NaN or Infinity. public static Energy FromThermsUs(QuantityValue thermsus) { - QuantityValue value = (QuantityValue) thermsus; + double value = (double) thermsus; return new Energy(value, EnergyUnit.ThermUs); } @@ -894,7 +891,7 @@ public static Energy FromThermsUs(QuantityValue thermsus) /// If value is NaN or Infinity. public static Energy FromWattDays(QuantityValue wattdays) { - QuantityValue value = (QuantityValue) wattdays; + double value = (double) wattdays; return new Energy(value, EnergyUnit.WattDay); } @@ -904,7 +901,7 @@ public static Energy FromWattDays(QuantityValue wattdays) /// If value is NaN or Infinity. public static Energy FromWattHours(QuantityValue watthours) { - QuantityValue value = (QuantityValue) watthours; + double value = (double) watthours; return new Energy(value, EnergyUnit.WattHour); } @@ -916,7 +913,7 @@ public static Energy FromWattHours(QuantityValue watthours) /// Energy unit value. public static Energy From(QuantityValue value, EnergyUnit fromUnit) { - return new Energy((QuantityValue)value, fromUnit); + return new Energy((double)value, fromUnit); } #endregion @@ -1086,25 +1083,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ } /// Get from multiplying value and . - public static Energy operator *(QuantityValue left, Energy right) + public static Energy operator *(double left, Energy right) { return new Energy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Energy operator *(Energy left, QuantityValue right) + public static Energy operator *(Energy left, double right) { return new Energy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Energy operator /(Energy left, QuantityValue right) + public static Energy operator /(Energy left, double right) { return new Energy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Energy left, Energy right) + public static double operator /(Energy left, Energy right) { return left.Joules / right.Joules; } @@ -1137,19 +1134,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Energ return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Energy left, Energy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Energy left, Energy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1162,29 +1146,7 @@ public int CompareTo(object obj) /// public int CompareTo(Energy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Energy objEnergy)) - return false; - return Equals(objEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Energy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1227,13 +1189,13 @@ public bool Equals(Energy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Energy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Energy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1244,7 +1206,7 @@ public bool Equals(Energy other, QuantityValue tolerance, ComparisonType compari /// A hash code for the current Energy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1255,16 +1217,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(EnergyUnit unit) + public double As(EnergyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1279,12 +1242,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is EnergyUnit typedUnit)) + if (!(unit is EnergyUnit unitAsEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsEnergyUnit); } /// @@ -1316,7 +1279,7 @@ public Energy ToUnit(EnergyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Energy)converted; } - else if (Enum.IsDefined(typeof(EnergyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1324,17 +1287,17 @@ public Energy ToUnit(EnergyUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EnergyUnit typedUnit)) + if (!(unit is EnergyUnit unitAsEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsEnergyUnit, DefaultConversionFunctions); } /// @@ -1361,10 +1324,10 @@ public Energy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(EnergyUnit unit) + private double GetValueAs(EnergyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 125d9bac9c..5a3eed83c2 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Entropy is an important concept in the branch of science known as thermodynamics. The idea of "irreversibility" is central to the understanding of entropy. It is often said that entropy is an expression of the disorder, or randomness of a system, or of our lack of information about it. Entropy is an extensive property. It has the dimension of energy divided by temperature, which has a unit of joules per kelvin (J/K) in the International System of Units /// [DataContract] - public partial struct Entropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Entropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static Entropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Entropy(QuantityValue value, EntropyUnit unit) + public Entropy(double value, EntropyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public Entropy(QuantityValue value, EntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Entropy(QuantityValue value, UnitSystem unitSystem) + public Entropy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public Entropy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,39 +163,39 @@ public Entropy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); + public double CaloriesPerKelvin => As(EntropyUnit.CaloriePerKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); + public double JoulesPerDegreeCelsius => As(EntropyUnit.JoulePerDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); + public double JoulesPerKelvin => As(EntropyUnit.JoulePerKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); + public double KilocaloriesPerKelvin => As(EntropyUnit.KilocaloriePerKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); + public double KilojoulesPerDegreeCelsius => As(EntropyUnit.KilojoulePerDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); + public double KilojoulesPerKelvin => As(EntropyUnit.KilojoulePerKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); + public double MegajoulesPerKelvin => As(EntropyUnit.MegajoulePerKelvin); #endregion @@ -272,7 +269,7 @@ public static string GetAbbreviation(EntropyUnit unit, IFormatProvider? provider /// If value is NaN or Infinity. public static Entropy FromCaloriesPerKelvin(QuantityValue caloriesperkelvin) { - QuantityValue value = (QuantityValue) caloriesperkelvin; + double value = (double) caloriesperkelvin; return new Entropy(value, EntropyUnit.CaloriePerKelvin); } @@ -282,7 +279,7 @@ public static Entropy FromCaloriesPerKelvin(QuantityValue caloriesperkelvin) /// If value is NaN or Infinity. public static Entropy FromJoulesPerDegreeCelsius(QuantityValue joulesperdegreecelsius) { - QuantityValue value = (QuantityValue) joulesperdegreecelsius; + double value = (double) joulesperdegreecelsius; return new Entropy(value, EntropyUnit.JoulePerDegreeCelsius); } @@ -292,7 +289,7 @@ public static Entropy FromJoulesPerDegreeCelsius(QuantityValue joulesperdegreece /// If value is NaN or Infinity. public static Entropy FromJoulesPerKelvin(QuantityValue joulesperkelvin) { - QuantityValue value = (QuantityValue) joulesperkelvin; + double value = (double) joulesperkelvin; return new Entropy(value, EntropyUnit.JoulePerKelvin); } @@ -302,7 +299,7 @@ public static Entropy FromJoulesPerKelvin(QuantityValue joulesperkelvin) /// If value is NaN or Infinity. public static Entropy FromKilocaloriesPerKelvin(QuantityValue kilocaloriesperkelvin) { - QuantityValue value = (QuantityValue) kilocaloriesperkelvin; + double value = (double) kilocaloriesperkelvin; return new Entropy(value, EntropyUnit.KilocaloriePerKelvin); } @@ -312,7 +309,7 @@ public static Entropy FromKilocaloriesPerKelvin(QuantityValue kilocaloriesperkel /// If value is NaN or Infinity. public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue kilojoulesperdegreecelsius) { - QuantityValue value = (QuantityValue) kilojoulesperdegreecelsius; + double value = (double) kilojoulesperdegreecelsius; return new Entropy(value, EntropyUnit.KilojoulePerDegreeCelsius); } @@ -322,7 +319,7 @@ public static Entropy FromKilojoulesPerDegreeCelsius(QuantityValue kilojoulesper /// If value is NaN or Infinity. public static Entropy FromKilojoulesPerKelvin(QuantityValue kilojoulesperkelvin) { - QuantityValue value = (QuantityValue) kilojoulesperkelvin; + double value = (double) kilojoulesperkelvin; return new Entropy(value, EntropyUnit.KilojoulePerKelvin); } @@ -332,7 +329,7 @@ public static Entropy FromKilojoulesPerKelvin(QuantityValue kilojoulesperkelvin) /// If value is NaN or Infinity. public static Entropy FromMegajoulesPerKelvin(QuantityValue megajoulesperkelvin) { - QuantityValue value = (QuantityValue) megajoulesperkelvin; + double value = (double) megajoulesperkelvin; return new Entropy(value, EntropyUnit.MegajoulePerKelvin); } @@ -344,7 +341,7 @@ public static Entropy FromMegajoulesPerKelvin(QuantityValue megajoulesperkelvin) /// Entropy unit value. public static Entropy From(QuantityValue value, EntropyUnit fromUnit) { - return new Entropy((QuantityValue)value, fromUnit); + return new Entropy((double)value, fromUnit); } #endregion @@ -514,25 +511,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro } /// Get from multiplying value and . - public static Entropy operator *(QuantityValue left, Entropy right) + public static Entropy operator *(double left, Entropy right) { return new Entropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Entropy operator *(Entropy left, QuantityValue right) + public static Entropy operator *(Entropy left, double right) { return new Entropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Entropy operator /(Entropy left, QuantityValue right) + public static Entropy operator /(Entropy left, double right) { return new Entropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Entropy left, Entropy right) + public static double operator /(Entropy left, Entropy right) { return left.JoulesPerKelvin / right.JoulesPerKelvin; } @@ -565,19 +562,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Entro return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Entropy left, Entropy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Entropy left, Entropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -590,29 +574,7 @@ public int CompareTo(object obj) /// public int CompareTo(Entropy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Entropy objEntropy)) - return false; - return Equals(objEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Entropy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -655,13 +617,13 @@ public bool Equals(Entropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Entropy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Entropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -672,7 +634,7 @@ public bool Equals(Entropy other, QuantityValue tolerance, ComparisonType compar /// A hash code for the current Entropy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -683,16 +645,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(EntropyUnit unit) + public double As(EntropyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -707,12 +670,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is EntropyUnit typedUnit)) + if (!(unit is EntropyUnit unitAsEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsEntropyUnit); } /// @@ -744,7 +707,7 @@ public Entropy ToUnit(EntropyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Entropy)converted; } - else if (Enum.IsDefined(typeof(EntropyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -752,17 +715,17 @@ public Entropy ToUnit(EntropyUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EntropyUnit typedUnit)) + if (!(unit is EntropyUnit unitAsEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsEntropyUnit, DefaultConversionFunctions); } /// @@ -789,10 +752,10 @@ public Entropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(EntropyUnit unit) + private double GetValueAs(EntropyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 08781f06c6..67478a3e16 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics, a force is any influence that causes an object to undergo a certain change, either concerning its movement, direction, or geometrical construction. In other words, a force can cause an object with mass to change its velocity (which includes to begin moving from a state of rest), i.e., to accelerate, or a flexible object to deform, or both. Force can also be described by intuitive concepts such as a push or a pull. A force has both magnitude and direction, making it a vector quantity. It is measured in the SI unit of newtons and represented by the symbol F. /// [DataContract] - public partial struct Force : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Force : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -86,9 +86,9 @@ static Force() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Force(QuantityValue value, ForceUnit unit) + public Force(double value, ForceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -100,14 +100,14 @@ public Force(QuantityValue value, ForceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Force(QuantityValue value, UnitSystem unitSystem) + public Force(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -148,10 +148,7 @@ public Force(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -174,79 +171,79 @@ public Force(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decanewtons => As(ForceUnit.Decanewton); + public double Decanewtons => As(ForceUnit.Decanewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Dyne => As(ForceUnit.Dyn); + public double Dyne => As(ForceUnit.Dyn); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForce => As(ForceUnit.KilogramForce); + public double KilogramsForce => As(ForceUnit.KilogramForce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilonewtons => As(ForceUnit.Kilonewton); + public double Kilonewtons => As(ForceUnit.Kilonewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KiloPonds => As(ForceUnit.KiloPond); + public double KiloPonds => As(ForceUnit.KiloPond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForce => As(ForceUnit.KilopoundForce); + public double KilopoundsForce => As(ForceUnit.KilopoundForce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Meganewtons => As(ForceUnit.Meganewton); + public double Meganewtons => As(ForceUnit.Meganewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Micronewtons => As(ForceUnit.Micronewton); + public double Micronewtons => As(ForceUnit.Micronewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millinewtons => As(ForceUnit.Millinewton); + public double Millinewtons => As(ForceUnit.Millinewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Newtons => As(ForceUnit.Newton); + public double Newtons => As(ForceUnit.Newton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OunceForce => As(ForceUnit.OunceForce); + public double OunceForce => As(ForceUnit.OunceForce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Poundals => As(ForceUnit.Poundal); + public double Poundals => As(ForceUnit.Poundal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForce => As(ForceUnit.PoundForce); + public double PoundsForce => As(ForceUnit.PoundForce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ShortTonsForce => As(ForceUnit.ShortTonForce); + public double ShortTonsForce => As(ForceUnit.ShortTonForce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForce => As(ForceUnit.TonneForce); + public double TonnesForce => As(ForceUnit.TonneForce); #endregion @@ -357,7 +354,7 @@ public static string GetAbbreviation(ForceUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Force FromDecanewtons(QuantityValue decanewtons) { - QuantityValue value = (QuantityValue) decanewtons; + double value = (double) decanewtons; return new Force(value, ForceUnit.Decanewton); } @@ -367,7 +364,7 @@ public static Force FromDecanewtons(QuantityValue decanewtons) /// If value is NaN or Infinity. public static Force FromDyne(QuantityValue dyne) { - QuantityValue value = (QuantityValue) dyne; + double value = (double) dyne; return new Force(value, ForceUnit.Dyn); } @@ -377,7 +374,7 @@ public static Force FromDyne(QuantityValue dyne) /// If value is NaN or Infinity. public static Force FromKilogramsForce(QuantityValue kilogramsforce) { - QuantityValue value = (QuantityValue) kilogramsforce; + double value = (double) kilogramsforce; return new Force(value, ForceUnit.KilogramForce); } @@ -387,7 +384,7 @@ public static Force FromKilogramsForce(QuantityValue kilogramsforce) /// If value is NaN or Infinity. public static Force FromKilonewtons(QuantityValue kilonewtons) { - QuantityValue value = (QuantityValue) kilonewtons; + double value = (double) kilonewtons; return new Force(value, ForceUnit.Kilonewton); } @@ -397,7 +394,7 @@ public static Force FromKilonewtons(QuantityValue kilonewtons) /// If value is NaN or Infinity. public static Force FromKiloPonds(QuantityValue kiloponds) { - QuantityValue value = (QuantityValue) kiloponds; + double value = (double) kiloponds; return new Force(value, ForceUnit.KiloPond); } @@ -407,7 +404,7 @@ public static Force FromKiloPonds(QuantityValue kiloponds) /// If value is NaN or Infinity. public static Force FromKilopoundsForce(QuantityValue kilopoundsforce) { - QuantityValue value = (QuantityValue) kilopoundsforce; + double value = (double) kilopoundsforce; return new Force(value, ForceUnit.KilopoundForce); } @@ -417,7 +414,7 @@ public static Force FromKilopoundsForce(QuantityValue kilopoundsforce) /// If value is NaN or Infinity. public static Force FromMeganewtons(QuantityValue meganewtons) { - QuantityValue value = (QuantityValue) meganewtons; + double value = (double) meganewtons; return new Force(value, ForceUnit.Meganewton); } @@ -427,7 +424,7 @@ public static Force FromMeganewtons(QuantityValue meganewtons) /// If value is NaN or Infinity. public static Force FromMicronewtons(QuantityValue micronewtons) { - QuantityValue value = (QuantityValue) micronewtons; + double value = (double) micronewtons; return new Force(value, ForceUnit.Micronewton); } @@ -437,7 +434,7 @@ public static Force FromMicronewtons(QuantityValue micronewtons) /// If value is NaN or Infinity. public static Force FromMillinewtons(QuantityValue millinewtons) { - QuantityValue value = (QuantityValue) millinewtons; + double value = (double) millinewtons; return new Force(value, ForceUnit.Millinewton); } @@ -447,7 +444,7 @@ public static Force FromMillinewtons(QuantityValue millinewtons) /// If value is NaN or Infinity. public static Force FromNewtons(QuantityValue newtons) { - QuantityValue value = (QuantityValue) newtons; + double value = (double) newtons; return new Force(value, ForceUnit.Newton); } @@ -457,7 +454,7 @@ public static Force FromNewtons(QuantityValue newtons) /// If value is NaN or Infinity. public static Force FromOunceForce(QuantityValue ounceforce) { - QuantityValue value = (QuantityValue) ounceforce; + double value = (double) ounceforce; return new Force(value, ForceUnit.OunceForce); } @@ -467,7 +464,7 @@ public static Force FromOunceForce(QuantityValue ounceforce) /// If value is NaN or Infinity. public static Force FromPoundals(QuantityValue poundals) { - QuantityValue value = (QuantityValue) poundals; + double value = (double) poundals; return new Force(value, ForceUnit.Poundal); } @@ -477,7 +474,7 @@ public static Force FromPoundals(QuantityValue poundals) /// If value is NaN or Infinity. public static Force FromPoundsForce(QuantityValue poundsforce) { - QuantityValue value = (QuantityValue) poundsforce; + double value = (double) poundsforce; return new Force(value, ForceUnit.PoundForce); } @@ -487,7 +484,7 @@ public static Force FromPoundsForce(QuantityValue poundsforce) /// If value is NaN or Infinity. public static Force FromShortTonsForce(QuantityValue shorttonsforce) { - QuantityValue value = (QuantityValue) shorttonsforce; + double value = (double) shorttonsforce; return new Force(value, ForceUnit.ShortTonForce); } @@ -497,7 +494,7 @@ public static Force FromShortTonsForce(QuantityValue shorttonsforce) /// If value is NaN or Infinity. public static Force FromTonnesForce(QuantityValue tonnesforce) { - QuantityValue value = (QuantityValue) tonnesforce; + double value = (double) tonnesforce; return new Force(value, ForceUnit.TonneForce); } @@ -509,7 +506,7 @@ public static Force FromTonnesForce(QuantityValue tonnesforce) /// Force unit value. public static Force From(QuantityValue value, ForceUnit fromUnit) { - return new Force((QuantityValue)value, fromUnit); + return new Force((double)value, fromUnit); } #endregion @@ -679,25 +676,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static Force operator *(QuantityValue left, Force right) + public static Force operator *(double left, Force right) { return new Force(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Force operator *(Force left, QuantityValue right) + public static Force operator *(Force left, double right) { return new Force(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Force operator /(Force left, QuantityValue right) + public static Force operator /(Force left, double right) { return new Force(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Force left, Force right) + public static double operator /(Force left, Force right) { return left.Newtons / right.Newtons; } @@ -730,19 +727,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Force left, Force right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Force left, Force right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -755,29 +739,7 @@ public int CompareTo(object obj) /// public int CompareTo(Force other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Force objForce)) - return false; - return Equals(objForce); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Force other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -820,13 +782,13 @@ public bool Equals(Force other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Force other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Force other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -837,7 +799,7 @@ public bool Equals(Force other, QuantityValue tolerance, ComparisonType comparis /// A hash code for the current Force. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -848,16 +810,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ForceUnit unit) + public double As(ForceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -872,12 +835,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ForceUnit typedUnit)) + if (!(unit is ForceUnit unitAsForceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsForceUnit); } /// @@ -909,7 +872,7 @@ public Force ToUnit(ForceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Force)converted; } - else if (Enum.IsDefined(typeof(ForceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -917,17 +880,17 @@ public Force ToUnit(ForceUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceUnit typedUnit)) + if (!(unit is ForceUnit unitAsForceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsForceUnit, DefaultConversionFunctions); } /// @@ -954,10 +917,10 @@ public Force ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ForceUnit unit) + private double GetValueAs(ForceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 8b897ef600..247b741b2a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Force change rate is the ratio of the force change to the time during which the change occurred (value of force changes per unit time). /// [DataContract] - public partial struct ForceChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForceChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -86,9 +86,9 @@ static ForceChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ForceChangeRate(QuantityValue value, ForceChangeRateUnit unit) + public ForceChangeRate(double value, ForceChangeRateUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -100,14 +100,14 @@ public ForceChangeRate(QuantityValue value, ForceChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForceChangeRate(QuantityValue value, UnitSystem unitSystem) + public ForceChangeRate(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -148,10 +148,7 @@ public ForceChangeRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -174,79 +171,79 @@ public ForceChangeRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); + public double CentinewtonsPerSecond => As(ForceChangeRateUnit.CentinewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); + public double DecanewtonsPerMinute => As(ForceChangeRateUnit.DecanewtonPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); + public double DecanewtonsPerSecond => As(ForceChangeRateUnit.DecanewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); + public double DecinewtonsPerSecond => As(ForceChangeRateUnit.DecinewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); + public double KilonewtonsPerMinute => As(ForceChangeRateUnit.KilonewtonPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); + public double KilonewtonsPerSecond => As(ForceChangeRateUnit.KilonewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); + public double KilopoundsForcePerMinute => As(ForceChangeRateUnit.KilopoundForcePerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); + public double KilopoundsForcePerSecond => As(ForceChangeRateUnit.KilopoundForcePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); + public double MicronewtonsPerSecond => As(ForceChangeRateUnit.MicronewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); + public double MillinewtonsPerSecond => As(ForceChangeRateUnit.MillinewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); + public double NanonewtonsPerSecond => As(ForceChangeRateUnit.NanonewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); + public double NewtonsPerMinute => As(ForceChangeRateUnit.NewtonPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); + public double NewtonsPerSecond => As(ForceChangeRateUnit.NewtonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); + public double PoundsForcePerMinute => As(ForceChangeRateUnit.PoundForcePerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); + public double PoundsForcePerSecond => As(ForceChangeRateUnit.PoundForcePerSecond); #endregion @@ -344,7 +341,7 @@ public static string GetAbbreviation(ForceChangeRateUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue centinewtonspersecond) { - QuantityValue value = (QuantityValue) centinewtonspersecond; + double value = (double) centinewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.CentinewtonPerSecond); } @@ -354,7 +351,7 @@ public static ForceChangeRate FromCentinewtonsPerSecond(QuantityValue centinewto /// If value is NaN or Infinity. public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue decanewtonsperminute) { - QuantityValue value = (QuantityValue) decanewtonsperminute; + double value = (double) decanewtonsperminute; return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerMinute); } @@ -364,7 +361,7 @@ public static ForceChangeRate FromDecanewtonsPerMinute(QuantityValue decanewtons /// If value is NaN or Infinity. public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue decanewtonspersecond) { - QuantityValue value = (QuantityValue) decanewtonspersecond; + double value = (double) decanewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.DecanewtonPerSecond); } @@ -374,7 +371,7 @@ public static ForceChangeRate FromDecanewtonsPerSecond(QuantityValue decanewtons /// If value is NaN or Infinity. public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue decinewtonspersecond) { - QuantityValue value = (QuantityValue) decinewtonspersecond; + double value = (double) decinewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.DecinewtonPerSecond); } @@ -384,7 +381,7 @@ public static ForceChangeRate FromDecinewtonsPerSecond(QuantityValue decinewtons /// If value is NaN or Infinity. public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue kilonewtonsperminute) { - QuantityValue value = (QuantityValue) kilonewtonsperminute; + double value = (double) kilonewtonsperminute; return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerMinute); } @@ -394,7 +391,7 @@ public static ForceChangeRate FromKilonewtonsPerMinute(QuantityValue kilonewtons /// If value is NaN or Infinity. public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue kilonewtonspersecond) { - QuantityValue value = (QuantityValue) kilonewtonspersecond; + double value = (double) kilonewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.KilonewtonPerSecond); } @@ -404,7 +401,7 @@ public static ForceChangeRate FromKilonewtonsPerSecond(QuantityValue kilonewtons /// If value is NaN or Infinity. public static ForceChangeRate FromKilopoundsForcePerMinute(QuantityValue kilopoundsforceperminute) { - QuantityValue value = (QuantityValue) kilopoundsforceperminute; + double value = (double) kilopoundsforceperminute; return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerMinute); } @@ -414,7 +411,7 @@ public static ForceChangeRate FromKilopoundsForcePerMinute(QuantityValue kilopou /// If value is NaN or Infinity. public static ForceChangeRate FromKilopoundsForcePerSecond(QuantityValue kilopoundsforcepersecond) { - QuantityValue value = (QuantityValue) kilopoundsforcepersecond; + double value = (double) kilopoundsforcepersecond; return new ForceChangeRate(value, ForceChangeRateUnit.KilopoundForcePerSecond); } @@ -424,7 +421,7 @@ public static ForceChangeRate FromKilopoundsForcePerSecond(QuantityValue kilopou /// If value is NaN or Infinity. public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue micronewtonspersecond) { - QuantityValue value = (QuantityValue) micronewtonspersecond; + double value = (double) micronewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.MicronewtonPerSecond); } @@ -434,7 +431,7 @@ public static ForceChangeRate FromMicronewtonsPerSecond(QuantityValue micronewto /// If value is NaN or Infinity. public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue millinewtonspersecond) { - QuantityValue value = (QuantityValue) millinewtonspersecond; + double value = (double) millinewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.MillinewtonPerSecond); } @@ -444,7 +441,7 @@ public static ForceChangeRate FromMillinewtonsPerSecond(QuantityValue millinewto /// If value is NaN or Infinity. public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue nanonewtonspersecond) { - QuantityValue value = (QuantityValue) nanonewtonspersecond; + double value = (double) nanonewtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.NanonewtonPerSecond); } @@ -454,7 +451,7 @@ public static ForceChangeRate FromNanonewtonsPerSecond(QuantityValue nanonewtons /// If value is NaN or Infinity. public static ForceChangeRate FromNewtonsPerMinute(QuantityValue newtonsperminute) { - QuantityValue value = (QuantityValue) newtonsperminute; + double value = (double) newtonsperminute; return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerMinute); } @@ -464,7 +461,7 @@ public static ForceChangeRate FromNewtonsPerMinute(QuantityValue newtonsperminut /// If value is NaN or Infinity. public static ForceChangeRate FromNewtonsPerSecond(QuantityValue newtonspersecond) { - QuantityValue value = (QuantityValue) newtonspersecond; + double value = (double) newtonspersecond; return new ForceChangeRate(value, ForceChangeRateUnit.NewtonPerSecond); } @@ -474,7 +471,7 @@ public static ForceChangeRate FromNewtonsPerSecond(QuantityValue newtonspersecon /// If value is NaN or Infinity. public static ForceChangeRate FromPoundsForcePerMinute(QuantityValue poundsforceperminute) { - QuantityValue value = (QuantityValue) poundsforceperminute; + double value = (double) poundsforceperminute; return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerMinute); } @@ -484,7 +481,7 @@ public static ForceChangeRate FromPoundsForcePerMinute(QuantityValue poundsforce /// If value is NaN or Infinity. public static ForceChangeRate FromPoundsForcePerSecond(QuantityValue poundsforcepersecond) { - QuantityValue value = (QuantityValue) poundsforcepersecond; + double value = (double) poundsforcepersecond; return new ForceChangeRate(value, ForceChangeRateUnit.PoundForcePerSecond); } @@ -496,7 +493,7 @@ public static ForceChangeRate FromPoundsForcePerSecond(QuantityValue poundsforce /// ForceChangeRate unit value. public static ForceChangeRate From(QuantityValue value, ForceChangeRateUnit fromUnit) { - return new ForceChangeRate((QuantityValue)value, fromUnit); + return new ForceChangeRate((double)value, fromUnit); } #endregion @@ -666,25 +663,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static ForceChangeRate operator *(QuantityValue left, ForceChangeRate right) + public static ForceChangeRate operator *(double left, ForceChangeRate right) { return new ForceChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ForceChangeRate operator *(ForceChangeRate left, QuantityValue right) + public static ForceChangeRate operator *(ForceChangeRate left, double right) { return new ForceChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ForceChangeRate operator /(ForceChangeRate left, QuantityValue right) + public static ForceChangeRate operator /(ForceChangeRate left, double right) { return new ForceChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ForceChangeRate left, ForceChangeRate right) + public static double operator /(ForceChangeRate left, ForceChangeRate right) { return left.NewtonsPerSecond / right.NewtonsPerSecond; } @@ -717,19 +714,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForceChangeRate left, ForceChangeRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForceChangeRate left, ForceChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -742,29 +726,7 @@ public int CompareTo(object obj) /// public int CompareTo(ForceChangeRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ForceChangeRate objForceChangeRate)) - return false; - return Equals(objForceChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForceChangeRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -807,13 +769,13 @@ public bool Equals(ForceChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForceChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ForceChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -824,7 +786,7 @@ public bool Equals(ForceChangeRate other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current ForceChangeRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -835,16 +797,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ForceChangeRateUnit unit) + public double As(ForceChangeRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -859,12 +822,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ForceChangeRateUnit typedUnit)) + if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsForceChangeRateUnit); } /// @@ -896,7 +859,7 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (ForceChangeRate)converted; } - else if (Enum.IsDefined(typeof(ForceChangeRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -904,17 +867,17 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceChangeRateUnit typedUnit)) + if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsForceChangeRateUnit, DefaultConversionFunctions); } /// @@ -941,10 +904,10 @@ public ForceChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ForceChangeRateUnit unit) + private double GetValueAs(ForceChangeRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index f937a368cf..820ff9473d 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The magnitude of force per unit length. /// [DataContract] - public partial struct ForcePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ForcePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -109,9 +109,9 @@ static ForcePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ForcePerLength(QuantityValue value, ForcePerLengthUnit unit) + public ForcePerLength(double value, ForcePerLengthUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -123,14 +123,14 @@ public ForcePerLength(QuantityValue value, ForcePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ForcePerLength(QuantityValue value, UnitSystem unitSystem) + public ForcePerLength(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -171,10 +171,7 @@ public ForcePerLength(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -197,194 +194,194 @@ public ForcePerLength(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); + public double CentinewtonsPerCentimeter => As(ForcePerLengthUnit.CentinewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); + public double CentinewtonsPerMeter => As(ForcePerLengthUnit.CentinewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); + public double CentinewtonsPerMillimeter => As(ForcePerLengthUnit.CentinewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); + public double DecanewtonsPerCentimeter => As(ForcePerLengthUnit.DecanewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); + public double DecanewtonsPerMeter => As(ForcePerLengthUnit.DecanewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); + public double DecanewtonsPerMillimeter => As(ForcePerLengthUnit.DecanewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); + public double DecinewtonsPerCentimeter => As(ForcePerLengthUnit.DecinewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); + public double DecinewtonsPerMeter => As(ForcePerLengthUnit.DecinewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); + public double DecinewtonsPerMillimeter => As(ForcePerLengthUnit.DecinewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); + public double KilogramsForcePerCentimeter => As(ForcePerLengthUnit.KilogramForcePerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); + public double KilogramsForcePerMeter => As(ForcePerLengthUnit.KilogramForcePerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); + public double KilogramsForcePerMillimeter => As(ForcePerLengthUnit.KilogramForcePerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); + public double KilonewtonsPerCentimeter => As(ForcePerLengthUnit.KilonewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); + public double KilonewtonsPerMeter => As(ForcePerLengthUnit.KilonewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); + public double KilonewtonsPerMillimeter => As(ForcePerLengthUnit.KilonewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); + public double KilopoundsForcePerFoot => As(ForcePerLengthUnit.KilopoundForcePerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); + public double KilopoundsForcePerInch => As(ForcePerLengthUnit.KilopoundForcePerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); + public double MeganewtonsPerCentimeter => As(ForcePerLengthUnit.MeganewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); + public double MeganewtonsPerMeter => As(ForcePerLengthUnit.MeganewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); + public double MeganewtonsPerMillimeter => As(ForcePerLengthUnit.MeganewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); + public double MicronewtonsPerCentimeter => As(ForcePerLengthUnit.MicronewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); + public double MicronewtonsPerMeter => As(ForcePerLengthUnit.MicronewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); + public double MicronewtonsPerMillimeter => As(ForcePerLengthUnit.MicronewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); + public double MillinewtonsPerCentimeter => As(ForcePerLengthUnit.MillinewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); + public double MillinewtonsPerMeter => As(ForcePerLengthUnit.MillinewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); + public double MillinewtonsPerMillimeter => As(ForcePerLengthUnit.MillinewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); + public double NanonewtonsPerCentimeter => As(ForcePerLengthUnit.NanonewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); + public double NanonewtonsPerMeter => As(ForcePerLengthUnit.NanonewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); + public double NanonewtonsPerMillimeter => As(ForcePerLengthUnit.NanonewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); + public double NewtonsPerCentimeter => As(ForcePerLengthUnit.NewtonPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); + public double NewtonsPerMeter => As(ForcePerLengthUnit.NewtonPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); + public double NewtonsPerMillimeter => As(ForcePerLengthUnit.NewtonPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); + public double PoundsForcePerFoot => As(ForcePerLengthUnit.PoundForcePerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); + public double PoundsForcePerInch => As(ForcePerLengthUnit.PoundForcePerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); + public double PoundsForcePerYard => As(ForcePerLengthUnit.PoundForcePerYard); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); + public double TonnesForcePerCentimeter => As(ForcePerLengthUnit.TonneForcePerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); + public double TonnesForcePerMeter => As(ForcePerLengthUnit.TonneForcePerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); + public double TonnesForcePerMillimeter => As(ForcePerLengthUnit.TonneForcePerMillimeter); #endregion @@ -557,7 +554,7 @@ public static string GetAbbreviation(ForcePerLengthUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ForcePerLength FromCentinewtonsPerCentimeter(QuantityValue centinewtonspercentimeter) { - QuantityValue value = (QuantityValue) centinewtonspercentimeter; + double value = (double) centinewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerCentimeter); } @@ -567,7 +564,7 @@ public static ForcePerLength FromCentinewtonsPerCentimeter(QuantityValue centine /// If value is NaN or Infinity. public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue centinewtonspermeter) { - QuantityValue value = (QuantityValue) centinewtonspermeter; + double value = (double) centinewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMeter); } @@ -577,7 +574,7 @@ public static ForcePerLength FromCentinewtonsPerMeter(QuantityValue centinewtons /// If value is NaN or Infinity. public static ForcePerLength FromCentinewtonsPerMillimeter(QuantityValue centinewtonspermillimeter) { - QuantityValue value = (QuantityValue) centinewtonspermillimeter; + double value = (double) centinewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.CentinewtonPerMillimeter); } @@ -587,7 +584,7 @@ public static ForcePerLength FromCentinewtonsPerMillimeter(QuantityValue centine /// If value is NaN or Infinity. public static ForcePerLength FromDecanewtonsPerCentimeter(QuantityValue decanewtonspercentimeter) { - QuantityValue value = (QuantityValue) decanewtonspercentimeter; + double value = (double) decanewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerCentimeter); } @@ -597,7 +594,7 @@ public static ForcePerLength FromDecanewtonsPerCentimeter(QuantityValue decanewt /// If value is NaN or Infinity. public static ForcePerLength FromDecanewtonsPerMeter(QuantityValue decanewtonspermeter) { - QuantityValue value = (QuantityValue) decanewtonspermeter; + double value = (double) decanewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMeter); } @@ -607,7 +604,7 @@ public static ForcePerLength FromDecanewtonsPerMeter(QuantityValue decanewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromDecanewtonsPerMillimeter(QuantityValue decanewtonspermillimeter) { - QuantityValue value = (QuantityValue) decanewtonspermillimeter; + double value = (double) decanewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecanewtonPerMillimeter); } @@ -617,7 +614,7 @@ public static ForcePerLength FromDecanewtonsPerMillimeter(QuantityValue decanewt /// If value is NaN or Infinity. public static ForcePerLength FromDecinewtonsPerCentimeter(QuantityValue decinewtonspercentimeter) { - QuantityValue value = (QuantityValue) decinewtonspercentimeter; + double value = (double) decinewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerCentimeter); } @@ -627,7 +624,7 @@ public static ForcePerLength FromDecinewtonsPerCentimeter(QuantityValue decinewt /// If value is NaN or Infinity. public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue decinewtonspermeter) { - QuantityValue value = (QuantityValue) decinewtonspermeter; + double value = (double) decinewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMeter); } @@ -637,7 +634,7 @@ public static ForcePerLength FromDecinewtonsPerMeter(QuantityValue decinewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromDecinewtonsPerMillimeter(QuantityValue decinewtonspermillimeter) { - QuantityValue value = (QuantityValue) decinewtonspermillimeter; + double value = (double) decinewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.DecinewtonPerMillimeter); } @@ -647,7 +644,7 @@ public static ForcePerLength FromDecinewtonsPerMillimeter(QuantityValue decinewt /// If value is NaN or Infinity. public static ForcePerLength FromKilogramsForcePerCentimeter(QuantityValue kilogramsforcepercentimeter) { - QuantityValue value = (QuantityValue) kilogramsforcepercentimeter; + double value = (double) kilogramsforcepercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerCentimeter); } @@ -657,7 +654,7 @@ public static ForcePerLength FromKilogramsForcePerCentimeter(QuantityValue kilog /// If value is NaN or Infinity. public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue kilogramsforcepermeter) { - QuantityValue value = (QuantityValue) kilogramsforcepermeter; + double value = (double) kilogramsforcepermeter; return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMeter); } @@ -667,7 +664,7 @@ public static ForcePerLength FromKilogramsForcePerMeter(QuantityValue kilogramsf /// If value is NaN or Infinity. public static ForcePerLength FromKilogramsForcePerMillimeter(QuantityValue kilogramsforcepermillimeter) { - QuantityValue value = (QuantityValue) kilogramsforcepermillimeter; + double value = (double) kilogramsforcepermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilogramForcePerMillimeter); } @@ -677,7 +674,7 @@ public static ForcePerLength FromKilogramsForcePerMillimeter(QuantityValue kilog /// If value is NaN or Infinity. public static ForcePerLength FromKilonewtonsPerCentimeter(QuantityValue kilonewtonspercentimeter) { - QuantityValue value = (QuantityValue) kilonewtonspercentimeter; + double value = (double) kilonewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerCentimeter); } @@ -687,7 +684,7 @@ public static ForcePerLength FromKilonewtonsPerCentimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue kilonewtonspermeter) { - QuantityValue value = (QuantityValue) kilonewtonspermeter; + double value = (double) kilonewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMeter); } @@ -697,7 +694,7 @@ public static ForcePerLength FromKilonewtonsPerMeter(QuantityValue kilonewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromKilonewtonsPerMillimeter(QuantityValue kilonewtonspermillimeter) { - QuantityValue value = (QuantityValue) kilonewtonspermillimeter; + double value = (double) kilonewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.KilonewtonPerMillimeter); } @@ -707,7 +704,7 @@ public static ForcePerLength FromKilonewtonsPerMillimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static ForcePerLength FromKilopoundsForcePerFoot(QuantityValue kilopoundsforceperfoot) { - QuantityValue value = (QuantityValue) kilopoundsforceperfoot; + double value = (double) kilopoundsforceperfoot; return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerFoot); } @@ -717,7 +714,7 @@ public static ForcePerLength FromKilopoundsForcePerFoot(QuantityValue kilopounds /// If value is NaN or Infinity. public static ForcePerLength FromKilopoundsForcePerInch(QuantityValue kilopoundsforceperinch) { - QuantityValue value = (QuantityValue) kilopoundsforceperinch; + double value = (double) kilopoundsforceperinch; return new ForcePerLength(value, ForcePerLengthUnit.KilopoundForcePerInch); } @@ -727,7 +724,7 @@ public static ForcePerLength FromKilopoundsForcePerInch(QuantityValue kilopounds /// If value is NaN or Infinity. public static ForcePerLength FromMeganewtonsPerCentimeter(QuantityValue meganewtonspercentimeter) { - QuantityValue value = (QuantityValue) meganewtonspercentimeter; + double value = (double) meganewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerCentimeter); } @@ -737,7 +734,7 @@ public static ForcePerLength FromMeganewtonsPerCentimeter(QuantityValue meganewt /// If value is NaN or Infinity. public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue meganewtonspermeter) { - QuantityValue value = (QuantityValue) meganewtonspermeter; + double value = (double) meganewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMeter); } @@ -747,7 +744,7 @@ public static ForcePerLength FromMeganewtonsPerMeter(QuantityValue meganewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromMeganewtonsPerMillimeter(QuantityValue meganewtonspermillimeter) { - QuantityValue value = (QuantityValue) meganewtonspermillimeter; + double value = (double) meganewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.MeganewtonPerMillimeter); } @@ -757,7 +754,7 @@ public static ForcePerLength FromMeganewtonsPerMillimeter(QuantityValue meganewt /// If value is NaN or Infinity. public static ForcePerLength FromMicronewtonsPerCentimeter(QuantityValue micronewtonspercentimeter) { - QuantityValue value = (QuantityValue) micronewtonspercentimeter; + double value = (double) micronewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerCentimeter); } @@ -767,7 +764,7 @@ public static ForcePerLength FromMicronewtonsPerCentimeter(QuantityValue microne /// If value is NaN or Infinity. public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue micronewtonspermeter) { - QuantityValue value = (QuantityValue) micronewtonspermeter; + double value = (double) micronewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMeter); } @@ -777,7 +774,7 @@ public static ForcePerLength FromMicronewtonsPerMeter(QuantityValue micronewtons /// If value is NaN or Infinity. public static ForcePerLength FromMicronewtonsPerMillimeter(QuantityValue micronewtonspermillimeter) { - QuantityValue value = (QuantityValue) micronewtonspermillimeter; + double value = (double) micronewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.MicronewtonPerMillimeter); } @@ -787,7 +784,7 @@ public static ForcePerLength FromMicronewtonsPerMillimeter(QuantityValue microne /// If value is NaN or Infinity. public static ForcePerLength FromMillinewtonsPerCentimeter(QuantityValue millinewtonspercentimeter) { - QuantityValue value = (QuantityValue) millinewtonspercentimeter; + double value = (double) millinewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerCentimeter); } @@ -797,7 +794,7 @@ public static ForcePerLength FromMillinewtonsPerCentimeter(QuantityValue milline /// If value is NaN or Infinity. public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue millinewtonspermeter) { - QuantityValue value = (QuantityValue) millinewtonspermeter; + double value = (double) millinewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMeter); } @@ -807,7 +804,7 @@ public static ForcePerLength FromMillinewtonsPerMeter(QuantityValue millinewtons /// If value is NaN or Infinity. public static ForcePerLength FromMillinewtonsPerMillimeter(QuantityValue millinewtonspermillimeter) { - QuantityValue value = (QuantityValue) millinewtonspermillimeter; + double value = (double) millinewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.MillinewtonPerMillimeter); } @@ -817,7 +814,7 @@ public static ForcePerLength FromMillinewtonsPerMillimeter(QuantityValue milline /// If value is NaN or Infinity. public static ForcePerLength FromNanonewtonsPerCentimeter(QuantityValue nanonewtonspercentimeter) { - QuantityValue value = (QuantityValue) nanonewtonspercentimeter; + double value = (double) nanonewtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerCentimeter); } @@ -827,7 +824,7 @@ public static ForcePerLength FromNanonewtonsPerCentimeter(QuantityValue nanonewt /// If value is NaN or Infinity. public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue nanonewtonspermeter) { - QuantityValue value = (QuantityValue) nanonewtonspermeter; + double value = (double) nanonewtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMeter); } @@ -837,7 +834,7 @@ public static ForcePerLength FromNanonewtonsPerMeter(QuantityValue nanonewtonspe /// If value is NaN or Infinity. public static ForcePerLength FromNanonewtonsPerMillimeter(QuantityValue nanonewtonspermillimeter) { - QuantityValue value = (QuantityValue) nanonewtonspermillimeter; + double value = (double) nanonewtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.NanonewtonPerMillimeter); } @@ -847,7 +844,7 @@ public static ForcePerLength FromNanonewtonsPerMillimeter(QuantityValue nanonewt /// If value is NaN or Infinity. public static ForcePerLength FromNewtonsPerCentimeter(QuantityValue newtonspercentimeter) { - QuantityValue value = (QuantityValue) newtonspercentimeter; + double value = (double) newtonspercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerCentimeter); } @@ -857,7 +854,7 @@ public static ForcePerLength FromNewtonsPerCentimeter(QuantityValue newtonsperce /// If value is NaN or Infinity. public static ForcePerLength FromNewtonsPerMeter(QuantityValue newtonspermeter) { - QuantityValue value = (QuantityValue) newtonspermeter; + double value = (double) newtonspermeter; return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMeter); } @@ -867,7 +864,7 @@ public static ForcePerLength FromNewtonsPerMeter(QuantityValue newtonspermeter) /// If value is NaN or Infinity. public static ForcePerLength FromNewtonsPerMillimeter(QuantityValue newtonspermillimeter) { - QuantityValue value = (QuantityValue) newtonspermillimeter; + double value = (double) newtonspermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.NewtonPerMillimeter); } @@ -877,7 +874,7 @@ public static ForcePerLength FromNewtonsPerMillimeter(QuantityValue newtonspermi /// If value is NaN or Infinity. public static ForcePerLength FromPoundsForcePerFoot(QuantityValue poundsforceperfoot) { - QuantityValue value = (QuantityValue) poundsforceperfoot; + double value = (double) poundsforceperfoot; return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerFoot); } @@ -887,7 +884,7 @@ public static ForcePerLength FromPoundsForcePerFoot(QuantityValue poundsforceper /// If value is NaN or Infinity. public static ForcePerLength FromPoundsForcePerInch(QuantityValue poundsforceperinch) { - QuantityValue value = (QuantityValue) poundsforceperinch; + double value = (double) poundsforceperinch; return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerInch); } @@ -897,7 +894,7 @@ public static ForcePerLength FromPoundsForcePerInch(QuantityValue poundsforceper /// If value is NaN or Infinity. public static ForcePerLength FromPoundsForcePerYard(QuantityValue poundsforceperyard) { - QuantityValue value = (QuantityValue) poundsforceperyard; + double value = (double) poundsforceperyard; return new ForcePerLength(value, ForcePerLengthUnit.PoundForcePerYard); } @@ -907,7 +904,7 @@ public static ForcePerLength FromPoundsForcePerYard(QuantityValue poundsforceper /// If value is NaN or Infinity. public static ForcePerLength FromTonnesForcePerCentimeter(QuantityValue tonnesforcepercentimeter) { - QuantityValue value = (QuantityValue) tonnesforcepercentimeter; + double value = (double) tonnesforcepercentimeter; return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerCentimeter); } @@ -917,7 +914,7 @@ public static ForcePerLength FromTonnesForcePerCentimeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static ForcePerLength FromTonnesForcePerMeter(QuantityValue tonnesforcepermeter) { - QuantityValue value = (QuantityValue) tonnesforcepermeter; + double value = (double) tonnesforcepermeter; return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMeter); } @@ -927,7 +924,7 @@ public static ForcePerLength FromTonnesForcePerMeter(QuantityValue tonnesforcepe /// If value is NaN or Infinity. public static ForcePerLength FromTonnesForcePerMillimeter(QuantityValue tonnesforcepermillimeter) { - QuantityValue value = (QuantityValue) tonnesforcepermillimeter; + double value = (double) tonnesforcepermillimeter; return new ForcePerLength(value, ForcePerLengthUnit.TonneForcePerMillimeter); } @@ -939,7 +936,7 @@ public static ForcePerLength FromTonnesForcePerMillimeter(QuantityValue tonnesfo /// ForcePerLength unit value. public static ForcePerLength From(QuantityValue value, ForcePerLengthUnit fromUnit) { - return new ForcePerLength((QuantityValue)value, fromUnit); + return new ForcePerLength((double)value, fromUnit); } #endregion @@ -1109,25 +1106,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force } /// Get from multiplying value and . - public static ForcePerLength operator *(QuantityValue left, ForcePerLength right) + public static ForcePerLength operator *(double left, ForcePerLength right) { return new ForcePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ForcePerLength operator *(ForcePerLength left, QuantityValue right) + public static ForcePerLength operator *(ForcePerLength left, double right) { return new ForcePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ForcePerLength operator /(ForcePerLength left, QuantityValue right) + public static ForcePerLength operator /(ForcePerLength left, double right) { return new ForcePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ForcePerLength left, ForcePerLength right) + public static double operator /(ForcePerLength left, ForcePerLength right) { return left.NewtonsPerMeter / right.NewtonsPerMeter; } @@ -1160,19 +1157,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Force return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ForcePerLength left, ForcePerLength right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ForcePerLength left, ForcePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1185,29 +1169,7 @@ public int CompareTo(object obj) /// public int CompareTo(ForcePerLength other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ForcePerLength objForcePerLength)) - return false; - return Equals(objForcePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ForcePerLength other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1250,13 +1212,13 @@ public bool Equals(ForcePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ForcePerLength other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ForcePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1267,7 +1229,7 @@ public bool Equals(ForcePerLength other, QuantityValue tolerance, ComparisonType /// A hash code for the current ForcePerLength. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1278,16 +1240,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ForcePerLengthUnit unit) + public double As(ForcePerLengthUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1302,12 +1265,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ForcePerLengthUnit typedUnit)) + if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsForcePerLengthUnit); } /// @@ -1339,7 +1302,7 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ForcePerLength)converted; } - else if (Enum.IsDefined(typeof(ForcePerLengthUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1347,17 +1310,17 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForcePerLengthUnit typedUnit)) + if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsForcePerLengthUnit, DefaultConversionFunctions); } /// @@ -1384,10 +1347,10 @@ public ForcePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ForcePerLengthUnit unit) + private double GetValueAs(ForcePerLengthUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 190de13050..695d03630d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The number of occurrences of a repeating event per unit time. /// [DataContract] - public partial struct Frequency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Frequency : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -82,9 +82,9 @@ static Frequency() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Frequency(QuantityValue value, FrequencyUnit unit) + public Frequency(double value, FrequencyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -96,14 +96,14 @@ public Frequency(QuantityValue value, FrequencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Frequency(QuantityValue value, UnitSystem unitSystem) + public Frequency(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,10 +144,7 @@ public Frequency(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -170,59 +167,59 @@ public Frequency(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); + public double BeatsPerMinute => As(FrequencyUnit.BeatPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BUnits => As(FrequencyUnit.BUnit); + public double BUnits => As(FrequencyUnit.BUnit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CyclesPerHour => As(FrequencyUnit.CyclePerHour); + public double CyclesPerHour => As(FrequencyUnit.CyclePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); + public double CyclesPerMinute => As(FrequencyUnit.CyclePerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigahertz => As(FrequencyUnit.Gigahertz); + public double Gigahertz => As(FrequencyUnit.Gigahertz); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hertz => As(FrequencyUnit.Hertz); + public double Hertz => As(FrequencyUnit.Hertz); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilohertz => As(FrequencyUnit.Kilohertz); + public double Kilohertz => As(FrequencyUnit.Kilohertz); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megahertz => As(FrequencyUnit.Megahertz); + public double Megahertz => As(FrequencyUnit.Megahertz); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PerSecond => As(FrequencyUnit.PerSecond); + public double PerSecond => As(FrequencyUnit.PerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); + public double RadiansPerSecond => As(FrequencyUnit.RadianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Terahertz => As(FrequencyUnit.Terahertz); + public double Terahertz => As(FrequencyUnit.Terahertz); #endregion @@ -251,7 +248,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: FrequencyUnit -> BaseUnit unitConverter.SetConversionFunction(FrequencyUnit.BeatPerMinute, FrequencyUnit.Hertz, quantity => new Frequency(quantity.Value / 60, FrequencyUnit.Hertz)); - unitConverter.SetConversionFunction(FrequencyUnit.BUnit, FrequencyUnit.Hertz, quantity => new Frequency(Math.Sqrt((double)quantity.Value * 1e3), FrequencyUnit.Hertz)); + unitConverter.SetConversionFunction(FrequencyUnit.BUnit, FrequencyUnit.Hertz, quantity => new Frequency(Math.Sqrt(quantity.Value * 1e3), FrequencyUnit.Hertz)); unitConverter.SetConversionFunction(FrequencyUnit.CyclePerHour, FrequencyUnit.Hertz, quantity => new Frequency(quantity.Value / 3600, FrequencyUnit.Hertz)); unitConverter.SetConversionFunction(FrequencyUnit.CyclePerMinute, FrequencyUnit.Hertz, quantity => new Frequency(quantity.Value / 60, FrequencyUnit.Hertz)); unitConverter.SetConversionFunction(FrequencyUnit.Gigahertz, FrequencyUnit.Hertz, quantity => new Frequency((quantity.Value) * 1e9d, FrequencyUnit.Hertz)); @@ -315,7 +312,7 @@ public static string GetAbbreviation(FrequencyUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static Frequency FromBeatsPerMinute(QuantityValue beatsperminute) { - QuantityValue value = (QuantityValue) beatsperminute; + double value = (double) beatsperminute; return new Frequency(value, FrequencyUnit.BeatPerMinute); } @@ -325,7 +322,7 @@ public static Frequency FromBeatsPerMinute(QuantityValue beatsperminute) /// If value is NaN or Infinity. public static Frequency FromBUnits(QuantityValue bunits) { - QuantityValue value = (QuantityValue) bunits; + double value = (double) bunits; return new Frequency(value, FrequencyUnit.BUnit); } @@ -335,7 +332,7 @@ public static Frequency FromBUnits(QuantityValue bunits) /// If value is NaN or Infinity. public static Frequency FromCyclesPerHour(QuantityValue cyclesperhour) { - QuantityValue value = (QuantityValue) cyclesperhour; + double value = (double) cyclesperhour; return new Frequency(value, FrequencyUnit.CyclePerHour); } @@ -345,7 +342,7 @@ public static Frequency FromCyclesPerHour(QuantityValue cyclesperhour) /// If value is NaN or Infinity. public static Frequency FromCyclesPerMinute(QuantityValue cyclesperminute) { - QuantityValue value = (QuantityValue) cyclesperminute; + double value = (double) cyclesperminute; return new Frequency(value, FrequencyUnit.CyclePerMinute); } @@ -355,7 +352,7 @@ public static Frequency FromCyclesPerMinute(QuantityValue cyclesperminute) /// If value is NaN or Infinity. public static Frequency FromGigahertz(QuantityValue gigahertz) { - QuantityValue value = (QuantityValue) gigahertz; + double value = (double) gigahertz; return new Frequency(value, FrequencyUnit.Gigahertz); } @@ -365,7 +362,7 @@ public static Frequency FromGigahertz(QuantityValue gigahertz) /// If value is NaN or Infinity. public static Frequency FromHertz(QuantityValue hertz) { - QuantityValue value = (QuantityValue) hertz; + double value = (double) hertz; return new Frequency(value, FrequencyUnit.Hertz); } @@ -375,7 +372,7 @@ public static Frequency FromHertz(QuantityValue hertz) /// If value is NaN or Infinity. public static Frequency FromKilohertz(QuantityValue kilohertz) { - QuantityValue value = (QuantityValue) kilohertz; + double value = (double) kilohertz; return new Frequency(value, FrequencyUnit.Kilohertz); } @@ -385,7 +382,7 @@ public static Frequency FromKilohertz(QuantityValue kilohertz) /// If value is NaN or Infinity. public static Frequency FromMegahertz(QuantityValue megahertz) { - QuantityValue value = (QuantityValue) megahertz; + double value = (double) megahertz; return new Frequency(value, FrequencyUnit.Megahertz); } @@ -395,7 +392,7 @@ public static Frequency FromMegahertz(QuantityValue megahertz) /// If value is NaN or Infinity. public static Frequency FromPerSecond(QuantityValue persecond) { - QuantityValue value = (QuantityValue) persecond; + double value = (double) persecond; return new Frequency(value, FrequencyUnit.PerSecond); } @@ -405,7 +402,7 @@ public static Frequency FromPerSecond(QuantityValue persecond) /// If value is NaN or Infinity. public static Frequency FromRadiansPerSecond(QuantityValue radianspersecond) { - QuantityValue value = (QuantityValue) radianspersecond; + double value = (double) radianspersecond; return new Frequency(value, FrequencyUnit.RadianPerSecond); } @@ -415,7 +412,7 @@ public static Frequency FromRadiansPerSecond(QuantityValue radianspersecond) /// If value is NaN or Infinity. public static Frequency FromTerahertz(QuantityValue terahertz) { - QuantityValue value = (QuantityValue) terahertz; + double value = (double) terahertz; return new Frequency(value, FrequencyUnit.Terahertz); } @@ -427,7 +424,7 @@ public static Frequency FromTerahertz(QuantityValue terahertz) /// Frequency unit value. public static Frequency From(QuantityValue value, FrequencyUnit fromUnit) { - return new Frequency((QuantityValue)value, fromUnit); + return new Frequency((double)value, fromUnit); } #endregion @@ -597,25 +594,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ } /// Get from multiplying value and . - public static Frequency operator *(QuantityValue left, Frequency right) + public static Frequency operator *(double left, Frequency right) { return new Frequency(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Frequency operator *(Frequency left, QuantityValue right) + public static Frequency operator *(Frequency left, double right) { return new Frequency(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Frequency operator /(Frequency left, QuantityValue right) + public static Frequency operator /(Frequency left, double right) { return new Frequency(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Frequency left, Frequency right) + public static double operator /(Frequency left, Frequency right) { return left.Hertz / right.Hertz; } @@ -648,19 +645,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Frequ return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Frequency left, Frequency right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Frequency left, Frequency right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -673,29 +657,7 @@ public int CompareTo(object obj) /// public int CompareTo(Frequency other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Frequency objFrequency)) - return false; - return Equals(objFrequency); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Frequency other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -738,13 +700,13 @@ public bool Equals(Frequency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Frequency other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Frequency other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -755,7 +717,7 @@ public bool Equals(Frequency other, QuantityValue tolerance, ComparisonType comp /// A hash code for the current Frequency. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -766,16 +728,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(FrequencyUnit unit) + public double As(FrequencyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -790,12 +753,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is FrequencyUnit typedUnit)) + if (!(unit is FrequencyUnit unitAsFrequencyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsFrequencyUnit); } /// @@ -827,7 +790,7 @@ public Frequency ToUnit(FrequencyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Frequency)converted; } - else if (Enum.IsDefined(typeof(FrequencyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -835,17 +798,17 @@ public Frequency ToUnit(FrequencyUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FrequencyUnit typedUnit)) + if (!(unit is FrequencyUnit unitAsFrequencyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsFrequencyUnit, DefaultConversionFunctions); } /// @@ -872,10 +835,10 @@ public Frequency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(FrequencyUnit unit) + private double GetValueAs(FrequencyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index 279770ce94..c2a2cfcf02 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Fuel_efficiency /// [DataContract] - public partial struct FuelEfficiency : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct FuelEfficiency : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static FuelEfficiency() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public FuelEfficiency(QuantityValue value, FuelEfficiencyUnit unit) + public FuelEfficiency(double value, FuelEfficiencyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public FuelEfficiency(QuantityValue value, FuelEfficiencyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public FuelEfficiency(QuantityValue value, UnitSystem unitSystem) + public FuelEfficiency(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public FuelEfficiency(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,24 +163,24 @@ public FuelEfficiency(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); + public double KilometersPerLiters => As(FuelEfficiencyUnit.KilometerPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); + public double LitersPer100Kilometers => As(FuelEfficiencyUnit.LiterPer100Kilometers); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); + public double MilesPerUkGallon => As(FuelEfficiencyUnit.MilePerUkGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); + public double MilesPerUsGallon => As(FuelEfficiencyUnit.MilePerUsGallon); #endregion @@ -248,7 +245,7 @@ public static string GetAbbreviation(FuelEfficiencyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static FuelEfficiency FromKilometersPerLiters(QuantityValue kilometersperliters) { - QuantityValue value = (QuantityValue) kilometersperliters; + double value = (double) kilometersperliters; return new FuelEfficiency(value, FuelEfficiencyUnit.KilometerPerLiter); } @@ -258,7 +255,7 @@ public static FuelEfficiency FromKilometersPerLiters(QuantityValue kilometersper /// If value is NaN or Infinity. public static FuelEfficiency FromLitersPer100Kilometers(QuantityValue litersper100kilometers) { - QuantityValue value = (QuantityValue) litersper100kilometers; + double value = (double) litersper100kilometers; return new FuelEfficiency(value, FuelEfficiencyUnit.LiterPer100Kilometers); } @@ -268,7 +265,7 @@ public static FuelEfficiency FromLitersPer100Kilometers(QuantityValue litersper1 /// If value is NaN or Infinity. public static FuelEfficiency FromMilesPerUkGallon(QuantityValue milesperukgallon) { - QuantityValue value = (QuantityValue) milesperukgallon; + double value = (double) milesperukgallon; return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUkGallon); } @@ -278,7 +275,7 @@ public static FuelEfficiency FromMilesPerUkGallon(QuantityValue milesperukgallon /// If value is NaN or Infinity. public static FuelEfficiency FromMilesPerUsGallon(QuantityValue milesperusgallon) { - QuantityValue value = (QuantityValue) milesperusgallon; + double value = (double) milesperusgallon; return new FuelEfficiency(value, FuelEfficiencyUnit.MilePerUsGallon); } @@ -290,7 +287,7 @@ public static FuelEfficiency FromMilesPerUsGallon(QuantityValue milesperusgallon /// FuelEfficiency unit value. public static FuelEfficiency From(QuantityValue value, FuelEfficiencyUnit fromUnit) { - return new FuelEfficiency((QuantityValue)value, fromUnit); + return new FuelEfficiency((double)value, fromUnit); } #endregion @@ -460,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE } /// Get from multiplying value and . - public static FuelEfficiency operator *(QuantityValue left, FuelEfficiency right) + public static FuelEfficiency operator *(double left, FuelEfficiency right) { return new FuelEfficiency(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static FuelEfficiency operator *(FuelEfficiency left, QuantityValue right) + public static FuelEfficiency operator *(FuelEfficiency left, double right) { return new FuelEfficiency(left.Value * right, left.Unit); } /// Get from dividing by value. - public static FuelEfficiency operator /(FuelEfficiency left, QuantityValue right) + public static FuelEfficiency operator /(FuelEfficiency left, double right) { return new FuelEfficiency(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(FuelEfficiency left, FuelEfficiency right) + public static double operator /(FuelEfficiency left, FuelEfficiency right) { return left.LitersPer100Kilometers / right.LitersPer100Kilometers; } @@ -511,19 +508,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out FuelE return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(FuelEfficiency left, FuelEfficiency right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(FuelEfficiency left, FuelEfficiency right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,29 +520,7 @@ public int CompareTo(object obj) /// public int CompareTo(FuelEfficiency other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is FuelEfficiency objFuelEfficiency)) - return false; - return Equals(objFuelEfficiency); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(FuelEfficiency other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -601,13 +563,13 @@ public bool Equals(FuelEfficiency other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(FuelEfficiency other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(FuelEfficiency other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -618,7 +580,7 @@ public bool Equals(FuelEfficiency other, QuantityValue tolerance, ComparisonType /// A hash code for the current FuelEfficiency. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -629,16 +591,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(FuelEfficiencyUnit unit) + public double As(FuelEfficiencyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -653,12 +616,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is FuelEfficiencyUnit typedUnit)) + if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsFuelEfficiencyUnit); } /// @@ -690,7 +653,7 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (FuelEfficiency)converted; } - else if (Enum.IsDefined(typeof(FuelEfficiencyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -698,17 +661,17 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FuelEfficiencyUnit typedUnit)) + if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsFuelEfficiencyUnit, DefaultConversionFunctions); } /// @@ -735,10 +698,10 @@ public FuelEfficiency ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(FuelEfficiencyUnit unit) + private double GetValueAs(FuelEfficiencyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index be4d11404e..2b0f9a5278 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Heat flux is the flow of energy per unit of area per unit of time /// [DataContract] - public partial struct HeatFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -89,9 +89,9 @@ static HeatFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public HeatFlux(QuantityValue value, HeatFluxUnit unit) + public HeatFlux(double value, HeatFluxUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -103,14 +103,14 @@ public HeatFlux(QuantityValue value, HeatFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatFlux(QuantityValue value, UnitSystem unitSystem) + public HeatFlux(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -151,10 +151,7 @@ public HeatFlux(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -177,94 +174,94 @@ public HeatFlux(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); + public double BtusPerHourSquareFoot => As(HeatFluxUnit.BtuPerHourSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); + public double BtusPerMinuteSquareFoot => As(HeatFluxUnit.BtuPerMinuteSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); + public double BtusPerSecondSquareFoot => As(HeatFluxUnit.BtuPerSecondSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); + public double BtusPerSecondSquareInch => As(HeatFluxUnit.BtuPerSecondSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); + public double CaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.CaloriePerSecondSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); + public double CentiwattsPerSquareMeter => As(HeatFluxUnit.CentiwattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); + public double DeciwattsPerSquareMeter => As(HeatFluxUnit.DeciwattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); + public double KilocaloriesPerHourSquareMeter => As(HeatFluxUnit.KilocaloriePerHourSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); + public double KilocaloriesPerSecondSquareCentimeter => As(HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); + public double KilowattsPerSquareMeter => As(HeatFluxUnit.KilowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); + public double MicrowattsPerSquareMeter => As(HeatFluxUnit.MicrowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); + public double MilliwattsPerSquareMeter => As(HeatFluxUnit.MilliwattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); + public double NanowattsPerSquareMeter => As(HeatFluxUnit.NanowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); + public double PoundsForcePerFootSecond => As(HeatFluxUnit.PoundForcePerFootSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); + public double PoundsPerSecondCubed => As(HeatFluxUnit.PoundPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); + public double WattsPerSquareFoot => As(HeatFluxUnit.WattPerSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); + public double WattsPerSquareInch => As(HeatFluxUnit.WattPerSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); + public double WattsPerSquareMeter => As(HeatFluxUnit.WattPerSquareMeter); #endregion @@ -371,7 +368,7 @@ public static string GetAbbreviation(HeatFluxUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue btusperhoursquarefoot) { - QuantityValue value = (QuantityValue) btusperhoursquarefoot; + double value = (double) btusperhoursquarefoot; return new HeatFlux(value, HeatFluxUnit.BtuPerHourSquareFoot); } @@ -381,7 +378,7 @@ public static HeatFlux FromBtusPerHourSquareFoot(QuantityValue btusperhoursquare /// If value is NaN or Infinity. public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue btusperminutesquarefoot) { - QuantityValue value = (QuantityValue) btusperminutesquarefoot; + double value = (double) btusperminutesquarefoot; return new HeatFlux(value, HeatFluxUnit.BtuPerMinuteSquareFoot); } @@ -391,7 +388,7 @@ public static HeatFlux FromBtusPerMinuteSquareFoot(QuantityValue btusperminutesq /// If value is NaN or Infinity. public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue btuspersecondsquarefoot) { - QuantityValue value = (QuantityValue) btuspersecondsquarefoot; + double value = (double) btuspersecondsquarefoot; return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareFoot); } @@ -401,7 +398,7 @@ public static HeatFlux FromBtusPerSecondSquareFoot(QuantityValue btuspersecondsq /// If value is NaN or Infinity. public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue btuspersecondsquareinch) { - QuantityValue value = (QuantityValue) btuspersecondsquareinch; + double value = (double) btuspersecondsquareinch; return new HeatFlux(value, HeatFluxUnit.BtuPerSecondSquareInch); } @@ -411,7 +408,7 @@ public static HeatFlux FromBtusPerSecondSquareInch(QuantityValue btuspersecondsq /// If value is NaN or Infinity. public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue caloriespersecondsquarecentimeter) { - QuantityValue value = (QuantityValue) caloriespersecondsquarecentimeter; + double value = (double) caloriespersecondsquarecentimeter; return new HeatFlux(value, HeatFluxUnit.CaloriePerSecondSquareCentimeter); } @@ -421,7 +418,7 @@ public static HeatFlux FromCaloriesPerSecondSquareCentimeter(QuantityValue calor /// If value is NaN or Infinity. public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue centiwattspersquaremeter) { - QuantityValue value = (QuantityValue) centiwattspersquaremeter; + double value = (double) centiwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.CentiwattPerSquareMeter); } @@ -431,7 +428,7 @@ public static HeatFlux FromCentiwattsPerSquareMeter(QuantityValue centiwattspers /// If value is NaN or Infinity. public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue deciwattspersquaremeter) { - QuantityValue value = (QuantityValue) deciwattspersquaremeter; + double value = (double) deciwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.DeciwattPerSquareMeter); } @@ -441,7 +438,7 @@ public static HeatFlux FromDeciwattsPerSquareMeter(QuantityValue deciwattspersqu /// If value is NaN or Infinity. public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue kilocaloriesperhoursquaremeter) { - QuantityValue value = (QuantityValue) kilocaloriesperhoursquaremeter; + double value = (double) kilocaloriesperhoursquaremeter; return new HeatFlux(value, HeatFluxUnit.KilocaloriePerHourSquareMeter); } @@ -451,7 +448,7 @@ public static HeatFlux FromKilocaloriesPerHourSquareMeter(QuantityValue kilocalo /// If value is NaN or Infinity. public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue kilocaloriespersecondsquarecentimeter) { - QuantityValue value = (QuantityValue) kilocaloriespersecondsquarecentimeter; + double value = (double) kilocaloriespersecondsquarecentimeter; return new HeatFlux(value, HeatFluxUnit.KilocaloriePerSecondSquareCentimeter); } @@ -461,7 +458,7 @@ public static HeatFlux FromKilocaloriesPerSecondSquareCentimeter(QuantityValue k /// If value is NaN or Infinity. public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter) { - QuantityValue value = (QuantityValue) kilowattspersquaremeter; + double value = (double) kilowattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.KilowattPerSquareMeter); } @@ -471,7 +468,7 @@ public static HeatFlux FromKilowattsPerSquareMeter(QuantityValue kilowattspersqu /// If value is NaN or Infinity. public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter) { - QuantityValue value = (QuantityValue) microwattspersquaremeter; + double value = (double) microwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.MicrowattPerSquareMeter); } @@ -481,7 +478,7 @@ public static HeatFlux FromMicrowattsPerSquareMeter(QuantityValue microwattspers /// If value is NaN or Infinity. public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter) { - QuantityValue value = (QuantityValue) milliwattspersquaremeter; + double value = (double) milliwattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.MilliwattPerSquareMeter); } @@ -491,7 +488,7 @@ public static HeatFlux FromMilliwattsPerSquareMeter(QuantityValue milliwattspers /// If value is NaN or Infinity. public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter) { - QuantityValue value = (QuantityValue) nanowattspersquaremeter; + double value = (double) nanowattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.NanowattPerSquareMeter); } @@ -501,7 +498,7 @@ public static HeatFlux FromNanowattsPerSquareMeter(QuantityValue nanowattspersqu /// If value is NaN or Infinity. public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue poundsforceperfootsecond) { - QuantityValue value = (QuantityValue) poundsforceperfootsecond; + double value = (double) poundsforceperfootsecond; return new HeatFlux(value, HeatFluxUnit.PoundForcePerFootSecond); } @@ -511,7 +508,7 @@ public static HeatFlux FromPoundsForcePerFootSecond(QuantityValue poundsforceper /// If value is NaN or Infinity. public static HeatFlux FromPoundsPerSecondCubed(QuantityValue poundspersecondcubed) { - QuantityValue value = (QuantityValue) poundspersecondcubed; + double value = (double) poundspersecondcubed; return new HeatFlux(value, HeatFluxUnit.PoundPerSecondCubed); } @@ -521,7 +518,7 @@ public static HeatFlux FromPoundsPerSecondCubed(QuantityValue poundspersecondcub /// If value is NaN or Infinity. public static HeatFlux FromWattsPerSquareFoot(QuantityValue wattspersquarefoot) { - QuantityValue value = (QuantityValue) wattspersquarefoot; + double value = (double) wattspersquarefoot; return new HeatFlux(value, HeatFluxUnit.WattPerSquareFoot); } @@ -531,7 +528,7 @@ public static HeatFlux FromWattsPerSquareFoot(QuantityValue wattspersquarefoot) /// If value is NaN or Infinity. public static HeatFlux FromWattsPerSquareInch(QuantityValue wattspersquareinch) { - QuantityValue value = (QuantityValue) wattspersquareinch; + double value = (double) wattspersquareinch; return new HeatFlux(value, HeatFluxUnit.WattPerSquareInch); } @@ -541,7 +538,7 @@ public static HeatFlux FromWattsPerSquareInch(QuantityValue wattspersquareinch) /// If value is NaN or Infinity. public static HeatFlux FromWattsPerSquareMeter(QuantityValue wattspersquaremeter) { - QuantityValue value = (QuantityValue) wattspersquaremeter; + double value = (double) wattspersquaremeter; return new HeatFlux(value, HeatFluxUnit.WattPerSquareMeter); } @@ -553,7 +550,7 @@ public static HeatFlux FromWattsPerSquareMeter(QuantityValue wattspersquaremeter /// HeatFlux unit value. public static HeatFlux From(QuantityValue value, HeatFluxUnit fromUnit) { - return new HeatFlux((QuantityValue)value, fromUnit); + return new HeatFlux((double)value, fromUnit); } #endregion @@ -723,25 +720,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF } /// Get from multiplying value and . - public static HeatFlux operator *(QuantityValue left, HeatFlux right) + public static HeatFlux operator *(double left, HeatFlux right) { return new HeatFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static HeatFlux operator *(HeatFlux left, QuantityValue right) + public static HeatFlux operator *(HeatFlux left, double right) { return new HeatFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static HeatFlux operator /(HeatFlux left, QuantityValue right) + public static HeatFlux operator /(HeatFlux left, double right) { return new HeatFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(HeatFlux left, HeatFlux right) + public static double operator /(HeatFlux left, HeatFlux right) { return left.WattsPerSquareMeter / right.WattsPerSquareMeter; } @@ -774,19 +771,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatFlux left, HeatFlux right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatFlux left, HeatFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -799,29 +783,7 @@ public int CompareTo(object obj) /// public int CompareTo(HeatFlux other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is HeatFlux objHeatFlux)) - return false; - return Equals(objHeatFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatFlux other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -864,13 +826,13 @@ public bool Equals(HeatFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatFlux other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -881,7 +843,7 @@ public bool Equals(HeatFlux other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current HeatFlux. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -892,16 +854,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(HeatFluxUnit unit) + public double As(HeatFluxUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -916,12 +879,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is HeatFluxUnit typedUnit)) + if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsHeatFluxUnit); } /// @@ -953,7 +916,7 @@ public HeatFlux ToUnit(HeatFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (HeatFlux)converted; } - else if (Enum.IsDefined(typeof(HeatFluxUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -961,17 +924,17 @@ public HeatFlux ToUnit(HeatFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatFluxUnit typedUnit)) + if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsHeatFluxUnit, DefaultConversionFunctions); } /// @@ -998,10 +961,10 @@ public HeatFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(HeatFluxUnit unit) + private double GetValueAs(HeatFluxUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 39919d552c..2e7f448c7b 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The heat transfer coefficient or film coefficient, or film effectiveness, in thermodynamics and in mechanics is the proportionality constant between the heat flux and the thermodynamic driving force for the flow of heat (i.e., the temperature difference, ΔT) /// [DataContract] - public partial struct HeatTransferCoefficient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct HeatTransferCoefficient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static HeatTransferCoefficient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public HeatTransferCoefficient(QuantityValue value, HeatTransferCoefficientUnit unit) + public HeatTransferCoefficient(double value, HeatTransferCoefficientUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public HeatTransferCoefficient(QuantityValue value, HeatTransferCoefficientUnit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public HeatTransferCoefficient(QuantityValue value, UnitSystem unitSystem) + public HeatTransferCoefficient(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public HeatTransferCoefficient(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public HeatTransferCoefficient(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); + public double BtusPerSquareFootDegreeFahrenheit => As(HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); + public double WattsPerSquareMeterCelsius => As(HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); + public double WattsPerSquareMeterKelvin => As(HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(HeatTransferCoefficientUnit unit, IFormatPr /// If value is NaN or Infinity. public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(QuantityValue btuspersquarefootdegreefahrenheit) { - QuantityValue value = (QuantityValue) btuspersquarefootdegreefahrenheit; + double value = (double) btuspersquarefootdegreefahrenheit; return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.BtuPerSquareFootDegreeFahrenheit); } @@ -246,7 +243,7 @@ public static HeatTransferCoefficient FromBtusPerSquareFootDegreeFahrenheit(Quan /// If value is NaN or Infinity. public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityValue wattspersquaremetercelsius) { - QuantityValue value = (QuantityValue) wattspersquaremetercelsius; + double value = (double) wattspersquaremetercelsius; return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterCelsius); } @@ -256,7 +253,7 @@ public static HeatTransferCoefficient FromWattsPerSquareMeterCelsius(QuantityVal /// If value is NaN or Infinity. public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValue wattspersquaremeterkelvin) { - QuantityValue value = (QuantityValue) wattspersquaremeterkelvin; + double value = (double) wattspersquaremeterkelvin; return new HeatTransferCoefficient(value, HeatTransferCoefficientUnit.WattPerSquareMeterKelvin); } @@ -268,7 +265,7 @@ public static HeatTransferCoefficient FromWattsPerSquareMeterKelvin(QuantityValu /// HeatTransferCoefficient unit value. public static HeatTransferCoefficient From(QuantityValue value, HeatTransferCoefficientUnit fromUnit) { - return new HeatTransferCoefficient((QuantityValue)value, fromUnit); + return new HeatTransferCoefficient((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT } /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(QuantityValue left, HeatTransferCoefficient right) + public static HeatTransferCoefficient operator *(double left, HeatTransferCoefficient right) { return new HeatTransferCoefficient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, QuantityValue right) + public static HeatTransferCoefficient operator *(HeatTransferCoefficient left, double right) { return new HeatTransferCoefficient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, QuantityValue right) + public static HeatTransferCoefficient operator /(HeatTransferCoefficient left, double right) { return new HeatTransferCoefficient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) + public static double operator /(HeatTransferCoefficient left, HeatTransferCoefficient right) { return left.WattsPerSquareMeterKelvin / right.WattsPerSquareMeterKelvin; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out HeatT return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(HeatTransferCoefficient left, HeatTransferCoefficient right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(HeatTransferCoefficient left, HeatTransferCoefficient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(HeatTransferCoefficient other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is HeatTransferCoefficient objHeatTransferCoefficient)) - return false; - return Equals(objHeatTransferCoefficient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(HeatTransferCoefficient other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(HeatTransferCoefficient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(HeatTransferCoefficient other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(HeatTransferCoefficient other, QuantityValue tolerance, Compa /// A hash code for the current HeatTransferCoefficient. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(HeatTransferCoefficientUnit unit) + public double As(HeatTransferCoefficientUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit typedUnit)) + if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsHeatTransferCoefficientUnit); } /// @@ -668,7 +631,7 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit, UnitConv var converted = conversionFunction(this); return (HeatTransferCoefficient)converted; } - else if (Enum.IsDefined(typeof(HeatTransferCoefficientUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit, UnitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit typedUnit)) + if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsHeatTransferCoefficientUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public HeatTransferCoefficient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(HeatTransferCoefficientUnit unit) + private double GetValueAs(HeatTransferCoefficientUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 66cc8c75f6..304d11ab4d 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Illuminance /// [DataContract] - public partial struct Illuminance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Illuminance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static Illuminance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Illuminance(QuantityValue value, IlluminanceUnit unit) + public Illuminance(double value, IlluminanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public Illuminance(QuantityValue value, IlluminanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Illuminance(QuantityValue value, UnitSystem unitSystem) + public Illuminance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public Illuminance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,24 +163,24 @@ public Illuminance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilolux => As(IlluminanceUnit.Kilolux); + public double Kilolux => As(IlluminanceUnit.Kilolux); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Lux => As(IlluminanceUnit.Lux); + public double Lux => As(IlluminanceUnit.Lux); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megalux => As(IlluminanceUnit.Megalux); + public double Megalux => As(IlluminanceUnit.Megalux); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millilux => As(IlluminanceUnit.Millilux); + public double Millilux => As(IlluminanceUnit.Millilux); #endregion @@ -248,7 +245,7 @@ public static string GetAbbreviation(IlluminanceUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Illuminance FromKilolux(QuantityValue kilolux) { - QuantityValue value = (QuantityValue) kilolux; + double value = (double) kilolux; return new Illuminance(value, IlluminanceUnit.Kilolux); } @@ -258,7 +255,7 @@ public static Illuminance FromKilolux(QuantityValue kilolux) /// If value is NaN or Infinity. public static Illuminance FromLux(QuantityValue lux) { - QuantityValue value = (QuantityValue) lux; + double value = (double) lux; return new Illuminance(value, IlluminanceUnit.Lux); } @@ -268,7 +265,7 @@ public static Illuminance FromLux(QuantityValue lux) /// If value is NaN or Infinity. public static Illuminance FromMegalux(QuantityValue megalux) { - QuantityValue value = (QuantityValue) megalux; + double value = (double) megalux; return new Illuminance(value, IlluminanceUnit.Megalux); } @@ -278,7 +275,7 @@ public static Illuminance FromMegalux(QuantityValue megalux) /// If value is NaN or Infinity. public static Illuminance FromMillilux(QuantityValue millilux) { - QuantityValue value = (QuantityValue) millilux; + double value = (double) millilux; return new Illuminance(value, IlluminanceUnit.Millilux); } @@ -290,7 +287,7 @@ public static Illuminance FromMillilux(QuantityValue millilux) /// Illuminance unit value. public static Illuminance From(QuantityValue value, IlluminanceUnit fromUnit) { - return new Illuminance((QuantityValue)value, fromUnit); + return new Illuminance((double)value, fromUnit); } #endregion @@ -460,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum } /// Get from multiplying value and . - public static Illuminance operator *(QuantityValue left, Illuminance right) + public static Illuminance operator *(double left, Illuminance right) { return new Illuminance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Illuminance operator *(Illuminance left, QuantityValue right) + public static Illuminance operator *(Illuminance left, double right) { return new Illuminance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Illuminance operator /(Illuminance left, QuantityValue right) + public static Illuminance operator /(Illuminance left, double right) { return new Illuminance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Illuminance left, Illuminance right) + public static double operator /(Illuminance left, Illuminance right) { return left.Lux / right.Lux; } @@ -511,19 +508,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Illum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Illuminance left, Illuminance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Illuminance left, Illuminance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,29 +520,7 @@ public int CompareTo(object obj) /// public int CompareTo(Illuminance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Illuminance objIlluminance)) - return false; - return Equals(objIlluminance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Illuminance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -601,13 +563,13 @@ public bool Equals(Illuminance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Illuminance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Illuminance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -618,7 +580,7 @@ public bool Equals(Illuminance other, QuantityValue tolerance, ComparisonType co /// A hash code for the current Illuminance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -629,16 +591,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(IlluminanceUnit unit) + public double As(IlluminanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -653,12 +616,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is IlluminanceUnit typedUnit)) + if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsIlluminanceUnit); } /// @@ -690,7 +653,7 @@ public Illuminance ToUnit(IlluminanceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Illuminance)converted; } - else if (Enum.IsDefined(typeof(IlluminanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -698,17 +661,17 @@ public Illuminance ToUnit(IlluminanceUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IlluminanceUnit typedUnit)) + if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsIlluminanceUnit, DefaultConversionFunctions); } /// @@ -735,10 +698,10 @@ public Illuminance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(IlluminanceUnit unit) + private double GetValueAs(IlluminanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 1c0f90b38f..880f4a52fb 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In computing and telecommunications, a unit of information is the capacity of some standard data storage system or communication channel, used to measure the capacities of other systems and channels. In information theory, units of information are also used to measure the information contents or entropy of random variables. /// [DataContract] - public partial struct Information : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Information : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly decimal _value; /// /// The unit this quantity was constructed with. @@ -97,7 +97,7 @@ static Information() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Information(QuantityValue value, InformationUnit unit) + public Information(decimal value, InformationUnit unit) { _value = value; _unit = unit; @@ -111,7 +111,7 @@ public Information(QuantityValue value, InformationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Information(QuantityValue value, UnitSystem unitSystem) + public Information(decimal value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,13 +159,12 @@ public Information(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; + public decimal Value => _value; - /// - QuantityValue IQuantity.Value => _value; + double IQuantity.Value => (double) _value; /// - decimal IDecimalQuantity.Value => (decimal)_value; + decimal IDecimalQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -188,134 +187,134 @@ public Information(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Bits => As(InformationUnit.Bit); + public double Bits => As(InformationUnit.Bit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Bytes => As(InformationUnit.Byte); + public double Bytes => As(InformationUnit.Byte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Exabits => As(InformationUnit.Exabit); + public double Exabits => As(InformationUnit.Exabit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Exabytes => As(InformationUnit.Exabyte); + public double Exabytes => As(InformationUnit.Exabyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Exbibits => As(InformationUnit.Exbibit); + public double Exbibits => As(InformationUnit.Exbibit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Exbibytes => As(InformationUnit.Exbibyte); + public double Exbibytes => As(InformationUnit.Exbibyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gibibits => As(InformationUnit.Gibibit); + public double Gibibits => As(InformationUnit.Gibibit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gibibytes => As(InformationUnit.Gibibyte); + public double Gibibytes => As(InformationUnit.Gibibyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigabits => As(InformationUnit.Gigabit); + public double Gigabits => As(InformationUnit.Gigabit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigabytes => As(InformationUnit.Gigabyte); + public double Gigabytes => As(InformationUnit.Gigabyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kibibits => As(InformationUnit.Kibibit); + public double Kibibits => As(InformationUnit.Kibibit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kibibytes => As(InformationUnit.Kibibyte); + public double Kibibytes => As(InformationUnit.Kibibyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilobits => As(InformationUnit.Kilobit); + public double Kilobits => As(InformationUnit.Kilobit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilobytes => As(InformationUnit.Kilobyte); + public double Kilobytes => As(InformationUnit.Kilobyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Mebibits => As(InformationUnit.Mebibit); + public double Mebibits => As(InformationUnit.Mebibit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Mebibytes => As(InformationUnit.Mebibyte); + public double Mebibytes => As(InformationUnit.Mebibyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megabits => As(InformationUnit.Megabit); + public double Megabits => As(InformationUnit.Megabit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megabytes => As(InformationUnit.Megabyte); + public double Megabytes => As(InformationUnit.Megabyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Pebibits => As(InformationUnit.Pebibit); + public double Pebibits => As(InformationUnit.Pebibit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Pebibytes => As(InformationUnit.Pebibyte); + public double Pebibytes => As(InformationUnit.Pebibyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Petabits => As(InformationUnit.Petabit); + public double Petabits => As(InformationUnit.Petabit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Petabytes => As(InformationUnit.Petabyte); + public double Petabytes => As(InformationUnit.Petabyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Tebibits => As(InformationUnit.Tebibit); + public double Tebibits => As(InformationUnit.Tebibit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Tebibytes => As(InformationUnit.Tebibyte); + public double Tebibytes => As(InformationUnit.Tebibyte); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Terabits => As(InformationUnit.Terabit); + public double Terabits => As(InformationUnit.Terabit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Terabytes => As(InformationUnit.Terabyte); + public double Terabytes => As(InformationUnit.Terabyte); #endregion @@ -446,7 +445,7 @@ public static string GetAbbreviation(InformationUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Information FromBits(QuantityValue bits) { - QuantityValue value = (QuantityValue) bits; + decimal value = (decimal) bits; return new Information(value, InformationUnit.Bit); } @@ -456,7 +455,7 @@ public static Information FromBits(QuantityValue bits) /// If value is NaN or Infinity. public static Information FromBytes(QuantityValue bytes) { - QuantityValue value = (QuantityValue) bytes; + decimal value = (decimal) bytes; return new Information(value, InformationUnit.Byte); } @@ -466,7 +465,7 @@ public static Information FromBytes(QuantityValue bytes) /// If value is NaN or Infinity. public static Information FromExabits(QuantityValue exabits) { - QuantityValue value = (QuantityValue) exabits; + decimal value = (decimal) exabits; return new Information(value, InformationUnit.Exabit); } @@ -476,7 +475,7 @@ public static Information FromExabits(QuantityValue exabits) /// If value is NaN or Infinity. public static Information FromExabytes(QuantityValue exabytes) { - QuantityValue value = (QuantityValue) exabytes; + decimal value = (decimal) exabytes; return new Information(value, InformationUnit.Exabyte); } @@ -486,7 +485,7 @@ public static Information FromExabytes(QuantityValue exabytes) /// If value is NaN or Infinity. public static Information FromExbibits(QuantityValue exbibits) { - QuantityValue value = (QuantityValue) exbibits; + decimal value = (decimal) exbibits; return new Information(value, InformationUnit.Exbibit); } @@ -496,7 +495,7 @@ public static Information FromExbibits(QuantityValue exbibits) /// If value is NaN or Infinity. public static Information FromExbibytes(QuantityValue exbibytes) { - QuantityValue value = (QuantityValue) exbibytes; + decimal value = (decimal) exbibytes; return new Information(value, InformationUnit.Exbibyte); } @@ -506,7 +505,7 @@ public static Information FromExbibytes(QuantityValue exbibytes) /// If value is NaN or Infinity. public static Information FromGibibits(QuantityValue gibibits) { - QuantityValue value = (QuantityValue) gibibits; + decimal value = (decimal) gibibits; return new Information(value, InformationUnit.Gibibit); } @@ -516,7 +515,7 @@ public static Information FromGibibits(QuantityValue gibibits) /// If value is NaN or Infinity. public static Information FromGibibytes(QuantityValue gibibytes) { - QuantityValue value = (QuantityValue) gibibytes; + decimal value = (decimal) gibibytes; return new Information(value, InformationUnit.Gibibyte); } @@ -526,7 +525,7 @@ public static Information FromGibibytes(QuantityValue gibibytes) /// If value is NaN or Infinity. public static Information FromGigabits(QuantityValue gigabits) { - QuantityValue value = (QuantityValue) gigabits; + decimal value = (decimal) gigabits; return new Information(value, InformationUnit.Gigabit); } @@ -536,7 +535,7 @@ public static Information FromGigabits(QuantityValue gigabits) /// If value is NaN or Infinity. public static Information FromGigabytes(QuantityValue gigabytes) { - QuantityValue value = (QuantityValue) gigabytes; + decimal value = (decimal) gigabytes; return new Information(value, InformationUnit.Gigabyte); } @@ -546,7 +545,7 @@ public static Information FromGigabytes(QuantityValue gigabytes) /// If value is NaN or Infinity. public static Information FromKibibits(QuantityValue kibibits) { - QuantityValue value = (QuantityValue) kibibits; + decimal value = (decimal) kibibits; return new Information(value, InformationUnit.Kibibit); } @@ -556,7 +555,7 @@ public static Information FromKibibits(QuantityValue kibibits) /// If value is NaN or Infinity. public static Information FromKibibytes(QuantityValue kibibytes) { - QuantityValue value = (QuantityValue) kibibytes; + decimal value = (decimal) kibibytes; return new Information(value, InformationUnit.Kibibyte); } @@ -566,7 +565,7 @@ public static Information FromKibibytes(QuantityValue kibibytes) /// If value is NaN or Infinity. public static Information FromKilobits(QuantityValue kilobits) { - QuantityValue value = (QuantityValue) kilobits; + decimal value = (decimal) kilobits; return new Information(value, InformationUnit.Kilobit); } @@ -576,7 +575,7 @@ public static Information FromKilobits(QuantityValue kilobits) /// If value is NaN or Infinity. public static Information FromKilobytes(QuantityValue kilobytes) { - QuantityValue value = (QuantityValue) kilobytes; + decimal value = (decimal) kilobytes; return new Information(value, InformationUnit.Kilobyte); } @@ -586,7 +585,7 @@ public static Information FromKilobytes(QuantityValue kilobytes) /// If value is NaN or Infinity. public static Information FromMebibits(QuantityValue mebibits) { - QuantityValue value = (QuantityValue) mebibits; + decimal value = (decimal) mebibits; return new Information(value, InformationUnit.Mebibit); } @@ -596,7 +595,7 @@ public static Information FromMebibits(QuantityValue mebibits) /// If value is NaN or Infinity. public static Information FromMebibytes(QuantityValue mebibytes) { - QuantityValue value = (QuantityValue) mebibytes; + decimal value = (decimal) mebibytes; return new Information(value, InformationUnit.Mebibyte); } @@ -606,7 +605,7 @@ public static Information FromMebibytes(QuantityValue mebibytes) /// If value is NaN or Infinity. public static Information FromMegabits(QuantityValue megabits) { - QuantityValue value = (QuantityValue) megabits; + decimal value = (decimal) megabits; return new Information(value, InformationUnit.Megabit); } @@ -616,7 +615,7 @@ public static Information FromMegabits(QuantityValue megabits) /// If value is NaN or Infinity. public static Information FromMegabytes(QuantityValue megabytes) { - QuantityValue value = (QuantityValue) megabytes; + decimal value = (decimal) megabytes; return new Information(value, InformationUnit.Megabyte); } @@ -626,7 +625,7 @@ public static Information FromMegabytes(QuantityValue megabytes) /// If value is NaN or Infinity. public static Information FromPebibits(QuantityValue pebibits) { - QuantityValue value = (QuantityValue) pebibits; + decimal value = (decimal) pebibits; return new Information(value, InformationUnit.Pebibit); } @@ -636,7 +635,7 @@ public static Information FromPebibits(QuantityValue pebibits) /// If value is NaN or Infinity. public static Information FromPebibytes(QuantityValue pebibytes) { - QuantityValue value = (QuantityValue) pebibytes; + decimal value = (decimal) pebibytes; return new Information(value, InformationUnit.Pebibyte); } @@ -646,7 +645,7 @@ public static Information FromPebibytes(QuantityValue pebibytes) /// If value is NaN or Infinity. public static Information FromPetabits(QuantityValue petabits) { - QuantityValue value = (QuantityValue) petabits; + decimal value = (decimal) petabits; return new Information(value, InformationUnit.Petabit); } @@ -656,7 +655,7 @@ public static Information FromPetabits(QuantityValue petabits) /// If value is NaN or Infinity. public static Information FromPetabytes(QuantityValue petabytes) { - QuantityValue value = (QuantityValue) petabytes; + decimal value = (decimal) petabytes; return new Information(value, InformationUnit.Petabyte); } @@ -666,7 +665,7 @@ public static Information FromPetabytes(QuantityValue petabytes) /// If value is NaN or Infinity. public static Information FromTebibits(QuantityValue tebibits) { - QuantityValue value = (QuantityValue) tebibits; + decimal value = (decimal) tebibits; return new Information(value, InformationUnit.Tebibit); } @@ -676,7 +675,7 @@ public static Information FromTebibits(QuantityValue tebibits) /// If value is NaN or Infinity. public static Information FromTebibytes(QuantityValue tebibytes) { - QuantityValue value = (QuantityValue) tebibytes; + decimal value = (decimal) tebibytes; return new Information(value, InformationUnit.Tebibyte); } @@ -686,7 +685,7 @@ public static Information FromTebibytes(QuantityValue tebibytes) /// If value is NaN or Infinity. public static Information FromTerabits(QuantityValue terabits) { - QuantityValue value = (QuantityValue) terabits; + decimal value = (decimal) terabits; return new Information(value, InformationUnit.Terabit); } @@ -696,7 +695,7 @@ public static Information FromTerabits(QuantityValue terabits) /// If value is NaN or Infinity. public static Information FromTerabytes(QuantityValue terabytes) { - QuantityValue value = (QuantityValue) terabytes; + decimal value = (decimal) terabytes; return new Information(value, InformationUnit.Terabyte); } @@ -708,7 +707,7 @@ public static Information FromTerabytes(QuantityValue terabytes) /// Information unit value. public static Information From(QuantityValue value, InformationUnit fromUnit) { - return new Information((QuantityValue)value, fromUnit); + return new Information((decimal)value, fromUnit); } #endregion @@ -878,25 +877,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor } /// Get from multiplying value and . - public static Information operator *(QuantityValue left, Information right) + public static Information operator *(decimal left, Information right) { return new Information(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Information operator *(Information left, QuantityValue right) + public static Information operator *(Information left, decimal right) { return new Information(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Information operator /(Information left, QuantityValue right) + public static Information operator /(Information left, decimal right) { return new Information(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Information left, Information right) + public static double operator /(Information left, Information right) { return left.Bits / right.Bits; } @@ -929,19 +928,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Information left, Information right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Information left, Information right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -954,29 +940,7 @@ public int CompareTo(object obj) /// public int CompareTo(Information other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Information objInformation)) - return false; - return Equals(objInformation); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Information other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1019,13 +983,13 @@ public bool Equals(Information other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Information other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Information other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1036,7 +1000,7 @@ public bool Equals(Information other, QuantityValue tolerance, ComparisonType co /// A hash code for the current Information. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1047,16 +1011,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(InformationUnit unit) + public double As(InformationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1071,12 +1036,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is InformationUnit typedUnit)) + if (!(unit is InformationUnit unitAsInformationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsInformationUnit); } /// @@ -1108,7 +1073,7 @@ public Information ToUnit(InformationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Information)converted; } - else if (Enum.IsDefined(typeof(InformationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1116,17 +1081,17 @@ public Information ToUnit(InformationUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is InformationUnit typedUnit)) + if (!(unit is InformationUnit unitAsInformationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsInformationUnit, DefaultConversionFunctions); } /// @@ -1153,10 +1118,10 @@ public Information ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(InformationUnit unit) + private decimal GetValueAs(InformationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (decimal)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index 155555ecc5..f395d39318 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Irradiance is the intensity of ultraviolet (UV) or visible light incident on a surface. /// [DataContract] - public partial struct Irradiance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static Irradiance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Irradiance(QuantityValue value, IrradianceUnit unit) + public Irradiance(double value, IrradianceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -99,14 +99,14 @@ public Irradiance(QuantityValue value, IrradianceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiance(QuantityValue value, UnitSystem unitSystem) + public Irradiance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,10 +147,7 @@ public Irradiance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +170,74 @@ public Irradiance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); + public double KilowattsPerSquareCentimeter => As(IrradianceUnit.KilowattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); + public double KilowattsPerSquareMeter => As(IrradianceUnit.KilowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); + public double MegawattsPerSquareCentimeter => As(IrradianceUnit.MegawattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); + public double MegawattsPerSquareMeter => As(IrradianceUnit.MegawattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); + public double MicrowattsPerSquareCentimeter => As(IrradianceUnit.MicrowattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); + public double MicrowattsPerSquareMeter => As(IrradianceUnit.MicrowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); + public double MilliwattsPerSquareCentimeter => As(IrradianceUnit.MilliwattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); + public double MilliwattsPerSquareMeter => As(IrradianceUnit.MilliwattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); + public double NanowattsPerSquareCentimeter => As(IrradianceUnit.NanowattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); + public double NanowattsPerSquareMeter => As(IrradianceUnit.NanowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); + public double PicowattsPerSquareCentimeter => As(IrradianceUnit.PicowattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); + public double PicowattsPerSquareMeter => As(IrradianceUnit.PicowattPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); + public double WattsPerSquareCentimeter => As(IrradianceUnit.WattPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); + public double WattsPerSquareMeter => As(IrradianceUnit.WattPerSquareMeter); #endregion @@ -335,7 +332,7 @@ public static string GetAbbreviation(IrradianceUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static Irradiance FromKilowattsPerSquareCentimeter(QuantityValue kilowattspersquarecentimeter) { - QuantityValue value = (QuantityValue) kilowattspersquarecentimeter; + double value = (double) kilowattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.KilowattPerSquareCentimeter); } @@ -345,7 +342,7 @@ public static Irradiance FromKilowattsPerSquareCentimeter(QuantityValue kilowatt /// If value is NaN or Infinity. public static Irradiance FromKilowattsPerSquareMeter(QuantityValue kilowattspersquaremeter) { - QuantityValue value = (QuantityValue) kilowattspersquaremeter; + double value = (double) kilowattspersquaremeter; return new Irradiance(value, IrradianceUnit.KilowattPerSquareMeter); } @@ -355,7 +352,7 @@ public static Irradiance FromKilowattsPerSquareMeter(QuantityValue kilowattspers /// If value is NaN or Infinity. public static Irradiance FromMegawattsPerSquareCentimeter(QuantityValue megawattspersquarecentimeter) { - QuantityValue value = (QuantityValue) megawattspersquarecentimeter; + double value = (double) megawattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.MegawattPerSquareCentimeter); } @@ -365,7 +362,7 @@ public static Irradiance FromMegawattsPerSquareCentimeter(QuantityValue megawatt /// If value is NaN or Infinity. public static Irradiance FromMegawattsPerSquareMeter(QuantityValue megawattspersquaremeter) { - QuantityValue value = (QuantityValue) megawattspersquaremeter; + double value = (double) megawattspersquaremeter; return new Irradiance(value, IrradianceUnit.MegawattPerSquareMeter); } @@ -375,7 +372,7 @@ public static Irradiance FromMegawattsPerSquareMeter(QuantityValue megawattspers /// If value is NaN or Infinity. public static Irradiance FromMicrowattsPerSquareCentimeter(QuantityValue microwattspersquarecentimeter) { - QuantityValue value = (QuantityValue) microwattspersquarecentimeter; + double value = (double) microwattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.MicrowattPerSquareCentimeter); } @@ -385,7 +382,7 @@ public static Irradiance FromMicrowattsPerSquareCentimeter(QuantityValue microwa /// If value is NaN or Infinity. public static Irradiance FromMicrowattsPerSquareMeter(QuantityValue microwattspersquaremeter) { - QuantityValue value = (QuantityValue) microwattspersquaremeter; + double value = (double) microwattspersquaremeter; return new Irradiance(value, IrradianceUnit.MicrowattPerSquareMeter); } @@ -395,7 +392,7 @@ public static Irradiance FromMicrowattsPerSquareMeter(QuantityValue microwattspe /// If value is NaN or Infinity. public static Irradiance FromMilliwattsPerSquareCentimeter(QuantityValue milliwattspersquarecentimeter) { - QuantityValue value = (QuantityValue) milliwattspersquarecentimeter; + double value = (double) milliwattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.MilliwattPerSquareCentimeter); } @@ -405,7 +402,7 @@ public static Irradiance FromMilliwattsPerSquareCentimeter(QuantityValue milliwa /// If value is NaN or Infinity. public static Irradiance FromMilliwattsPerSquareMeter(QuantityValue milliwattspersquaremeter) { - QuantityValue value = (QuantityValue) milliwattspersquaremeter; + double value = (double) milliwattspersquaremeter; return new Irradiance(value, IrradianceUnit.MilliwattPerSquareMeter); } @@ -415,7 +412,7 @@ public static Irradiance FromMilliwattsPerSquareMeter(QuantityValue milliwattspe /// If value is NaN or Infinity. public static Irradiance FromNanowattsPerSquareCentimeter(QuantityValue nanowattspersquarecentimeter) { - QuantityValue value = (QuantityValue) nanowattspersquarecentimeter; + double value = (double) nanowattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.NanowattPerSquareCentimeter); } @@ -425,7 +422,7 @@ public static Irradiance FromNanowattsPerSquareCentimeter(QuantityValue nanowatt /// If value is NaN or Infinity. public static Irradiance FromNanowattsPerSquareMeter(QuantityValue nanowattspersquaremeter) { - QuantityValue value = (QuantityValue) nanowattspersquaremeter; + double value = (double) nanowattspersquaremeter; return new Irradiance(value, IrradianceUnit.NanowattPerSquareMeter); } @@ -435,7 +432,7 @@ public static Irradiance FromNanowattsPerSquareMeter(QuantityValue nanowattspers /// If value is NaN or Infinity. public static Irradiance FromPicowattsPerSquareCentimeter(QuantityValue picowattspersquarecentimeter) { - QuantityValue value = (QuantityValue) picowattspersquarecentimeter; + double value = (double) picowattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.PicowattPerSquareCentimeter); } @@ -445,7 +442,7 @@ public static Irradiance FromPicowattsPerSquareCentimeter(QuantityValue picowatt /// If value is NaN or Infinity. public static Irradiance FromPicowattsPerSquareMeter(QuantityValue picowattspersquaremeter) { - QuantityValue value = (QuantityValue) picowattspersquaremeter; + double value = (double) picowattspersquaremeter; return new Irradiance(value, IrradianceUnit.PicowattPerSquareMeter); } @@ -455,7 +452,7 @@ public static Irradiance FromPicowattsPerSquareMeter(QuantityValue picowattspers /// If value is NaN or Infinity. public static Irradiance FromWattsPerSquareCentimeter(QuantityValue wattspersquarecentimeter) { - QuantityValue value = (QuantityValue) wattspersquarecentimeter; + double value = (double) wattspersquarecentimeter; return new Irradiance(value, IrradianceUnit.WattPerSquareCentimeter); } @@ -465,7 +462,7 @@ public static Irradiance FromWattsPerSquareCentimeter(QuantityValue wattspersqua /// If value is NaN or Infinity. public static Irradiance FromWattsPerSquareMeter(QuantityValue wattspersquaremeter) { - QuantityValue value = (QuantityValue) wattspersquaremeter; + double value = (double) wattspersquaremeter; return new Irradiance(value, IrradianceUnit.WattPerSquareMeter); } @@ -477,7 +474,7 @@ public static Irradiance FromWattsPerSquareMeter(QuantityValue wattspersquaremet /// Irradiance unit value. public static Irradiance From(QuantityValue value, IrradianceUnit fromUnit) { - return new Irradiance((QuantityValue)value, fromUnit); + return new Irradiance((double)value, fromUnit); } #endregion @@ -647,25 +644,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad } /// Get from multiplying value and . - public static Irradiance operator *(QuantityValue left, Irradiance right) + public static Irradiance operator *(double left, Irradiance right) { return new Irradiance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Irradiance operator *(Irradiance left, QuantityValue right) + public static Irradiance operator *(Irradiance left, double right) { return new Irradiance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Irradiance operator /(Irradiance left, QuantityValue right) + public static Irradiance operator /(Irradiance left, double right) { return new Irradiance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Irradiance left, Irradiance right) + public static double operator /(Irradiance left, Irradiance right) { return left.WattsPerSquareMeter / right.WattsPerSquareMeter; } @@ -698,19 +695,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiance left, Irradiance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiance left, Irradiance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -723,29 +707,7 @@ public int CompareTo(object obj) /// public int CompareTo(Irradiance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Irradiance objIrradiance)) - return false; - return Equals(objIrradiance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -788,13 +750,13 @@ public bool Equals(Irradiance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Irradiance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -805,7 +767,7 @@ public bool Equals(Irradiance other, QuantityValue tolerance, ComparisonType com /// A hash code for the current Irradiance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -816,16 +778,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(IrradianceUnit unit) + public double As(IrradianceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -840,12 +803,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is IrradianceUnit typedUnit)) + if (!(unit is IrradianceUnit unitAsIrradianceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsIrradianceUnit); } /// @@ -877,7 +840,7 @@ public Irradiance ToUnit(IrradianceUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Irradiance)converted; } - else if (Enum.IsDefined(typeof(IrradianceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -885,17 +848,17 @@ public Irradiance ToUnit(IrradianceUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradianceUnit typedUnit)) + if (!(unit is IrradianceUnit unitAsIrradianceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsIrradianceUnit, DefaultConversionFunctions); } /// @@ -922,10 +885,10 @@ public Irradiance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(IrradianceUnit unit) + private double GetValueAs(IrradianceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 943088a2af..9ddd5731b6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Irradiation /// [DataContract] - public partial struct Irradiation : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Irradiation : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static Irradiation() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Irradiation(QuantityValue value, IrradiationUnit unit) + public Irradiation(double value, IrradiationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -95,14 +95,14 @@ public Irradiation(QuantityValue value, IrradiationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Irradiation(QuantityValue value, UnitSystem unitSystem) + public Irradiation(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,10 +143,7 @@ public Irradiation(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -169,39 +166,39 @@ public Irradiation(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); + public double JoulesPerSquareCentimeter => As(IrradiationUnit.JoulePerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); + public double JoulesPerSquareMeter => As(IrradiationUnit.JoulePerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); + public double JoulesPerSquareMillimeter => As(IrradiationUnit.JoulePerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); + public double KilojoulesPerSquareMeter => As(IrradiationUnit.KilojoulePerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); + public double KilowattHoursPerSquareMeter => As(IrradiationUnit.KilowattHourPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); + public double MillijoulesPerSquareCentimeter => As(IrradiationUnit.MillijoulePerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); + public double WattHoursPerSquareMeter => As(IrradiationUnit.WattHourPerSquareMeter); #endregion @@ -275,7 +272,7 @@ public static string GetAbbreviation(IrradiationUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Irradiation FromJoulesPerSquareCentimeter(QuantityValue joulespersquarecentimeter) { - QuantityValue value = (QuantityValue) joulespersquarecentimeter; + double value = (double) joulespersquarecentimeter; return new Irradiation(value, IrradiationUnit.JoulePerSquareCentimeter); } @@ -285,7 +282,7 @@ public static Irradiation FromJoulesPerSquareCentimeter(QuantityValue joulespers /// If value is NaN or Infinity. public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquaremeter) { - QuantityValue value = (QuantityValue) joulespersquaremeter; + double value = (double) joulespersquaremeter; return new Irradiation(value, IrradiationUnit.JoulePerSquareMeter); } @@ -295,7 +292,7 @@ public static Irradiation FromJoulesPerSquareMeter(QuantityValue joulespersquare /// If value is NaN or Infinity. public static Irradiation FromJoulesPerSquareMillimeter(QuantityValue joulespersquaremillimeter) { - QuantityValue value = (QuantityValue) joulespersquaremillimeter; + double value = (double) joulespersquaremillimeter; return new Irradiation(value, IrradiationUnit.JoulePerSquareMillimeter); } @@ -305,7 +302,7 @@ public static Irradiation FromJoulesPerSquareMillimeter(QuantityValue joulespers /// If value is NaN or Infinity. public static Irradiation FromKilojoulesPerSquareMeter(QuantityValue kilojoulespersquaremeter) { - QuantityValue value = (QuantityValue) kilojoulespersquaremeter; + double value = (double) kilojoulespersquaremeter; return new Irradiation(value, IrradiationUnit.KilojoulePerSquareMeter); } @@ -315,7 +312,7 @@ public static Irradiation FromKilojoulesPerSquareMeter(QuantityValue kilojoulesp /// If value is NaN or Infinity. public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatthourspersquaremeter) { - QuantityValue value = (QuantityValue) kilowatthourspersquaremeter; + double value = (double) kilowatthourspersquaremeter; return new Irradiation(value, IrradiationUnit.KilowattHourPerSquareMeter); } @@ -325,7 +322,7 @@ public static Irradiation FromKilowattHoursPerSquareMeter(QuantityValue kilowatt /// If value is NaN or Infinity. public static Irradiation FromMillijoulesPerSquareCentimeter(QuantityValue millijoulespersquarecentimeter) { - QuantityValue value = (QuantityValue) millijoulespersquarecentimeter; + double value = (double) millijoulespersquarecentimeter; return new Irradiation(value, IrradiationUnit.MillijoulePerSquareCentimeter); } @@ -335,7 +332,7 @@ public static Irradiation FromMillijoulesPerSquareCentimeter(QuantityValue milli /// If value is NaN or Infinity. public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthourspersquaremeter) { - QuantityValue value = (QuantityValue) watthourspersquaremeter; + double value = (double) watthourspersquaremeter; return new Irradiation(value, IrradiationUnit.WattHourPerSquareMeter); } @@ -347,7 +344,7 @@ public static Irradiation FromWattHoursPerSquareMeter(QuantityValue watthoursper /// Irradiation unit value. public static Irradiation From(QuantityValue value, IrradiationUnit fromUnit) { - return new Irradiation((QuantityValue)value, fromUnit); + return new Irradiation((double)value, fromUnit); } #endregion @@ -517,25 +514,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad } /// Get from multiplying value and . - public static Irradiation operator *(QuantityValue left, Irradiation right) + public static Irradiation operator *(double left, Irradiation right) { return new Irradiation(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Irradiation operator *(Irradiation left, QuantityValue right) + public static Irradiation operator *(Irradiation left, double right) { return new Irradiation(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Irradiation operator /(Irradiation left, QuantityValue right) + public static Irradiation operator /(Irradiation left, double right) { return new Irradiation(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Irradiation left, Irradiation right) + public static double operator /(Irradiation left, Irradiation right) { return left.JoulesPerSquareMeter / right.JoulesPerSquareMeter; } @@ -568,19 +565,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Irrad return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Irradiation left, Irradiation right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Irradiation left, Irradiation right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -593,29 +577,7 @@ public int CompareTo(object obj) /// public int CompareTo(Irradiation other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Irradiation objIrradiation)) - return false; - return Equals(objIrradiation); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Irradiation other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -658,13 +620,13 @@ public bool Equals(Irradiation other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Irradiation other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Irradiation other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -675,7 +637,7 @@ public bool Equals(Irradiation other, QuantityValue tolerance, ComparisonType co /// A hash code for the current Irradiation. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -686,16 +648,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(IrradiationUnit unit) + public double As(IrradiationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -710,12 +673,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is IrradiationUnit typedUnit)) + if (!(unit is IrradiationUnit unitAsIrradiationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsIrradiationUnit); } /// @@ -747,7 +710,7 @@ public Irradiation ToUnit(IrradiationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Irradiation)converted; } - else if (Enum.IsDefined(typeof(IrradiationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -755,17 +718,17 @@ public Irradiation ToUnit(IrradiationUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradiationUnit typedUnit)) + if (!(unit is IrradiationUnit unitAsIrradiationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsIrradiationUnit, DefaultConversionFunctions); } /// @@ -792,10 +755,10 @@ public Irradiation ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(IrradiationUnit unit) + private double GetValueAs(IrradiationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index d590a3b824..7c5b0cee06 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct Jerk : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Jerk : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -82,9 +82,9 @@ static Jerk() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Jerk(QuantityValue value, JerkUnit unit) + public Jerk(double value, JerkUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -96,14 +96,14 @@ public Jerk(QuantityValue value, JerkUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Jerk(QuantityValue value, UnitSystem unitSystem) + public Jerk(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -144,10 +144,7 @@ public Jerk(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -170,59 +167,59 @@ public Jerk(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersPerSecondCubed => As(JerkUnit.CentimeterPerSecondCubed); + public double CentimetersPerSecondCubed => As(JerkUnit.CentimeterPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimetersPerSecondCubed => As(JerkUnit.DecimeterPerSecondCubed); + public double DecimetersPerSecondCubed => As(JerkUnit.DecimeterPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetPerSecondCubed => As(JerkUnit.FootPerSecondCubed); + public double FeetPerSecondCubed => As(JerkUnit.FootPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesPerSecondCubed => As(JerkUnit.InchPerSecondCubed); + public double InchesPerSecondCubed => As(JerkUnit.InchPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilometersPerSecondCubed => As(JerkUnit.KilometerPerSecondCubed); + public double KilometersPerSecondCubed => As(JerkUnit.KilometerPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersPerSecondCubed => As(JerkUnit.MeterPerSecondCubed); + public double MetersPerSecondCubed => As(JerkUnit.MeterPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrometersPerSecondCubed => As(JerkUnit.MicrometerPerSecondCubed); + public double MicrometersPerSecondCubed => As(JerkUnit.MicrometerPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersPerSecondCubed => As(JerkUnit.MillimeterPerSecondCubed); + public double MillimetersPerSecondCubed => As(JerkUnit.MillimeterPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillistandardGravitiesPerSecond => As(JerkUnit.MillistandardGravitiesPerSecond); + public double MillistandardGravitiesPerSecond => As(JerkUnit.MillistandardGravitiesPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanometersPerSecondCubed => As(JerkUnit.NanometerPerSecondCubed); + public double NanometersPerSecondCubed => As(JerkUnit.NanometerPerSecondCubed); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardGravitiesPerSecond => As(JerkUnit.StandardGravitiesPerSecond); + public double StandardGravitiesPerSecond => As(JerkUnit.StandardGravitiesPerSecond); #endregion @@ -319,7 +316,7 @@ public static string GetAbbreviation(JerkUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Jerk FromCentimetersPerSecondCubed(QuantityValue centimeterspersecondcubed) { - QuantityValue value = (QuantityValue) centimeterspersecondcubed; + double value = (double) centimeterspersecondcubed; return new Jerk(value, JerkUnit.CentimeterPerSecondCubed); } @@ -329,7 +326,7 @@ public static Jerk FromCentimetersPerSecondCubed(QuantityValue centimeterspersec /// If value is NaN or Infinity. public static Jerk FromDecimetersPerSecondCubed(QuantityValue decimeterspersecondcubed) { - QuantityValue value = (QuantityValue) decimeterspersecondcubed; + double value = (double) decimeterspersecondcubed; return new Jerk(value, JerkUnit.DecimeterPerSecondCubed); } @@ -339,7 +336,7 @@ public static Jerk FromDecimetersPerSecondCubed(QuantityValue decimeterspersecon /// If value is NaN or Infinity. public static Jerk FromFeetPerSecondCubed(QuantityValue feetpersecondcubed) { - QuantityValue value = (QuantityValue) feetpersecondcubed; + double value = (double) feetpersecondcubed; return new Jerk(value, JerkUnit.FootPerSecondCubed); } @@ -349,7 +346,7 @@ public static Jerk FromFeetPerSecondCubed(QuantityValue feetpersecondcubed) /// If value is NaN or Infinity. public static Jerk FromInchesPerSecondCubed(QuantityValue inchespersecondcubed) { - QuantityValue value = (QuantityValue) inchespersecondcubed; + double value = (double) inchespersecondcubed; return new Jerk(value, JerkUnit.InchPerSecondCubed); } @@ -359,7 +356,7 @@ public static Jerk FromInchesPerSecondCubed(QuantityValue inchespersecondcubed) /// If value is NaN or Infinity. public static Jerk FromKilometersPerSecondCubed(QuantityValue kilometerspersecondcubed) { - QuantityValue value = (QuantityValue) kilometerspersecondcubed; + double value = (double) kilometerspersecondcubed; return new Jerk(value, JerkUnit.KilometerPerSecondCubed); } @@ -369,7 +366,7 @@ public static Jerk FromKilometersPerSecondCubed(QuantityValue kilometerspersecon /// If value is NaN or Infinity. public static Jerk FromMetersPerSecondCubed(QuantityValue meterspersecondcubed) { - QuantityValue value = (QuantityValue) meterspersecondcubed; + double value = (double) meterspersecondcubed; return new Jerk(value, JerkUnit.MeterPerSecondCubed); } @@ -379,7 +376,7 @@ public static Jerk FromMetersPerSecondCubed(QuantityValue meterspersecondcubed) /// If value is NaN or Infinity. public static Jerk FromMicrometersPerSecondCubed(QuantityValue micrometerspersecondcubed) { - QuantityValue value = (QuantityValue) micrometerspersecondcubed; + double value = (double) micrometerspersecondcubed; return new Jerk(value, JerkUnit.MicrometerPerSecondCubed); } @@ -389,7 +386,7 @@ public static Jerk FromMicrometersPerSecondCubed(QuantityValue micrometerspersec /// If value is NaN or Infinity. public static Jerk FromMillimetersPerSecondCubed(QuantityValue millimeterspersecondcubed) { - QuantityValue value = (QuantityValue) millimeterspersecondcubed; + double value = (double) millimeterspersecondcubed; return new Jerk(value, JerkUnit.MillimeterPerSecondCubed); } @@ -399,7 +396,7 @@ public static Jerk FromMillimetersPerSecondCubed(QuantityValue millimeterspersec /// If value is NaN or Infinity. public static Jerk FromMillistandardGravitiesPerSecond(QuantityValue millistandardgravitiespersecond) { - QuantityValue value = (QuantityValue) millistandardgravitiespersecond; + double value = (double) millistandardgravitiespersecond; return new Jerk(value, JerkUnit.MillistandardGravitiesPerSecond); } @@ -409,7 +406,7 @@ public static Jerk FromMillistandardGravitiesPerSecond(QuantityValue millistanda /// If value is NaN or Infinity. public static Jerk FromNanometersPerSecondCubed(QuantityValue nanometerspersecondcubed) { - QuantityValue value = (QuantityValue) nanometerspersecondcubed; + double value = (double) nanometerspersecondcubed; return new Jerk(value, JerkUnit.NanometerPerSecondCubed); } @@ -419,7 +416,7 @@ public static Jerk FromNanometersPerSecondCubed(QuantityValue nanometerspersecon /// If value is NaN or Infinity. public static Jerk FromStandardGravitiesPerSecond(QuantityValue standardgravitiespersecond) { - QuantityValue value = (QuantityValue) standardgravitiespersecond; + double value = (double) standardgravitiespersecond; return new Jerk(value, JerkUnit.StandardGravitiesPerSecond); } @@ -431,7 +428,7 @@ public static Jerk FromStandardGravitiesPerSecond(QuantityValue standardgravitie /// Jerk unit value. public static Jerk From(QuantityValue value, JerkUnit fromUnit) { - return new Jerk((QuantityValue)value, fromUnit); + return new Jerk((double)value, fromUnit); } #endregion @@ -601,25 +598,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU } /// Get from multiplying value and . - public static Jerk operator *(QuantityValue left, Jerk right) + public static Jerk operator *(double left, Jerk right) { return new Jerk(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Jerk operator *(Jerk left, QuantityValue right) + public static Jerk operator *(Jerk left, double right) { return new Jerk(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Jerk operator /(Jerk left, QuantityValue right) + public static Jerk operator /(Jerk left, double right) { return new Jerk(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Jerk left, Jerk right) + public static double operator /(Jerk left, Jerk right) { return left.MetersPerSecondCubed / right.MetersPerSecondCubed; } @@ -652,19 +649,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out JerkU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Jerk left, Jerk right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Jerk left, Jerk right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -677,29 +661,7 @@ public int CompareTo(object obj) /// public int CompareTo(Jerk other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Jerk objJerk)) - return false; - return Equals(objJerk); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Jerk other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -742,13 +704,13 @@ public bool Equals(Jerk other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Jerk other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -759,7 +721,7 @@ public bool Equals(Jerk other, QuantityValue tolerance, ComparisonType compariso /// A hash code for the current Jerk. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -770,16 +732,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(JerkUnit unit) + public double As(JerkUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -794,12 +757,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is JerkUnit typedUnit)) + if (!(unit is JerkUnit unitAsJerkUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsJerkUnit); } /// @@ -831,7 +794,7 @@ public Jerk ToUnit(JerkUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Jerk)converted; } - else if (Enum.IsDefined(typeof(JerkUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -839,17 +802,17 @@ public Jerk ToUnit(JerkUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is JerkUnit typedUnit)) + if (!(unit is JerkUnit unitAsJerkUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsJerkUnit, DefaultConversionFunctions); } /// @@ -876,10 +839,10 @@ public Jerk ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(JerkUnit unit) + private double GetValueAs(JerkUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index bb3d26a618..35282f2c29 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Viscosity /// [DataContract] - public partial struct KinematicViscosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct KinematicViscosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static KinematicViscosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public KinematicViscosity(QuantityValue value, KinematicViscosityUnit unit) + public KinematicViscosity(double value, KinematicViscosityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -97,14 +97,14 @@ public KinematicViscosity(QuantityValue value, KinematicViscosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public KinematicViscosity(QuantityValue value, UnitSystem unitSystem) + public KinematicViscosity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,10 +145,7 @@ public KinematicViscosity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -171,49 +168,49 @@ public KinematicViscosity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centistokes => As(KinematicViscosityUnit.Centistokes); + public double Centistokes => As(KinematicViscosityUnit.Centistokes); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decistokes => As(KinematicViscosityUnit.Decistokes); + public double Decistokes => As(KinematicViscosityUnit.Decistokes); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilostokes => As(KinematicViscosityUnit.Kilostokes); + public double Kilostokes => As(KinematicViscosityUnit.Kilostokes); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microstokes => As(KinematicViscosityUnit.Microstokes); + public double Microstokes => As(KinematicViscosityUnit.Microstokes); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millistokes => As(KinematicViscosityUnit.Millistokes); + public double Millistokes => As(KinematicViscosityUnit.Millistokes); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanostokes => As(KinematicViscosityUnit.Nanostokes); + public double Nanostokes => As(KinematicViscosityUnit.Nanostokes); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); + public double SquareFeetPerSecond => As(KinematicViscosityUnit.SquareFootPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); + public double SquareMetersPerSecond => As(KinematicViscosityUnit.SquareMeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Stokes => As(KinematicViscosityUnit.Stokes); + public double Stokes => As(KinematicViscosityUnit.Stokes); #endregion @@ -301,7 +298,7 @@ public static string GetAbbreviation(KinematicViscosityUnit unit, IFormatProvide /// If value is NaN or Infinity. public static KinematicViscosity FromCentistokes(QuantityValue centistokes) { - QuantityValue value = (QuantityValue) centistokes; + double value = (double) centistokes; return new KinematicViscosity(value, KinematicViscosityUnit.Centistokes); } @@ -311,7 +308,7 @@ public static KinematicViscosity FromCentistokes(QuantityValue centistokes) /// If value is NaN or Infinity. public static KinematicViscosity FromDecistokes(QuantityValue decistokes) { - QuantityValue value = (QuantityValue) decistokes; + double value = (double) decistokes; return new KinematicViscosity(value, KinematicViscosityUnit.Decistokes); } @@ -321,7 +318,7 @@ public static KinematicViscosity FromDecistokes(QuantityValue decistokes) /// If value is NaN or Infinity. public static KinematicViscosity FromKilostokes(QuantityValue kilostokes) { - QuantityValue value = (QuantityValue) kilostokes; + double value = (double) kilostokes; return new KinematicViscosity(value, KinematicViscosityUnit.Kilostokes); } @@ -331,7 +328,7 @@ public static KinematicViscosity FromKilostokes(QuantityValue kilostokes) /// If value is NaN or Infinity. public static KinematicViscosity FromMicrostokes(QuantityValue microstokes) { - QuantityValue value = (QuantityValue) microstokes; + double value = (double) microstokes; return new KinematicViscosity(value, KinematicViscosityUnit.Microstokes); } @@ -341,7 +338,7 @@ public static KinematicViscosity FromMicrostokes(QuantityValue microstokes) /// If value is NaN or Infinity. public static KinematicViscosity FromMillistokes(QuantityValue millistokes) { - QuantityValue value = (QuantityValue) millistokes; + double value = (double) millistokes; return new KinematicViscosity(value, KinematicViscosityUnit.Millistokes); } @@ -351,7 +348,7 @@ public static KinematicViscosity FromMillistokes(QuantityValue millistokes) /// If value is NaN or Infinity. public static KinematicViscosity FromNanostokes(QuantityValue nanostokes) { - QuantityValue value = (QuantityValue) nanostokes; + double value = (double) nanostokes; return new KinematicViscosity(value, KinematicViscosityUnit.Nanostokes); } @@ -361,7 +358,7 @@ public static KinematicViscosity FromNanostokes(QuantityValue nanostokes) /// If value is NaN or Infinity. public static KinematicViscosity FromSquareFeetPerSecond(QuantityValue squarefeetpersecond) { - QuantityValue value = (QuantityValue) squarefeetpersecond; + double value = (double) squarefeetpersecond; return new KinematicViscosity(value, KinematicViscosityUnit.SquareFootPerSecond); } @@ -371,7 +368,7 @@ public static KinematicViscosity FromSquareFeetPerSecond(QuantityValue squarefee /// If value is NaN or Infinity. public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue squaremeterspersecond) { - QuantityValue value = (QuantityValue) squaremeterspersecond; + double value = (double) squaremeterspersecond; return new KinematicViscosity(value, KinematicViscosityUnit.SquareMeterPerSecond); } @@ -381,7 +378,7 @@ public static KinematicViscosity FromSquareMetersPerSecond(QuantityValue squarem /// If value is NaN or Infinity. public static KinematicViscosity FromStokes(QuantityValue stokes) { - QuantityValue value = (QuantityValue) stokes; + double value = (double) stokes; return new KinematicViscosity(value, KinematicViscosityUnit.Stokes); } @@ -393,7 +390,7 @@ public static KinematicViscosity FromStokes(QuantityValue stokes) /// KinematicViscosity unit value. public static KinematicViscosity From(QuantityValue value, KinematicViscosityUnit fromUnit) { - return new KinematicViscosity((QuantityValue)value, fromUnit); + return new KinematicViscosity((double)value, fromUnit); } #endregion @@ -563,25 +560,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem } /// Get from multiplying value and . - public static KinematicViscosity operator *(QuantityValue left, KinematicViscosity right) + public static KinematicViscosity operator *(double left, KinematicViscosity right) { return new KinematicViscosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static KinematicViscosity operator *(KinematicViscosity left, QuantityValue right) + public static KinematicViscosity operator *(KinematicViscosity left, double right) { return new KinematicViscosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static KinematicViscosity operator /(KinematicViscosity left, QuantityValue right) + public static KinematicViscosity operator /(KinematicViscosity left, double right) { return new KinematicViscosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(KinematicViscosity left, KinematicViscosity right) + public static double operator /(KinematicViscosity left, KinematicViscosity right) { return left.SquareMetersPerSecond / right.SquareMetersPerSecond; } @@ -614,19 +611,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Kinem return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(KinematicViscosity left, KinematicViscosity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(KinematicViscosity left, KinematicViscosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -639,29 +623,7 @@ public int CompareTo(object obj) /// public int CompareTo(KinematicViscosity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is KinematicViscosity objKinematicViscosity)) - return false; - return Equals(objKinematicViscosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(KinematicViscosity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -704,13 +666,13 @@ public bool Equals(KinematicViscosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(KinematicViscosity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(KinematicViscosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -721,7 +683,7 @@ public bool Equals(KinematicViscosity other, QuantityValue tolerance, Comparison /// A hash code for the current KinematicViscosity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -732,16 +694,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(KinematicViscosityUnit unit) + public double As(KinematicViscosityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -756,12 +719,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is KinematicViscosityUnit typedUnit)) + if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsKinematicViscosityUnit); } /// @@ -793,7 +756,7 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit, UnitConverter unit var converted = conversionFunction(this); return (KinematicViscosity)converted; } - else if (Enum.IsDefined(typeof(KinematicViscosityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -801,17 +764,17 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is KinematicViscosityUnit typedUnit)) + if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsKinematicViscosityUnit, DefaultConversionFunctions); } /// @@ -838,10 +801,10 @@ public KinematicViscosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(KinematicViscosityUnit unit) + private double GetValueAs(KinematicViscosityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index 615c634f71..fa9e8077ee 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -36,13 +36,13 @@ namespace UnitsNet /// [Obsolete("Use TemperatureGradient instead.")] [DataContract] - public partial struct LapseRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LapseRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static LapseRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LapseRate(QuantityValue value, LapseRateUnit unit) + public LapseRate(double value, LapseRateUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -87,14 +87,14 @@ public LapseRate(QuantityValue value, LapseRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LapseRate(QuantityValue value, UnitSystem unitSystem) + public LapseRate(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,10 +135,7 @@ public LapseRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -161,9 +158,9 @@ public LapseRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); + public double DegreesCelciusPerKilometer => As(LapseRateUnit.DegreeCelsiusPerKilometer); #endregion @@ -219,7 +216,7 @@ public static string GetAbbreviation(LapseRateUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static LapseRate FromDegreesCelciusPerKilometer(QuantityValue degreescelciusperkilometer) { - QuantityValue value = (QuantityValue) degreescelciusperkilometer; + double value = (double) degreescelciusperkilometer; return new LapseRate(value, LapseRateUnit.DegreeCelsiusPerKilometer); } @@ -231,7 +228,7 @@ public static LapseRate FromDegreesCelciusPerKilometer(QuantityValue degreescelc /// LapseRate unit value. public static LapseRate From(QuantityValue value, LapseRateUnit fromUnit) { - return new LapseRate((QuantityValue)value, fromUnit); + return new LapseRate((double)value, fromUnit); } #endregion @@ -401,25 +398,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse } /// Get from multiplying value and . - public static LapseRate operator *(QuantityValue left, LapseRate right) + public static LapseRate operator *(double left, LapseRate right) { return new LapseRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LapseRate operator *(LapseRate left, QuantityValue right) + public static LapseRate operator *(LapseRate left, double right) { return new LapseRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LapseRate operator /(LapseRate left, QuantityValue right) + public static LapseRate operator /(LapseRate left, double right) { return new LapseRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(LapseRate left, LapseRate right) + public static double operator /(LapseRate left, LapseRate right) { return left.DegreesCelciusPerKilometer / right.DegreesCelciusPerKilometer; } @@ -452,19 +449,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lapse return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LapseRate left, LapseRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LapseRate left, LapseRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -477,29 +461,7 @@ public int CompareTo(object obj) /// public int CompareTo(LapseRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is LapseRate objLapseRate)) - return false; - return Equals(objLapseRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LapseRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -542,13 +504,13 @@ public bool Equals(LapseRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LapseRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -559,7 +521,7 @@ public bool Equals(LapseRate other, QuantityValue tolerance, ComparisonType comp /// A hash code for the current LapseRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -570,16 +532,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LapseRateUnit unit) + public double As(LapseRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -594,12 +557,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LapseRateUnit typedUnit)) + if (!(unit is LapseRateUnit unitAsLapseRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLapseRateUnit); } /// @@ -631,7 +594,7 @@ public LapseRate ToUnit(LapseRateUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (LapseRate)converted; } - else if (Enum.IsDefined(typeof(LapseRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -639,17 +602,17 @@ public LapseRate ToUnit(LapseRateUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LapseRateUnit typedUnit)) + if (!(unit is LapseRateUnit unitAsLapseRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLapseRateUnit, DefaultConversionFunctions); } /// @@ -676,10 +639,10 @@ public LapseRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LapseRateUnit unit) + private double GetValueAs(LapseRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index 2d564bacc4..ab1960b463 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Many different units of length have been used around the world. The main units in modern use are U.S. customary units in the United States and the Metric system elsewhere. British Imperial units are still used for some purposes in the United Kingdom and some other countries. The metric system is sub-divided into SI and non-SI units. /// [DataContract] - public partial struct Length : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Length : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -107,9 +107,9 @@ static Length() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Length(QuantityValue value, LengthUnit unit) + public Length(double value, LengthUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -121,14 +121,14 @@ public Length(QuantityValue value, LengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Length(QuantityValue value, UnitSystem unitSystem) + public Length(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -169,10 +169,7 @@ public Length(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -195,184 +192,184 @@ public Length(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Angstroms => As(LengthUnit.Angstrom); + public double Angstroms => As(LengthUnit.Angstrom); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AstronomicalUnits => As(LengthUnit.AstronomicalUnit); + public double AstronomicalUnits => As(LengthUnit.AstronomicalUnit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centimeters => As(LengthUnit.Centimeter); + public double Centimeters => As(LengthUnit.Centimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Chains => As(LengthUnit.Chain); + public double Chains => As(LengthUnit.Chain); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DataMiles => As(LengthUnit.DataMile); + public double DataMiles => As(LengthUnit.DataMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decameters => As(LengthUnit.Decameter); + public double Decameters => As(LengthUnit.Decameter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decimeters => As(LengthUnit.Decimeter); + public double Decimeters => As(LengthUnit.Decimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DtpPicas => As(LengthUnit.DtpPica); + public double DtpPicas => As(LengthUnit.DtpPica); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DtpPoints => As(LengthUnit.DtpPoint); + public double DtpPoints => As(LengthUnit.DtpPoint); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Fathoms => As(LengthUnit.Fathom); + public double Fathoms => As(LengthUnit.Fathom); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Feet => As(LengthUnit.Foot); + public double Feet => As(LengthUnit.Foot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hands => As(LengthUnit.Hand); + public double Hands => As(LengthUnit.Hand); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hectometers => As(LengthUnit.Hectometer); + public double Hectometers => As(LengthUnit.Hectometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Inches => As(LengthUnit.Inch); + public double Inches => As(LengthUnit.Inch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilolightYears => As(LengthUnit.KilolightYear); + public double KilolightYears => As(LengthUnit.KilolightYear); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilometers => As(LengthUnit.Kilometer); + public double Kilometers => As(LengthUnit.Kilometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kiloparsecs => As(LengthUnit.Kiloparsec); + public double Kiloparsecs => As(LengthUnit.Kiloparsec); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LightYears => As(LengthUnit.LightYear); + public double LightYears => As(LengthUnit.LightYear); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegalightYears => As(LengthUnit.MegalightYear); + public double MegalightYears => As(LengthUnit.MegalightYear); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megaparsecs => As(LengthUnit.Megaparsec); + public double Megaparsecs => As(LengthUnit.Megaparsec); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Meters => As(LengthUnit.Meter); + public double Meters => As(LengthUnit.Meter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microinches => As(LengthUnit.Microinch); + public double Microinches => As(LengthUnit.Microinch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Micrometers => As(LengthUnit.Micrometer); + public double Micrometers => As(LengthUnit.Micrometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Mils => As(LengthUnit.Mil); + public double Mils => As(LengthUnit.Mil); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Miles => As(LengthUnit.Mile); + public double Miles => As(LengthUnit.Mile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millimeters => As(LengthUnit.Millimeter); + public double Millimeters => As(LengthUnit.Millimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanometers => As(LengthUnit.Nanometer); + public double Nanometers => As(LengthUnit.Nanometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NauticalMiles => As(LengthUnit.NauticalMile); + public double NauticalMiles => As(LengthUnit.NauticalMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Parsecs => As(LengthUnit.Parsec); + public double Parsecs => As(LengthUnit.Parsec); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PrinterPicas => As(LengthUnit.PrinterPica); + public double PrinterPicas => As(LengthUnit.PrinterPica); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PrinterPoints => As(LengthUnit.PrinterPoint); + public double PrinterPoints => As(LengthUnit.PrinterPoint); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Shackles => As(LengthUnit.Shackle); + public double Shackles => As(LengthUnit.Shackle); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SolarRadiuses => As(LengthUnit.SolarRadius); + public double SolarRadiuses => As(LengthUnit.SolarRadius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Twips => As(LengthUnit.Twip); + public double Twips => As(LengthUnit.Twip); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsSurveyFeet => As(LengthUnit.UsSurveyFoot); + public double UsSurveyFeet => As(LengthUnit.UsSurveyFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Yards => As(LengthUnit.Yard); + public double Yards => As(LengthUnit.Yard); #endregion @@ -565,7 +562,7 @@ public static string GetAbbreviation(LengthUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Length FromAngstroms(QuantityValue angstroms) { - QuantityValue value = (QuantityValue) angstroms; + double value = (double) angstroms; return new Length(value, LengthUnit.Angstrom); } @@ -575,7 +572,7 @@ public static Length FromAngstroms(QuantityValue angstroms) /// If value is NaN or Infinity. public static Length FromAstronomicalUnits(QuantityValue astronomicalunits) { - QuantityValue value = (QuantityValue) astronomicalunits; + double value = (double) astronomicalunits; return new Length(value, LengthUnit.AstronomicalUnit); } @@ -585,7 +582,7 @@ public static Length FromAstronomicalUnits(QuantityValue astronomicalunits) /// If value is NaN or Infinity. public static Length FromCentimeters(QuantityValue centimeters) { - QuantityValue value = (QuantityValue) centimeters; + double value = (double) centimeters; return new Length(value, LengthUnit.Centimeter); } @@ -595,7 +592,7 @@ public static Length FromCentimeters(QuantityValue centimeters) /// If value is NaN or Infinity. public static Length FromChains(QuantityValue chains) { - QuantityValue value = (QuantityValue) chains; + double value = (double) chains; return new Length(value, LengthUnit.Chain); } @@ -605,7 +602,7 @@ public static Length FromChains(QuantityValue chains) /// If value is NaN or Infinity. public static Length FromDataMiles(QuantityValue datamiles) { - QuantityValue value = (QuantityValue) datamiles; + double value = (double) datamiles; return new Length(value, LengthUnit.DataMile); } @@ -615,7 +612,7 @@ public static Length FromDataMiles(QuantityValue datamiles) /// If value is NaN or Infinity. public static Length FromDecameters(QuantityValue decameters) { - QuantityValue value = (QuantityValue) decameters; + double value = (double) decameters; return new Length(value, LengthUnit.Decameter); } @@ -625,7 +622,7 @@ public static Length FromDecameters(QuantityValue decameters) /// If value is NaN or Infinity. public static Length FromDecimeters(QuantityValue decimeters) { - QuantityValue value = (QuantityValue) decimeters; + double value = (double) decimeters; return new Length(value, LengthUnit.Decimeter); } @@ -635,7 +632,7 @@ public static Length FromDecimeters(QuantityValue decimeters) /// If value is NaN or Infinity. public static Length FromDtpPicas(QuantityValue dtppicas) { - QuantityValue value = (QuantityValue) dtppicas; + double value = (double) dtppicas; return new Length(value, LengthUnit.DtpPica); } @@ -645,7 +642,7 @@ public static Length FromDtpPicas(QuantityValue dtppicas) /// If value is NaN or Infinity. public static Length FromDtpPoints(QuantityValue dtppoints) { - QuantityValue value = (QuantityValue) dtppoints; + double value = (double) dtppoints; return new Length(value, LengthUnit.DtpPoint); } @@ -655,7 +652,7 @@ public static Length FromDtpPoints(QuantityValue dtppoints) /// If value is NaN or Infinity. public static Length FromFathoms(QuantityValue fathoms) { - QuantityValue value = (QuantityValue) fathoms; + double value = (double) fathoms; return new Length(value, LengthUnit.Fathom); } @@ -665,7 +662,7 @@ public static Length FromFathoms(QuantityValue fathoms) /// If value is NaN or Infinity. public static Length FromFeet(QuantityValue feet) { - QuantityValue value = (QuantityValue) feet; + double value = (double) feet; return new Length(value, LengthUnit.Foot); } @@ -675,7 +672,7 @@ public static Length FromFeet(QuantityValue feet) /// If value is NaN or Infinity. public static Length FromHands(QuantityValue hands) { - QuantityValue value = (QuantityValue) hands; + double value = (double) hands; return new Length(value, LengthUnit.Hand); } @@ -685,7 +682,7 @@ public static Length FromHands(QuantityValue hands) /// If value is NaN or Infinity. public static Length FromHectometers(QuantityValue hectometers) { - QuantityValue value = (QuantityValue) hectometers; + double value = (double) hectometers; return new Length(value, LengthUnit.Hectometer); } @@ -695,7 +692,7 @@ public static Length FromHectometers(QuantityValue hectometers) /// If value is NaN or Infinity. public static Length FromInches(QuantityValue inches) { - QuantityValue value = (QuantityValue) inches; + double value = (double) inches; return new Length(value, LengthUnit.Inch); } @@ -705,7 +702,7 @@ public static Length FromInches(QuantityValue inches) /// If value is NaN or Infinity. public static Length FromKilolightYears(QuantityValue kilolightyears) { - QuantityValue value = (QuantityValue) kilolightyears; + double value = (double) kilolightyears; return new Length(value, LengthUnit.KilolightYear); } @@ -715,7 +712,7 @@ public static Length FromKilolightYears(QuantityValue kilolightyears) /// If value is NaN or Infinity. public static Length FromKilometers(QuantityValue kilometers) { - QuantityValue value = (QuantityValue) kilometers; + double value = (double) kilometers; return new Length(value, LengthUnit.Kilometer); } @@ -725,7 +722,7 @@ public static Length FromKilometers(QuantityValue kilometers) /// If value is NaN or Infinity. public static Length FromKiloparsecs(QuantityValue kiloparsecs) { - QuantityValue value = (QuantityValue) kiloparsecs; + double value = (double) kiloparsecs; return new Length(value, LengthUnit.Kiloparsec); } @@ -735,7 +732,7 @@ public static Length FromKiloparsecs(QuantityValue kiloparsecs) /// If value is NaN or Infinity. public static Length FromLightYears(QuantityValue lightyears) { - QuantityValue value = (QuantityValue) lightyears; + double value = (double) lightyears; return new Length(value, LengthUnit.LightYear); } @@ -745,7 +742,7 @@ public static Length FromLightYears(QuantityValue lightyears) /// If value is NaN or Infinity. public static Length FromMegalightYears(QuantityValue megalightyears) { - QuantityValue value = (QuantityValue) megalightyears; + double value = (double) megalightyears; return new Length(value, LengthUnit.MegalightYear); } @@ -755,7 +752,7 @@ public static Length FromMegalightYears(QuantityValue megalightyears) /// If value is NaN or Infinity. public static Length FromMegaparsecs(QuantityValue megaparsecs) { - QuantityValue value = (QuantityValue) megaparsecs; + double value = (double) megaparsecs; return new Length(value, LengthUnit.Megaparsec); } @@ -765,7 +762,7 @@ public static Length FromMegaparsecs(QuantityValue megaparsecs) /// If value is NaN or Infinity. public static Length FromMeters(QuantityValue meters) { - QuantityValue value = (QuantityValue) meters; + double value = (double) meters; return new Length(value, LengthUnit.Meter); } @@ -775,7 +772,7 @@ public static Length FromMeters(QuantityValue meters) /// If value is NaN or Infinity. public static Length FromMicroinches(QuantityValue microinches) { - QuantityValue value = (QuantityValue) microinches; + double value = (double) microinches; return new Length(value, LengthUnit.Microinch); } @@ -785,7 +782,7 @@ public static Length FromMicroinches(QuantityValue microinches) /// If value is NaN or Infinity. public static Length FromMicrometers(QuantityValue micrometers) { - QuantityValue value = (QuantityValue) micrometers; + double value = (double) micrometers; return new Length(value, LengthUnit.Micrometer); } @@ -795,7 +792,7 @@ public static Length FromMicrometers(QuantityValue micrometers) /// If value is NaN or Infinity. public static Length FromMils(QuantityValue mils) { - QuantityValue value = (QuantityValue) mils; + double value = (double) mils; return new Length(value, LengthUnit.Mil); } @@ -805,7 +802,7 @@ public static Length FromMils(QuantityValue mils) /// If value is NaN or Infinity. public static Length FromMiles(QuantityValue miles) { - QuantityValue value = (QuantityValue) miles; + double value = (double) miles; return new Length(value, LengthUnit.Mile); } @@ -815,7 +812,7 @@ public static Length FromMiles(QuantityValue miles) /// If value is NaN or Infinity. public static Length FromMillimeters(QuantityValue millimeters) { - QuantityValue value = (QuantityValue) millimeters; + double value = (double) millimeters; return new Length(value, LengthUnit.Millimeter); } @@ -825,7 +822,7 @@ public static Length FromMillimeters(QuantityValue millimeters) /// If value is NaN or Infinity. public static Length FromNanometers(QuantityValue nanometers) { - QuantityValue value = (QuantityValue) nanometers; + double value = (double) nanometers; return new Length(value, LengthUnit.Nanometer); } @@ -835,7 +832,7 @@ public static Length FromNanometers(QuantityValue nanometers) /// If value is NaN or Infinity. public static Length FromNauticalMiles(QuantityValue nauticalmiles) { - QuantityValue value = (QuantityValue) nauticalmiles; + double value = (double) nauticalmiles; return new Length(value, LengthUnit.NauticalMile); } @@ -845,7 +842,7 @@ public static Length FromNauticalMiles(QuantityValue nauticalmiles) /// If value is NaN or Infinity. public static Length FromParsecs(QuantityValue parsecs) { - QuantityValue value = (QuantityValue) parsecs; + double value = (double) parsecs; return new Length(value, LengthUnit.Parsec); } @@ -855,7 +852,7 @@ public static Length FromParsecs(QuantityValue parsecs) /// If value is NaN or Infinity. public static Length FromPrinterPicas(QuantityValue printerpicas) { - QuantityValue value = (QuantityValue) printerpicas; + double value = (double) printerpicas; return new Length(value, LengthUnit.PrinterPica); } @@ -865,7 +862,7 @@ public static Length FromPrinterPicas(QuantityValue printerpicas) /// If value is NaN or Infinity. public static Length FromPrinterPoints(QuantityValue printerpoints) { - QuantityValue value = (QuantityValue) printerpoints; + double value = (double) printerpoints; return new Length(value, LengthUnit.PrinterPoint); } @@ -875,7 +872,7 @@ public static Length FromPrinterPoints(QuantityValue printerpoints) /// If value is NaN or Infinity. public static Length FromShackles(QuantityValue shackles) { - QuantityValue value = (QuantityValue) shackles; + double value = (double) shackles; return new Length(value, LengthUnit.Shackle); } @@ -885,7 +882,7 @@ public static Length FromShackles(QuantityValue shackles) /// If value is NaN or Infinity. public static Length FromSolarRadiuses(QuantityValue solarradiuses) { - QuantityValue value = (QuantityValue) solarradiuses; + double value = (double) solarradiuses; return new Length(value, LengthUnit.SolarRadius); } @@ -895,7 +892,7 @@ public static Length FromSolarRadiuses(QuantityValue solarradiuses) /// If value is NaN or Infinity. public static Length FromTwips(QuantityValue twips) { - QuantityValue value = (QuantityValue) twips; + double value = (double) twips; return new Length(value, LengthUnit.Twip); } @@ -905,7 +902,7 @@ public static Length FromTwips(QuantityValue twips) /// If value is NaN or Infinity. public static Length FromUsSurveyFeet(QuantityValue ussurveyfeet) { - QuantityValue value = (QuantityValue) ussurveyfeet; + double value = (double) ussurveyfeet; return new Length(value, LengthUnit.UsSurveyFoot); } @@ -915,7 +912,7 @@ public static Length FromUsSurveyFeet(QuantityValue ussurveyfeet) /// If value is NaN or Infinity. public static Length FromYards(QuantityValue yards) { - QuantityValue value = (QuantityValue) yards; + double value = (double) yards; return new Length(value, LengthUnit.Yard); } @@ -927,7 +924,7 @@ public static Length FromYards(QuantityValue yards) /// Length unit value. public static Length From(QuantityValue value, LengthUnit fromUnit) { - return new Length((QuantityValue)value, fromUnit); + return new Length((double)value, fromUnit); } #endregion @@ -1097,25 +1094,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt } /// Get from multiplying value and . - public static Length operator *(QuantityValue left, Length right) + public static Length operator *(double left, Length right) { return new Length(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Length operator *(Length left, QuantityValue right) + public static Length operator *(Length left, double right) { return new Length(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Length operator /(Length left, QuantityValue right) + public static Length operator /(Length left, double right) { return new Length(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Length left, Length right) + public static double operator /(Length left, Length right) { return left.Meters / right.Meters; } @@ -1148,19 +1145,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lengt return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Length left, Length right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Length left, Length right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1173,29 +1157,7 @@ public int CompareTo(object obj) /// public int CompareTo(Length other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Length objLength)) - return false; - return Equals(objLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Length other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1238,13 +1200,13 @@ public bool Equals(Length other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Length other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Length other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1255,7 +1217,7 @@ public bool Equals(Length other, QuantityValue tolerance, ComparisonType compari /// A hash code for the current Length. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1266,16 +1228,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LengthUnit unit) + public double As(LengthUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1290,12 +1253,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LengthUnit typedUnit)) + if (!(unit is LengthUnit unitAsLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLengthUnit); } /// @@ -1327,7 +1290,7 @@ public Length ToUnit(LengthUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Length)converted; } - else if (Enum.IsDefined(typeof(LengthUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1335,17 +1298,17 @@ public Length ToUnit(LengthUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LengthUnit typedUnit)) + if (!(unit is LengthUnit unitAsLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLengthUnit, DefaultConversionFunctions); } /// @@ -1372,10 +1335,10 @@ public Length ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LengthUnit unit) + private double GetValueAs(LengthUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 2610e6c6f9..16b78f3430 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Level is the logarithm of the ratio of a quantity Q to a reference value of that quantity, Q₀, expressed in dimensionless units. /// [DataContract] - public partial struct Level : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Level : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static Level() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Level(QuantityValue value, LevelUnit unit) + public Level(double value, LevelUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -87,14 +87,14 @@ public Level(QuantityValue value, LevelUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Level(QuantityValue value, UnitSystem unitSystem) + public Level(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,10 +135,7 @@ public Level(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -161,14 +158,14 @@ public Level(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decibels => As(LevelUnit.Decibel); + public double Decibels => As(LevelUnit.Decibel); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nepers => As(LevelUnit.Neper); + public double Nepers => As(LevelUnit.Neper); #endregion @@ -227,7 +224,7 @@ public static string GetAbbreviation(LevelUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Level FromDecibels(QuantityValue decibels) { - QuantityValue value = (QuantityValue) decibels; + double value = (double) decibels; return new Level(value, LevelUnit.Decibel); } @@ -237,7 +234,7 @@ public static Level FromDecibels(QuantityValue decibels) /// If value is NaN or Infinity. public static Level FromNepers(QuantityValue nepers) { - QuantityValue value = (QuantityValue) nepers; + double value = (double) nepers; return new Level(value, LevelUnit.Neper); } @@ -249,7 +246,7 @@ public static Level FromNepers(QuantityValue nepers) /// Level unit value. public static Level From(QuantityValue value, LevelUnit fromUnit) { - return new Level((QuantityValue)value, fromUnit); + return new Level((double)value, fromUnit); } #endregion @@ -411,7 +408,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level { // Logarithmic addition // Formula: 10 * log10(10^(x/10) + 10^(y/10)) - return new Level(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); + return new Level(10 * Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic subtraction of two . @@ -419,11 +416,11 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level { // Logarithmic subtraction // Formula: 10 * log10(10^(x/10) - 10^(y/10)) - return new Level(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); + return new Level(10 * Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic multiplication of value and . - public static Level operator *(QuantityValue left, Level right) + public static Level operator *(double left, Level right) { // Logarithmic multiplication = addition return new Level(left + right.Value, right.Unit); @@ -433,14 +430,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level public static Level operator *(Level left, double right) { // Logarithmic multiplication = addition - return new Level(left.Value + (QuantityValue)right, left.Unit); + return new Level(left.Value + (double)right, left.Unit); } /// Get from logarithmic division of by value. public static Level operator /(Level left, double right) { // Logarithmic division = subtraction - return new Level(left.Value - (QuantityValue)right, left.Unit); + return new Level(left.Value - (double)right, left.Unit); } /// Get ratio value from logarithmic division of by . @@ -478,19 +475,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Level return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Level left, Level right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Level left, Level right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -503,29 +487,7 @@ public int CompareTo(object obj) /// public int CompareTo(Level other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Level objLevel)) - return false; - return Equals(objLevel); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Level other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -568,13 +530,13 @@ public bool Equals(Level other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Level other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Level other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -585,7 +547,7 @@ public bool Equals(Level other, QuantityValue tolerance, ComparisonType comparis /// A hash code for the current Level. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -596,16 +558,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LevelUnit unit) + public double As(LevelUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -620,12 +583,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LevelUnit typedUnit)) + if (!(unit is LevelUnit unitAsLevelUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLevelUnit); } /// @@ -657,7 +620,7 @@ public Level ToUnit(LevelUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Level)converted; } - else if (Enum.IsDefined(typeof(LevelUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -665,17 +628,17 @@ public Level ToUnit(LevelUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LevelUnit typedUnit)) + if (!(unit is LevelUnit unitAsLevelUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLevelUnit, DefaultConversionFunctions); } /// @@ -702,10 +665,10 @@ public Level ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LevelUnit unit) + private double GetValueAs(LevelUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index ceec19fbc9..659ad66f37 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -88,9 +88,9 @@ static LinearDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LinearDensity(QuantityValue value, LinearDensityUnit unit) + public LinearDensity(double value, LinearDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -102,14 +102,14 @@ public LinearDensity(QuantityValue value, LinearDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearDensity(QuantityValue value, UnitSystem unitSystem) + public LinearDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -150,10 +150,7 @@ public LinearDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -176,74 +173,74 @@ public LinearDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); + public double GramsPerCentimeter => As(LinearDensityUnit.GramPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerMeter => As(LinearDensityUnit.GramPerMeter); + public double GramsPerMeter => As(LinearDensityUnit.GramPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); + public double GramsPerMillimeter => As(LinearDensityUnit.GramPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); + public double KilogramsPerCentimeter => As(LinearDensityUnit.KilogramPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); + public double KilogramsPerMeter => As(LinearDensityUnit.KilogramPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); + public double KilogramsPerMillimeter => As(LinearDensityUnit.KilogramPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); + public double MicrogramsPerCentimeter => As(LinearDensityUnit.MicrogramPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); + public double MicrogramsPerMeter => As(LinearDensityUnit.MicrogramPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); + public double MicrogramsPerMillimeter => As(LinearDensityUnit.MicrogramPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); + public double MilligramsPerCentimeter => As(LinearDensityUnit.MilligramPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); + public double MilligramsPerMeter => As(LinearDensityUnit.MilligramPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); + public double MilligramsPerMillimeter => As(LinearDensityUnit.MilligramPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); + public double PoundsPerFoot => As(LinearDensityUnit.PoundPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerInch => As(LinearDensityUnit.PoundPerInch); + public double PoundsPerInch => As(LinearDensityUnit.PoundPerInch); #endregion @@ -338,7 +335,7 @@ public static string GetAbbreviation(LinearDensityUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static LinearDensity FromGramsPerCentimeter(QuantityValue gramspercentimeter) { - QuantityValue value = (QuantityValue) gramspercentimeter; + double value = (double) gramspercentimeter; return new LinearDensity(value, LinearDensityUnit.GramPerCentimeter); } @@ -348,7 +345,7 @@ public static LinearDensity FromGramsPerCentimeter(QuantityValue gramspercentime /// If value is NaN or Infinity. public static LinearDensity FromGramsPerMeter(QuantityValue gramspermeter) { - QuantityValue value = (QuantityValue) gramspermeter; + double value = (double) gramspermeter; return new LinearDensity(value, LinearDensityUnit.GramPerMeter); } @@ -358,7 +355,7 @@ public static LinearDensity FromGramsPerMeter(QuantityValue gramspermeter) /// If value is NaN or Infinity. public static LinearDensity FromGramsPerMillimeter(QuantityValue gramspermillimeter) { - QuantityValue value = (QuantityValue) gramspermillimeter; + double value = (double) gramspermillimeter; return new LinearDensity(value, LinearDensityUnit.GramPerMillimeter); } @@ -368,7 +365,7 @@ public static LinearDensity FromGramsPerMillimeter(QuantityValue gramspermillime /// If value is NaN or Infinity. public static LinearDensity FromKilogramsPerCentimeter(QuantityValue kilogramspercentimeter) { - QuantityValue value = (QuantityValue) kilogramspercentimeter; + double value = (double) kilogramspercentimeter; return new LinearDensity(value, LinearDensityUnit.KilogramPerCentimeter); } @@ -378,7 +375,7 @@ public static LinearDensity FromKilogramsPerCentimeter(QuantityValue kilogramspe /// If value is NaN or Infinity. public static LinearDensity FromKilogramsPerMeter(QuantityValue kilogramspermeter) { - QuantityValue value = (QuantityValue) kilogramspermeter; + double value = (double) kilogramspermeter; return new LinearDensity(value, LinearDensityUnit.KilogramPerMeter); } @@ -388,7 +385,7 @@ public static LinearDensity FromKilogramsPerMeter(QuantityValue kilogramspermete /// If value is NaN or Infinity. public static LinearDensity FromKilogramsPerMillimeter(QuantityValue kilogramspermillimeter) { - QuantityValue value = (QuantityValue) kilogramspermillimeter; + double value = (double) kilogramspermillimeter; return new LinearDensity(value, LinearDensityUnit.KilogramPerMillimeter); } @@ -398,7 +395,7 @@ public static LinearDensity FromKilogramsPerMillimeter(QuantityValue kilogramspe /// If value is NaN or Infinity. public static LinearDensity FromMicrogramsPerCentimeter(QuantityValue microgramspercentimeter) { - QuantityValue value = (QuantityValue) microgramspercentimeter; + double value = (double) microgramspercentimeter; return new LinearDensity(value, LinearDensityUnit.MicrogramPerCentimeter); } @@ -408,7 +405,7 @@ public static LinearDensity FromMicrogramsPerCentimeter(QuantityValue micrograms /// If value is NaN or Infinity. public static LinearDensity FromMicrogramsPerMeter(QuantityValue microgramspermeter) { - QuantityValue value = (QuantityValue) microgramspermeter; + double value = (double) microgramspermeter; return new LinearDensity(value, LinearDensityUnit.MicrogramPerMeter); } @@ -418,7 +415,7 @@ public static LinearDensity FromMicrogramsPerMeter(QuantityValue microgramsperme /// If value is NaN or Infinity. public static LinearDensity FromMicrogramsPerMillimeter(QuantityValue microgramspermillimeter) { - QuantityValue value = (QuantityValue) microgramspermillimeter; + double value = (double) microgramspermillimeter; return new LinearDensity(value, LinearDensityUnit.MicrogramPerMillimeter); } @@ -428,7 +425,7 @@ public static LinearDensity FromMicrogramsPerMillimeter(QuantityValue micrograms /// If value is NaN or Infinity. public static LinearDensity FromMilligramsPerCentimeter(QuantityValue milligramspercentimeter) { - QuantityValue value = (QuantityValue) milligramspercentimeter; + double value = (double) milligramspercentimeter; return new LinearDensity(value, LinearDensityUnit.MilligramPerCentimeter); } @@ -438,7 +435,7 @@ public static LinearDensity FromMilligramsPerCentimeter(QuantityValue milligrams /// If value is NaN or Infinity. public static LinearDensity FromMilligramsPerMeter(QuantityValue milligramspermeter) { - QuantityValue value = (QuantityValue) milligramspermeter; + double value = (double) milligramspermeter; return new LinearDensity(value, LinearDensityUnit.MilligramPerMeter); } @@ -448,7 +445,7 @@ public static LinearDensity FromMilligramsPerMeter(QuantityValue milligramsperme /// If value is NaN or Infinity. public static LinearDensity FromMilligramsPerMillimeter(QuantityValue milligramspermillimeter) { - QuantityValue value = (QuantityValue) milligramspermillimeter; + double value = (double) milligramspermillimeter; return new LinearDensity(value, LinearDensityUnit.MilligramPerMillimeter); } @@ -458,7 +455,7 @@ public static LinearDensity FromMilligramsPerMillimeter(QuantityValue milligrams /// If value is NaN or Infinity. public static LinearDensity FromPoundsPerFoot(QuantityValue poundsperfoot) { - QuantityValue value = (QuantityValue) poundsperfoot; + double value = (double) poundsperfoot; return new LinearDensity(value, LinearDensityUnit.PoundPerFoot); } @@ -468,7 +465,7 @@ public static LinearDensity FromPoundsPerFoot(QuantityValue poundsperfoot) /// If value is NaN or Infinity. public static LinearDensity FromPoundsPerInch(QuantityValue poundsperinch) { - QuantityValue value = (QuantityValue) poundsperinch; + double value = (double) poundsperinch; return new LinearDensity(value, LinearDensityUnit.PoundPerInch); } @@ -480,7 +477,7 @@ public static LinearDensity FromPoundsPerInch(QuantityValue poundsperinch) /// LinearDensity unit value. public static LinearDensity From(QuantityValue value, LinearDensityUnit fromUnit) { - return new LinearDensity((QuantityValue)value, fromUnit); + return new LinearDensity((double)value, fromUnit); } #endregion @@ -650,25 +647,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea } /// Get from multiplying value and . - public static LinearDensity operator *(QuantityValue left, LinearDensity right) + public static LinearDensity operator *(double left, LinearDensity right) { return new LinearDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LinearDensity operator *(LinearDensity left, QuantityValue right) + public static LinearDensity operator *(LinearDensity left, double right) { return new LinearDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LinearDensity operator /(LinearDensity left, QuantityValue right) + public static LinearDensity operator /(LinearDensity left, double right) { return new LinearDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(LinearDensity left, LinearDensity right) + public static double operator /(LinearDensity left, LinearDensity right) { return left.KilogramsPerMeter / right.KilogramsPerMeter; } @@ -701,19 +698,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearDensity left, LinearDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearDensity left, LinearDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -726,29 +710,7 @@ public int CompareTo(object obj) /// public int CompareTo(LinearDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is LinearDensity objLinearDensity)) - return false; - return Equals(objLinearDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -791,13 +753,13 @@ public bool Equals(LinearDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(LinearDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -808,7 +770,7 @@ public bool Equals(LinearDensity other, QuantityValue tolerance, ComparisonType /// A hash code for the current LinearDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -819,16 +781,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LinearDensityUnit unit) + public double As(LinearDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -843,12 +806,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LinearDensityUnit typedUnit)) + if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLinearDensityUnit); } /// @@ -880,7 +843,7 @@ public LinearDensity ToUnit(LinearDensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (LinearDensity)converted; } - else if (Enum.IsDefined(typeof(LinearDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -888,17 +851,17 @@ public LinearDensity ToUnit(LinearDensityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearDensityUnit typedUnit)) + if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLinearDensityUnit, DefaultConversionFunctions); } /// @@ -925,10 +888,10 @@ public LinearDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LinearDensityUnit unit) + private double GetValueAs(LinearDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 5500223a41..20a484724a 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Linear_density /// [DataContract] - public partial struct LinearPowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LinearPowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -99,9 +99,9 @@ static LinearPowerDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LinearPowerDensity(QuantityValue value, LinearPowerDensityUnit unit) + public LinearPowerDensity(double value, LinearPowerDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -113,14 +113,14 @@ public LinearPowerDensity(QuantityValue value, LinearPowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LinearPowerDensity(QuantityValue value, UnitSystem unitSystem) + public LinearPowerDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -161,10 +161,7 @@ public LinearPowerDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -187,129 +184,129 @@ public LinearPowerDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); + public double GigawattsPerCentimeter => As(LinearPowerDensityUnit.GigawattPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); + public double GigawattsPerFoot => As(LinearPowerDensityUnit.GigawattPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); + public double GigawattsPerInch => As(LinearPowerDensityUnit.GigawattPerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); + public double GigawattsPerMeter => As(LinearPowerDensityUnit.GigawattPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); + public double GigawattsPerMillimeter => As(LinearPowerDensityUnit.GigawattPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); + public double KilowattsPerCentimeter => As(LinearPowerDensityUnit.KilowattPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); + public double KilowattsPerFoot => As(LinearPowerDensityUnit.KilowattPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); + public double KilowattsPerInch => As(LinearPowerDensityUnit.KilowattPerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); + public double KilowattsPerMeter => As(LinearPowerDensityUnit.KilowattPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); + public double KilowattsPerMillimeter => As(LinearPowerDensityUnit.KilowattPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); + public double MegawattsPerCentimeter => As(LinearPowerDensityUnit.MegawattPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); + public double MegawattsPerFoot => As(LinearPowerDensityUnit.MegawattPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); + public double MegawattsPerInch => As(LinearPowerDensityUnit.MegawattPerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); + public double MegawattsPerMeter => As(LinearPowerDensityUnit.MegawattPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); + public double MegawattsPerMillimeter => As(LinearPowerDensityUnit.MegawattPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); + public double MilliwattsPerCentimeter => As(LinearPowerDensityUnit.MilliwattPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); + public double MilliwattsPerFoot => As(LinearPowerDensityUnit.MilliwattPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); + public double MilliwattsPerInch => As(LinearPowerDensityUnit.MilliwattPerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); + public double MilliwattsPerMeter => As(LinearPowerDensityUnit.MilliwattPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); + public double MilliwattsPerMillimeter => As(LinearPowerDensityUnit.MilliwattPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); + public double WattsPerCentimeter => As(LinearPowerDensityUnit.WattPerCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); + public double WattsPerFoot => As(LinearPowerDensityUnit.WattPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); + public double WattsPerInch => As(LinearPowerDensityUnit.WattPerInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); + public double WattsPerMeter => As(LinearPowerDensityUnit.WattPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); + public double WattsPerMillimeter => As(LinearPowerDensityUnit.WattPerMillimeter); #endregion @@ -437,7 +434,7 @@ public static string GetAbbreviation(LinearPowerDensityUnit unit, IFormatProvide /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerCentimeter(QuantityValue gigawattspercentimeter) { - QuantityValue value = (QuantityValue) gigawattspercentimeter; + double value = (double) gigawattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerCentimeter); } @@ -447,7 +444,7 @@ public static LinearPowerDensity FromGigawattsPerCentimeter(QuantityValue gigawa /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerFoot(QuantityValue gigawattsperfoot) { - QuantityValue value = (QuantityValue) gigawattsperfoot; + double value = (double) gigawattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerFoot); } @@ -457,7 +454,7 @@ public static LinearPowerDensity FromGigawattsPerFoot(QuantityValue gigawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerInch(QuantityValue gigawattsperinch) { - QuantityValue value = (QuantityValue) gigawattsperinch; + double value = (double) gigawattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerInch); } @@ -467,7 +464,7 @@ public static LinearPowerDensity FromGigawattsPerInch(QuantityValue gigawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerMeter(QuantityValue gigawattspermeter) { - QuantityValue value = (QuantityValue) gigawattspermeter; + double value = (double) gigawattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMeter); } @@ -477,7 +474,7 @@ public static LinearPowerDensity FromGigawattsPerMeter(QuantityValue gigawattspe /// If value is NaN or Infinity. public static LinearPowerDensity FromGigawattsPerMillimeter(QuantityValue gigawattspermillimeter) { - QuantityValue value = (QuantityValue) gigawattspermillimeter; + double value = (double) gigawattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.GigawattPerMillimeter); } @@ -487,7 +484,7 @@ public static LinearPowerDensity FromGigawattsPerMillimeter(QuantityValue gigawa /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerCentimeter(QuantityValue kilowattspercentimeter) { - QuantityValue value = (QuantityValue) kilowattspercentimeter; + double value = (double) kilowattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerCentimeter); } @@ -497,7 +494,7 @@ public static LinearPowerDensity FromKilowattsPerCentimeter(QuantityValue kilowa /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerFoot(QuantityValue kilowattsperfoot) { - QuantityValue value = (QuantityValue) kilowattsperfoot; + double value = (double) kilowattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerFoot); } @@ -507,7 +504,7 @@ public static LinearPowerDensity FromKilowattsPerFoot(QuantityValue kilowattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerInch(QuantityValue kilowattsperinch) { - QuantityValue value = (QuantityValue) kilowattsperinch; + double value = (double) kilowattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerInch); } @@ -517,7 +514,7 @@ public static LinearPowerDensity FromKilowattsPerInch(QuantityValue kilowattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerMeter(QuantityValue kilowattspermeter) { - QuantityValue value = (QuantityValue) kilowattspermeter; + double value = (double) kilowattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMeter); } @@ -527,7 +524,7 @@ public static LinearPowerDensity FromKilowattsPerMeter(QuantityValue kilowattspe /// If value is NaN or Infinity. public static LinearPowerDensity FromKilowattsPerMillimeter(QuantityValue kilowattspermillimeter) { - QuantityValue value = (QuantityValue) kilowattspermillimeter; + double value = (double) kilowattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.KilowattPerMillimeter); } @@ -537,7 +534,7 @@ public static LinearPowerDensity FromKilowattsPerMillimeter(QuantityValue kilowa /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerCentimeter(QuantityValue megawattspercentimeter) { - QuantityValue value = (QuantityValue) megawattspercentimeter; + double value = (double) megawattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerCentimeter); } @@ -547,7 +544,7 @@ public static LinearPowerDensity FromMegawattsPerCentimeter(QuantityValue megawa /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerFoot(QuantityValue megawattsperfoot) { - QuantityValue value = (QuantityValue) megawattsperfoot; + double value = (double) megawattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerFoot); } @@ -557,7 +554,7 @@ public static LinearPowerDensity FromMegawattsPerFoot(QuantityValue megawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerInch(QuantityValue megawattsperinch) { - QuantityValue value = (QuantityValue) megawattsperinch; + double value = (double) megawattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerInch); } @@ -567,7 +564,7 @@ public static LinearPowerDensity FromMegawattsPerInch(QuantityValue megawattsper /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerMeter(QuantityValue megawattspermeter) { - QuantityValue value = (QuantityValue) megawattspermeter; + double value = (double) megawattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMeter); } @@ -577,7 +574,7 @@ public static LinearPowerDensity FromMegawattsPerMeter(QuantityValue megawattspe /// If value is NaN or Infinity. public static LinearPowerDensity FromMegawattsPerMillimeter(QuantityValue megawattspermillimeter) { - QuantityValue value = (QuantityValue) megawattspermillimeter; + double value = (double) megawattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MegawattPerMillimeter); } @@ -587,7 +584,7 @@ public static LinearPowerDensity FromMegawattsPerMillimeter(QuantityValue megawa /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerCentimeter(QuantityValue milliwattspercentimeter) { - QuantityValue value = (QuantityValue) milliwattspercentimeter; + double value = (double) milliwattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerCentimeter); } @@ -597,7 +594,7 @@ public static LinearPowerDensity FromMilliwattsPerCentimeter(QuantityValue milli /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerFoot(QuantityValue milliwattsperfoot) { - QuantityValue value = (QuantityValue) milliwattsperfoot; + double value = (double) milliwattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerFoot); } @@ -607,7 +604,7 @@ public static LinearPowerDensity FromMilliwattsPerFoot(QuantityValue milliwattsp /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerInch(QuantityValue milliwattsperinch) { - QuantityValue value = (QuantityValue) milliwattsperinch; + double value = (double) milliwattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerInch); } @@ -617,7 +614,7 @@ public static LinearPowerDensity FromMilliwattsPerInch(QuantityValue milliwattsp /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerMeter(QuantityValue milliwattspermeter) { - QuantityValue value = (QuantityValue) milliwattspermeter; + double value = (double) milliwattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMeter); } @@ -627,7 +624,7 @@ public static LinearPowerDensity FromMilliwattsPerMeter(QuantityValue milliwatts /// If value is NaN or Infinity. public static LinearPowerDensity FromMilliwattsPerMillimeter(QuantityValue milliwattspermillimeter) { - QuantityValue value = (QuantityValue) milliwattspermillimeter; + double value = (double) milliwattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.MilliwattPerMillimeter); } @@ -637,7 +634,7 @@ public static LinearPowerDensity FromMilliwattsPerMillimeter(QuantityValue milli /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerCentimeter(QuantityValue wattspercentimeter) { - QuantityValue value = (QuantityValue) wattspercentimeter; + double value = (double) wattspercentimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerCentimeter); } @@ -647,7 +644,7 @@ public static LinearPowerDensity FromWattsPerCentimeter(QuantityValue wattsperce /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerFoot(QuantityValue wattsperfoot) { - QuantityValue value = (QuantityValue) wattsperfoot; + double value = (double) wattsperfoot; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerFoot); } @@ -657,7 +654,7 @@ public static LinearPowerDensity FromWattsPerFoot(QuantityValue wattsperfoot) /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerInch(QuantityValue wattsperinch) { - QuantityValue value = (QuantityValue) wattsperinch; + double value = (double) wattsperinch; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerInch); } @@ -667,7 +664,7 @@ public static LinearPowerDensity FromWattsPerInch(QuantityValue wattsperinch) /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerMeter(QuantityValue wattspermeter) { - QuantityValue value = (QuantityValue) wattspermeter; + double value = (double) wattspermeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMeter); } @@ -677,7 +674,7 @@ public static LinearPowerDensity FromWattsPerMeter(QuantityValue wattspermeter) /// If value is NaN or Infinity. public static LinearPowerDensity FromWattsPerMillimeter(QuantityValue wattspermillimeter) { - QuantityValue value = (QuantityValue) wattspermillimeter; + double value = (double) wattspermillimeter; return new LinearPowerDensity(value, LinearPowerDensityUnit.WattPerMillimeter); } @@ -689,7 +686,7 @@ public static LinearPowerDensity FromWattsPerMillimeter(QuantityValue wattspermi /// LinearPowerDensity unit value. public static LinearPowerDensity From(QuantityValue value, LinearPowerDensityUnit fromUnit) { - return new LinearPowerDensity((QuantityValue)value, fromUnit); + return new LinearPowerDensity((double)value, fromUnit); } #endregion @@ -859,25 +856,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea } /// Get from multiplying value and . - public static LinearPowerDensity operator *(QuantityValue left, LinearPowerDensity right) + public static LinearPowerDensity operator *(double left, LinearPowerDensity right) { return new LinearPowerDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LinearPowerDensity operator *(LinearPowerDensity left, QuantityValue right) + public static LinearPowerDensity operator *(LinearPowerDensity left, double right) { return new LinearPowerDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LinearPowerDensity operator /(LinearPowerDensity left, QuantityValue right) + public static LinearPowerDensity operator /(LinearPowerDensity left, double right) { return new LinearPowerDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(LinearPowerDensity left, LinearPowerDensity right) + public static double operator /(LinearPowerDensity left, LinearPowerDensity right) { return left.WattsPerMeter / right.WattsPerMeter; } @@ -910,19 +907,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Linea return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LinearPowerDensity left, LinearPowerDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LinearPowerDensity left, LinearPowerDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -935,29 +919,7 @@ public int CompareTo(object obj) /// public int CompareTo(LinearPowerDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is LinearPowerDensity objLinearPowerDensity)) - return false; - return Equals(objLinearPowerDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LinearPowerDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1000,13 +962,13 @@ public bool Equals(LinearPowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LinearPowerDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1017,7 +979,7 @@ public bool Equals(LinearPowerDensity other, QuantityValue tolerance, Comparison /// A hash code for the current LinearPowerDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1028,16 +990,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LinearPowerDensityUnit unit) + public double As(LinearPowerDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1052,12 +1015,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LinearPowerDensityUnit typedUnit)) + if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLinearPowerDensityUnit); } /// @@ -1089,7 +1052,7 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit, UnitConverter unit var converted = conversionFunction(this); return (LinearPowerDensity)converted; } - else if (Enum.IsDefined(typeof(LinearPowerDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1097,17 +1060,17 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearPowerDensityUnit typedUnit)) + if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLinearPowerDensityUnit, DefaultConversionFunctions); } /// @@ -1134,10 +1097,10 @@ public LinearPowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LinearPowerDensityUnit unit) + private double GetValueAs(LinearPowerDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index 0f8d6b6604..d78acbfd8c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminosity /// [DataContract] - public partial struct Luminosity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Luminosity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -88,9 +88,9 @@ static Luminosity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Luminosity(QuantityValue value, LuminosityUnit unit) + public Luminosity(double value, LuminosityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -102,14 +102,14 @@ public Luminosity(QuantityValue value, LuminosityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Luminosity(QuantityValue value, UnitSystem unitSystem) + public Luminosity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -150,10 +150,7 @@ public Luminosity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -176,74 +173,74 @@ public Luminosity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decawatts => As(LuminosityUnit.Decawatt); + public double Decawatts => As(LuminosityUnit.Decawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Deciwatts => As(LuminosityUnit.Deciwatt); + public double Deciwatts => As(LuminosityUnit.Deciwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Femtowatts => As(LuminosityUnit.Femtowatt); + public double Femtowatts => As(LuminosityUnit.Femtowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigawatts => As(LuminosityUnit.Gigawatt); + public double Gigawatts => As(LuminosityUnit.Gigawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilowatts => As(LuminosityUnit.Kilowatt); + public double Kilowatts => As(LuminosityUnit.Kilowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megawatts => As(LuminosityUnit.Megawatt); + public double Megawatts => As(LuminosityUnit.Megawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microwatts => As(LuminosityUnit.Microwatt); + public double Microwatts => As(LuminosityUnit.Microwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliwatts => As(LuminosityUnit.Milliwatt); + public double Milliwatts => As(LuminosityUnit.Milliwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanowatts => As(LuminosityUnit.Nanowatt); + public double Nanowatts => As(LuminosityUnit.Nanowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Petawatts => As(LuminosityUnit.Petawatt); + public double Petawatts => As(LuminosityUnit.Petawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Picowatts => As(LuminosityUnit.Picowatt); + public double Picowatts => As(LuminosityUnit.Picowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SolarLuminosities => As(LuminosityUnit.SolarLuminosity); + public double SolarLuminosities => As(LuminosityUnit.SolarLuminosity); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Terawatts => As(LuminosityUnit.Terawatt); + public double Terawatts => As(LuminosityUnit.Terawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Watts => As(LuminosityUnit.Watt); + public double Watts => As(LuminosityUnit.Watt); #endregion @@ -338,7 +335,7 @@ public static string GetAbbreviation(LuminosityUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static Luminosity FromDecawatts(QuantityValue decawatts) { - QuantityValue value = (QuantityValue) decawatts; + double value = (double) decawatts; return new Luminosity(value, LuminosityUnit.Decawatt); } @@ -348,7 +345,7 @@ public static Luminosity FromDecawatts(QuantityValue decawatts) /// If value is NaN or Infinity. public static Luminosity FromDeciwatts(QuantityValue deciwatts) { - QuantityValue value = (QuantityValue) deciwatts; + double value = (double) deciwatts; return new Luminosity(value, LuminosityUnit.Deciwatt); } @@ -358,7 +355,7 @@ public static Luminosity FromDeciwatts(QuantityValue deciwatts) /// If value is NaN or Infinity. public static Luminosity FromFemtowatts(QuantityValue femtowatts) { - QuantityValue value = (QuantityValue) femtowatts; + double value = (double) femtowatts; return new Luminosity(value, LuminosityUnit.Femtowatt); } @@ -368,7 +365,7 @@ public static Luminosity FromFemtowatts(QuantityValue femtowatts) /// If value is NaN or Infinity. public static Luminosity FromGigawatts(QuantityValue gigawatts) { - QuantityValue value = (QuantityValue) gigawatts; + double value = (double) gigawatts; return new Luminosity(value, LuminosityUnit.Gigawatt); } @@ -378,7 +375,7 @@ public static Luminosity FromGigawatts(QuantityValue gigawatts) /// If value is NaN or Infinity. public static Luminosity FromKilowatts(QuantityValue kilowatts) { - QuantityValue value = (QuantityValue) kilowatts; + double value = (double) kilowatts; return new Luminosity(value, LuminosityUnit.Kilowatt); } @@ -388,7 +385,7 @@ public static Luminosity FromKilowatts(QuantityValue kilowatts) /// If value is NaN or Infinity. public static Luminosity FromMegawatts(QuantityValue megawatts) { - QuantityValue value = (QuantityValue) megawatts; + double value = (double) megawatts; return new Luminosity(value, LuminosityUnit.Megawatt); } @@ -398,7 +395,7 @@ public static Luminosity FromMegawatts(QuantityValue megawatts) /// If value is NaN or Infinity. public static Luminosity FromMicrowatts(QuantityValue microwatts) { - QuantityValue value = (QuantityValue) microwatts; + double value = (double) microwatts; return new Luminosity(value, LuminosityUnit.Microwatt); } @@ -408,7 +405,7 @@ public static Luminosity FromMicrowatts(QuantityValue microwatts) /// If value is NaN or Infinity. public static Luminosity FromMilliwatts(QuantityValue milliwatts) { - QuantityValue value = (QuantityValue) milliwatts; + double value = (double) milliwatts; return new Luminosity(value, LuminosityUnit.Milliwatt); } @@ -418,7 +415,7 @@ public static Luminosity FromMilliwatts(QuantityValue milliwatts) /// If value is NaN or Infinity. public static Luminosity FromNanowatts(QuantityValue nanowatts) { - QuantityValue value = (QuantityValue) nanowatts; + double value = (double) nanowatts; return new Luminosity(value, LuminosityUnit.Nanowatt); } @@ -428,7 +425,7 @@ public static Luminosity FromNanowatts(QuantityValue nanowatts) /// If value is NaN or Infinity. public static Luminosity FromPetawatts(QuantityValue petawatts) { - QuantityValue value = (QuantityValue) petawatts; + double value = (double) petawatts; return new Luminosity(value, LuminosityUnit.Petawatt); } @@ -438,7 +435,7 @@ public static Luminosity FromPetawatts(QuantityValue petawatts) /// If value is NaN or Infinity. public static Luminosity FromPicowatts(QuantityValue picowatts) { - QuantityValue value = (QuantityValue) picowatts; + double value = (double) picowatts; return new Luminosity(value, LuminosityUnit.Picowatt); } @@ -448,7 +445,7 @@ public static Luminosity FromPicowatts(QuantityValue picowatts) /// If value is NaN or Infinity. public static Luminosity FromSolarLuminosities(QuantityValue solarluminosities) { - QuantityValue value = (QuantityValue) solarluminosities; + double value = (double) solarluminosities; return new Luminosity(value, LuminosityUnit.SolarLuminosity); } @@ -458,7 +455,7 @@ public static Luminosity FromSolarLuminosities(QuantityValue solarluminosities) /// If value is NaN or Infinity. public static Luminosity FromTerawatts(QuantityValue terawatts) { - QuantityValue value = (QuantityValue) terawatts; + double value = (double) terawatts; return new Luminosity(value, LuminosityUnit.Terawatt); } @@ -468,7 +465,7 @@ public static Luminosity FromTerawatts(QuantityValue terawatts) /// If value is NaN or Infinity. public static Luminosity FromWatts(QuantityValue watts) { - QuantityValue value = (QuantityValue) watts; + double value = (double) watts; return new Luminosity(value, LuminosityUnit.Watt); } @@ -480,7 +477,7 @@ public static Luminosity FromWatts(QuantityValue watts) /// Luminosity unit value. public static Luminosity From(QuantityValue value, LuminosityUnit fromUnit) { - return new Luminosity((QuantityValue)value, fromUnit); + return new Luminosity((double)value, fromUnit); } #endregion @@ -650,25 +647,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static Luminosity operator *(QuantityValue left, Luminosity right) + public static Luminosity operator *(double left, Luminosity right) { return new Luminosity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Luminosity operator *(Luminosity left, QuantityValue right) + public static Luminosity operator *(Luminosity left, double right) { return new Luminosity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Luminosity operator /(Luminosity left, QuantityValue right) + public static Luminosity operator /(Luminosity left, double right) { return new Luminosity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Luminosity left, Luminosity right) + public static double operator /(Luminosity left, Luminosity right) { return left.Watts / right.Watts; } @@ -701,19 +698,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Luminosity left, Luminosity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Luminosity left, Luminosity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -726,29 +710,7 @@ public int CompareTo(object obj) /// public int CompareTo(Luminosity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Luminosity objLuminosity)) - return false; - return Equals(objLuminosity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Luminosity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -791,13 +753,13 @@ public bool Equals(Luminosity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Luminosity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Luminosity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -808,7 +770,7 @@ public bool Equals(Luminosity other, QuantityValue tolerance, ComparisonType com /// A hash code for the current Luminosity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -819,16 +781,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LuminosityUnit unit) + public double As(LuminosityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -843,12 +806,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LuminosityUnit typedUnit)) + if (!(unit is LuminosityUnit unitAsLuminosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLuminosityUnit); } /// @@ -880,7 +843,7 @@ public Luminosity ToUnit(LuminosityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Luminosity)converted; } - else if (Enum.IsDefined(typeof(LuminosityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -888,17 +851,17 @@ public Luminosity ToUnit(LuminosityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminosityUnit typedUnit)) + if (!(unit is LuminosityUnit unitAsLuminosityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLuminosityUnit, DefaultConversionFunctions); } /// @@ -925,10 +888,10 @@ public Luminosity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LuminosityUnit unit) + private double GetValueAs(LuminosityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index 815f8a24de..debe7b5dd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_flux /// [DataContract] - public partial struct LuminousFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static LuminousFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LuminousFlux(QuantityValue value, LuminousFluxUnit unit) + public LuminousFlux(double value, LuminousFluxUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public LuminousFlux(QuantityValue value, LuminousFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousFlux(QuantityValue value, UnitSystem unitSystem) + public LuminousFlux(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public LuminousFlux(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public LuminousFlux(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Lumens => As(LuminousFluxUnit.Lumen); + public double Lumens => As(LuminousFluxUnit.Lumen); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(LuminousFluxUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static LuminousFlux FromLumens(QuantityValue lumens) { - QuantityValue value = (QuantityValue) lumens; + double value = (double) lumens; return new LuminousFlux(value, LuminousFluxUnit.Lumen); } @@ -233,7 +230,7 @@ public static LuminousFlux FromLumens(QuantityValue lumens) /// LuminousFlux unit value. public static LuminousFlux From(QuantityValue value, LuminousFluxUnit fromUnit) { - return new LuminousFlux((QuantityValue)value, fromUnit); + return new LuminousFlux((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static LuminousFlux operator *(QuantityValue left, LuminousFlux right) + public static LuminousFlux operator *(double left, LuminousFlux right) { return new LuminousFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LuminousFlux operator *(LuminousFlux left, QuantityValue right) + public static LuminousFlux operator *(LuminousFlux left, double right) { return new LuminousFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LuminousFlux operator /(LuminousFlux left, QuantityValue right) + public static LuminousFlux operator /(LuminousFlux left, double right) { return new LuminousFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(LuminousFlux left, LuminousFlux right) + public static double operator /(LuminousFlux left, LuminousFlux right) { return left.Lumens / right.Lumens; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousFlux left, LuminousFlux right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousFlux left, LuminousFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(LuminousFlux other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is LuminousFlux objLuminousFlux)) - return false; - return Equals(objLuminousFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousFlux other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(LuminousFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousFlux other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(LuminousFlux other, QuantityValue tolerance, ComparisonType c /// A hash code for the current LuminousFlux. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LuminousFluxUnit unit) + public double As(LuminousFluxUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LuminousFluxUnit typedUnit)) + if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLuminousFluxUnit); } /// @@ -633,7 +596,7 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (LuminousFlux)converted; } - else if (Enum.IsDefined(typeof(LuminousFluxUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousFluxUnit typedUnit)) + if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLuminousFluxUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public LuminousFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LuminousFluxUnit unit) + private double GetValueAs(LuminousFluxUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 0e338c9e86..82199274f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Luminous_intensity /// [DataContract] - public partial struct LuminousIntensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct LuminousIntensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static LuminousIntensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public LuminousIntensity(QuantityValue value, LuminousIntensityUnit unit) + public LuminousIntensity(double value, LuminousIntensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public LuminousIntensity(QuantityValue value, LuminousIntensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public LuminousIntensity(QuantityValue value, UnitSystem unitSystem) + public LuminousIntensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public LuminousIntensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public LuminousIntensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Candela => As(LuminousIntensityUnit.Candela); + public double Candela => As(LuminousIntensityUnit.Candela); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(LuminousIntensityUnit unit, IFormatProvider /// If value is NaN or Infinity. public static LuminousIntensity FromCandela(QuantityValue candela) { - QuantityValue value = (QuantityValue) candela; + double value = (double) candela; return new LuminousIntensity(value, LuminousIntensityUnit.Candela); } @@ -233,7 +230,7 @@ public static LuminousIntensity FromCandela(QuantityValue candela) /// LuminousIntensity unit value. public static LuminousIntensity From(QuantityValue value, LuminousIntensityUnit fromUnit) { - return new LuminousIntensity((QuantityValue)value, fromUnit); + return new LuminousIntensity((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin } /// Get from multiplying value and . - public static LuminousIntensity operator *(QuantityValue left, LuminousIntensity right) + public static LuminousIntensity operator *(double left, LuminousIntensity right) { return new LuminousIntensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static LuminousIntensity operator *(LuminousIntensity left, QuantityValue right) + public static LuminousIntensity operator *(LuminousIntensity left, double right) { return new LuminousIntensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static LuminousIntensity operator /(LuminousIntensity left, QuantityValue right) + public static LuminousIntensity operator /(LuminousIntensity left, double right) { return new LuminousIntensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(LuminousIntensity left, LuminousIntensity right) + public static double operator /(LuminousIntensity left, LuminousIntensity right) { return left.Candela / right.Candela; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Lumin return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(LuminousIntensity left, LuminousIntensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(LuminousIntensity left, LuminousIntensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(LuminousIntensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is LuminousIntensity objLuminousIntensity)) - return false; - return Equals(objLuminousIntensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(LuminousIntensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(LuminousIntensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(LuminousIntensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(LuminousIntensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(LuminousIntensity other, QuantityValue tolerance, ComparisonT /// A hash code for the current LuminousIntensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(LuminousIntensityUnit unit) + public double As(LuminousIntensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is LuminousIntensityUnit typedUnit)) + if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsLuminousIntensityUnit); } /// @@ -633,7 +596,7 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (LuminousIntensity)converted; } - else if (Enum.IsDefined(typeof(LuminousIntensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit, UnitConverter unitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousIntensityUnit typedUnit)) + if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsLuminousIntensityUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public LuminousIntensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(LuminousIntensityUnit unit) + private double GetValueAs(LuminousIntensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 11250ee88c..6103ff0bc9 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_field /// [DataContract] - public partial struct MagneticField : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticField : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static MagneticField() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MagneticField(QuantityValue value, MagneticFieldUnit unit) + public MagneticField(double value, MagneticFieldUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -94,14 +94,14 @@ public MagneticField(QuantityValue value, MagneticFieldUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticField(QuantityValue value, UnitSystem unitSystem) + public MagneticField(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,10 +142,7 @@ public MagneticField(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -168,34 +165,34 @@ public MagneticField(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gausses => As(MagneticFieldUnit.Gauss); + public double Gausses => As(MagneticFieldUnit.Gauss); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microteslas => As(MagneticFieldUnit.Microtesla); + public double Microteslas => As(MagneticFieldUnit.Microtesla); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milligausses => As(MagneticFieldUnit.Milligauss); + public double Milligausses => As(MagneticFieldUnit.Milligauss); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliteslas => As(MagneticFieldUnit.Millitesla); + public double Milliteslas => As(MagneticFieldUnit.Millitesla); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanoteslas => As(MagneticFieldUnit.Nanotesla); + public double Nanoteslas => As(MagneticFieldUnit.Nanotesla); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Teslas => As(MagneticFieldUnit.Tesla); + public double Teslas => As(MagneticFieldUnit.Tesla); #endregion @@ -266,7 +263,7 @@ public static string GetAbbreviation(MagneticFieldUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static MagneticField FromGausses(QuantityValue gausses) { - QuantityValue value = (QuantityValue) gausses; + double value = (double) gausses; return new MagneticField(value, MagneticFieldUnit.Gauss); } @@ -276,7 +273,7 @@ public static MagneticField FromGausses(QuantityValue gausses) /// If value is NaN or Infinity. public static MagneticField FromMicroteslas(QuantityValue microteslas) { - QuantityValue value = (QuantityValue) microteslas; + double value = (double) microteslas; return new MagneticField(value, MagneticFieldUnit.Microtesla); } @@ -286,7 +283,7 @@ public static MagneticField FromMicroteslas(QuantityValue microteslas) /// If value is NaN or Infinity. public static MagneticField FromMilligausses(QuantityValue milligausses) { - QuantityValue value = (QuantityValue) milligausses; + double value = (double) milligausses; return new MagneticField(value, MagneticFieldUnit.Milligauss); } @@ -296,7 +293,7 @@ public static MagneticField FromMilligausses(QuantityValue milligausses) /// If value is NaN or Infinity. public static MagneticField FromMilliteslas(QuantityValue milliteslas) { - QuantityValue value = (QuantityValue) milliteslas; + double value = (double) milliteslas; return new MagneticField(value, MagneticFieldUnit.Millitesla); } @@ -306,7 +303,7 @@ public static MagneticField FromMilliteslas(QuantityValue milliteslas) /// If value is NaN or Infinity. public static MagneticField FromNanoteslas(QuantityValue nanoteslas) { - QuantityValue value = (QuantityValue) nanoteslas; + double value = (double) nanoteslas; return new MagneticField(value, MagneticFieldUnit.Nanotesla); } @@ -316,7 +313,7 @@ public static MagneticField FromNanoteslas(QuantityValue nanoteslas) /// If value is NaN or Infinity. public static MagneticField FromTeslas(QuantityValue teslas) { - QuantityValue value = (QuantityValue) teslas; + double value = (double) teslas; return new MagneticField(value, MagneticFieldUnit.Tesla); } @@ -328,7 +325,7 @@ public static MagneticField FromTeslas(QuantityValue teslas) /// MagneticField unit value. public static MagneticField From(QuantityValue value, MagneticFieldUnit fromUnit) { - return new MagneticField((QuantityValue)value, fromUnit); + return new MagneticField((double)value, fromUnit); } #endregion @@ -498,25 +495,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static MagneticField operator *(QuantityValue left, MagneticField right) + public static MagneticField operator *(double left, MagneticField right) { return new MagneticField(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MagneticField operator *(MagneticField left, QuantityValue right) + public static MagneticField operator *(MagneticField left, double right) { return new MagneticField(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MagneticField operator /(MagneticField left, QuantityValue right) + public static MagneticField operator /(MagneticField left, double right) { return new MagneticField(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MagneticField left, MagneticField right) + public static double operator /(MagneticField left, MagneticField right) { return left.Teslas / right.Teslas; } @@ -549,19 +546,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticField left, MagneticField right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticField left, MagneticField right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -574,29 +558,7 @@ public int CompareTo(object obj) /// public int CompareTo(MagneticField other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MagneticField objMagneticField)) - return false; - return Equals(objMagneticField); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticField other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -639,13 +601,13 @@ public bool Equals(MagneticField other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticField other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MagneticField other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -656,7 +618,7 @@ public bool Equals(MagneticField other, QuantityValue tolerance, ComparisonType /// A hash code for the current MagneticField. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -667,16 +629,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MagneticFieldUnit unit) + public double As(MagneticFieldUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -691,12 +654,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MagneticFieldUnit typedUnit)) + if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMagneticFieldUnit); } /// @@ -728,7 +691,7 @@ public MagneticField ToUnit(MagneticFieldUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MagneticField)converted; } - else if (Enum.IsDefined(typeof(MagneticFieldUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -736,17 +699,17 @@ public MagneticField ToUnit(MagneticFieldUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFieldUnit typedUnit)) + if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMagneticFieldUnit, DefaultConversionFunctions); } /// @@ -773,10 +736,10 @@ public MagneticField ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MagneticFieldUnit unit) + private double GetValueAs(MagneticFieldUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index d5bd23d80a..4be6d9f2f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetic_flux /// [DataContract] - public partial struct MagneticFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MagneticFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static MagneticFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MagneticFlux(QuantityValue value, MagneticFluxUnit unit) + public MagneticFlux(double value, MagneticFluxUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public MagneticFlux(QuantityValue value, MagneticFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MagneticFlux(QuantityValue value, UnitSystem unitSystem) + public MagneticFlux(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public MagneticFlux(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public MagneticFlux(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Webers => As(MagneticFluxUnit.Weber); + public double Webers => As(MagneticFluxUnit.Weber); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(MagneticFluxUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static MagneticFlux FromWebers(QuantityValue webers) { - QuantityValue value = (QuantityValue) webers; + double value = (double) webers; return new MagneticFlux(value, MagneticFluxUnit.Weber); } @@ -233,7 +230,7 @@ public static MagneticFlux FromWebers(QuantityValue webers) /// MagneticFlux unit value. public static MagneticFlux From(QuantityValue value, MagneticFluxUnit fromUnit) { - return new MagneticFlux((QuantityValue)value, fromUnit); + return new MagneticFlux((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static MagneticFlux operator *(QuantityValue left, MagneticFlux right) + public static MagneticFlux operator *(double left, MagneticFlux right) { return new MagneticFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MagneticFlux operator *(MagneticFlux left, QuantityValue right) + public static MagneticFlux operator *(MagneticFlux left, double right) { return new MagneticFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MagneticFlux operator /(MagneticFlux left, QuantityValue right) + public static MagneticFlux operator /(MagneticFlux left, double right) { return new MagneticFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MagneticFlux left, MagneticFlux right) + public static double operator /(MagneticFlux left, MagneticFlux right) { return left.Webers / right.Webers; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MagneticFlux left, MagneticFlux right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MagneticFlux left, MagneticFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(MagneticFlux other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MagneticFlux objMagneticFlux)) - return false; - return Equals(objMagneticFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MagneticFlux other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(MagneticFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MagneticFlux other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(MagneticFlux other, QuantityValue tolerance, ComparisonType c /// A hash code for the current MagneticFlux. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MagneticFluxUnit unit) + public double As(MagneticFluxUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MagneticFluxUnit typedUnit)) + if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMagneticFluxUnit); } /// @@ -633,7 +596,7 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MagneticFlux)converted; } - else if (Enum.IsDefined(typeof(MagneticFluxUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFluxUnit typedUnit)) + if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMagneticFluxUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public MagneticFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MagneticFluxUnit unit) + private double GetValueAs(MagneticFluxUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index 1696417a38..f9a7bc0f03 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Magnetization /// [DataContract] - public partial struct Magnetization : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Magnetization : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Magnetization() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Magnetization(QuantityValue value, MagnetizationUnit unit) + public Magnetization(double value, MagnetizationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public Magnetization(QuantityValue value, MagnetizationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Magnetization(QuantityValue value, UnitSystem unitSystem) + public Magnetization(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public Magnetization(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public Magnetization(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); + public double AmperesPerMeter => As(MagnetizationUnit.AmperePerMeter); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(MagnetizationUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static Magnetization FromAmperesPerMeter(QuantityValue amperespermeter) { - QuantityValue value = (QuantityValue) amperespermeter; + double value = (double) amperespermeter; return new Magnetization(value, MagnetizationUnit.AmperePerMeter); } @@ -233,7 +230,7 @@ public static Magnetization FromAmperesPerMeter(QuantityValue amperespermeter) /// Magnetization unit value. public static Magnetization From(QuantityValue value, MagnetizationUnit fromUnit) { - return new Magnetization((QuantityValue)value, fromUnit); + return new Magnetization((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne } /// Get from multiplying value and . - public static Magnetization operator *(QuantityValue left, Magnetization right) + public static Magnetization operator *(double left, Magnetization right) { return new Magnetization(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Magnetization operator *(Magnetization left, QuantityValue right) + public static Magnetization operator *(Magnetization left, double right) { return new Magnetization(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Magnetization operator /(Magnetization left, QuantityValue right) + public static Magnetization operator /(Magnetization left, double right) { return new Magnetization(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Magnetization left, Magnetization right) + public static double operator /(Magnetization left, Magnetization right) { return left.AmperesPerMeter / right.AmperesPerMeter; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Magne return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Magnetization left, Magnetization right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Magnetization left, Magnetization right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(Magnetization other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Magnetization objMagnetization)) - return false; - return Equals(objMagnetization); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Magnetization other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(Magnetization other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Magnetization other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Magnetization other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(Magnetization other, QuantityValue tolerance, ComparisonType /// A hash code for the current Magnetization. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MagnetizationUnit unit) + public double As(MagnetizationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MagnetizationUnit typedUnit)) + if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMagnetizationUnit); } /// @@ -633,7 +596,7 @@ public Magnetization ToUnit(MagnetizationUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Magnetization)converted; } - else if (Enum.IsDefined(typeof(MagnetizationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public Magnetization ToUnit(MagnetizationUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagnetizationUnit typedUnit)) + if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMagnetizationUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public Magnetization ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MagnetizationUnit unit) + private double GetValueAs(MagnetizationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 968a692d08..16ecf48781 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics, mass (from Greek μᾶζα "barley cake, lump [of dough]") is a property of a physical system or body, giving rise to the phenomena of the body's resistance to being accelerated by a force and the strength of its mutual gravitational attraction with other bodies. Instruments such as mass balances or scales use those phenomena to measure mass. The SI unit of mass is the kilogram (kg). /// [DataContract] - public partial struct Mass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Mass : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -96,9 +96,9 @@ static Mass() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Mass(QuantityValue value, MassUnit unit) + public Mass(double value, MassUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -110,14 +110,14 @@ public Mass(QuantityValue value, MassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Mass(QuantityValue value, UnitSystem unitSystem) + public Mass(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -158,10 +158,7 @@ public Mass(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -184,129 +181,129 @@ public Mass(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centigrams => As(MassUnit.Centigram); + public double Centigrams => As(MassUnit.Centigram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decagrams => As(MassUnit.Decagram); + public double Decagrams => As(MassUnit.Decagram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decigrams => As(MassUnit.Decigram); + public double Decigrams => As(MassUnit.Decigram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue EarthMasses => As(MassUnit.EarthMass); + public double EarthMasses => As(MassUnit.EarthMass); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Grains => As(MassUnit.Grain); + public double Grains => As(MassUnit.Grain); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Grams => As(MassUnit.Gram); + public double Grams => As(MassUnit.Gram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hectograms => As(MassUnit.Hectogram); + public double Hectograms => As(MassUnit.Hectogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilograms => As(MassUnit.Kilogram); + public double Kilograms => As(MassUnit.Kilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilopounds => As(MassUnit.Kilopound); + public double Kilopounds => As(MassUnit.Kilopound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilotonnes => As(MassUnit.Kilotonne); + public double Kilotonnes => As(MassUnit.Kilotonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LongHundredweight => As(MassUnit.LongHundredweight); + public double LongHundredweight => As(MassUnit.LongHundredweight); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LongTons => As(MassUnit.LongTon); + public double LongTons => As(MassUnit.LongTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megapounds => As(MassUnit.Megapound); + public double Megapounds => As(MassUnit.Megapound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megatonnes => As(MassUnit.Megatonne); + public double Megatonnes => As(MassUnit.Megatonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Micrograms => As(MassUnit.Microgram); + public double Micrograms => As(MassUnit.Microgram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milligrams => As(MassUnit.Milligram); + public double Milligrams => As(MassUnit.Milligram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanograms => As(MassUnit.Nanogram); + public double Nanograms => As(MassUnit.Nanogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Ounces => As(MassUnit.Ounce); + public double Ounces => As(MassUnit.Ounce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Pounds => As(MassUnit.Pound); + public double Pounds => As(MassUnit.Pound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ShortHundredweight => As(MassUnit.ShortHundredweight); + public double ShortHundredweight => As(MassUnit.ShortHundredweight); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ShortTons => As(MassUnit.ShortTon); + public double ShortTons => As(MassUnit.ShortTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Slugs => As(MassUnit.Slug); + public double Slugs => As(MassUnit.Slug); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SolarMasses => As(MassUnit.SolarMass); + public double SolarMasses => As(MassUnit.SolarMass); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Stone => As(MassUnit.Stone); + public double Stone => As(MassUnit.Stone); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Tonnes => As(MassUnit.Tonne); + public double Tonnes => As(MassUnit.Tonne); #endregion @@ -469,7 +466,7 @@ public static string GetAbbreviation(MassUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Mass FromCentigrams(QuantityValue centigrams) { - QuantityValue value = (QuantityValue) centigrams; + double value = (double) centigrams; return new Mass(value, MassUnit.Centigram); } @@ -479,7 +476,7 @@ public static Mass FromCentigrams(QuantityValue centigrams) /// If value is NaN or Infinity. public static Mass FromDecagrams(QuantityValue decagrams) { - QuantityValue value = (QuantityValue) decagrams; + double value = (double) decagrams; return new Mass(value, MassUnit.Decagram); } @@ -489,7 +486,7 @@ public static Mass FromDecagrams(QuantityValue decagrams) /// If value is NaN or Infinity. public static Mass FromDecigrams(QuantityValue decigrams) { - QuantityValue value = (QuantityValue) decigrams; + double value = (double) decigrams; return new Mass(value, MassUnit.Decigram); } @@ -499,7 +496,7 @@ public static Mass FromDecigrams(QuantityValue decigrams) /// If value is NaN or Infinity. public static Mass FromEarthMasses(QuantityValue earthmasses) { - QuantityValue value = (QuantityValue) earthmasses; + double value = (double) earthmasses; return new Mass(value, MassUnit.EarthMass); } @@ -509,7 +506,7 @@ public static Mass FromEarthMasses(QuantityValue earthmasses) /// If value is NaN or Infinity. public static Mass FromGrains(QuantityValue grains) { - QuantityValue value = (QuantityValue) grains; + double value = (double) grains; return new Mass(value, MassUnit.Grain); } @@ -519,7 +516,7 @@ public static Mass FromGrains(QuantityValue grains) /// If value is NaN or Infinity. public static Mass FromGrams(QuantityValue grams) { - QuantityValue value = (QuantityValue) grams; + double value = (double) grams; return new Mass(value, MassUnit.Gram); } @@ -529,7 +526,7 @@ public static Mass FromGrams(QuantityValue grams) /// If value is NaN or Infinity. public static Mass FromHectograms(QuantityValue hectograms) { - QuantityValue value = (QuantityValue) hectograms; + double value = (double) hectograms; return new Mass(value, MassUnit.Hectogram); } @@ -539,7 +536,7 @@ public static Mass FromHectograms(QuantityValue hectograms) /// If value is NaN or Infinity. public static Mass FromKilograms(QuantityValue kilograms) { - QuantityValue value = (QuantityValue) kilograms; + double value = (double) kilograms; return new Mass(value, MassUnit.Kilogram); } @@ -549,7 +546,7 @@ public static Mass FromKilograms(QuantityValue kilograms) /// If value is NaN or Infinity. public static Mass FromKilopounds(QuantityValue kilopounds) { - QuantityValue value = (QuantityValue) kilopounds; + double value = (double) kilopounds; return new Mass(value, MassUnit.Kilopound); } @@ -559,7 +556,7 @@ public static Mass FromKilopounds(QuantityValue kilopounds) /// If value is NaN or Infinity. public static Mass FromKilotonnes(QuantityValue kilotonnes) { - QuantityValue value = (QuantityValue) kilotonnes; + double value = (double) kilotonnes; return new Mass(value, MassUnit.Kilotonne); } @@ -569,7 +566,7 @@ public static Mass FromKilotonnes(QuantityValue kilotonnes) /// If value is NaN or Infinity. public static Mass FromLongHundredweight(QuantityValue longhundredweight) { - QuantityValue value = (QuantityValue) longhundredweight; + double value = (double) longhundredweight; return new Mass(value, MassUnit.LongHundredweight); } @@ -579,7 +576,7 @@ public static Mass FromLongHundredweight(QuantityValue longhundredweight) /// If value is NaN or Infinity. public static Mass FromLongTons(QuantityValue longtons) { - QuantityValue value = (QuantityValue) longtons; + double value = (double) longtons; return new Mass(value, MassUnit.LongTon); } @@ -589,7 +586,7 @@ public static Mass FromLongTons(QuantityValue longtons) /// If value is NaN or Infinity. public static Mass FromMegapounds(QuantityValue megapounds) { - QuantityValue value = (QuantityValue) megapounds; + double value = (double) megapounds; return new Mass(value, MassUnit.Megapound); } @@ -599,7 +596,7 @@ public static Mass FromMegapounds(QuantityValue megapounds) /// If value is NaN or Infinity. public static Mass FromMegatonnes(QuantityValue megatonnes) { - QuantityValue value = (QuantityValue) megatonnes; + double value = (double) megatonnes; return new Mass(value, MassUnit.Megatonne); } @@ -609,7 +606,7 @@ public static Mass FromMegatonnes(QuantityValue megatonnes) /// If value is NaN or Infinity. public static Mass FromMicrograms(QuantityValue micrograms) { - QuantityValue value = (QuantityValue) micrograms; + double value = (double) micrograms; return new Mass(value, MassUnit.Microgram); } @@ -619,7 +616,7 @@ public static Mass FromMicrograms(QuantityValue micrograms) /// If value is NaN or Infinity. public static Mass FromMilligrams(QuantityValue milligrams) { - QuantityValue value = (QuantityValue) milligrams; + double value = (double) milligrams; return new Mass(value, MassUnit.Milligram); } @@ -629,7 +626,7 @@ public static Mass FromMilligrams(QuantityValue milligrams) /// If value is NaN or Infinity. public static Mass FromNanograms(QuantityValue nanograms) { - QuantityValue value = (QuantityValue) nanograms; + double value = (double) nanograms; return new Mass(value, MassUnit.Nanogram); } @@ -639,7 +636,7 @@ public static Mass FromNanograms(QuantityValue nanograms) /// If value is NaN or Infinity. public static Mass FromOunces(QuantityValue ounces) { - QuantityValue value = (QuantityValue) ounces; + double value = (double) ounces; return new Mass(value, MassUnit.Ounce); } @@ -649,7 +646,7 @@ public static Mass FromOunces(QuantityValue ounces) /// If value is NaN or Infinity. public static Mass FromPounds(QuantityValue pounds) { - QuantityValue value = (QuantityValue) pounds; + double value = (double) pounds; return new Mass(value, MassUnit.Pound); } @@ -659,7 +656,7 @@ public static Mass FromPounds(QuantityValue pounds) /// If value is NaN or Infinity. public static Mass FromShortHundredweight(QuantityValue shorthundredweight) { - QuantityValue value = (QuantityValue) shorthundredweight; + double value = (double) shorthundredweight; return new Mass(value, MassUnit.ShortHundredweight); } @@ -669,7 +666,7 @@ public static Mass FromShortHundredweight(QuantityValue shorthundredweight) /// If value is NaN or Infinity. public static Mass FromShortTons(QuantityValue shorttons) { - QuantityValue value = (QuantityValue) shorttons; + double value = (double) shorttons; return new Mass(value, MassUnit.ShortTon); } @@ -679,7 +676,7 @@ public static Mass FromShortTons(QuantityValue shorttons) /// If value is NaN or Infinity. public static Mass FromSlugs(QuantityValue slugs) { - QuantityValue value = (QuantityValue) slugs; + double value = (double) slugs; return new Mass(value, MassUnit.Slug); } @@ -689,7 +686,7 @@ public static Mass FromSlugs(QuantityValue slugs) /// If value is NaN or Infinity. public static Mass FromSolarMasses(QuantityValue solarmasses) { - QuantityValue value = (QuantityValue) solarmasses; + double value = (double) solarmasses; return new Mass(value, MassUnit.SolarMass); } @@ -699,7 +696,7 @@ public static Mass FromSolarMasses(QuantityValue solarmasses) /// If value is NaN or Infinity. public static Mass FromStone(QuantityValue stone) { - QuantityValue value = (QuantityValue) stone; + double value = (double) stone; return new Mass(value, MassUnit.Stone); } @@ -709,7 +706,7 @@ public static Mass FromStone(QuantityValue stone) /// If value is NaN or Infinity. public static Mass FromTonnes(QuantityValue tonnes) { - QuantityValue value = (QuantityValue) tonnes; + double value = (double) tonnes; return new Mass(value, MassUnit.Tonne); } @@ -721,7 +718,7 @@ public static Mass FromTonnes(QuantityValue tonnes) /// Mass unit value. public static Mass From(QuantityValue value, MassUnit fromUnit) { - return new Mass((QuantityValue)value, fromUnit); + return new Mass((double)value, fromUnit); } #endregion @@ -891,25 +888,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU } /// Get from multiplying value and . - public static Mass operator *(QuantityValue left, Mass right) + public static Mass operator *(double left, Mass right) { return new Mass(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Mass operator *(Mass left, QuantityValue right) + public static Mass operator *(Mass left, double right) { return new Mass(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Mass operator /(Mass left, QuantityValue right) + public static Mass operator /(Mass left, double right) { return new Mass(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Mass left, Mass right) + public static double operator /(Mass left, Mass right) { return left.Kilograms / right.Kilograms; } @@ -942,19 +939,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassU return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Mass left, Mass right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Mass left, Mass right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -967,29 +951,7 @@ public int CompareTo(object obj) /// public int CompareTo(Mass other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Mass objMass)) - return false; - return Equals(objMass); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Mass other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1032,13 +994,13 @@ public bool Equals(Mass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Mass other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1049,7 +1011,7 @@ public bool Equals(Mass other, QuantityValue tolerance, ComparisonType compariso /// A hash code for the current Mass. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1060,16 +1022,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MassUnit unit) + public double As(MassUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1084,12 +1047,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MassUnit typedUnit)) + if (!(unit is MassUnit unitAsMassUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMassUnit); } /// @@ -1121,7 +1084,7 @@ public Mass ToUnit(MassUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Mass)converted; } - else if (Enum.IsDefined(typeof(MassUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1129,17 +1092,17 @@ public Mass ToUnit(MassUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassUnit typedUnit)) + if (!(unit is MassUnit unitAsMassUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMassUnit, DefaultConversionFunctions); } /// @@ -1166,10 +1129,10 @@ public Mass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MassUnit unit) + private double GetValueAs(MassUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 23e88d2caa..4e0adad314 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_concentration_(chemistry) /// [DataContract] - public partial struct MassConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -123,9 +123,9 @@ static MassConcentration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassConcentration(QuantityValue value, MassConcentrationUnit unit) + public MassConcentration(double value, MassConcentrationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -137,14 +137,14 @@ public MassConcentration(QuantityValue value, MassConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassConcentration(QuantityValue value, UnitSystem unitSystem) + public MassConcentration(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -185,10 +185,7 @@ public MassConcentration(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -211,249 +208,249 @@ public MassConcentration(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); + public double CentigramsPerDeciliter => As(MassConcentrationUnit.CentigramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); + public double CentigramsPerLiter => As(MassConcentrationUnit.CentigramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); + public double CentigramsPerMicroliter => As(MassConcentrationUnit.CentigramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); + public double CentigramsPerMilliliter => As(MassConcentrationUnit.CentigramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); + public double DecigramsPerDeciliter => As(MassConcentrationUnit.DecigramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); + public double DecigramsPerLiter => As(MassConcentrationUnit.DecigramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); + public double DecigramsPerMicroliter => As(MassConcentrationUnit.DecigramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); + public double DecigramsPerMilliliter => As(MassConcentrationUnit.DecigramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); + public double GramsPerCubicCentimeter => As(MassConcentrationUnit.GramPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); + public double GramsPerCubicMeter => As(MassConcentrationUnit.GramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); + public double GramsPerCubicMillimeter => As(MassConcentrationUnit.GramPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); + public double GramsPerDeciliter => As(MassConcentrationUnit.GramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); + public double GramsPerLiter => As(MassConcentrationUnit.GramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); + public double GramsPerMicroliter => As(MassConcentrationUnit.GramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); + public double GramsPerMilliliter => As(MassConcentrationUnit.GramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); + public double KilogramsPerCubicCentimeter => As(MassConcentrationUnit.KilogramPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); + public double KilogramsPerCubicMeter => As(MassConcentrationUnit.KilogramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); + public double KilogramsPerCubicMillimeter => As(MassConcentrationUnit.KilogramPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); + public double KilogramsPerLiter => As(MassConcentrationUnit.KilogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); + public double KilopoundsPerCubicFoot => As(MassConcentrationUnit.KilopoundPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); + public double KilopoundsPerCubicInch => As(MassConcentrationUnit.KilopoundPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); + public double MicrogramsPerCubicMeter => As(MassConcentrationUnit.MicrogramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); + public double MicrogramsPerDeciliter => As(MassConcentrationUnit.MicrogramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); + public double MicrogramsPerLiter => As(MassConcentrationUnit.MicrogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); + public double MicrogramsPerMicroliter => As(MassConcentrationUnit.MicrogramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); + public double MicrogramsPerMilliliter => As(MassConcentrationUnit.MicrogramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); + public double MilligramsPerCubicMeter => As(MassConcentrationUnit.MilligramPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); + public double MilligramsPerDeciliter => As(MassConcentrationUnit.MilligramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); + public double MilligramsPerLiter => As(MassConcentrationUnit.MilligramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); + public double MilligramsPerMicroliter => As(MassConcentrationUnit.MilligramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); + public double MilligramsPerMilliliter => As(MassConcentrationUnit.MilligramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); + public double NanogramsPerDeciliter => As(MassConcentrationUnit.NanogramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); + public double NanogramsPerLiter => As(MassConcentrationUnit.NanogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); + public double NanogramsPerMicroliter => As(MassConcentrationUnit.NanogramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); + public double NanogramsPerMilliliter => As(MassConcentrationUnit.NanogramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); + public double OuncesPerImperialGallon => As(MassConcentrationUnit.OuncePerImperialGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); + public double OuncesPerUSGallon => As(MassConcentrationUnit.OuncePerUSGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); + public double PicogramsPerDeciliter => As(MassConcentrationUnit.PicogramPerDeciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); + public double PicogramsPerLiter => As(MassConcentrationUnit.PicogramPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); + public double PicogramsPerMicroliter => As(MassConcentrationUnit.PicogramPerMicroliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); + public double PicogramsPerMilliliter => As(MassConcentrationUnit.PicogramPerMilliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); + public double PoundsPerCubicFoot => As(MassConcentrationUnit.PoundPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); + public double PoundsPerCubicInch => As(MassConcentrationUnit.PoundPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); + public double PoundsPerImperialGallon => As(MassConcentrationUnit.PoundPerImperialGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); + public double PoundsPerUSGallon => As(MassConcentrationUnit.PoundPerUSGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); + public double SlugsPerCubicFoot => As(MassConcentrationUnit.SlugPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); + public double TonnesPerCubicCentimeter => As(MassConcentrationUnit.TonnePerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); + public double TonnesPerCubicMeter => As(MassConcentrationUnit.TonnePerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); + public double TonnesPerCubicMillimeter => As(MassConcentrationUnit.TonnePerCubicMillimeter); #endregion @@ -657,7 +654,7 @@ public static string GetAbbreviation(MassConcentrationUnit unit, IFormatProvider /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerDeciliter(QuantityValue centigramsperdeciliter) { - QuantityValue value = (QuantityValue) centigramsperdeciliter; + double value = (double) centigramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerDeciliter); } @@ -667,7 +664,7 @@ public static MassConcentration FromCentigramsPerDeciliter(QuantityValue centigr /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerLiter(QuantityValue centigramsperliter) { - QuantityValue value = (QuantityValue) centigramsperliter; + double value = (double) centigramsperliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerLiter); } @@ -677,7 +674,7 @@ public static MassConcentration FromCentigramsPerLiter(QuantityValue centigramsp /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerMicroliter(QuantityValue centigramspermicroliter) { - QuantityValue value = (QuantityValue) centigramspermicroliter; + double value = (double) centigramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerMicroliter); } @@ -687,7 +684,7 @@ public static MassConcentration FromCentigramsPerMicroliter(QuantityValue centig /// If value is NaN or Infinity. public static MassConcentration FromCentigramsPerMilliliter(QuantityValue centigramspermilliliter) { - QuantityValue value = (QuantityValue) centigramspermilliliter; + double value = (double) centigramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.CentigramPerMilliliter); } @@ -697,7 +694,7 @@ public static MassConcentration FromCentigramsPerMilliliter(QuantityValue centig /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerDeciliter(QuantityValue decigramsperdeciliter) { - QuantityValue value = (QuantityValue) decigramsperdeciliter; + double value = (double) decigramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerDeciliter); } @@ -707,7 +704,7 @@ public static MassConcentration FromDecigramsPerDeciliter(QuantityValue decigram /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerLiter(QuantityValue decigramsperliter) { - QuantityValue value = (QuantityValue) decigramsperliter; + double value = (double) decigramsperliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerLiter); } @@ -717,7 +714,7 @@ public static MassConcentration FromDecigramsPerLiter(QuantityValue decigramsper /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerMicroliter(QuantityValue decigramspermicroliter) { - QuantityValue value = (QuantityValue) decigramspermicroliter; + double value = (double) decigramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerMicroliter); } @@ -727,7 +724,7 @@ public static MassConcentration FromDecigramsPerMicroliter(QuantityValue decigra /// If value is NaN or Infinity. public static MassConcentration FromDecigramsPerMilliliter(QuantityValue decigramspermilliliter) { - QuantityValue value = (QuantityValue) decigramspermilliliter; + double value = (double) decigramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.DecigramPerMilliliter); } @@ -737,7 +734,7 @@ public static MassConcentration FromDecigramsPerMilliliter(QuantityValue decigra /// If value is NaN or Infinity. public static MassConcentration FromGramsPerCubicCentimeter(QuantityValue gramspercubiccentimeter) { - QuantityValue value = (QuantityValue) gramspercubiccentimeter; + double value = (double) gramspercubiccentimeter; return new MassConcentration(value, MassConcentrationUnit.GramPerCubicCentimeter); } @@ -747,7 +744,7 @@ public static MassConcentration FromGramsPerCubicCentimeter(QuantityValue gramsp /// If value is NaN or Infinity. public static MassConcentration FromGramsPerCubicMeter(QuantityValue gramspercubicmeter) { - QuantityValue value = (QuantityValue) gramspercubicmeter; + double value = (double) gramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMeter); } @@ -757,7 +754,7 @@ public static MassConcentration FromGramsPerCubicMeter(QuantityValue gramspercub /// If value is NaN or Infinity. public static MassConcentration FromGramsPerCubicMillimeter(QuantityValue gramspercubicmillimeter) { - QuantityValue value = (QuantityValue) gramspercubicmillimeter; + double value = (double) gramspercubicmillimeter; return new MassConcentration(value, MassConcentrationUnit.GramPerCubicMillimeter); } @@ -767,7 +764,7 @@ public static MassConcentration FromGramsPerCubicMillimeter(QuantityValue gramsp /// If value is NaN or Infinity. public static MassConcentration FromGramsPerDeciliter(QuantityValue gramsperdeciliter) { - QuantityValue value = (QuantityValue) gramsperdeciliter; + double value = (double) gramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.GramPerDeciliter); } @@ -777,7 +774,7 @@ public static MassConcentration FromGramsPerDeciliter(QuantityValue gramsperdeci /// If value is NaN or Infinity. public static MassConcentration FromGramsPerLiter(QuantityValue gramsperliter) { - QuantityValue value = (QuantityValue) gramsperliter; + double value = (double) gramsperliter; return new MassConcentration(value, MassConcentrationUnit.GramPerLiter); } @@ -787,7 +784,7 @@ public static MassConcentration FromGramsPerLiter(QuantityValue gramsperliter) /// If value is NaN or Infinity. public static MassConcentration FromGramsPerMicroliter(QuantityValue gramspermicroliter) { - QuantityValue value = (QuantityValue) gramspermicroliter; + double value = (double) gramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.GramPerMicroliter); } @@ -797,7 +794,7 @@ public static MassConcentration FromGramsPerMicroliter(QuantityValue gramspermic /// If value is NaN or Infinity. public static MassConcentration FromGramsPerMilliliter(QuantityValue gramspermilliliter) { - QuantityValue value = (QuantityValue) gramspermilliliter; + double value = (double) gramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.GramPerMilliliter); } @@ -807,7 +804,7 @@ public static MassConcentration FromGramsPerMilliliter(QuantityValue gramspermil /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerCubicCentimeter(QuantityValue kilogramspercubiccentimeter) { - QuantityValue value = (QuantityValue) kilogramspercubiccentimeter; + double value = (double) kilogramspercubiccentimeter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicCentimeter); } @@ -817,7 +814,7 @@ public static MassConcentration FromKilogramsPerCubicCentimeter(QuantityValue ki /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerCubicMeter(QuantityValue kilogramspercubicmeter) { - QuantityValue value = (QuantityValue) kilogramspercubicmeter; + double value = (double) kilogramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMeter); } @@ -827,7 +824,7 @@ public static MassConcentration FromKilogramsPerCubicMeter(QuantityValue kilogra /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerCubicMillimeter(QuantityValue kilogramspercubicmillimeter) { - QuantityValue value = (QuantityValue) kilogramspercubicmillimeter; + double value = (double) kilogramspercubicmillimeter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerCubicMillimeter); } @@ -837,7 +834,7 @@ public static MassConcentration FromKilogramsPerCubicMillimeter(QuantityValue ki /// If value is NaN or Infinity. public static MassConcentration FromKilogramsPerLiter(QuantityValue kilogramsperliter) { - QuantityValue value = (QuantityValue) kilogramsperliter; + double value = (double) kilogramsperliter; return new MassConcentration(value, MassConcentrationUnit.KilogramPerLiter); } @@ -847,7 +844,7 @@ public static MassConcentration FromKilogramsPerLiter(QuantityValue kilogramsper /// If value is NaN or Infinity. public static MassConcentration FromKilopoundsPerCubicFoot(QuantityValue kilopoundspercubicfoot) { - QuantityValue value = (QuantityValue) kilopoundspercubicfoot; + double value = (double) kilopoundspercubicfoot; return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicFoot); } @@ -857,7 +854,7 @@ public static MassConcentration FromKilopoundsPerCubicFoot(QuantityValue kilopou /// If value is NaN or Infinity. public static MassConcentration FromKilopoundsPerCubicInch(QuantityValue kilopoundspercubicinch) { - QuantityValue value = (QuantityValue) kilopoundspercubicinch; + double value = (double) kilopoundspercubicinch; return new MassConcentration(value, MassConcentrationUnit.KilopoundPerCubicInch); } @@ -867,7 +864,7 @@ public static MassConcentration FromKilopoundsPerCubicInch(QuantityValue kilopou /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerCubicMeter(QuantityValue microgramspercubicmeter) { - QuantityValue value = (QuantityValue) microgramspercubicmeter; + double value = (double) microgramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerCubicMeter); } @@ -877,7 +874,7 @@ public static MassConcentration FromMicrogramsPerCubicMeter(QuantityValue microg /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerDeciliter(QuantityValue microgramsperdeciliter) { - QuantityValue value = (QuantityValue) microgramsperdeciliter; + double value = (double) microgramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerDeciliter); } @@ -887,7 +884,7 @@ public static MassConcentration FromMicrogramsPerDeciliter(QuantityValue microgr /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerLiter(QuantityValue microgramsperliter) { - QuantityValue value = (QuantityValue) microgramsperliter; + double value = (double) microgramsperliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerLiter); } @@ -897,7 +894,7 @@ public static MassConcentration FromMicrogramsPerLiter(QuantityValue microgramsp /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerMicroliter(QuantityValue microgramspermicroliter) { - QuantityValue value = (QuantityValue) microgramspermicroliter; + double value = (double) microgramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMicroliter); } @@ -907,7 +904,7 @@ public static MassConcentration FromMicrogramsPerMicroliter(QuantityValue microg /// If value is NaN or Infinity. public static MassConcentration FromMicrogramsPerMilliliter(QuantityValue microgramspermilliliter) { - QuantityValue value = (QuantityValue) microgramspermilliliter; + double value = (double) microgramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.MicrogramPerMilliliter); } @@ -917,7 +914,7 @@ public static MassConcentration FromMicrogramsPerMilliliter(QuantityValue microg /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerCubicMeter(QuantityValue milligramspercubicmeter) { - QuantityValue value = (QuantityValue) milligramspercubicmeter; + double value = (double) milligramspercubicmeter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerCubicMeter); } @@ -927,7 +924,7 @@ public static MassConcentration FromMilligramsPerCubicMeter(QuantityValue millig /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerDeciliter(QuantityValue milligramsperdeciliter) { - QuantityValue value = (QuantityValue) milligramsperdeciliter; + double value = (double) milligramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerDeciliter); } @@ -937,7 +934,7 @@ public static MassConcentration FromMilligramsPerDeciliter(QuantityValue milligr /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerLiter(QuantityValue milligramsperliter) { - QuantityValue value = (QuantityValue) milligramsperliter; + double value = (double) milligramsperliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerLiter); } @@ -947,7 +944,7 @@ public static MassConcentration FromMilligramsPerLiter(QuantityValue milligramsp /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerMicroliter(QuantityValue milligramspermicroliter) { - QuantityValue value = (QuantityValue) milligramspermicroliter; + double value = (double) milligramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerMicroliter); } @@ -957,7 +954,7 @@ public static MassConcentration FromMilligramsPerMicroliter(QuantityValue millig /// If value is NaN or Infinity. public static MassConcentration FromMilligramsPerMilliliter(QuantityValue milligramspermilliliter) { - QuantityValue value = (QuantityValue) milligramspermilliliter; + double value = (double) milligramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.MilligramPerMilliliter); } @@ -967,7 +964,7 @@ public static MassConcentration FromMilligramsPerMilliliter(QuantityValue millig /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerDeciliter(QuantityValue nanogramsperdeciliter) { - QuantityValue value = (QuantityValue) nanogramsperdeciliter; + double value = (double) nanogramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerDeciliter); } @@ -977,7 +974,7 @@ public static MassConcentration FromNanogramsPerDeciliter(QuantityValue nanogram /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerLiter(QuantityValue nanogramsperliter) { - QuantityValue value = (QuantityValue) nanogramsperliter; + double value = (double) nanogramsperliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerLiter); } @@ -987,7 +984,7 @@ public static MassConcentration FromNanogramsPerLiter(QuantityValue nanogramsper /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerMicroliter(QuantityValue nanogramspermicroliter) { - QuantityValue value = (QuantityValue) nanogramspermicroliter; + double value = (double) nanogramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerMicroliter); } @@ -997,7 +994,7 @@ public static MassConcentration FromNanogramsPerMicroliter(QuantityValue nanogra /// If value is NaN or Infinity. public static MassConcentration FromNanogramsPerMilliliter(QuantityValue nanogramspermilliliter) { - QuantityValue value = (QuantityValue) nanogramspermilliliter; + double value = (double) nanogramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.NanogramPerMilliliter); } @@ -1007,7 +1004,7 @@ public static MassConcentration FromNanogramsPerMilliliter(QuantityValue nanogra /// If value is NaN or Infinity. public static MassConcentration FromOuncesPerImperialGallon(QuantityValue ouncesperimperialgallon) { - QuantityValue value = (QuantityValue) ouncesperimperialgallon; + double value = (double) ouncesperimperialgallon; return new MassConcentration(value, MassConcentrationUnit.OuncePerImperialGallon); } @@ -1017,7 +1014,7 @@ public static MassConcentration FromOuncesPerImperialGallon(QuantityValue ounces /// If value is NaN or Infinity. public static MassConcentration FromOuncesPerUSGallon(QuantityValue ouncesperusgallon) { - QuantityValue value = (QuantityValue) ouncesperusgallon; + double value = (double) ouncesperusgallon; return new MassConcentration(value, MassConcentrationUnit.OuncePerUSGallon); } @@ -1027,7 +1024,7 @@ public static MassConcentration FromOuncesPerUSGallon(QuantityValue ouncesperusg /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerDeciliter(QuantityValue picogramsperdeciliter) { - QuantityValue value = (QuantityValue) picogramsperdeciliter; + double value = (double) picogramsperdeciliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerDeciliter); } @@ -1037,7 +1034,7 @@ public static MassConcentration FromPicogramsPerDeciliter(QuantityValue picogram /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerLiter(QuantityValue picogramsperliter) { - QuantityValue value = (QuantityValue) picogramsperliter; + double value = (double) picogramsperliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerLiter); } @@ -1047,7 +1044,7 @@ public static MassConcentration FromPicogramsPerLiter(QuantityValue picogramsper /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerMicroliter(QuantityValue picogramspermicroliter) { - QuantityValue value = (QuantityValue) picogramspermicroliter; + double value = (double) picogramspermicroliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerMicroliter); } @@ -1057,7 +1054,7 @@ public static MassConcentration FromPicogramsPerMicroliter(QuantityValue picogra /// If value is NaN or Infinity. public static MassConcentration FromPicogramsPerMilliliter(QuantityValue picogramspermilliliter) { - QuantityValue value = (QuantityValue) picogramspermilliliter; + double value = (double) picogramspermilliliter; return new MassConcentration(value, MassConcentrationUnit.PicogramPerMilliliter); } @@ -1067,7 +1064,7 @@ public static MassConcentration FromPicogramsPerMilliliter(QuantityValue picogra /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerCubicFoot(QuantityValue poundspercubicfoot) { - QuantityValue value = (QuantityValue) poundspercubicfoot; + double value = (double) poundspercubicfoot; return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicFoot); } @@ -1077,7 +1074,7 @@ public static MassConcentration FromPoundsPerCubicFoot(QuantityValue poundspercu /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerCubicInch(QuantityValue poundspercubicinch) { - QuantityValue value = (QuantityValue) poundspercubicinch; + double value = (double) poundspercubicinch; return new MassConcentration(value, MassConcentrationUnit.PoundPerCubicInch); } @@ -1087,7 +1084,7 @@ public static MassConcentration FromPoundsPerCubicInch(QuantityValue poundspercu /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerImperialGallon(QuantityValue poundsperimperialgallon) { - QuantityValue value = (QuantityValue) poundsperimperialgallon; + double value = (double) poundsperimperialgallon; return new MassConcentration(value, MassConcentrationUnit.PoundPerImperialGallon); } @@ -1097,7 +1094,7 @@ public static MassConcentration FromPoundsPerImperialGallon(QuantityValue pounds /// If value is NaN or Infinity. public static MassConcentration FromPoundsPerUSGallon(QuantityValue poundsperusgallon) { - QuantityValue value = (QuantityValue) poundsperusgallon; + double value = (double) poundsperusgallon; return new MassConcentration(value, MassConcentrationUnit.PoundPerUSGallon); } @@ -1107,7 +1104,7 @@ public static MassConcentration FromPoundsPerUSGallon(QuantityValue poundsperusg /// If value is NaN or Infinity. public static MassConcentration FromSlugsPerCubicFoot(QuantityValue slugspercubicfoot) { - QuantityValue value = (QuantityValue) slugspercubicfoot; + double value = (double) slugspercubicfoot; return new MassConcentration(value, MassConcentrationUnit.SlugPerCubicFoot); } @@ -1117,7 +1114,7 @@ public static MassConcentration FromSlugsPerCubicFoot(QuantityValue slugspercubi /// If value is NaN or Infinity. public static MassConcentration FromTonnesPerCubicCentimeter(QuantityValue tonnespercubiccentimeter) { - QuantityValue value = (QuantityValue) tonnespercubiccentimeter; + double value = (double) tonnespercubiccentimeter; return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicCentimeter); } @@ -1127,7 +1124,7 @@ public static MassConcentration FromTonnesPerCubicCentimeter(QuantityValue tonne /// If value is NaN or Infinity. public static MassConcentration FromTonnesPerCubicMeter(QuantityValue tonnespercubicmeter) { - QuantityValue value = (QuantityValue) tonnespercubicmeter; + double value = (double) tonnespercubicmeter; return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMeter); } @@ -1137,7 +1134,7 @@ public static MassConcentration FromTonnesPerCubicMeter(QuantityValue tonnesperc /// If value is NaN or Infinity. public static MassConcentration FromTonnesPerCubicMillimeter(QuantityValue tonnespercubicmillimeter) { - QuantityValue value = (QuantityValue) tonnespercubicmillimeter; + double value = (double) tonnespercubicmillimeter; return new MassConcentration(value, MassConcentrationUnit.TonnePerCubicMillimeter); } @@ -1149,7 +1146,7 @@ public static MassConcentration FromTonnesPerCubicMillimeter(QuantityValue tonne /// MassConcentration unit value. public static MassConcentration From(QuantityValue value, MassConcentrationUnit fromUnit) { - return new MassConcentration((QuantityValue)value, fromUnit); + return new MassConcentration((double)value, fromUnit); } #endregion @@ -1319,25 +1316,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC } /// Get from multiplying value and . - public static MassConcentration operator *(QuantityValue left, MassConcentration right) + public static MassConcentration operator *(double left, MassConcentration right) { return new MassConcentration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassConcentration operator *(MassConcentration left, QuantityValue right) + public static MassConcentration operator *(MassConcentration left, double right) { return new MassConcentration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassConcentration operator /(MassConcentration left, QuantityValue right) + public static MassConcentration operator /(MassConcentration left, double right) { return new MassConcentration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MassConcentration left, MassConcentration right) + public static double operator /(MassConcentration left, MassConcentration right) { return left.KilogramsPerCubicMeter / right.KilogramsPerCubicMeter; } @@ -1370,19 +1367,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassC return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassConcentration left, MassConcentration right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassConcentration left, MassConcentration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1395,29 +1379,7 @@ public int CompareTo(object obj) /// public int CompareTo(MassConcentration other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MassConcentration objMassConcentration)) - return false; - return Equals(objMassConcentration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassConcentration other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1460,13 +1422,13 @@ public bool Equals(MassConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassConcentration other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MassConcentration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1477,7 +1439,7 @@ public bool Equals(MassConcentration other, QuantityValue tolerance, ComparisonT /// A hash code for the current MassConcentration. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1488,16 +1450,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MassConcentrationUnit unit) + public double As(MassConcentrationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1512,12 +1475,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MassConcentrationUnit typedUnit)) + if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMassConcentrationUnit); } /// @@ -1549,7 +1512,7 @@ public MassConcentration ToUnit(MassConcentrationUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (MassConcentration)converted; } - else if (Enum.IsDefined(typeof(MassConcentrationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1557,17 +1520,17 @@ public MassConcentration ToUnit(MassConcentrationUnit unit, UnitConverter unitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassConcentrationUnit typedUnit)) + if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMassConcentrationUnit, DefaultConversionFunctions); } /// @@ -1594,10 +1557,10 @@ public MassConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MassConcentrationUnit unit) + private double GetValueAs(MassConcentrationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index e20dfffc3b..30ce043051 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Mass flow is the ratio of the mass change to the time during which the change occurred (value of mass changes per unit time). /// [DataContract] - public partial struct MassFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -104,9 +104,9 @@ static MassFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFlow(QuantityValue value, MassFlowUnit unit) + public MassFlow(double value, MassFlowUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,14 +118,14 @@ public MassFlow(QuantityValue value, MassFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlow(QuantityValue value, UnitSystem unitSystem) + public MassFlow(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -166,10 +166,7 @@ public MassFlow(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -192,169 +189,169 @@ public MassFlow(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); + public double CentigramsPerDay => As(MassFlowUnit.CentigramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); + public double CentigramsPerSecond => As(MassFlowUnit.CentigramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); + public double DecagramsPerDay => As(MassFlowUnit.DecagramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); + public double DecagramsPerSecond => As(MassFlowUnit.DecagramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); + public double DecigramsPerDay => As(MassFlowUnit.DecigramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); + public double DecigramsPerSecond => As(MassFlowUnit.DecigramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerDay => As(MassFlowUnit.GramPerDay); + public double GramsPerDay => As(MassFlowUnit.GramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerHour => As(MassFlowUnit.GramPerHour); + public double GramsPerHour => As(MassFlowUnit.GramPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerSecond => As(MassFlowUnit.GramPerSecond); + public double GramsPerSecond => As(MassFlowUnit.GramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); + public double HectogramsPerDay => As(MassFlowUnit.HectogramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); + public double HectogramsPerSecond => As(MassFlowUnit.HectogramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); + public double KilogramsPerDay => As(MassFlowUnit.KilogramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); + public double KilogramsPerHour => As(MassFlowUnit.KilogramPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); + public double KilogramsPerMinute => As(MassFlowUnit.KilogramPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); + public double KilogramsPerSecond => As(MassFlowUnit.KilogramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); + public double MegagramsPerDay => As(MassFlowUnit.MegagramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); + public double MegapoundsPerDay => As(MassFlowUnit.MegapoundPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); + public double MegapoundsPerHour => As(MassFlowUnit.MegapoundPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); + public double MegapoundsPerMinute => As(MassFlowUnit.MegapoundPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); + public double MegapoundsPerSecond => As(MassFlowUnit.MegapoundPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); + public double MicrogramsPerDay => As(MassFlowUnit.MicrogramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); + public double MicrogramsPerSecond => As(MassFlowUnit.MicrogramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); + public double MilligramsPerDay => As(MassFlowUnit.MilligramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); + public double MilligramsPerSecond => As(MassFlowUnit.MilligramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); + public double NanogramsPerDay => As(MassFlowUnit.NanogramPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); + public double NanogramsPerSecond => As(MassFlowUnit.NanogramPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerDay => As(MassFlowUnit.PoundPerDay); + public double PoundsPerDay => As(MassFlowUnit.PoundPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerHour => As(MassFlowUnit.PoundPerHour); + public double PoundsPerHour => As(MassFlowUnit.PoundPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); + public double PoundsPerMinute => As(MassFlowUnit.PoundPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); + public double PoundsPerSecond => As(MassFlowUnit.PoundPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); + public double ShortTonsPerHour => As(MassFlowUnit.ShortTonPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerDay => As(MassFlowUnit.TonnePerDay); + public double TonnesPerDay => As(MassFlowUnit.TonnePerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesPerHour => As(MassFlowUnit.TonnePerHour); + public double TonnesPerHour => As(MassFlowUnit.TonnePerHour); #endregion @@ -508,7 +505,7 @@ public static string GetAbbreviation(MassFlowUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static MassFlow FromCentigramsPerDay(QuantityValue centigramsperday) { - QuantityValue value = (QuantityValue) centigramsperday; + double value = (double) centigramsperday; return new MassFlow(value, MassFlowUnit.CentigramPerDay); } @@ -518,7 +515,7 @@ public static MassFlow FromCentigramsPerDay(QuantityValue centigramsperday) /// If value is NaN or Infinity. public static MassFlow FromCentigramsPerSecond(QuantityValue centigramspersecond) { - QuantityValue value = (QuantityValue) centigramspersecond; + double value = (double) centigramspersecond; return new MassFlow(value, MassFlowUnit.CentigramPerSecond); } @@ -528,7 +525,7 @@ public static MassFlow FromCentigramsPerSecond(QuantityValue centigramspersecond /// If value is NaN or Infinity. public static MassFlow FromDecagramsPerDay(QuantityValue decagramsperday) { - QuantityValue value = (QuantityValue) decagramsperday; + double value = (double) decagramsperday; return new MassFlow(value, MassFlowUnit.DecagramPerDay); } @@ -538,7 +535,7 @@ public static MassFlow FromDecagramsPerDay(QuantityValue decagramsperday) /// If value is NaN or Infinity. public static MassFlow FromDecagramsPerSecond(QuantityValue decagramspersecond) { - QuantityValue value = (QuantityValue) decagramspersecond; + double value = (double) decagramspersecond; return new MassFlow(value, MassFlowUnit.DecagramPerSecond); } @@ -548,7 +545,7 @@ public static MassFlow FromDecagramsPerSecond(QuantityValue decagramspersecond) /// If value is NaN or Infinity. public static MassFlow FromDecigramsPerDay(QuantityValue decigramsperday) { - QuantityValue value = (QuantityValue) decigramsperday; + double value = (double) decigramsperday; return new MassFlow(value, MassFlowUnit.DecigramPerDay); } @@ -558,7 +555,7 @@ public static MassFlow FromDecigramsPerDay(QuantityValue decigramsperday) /// If value is NaN or Infinity. public static MassFlow FromDecigramsPerSecond(QuantityValue decigramspersecond) { - QuantityValue value = (QuantityValue) decigramspersecond; + double value = (double) decigramspersecond; return new MassFlow(value, MassFlowUnit.DecigramPerSecond); } @@ -568,7 +565,7 @@ public static MassFlow FromDecigramsPerSecond(QuantityValue decigramspersecond) /// If value is NaN or Infinity. public static MassFlow FromGramsPerDay(QuantityValue gramsperday) { - QuantityValue value = (QuantityValue) gramsperday; + double value = (double) gramsperday; return new MassFlow(value, MassFlowUnit.GramPerDay); } @@ -578,7 +575,7 @@ public static MassFlow FromGramsPerDay(QuantityValue gramsperday) /// If value is NaN or Infinity. public static MassFlow FromGramsPerHour(QuantityValue gramsperhour) { - QuantityValue value = (QuantityValue) gramsperhour; + double value = (double) gramsperhour; return new MassFlow(value, MassFlowUnit.GramPerHour); } @@ -588,7 +585,7 @@ public static MassFlow FromGramsPerHour(QuantityValue gramsperhour) /// If value is NaN or Infinity. public static MassFlow FromGramsPerSecond(QuantityValue gramspersecond) { - QuantityValue value = (QuantityValue) gramspersecond; + double value = (double) gramspersecond; return new MassFlow(value, MassFlowUnit.GramPerSecond); } @@ -598,7 +595,7 @@ public static MassFlow FromGramsPerSecond(QuantityValue gramspersecond) /// If value is NaN or Infinity. public static MassFlow FromHectogramsPerDay(QuantityValue hectogramsperday) { - QuantityValue value = (QuantityValue) hectogramsperday; + double value = (double) hectogramsperday; return new MassFlow(value, MassFlowUnit.HectogramPerDay); } @@ -608,7 +605,7 @@ public static MassFlow FromHectogramsPerDay(QuantityValue hectogramsperday) /// If value is NaN or Infinity. public static MassFlow FromHectogramsPerSecond(QuantityValue hectogramspersecond) { - QuantityValue value = (QuantityValue) hectogramspersecond; + double value = (double) hectogramspersecond; return new MassFlow(value, MassFlowUnit.HectogramPerSecond); } @@ -618,7 +615,7 @@ public static MassFlow FromHectogramsPerSecond(QuantityValue hectogramspersecond /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerDay(QuantityValue kilogramsperday) { - QuantityValue value = (QuantityValue) kilogramsperday; + double value = (double) kilogramsperday; return new MassFlow(value, MassFlowUnit.KilogramPerDay); } @@ -628,7 +625,7 @@ public static MassFlow FromKilogramsPerDay(QuantityValue kilogramsperday) /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerHour(QuantityValue kilogramsperhour) { - QuantityValue value = (QuantityValue) kilogramsperhour; + double value = (double) kilogramsperhour; return new MassFlow(value, MassFlowUnit.KilogramPerHour); } @@ -638,7 +635,7 @@ public static MassFlow FromKilogramsPerHour(QuantityValue kilogramsperhour) /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerMinute(QuantityValue kilogramsperminute) { - QuantityValue value = (QuantityValue) kilogramsperminute; + double value = (double) kilogramsperminute; return new MassFlow(value, MassFlowUnit.KilogramPerMinute); } @@ -648,7 +645,7 @@ public static MassFlow FromKilogramsPerMinute(QuantityValue kilogramsperminute) /// If value is NaN or Infinity. public static MassFlow FromKilogramsPerSecond(QuantityValue kilogramspersecond) { - QuantityValue value = (QuantityValue) kilogramspersecond; + double value = (double) kilogramspersecond; return new MassFlow(value, MassFlowUnit.KilogramPerSecond); } @@ -658,7 +655,7 @@ public static MassFlow FromKilogramsPerSecond(QuantityValue kilogramspersecond) /// If value is NaN or Infinity. public static MassFlow FromMegagramsPerDay(QuantityValue megagramsperday) { - QuantityValue value = (QuantityValue) megagramsperday; + double value = (double) megagramsperday; return new MassFlow(value, MassFlowUnit.MegagramPerDay); } @@ -668,7 +665,7 @@ public static MassFlow FromMegagramsPerDay(QuantityValue megagramsperday) /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerDay(QuantityValue megapoundsperday) { - QuantityValue value = (QuantityValue) megapoundsperday; + double value = (double) megapoundsperday; return new MassFlow(value, MassFlowUnit.MegapoundPerDay); } @@ -678,7 +675,7 @@ public static MassFlow FromMegapoundsPerDay(QuantityValue megapoundsperday) /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerHour(QuantityValue megapoundsperhour) { - QuantityValue value = (QuantityValue) megapoundsperhour; + double value = (double) megapoundsperhour; return new MassFlow(value, MassFlowUnit.MegapoundPerHour); } @@ -688,7 +685,7 @@ public static MassFlow FromMegapoundsPerHour(QuantityValue megapoundsperhour) /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerMinute(QuantityValue megapoundsperminute) { - QuantityValue value = (QuantityValue) megapoundsperminute; + double value = (double) megapoundsperminute; return new MassFlow(value, MassFlowUnit.MegapoundPerMinute); } @@ -698,7 +695,7 @@ public static MassFlow FromMegapoundsPerMinute(QuantityValue megapoundsperminute /// If value is NaN or Infinity. public static MassFlow FromMegapoundsPerSecond(QuantityValue megapoundspersecond) { - QuantityValue value = (QuantityValue) megapoundspersecond; + double value = (double) megapoundspersecond; return new MassFlow(value, MassFlowUnit.MegapoundPerSecond); } @@ -708,7 +705,7 @@ public static MassFlow FromMegapoundsPerSecond(QuantityValue megapoundspersecond /// If value is NaN or Infinity. public static MassFlow FromMicrogramsPerDay(QuantityValue microgramsperday) { - QuantityValue value = (QuantityValue) microgramsperday; + double value = (double) microgramsperday; return new MassFlow(value, MassFlowUnit.MicrogramPerDay); } @@ -718,7 +715,7 @@ public static MassFlow FromMicrogramsPerDay(QuantityValue microgramsperday) /// If value is NaN or Infinity. public static MassFlow FromMicrogramsPerSecond(QuantityValue microgramspersecond) { - QuantityValue value = (QuantityValue) microgramspersecond; + double value = (double) microgramspersecond; return new MassFlow(value, MassFlowUnit.MicrogramPerSecond); } @@ -728,7 +725,7 @@ public static MassFlow FromMicrogramsPerSecond(QuantityValue microgramspersecond /// If value is NaN or Infinity. public static MassFlow FromMilligramsPerDay(QuantityValue milligramsperday) { - QuantityValue value = (QuantityValue) milligramsperday; + double value = (double) milligramsperday; return new MassFlow(value, MassFlowUnit.MilligramPerDay); } @@ -738,7 +735,7 @@ public static MassFlow FromMilligramsPerDay(QuantityValue milligramsperday) /// If value is NaN or Infinity. public static MassFlow FromMilligramsPerSecond(QuantityValue milligramspersecond) { - QuantityValue value = (QuantityValue) milligramspersecond; + double value = (double) milligramspersecond; return new MassFlow(value, MassFlowUnit.MilligramPerSecond); } @@ -748,7 +745,7 @@ public static MassFlow FromMilligramsPerSecond(QuantityValue milligramspersecond /// If value is NaN or Infinity. public static MassFlow FromNanogramsPerDay(QuantityValue nanogramsperday) { - QuantityValue value = (QuantityValue) nanogramsperday; + double value = (double) nanogramsperday; return new MassFlow(value, MassFlowUnit.NanogramPerDay); } @@ -758,7 +755,7 @@ public static MassFlow FromNanogramsPerDay(QuantityValue nanogramsperday) /// If value is NaN or Infinity. public static MassFlow FromNanogramsPerSecond(QuantityValue nanogramspersecond) { - QuantityValue value = (QuantityValue) nanogramspersecond; + double value = (double) nanogramspersecond; return new MassFlow(value, MassFlowUnit.NanogramPerSecond); } @@ -768,7 +765,7 @@ public static MassFlow FromNanogramsPerSecond(QuantityValue nanogramspersecond) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerDay(QuantityValue poundsperday) { - QuantityValue value = (QuantityValue) poundsperday; + double value = (double) poundsperday; return new MassFlow(value, MassFlowUnit.PoundPerDay); } @@ -778,7 +775,7 @@ public static MassFlow FromPoundsPerDay(QuantityValue poundsperday) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerHour(QuantityValue poundsperhour) { - QuantityValue value = (QuantityValue) poundsperhour; + double value = (double) poundsperhour; return new MassFlow(value, MassFlowUnit.PoundPerHour); } @@ -788,7 +785,7 @@ public static MassFlow FromPoundsPerHour(QuantityValue poundsperhour) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerMinute(QuantityValue poundsperminute) { - QuantityValue value = (QuantityValue) poundsperminute; + double value = (double) poundsperminute; return new MassFlow(value, MassFlowUnit.PoundPerMinute); } @@ -798,7 +795,7 @@ public static MassFlow FromPoundsPerMinute(QuantityValue poundsperminute) /// If value is NaN or Infinity. public static MassFlow FromPoundsPerSecond(QuantityValue poundspersecond) { - QuantityValue value = (QuantityValue) poundspersecond; + double value = (double) poundspersecond; return new MassFlow(value, MassFlowUnit.PoundPerSecond); } @@ -808,7 +805,7 @@ public static MassFlow FromPoundsPerSecond(QuantityValue poundspersecond) /// If value is NaN or Infinity. public static MassFlow FromShortTonsPerHour(QuantityValue shorttonsperhour) { - QuantityValue value = (QuantityValue) shorttonsperhour; + double value = (double) shorttonsperhour; return new MassFlow(value, MassFlowUnit.ShortTonPerHour); } @@ -818,7 +815,7 @@ public static MassFlow FromShortTonsPerHour(QuantityValue shorttonsperhour) /// If value is NaN or Infinity. public static MassFlow FromTonnesPerDay(QuantityValue tonnesperday) { - QuantityValue value = (QuantityValue) tonnesperday; + double value = (double) tonnesperday; return new MassFlow(value, MassFlowUnit.TonnePerDay); } @@ -828,7 +825,7 @@ public static MassFlow FromTonnesPerDay(QuantityValue tonnesperday) /// If value is NaN or Infinity. public static MassFlow FromTonnesPerHour(QuantityValue tonnesperhour) { - QuantityValue value = (QuantityValue) tonnesperhour; + double value = (double) tonnesperhour; return new MassFlow(value, MassFlowUnit.TonnePerHour); } @@ -840,7 +837,7 @@ public static MassFlow FromTonnesPerHour(QuantityValue tonnesperhour) /// MassFlow unit value. public static MassFlow From(QuantityValue value, MassFlowUnit fromUnit) { - return new MassFlow((QuantityValue)value, fromUnit); + return new MassFlow((double)value, fromUnit); } #endregion @@ -1010,25 +1007,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFlow operator *(QuantityValue left, MassFlow right) + public static MassFlow operator *(double left, MassFlow right) { return new MassFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFlow operator *(MassFlow left, QuantityValue right) + public static MassFlow operator *(MassFlow left, double right) { return new MassFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFlow operator /(MassFlow left, QuantityValue right) + public static MassFlow operator /(MassFlow left, double right) { return new MassFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MassFlow left, MassFlow right) + public static double operator /(MassFlow left, MassFlow right) { return left.GramsPerSecond / right.GramsPerSecond; } @@ -1061,19 +1058,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlow left, MassFlow right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlow left, MassFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1086,29 +1070,7 @@ public int CompareTo(object obj) /// public int CompareTo(MassFlow other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MassFlow objMassFlow)) - return false; - return Equals(objMassFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlow other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1151,13 +1113,13 @@ public bool Equals(MassFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlow other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1168,7 +1130,7 @@ public bool Equals(MassFlow other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current MassFlow. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1179,16 +1141,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MassFlowUnit unit) + public double As(MassFlowUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1203,12 +1166,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MassFlowUnit typedUnit)) + if (!(unit is MassFlowUnit unitAsMassFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMassFlowUnit); } /// @@ -1240,7 +1203,7 @@ public MassFlow ToUnit(MassFlowUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MassFlow)converted; } - else if (Enum.IsDefined(typeof(MassFlowUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1248,17 +1211,17 @@ public MassFlow ToUnit(MassFlowUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFlowUnit typedUnit)) + if (!(unit is MassFlowUnit unitAsMassFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMassFlowUnit, DefaultConversionFunctions); } /// @@ -1285,10 +1248,10 @@ public MassFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MassFlowUnit unit) + private double GetValueAs(MassFlowUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index b4836741f1..48a6bb8a9a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Mass flux is the mass flow rate per unit area. /// [DataContract] - public partial struct MassFlux : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFlux : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static MassFlux() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFlux(QuantityValue value, MassFluxUnit unit) + public MassFlux(double value, MassFluxUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -97,14 +97,14 @@ public MassFlux(QuantityValue value, MassFluxUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFlux(QuantityValue value, UnitSystem unitSystem) + public MassFlux(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,10 +145,7 @@ public MassFlux(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -171,64 +168,64 @@ public MassFlux(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); + public double GramsPerHourPerSquareCentimeter => As(MassFluxUnit.GramPerHourPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); + public double GramsPerHourPerSquareMeter => As(MassFluxUnit.GramPerHourPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); + public double GramsPerHourPerSquareMillimeter => As(MassFluxUnit.GramPerHourPerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); + public double GramsPerSecondPerSquareCentimeter => As(MassFluxUnit.GramPerSecondPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); + public double GramsPerSecondPerSquareMeter => As(MassFluxUnit.GramPerSecondPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); + public double GramsPerSecondPerSquareMillimeter => As(MassFluxUnit.GramPerSecondPerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); + public double KilogramsPerHourPerSquareCentimeter => As(MassFluxUnit.KilogramPerHourPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); + public double KilogramsPerHourPerSquareMeter => As(MassFluxUnit.KilogramPerHourPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); + public double KilogramsPerHourPerSquareMillimeter => As(MassFluxUnit.KilogramPerHourPerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); + public double KilogramsPerSecondPerSquareCentimeter => As(MassFluxUnit.KilogramPerSecondPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); + public double KilogramsPerSecondPerSquareMeter => As(MassFluxUnit.KilogramPerSecondPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); + public double KilogramsPerSecondPerSquareMillimeter => As(MassFluxUnit.KilogramPerSecondPerSquareMillimeter); #endregion @@ -317,7 +314,7 @@ public static string GetAbbreviation(MassFluxUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static MassFlux FromGramsPerHourPerSquareCentimeter(QuantityValue gramsperhourpersquarecentimeter) { - QuantityValue value = (QuantityValue) gramsperhourpersquarecentimeter; + double value = (double) gramsperhourpersquarecentimeter; return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareCentimeter); } @@ -327,7 +324,7 @@ public static MassFlux FromGramsPerHourPerSquareCentimeter(QuantityValue gramspe /// If value is NaN or Infinity. public static MassFlux FromGramsPerHourPerSquareMeter(QuantityValue gramsperhourpersquaremeter) { - QuantityValue value = (QuantityValue) gramsperhourpersquaremeter; + double value = (double) gramsperhourpersquaremeter; return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMeter); } @@ -337,7 +334,7 @@ public static MassFlux FromGramsPerHourPerSquareMeter(QuantityValue gramsperhour /// If value is NaN or Infinity. public static MassFlux FromGramsPerHourPerSquareMillimeter(QuantityValue gramsperhourpersquaremillimeter) { - QuantityValue value = (QuantityValue) gramsperhourpersquaremillimeter; + double value = (double) gramsperhourpersquaremillimeter; return new MassFlux(value, MassFluxUnit.GramPerHourPerSquareMillimeter); } @@ -347,7 +344,7 @@ public static MassFlux FromGramsPerHourPerSquareMillimeter(QuantityValue gramspe /// If value is NaN or Infinity. public static MassFlux FromGramsPerSecondPerSquareCentimeter(QuantityValue gramspersecondpersquarecentimeter) { - QuantityValue value = (QuantityValue) gramspersecondpersquarecentimeter; + double value = (double) gramspersecondpersquarecentimeter; return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareCentimeter); } @@ -357,7 +354,7 @@ public static MassFlux FromGramsPerSecondPerSquareCentimeter(QuantityValue grams /// If value is NaN or Infinity. public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue gramspersecondpersquaremeter) { - QuantityValue value = (QuantityValue) gramspersecondpersquaremeter; + double value = (double) gramspersecondpersquaremeter; return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMeter); } @@ -367,7 +364,7 @@ public static MassFlux FromGramsPerSecondPerSquareMeter(QuantityValue gramsperse /// If value is NaN or Infinity. public static MassFlux FromGramsPerSecondPerSquareMillimeter(QuantityValue gramspersecondpersquaremillimeter) { - QuantityValue value = (QuantityValue) gramspersecondpersquaremillimeter; + double value = (double) gramspersecondpersquaremillimeter; return new MassFlux(value, MassFluxUnit.GramPerSecondPerSquareMillimeter); } @@ -377,7 +374,7 @@ public static MassFlux FromGramsPerSecondPerSquareMillimeter(QuantityValue grams /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerHourPerSquareCentimeter(QuantityValue kilogramsperhourpersquarecentimeter) { - QuantityValue value = (QuantityValue) kilogramsperhourpersquarecentimeter; + double value = (double) kilogramsperhourpersquarecentimeter; return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareCentimeter); } @@ -387,7 +384,7 @@ public static MassFlux FromKilogramsPerHourPerSquareCentimeter(QuantityValue kil /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerHourPerSquareMeter(QuantityValue kilogramsperhourpersquaremeter) { - QuantityValue value = (QuantityValue) kilogramsperhourpersquaremeter; + double value = (double) kilogramsperhourpersquaremeter; return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMeter); } @@ -397,7 +394,7 @@ public static MassFlux FromKilogramsPerHourPerSquareMeter(QuantityValue kilogram /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerHourPerSquareMillimeter(QuantityValue kilogramsperhourpersquaremillimeter) { - QuantityValue value = (QuantityValue) kilogramsperhourpersquaremillimeter; + double value = (double) kilogramsperhourpersquaremillimeter; return new MassFlux(value, MassFluxUnit.KilogramPerHourPerSquareMillimeter); } @@ -407,7 +404,7 @@ public static MassFlux FromKilogramsPerHourPerSquareMillimeter(QuantityValue kil /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(QuantityValue kilogramspersecondpersquarecentimeter) { - QuantityValue value = (QuantityValue) kilogramspersecondpersquarecentimeter; + double value = (double) kilogramspersecondpersquarecentimeter; return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareCentimeter); } @@ -417,7 +414,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareCentimeter(QuantityValue k /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue kilogramspersecondpersquaremeter) { - QuantityValue value = (QuantityValue) kilogramspersecondpersquaremeter; + double value = (double) kilogramspersecondpersquaremeter; return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMeter); } @@ -427,7 +424,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareMeter(QuantityValue kilogr /// If value is NaN or Infinity. public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(QuantityValue kilogramspersecondpersquaremillimeter) { - QuantityValue value = (QuantityValue) kilogramspersecondpersquaremillimeter; + double value = (double) kilogramspersecondpersquaremillimeter; return new MassFlux(value, MassFluxUnit.KilogramPerSecondPerSquareMillimeter); } @@ -439,7 +436,7 @@ public static MassFlux FromKilogramsPerSecondPerSquareMillimeter(QuantityValue k /// MassFlux unit value. public static MassFlux From(QuantityValue value, MassFluxUnit fromUnit) { - return new MassFlux((QuantityValue)value, fromUnit); + return new MassFlux((double)value, fromUnit); } #endregion @@ -609,25 +606,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFlux operator *(QuantityValue left, MassFlux right) + public static MassFlux operator *(double left, MassFlux right) { return new MassFlux(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFlux operator *(MassFlux left, QuantityValue right) + public static MassFlux operator *(MassFlux left, double right) { return new MassFlux(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFlux operator /(MassFlux left, QuantityValue right) + public static MassFlux operator /(MassFlux left, double right) { return new MassFlux(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MassFlux left, MassFlux right) + public static double operator /(MassFlux left, MassFlux right) { return left.KilogramsPerSecondPerSquareMeter / right.KilogramsPerSecondPerSquareMeter; } @@ -660,19 +657,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFlux left, MassFlux right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFlux left, MassFlux right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -685,29 +669,7 @@ public int CompareTo(object obj) /// public int CompareTo(MassFlux other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MassFlux objMassFlux)) - return false; - return Equals(objMassFlux); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFlux other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -750,13 +712,13 @@ public bool Equals(MassFlux other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFlux other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -767,7 +729,7 @@ public bool Equals(MassFlux other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current MassFlux. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -778,16 +740,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MassFluxUnit unit) + public double As(MassFluxUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -802,12 +765,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MassFluxUnit typedUnit)) + if (!(unit is MassFluxUnit unitAsMassFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMassFluxUnit); } /// @@ -839,7 +802,7 @@ public MassFlux ToUnit(MassFluxUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MassFlux)converted; } - else if (Enum.IsDefined(typeof(MassFluxUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -847,17 +810,17 @@ public MassFlux ToUnit(MassFluxUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFluxUnit typedUnit)) + if (!(unit is MassFluxUnit unitAsMassFluxUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMassFluxUnit, DefaultConversionFunctions); } /// @@ -884,10 +847,10 @@ public MassFlux ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MassFluxUnit unit) + private double GetValueAs(MassFluxUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 56da91983a..2f4b8fe473 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Mass_fraction_(chemistry) /// [DataContract] - public partial struct MassFraction : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassFraction : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -98,9 +98,9 @@ static MassFraction() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassFraction(QuantityValue value, MassFractionUnit unit) + public MassFraction(double value, MassFractionUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -112,14 +112,14 @@ public MassFraction(QuantityValue value, MassFractionUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassFraction(QuantityValue value, UnitSystem unitSystem) + public MassFraction(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -160,10 +160,7 @@ public MassFraction(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -186,124 +183,124 @@ public MassFraction(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); + public double CentigramsPerGram => As(MassFractionUnit.CentigramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); + public double CentigramsPerKilogram => As(MassFractionUnit.CentigramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); + public double DecagramsPerGram => As(MassFractionUnit.DecagramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); + public double DecagramsPerKilogram => As(MassFractionUnit.DecagramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); + public double DecigramsPerGram => As(MassFractionUnit.DecigramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); + public double DecigramsPerKilogram => As(MassFractionUnit.DecigramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimalFractions => As(MassFractionUnit.DecimalFraction); + public double DecimalFractions => As(MassFractionUnit.DecimalFraction); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerGram => As(MassFractionUnit.GramPerGram); + public double GramsPerGram => As(MassFractionUnit.GramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); + public double GramsPerKilogram => As(MassFractionUnit.GramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); + public double HectogramsPerGram => As(MassFractionUnit.HectogramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); + public double HectogramsPerKilogram => As(MassFractionUnit.HectogramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); + public double KilogramsPerGram => As(MassFractionUnit.KilogramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); + public double KilogramsPerKilogram => As(MassFractionUnit.KilogramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); + public double MicrogramsPerGram => As(MassFractionUnit.MicrogramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); + public double MicrogramsPerKilogram => As(MassFractionUnit.MicrogramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); + public double MilligramsPerGram => As(MassFractionUnit.MilligramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); + public double MilligramsPerKilogram => As(MassFractionUnit.MilligramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); + public double NanogramsPerGram => As(MassFractionUnit.NanogramPerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); + public double NanogramsPerKilogram => As(MassFractionUnit.NanogramPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerBillion => As(MassFractionUnit.PartPerBillion); + public double PartsPerBillion => As(MassFractionUnit.PartPerBillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerMillion => As(MassFractionUnit.PartPerMillion); + public double PartsPerMillion => As(MassFractionUnit.PartPerMillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerThousand => As(MassFractionUnit.PartPerThousand); + public double PartsPerThousand => As(MassFractionUnit.PartPerThousand); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); + public double PartsPerTrillion => As(MassFractionUnit.PartPerTrillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Percent => As(MassFractionUnit.Percent); + public double Percent => As(MassFractionUnit.Percent); #endregion @@ -428,7 +425,7 @@ public static string GetAbbreviation(MassFractionUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static MassFraction FromCentigramsPerGram(QuantityValue centigramspergram) { - QuantityValue value = (QuantityValue) centigramspergram; + double value = (double) centigramspergram; return new MassFraction(value, MassFractionUnit.CentigramPerGram); } @@ -438,7 +435,7 @@ public static MassFraction FromCentigramsPerGram(QuantityValue centigramspergram /// If value is NaN or Infinity. public static MassFraction FromCentigramsPerKilogram(QuantityValue centigramsperkilogram) { - QuantityValue value = (QuantityValue) centigramsperkilogram; + double value = (double) centigramsperkilogram; return new MassFraction(value, MassFractionUnit.CentigramPerKilogram); } @@ -448,7 +445,7 @@ public static MassFraction FromCentigramsPerKilogram(QuantityValue centigramsper /// If value is NaN or Infinity. public static MassFraction FromDecagramsPerGram(QuantityValue decagramspergram) { - QuantityValue value = (QuantityValue) decagramspergram; + double value = (double) decagramspergram; return new MassFraction(value, MassFractionUnit.DecagramPerGram); } @@ -458,7 +455,7 @@ public static MassFraction FromDecagramsPerGram(QuantityValue decagramspergram) /// If value is NaN or Infinity. public static MassFraction FromDecagramsPerKilogram(QuantityValue decagramsperkilogram) { - QuantityValue value = (QuantityValue) decagramsperkilogram; + double value = (double) decagramsperkilogram; return new MassFraction(value, MassFractionUnit.DecagramPerKilogram); } @@ -468,7 +465,7 @@ public static MassFraction FromDecagramsPerKilogram(QuantityValue decagramsperki /// If value is NaN or Infinity. public static MassFraction FromDecigramsPerGram(QuantityValue decigramspergram) { - QuantityValue value = (QuantityValue) decigramspergram; + double value = (double) decigramspergram; return new MassFraction(value, MassFractionUnit.DecigramPerGram); } @@ -478,7 +475,7 @@ public static MassFraction FromDecigramsPerGram(QuantityValue decigramspergram) /// If value is NaN or Infinity. public static MassFraction FromDecigramsPerKilogram(QuantityValue decigramsperkilogram) { - QuantityValue value = (QuantityValue) decigramsperkilogram; + double value = (double) decigramsperkilogram; return new MassFraction(value, MassFractionUnit.DecigramPerKilogram); } @@ -488,7 +485,7 @@ public static MassFraction FromDecigramsPerKilogram(QuantityValue decigramsperki /// If value is NaN or Infinity. public static MassFraction FromDecimalFractions(QuantityValue decimalfractions) { - QuantityValue value = (QuantityValue) decimalfractions; + double value = (double) decimalfractions; return new MassFraction(value, MassFractionUnit.DecimalFraction); } @@ -498,7 +495,7 @@ public static MassFraction FromDecimalFractions(QuantityValue decimalfractions) /// If value is NaN or Infinity. public static MassFraction FromGramsPerGram(QuantityValue gramspergram) { - QuantityValue value = (QuantityValue) gramspergram; + double value = (double) gramspergram; return new MassFraction(value, MassFractionUnit.GramPerGram); } @@ -508,7 +505,7 @@ public static MassFraction FromGramsPerGram(QuantityValue gramspergram) /// If value is NaN or Infinity. public static MassFraction FromGramsPerKilogram(QuantityValue gramsperkilogram) { - QuantityValue value = (QuantityValue) gramsperkilogram; + double value = (double) gramsperkilogram; return new MassFraction(value, MassFractionUnit.GramPerKilogram); } @@ -518,7 +515,7 @@ public static MassFraction FromGramsPerKilogram(QuantityValue gramsperkilogram) /// If value is NaN or Infinity. public static MassFraction FromHectogramsPerGram(QuantityValue hectogramspergram) { - QuantityValue value = (QuantityValue) hectogramspergram; + double value = (double) hectogramspergram; return new MassFraction(value, MassFractionUnit.HectogramPerGram); } @@ -528,7 +525,7 @@ public static MassFraction FromHectogramsPerGram(QuantityValue hectogramspergram /// If value is NaN or Infinity. public static MassFraction FromHectogramsPerKilogram(QuantityValue hectogramsperkilogram) { - QuantityValue value = (QuantityValue) hectogramsperkilogram; + double value = (double) hectogramsperkilogram; return new MassFraction(value, MassFractionUnit.HectogramPerKilogram); } @@ -538,7 +535,7 @@ public static MassFraction FromHectogramsPerKilogram(QuantityValue hectogramsper /// If value is NaN or Infinity. public static MassFraction FromKilogramsPerGram(QuantityValue kilogramspergram) { - QuantityValue value = (QuantityValue) kilogramspergram; + double value = (double) kilogramspergram; return new MassFraction(value, MassFractionUnit.KilogramPerGram); } @@ -548,7 +545,7 @@ public static MassFraction FromKilogramsPerGram(QuantityValue kilogramspergram) /// If value is NaN or Infinity. public static MassFraction FromKilogramsPerKilogram(QuantityValue kilogramsperkilogram) { - QuantityValue value = (QuantityValue) kilogramsperkilogram; + double value = (double) kilogramsperkilogram; return new MassFraction(value, MassFractionUnit.KilogramPerKilogram); } @@ -558,7 +555,7 @@ public static MassFraction FromKilogramsPerKilogram(QuantityValue kilogramsperki /// If value is NaN or Infinity. public static MassFraction FromMicrogramsPerGram(QuantityValue microgramspergram) { - QuantityValue value = (QuantityValue) microgramspergram; + double value = (double) microgramspergram; return new MassFraction(value, MassFractionUnit.MicrogramPerGram); } @@ -568,7 +565,7 @@ public static MassFraction FromMicrogramsPerGram(QuantityValue microgramspergram /// If value is NaN or Infinity. public static MassFraction FromMicrogramsPerKilogram(QuantityValue microgramsperkilogram) { - QuantityValue value = (QuantityValue) microgramsperkilogram; + double value = (double) microgramsperkilogram; return new MassFraction(value, MassFractionUnit.MicrogramPerKilogram); } @@ -578,7 +575,7 @@ public static MassFraction FromMicrogramsPerKilogram(QuantityValue microgramsper /// If value is NaN or Infinity. public static MassFraction FromMilligramsPerGram(QuantityValue milligramspergram) { - QuantityValue value = (QuantityValue) milligramspergram; + double value = (double) milligramspergram; return new MassFraction(value, MassFractionUnit.MilligramPerGram); } @@ -588,7 +585,7 @@ public static MassFraction FromMilligramsPerGram(QuantityValue milligramspergram /// If value is NaN or Infinity. public static MassFraction FromMilligramsPerKilogram(QuantityValue milligramsperkilogram) { - QuantityValue value = (QuantityValue) milligramsperkilogram; + double value = (double) milligramsperkilogram; return new MassFraction(value, MassFractionUnit.MilligramPerKilogram); } @@ -598,7 +595,7 @@ public static MassFraction FromMilligramsPerKilogram(QuantityValue milligramsper /// If value is NaN or Infinity. public static MassFraction FromNanogramsPerGram(QuantityValue nanogramspergram) { - QuantityValue value = (QuantityValue) nanogramspergram; + double value = (double) nanogramspergram; return new MassFraction(value, MassFractionUnit.NanogramPerGram); } @@ -608,7 +605,7 @@ public static MassFraction FromNanogramsPerGram(QuantityValue nanogramspergram) /// If value is NaN or Infinity. public static MassFraction FromNanogramsPerKilogram(QuantityValue nanogramsperkilogram) { - QuantityValue value = (QuantityValue) nanogramsperkilogram; + double value = (double) nanogramsperkilogram; return new MassFraction(value, MassFractionUnit.NanogramPerKilogram); } @@ -618,7 +615,7 @@ public static MassFraction FromNanogramsPerKilogram(QuantityValue nanogramsperki /// If value is NaN or Infinity. public static MassFraction FromPartsPerBillion(QuantityValue partsperbillion) { - QuantityValue value = (QuantityValue) partsperbillion; + double value = (double) partsperbillion; return new MassFraction(value, MassFractionUnit.PartPerBillion); } @@ -628,7 +625,7 @@ public static MassFraction FromPartsPerBillion(QuantityValue partsperbillion) /// If value is NaN or Infinity. public static MassFraction FromPartsPerMillion(QuantityValue partspermillion) { - QuantityValue value = (QuantityValue) partspermillion; + double value = (double) partspermillion; return new MassFraction(value, MassFractionUnit.PartPerMillion); } @@ -638,7 +635,7 @@ public static MassFraction FromPartsPerMillion(QuantityValue partspermillion) /// If value is NaN or Infinity. public static MassFraction FromPartsPerThousand(QuantityValue partsperthousand) { - QuantityValue value = (QuantityValue) partsperthousand; + double value = (double) partsperthousand; return new MassFraction(value, MassFractionUnit.PartPerThousand); } @@ -648,7 +645,7 @@ public static MassFraction FromPartsPerThousand(QuantityValue partsperthousand) /// If value is NaN or Infinity. public static MassFraction FromPartsPerTrillion(QuantityValue partspertrillion) { - QuantityValue value = (QuantityValue) partspertrillion; + double value = (double) partspertrillion; return new MassFraction(value, MassFractionUnit.PartPerTrillion); } @@ -658,7 +655,7 @@ public static MassFraction FromPartsPerTrillion(QuantityValue partspertrillion) /// If value is NaN or Infinity. public static MassFraction FromPercent(QuantityValue percent) { - QuantityValue value = (QuantityValue) percent; + double value = (double) percent; return new MassFraction(value, MassFractionUnit.Percent); } @@ -670,7 +667,7 @@ public static MassFraction FromPercent(QuantityValue percent) /// MassFraction unit value. public static MassFraction From(QuantityValue value, MassFractionUnit fromUnit) { - return new MassFraction((QuantityValue)value, fromUnit); + return new MassFraction((double)value, fromUnit); } #endregion @@ -840,25 +837,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF } /// Get from multiplying value and . - public static MassFraction operator *(QuantityValue left, MassFraction right) + public static MassFraction operator *(double left, MassFraction right) { return new MassFraction(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassFraction operator *(MassFraction left, QuantityValue right) + public static MassFraction operator *(MassFraction left, double right) { return new MassFraction(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassFraction operator /(MassFraction left, QuantityValue right) + public static MassFraction operator /(MassFraction left, double right) { return new MassFraction(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MassFraction left, MassFraction right) + public static double operator /(MassFraction left, MassFraction right) { return left.DecimalFractions / right.DecimalFractions; } @@ -891,19 +888,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassF return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassFraction left, MassFraction right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassFraction left, MassFraction right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -916,29 +900,7 @@ public int CompareTo(object obj) /// public int CompareTo(MassFraction other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MassFraction objMassFraction)) - return false; - return Equals(objMassFraction); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassFraction other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -981,13 +943,13 @@ public bool Equals(MassFraction other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassFraction other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MassFraction other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -998,7 +960,7 @@ public bool Equals(MassFraction other, QuantityValue tolerance, ComparisonType c /// A hash code for the current MassFraction. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1009,16 +971,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MassFractionUnit unit) + public double As(MassFractionUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1033,12 +996,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MassFractionUnit typedUnit)) + if (!(unit is MassFractionUnit unitAsMassFractionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMassFractionUnit); } /// @@ -1070,7 +1033,7 @@ public MassFraction ToUnit(MassFractionUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MassFraction)converted; } - else if (Enum.IsDefined(typeof(MassFractionUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1078,17 +1041,17 @@ public MassFraction ToUnit(MassFractionUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFractionUnit typedUnit)) + if (!(unit is MassFractionUnit unitAsMassFractionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMassFractionUnit, DefaultConversionFunctions); } /// @@ -1115,10 +1078,10 @@ public MassFraction ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MassFractionUnit unit) + private double GetValueAs(MassFractionUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 5af13e39b5..50edc3fea1 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A property of body reflects how its mass is distributed with regard to an axis. /// [DataContract] - public partial struct MassMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MassMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -99,9 +99,9 @@ static MassMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MassMomentOfInertia(QuantityValue value, MassMomentOfInertiaUnit unit) + public MassMomentOfInertia(double value, MassMomentOfInertiaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -113,14 +113,14 @@ public MassMomentOfInertia(QuantityValue value, MassMomentOfInertiaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MassMomentOfInertia(QuantityValue value, UnitSystem unitSystem) + public MassMomentOfInertia(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -161,10 +161,7 @@ public MassMomentOfInertia(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -187,144 +184,144 @@ public MassMomentOfInertia(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); + public double GramSquareCentimeters => As(MassMomentOfInertiaUnit.GramSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); + public double GramSquareDecimeters => As(MassMomentOfInertiaUnit.GramSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); + public double GramSquareMeters => As(MassMomentOfInertiaUnit.GramSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); + public double GramSquareMillimeters => As(MassMomentOfInertiaUnit.GramSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); + public double KilogramSquareCentimeters => As(MassMomentOfInertiaUnit.KilogramSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); + public double KilogramSquareDecimeters => As(MassMomentOfInertiaUnit.KilogramSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); + public double KilogramSquareMeters => As(MassMomentOfInertiaUnit.KilogramSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); + public double KilogramSquareMillimeters => As(MassMomentOfInertiaUnit.KilogramSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); + public double KilotonneSquareCentimeters => As(MassMomentOfInertiaUnit.KilotonneSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); + public double KilotonneSquareDecimeters => As(MassMomentOfInertiaUnit.KilotonneSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); + public double KilotonneSquareMeters => As(MassMomentOfInertiaUnit.KilotonneSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); + public double KilotonneSquareMilimeters => As(MassMomentOfInertiaUnit.KilotonneSquareMilimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); + public double MegatonneSquareCentimeters => As(MassMomentOfInertiaUnit.MegatonneSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); + public double MegatonneSquareDecimeters => As(MassMomentOfInertiaUnit.MegatonneSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); + public double MegatonneSquareMeters => As(MassMomentOfInertiaUnit.MegatonneSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); + public double MegatonneSquareMilimeters => As(MassMomentOfInertiaUnit.MegatonneSquareMilimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); + public double MilligramSquareCentimeters => As(MassMomentOfInertiaUnit.MilligramSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); + public double MilligramSquareDecimeters => As(MassMomentOfInertiaUnit.MilligramSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); + public double MilligramSquareMeters => As(MassMomentOfInertiaUnit.MilligramSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); + public double MilligramSquareMillimeters => As(MassMomentOfInertiaUnit.MilligramSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); + public double PoundSquareFeet => As(MassMomentOfInertiaUnit.PoundSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); + public double PoundSquareInches => As(MassMomentOfInertiaUnit.PoundSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); + public double SlugSquareFeet => As(MassMomentOfInertiaUnit.SlugSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); + public double SlugSquareInches => As(MassMomentOfInertiaUnit.SlugSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); + public double TonneSquareCentimeters => As(MassMomentOfInertiaUnit.TonneSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); + public double TonneSquareDecimeters => As(MassMomentOfInertiaUnit.TonneSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); + public double TonneSquareMeters => As(MassMomentOfInertiaUnit.TonneSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); + public double TonneSquareMilimeters => As(MassMomentOfInertiaUnit.TonneSquareMilimeter); #endregion @@ -461,7 +458,7 @@ public static string GetAbbreviation(MassMomentOfInertiaUnit unit, IFormatProvid /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue gramsquarecentimeters) { - QuantityValue value = (QuantityValue) gramsquarecentimeters; + double value = (double) gramsquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareCentimeter); } @@ -471,7 +468,7 @@ public static MassMomentOfInertia FromGramSquareCentimeters(QuantityValue gramsq /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue gramsquaredecimeters) { - QuantityValue value = (QuantityValue) gramsquaredecimeters; + double value = (double) gramsquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareDecimeter); } @@ -481,7 +478,7 @@ public static MassMomentOfInertia FromGramSquareDecimeters(QuantityValue gramsqu /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareMeters(QuantityValue gramsquaremeters) { - QuantityValue value = (QuantityValue) gramsquaremeters; + double value = (double) gramsquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMeter); } @@ -491,7 +488,7 @@ public static MassMomentOfInertia FromGramSquareMeters(QuantityValue gramsquarem /// If value is NaN or Infinity. public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue gramsquaremillimeters) { - QuantityValue value = (QuantityValue) gramsquaremillimeters; + double value = (double) gramsquaremillimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.GramSquareMillimeter); } @@ -501,7 +498,7 @@ public static MassMomentOfInertia FromGramSquareMillimeters(QuantityValue gramsq /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue kilogramsquarecentimeters) { - QuantityValue value = (QuantityValue) kilogramsquarecentimeters; + double value = (double) kilogramsquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareCentimeter); } @@ -511,7 +508,7 @@ public static MassMomentOfInertia FromKilogramSquareCentimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue kilogramsquaredecimeters) { - QuantityValue value = (QuantityValue) kilogramsquaredecimeters; + double value = (double) kilogramsquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareDecimeter); } @@ -521,7 +518,7 @@ public static MassMomentOfInertia FromKilogramSquareDecimeters(QuantityValue kil /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue kilogramsquaremeters) { - QuantityValue value = (QuantityValue) kilogramsquaremeters; + double value = (double) kilogramsquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMeter); } @@ -531,7 +528,7 @@ public static MassMomentOfInertia FromKilogramSquareMeters(QuantityValue kilogra /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue kilogramsquaremillimeters) { - QuantityValue value = (QuantityValue) kilogramsquaremillimeters; + double value = (double) kilogramsquaremillimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilogramSquareMillimeter); } @@ -541,7 +538,7 @@ public static MassMomentOfInertia FromKilogramSquareMillimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue kilotonnesquarecentimeters) { - QuantityValue value = (QuantityValue) kilotonnesquarecentimeters; + double value = (double) kilotonnesquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareCentimeter); } @@ -551,7 +548,7 @@ public static MassMomentOfInertia FromKilotonneSquareCentimeters(QuantityValue k /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue kilotonnesquaredecimeters) { - QuantityValue value = (QuantityValue) kilotonnesquaredecimeters; + double value = (double) kilotonnesquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareDecimeter); } @@ -561,7 +558,7 @@ public static MassMomentOfInertia FromKilotonneSquareDecimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue kilotonnesquaremeters) { - QuantityValue value = (QuantityValue) kilotonnesquaremeters; + double value = (double) kilotonnesquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMeter); } @@ -571,7 +568,7 @@ public static MassMomentOfInertia FromKilotonneSquareMeters(QuantityValue kiloto /// If value is NaN or Infinity. public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue kilotonnesquaremilimeters) { - QuantityValue value = (QuantityValue) kilotonnesquaremilimeters; + double value = (double) kilotonnesquaremilimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.KilotonneSquareMilimeter); } @@ -581,7 +578,7 @@ public static MassMomentOfInertia FromKilotonneSquareMilimeters(QuantityValue ki /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue megatonnesquarecentimeters) { - QuantityValue value = (QuantityValue) megatonnesquarecentimeters; + double value = (double) megatonnesquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareCentimeter); } @@ -591,7 +588,7 @@ public static MassMomentOfInertia FromMegatonneSquareCentimeters(QuantityValue m /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue megatonnesquaredecimeters) { - QuantityValue value = (QuantityValue) megatonnesquaredecimeters; + double value = (double) megatonnesquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareDecimeter); } @@ -601,7 +598,7 @@ public static MassMomentOfInertia FromMegatonneSquareDecimeters(QuantityValue me /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue megatonnesquaremeters) { - QuantityValue value = (QuantityValue) megatonnesquaremeters; + double value = (double) megatonnesquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMeter); } @@ -611,7 +608,7 @@ public static MassMomentOfInertia FromMegatonneSquareMeters(QuantityValue megato /// If value is NaN or Infinity. public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue megatonnesquaremilimeters) { - QuantityValue value = (QuantityValue) megatonnesquaremilimeters; + double value = (double) megatonnesquaremilimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MegatonneSquareMilimeter); } @@ -621,7 +618,7 @@ public static MassMomentOfInertia FromMegatonneSquareMilimeters(QuantityValue me /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue milligramsquarecentimeters) { - QuantityValue value = (QuantityValue) milligramsquarecentimeters; + double value = (double) milligramsquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareCentimeter); } @@ -631,7 +628,7 @@ public static MassMomentOfInertia FromMilligramSquareCentimeters(QuantityValue m /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue milligramsquaredecimeters) { - QuantityValue value = (QuantityValue) milligramsquaredecimeters; + double value = (double) milligramsquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareDecimeter); } @@ -641,7 +638,7 @@ public static MassMomentOfInertia FromMilligramSquareDecimeters(QuantityValue mi /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue milligramsquaremeters) { - QuantityValue value = (QuantityValue) milligramsquaremeters; + double value = (double) milligramsquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMeter); } @@ -651,7 +648,7 @@ public static MassMomentOfInertia FromMilligramSquareMeters(QuantityValue millig /// If value is NaN or Infinity. public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue milligramsquaremillimeters) { - QuantityValue value = (QuantityValue) milligramsquaremillimeters; + double value = (double) milligramsquaremillimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.MilligramSquareMillimeter); } @@ -661,7 +658,7 @@ public static MassMomentOfInertia FromMilligramSquareMillimeters(QuantityValue m /// If value is NaN or Infinity. public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue poundsquarefeet) { - QuantityValue value = (QuantityValue) poundsquarefeet; + double value = (double) poundsquarefeet; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareFoot); } @@ -671,7 +668,7 @@ public static MassMomentOfInertia FromPoundSquareFeet(QuantityValue poundsquaref /// If value is NaN or Infinity. public static MassMomentOfInertia FromPoundSquareInches(QuantityValue poundsquareinches) { - QuantityValue value = (QuantityValue) poundsquareinches; + double value = (double) poundsquareinches; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.PoundSquareInch); } @@ -681,7 +678,7 @@ public static MassMomentOfInertia FromPoundSquareInches(QuantityValue poundsquar /// If value is NaN or Infinity. public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue slugsquarefeet) { - QuantityValue value = (QuantityValue) slugsquarefeet; + double value = (double) slugsquarefeet; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareFoot); } @@ -691,7 +688,7 @@ public static MassMomentOfInertia FromSlugSquareFeet(QuantityValue slugsquarefee /// If value is NaN or Infinity. public static MassMomentOfInertia FromSlugSquareInches(QuantityValue slugsquareinches) { - QuantityValue value = (QuantityValue) slugsquareinches; + double value = (double) slugsquareinches; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.SlugSquareInch); } @@ -701,7 +698,7 @@ public static MassMomentOfInertia FromSlugSquareInches(QuantityValue slugsquarei /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue tonnesquarecentimeters) { - QuantityValue value = (QuantityValue) tonnesquarecentimeters; + double value = (double) tonnesquarecentimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareCentimeter); } @@ -711,7 +708,7 @@ public static MassMomentOfInertia FromTonneSquareCentimeters(QuantityValue tonne /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue tonnesquaredecimeters) { - QuantityValue value = (QuantityValue) tonnesquaredecimeters; + double value = (double) tonnesquaredecimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareDecimeter); } @@ -721,7 +718,7 @@ public static MassMomentOfInertia FromTonneSquareDecimeters(QuantityValue tonnes /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue tonnesquaremeters) { - QuantityValue value = (QuantityValue) tonnesquaremeters; + double value = (double) tonnesquaremeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMeter); } @@ -731,7 +728,7 @@ public static MassMomentOfInertia FromTonneSquareMeters(QuantityValue tonnesquar /// If value is NaN or Infinity. public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue tonnesquaremilimeters) { - QuantityValue value = (QuantityValue) tonnesquaremilimeters; + double value = (double) tonnesquaremilimeters; return new MassMomentOfInertia(value, MassMomentOfInertiaUnit.TonneSquareMilimeter); } @@ -743,7 +740,7 @@ public static MassMomentOfInertia FromTonneSquareMilimeters(QuantityValue tonnes /// MassMomentOfInertia unit value. public static MassMomentOfInertia From(QuantityValue value, MassMomentOfInertiaUnit fromUnit) { - return new MassMomentOfInertia((QuantityValue)value, fromUnit); + return new MassMomentOfInertia((double)value, fromUnit); } #endregion @@ -913,25 +910,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM } /// Get from multiplying value and . - public static MassMomentOfInertia operator *(QuantityValue left, MassMomentOfInertia right) + public static MassMomentOfInertia operator *(double left, MassMomentOfInertia right) { return new MassMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MassMomentOfInertia operator *(MassMomentOfInertia left, QuantityValue right) + public static MassMomentOfInertia operator *(MassMomentOfInertia left, double right) { return new MassMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MassMomentOfInertia operator /(MassMomentOfInertia left, QuantityValue right) + public static MassMomentOfInertia operator /(MassMomentOfInertia left, double right) { return new MassMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MassMomentOfInertia left, MassMomentOfInertia right) + public static double operator /(MassMomentOfInertia left, MassMomentOfInertia right) { return left.KilogramSquareMeters / right.KilogramSquareMeters; } @@ -964,19 +961,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out MassM return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MassMomentOfInertia left, MassMomentOfInertia right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MassMomentOfInertia left, MassMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -989,29 +973,7 @@ public int CompareTo(object obj) /// public int CompareTo(MassMomentOfInertia other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MassMomentOfInertia objMassMomentOfInertia)) - return false; - return Equals(objMassMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MassMomentOfInertia other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1054,13 +1016,13 @@ public bool Equals(MassMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MassMomentOfInertia other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1071,7 +1033,7 @@ public bool Equals(MassMomentOfInertia other, QuantityValue tolerance, Compariso /// A hash code for the current MassMomentOfInertia. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1082,16 +1044,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MassMomentOfInertiaUnit unit) + public double As(MassMomentOfInertiaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1106,12 +1069,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit typedUnit)) + if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMassMomentOfInertiaUnit); } /// @@ -1143,7 +1106,7 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit, UnitConverter un var converted = conversionFunction(this); return (MassMomentOfInertia)converted; } - else if (Enum.IsDefined(typeof(MassMomentOfInertiaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1151,17 +1114,17 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit typedUnit)) + if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMassMomentOfInertiaUnit, DefaultConversionFunctions); } /// @@ -1188,10 +1151,10 @@ public MassMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MassMomentOfInertiaUnit unit) + private double GetValueAs(MassMomentOfInertiaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 4979bd2a8d..3b11d29f12 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Molar energy is the amount of energy stored in 1 mole of a substance. /// [DataContract] - public partial struct MolarEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static MolarEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarEnergy(QuantityValue value, MolarEnergyUnit unit) + public MolarEnergy(double value, MolarEnergyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public MolarEnergy(QuantityValue value, MolarEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEnergy(QuantityValue value, UnitSystem unitSystem) + public MolarEnergy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public MolarEnergy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public MolarEnergy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); + public double JoulesPerMole => As(MolarEnergyUnit.JoulePerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); + public double KilojoulesPerMole => As(MolarEnergyUnit.KilojoulePerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); + public double MegajoulesPerMole => As(MolarEnergyUnit.MegajoulePerMole); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(MolarEnergyUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static MolarEnergy FromJoulesPerMole(QuantityValue joulespermole) { - QuantityValue value = (QuantityValue) joulespermole; + double value = (double) joulespermole; return new MolarEnergy(value, MolarEnergyUnit.JoulePerMole); } @@ -246,7 +243,7 @@ public static MolarEnergy FromJoulesPerMole(QuantityValue joulespermole) /// If value is NaN or Infinity. public static MolarEnergy FromKilojoulesPerMole(QuantityValue kilojoulespermole) { - QuantityValue value = (QuantityValue) kilojoulespermole; + double value = (double) kilojoulespermole; return new MolarEnergy(value, MolarEnergyUnit.KilojoulePerMole); } @@ -256,7 +253,7 @@ public static MolarEnergy FromKilojoulesPerMole(QuantityValue kilojoulespermole) /// If value is NaN or Infinity. public static MolarEnergy FromMegajoulesPerMole(QuantityValue megajoulespermole) { - QuantityValue value = (QuantityValue) megajoulespermole; + double value = (double) megajoulespermole; return new MolarEnergy(value, MolarEnergyUnit.MegajoulePerMole); } @@ -268,7 +265,7 @@ public static MolarEnergy FromMegajoulesPerMole(QuantityValue megajoulespermole) /// MolarEnergy unit value. public static MolarEnergy From(QuantityValue value, MolarEnergyUnit fromUnit) { - return new MolarEnergy((QuantityValue)value, fromUnit); + return new MolarEnergy((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarEnergy operator *(QuantityValue left, MolarEnergy right) + public static MolarEnergy operator *(double left, MolarEnergy right) { return new MolarEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarEnergy operator *(MolarEnergy left, QuantityValue right) + public static MolarEnergy operator *(MolarEnergy left, double right) { return new MolarEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarEnergy operator /(MolarEnergy left, QuantityValue right) + public static MolarEnergy operator /(MolarEnergy left, double right) { return new MolarEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MolarEnergy left, MolarEnergy right) + public static double operator /(MolarEnergy left, MolarEnergy right) { return left.JoulesPerMole / right.JoulesPerMole; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEnergy left, MolarEnergy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEnergy left, MolarEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(MolarEnergy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MolarEnergy objMolarEnergy)) - return false; - return Equals(objMolarEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEnergy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(MolarEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEnergy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MolarEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(MolarEnergy other, QuantityValue tolerance, ComparisonType co /// A hash code for the current MolarEnergy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MolarEnergyUnit unit) + public double As(MolarEnergyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MolarEnergyUnit typedUnit)) + if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMolarEnergyUnit); } /// @@ -668,7 +631,7 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MolarEnergy)converted; } - else if (Enum.IsDefined(typeof(MolarEnergyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEnergyUnit typedUnit)) + if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMolarEnergyUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public MolarEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MolarEnergyUnit unit) + private double GetValueAs(MolarEnergyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index c11e95ba80..857fcdaf4a 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Molar entropy is amount of energy required to increase temperature of 1 mole substance by 1 Kelvin. /// [DataContract] - public partial struct MolarEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static MolarEntropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarEntropy(QuantityValue value, MolarEntropyUnit unit) + public MolarEntropy(double value, MolarEntropyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public MolarEntropy(QuantityValue value, MolarEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarEntropy(QuantityValue value, UnitSystem unitSystem) + public MolarEntropy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public MolarEntropy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public MolarEntropy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); + public double JoulesPerMoleKelvin => As(MolarEntropyUnit.JoulePerMoleKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); + public double KilojoulesPerMoleKelvin => As(MolarEntropyUnit.KilojoulePerMoleKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); + public double MegajoulesPerMoleKelvin => As(MolarEntropyUnit.MegajoulePerMoleKelvin); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(MolarEntropyUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue joulespermolekelvin) { - QuantityValue value = (QuantityValue) joulespermolekelvin; + double value = (double) joulespermolekelvin; return new MolarEntropy(value, MolarEntropyUnit.JoulePerMoleKelvin); } @@ -246,7 +243,7 @@ public static MolarEntropy FromJoulesPerMoleKelvin(QuantityValue joulespermoleke /// If value is NaN or Infinity. public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue kilojoulespermolekelvin) { - QuantityValue value = (QuantityValue) kilojoulespermolekelvin; + double value = (double) kilojoulespermolekelvin; return new MolarEntropy(value, MolarEntropyUnit.KilojoulePerMoleKelvin); } @@ -256,7 +253,7 @@ public static MolarEntropy FromKilojoulesPerMoleKelvin(QuantityValue kilojoulesp /// If value is NaN or Infinity. public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue megajoulespermolekelvin) { - QuantityValue value = (QuantityValue) megajoulespermolekelvin; + double value = (double) megajoulespermolekelvin; return new MolarEntropy(value, MolarEntropyUnit.MegajoulePerMoleKelvin); } @@ -268,7 +265,7 @@ public static MolarEntropy FromMegajoulesPerMoleKelvin(QuantityValue megajoulesp /// MolarEntropy unit value. public static MolarEntropy From(QuantityValue value, MolarEntropyUnit fromUnit) { - return new MolarEntropy((QuantityValue)value, fromUnit); + return new MolarEntropy((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarEntropy operator *(QuantityValue left, MolarEntropy right) + public static MolarEntropy operator *(double left, MolarEntropy right) { return new MolarEntropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarEntropy operator *(MolarEntropy left, QuantityValue right) + public static MolarEntropy operator *(MolarEntropy left, double right) { return new MolarEntropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarEntropy operator /(MolarEntropy left, QuantityValue right) + public static MolarEntropy operator /(MolarEntropy left, double right) { return new MolarEntropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MolarEntropy left, MolarEntropy right) + public static double operator /(MolarEntropy left, MolarEntropy right) { return left.JoulesPerMoleKelvin / right.JoulesPerMoleKelvin; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarEntropy left, MolarEntropy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarEntropy left, MolarEntropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(MolarEntropy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MolarEntropy objMolarEntropy)) - return false; - return Equals(objMolarEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarEntropy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(MolarEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarEntropy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(MolarEntropy other, QuantityValue tolerance, ComparisonType c /// A hash code for the current MolarEntropy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MolarEntropyUnit unit) + public double As(MolarEntropyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MolarEntropyUnit typedUnit)) + if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMolarEntropyUnit); } /// @@ -668,7 +631,7 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MolarEntropy)converted; } - else if (Enum.IsDefined(typeof(MolarEntropyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEntropyUnit typedUnit)) + if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMolarEntropyUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public MolarEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MolarEntropyUnit unit) + private double GetValueAs(MolarEntropyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 94f91b9b40..1bc540caa7 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In chemistry, the molar mass M is a physical property defined as the mass of a given substance (chemical element or chemical compound) divided by the amount of substance. /// [DataContract] - public partial struct MolarMass : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct MolarMass : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static MolarMass() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public MolarMass(QuantityValue value, MolarMassUnit unit) + public MolarMass(double value, MolarMassUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -97,14 +97,14 @@ public MolarMass(QuantityValue value, MolarMassUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public MolarMass(QuantityValue value, UnitSystem unitSystem) + public MolarMass(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,10 +145,7 @@ public MolarMass(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -171,64 +168,64 @@ public MolarMass(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); + public double CentigramsPerMole => As(MolarMassUnit.CentigramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); + public double DecagramsPerMole => As(MolarMassUnit.DecagramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); + public double DecigramsPerMole => As(MolarMassUnit.DecigramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerMole => As(MolarMassUnit.GramPerMole); + public double GramsPerMole => As(MolarMassUnit.GramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); + public double HectogramsPerMole => As(MolarMassUnit.HectogramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); + public double KilogramsPerMole => As(MolarMassUnit.KilogramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); + public double KilopoundsPerMole => As(MolarMassUnit.KilopoundPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); + public double MegapoundsPerMole => As(MolarMassUnit.MegapoundPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); + public double MicrogramsPerMole => As(MolarMassUnit.MicrogramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); + public double MilligramsPerMole => As(MolarMassUnit.MilligramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); + public double NanogramsPerMole => As(MolarMassUnit.NanogramPerMole); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerMole => As(MolarMassUnit.PoundPerMole); + public double PoundsPerMole => As(MolarMassUnit.PoundPerMole); #endregion @@ -329,7 +326,7 @@ public static string GetAbbreviation(MolarMassUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static MolarMass FromCentigramsPerMole(QuantityValue centigramspermole) { - QuantityValue value = (QuantityValue) centigramspermole; + double value = (double) centigramspermole; return new MolarMass(value, MolarMassUnit.CentigramPerMole); } @@ -339,7 +336,7 @@ public static MolarMass FromCentigramsPerMole(QuantityValue centigramspermole) /// If value is NaN or Infinity. public static MolarMass FromDecagramsPerMole(QuantityValue decagramspermole) { - QuantityValue value = (QuantityValue) decagramspermole; + double value = (double) decagramspermole; return new MolarMass(value, MolarMassUnit.DecagramPerMole); } @@ -349,7 +346,7 @@ public static MolarMass FromDecagramsPerMole(QuantityValue decagramspermole) /// If value is NaN or Infinity. public static MolarMass FromDecigramsPerMole(QuantityValue decigramspermole) { - QuantityValue value = (QuantityValue) decigramspermole; + double value = (double) decigramspermole; return new MolarMass(value, MolarMassUnit.DecigramPerMole); } @@ -359,7 +356,7 @@ public static MolarMass FromDecigramsPerMole(QuantityValue decigramspermole) /// If value is NaN or Infinity. public static MolarMass FromGramsPerMole(QuantityValue gramspermole) { - QuantityValue value = (QuantityValue) gramspermole; + double value = (double) gramspermole; return new MolarMass(value, MolarMassUnit.GramPerMole); } @@ -369,7 +366,7 @@ public static MolarMass FromGramsPerMole(QuantityValue gramspermole) /// If value is NaN or Infinity. public static MolarMass FromHectogramsPerMole(QuantityValue hectogramspermole) { - QuantityValue value = (QuantityValue) hectogramspermole; + double value = (double) hectogramspermole; return new MolarMass(value, MolarMassUnit.HectogramPerMole); } @@ -379,7 +376,7 @@ public static MolarMass FromHectogramsPerMole(QuantityValue hectogramspermole) /// If value is NaN or Infinity. public static MolarMass FromKilogramsPerMole(QuantityValue kilogramspermole) { - QuantityValue value = (QuantityValue) kilogramspermole; + double value = (double) kilogramspermole; return new MolarMass(value, MolarMassUnit.KilogramPerMole); } @@ -389,7 +386,7 @@ public static MolarMass FromKilogramsPerMole(QuantityValue kilogramspermole) /// If value is NaN or Infinity. public static MolarMass FromKilopoundsPerMole(QuantityValue kilopoundspermole) { - QuantityValue value = (QuantityValue) kilopoundspermole; + double value = (double) kilopoundspermole; return new MolarMass(value, MolarMassUnit.KilopoundPerMole); } @@ -399,7 +396,7 @@ public static MolarMass FromKilopoundsPerMole(QuantityValue kilopoundspermole) /// If value is NaN or Infinity. public static MolarMass FromMegapoundsPerMole(QuantityValue megapoundspermole) { - QuantityValue value = (QuantityValue) megapoundspermole; + double value = (double) megapoundspermole; return new MolarMass(value, MolarMassUnit.MegapoundPerMole); } @@ -409,7 +406,7 @@ public static MolarMass FromMegapoundsPerMole(QuantityValue megapoundspermole) /// If value is NaN or Infinity. public static MolarMass FromMicrogramsPerMole(QuantityValue microgramspermole) { - QuantityValue value = (QuantityValue) microgramspermole; + double value = (double) microgramspermole; return new MolarMass(value, MolarMassUnit.MicrogramPerMole); } @@ -419,7 +416,7 @@ public static MolarMass FromMicrogramsPerMole(QuantityValue microgramspermole) /// If value is NaN or Infinity. public static MolarMass FromMilligramsPerMole(QuantityValue milligramspermole) { - QuantityValue value = (QuantityValue) milligramspermole; + double value = (double) milligramspermole; return new MolarMass(value, MolarMassUnit.MilligramPerMole); } @@ -429,7 +426,7 @@ public static MolarMass FromMilligramsPerMole(QuantityValue milligramspermole) /// If value is NaN or Infinity. public static MolarMass FromNanogramsPerMole(QuantityValue nanogramspermole) { - QuantityValue value = (QuantityValue) nanogramspermole; + double value = (double) nanogramspermole; return new MolarMass(value, MolarMassUnit.NanogramPerMole); } @@ -439,7 +436,7 @@ public static MolarMass FromNanogramsPerMole(QuantityValue nanogramspermole) /// If value is NaN or Infinity. public static MolarMass FromPoundsPerMole(QuantityValue poundspermole) { - QuantityValue value = (QuantityValue) poundspermole; + double value = (double) poundspermole; return new MolarMass(value, MolarMassUnit.PoundPerMole); } @@ -451,7 +448,7 @@ public static MolarMass FromPoundsPerMole(QuantityValue poundspermole) /// MolarMass unit value. public static MolarMass From(QuantityValue value, MolarMassUnit fromUnit) { - return new MolarMass((QuantityValue)value, fromUnit); + return new MolarMass((double)value, fromUnit); } #endregion @@ -621,25 +618,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static MolarMass operator *(QuantityValue left, MolarMass right) + public static MolarMass operator *(double left, MolarMass right) { return new MolarMass(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static MolarMass operator *(MolarMass left, QuantityValue right) + public static MolarMass operator *(MolarMass left, double right) { return new MolarMass(left.Value * right, left.Unit); } /// Get from dividing by value. - public static MolarMass operator /(MolarMass left, QuantityValue right) + public static MolarMass operator /(MolarMass left, double right) { return new MolarMass(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(MolarMass left, MolarMass right) + public static double operator /(MolarMass left, MolarMass right) { return left.KilogramsPerMole / right.KilogramsPerMole; } @@ -672,19 +669,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(MolarMass left, MolarMass right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(MolarMass left, MolarMass right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -697,29 +681,7 @@ public int CompareTo(object obj) /// public int CompareTo(MolarMass other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is MolarMass objMolarMass)) - return false; - return Equals(objMolarMass); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(MolarMass other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -762,13 +724,13 @@ public bool Equals(MolarMass other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(MolarMass other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -779,7 +741,7 @@ public bool Equals(MolarMass other, QuantityValue tolerance, ComparisonType comp /// A hash code for the current MolarMass. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -790,16 +752,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MolarMassUnit unit) + public double As(MolarMassUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -814,12 +777,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MolarMassUnit typedUnit)) + if (!(unit is MolarMassUnit unitAsMolarMassUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMolarMassUnit); } /// @@ -851,7 +814,7 @@ public MolarMass ToUnit(MolarMassUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (MolarMass)converted; } - else if (Enum.IsDefined(typeof(MolarMassUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -859,17 +822,17 @@ public MolarMass ToUnit(MolarMassUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarMassUnit typedUnit)) + if (!(unit is MolarMassUnit unitAsMolarMassUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMolarMassUnit, DefaultConversionFunctions); } /// @@ -896,10 +859,10 @@ public MolarMass ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MolarMassUnit unit) + private double GetValueAs(MolarMassUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index e654cdedfc..0403f2c28f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Molar_concentration /// [DataContract] - public partial struct Molarity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Molarity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -91,9 +91,9 @@ static Molarity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Molarity(QuantityValue value, MolarityUnit unit) + public Molarity(double value, MolarityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -105,14 +105,14 @@ public Molarity(QuantityValue value, MolarityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Molarity(QuantityValue value, UnitSystem unitSystem) + public Molarity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -153,10 +153,7 @@ public Molarity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -179,49 +176,49 @@ public Molarity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimolesPerLiter => As(MolarityUnit.CentimolePerLiter); + public double CentimolesPerLiter => As(MolarityUnit.CentimolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimolesPerLiter => As(MolarityUnit.DecimolePerLiter); + public double DecimolesPerLiter => As(MolarityUnit.DecimolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FemtomolesPerLiter => As(MolarityUnit.FemtomolePerLiter); + public double FemtomolesPerLiter => As(MolarityUnit.FemtomolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicromolesPerLiter => As(MolarityUnit.MicromolePerLiter); + public double MicromolesPerLiter => As(MolarityUnit.MicromolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimolesPerLiter => As(MolarityUnit.MillimolePerLiter); + public double MillimolesPerLiter => As(MolarityUnit.MillimolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MolesPerCubicMeter => As(MolarityUnit.MolePerCubicMeter); + public double MolesPerCubicMeter => As(MolarityUnit.MolePerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MolesPerLiter => As(MolarityUnit.MolePerLiter); + public double MolesPerLiter => As(MolarityUnit.MolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanomolesPerLiter => As(MolarityUnit.NanomolePerLiter); + public double NanomolesPerLiter => As(MolarityUnit.NanomolePerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicomolesPerLiter => As(MolarityUnit.PicomolePerLiter); + public double PicomolesPerLiter => As(MolarityUnit.PicomolePerLiter); #endregion @@ -325,7 +322,7 @@ public static string GetAbbreviation(MolarityUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static Molarity FromCentimolesPerLiter(QuantityValue centimolesperliter) { - QuantityValue value = (QuantityValue) centimolesperliter; + double value = (double) centimolesperliter; return new Molarity(value, MolarityUnit.CentimolePerLiter); } @@ -335,7 +332,7 @@ public static Molarity FromCentimolesPerLiter(QuantityValue centimolesperliter) /// If value is NaN or Infinity. public static Molarity FromDecimolesPerLiter(QuantityValue decimolesperliter) { - QuantityValue value = (QuantityValue) decimolesperliter; + double value = (double) decimolesperliter; return new Molarity(value, MolarityUnit.DecimolePerLiter); } @@ -345,7 +342,7 @@ public static Molarity FromDecimolesPerLiter(QuantityValue decimolesperliter) /// If value is NaN or Infinity. public static Molarity FromFemtomolesPerLiter(QuantityValue femtomolesperliter) { - QuantityValue value = (QuantityValue) femtomolesperliter; + double value = (double) femtomolesperliter; return new Molarity(value, MolarityUnit.FemtomolePerLiter); } @@ -355,7 +352,7 @@ public static Molarity FromFemtomolesPerLiter(QuantityValue femtomolesperliter) /// If value is NaN or Infinity. public static Molarity FromMicromolesPerLiter(QuantityValue micromolesperliter) { - QuantityValue value = (QuantityValue) micromolesperliter; + double value = (double) micromolesperliter; return new Molarity(value, MolarityUnit.MicromolePerLiter); } @@ -365,7 +362,7 @@ public static Molarity FromMicromolesPerLiter(QuantityValue micromolesperliter) /// If value is NaN or Infinity. public static Molarity FromMillimolesPerLiter(QuantityValue millimolesperliter) { - QuantityValue value = (QuantityValue) millimolesperliter; + double value = (double) millimolesperliter; return new Molarity(value, MolarityUnit.MillimolePerLiter); } @@ -375,7 +372,7 @@ public static Molarity FromMillimolesPerLiter(QuantityValue millimolesperliter) /// If value is NaN or Infinity. public static Molarity FromMolesPerCubicMeter(QuantityValue molespercubicmeter) { - QuantityValue value = (QuantityValue) molespercubicmeter; + double value = (double) molespercubicmeter; return new Molarity(value, MolarityUnit.MolePerCubicMeter); } @@ -385,7 +382,7 @@ public static Molarity FromMolesPerCubicMeter(QuantityValue molespercubicmeter) /// If value is NaN or Infinity. public static Molarity FromMolesPerLiter(QuantityValue molesperliter) { - QuantityValue value = (QuantityValue) molesperliter; + double value = (double) molesperliter; return new Molarity(value, MolarityUnit.MolePerLiter); } @@ -395,7 +392,7 @@ public static Molarity FromMolesPerLiter(QuantityValue molesperliter) /// If value is NaN or Infinity. public static Molarity FromNanomolesPerLiter(QuantityValue nanomolesperliter) { - QuantityValue value = (QuantityValue) nanomolesperliter; + double value = (double) nanomolesperliter; return new Molarity(value, MolarityUnit.NanomolePerLiter); } @@ -405,7 +402,7 @@ public static Molarity FromNanomolesPerLiter(QuantityValue nanomolesperliter) /// If value is NaN or Infinity. public static Molarity FromPicomolesPerLiter(QuantityValue picomolesperliter) { - QuantityValue value = (QuantityValue) picomolesperliter; + double value = (double) picomolesperliter; return new Molarity(value, MolarityUnit.PicomolePerLiter); } @@ -417,7 +414,7 @@ public static Molarity FromPicomolesPerLiter(QuantityValue picomolesperliter) /// Molarity unit value. public static Molarity From(QuantityValue value, MolarityUnit fromUnit) { - return new Molarity((QuantityValue)value, fromUnit); + return new Molarity((double)value, fromUnit); } #endregion @@ -587,25 +584,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar } /// Get from multiplying value and . - public static Molarity operator *(QuantityValue left, Molarity right) + public static Molarity operator *(double left, Molarity right) { return new Molarity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Molarity operator *(Molarity left, QuantityValue right) + public static Molarity operator *(Molarity left, double right) { return new Molarity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Molarity operator /(Molarity left, QuantityValue right) + public static Molarity operator /(Molarity left, double right) { return new Molarity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Molarity left, Molarity right) + public static double operator /(Molarity left, Molarity right) { return left.MolesPerCubicMeter / right.MolesPerCubicMeter; } @@ -638,19 +635,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Molar return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Molarity left, Molarity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Molarity left, Molarity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -663,29 +647,7 @@ public int CompareTo(object obj) /// public int CompareTo(Molarity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Molarity objMolarity)) - return false; - return Equals(objMolarity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Molarity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -728,13 +690,13 @@ public bool Equals(Molarity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Molarity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Molarity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -745,7 +707,7 @@ public bool Equals(Molarity other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current Molarity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -756,16 +718,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(MolarityUnit unit) + public double As(MolarityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -780,12 +743,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is MolarityUnit typedUnit)) + if (!(unit is MolarityUnit unitAsMolarityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsMolarityUnit); } /// @@ -817,7 +780,7 @@ public Molarity ToUnit(MolarityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Molarity)converted; } - else if (Enum.IsDefined(typeof(MolarityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -825,17 +788,17 @@ public Molarity ToUnit(MolarityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarityUnit typedUnit)) + if (!(unit is MolarityUnit unitAsMolarityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsMolarityUnit, DefaultConversionFunctions); } /// @@ -862,10 +825,10 @@ public Molarity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(MolarityUnit unit) + private double GetValueAs(MolarityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 859e80a650..8f4f597901 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permeability_(electromagnetism) /// [DataContract] - public partial struct Permeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permeability : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Permeability() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Permeability(QuantityValue value, PermeabilityUnit unit) + public Permeability(double value, PermeabilityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public Permeability(QuantityValue value, PermeabilityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permeability(QuantityValue value, UnitSystem unitSystem) + public Permeability(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public Permeability(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public Permeability(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); + public double HenriesPerMeter => As(PermeabilityUnit.HenryPerMeter); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(PermeabilityUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static Permeability FromHenriesPerMeter(QuantityValue henriespermeter) { - QuantityValue value = (QuantityValue) henriespermeter; + double value = (double) henriespermeter; return new Permeability(value, PermeabilityUnit.HenryPerMeter); } @@ -233,7 +230,7 @@ public static Permeability FromHenriesPerMeter(QuantityValue henriespermeter) /// Permeability unit value. public static Permeability From(QuantityValue value, PermeabilityUnit fromUnit) { - return new Permeability((QuantityValue)value, fromUnit); + return new Permeability((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme } /// Get from multiplying value and . - public static Permeability operator *(QuantityValue left, Permeability right) + public static Permeability operator *(double left, Permeability right) { return new Permeability(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Permeability operator *(Permeability left, QuantityValue right) + public static Permeability operator *(Permeability left, double right) { return new Permeability(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Permeability operator /(Permeability left, QuantityValue right) + public static Permeability operator /(Permeability left, double right) { return new Permeability(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Permeability left, Permeability right) + public static double operator /(Permeability left, Permeability right) { return left.HenriesPerMeter / right.HenriesPerMeter; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Perme return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permeability left, Permeability right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permeability left, Permeability right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(Permeability other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Permeability objPermeability)) - return false; - return Equals(objPermeability); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permeability other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(Permeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permeability other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Permeability other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(Permeability other, QuantityValue tolerance, ComparisonType c /// A hash code for the current Permeability. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PermeabilityUnit unit) + public double As(PermeabilityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PermeabilityUnit typedUnit)) + if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPermeabilityUnit); } /// @@ -633,7 +596,7 @@ public Permeability ToUnit(PermeabilityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Permeability)converted; } - else if (Enum.IsDefined(typeof(PermeabilityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public Permeability ToUnit(PermeabilityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermeabilityUnit typedUnit)) + if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPermeabilityUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public Permeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PermeabilityUnit unit) + private double GetValueAs(PermeabilityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index 666aeab093..a375f49800 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permittivity /// [DataContract] - public partial struct Permittivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Permittivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Permittivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Permittivity(QuantityValue value, PermittivityUnit unit) + public Permittivity(double value, PermittivityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public Permittivity(QuantityValue value, PermittivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Permittivity(QuantityValue value, UnitSystem unitSystem) + public Permittivity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public Permittivity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public Permittivity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); + public double FaradsPerMeter => As(PermittivityUnit.FaradPerMeter); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(PermittivityUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static Permittivity FromFaradsPerMeter(QuantityValue faradspermeter) { - QuantityValue value = (QuantityValue) faradspermeter; + double value = (double) faradspermeter; return new Permittivity(value, PermittivityUnit.FaradPerMeter); } @@ -233,7 +230,7 @@ public static Permittivity FromFaradsPerMeter(QuantityValue faradspermeter) /// Permittivity unit value. public static Permittivity From(QuantityValue value, PermittivityUnit fromUnit) { - return new Permittivity((QuantityValue)value, fromUnit); + return new Permittivity((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi } /// Get from multiplying value and . - public static Permittivity operator *(QuantityValue left, Permittivity right) + public static Permittivity operator *(double left, Permittivity right) { return new Permittivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Permittivity operator *(Permittivity left, QuantityValue right) + public static Permittivity operator *(Permittivity left, double right) { return new Permittivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Permittivity operator /(Permittivity left, QuantityValue right) + public static Permittivity operator /(Permittivity left, double right) { return new Permittivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Permittivity left, Permittivity right) + public static double operator /(Permittivity left, Permittivity right) { return left.FaradsPerMeter / right.FaradsPerMeter; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Permi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Permittivity left, Permittivity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Permittivity left, Permittivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(Permittivity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Permittivity objPermittivity)) - return false; - return Equals(objPermittivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Permittivity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(Permittivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Permittivity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Permittivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(Permittivity other, QuantityValue tolerance, ComparisonType c /// A hash code for the current Permittivity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PermittivityUnit unit) + public double As(PermittivityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PermittivityUnit typedUnit)) + if (!(unit is PermittivityUnit unitAsPermittivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPermittivityUnit); } /// @@ -633,7 +596,7 @@ public Permittivity ToUnit(PermittivityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Permittivity)converted; } - else if (Enum.IsDefined(typeof(PermittivityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public Permittivity ToUnit(PermittivityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermittivityUnit typedUnit)) + if (!(unit is PermittivityUnit unitAsPermittivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPermittivityUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public Permittivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PermittivityUnit unit) + private double GetValueAs(PermittivityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 0ed6169e45..3bf7765d64 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Permeability_(Earth_sciences) /// [DataContract] - public partial struct PorousMediumPermeability : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PorousMediumPermeability : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -79,9 +79,9 @@ static PorousMediumPermeability() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PorousMediumPermeability(QuantityValue value, PorousMediumPermeabilityUnit unit) + public PorousMediumPermeability(double value, PorousMediumPermeabilityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -93,14 +93,14 @@ public PorousMediumPermeability(QuantityValue value, PorousMediumPermeabilityUni /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PorousMediumPermeability(QuantityValue value, UnitSystem unitSystem) + public PorousMediumPermeability(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -141,10 +141,7 @@ public PorousMediumPermeability(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -167,29 +164,29 @@ public PorousMediumPermeability(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Darcys => As(PorousMediumPermeabilityUnit.Darcy); + public double Darcys => As(PorousMediumPermeabilityUnit.Darcy); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microdarcys => As(PorousMediumPermeabilityUnit.Microdarcy); + public double Microdarcys => As(PorousMediumPermeabilityUnit.Microdarcy); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millidarcys => As(PorousMediumPermeabilityUnit.Millidarcy); + public double Millidarcys => As(PorousMediumPermeabilityUnit.Millidarcy); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareCentimeters => As(PorousMediumPermeabilityUnit.SquareCentimeter); + public double SquareCentimeters => As(PorousMediumPermeabilityUnit.SquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMeters => As(PorousMediumPermeabilityUnit.SquareMeter); + public double SquareMeters => As(PorousMediumPermeabilityUnit.SquareMeter); #endregion @@ -257,7 +254,7 @@ public static string GetAbbreviation(PorousMediumPermeabilityUnit unit, IFormatP /// If value is NaN or Infinity. public static PorousMediumPermeability FromDarcys(QuantityValue darcys) { - QuantityValue value = (QuantityValue) darcys; + double value = (double) darcys; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Darcy); } @@ -267,7 +264,7 @@ public static PorousMediumPermeability FromDarcys(QuantityValue darcys) /// If value is NaN or Infinity. public static PorousMediumPermeability FromMicrodarcys(QuantityValue microdarcys) { - QuantityValue value = (QuantityValue) microdarcys; + double value = (double) microdarcys; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Microdarcy); } @@ -277,7 +274,7 @@ public static PorousMediumPermeability FromMicrodarcys(QuantityValue microdarcys /// If value is NaN or Infinity. public static PorousMediumPermeability FromMillidarcys(QuantityValue millidarcys) { - QuantityValue value = (QuantityValue) millidarcys; + double value = (double) millidarcys; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.Millidarcy); } @@ -287,7 +284,7 @@ public static PorousMediumPermeability FromMillidarcys(QuantityValue millidarcys /// If value is NaN or Infinity. public static PorousMediumPermeability FromSquareCentimeters(QuantityValue squarecentimeters) { - QuantityValue value = (QuantityValue) squarecentimeters; + double value = (double) squarecentimeters; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.SquareCentimeter); } @@ -297,7 +294,7 @@ public static PorousMediumPermeability FromSquareCentimeters(QuantityValue squar /// If value is NaN or Infinity. public static PorousMediumPermeability FromSquareMeters(QuantityValue squaremeters) { - QuantityValue value = (QuantityValue) squaremeters; + double value = (double) squaremeters; return new PorousMediumPermeability(value, PorousMediumPermeabilityUnit.SquareMeter); } @@ -309,7 +306,7 @@ public static PorousMediumPermeability FromSquareMeters(QuantityValue squaremete /// PorousMediumPermeability unit value. public static PorousMediumPermeability From(QuantityValue value, PorousMediumPermeabilityUnit fromUnit) { - return new PorousMediumPermeability((QuantityValue)value, fromUnit); + return new PorousMediumPermeability((double)value, fromUnit); } #endregion @@ -479,25 +476,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou } /// Get from multiplying value and . - public static PorousMediumPermeability operator *(QuantityValue left, PorousMediumPermeability right) + public static PorousMediumPermeability operator *(double left, PorousMediumPermeability right) { return new PorousMediumPermeability(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PorousMediumPermeability operator *(PorousMediumPermeability left, QuantityValue right) + public static PorousMediumPermeability operator *(PorousMediumPermeability left, double right) { return new PorousMediumPermeability(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PorousMediumPermeability operator /(PorousMediumPermeability left, QuantityValue right) + public static PorousMediumPermeability operator /(PorousMediumPermeability left, double right) { return new PorousMediumPermeability(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(PorousMediumPermeability left, PorousMediumPermeability right) + public static double operator /(PorousMediumPermeability left, PorousMediumPermeability right) { return left.SquareMeters / right.SquareMeters; } @@ -530,19 +527,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Porou return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PorousMediumPermeability left, PorousMediumPermeability right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PorousMediumPermeability left, PorousMediumPermeability right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -555,29 +539,7 @@ public int CompareTo(object obj) /// public int CompareTo(PorousMediumPermeability other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is PorousMediumPermeability objPorousMediumPermeability)) - return false; - return Equals(objPorousMediumPermeability); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PorousMediumPermeability other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -620,13 +582,13 @@ public bool Equals(PorousMediumPermeability other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PorousMediumPermeability other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -637,7 +599,7 @@ public bool Equals(PorousMediumPermeability other, QuantityValue tolerance, Comp /// A hash code for the current PorousMediumPermeability. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -648,16 +610,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PorousMediumPermeabilityUnit unit) + public double As(PorousMediumPermeabilityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -672,12 +635,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit typedUnit)) + if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPorousMediumPermeabilityUnit); } /// @@ -709,7 +672,7 @@ public PorousMediumPermeability ToUnit(PorousMediumPermeabilityUnit unit, UnitCo var converted = conversionFunction(this); return (PorousMediumPermeability)converted; } - else if (Enum.IsDefined(typeof(PorousMediumPermeabilityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -717,17 +680,17 @@ public PorousMediumPermeability ToUnit(PorousMediumPermeabilityUnit unit, UnitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit typedUnit)) + if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPorousMediumPermeabilityUnit, DefaultConversionFunctions); } /// @@ -754,10 +717,10 @@ public PorousMediumPermeability ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PorousMediumPermeabilityUnit unit) + private double GetValueAs(PorousMediumPermeabilityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index fd569d371d..843092f2dc 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics, power is the rate of doing work. It is equivalent to an amount of energy consumed per unit time. /// [DataContract] - public partial struct Power : IQuantity, IDecimalQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Power : IQuantity, IDecimalQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly decimal _value; /// /// The unit this quantity was constructed with. @@ -97,7 +97,7 @@ static Power() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Power(QuantityValue value, PowerUnit unit) + public Power(decimal value, PowerUnit unit) { _value = value; _unit = unit; @@ -111,7 +111,7 @@ public Power(QuantityValue value, PowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Power(QuantityValue value, UnitSystem unitSystem) + public Power(decimal value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -159,13 +159,12 @@ public Power(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; + public decimal Value => _value; - /// - QuantityValue IQuantity.Value => _value; + double IQuantity.Value => (double) _value; /// - decimal IDecimalQuantity.Value => (decimal)_value; + decimal IDecimalQuantity.Value => _value; Enum IQuantity.Unit => Unit; @@ -188,134 +187,134 @@ public Power(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BoilerHorsepower => As(PowerUnit.BoilerHorsepower); + public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); + public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decawatts => As(PowerUnit.Decawatt); + public double Decawatts => As(PowerUnit.Decawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Deciwatts => As(PowerUnit.Deciwatt); + public double Deciwatts => As(PowerUnit.Deciwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); + public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Femtowatts => As(PowerUnit.Femtowatt); + public double Femtowatts => As(PowerUnit.Femtowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); + public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigawatts => As(PowerUnit.Gigawatt); + public double Gigawatts => As(PowerUnit.Gigawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); + public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerHour => As(PowerUnit.JoulePerHour); + public double JoulesPerHour => As(PowerUnit.JoulePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); + public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); + public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilowatts => As(PowerUnit.Kilowatt); + public double Kilowatts => As(PowerUnit.Kilowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); + public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); + public double MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); + public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megawatts => As(PowerUnit.Megawatt); + public double Megawatts => As(PowerUnit.Megawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetricHorsepower => As(PowerUnit.MetricHorsepower); + public double MetricHorsepower => As(PowerUnit.MetricHorsepower); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microwatts => As(PowerUnit.Microwatt); + public double Microwatts => As(PowerUnit.Microwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); + public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliwatts => As(PowerUnit.Milliwatt); + public double Milliwatts => As(PowerUnit.Milliwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Nanowatts => As(PowerUnit.Nanowatt); + public double Nanowatts => As(PowerUnit.Nanowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Petawatts => As(PowerUnit.Petawatt); + public double Petawatts => As(PowerUnit.Petawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Picowatts => As(PowerUnit.Picowatt); + public double Picowatts => As(PowerUnit.Picowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Terawatts => As(PowerUnit.Terawatt); + public double Terawatts => As(PowerUnit.Terawatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Watts => As(PowerUnit.Watt); + public double Watts => As(PowerUnit.Watt); #endregion @@ -329,7 +328,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PowerUnit unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BoilerHorsepower, quantity => new Power(quantity.Value / 9812.5m, PowerUnit.BoilerHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.29307107017m, PowerUnit.BritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.293071m, PowerUnit.BritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Decawatt, quantity => new Power((quantity.Value) / 1e1m, PowerUnit.Decawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Deciwatt, quantity => new Power((quantity.Value) / 1e-1m, PowerUnit.Deciwatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.ElectricalHorsepower, quantity => new Power(quantity.Value / 746m, PowerUnit.ElectricalHorsepower)); @@ -338,11 +337,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Gigawatt, quantity => new Power((quantity.Value) / 1e9m, PowerUnit.Gigawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.HydraulicHorsepower, quantity => new Power(quantity.Value / 745.69988145m, PowerUnit.HydraulicHorsepower)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.JoulePerHour, quantity => new Power(quantity.Value * 3600m, PowerUnit.JoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilojoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e3m, PowerUnit.KilojoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Kilowatt, quantity => new Power((quantity.Value) / 1e3m, PowerUnit.Kilowatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MechanicalHorsepower, quantity => new Power(quantity.Value / 745.69m, PowerUnit.MechanicalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegajoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e6m, PowerUnit.MegajoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Megawatt, quantity => new Power((quantity.Value) / 1e6m, PowerUnit.Megawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MetricHorsepower, quantity => new Power(quantity.Value / 735.49875m, PowerUnit.MetricHorsepower)); @@ -359,7 +358,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: PowerUnit -> BaseUnit unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 9812.5m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.29307107017m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.293071m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Decawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Deciwatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e-1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 746m, PowerUnit.Watt)); @@ -368,11 +367,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Gigawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e9m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69988145m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, PowerUnit.Watt, quantity => new Power(quantity.Value / 3600m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e3m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Kilowatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e6m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Megawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 735.49875m, PowerUnit.Watt)); @@ -446,7 +445,7 @@ public static string GetAbbreviation(PowerUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower) { - QuantityValue value = (QuantityValue) boilerhorsepower; + decimal value = (decimal) boilerhorsepower; return new Power(value, PowerUnit.BoilerHorsepower); } @@ -456,7 +455,7 @@ public static Power FromBoilerHorsepower(QuantityValue boilerhorsepower) /// If value is NaN or Infinity. public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalunitsperhour) { - QuantityValue value = (QuantityValue) britishthermalunitsperhour; + decimal value = (decimal) britishthermalunitsperhour; return new Power(value, PowerUnit.BritishThermalUnitPerHour); } @@ -466,7 +465,7 @@ public static Power FromBritishThermalUnitsPerHour(QuantityValue britishthermalu /// If value is NaN or Infinity. public static Power FromDecawatts(QuantityValue decawatts) { - QuantityValue value = (QuantityValue) decawatts; + decimal value = (decimal) decawatts; return new Power(value, PowerUnit.Decawatt); } @@ -476,7 +475,7 @@ public static Power FromDecawatts(QuantityValue decawatts) /// If value is NaN or Infinity. public static Power FromDeciwatts(QuantityValue deciwatts) { - QuantityValue value = (QuantityValue) deciwatts; + decimal value = (decimal) deciwatts; return new Power(value, PowerUnit.Deciwatt); } @@ -486,7 +485,7 @@ public static Power FromDeciwatts(QuantityValue deciwatts) /// If value is NaN or Infinity. public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower) { - QuantityValue value = (QuantityValue) electricalhorsepower; + decimal value = (decimal) electricalhorsepower; return new Power(value, PowerUnit.ElectricalHorsepower); } @@ -496,7 +495,7 @@ public static Power FromElectricalHorsepower(QuantityValue electricalhorsepower) /// If value is NaN or Infinity. public static Power FromFemtowatts(QuantityValue femtowatts) { - QuantityValue value = (QuantityValue) femtowatts; + decimal value = (decimal) femtowatts; return new Power(value, PowerUnit.Femtowatt); } @@ -506,7 +505,7 @@ public static Power FromFemtowatts(QuantityValue femtowatts) /// If value is NaN or Infinity. public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour) { - QuantityValue value = (QuantityValue) gigajoulesperhour; + decimal value = (decimal) gigajoulesperhour; return new Power(value, PowerUnit.GigajoulePerHour); } @@ -516,7 +515,7 @@ public static Power FromGigajoulesPerHour(QuantityValue gigajoulesperhour) /// If value is NaN or Infinity. public static Power FromGigawatts(QuantityValue gigawatts) { - QuantityValue value = (QuantityValue) gigawatts; + decimal value = (decimal) gigawatts; return new Power(value, PowerUnit.Gigawatt); } @@ -526,7 +525,7 @@ public static Power FromGigawatts(QuantityValue gigawatts) /// If value is NaN or Infinity. public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower) { - QuantityValue value = (QuantityValue) hydraulichorsepower; + decimal value = (decimal) hydraulichorsepower; return new Power(value, PowerUnit.HydraulicHorsepower); } @@ -536,7 +535,7 @@ public static Power FromHydraulicHorsepower(QuantityValue hydraulichorsepower) /// If value is NaN or Infinity. public static Power FromJoulesPerHour(QuantityValue joulesperhour) { - QuantityValue value = (QuantityValue) joulesperhour; + decimal value = (decimal) joulesperhour; return new Power(value, PowerUnit.JoulePerHour); } @@ -546,7 +545,7 @@ public static Power FromJoulesPerHour(QuantityValue joulesperhour) /// If value is NaN or Infinity. public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritishthermalunitsperhour) { - QuantityValue value = (QuantityValue) kilobritishthermalunitsperhour; + decimal value = (decimal) kilobritishthermalunitsperhour; return new Power(value, PowerUnit.KilobritishThermalUnitPerHour); } @@ -556,7 +555,7 @@ public static Power FromKilobritishThermalUnitsPerHour(QuantityValue kilobritish /// If value is NaN or Infinity. public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour) { - QuantityValue value = (QuantityValue) kilojoulesperhour; + decimal value = (decimal) kilojoulesperhour; return new Power(value, PowerUnit.KilojoulePerHour); } @@ -566,7 +565,7 @@ public static Power FromKilojoulesPerHour(QuantityValue kilojoulesperhour) /// If value is NaN or Infinity. public static Power FromKilowatts(QuantityValue kilowatts) { - QuantityValue value = (QuantityValue) kilowatts; + decimal value = (decimal) kilowatts; return new Power(value, PowerUnit.Kilowatt); } @@ -576,7 +575,7 @@ public static Power FromKilowatts(QuantityValue kilowatts) /// If value is NaN or Infinity. public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower) { - QuantityValue value = (QuantityValue) mechanicalhorsepower; + decimal value = (decimal) mechanicalhorsepower; return new Power(value, PowerUnit.MechanicalHorsepower); } @@ -586,7 +585,7 @@ public static Power FromMechanicalHorsepower(QuantityValue mechanicalhorsepower) /// If value is NaN or Infinity. public static Power FromMegabritishThermalUnitsPerHour(QuantityValue megabritishthermalunitsperhour) { - QuantityValue value = (QuantityValue) megabritishthermalunitsperhour; + decimal value = (decimal) megabritishthermalunitsperhour; return new Power(value, PowerUnit.MegabritishThermalUnitPerHour); } @@ -596,7 +595,7 @@ public static Power FromMegabritishThermalUnitsPerHour(QuantityValue megabritish /// If value is NaN or Infinity. public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour) { - QuantityValue value = (QuantityValue) megajoulesperhour; + decimal value = (decimal) megajoulesperhour; return new Power(value, PowerUnit.MegajoulePerHour); } @@ -606,7 +605,7 @@ public static Power FromMegajoulesPerHour(QuantityValue megajoulesperhour) /// If value is NaN or Infinity. public static Power FromMegawatts(QuantityValue megawatts) { - QuantityValue value = (QuantityValue) megawatts; + decimal value = (decimal) megawatts; return new Power(value, PowerUnit.Megawatt); } @@ -616,7 +615,7 @@ public static Power FromMegawatts(QuantityValue megawatts) /// If value is NaN or Infinity. public static Power FromMetricHorsepower(QuantityValue metrichorsepower) { - QuantityValue value = (QuantityValue) metrichorsepower; + decimal value = (decimal) metrichorsepower; return new Power(value, PowerUnit.MetricHorsepower); } @@ -626,7 +625,7 @@ public static Power FromMetricHorsepower(QuantityValue metrichorsepower) /// If value is NaN or Infinity. public static Power FromMicrowatts(QuantityValue microwatts) { - QuantityValue value = (QuantityValue) microwatts; + decimal value = (decimal) microwatts; return new Power(value, PowerUnit.Microwatt); } @@ -636,7 +635,7 @@ public static Power FromMicrowatts(QuantityValue microwatts) /// If value is NaN or Infinity. public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour) { - QuantityValue value = (QuantityValue) millijoulesperhour; + decimal value = (decimal) millijoulesperhour; return new Power(value, PowerUnit.MillijoulePerHour); } @@ -646,7 +645,7 @@ public static Power FromMillijoulesPerHour(QuantityValue millijoulesperhour) /// If value is NaN or Infinity. public static Power FromMilliwatts(QuantityValue milliwatts) { - QuantityValue value = (QuantityValue) milliwatts; + decimal value = (decimal) milliwatts; return new Power(value, PowerUnit.Milliwatt); } @@ -656,7 +655,7 @@ public static Power FromMilliwatts(QuantityValue milliwatts) /// If value is NaN or Infinity. public static Power FromNanowatts(QuantityValue nanowatts) { - QuantityValue value = (QuantityValue) nanowatts; + decimal value = (decimal) nanowatts; return new Power(value, PowerUnit.Nanowatt); } @@ -666,7 +665,7 @@ public static Power FromNanowatts(QuantityValue nanowatts) /// If value is NaN or Infinity. public static Power FromPetawatts(QuantityValue petawatts) { - QuantityValue value = (QuantityValue) petawatts; + decimal value = (decimal) petawatts; return new Power(value, PowerUnit.Petawatt); } @@ -676,7 +675,7 @@ public static Power FromPetawatts(QuantityValue petawatts) /// If value is NaN or Infinity. public static Power FromPicowatts(QuantityValue picowatts) { - QuantityValue value = (QuantityValue) picowatts; + decimal value = (decimal) picowatts; return new Power(value, PowerUnit.Picowatt); } @@ -686,7 +685,7 @@ public static Power FromPicowatts(QuantityValue picowatts) /// If value is NaN or Infinity. public static Power FromTerawatts(QuantityValue terawatts) { - QuantityValue value = (QuantityValue) terawatts; + decimal value = (decimal) terawatts; return new Power(value, PowerUnit.Terawatt); } @@ -696,7 +695,7 @@ public static Power FromTerawatts(QuantityValue terawatts) /// If value is NaN or Infinity. public static Power FromWatts(QuantityValue watts) { - QuantityValue value = (QuantityValue) watts; + decimal value = (decimal) watts; return new Power(value, PowerUnit.Watt); } @@ -708,7 +707,7 @@ public static Power FromWatts(QuantityValue watts) /// Power unit value. public static Power From(QuantityValue value, PowerUnit fromUnit) { - return new Power((QuantityValue)value, fromUnit); + return new Power((decimal)value, fromUnit); } #endregion @@ -878,25 +877,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get from multiplying value and . - public static Power operator *(QuantityValue left, Power right) + public static Power operator *(decimal left, Power right) { return new Power(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Power operator *(Power left, QuantityValue right) + public static Power operator *(Power left, decimal right) { return new Power(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Power operator /(Power left, QuantityValue right) + public static Power operator /(Power left, decimal right) { return new Power(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Power left, Power right) + public static double operator /(Power left, Power right) { return left.Watts / right.Watts; } @@ -929,19 +928,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Power left, Power right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Power left, Power right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -954,29 +940,7 @@ public int CompareTo(object obj) /// public int CompareTo(Power other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Power objPower)) - return false; - return Equals(objPower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Power other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1019,13 +983,13 @@ public bool Equals(Power other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Power other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Power other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1036,7 +1000,7 @@ public bool Equals(Power other, QuantityValue tolerance, ComparisonType comparis /// A hash code for the current Power. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1047,16 +1011,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PowerUnit unit) + public double As(PowerUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1071,12 +1036,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PowerUnit typedUnit)) + if (!(unit is PowerUnit unitAsPowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPowerUnit); } /// @@ -1108,7 +1073,7 @@ public Power ToUnit(PowerUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Power)converted; } - else if (Enum.IsDefined(typeof(PowerUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1116,17 +1081,17 @@ public Power ToUnit(PowerUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerUnit typedUnit)) + if (!(unit is PowerUnit unitAsPowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPowerUnit, DefaultConversionFunctions); } /// @@ -1153,10 +1118,10 @@ public Power ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PowerUnit unit) + private decimal GetValueAs(PowerUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (decimal)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index e35dfe4767..a13b01eef5 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The amount of power in a volume. /// [DataContract] - public partial struct PowerDensity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerDensity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -115,9 +115,9 @@ static PowerDensity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PowerDensity(QuantityValue value, PowerDensityUnit unit) + public PowerDensity(double value, PowerDensityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -129,14 +129,14 @@ public PowerDensity(QuantityValue value, PowerDensityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerDensity(QuantityValue value, UnitSystem unitSystem) + public PowerDensity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -177,10 +177,7 @@ public PowerDensity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -203,224 +200,224 @@ public PowerDensity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); + public double DecawattsPerCubicFoot => As(PowerDensityUnit.DecawattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); + public double DecawattsPerCubicInch => As(PowerDensityUnit.DecawattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); + public double DecawattsPerCubicMeter => As(PowerDensityUnit.DecawattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); + public double DecawattsPerLiter => As(PowerDensityUnit.DecawattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); + public double DeciwattsPerCubicFoot => As(PowerDensityUnit.DeciwattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); + public double DeciwattsPerCubicInch => As(PowerDensityUnit.DeciwattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); + public double DeciwattsPerCubicMeter => As(PowerDensityUnit.DeciwattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); + public double DeciwattsPerLiter => As(PowerDensityUnit.DeciwattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); + public double GigawattsPerCubicFoot => As(PowerDensityUnit.GigawattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); + public double GigawattsPerCubicInch => As(PowerDensityUnit.GigawattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); + public double GigawattsPerCubicMeter => As(PowerDensityUnit.GigawattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); + public double GigawattsPerLiter => As(PowerDensityUnit.GigawattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); + public double KilowattsPerCubicFoot => As(PowerDensityUnit.KilowattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); + public double KilowattsPerCubicInch => As(PowerDensityUnit.KilowattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); + public double KilowattsPerCubicMeter => As(PowerDensityUnit.KilowattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); + public double KilowattsPerLiter => As(PowerDensityUnit.KilowattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); + public double MegawattsPerCubicFoot => As(PowerDensityUnit.MegawattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); + public double MegawattsPerCubicInch => As(PowerDensityUnit.MegawattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); + public double MegawattsPerCubicMeter => As(PowerDensityUnit.MegawattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); + public double MegawattsPerLiter => As(PowerDensityUnit.MegawattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); + public double MicrowattsPerCubicFoot => As(PowerDensityUnit.MicrowattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); + public double MicrowattsPerCubicInch => As(PowerDensityUnit.MicrowattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); + public double MicrowattsPerCubicMeter => As(PowerDensityUnit.MicrowattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); + public double MicrowattsPerLiter => As(PowerDensityUnit.MicrowattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); + public double MilliwattsPerCubicFoot => As(PowerDensityUnit.MilliwattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); + public double MilliwattsPerCubicInch => As(PowerDensityUnit.MilliwattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); + public double MilliwattsPerCubicMeter => As(PowerDensityUnit.MilliwattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); + public double MilliwattsPerLiter => As(PowerDensityUnit.MilliwattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); + public double NanowattsPerCubicFoot => As(PowerDensityUnit.NanowattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); + public double NanowattsPerCubicInch => As(PowerDensityUnit.NanowattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); + public double NanowattsPerCubicMeter => As(PowerDensityUnit.NanowattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); + public double NanowattsPerLiter => As(PowerDensityUnit.NanowattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); + public double PicowattsPerCubicFoot => As(PowerDensityUnit.PicowattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); + public double PicowattsPerCubicInch => As(PowerDensityUnit.PicowattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); + public double PicowattsPerCubicMeter => As(PowerDensityUnit.PicowattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); + public double PicowattsPerLiter => As(PowerDensityUnit.PicowattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); + public double TerawattsPerCubicFoot => As(PowerDensityUnit.TerawattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); + public double TerawattsPerCubicInch => As(PowerDensityUnit.TerawattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); + public double TerawattsPerCubicMeter => As(PowerDensityUnit.TerawattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); + public double TerawattsPerLiter => As(PowerDensityUnit.TerawattPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); + public double WattsPerCubicFoot => As(PowerDensityUnit.WattPerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); + public double WattsPerCubicInch => As(PowerDensityUnit.WattPerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); + public double WattsPerCubicMeter => As(PowerDensityUnit.WattPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerLiter => As(PowerDensityUnit.WattPerLiter); + public double WattsPerLiter => As(PowerDensityUnit.WattPerLiter); #endregion @@ -605,7 +602,7 @@ public static string GetAbbreviation(PowerDensityUnit unit, IFormatProvider? pro /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue decawattspercubicfoot) { - QuantityValue value = (QuantityValue) decawattspercubicfoot; + double value = (double) decawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicFoot); } @@ -615,7 +612,7 @@ public static PowerDensity FromDecawattsPerCubicFoot(QuantityValue decawattsperc /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerCubicInch(QuantityValue decawattspercubicinch) { - QuantityValue value = (QuantityValue) decawattspercubicinch; + double value = (double) decawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicInch); } @@ -625,7 +622,7 @@ public static PowerDensity FromDecawattsPerCubicInch(QuantityValue decawattsperc /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue decawattspercubicmeter) { - QuantityValue value = (QuantityValue) decawattspercubicmeter; + double value = (double) decawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.DecawattPerCubicMeter); } @@ -635,7 +632,7 @@ public static PowerDensity FromDecawattsPerCubicMeter(QuantityValue decawattsper /// If value is NaN or Infinity. public static PowerDensity FromDecawattsPerLiter(QuantityValue decawattsperliter) { - QuantityValue value = (QuantityValue) decawattsperliter; + double value = (double) decawattsperliter; return new PowerDensity(value, PowerDensityUnit.DecawattPerLiter); } @@ -645,7 +642,7 @@ public static PowerDensity FromDecawattsPerLiter(QuantityValue decawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue deciwattspercubicfoot) { - QuantityValue value = (QuantityValue) deciwattspercubicfoot; + double value = (double) deciwattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicFoot); } @@ -655,7 +652,7 @@ public static PowerDensity FromDeciwattsPerCubicFoot(QuantityValue deciwattsperc /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue deciwattspercubicinch) { - QuantityValue value = (QuantityValue) deciwattspercubicinch; + double value = (double) deciwattspercubicinch; return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicInch); } @@ -665,7 +662,7 @@ public static PowerDensity FromDeciwattsPerCubicInch(QuantityValue deciwattsperc /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue deciwattspercubicmeter) { - QuantityValue value = (QuantityValue) deciwattspercubicmeter; + double value = (double) deciwattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.DeciwattPerCubicMeter); } @@ -675,7 +672,7 @@ public static PowerDensity FromDeciwattsPerCubicMeter(QuantityValue deciwattsper /// If value is NaN or Infinity. public static PowerDensity FromDeciwattsPerLiter(QuantityValue deciwattsperliter) { - QuantityValue value = (QuantityValue) deciwattsperliter; + double value = (double) deciwattsperliter; return new PowerDensity(value, PowerDensityUnit.DeciwattPerLiter); } @@ -685,7 +682,7 @@ public static PowerDensity FromDeciwattsPerLiter(QuantityValue deciwattsperliter /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue gigawattspercubicfoot) { - QuantityValue value = (QuantityValue) gigawattspercubicfoot; + double value = (double) gigawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicFoot); } @@ -695,7 +692,7 @@ public static PowerDensity FromGigawattsPerCubicFoot(QuantityValue gigawattsperc /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerCubicInch(QuantityValue gigawattspercubicinch) { - QuantityValue value = (QuantityValue) gigawattspercubicinch; + double value = (double) gigawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicInch); } @@ -705,7 +702,7 @@ public static PowerDensity FromGigawattsPerCubicInch(QuantityValue gigawattsperc /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue gigawattspercubicmeter) { - QuantityValue value = (QuantityValue) gigawattspercubicmeter; + double value = (double) gigawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.GigawattPerCubicMeter); } @@ -715,7 +712,7 @@ public static PowerDensity FromGigawattsPerCubicMeter(QuantityValue gigawattsper /// If value is NaN or Infinity. public static PowerDensity FromGigawattsPerLiter(QuantityValue gigawattsperliter) { - QuantityValue value = (QuantityValue) gigawattsperliter; + double value = (double) gigawattsperliter; return new PowerDensity(value, PowerDensityUnit.GigawattPerLiter); } @@ -725,7 +722,7 @@ public static PowerDensity FromGigawattsPerLiter(QuantityValue gigawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue kilowattspercubicfoot) { - QuantityValue value = (QuantityValue) kilowattspercubicfoot; + double value = (double) kilowattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicFoot); } @@ -735,7 +732,7 @@ public static PowerDensity FromKilowattsPerCubicFoot(QuantityValue kilowattsperc /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerCubicInch(QuantityValue kilowattspercubicinch) { - QuantityValue value = (QuantityValue) kilowattspercubicinch; + double value = (double) kilowattspercubicinch; return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicInch); } @@ -745,7 +742,7 @@ public static PowerDensity FromKilowattsPerCubicInch(QuantityValue kilowattsperc /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue kilowattspercubicmeter) { - QuantityValue value = (QuantityValue) kilowattspercubicmeter; + double value = (double) kilowattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.KilowattPerCubicMeter); } @@ -755,7 +752,7 @@ public static PowerDensity FromKilowattsPerCubicMeter(QuantityValue kilowattsper /// If value is NaN or Infinity. public static PowerDensity FromKilowattsPerLiter(QuantityValue kilowattsperliter) { - QuantityValue value = (QuantityValue) kilowattsperliter; + double value = (double) kilowattsperliter; return new PowerDensity(value, PowerDensityUnit.KilowattPerLiter); } @@ -765,7 +762,7 @@ public static PowerDensity FromKilowattsPerLiter(QuantityValue kilowattsperliter /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue megawattspercubicfoot) { - QuantityValue value = (QuantityValue) megawattspercubicfoot; + double value = (double) megawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicFoot); } @@ -775,7 +772,7 @@ public static PowerDensity FromMegawattsPerCubicFoot(QuantityValue megawattsperc /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerCubicInch(QuantityValue megawattspercubicinch) { - QuantityValue value = (QuantityValue) megawattspercubicinch; + double value = (double) megawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicInch); } @@ -785,7 +782,7 @@ public static PowerDensity FromMegawattsPerCubicInch(QuantityValue megawattsperc /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue megawattspercubicmeter) { - QuantityValue value = (QuantityValue) megawattspercubicmeter; + double value = (double) megawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.MegawattPerCubicMeter); } @@ -795,7 +792,7 @@ public static PowerDensity FromMegawattsPerCubicMeter(QuantityValue megawattsper /// If value is NaN or Infinity. public static PowerDensity FromMegawattsPerLiter(QuantityValue megawattsperliter) { - QuantityValue value = (QuantityValue) megawattsperliter; + double value = (double) megawattsperliter; return new PowerDensity(value, PowerDensityUnit.MegawattPerLiter); } @@ -805,7 +802,7 @@ public static PowerDensity FromMegawattsPerLiter(QuantityValue megawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue microwattspercubicfoot) { - QuantityValue value = (QuantityValue) microwattspercubicfoot; + double value = (double) microwattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicFoot); } @@ -815,7 +812,7 @@ public static PowerDensity FromMicrowattsPerCubicFoot(QuantityValue microwattspe /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue microwattspercubicinch) { - QuantityValue value = (QuantityValue) microwattspercubicinch; + double value = (double) microwattspercubicinch; return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicInch); } @@ -825,7 +822,7 @@ public static PowerDensity FromMicrowattsPerCubicInch(QuantityValue microwattspe /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue microwattspercubicmeter) { - QuantityValue value = (QuantityValue) microwattspercubicmeter; + double value = (double) microwattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.MicrowattPerCubicMeter); } @@ -835,7 +832,7 @@ public static PowerDensity FromMicrowattsPerCubicMeter(QuantityValue microwattsp /// If value is NaN or Infinity. public static PowerDensity FromMicrowattsPerLiter(QuantityValue microwattsperliter) { - QuantityValue value = (QuantityValue) microwattsperliter; + double value = (double) microwattsperliter; return new PowerDensity(value, PowerDensityUnit.MicrowattPerLiter); } @@ -845,7 +842,7 @@ public static PowerDensity FromMicrowattsPerLiter(QuantityValue microwattsperlit /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue milliwattspercubicfoot) { - QuantityValue value = (QuantityValue) milliwattspercubicfoot; + double value = (double) milliwattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicFoot); } @@ -855,7 +852,7 @@ public static PowerDensity FromMilliwattsPerCubicFoot(QuantityValue milliwattspe /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue milliwattspercubicinch) { - QuantityValue value = (QuantityValue) milliwattspercubicinch; + double value = (double) milliwattspercubicinch; return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicInch); } @@ -865,7 +862,7 @@ public static PowerDensity FromMilliwattsPerCubicInch(QuantityValue milliwattspe /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue milliwattspercubicmeter) { - QuantityValue value = (QuantityValue) milliwattspercubicmeter; + double value = (double) milliwattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.MilliwattPerCubicMeter); } @@ -875,7 +872,7 @@ public static PowerDensity FromMilliwattsPerCubicMeter(QuantityValue milliwattsp /// If value is NaN or Infinity. public static PowerDensity FromMilliwattsPerLiter(QuantityValue milliwattsperliter) { - QuantityValue value = (QuantityValue) milliwattsperliter; + double value = (double) milliwattsperliter; return new PowerDensity(value, PowerDensityUnit.MilliwattPerLiter); } @@ -885,7 +882,7 @@ public static PowerDensity FromMilliwattsPerLiter(QuantityValue milliwattsperlit /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue nanowattspercubicfoot) { - QuantityValue value = (QuantityValue) nanowattspercubicfoot; + double value = (double) nanowattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicFoot); } @@ -895,7 +892,7 @@ public static PowerDensity FromNanowattsPerCubicFoot(QuantityValue nanowattsperc /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerCubicInch(QuantityValue nanowattspercubicinch) { - QuantityValue value = (QuantityValue) nanowattspercubicinch; + double value = (double) nanowattspercubicinch; return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicInch); } @@ -905,7 +902,7 @@ public static PowerDensity FromNanowattsPerCubicInch(QuantityValue nanowattsperc /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue nanowattspercubicmeter) { - QuantityValue value = (QuantityValue) nanowattspercubicmeter; + double value = (double) nanowattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.NanowattPerCubicMeter); } @@ -915,7 +912,7 @@ public static PowerDensity FromNanowattsPerCubicMeter(QuantityValue nanowattsper /// If value is NaN or Infinity. public static PowerDensity FromNanowattsPerLiter(QuantityValue nanowattsperliter) { - QuantityValue value = (QuantityValue) nanowattsperliter; + double value = (double) nanowattsperliter; return new PowerDensity(value, PowerDensityUnit.NanowattPerLiter); } @@ -925,7 +922,7 @@ public static PowerDensity FromNanowattsPerLiter(QuantityValue nanowattsperliter /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue picowattspercubicfoot) { - QuantityValue value = (QuantityValue) picowattspercubicfoot; + double value = (double) picowattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicFoot); } @@ -935,7 +932,7 @@ public static PowerDensity FromPicowattsPerCubicFoot(QuantityValue picowattsperc /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerCubicInch(QuantityValue picowattspercubicinch) { - QuantityValue value = (QuantityValue) picowattspercubicinch; + double value = (double) picowattspercubicinch; return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicInch); } @@ -945,7 +942,7 @@ public static PowerDensity FromPicowattsPerCubicInch(QuantityValue picowattsperc /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue picowattspercubicmeter) { - QuantityValue value = (QuantityValue) picowattspercubicmeter; + double value = (double) picowattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.PicowattPerCubicMeter); } @@ -955,7 +952,7 @@ public static PowerDensity FromPicowattsPerCubicMeter(QuantityValue picowattsper /// If value is NaN or Infinity. public static PowerDensity FromPicowattsPerLiter(QuantityValue picowattsperliter) { - QuantityValue value = (QuantityValue) picowattsperliter; + double value = (double) picowattsperliter; return new PowerDensity(value, PowerDensityUnit.PicowattPerLiter); } @@ -965,7 +962,7 @@ public static PowerDensity FromPicowattsPerLiter(QuantityValue picowattsperliter /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue terawattspercubicfoot) { - QuantityValue value = (QuantityValue) terawattspercubicfoot; + double value = (double) terawattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicFoot); } @@ -975,7 +972,7 @@ public static PowerDensity FromTerawattsPerCubicFoot(QuantityValue terawattsperc /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerCubicInch(QuantityValue terawattspercubicinch) { - QuantityValue value = (QuantityValue) terawattspercubicinch; + double value = (double) terawattspercubicinch; return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicInch); } @@ -985,7 +982,7 @@ public static PowerDensity FromTerawattsPerCubicInch(QuantityValue terawattsperc /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue terawattspercubicmeter) { - QuantityValue value = (QuantityValue) terawattspercubicmeter; + double value = (double) terawattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.TerawattPerCubicMeter); } @@ -995,7 +992,7 @@ public static PowerDensity FromTerawattsPerCubicMeter(QuantityValue terawattsper /// If value is NaN or Infinity. public static PowerDensity FromTerawattsPerLiter(QuantityValue terawattsperliter) { - QuantityValue value = (QuantityValue) terawattsperliter; + double value = (double) terawattsperliter; return new PowerDensity(value, PowerDensityUnit.TerawattPerLiter); } @@ -1005,7 +1002,7 @@ public static PowerDensity FromTerawattsPerLiter(QuantityValue terawattsperliter /// If value is NaN or Infinity. public static PowerDensity FromWattsPerCubicFoot(QuantityValue wattspercubicfoot) { - QuantityValue value = (QuantityValue) wattspercubicfoot; + double value = (double) wattspercubicfoot; return new PowerDensity(value, PowerDensityUnit.WattPerCubicFoot); } @@ -1015,7 +1012,7 @@ public static PowerDensity FromWattsPerCubicFoot(QuantityValue wattspercubicfoot /// If value is NaN or Infinity. public static PowerDensity FromWattsPerCubicInch(QuantityValue wattspercubicinch) { - QuantityValue value = (QuantityValue) wattspercubicinch; + double value = (double) wattspercubicinch; return new PowerDensity(value, PowerDensityUnit.WattPerCubicInch); } @@ -1025,7 +1022,7 @@ public static PowerDensity FromWattsPerCubicInch(QuantityValue wattspercubicinch /// If value is NaN or Infinity. public static PowerDensity FromWattsPerCubicMeter(QuantityValue wattspercubicmeter) { - QuantityValue value = (QuantityValue) wattspercubicmeter; + double value = (double) wattspercubicmeter; return new PowerDensity(value, PowerDensityUnit.WattPerCubicMeter); } @@ -1035,7 +1032,7 @@ public static PowerDensity FromWattsPerCubicMeter(QuantityValue wattspercubicmet /// If value is NaN or Infinity. public static PowerDensity FromWattsPerLiter(QuantityValue wattsperliter) { - QuantityValue value = (QuantityValue) wattsperliter; + double value = (double) wattsperliter; return new PowerDensity(value, PowerDensityUnit.WattPerLiter); } @@ -1047,7 +1044,7 @@ public static PowerDensity FromWattsPerLiter(QuantityValue wattsperliter) /// PowerDensity unit value. public static PowerDensity From(QuantityValue value, PowerDensityUnit fromUnit) { - return new PowerDensity((QuantityValue)value, fromUnit); + return new PowerDensity((double)value, fromUnit); } #endregion @@ -1217,25 +1214,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get from multiplying value and . - public static PowerDensity operator *(QuantityValue left, PowerDensity right) + public static PowerDensity operator *(double left, PowerDensity right) { return new PowerDensity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PowerDensity operator *(PowerDensity left, QuantityValue right) + public static PowerDensity operator *(PowerDensity left, double right) { return new PowerDensity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PowerDensity operator /(PowerDensity left, QuantityValue right) + public static PowerDensity operator /(PowerDensity left, double right) { return new PowerDensity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(PowerDensity left, PowerDensity right) + public static double operator /(PowerDensity left, PowerDensity right) { return left.WattsPerCubicMeter / right.WattsPerCubicMeter; } @@ -1268,19 +1265,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerDensity left, PowerDensity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerDensity left, PowerDensity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1293,29 +1277,7 @@ public int CompareTo(object obj) /// public int CompareTo(PowerDensity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is PowerDensity objPowerDensity)) - return false; - return Equals(objPowerDensity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerDensity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1358,13 +1320,13 @@ public bool Equals(PowerDensity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerDensity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(PowerDensity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1375,7 +1337,7 @@ public bool Equals(PowerDensity other, QuantityValue tolerance, ComparisonType c /// A hash code for the current PowerDensity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1386,16 +1348,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PowerDensityUnit unit) + public double As(PowerDensityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1410,12 +1373,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PowerDensityUnit typedUnit)) + if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPowerDensityUnit); } /// @@ -1447,7 +1410,7 @@ public PowerDensity ToUnit(PowerDensityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (PowerDensity)converted; } - else if (Enum.IsDefined(typeof(PowerDensityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1455,17 +1418,17 @@ public PowerDensity ToUnit(PowerDensityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerDensityUnit typedUnit)) + if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPowerDensityUnit, DefaultConversionFunctions); } /// @@ -1492,10 +1455,10 @@ public PowerDensity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PowerDensityUnit unit) + private double GetValueAs(PowerDensityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index b76f6f4e1f..e2297bd8ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The strength of a signal expressed in decibels (dB) relative to one watt. /// [DataContract] - public partial struct PowerRatio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PowerRatio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static PowerRatio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PowerRatio(QuantityValue value, PowerRatioUnit unit) + public PowerRatio(double value, PowerRatioUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -87,14 +87,14 @@ public PowerRatio(QuantityValue value, PowerRatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PowerRatio(QuantityValue value, UnitSystem unitSystem) + public PowerRatio(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,10 +135,7 @@ public PowerRatio(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -161,14 +158,14 @@ public PowerRatio(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); + public double DecibelMilliwatts => As(PowerRatioUnit.DecibelMilliwatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecibelWatts => As(PowerRatioUnit.DecibelWatt); + public double DecibelWatts => As(PowerRatioUnit.DecibelWatt); #endregion @@ -227,7 +224,7 @@ public static string GetAbbreviation(PowerRatioUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static PowerRatio FromDecibelMilliwatts(QuantityValue decibelmilliwatts) { - QuantityValue value = (QuantityValue) decibelmilliwatts; + double value = (double) decibelmilliwatts; return new PowerRatio(value, PowerRatioUnit.DecibelMilliwatt); } @@ -237,7 +234,7 @@ public static PowerRatio FromDecibelMilliwatts(QuantityValue decibelmilliwatts) /// If value is NaN or Infinity. public static PowerRatio FromDecibelWatts(QuantityValue decibelwatts) { - QuantityValue value = (QuantityValue) decibelwatts; + double value = (double) decibelwatts; return new PowerRatio(value, PowerRatioUnit.DecibelWatt); } @@ -249,7 +246,7 @@ public static PowerRatio FromDecibelWatts(QuantityValue decibelwatts) /// PowerRatio unit value. public static PowerRatio From(QuantityValue value, PowerRatioUnit fromUnit) { - return new PowerRatio((QuantityValue)value, fromUnit); + return new PowerRatio((double)value, fromUnit); } #endregion @@ -411,7 +408,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power { // Logarithmic addition // Formula: 10 * log10(10^(x/10) + 10^(y/10)) - return new PowerRatio(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) + Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); + return new PowerRatio(10 * Math.Log10(Math.Pow(10, left.Value/10) + Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic subtraction of two . @@ -419,11 +416,11 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power { // Logarithmic subtraction // Formula: 10 * log10(10^(x/10) - 10^(y/10)) - return new PowerRatio(10 * Math.Log10(Math.Pow(10, (double)left.Value/10) - Math.Pow(10, (double)right.GetValueAs(left.Unit)/10)), left.Unit); + return new PowerRatio(10 * Math.Log10(Math.Pow(10, left.Value/10) - Math.Pow(10, right.GetValueAs(left.Unit)/10)), left.Unit); } /// Get from logarithmic multiplication of value and . - public static PowerRatio operator *(QuantityValue left, PowerRatio right) + public static PowerRatio operator *(double left, PowerRatio right) { // Logarithmic multiplication = addition return new PowerRatio(left + right.Value, right.Unit); @@ -433,14 +430,14 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power public static PowerRatio operator *(PowerRatio left, double right) { // Logarithmic multiplication = addition - return new PowerRatio(left.Value + (QuantityValue)right, left.Unit); + return new PowerRatio(left.Value + (double)right, left.Unit); } /// Get from logarithmic division of by value. public static PowerRatio operator /(PowerRatio left, double right) { // Logarithmic division = subtraction - return new PowerRatio(left.Value - (QuantityValue)right, left.Unit); + return new PowerRatio(left.Value - (double)right, left.Unit); } /// Get ratio value from logarithmic division of by . @@ -478,19 +475,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PowerRatio left, PowerRatio right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PowerRatio left, PowerRatio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -503,29 +487,7 @@ public int CompareTo(object obj) /// public int CompareTo(PowerRatio other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is PowerRatio objPowerRatio)) - return false; - return Equals(objPowerRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PowerRatio other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -568,13 +530,13 @@ public bool Equals(PowerRatio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PowerRatio other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(PowerRatio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -585,7 +547,7 @@ public bool Equals(PowerRatio other, QuantityValue tolerance, ComparisonType com /// A hash code for the current PowerRatio. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -596,16 +558,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PowerRatioUnit unit) + public double As(PowerRatioUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -620,12 +583,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PowerRatioUnit typedUnit)) + if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPowerRatioUnit); } /// @@ -657,7 +620,7 @@ public PowerRatio ToUnit(PowerRatioUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (PowerRatio)converted; } - else if (Enum.IsDefined(typeof(PowerRatioUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -665,17 +628,17 @@ public PowerRatio ToUnit(PowerRatioUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerRatioUnit typedUnit)) + if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPowerRatioUnit, DefaultConversionFunctions); } /// @@ -702,10 +665,10 @@ public PowerRatio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PowerRatioUnit unit) + private double GetValueAs(PowerRatioUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index cd4dcfda52..12ab6f58c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Pressure (symbol: P or p) is the ratio of force to the area over which that force is distributed. Pressure is force per unit area applied in a direction perpendicular to the surface of an object. Gauge pressure (also spelled gage pressure)[a] is the pressure relative to the local atmospheric or ambient pressure. Pressure is measured in any unit of force divided by any unit of area. The SI unit of pressure is the newton per square metre, which is called the pascal (Pa) after the seventeenth-century philosopher and scientist Blaise Pascal. A pressure of 1 Pa is small; it approximately equals the pressure exerted by a dollar bill resting flat on a table. Everyday pressures are often stated in kilopascals (1 kPa = 1000 Pa). /// [DataContract] - public partial struct Pressure : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Pressure : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -118,9 +118,9 @@ static Pressure() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Pressure(QuantityValue value, PressureUnit unit) + public Pressure(double value, PressureUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -132,14 +132,14 @@ public Pressure(QuantityValue value, PressureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Pressure(QuantityValue value, UnitSystem unitSystem) + public Pressure(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -180,10 +180,7 @@ public Pressure(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -206,239 +203,239 @@ public Pressure(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Atmospheres => As(PressureUnit.Atmosphere); + public double Atmospheres => As(PressureUnit.Atmosphere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Bars => As(PressureUnit.Bar); + public double Bars => As(PressureUnit.Bar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centibars => As(PressureUnit.Centibar); + public double Centibars => As(PressureUnit.Centibar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decapascals => As(PressureUnit.Decapascal); + public double Decapascals => As(PressureUnit.Decapascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decibars => As(PressureUnit.Decibar); + public double Decibars => As(PressureUnit.Decibar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); + public double DynesPerSquareCentimeter => As(PressureUnit.DynePerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetOfElevation => As(PressureUnit.FootOfElevation); + public double FeetOfElevation => As(PressureUnit.FootOfElevation); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetOfHead => As(PressureUnit.FootOfHead); + public double FeetOfHead => As(PressureUnit.FootOfHead); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Gigapascals => As(PressureUnit.Gigapascal); + public double Gigapascals => As(PressureUnit.Gigapascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hectopascals => As(PressureUnit.Hectopascal); + public double Hectopascals => As(PressureUnit.Hectopascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesOfMercury => As(PressureUnit.InchOfMercury); + public double InchesOfMercury => As(PressureUnit.InchOfMercury); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); + public double InchesOfWaterColumn => As(PressureUnit.InchOfWaterColumn); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilobars => As(PressureUnit.Kilobar); + public double Kilobars => As(PressureUnit.Kilobar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); + public double KilogramsForcePerSquareCentimeter => As(PressureUnit.KilogramForcePerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); + public double KilogramsForcePerSquareMeter => As(PressureUnit.KilogramForcePerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); + public double KilogramsForcePerSquareMillimeter => As(PressureUnit.KilogramForcePerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); + public double KilonewtonsPerSquareCentimeter => As(PressureUnit.KilonewtonPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); + public double KilonewtonsPerSquareMeter => As(PressureUnit.KilonewtonPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); + public double KilonewtonsPerSquareMillimeter => As(PressureUnit.KilonewtonPerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kilopascals => As(PressureUnit.Kilopascal); + public double Kilopascals => As(PressureUnit.Kilopascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); + public double KilopoundsForcePerSquareFoot => As(PressureUnit.KilopoundForcePerSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); + public double KilopoundsForcePerSquareInch => As(PressureUnit.KilopoundForcePerSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil); + public double KilopoundsForcePerSquareMil => As(PressureUnit.KilopoundForcePerSquareMil); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megabars => As(PressureUnit.Megabar); + public double Megabars => As(PressureUnit.Megabar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); + public double MeganewtonsPerSquareMeter => As(PressureUnit.MeganewtonPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megapascals => As(PressureUnit.Megapascal); + public double Megapascals => As(PressureUnit.Megapascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersOfElevation => As(PressureUnit.MeterOfElevation); + public double MetersOfElevation => As(PressureUnit.MeterOfElevation); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersOfHead => As(PressureUnit.MeterOfHead); + public double MetersOfHead => As(PressureUnit.MeterOfHead); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microbars => As(PressureUnit.Microbar); + public double Microbars => As(PressureUnit.Microbar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Micropascals => As(PressureUnit.Micropascal); + public double Micropascals => As(PressureUnit.Micropascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millibars => As(PressureUnit.Millibar); + public double Millibars => As(PressureUnit.Millibar); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); + public double MillimetersOfMercury => As(PressureUnit.MillimeterOfMercury); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimeterOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn); + public double MillimeterOfWaterColumn => As(PressureUnit.MillimeterOfWaterColumn); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Millipascals => As(PressureUnit.Millipascal); + public double Millipascals => As(PressureUnit.Millipascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); + public double NewtonsPerSquareCentimeter => As(PressureUnit.NewtonPerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); + public double NewtonsPerSquareMeter => As(PressureUnit.NewtonPerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); + public double NewtonsPerSquareMillimeter => As(PressureUnit.NewtonPerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Pascals => As(PressureUnit.Pascal); + public double Pascals => As(PressureUnit.Pascal); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); + public double PoundsForcePerSquareFoot => As(PressureUnit.PoundForcePerSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); + public double PoundsForcePerSquareInch => As(PressureUnit.PoundForcePerSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil); + public double PoundsForcePerSquareMil => As(PressureUnit.PoundForcePerSquareMil); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); + public double PoundsPerInchSecondSquared => As(PressureUnit.PoundPerInchSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); + public double TechnicalAtmospheres => As(PressureUnit.TechnicalAtmosphere); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); + public double TonnesForcePerSquareCentimeter => As(PressureUnit.TonneForcePerSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); + public double TonnesForcePerSquareMeter => As(PressureUnit.TonneForcePerSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); + public double TonnesForcePerSquareMillimeter => As(PressureUnit.TonneForcePerSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Torrs => As(PressureUnit.Torr); + public double Torrs => As(PressureUnit.Torr); #endregion @@ -457,7 +454,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Decapascal, quantity => new Pressure((quantity.Value) / 1e1d, PressureUnit.Decapascal)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Decibar, quantity => new Pressure((quantity.Value / 1e5) / 1e-1d, PressureUnit.Decibar)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.DynePerSquareCentimeter, quantity => new Pressure(quantity.Value / 1.0e-1, PressureUnit.DynePerSquareCentimeter)); - unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.FootOfElevation, quantity => new Pressure((1.0 - Math.Pow((double)quantity.Value / 101325.0, 0.190284)) * 145366.45, PressureUnit.FootOfElevation)); + unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.FootOfElevation, quantity => new Pressure((1.0 - Math.Pow(quantity.Value / 101325.0, 0.190284)) * 145366.45, PressureUnit.FootOfElevation)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.FootOfHead, quantity => new Pressure(quantity.Value * 0.000334552565551, PressureUnit.FootOfHead)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Gigapascal, quantity => new Pressure((quantity.Value) / 1e9d, PressureUnit.Gigapascal)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Hectopascal, quantity => new Pressure((quantity.Value) / 1e2d, PressureUnit.Hectopascal)); @@ -477,7 +474,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Megabar, quantity => new Pressure((quantity.Value / 1e5) / 1e6d, PressureUnit.Megabar)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeganewtonPerSquareMeter, quantity => new Pressure((quantity.Value) / 1e6d, PressureUnit.MeganewtonPerSquareMeter)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Megapascal, quantity => new Pressure((quantity.Value) / 1e6d, PressureUnit.Megapascal)); - unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeterOfElevation, quantity => new Pressure((1.0 - Math.Pow((double)quantity.Value / 101325.0, 0.190284)) * 44307.69396, PressureUnit.MeterOfElevation)); + unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeterOfElevation, quantity => new Pressure((1.0 - Math.Pow(quantity.Value / 101325.0, 0.190284)) * 44307.69396, PressureUnit.MeterOfElevation)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.MeterOfHead, quantity => new Pressure(quantity.Value * 0.0001019977334, PressureUnit.MeterOfHead)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Microbar, quantity => new Pressure((quantity.Value / 1e5) / 1e-6d, PressureUnit.Microbar)); unitConverter.SetConversionFunction(PressureUnit.Pascal, PressureUnit.Micropascal, quantity => new Pressure((quantity.Value) / 1e-6d, PressureUnit.Micropascal)); @@ -508,7 +505,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Decapascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e1d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Decibar, PressureUnit.Pascal, quantity => new Pressure((quantity.Value * 1e5) * 1e-1d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.DynePerSquareCentimeter, PressureUnit.Pascal, quantity => new Pressure(quantity.Value * 1.0e-1, PressureUnit.Pascal)); - unitConverter.SetConversionFunction(PressureUnit.FootOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - ((double)quantity.Value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); + unitConverter.SetConversionFunction(PressureUnit.FootOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - (quantity.Value / 145366.45), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.FootOfHead, PressureUnit.Pascal, quantity => new Pressure(quantity.Value * 2989.0669, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Gigapascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e9d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Hectopascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e2d, PressureUnit.Pascal)); @@ -528,7 +525,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PressureUnit.Megabar, PressureUnit.Pascal, quantity => new Pressure((quantity.Value * 1e5) * 1e6d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.MeganewtonPerSquareMeter, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e6d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Megapascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e6d, PressureUnit.Pascal)); - unitConverter.SetConversionFunction(PressureUnit.MeterOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - ((double)quantity.Value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); + unitConverter.SetConversionFunction(PressureUnit.MeterOfElevation, PressureUnit.Pascal, quantity => new Pressure(Math.Pow(1.0 - (quantity.Value / 44307.69396), 5.2553026003237266401799415610351) * 101325.0, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.MeterOfHead, PressureUnit.Pascal, quantity => new Pressure(quantity.Value * 9804.139432, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Microbar, PressureUnit.Pascal, quantity => new Pressure((quantity.Value * 1e5) * 1e-6d, PressureUnit.Pascal)); unitConverter.SetConversionFunction(PressureUnit.Micropascal, PressureUnit.Pascal, quantity => new Pressure((quantity.Value) * 1e-6d, PressureUnit.Pascal)); @@ -663,7 +660,7 @@ public static string GetAbbreviation(PressureUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static Pressure FromAtmospheres(QuantityValue atmospheres) { - QuantityValue value = (QuantityValue) atmospheres; + double value = (double) atmospheres; return new Pressure(value, PressureUnit.Atmosphere); } @@ -673,7 +670,7 @@ public static Pressure FromAtmospheres(QuantityValue atmospheres) /// If value is NaN or Infinity. public static Pressure FromBars(QuantityValue bars) { - QuantityValue value = (QuantityValue) bars; + double value = (double) bars; return new Pressure(value, PressureUnit.Bar); } @@ -683,7 +680,7 @@ public static Pressure FromBars(QuantityValue bars) /// If value is NaN or Infinity. public static Pressure FromCentibars(QuantityValue centibars) { - QuantityValue value = (QuantityValue) centibars; + double value = (double) centibars; return new Pressure(value, PressureUnit.Centibar); } @@ -693,7 +690,7 @@ public static Pressure FromCentibars(QuantityValue centibars) /// If value is NaN or Infinity. public static Pressure FromDecapascals(QuantityValue decapascals) { - QuantityValue value = (QuantityValue) decapascals; + double value = (double) decapascals; return new Pressure(value, PressureUnit.Decapascal); } @@ -703,7 +700,7 @@ public static Pressure FromDecapascals(QuantityValue decapascals) /// If value is NaN or Infinity. public static Pressure FromDecibars(QuantityValue decibars) { - QuantityValue value = (QuantityValue) decibars; + double value = (double) decibars; return new Pressure(value, PressureUnit.Decibar); } @@ -713,7 +710,7 @@ public static Pressure FromDecibars(QuantityValue decibars) /// If value is NaN or Infinity. public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquarecentimeter) { - QuantityValue value = (QuantityValue) dynespersquarecentimeter; + double value = (double) dynespersquarecentimeter; return new Pressure(value, PressureUnit.DynePerSquareCentimeter); } @@ -723,7 +720,7 @@ public static Pressure FromDynesPerSquareCentimeter(QuantityValue dynespersquare /// If value is NaN or Infinity. public static Pressure FromFeetOfElevation(QuantityValue feetofelevation) { - QuantityValue value = (QuantityValue) feetofelevation; + double value = (double) feetofelevation; return new Pressure(value, PressureUnit.FootOfElevation); } @@ -733,7 +730,7 @@ public static Pressure FromFeetOfElevation(QuantityValue feetofelevation) /// If value is NaN or Infinity. public static Pressure FromFeetOfHead(QuantityValue feetofhead) { - QuantityValue value = (QuantityValue) feetofhead; + double value = (double) feetofhead; return new Pressure(value, PressureUnit.FootOfHead); } @@ -743,7 +740,7 @@ public static Pressure FromFeetOfHead(QuantityValue feetofhead) /// If value is NaN or Infinity. public static Pressure FromGigapascals(QuantityValue gigapascals) { - QuantityValue value = (QuantityValue) gigapascals; + double value = (double) gigapascals; return new Pressure(value, PressureUnit.Gigapascal); } @@ -753,7 +750,7 @@ public static Pressure FromGigapascals(QuantityValue gigapascals) /// If value is NaN or Infinity. public static Pressure FromHectopascals(QuantityValue hectopascals) { - QuantityValue value = (QuantityValue) hectopascals; + double value = (double) hectopascals; return new Pressure(value, PressureUnit.Hectopascal); } @@ -763,7 +760,7 @@ public static Pressure FromHectopascals(QuantityValue hectopascals) /// If value is NaN or Infinity. public static Pressure FromInchesOfMercury(QuantityValue inchesofmercury) { - QuantityValue value = (QuantityValue) inchesofmercury; + double value = (double) inchesofmercury; return new Pressure(value, PressureUnit.InchOfMercury); } @@ -773,7 +770,7 @@ public static Pressure FromInchesOfMercury(QuantityValue inchesofmercury) /// If value is NaN or Infinity. public static Pressure FromInchesOfWaterColumn(QuantityValue inchesofwatercolumn) { - QuantityValue value = (QuantityValue) inchesofwatercolumn; + double value = (double) inchesofwatercolumn; return new Pressure(value, PressureUnit.InchOfWaterColumn); } @@ -783,7 +780,7 @@ public static Pressure FromInchesOfWaterColumn(QuantityValue inchesofwatercolumn /// If value is NaN or Infinity. public static Pressure FromKilobars(QuantityValue kilobars) { - QuantityValue value = (QuantityValue) kilobars; + double value = (double) kilobars; return new Pressure(value, PressureUnit.Kilobar); } @@ -793,7 +790,7 @@ public static Pressure FromKilobars(QuantityValue kilobars) /// If value is NaN or Infinity. public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue kilogramsforcepersquarecentimeter) { - QuantityValue value = (QuantityValue) kilogramsforcepersquarecentimeter; + double value = (double) kilogramsforcepersquarecentimeter; return new Pressure(value, PressureUnit.KilogramForcePerSquareCentimeter); } @@ -803,7 +800,7 @@ public static Pressure FromKilogramsForcePerSquareCentimeter(QuantityValue kilog /// If value is NaN or Infinity. public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue kilogramsforcepersquaremeter) { - QuantityValue value = (QuantityValue) kilogramsforcepersquaremeter; + double value = (double) kilogramsforcepersquaremeter; return new Pressure(value, PressureUnit.KilogramForcePerSquareMeter); } @@ -813,7 +810,7 @@ public static Pressure FromKilogramsForcePerSquareMeter(QuantityValue kilogramsf /// If value is NaN or Infinity. public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue kilogramsforcepersquaremillimeter) { - QuantityValue value = (QuantityValue) kilogramsforcepersquaremillimeter; + double value = (double) kilogramsforcepersquaremillimeter; return new Pressure(value, PressureUnit.KilogramForcePerSquareMillimeter); } @@ -823,7 +820,7 @@ public static Pressure FromKilogramsForcePerSquareMillimeter(QuantityValue kilog /// If value is NaN or Infinity. public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue kilonewtonspersquarecentimeter) { - QuantityValue value = (QuantityValue) kilonewtonspersquarecentimeter; + double value = (double) kilonewtonspersquarecentimeter; return new Pressure(value, PressureUnit.KilonewtonPerSquareCentimeter); } @@ -833,7 +830,7 @@ public static Pressure FromKilonewtonsPerSquareCentimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue kilonewtonspersquaremeter) { - QuantityValue value = (QuantityValue) kilonewtonspersquaremeter; + double value = (double) kilonewtonspersquaremeter; return new Pressure(value, PressureUnit.KilonewtonPerSquareMeter); } @@ -843,7 +840,7 @@ public static Pressure FromKilonewtonsPerSquareMeter(QuantityValue kilonewtonspe /// If value is NaN or Infinity. public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue kilonewtonspersquaremillimeter) { - QuantityValue value = (QuantityValue) kilonewtonspersquaremillimeter; + double value = (double) kilonewtonspersquaremillimeter; return new Pressure(value, PressureUnit.KilonewtonPerSquareMillimeter); } @@ -853,7 +850,7 @@ public static Pressure FromKilonewtonsPerSquareMillimeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static Pressure FromKilopascals(QuantityValue kilopascals) { - QuantityValue value = (QuantityValue) kilopascals; + double value = (double) kilopascals; return new Pressure(value, PressureUnit.Kilopascal); } @@ -863,7 +860,7 @@ public static Pressure FromKilopascals(QuantityValue kilopascals) /// If value is NaN or Infinity. public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue kilopoundsforcepersquarefoot) { - QuantityValue value = (QuantityValue) kilopoundsforcepersquarefoot; + double value = (double) kilopoundsforcepersquarefoot; return new Pressure(value, PressureUnit.KilopoundForcePerSquareFoot); } @@ -873,7 +870,7 @@ public static Pressure FromKilopoundsForcePerSquareFoot(QuantityValue kilopounds /// If value is NaN or Infinity. public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue kilopoundsforcepersquareinch) { - QuantityValue value = (QuantityValue) kilopoundsforcepersquareinch; + double value = (double) kilopoundsforcepersquareinch; return new Pressure(value, PressureUnit.KilopoundForcePerSquareInch); } @@ -883,7 +880,7 @@ public static Pressure FromKilopoundsForcePerSquareInch(QuantityValue kilopounds /// If value is NaN or Infinity. public static Pressure FromKilopoundsForcePerSquareMil(QuantityValue kilopoundsforcepersquaremil) { - QuantityValue value = (QuantityValue) kilopoundsforcepersquaremil; + double value = (double) kilopoundsforcepersquaremil; return new Pressure(value, PressureUnit.KilopoundForcePerSquareMil); } @@ -893,7 +890,7 @@ public static Pressure FromKilopoundsForcePerSquareMil(QuantityValue kilopoundsf /// If value is NaN or Infinity. public static Pressure FromMegabars(QuantityValue megabars) { - QuantityValue value = (QuantityValue) megabars; + double value = (double) megabars; return new Pressure(value, PressureUnit.Megabar); } @@ -903,7 +900,7 @@ public static Pressure FromMegabars(QuantityValue megabars) /// If value is NaN or Infinity. public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue meganewtonspersquaremeter) { - QuantityValue value = (QuantityValue) meganewtonspersquaremeter; + double value = (double) meganewtonspersquaremeter; return new Pressure(value, PressureUnit.MeganewtonPerSquareMeter); } @@ -913,7 +910,7 @@ public static Pressure FromMeganewtonsPerSquareMeter(QuantityValue meganewtonspe /// If value is NaN or Infinity. public static Pressure FromMegapascals(QuantityValue megapascals) { - QuantityValue value = (QuantityValue) megapascals; + double value = (double) megapascals; return new Pressure(value, PressureUnit.Megapascal); } @@ -923,7 +920,7 @@ public static Pressure FromMegapascals(QuantityValue megapascals) /// If value is NaN or Infinity. public static Pressure FromMetersOfElevation(QuantityValue metersofelevation) { - QuantityValue value = (QuantityValue) metersofelevation; + double value = (double) metersofelevation; return new Pressure(value, PressureUnit.MeterOfElevation); } @@ -933,7 +930,7 @@ public static Pressure FromMetersOfElevation(QuantityValue metersofelevation) /// If value is NaN or Infinity. public static Pressure FromMetersOfHead(QuantityValue metersofhead) { - QuantityValue value = (QuantityValue) metersofhead; + double value = (double) metersofhead; return new Pressure(value, PressureUnit.MeterOfHead); } @@ -943,7 +940,7 @@ public static Pressure FromMetersOfHead(QuantityValue metersofhead) /// If value is NaN or Infinity. public static Pressure FromMicrobars(QuantityValue microbars) { - QuantityValue value = (QuantityValue) microbars; + double value = (double) microbars; return new Pressure(value, PressureUnit.Microbar); } @@ -953,7 +950,7 @@ public static Pressure FromMicrobars(QuantityValue microbars) /// If value is NaN or Infinity. public static Pressure FromMicropascals(QuantityValue micropascals) { - QuantityValue value = (QuantityValue) micropascals; + double value = (double) micropascals; return new Pressure(value, PressureUnit.Micropascal); } @@ -963,7 +960,7 @@ public static Pressure FromMicropascals(QuantityValue micropascals) /// If value is NaN or Infinity. public static Pressure FromMillibars(QuantityValue millibars) { - QuantityValue value = (QuantityValue) millibars; + double value = (double) millibars; return new Pressure(value, PressureUnit.Millibar); } @@ -973,7 +970,7 @@ public static Pressure FromMillibars(QuantityValue millibars) /// If value is NaN or Infinity. public static Pressure FromMillimetersOfMercury(QuantityValue millimetersofmercury) { - QuantityValue value = (QuantityValue) millimetersofmercury; + double value = (double) millimetersofmercury; return new Pressure(value, PressureUnit.MillimeterOfMercury); } @@ -983,7 +980,7 @@ public static Pressure FromMillimetersOfMercury(QuantityValue millimetersofmercu /// If value is NaN or Infinity. public static Pressure FromMillimeterOfWaterColumn(QuantityValue millimeterofwatercolumn) { - QuantityValue value = (QuantityValue) millimeterofwatercolumn; + double value = (double) millimeterofwatercolumn; return new Pressure(value, PressureUnit.MillimeterOfWaterColumn); } @@ -993,7 +990,7 @@ public static Pressure FromMillimeterOfWaterColumn(QuantityValue millimeterofwat /// If value is NaN or Infinity. public static Pressure FromMillipascals(QuantityValue millipascals) { - QuantityValue value = (QuantityValue) millipascals; + double value = (double) millipascals; return new Pressure(value, PressureUnit.Millipascal); } @@ -1003,7 +1000,7 @@ public static Pressure FromMillipascals(QuantityValue millipascals) /// If value is NaN or Infinity. public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue newtonspersquarecentimeter) { - QuantityValue value = (QuantityValue) newtonspersquarecentimeter; + double value = (double) newtonspersquarecentimeter; return new Pressure(value, PressureUnit.NewtonPerSquareCentimeter); } @@ -1013,7 +1010,7 @@ public static Pressure FromNewtonsPerSquareCentimeter(QuantityValue newtonspersq /// If value is NaN or Infinity. public static Pressure FromNewtonsPerSquareMeter(QuantityValue newtonspersquaremeter) { - QuantityValue value = (QuantityValue) newtonspersquaremeter; + double value = (double) newtonspersquaremeter; return new Pressure(value, PressureUnit.NewtonPerSquareMeter); } @@ -1023,7 +1020,7 @@ public static Pressure FromNewtonsPerSquareMeter(QuantityValue newtonspersquarem /// If value is NaN or Infinity. public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue newtonspersquaremillimeter) { - QuantityValue value = (QuantityValue) newtonspersquaremillimeter; + double value = (double) newtonspersquaremillimeter; return new Pressure(value, PressureUnit.NewtonPerSquareMillimeter); } @@ -1033,7 +1030,7 @@ public static Pressure FromNewtonsPerSquareMillimeter(QuantityValue newtonspersq /// If value is NaN or Infinity. public static Pressure FromPascals(QuantityValue pascals) { - QuantityValue value = (QuantityValue) pascals; + double value = (double) pascals; return new Pressure(value, PressureUnit.Pascal); } @@ -1043,7 +1040,7 @@ public static Pressure FromPascals(QuantityValue pascals) /// If value is NaN or Infinity. public static Pressure FromPoundsForcePerSquareFoot(QuantityValue poundsforcepersquarefoot) { - QuantityValue value = (QuantityValue) poundsforcepersquarefoot; + double value = (double) poundsforcepersquarefoot; return new Pressure(value, PressureUnit.PoundForcePerSquareFoot); } @@ -1053,7 +1050,7 @@ public static Pressure FromPoundsForcePerSquareFoot(QuantityValue poundsforceper /// If value is NaN or Infinity. public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforcepersquareinch) { - QuantityValue value = (QuantityValue) poundsforcepersquareinch; + double value = (double) poundsforcepersquareinch; return new Pressure(value, PressureUnit.PoundForcePerSquareInch); } @@ -1063,7 +1060,7 @@ public static Pressure FromPoundsForcePerSquareInch(QuantityValue poundsforceper /// If value is NaN or Infinity. public static Pressure FromPoundsForcePerSquareMil(QuantityValue poundsforcepersquaremil) { - QuantityValue value = (QuantityValue) poundsforcepersquaremil; + double value = (double) poundsforcepersquaremil; return new Pressure(value, PressureUnit.PoundForcePerSquareMil); } @@ -1073,7 +1070,7 @@ public static Pressure FromPoundsForcePerSquareMil(QuantityValue poundsforcepers /// If value is NaN or Infinity. public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinchsecondsquared) { - QuantityValue value = (QuantityValue) poundsperinchsecondsquared; + double value = (double) poundsperinchsecondsquared; return new Pressure(value, PressureUnit.PoundPerInchSecondSquared); } @@ -1083,7 +1080,7 @@ public static Pressure FromPoundsPerInchSecondSquared(QuantityValue poundsperinc /// If value is NaN or Infinity. public static Pressure FromTechnicalAtmospheres(QuantityValue technicalatmospheres) { - QuantityValue value = (QuantityValue) technicalatmospheres; + double value = (double) technicalatmospheres; return new Pressure(value, PressureUnit.TechnicalAtmosphere); } @@ -1093,7 +1090,7 @@ public static Pressure FromTechnicalAtmospheres(QuantityValue technicalatmospher /// If value is NaN or Infinity. public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue tonnesforcepersquarecentimeter) { - QuantityValue value = (QuantityValue) tonnesforcepersquarecentimeter; + double value = (double) tonnesforcepersquarecentimeter; return new Pressure(value, PressureUnit.TonneForcePerSquareCentimeter); } @@ -1103,7 +1100,7 @@ public static Pressure FromTonnesForcePerSquareCentimeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static Pressure FromTonnesForcePerSquareMeter(QuantityValue tonnesforcepersquaremeter) { - QuantityValue value = (QuantityValue) tonnesforcepersquaremeter; + double value = (double) tonnesforcepersquaremeter; return new Pressure(value, PressureUnit.TonneForcePerSquareMeter); } @@ -1113,7 +1110,7 @@ public static Pressure FromTonnesForcePerSquareMeter(QuantityValue tonnesforcepe /// If value is NaN or Infinity. public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue tonnesforcepersquaremillimeter) { - QuantityValue value = (QuantityValue) tonnesforcepersquaremillimeter; + double value = (double) tonnesforcepersquaremillimeter; return new Pressure(value, PressureUnit.TonneForcePerSquareMillimeter); } @@ -1123,7 +1120,7 @@ public static Pressure FromTonnesForcePerSquareMillimeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static Pressure FromTorrs(QuantityValue torrs) { - QuantityValue value = (QuantityValue) torrs; + double value = (double) torrs; return new Pressure(value, PressureUnit.Torr); } @@ -1135,7 +1132,7 @@ public static Pressure FromTorrs(QuantityValue torrs) /// Pressure unit value. public static Pressure From(QuantityValue value, PressureUnit fromUnit) { - return new Pressure((QuantityValue)value, fromUnit); + return new Pressure((double)value, fromUnit); } #endregion @@ -1305,25 +1302,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press } /// Get from multiplying value and . - public static Pressure operator *(QuantityValue left, Pressure right) + public static Pressure operator *(double left, Pressure right) { return new Pressure(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Pressure operator *(Pressure left, QuantityValue right) + public static Pressure operator *(Pressure left, double right) { return new Pressure(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Pressure operator /(Pressure left, QuantityValue right) + public static Pressure operator /(Pressure left, double right) { return new Pressure(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Pressure left, Pressure right) + public static double operator /(Pressure left, Pressure right) { return left.Pascals / right.Pascals; } @@ -1356,19 +1353,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Pressure left, Pressure right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Pressure left, Pressure right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1381,29 +1365,7 @@ public int CompareTo(object obj) /// public int CompareTo(Pressure other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Pressure objPressure)) - return false; - return Equals(objPressure); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Pressure other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1446,13 +1408,13 @@ public bool Equals(Pressure other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Pressure other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Pressure other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1463,7 +1425,7 @@ public bool Equals(Pressure other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current Pressure. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1474,16 +1436,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PressureUnit unit) + public double As(PressureUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1498,12 +1461,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PressureUnit typedUnit)) + if (!(unit is PressureUnit unitAsPressureUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPressureUnit); } /// @@ -1535,7 +1498,7 @@ public Pressure ToUnit(PressureUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Pressure)converted; } - else if (Enum.IsDefined(typeof(PressureUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1543,17 +1506,17 @@ public Pressure ToUnit(PressureUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureUnit typedUnit)) + if (!(unit is PressureUnit unitAsPressureUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPressureUnit, DefaultConversionFunctions); } /// @@ -1580,10 +1543,10 @@ public Pressure ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PressureUnit unit) + private double GetValueAs(PressureUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 06d14aeaa6..7ee7d7f344 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Pressure change rate is the ratio of the pressure change to the time during which the change occurred (value of pressure changes per unit time). /// [DataContract] - public partial struct PressureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct PressureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static PressureChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public PressureChangeRate(QuantityValue value, PressureChangeRateUnit unit) + public PressureChangeRate(double value, PressureChangeRateUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -99,14 +99,14 @@ public PressureChangeRate(QuantityValue value, PressureChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public PressureChangeRate(QuantityValue value, UnitSystem unitSystem) + public PressureChangeRate(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,10 +147,7 @@ public PressureChangeRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -173,74 +170,74 @@ public PressureChangeRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); + public double AtmospheresPerSecond => As(PressureChangeRateUnit.AtmospherePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); + public double KilopascalsPerMinute => As(PressureChangeRateUnit.KilopascalPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); + public double KilopascalsPerSecond => As(PressureChangeRateUnit.KilopascalPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); + public double KilopoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); + public double KilopoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); + public double MegapascalsPerMinute => As(PressureChangeRateUnit.MegapascalPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); + public double MegapascalsPerSecond => As(PressureChangeRateUnit.MegapascalPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); + public double MegapoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); + public double MegapoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersOfMercuryPerSecond => As(PressureChangeRateUnit.MillimeterOfMercuryPerSecond); + public double MillimetersOfMercuryPerSecond => As(PressureChangeRateUnit.MillimeterOfMercuryPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); + public double PascalsPerMinute => As(PressureChangeRateUnit.PascalPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); + public double PascalsPerSecond => As(PressureChangeRateUnit.PascalPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); + public double PoundsForcePerSquareInchPerMinute => As(PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); + public double PoundsForcePerSquareInchPerSecond => As(PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); #endregion @@ -349,7 +346,7 @@ public static string GetAbbreviation(PressureChangeRateUnit unit, IFormatProvide /// If value is NaN or Infinity. public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue atmospherespersecond) { - QuantityValue value = (QuantityValue) atmospherespersecond; + double value = (double) atmospherespersecond; return new PressureChangeRate(value, PressureChangeRateUnit.AtmospherePerSecond); } @@ -359,7 +356,7 @@ public static PressureChangeRate FromAtmospheresPerSecond(QuantityValue atmosphe /// If value is NaN or Infinity. public static PressureChangeRate FromKilopascalsPerMinute(QuantityValue kilopascalsperminute) { - QuantityValue value = (QuantityValue) kilopascalsperminute; + double value = (double) kilopascalsperminute; return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerMinute); } @@ -369,7 +366,7 @@ public static PressureChangeRate FromKilopascalsPerMinute(QuantityValue kilopasc /// If value is NaN or Infinity. public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue kilopascalspersecond) { - QuantityValue value = (QuantityValue) kilopascalspersecond; + double value = (double) kilopascalspersecond; return new PressureChangeRate(value, PressureChangeRateUnit.KilopascalPerSecond); } @@ -379,7 +376,7 @@ public static PressureChangeRate FromKilopascalsPerSecond(QuantityValue kilopasc /// If value is NaN or Infinity. public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(QuantityValue kilopoundsforcepersquareinchperminute) { - QuantityValue value = (QuantityValue) kilopoundsforcepersquareinchperminute; + double value = (double) kilopoundsforcepersquareinchperminute; return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerMinute); } @@ -389,7 +386,7 @@ public static PressureChangeRate FromKilopoundsForcePerSquareInchPerMinute(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(QuantityValue kilopoundsforcepersquareinchpersecond) { - QuantityValue value = (QuantityValue) kilopoundsforcepersquareinchpersecond; + double value = (double) kilopoundsforcepersquareinchpersecond; return new PressureChangeRate(value, PressureChangeRateUnit.KilopoundForcePerSquareInchPerSecond); } @@ -399,7 +396,7 @@ public static PressureChangeRate FromKilopoundsForcePerSquareInchPerSecond(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromMegapascalsPerMinute(QuantityValue megapascalsperminute) { - QuantityValue value = (QuantityValue) megapascalsperminute; + double value = (double) megapascalsperminute; return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerMinute); } @@ -409,7 +406,7 @@ public static PressureChangeRate FromMegapascalsPerMinute(QuantityValue megapasc /// If value is NaN or Infinity. public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue megapascalspersecond) { - QuantityValue value = (QuantityValue) megapascalspersecond; + double value = (double) megapascalspersecond; return new PressureChangeRate(value, PressureChangeRateUnit.MegapascalPerSecond); } @@ -419,7 +416,7 @@ public static PressureChangeRate FromMegapascalsPerSecond(QuantityValue megapasc /// If value is NaN or Infinity. public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(QuantityValue megapoundsforcepersquareinchperminute) { - QuantityValue value = (QuantityValue) megapoundsforcepersquareinchperminute; + double value = (double) megapoundsforcepersquareinchperminute; return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerMinute); } @@ -429,7 +426,7 @@ public static PressureChangeRate FromMegapoundsForcePerSquareInchPerMinute(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(QuantityValue megapoundsforcepersquareinchpersecond) { - QuantityValue value = (QuantityValue) megapoundsforcepersquareinchpersecond; + double value = (double) megapoundsforcepersquareinchpersecond; return new PressureChangeRate(value, PressureChangeRateUnit.MegapoundForcePerSquareInchPerSecond); } @@ -439,7 +436,7 @@ public static PressureChangeRate FromMegapoundsForcePerSquareInchPerSecond(Quant /// If value is NaN or Infinity. public static PressureChangeRate FromMillimetersOfMercuryPerSecond(QuantityValue millimetersofmercurypersecond) { - QuantityValue value = (QuantityValue) millimetersofmercurypersecond; + double value = (double) millimetersofmercurypersecond; return new PressureChangeRate(value, PressureChangeRateUnit.MillimeterOfMercuryPerSecond); } @@ -449,7 +446,7 @@ public static PressureChangeRate FromMillimetersOfMercuryPerSecond(QuantityValue /// If value is NaN or Infinity. public static PressureChangeRate FromPascalsPerMinute(QuantityValue pascalsperminute) { - QuantityValue value = (QuantityValue) pascalsperminute; + double value = (double) pascalsperminute; return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerMinute); } @@ -459,7 +456,7 @@ public static PressureChangeRate FromPascalsPerMinute(QuantityValue pascalspermi /// If value is NaN or Infinity. public static PressureChangeRate FromPascalsPerSecond(QuantityValue pascalspersecond) { - QuantityValue value = (QuantityValue) pascalspersecond; + double value = (double) pascalspersecond; return new PressureChangeRate(value, PressureChangeRateUnit.PascalPerSecond); } @@ -469,7 +466,7 @@ public static PressureChangeRate FromPascalsPerSecond(QuantityValue pascalsperse /// If value is NaN or Infinity. public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(QuantityValue poundsforcepersquareinchperminute) { - QuantityValue value = (QuantityValue) poundsforcepersquareinchperminute; + double value = (double) poundsforcepersquareinchperminute; return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerMinute); } @@ -479,7 +476,7 @@ public static PressureChangeRate FromPoundsForcePerSquareInchPerMinute(QuantityV /// If value is NaN or Infinity. public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(QuantityValue poundsforcepersquareinchpersecond) { - QuantityValue value = (QuantityValue) poundsforcepersquareinchpersecond; + double value = (double) poundsforcepersquareinchpersecond; return new PressureChangeRate(value, PressureChangeRateUnit.PoundForcePerSquareInchPerSecond); } @@ -491,7 +488,7 @@ public static PressureChangeRate FromPoundsForcePerSquareInchPerSecond(QuantityV /// PressureChangeRate unit value. public static PressureChangeRate From(QuantityValue value, PressureChangeRateUnit fromUnit) { - return new PressureChangeRate((QuantityValue)value, fromUnit); + return new PressureChangeRate((double)value, fromUnit); } #endregion @@ -661,25 +658,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press } /// Get from multiplying value and . - public static PressureChangeRate operator *(QuantityValue left, PressureChangeRate right) + public static PressureChangeRate operator *(double left, PressureChangeRate right) { return new PressureChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static PressureChangeRate operator *(PressureChangeRate left, QuantityValue right) + public static PressureChangeRate operator *(PressureChangeRate left, double right) { return new PressureChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static PressureChangeRate operator /(PressureChangeRate left, QuantityValue right) + public static PressureChangeRate operator /(PressureChangeRate left, double right) { return new PressureChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(PressureChangeRate left, PressureChangeRate right) + public static double operator /(PressureChangeRate left, PressureChangeRate right) { return left.PascalsPerSecond / right.PascalsPerSecond; } @@ -712,19 +709,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Press return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(PressureChangeRate left, PressureChangeRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(PressureChangeRate left, PressureChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -737,29 +721,7 @@ public int CompareTo(object obj) /// public int CompareTo(PressureChangeRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is PressureChangeRate objPressureChangeRate)) - return false; - return Equals(objPressureChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(PressureChangeRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -802,13 +764,13 @@ public bool Equals(PressureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(PressureChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(PressureChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -819,7 +781,7 @@ public bool Equals(PressureChangeRate other, QuantityValue tolerance, Comparison /// A hash code for the current PressureChangeRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -830,16 +792,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(PressureChangeRateUnit unit) + public double As(PressureChangeRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -854,12 +817,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is PressureChangeRateUnit typedUnit)) + if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsPressureChangeRateUnit); } /// @@ -891,7 +854,7 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit, UnitConverter unit var converted = conversionFunction(this); return (PressureChangeRate)converted; } - else if (Enum.IsDefined(typeof(PressureChangeRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -899,17 +862,17 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureChangeRateUnit typedUnit)) + if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsPressureChangeRateUnit, DefaultConversionFunctions); } /// @@ -936,10 +899,10 @@ public PressureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(PressureChangeRateUnit unit) + private double GetValueAs(PressureChangeRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 5cd1baf2d0..4477fbdf39 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In mathematics, a ratio is a relationship between two numbers of the same kind (e.g., objects, persons, students, spoonfuls, units of whatever identical dimension), usually expressed as "a to b" or a:b, sometimes expressed arithmetically as a dimensionless quotient of the two that explicitly indicates how many times the first number contains the second (not necessarily an integer). /// [DataContract] - public partial struct Ratio : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Ratio : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static Ratio() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Ratio(QuantityValue value, RatioUnit unit) + public Ratio(double value, RatioUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public Ratio(QuantityValue value, RatioUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Ratio(QuantityValue value, UnitSystem unitSystem) + public Ratio(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public Ratio(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,34 +162,34 @@ public Ratio(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimalFractions => As(RatioUnit.DecimalFraction); + public double DecimalFractions => As(RatioUnit.DecimalFraction); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerBillion => As(RatioUnit.PartPerBillion); + public double PartsPerBillion => As(RatioUnit.PartPerBillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerMillion => As(RatioUnit.PartPerMillion); + public double PartsPerMillion => As(RatioUnit.PartPerMillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerThousand => As(RatioUnit.PartPerThousand); + public double PartsPerThousand => As(RatioUnit.PartPerThousand); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerTrillion => As(RatioUnit.PartPerTrillion); + public double PartsPerTrillion => As(RatioUnit.PartPerTrillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Percent => As(RatioUnit.Percent); + public double Percent => As(RatioUnit.Percent); #endregion @@ -263,7 +260,7 @@ public static string GetAbbreviation(RatioUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Ratio FromDecimalFractions(QuantityValue decimalfractions) { - QuantityValue value = (QuantityValue) decimalfractions; + double value = (double) decimalfractions; return new Ratio(value, RatioUnit.DecimalFraction); } @@ -273,7 +270,7 @@ public static Ratio FromDecimalFractions(QuantityValue decimalfractions) /// If value is NaN or Infinity. public static Ratio FromPartsPerBillion(QuantityValue partsperbillion) { - QuantityValue value = (QuantityValue) partsperbillion; + double value = (double) partsperbillion; return new Ratio(value, RatioUnit.PartPerBillion); } @@ -283,7 +280,7 @@ public static Ratio FromPartsPerBillion(QuantityValue partsperbillion) /// If value is NaN or Infinity. public static Ratio FromPartsPerMillion(QuantityValue partspermillion) { - QuantityValue value = (QuantityValue) partspermillion; + double value = (double) partspermillion; return new Ratio(value, RatioUnit.PartPerMillion); } @@ -293,7 +290,7 @@ public static Ratio FromPartsPerMillion(QuantityValue partspermillion) /// If value is NaN or Infinity. public static Ratio FromPartsPerThousand(QuantityValue partsperthousand) { - QuantityValue value = (QuantityValue) partsperthousand; + double value = (double) partsperthousand; return new Ratio(value, RatioUnit.PartPerThousand); } @@ -303,7 +300,7 @@ public static Ratio FromPartsPerThousand(QuantityValue partsperthousand) /// If value is NaN or Infinity. public static Ratio FromPartsPerTrillion(QuantityValue partspertrillion) { - QuantityValue value = (QuantityValue) partspertrillion; + double value = (double) partspertrillion; return new Ratio(value, RatioUnit.PartPerTrillion); } @@ -313,7 +310,7 @@ public static Ratio FromPartsPerTrillion(QuantityValue partspertrillion) /// If value is NaN or Infinity. public static Ratio FromPercent(QuantityValue percent) { - QuantityValue value = (QuantityValue) percent; + double value = (double) percent; return new Ratio(value, RatioUnit.Percent); } @@ -325,7 +322,7 @@ public static Ratio FromPercent(QuantityValue percent) /// Ratio unit value. public static Ratio From(QuantityValue value, RatioUnit fromUnit) { - return new Ratio((QuantityValue)value, fromUnit); + return new Ratio((double)value, fromUnit); } #endregion @@ -495,25 +492,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio } /// Get from multiplying value and . - public static Ratio operator *(QuantityValue left, Ratio right) + public static Ratio operator *(double left, Ratio right) { return new Ratio(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Ratio operator *(Ratio left, QuantityValue right) + public static Ratio operator *(Ratio left, double right) { return new Ratio(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Ratio operator /(Ratio left, QuantityValue right) + public static Ratio operator /(Ratio left, double right) { return new Ratio(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Ratio left, Ratio right) + public static double operator /(Ratio left, Ratio right) { return left.DecimalFractions / right.DecimalFractions; } @@ -546,19 +543,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Ratio left, Ratio right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Ratio left, Ratio right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -571,29 +555,7 @@ public int CompareTo(object obj) /// public int CompareTo(Ratio other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Ratio objRatio)) - return false; - return Equals(objRatio); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Ratio other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -636,13 +598,13 @@ public bool Equals(Ratio other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Ratio other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -653,7 +615,7 @@ public bool Equals(Ratio other, QuantityValue tolerance, ComparisonType comparis /// A hash code for the current Ratio. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -664,16 +626,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RatioUnit unit) + public double As(RatioUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -688,12 +651,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RatioUnit typedUnit)) + if (!(unit is RatioUnit unitAsRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRatioUnit); } /// @@ -725,7 +688,7 @@ public Ratio ToUnit(RatioUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Ratio)converted; } - else if (Enum.IsDefined(typeof(RatioUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -733,17 +696,17 @@ public Ratio ToUnit(RatioUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioUnit typedUnit)) + if (!(unit is RatioUnit unitAsRatioUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRatioUnit, DefaultConversionFunctions); } /// @@ -770,10 +733,10 @@ public Ratio ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RatioUnit unit) + private double GetValueAs(RatioUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 55d191ea6c..9a19832e06 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The change in ratio per unit of time. /// [DataContract] - public partial struct RatioChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RatioChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static RatioChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RatioChangeRate(QuantityValue value, RatioChangeRateUnit unit) + public RatioChangeRate(double value, RatioChangeRateUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -87,14 +87,14 @@ public RatioChangeRate(QuantityValue value, RatioChangeRateUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RatioChangeRate(QuantityValue value, UnitSystem unitSystem) + public RatioChangeRate(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,10 +135,7 @@ public RatioChangeRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -161,14 +158,14 @@ public RatioChangeRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); + public double DecimalFractionsPerSecond => As(RatioChangeRateUnit.DecimalFractionPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); + public double PercentsPerSecond => As(RatioChangeRateUnit.PercentPerSecond); #endregion @@ -227,7 +224,7 @@ public static string GetAbbreviation(RatioChangeRateUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static RatioChangeRate FromDecimalFractionsPerSecond(QuantityValue decimalfractionspersecond) { - QuantityValue value = (QuantityValue) decimalfractionspersecond; + double value = (double) decimalfractionspersecond; return new RatioChangeRate(value, RatioChangeRateUnit.DecimalFractionPerSecond); } @@ -237,7 +234,7 @@ public static RatioChangeRate FromDecimalFractionsPerSecond(QuantityValue decima /// If value is NaN or Infinity. public static RatioChangeRate FromPercentsPerSecond(QuantityValue percentspersecond) { - QuantityValue value = (QuantityValue) percentspersecond; + double value = (double) percentspersecond; return new RatioChangeRate(value, RatioChangeRateUnit.PercentPerSecond); } @@ -249,7 +246,7 @@ public static RatioChangeRate FromPercentsPerSecond(QuantityValue percentspersec /// RatioChangeRate unit value. public static RatioChangeRate From(QuantityValue value, RatioChangeRateUnit fromUnit) { - return new RatioChangeRate((QuantityValue)value, fromUnit); + return new RatioChangeRate((double)value, fromUnit); } #endregion @@ -419,25 +416,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio } /// Get from multiplying value and . - public static RatioChangeRate operator *(QuantityValue left, RatioChangeRate right) + public static RatioChangeRate operator *(double left, RatioChangeRate right) { return new RatioChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RatioChangeRate operator *(RatioChangeRate left, QuantityValue right) + public static RatioChangeRate operator *(RatioChangeRate left, double right) { return new RatioChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RatioChangeRate operator /(RatioChangeRate left, QuantityValue right) + public static RatioChangeRate operator /(RatioChangeRate left, double right) { return new RatioChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(RatioChangeRate left, RatioChangeRate right) + public static double operator /(RatioChangeRate left, RatioChangeRate right) { return left.DecimalFractionsPerSecond / right.DecimalFractionsPerSecond; } @@ -470,19 +467,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Ratio return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RatioChangeRate left, RatioChangeRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RatioChangeRate left, RatioChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,29 +479,7 @@ public int CompareTo(object obj) /// public int CompareTo(RatioChangeRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is RatioChangeRate objRatioChangeRate)) - return false; - return Equals(objRatioChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RatioChangeRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -560,13 +522,13 @@ public bool Equals(RatioChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RatioChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(RatioChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +539,7 @@ public bool Equals(RatioChangeRate other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current RatioChangeRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -588,16 +550,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RatioChangeRateUnit unit) + public double As(RatioChangeRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -612,12 +575,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RatioChangeRateUnit typedUnit)) + if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRatioChangeRateUnit); } /// @@ -649,7 +612,7 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (RatioChangeRate)converted; } - else if (Enum.IsDefined(typeof(RatioChangeRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -657,17 +620,17 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioChangeRateUnit typedUnit)) + if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRatioChangeRateUnit, DefaultConversionFunctions); } /// @@ -694,10 +657,10 @@ public RatioChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RatioChangeRateUnit unit) + private double GetValueAs(RatioChangeRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index bcb82d37ff..b46c2e5303 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The Volt-ampere reactive hour (expressed as varh) is the reactive power of one Volt-ampere reactive produced in one hour. /// [DataContract] - public partial struct ReactiveEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactiveEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static ReactiveEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReactiveEnergy(QuantityValue value, ReactiveEnergyUnit unit) + public ReactiveEnergy(double value, ReactiveEnergyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public ReactiveEnergy(QuantityValue value, ReactiveEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactiveEnergy(QuantityValue value, UnitSystem unitSystem) + public ReactiveEnergy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public ReactiveEnergy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public ReactiveEnergy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); + public double KilovoltampereReactiveHours => As(ReactiveEnergyUnit.KilovoltampereReactiveHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); + public double MegavoltampereReactiveHours => As(ReactiveEnergyUnit.MegavoltampereReactiveHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); + public double VoltampereReactiveHours => As(ReactiveEnergyUnit.VoltampereReactiveHour); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(ReactiveEnergyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue kilovoltamperereactivehours) { - QuantityValue value = (QuantityValue) kilovoltamperereactivehours; + double value = (double) kilovoltamperereactivehours; return new ReactiveEnergy(value, ReactiveEnergyUnit.KilovoltampereReactiveHour); } @@ -246,7 +243,7 @@ public static ReactiveEnergy FromKilovoltampereReactiveHours(QuantityValue kilov /// If value is NaN or Infinity. public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue megavoltamperereactivehours) { - QuantityValue value = (QuantityValue) megavoltamperereactivehours; + double value = (double) megavoltamperereactivehours; return new ReactiveEnergy(value, ReactiveEnergyUnit.MegavoltampereReactiveHour); } @@ -256,7 +253,7 @@ public static ReactiveEnergy FromMegavoltampereReactiveHours(QuantityValue megav /// If value is NaN or Infinity. public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue voltamperereactivehours) { - QuantityValue value = (QuantityValue) voltamperereactivehours; + double value = (double) voltamperereactivehours; return new ReactiveEnergy(value, ReactiveEnergyUnit.VoltampereReactiveHour); } @@ -268,7 +265,7 @@ public static ReactiveEnergy FromVoltampereReactiveHours(QuantityValue voltamper /// ReactiveEnergy unit value. public static ReactiveEnergy From(QuantityValue value, ReactiveEnergyUnit fromUnit) { - return new ReactiveEnergy((QuantityValue)value, fromUnit); + return new ReactiveEnergy((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React } /// Get from multiplying value and . - public static ReactiveEnergy operator *(QuantityValue left, ReactiveEnergy right) + public static ReactiveEnergy operator *(double left, ReactiveEnergy right) { return new ReactiveEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReactiveEnergy operator *(ReactiveEnergy left, QuantityValue right) + public static ReactiveEnergy operator *(ReactiveEnergy left, double right) { return new ReactiveEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReactiveEnergy operator /(ReactiveEnergy left, QuantityValue right) + public static ReactiveEnergy operator /(ReactiveEnergy left, double right) { return new ReactiveEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ReactiveEnergy left, ReactiveEnergy right) + public static double operator /(ReactiveEnergy left, ReactiveEnergy right) { return left.VoltampereReactiveHours / right.VoltampereReactiveHours; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactiveEnergy left, ReactiveEnergy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactiveEnergy left, ReactiveEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(ReactiveEnergy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ReactiveEnergy objReactiveEnergy)) - return false; - return Equals(objReactiveEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactiveEnergy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(ReactiveEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactiveEnergy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(ReactiveEnergy other, QuantityValue tolerance, ComparisonType /// A hash code for the current ReactiveEnergy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ReactiveEnergyUnit unit) + public double As(ReactiveEnergyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ReactiveEnergyUnit typedUnit)) + if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsReactiveEnergyUnit); } /// @@ -668,7 +631,7 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ReactiveEnergy)converted; } - else if (Enum.IsDefined(typeof(ReactiveEnergyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactiveEnergyUnit typedUnit)) + if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsReactiveEnergyUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public ReactiveEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ReactiveEnergyUnit unit) + private double GetValueAs(ReactiveEnergyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 0a4d9cb603..12ba60dcba 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Volt-ampere reactive (var) is a unit by which reactive power is expressed in an AC electric power system. Reactive power exists in an AC circuit when the current and voltage are not in phase. /// [DataContract] - public partial struct ReactivePower : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReactivePower : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static ReactivePower() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReactivePower(QuantityValue value, ReactivePowerUnit unit) + public ReactivePower(double value, ReactivePowerUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public ReactivePower(QuantityValue value, ReactivePowerUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReactivePower(QuantityValue value, UnitSystem unitSystem) + public ReactivePower(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public ReactivePower(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public ReactivePower(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); + public double GigavoltamperesReactive => As(ReactivePowerUnit.GigavoltampereReactive); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); + public double KilovoltamperesReactive => As(ReactivePowerUnit.KilovoltampereReactive); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); + public double MegavoltamperesReactive => As(ReactivePowerUnit.MegavoltampereReactive); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); + public double VoltamperesReactive => As(ReactivePowerUnit.VoltampereReactive); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(ReactivePowerUnit unit, IFormatProvider? pr /// If value is NaN or Infinity. public static ReactivePower FromGigavoltamperesReactive(QuantityValue gigavoltamperesreactive) { - QuantityValue value = (QuantityValue) gigavoltamperesreactive; + double value = (double) gigavoltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.GigavoltampereReactive); } @@ -255,7 +252,7 @@ public static ReactivePower FromGigavoltamperesReactive(QuantityValue gigavoltam /// If value is NaN or Infinity. public static ReactivePower FromKilovoltamperesReactive(QuantityValue kilovoltamperesreactive) { - QuantityValue value = (QuantityValue) kilovoltamperesreactive; + double value = (double) kilovoltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.KilovoltampereReactive); } @@ -265,7 +262,7 @@ public static ReactivePower FromKilovoltamperesReactive(QuantityValue kilovoltam /// If value is NaN or Infinity. public static ReactivePower FromMegavoltamperesReactive(QuantityValue megavoltamperesreactive) { - QuantityValue value = (QuantityValue) megavoltamperesreactive; + double value = (double) megavoltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.MegavoltampereReactive); } @@ -275,7 +272,7 @@ public static ReactivePower FromMegavoltamperesReactive(QuantityValue megavoltam /// If value is NaN or Infinity. public static ReactivePower FromVoltamperesReactive(QuantityValue voltamperesreactive) { - QuantityValue value = (QuantityValue) voltamperesreactive; + double value = (double) voltamperesreactive; return new ReactivePower(value, ReactivePowerUnit.VoltampereReactive); } @@ -287,7 +284,7 @@ public static ReactivePower FromVoltamperesReactive(QuantityValue voltamperesrea /// ReactivePower unit value. public static ReactivePower From(QuantityValue value, ReactivePowerUnit fromUnit) { - return new ReactivePower((QuantityValue)value, fromUnit); + return new ReactivePower((double)value, fromUnit); } #endregion @@ -457,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React } /// Get from multiplying value and . - public static ReactivePower operator *(QuantityValue left, ReactivePower right) + public static ReactivePower operator *(double left, ReactivePower right) { return new ReactivePower(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReactivePower operator *(ReactivePower left, QuantityValue right) + public static ReactivePower operator *(ReactivePower left, double right) { return new ReactivePower(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReactivePower operator /(ReactivePower left, QuantityValue right) + public static ReactivePower operator /(ReactivePower left, double right) { return new ReactivePower(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ReactivePower left, ReactivePower right) + public static double operator /(ReactivePower left, ReactivePower right) { return left.VoltamperesReactive / right.VoltamperesReactive; } @@ -508,19 +505,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out React return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReactivePower left, ReactivePower right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReactivePower left, ReactivePower right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -533,29 +517,7 @@ public int CompareTo(object obj) /// public int CompareTo(ReactivePower other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ReactivePower objReactivePower)) - return false; - return Equals(objReactivePower); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReactivePower other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -598,13 +560,13 @@ public bool Equals(ReactivePower other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReactivePower other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ReactivePower other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +577,7 @@ public bool Equals(ReactivePower other, QuantityValue tolerance, ComparisonType /// A hash code for the current ReactivePower. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -626,16 +588,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ReactivePowerUnit unit) + public double As(ReactivePowerUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -650,12 +613,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ReactivePowerUnit typedUnit)) + if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsReactivePowerUnit); } /// @@ -687,7 +650,7 @@ public ReactivePower ToUnit(ReactivePowerUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (ReactivePower)converted; } - else if (Enum.IsDefined(typeof(ReactivePowerUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -695,17 +658,17 @@ public ReactivePower ToUnit(ReactivePowerUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactivePowerUnit typedUnit)) + if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsReactivePowerUnit, DefaultConversionFunctions); } /// @@ -732,10 +695,10 @@ public ReactivePower ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ReactivePowerUnit unit) + private double GetValueAs(ReactivePowerUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index f0756bf8c4..fa18c54017 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Inverse-square_law /// [DataContract] - public partial struct ReciprocalArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -85,9 +85,9 @@ static ReciprocalArea() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReciprocalArea(QuantityValue value, ReciprocalAreaUnit unit) + public ReciprocalArea(double value, ReciprocalAreaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -99,14 +99,14 @@ public ReciprocalArea(QuantityValue value, ReciprocalAreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReciprocalArea(QuantityValue value, UnitSystem unitSystem) + public ReciprocalArea(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -147,10 +147,7 @@ public ReciprocalArea(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -173,59 +170,59 @@ public ReciprocalArea(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); + public double InverseSquareCentimeters => As(ReciprocalAreaUnit.InverseSquareCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); + public double InverseSquareDecimeters => As(ReciprocalAreaUnit.InverseSquareDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); + public double InverseSquareFeet => As(ReciprocalAreaUnit.InverseSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); + public double InverseSquareInches => As(ReciprocalAreaUnit.InverseSquareInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); + public double InverseSquareKilometers => As(ReciprocalAreaUnit.InverseSquareKilometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); + public double InverseSquareMeters => As(ReciprocalAreaUnit.InverseSquareMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); + public double InverseSquareMicrometers => As(ReciprocalAreaUnit.InverseSquareMicrometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); + public double InverseSquareMiles => As(ReciprocalAreaUnit.InverseSquareMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); + public double InverseSquareMillimeters => As(ReciprocalAreaUnit.InverseSquareMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); + public double InverseSquareYards => As(ReciprocalAreaUnit.InverseSquareYard); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); + public double InverseUsSurveySquareFeet => As(ReciprocalAreaUnit.InverseUsSurveySquareFoot); #endregion @@ -311,7 +308,7 @@ public static string GetAbbreviation(ReciprocalAreaUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareCentimeters(QuantityValue inversesquarecentimeters) { - QuantityValue value = (QuantityValue) inversesquarecentimeters; + double value = (double) inversesquarecentimeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareCentimeter); } @@ -321,7 +318,7 @@ public static ReciprocalArea FromInverseSquareCentimeters(QuantityValue inverses /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareDecimeters(QuantityValue inversesquaredecimeters) { - QuantityValue value = (QuantityValue) inversesquaredecimeters; + double value = (double) inversesquaredecimeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareDecimeter); } @@ -331,7 +328,7 @@ public static ReciprocalArea FromInverseSquareDecimeters(QuantityValue inversesq /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareFeet(QuantityValue inversesquarefeet) { - QuantityValue value = (QuantityValue) inversesquarefeet; + double value = (double) inversesquarefeet; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareFoot); } @@ -341,7 +338,7 @@ public static ReciprocalArea FromInverseSquareFeet(QuantityValue inversesquarefe /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareInches(QuantityValue inversesquareinches) { - QuantityValue value = (QuantityValue) inversesquareinches; + double value = (double) inversesquareinches; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareInch); } @@ -351,7 +348,7 @@ public static ReciprocalArea FromInverseSquareInches(QuantityValue inversesquare /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareKilometers(QuantityValue inversesquarekilometers) { - QuantityValue value = (QuantityValue) inversesquarekilometers; + double value = (double) inversesquarekilometers; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareKilometer); } @@ -361,7 +358,7 @@ public static ReciprocalArea FromInverseSquareKilometers(QuantityValue inversesq /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMeters(QuantityValue inversesquaremeters) { - QuantityValue value = (QuantityValue) inversesquaremeters; + double value = (double) inversesquaremeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMeter); } @@ -371,7 +368,7 @@ public static ReciprocalArea FromInverseSquareMeters(QuantityValue inversesquare /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMicrometers(QuantityValue inversesquaremicrometers) { - QuantityValue value = (QuantityValue) inversesquaremicrometers; + double value = (double) inversesquaremicrometers; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMicrometer); } @@ -381,7 +378,7 @@ public static ReciprocalArea FromInverseSquareMicrometers(QuantityValue inverses /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMiles(QuantityValue inversesquaremiles) { - QuantityValue value = (QuantityValue) inversesquaremiles; + double value = (double) inversesquaremiles; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMile); } @@ -391,7 +388,7 @@ public static ReciprocalArea FromInverseSquareMiles(QuantityValue inversesquarem /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareMillimeters(QuantityValue inversesquaremillimeters) { - QuantityValue value = (QuantityValue) inversesquaremillimeters; + double value = (double) inversesquaremillimeters; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareMillimeter); } @@ -401,7 +398,7 @@ public static ReciprocalArea FromInverseSquareMillimeters(QuantityValue inverses /// If value is NaN or Infinity. public static ReciprocalArea FromInverseSquareYards(QuantityValue inversesquareyards) { - QuantityValue value = (QuantityValue) inversesquareyards; + double value = (double) inversesquareyards; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseSquareYard); } @@ -411,7 +408,7 @@ public static ReciprocalArea FromInverseSquareYards(QuantityValue inversesquarey /// If value is NaN or Infinity. public static ReciprocalArea FromInverseUsSurveySquareFeet(QuantityValue inverseussurveysquarefeet) { - QuantityValue value = (QuantityValue) inverseussurveysquarefeet; + double value = (double) inverseussurveysquarefeet; return new ReciprocalArea(value, ReciprocalAreaUnit.InverseUsSurveySquareFoot); } @@ -423,7 +420,7 @@ public static ReciprocalArea FromInverseUsSurveySquareFeet(QuantityValue inverse /// ReciprocalArea unit value. public static ReciprocalArea From(QuantityValue value, ReciprocalAreaUnit fromUnit) { - return new ReciprocalArea((QuantityValue)value, fromUnit); + return new ReciprocalArea((double)value, fromUnit); } #endregion @@ -593,25 +590,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip } /// Get from multiplying value and . - public static ReciprocalArea operator *(QuantityValue left, ReciprocalArea right) + public static ReciprocalArea operator *(double left, ReciprocalArea right) { return new ReciprocalArea(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReciprocalArea operator *(ReciprocalArea left, QuantityValue right) + public static ReciprocalArea operator *(ReciprocalArea left, double right) { return new ReciprocalArea(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReciprocalArea operator /(ReciprocalArea left, QuantityValue right) + public static ReciprocalArea operator /(ReciprocalArea left, double right) { return new ReciprocalArea(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ReciprocalArea left, ReciprocalArea right) + public static double operator /(ReciprocalArea left, ReciprocalArea right) { return left.InverseSquareMeters / right.InverseSquareMeters; } @@ -644,19 +641,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReciprocalArea left, ReciprocalArea right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReciprocalArea left, ReciprocalArea right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -669,29 +653,7 @@ public int CompareTo(object obj) /// public int CompareTo(ReciprocalArea other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ReciprocalArea objReciprocalArea)) - return false; - return Equals(objReciprocalArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReciprocalArea other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -734,13 +696,13 @@ public bool Equals(ReciprocalArea other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReciprocalArea other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ReciprocalArea other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -751,7 +713,7 @@ public bool Equals(ReciprocalArea other, QuantityValue tolerance, ComparisonType /// A hash code for the current ReciprocalArea. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -762,16 +724,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ReciprocalAreaUnit unit) + public double As(ReciprocalAreaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -786,12 +749,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ReciprocalAreaUnit typedUnit)) + if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsReciprocalAreaUnit); } /// @@ -823,7 +786,7 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (ReciprocalArea)converted; } - else if (Enum.IsDefined(typeof(ReciprocalAreaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -831,17 +794,17 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalAreaUnit typedUnit)) + if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsReciprocalAreaUnit, DefaultConversionFunctions); } /// @@ -868,10 +831,10 @@ public ReciprocalArea ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ReciprocalAreaUnit unit) + private double GetValueAs(ReciprocalAreaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index 80d8b7d8e3..db5125af45 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Reciprocal_length /// [DataContract] - public partial struct ReciprocalLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ReciprocalLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -84,9 +84,9 @@ static ReciprocalLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ReciprocalLength(QuantityValue value, ReciprocalLengthUnit unit) + public ReciprocalLength(double value, ReciprocalLengthUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -98,14 +98,14 @@ public ReciprocalLength(QuantityValue value, ReciprocalLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ReciprocalLength(QuantityValue value, UnitSystem unitSystem) + public ReciprocalLength(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -146,10 +146,7 @@ public ReciprocalLength(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -172,54 +169,54 @@ public ReciprocalLength(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); + public double InverseCentimeters => As(ReciprocalLengthUnit.InverseCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseFeet => As(ReciprocalLengthUnit.InverseFoot); + public double InverseFeet => As(ReciprocalLengthUnit.InverseFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseInches => As(ReciprocalLengthUnit.InverseInch); + public double InverseInches => As(ReciprocalLengthUnit.InverseInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMeters => As(ReciprocalLengthUnit.InverseMeter); + public double InverseMeters => As(ReciprocalLengthUnit.InverseMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); + public double InverseMicroinches => As(ReciprocalLengthUnit.InverseMicroinch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMils => As(ReciprocalLengthUnit.InverseMil); + public double InverseMils => As(ReciprocalLengthUnit.InverseMil); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMiles => As(ReciprocalLengthUnit.InverseMile); + public double InverseMiles => As(ReciprocalLengthUnit.InverseMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); + public double InverseMillimeters => As(ReciprocalLengthUnit.InverseMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); + public double InverseUsSurveyFeet => As(ReciprocalLengthUnit.InverseUsSurveyFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InverseYards => As(ReciprocalLengthUnit.InverseYard); + public double InverseYards => As(ReciprocalLengthUnit.InverseYard); #endregion @@ -302,7 +299,7 @@ public static string GetAbbreviation(ReciprocalLengthUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static ReciprocalLength FromInverseCentimeters(QuantityValue inversecentimeters) { - QuantityValue value = (QuantityValue) inversecentimeters; + double value = (double) inversecentimeters; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseCentimeter); } @@ -312,7 +309,7 @@ public static ReciprocalLength FromInverseCentimeters(QuantityValue inversecenti /// If value is NaN or Infinity. public static ReciprocalLength FromInverseFeet(QuantityValue inversefeet) { - QuantityValue value = (QuantityValue) inversefeet; + double value = (double) inversefeet; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseFoot); } @@ -322,7 +319,7 @@ public static ReciprocalLength FromInverseFeet(QuantityValue inversefeet) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseInches(QuantityValue inverseinches) { - QuantityValue value = (QuantityValue) inverseinches; + double value = (double) inverseinches; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseInch); } @@ -332,7 +329,7 @@ public static ReciprocalLength FromInverseInches(QuantityValue inverseinches) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMeters(QuantityValue inversemeters) { - QuantityValue value = (QuantityValue) inversemeters; + double value = (double) inversemeters; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMeter); } @@ -342,7 +339,7 @@ public static ReciprocalLength FromInverseMeters(QuantityValue inversemeters) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMicroinches(QuantityValue inversemicroinches) { - QuantityValue value = (QuantityValue) inversemicroinches; + double value = (double) inversemicroinches; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMicroinch); } @@ -352,7 +349,7 @@ public static ReciprocalLength FromInverseMicroinches(QuantityValue inversemicro /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMils(QuantityValue inversemils) { - QuantityValue value = (QuantityValue) inversemils; + double value = (double) inversemils; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMil); } @@ -362,7 +359,7 @@ public static ReciprocalLength FromInverseMils(QuantityValue inversemils) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMiles(QuantityValue inversemiles) { - QuantityValue value = (QuantityValue) inversemiles; + double value = (double) inversemiles; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMile); } @@ -372,7 +369,7 @@ public static ReciprocalLength FromInverseMiles(QuantityValue inversemiles) /// If value is NaN or Infinity. public static ReciprocalLength FromInverseMillimeters(QuantityValue inversemillimeters) { - QuantityValue value = (QuantityValue) inversemillimeters; + double value = (double) inversemillimeters; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseMillimeter); } @@ -382,7 +379,7 @@ public static ReciprocalLength FromInverseMillimeters(QuantityValue inversemilli /// If value is NaN or Infinity. public static ReciprocalLength FromInverseUsSurveyFeet(QuantityValue inverseussurveyfeet) { - QuantityValue value = (QuantityValue) inverseussurveyfeet; + double value = (double) inverseussurveyfeet; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseUsSurveyFoot); } @@ -392,7 +389,7 @@ public static ReciprocalLength FromInverseUsSurveyFeet(QuantityValue inverseussu /// If value is NaN or Infinity. public static ReciprocalLength FromInverseYards(QuantityValue inverseyards) { - QuantityValue value = (QuantityValue) inverseyards; + double value = (double) inverseyards; return new ReciprocalLength(value, ReciprocalLengthUnit.InverseYard); } @@ -404,7 +401,7 @@ public static ReciprocalLength FromInverseYards(QuantityValue inverseyards) /// ReciprocalLength unit value. public static ReciprocalLength From(QuantityValue value, ReciprocalLengthUnit fromUnit) { - return new ReciprocalLength((QuantityValue)value, fromUnit); + return new ReciprocalLength((double)value, fromUnit); } #endregion @@ -574,25 +571,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip } /// Get from multiplying value and . - public static ReciprocalLength operator *(QuantityValue left, ReciprocalLength right) + public static ReciprocalLength operator *(double left, ReciprocalLength right) { return new ReciprocalLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ReciprocalLength operator *(ReciprocalLength left, QuantityValue right) + public static ReciprocalLength operator *(ReciprocalLength left, double right) { return new ReciprocalLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ReciprocalLength operator /(ReciprocalLength left, QuantityValue right) + public static ReciprocalLength operator /(ReciprocalLength left, double right) { return new ReciprocalLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ReciprocalLength left, ReciprocalLength right) + public static double operator /(ReciprocalLength left, ReciprocalLength right) { return left.InverseMeters / right.InverseMeters; } @@ -625,19 +622,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Recip return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ReciprocalLength left, ReciprocalLength right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ReciprocalLength left, ReciprocalLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -650,29 +634,7 @@ public int CompareTo(object obj) /// public int CompareTo(ReciprocalLength other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ReciprocalLength objReciprocalLength)) - return false; - return Equals(objReciprocalLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ReciprocalLength other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -715,13 +677,13 @@ public bool Equals(ReciprocalLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ReciprocalLength other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -732,7 +694,7 @@ public bool Equals(ReciprocalLength other, QuantityValue tolerance, ComparisonTy /// A hash code for the current ReciprocalLength. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -743,16 +705,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ReciprocalLengthUnit unit) + public double As(ReciprocalLengthUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -767,12 +730,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ReciprocalLengthUnit typedUnit)) + if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsReciprocalLengthUnit); } /// @@ -804,7 +767,7 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (ReciprocalLength)converted; } - else if (Enum.IsDefined(typeof(ReciprocalLengthUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -812,17 +775,17 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit, UnitConverter unitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalLengthUnit typedUnit)) + if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsReciprocalLengthUnit, DefaultConversionFunctions); } /// @@ -849,10 +812,10 @@ public ReciprocalLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ReciprocalLengthUnit unit) + private double GetValueAs(ReciprocalLengthUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index 42045a858b..b91d29a949 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Relative humidity is a ratio of the actual water vapor present in the air to the maximum water vapor in the air at the given temperature. /// [DataContract] - public partial struct RelativeHumidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RelativeHumidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static RelativeHumidity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RelativeHumidity(QuantityValue value, RelativeHumidityUnit unit) + public RelativeHumidity(double value, RelativeHumidityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -86,14 +86,14 @@ public RelativeHumidity(QuantityValue value, RelativeHumidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RelativeHumidity(QuantityValue value, UnitSystem unitSystem) + public RelativeHumidity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,10 +134,7 @@ public RelativeHumidity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +157,9 @@ public RelativeHumidity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Percent => As(RelativeHumidityUnit.Percent); + public double Percent => As(RelativeHumidityUnit.Percent); #endregion @@ -218,7 +215,7 @@ public static string GetAbbreviation(RelativeHumidityUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static RelativeHumidity FromPercent(QuantityValue percent) { - QuantityValue value = (QuantityValue) percent; + double value = (double) percent; return new RelativeHumidity(value, RelativeHumidityUnit.Percent); } @@ -230,7 +227,7 @@ public static RelativeHumidity FromPercent(QuantityValue percent) /// RelativeHumidity unit value. public static RelativeHumidity From(QuantityValue value, RelativeHumidityUnit fromUnit) { - return new RelativeHumidity((QuantityValue)value, fromUnit); + return new RelativeHumidity((double)value, fromUnit); } #endregion @@ -400,25 +397,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat } /// Get from multiplying value and . - public static RelativeHumidity operator *(QuantityValue left, RelativeHumidity right) + public static RelativeHumidity operator *(double left, RelativeHumidity right) { return new RelativeHumidity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RelativeHumidity operator *(RelativeHumidity left, QuantityValue right) + public static RelativeHumidity operator *(RelativeHumidity left, double right) { return new RelativeHumidity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RelativeHumidity operator /(RelativeHumidity left, QuantityValue right) + public static RelativeHumidity operator /(RelativeHumidity left, double right) { return new RelativeHumidity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(RelativeHumidity left, RelativeHumidity right) + public static double operator /(RelativeHumidity left, RelativeHumidity right) { return left.Percent / right.Percent; } @@ -451,19 +448,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Relat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RelativeHumidity left, RelativeHumidity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RelativeHumidity left, RelativeHumidity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -476,29 +460,7 @@ public int CompareTo(object obj) /// public int CompareTo(RelativeHumidity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is RelativeHumidity objRelativeHumidity)) - return false; - return Equals(objRelativeHumidity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RelativeHumidity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -541,13 +503,13 @@ public bool Equals(RelativeHumidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RelativeHumidity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +520,7 @@ public bool Equals(RelativeHumidity other, QuantityValue tolerance, ComparisonTy /// A hash code for the current RelativeHumidity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -569,16 +531,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RelativeHumidityUnit unit) + public double As(RelativeHumidityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -593,12 +556,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RelativeHumidityUnit typedUnit)) + if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRelativeHumidityUnit); } /// @@ -630,7 +593,7 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (RelativeHumidity)converted; } - else if (Enum.IsDefined(typeof(RelativeHumidityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -638,17 +601,17 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit, UnitConverter unitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RelativeHumidityUnit typedUnit)) + if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRelativeHumidityUnit, DefaultConversionFunctions); } /// @@ -675,10 +638,10 @@ public RelativeHumidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RelativeHumidityUnit unit) + private double GetValueAs(RelativeHumidityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 4f2c933aca..82e5e89d70 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Angular acceleration is the rate of change of rotational speed. /// [DataContract] - public partial struct RotationalAcceleration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalAcceleration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static RotationalAcceleration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalAcceleration(QuantityValue value, RotationalAccelerationUnit unit) + public RotationalAcceleration(double value, RotationalAccelerationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public RotationalAcceleration(QuantityValue value, RotationalAccelerationUnit un /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalAcceleration(QuantityValue value, UnitSystem unitSystem) + public RotationalAcceleration(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public RotationalAcceleration(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public RotationalAcceleration(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); + public double DegreesPerSecondSquared => As(RotationalAccelerationUnit.DegreePerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); + public double RadiansPerSecondSquared => As(RotationalAccelerationUnit.RadianPerSecondSquared); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); + public double RevolutionsPerMinutePerSecond => As(RotationalAccelerationUnit.RevolutionPerMinutePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); + public double RevolutionsPerSecondSquared => As(RotationalAccelerationUnit.RevolutionPerSecondSquared); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(RotationalAccelerationUnit unit, IFormatPro /// If value is NaN or Infinity. public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue degreespersecondsquared) { - QuantityValue value = (QuantityValue) degreespersecondsquared; + double value = (double) degreespersecondsquared; return new RotationalAcceleration(value, RotationalAccelerationUnit.DegreePerSecondSquared); } @@ -255,7 +252,7 @@ public static RotationalAcceleration FromDegreesPerSecondSquared(QuantityValue d /// If value is NaN or Infinity. public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue radianspersecondsquared) { - QuantityValue value = (QuantityValue) radianspersecondsquared; + double value = (double) radianspersecondsquared; return new RotationalAcceleration(value, RotationalAccelerationUnit.RadianPerSecondSquared); } @@ -265,7 +262,7 @@ public static RotationalAcceleration FromRadiansPerSecondSquared(QuantityValue r /// If value is NaN or Infinity. public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityValue revolutionsperminutepersecond) { - QuantityValue value = (QuantityValue) revolutionsperminutepersecond; + double value = (double) revolutionsperminutepersecond; return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerMinutePerSecond); } @@ -275,7 +272,7 @@ public static RotationalAcceleration FromRevolutionsPerMinutePerSecond(QuantityV /// If value is NaN or Infinity. public static RotationalAcceleration FromRevolutionsPerSecondSquared(QuantityValue revolutionspersecondsquared) { - QuantityValue value = (QuantityValue) revolutionspersecondsquared; + double value = (double) revolutionspersecondsquared; return new RotationalAcceleration(value, RotationalAccelerationUnit.RevolutionPerSecondSquared); } @@ -287,7 +284,7 @@ public static RotationalAcceleration FromRevolutionsPerSecondSquared(QuantityVal /// RotationalAcceleration unit value. public static RotationalAcceleration From(QuantityValue value, RotationalAccelerationUnit fromUnit) { - return new RotationalAcceleration((QuantityValue)value, fromUnit); + return new RotationalAcceleration((double)value, fromUnit); } #endregion @@ -457,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalAcceleration operator *(QuantityValue left, RotationalAcceleration right) + public static RotationalAcceleration operator *(double left, RotationalAcceleration right) { return new RotationalAcceleration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalAcceleration operator *(RotationalAcceleration left, QuantityValue right) + public static RotationalAcceleration operator *(RotationalAcceleration left, double right) { return new RotationalAcceleration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalAcceleration operator /(RotationalAcceleration left, QuantityValue right) + public static RotationalAcceleration operator /(RotationalAcceleration left, double right) { return new RotationalAcceleration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(RotationalAcceleration left, RotationalAcceleration right) + public static double operator /(RotationalAcceleration left, RotationalAcceleration right) { return left.RadiansPerSecondSquared / right.RadiansPerSecondSquared; } @@ -508,19 +505,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalAcceleration left, RotationalAcceleration right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalAcceleration left, RotationalAcceleration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -533,29 +517,7 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalAcceleration other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is RotationalAcceleration objRotationalAcceleration)) - return false; - return Equals(objRotationalAcceleration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalAcceleration other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -598,13 +560,13 @@ public bool Equals(RotationalAcceleration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalAcceleration other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(RotationalAcceleration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +577,7 @@ public bool Equals(RotationalAcceleration other, QuantityValue tolerance, Compar /// A hash code for the current RotationalAcceleration. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -626,16 +588,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RotationalAccelerationUnit unit) + public double As(RotationalAccelerationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -650,12 +613,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RotationalAccelerationUnit typedUnit)) + if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRotationalAccelerationUnit); } /// @@ -687,7 +650,7 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit, UnitConver var converted = conversionFunction(this); return (RotationalAcceleration)converted; } - else if (Enum.IsDefined(typeof(RotationalAccelerationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -695,17 +658,17 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit, UnitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalAccelerationUnit typedUnit)) + if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRotationalAccelerationUnit, DefaultConversionFunctions); } /// @@ -732,10 +695,10 @@ public RotationalAcceleration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RotationalAccelerationUnit unit) + private double GetValueAs(RotationalAccelerationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index fe07f1048a..85e4e1cff9 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Rotational speed (sometimes called speed of revolution) is the number of complete rotations, revolutions, cycles, or turns per time unit. Rotational speed is a cyclic frequency, measured in radians per second or in hertz in the SI System by scientists, or in revolutions per minute (rpm or min-1) or revolutions per second in everyday life. The symbol for rotational speed is ω (the Greek lowercase letter "omega"). /// [DataContract] - public partial struct RotationalSpeed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalSpeed : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -84,9 +84,9 @@ static RotationalSpeed() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalSpeed(QuantityValue value, RotationalSpeedUnit unit) + public RotationalSpeed(double value, RotationalSpeedUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -98,14 +98,14 @@ public RotationalSpeed(QuantityValue value, RotationalSpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalSpeed(QuantityValue value, UnitSystem unitSystem) + public RotationalSpeed(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -146,10 +146,7 @@ public RotationalSpeed(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -172,69 +169,69 @@ public RotationalSpeed(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); + public double CentiradiansPerSecond => As(RotationalSpeedUnit.CentiradianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); + public double DeciradiansPerSecond => As(RotationalSpeedUnit.DeciradianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); + public double DegreesPerMinute => As(RotationalSpeedUnit.DegreePerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); + public double DegreesPerSecond => As(RotationalSpeedUnit.DegreePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); + public double MicrodegreesPerSecond => As(RotationalSpeedUnit.MicrodegreePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); + public double MicroradiansPerSecond => As(RotationalSpeedUnit.MicroradianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); + public double MillidegreesPerSecond => As(RotationalSpeedUnit.MillidegreePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); + public double MilliradiansPerSecond => As(RotationalSpeedUnit.MilliradianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); + public double NanodegreesPerSecond => As(RotationalSpeedUnit.NanodegreePerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); + public double NanoradiansPerSecond => As(RotationalSpeedUnit.NanoradianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); + public double RadiansPerSecond => As(RotationalSpeedUnit.RadianPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); + public double RevolutionsPerMinute => As(RotationalSpeedUnit.RevolutionPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); + public double RevolutionsPerSecond => As(RotationalSpeedUnit.RevolutionPerSecond); #endregion @@ -338,7 +335,7 @@ public static string GetAbbreviation(RotationalSpeedUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue centiradianspersecond) { - QuantityValue value = (QuantityValue) centiradianspersecond; + double value = (double) centiradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.CentiradianPerSecond); } @@ -348,7 +345,7 @@ public static RotationalSpeed FromCentiradiansPerSecond(QuantityValue centiradia /// If value is NaN or Infinity. public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue deciradianspersecond) { - QuantityValue value = (QuantityValue) deciradianspersecond; + double value = (double) deciradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.DeciradianPerSecond); } @@ -358,7 +355,7 @@ public static RotationalSpeed FromDeciradiansPerSecond(QuantityValue deciradians /// If value is NaN or Infinity. public static RotationalSpeed FromDegreesPerMinute(QuantityValue degreesperminute) { - QuantityValue value = (QuantityValue) degreesperminute; + double value = (double) degreesperminute; return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerMinute); } @@ -368,7 +365,7 @@ public static RotationalSpeed FromDegreesPerMinute(QuantityValue degreesperminut /// If value is NaN or Infinity. public static RotationalSpeed FromDegreesPerSecond(QuantityValue degreespersecond) { - QuantityValue value = (QuantityValue) degreespersecond; + double value = (double) degreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.DegreePerSecond); } @@ -378,7 +375,7 @@ public static RotationalSpeed FromDegreesPerSecond(QuantityValue degreespersecon /// If value is NaN or Infinity. public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue microdegreespersecond) { - QuantityValue value = (QuantityValue) microdegreespersecond; + double value = (double) microdegreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MicrodegreePerSecond); } @@ -388,7 +385,7 @@ public static RotationalSpeed FromMicrodegreesPerSecond(QuantityValue microdegre /// If value is NaN or Infinity. public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue microradianspersecond) { - QuantityValue value = (QuantityValue) microradianspersecond; + double value = (double) microradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MicroradianPerSecond); } @@ -398,7 +395,7 @@ public static RotationalSpeed FromMicroradiansPerSecond(QuantityValue microradia /// If value is NaN or Infinity. public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue millidegreespersecond) { - QuantityValue value = (QuantityValue) millidegreespersecond; + double value = (double) millidegreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MillidegreePerSecond); } @@ -408,7 +405,7 @@ public static RotationalSpeed FromMillidegreesPerSecond(QuantityValue millidegre /// If value is NaN or Infinity. public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue milliradianspersecond) { - QuantityValue value = (QuantityValue) milliradianspersecond; + double value = (double) milliradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.MilliradianPerSecond); } @@ -418,7 +415,7 @@ public static RotationalSpeed FromMilliradiansPerSecond(QuantityValue milliradia /// If value is NaN or Infinity. public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue nanodegreespersecond) { - QuantityValue value = (QuantityValue) nanodegreespersecond; + double value = (double) nanodegreespersecond; return new RotationalSpeed(value, RotationalSpeedUnit.NanodegreePerSecond); } @@ -428,7 +425,7 @@ public static RotationalSpeed FromNanodegreesPerSecond(QuantityValue nanodegrees /// If value is NaN or Infinity. public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue nanoradianspersecond) { - QuantityValue value = (QuantityValue) nanoradianspersecond; + double value = (double) nanoradianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.NanoradianPerSecond); } @@ -438,7 +435,7 @@ public static RotationalSpeed FromNanoradiansPerSecond(QuantityValue nanoradians /// If value is NaN or Infinity. public static RotationalSpeed FromRadiansPerSecond(QuantityValue radianspersecond) { - QuantityValue value = (QuantityValue) radianspersecond; + double value = (double) radianspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.RadianPerSecond); } @@ -448,7 +445,7 @@ public static RotationalSpeed FromRadiansPerSecond(QuantityValue radianspersecon /// If value is NaN or Infinity. public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue revolutionsperminute) { - QuantityValue value = (QuantityValue) revolutionsperminute; + double value = (double) revolutionsperminute; return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerMinute); } @@ -458,7 +455,7 @@ public static RotationalSpeed FromRevolutionsPerMinute(QuantityValue revolutions /// If value is NaN or Infinity. public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue revolutionspersecond) { - QuantityValue value = (QuantityValue) revolutionspersecond; + double value = (double) revolutionspersecond; return new RotationalSpeed(value, RotationalSpeedUnit.RevolutionPerSecond); } @@ -470,7 +467,7 @@ public static RotationalSpeed FromRevolutionsPerSecond(QuantityValue revolutions /// RotationalSpeed unit value. public static RotationalSpeed From(QuantityValue value, RotationalSpeedUnit fromUnit) { - return new RotationalSpeed((QuantityValue)value, fromUnit); + return new RotationalSpeed((double)value, fromUnit); } #endregion @@ -640,25 +637,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalSpeed operator *(QuantityValue left, RotationalSpeed right) + public static RotationalSpeed operator *(double left, RotationalSpeed right) { return new RotationalSpeed(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalSpeed operator *(RotationalSpeed left, QuantityValue right) + public static RotationalSpeed operator *(RotationalSpeed left, double right) { return new RotationalSpeed(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalSpeed operator /(RotationalSpeed left, QuantityValue right) + public static RotationalSpeed operator /(RotationalSpeed left, double right) { return new RotationalSpeed(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(RotationalSpeed left, RotationalSpeed right) + public static double operator /(RotationalSpeed left, RotationalSpeed right) { return left.RadiansPerSecond / right.RadiansPerSecond; } @@ -691,19 +688,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalSpeed left, RotationalSpeed right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalSpeed left, RotationalSpeed right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -716,29 +700,7 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalSpeed other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is RotationalSpeed objRotationalSpeed)) - return false; - return Equals(objRotationalSpeed); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalSpeed other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -781,13 +743,13 @@ public bool Equals(RotationalSpeed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalSpeed other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(RotationalSpeed other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -798,7 +760,7 @@ public bool Equals(RotationalSpeed other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current RotationalSpeed. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -809,16 +771,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RotationalSpeedUnit unit) + public double As(RotationalSpeedUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -833,12 +796,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RotationalSpeedUnit typedUnit)) + if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRotationalSpeedUnit); } /// @@ -870,7 +833,7 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (RotationalSpeed)converted; } - else if (Enum.IsDefined(typeof(RotationalSpeedUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -878,17 +841,17 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalSpeedUnit typedUnit)) + if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRotationalSpeedUnit, DefaultConversionFunctions); } /// @@ -915,10 +878,10 @@ public RotationalSpeed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RotationalSpeedUnit unit) + private double GetValueAs(RotationalSpeedUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index 566185aa51..dd3526719d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffness : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffness : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -104,9 +104,9 @@ static RotationalStiffness() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalStiffness(QuantityValue value, RotationalStiffnessUnit unit) + public RotationalStiffness(double value, RotationalStiffnessUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -118,14 +118,14 @@ public RotationalStiffness(QuantityValue value, RotationalStiffnessUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffness(QuantityValue value, UnitSystem unitSystem) + public RotationalStiffness(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -166,10 +166,7 @@ public RotationalStiffness(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -192,169 +189,169 @@ public RotationalStiffness(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); + public double CentinewtonMetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); + public double CentinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); + public double CentinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); + public double DecanewtonMetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); + public double DecanewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); + public double DecanewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); + public double DecinewtonMetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); + public double DecinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); + public double DecinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); + public double KilonewtonMetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); + public double KilonewtonMetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); + public double KilonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); + public double KilonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); + public double KilopoundForceFeetPerDegrees => As(RotationalStiffnessUnit.KilopoundForceFootPerDegrees); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); + public double MeganewtonMetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); + public double MeganewtonMetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); + public double MeganewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); + public double MeganewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); + public double MicronewtonMetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); + public double MicronewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); + public double MicronewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); + public double MillinewtonMetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); + public double MillinewtonMillimetersPerDegree => As(RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); + public double MillinewtonMillimetersPerRadian => As(RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); + public double NanonewtonMetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); + public double NanonewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); + public double NanonewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); + public double NewtonMetersPerDegree => As(RotationalStiffnessUnit.NewtonMeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); + public double NewtonMetersPerRadian => As(RotationalStiffnessUnit.NewtonMeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); + public double NewtonMillimetersPerDegree => As(RotationalStiffnessUnit.NewtonMillimeterPerDegree); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); + public double NewtonMillimetersPerRadian => As(RotationalStiffnessUnit.NewtonMillimeterPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); + public double PoundForceFeetPerRadian => As(RotationalStiffnessUnit.PoundForceFeetPerRadian); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); + public double PoundForceFeetPerDegrees => As(RotationalStiffnessUnit.PoundForceFootPerDegrees); #endregion @@ -506,7 +503,7 @@ public static string GetAbbreviation(RotationalStiffnessUnit unit, IFormatProvid /// If value is NaN or Infinity. public static RotationalStiffness FromCentinewtonMetersPerDegree(QuantityValue centinewtonmetersperdegree) { - QuantityValue value = (QuantityValue) centinewtonmetersperdegree; + double value = (double) centinewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMeterPerDegree); } @@ -516,7 +513,7 @@ public static RotationalStiffness FromCentinewtonMetersPerDegree(QuantityValue c /// If value is NaN or Infinity. public static RotationalStiffness FromCentinewtonMillimetersPerDegree(QuantityValue centinewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) centinewtonmillimetersperdegree; + double value = (double) centinewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerDegree); } @@ -526,7 +523,7 @@ public static RotationalStiffness FromCentinewtonMillimetersPerDegree(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromCentinewtonMillimetersPerRadian(QuantityValue centinewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) centinewtonmillimetersperradian; + double value = (double) centinewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.CentinewtonMillimeterPerRadian); } @@ -536,7 +533,7 @@ public static RotationalStiffness FromCentinewtonMillimetersPerRadian(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromDecanewtonMetersPerDegree(QuantityValue decanewtonmetersperdegree) { - QuantityValue value = (QuantityValue) decanewtonmetersperdegree; + double value = (double) decanewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMeterPerDegree); } @@ -546,7 +543,7 @@ public static RotationalStiffness FromDecanewtonMetersPerDegree(QuantityValue de /// If value is NaN or Infinity. public static RotationalStiffness FromDecanewtonMillimetersPerDegree(QuantityValue decanewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) decanewtonmillimetersperdegree; + double value = (double) decanewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerDegree); } @@ -556,7 +553,7 @@ public static RotationalStiffness FromDecanewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromDecanewtonMillimetersPerRadian(QuantityValue decanewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) decanewtonmillimetersperradian; + double value = (double) decanewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.DecanewtonMillimeterPerRadian); } @@ -566,7 +563,7 @@ public static RotationalStiffness FromDecanewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromDecinewtonMetersPerDegree(QuantityValue decinewtonmetersperdegree) { - QuantityValue value = (QuantityValue) decinewtonmetersperdegree; + double value = (double) decinewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMeterPerDegree); } @@ -576,7 +573,7 @@ public static RotationalStiffness FromDecinewtonMetersPerDegree(QuantityValue de /// If value is NaN or Infinity. public static RotationalStiffness FromDecinewtonMillimetersPerDegree(QuantityValue decinewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) decinewtonmillimetersperdegree; + double value = (double) decinewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerDegree); } @@ -586,7 +583,7 @@ public static RotationalStiffness FromDecinewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromDecinewtonMillimetersPerRadian(QuantityValue decinewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) decinewtonmillimetersperradian; + double value = (double) decinewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.DecinewtonMillimeterPerRadian); } @@ -596,7 +593,7 @@ public static RotationalStiffness FromDecinewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMetersPerDegree(QuantityValue kilonewtonmetersperdegree) { - QuantityValue value = (QuantityValue) kilonewtonmetersperdegree; + double value = (double) kilonewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerDegree); } @@ -606,7 +603,7 @@ public static RotationalStiffness FromKilonewtonMetersPerDegree(QuantityValue ki /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue kilonewtonmetersperradian) { - QuantityValue value = (QuantityValue) kilonewtonmetersperradian; + double value = (double) kilonewtonmetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMeterPerRadian); } @@ -616,7 +613,7 @@ public static RotationalStiffness FromKilonewtonMetersPerRadian(QuantityValue ki /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMillimetersPerDegree(QuantityValue kilonewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) kilonewtonmillimetersperdegree; + double value = (double) kilonewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerDegree); } @@ -626,7 +623,7 @@ public static RotationalStiffness FromKilonewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromKilonewtonMillimetersPerRadian(QuantityValue kilonewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) kilonewtonmillimetersperradian; + double value = (double) kilonewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.KilonewtonMillimeterPerRadian); } @@ -636,7 +633,7 @@ public static RotationalStiffness FromKilonewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromKilopoundForceFeetPerDegrees(QuantityValue kilopoundforcefeetperdegrees) { - QuantityValue value = (QuantityValue) kilopoundforcefeetperdegrees; + double value = (double) kilopoundforcefeetperdegrees; return new RotationalStiffness(value, RotationalStiffnessUnit.KilopoundForceFootPerDegrees); } @@ -646,7 +643,7 @@ public static RotationalStiffness FromKilopoundForceFeetPerDegrees(QuantityValue /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMetersPerDegree(QuantityValue meganewtonmetersperdegree) { - QuantityValue value = (QuantityValue) meganewtonmetersperdegree; + double value = (double) meganewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerDegree); } @@ -656,7 +653,7 @@ public static RotationalStiffness FromMeganewtonMetersPerDegree(QuantityValue me /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue meganewtonmetersperradian) { - QuantityValue value = (QuantityValue) meganewtonmetersperradian; + double value = (double) meganewtonmetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMeterPerRadian); } @@ -666,7 +663,7 @@ public static RotationalStiffness FromMeganewtonMetersPerRadian(QuantityValue me /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMillimetersPerDegree(QuantityValue meganewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) meganewtonmillimetersperdegree; + double value = (double) meganewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerDegree); } @@ -676,7 +673,7 @@ public static RotationalStiffness FromMeganewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromMeganewtonMillimetersPerRadian(QuantityValue meganewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) meganewtonmillimetersperradian; + double value = (double) meganewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MeganewtonMillimeterPerRadian); } @@ -686,7 +683,7 @@ public static RotationalStiffness FromMeganewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromMicronewtonMetersPerDegree(QuantityValue micronewtonmetersperdegree) { - QuantityValue value = (QuantityValue) micronewtonmetersperdegree; + double value = (double) micronewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMeterPerDegree); } @@ -696,7 +693,7 @@ public static RotationalStiffness FromMicronewtonMetersPerDegree(QuantityValue m /// If value is NaN or Infinity. public static RotationalStiffness FromMicronewtonMillimetersPerDegree(QuantityValue micronewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) micronewtonmillimetersperdegree; + double value = (double) micronewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerDegree); } @@ -706,7 +703,7 @@ public static RotationalStiffness FromMicronewtonMillimetersPerDegree(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromMicronewtonMillimetersPerRadian(QuantityValue micronewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) micronewtonmillimetersperradian; + double value = (double) micronewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MicronewtonMillimeterPerRadian); } @@ -716,7 +713,7 @@ public static RotationalStiffness FromMicronewtonMillimetersPerRadian(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromMillinewtonMetersPerDegree(QuantityValue millinewtonmetersperdegree) { - QuantityValue value = (QuantityValue) millinewtonmetersperdegree; + double value = (double) millinewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMeterPerDegree); } @@ -726,7 +723,7 @@ public static RotationalStiffness FromMillinewtonMetersPerDegree(QuantityValue m /// If value is NaN or Infinity. public static RotationalStiffness FromMillinewtonMillimetersPerDegree(QuantityValue millinewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) millinewtonmillimetersperdegree; + double value = (double) millinewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerDegree); } @@ -736,7 +733,7 @@ public static RotationalStiffness FromMillinewtonMillimetersPerDegree(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromMillinewtonMillimetersPerRadian(QuantityValue millinewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) millinewtonmillimetersperradian; + double value = (double) millinewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.MillinewtonMillimeterPerRadian); } @@ -746,7 +743,7 @@ public static RotationalStiffness FromMillinewtonMillimetersPerRadian(QuantityVa /// If value is NaN or Infinity. public static RotationalStiffness FromNanonewtonMetersPerDegree(QuantityValue nanonewtonmetersperdegree) { - QuantityValue value = (QuantityValue) nanonewtonmetersperdegree; + double value = (double) nanonewtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMeterPerDegree); } @@ -756,7 +753,7 @@ public static RotationalStiffness FromNanonewtonMetersPerDegree(QuantityValue na /// If value is NaN or Infinity. public static RotationalStiffness FromNanonewtonMillimetersPerDegree(QuantityValue nanonewtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) nanonewtonmillimetersperdegree; + double value = (double) nanonewtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerDegree); } @@ -766,7 +763,7 @@ public static RotationalStiffness FromNanonewtonMillimetersPerDegree(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromNanonewtonMillimetersPerRadian(QuantityValue nanonewtonmillimetersperradian) { - QuantityValue value = (QuantityValue) nanonewtonmillimetersperradian; + double value = (double) nanonewtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.NanonewtonMillimeterPerRadian); } @@ -776,7 +773,7 @@ public static RotationalStiffness FromNanonewtonMillimetersPerRadian(QuantityVal /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMetersPerDegree(QuantityValue newtonmetersperdegree) { - QuantityValue value = (QuantityValue) newtonmetersperdegree; + double value = (double) newtonmetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerDegree); } @@ -786,7 +783,7 @@ public static RotationalStiffness FromNewtonMetersPerDegree(QuantityValue newton /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue newtonmetersperradian) { - QuantityValue value = (QuantityValue) newtonmetersperradian; + double value = (double) newtonmetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMeterPerRadian); } @@ -796,7 +793,7 @@ public static RotationalStiffness FromNewtonMetersPerRadian(QuantityValue newton /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMillimetersPerDegree(QuantityValue newtonmillimetersperdegree) { - QuantityValue value = (QuantityValue) newtonmillimetersperdegree; + double value = (double) newtonmillimetersperdegree; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerDegree); } @@ -806,7 +803,7 @@ public static RotationalStiffness FromNewtonMillimetersPerDegree(QuantityValue n /// If value is NaN or Infinity. public static RotationalStiffness FromNewtonMillimetersPerRadian(QuantityValue newtonmillimetersperradian) { - QuantityValue value = (QuantityValue) newtonmillimetersperradian; + double value = (double) newtonmillimetersperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.NewtonMillimeterPerRadian); } @@ -816,7 +813,7 @@ public static RotationalStiffness FromNewtonMillimetersPerRadian(QuantityValue n /// If value is NaN or Infinity. public static RotationalStiffness FromPoundForceFeetPerRadian(QuantityValue poundforcefeetperradian) { - QuantityValue value = (QuantityValue) poundforcefeetperradian; + double value = (double) poundforcefeetperradian; return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFeetPerRadian); } @@ -826,7 +823,7 @@ public static RotationalStiffness FromPoundForceFeetPerRadian(QuantityValue poun /// If value is NaN or Infinity. public static RotationalStiffness FromPoundForceFeetPerDegrees(QuantityValue poundforcefeetperdegrees) { - QuantityValue value = (QuantityValue) poundforcefeetperdegrees; + double value = (double) poundforcefeetperdegrees; return new RotationalStiffness(value, RotationalStiffnessUnit.PoundForceFootPerDegrees); } @@ -838,7 +835,7 @@ public static RotationalStiffness FromPoundForceFeetPerDegrees(QuantityValue pou /// RotationalStiffness unit value. public static RotationalStiffness From(QuantityValue value, RotationalStiffnessUnit fromUnit) { - return new RotationalStiffness((QuantityValue)value, fromUnit); + return new RotationalStiffness((double)value, fromUnit); } #endregion @@ -1008,25 +1005,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalStiffness operator *(QuantityValue left, RotationalStiffness right) + public static RotationalStiffness operator *(double left, RotationalStiffness right) { return new RotationalStiffness(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalStiffness operator *(RotationalStiffness left, QuantityValue right) + public static RotationalStiffness operator *(RotationalStiffness left, double right) { return new RotationalStiffness(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalStiffness operator /(RotationalStiffness left, QuantityValue right) + public static RotationalStiffness operator /(RotationalStiffness left, double right) { return new RotationalStiffness(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(RotationalStiffness left, RotationalStiffness right) + public static double operator /(RotationalStiffness left, RotationalStiffness right) { return left.NewtonMetersPerRadian / right.NewtonMetersPerRadian; } @@ -1059,19 +1056,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffness left, RotationalStiffness right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffness left, RotationalStiffness right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1084,29 +1068,7 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalStiffness other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is RotationalStiffness objRotationalStiffness)) - return false; - return Equals(objRotationalStiffness); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffness other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1149,13 +1111,13 @@ public bool Equals(RotationalStiffness other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffness other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(RotationalStiffness other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1166,7 +1128,7 @@ public bool Equals(RotationalStiffness other, QuantityValue tolerance, Compariso /// A hash code for the current RotationalStiffness. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1177,16 +1139,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RotationalStiffnessUnit unit) + public double As(RotationalStiffnessUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1201,12 +1164,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessUnit typedUnit)) + if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRotationalStiffnessUnit); } /// @@ -1238,7 +1201,7 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit, UnitConverter un var converted = conversionFunction(this); return (RotationalStiffness)converted; } - else if (Enum.IsDefined(typeof(RotationalStiffnessUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1246,17 +1209,17 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessUnit typedUnit)) + if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRotationalStiffnessUnit, DefaultConversionFunctions); } /// @@ -1283,10 +1246,10 @@ public RotationalStiffness ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RotationalStiffnessUnit unit) + private double GetValueAs(RotationalStiffnessUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 891a7f8e9d..603b45d53a 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Stiffness#Rotational_stiffness /// [DataContract] - public partial struct RotationalStiffnessPerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct RotationalStiffnessPerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static RotationalStiffnessPerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public RotationalStiffnessPerLength(QuantityValue value, RotationalStiffnessPerLengthUnit unit) + public RotationalStiffnessPerLength(double value, RotationalStiffnessPerLengthUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -90,14 +90,14 @@ public RotationalStiffnessPerLength(QuantityValue value, RotationalStiffnessPerL /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public RotationalStiffnessPerLength(QuantityValue value, UnitSystem unitSystem) + public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,10 +138,7 @@ public RotationalStiffnessPerLength(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -164,29 +161,29 @@ public RotationalStiffnessPerLength(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); + public double KilonewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); + public double KilopoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); + public double MeganewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); + public double NewtonMetersPerRadianPerMeter => As(RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); + public double PoundForceFeetPerDegreesPerFeet => As(RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); #endregion @@ -254,7 +251,7 @@ public static string GetAbbreviation(RotationalStiffnessPerLengthUnit unit, IFor /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter(QuantityValue kilonewtonmetersperradianpermeter) { - QuantityValue value = (QuantityValue) kilonewtonmetersperradianpermeter; + double value = (double) kilonewtonmetersperradianpermeter; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilonewtonMeterPerRadianPerMeter); } @@ -264,7 +261,7 @@ public static RotationalStiffnessPerLength FromKilonewtonMetersPerRadianPerMeter /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFeet(QuantityValue kilopoundforcefeetperdegreesperfeet) { - QuantityValue value = (QuantityValue) kilopoundforcefeetperdegreesperfeet; + double value = (double) kilopoundforcefeetperdegreesperfeet; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.KilopoundForceFootPerDegreesPerFoot); } @@ -274,7 +271,7 @@ public static RotationalStiffnessPerLength FromKilopoundForceFeetPerDegreesPerFe /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter(QuantityValue meganewtonmetersperradianpermeter) { - QuantityValue value = (QuantityValue) meganewtonmetersperradianpermeter; + double value = (double) meganewtonmetersperradianpermeter; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.MeganewtonMeterPerRadianPerMeter); } @@ -284,7 +281,7 @@ public static RotationalStiffnessPerLength FromMeganewtonMetersPerRadianPerMeter /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(QuantityValue newtonmetersperradianpermeter) { - QuantityValue value = (QuantityValue) newtonmetersperradianpermeter; + double value = (double) newtonmetersperradianpermeter; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.NewtonMeterPerRadianPerMeter); } @@ -294,7 +291,7 @@ public static RotationalStiffnessPerLength FromNewtonMetersPerRadianPerMeter(Qua /// If value is NaN or Infinity. public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(QuantityValue poundforcefeetperdegreesperfeet) { - QuantityValue value = (QuantityValue) poundforcefeetperdegreesperfeet; + double value = (double) poundforcefeetperdegreesperfeet; return new RotationalStiffnessPerLength(value, RotationalStiffnessPerLengthUnit.PoundForceFootPerDegreesPerFoot); } @@ -306,7 +303,7 @@ public static RotationalStiffnessPerLength FromPoundForceFeetPerDegreesPerFeet(Q /// RotationalStiffnessPerLength unit value. public static RotationalStiffnessPerLength From(QuantityValue value, RotationalStiffnessPerLengthUnit fromUnit) { - return new RotationalStiffnessPerLength((QuantityValue)value, fromUnit); + return new RotationalStiffnessPerLength((double)value, fromUnit); } #endregion @@ -476,25 +473,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat } /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(QuantityValue left, RotationalStiffnessPerLength right) + public static RotationalStiffnessPerLength operator *(double left, RotationalStiffnessPerLength right) { return new RotationalStiffnessPerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, QuantityValue right) + public static RotationalStiffnessPerLength operator *(RotationalStiffnessPerLength left, double right) { return new RotationalStiffnessPerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, QuantityValue right) + public static RotationalStiffnessPerLength operator /(RotationalStiffnessPerLength left, double right) { return new RotationalStiffnessPerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) + public static double operator /(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) { return left.NewtonMetersPerRadianPerMeter / right.NewtonMetersPerRadianPerMeter; } @@ -527,19 +524,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Rotat return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(RotationalStiffnessPerLength left, RotationalStiffnessPerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -552,29 +536,7 @@ public int CompareTo(object obj) /// public int CompareTo(RotationalStiffnessPerLength other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is RotationalStiffnessPerLength objRotationalStiffnessPerLength)) - return false; - return Equals(objRotationalStiffnessPerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(RotationalStiffnessPerLength other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -617,13 +579,13 @@ public bool Equals(RotationalStiffnessPerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(RotationalStiffnessPerLength other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(RotationalStiffnessPerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -634,7 +596,7 @@ public bool Equals(RotationalStiffnessPerLength other, QuantityValue tolerance, /// A hash code for the current RotationalStiffnessPerLength. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -645,16 +607,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(RotationalStiffnessPerLengthUnit unit) + public double As(RotationalStiffnessPerLengthUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -669,12 +632,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsRotationalStiffnessPerLengthUnit); } /// @@ -706,7 +669,7 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit var converted = conversionFunction(this); return (RotationalStiffnessPerLength)converted; } - else if (Enum.IsDefined(typeof(RotationalStiffnessPerLengthUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -714,17 +677,17 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsRotationalStiffnessPerLengthUnit, DefaultConversionFunctions); } /// @@ -751,10 +714,10 @@ public RotationalStiffnessPerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(RotationalStiffnessPerLengthUnit unit) + private double GetValueAs(RotationalStiffnessPerLengthUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index f6d4428b4a..4b70a95229 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A way of representing a number of items. /// [DataContract] - public partial struct Scalar : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Scalar : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static Scalar() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Scalar(QuantityValue value, ScalarUnit unit) + public Scalar(double value, ScalarUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -86,14 +86,14 @@ public Scalar(QuantityValue value, ScalarUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Scalar(QuantityValue value, UnitSystem unitSystem) + public Scalar(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,10 +134,7 @@ public Scalar(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +157,9 @@ public Scalar(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Amount => As(ScalarUnit.Amount); + public double Amount => As(ScalarUnit.Amount); #endregion @@ -218,7 +215,7 @@ public static string GetAbbreviation(ScalarUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Scalar FromAmount(QuantityValue amount) { - QuantityValue value = (QuantityValue) amount; + double value = (double) amount; return new Scalar(value, ScalarUnit.Amount); } @@ -230,7 +227,7 @@ public static Scalar FromAmount(QuantityValue amount) /// Scalar unit value. public static Scalar From(QuantityValue value, ScalarUnit fromUnit) { - return new Scalar((QuantityValue)value, fromUnit); + return new Scalar((double)value, fromUnit); } #endregion @@ -400,25 +397,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala } /// Get from multiplying value and . - public static Scalar operator *(QuantityValue left, Scalar right) + public static Scalar operator *(double left, Scalar right) { return new Scalar(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Scalar operator *(Scalar left, QuantityValue right) + public static Scalar operator *(Scalar left, double right) { return new Scalar(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Scalar operator /(Scalar left, QuantityValue right) + public static Scalar operator /(Scalar left, double right) { return new Scalar(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Scalar left, Scalar right) + public static double operator /(Scalar left, Scalar right) { return left.Amount / right.Amount; } @@ -451,19 +448,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Scala return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Scalar left, Scalar right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Scalar left, Scalar right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -476,29 +460,7 @@ public int CompareTo(object obj) /// public int CompareTo(Scalar other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Scalar objScalar)) - return false; - return Equals(objScalar); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Scalar other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -541,13 +503,13 @@ public bool Equals(Scalar other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Scalar other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +520,7 @@ public bool Equals(Scalar other, QuantityValue tolerance, ComparisonType compari /// A hash code for the current Scalar. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -569,16 +531,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ScalarUnit unit) + public double As(ScalarUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -593,12 +556,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ScalarUnit typedUnit)) + if (!(unit is ScalarUnit unitAsScalarUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsScalarUnit); } /// @@ -630,7 +593,7 @@ public Scalar ToUnit(ScalarUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Scalar)converted; } - else if (Enum.IsDefined(typeof(ScalarUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -638,17 +601,17 @@ public Scalar ToUnit(ScalarUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ScalarUnit typedUnit)) + if (!(unit is ScalarUnit unitAsScalarUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsScalarUnit, DefaultConversionFunctions); } /// @@ -675,10 +638,10 @@ public Scalar ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ScalarUnit unit) + private double GetValueAs(ScalarUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index dd664f80ca..9a4b65cb3d 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Solid_angle /// [DataContract] - public partial struct SolidAngle : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SolidAngle : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static SolidAngle() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SolidAngle(QuantityValue value, SolidAngleUnit unit) + public SolidAngle(double value, SolidAngleUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public SolidAngle(QuantityValue value, SolidAngleUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SolidAngle(QuantityValue value, UnitSystem unitSystem) + public SolidAngle(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public SolidAngle(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public SolidAngle(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Steradians => As(SolidAngleUnit.Steradian); + public double Steradians => As(SolidAngleUnit.Steradian); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(SolidAngleUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static SolidAngle FromSteradians(QuantityValue steradians) { - QuantityValue value = (QuantityValue) steradians; + double value = (double) steradians; return new SolidAngle(value, SolidAngleUnit.Steradian); } @@ -233,7 +230,7 @@ public static SolidAngle FromSteradians(QuantityValue steradians) /// SolidAngle unit value. public static SolidAngle From(QuantityValue value, SolidAngleUnit fromUnit) { - return new SolidAngle((QuantityValue)value, fromUnit); + return new SolidAngle((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid } /// Get from multiplying value and . - public static SolidAngle operator *(QuantityValue left, SolidAngle right) + public static SolidAngle operator *(double left, SolidAngle right) { return new SolidAngle(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SolidAngle operator *(SolidAngle left, QuantityValue right) + public static SolidAngle operator *(SolidAngle left, double right) { return new SolidAngle(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SolidAngle operator /(SolidAngle left, QuantityValue right) + public static SolidAngle operator /(SolidAngle left, double right) { return new SolidAngle(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(SolidAngle left, SolidAngle right) + public static double operator /(SolidAngle left, SolidAngle right) { return left.Steradians / right.Steradians; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Solid return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SolidAngle left, SolidAngle right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SolidAngle left, SolidAngle right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(SolidAngle other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is SolidAngle objSolidAngle)) - return false; - return Equals(objSolidAngle); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SolidAngle other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(SolidAngle other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SolidAngle other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(SolidAngle other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(SolidAngle other, QuantityValue tolerance, ComparisonType com /// A hash code for the current SolidAngle. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SolidAngleUnit unit) + public double As(SolidAngleUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SolidAngleUnit typedUnit)) + if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSolidAngleUnit); } /// @@ -633,7 +596,7 @@ public SolidAngle ToUnit(SolidAngleUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (SolidAngle)converted; } - else if (Enum.IsDefined(typeof(SolidAngleUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public SolidAngle ToUnit(SolidAngleUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SolidAngleUnit typedUnit)) + if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSolidAngleUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public SolidAngle ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SolidAngleUnit unit) + private double GetValueAs(SolidAngleUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index e5f236b1cc..454fa20918 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Specific_energy /// [DataContract] - public partial struct SpecificEnergy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEnergy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -103,9 +103,9 @@ static SpecificEnergy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificEnergy(QuantityValue value, SpecificEnergyUnit unit) + public SpecificEnergy(double value, SpecificEnergyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,14 +117,14 @@ public SpecificEnergy(QuantityValue value, SpecificEnergyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEnergy(QuantityValue value, UnitSystem unitSystem) + public SpecificEnergy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -165,10 +165,7 @@ public SpecificEnergy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -191,149 +188,149 @@ public SpecificEnergy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); + public double BtuPerPound => As(SpecificEnergyUnit.BtuPerPound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); + public double CaloriesPerGram => As(SpecificEnergyUnit.CaloriePerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); + public double GigawattDaysPerKilogram => As(SpecificEnergyUnit.GigawattDayPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); + public double GigawattDaysPerShortTon => As(SpecificEnergyUnit.GigawattDayPerShortTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); + public double GigawattDaysPerTonne => As(SpecificEnergyUnit.GigawattDayPerTonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); + public double GigawattHoursPerKilogram => As(SpecificEnergyUnit.GigawattHourPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GigawattHoursPerPound => As(SpecificEnergyUnit.GigawattHourPerPound); + public double GigawattHoursPerPound => As(SpecificEnergyUnit.GigawattHourPerPound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); + public double JoulesPerKilogram => As(SpecificEnergyUnit.JoulePerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); + public double KilocaloriesPerGram => As(SpecificEnergyUnit.KilocaloriePerGram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); + public double KilojoulesPerKilogram => As(SpecificEnergyUnit.KilojoulePerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); + public double KilowattDaysPerKilogram => As(SpecificEnergyUnit.KilowattDayPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); + public double KilowattDaysPerShortTon => As(SpecificEnergyUnit.KilowattDayPerShortTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); + public double KilowattDaysPerTonne => As(SpecificEnergyUnit.KilowattDayPerTonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); + public double KilowattHoursPerKilogram => As(SpecificEnergyUnit.KilowattHourPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilowattHoursPerPound => As(SpecificEnergyUnit.KilowattHourPerPound); + public double KilowattHoursPerPound => As(SpecificEnergyUnit.KilowattHourPerPound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); + public double MegajoulesPerKilogram => As(SpecificEnergyUnit.MegajoulePerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); + public double MegawattDaysPerKilogram => As(SpecificEnergyUnit.MegawattDayPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); + public double MegawattDaysPerShortTon => As(SpecificEnergyUnit.MegawattDayPerShortTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); + public double MegawattDaysPerTonne => As(SpecificEnergyUnit.MegawattDayPerTonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); + public double MegawattHoursPerKilogram => As(SpecificEnergyUnit.MegawattHourPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegawattHoursPerPound => As(SpecificEnergyUnit.MegawattHourPerPound); + public double MegawattHoursPerPound => As(SpecificEnergyUnit.MegawattHourPerPound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); + public double TerawattDaysPerKilogram => As(SpecificEnergyUnit.TerawattDayPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); + public double TerawattDaysPerShortTon => As(SpecificEnergyUnit.TerawattDayPerShortTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); + public double TerawattDaysPerTonne => As(SpecificEnergyUnit.TerawattDayPerTonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); + public double WattDaysPerKilogram => As(SpecificEnergyUnit.WattDayPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); + public double WattDaysPerShortTon => As(SpecificEnergyUnit.WattDayPerShortTon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); + public double WattDaysPerTonne => As(SpecificEnergyUnit.WattDayPerTonne); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); + public double WattHoursPerKilogram => As(SpecificEnergyUnit.WattHourPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattHoursPerPound => As(SpecificEnergyUnit.WattHourPerPound); + public double WattHoursPerPound => As(SpecificEnergyUnit.WattHourPerPound); #endregion @@ -473,7 +470,7 @@ public static string GetAbbreviation(SpecificEnergyUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static SpecificEnergy FromBtuPerPound(QuantityValue btuperpound) { - QuantityValue value = (QuantityValue) btuperpound; + double value = (double) btuperpound; return new SpecificEnergy(value, SpecificEnergyUnit.BtuPerPound); } @@ -483,7 +480,7 @@ public static SpecificEnergy FromBtuPerPound(QuantityValue btuperpound) /// If value is NaN or Infinity. public static SpecificEnergy FromCaloriesPerGram(QuantityValue caloriespergram) { - QuantityValue value = (QuantityValue) caloriespergram; + double value = (double) caloriespergram; return new SpecificEnergy(value, SpecificEnergyUnit.CaloriePerGram); } @@ -493,7 +490,7 @@ public static SpecificEnergy FromCaloriesPerGram(QuantityValue caloriespergram) /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattDaysPerKilogram(QuantityValue gigawattdaysperkilogram) { - QuantityValue value = (QuantityValue) gigawattdaysperkilogram; + double value = (double) gigawattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerKilogram); } @@ -503,7 +500,7 @@ public static SpecificEnergy FromGigawattDaysPerKilogram(QuantityValue gigawattd /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattDaysPerShortTon(QuantityValue gigawattdayspershortton) { - QuantityValue value = (QuantityValue) gigawattdayspershortton; + double value = (double) gigawattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerShortTon); } @@ -513,7 +510,7 @@ public static SpecificEnergy FromGigawattDaysPerShortTon(QuantityValue gigawattd /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattDaysPerTonne(QuantityValue gigawattdayspertonne) { - QuantityValue value = (QuantityValue) gigawattdayspertonne; + double value = (double) gigawattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattDayPerTonne); } @@ -523,7 +520,7 @@ public static SpecificEnergy FromGigawattDaysPerTonne(QuantityValue gigawattdays /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattHoursPerKilogram(QuantityValue gigawatthoursperkilogram) { - QuantityValue value = (QuantityValue) gigawatthoursperkilogram; + double value = (double) gigawatthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerKilogram); } @@ -533,7 +530,7 @@ public static SpecificEnergy FromGigawattHoursPerKilogram(QuantityValue gigawatt /// If value is NaN or Infinity. public static SpecificEnergy FromGigawattHoursPerPound(QuantityValue gigawatthoursperpound) { - QuantityValue value = (QuantityValue) gigawatthoursperpound; + double value = (double) gigawatthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.GigawattHourPerPound); } @@ -543,7 +540,7 @@ public static SpecificEnergy FromGigawattHoursPerPound(QuantityValue gigawatthou /// If value is NaN or Infinity. public static SpecificEnergy FromJoulesPerKilogram(QuantityValue joulesperkilogram) { - QuantityValue value = (QuantityValue) joulesperkilogram; + double value = (double) joulesperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.JoulePerKilogram); } @@ -553,7 +550,7 @@ public static SpecificEnergy FromJoulesPerKilogram(QuantityValue joulesperkilogr /// If value is NaN or Infinity. public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue kilocaloriespergram) { - QuantityValue value = (QuantityValue) kilocaloriespergram; + double value = (double) kilocaloriespergram; return new SpecificEnergy(value, SpecificEnergyUnit.KilocaloriePerGram); } @@ -563,7 +560,7 @@ public static SpecificEnergy FromKilocaloriesPerGram(QuantityValue kilocaloriesp /// If value is NaN or Infinity. public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue kilojoulesperkilogram) { - QuantityValue value = (QuantityValue) kilojoulesperkilogram; + double value = (double) kilojoulesperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.KilojoulePerKilogram); } @@ -573,7 +570,7 @@ public static SpecificEnergy FromKilojoulesPerKilogram(QuantityValue kilojoulesp /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattDaysPerKilogram(QuantityValue kilowattdaysperkilogram) { - QuantityValue value = (QuantityValue) kilowattdaysperkilogram; + double value = (double) kilowattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerKilogram); } @@ -583,7 +580,7 @@ public static SpecificEnergy FromKilowattDaysPerKilogram(QuantityValue kilowattd /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattDaysPerShortTon(QuantityValue kilowattdayspershortton) { - QuantityValue value = (QuantityValue) kilowattdayspershortton; + double value = (double) kilowattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerShortTon); } @@ -593,7 +590,7 @@ public static SpecificEnergy FromKilowattDaysPerShortTon(QuantityValue kilowattd /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattDaysPerTonne(QuantityValue kilowattdayspertonne) { - QuantityValue value = (QuantityValue) kilowattdayspertonne; + double value = (double) kilowattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattDayPerTonne); } @@ -603,7 +600,7 @@ public static SpecificEnergy FromKilowattDaysPerTonne(QuantityValue kilowattdays /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue kilowatthoursperkilogram) { - QuantityValue value = (QuantityValue) kilowatthoursperkilogram; + double value = (double) kilowatthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerKilogram); } @@ -613,7 +610,7 @@ public static SpecificEnergy FromKilowattHoursPerKilogram(QuantityValue kilowatt /// If value is NaN or Infinity. public static SpecificEnergy FromKilowattHoursPerPound(QuantityValue kilowatthoursperpound) { - QuantityValue value = (QuantityValue) kilowatthoursperpound; + double value = (double) kilowatthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.KilowattHourPerPound); } @@ -623,7 +620,7 @@ public static SpecificEnergy FromKilowattHoursPerPound(QuantityValue kilowatthou /// If value is NaN or Infinity. public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue megajoulesperkilogram) { - QuantityValue value = (QuantityValue) megajoulesperkilogram; + double value = (double) megajoulesperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.MegajoulePerKilogram); } @@ -633,7 +630,7 @@ public static SpecificEnergy FromMegajoulesPerKilogram(QuantityValue megajoulesp /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattDaysPerKilogram(QuantityValue megawattdaysperkilogram) { - QuantityValue value = (QuantityValue) megawattdaysperkilogram; + double value = (double) megawattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerKilogram); } @@ -643,7 +640,7 @@ public static SpecificEnergy FromMegawattDaysPerKilogram(QuantityValue megawattd /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattDaysPerShortTon(QuantityValue megawattdayspershortton) { - QuantityValue value = (QuantityValue) megawattdayspershortton; + double value = (double) megawattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerShortTon); } @@ -653,7 +650,7 @@ public static SpecificEnergy FromMegawattDaysPerShortTon(QuantityValue megawattd /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattDaysPerTonne(QuantityValue megawattdayspertonne) { - QuantityValue value = (QuantityValue) megawattdayspertonne; + double value = (double) megawattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattDayPerTonne); } @@ -663,7 +660,7 @@ public static SpecificEnergy FromMegawattDaysPerTonne(QuantityValue megawattdays /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue megawatthoursperkilogram) { - QuantityValue value = (QuantityValue) megawatthoursperkilogram; + double value = (double) megawatthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerKilogram); } @@ -673,7 +670,7 @@ public static SpecificEnergy FromMegawattHoursPerKilogram(QuantityValue megawatt /// If value is NaN or Infinity. public static SpecificEnergy FromMegawattHoursPerPound(QuantityValue megawatthoursperpound) { - QuantityValue value = (QuantityValue) megawatthoursperpound; + double value = (double) megawatthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.MegawattHourPerPound); } @@ -683,7 +680,7 @@ public static SpecificEnergy FromMegawattHoursPerPound(QuantityValue megawatthou /// If value is NaN or Infinity. public static SpecificEnergy FromTerawattDaysPerKilogram(QuantityValue terawattdaysperkilogram) { - QuantityValue value = (QuantityValue) terawattdaysperkilogram; + double value = (double) terawattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerKilogram); } @@ -693,7 +690,7 @@ public static SpecificEnergy FromTerawattDaysPerKilogram(QuantityValue terawattd /// If value is NaN or Infinity. public static SpecificEnergy FromTerawattDaysPerShortTon(QuantityValue terawattdayspershortton) { - QuantityValue value = (QuantityValue) terawattdayspershortton; + double value = (double) terawattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerShortTon); } @@ -703,7 +700,7 @@ public static SpecificEnergy FromTerawattDaysPerShortTon(QuantityValue terawattd /// If value is NaN or Infinity. public static SpecificEnergy FromTerawattDaysPerTonne(QuantityValue terawattdayspertonne) { - QuantityValue value = (QuantityValue) terawattdayspertonne; + double value = (double) terawattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.TerawattDayPerTonne); } @@ -713,7 +710,7 @@ public static SpecificEnergy FromTerawattDaysPerTonne(QuantityValue terawattdays /// If value is NaN or Infinity. public static SpecificEnergy FromWattDaysPerKilogram(QuantityValue wattdaysperkilogram) { - QuantityValue value = (QuantityValue) wattdaysperkilogram; + double value = (double) wattdaysperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerKilogram); } @@ -723,7 +720,7 @@ public static SpecificEnergy FromWattDaysPerKilogram(QuantityValue wattdaysperki /// If value is NaN or Infinity. public static SpecificEnergy FromWattDaysPerShortTon(QuantityValue wattdayspershortton) { - QuantityValue value = (QuantityValue) wattdayspershortton; + double value = (double) wattdayspershortton; return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerShortTon); } @@ -733,7 +730,7 @@ public static SpecificEnergy FromWattDaysPerShortTon(QuantityValue wattdayspersh /// If value is NaN or Infinity. public static SpecificEnergy FromWattDaysPerTonne(QuantityValue wattdayspertonne) { - QuantityValue value = (QuantityValue) wattdayspertonne; + double value = (double) wattdayspertonne; return new SpecificEnergy(value, SpecificEnergyUnit.WattDayPerTonne); } @@ -743,7 +740,7 @@ public static SpecificEnergy FromWattDaysPerTonne(QuantityValue wattdayspertonne /// If value is NaN or Infinity. public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue watthoursperkilogram) { - QuantityValue value = (QuantityValue) watthoursperkilogram; + double value = (double) watthoursperkilogram; return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerKilogram); } @@ -753,7 +750,7 @@ public static SpecificEnergy FromWattHoursPerKilogram(QuantityValue watthoursper /// If value is NaN or Infinity. public static SpecificEnergy FromWattHoursPerPound(QuantityValue watthoursperpound) { - QuantityValue value = (QuantityValue) watthoursperpound; + double value = (double) watthoursperpound; return new SpecificEnergy(value, SpecificEnergyUnit.WattHourPerPound); } @@ -765,7 +762,7 @@ public static SpecificEnergy FromWattHoursPerPound(QuantityValue watthoursperpou /// SpecificEnergy unit value. public static SpecificEnergy From(QuantityValue value, SpecificEnergyUnit fromUnit) { - return new SpecificEnergy((QuantityValue)value, fromUnit); + return new SpecificEnergy((double)value, fromUnit); } #endregion @@ -935,25 +932,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificEnergy operator *(QuantityValue left, SpecificEnergy right) + public static SpecificEnergy operator *(double left, SpecificEnergy right) { return new SpecificEnergy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificEnergy operator *(SpecificEnergy left, QuantityValue right) + public static SpecificEnergy operator *(SpecificEnergy left, double right) { return new SpecificEnergy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificEnergy operator /(SpecificEnergy left, QuantityValue right) + public static SpecificEnergy operator /(SpecificEnergy left, double right) { return new SpecificEnergy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(SpecificEnergy left, SpecificEnergy right) + public static double operator /(SpecificEnergy left, SpecificEnergy right) { return left.JoulesPerKilogram / right.JoulesPerKilogram; } @@ -986,19 +983,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEnergy left, SpecificEnergy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEnergy left, SpecificEnergy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1011,29 +995,7 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificEnergy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is SpecificEnergy objSpecificEnergy)) - return false; - return Equals(objSpecificEnergy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEnergy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1076,13 +1038,13 @@ public bool Equals(SpecificEnergy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEnergy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(SpecificEnergy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1093,7 +1055,7 @@ public bool Equals(SpecificEnergy other, QuantityValue tolerance, ComparisonType /// A hash code for the current SpecificEnergy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1104,16 +1066,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SpecificEnergyUnit unit) + public double As(SpecificEnergyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1128,12 +1091,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SpecificEnergyUnit typedUnit)) + if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSpecificEnergyUnit); } /// @@ -1165,7 +1128,7 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (SpecificEnergy)converted; } - else if (Enum.IsDefined(typeof(SpecificEnergyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1173,17 +1136,17 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEnergyUnit typedUnit)) + if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSpecificEnergyUnit, DefaultConversionFunctions); } /// @@ -1210,10 +1173,10 @@ public SpecificEnergy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SpecificEnergyUnit unit) + private double GetValueAs(SpecificEnergyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 7e4bdf3c92..26c1ea1e6f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Specific entropy is an amount of energy required to raise temperature of a substance by 1 Kelvin per unit mass. /// [DataContract] - public partial struct SpecificEntropy : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificEntropy : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static SpecificEntropy() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificEntropy(QuantityValue value, SpecificEntropyUnit unit) + public SpecificEntropy(double value, SpecificEntropyUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -94,14 +94,14 @@ public SpecificEntropy(QuantityValue value, SpecificEntropyUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificEntropy(QuantityValue value, UnitSystem unitSystem) + public SpecificEntropy(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,10 +142,7 @@ public SpecificEntropy(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -168,49 +165,49 @@ public SpecificEntropy(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); + public double BtusPerPoundFahrenheit => As(SpecificEntropyUnit.BtuPerPoundFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); + public double CaloriesPerGramKelvin => As(SpecificEntropyUnit.CaloriePerGramKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); + public double JoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); + public double JoulesPerKilogramKelvin => As(SpecificEntropyUnit.JoulePerKilogramKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); + public double KilocaloriesPerGramKelvin => As(SpecificEntropyUnit.KilocaloriePerGramKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); + public double KilojoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); + public double KilojoulesPerKilogramKelvin => As(SpecificEntropyUnit.KilojoulePerKilogramKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); + public double MegajoulesPerKilogramDegreeCelsius => As(SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); + public double MegajoulesPerKilogramKelvin => As(SpecificEntropyUnit.MegajoulePerKilogramKelvin); #endregion @@ -290,7 +287,7 @@ public static string GetAbbreviation(SpecificEntropyUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static SpecificEntropy FromBtusPerPoundFahrenheit(QuantityValue btusperpoundfahrenheit) { - QuantityValue value = (QuantityValue) btusperpoundfahrenheit; + double value = (double) btusperpoundfahrenheit; return new SpecificEntropy(value, SpecificEntropyUnit.BtuPerPoundFahrenheit); } @@ -300,7 +297,7 @@ public static SpecificEntropy FromBtusPerPoundFahrenheit(QuantityValue btusperpo /// If value is NaN or Infinity. public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue caloriespergramkelvin) { - QuantityValue value = (QuantityValue) caloriespergramkelvin; + double value = (double) caloriespergramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.CaloriePerGramKelvin); } @@ -310,7 +307,7 @@ public static SpecificEntropy FromCaloriesPerGramKelvin(QuantityValue caloriespe /// If value is NaN or Infinity. public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue joulesperkilogramdegreecelsius) { - QuantityValue value = (QuantityValue) joulesperkilogramdegreecelsius; + double value = (double) joulesperkilogramdegreecelsius; return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramDegreeCelsius); } @@ -320,7 +317,7 @@ public static SpecificEntropy FromJoulesPerKilogramDegreeCelsius(QuantityValue j /// If value is NaN or Infinity. public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue joulesperkilogramkelvin) { - QuantityValue value = (QuantityValue) joulesperkilogramkelvin; + double value = (double) joulesperkilogramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.JoulePerKilogramKelvin); } @@ -330,7 +327,7 @@ public static SpecificEntropy FromJoulesPerKilogramKelvin(QuantityValue joulespe /// If value is NaN or Infinity. public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue kilocaloriespergramkelvin) { - QuantityValue value = (QuantityValue) kilocaloriespergramkelvin; + double value = (double) kilocaloriespergramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.KilocaloriePerGramKelvin); } @@ -340,7 +337,7 @@ public static SpecificEntropy FromKilocaloriesPerGramKelvin(QuantityValue kiloca /// If value is NaN or Infinity. public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityValue kilojoulesperkilogramdegreecelsius) { - QuantityValue value = (QuantityValue) kilojoulesperkilogramdegreecelsius; + double value = (double) kilojoulesperkilogramdegreecelsius; return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramDegreeCelsius); } @@ -350,7 +347,7 @@ public static SpecificEntropy FromKilojoulesPerKilogramDegreeCelsius(QuantityVal /// If value is NaN or Infinity. public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue kilojoulesperkilogramkelvin) { - QuantityValue value = (QuantityValue) kilojoulesperkilogramkelvin; + double value = (double) kilojoulesperkilogramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.KilojoulePerKilogramKelvin); } @@ -360,7 +357,7 @@ public static SpecificEntropy FromKilojoulesPerKilogramKelvin(QuantityValue kilo /// If value is NaN or Infinity. public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityValue megajoulesperkilogramdegreecelsius) { - QuantityValue value = (QuantityValue) megajoulesperkilogramdegreecelsius; + double value = (double) megajoulesperkilogramdegreecelsius; return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramDegreeCelsius); } @@ -370,7 +367,7 @@ public static SpecificEntropy FromMegajoulesPerKilogramDegreeCelsius(QuantityVal /// If value is NaN or Infinity. public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue megajoulesperkilogramkelvin) { - QuantityValue value = (QuantityValue) megajoulesperkilogramkelvin; + double value = (double) megajoulesperkilogramkelvin; return new SpecificEntropy(value, SpecificEntropyUnit.MegajoulePerKilogramKelvin); } @@ -382,7 +379,7 @@ public static SpecificEntropy FromMegajoulesPerKilogramKelvin(QuantityValue mega /// SpecificEntropy unit value. public static SpecificEntropy From(QuantityValue value, SpecificEntropyUnit fromUnit) { - return new SpecificEntropy((QuantityValue)value, fromUnit); + return new SpecificEntropy((double)value, fromUnit); } #endregion @@ -552,25 +549,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificEntropy operator *(QuantityValue left, SpecificEntropy right) + public static SpecificEntropy operator *(double left, SpecificEntropy right) { return new SpecificEntropy(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificEntropy operator *(SpecificEntropy left, QuantityValue right) + public static SpecificEntropy operator *(SpecificEntropy left, double right) { return new SpecificEntropy(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificEntropy operator /(SpecificEntropy left, QuantityValue right) + public static SpecificEntropy operator /(SpecificEntropy left, double right) { return new SpecificEntropy(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(SpecificEntropy left, SpecificEntropy right) + public static double operator /(SpecificEntropy left, SpecificEntropy right) { return left.JoulesPerKilogramKelvin / right.JoulesPerKilogramKelvin; } @@ -603,19 +600,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificEntropy left, SpecificEntropy right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificEntropy left, SpecificEntropy right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -628,29 +612,7 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificEntropy other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is SpecificEntropy objSpecificEntropy)) - return false; - return Equals(objSpecificEntropy); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificEntropy other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -693,13 +655,13 @@ public bool Equals(SpecificEntropy other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificEntropy other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(SpecificEntropy other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -710,7 +672,7 @@ public bool Equals(SpecificEntropy other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current SpecificEntropy. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -721,16 +683,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SpecificEntropyUnit unit) + public double As(SpecificEntropyUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -745,12 +708,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SpecificEntropyUnit typedUnit)) + if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSpecificEntropyUnit); } /// @@ -782,7 +745,7 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (SpecificEntropy)converted; } - else if (Enum.IsDefined(typeof(SpecificEntropyUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -790,17 +753,17 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEntropyUnit typedUnit)) + if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSpecificEntropyUnit, DefaultConversionFunctions); } /// @@ -827,10 +790,10 @@ public SpecificEntropy ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SpecificEntropyUnit unit) + private double GetValueAs(SpecificEntropyUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index 96cd5c2aee..e295f67c8e 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thrust-specific_fuel_consumption /// [DataContract] - public partial struct SpecificFuelConsumption : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificFuelConsumption : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static SpecificFuelConsumption() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificFuelConsumption(QuantityValue value, SpecificFuelConsumptionUnit unit) + public SpecificFuelConsumption(double value, SpecificFuelConsumptionUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public SpecificFuelConsumption(QuantityValue value, SpecificFuelConsumptionUnit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) + public SpecificFuelConsumption(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public SpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,24 +163,24 @@ public SpecificFuelConsumption(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); + public double GramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); + public double KilogramsPerKilogramForceHour => As(SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); + public double KilogramsPerKiloNewtonSecond => As(SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); + public double PoundsMassPerPoundForceHour => As(SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); #endregion @@ -248,7 +245,7 @@ public static string GetAbbreviation(SpecificFuelConsumptionUnit unit, IFormatPr /// If value is NaN or Infinity. public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(QuantityValue gramsperkilonewtonsecond) { - QuantityValue value = (QuantityValue) gramsperkilonewtonsecond; + double value = (double) gramsperkilonewtonsecond; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.GramPerKiloNewtonSecond); } @@ -258,7 +255,7 @@ public static SpecificFuelConsumption FromGramsPerKiloNewtonSecond(QuantityValue /// If value is NaN or Infinity. public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(QuantityValue kilogramsperkilogramforcehour) { - QuantityValue value = (QuantityValue) kilogramsperkilogramforcehour; + double value = (double) kilogramsperkilogramforcehour; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKilogramForceHour); } @@ -268,7 +265,7 @@ public static SpecificFuelConsumption FromKilogramsPerKilogramForceHour(Quantity /// If value is NaN or Infinity. public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(QuantityValue kilogramsperkilonewtonsecond) { - QuantityValue value = (QuantityValue) kilogramsperkilonewtonsecond; + double value = (double) kilogramsperkilonewtonsecond; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.KilogramPerKiloNewtonSecond); } @@ -278,7 +275,7 @@ public static SpecificFuelConsumption FromKilogramsPerKiloNewtonSecond(QuantityV /// If value is NaN or Infinity. public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(QuantityValue poundsmassperpoundforcehour) { - QuantityValue value = (QuantityValue) poundsmassperpoundforcehour; + double value = (double) poundsmassperpoundforcehour; return new SpecificFuelConsumption(value, SpecificFuelConsumptionUnit.PoundMassPerPoundForceHour); } @@ -290,7 +287,7 @@ public static SpecificFuelConsumption FromPoundsMassPerPoundForceHour(QuantityVa /// SpecificFuelConsumption unit value. public static SpecificFuelConsumption From(QuantityValue value, SpecificFuelConsumptionUnit fromUnit) { - return new SpecificFuelConsumption((QuantityValue)value, fromUnit); + return new SpecificFuelConsumption((double)value, fromUnit); } #endregion @@ -460,25 +457,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificFuelConsumption operator *(QuantityValue left, SpecificFuelConsumption right) + public static SpecificFuelConsumption operator *(double left, SpecificFuelConsumption right) { return new SpecificFuelConsumption(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificFuelConsumption operator *(SpecificFuelConsumption left, QuantityValue right) + public static SpecificFuelConsumption operator *(SpecificFuelConsumption left, double right) { return new SpecificFuelConsumption(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificFuelConsumption operator /(SpecificFuelConsumption left, QuantityValue right) + public static SpecificFuelConsumption operator /(SpecificFuelConsumption left, double right) { return new SpecificFuelConsumption(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(SpecificFuelConsumption left, SpecificFuelConsumption right) + public static double operator /(SpecificFuelConsumption left, SpecificFuelConsumption right) { return left.GramsPerKiloNewtonSecond / right.GramsPerKiloNewtonSecond; } @@ -511,19 +508,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificFuelConsumption left, SpecificFuelConsumption right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificFuelConsumption left, SpecificFuelConsumption right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -536,29 +520,7 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificFuelConsumption other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is SpecificFuelConsumption objSpecificFuelConsumption)) - return false; - return Equals(objSpecificFuelConsumption); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificFuelConsumption other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -601,13 +563,13 @@ public bool Equals(SpecificFuelConsumption other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificFuelConsumption other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -618,7 +580,7 @@ public bool Equals(SpecificFuelConsumption other, QuantityValue tolerance, Compa /// A hash code for the current SpecificFuelConsumption. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -629,16 +591,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SpecificFuelConsumptionUnit unit) + public double As(SpecificFuelConsumptionUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -653,12 +616,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit typedUnit)) + if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSpecificFuelConsumptionUnit); } /// @@ -690,7 +653,7 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit, UnitConv var converted = conversionFunction(this); return (SpecificFuelConsumption)converted; } - else if (Enum.IsDefined(typeof(SpecificFuelConsumptionUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -698,17 +661,17 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit, UnitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit typedUnit)) + if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSpecificFuelConsumptionUnit, DefaultConversionFunctions); } /// @@ -735,10 +698,10 @@ public SpecificFuelConsumption ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SpecificFuelConsumptionUnit unit) + private double GetValueAs(SpecificFuelConsumptionUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index 4a7f1dbd7a..f15fc45a52 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In thermodynamics, the specific volume of a substance is the ratio of the substance's volume to its mass. It is the reciprocal of density and an intrinsic property of matter as well. /// [DataContract] - public partial struct SpecificVolume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificVolume : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -74,9 +74,9 @@ static SpecificVolume() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificVolume(QuantityValue value, SpecificVolumeUnit unit) + public SpecificVolume(double value, SpecificVolumeUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -88,14 +88,14 @@ public SpecificVolume(QuantityValue value, SpecificVolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificVolume(QuantityValue value, UnitSystem unitSystem) + public SpecificVolume(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -136,10 +136,7 @@ public SpecificVolume(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -162,19 +159,19 @@ public SpecificVolume(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); + public double CubicFeetPerPound => As(SpecificVolumeUnit.CubicFootPerPound); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); + public double CubicMetersPerKilogram => As(SpecificVolumeUnit.CubicMeterPerKilogram); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); + public double MillicubicMetersPerKilogram => As(SpecificVolumeUnit.MillicubicMeterPerKilogram); #endregion @@ -236,7 +233,7 @@ public static string GetAbbreviation(SpecificVolumeUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static SpecificVolume FromCubicFeetPerPound(QuantityValue cubicfeetperpound) { - QuantityValue value = (QuantityValue) cubicfeetperpound; + double value = (double) cubicfeetperpound; return new SpecificVolume(value, SpecificVolumeUnit.CubicFootPerPound); } @@ -246,7 +243,7 @@ public static SpecificVolume FromCubicFeetPerPound(QuantityValue cubicfeetperpou /// If value is NaN or Infinity. public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue cubicmetersperkilogram) { - QuantityValue value = (QuantityValue) cubicmetersperkilogram; + double value = (double) cubicmetersperkilogram; return new SpecificVolume(value, SpecificVolumeUnit.CubicMeterPerKilogram); } @@ -256,7 +253,7 @@ public static SpecificVolume FromCubicMetersPerKilogram(QuantityValue cubicmeter /// If value is NaN or Infinity. public static SpecificVolume FromMillicubicMetersPerKilogram(QuantityValue millicubicmetersperkilogram) { - QuantityValue value = (QuantityValue) millicubicmetersperkilogram; + double value = (double) millicubicmetersperkilogram; return new SpecificVolume(value, SpecificVolumeUnit.MillicubicMeterPerKilogram); } @@ -268,7 +265,7 @@ public static SpecificVolume FromMillicubicMetersPerKilogram(QuantityValue milli /// SpecificVolume unit value. public static SpecificVolume From(QuantityValue value, SpecificVolumeUnit fromUnit) { - return new SpecificVolume((QuantityValue)value, fromUnit); + return new SpecificVolume((double)value, fromUnit); } #endregion @@ -438,25 +435,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificVolume operator *(QuantityValue left, SpecificVolume right) + public static SpecificVolume operator *(double left, SpecificVolume right) { return new SpecificVolume(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificVolume operator *(SpecificVolume left, QuantityValue right) + public static SpecificVolume operator *(SpecificVolume left, double right) { return new SpecificVolume(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificVolume operator /(SpecificVolume left, QuantityValue right) + public static SpecificVolume operator /(SpecificVolume left, double right) { return new SpecificVolume(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(SpecificVolume left, SpecificVolume right) + public static double operator /(SpecificVolume left, SpecificVolume right) { return left.CubicMetersPerKilogram / right.CubicMetersPerKilogram; } @@ -489,19 +486,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificVolume left, SpecificVolume right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificVolume left, SpecificVolume right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -514,29 +498,7 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificVolume other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is SpecificVolume objSpecificVolume)) - return false; - return Equals(objSpecificVolume); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificVolume other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -579,13 +541,13 @@ public bool Equals(SpecificVolume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificVolume other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(SpecificVolume other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -596,7 +558,7 @@ public bool Equals(SpecificVolume other, QuantityValue tolerance, ComparisonType /// A hash code for the current SpecificVolume. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -607,16 +569,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SpecificVolumeUnit unit) + public double As(SpecificVolumeUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -631,12 +594,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SpecificVolumeUnit typedUnit)) + if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSpecificVolumeUnit); } /// @@ -668,7 +631,7 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (SpecificVolume)converted; } - else if (Enum.IsDefined(typeof(SpecificVolumeUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -676,17 +639,17 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificVolumeUnit typedUnit)) + if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSpecificVolumeUnit, DefaultConversionFunctions); } /// @@ -713,10 +676,10 @@ public SpecificVolume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SpecificVolumeUnit unit) + private double GetValueAs(SpecificVolumeUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index e00a8d857d..1698dbf5e8 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// http://en.wikipedia.org/wiki/Specificweight /// [DataContract] - public partial struct SpecificWeight : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct SpecificWeight : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -91,9 +91,9 @@ static SpecificWeight() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public SpecificWeight(QuantityValue value, SpecificWeightUnit unit) + public SpecificWeight(double value, SpecificWeightUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -105,14 +105,14 @@ public SpecificWeight(QuantityValue value, SpecificWeightUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public SpecificWeight(QuantityValue value, UnitSystem unitSystem) + public SpecificWeight(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -153,10 +153,7 @@ public SpecificWeight(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -179,89 +176,89 @@ public SpecificWeight(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); + public double KilogramsForcePerCubicCentimeter => As(SpecificWeightUnit.KilogramForcePerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); + public double KilogramsForcePerCubicMeter => As(SpecificWeightUnit.KilogramForcePerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); + public double KilogramsForcePerCubicMillimeter => As(SpecificWeightUnit.KilogramForcePerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); + public double KilonewtonsPerCubicCentimeter => As(SpecificWeightUnit.KilonewtonPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); + public double KilonewtonsPerCubicMeter => As(SpecificWeightUnit.KilonewtonPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); + public double KilonewtonsPerCubicMillimeter => As(SpecificWeightUnit.KilonewtonPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); + public double KilopoundsForcePerCubicFoot => As(SpecificWeightUnit.KilopoundForcePerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); + public double KilopoundsForcePerCubicInch => As(SpecificWeightUnit.KilopoundForcePerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); + public double MeganewtonsPerCubicMeter => As(SpecificWeightUnit.MeganewtonPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); + public double NewtonsPerCubicCentimeter => As(SpecificWeightUnit.NewtonPerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); + public double NewtonsPerCubicMeter => As(SpecificWeightUnit.NewtonPerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); + public double NewtonsPerCubicMillimeter => As(SpecificWeightUnit.NewtonPerCubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); + public double PoundsForcePerCubicFoot => As(SpecificWeightUnit.PoundForcePerCubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); + public double PoundsForcePerCubicInch => As(SpecificWeightUnit.PoundForcePerCubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); + public double TonnesForcePerCubicCentimeter => As(SpecificWeightUnit.TonneForcePerCubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); + public double TonnesForcePerCubicMeter => As(SpecificWeightUnit.TonneForcePerCubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); + public double TonnesForcePerCubicMillimeter => As(SpecificWeightUnit.TonneForcePerCubicMillimeter); #endregion @@ -365,7 +362,7 @@ public static string GetAbbreviation(SpecificWeightUnit unit, IFormatProvider? p /// If value is NaN or Infinity. public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue kilogramsforcepercubiccentimeter) { - QuantityValue value = (QuantityValue) kilogramsforcepercubiccentimeter; + double value = (double) kilogramsforcepercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicCentimeter); } @@ -375,7 +372,7 @@ public static SpecificWeight FromKilogramsForcePerCubicCentimeter(QuantityValue /// If value is NaN or Infinity. public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue kilogramsforcepercubicmeter) { - QuantityValue value = (QuantityValue) kilogramsforcepercubicmeter; + double value = (double) kilogramsforcepercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMeter); } @@ -385,7 +382,7 @@ public static SpecificWeight FromKilogramsForcePerCubicMeter(QuantityValue kilog /// If value is NaN or Infinity. public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue kilogramsforcepercubicmillimeter) { - QuantityValue value = (QuantityValue) kilogramsforcepercubicmillimeter; + double value = (double) kilogramsforcepercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.KilogramForcePerCubicMillimeter); } @@ -395,7 +392,7 @@ public static SpecificWeight FromKilogramsForcePerCubicMillimeter(QuantityValue /// If value is NaN or Infinity. public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue kilonewtonspercubiccentimeter) { - QuantityValue value = (QuantityValue) kilonewtonspercubiccentimeter; + double value = (double) kilonewtonspercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicCentimeter); } @@ -405,7 +402,7 @@ public static SpecificWeight FromKilonewtonsPerCubicCentimeter(QuantityValue kil /// If value is NaN or Infinity. public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue kilonewtonspercubicmeter) { - QuantityValue value = (QuantityValue) kilonewtonspercubicmeter; + double value = (double) kilonewtonspercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMeter); } @@ -415,7 +412,7 @@ public static SpecificWeight FromKilonewtonsPerCubicMeter(QuantityValue kilonewt /// If value is NaN or Infinity. public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue kilonewtonspercubicmillimeter) { - QuantityValue value = (QuantityValue) kilonewtonspercubicmillimeter; + double value = (double) kilonewtonspercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.KilonewtonPerCubicMillimeter); } @@ -425,7 +422,7 @@ public static SpecificWeight FromKilonewtonsPerCubicMillimeter(QuantityValue kil /// If value is NaN or Infinity. public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue kilopoundsforcepercubicfoot) { - QuantityValue value = (QuantityValue) kilopoundsforcepercubicfoot; + double value = (double) kilopoundsforcepercubicfoot; return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicFoot); } @@ -435,7 +432,7 @@ public static SpecificWeight FromKilopoundsForcePerCubicFoot(QuantityValue kilop /// If value is NaN or Infinity. public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue kilopoundsforcepercubicinch) { - QuantityValue value = (QuantityValue) kilopoundsforcepercubicinch; + double value = (double) kilopoundsforcepercubicinch; return new SpecificWeight(value, SpecificWeightUnit.KilopoundForcePerCubicInch); } @@ -445,7 +442,7 @@ public static SpecificWeight FromKilopoundsForcePerCubicInch(QuantityValue kilop /// If value is NaN or Infinity. public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue meganewtonspercubicmeter) { - QuantityValue value = (QuantityValue) meganewtonspercubicmeter; + double value = (double) meganewtonspercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.MeganewtonPerCubicMeter); } @@ -455,7 +452,7 @@ public static SpecificWeight FromMeganewtonsPerCubicMeter(QuantityValue meganewt /// If value is NaN or Infinity. public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue newtonspercubiccentimeter) { - QuantityValue value = (QuantityValue) newtonspercubiccentimeter; + double value = (double) newtonspercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicCentimeter); } @@ -465,7 +462,7 @@ public static SpecificWeight FromNewtonsPerCubicCentimeter(QuantityValue newtons /// If value is NaN or Infinity. public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue newtonspercubicmeter) { - QuantityValue value = (QuantityValue) newtonspercubicmeter; + double value = (double) newtonspercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMeter); } @@ -475,7 +472,7 @@ public static SpecificWeight FromNewtonsPerCubicMeter(QuantityValue newtonspercu /// If value is NaN or Infinity. public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue newtonspercubicmillimeter) { - QuantityValue value = (QuantityValue) newtonspercubicmillimeter; + double value = (double) newtonspercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.NewtonPerCubicMillimeter); } @@ -485,7 +482,7 @@ public static SpecificWeight FromNewtonsPerCubicMillimeter(QuantityValue newtons /// If value is NaN or Infinity. public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue poundsforcepercubicfoot) { - QuantityValue value = (QuantityValue) poundsforcepercubicfoot; + double value = (double) poundsforcepercubicfoot; return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicFoot); } @@ -495,7 +492,7 @@ public static SpecificWeight FromPoundsForcePerCubicFoot(QuantityValue poundsfor /// If value is NaN or Infinity. public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue poundsforcepercubicinch) { - QuantityValue value = (QuantityValue) poundsforcepercubicinch; + double value = (double) poundsforcepercubicinch; return new SpecificWeight(value, SpecificWeightUnit.PoundForcePerCubicInch); } @@ -505,7 +502,7 @@ public static SpecificWeight FromPoundsForcePerCubicInch(QuantityValue poundsfor /// If value is NaN or Infinity. public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue tonnesforcepercubiccentimeter) { - QuantityValue value = (QuantityValue) tonnesforcepercubiccentimeter; + double value = (double) tonnesforcepercubiccentimeter; return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicCentimeter); } @@ -515,7 +512,7 @@ public static SpecificWeight FromTonnesForcePerCubicCentimeter(QuantityValue ton /// If value is NaN or Infinity. public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue tonnesforcepercubicmeter) { - QuantityValue value = (QuantityValue) tonnesforcepercubicmeter; + double value = (double) tonnesforcepercubicmeter; return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMeter); } @@ -525,7 +522,7 @@ public static SpecificWeight FromTonnesForcePerCubicMeter(QuantityValue tonnesfo /// If value is NaN or Infinity. public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue tonnesforcepercubicmillimeter) { - QuantityValue value = (QuantityValue) tonnesforcepercubicmillimeter; + double value = (double) tonnesforcepercubicmillimeter; return new SpecificWeight(value, SpecificWeightUnit.TonneForcePerCubicMillimeter); } @@ -537,7 +534,7 @@ public static SpecificWeight FromTonnesForcePerCubicMillimeter(QuantityValue ton /// SpecificWeight unit value. public static SpecificWeight From(QuantityValue value, SpecificWeightUnit fromUnit) { - return new SpecificWeight((QuantityValue)value, fromUnit); + return new SpecificWeight((double)value, fromUnit); } #endregion @@ -707,25 +704,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci } /// Get from multiplying value and . - public static SpecificWeight operator *(QuantityValue left, SpecificWeight right) + public static SpecificWeight operator *(double left, SpecificWeight right) { return new SpecificWeight(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static SpecificWeight operator *(SpecificWeight left, QuantityValue right) + public static SpecificWeight operator *(SpecificWeight left, double right) { return new SpecificWeight(left.Value * right, left.Unit); } /// Get from dividing by value. - public static SpecificWeight operator /(SpecificWeight left, QuantityValue right) + public static SpecificWeight operator /(SpecificWeight left, double right) { return new SpecificWeight(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(SpecificWeight left, SpecificWeight right) + public static double operator /(SpecificWeight left, SpecificWeight right) { return left.NewtonsPerCubicMeter / right.NewtonsPerCubicMeter; } @@ -758,19 +755,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speci return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(SpecificWeight left, SpecificWeight right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(SpecificWeight left, SpecificWeight right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -783,29 +767,7 @@ public int CompareTo(object obj) /// public int CompareTo(SpecificWeight other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is SpecificWeight objSpecificWeight)) - return false; - return Equals(objSpecificWeight); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(SpecificWeight other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -848,13 +810,13 @@ public bool Equals(SpecificWeight other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(SpecificWeight other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(SpecificWeight other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -865,7 +827,7 @@ public bool Equals(SpecificWeight other, QuantityValue tolerance, ComparisonType /// A hash code for the current SpecificWeight. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -876,16 +838,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SpecificWeightUnit unit) + public double As(SpecificWeightUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -900,12 +863,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SpecificWeightUnit typedUnit)) + if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSpecificWeightUnit); } /// @@ -937,7 +900,7 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit, UnitConverter unitConverte var converted = conversionFunction(this); return (SpecificWeight)converted; } - else if (Enum.IsDefined(typeof(SpecificWeightUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -945,17 +908,17 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit, UnitConverter unitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificWeightUnit typedUnit)) + if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSpecificWeightUnit, DefaultConversionFunctions); } /// @@ -982,10 +945,10 @@ public SpecificWeight ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SpecificWeightUnit unit) + private double GetValueAs(SpecificWeightUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index e28ac87c05..f064d928b9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In everyday use and in kinematics, the speed of an object is the magnitude of its velocity (the rate of change of its position); it is thus a scalar quantity.[1] The average speed of an object in an interval of time is the distance travelled by the object divided by the duration of the interval;[2] the instantaneous speed is the limit of the average speed as the duration of the time interval approaches zero. /// [DataContract] - public partial struct Speed : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Speed : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -103,9 +103,9 @@ static Speed() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Speed(QuantityValue value, SpeedUnit unit) + public Speed(double value, SpeedUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -117,14 +117,14 @@ public Speed(QuantityValue value, SpeedUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Speed(QuantityValue value, UnitSystem unitSystem) + public Speed(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -165,10 +165,7 @@ public Speed(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -191,164 +188,164 @@ public Speed(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); + public double CentimetersPerHour => As(SpeedUnit.CentimeterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); + public double CentimetersPerMinutes => As(SpeedUnit.CentimeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); + public double CentimetersPerSecond => As(SpeedUnit.CentimeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); + public double DecimetersPerMinutes => As(SpeedUnit.DecimeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); + public double DecimetersPerSecond => As(SpeedUnit.DecimeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetPerHour => As(SpeedUnit.FootPerHour); + public double FeetPerHour => As(SpeedUnit.FootPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetPerMinute => As(SpeedUnit.FootPerMinute); + public double FeetPerMinute => As(SpeedUnit.FootPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetPerSecond => As(SpeedUnit.FootPerSecond); + public double FeetPerSecond => As(SpeedUnit.FootPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesPerHour => As(SpeedUnit.InchPerHour); + public double InchesPerHour => As(SpeedUnit.InchPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesPerMinute => As(SpeedUnit.InchPerMinute); + public double InchesPerMinute => As(SpeedUnit.InchPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesPerSecond => As(SpeedUnit.InchPerSecond); + public double InchesPerSecond => As(SpeedUnit.InchPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilometersPerHour => As(SpeedUnit.KilometerPerHour); + public double KilometersPerHour => As(SpeedUnit.KilometerPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); + public double KilometersPerMinutes => As(SpeedUnit.KilometerPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); + public double KilometersPerSecond => As(SpeedUnit.KilometerPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Knots => As(SpeedUnit.Knot); + public double Knots => As(SpeedUnit.Knot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersPerHour => As(SpeedUnit.MeterPerHour); + public double MetersPerHour => As(SpeedUnit.MeterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersPerMinutes => As(SpeedUnit.MeterPerMinute); + public double MetersPerMinutes => As(SpeedUnit.MeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersPerSecond => As(SpeedUnit.MeterPerSecond); + public double MetersPerSecond => As(SpeedUnit.MeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); + public double MicrometersPerMinutes => As(SpeedUnit.MicrometerPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); + public double MicrometersPerSecond => As(SpeedUnit.MicrometerPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MilesPerHour => As(SpeedUnit.MilePerHour); + public double MilesPerHour => As(SpeedUnit.MilePerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); + public double MillimetersPerHour => As(SpeedUnit.MillimeterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); + public double MillimetersPerMinutes => As(SpeedUnit.MillimeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); + public double MillimetersPerSecond => As(SpeedUnit.MillimeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); + public double NanometersPerMinutes => As(SpeedUnit.NanometerPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); + public double NanometersPerSecond => As(SpeedUnit.NanometerPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); + public double UsSurveyFeetPerHour => As(SpeedUnit.UsSurveyFootPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); + public double UsSurveyFeetPerMinute => As(SpeedUnit.UsSurveyFootPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); + public double UsSurveyFeetPerSecond => As(SpeedUnit.UsSurveyFootPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue YardsPerHour => As(SpeedUnit.YardPerHour); + public double YardsPerHour => As(SpeedUnit.YardPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue YardsPerMinute => As(SpeedUnit.YardPerMinute); + public double YardsPerMinute => As(SpeedUnit.YardPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue YardsPerSecond => As(SpeedUnit.YardPerSecond); + public double YardsPerSecond => As(SpeedUnit.YardPerSecond); #endregion @@ -520,7 +517,7 @@ public static string GetAbbreviation(SpeedUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Speed FromCentimetersPerHour(QuantityValue centimetersperhour) { - QuantityValue value = (QuantityValue) centimetersperhour; + double value = (double) centimetersperhour; return new Speed(value, SpeedUnit.CentimeterPerHour); } @@ -530,7 +527,7 @@ public static Speed FromCentimetersPerHour(QuantityValue centimetersperhour) /// If value is NaN or Infinity. public static Speed FromCentimetersPerMinutes(QuantityValue centimetersperminutes) { - QuantityValue value = (QuantityValue) centimetersperminutes; + double value = (double) centimetersperminutes; return new Speed(value, SpeedUnit.CentimeterPerMinute); } @@ -540,7 +537,7 @@ public static Speed FromCentimetersPerMinutes(QuantityValue centimetersperminute /// If value is NaN or Infinity. public static Speed FromCentimetersPerSecond(QuantityValue centimeterspersecond) { - QuantityValue value = (QuantityValue) centimeterspersecond; + double value = (double) centimeterspersecond; return new Speed(value, SpeedUnit.CentimeterPerSecond); } @@ -550,7 +547,7 @@ public static Speed FromCentimetersPerSecond(QuantityValue centimeterspersecond) /// If value is NaN or Infinity. public static Speed FromDecimetersPerMinutes(QuantityValue decimetersperminutes) { - QuantityValue value = (QuantityValue) decimetersperminutes; + double value = (double) decimetersperminutes; return new Speed(value, SpeedUnit.DecimeterPerMinute); } @@ -560,7 +557,7 @@ public static Speed FromDecimetersPerMinutes(QuantityValue decimetersperminutes) /// If value is NaN or Infinity. public static Speed FromDecimetersPerSecond(QuantityValue decimeterspersecond) { - QuantityValue value = (QuantityValue) decimeterspersecond; + double value = (double) decimeterspersecond; return new Speed(value, SpeedUnit.DecimeterPerSecond); } @@ -570,7 +567,7 @@ public static Speed FromDecimetersPerSecond(QuantityValue decimeterspersecond) /// If value is NaN or Infinity. public static Speed FromFeetPerHour(QuantityValue feetperhour) { - QuantityValue value = (QuantityValue) feetperhour; + double value = (double) feetperhour; return new Speed(value, SpeedUnit.FootPerHour); } @@ -580,7 +577,7 @@ public static Speed FromFeetPerHour(QuantityValue feetperhour) /// If value is NaN or Infinity. public static Speed FromFeetPerMinute(QuantityValue feetperminute) { - QuantityValue value = (QuantityValue) feetperminute; + double value = (double) feetperminute; return new Speed(value, SpeedUnit.FootPerMinute); } @@ -590,7 +587,7 @@ public static Speed FromFeetPerMinute(QuantityValue feetperminute) /// If value is NaN or Infinity. public static Speed FromFeetPerSecond(QuantityValue feetpersecond) { - QuantityValue value = (QuantityValue) feetpersecond; + double value = (double) feetpersecond; return new Speed(value, SpeedUnit.FootPerSecond); } @@ -600,7 +597,7 @@ public static Speed FromFeetPerSecond(QuantityValue feetpersecond) /// If value is NaN or Infinity. public static Speed FromInchesPerHour(QuantityValue inchesperhour) { - QuantityValue value = (QuantityValue) inchesperhour; + double value = (double) inchesperhour; return new Speed(value, SpeedUnit.InchPerHour); } @@ -610,7 +607,7 @@ public static Speed FromInchesPerHour(QuantityValue inchesperhour) /// If value is NaN or Infinity. public static Speed FromInchesPerMinute(QuantityValue inchesperminute) { - QuantityValue value = (QuantityValue) inchesperminute; + double value = (double) inchesperminute; return new Speed(value, SpeedUnit.InchPerMinute); } @@ -620,7 +617,7 @@ public static Speed FromInchesPerMinute(QuantityValue inchesperminute) /// If value is NaN or Infinity. public static Speed FromInchesPerSecond(QuantityValue inchespersecond) { - QuantityValue value = (QuantityValue) inchespersecond; + double value = (double) inchespersecond; return new Speed(value, SpeedUnit.InchPerSecond); } @@ -630,7 +627,7 @@ public static Speed FromInchesPerSecond(QuantityValue inchespersecond) /// If value is NaN or Infinity. public static Speed FromKilometersPerHour(QuantityValue kilometersperhour) { - QuantityValue value = (QuantityValue) kilometersperhour; + double value = (double) kilometersperhour; return new Speed(value, SpeedUnit.KilometerPerHour); } @@ -640,7 +637,7 @@ public static Speed FromKilometersPerHour(QuantityValue kilometersperhour) /// If value is NaN or Infinity. public static Speed FromKilometersPerMinutes(QuantityValue kilometersperminutes) { - QuantityValue value = (QuantityValue) kilometersperminutes; + double value = (double) kilometersperminutes; return new Speed(value, SpeedUnit.KilometerPerMinute); } @@ -650,7 +647,7 @@ public static Speed FromKilometersPerMinutes(QuantityValue kilometersperminutes) /// If value is NaN or Infinity. public static Speed FromKilometersPerSecond(QuantityValue kilometerspersecond) { - QuantityValue value = (QuantityValue) kilometerspersecond; + double value = (double) kilometerspersecond; return new Speed(value, SpeedUnit.KilometerPerSecond); } @@ -660,7 +657,7 @@ public static Speed FromKilometersPerSecond(QuantityValue kilometerspersecond) /// If value is NaN or Infinity. public static Speed FromKnots(QuantityValue knots) { - QuantityValue value = (QuantityValue) knots; + double value = (double) knots; return new Speed(value, SpeedUnit.Knot); } @@ -670,7 +667,7 @@ public static Speed FromKnots(QuantityValue knots) /// If value is NaN or Infinity. public static Speed FromMetersPerHour(QuantityValue metersperhour) { - QuantityValue value = (QuantityValue) metersperhour; + double value = (double) metersperhour; return new Speed(value, SpeedUnit.MeterPerHour); } @@ -680,7 +677,7 @@ public static Speed FromMetersPerHour(QuantityValue metersperhour) /// If value is NaN or Infinity. public static Speed FromMetersPerMinutes(QuantityValue metersperminutes) { - QuantityValue value = (QuantityValue) metersperminutes; + double value = (double) metersperminutes; return new Speed(value, SpeedUnit.MeterPerMinute); } @@ -690,7 +687,7 @@ public static Speed FromMetersPerMinutes(QuantityValue metersperminutes) /// If value is NaN or Infinity. public static Speed FromMetersPerSecond(QuantityValue meterspersecond) { - QuantityValue value = (QuantityValue) meterspersecond; + double value = (double) meterspersecond; return new Speed(value, SpeedUnit.MeterPerSecond); } @@ -700,7 +697,7 @@ public static Speed FromMetersPerSecond(QuantityValue meterspersecond) /// If value is NaN or Infinity. public static Speed FromMicrometersPerMinutes(QuantityValue micrometersperminutes) { - QuantityValue value = (QuantityValue) micrometersperminutes; + double value = (double) micrometersperminutes; return new Speed(value, SpeedUnit.MicrometerPerMinute); } @@ -710,7 +707,7 @@ public static Speed FromMicrometersPerMinutes(QuantityValue micrometersperminute /// If value is NaN or Infinity. public static Speed FromMicrometersPerSecond(QuantityValue micrometerspersecond) { - QuantityValue value = (QuantityValue) micrometerspersecond; + double value = (double) micrometerspersecond; return new Speed(value, SpeedUnit.MicrometerPerSecond); } @@ -720,7 +717,7 @@ public static Speed FromMicrometersPerSecond(QuantityValue micrometerspersecond) /// If value is NaN or Infinity. public static Speed FromMilesPerHour(QuantityValue milesperhour) { - QuantityValue value = (QuantityValue) milesperhour; + double value = (double) milesperhour; return new Speed(value, SpeedUnit.MilePerHour); } @@ -730,7 +727,7 @@ public static Speed FromMilesPerHour(QuantityValue milesperhour) /// If value is NaN or Infinity. public static Speed FromMillimetersPerHour(QuantityValue millimetersperhour) { - QuantityValue value = (QuantityValue) millimetersperhour; + double value = (double) millimetersperhour; return new Speed(value, SpeedUnit.MillimeterPerHour); } @@ -740,7 +737,7 @@ public static Speed FromMillimetersPerHour(QuantityValue millimetersperhour) /// If value is NaN or Infinity. public static Speed FromMillimetersPerMinutes(QuantityValue millimetersperminutes) { - QuantityValue value = (QuantityValue) millimetersperminutes; + double value = (double) millimetersperminutes; return new Speed(value, SpeedUnit.MillimeterPerMinute); } @@ -750,7 +747,7 @@ public static Speed FromMillimetersPerMinutes(QuantityValue millimetersperminute /// If value is NaN or Infinity. public static Speed FromMillimetersPerSecond(QuantityValue millimeterspersecond) { - QuantityValue value = (QuantityValue) millimeterspersecond; + double value = (double) millimeterspersecond; return new Speed(value, SpeedUnit.MillimeterPerSecond); } @@ -760,7 +757,7 @@ public static Speed FromMillimetersPerSecond(QuantityValue millimeterspersecond) /// If value is NaN or Infinity. public static Speed FromNanometersPerMinutes(QuantityValue nanometersperminutes) { - QuantityValue value = (QuantityValue) nanometersperminutes; + double value = (double) nanometersperminutes; return new Speed(value, SpeedUnit.NanometerPerMinute); } @@ -770,7 +767,7 @@ public static Speed FromNanometersPerMinutes(QuantityValue nanometersperminutes) /// If value is NaN or Infinity. public static Speed FromNanometersPerSecond(QuantityValue nanometerspersecond) { - QuantityValue value = (QuantityValue) nanometerspersecond; + double value = (double) nanometerspersecond; return new Speed(value, SpeedUnit.NanometerPerSecond); } @@ -780,7 +777,7 @@ public static Speed FromNanometersPerSecond(QuantityValue nanometerspersecond) /// If value is NaN or Infinity. public static Speed FromUsSurveyFeetPerHour(QuantityValue ussurveyfeetperhour) { - QuantityValue value = (QuantityValue) ussurveyfeetperhour; + double value = (double) ussurveyfeetperhour; return new Speed(value, SpeedUnit.UsSurveyFootPerHour); } @@ -790,7 +787,7 @@ public static Speed FromUsSurveyFeetPerHour(QuantityValue ussurveyfeetperhour) /// If value is NaN or Infinity. public static Speed FromUsSurveyFeetPerMinute(QuantityValue ussurveyfeetperminute) { - QuantityValue value = (QuantityValue) ussurveyfeetperminute; + double value = (double) ussurveyfeetperminute; return new Speed(value, SpeedUnit.UsSurveyFootPerMinute); } @@ -800,7 +797,7 @@ public static Speed FromUsSurveyFeetPerMinute(QuantityValue ussurveyfeetperminut /// If value is NaN or Infinity. public static Speed FromUsSurveyFeetPerSecond(QuantityValue ussurveyfeetpersecond) { - QuantityValue value = (QuantityValue) ussurveyfeetpersecond; + double value = (double) ussurveyfeetpersecond; return new Speed(value, SpeedUnit.UsSurveyFootPerSecond); } @@ -810,7 +807,7 @@ public static Speed FromUsSurveyFeetPerSecond(QuantityValue ussurveyfeetpersecon /// If value is NaN or Infinity. public static Speed FromYardsPerHour(QuantityValue yardsperhour) { - QuantityValue value = (QuantityValue) yardsperhour; + double value = (double) yardsperhour; return new Speed(value, SpeedUnit.YardPerHour); } @@ -820,7 +817,7 @@ public static Speed FromYardsPerHour(QuantityValue yardsperhour) /// If value is NaN or Infinity. public static Speed FromYardsPerMinute(QuantityValue yardsperminute) { - QuantityValue value = (QuantityValue) yardsperminute; + double value = (double) yardsperminute; return new Speed(value, SpeedUnit.YardPerMinute); } @@ -830,7 +827,7 @@ public static Speed FromYardsPerMinute(QuantityValue yardsperminute) /// If value is NaN or Infinity. public static Speed FromYardsPerSecond(QuantityValue yardspersecond) { - QuantityValue value = (QuantityValue) yardspersecond; + double value = (double) yardspersecond; return new Speed(value, SpeedUnit.YardPerSecond); } @@ -842,7 +839,7 @@ public static Speed FromYardsPerSecond(QuantityValue yardspersecond) /// Speed unit value. public static Speed From(QuantityValue value, SpeedUnit fromUnit) { - return new Speed((QuantityValue)value, fromUnit); + return new Speed((double)value, fromUnit); } #endregion @@ -1012,25 +1009,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed } /// Get from multiplying value and . - public static Speed operator *(QuantityValue left, Speed right) + public static Speed operator *(double left, Speed right) { return new Speed(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Speed operator *(Speed left, QuantityValue right) + public static Speed operator *(Speed left, double right) { return new Speed(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Speed operator /(Speed left, QuantityValue right) + public static Speed operator /(Speed left, double right) { return new Speed(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Speed left, Speed right) + public static double operator /(Speed left, Speed right) { return left.MetersPerSecond / right.MetersPerSecond; } @@ -1063,19 +1060,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Speed return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Speed left, Speed right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Speed left, Speed right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1088,29 +1072,7 @@ public int CompareTo(object obj) /// public int CompareTo(Speed other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Speed objSpeed)) - return false; - return Equals(objSpeed); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Speed other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1153,13 +1115,13 @@ public bool Equals(Speed other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Speed other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1170,7 +1132,7 @@ public bool Equals(Speed other, QuantityValue tolerance, ComparisonType comparis /// A hash code for the current Speed. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1181,16 +1143,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(SpeedUnit unit) + public double As(SpeedUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1205,12 +1168,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is SpeedUnit typedUnit)) + if (!(unit is SpeedUnit unitAsSpeedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsSpeedUnit); } /// @@ -1242,7 +1205,7 @@ public Speed ToUnit(SpeedUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Speed)converted; } - else if (Enum.IsDefined(typeof(SpeedUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1250,17 +1213,17 @@ public Speed ToUnit(SpeedUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpeedUnit typedUnit)) + if (!(unit is SpeedUnit unitAsSpeedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsSpeedUnit, DefaultConversionFunctions); } /// @@ -1287,10 +1250,10 @@ public Speed ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(SpeedUnit unit) + private double GetValueAs(SpeedUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 9cc738ec93..9267650cd1 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The molar flow rate of a gas corrected to standardized conditions of temperature and pressure thus representing a fixed number of moles of gas regardless of composition and actual flow conditions. /// [DataContract] - public partial struct StandardVolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct StandardVolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static StandardVolumeFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public StandardVolumeFlow(QuantityValue value, StandardVolumeFlowUnit unit) + public StandardVolumeFlow(double value, StandardVolumeFlowUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -94,14 +94,14 @@ public StandardVolumeFlow(QuantityValue value, StandardVolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public StandardVolumeFlow(QuantityValue value, UnitSystem unitSystem) + public StandardVolumeFlow(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,10 +142,7 @@ public StandardVolumeFlow(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -168,49 +165,49 @@ public StandardVolumeFlow(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); + public double StandardCubicCentimetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); + public double StandardCubicFeetPerHour => As(StandardVolumeFlowUnit.StandardCubicFootPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); + public double StandardCubicFeetPerMinute => As(StandardVolumeFlowUnit.StandardCubicFootPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); + public double StandardCubicFeetPerSecond => As(StandardVolumeFlowUnit.StandardCubicFootPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); + public double StandardCubicMetersPerDay => As(StandardVolumeFlowUnit.StandardCubicMeterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); + public double StandardCubicMetersPerHour => As(StandardVolumeFlowUnit.StandardCubicMeterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); + public double StandardCubicMetersPerMinute => As(StandardVolumeFlowUnit.StandardCubicMeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); + public double StandardCubicMetersPerSecond => As(StandardVolumeFlowUnit.StandardCubicMeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); + public double StandardLitersPerMinute => As(StandardVolumeFlowUnit.StandardLiterPerMinute); #endregion @@ -290,7 +287,7 @@ public static string GetAbbreviation(StandardVolumeFlowUnit unit, IFormatProvide /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(QuantityValue standardcubiccentimetersperminute) { - QuantityValue value = (QuantityValue) standardcubiccentimetersperminute; + double value = (double) standardcubiccentimetersperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicCentimeterPerMinute); } @@ -300,7 +297,7 @@ public static StandardVolumeFlow FromStandardCubicCentimetersPerMinute(QuantityV /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicFeetPerHour(QuantityValue standardcubicfeetperhour) { - QuantityValue value = (QuantityValue) standardcubicfeetperhour; + double value = (double) standardcubicfeetperhour; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerHour); } @@ -310,7 +307,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerHour(QuantityValue stan /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicFeetPerMinute(QuantityValue standardcubicfeetperminute) { - QuantityValue value = (QuantityValue) standardcubicfeetperminute; + double value = (double) standardcubicfeetperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerMinute); } @@ -320,7 +317,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerMinute(QuantityValue st /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicFeetPerSecond(QuantityValue standardcubicfeetpersecond) { - QuantityValue value = (QuantityValue) standardcubicfeetpersecond; + double value = (double) standardcubicfeetpersecond; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicFootPerSecond); } @@ -330,7 +327,7 @@ public static StandardVolumeFlow FromStandardCubicFeetPerSecond(QuantityValue st /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerDay(QuantityValue standardcubicmetersperday) { - QuantityValue value = (QuantityValue) standardcubicmetersperday; + double value = (double) standardcubicmetersperday; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerDay); } @@ -340,7 +337,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerDay(QuantityValue sta /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerHour(QuantityValue standardcubicmetersperhour) { - QuantityValue value = (QuantityValue) standardcubicmetersperhour; + double value = (double) standardcubicmetersperhour; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerHour); } @@ -350,7 +347,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerHour(QuantityValue st /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerMinute(QuantityValue standardcubicmetersperminute) { - QuantityValue value = (QuantityValue) standardcubicmetersperminute; + double value = (double) standardcubicmetersperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerMinute); } @@ -360,7 +357,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerMinute(QuantityValue /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardCubicMetersPerSecond(QuantityValue standardcubicmeterspersecond) { - QuantityValue value = (QuantityValue) standardcubicmeterspersecond; + double value = (double) standardcubicmeterspersecond; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardCubicMeterPerSecond); } @@ -370,7 +367,7 @@ public static StandardVolumeFlow FromStandardCubicMetersPerSecond(QuantityValue /// If value is NaN or Infinity. public static StandardVolumeFlow FromStandardLitersPerMinute(QuantityValue standardlitersperminute) { - QuantityValue value = (QuantityValue) standardlitersperminute; + double value = (double) standardlitersperminute; return new StandardVolumeFlow(value, StandardVolumeFlowUnit.StandardLiterPerMinute); } @@ -382,7 +379,7 @@ public static StandardVolumeFlow FromStandardLitersPerMinute(QuantityValue stand /// StandardVolumeFlow unit value. public static StandardVolumeFlow From(QuantityValue value, StandardVolumeFlowUnit fromUnit) { - return new StandardVolumeFlow((QuantityValue)value, fromUnit); + return new StandardVolumeFlow((double)value, fromUnit); } #endregion @@ -552,25 +549,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand } /// Get from multiplying value and . - public static StandardVolumeFlow operator *(QuantityValue left, StandardVolumeFlow right) + public static StandardVolumeFlow operator *(double left, StandardVolumeFlow right) { return new StandardVolumeFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static StandardVolumeFlow operator *(StandardVolumeFlow left, QuantityValue right) + public static StandardVolumeFlow operator *(StandardVolumeFlow left, double right) { return new StandardVolumeFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static StandardVolumeFlow operator /(StandardVolumeFlow left, QuantityValue right) + public static StandardVolumeFlow operator /(StandardVolumeFlow left, double right) { return new StandardVolumeFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(StandardVolumeFlow left, StandardVolumeFlow right) + public static double operator /(StandardVolumeFlow left, StandardVolumeFlow right) { return left.StandardCubicMetersPerSecond / right.StandardCubicMetersPerSecond; } @@ -603,19 +600,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Stand return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(StandardVolumeFlow left, StandardVolumeFlow right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(StandardVolumeFlow left, StandardVolumeFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -628,29 +612,7 @@ public int CompareTo(object obj) /// public int CompareTo(StandardVolumeFlow other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is StandardVolumeFlow objStandardVolumeFlow)) - return false; - return Equals(objStandardVolumeFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(StandardVolumeFlow other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -693,13 +655,13 @@ public bool Equals(StandardVolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(StandardVolumeFlow other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -710,7 +672,7 @@ public bool Equals(StandardVolumeFlow other, QuantityValue tolerance, Comparison /// A hash code for the current StandardVolumeFlow. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -721,16 +683,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(StandardVolumeFlowUnit unit) + public double As(StandardVolumeFlowUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -745,12 +708,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is StandardVolumeFlowUnit typedUnit)) + if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsStandardVolumeFlowUnit); } /// @@ -782,7 +745,7 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit, UnitConverter unit var converted = conversionFunction(this); return (StandardVolumeFlow)converted; } - else if (Enum.IsDefined(typeof(StandardVolumeFlowUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -790,17 +753,17 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit, UnitConverter unit } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is StandardVolumeFlowUnit typedUnit)) + if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsStandardVolumeFlowUnit, DefaultConversionFunctions); } /// @@ -827,10 +790,10 @@ public StandardVolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(StandardVolumeFlowUnit unit) + private double GetValueAs(StandardVolumeFlowUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 82d5b8ebe8..9b314a7349 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A temperature is a numerical measure of hot or cold. Its measurement is by detection of heat radiation or particle velocity or kinetic energy, or by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. The fundamental physical definition of temperature is provided by thermodynamics. /// [DataContract] - public partial struct Temperature : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Temperature : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static Temperature() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Temperature(QuantityValue value, TemperatureUnit unit) + public Temperature(double value, TemperatureUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -95,14 +95,14 @@ public Temperature(QuantityValue value, TemperatureUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Temperature(QuantityValue value, UnitSystem unitSystem) + public Temperature(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,10 +143,7 @@ public Temperature(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -169,54 +166,54 @@ public Temperature(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelsius => As(TemperatureUnit.DegreeCelsius); + public double DegreesCelsius => As(TemperatureUnit.DegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesDelisle => As(TemperatureUnit.DegreeDelisle); + public double DegreesDelisle => As(TemperatureUnit.DegreeDelisle); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); + public double DegreesFahrenheit => As(TemperatureUnit.DegreeFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesNewton => As(TemperatureUnit.DegreeNewton); + public double DegreesNewton => As(TemperatureUnit.DegreeNewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesRankine => As(TemperatureUnit.DegreeRankine); + public double DegreesRankine => As(TemperatureUnit.DegreeRankine); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesReaumur => As(TemperatureUnit.DegreeReaumur); + public double DegreesReaumur => As(TemperatureUnit.DegreeReaumur); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesRoemer => As(TemperatureUnit.DegreeRoemer); + public double DegreesRoemer => As(TemperatureUnit.DegreeRoemer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kelvins => As(TemperatureUnit.Kelvin); + public double Kelvins => As(TemperatureUnit.Kelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); + public double MillidegreesCelsius => As(TemperatureUnit.MillidegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SolarTemperatures => As(TemperatureUnit.SolarTemperature); + public double SolarTemperatures => As(TemperatureUnit.SolarTemperature); #endregion @@ -299,7 +296,7 @@ public static string GetAbbreviation(TemperatureUnit unit, IFormatProvider? prov /// If value is NaN or Infinity. public static Temperature FromDegreesCelsius(QuantityValue degreescelsius) { - QuantityValue value = (QuantityValue) degreescelsius; + double value = (double) degreescelsius; return new Temperature(value, TemperatureUnit.DegreeCelsius); } @@ -309,7 +306,7 @@ public static Temperature FromDegreesCelsius(QuantityValue degreescelsius) /// If value is NaN or Infinity. public static Temperature FromDegreesDelisle(QuantityValue degreesdelisle) { - QuantityValue value = (QuantityValue) degreesdelisle; + double value = (double) degreesdelisle; return new Temperature(value, TemperatureUnit.DegreeDelisle); } @@ -319,7 +316,7 @@ public static Temperature FromDegreesDelisle(QuantityValue degreesdelisle) /// If value is NaN or Infinity. public static Temperature FromDegreesFahrenheit(QuantityValue degreesfahrenheit) { - QuantityValue value = (QuantityValue) degreesfahrenheit; + double value = (double) degreesfahrenheit; return new Temperature(value, TemperatureUnit.DegreeFahrenheit); } @@ -329,7 +326,7 @@ public static Temperature FromDegreesFahrenheit(QuantityValue degreesfahrenheit) /// If value is NaN or Infinity. public static Temperature FromDegreesNewton(QuantityValue degreesnewton) { - QuantityValue value = (QuantityValue) degreesnewton; + double value = (double) degreesnewton; return new Temperature(value, TemperatureUnit.DegreeNewton); } @@ -339,7 +336,7 @@ public static Temperature FromDegreesNewton(QuantityValue degreesnewton) /// If value is NaN or Infinity. public static Temperature FromDegreesRankine(QuantityValue degreesrankine) { - QuantityValue value = (QuantityValue) degreesrankine; + double value = (double) degreesrankine; return new Temperature(value, TemperatureUnit.DegreeRankine); } @@ -349,7 +346,7 @@ public static Temperature FromDegreesRankine(QuantityValue degreesrankine) /// If value is NaN or Infinity. public static Temperature FromDegreesReaumur(QuantityValue degreesreaumur) { - QuantityValue value = (QuantityValue) degreesreaumur; + double value = (double) degreesreaumur; return new Temperature(value, TemperatureUnit.DegreeReaumur); } @@ -359,7 +356,7 @@ public static Temperature FromDegreesReaumur(QuantityValue degreesreaumur) /// If value is NaN or Infinity. public static Temperature FromDegreesRoemer(QuantityValue degreesroemer) { - QuantityValue value = (QuantityValue) degreesroemer; + double value = (double) degreesroemer; return new Temperature(value, TemperatureUnit.DegreeRoemer); } @@ -369,7 +366,7 @@ public static Temperature FromDegreesRoemer(QuantityValue degreesroemer) /// If value is NaN or Infinity. public static Temperature FromKelvins(QuantityValue kelvins) { - QuantityValue value = (QuantityValue) kelvins; + double value = (double) kelvins; return new Temperature(value, TemperatureUnit.Kelvin); } @@ -379,7 +376,7 @@ public static Temperature FromKelvins(QuantityValue kelvins) /// If value is NaN or Infinity. public static Temperature FromMillidegreesCelsius(QuantityValue millidegreescelsius) { - QuantityValue value = (QuantityValue) millidegreescelsius; + double value = (double) millidegreescelsius; return new Temperature(value, TemperatureUnit.MillidegreeCelsius); } @@ -389,7 +386,7 @@ public static Temperature FromMillidegreesCelsius(QuantityValue millidegreescels /// If value is NaN or Infinity. public static Temperature FromSolarTemperatures(QuantityValue solartemperatures) { - QuantityValue value = (QuantityValue) solartemperatures; + double value = (double) solartemperatures; return new Temperature(value, TemperatureUnit.SolarTemperature); } @@ -401,7 +398,7 @@ public static Temperature FromSolarTemperatures(QuantityValue solartemperatures) /// Temperature unit value. public static Temperature From(QuantityValue value, TemperatureUnit fromUnit) { - return new Temperature((QuantityValue)value, fromUnit); + return new Temperature((double)value, fromUnit); } #endregion @@ -576,19 +573,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Temperature left, Temperature right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Temperature left, Temperature right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -601,29 +585,7 @@ public int CompareTo(object obj) /// public int CompareTo(Temperature other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Temperature objTemperature)) - return false; - return Equals(objTemperature); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Temperature other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -666,13 +628,13 @@ public bool Equals(Temperature other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Temperature other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Temperature other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -683,7 +645,7 @@ public bool Equals(Temperature other, QuantityValue tolerance, ComparisonType co /// A hash code for the current Temperature. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -694,16 +656,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TemperatureUnit unit) + public double As(TemperatureUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -718,12 +681,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TemperatureUnit typedUnit)) + if (!(unit is TemperatureUnit unitAsTemperatureUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTemperatureUnit); } /// @@ -755,7 +718,7 @@ public Temperature ToUnit(TemperatureUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Temperature)converted; } - else if (Enum.IsDefined(typeof(TemperatureUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -763,17 +726,17 @@ public Temperature ToUnit(TemperatureUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureUnit typedUnit)) + if (!(unit is TemperatureUnit unitAsTemperatureUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTemperatureUnit, DefaultConversionFunctions); } /// @@ -800,10 +763,10 @@ public Temperature ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TemperatureUnit unit) + private double GetValueAs(TemperatureUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index a832939860..0f3704b67e 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Temperature change rate is the ratio of the temperature change to the time during which the change occurred (value of temperature changes per unit time). /// [DataContract] - public partial struct TemperatureChangeRate : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureChangeRate : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -81,9 +81,9 @@ static TemperatureChangeRate() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureChangeRate(QuantityValue value, TemperatureChangeRateUnit unit) + public TemperatureChangeRate(double value, TemperatureChangeRateUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -95,14 +95,14 @@ public TemperatureChangeRate(QuantityValue value, TemperatureChangeRateUnit unit /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureChangeRate(QuantityValue value, UnitSystem unitSystem) + public TemperatureChangeRate(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -143,10 +143,7 @@ public TemperatureChangeRate(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -169,54 +166,54 @@ public TemperatureChangeRate(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); + public double CentidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); + public double DecadegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); + public double DecidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); + public double DegreesCelsiusPerMinute => As(TemperatureChangeRateUnit.DegreeCelsiusPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); + public double DegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.DegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); + public double HectodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); + public double KilodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); + public double MicrodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); + public double MillidegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); + public double NanodegreesCelsiusPerSecond => As(TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); #endregion @@ -299,7 +296,7 @@ public static string GetAbbreviation(TemperatureChangeRateUnit unit, IFormatProv /// If value is NaN or Infinity. public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityValue centidegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) centidegreescelsiuspersecond; + double value = (double) centidegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.CentidegreeCelsiusPerSecond); } @@ -309,7 +306,7 @@ public static TemperatureChangeRate FromCentidegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValue decadegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) decadegreescelsiuspersecond; + double value = (double) decadegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecadegreeCelsiusPerSecond); } @@ -319,7 +316,7 @@ public static TemperatureChangeRate FromDecadegreesCelsiusPerSecond(QuantityValu /// If value is NaN or Infinity. public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValue decidegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) decidegreescelsiuspersecond; + double value = (double) decidegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DecidegreeCelsiusPerSecond); } @@ -329,7 +326,7 @@ public static TemperatureChangeRate FromDecidegreesCelsiusPerSecond(QuantityValu /// If value is NaN or Infinity. public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue degreescelsiusperminute) { - QuantityValue value = (QuantityValue) degreescelsiusperminute; + double value = (double) degreescelsiusperminute; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerMinute); } @@ -339,7 +336,7 @@ public static TemperatureChangeRate FromDegreesCelsiusPerMinute(QuantityValue de /// If value is NaN or Infinity. public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue degreescelsiuspersecond) { - QuantityValue value = (QuantityValue) degreescelsiuspersecond; + double value = (double) degreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.DegreeCelsiusPerSecond); } @@ -349,7 +346,7 @@ public static TemperatureChangeRate FromDegreesCelsiusPerSecond(QuantityValue de /// If value is NaN or Infinity. public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityValue hectodegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) hectodegreescelsiuspersecond; + double value = (double) hectodegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.HectodegreeCelsiusPerSecond); } @@ -359,7 +356,7 @@ public static TemperatureChangeRate FromHectodegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValue kilodegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) kilodegreescelsiuspersecond; + double value = (double) kilodegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.KilodegreeCelsiusPerSecond); } @@ -369,7 +366,7 @@ public static TemperatureChangeRate FromKilodegreesCelsiusPerSecond(QuantityValu /// If value is NaN or Infinity. public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityValue microdegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) microdegreescelsiuspersecond; + double value = (double) microdegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MicrodegreeCelsiusPerSecond); } @@ -379,7 +376,7 @@ public static TemperatureChangeRate FromMicrodegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityValue millidegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) millidegreescelsiuspersecond; + double value = (double) millidegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.MillidegreeCelsiusPerSecond); } @@ -389,7 +386,7 @@ public static TemperatureChangeRate FromMillidegreesCelsiusPerSecond(QuantityVal /// If value is NaN or Infinity. public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValue nanodegreescelsiuspersecond) { - QuantityValue value = (QuantityValue) nanodegreescelsiuspersecond; + double value = (double) nanodegreescelsiuspersecond; return new TemperatureChangeRate(value, TemperatureChangeRateUnit.NanodegreeCelsiusPerSecond); } @@ -401,7 +398,7 @@ public static TemperatureChangeRate FromNanodegreesCelsiusPerSecond(QuantityValu /// TemperatureChangeRate unit value. public static TemperatureChangeRate From(QuantityValue value, TemperatureChangeRateUnit fromUnit) { - return new TemperatureChangeRate((QuantityValue)value, fromUnit); + return new TemperatureChangeRate((double)value, fromUnit); } #endregion @@ -571,25 +568,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureChangeRate operator *(QuantityValue left, TemperatureChangeRate right) + public static TemperatureChangeRate operator *(double left, TemperatureChangeRate right) { return new TemperatureChangeRate(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureChangeRate operator *(TemperatureChangeRate left, QuantityValue right) + public static TemperatureChangeRate operator *(TemperatureChangeRate left, double right) { return new TemperatureChangeRate(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureChangeRate operator /(TemperatureChangeRate left, QuantityValue right) + public static TemperatureChangeRate operator /(TemperatureChangeRate left, double right) { return new TemperatureChangeRate(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(TemperatureChangeRate left, TemperatureChangeRate right) + public static double operator /(TemperatureChangeRate left, TemperatureChangeRate right) { return left.DegreesCelsiusPerSecond / right.DegreesCelsiusPerSecond; } @@ -622,19 +619,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureChangeRate left, TemperatureChangeRate right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureChangeRate left, TemperatureChangeRate right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -647,29 +631,7 @@ public int CompareTo(object obj) /// public int CompareTo(TemperatureChangeRate other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is TemperatureChangeRate objTemperatureChangeRate)) - return false; - return Equals(objTemperatureChangeRate); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureChangeRate other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -712,13 +674,13 @@ public bool Equals(TemperatureChangeRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureChangeRate other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -729,7 +691,7 @@ public bool Equals(TemperatureChangeRate other, QuantityValue tolerance, Compari /// A hash code for the current TemperatureChangeRate. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -740,16 +702,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TemperatureChangeRateUnit unit) + public double As(TemperatureChangeRateUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -764,12 +727,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TemperatureChangeRateUnit typedUnit)) + if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTemperatureChangeRateUnit); } /// @@ -801,7 +764,7 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit, UnitConverte var converted = conversionFunction(this); return (TemperatureChangeRate)converted; } - else if (Enum.IsDefined(typeof(TemperatureChangeRateUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -809,17 +772,17 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit, UnitConverte } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureChangeRateUnit typedUnit)) + if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTemperatureChangeRateUnit, DefaultConversionFunctions); } /// @@ -846,10 +809,10 @@ public TemperatureChangeRate ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TemperatureChangeRateUnit unit) + private double GetValueAs(TemperatureChangeRateUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 94d9813fe9..5fb8eaf2ac 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Difference between two temperatures. The conversions are different than for Temperature. /// [DataContract] - public partial struct TemperatureDelta : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureDelta : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -80,9 +80,9 @@ static TemperatureDelta() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureDelta(QuantityValue value, TemperatureDeltaUnit unit) + public TemperatureDelta(double value, TemperatureDeltaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -94,14 +94,14 @@ public TemperatureDelta(QuantityValue value, TemperatureDeltaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureDelta(QuantityValue value, UnitSystem unitSystem) + public TemperatureDelta(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -142,10 +142,7 @@ public TemperatureDelta(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -168,49 +165,49 @@ public TemperatureDelta(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); + public double DegreesCelsius => As(TemperatureDeltaUnit.DegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); + public double DegreesDelisle => As(TemperatureDeltaUnit.DegreeDelisle); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); + public double DegreesFahrenheit => As(TemperatureDeltaUnit.DegreeFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); + public double DegreesNewton => As(TemperatureDeltaUnit.DegreeNewton); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); + public double DegreesRankine => As(TemperatureDeltaUnit.DegreeRankine); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); + public double DegreesReaumur => As(TemperatureDeltaUnit.DegreeReaumur); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); + public double DegreesRoemer => As(TemperatureDeltaUnit.DegreeRoemer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kelvins => As(TemperatureDeltaUnit.Kelvin); + public double Kelvins => As(TemperatureDeltaUnit.Kelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); + public double MillidegreesCelsius => As(TemperatureDeltaUnit.MillidegreeCelsius); #endregion @@ -290,7 +287,7 @@ public static string GetAbbreviation(TemperatureDeltaUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesCelsius(QuantityValue degreescelsius) { - QuantityValue value = (QuantityValue) degreescelsius; + double value = (double) degreescelsius; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeCelsius); } @@ -300,7 +297,7 @@ public static TemperatureDelta FromDegreesCelsius(QuantityValue degreescelsius) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesDelisle(QuantityValue degreesdelisle) { - QuantityValue value = (QuantityValue) degreesdelisle; + double value = (double) degreesdelisle; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeDelisle); } @@ -310,7 +307,7 @@ public static TemperatureDelta FromDegreesDelisle(QuantityValue degreesdelisle) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesFahrenheit(QuantityValue degreesfahrenheit) { - QuantityValue value = (QuantityValue) degreesfahrenheit; + double value = (double) degreesfahrenheit; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeFahrenheit); } @@ -320,7 +317,7 @@ public static TemperatureDelta FromDegreesFahrenheit(QuantityValue degreesfahren /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesNewton(QuantityValue degreesnewton) { - QuantityValue value = (QuantityValue) degreesnewton; + double value = (double) degreesnewton; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeNewton); } @@ -330,7 +327,7 @@ public static TemperatureDelta FromDegreesNewton(QuantityValue degreesnewton) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesRankine(QuantityValue degreesrankine) { - QuantityValue value = (QuantityValue) degreesrankine; + double value = (double) degreesrankine; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRankine); } @@ -340,7 +337,7 @@ public static TemperatureDelta FromDegreesRankine(QuantityValue degreesrankine) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesReaumur(QuantityValue degreesreaumur) { - QuantityValue value = (QuantityValue) degreesreaumur; + double value = (double) degreesreaumur; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeReaumur); } @@ -350,7 +347,7 @@ public static TemperatureDelta FromDegreesReaumur(QuantityValue degreesreaumur) /// If value is NaN or Infinity. public static TemperatureDelta FromDegreesRoemer(QuantityValue degreesroemer) { - QuantityValue value = (QuantityValue) degreesroemer; + double value = (double) degreesroemer; return new TemperatureDelta(value, TemperatureDeltaUnit.DegreeRoemer); } @@ -360,7 +357,7 @@ public static TemperatureDelta FromDegreesRoemer(QuantityValue degreesroemer) /// If value is NaN or Infinity. public static TemperatureDelta FromKelvins(QuantityValue kelvins) { - QuantityValue value = (QuantityValue) kelvins; + double value = (double) kelvins; return new TemperatureDelta(value, TemperatureDeltaUnit.Kelvin); } @@ -370,7 +367,7 @@ public static TemperatureDelta FromKelvins(QuantityValue kelvins) /// If value is NaN or Infinity. public static TemperatureDelta FromMillidegreesCelsius(QuantityValue millidegreescelsius) { - QuantityValue value = (QuantityValue) millidegreescelsius; + double value = (double) millidegreescelsius; return new TemperatureDelta(value, TemperatureDeltaUnit.MillidegreeCelsius); } @@ -382,7 +379,7 @@ public static TemperatureDelta FromMillidegreesCelsius(QuantityValue millidegree /// TemperatureDelta unit value. public static TemperatureDelta From(QuantityValue value, TemperatureDeltaUnit fromUnit) { - return new TemperatureDelta((QuantityValue)value, fromUnit); + return new TemperatureDelta((double)value, fromUnit); } #endregion @@ -552,25 +549,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureDelta operator *(QuantityValue left, TemperatureDelta right) + public static TemperatureDelta operator *(double left, TemperatureDelta right) { return new TemperatureDelta(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureDelta operator *(TemperatureDelta left, QuantityValue right) + public static TemperatureDelta operator *(TemperatureDelta left, double right) { return new TemperatureDelta(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureDelta operator /(TemperatureDelta left, QuantityValue right) + public static TemperatureDelta operator /(TemperatureDelta left, double right) { return new TemperatureDelta(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(TemperatureDelta left, TemperatureDelta right) + public static double operator /(TemperatureDelta left, TemperatureDelta right) { return left.Kelvins / right.Kelvins; } @@ -603,19 +600,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureDelta left, TemperatureDelta right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureDelta left, TemperatureDelta right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -628,29 +612,7 @@ public int CompareTo(object obj) /// public int CompareTo(TemperatureDelta other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is TemperatureDelta objTemperatureDelta)) - return false; - return Equals(objTemperatureDelta); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureDelta other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -693,13 +655,13 @@ public bool Equals(TemperatureDelta other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureDelta other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -710,7 +672,7 @@ public bool Equals(TemperatureDelta other, QuantityValue tolerance, ComparisonTy /// A hash code for the current TemperatureDelta. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -721,16 +683,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TemperatureDeltaUnit unit) + public double As(TemperatureDeltaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -745,12 +708,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TemperatureDeltaUnit typedUnit)) + if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTemperatureDeltaUnit); } /// @@ -782,7 +745,7 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit, UnitConverter unitConv var converted = conversionFunction(this); return (TemperatureDelta)converted; } - else if (Enum.IsDefined(typeof(TemperatureDeltaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -790,17 +753,17 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit, UnitConverter unitConv } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureDeltaUnit typedUnit)) + if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTemperatureDeltaUnit, DefaultConversionFunctions); } /// @@ -827,10 +790,10 @@ public TemperatureDelta ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TemperatureDeltaUnit unit) + private double GetValueAs(TemperatureDeltaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index 1d2405a4e2..aaff14abca 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct TemperatureGradient : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TemperatureGradient : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static TemperatureGradient() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TemperatureGradient(QuantityValue value, TemperatureGradientUnit unit) + public TemperatureGradient(double value, TemperatureGradientUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public TemperatureGradient(QuantityValue value, TemperatureGradientUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TemperatureGradient(QuantityValue value, UnitSystem unitSystem) + public TemperatureGradient(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public TemperatureGradient(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,24 +160,24 @@ public TemperatureGradient(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelciusPerKilometer => As(TemperatureGradientUnit.DegreeCelsiusPerKilometer); + public double DegreesCelciusPerKilometer => As(TemperatureGradientUnit.DegreeCelsiusPerKilometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesCelciusPerMeter => As(TemperatureGradientUnit.DegreeCelsiusPerMeter); + public double DegreesCelciusPerMeter => As(TemperatureGradientUnit.DegreeCelsiusPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DegreesFahrenheitPerFoot => As(TemperatureGradientUnit.DegreeFahrenheitPerFoot); + public double DegreesFahrenheitPerFoot => As(TemperatureGradientUnit.DegreeFahrenheitPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KelvinsPerMeter => As(TemperatureGradientUnit.KelvinPerMeter); + public double KelvinsPerMeter => As(TemperatureGradientUnit.KelvinPerMeter); #endregion @@ -245,7 +242,7 @@ public static string GetAbbreviation(TemperatureGradientUnit unit, IFormatProvid /// If value is NaN or Infinity. public static TemperatureGradient FromDegreesCelciusPerKilometer(QuantityValue degreescelciusperkilometer) { - QuantityValue value = (QuantityValue) degreescelciusperkilometer; + double value = (double) degreescelciusperkilometer; return new TemperatureGradient(value, TemperatureGradientUnit.DegreeCelsiusPerKilometer); } @@ -255,7 +252,7 @@ public static TemperatureGradient FromDegreesCelciusPerKilometer(QuantityValue d /// If value is NaN or Infinity. public static TemperatureGradient FromDegreesCelciusPerMeter(QuantityValue degreescelciuspermeter) { - QuantityValue value = (QuantityValue) degreescelciuspermeter; + double value = (double) degreescelciuspermeter; return new TemperatureGradient(value, TemperatureGradientUnit.DegreeCelsiusPerMeter); } @@ -265,7 +262,7 @@ public static TemperatureGradient FromDegreesCelciusPerMeter(QuantityValue degre /// If value is NaN or Infinity. public static TemperatureGradient FromDegreesFahrenheitPerFoot(QuantityValue degreesfahrenheitperfoot) { - QuantityValue value = (QuantityValue) degreesfahrenheitperfoot; + double value = (double) degreesfahrenheitperfoot; return new TemperatureGradient(value, TemperatureGradientUnit.DegreeFahrenheitPerFoot); } @@ -275,7 +272,7 @@ public static TemperatureGradient FromDegreesFahrenheitPerFoot(QuantityValue deg /// If value is NaN or Infinity. public static TemperatureGradient FromKelvinsPerMeter(QuantityValue kelvinspermeter) { - QuantityValue value = (QuantityValue) kelvinspermeter; + double value = (double) kelvinspermeter; return new TemperatureGradient(value, TemperatureGradientUnit.KelvinPerMeter); } @@ -287,7 +284,7 @@ public static TemperatureGradient FromKelvinsPerMeter(QuantityValue kelvinsperme /// TemperatureGradient unit value. public static TemperatureGradient From(QuantityValue value, TemperatureGradientUnit fromUnit) { - return new TemperatureGradient((QuantityValue)value, fromUnit); + return new TemperatureGradient((double)value, fromUnit); } #endregion @@ -457,25 +454,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe } /// Get from multiplying value and . - public static TemperatureGradient operator *(QuantityValue left, TemperatureGradient right) + public static TemperatureGradient operator *(double left, TemperatureGradient right) { return new TemperatureGradient(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TemperatureGradient operator *(TemperatureGradient left, QuantityValue right) + public static TemperatureGradient operator *(TemperatureGradient left, double right) { return new TemperatureGradient(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TemperatureGradient operator /(TemperatureGradient left, QuantityValue right) + public static TemperatureGradient operator /(TemperatureGradient left, double right) { return new TemperatureGradient(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(TemperatureGradient left, TemperatureGradient right) + public static double operator /(TemperatureGradient left, TemperatureGradient right) { return left.KelvinsPerMeter / right.KelvinsPerMeter; } @@ -508,19 +505,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Tempe return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TemperatureGradient left, TemperatureGradient right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TemperatureGradient left, TemperatureGradient right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -533,29 +517,7 @@ public int CompareTo(object obj) /// public int CompareTo(TemperatureGradient other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is TemperatureGradient objTemperatureGradient)) - return false; - return Equals(objTemperatureGradient); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TemperatureGradient other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -598,13 +560,13 @@ public bool Equals(TemperatureGradient other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TemperatureGradient other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(TemperatureGradient other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -615,7 +577,7 @@ public bool Equals(TemperatureGradient other, QuantityValue tolerance, Compariso /// A hash code for the current TemperatureGradient. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -626,16 +588,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TemperatureGradientUnit unit) + public double As(TemperatureGradientUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -650,12 +613,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TemperatureGradientUnit typedUnit)) + if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTemperatureGradientUnit); } /// @@ -687,7 +650,7 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit, UnitConverter un var converted = conversionFunction(this); return (TemperatureGradient)converted; } - else if (Enum.IsDefined(typeof(TemperatureGradientUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -695,17 +658,17 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureGradientUnit typedUnit)) + if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTemperatureGradientUnit, DefaultConversionFunctions); } /// @@ -732,10 +695,10 @@ public TemperatureGradient ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TemperatureGradientUnit unit) + private double GetValueAs(TemperatureGradientUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 2dea56e22d..0da7968b47 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Thermal_Conductivity /// [DataContract] - public partial struct ThermalConductivity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalConductivity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -76,9 +76,9 @@ static ThermalConductivity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ThermalConductivity(QuantityValue value, ThermalConductivityUnit unit) + public ThermalConductivity(double value, ThermalConductivityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -90,14 +90,14 @@ public ThermalConductivity(QuantityValue value, ThermalConductivityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalConductivity(QuantityValue value, UnitSystem unitSystem) + public ThermalConductivity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -138,10 +138,7 @@ public ThermalConductivity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -164,14 +161,14 @@ public ThermalConductivity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); + public double BtusPerHourFootFahrenheit => As(ThermalConductivityUnit.BtuPerHourFootFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); + public double WattsPerMeterKelvin => As(ThermalConductivityUnit.WattPerMeterKelvin); #endregion @@ -230,7 +227,7 @@ public static string GetAbbreviation(ThermalConductivityUnit unit, IFormatProvid /// If value is NaN or Infinity. public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue btusperhourfootfahrenheit) { - QuantityValue value = (QuantityValue) btusperhourfootfahrenheit; + double value = (double) btusperhourfootfahrenheit; return new ThermalConductivity(value, ThermalConductivityUnit.BtuPerHourFootFahrenheit); } @@ -240,7 +237,7 @@ public static ThermalConductivity FromBtusPerHourFootFahrenheit(QuantityValue bt /// If value is NaN or Infinity. public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue wattspermeterkelvin) { - QuantityValue value = (QuantityValue) wattspermeterkelvin; + double value = (double) wattspermeterkelvin; return new ThermalConductivity(value, ThermalConductivityUnit.WattPerMeterKelvin); } @@ -252,7 +249,7 @@ public static ThermalConductivity FromWattsPerMeterKelvin(QuantityValue wattsper /// ThermalConductivity unit value. public static ThermalConductivity From(QuantityValue value, ThermalConductivityUnit fromUnit) { - return new ThermalConductivity((QuantityValue)value, fromUnit); + return new ThermalConductivity((double)value, fromUnit); } #endregion @@ -422,25 +419,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm } /// Get from multiplying value and . - public static ThermalConductivity operator *(QuantityValue left, ThermalConductivity right) + public static ThermalConductivity operator *(double left, ThermalConductivity right) { return new ThermalConductivity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ThermalConductivity operator *(ThermalConductivity left, QuantityValue right) + public static ThermalConductivity operator *(ThermalConductivity left, double right) { return new ThermalConductivity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ThermalConductivity operator /(ThermalConductivity left, QuantityValue right) + public static ThermalConductivity operator /(ThermalConductivity left, double right) { return new ThermalConductivity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ThermalConductivity left, ThermalConductivity right) + public static double operator /(ThermalConductivity left, ThermalConductivity right) { return left.WattsPerMeterKelvin / right.WattsPerMeterKelvin; } @@ -473,19 +470,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalConductivity left, ThermalConductivity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalConductivity left, ThermalConductivity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -498,29 +482,7 @@ public int CompareTo(object obj) /// public int CompareTo(ThermalConductivity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ThermalConductivity objThermalConductivity)) - return false; - return Equals(objThermalConductivity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalConductivity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -563,13 +525,13 @@ public bool Equals(ThermalConductivity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalConductivity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ThermalConductivity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -580,7 +542,7 @@ public bool Equals(ThermalConductivity other, QuantityValue tolerance, Compariso /// A hash code for the current ThermalConductivity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -591,16 +553,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ThermalConductivityUnit unit) + public double As(ThermalConductivityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -615,12 +578,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ThermalConductivityUnit typedUnit)) + if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsThermalConductivityUnit); } /// @@ -652,7 +615,7 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit, UnitConverter un var converted = conversionFunction(this); return (ThermalConductivity)converted; } - else if (Enum.IsDefined(typeof(ThermalConductivityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -660,17 +623,17 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalConductivityUnit typedUnit)) + if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsThermalConductivityUnit, DefaultConversionFunctions); } /// @@ -697,10 +660,10 @@ public ThermalConductivity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ThermalConductivityUnit unit) + private double GetValueAs(ThermalConductivityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 520040cd26..7ab40b994c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Heat Transfer Coefficient or Thermal conductivity - indicates a materials ability to conduct heat. /// [DataContract] - public partial struct ThermalResistance : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct ThermalResistance : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static ThermalResistance() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public ThermalResistance(QuantityValue value, ThermalResistanceUnit unit) + public ThermalResistance(double value, ThermalResistanceUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public ThermalResistance(QuantityValue value, ThermalResistanceUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public ThermalResistance(QuantityValue value, UnitSystem unitSystem) + public ThermalResistance(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public ThermalResistance(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,34 +162,34 @@ public ThermalResistance(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); + public double HourSquareFeetDegreesFahrenheitPerBtu => As(ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); + public double SquareCentimeterHourDegreesCelsiusPerKilocalorie => As(ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); + public double SquareCentimeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); + public double SquareMeterDegreesCelsiusPerWatt => As(ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); + public double SquareMeterKelvinsPerKilowatt => As(ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue SquareMeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareMeterKelvinPerWatt); + public double SquareMeterKelvinsPerWatt => As(ThermalResistanceUnit.SquareMeterKelvinPerWatt); #endregion @@ -263,7 +260,7 @@ public static string GetAbbreviation(ThermalResistanceUnit unit, IFormatProvider /// If value is NaN or Infinity. public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(QuantityValue hoursquarefeetdegreesfahrenheitperbtu) { - QuantityValue value = (QuantityValue) hoursquarefeetdegreesfahrenheitperbtu; + double value = (double) hoursquarefeetdegreesfahrenheitperbtu; return new ThermalResistance(value, ThermalResistanceUnit.HourSquareFeetDegreeFahrenheitPerBtu); } @@ -273,7 +270,7 @@ public static ThermalResistance FromHourSquareFeetDegreesFahrenheitPerBtu(Quanti /// If value is NaN or Infinity. public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocalorie(QuantityValue squarecentimeterhourdegreescelsiusperkilocalorie) { - QuantityValue value = (QuantityValue) squarecentimeterhourdegreescelsiusperkilocalorie; + double value = (double) squarecentimeterhourdegreescelsiusperkilocalorie; return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterHourDegreeCelsiusPerKilocalorie); } @@ -283,7 +280,7 @@ public static ThermalResistance FromSquareCentimeterHourDegreesCelsiusPerKilocal /// If value is NaN or Infinity. public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue squarecentimeterkelvinsperwatt) { - QuantityValue value = (QuantityValue) squarecentimeterkelvinsperwatt; + double value = (double) squarecentimeterkelvinsperwatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareCentimeterKelvinPerWatt); } @@ -293,7 +290,7 @@ public static ThermalResistance FromSquareCentimeterKelvinsPerWatt(QuantityValue /// If value is NaN or Infinity. public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityValue squaremeterdegreescelsiusperwatt) { - QuantityValue value = (QuantityValue) squaremeterdegreescelsiusperwatt; + double value = (double) squaremeterdegreescelsiusperwatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterDegreeCelsiusPerWatt); } @@ -303,7 +300,7 @@ public static ThermalResistance FromSquareMeterDegreesCelsiusPerWatt(QuantityVal /// If value is NaN or Infinity. public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue squaremeterkelvinsperkilowatt) { - QuantityValue value = (QuantityValue) squaremeterkelvinsperkilowatt; + double value = (double) squaremeterkelvinsperkilowatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerKilowatt); } @@ -313,7 +310,7 @@ public static ThermalResistance FromSquareMeterKelvinsPerKilowatt(QuantityValue /// If value is NaN or Infinity. public static ThermalResistance FromSquareMeterKelvinsPerWatt(QuantityValue squaremeterkelvinsperwatt) { - QuantityValue value = (QuantityValue) squaremeterkelvinsperwatt; + double value = (double) squaremeterkelvinsperwatt; return new ThermalResistance(value, ThermalResistanceUnit.SquareMeterKelvinPerWatt); } @@ -325,7 +322,7 @@ public static ThermalResistance FromSquareMeterKelvinsPerWatt(QuantityValue squa /// ThermalResistance unit value. public static ThermalResistance From(QuantityValue value, ThermalResistanceUnit fromUnit) { - return new ThermalResistance((QuantityValue)value, fromUnit); + return new ThermalResistance((double)value, fromUnit); } #endregion @@ -495,25 +492,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm } /// Get from multiplying value and . - public static ThermalResistance operator *(QuantityValue left, ThermalResistance right) + public static ThermalResistance operator *(double left, ThermalResistance right) { return new ThermalResistance(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static ThermalResistance operator *(ThermalResistance left, QuantityValue right) + public static ThermalResistance operator *(ThermalResistance left, double right) { return new ThermalResistance(left.Value * right, left.Unit); } /// Get from dividing by value. - public static ThermalResistance operator /(ThermalResistance left, QuantityValue right) + public static ThermalResistance operator /(ThermalResistance left, double right) { return new ThermalResistance(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(ThermalResistance left, ThermalResistance right) + public static double operator /(ThermalResistance left, ThermalResistance right) { return left.SquareMeterKelvinsPerKilowatt / right.SquareMeterKelvinsPerKilowatt; } @@ -546,19 +543,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Therm return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(ThermalResistance left, ThermalResistance right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(ThermalResistance left, ThermalResistance right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -571,29 +555,7 @@ public int CompareTo(object obj) /// public int CompareTo(ThermalResistance other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is ThermalResistance objThermalResistance)) - return false; - return Equals(objThermalResistance); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(ThermalResistance other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -636,13 +598,13 @@ public bool Equals(ThermalResistance other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(ThermalResistance other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(ThermalResistance other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -653,7 +615,7 @@ public bool Equals(ThermalResistance other, QuantityValue tolerance, ComparisonT /// A hash code for the current ThermalResistance. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -664,16 +626,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(ThermalResistanceUnit unit) + public double As(ThermalResistanceUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -688,12 +651,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is ThermalResistanceUnit typedUnit)) + if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsThermalResistanceUnit); } /// @@ -725,7 +688,7 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (ThermalResistance)converted; } - else if (Enum.IsDefined(typeof(ThermalResistanceUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -733,17 +696,17 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit, UnitConverter unitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalResistanceUnit typedUnit)) + if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsThermalResistanceUnit, DefaultConversionFunctions); } /// @@ -770,10 +733,10 @@ public ThermalResistance ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(ThermalResistanceUnit unit) + private double GetValueAs(ThermalResistanceUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index de02228368..2a512729ec 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Torque, moment or moment of force (see the terminology below), is the tendency of a force to rotate an object about an axis,[1] fulcrum, or pivot. Just as a force is a push or a pull, a torque can be thought of as a twist to an object. Mathematically, torque is defined as the cross product of the lever-arm distance and force, which tends to produce rotation. Loosely speaking, torque is a measure of the turning force on an object such as a bolt or a flywheel. For example, pushing or pulling the handle of a wrench connected to a nut or bolt produces a torque (turning force) that loosens or tightens the nut or bolt. /// [DataContract] - public partial struct Torque : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Torque : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -96,9 +96,9 @@ static Torque() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Torque(QuantityValue value, TorqueUnit unit) + public Torque(double value, TorqueUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -110,14 +110,14 @@ public Torque(QuantityValue value, TorqueUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Torque(QuantityValue value, UnitSystem unitSystem) + public Torque(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -158,10 +158,7 @@ public Torque(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -184,129 +181,129 @@ public Torque(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramForceCentimeters => As(TorqueUnit.GramForceCentimeter); + public double GramForceCentimeters => As(TorqueUnit.GramForceCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramForceMeters => As(TorqueUnit.GramForceMeter); + public double GramForceMeters => As(TorqueUnit.GramForceMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue GramForceMillimeters => As(TorqueUnit.GramForceMillimeter); + public double GramForceMillimeters => As(TorqueUnit.GramForceMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); + public double KilogramForceCentimeters => As(TorqueUnit.KilogramForceCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); + public double KilogramForceMeters => As(TorqueUnit.KilogramForceMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); + public double KilogramForceMillimeters => As(TorqueUnit.KilogramForceMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); + public double KilonewtonCentimeters => As(TorqueUnit.KilonewtonCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); + public double KilonewtonMeters => As(TorqueUnit.KilonewtonMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); + public double KilonewtonMillimeters => As(TorqueUnit.KilonewtonMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); + public double KilopoundForceFeet => As(TorqueUnit.KilopoundForceFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); + public double KilopoundForceInches => As(TorqueUnit.KilopoundForceInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); + public double MeganewtonCentimeters => As(TorqueUnit.MeganewtonCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); + public double MeganewtonMeters => As(TorqueUnit.MeganewtonMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); + public double MeganewtonMillimeters => As(TorqueUnit.MeganewtonMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); + public double MegapoundForceFeet => As(TorqueUnit.MegapoundForceFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); + public double MegapoundForceInches => As(TorqueUnit.MegapoundForceInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); + public double NewtonCentimeters => As(TorqueUnit.NewtonCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMeters => As(TorqueUnit.NewtonMeter); + public double NewtonMeters => As(TorqueUnit.NewtonMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); + public double NewtonMillimeters => As(TorqueUnit.NewtonMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundalFeet => As(TorqueUnit.PoundalFoot); + public double PoundalFeet => As(TorqueUnit.PoundalFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceFeet => As(TorqueUnit.PoundForceFoot); + public double PoundForceFeet => As(TorqueUnit.PoundForceFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceInches => As(TorqueUnit.PoundForceInch); + public double PoundForceInches => As(TorqueUnit.PoundForceInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); + public double TonneForceCentimeters => As(TorqueUnit.TonneForceCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneForceMeters => As(TorqueUnit.TonneForceMeter); + public double TonneForceMeters => As(TorqueUnit.TonneForceMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); + public double TonneForceMillimeters => As(TorqueUnit.TonneForceMillimeter); #endregion @@ -437,7 +434,7 @@ public static string GetAbbreviation(TorqueUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Torque FromGramForceCentimeters(QuantityValue gramforcecentimeters) { - QuantityValue value = (QuantityValue) gramforcecentimeters; + double value = (double) gramforcecentimeters; return new Torque(value, TorqueUnit.GramForceCentimeter); } @@ -447,7 +444,7 @@ public static Torque FromGramForceCentimeters(QuantityValue gramforcecentimeters /// If value is NaN or Infinity. public static Torque FromGramForceMeters(QuantityValue gramforcemeters) { - QuantityValue value = (QuantityValue) gramforcemeters; + double value = (double) gramforcemeters; return new Torque(value, TorqueUnit.GramForceMeter); } @@ -457,7 +454,7 @@ public static Torque FromGramForceMeters(QuantityValue gramforcemeters) /// If value is NaN or Infinity. public static Torque FromGramForceMillimeters(QuantityValue gramforcemillimeters) { - QuantityValue value = (QuantityValue) gramforcemillimeters; + double value = (double) gramforcemillimeters; return new Torque(value, TorqueUnit.GramForceMillimeter); } @@ -467,7 +464,7 @@ public static Torque FromGramForceMillimeters(QuantityValue gramforcemillimeters /// If value is NaN or Infinity. public static Torque FromKilogramForceCentimeters(QuantityValue kilogramforcecentimeters) { - QuantityValue value = (QuantityValue) kilogramforcecentimeters; + double value = (double) kilogramforcecentimeters; return new Torque(value, TorqueUnit.KilogramForceCentimeter); } @@ -477,7 +474,7 @@ public static Torque FromKilogramForceCentimeters(QuantityValue kilogramforcecen /// If value is NaN or Infinity. public static Torque FromKilogramForceMeters(QuantityValue kilogramforcemeters) { - QuantityValue value = (QuantityValue) kilogramforcemeters; + double value = (double) kilogramforcemeters; return new Torque(value, TorqueUnit.KilogramForceMeter); } @@ -487,7 +484,7 @@ public static Torque FromKilogramForceMeters(QuantityValue kilogramforcemeters) /// If value is NaN or Infinity. public static Torque FromKilogramForceMillimeters(QuantityValue kilogramforcemillimeters) { - QuantityValue value = (QuantityValue) kilogramforcemillimeters; + double value = (double) kilogramforcemillimeters; return new Torque(value, TorqueUnit.KilogramForceMillimeter); } @@ -497,7 +494,7 @@ public static Torque FromKilogramForceMillimeters(QuantityValue kilogramforcemil /// If value is NaN or Infinity. public static Torque FromKilonewtonCentimeters(QuantityValue kilonewtoncentimeters) { - QuantityValue value = (QuantityValue) kilonewtoncentimeters; + double value = (double) kilonewtoncentimeters; return new Torque(value, TorqueUnit.KilonewtonCentimeter); } @@ -507,7 +504,7 @@ public static Torque FromKilonewtonCentimeters(QuantityValue kilonewtoncentimete /// If value is NaN or Infinity. public static Torque FromKilonewtonMeters(QuantityValue kilonewtonmeters) { - QuantityValue value = (QuantityValue) kilonewtonmeters; + double value = (double) kilonewtonmeters; return new Torque(value, TorqueUnit.KilonewtonMeter); } @@ -517,7 +514,7 @@ public static Torque FromKilonewtonMeters(QuantityValue kilonewtonmeters) /// If value is NaN or Infinity. public static Torque FromKilonewtonMillimeters(QuantityValue kilonewtonmillimeters) { - QuantityValue value = (QuantityValue) kilonewtonmillimeters; + double value = (double) kilonewtonmillimeters; return new Torque(value, TorqueUnit.KilonewtonMillimeter); } @@ -527,7 +524,7 @@ public static Torque FromKilonewtonMillimeters(QuantityValue kilonewtonmillimete /// If value is NaN or Infinity. public static Torque FromKilopoundForceFeet(QuantityValue kilopoundforcefeet) { - QuantityValue value = (QuantityValue) kilopoundforcefeet; + double value = (double) kilopoundforcefeet; return new Torque(value, TorqueUnit.KilopoundForceFoot); } @@ -537,7 +534,7 @@ public static Torque FromKilopoundForceFeet(QuantityValue kilopoundforcefeet) /// If value is NaN or Infinity. public static Torque FromKilopoundForceInches(QuantityValue kilopoundforceinches) { - QuantityValue value = (QuantityValue) kilopoundforceinches; + double value = (double) kilopoundforceinches; return new Torque(value, TorqueUnit.KilopoundForceInch); } @@ -547,7 +544,7 @@ public static Torque FromKilopoundForceInches(QuantityValue kilopoundforceinches /// If value is NaN or Infinity. public static Torque FromMeganewtonCentimeters(QuantityValue meganewtoncentimeters) { - QuantityValue value = (QuantityValue) meganewtoncentimeters; + double value = (double) meganewtoncentimeters; return new Torque(value, TorqueUnit.MeganewtonCentimeter); } @@ -557,7 +554,7 @@ public static Torque FromMeganewtonCentimeters(QuantityValue meganewtoncentimete /// If value is NaN or Infinity. public static Torque FromMeganewtonMeters(QuantityValue meganewtonmeters) { - QuantityValue value = (QuantityValue) meganewtonmeters; + double value = (double) meganewtonmeters; return new Torque(value, TorqueUnit.MeganewtonMeter); } @@ -567,7 +564,7 @@ public static Torque FromMeganewtonMeters(QuantityValue meganewtonmeters) /// If value is NaN or Infinity. public static Torque FromMeganewtonMillimeters(QuantityValue meganewtonmillimeters) { - QuantityValue value = (QuantityValue) meganewtonmillimeters; + double value = (double) meganewtonmillimeters; return new Torque(value, TorqueUnit.MeganewtonMillimeter); } @@ -577,7 +574,7 @@ public static Torque FromMeganewtonMillimeters(QuantityValue meganewtonmillimete /// If value is NaN or Infinity. public static Torque FromMegapoundForceFeet(QuantityValue megapoundforcefeet) { - QuantityValue value = (QuantityValue) megapoundforcefeet; + double value = (double) megapoundforcefeet; return new Torque(value, TorqueUnit.MegapoundForceFoot); } @@ -587,7 +584,7 @@ public static Torque FromMegapoundForceFeet(QuantityValue megapoundforcefeet) /// If value is NaN or Infinity. public static Torque FromMegapoundForceInches(QuantityValue megapoundforceinches) { - QuantityValue value = (QuantityValue) megapoundforceinches; + double value = (double) megapoundforceinches; return new Torque(value, TorqueUnit.MegapoundForceInch); } @@ -597,7 +594,7 @@ public static Torque FromMegapoundForceInches(QuantityValue megapoundforceinches /// If value is NaN or Infinity. public static Torque FromNewtonCentimeters(QuantityValue newtoncentimeters) { - QuantityValue value = (QuantityValue) newtoncentimeters; + double value = (double) newtoncentimeters; return new Torque(value, TorqueUnit.NewtonCentimeter); } @@ -607,7 +604,7 @@ public static Torque FromNewtonCentimeters(QuantityValue newtoncentimeters) /// If value is NaN or Infinity. public static Torque FromNewtonMeters(QuantityValue newtonmeters) { - QuantityValue value = (QuantityValue) newtonmeters; + double value = (double) newtonmeters; return new Torque(value, TorqueUnit.NewtonMeter); } @@ -617,7 +614,7 @@ public static Torque FromNewtonMeters(QuantityValue newtonmeters) /// If value is NaN or Infinity. public static Torque FromNewtonMillimeters(QuantityValue newtonmillimeters) { - QuantityValue value = (QuantityValue) newtonmillimeters; + double value = (double) newtonmillimeters; return new Torque(value, TorqueUnit.NewtonMillimeter); } @@ -627,7 +624,7 @@ public static Torque FromNewtonMillimeters(QuantityValue newtonmillimeters) /// If value is NaN or Infinity. public static Torque FromPoundalFeet(QuantityValue poundalfeet) { - QuantityValue value = (QuantityValue) poundalfeet; + double value = (double) poundalfeet; return new Torque(value, TorqueUnit.PoundalFoot); } @@ -637,7 +634,7 @@ public static Torque FromPoundalFeet(QuantityValue poundalfeet) /// If value is NaN or Infinity. public static Torque FromPoundForceFeet(QuantityValue poundforcefeet) { - QuantityValue value = (QuantityValue) poundforcefeet; + double value = (double) poundforcefeet; return new Torque(value, TorqueUnit.PoundForceFoot); } @@ -647,7 +644,7 @@ public static Torque FromPoundForceFeet(QuantityValue poundforcefeet) /// If value is NaN or Infinity. public static Torque FromPoundForceInches(QuantityValue poundforceinches) { - QuantityValue value = (QuantityValue) poundforceinches; + double value = (double) poundforceinches; return new Torque(value, TorqueUnit.PoundForceInch); } @@ -657,7 +654,7 @@ public static Torque FromPoundForceInches(QuantityValue poundforceinches) /// If value is NaN or Infinity. public static Torque FromTonneForceCentimeters(QuantityValue tonneforcecentimeters) { - QuantityValue value = (QuantityValue) tonneforcecentimeters; + double value = (double) tonneforcecentimeters; return new Torque(value, TorqueUnit.TonneForceCentimeter); } @@ -667,7 +664,7 @@ public static Torque FromTonneForceCentimeters(QuantityValue tonneforcecentimete /// If value is NaN or Infinity. public static Torque FromTonneForceMeters(QuantityValue tonneforcemeters) { - QuantityValue value = (QuantityValue) tonneforcemeters; + double value = (double) tonneforcemeters; return new Torque(value, TorqueUnit.TonneForceMeter); } @@ -677,7 +674,7 @@ public static Torque FromTonneForceMeters(QuantityValue tonneforcemeters) /// If value is NaN or Infinity. public static Torque FromTonneForceMillimeters(QuantityValue tonneforcemillimeters) { - QuantityValue value = (QuantityValue) tonneforcemillimeters; + double value = (double) tonneforcemillimeters; return new Torque(value, TorqueUnit.TonneForceMillimeter); } @@ -689,7 +686,7 @@ public static Torque FromTonneForceMillimeters(QuantityValue tonneforcemillimete /// Torque unit value. public static Torque From(QuantityValue value, TorqueUnit fromUnit) { - return new Torque((QuantityValue)value, fromUnit); + return new Torque((double)value, fromUnit); } #endregion @@ -859,25 +856,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu } /// Get from multiplying value and . - public static Torque operator *(QuantityValue left, Torque right) + public static Torque operator *(double left, Torque right) { return new Torque(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Torque operator *(Torque left, QuantityValue right) + public static Torque operator *(Torque left, double right) { return new Torque(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Torque operator /(Torque left, QuantityValue right) + public static Torque operator /(Torque left, double right) { return new Torque(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Torque left, Torque right) + public static double operator /(Torque left, Torque right) { return left.NewtonMeters / right.NewtonMeters; } @@ -910,19 +907,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Torque left, Torque right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Torque left, Torque right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -935,29 +919,7 @@ public int CompareTo(object obj) /// public int CompareTo(Torque other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Torque objTorque)) - return false; - return Equals(objTorque); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Torque other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1000,13 +962,13 @@ public bool Equals(Torque other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Torque other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Torque other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1017,7 +979,7 @@ public bool Equals(Torque other, QuantityValue tolerance, ComparisonType compari /// A hash code for the current Torque. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1028,16 +990,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TorqueUnit unit) + public double As(TorqueUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1052,12 +1015,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TorqueUnit typedUnit)) + if (!(unit is TorqueUnit unitAsTorqueUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTorqueUnit); } /// @@ -1089,7 +1052,7 @@ public Torque ToUnit(TorqueUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Torque)converted; } - else if (Enum.IsDefined(typeof(TorqueUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1097,17 +1060,17 @@ public Torque ToUnit(TorqueUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorqueUnit typedUnit)) + if (!(unit is TorqueUnit unitAsTorqueUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTorqueUnit, DefaultConversionFunctions); } /// @@ -1134,10 +1097,10 @@ public Torque ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TorqueUnit unit) + private double GetValueAs(TorqueUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 534f572aef..4fd2f5f8ef 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// The magnitude of torque per unit length. /// [DataContract] - public partial struct TorquePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct TorquePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -92,9 +92,9 @@ static TorquePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public TorquePerLength(QuantityValue value, TorquePerLengthUnit unit) + public TorquePerLength(double value, TorquePerLengthUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -106,14 +106,14 @@ public TorquePerLength(QuantityValue value, TorquePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public TorquePerLength(QuantityValue value, UnitSystem unitSystem) + public TorquePerLength(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -154,10 +154,7 @@ public TorquePerLength(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -180,109 +177,109 @@ public TorquePerLength(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); + public double KilogramForceCentimetersPerMeter => As(TorquePerLengthUnit.KilogramForceCentimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); + public double KilogramForceMetersPerMeter => As(TorquePerLengthUnit.KilogramForceMeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); + public double KilogramForceMillimetersPerMeter => As(TorquePerLengthUnit.KilogramForceMillimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); + public double KilonewtonCentimetersPerMeter => As(TorquePerLengthUnit.KilonewtonCentimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); + public double KilonewtonMetersPerMeter => As(TorquePerLengthUnit.KilonewtonMeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); + public double KilonewtonMillimetersPerMeter => As(TorquePerLengthUnit.KilonewtonMillimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); + public double KilopoundForceFeetPerFoot => As(TorquePerLengthUnit.KilopoundForceFootPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); + public double KilopoundForceInchesPerFoot => As(TorquePerLengthUnit.KilopoundForceInchPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); + public double MeganewtonCentimetersPerMeter => As(TorquePerLengthUnit.MeganewtonCentimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); + public double MeganewtonMetersPerMeter => As(TorquePerLengthUnit.MeganewtonMeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); + public double MeganewtonMillimetersPerMeter => As(TorquePerLengthUnit.MeganewtonMillimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); + public double MegapoundForceFeetPerFoot => As(TorquePerLengthUnit.MegapoundForceFootPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); + public double MegapoundForceInchesPerFoot => As(TorquePerLengthUnit.MegapoundForceInchPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); + public double NewtonCentimetersPerMeter => As(TorquePerLengthUnit.NewtonCentimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); + public double NewtonMetersPerMeter => As(TorquePerLengthUnit.NewtonMeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); + public double NewtonMillimetersPerMeter => As(TorquePerLengthUnit.NewtonMillimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); + public double PoundForceFeetPerFoot => As(TorquePerLengthUnit.PoundForceFootPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); + public double PoundForceInchesPerFoot => As(TorquePerLengthUnit.PoundForceInchPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); + public double TonneForceCentimetersPerMeter => As(TorquePerLengthUnit.TonneForceCentimeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); + public double TonneForceMetersPerMeter => As(TorquePerLengthUnit.TonneForceMeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); + public double TonneForceMillimetersPerMeter => As(TorquePerLengthUnit.TonneForceMillimeterPerMeter); #endregion @@ -401,7 +398,7 @@ public static string GetAbbreviation(TorquePerLengthUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static TorquePerLength FromKilogramForceCentimetersPerMeter(QuantityValue kilogramforcecentimeterspermeter) { - QuantityValue value = (QuantityValue) kilogramforcecentimeterspermeter; + double value = (double) kilogramforcecentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceCentimeterPerMeter); } @@ -411,7 +408,7 @@ public static TorquePerLength FromKilogramForceCentimetersPerMeter(QuantityValue /// If value is NaN or Infinity. public static TorquePerLength FromKilogramForceMetersPerMeter(QuantityValue kilogramforcemeterspermeter) { - QuantityValue value = (QuantityValue) kilogramforcemeterspermeter; + double value = (double) kilogramforcemeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMeterPerMeter); } @@ -421,7 +418,7 @@ public static TorquePerLength FromKilogramForceMetersPerMeter(QuantityValue kilo /// If value is NaN or Infinity. public static TorquePerLength FromKilogramForceMillimetersPerMeter(QuantityValue kilogramforcemillimeterspermeter) { - QuantityValue value = (QuantityValue) kilogramforcemillimeterspermeter; + double value = (double) kilogramforcemillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilogramForceMillimeterPerMeter); } @@ -431,7 +428,7 @@ public static TorquePerLength FromKilogramForceMillimetersPerMeter(QuantityValue /// If value is NaN or Infinity. public static TorquePerLength FromKilonewtonCentimetersPerMeter(QuantityValue kilonewtoncentimeterspermeter) { - QuantityValue value = (QuantityValue) kilonewtoncentimeterspermeter; + double value = (double) kilonewtoncentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonCentimeterPerMeter); } @@ -441,7 +438,7 @@ public static TorquePerLength FromKilonewtonCentimetersPerMeter(QuantityValue ki /// If value is NaN or Infinity. public static TorquePerLength FromKilonewtonMetersPerMeter(QuantityValue kilonewtonmeterspermeter) { - QuantityValue value = (QuantityValue) kilonewtonmeterspermeter; + double value = (double) kilonewtonmeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMeterPerMeter); } @@ -451,7 +448,7 @@ public static TorquePerLength FromKilonewtonMetersPerMeter(QuantityValue kilonew /// If value is NaN or Infinity. public static TorquePerLength FromKilonewtonMillimetersPerMeter(QuantityValue kilonewtonmillimeterspermeter) { - QuantityValue value = (QuantityValue) kilonewtonmillimeterspermeter; + double value = (double) kilonewtonmillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.KilonewtonMillimeterPerMeter); } @@ -461,7 +458,7 @@ public static TorquePerLength FromKilonewtonMillimetersPerMeter(QuantityValue ki /// If value is NaN or Infinity. public static TorquePerLength FromKilopoundForceFeetPerFoot(QuantityValue kilopoundforcefeetperfoot) { - QuantityValue value = (QuantityValue) kilopoundforcefeetperfoot; + double value = (double) kilopoundforcefeetperfoot; return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceFootPerFoot); } @@ -471,7 +468,7 @@ public static TorquePerLength FromKilopoundForceFeetPerFoot(QuantityValue kilopo /// If value is NaN or Infinity. public static TorquePerLength FromKilopoundForceInchesPerFoot(QuantityValue kilopoundforceinchesperfoot) { - QuantityValue value = (QuantityValue) kilopoundforceinchesperfoot; + double value = (double) kilopoundforceinchesperfoot; return new TorquePerLength(value, TorquePerLengthUnit.KilopoundForceInchPerFoot); } @@ -481,7 +478,7 @@ public static TorquePerLength FromKilopoundForceInchesPerFoot(QuantityValue kilo /// If value is NaN or Infinity. public static TorquePerLength FromMeganewtonCentimetersPerMeter(QuantityValue meganewtoncentimeterspermeter) { - QuantityValue value = (QuantityValue) meganewtoncentimeterspermeter; + double value = (double) meganewtoncentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonCentimeterPerMeter); } @@ -491,7 +488,7 @@ public static TorquePerLength FromMeganewtonCentimetersPerMeter(QuantityValue me /// If value is NaN or Infinity. public static TorquePerLength FromMeganewtonMetersPerMeter(QuantityValue meganewtonmeterspermeter) { - QuantityValue value = (QuantityValue) meganewtonmeterspermeter; + double value = (double) meganewtonmeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMeterPerMeter); } @@ -501,7 +498,7 @@ public static TorquePerLength FromMeganewtonMetersPerMeter(QuantityValue meganew /// If value is NaN or Infinity. public static TorquePerLength FromMeganewtonMillimetersPerMeter(QuantityValue meganewtonmillimeterspermeter) { - QuantityValue value = (QuantityValue) meganewtonmillimeterspermeter; + double value = (double) meganewtonmillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.MeganewtonMillimeterPerMeter); } @@ -511,7 +508,7 @@ public static TorquePerLength FromMeganewtonMillimetersPerMeter(QuantityValue me /// If value is NaN or Infinity. public static TorquePerLength FromMegapoundForceFeetPerFoot(QuantityValue megapoundforcefeetperfoot) { - QuantityValue value = (QuantityValue) megapoundforcefeetperfoot; + double value = (double) megapoundforcefeetperfoot; return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceFootPerFoot); } @@ -521,7 +518,7 @@ public static TorquePerLength FromMegapoundForceFeetPerFoot(QuantityValue megapo /// If value is NaN or Infinity. public static TorquePerLength FromMegapoundForceInchesPerFoot(QuantityValue megapoundforceinchesperfoot) { - QuantityValue value = (QuantityValue) megapoundforceinchesperfoot; + double value = (double) megapoundforceinchesperfoot; return new TorquePerLength(value, TorquePerLengthUnit.MegapoundForceInchPerFoot); } @@ -531,7 +528,7 @@ public static TorquePerLength FromMegapoundForceInchesPerFoot(QuantityValue mega /// If value is NaN or Infinity. public static TorquePerLength FromNewtonCentimetersPerMeter(QuantityValue newtoncentimeterspermeter) { - QuantityValue value = (QuantityValue) newtoncentimeterspermeter; + double value = (double) newtoncentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.NewtonCentimeterPerMeter); } @@ -541,7 +538,7 @@ public static TorquePerLength FromNewtonCentimetersPerMeter(QuantityValue newton /// If value is NaN or Infinity. public static TorquePerLength FromNewtonMetersPerMeter(QuantityValue newtonmeterspermeter) { - QuantityValue value = (QuantityValue) newtonmeterspermeter; + double value = (double) newtonmeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.NewtonMeterPerMeter); } @@ -551,7 +548,7 @@ public static TorquePerLength FromNewtonMetersPerMeter(QuantityValue newtonmeter /// If value is NaN or Infinity. public static TorquePerLength FromNewtonMillimetersPerMeter(QuantityValue newtonmillimeterspermeter) { - QuantityValue value = (QuantityValue) newtonmillimeterspermeter; + double value = (double) newtonmillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.NewtonMillimeterPerMeter); } @@ -561,7 +558,7 @@ public static TorquePerLength FromNewtonMillimetersPerMeter(QuantityValue newton /// If value is NaN or Infinity. public static TorquePerLength FromPoundForceFeetPerFoot(QuantityValue poundforcefeetperfoot) { - QuantityValue value = (QuantityValue) poundforcefeetperfoot; + double value = (double) poundforcefeetperfoot; return new TorquePerLength(value, TorquePerLengthUnit.PoundForceFootPerFoot); } @@ -571,7 +568,7 @@ public static TorquePerLength FromPoundForceFeetPerFoot(QuantityValue poundforce /// If value is NaN or Infinity. public static TorquePerLength FromPoundForceInchesPerFoot(QuantityValue poundforceinchesperfoot) { - QuantityValue value = (QuantityValue) poundforceinchesperfoot; + double value = (double) poundforceinchesperfoot; return new TorquePerLength(value, TorquePerLengthUnit.PoundForceInchPerFoot); } @@ -581,7 +578,7 @@ public static TorquePerLength FromPoundForceInchesPerFoot(QuantityValue poundfor /// If value is NaN or Infinity. public static TorquePerLength FromTonneForceCentimetersPerMeter(QuantityValue tonneforcecentimeterspermeter) { - QuantityValue value = (QuantityValue) tonneforcecentimeterspermeter; + double value = (double) tonneforcecentimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.TonneForceCentimeterPerMeter); } @@ -591,7 +588,7 @@ public static TorquePerLength FromTonneForceCentimetersPerMeter(QuantityValue to /// If value is NaN or Infinity. public static TorquePerLength FromTonneForceMetersPerMeter(QuantityValue tonneforcemeterspermeter) { - QuantityValue value = (QuantityValue) tonneforcemeterspermeter; + double value = (double) tonneforcemeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMeterPerMeter); } @@ -601,7 +598,7 @@ public static TorquePerLength FromTonneForceMetersPerMeter(QuantityValue tonnefo /// If value is NaN or Infinity. public static TorquePerLength FromTonneForceMillimetersPerMeter(QuantityValue tonneforcemillimeterspermeter) { - QuantityValue value = (QuantityValue) tonneforcemillimeterspermeter; + double value = (double) tonneforcemillimeterspermeter; return new TorquePerLength(value, TorquePerLengthUnit.TonneForceMillimeterPerMeter); } @@ -613,7 +610,7 @@ public static TorquePerLength FromTonneForceMillimetersPerMeter(QuantityValue to /// TorquePerLength unit value. public static TorquePerLength From(QuantityValue value, TorquePerLengthUnit fromUnit) { - return new TorquePerLength((QuantityValue)value, fromUnit); + return new TorquePerLength((double)value, fromUnit); } #endregion @@ -783,25 +780,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu } /// Get from multiplying value and . - public static TorquePerLength operator *(QuantityValue left, TorquePerLength right) + public static TorquePerLength operator *(double left, TorquePerLength right) { return new TorquePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static TorquePerLength operator *(TorquePerLength left, QuantityValue right) + public static TorquePerLength operator *(TorquePerLength left, double right) { return new TorquePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static TorquePerLength operator /(TorquePerLength left, QuantityValue right) + public static TorquePerLength operator /(TorquePerLength left, double right) { return new TorquePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(TorquePerLength left, TorquePerLength right) + public static double operator /(TorquePerLength left, TorquePerLength right) { return left.NewtonMetersPerMeter / right.NewtonMetersPerMeter; } @@ -834,19 +831,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Torqu return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(TorquePerLength left, TorquePerLength right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(TorquePerLength left, TorquePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -859,29 +843,7 @@ public int CompareTo(object obj) /// public int CompareTo(TorquePerLength other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is TorquePerLength objTorquePerLength)) - return false; - return Equals(objTorquePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(TorquePerLength other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -924,13 +886,13 @@ public bool Equals(TorquePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(TorquePerLength other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(TorquePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -941,7 +903,7 @@ public bool Equals(TorquePerLength other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current TorquePerLength. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -952,16 +914,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TorquePerLengthUnit unit) + public double As(TorquePerLengthUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -976,12 +939,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TorquePerLengthUnit typedUnit)) + if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTorquePerLengthUnit); } /// @@ -1013,7 +976,7 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (TorquePerLength)converted; } - else if (Enum.IsDefined(typeof(TorquePerLengthUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1021,17 +984,17 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorquePerLengthUnit typedUnit)) + if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTorquePerLengthUnit, DefaultConversionFunctions); } /// @@ -1058,10 +1021,10 @@ public TorquePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TorquePerLengthUnit unit) + private double GetValueAs(TorquePerLengthUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index 0e87ea313b..f94f7592e1 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Turbidity /// [DataContract] - public partial struct Turbidity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Turbidity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -75,9 +75,9 @@ static Turbidity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Turbidity(QuantityValue value, TurbidityUnit unit) + public Turbidity(double value, TurbidityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -89,14 +89,14 @@ public Turbidity(QuantityValue value, TurbidityUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Turbidity(QuantityValue value, UnitSystem unitSystem) + public Turbidity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -137,10 +137,7 @@ public Turbidity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -163,9 +160,9 @@ public Turbidity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NTU => As(TurbidityUnit.NTU); + public double NTU => As(TurbidityUnit.NTU); #endregion @@ -221,7 +218,7 @@ public static string GetAbbreviation(TurbidityUnit unit, IFormatProvider? provid /// If value is NaN or Infinity. public static Turbidity FromNTU(QuantityValue ntu) { - QuantityValue value = (QuantityValue) ntu; + double value = (double) ntu; return new Turbidity(value, TurbidityUnit.NTU); } @@ -233,7 +230,7 @@ public static Turbidity FromNTU(QuantityValue ntu) /// Turbidity unit value. public static Turbidity From(QuantityValue value, TurbidityUnit fromUnit) { - return new Turbidity((QuantityValue)value, fromUnit); + return new Turbidity((double)value, fromUnit); } #endregion @@ -403,25 +400,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi } /// Get from multiplying value and . - public static Turbidity operator *(QuantityValue left, Turbidity right) + public static Turbidity operator *(double left, Turbidity right) { return new Turbidity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Turbidity operator *(Turbidity left, QuantityValue right) + public static Turbidity operator *(Turbidity left, double right) { return new Turbidity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Turbidity operator /(Turbidity left, QuantityValue right) + public static Turbidity operator /(Turbidity left, double right) { return new Turbidity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Turbidity left, Turbidity right) + public static double operator /(Turbidity left, Turbidity right) { return left.NTU / right.NTU; } @@ -454,19 +451,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Turbi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Turbidity left, Turbidity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Turbidity left, Turbidity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -479,29 +463,7 @@ public int CompareTo(object obj) /// public int CompareTo(Turbidity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Turbidity objTurbidity)) - return false; - return Equals(objTurbidity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Turbidity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -544,13 +506,13 @@ public bool Equals(Turbidity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Turbidity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -561,7 +523,7 @@ public bool Equals(Turbidity other, QuantityValue tolerance, ComparisonType comp /// A hash code for the current Turbidity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -572,16 +534,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(TurbidityUnit unit) + public double As(TurbidityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -596,12 +559,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is TurbidityUnit typedUnit)) + if (!(unit is TurbidityUnit unitAsTurbidityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsTurbidityUnit); } /// @@ -633,7 +596,7 @@ public Turbidity ToUnit(TurbidityUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Turbidity)converted; } - else if (Enum.IsDefined(typeof(TurbidityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -641,17 +604,17 @@ public Turbidity ToUnit(TurbidityUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TurbidityUnit typedUnit)) + if (!(unit is TurbidityUnit unitAsTurbidityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsTurbidityUnit, DefaultConversionFunctions); } /// @@ -678,10 +641,10 @@ public Turbidity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(TurbidityUnit unit) + private double GetValueAs(TurbidityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 2bedd85d64..454db0c919 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Vitamin A: 1 IU is the biological equivalent of 0.3 µg retinol, or of 0.6 µg beta-carotene. /// [DataContract] - public partial struct VitaminA : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VitaminA : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -72,9 +72,9 @@ static VitaminA() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VitaminA(QuantityValue value, VitaminAUnit unit) + public VitaminA(double value, VitaminAUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -86,14 +86,14 @@ public VitaminA(QuantityValue value, VitaminAUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VitaminA(QuantityValue value, UnitSystem unitSystem) + public VitaminA(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -134,10 +134,7 @@ public VitaminA(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -160,9 +157,9 @@ public VitaminA(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InternationalUnits => As(VitaminAUnit.InternationalUnit); + public double InternationalUnits => As(VitaminAUnit.InternationalUnit); #endregion @@ -218,7 +215,7 @@ public static string GetAbbreviation(VitaminAUnit unit, IFormatProvider? provide /// If value is NaN or Infinity. public static VitaminA FromInternationalUnits(QuantityValue internationalunits) { - QuantityValue value = (QuantityValue) internationalunits; + double value = (double) internationalunits; return new VitaminA(value, VitaminAUnit.InternationalUnit); } @@ -230,7 +227,7 @@ public static VitaminA FromInternationalUnits(QuantityValue internationalunits) /// VitaminA unit value. public static VitaminA From(QuantityValue value, VitaminAUnit fromUnit) { - return new VitaminA((QuantityValue)value, fromUnit); + return new VitaminA((double)value, fromUnit); } #endregion @@ -400,25 +397,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam } /// Get from multiplying value and . - public static VitaminA operator *(QuantityValue left, VitaminA right) + public static VitaminA operator *(double left, VitaminA right) { return new VitaminA(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VitaminA operator *(VitaminA left, QuantityValue right) + public static VitaminA operator *(VitaminA left, double right) { return new VitaminA(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VitaminA operator /(VitaminA left, QuantityValue right) + public static VitaminA operator /(VitaminA left, double right) { return new VitaminA(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(VitaminA left, VitaminA right) + public static double operator /(VitaminA left, VitaminA right) { return left.InternationalUnits / right.InternationalUnits; } @@ -451,19 +448,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Vitam return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VitaminA left, VitaminA right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VitaminA left, VitaminA right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -476,29 +460,7 @@ public int CompareTo(object obj) /// public int CompareTo(VitaminA other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is VitaminA objVitaminA)) - return false; - return Equals(objVitaminA); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VitaminA other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -541,13 +503,13 @@ public bool Equals(VitaminA other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VitaminA other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -558,7 +520,7 @@ public bool Equals(VitaminA other, QuantityValue tolerance, ComparisonType compa /// A hash code for the current VitaminA. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -569,16 +531,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VitaminAUnit unit) + public double As(VitaminAUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -593,12 +556,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VitaminAUnit typedUnit)) + if (!(unit is VitaminAUnit unitAsVitaminAUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVitaminAUnit); } /// @@ -630,7 +593,7 @@ public VitaminA ToUnit(VitaminAUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (VitaminA)converted; } - else if (Enum.IsDefined(typeof(VitaminAUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -638,17 +601,17 @@ public VitaminA ToUnit(VitaminAUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VitaminAUnit typedUnit)) + if (!(unit is VitaminAUnit unitAsVitaminAUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVitaminAUnit, DefaultConversionFunctions); } /// @@ -675,10 +638,10 @@ public VitaminA ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VitaminAUnit unit) + private double GetValueAs(VitaminAUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 80f0571e29..2d54789723 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Volume is the quantity of three-dimensional space enclosed by some closed boundary, for example, the space that a substance (solid, liquid, gas, or plasma) or shape occupies or contains.[1] Volume is often quantified numerically using the SI derived unit, the cubic metre. The volume of a container is generally understood to be the capacity of the container, i. e. the amount of fluid (gas or liquid) that the container could hold, rather than the amount of space the container itself displaces. /// [DataContract] - public partial struct Volume : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct Volume : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -123,9 +123,9 @@ static Volume() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public Volume(QuantityValue value, VolumeUnit unit) + public Volume(double value, VolumeUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -137,14 +137,14 @@ public Volume(QuantityValue value, VolumeUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public Volume(QuantityValue value, UnitSystem unitSystem) + public Volume(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -185,10 +185,7 @@ public Volume(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -211,264 +208,264 @@ public Volume(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AcreFeet => As(VolumeUnit.AcreFoot); + public double AcreFeet => As(VolumeUnit.AcreFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AuTablespoons => As(VolumeUnit.AuTablespoon); + public double AuTablespoons => As(VolumeUnit.AuTablespoon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BoardFeet => As(VolumeUnit.BoardFoot); + public double BoardFeet => As(VolumeUnit.BoardFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Centiliters => As(VolumeUnit.Centiliter); + public double Centiliters => As(VolumeUnit.Centiliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicCentimeters => As(VolumeUnit.CubicCentimeter); + public double CubicCentimeters => As(VolumeUnit.CubicCentimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicDecimeters => As(VolumeUnit.CubicDecimeter); + public double CubicDecimeters => As(VolumeUnit.CubicDecimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicFeet => As(VolumeUnit.CubicFoot); + public double CubicFeet => As(VolumeUnit.CubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicHectometers => As(VolumeUnit.CubicHectometer); + public double CubicHectometers => As(VolumeUnit.CubicHectometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicInches => As(VolumeUnit.CubicInch); + public double CubicInches => As(VolumeUnit.CubicInch); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicKilometers => As(VolumeUnit.CubicKilometer); + public double CubicKilometers => As(VolumeUnit.CubicKilometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMeters => As(VolumeUnit.CubicMeter); + public double CubicMeters => As(VolumeUnit.CubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMicrometers => As(VolumeUnit.CubicMicrometer); + public double CubicMicrometers => As(VolumeUnit.CubicMicrometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMiles => As(VolumeUnit.CubicMile); + public double CubicMiles => As(VolumeUnit.CubicMile); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMillimeters => As(VolumeUnit.CubicMillimeter); + public double CubicMillimeters => As(VolumeUnit.CubicMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYards => As(VolumeUnit.CubicYard); + public double CubicYards => As(VolumeUnit.CubicYard); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Decaliters => As(VolumeUnit.Decaliter); + public double Decaliters => As(VolumeUnit.Decaliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecausGallons => As(VolumeUnit.DecausGallon); + public double DecausGallons => As(VolumeUnit.DecausGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Deciliters => As(VolumeUnit.Deciliter); + public double Deciliters => As(VolumeUnit.Deciliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DeciusGallons => As(VolumeUnit.DeciusGallon); + public double DeciusGallons => As(VolumeUnit.DeciusGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectocubicFeet => As(VolumeUnit.HectocubicFoot); + public double HectocubicFeet => As(VolumeUnit.HectocubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectocubicMeters => As(VolumeUnit.HectocubicMeter); + public double HectocubicMeters => As(VolumeUnit.HectocubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Hectoliters => As(VolumeUnit.Hectoliter); + public double Hectoliters => As(VolumeUnit.Hectoliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue HectousGallons => As(VolumeUnit.HectousGallon); + public double HectousGallons => As(VolumeUnit.HectousGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); + public double ImperialBeerBarrels => As(VolumeUnit.ImperialBeerBarrel); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ImperialGallons => As(VolumeUnit.ImperialGallon); + public double ImperialGallons => As(VolumeUnit.ImperialGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ImperialOunces => As(VolumeUnit.ImperialOunce); + public double ImperialOunces => As(VolumeUnit.ImperialOunce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue ImperialPints => As(VolumeUnit.ImperialPint); + public double ImperialPints => As(VolumeUnit.ImperialPint); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocubicFeet => As(VolumeUnit.KilocubicFoot); + public double KilocubicFeet => As(VolumeUnit.KilocubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocubicMeters => As(VolumeUnit.KilocubicMeter); + public double KilocubicMeters => As(VolumeUnit.KilocubicMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); + public double KiloimperialGallons => As(VolumeUnit.KiloimperialGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Kiloliters => As(VolumeUnit.Kiloliter); + public double Kiloliters => As(VolumeUnit.Kiloliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilousGallons => As(VolumeUnit.KilousGallon); + public double KilousGallons => As(VolumeUnit.KilousGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Liters => As(VolumeUnit.Liter); + public double Liters => As(VolumeUnit.Liter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegacubicFeet => As(VolumeUnit.MegacubicFoot); + public double MegacubicFeet => As(VolumeUnit.MegacubicFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); + public double MegaimperialGallons => As(VolumeUnit.MegaimperialGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Megaliters => As(VolumeUnit.Megaliter); + public double Megaliters => As(VolumeUnit.Megaliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegausGallons => As(VolumeUnit.MegausGallon); + public double MegausGallons => As(VolumeUnit.MegausGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetricCups => As(VolumeUnit.MetricCup); + public double MetricCups => As(VolumeUnit.MetricCup); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); + public double MetricTeaspoons => As(VolumeUnit.MetricTeaspoon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Microliters => As(VolumeUnit.Microliter); + public double Microliters => As(VolumeUnit.Microliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Milliliters => As(VolumeUnit.Milliliter); + public double Milliliters => As(VolumeUnit.Milliliter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OilBarrels => As(VolumeUnit.OilBarrel); + public double OilBarrels => As(VolumeUnit.OilBarrel); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UkTablespoons => As(VolumeUnit.UkTablespoon); + public double UkTablespoons => As(VolumeUnit.UkTablespoon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); + public double UsBeerBarrels => As(VolumeUnit.UsBeerBarrel); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); + public double UsCustomaryCups => As(VolumeUnit.UsCustomaryCup); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsGallons => As(VolumeUnit.UsGallon); + public double UsGallons => As(VolumeUnit.UsGallon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsLegalCups => As(VolumeUnit.UsLegalCup); + public double UsLegalCups => As(VolumeUnit.UsLegalCup); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsOunces => As(VolumeUnit.UsOunce); + public double UsOunces => As(VolumeUnit.UsOunce); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsPints => As(VolumeUnit.UsPint); + public double UsPints => As(VolumeUnit.UsPint); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsQuarts => As(VolumeUnit.UsQuart); + public double UsQuarts => As(VolumeUnit.UsQuart); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsTablespoons => As(VolumeUnit.UsTablespoon); + public double UsTablespoons => As(VolumeUnit.UsTablespoon); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsTeaspoons => As(VolumeUnit.UsTeaspoon); + public double UsTeaspoons => As(VolumeUnit.UsTeaspoon); #endregion @@ -724,7 +721,7 @@ public static string GetAbbreviation(VolumeUnit unit, IFormatProvider? provider) /// If value is NaN or Infinity. public static Volume FromAcreFeet(QuantityValue acrefeet) { - QuantityValue value = (QuantityValue) acrefeet; + double value = (double) acrefeet; return new Volume(value, VolumeUnit.AcreFoot); } @@ -734,7 +731,7 @@ public static Volume FromAcreFeet(QuantityValue acrefeet) /// If value is NaN or Infinity. public static Volume FromAuTablespoons(QuantityValue autablespoons) { - QuantityValue value = (QuantityValue) autablespoons; + double value = (double) autablespoons; return new Volume(value, VolumeUnit.AuTablespoon); } @@ -744,7 +741,7 @@ public static Volume FromAuTablespoons(QuantityValue autablespoons) /// If value is NaN or Infinity. public static Volume FromBoardFeet(QuantityValue boardfeet) { - QuantityValue value = (QuantityValue) boardfeet; + double value = (double) boardfeet; return new Volume(value, VolumeUnit.BoardFoot); } @@ -754,7 +751,7 @@ public static Volume FromBoardFeet(QuantityValue boardfeet) /// If value is NaN or Infinity. public static Volume FromCentiliters(QuantityValue centiliters) { - QuantityValue value = (QuantityValue) centiliters; + double value = (double) centiliters; return new Volume(value, VolumeUnit.Centiliter); } @@ -764,7 +761,7 @@ public static Volume FromCentiliters(QuantityValue centiliters) /// If value is NaN or Infinity. public static Volume FromCubicCentimeters(QuantityValue cubiccentimeters) { - QuantityValue value = (QuantityValue) cubiccentimeters; + double value = (double) cubiccentimeters; return new Volume(value, VolumeUnit.CubicCentimeter); } @@ -774,7 +771,7 @@ public static Volume FromCubicCentimeters(QuantityValue cubiccentimeters) /// If value is NaN or Infinity. public static Volume FromCubicDecimeters(QuantityValue cubicdecimeters) { - QuantityValue value = (QuantityValue) cubicdecimeters; + double value = (double) cubicdecimeters; return new Volume(value, VolumeUnit.CubicDecimeter); } @@ -784,7 +781,7 @@ public static Volume FromCubicDecimeters(QuantityValue cubicdecimeters) /// If value is NaN or Infinity. public static Volume FromCubicFeet(QuantityValue cubicfeet) { - QuantityValue value = (QuantityValue) cubicfeet; + double value = (double) cubicfeet; return new Volume(value, VolumeUnit.CubicFoot); } @@ -794,7 +791,7 @@ public static Volume FromCubicFeet(QuantityValue cubicfeet) /// If value is NaN or Infinity. public static Volume FromCubicHectometers(QuantityValue cubichectometers) { - QuantityValue value = (QuantityValue) cubichectometers; + double value = (double) cubichectometers; return new Volume(value, VolumeUnit.CubicHectometer); } @@ -804,7 +801,7 @@ public static Volume FromCubicHectometers(QuantityValue cubichectometers) /// If value is NaN or Infinity. public static Volume FromCubicInches(QuantityValue cubicinches) { - QuantityValue value = (QuantityValue) cubicinches; + double value = (double) cubicinches; return new Volume(value, VolumeUnit.CubicInch); } @@ -814,7 +811,7 @@ public static Volume FromCubicInches(QuantityValue cubicinches) /// If value is NaN or Infinity. public static Volume FromCubicKilometers(QuantityValue cubickilometers) { - QuantityValue value = (QuantityValue) cubickilometers; + double value = (double) cubickilometers; return new Volume(value, VolumeUnit.CubicKilometer); } @@ -824,7 +821,7 @@ public static Volume FromCubicKilometers(QuantityValue cubickilometers) /// If value is NaN or Infinity. public static Volume FromCubicMeters(QuantityValue cubicmeters) { - QuantityValue value = (QuantityValue) cubicmeters; + double value = (double) cubicmeters; return new Volume(value, VolumeUnit.CubicMeter); } @@ -834,7 +831,7 @@ public static Volume FromCubicMeters(QuantityValue cubicmeters) /// If value is NaN or Infinity. public static Volume FromCubicMicrometers(QuantityValue cubicmicrometers) { - QuantityValue value = (QuantityValue) cubicmicrometers; + double value = (double) cubicmicrometers; return new Volume(value, VolumeUnit.CubicMicrometer); } @@ -844,7 +841,7 @@ public static Volume FromCubicMicrometers(QuantityValue cubicmicrometers) /// If value is NaN or Infinity. public static Volume FromCubicMiles(QuantityValue cubicmiles) { - QuantityValue value = (QuantityValue) cubicmiles; + double value = (double) cubicmiles; return new Volume(value, VolumeUnit.CubicMile); } @@ -854,7 +851,7 @@ public static Volume FromCubicMiles(QuantityValue cubicmiles) /// If value is NaN or Infinity. public static Volume FromCubicMillimeters(QuantityValue cubicmillimeters) { - QuantityValue value = (QuantityValue) cubicmillimeters; + double value = (double) cubicmillimeters; return new Volume(value, VolumeUnit.CubicMillimeter); } @@ -864,7 +861,7 @@ public static Volume FromCubicMillimeters(QuantityValue cubicmillimeters) /// If value is NaN or Infinity. public static Volume FromCubicYards(QuantityValue cubicyards) { - QuantityValue value = (QuantityValue) cubicyards; + double value = (double) cubicyards; return new Volume(value, VolumeUnit.CubicYard); } @@ -874,7 +871,7 @@ public static Volume FromCubicYards(QuantityValue cubicyards) /// If value is NaN or Infinity. public static Volume FromDecaliters(QuantityValue decaliters) { - QuantityValue value = (QuantityValue) decaliters; + double value = (double) decaliters; return new Volume(value, VolumeUnit.Decaliter); } @@ -884,7 +881,7 @@ public static Volume FromDecaliters(QuantityValue decaliters) /// If value is NaN or Infinity. public static Volume FromDecausGallons(QuantityValue decausgallons) { - QuantityValue value = (QuantityValue) decausgallons; + double value = (double) decausgallons; return new Volume(value, VolumeUnit.DecausGallon); } @@ -894,7 +891,7 @@ public static Volume FromDecausGallons(QuantityValue decausgallons) /// If value is NaN or Infinity. public static Volume FromDeciliters(QuantityValue deciliters) { - QuantityValue value = (QuantityValue) deciliters; + double value = (double) deciliters; return new Volume(value, VolumeUnit.Deciliter); } @@ -904,7 +901,7 @@ public static Volume FromDeciliters(QuantityValue deciliters) /// If value is NaN or Infinity. public static Volume FromDeciusGallons(QuantityValue deciusgallons) { - QuantityValue value = (QuantityValue) deciusgallons; + double value = (double) deciusgallons; return new Volume(value, VolumeUnit.DeciusGallon); } @@ -914,7 +911,7 @@ public static Volume FromDeciusGallons(QuantityValue deciusgallons) /// If value is NaN or Infinity. public static Volume FromHectocubicFeet(QuantityValue hectocubicfeet) { - QuantityValue value = (QuantityValue) hectocubicfeet; + double value = (double) hectocubicfeet; return new Volume(value, VolumeUnit.HectocubicFoot); } @@ -924,7 +921,7 @@ public static Volume FromHectocubicFeet(QuantityValue hectocubicfeet) /// If value is NaN or Infinity. public static Volume FromHectocubicMeters(QuantityValue hectocubicmeters) { - QuantityValue value = (QuantityValue) hectocubicmeters; + double value = (double) hectocubicmeters; return new Volume(value, VolumeUnit.HectocubicMeter); } @@ -934,7 +931,7 @@ public static Volume FromHectocubicMeters(QuantityValue hectocubicmeters) /// If value is NaN or Infinity. public static Volume FromHectoliters(QuantityValue hectoliters) { - QuantityValue value = (QuantityValue) hectoliters; + double value = (double) hectoliters; return new Volume(value, VolumeUnit.Hectoliter); } @@ -944,7 +941,7 @@ public static Volume FromHectoliters(QuantityValue hectoliters) /// If value is NaN or Infinity. public static Volume FromHectousGallons(QuantityValue hectousgallons) { - QuantityValue value = (QuantityValue) hectousgallons; + double value = (double) hectousgallons; return new Volume(value, VolumeUnit.HectousGallon); } @@ -954,7 +951,7 @@ public static Volume FromHectousGallons(QuantityValue hectousgallons) /// If value is NaN or Infinity. public static Volume FromImperialBeerBarrels(QuantityValue imperialbeerbarrels) { - QuantityValue value = (QuantityValue) imperialbeerbarrels; + double value = (double) imperialbeerbarrels; return new Volume(value, VolumeUnit.ImperialBeerBarrel); } @@ -964,7 +961,7 @@ public static Volume FromImperialBeerBarrels(QuantityValue imperialbeerbarrels) /// If value is NaN or Infinity. public static Volume FromImperialGallons(QuantityValue imperialgallons) { - QuantityValue value = (QuantityValue) imperialgallons; + double value = (double) imperialgallons; return new Volume(value, VolumeUnit.ImperialGallon); } @@ -974,7 +971,7 @@ public static Volume FromImperialGallons(QuantityValue imperialgallons) /// If value is NaN or Infinity. public static Volume FromImperialOunces(QuantityValue imperialounces) { - QuantityValue value = (QuantityValue) imperialounces; + double value = (double) imperialounces; return new Volume(value, VolumeUnit.ImperialOunce); } @@ -984,7 +981,7 @@ public static Volume FromImperialOunces(QuantityValue imperialounces) /// If value is NaN or Infinity. public static Volume FromImperialPints(QuantityValue imperialpints) { - QuantityValue value = (QuantityValue) imperialpints; + double value = (double) imperialpints; return new Volume(value, VolumeUnit.ImperialPint); } @@ -994,7 +991,7 @@ public static Volume FromImperialPints(QuantityValue imperialpints) /// If value is NaN or Infinity. public static Volume FromKilocubicFeet(QuantityValue kilocubicfeet) { - QuantityValue value = (QuantityValue) kilocubicfeet; + double value = (double) kilocubicfeet; return new Volume(value, VolumeUnit.KilocubicFoot); } @@ -1004,7 +1001,7 @@ public static Volume FromKilocubicFeet(QuantityValue kilocubicfeet) /// If value is NaN or Infinity. public static Volume FromKilocubicMeters(QuantityValue kilocubicmeters) { - QuantityValue value = (QuantityValue) kilocubicmeters; + double value = (double) kilocubicmeters; return new Volume(value, VolumeUnit.KilocubicMeter); } @@ -1014,7 +1011,7 @@ public static Volume FromKilocubicMeters(QuantityValue kilocubicmeters) /// If value is NaN or Infinity. public static Volume FromKiloimperialGallons(QuantityValue kiloimperialgallons) { - QuantityValue value = (QuantityValue) kiloimperialgallons; + double value = (double) kiloimperialgallons; return new Volume(value, VolumeUnit.KiloimperialGallon); } @@ -1024,7 +1021,7 @@ public static Volume FromKiloimperialGallons(QuantityValue kiloimperialgallons) /// If value is NaN or Infinity. public static Volume FromKiloliters(QuantityValue kiloliters) { - QuantityValue value = (QuantityValue) kiloliters; + double value = (double) kiloliters; return new Volume(value, VolumeUnit.Kiloliter); } @@ -1034,7 +1031,7 @@ public static Volume FromKiloliters(QuantityValue kiloliters) /// If value is NaN or Infinity. public static Volume FromKilousGallons(QuantityValue kilousgallons) { - QuantityValue value = (QuantityValue) kilousgallons; + double value = (double) kilousgallons; return new Volume(value, VolumeUnit.KilousGallon); } @@ -1044,7 +1041,7 @@ public static Volume FromKilousGallons(QuantityValue kilousgallons) /// If value is NaN or Infinity. public static Volume FromLiters(QuantityValue liters) { - QuantityValue value = (QuantityValue) liters; + double value = (double) liters; return new Volume(value, VolumeUnit.Liter); } @@ -1054,7 +1051,7 @@ public static Volume FromLiters(QuantityValue liters) /// If value is NaN or Infinity. public static Volume FromMegacubicFeet(QuantityValue megacubicfeet) { - QuantityValue value = (QuantityValue) megacubicfeet; + double value = (double) megacubicfeet; return new Volume(value, VolumeUnit.MegacubicFoot); } @@ -1064,7 +1061,7 @@ public static Volume FromMegacubicFeet(QuantityValue megacubicfeet) /// If value is NaN or Infinity. public static Volume FromMegaimperialGallons(QuantityValue megaimperialgallons) { - QuantityValue value = (QuantityValue) megaimperialgallons; + double value = (double) megaimperialgallons; return new Volume(value, VolumeUnit.MegaimperialGallon); } @@ -1074,7 +1071,7 @@ public static Volume FromMegaimperialGallons(QuantityValue megaimperialgallons) /// If value is NaN or Infinity. public static Volume FromMegaliters(QuantityValue megaliters) { - QuantityValue value = (QuantityValue) megaliters; + double value = (double) megaliters; return new Volume(value, VolumeUnit.Megaliter); } @@ -1084,7 +1081,7 @@ public static Volume FromMegaliters(QuantityValue megaliters) /// If value is NaN or Infinity. public static Volume FromMegausGallons(QuantityValue megausgallons) { - QuantityValue value = (QuantityValue) megausgallons; + double value = (double) megausgallons; return new Volume(value, VolumeUnit.MegausGallon); } @@ -1094,7 +1091,7 @@ public static Volume FromMegausGallons(QuantityValue megausgallons) /// If value is NaN or Infinity. public static Volume FromMetricCups(QuantityValue metriccups) { - QuantityValue value = (QuantityValue) metriccups; + double value = (double) metriccups; return new Volume(value, VolumeUnit.MetricCup); } @@ -1104,7 +1101,7 @@ public static Volume FromMetricCups(QuantityValue metriccups) /// If value is NaN or Infinity. public static Volume FromMetricTeaspoons(QuantityValue metricteaspoons) { - QuantityValue value = (QuantityValue) metricteaspoons; + double value = (double) metricteaspoons; return new Volume(value, VolumeUnit.MetricTeaspoon); } @@ -1114,7 +1111,7 @@ public static Volume FromMetricTeaspoons(QuantityValue metricteaspoons) /// If value is NaN or Infinity. public static Volume FromMicroliters(QuantityValue microliters) { - QuantityValue value = (QuantityValue) microliters; + double value = (double) microliters; return new Volume(value, VolumeUnit.Microliter); } @@ -1124,7 +1121,7 @@ public static Volume FromMicroliters(QuantityValue microliters) /// If value is NaN or Infinity. public static Volume FromMilliliters(QuantityValue milliliters) { - QuantityValue value = (QuantityValue) milliliters; + double value = (double) milliliters; return new Volume(value, VolumeUnit.Milliliter); } @@ -1134,7 +1131,7 @@ public static Volume FromMilliliters(QuantityValue milliliters) /// If value is NaN or Infinity. public static Volume FromOilBarrels(QuantityValue oilbarrels) { - QuantityValue value = (QuantityValue) oilbarrels; + double value = (double) oilbarrels; return new Volume(value, VolumeUnit.OilBarrel); } @@ -1144,7 +1141,7 @@ public static Volume FromOilBarrels(QuantityValue oilbarrels) /// If value is NaN or Infinity. public static Volume FromUkTablespoons(QuantityValue uktablespoons) { - QuantityValue value = (QuantityValue) uktablespoons; + double value = (double) uktablespoons; return new Volume(value, VolumeUnit.UkTablespoon); } @@ -1154,7 +1151,7 @@ public static Volume FromUkTablespoons(QuantityValue uktablespoons) /// If value is NaN or Infinity. public static Volume FromUsBeerBarrels(QuantityValue usbeerbarrels) { - QuantityValue value = (QuantityValue) usbeerbarrels; + double value = (double) usbeerbarrels; return new Volume(value, VolumeUnit.UsBeerBarrel); } @@ -1164,7 +1161,7 @@ public static Volume FromUsBeerBarrels(QuantityValue usbeerbarrels) /// If value is NaN or Infinity. public static Volume FromUsCustomaryCups(QuantityValue uscustomarycups) { - QuantityValue value = (QuantityValue) uscustomarycups; + double value = (double) uscustomarycups; return new Volume(value, VolumeUnit.UsCustomaryCup); } @@ -1174,7 +1171,7 @@ public static Volume FromUsCustomaryCups(QuantityValue uscustomarycups) /// If value is NaN or Infinity. public static Volume FromUsGallons(QuantityValue usgallons) { - QuantityValue value = (QuantityValue) usgallons; + double value = (double) usgallons; return new Volume(value, VolumeUnit.UsGallon); } @@ -1184,7 +1181,7 @@ public static Volume FromUsGallons(QuantityValue usgallons) /// If value is NaN or Infinity. public static Volume FromUsLegalCups(QuantityValue uslegalcups) { - QuantityValue value = (QuantityValue) uslegalcups; + double value = (double) uslegalcups; return new Volume(value, VolumeUnit.UsLegalCup); } @@ -1194,7 +1191,7 @@ public static Volume FromUsLegalCups(QuantityValue uslegalcups) /// If value is NaN or Infinity. public static Volume FromUsOunces(QuantityValue usounces) { - QuantityValue value = (QuantityValue) usounces; + double value = (double) usounces; return new Volume(value, VolumeUnit.UsOunce); } @@ -1204,7 +1201,7 @@ public static Volume FromUsOunces(QuantityValue usounces) /// If value is NaN or Infinity. public static Volume FromUsPints(QuantityValue uspints) { - QuantityValue value = (QuantityValue) uspints; + double value = (double) uspints; return new Volume(value, VolumeUnit.UsPint); } @@ -1214,7 +1211,7 @@ public static Volume FromUsPints(QuantityValue uspints) /// If value is NaN or Infinity. public static Volume FromUsQuarts(QuantityValue usquarts) { - QuantityValue value = (QuantityValue) usquarts; + double value = (double) usquarts; return new Volume(value, VolumeUnit.UsQuart); } @@ -1224,7 +1221,7 @@ public static Volume FromUsQuarts(QuantityValue usquarts) /// If value is NaN or Infinity. public static Volume FromUsTablespoons(QuantityValue ustablespoons) { - QuantityValue value = (QuantityValue) ustablespoons; + double value = (double) ustablespoons; return new Volume(value, VolumeUnit.UsTablespoon); } @@ -1234,7 +1231,7 @@ public static Volume FromUsTablespoons(QuantityValue ustablespoons) /// If value is NaN or Infinity. public static Volume FromUsTeaspoons(QuantityValue usteaspoons) { - QuantityValue value = (QuantityValue) usteaspoons; + double value = (double) usteaspoons; return new Volume(value, VolumeUnit.UsTeaspoon); } @@ -1246,7 +1243,7 @@ public static Volume FromUsTeaspoons(QuantityValue usteaspoons) /// Volume unit value. public static Volume From(QuantityValue value, VolumeUnit fromUnit) { - return new Volume((QuantityValue)value, fromUnit); + return new Volume((double)value, fromUnit); } #endregion @@ -1416,25 +1413,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static Volume operator *(QuantityValue left, Volume right) + public static Volume operator *(double left, Volume right) { return new Volume(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static Volume operator *(Volume left, QuantityValue right) + public static Volume operator *(Volume left, double right) { return new Volume(left.Value * right, left.Unit); } /// Get from dividing by value. - public static Volume operator /(Volume left, QuantityValue right) + public static Volume operator /(Volume left, double right) { return new Volume(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(Volume left, Volume right) + public static double operator /(Volume left, Volume right) { return left.CubicMeters / right.CubicMeters; } @@ -1467,19 +1464,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(Volume left, Volume right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(Volume left, Volume right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1492,29 +1476,7 @@ public int CompareTo(object obj) /// public int CompareTo(Volume other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is Volume objVolume)) - return false; - return Equals(objVolume); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(Volume other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1557,13 +1519,13 @@ public bool Equals(Volume other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Volume other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(Volume other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1574,7 +1536,7 @@ public bool Equals(Volume other, QuantityValue tolerance, ComparisonType compari /// A hash code for the current Volume. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1585,16 +1547,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VolumeUnit unit) + public double As(VolumeUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1609,12 +1572,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VolumeUnit typedUnit)) + if (!(unit is VolumeUnit unitAsVolumeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVolumeUnit); } /// @@ -1646,7 +1609,7 @@ public Volume ToUnit(VolumeUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (Volume)converted; } - else if (Enum.IsDefined(typeof(VolumeUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1654,17 +1617,17 @@ public Volume ToUnit(VolumeUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeUnit typedUnit)) + if (!(unit is VolumeUnit unitAsVolumeUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVolumeUnit, DefaultConversionFunctions); } /// @@ -1691,10 +1654,10 @@ public Volume ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VolumeUnit unit) + private double GetValueAs(VolumeUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 4f81ca2c36..26d1de1beb 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Concentration#Volume_concentration /// [DataContract] - public partial struct VolumeConcentration : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeConcentration : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -94,9 +94,9 @@ static VolumeConcentration() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeConcentration(QuantityValue value, VolumeConcentrationUnit unit) + public VolumeConcentration(double value, VolumeConcentrationUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -108,14 +108,14 @@ public VolumeConcentration(QuantityValue value, VolumeConcentrationUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeConcentration(QuantityValue value, UnitSystem unitSystem) + public VolumeConcentration(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -156,10 +156,7 @@ public VolumeConcentration(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -182,104 +179,104 @@ public VolumeConcentration(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); + public double CentilitersPerLiter => As(VolumeConcentrationUnit.CentilitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); + public double CentilitersPerMililiter => As(VolumeConcentrationUnit.CentilitersPerMililiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); + public double DecilitersPerLiter => As(VolumeConcentrationUnit.DecilitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); + public double DecilitersPerMililiter => As(VolumeConcentrationUnit.DecilitersPerMililiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); + public double DecimalFractions => As(VolumeConcentrationUnit.DecimalFraction); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); + public double LitersPerLiter => As(VolumeConcentrationUnit.LitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); + public double LitersPerMililiter => As(VolumeConcentrationUnit.LitersPerMililiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); + public double MicrolitersPerLiter => As(VolumeConcentrationUnit.MicrolitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); + public double MicrolitersPerMililiter => As(VolumeConcentrationUnit.MicrolitersPerMililiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); + public double MillilitersPerLiter => As(VolumeConcentrationUnit.MillilitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); + public double MillilitersPerMililiter => As(VolumeConcentrationUnit.MillilitersPerMililiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); + public double NanolitersPerLiter => As(VolumeConcentrationUnit.NanolitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); + public double NanolitersPerMililiter => As(VolumeConcentrationUnit.NanolitersPerMililiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); + public double PartsPerBillion => As(VolumeConcentrationUnit.PartPerBillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); + public double PartsPerMillion => As(VolumeConcentrationUnit.PartPerMillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); + public double PartsPerThousand => As(VolumeConcentrationUnit.PartPerThousand); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); + public double PartsPerTrillion => As(VolumeConcentrationUnit.PartPerTrillion); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue Percent => As(VolumeConcentrationUnit.Percent); + public double Percent => As(VolumeConcentrationUnit.Percent); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); + public double PicolitersPerLiter => As(VolumeConcentrationUnit.PicolitersPerLiter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); + public double PicolitersPerMililiter => As(VolumeConcentrationUnit.PicolitersPerMililiter); #endregion @@ -392,7 +389,7 @@ public static string GetAbbreviation(VolumeConcentrationUnit unit, IFormatProvid /// If value is NaN or Infinity. public static VolumeConcentration FromCentilitersPerLiter(QuantityValue centilitersperliter) { - QuantityValue value = (QuantityValue) centilitersperliter; + double value = (double) centilitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerLiter); } @@ -402,7 +399,7 @@ public static VolumeConcentration FromCentilitersPerLiter(QuantityValue centilit /// If value is NaN or Infinity. public static VolumeConcentration FromCentilitersPerMililiter(QuantityValue centiliterspermililiter) { - QuantityValue value = (QuantityValue) centiliterspermililiter; + double value = (double) centiliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.CentilitersPerMililiter); } @@ -412,7 +409,7 @@ public static VolumeConcentration FromCentilitersPerMililiter(QuantityValue cent /// If value is NaN or Infinity. public static VolumeConcentration FromDecilitersPerLiter(QuantityValue decilitersperliter) { - QuantityValue value = (QuantityValue) decilitersperliter; + double value = (double) decilitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerLiter); } @@ -422,7 +419,7 @@ public static VolumeConcentration FromDecilitersPerLiter(QuantityValue deciliter /// If value is NaN or Infinity. public static VolumeConcentration FromDecilitersPerMililiter(QuantityValue deciliterspermililiter) { - QuantityValue value = (QuantityValue) deciliterspermililiter; + double value = (double) deciliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.DecilitersPerMililiter); } @@ -432,7 +429,7 @@ public static VolumeConcentration FromDecilitersPerMililiter(QuantityValue decil /// If value is NaN or Infinity. public static VolumeConcentration FromDecimalFractions(QuantityValue decimalfractions) { - QuantityValue value = (QuantityValue) decimalfractions; + double value = (double) decimalfractions; return new VolumeConcentration(value, VolumeConcentrationUnit.DecimalFraction); } @@ -442,7 +439,7 @@ public static VolumeConcentration FromDecimalFractions(QuantityValue decimalfrac /// If value is NaN or Infinity. public static VolumeConcentration FromLitersPerLiter(QuantityValue litersperliter) { - QuantityValue value = (QuantityValue) litersperliter; + double value = (double) litersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerLiter); } @@ -452,7 +449,7 @@ public static VolumeConcentration FromLitersPerLiter(QuantityValue litersperlite /// If value is NaN or Infinity. public static VolumeConcentration FromLitersPerMililiter(QuantityValue literspermililiter) { - QuantityValue value = (QuantityValue) literspermililiter; + double value = (double) literspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.LitersPerMililiter); } @@ -462,7 +459,7 @@ public static VolumeConcentration FromLitersPerMililiter(QuantityValue litersper /// If value is NaN or Infinity. public static VolumeConcentration FromMicrolitersPerLiter(QuantityValue microlitersperliter) { - QuantityValue value = (QuantityValue) microlitersperliter; + double value = (double) microlitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerLiter); } @@ -472,7 +469,7 @@ public static VolumeConcentration FromMicrolitersPerLiter(QuantityValue microlit /// If value is NaN or Infinity. public static VolumeConcentration FromMicrolitersPerMililiter(QuantityValue microliterspermililiter) { - QuantityValue value = (QuantityValue) microliterspermililiter; + double value = (double) microliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.MicrolitersPerMililiter); } @@ -482,7 +479,7 @@ public static VolumeConcentration FromMicrolitersPerMililiter(QuantityValue micr /// If value is NaN or Infinity. public static VolumeConcentration FromMillilitersPerLiter(QuantityValue millilitersperliter) { - QuantityValue value = (QuantityValue) millilitersperliter; + double value = (double) millilitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerLiter); } @@ -492,7 +489,7 @@ public static VolumeConcentration FromMillilitersPerLiter(QuantityValue millilit /// If value is NaN or Infinity. public static VolumeConcentration FromMillilitersPerMililiter(QuantityValue milliliterspermililiter) { - QuantityValue value = (QuantityValue) milliliterspermililiter; + double value = (double) milliliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.MillilitersPerMililiter); } @@ -502,7 +499,7 @@ public static VolumeConcentration FromMillilitersPerMililiter(QuantityValue mill /// If value is NaN or Infinity. public static VolumeConcentration FromNanolitersPerLiter(QuantityValue nanolitersperliter) { - QuantityValue value = (QuantityValue) nanolitersperliter; + double value = (double) nanolitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerLiter); } @@ -512,7 +509,7 @@ public static VolumeConcentration FromNanolitersPerLiter(QuantityValue nanoliter /// If value is NaN or Infinity. public static VolumeConcentration FromNanolitersPerMililiter(QuantityValue nanoliterspermililiter) { - QuantityValue value = (QuantityValue) nanoliterspermililiter; + double value = (double) nanoliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.NanolitersPerMililiter); } @@ -522,7 +519,7 @@ public static VolumeConcentration FromNanolitersPerMililiter(QuantityValue nanol /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerBillion(QuantityValue partsperbillion) { - QuantityValue value = (QuantityValue) partsperbillion; + double value = (double) partsperbillion; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerBillion); } @@ -532,7 +529,7 @@ public static VolumeConcentration FromPartsPerBillion(QuantityValue partsperbill /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerMillion(QuantityValue partspermillion) { - QuantityValue value = (QuantityValue) partspermillion; + double value = (double) partspermillion; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerMillion); } @@ -542,7 +539,7 @@ public static VolumeConcentration FromPartsPerMillion(QuantityValue partspermill /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerThousand(QuantityValue partsperthousand) { - QuantityValue value = (QuantityValue) partsperthousand; + double value = (double) partsperthousand; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerThousand); } @@ -552,7 +549,7 @@ public static VolumeConcentration FromPartsPerThousand(QuantityValue partspertho /// If value is NaN or Infinity. public static VolumeConcentration FromPartsPerTrillion(QuantityValue partspertrillion) { - QuantityValue value = (QuantityValue) partspertrillion; + double value = (double) partspertrillion; return new VolumeConcentration(value, VolumeConcentrationUnit.PartPerTrillion); } @@ -562,7 +559,7 @@ public static VolumeConcentration FromPartsPerTrillion(QuantityValue partspertri /// If value is NaN or Infinity. public static VolumeConcentration FromPercent(QuantityValue percent) { - QuantityValue value = (QuantityValue) percent; + double value = (double) percent; return new VolumeConcentration(value, VolumeConcentrationUnit.Percent); } @@ -572,7 +569,7 @@ public static VolumeConcentration FromPercent(QuantityValue percent) /// If value is NaN or Infinity. public static VolumeConcentration FromPicolitersPerLiter(QuantityValue picolitersperliter) { - QuantityValue value = (QuantityValue) picolitersperliter; + double value = (double) picolitersperliter; return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerLiter); } @@ -582,7 +579,7 @@ public static VolumeConcentration FromPicolitersPerLiter(QuantityValue picoliter /// If value is NaN or Infinity. public static VolumeConcentration FromPicolitersPerMililiter(QuantityValue picoliterspermililiter) { - QuantityValue value = (QuantityValue) picoliterspermililiter; + double value = (double) picoliterspermililiter; return new VolumeConcentration(value, VolumeConcentrationUnit.PicolitersPerMililiter); } @@ -594,7 +591,7 @@ public static VolumeConcentration FromPicolitersPerMililiter(QuantityValue picol /// VolumeConcentration unit value. public static VolumeConcentration From(QuantityValue value, VolumeConcentrationUnit fromUnit) { - return new VolumeConcentration((QuantityValue)value, fromUnit); + return new VolumeConcentration((double)value, fromUnit); } #endregion @@ -764,25 +761,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeConcentration operator *(QuantityValue left, VolumeConcentration right) + public static VolumeConcentration operator *(double left, VolumeConcentration right) { return new VolumeConcentration(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeConcentration operator *(VolumeConcentration left, QuantityValue right) + public static VolumeConcentration operator *(VolumeConcentration left, double right) { return new VolumeConcentration(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeConcentration operator /(VolumeConcentration left, QuantityValue right) + public static VolumeConcentration operator /(VolumeConcentration left, double right) { return new VolumeConcentration(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(VolumeConcentration left, VolumeConcentration right) + public static double operator /(VolumeConcentration left, VolumeConcentration right) { return left.DecimalFractions / right.DecimalFractions; } @@ -815,19 +812,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeConcentration left, VolumeConcentration right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeConcentration left, VolumeConcentration right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -840,29 +824,7 @@ public int CompareTo(object obj) /// public int CompareTo(VolumeConcentration other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is VolumeConcentration objVolumeConcentration)) - return false; - return Equals(objVolumeConcentration); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeConcentration other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -905,13 +867,13 @@ public bool Equals(VolumeConcentration other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeConcentration other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(VolumeConcentration other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -922,7 +884,7 @@ public bool Equals(VolumeConcentration other, QuantityValue tolerance, Compariso /// A hash code for the current VolumeConcentration. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -933,16 +895,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VolumeConcentrationUnit unit) + public double As(VolumeConcentrationUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -957,12 +920,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VolumeConcentrationUnit typedUnit)) + if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVolumeConcentrationUnit); } /// @@ -994,7 +957,7 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit, UnitConverter un var converted = conversionFunction(this); return (VolumeConcentration)converted; } - else if (Enum.IsDefined(typeof(VolumeConcentrationUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1002,17 +965,17 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit, UnitConverter un } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeConcentrationUnit typedUnit)) + if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVolumeConcentrationUnit, DefaultConversionFunctions); } /// @@ -1039,10 +1002,10 @@ public VolumeConcentration ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VolumeConcentrationUnit unit) + private double GetValueAs(VolumeConcentrationUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index db17809849..14cecc5941 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// In physics and engineering, in particular fluid dynamics and hydrometry, the volumetric flow rate, (also known as volume flow rate, rate of fluid flow or volume velocity) is the volume of fluid which passes through a given surface per unit time. The SI unit is m³/s (cubic meters per second). In US Customary Units and British Imperial Units, volumetric flow rate is often expressed as ft³/s (cubic feet per second). It is usually represented by the symbol Q. /// [DataContract] - public partial struct VolumeFlow : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlow : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -133,9 +133,9 @@ static VolumeFlow() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeFlow(QuantityValue value, VolumeFlowUnit unit) + public VolumeFlow(double value, VolumeFlowUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -147,14 +147,14 @@ public VolumeFlow(QuantityValue value, VolumeFlowUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlow(QuantityValue value, UnitSystem unitSystem) + public VolumeFlow(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -195,10 +195,7 @@ public VolumeFlow(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -221,314 +218,314 @@ public VolumeFlow(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); + public double AcreFeetPerDay => As(VolumeFlowUnit.AcreFootPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); + public double AcreFeetPerHour => As(VolumeFlowUnit.AcreFootPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); + public double AcreFeetPerMinute => As(VolumeFlowUnit.AcreFootPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); + public double AcreFeetPerSecond => As(VolumeFlowUnit.AcreFootPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); + public double CentilitersPerDay => As(VolumeFlowUnit.CentiliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentilitersPerHour => As(VolumeFlowUnit.CentiliterPerHour); + public double CentilitersPerHour => As(VolumeFlowUnit.CentiliterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); + public double CentilitersPerMinute => As(VolumeFlowUnit.CentiliterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); + public double CentilitersPerSecond => As(VolumeFlowUnit.CentiliterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); + public double CubicCentimetersPerMinute => As(VolumeFlowUnit.CubicCentimeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); + public double CubicDecimetersPerMinute => As(VolumeFlowUnit.CubicDecimeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); + public double CubicFeetPerHour => As(VolumeFlowUnit.CubicFootPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); + public double CubicFeetPerMinute => As(VolumeFlowUnit.CubicFootPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); + public double CubicFeetPerSecond => As(VolumeFlowUnit.CubicFootPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); + public double CubicMetersPerDay => As(VolumeFlowUnit.CubicMeterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); + public double CubicMetersPerHour => As(VolumeFlowUnit.CubicMeterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); + public double CubicMetersPerMinute => As(VolumeFlowUnit.CubicMeterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); + public double CubicMetersPerSecond => As(VolumeFlowUnit.CubicMeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); + public double CubicMillimetersPerSecond => As(VolumeFlowUnit.CubicMillimeterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); + public double CubicYardsPerDay => As(VolumeFlowUnit.CubicYardPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); + public double CubicYardsPerHour => As(VolumeFlowUnit.CubicYardPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); + public double CubicYardsPerMinute => As(VolumeFlowUnit.CubicYardPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); + public double CubicYardsPerSecond => As(VolumeFlowUnit.CubicYardPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); + public double DecilitersPerDay => As(VolumeFlowUnit.DeciliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecilitersPerHour => As(VolumeFlowUnit.DeciliterPerHour); + public double DecilitersPerHour => As(VolumeFlowUnit.DeciliterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); + public double DecilitersPerMinute => As(VolumeFlowUnit.DeciliterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); + public double DecilitersPerSecond => As(VolumeFlowUnit.DeciliterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); + public double KilolitersPerDay => As(VolumeFlowUnit.KiloliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilolitersPerHour => As(VolumeFlowUnit.KiloliterPerHour); + public double KilolitersPerHour => As(VolumeFlowUnit.KiloliterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); + public double KilolitersPerMinute => As(VolumeFlowUnit.KiloliterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); + public double KilolitersPerSecond => As(VolumeFlowUnit.KiloliterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); + public double KilousGallonsPerMinute => As(VolumeFlowUnit.KilousGallonPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerDay => As(VolumeFlowUnit.LiterPerDay); + public double LitersPerDay => As(VolumeFlowUnit.LiterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerHour => As(VolumeFlowUnit.LiterPerHour); + public double LitersPerHour => As(VolumeFlowUnit.LiterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); + public double LitersPerMinute => As(VolumeFlowUnit.LiterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); + public double LitersPerSecond => As(VolumeFlowUnit.LiterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); + public double MegalitersPerDay => As(VolumeFlowUnit.MegaliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); + public double MegaukGallonsPerSecond => As(VolumeFlowUnit.MegaukGallonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); + public double MicrolitersPerDay => As(VolumeFlowUnit.MicroliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrolitersPerHour => As(VolumeFlowUnit.MicroliterPerHour); + public double MicrolitersPerHour => As(VolumeFlowUnit.MicroliterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); + public double MicrolitersPerMinute => As(VolumeFlowUnit.MicroliterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); + public double MicrolitersPerSecond => As(VolumeFlowUnit.MicroliterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); + public double MillilitersPerDay => As(VolumeFlowUnit.MilliliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillilitersPerHour => As(VolumeFlowUnit.MilliliterPerHour); + public double MillilitersPerHour => As(VolumeFlowUnit.MilliliterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); + public double MillilitersPerMinute => As(VolumeFlowUnit.MilliliterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); + public double MillilitersPerSecond => As(VolumeFlowUnit.MilliliterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); + public double MillionUsGallonsPerDay => As(VolumeFlowUnit.MillionUsGallonPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); + public double NanolitersPerDay => As(VolumeFlowUnit.NanoliterPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanolitersPerHour => As(VolumeFlowUnit.NanoliterPerHour); + public double NanolitersPerHour => As(VolumeFlowUnit.NanoliterPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); + public double NanolitersPerMinute => As(VolumeFlowUnit.NanoliterPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); + public double NanolitersPerSecond => As(VolumeFlowUnit.NanoliterPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); + public double OilBarrelsPerDay => As(VolumeFlowUnit.OilBarrelPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); + public double OilBarrelsPerHour => As(VolumeFlowUnit.OilBarrelPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); + public double OilBarrelsPerMinute => As(VolumeFlowUnit.OilBarrelPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); + public double OilBarrelsPerSecond => As(VolumeFlowUnit.OilBarrelPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); + public double UkGallonsPerDay => As(VolumeFlowUnit.UkGallonPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); + public double UkGallonsPerHour => As(VolumeFlowUnit.UkGallonPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); + public double UkGallonsPerMinute => As(VolumeFlowUnit.UkGallonPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); + public double UkGallonsPerSecond => As(VolumeFlowUnit.UkGallonPerSecond); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); + public double UsGallonsPerDay => As(VolumeFlowUnit.UsGallonPerDay); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); + public double UsGallonsPerHour => As(VolumeFlowUnit.UsGallonPerHour); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); + public double UsGallonsPerMinute => As(VolumeFlowUnit.UsGallonPerMinute); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); + public double UsGallonsPerSecond => As(VolumeFlowUnit.UsGallonPerSecond); #endregion @@ -794,7 +791,7 @@ public static string GetAbbreviation(VolumeFlowUnit unit, IFormatProvider? provi /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerDay(QuantityValue acrefeetperday) { - QuantityValue value = (QuantityValue) acrefeetperday; + double value = (double) acrefeetperday; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerDay); } @@ -804,7 +801,7 @@ public static VolumeFlow FromAcreFeetPerDay(QuantityValue acrefeetperday) /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerHour(QuantityValue acrefeetperhour) { - QuantityValue value = (QuantityValue) acrefeetperhour; + double value = (double) acrefeetperhour; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerHour); } @@ -814,7 +811,7 @@ public static VolumeFlow FromAcreFeetPerHour(QuantityValue acrefeetperhour) /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerMinute(QuantityValue acrefeetperminute) { - QuantityValue value = (QuantityValue) acrefeetperminute; + double value = (double) acrefeetperminute; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerMinute); } @@ -824,7 +821,7 @@ public static VolumeFlow FromAcreFeetPerMinute(QuantityValue acrefeetperminute) /// If value is NaN or Infinity. public static VolumeFlow FromAcreFeetPerSecond(QuantityValue acrefeetpersecond) { - QuantityValue value = (QuantityValue) acrefeetpersecond; + double value = (double) acrefeetpersecond; return new VolumeFlow(value, VolumeFlowUnit.AcreFootPerSecond); } @@ -834,7 +831,7 @@ public static VolumeFlow FromAcreFeetPerSecond(QuantityValue acrefeetpersecond) /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerDay(QuantityValue centilitersperday) { - QuantityValue value = (QuantityValue) centilitersperday; + double value = (double) centilitersperday; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerDay); } @@ -844,7 +841,7 @@ public static VolumeFlow FromCentilitersPerDay(QuantityValue centilitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerHour(QuantityValue centilitersperhour) { - QuantityValue value = (QuantityValue) centilitersperhour; + double value = (double) centilitersperhour; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerHour); } @@ -854,7 +851,7 @@ public static VolumeFlow FromCentilitersPerHour(QuantityValue centilitersperhour /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerMinute(QuantityValue centilitersperminute) { - QuantityValue value = (QuantityValue) centilitersperminute; + double value = (double) centilitersperminute; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerMinute); } @@ -864,7 +861,7 @@ public static VolumeFlow FromCentilitersPerMinute(QuantityValue centiliterspermi /// If value is NaN or Infinity. public static VolumeFlow FromCentilitersPerSecond(QuantityValue centiliterspersecond) { - QuantityValue value = (QuantityValue) centiliterspersecond; + double value = (double) centiliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.CentiliterPerSecond); } @@ -874,7 +871,7 @@ public static VolumeFlow FromCentilitersPerSecond(QuantityValue centilitersperse /// If value is NaN or Infinity. public static VolumeFlow FromCubicCentimetersPerMinute(QuantityValue cubiccentimetersperminute) { - QuantityValue value = (QuantityValue) cubiccentimetersperminute; + double value = (double) cubiccentimetersperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicCentimeterPerMinute); } @@ -884,7 +881,7 @@ public static VolumeFlow FromCubicCentimetersPerMinute(QuantityValue cubiccentim /// If value is NaN or Infinity. public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue cubicdecimetersperminute) { - QuantityValue value = (QuantityValue) cubicdecimetersperminute; + double value = (double) cubicdecimetersperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicDecimeterPerMinute); } @@ -894,7 +891,7 @@ public static VolumeFlow FromCubicDecimetersPerMinute(QuantityValue cubicdecimet /// If value is NaN or Infinity. public static VolumeFlow FromCubicFeetPerHour(QuantityValue cubicfeetperhour) { - QuantityValue value = (QuantityValue) cubicfeetperhour; + double value = (double) cubicfeetperhour; return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerHour); } @@ -904,7 +901,7 @@ public static VolumeFlow FromCubicFeetPerHour(QuantityValue cubicfeetperhour) /// If value is NaN or Infinity. public static VolumeFlow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute) { - QuantityValue value = (QuantityValue) cubicfeetperminute; + double value = (double) cubicfeetperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerMinute); } @@ -914,7 +911,7 @@ public static VolumeFlow FromCubicFeetPerMinute(QuantityValue cubicfeetperminute /// If value is NaN or Infinity. public static VolumeFlow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond) { - QuantityValue value = (QuantityValue) cubicfeetpersecond; + double value = (double) cubicfeetpersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicFootPerSecond); } @@ -924,7 +921,7 @@ public static VolumeFlow FromCubicFeetPerSecond(QuantityValue cubicfeetpersecond /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerDay(QuantityValue cubicmetersperday) { - QuantityValue value = (QuantityValue) cubicmetersperday; + double value = (double) cubicmetersperday; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerDay); } @@ -934,7 +931,7 @@ public static VolumeFlow FromCubicMetersPerDay(QuantityValue cubicmetersperday) /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerHour(QuantityValue cubicmetersperhour) { - QuantityValue value = (QuantityValue) cubicmetersperhour; + double value = (double) cubicmetersperhour; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerHour); } @@ -944,7 +941,7 @@ public static VolumeFlow FromCubicMetersPerHour(QuantityValue cubicmetersperhour /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerMinute(QuantityValue cubicmetersperminute) { - QuantityValue value = (QuantityValue) cubicmetersperminute; + double value = (double) cubicmetersperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerMinute); } @@ -954,7 +951,7 @@ public static VolumeFlow FromCubicMetersPerMinute(QuantityValue cubicmeterspermi /// If value is NaN or Infinity. public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmeterspersecond) { - QuantityValue value = (QuantityValue) cubicmeterspersecond; + double value = (double) cubicmeterspersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicMeterPerSecond); } @@ -964,7 +961,7 @@ public static VolumeFlow FromCubicMetersPerSecond(QuantityValue cubicmetersperse /// If value is NaN or Infinity. public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillimeterspersecond) { - QuantityValue value = (QuantityValue) cubicmillimeterspersecond; + double value = (double) cubicmillimeterspersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicMillimeterPerSecond); } @@ -974,7 +971,7 @@ public static VolumeFlow FromCubicMillimetersPerSecond(QuantityValue cubicmillim /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerDay(QuantityValue cubicyardsperday) { - QuantityValue value = (QuantityValue) cubicyardsperday; + double value = (double) cubicyardsperday; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerDay); } @@ -984,7 +981,7 @@ public static VolumeFlow FromCubicYardsPerDay(QuantityValue cubicyardsperday) /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerHour(QuantityValue cubicyardsperhour) { - QuantityValue value = (QuantityValue) cubicyardsperhour; + double value = (double) cubicyardsperhour; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerHour); } @@ -994,7 +991,7 @@ public static VolumeFlow FromCubicYardsPerHour(QuantityValue cubicyardsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerMinute(QuantityValue cubicyardsperminute) { - QuantityValue value = (QuantityValue) cubicyardsperminute; + double value = (double) cubicyardsperminute; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerMinute); } @@ -1004,7 +1001,7 @@ public static VolumeFlow FromCubicYardsPerMinute(QuantityValue cubicyardsperminu /// If value is NaN or Infinity. public static VolumeFlow FromCubicYardsPerSecond(QuantityValue cubicyardspersecond) { - QuantityValue value = (QuantityValue) cubicyardspersecond; + double value = (double) cubicyardspersecond; return new VolumeFlow(value, VolumeFlowUnit.CubicYardPerSecond); } @@ -1014,7 +1011,7 @@ public static VolumeFlow FromCubicYardsPerSecond(QuantityValue cubicyardsperseco /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerDay(QuantityValue decilitersperday) { - QuantityValue value = (QuantityValue) decilitersperday; + double value = (double) decilitersperday; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerDay); } @@ -1024,7 +1021,7 @@ public static VolumeFlow FromDecilitersPerDay(QuantityValue decilitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerHour(QuantityValue decilitersperhour) { - QuantityValue value = (QuantityValue) decilitersperhour; + double value = (double) decilitersperhour; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerHour); } @@ -1034,7 +1031,7 @@ public static VolumeFlow FromDecilitersPerHour(QuantityValue decilitersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerMinute(QuantityValue decilitersperminute) { - QuantityValue value = (QuantityValue) decilitersperminute; + double value = (double) decilitersperminute; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerMinute); } @@ -1044,7 +1041,7 @@ public static VolumeFlow FromDecilitersPerMinute(QuantityValue decilitersperminu /// If value is NaN or Infinity. public static VolumeFlow FromDecilitersPerSecond(QuantityValue deciliterspersecond) { - QuantityValue value = (QuantityValue) deciliterspersecond; + double value = (double) deciliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.DeciliterPerSecond); } @@ -1054,7 +1051,7 @@ public static VolumeFlow FromDecilitersPerSecond(QuantityValue decilitersperseco /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerDay(QuantityValue kilolitersperday) { - QuantityValue value = (QuantityValue) kilolitersperday; + double value = (double) kilolitersperday; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerDay); } @@ -1064,7 +1061,7 @@ public static VolumeFlow FromKilolitersPerDay(QuantityValue kilolitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerHour(QuantityValue kilolitersperhour) { - QuantityValue value = (QuantityValue) kilolitersperhour; + double value = (double) kilolitersperhour; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerHour); } @@ -1074,7 +1071,7 @@ public static VolumeFlow FromKilolitersPerHour(QuantityValue kilolitersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerMinute(QuantityValue kilolitersperminute) { - QuantityValue value = (QuantityValue) kilolitersperminute; + double value = (double) kilolitersperminute; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerMinute); } @@ -1084,7 +1081,7 @@ public static VolumeFlow FromKilolitersPerMinute(QuantityValue kilolitersperminu /// If value is NaN or Infinity. public static VolumeFlow FromKilolitersPerSecond(QuantityValue kiloliterspersecond) { - QuantityValue value = (QuantityValue) kiloliterspersecond; + double value = (double) kiloliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.KiloliterPerSecond); } @@ -1094,7 +1091,7 @@ public static VolumeFlow FromKilolitersPerSecond(QuantityValue kilolitersperseco /// If value is NaN or Infinity. public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue kilousgallonsperminute) { - QuantityValue value = (QuantityValue) kilousgallonsperminute; + double value = (double) kilousgallonsperminute; return new VolumeFlow(value, VolumeFlowUnit.KilousGallonPerMinute); } @@ -1104,7 +1101,7 @@ public static VolumeFlow FromKilousGallonsPerMinute(QuantityValue kilousgallonsp /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerDay(QuantityValue litersperday) { - QuantityValue value = (QuantityValue) litersperday; + double value = (double) litersperday; return new VolumeFlow(value, VolumeFlowUnit.LiterPerDay); } @@ -1114,7 +1111,7 @@ public static VolumeFlow FromLitersPerDay(QuantityValue litersperday) /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerHour(QuantityValue litersperhour) { - QuantityValue value = (QuantityValue) litersperhour; + double value = (double) litersperhour; return new VolumeFlow(value, VolumeFlowUnit.LiterPerHour); } @@ -1124,7 +1121,7 @@ public static VolumeFlow FromLitersPerHour(QuantityValue litersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerMinute(QuantityValue litersperminute) { - QuantityValue value = (QuantityValue) litersperminute; + double value = (double) litersperminute; return new VolumeFlow(value, VolumeFlowUnit.LiterPerMinute); } @@ -1134,7 +1131,7 @@ public static VolumeFlow FromLitersPerMinute(QuantityValue litersperminute) /// If value is NaN or Infinity. public static VolumeFlow FromLitersPerSecond(QuantityValue literspersecond) { - QuantityValue value = (QuantityValue) literspersecond; + double value = (double) literspersecond; return new VolumeFlow(value, VolumeFlowUnit.LiterPerSecond); } @@ -1144,7 +1141,7 @@ public static VolumeFlow FromLitersPerSecond(QuantityValue literspersecond) /// If value is NaN or Infinity. public static VolumeFlow FromMegalitersPerDay(QuantityValue megalitersperday) { - QuantityValue value = (QuantityValue) megalitersperday; + double value = (double) megalitersperday; return new VolumeFlow(value, VolumeFlowUnit.MegaliterPerDay); } @@ -1154,7 +1151,7 @@ public static VolumeFlow FromMegalitersPerDay(QuantityValue megalitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromMegaukGallonsPerSecond(QuantityValue megaukgallonspersecond) { - QuantityValue value = (QuantityValue) megaukgallonspersecond; + double value = (double) megaukgallonspersecond; return new VolumeFlow(value, VolumeFlowUnit.MegaukGallonPerSecond); } @@ -1164,7 +1161,7 @@ public static VolumeFlow FromMegaukGallonsPerSecond(QuantityValue megaukgallonsp /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerDay(QuantityValue microlitersperday) { - QuantityValue value = (QuantityValue) microlitersperday; + double value = (double) microlitersperday; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerDay); } @@ -1174,7 +1171,7 @@ public static VolumeFlow FromMicrolitersPerDay(QuantityValue microlitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerHour(QuantityValue microlitersperhour) { - QuantityValue value = (QuantityValue) microlitersperhour; + double value = (double) microlitersperhour; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerHour); } @@ -1184,7 +1181,7 @@ public static VolumeFlow FromMicrolitersPerHour(QuantityValue microlitersperhour /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerMinute(QuantityValue microlitersperminute) { - QuantityValue value = (QuantityValue) microlitersperminute; + double value = (double) microlitersperminute; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerMinute); } @@ -1194,7 +1191,7 @@ public static VolumeFlow FromMicrolitersPerMinute(QuantityValue microliterspermi /// If value is NaN or Infinity. public static VolumeFlow FromMicrolitersPerSecond(QuantityValue microliterspersecond) { - QuantityValue value = (QuantityValue) microliterspersecond; + double value = (double) microliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.MicroliterPerSecond); } @@ -1204,7 +1201,7 @@ public static VolumeFlow FromMicrolitersPerSecond(QuantityValue microlitersperse /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerDay(QuantityValue millilitersperday) { - QuantityValue value = (QuantityValue) millilitersperday; + double value = (double) millilitersperday; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerDay); } @@ -1214,7 +1211,7 @@ public static VolumeFlow FromMillilitersPerDay(QuantityValue millilitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerHour(QuantityValue millilitersperhour) { - QuantityValue value = (QuantityValue) millilitersperhour; + double value = (double) millilitersperhour; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerHour); } @@ -1224,7 +1221,7 @@ public static VolumeFlow FromMillilitersPerHour(QuantityValue millilitersperhour /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerMinute(QuantityValue millilitersperminute) { - QuantityValue value = (QuantityValue) millilitersperminute; + double value = (double) millilitersperminute; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerMinute); } @@ -1234,7 +1231,7 @@ public static VolumeFlow FromMillilitersPerMinute(QuantityValue milliliterspermi /// If value is NaN or Infinity. public static VolumeFlow FromMillilitersPerSecond(QuantityValue milliliterspersecond) { - QuantityValue value = (QuantityValue) milliliterspersecond; + double value = (double) milliliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.MilliliterPerSecond); } @@ -1244,7 +1241,7 @@ public static VolumeFlow FromMillilitersPerSecond(QuantityValue millilitersperse /// If value is NaN or Infinity. public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallonsperday) { - QuantityValue value = (QuantityValue) millionusgallonsperday; + double value = (double) millionusgallonsperday; return new VolumeFlow(value, VolumeFlowUnit.MillionUsGallonPerDay); } @@ -1254,7 +1251,7 @@ public static VolumeFlow FromMillionUsGallonsPerDay(QuantityValue millionusgallo /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerDay(QuantityValue nanolitersperday) { - QuantityValue value = (QuantityValue) nanolitersperday; + double value = (double) nanolitersperday; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerDay); } @@ -1264,7 +1261,7 @@ public static VolumeFlow FromNanolitersPerDay(QuantityValue nanolitersperday) /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerHour(QuantityValue nanolitersperhour) { - QuantityValue value = (QuantityValue) nanolitersperhour; + double value = (double) nanolitersperhour; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerHour); } @@ -1274,7 +1271,7 @@ public static VolumeFlow FromNanolitersPerHour(QuantityValue nanolitersperhour) /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerMinute(QuantityValue nanolitersperminute) { - QuantityValue value = (QuantityValue) nanolitersperminute; + double value = (double) nanolitersperminute; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerMinute); } @@ -1284,7 +1281,7 @@ public static VolumeFlow FromNanolitersPerMinute(QuantityValue nanolitersperminu /// If value is NaN or Infinity. public static VolumeFlow FromNanolitersPerSecond(QuantityValue nanoliterspersecond) { - QuantityValue value = (QuantityValue) nanoliterspersecond; + double value = (double) nanoliterspersecond; return new VolumeFlow(value, VolumeFlowUnit.NanoliterPerSecond); } @@ -1294,7 +1291,7 @@ public static VolumeFlow FromNanolitersPerSecond(QuantityValue nanolitersperseco /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday) { - QuantityValue value = (QuantityValue) oilbarrelsperday; + double value = (double) oilbarrelsperday; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerDay); } @@ -1304,7 +1301,7 @@ public static VolumeFlow FromOilBarrelsPerDay(QuantityValue oilbarrelsperday) /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerHour(QuantityValue oilbarrelsperhour) { - QuantityValue value = (QuantityValue) oilbarrelsperhour; + double value = (double) oilbarrelsperhour; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerHour); } @@ -1314,7 +1311,7 @@ public static VolumeFlow FromOilBarrelsPerHour(QuantityValue oilbarrelsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue oilbarrelsperminute) { - QuantityValue value = (QuantityValue) oilbarrelsperminute; + double value = (double) oilbarrelsperminute; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerMinute); } @@ -1324,7 +1321,7 @@ public static VolumeFlow FromOilBarrelsPerMinute(QuantityValue oilbarrelsperminu /// If value is NaN or Infinity. public static VolumeFlow FromOilBarrelsPerSecond(QuantityValue oilbarrelspersecond) { - QuantityValue value = (QuantityValue) oilbarrelspersecond; + double value = (double) oilbarrelspersecond; return new VolumeFlow(value, VolumeFlowUnit.OilBarrelPerSecond); } @@ -1334,7 +1331,7 @@ public static VolumeFlow FromOilBarrelsPerSecond(QuantityValue oilbarrelsperseco /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerDay(QuantityValue ukgallonsperday) { - QuantityValue value = (QuantityValue) ukgallonsperday; + double value = (double) ukgallonsperday; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerDay); } @@ -1344,7 +1341,7 @@ public static VolumeFlow FromUkGallonsPerDay(QuantityValue ukgallonsperday) /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerHour(QuantityValue ukgallonsperhour) { - QuantityValue value = (QuantityValue) ukgallonsperhour; + double value = (double) ukgallonsperhour; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerHour); } @@ -1354,7 +1351,7 @@ public static VolumeFlow FromUkGallonsPerHour(QuantityValue ukgallonsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerMinute(QuantityValue ukgallonsperminute) { - QuantityValue value = (QuantityValue) ukgallonsperminute; + double value = (double) ukgallonsperminute; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerMinute); } @@ -1364,7 +1361,7 @@ public static VolumeFlow FromUkGallonsPerMinute(QuantityValue ukgallonsperminute /// If value is NaN or Infinity. public static VolumeFlow FromUkGallonsPerSecond(QuantityValue ukgallonspersecond) { - QuantityValue value = (QuantityValue) ukgallonspersecond; + double value = (double) ukgallonspersecond; return new VolumeFlow(value, VolumeFlowUnit.UkGallonPerSecond); } @@ -1374,7 +1371,7 @@ public static VolumeFlow FromUkGallonsPerSecond(QuantityValue ukgallonspersecond /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerDay(QuantityValue usgallonsperday) { - QuantityValue value = (QuantityValue) usgallonsperday; + double value = (double) usgallonsperday; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerDay); } @@ -1384,7 +1381,7 @@ public static VolumeFlow FromUsGallonsPerDay(QuantityValue usgallonsperday) /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerHour(QuantityValue usgallonsperhour) { - QuantityValue value = (QuantityValue) usgallonsperhour; + double value = (double) usgallonsperhour; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerHour); } @@ -1394,7 +1391,7 @@ public static VolumeFlow FromUsGallonsPerHour(QuantityValue usgallonsperhour) /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerMinute(QuantityValue usgallonsperminute) { - QuantityValue value = (QuantityValue) usgallonsperminute; + double value = (double) usgallonsperminute; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerMinute); } @@ -1404,7 +1401,7 @@ public static VolumeFlow FromUsGallonsPerMinute(QuantityValue usgallonsperminute /// If value is NaN or Infinity. public static VolumeFlow FromUsGallonsPerSecond(QuantityValue usgallonspersecond) { - QuantityValue value = (QuantityValue) usgallonspersecond; + double value = (double) usgallonspersecond; return new VolumeFlow(value, VolumeFlowUnit.UsGallonPerSecond); } @@ -1416,7 +1413,7 @@ public static VolumeFlow FromUsGallonsPerSecond(QuantityValue usgallonspersecond /// VolumeFlow unit value. public static VolumeFlow From(QuantityValue value, VolumeFlowUnit fromUnit) { - return new VolumeFlow((QuantityValue)value, fromUnit); + return new VolumeFlow((double)value, fromUnit); } #endregion @@ -1586,25 +1583,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeFlow operator *(QuantityValue left, VolumeFlow right) + public static VolumeFlow operator *(double left, VolumeFlow right) { return new VolumeFlow(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeFlow operator *(VolumeFlow left, QuantityValue right) + public static VolumeFlow operator *(VolumeFlow left, double right) { return new VolumeFlow(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeFlow operator /(VolumeFlow left, QuantityValue right) + public static VolumeFlow operator /(VolumeFlow left, double right) { return new VolumeFlow(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(VolumeFlow left, VolumeFlow right) + public static double operator /(VolumeFlow left, VolumeFlow right) { return left.CubicMetersPerSecond / right.CubicMetersPerSecond; } @@ -1637,19 +1634,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeFlow left, VolumeFlow right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeFlow left, VolumeFlow right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -1662,29 +1646,7 @@ public int CompareTo(object obj) /// public int CompareTo(VolumeFlow other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is VolumeFlow objVolumeFlow)) - return false; - return Equals(objVolumeFlow); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeFlow other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -1727,13 +1689,13 @@ public bool Equals(VolumeFlow other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeFlow other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1744,7 +1706,7 @@ public bool Equals(VolumeFlow other, QuantityValue tolerance, ComparisonType com /// A hash code for the current VolumeFlow. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -1755,16 +1717,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VolumeFlowUnit unit) + public double As(VolumeFlowUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1779,12 +1742,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowUnit typedUnit)) + if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVolumeFlowUnit); } /// @@ -1816,7 +1779,7 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit, UnitConverter unitConverter) var converted = conversionFunction(this); return (VolumeFlow)converted; } - else if (Enum.IsDefined(typeof(VolumeFlowUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -1824,17 +1787,17 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit, UnitConverter unitConverter) } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowUnit typedUnit)) + if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVolumeFlowUnit, DefaultConversionFunctions); } /// @@ -1861,10 +1824,10 @@ public VolumeFlow ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VolumeFlowUnit unit) + private double GetValueAs(VolumeFlowUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 4f27c89490..93e98d1704 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// /// [DataContract] - public partial struct VolumeFlowPerArea : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumeFlowPerArea : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -73,9 +73,9 @@ static VolumeFlowPerArea() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumeFlowPerArea(QuantityValue value, VolumeFlowPerAreaUnit unit) + public VolumeFlowPerArea(double value, VolumeFlowPerAreaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -87,14 +87,14 @@ public VolumeFlowPerArea(QuantityValue value, VolumeFlowPerAreaUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumeFlowPerArea(QuantityValue value, UnitSystem unitSystem) + public VolumeFlowPerArea(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -135,10 +135,7 @@ public VolumeFlowPerArea(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -161,14 +158,14 @@ public VolumeFlowPerArea(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicFeetPerMinutePerSquareFoot => As(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); + public double CubicFeetPerMinutePerSquareFoot => As(VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerSecondPerSquareMeter => As(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); + public double CubicMetersPerSecondPerSquareMeter => As(VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); #endregion @@ -227,7 +224,7 @@ public static string GetAbbreviation(VolumeFlowPerAreaUnit unit, IFormatProvider /// If value is NaN or Infinity. public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(QuantityValue cubicfeetperminutepersquarefoot) { - QuantityValue value = (QuantityValue) cubicfeetperminutepersquarefoot; + double value = (double) cubicfeetperminutepersquarefoot; return new VolumeFlowPerArea(value, VolumeFlowPerAreaUnit.CubicFootPerMinutePerSquareFoot); } @@ -237,7 +234,7 @@ public static VolumeFlowPerArea FromCubicFeetPerMinutePerSquareFoot(QuantityValu /// If value is NaN or Infinity. public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(QuantityValue cubicmeterspersecondpersquaremeter) { - QuantityValue value = (QuantityValue) cubicmeterspersecondpersquaremeter; + double value = (double) cubicmeterspersecondpersquaremeter; return new VolumeFlowPerArea(value, VolumeFlowPerAreaUnit.CubicMeterPerSecondPerSquareMeter); } @@ -249,7 +246,7 @@ public static VolumeFlowPerArea FromCubicMetersPerSecondPerSquareMeter(QuantityV /// VolumeFlowPerArea unit value. public static VolumeFlowPerArea From(QuantityValue value, VolumeFlowPerAreaUnit fromUnit) { - return new VolumeFlowPerArea((QuantityValue)value, fromUnit); + return new VolumeFlowPerArea((double)value, fromUnit); } #endregion @@ -419,25 +416,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumeFlowPerArea operator *(QuantityValue left, VolumeFlowPerArea right) + public static VolumeFlowPerArea operator *(double left, VolumeFlowPerArea right) { return new VolumeFlowPerArea(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumeFlowPerArea operator *(VolumeFlowPerArea left, QuantityValue right) + public static VolumeFlowPerArea operator *(VolumeFlowPerArea left, double right) { return new VolumeFlowPerArea(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumeFlowPerArea operator /(VolumeFlowPerArea left, QuantityValue right) + public static VolumeFlowPerArea operator /(VolumeFlowPerArea left, double right) { return new VolumeFlowPerArea(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(VolumeFlowPerArea left, VolumeFlowPerArea right) + public static double operator /(VolumeFlowPerArea left, VolumeFlowPerArea right) { return left.CubicMetersPerSecondPerSquareMeter / right.CubicMetersPerSecondPerSquareMeter; } @@ -470,19 +467,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumeFlowPerArea left, VolumeFlowPerArea right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumeFlowPerArea left, VolumeFlowPerArea right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -495,29 +479,7 @@ public int CompareTo(object obj) /// public int CompareTo(VolumeFlowPerArea other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is VolumeFlowPerArea objVolumeFlowPerArea)) - return false; - return Equals(objVolumeFlowPerArea); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumeFlowPerArea other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -560,13 +522,13 @@ public bool Equals(VolumeFlowPerArea other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumeFlowPerArea other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -577,7 +539,7 @@ public bool Equals(VolumeFlowPerArea other, QuantityValue tolerance, ComparisonT /// A hash code for the current VolumeFlowPerArea. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -588,16 +550,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VolumeFlowPerAreaUnit unit) + public double As(VolumeFlowPerAreaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -612,12 +575,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit typedUnit)) + if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVolumeFlowPerAreaUnit); } /// @@ -649,7 +612,7 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit, UnitConverter unitCo var converted = conversionFunction(this); return (VolumeFlowPerArea)converted; } - else if (Enum.IsDefined(typeof(VolumeFlowPerAreaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -657,17 +620,17 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit, UnitConverter unitCo } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit typedUnit)) + if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVolumeFlowPerAreaUnit, DefaultConversionFunctions); } /// @@ -694,10 +657,10 @@ public VolumeFlowPerArea ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VolumeFlowPerAreaUnit unit) + private double GetValueAs(VolumeFlowPerAreaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index 3b401ddbe6..d07460ee38 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// Volume, typically of fluid, that a container can hold within a unit of length. /// [DataContract] - public partial struct VolumePerLength : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumePerLength : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -78,9 +78,9 @@ static VolumePerLength() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumePerLength(QuantityValue value, VolumePerLengthUnit unit) + public VolumePerLength(double value, VolumePerLengthUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -92,14 +92,14 @@ public VolumePerLength(QuantityValue value, VolumePerLengthUnit unit) /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumePerLength(QuantityValue value, UnitSystem unitSystem) + public VolumePerLength(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -140,10 +140,7 @@ public VolumePerLength(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -166,39 +163,39 @@ public VolumePerLength(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); + public double CubicMetersPerMeter => As(VolumePerLengthUnit.CubicMeterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); + public double CubicYardsPerFoot => As(VolumePerLengthUnit.CubicYardPerFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); + public double CubicYardsPerUsSurveyFoot => As(VolumePerLengthUnit.CubicYardPerUsSurveyFoot); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); + public double LitersPerKilometer => As(VolumePerLengthUnit.LiterPerKilometer); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); + public double LitersPerMeter => As(VolumePerLengthUnit.LiterPerMeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); + public double LitersPerMillimeter => As(VolumePerLengthUnit.LiterPerMillimeter); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); + public double OilBarrelsPerFoot => As(VolumePerLengthUnit.OilBarrelPerFoot); #endregion @@ -272,7 +269,7 @@ public static string GetAbbreviation(VolumePerLengthUnit unit, IFormatProvider? /// If value is NaN or Infinity. public static VolumePerLength FromCubicMetersPerMeter(QuantityValue cubicmeterspermeter) { - QuantityValue value = (QuantityValue) cubicmeterspermeter; + double value = (double) cubicmeterspermeter; return new VolumePerLength(value, VolumePerLengthUnit.CubicMeterPerMeter); } @@ -282,7 +279,7 @@ public static VolumePerLength FromCubicMetersPerMeter(QuantityValue cubicmetersp /// If value is NaN or Infinity. public static VolumePerLength FromCubicYardsPerFoot(QuantityValue cubicyardsperfoot) { - QuantityValue value = (QuantityValue) cubicyardsperfoot; + double value = (double) cubicyardsperfoot; return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerFoot); } @@ -292,7 +289,7 @@ public static VolumePerLength FromCubicYardsPerFoot(QuantityValue cubicyardsperf /// If value is NaN or Infinity. public static VolumePerLength FromCubicYardsPerUsSurveyFoot(QuantityValue cubicyardsperussurveyfoot) { - QuantityValue value = (QuantityValue) cubicyardsperussurveyfoot; + double value = (double) cubicyardsperussurveyfoot; return new VolumePerLength(value, VolumePerLengthUnit.CubicYardPerUsSurveyFoot); } @@ -302,7 +299,7 @@ public static VolumePerLength FromCubicYardsPerUsSurveyFoot(QuantityValue cubicy /// If value is NaN or Infinity. public static VolumePerLength FromLitersPerKilometer(QuantityValue litersperkilometer) { - QuantityValue value = (QuantityValue) litersperkilometer; + double value = (double) litersperkilometer; return new VolumePerLength(value, VolumePerLengthUnit.LiterPerKilometer); } @@ -312,7 +309,7 @@ public static VolumePerLength FromLitersPerKilometer(QuantityValue litersperkilo /// If value is NaN or Infinity. public static VolumePerLength FromLitersPerMeter(QuantityValue literspermeter) { - QuantityValue value = (QuantityValue) literspermeter; + double value = (double) literspermeter; return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMeter); } @@ -322,7 +319,7 @@ public static VolumePerLength FromLitersPerMeter(QuantityValue literspermeter) /// If value is NaN or Infinity. public static VolumePerLength FromLitersPerMillimeter(QuantityValue literspermillimeter) { - QuantityValue value = (QuantityValue) literspermillimeter; + double value = (double) literspermillimeter; return new VolumePerLength(value, VolumePerLengthUnit.LiterPerMillimeter); } @@ -332,7 +329,7 @@ public static VolumePerLength FromLitersPerMillimeter(QuantityValue literspermil /// If value is NaN or Infinity. public static VolumePerLength FromOilBarrelsPerFoot(QuantityValue oilbarrelsperfoot) { - QuantityValue value = (QuantityValue) oilbarrelsperfoot; + double value = (double) oilbarrelsperfoot; return new VolumePerLength(value, VolumePerLengthUnit.OilBarrelPerFoot); } @@ -344,7 +341,7 @@ public static VolumePerLength FromOilBarrelsPerFoot(QuantityValue oilbarrelsperf /// VolumePerLength unit value. public static VolumePerLength From(QuantityValue value, VolumePerLengthUnit fromUnit) { - return new VolumePerLength((QuantityValue)value, fromUnit); + return new VolumePerLength((double)value, fromUnit); } #endregion @@ -514,25 +511,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumePerLength operator *(QuantityValue left, VolumePerLength right) + public static VolumePerLength operator *(double left, VolumePerLength right) { return new VolumePerLength(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumePerLength operator *(VolumePerLength left, QuantityValue right) + public static VolumePerLength operator *(VolumePerLength left, double right) { return new VolumePerLength(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumePerLength operator /(VolumePerLength left, QuantityValue right) + public static VolumePerLength operator /(VolumePerLength left, double right) { return new VolumePerLength(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(VolumePerLength left, VolumePerLength right) + public static double operator /(VolumePerLength left, VolumePerLength right) { return left.CubicMetersPerMeter / right.CubicMetersPerMeter; } @@ -565,19 +562,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumePerLength left, VolumePerLength right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumePerLength left, VolumePerLength right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -590,29 +574,7 @@ public int CompareTo(object obj) /// public int CompareTo(VolumePerLength other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is VolumePerLength objVolumePerLength)) - return false; - return Equals(objVolumePerLength); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumePerLength other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -655,13 +617,13 @@ public bool Equals(VolumePerLength other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumePerLength other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(VolumePerLength other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -672,7 +634,7 @@ public bool Equals(VolumePerLength other, QuantityValue tolerance, ComparisonTyp /// A hash code for the current VolumePerLength. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -683,16 +645,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VolumePerLengthUnit unit) + public double As(VolumePerLengthUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -707,12 +670,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VolumePerLengthUnit typedUnit)) + if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVolumePerLengthUnit); } /// @@ -744,7 +707,7 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit, UnitConverter unitConver var converted = conversionFunction(this); return (VolumePerLength)converted; } - else if (Enum.IsDefined(typeof(VolumePerLengthUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -752,17 +715,17 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit, UnitConverter unitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumePerLengthUnit typedUnit)) + if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVolumePerLengthUnit, DefaultConversionFunctions); } /// @@ -789,10 +752,10 @@ public VolumePerLength ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VolumePerLengthUnit unit) + private double GetValueAs(VolumePerLengthUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index efcc549362..3ca758cbc0 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -38,13 +38,13 @@ namespace UnitsNet /// https://en.wikipedia.org/wiki/Volumetric_heat_capacity /// [DataContract] - public partial struct VolumetricHeatCapacity : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct VolumetricHeatCapacity : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -83,9 +83,9 @@ static VolumetricHeatCapacity() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public VolumetricHeatCapacity(QuantityValue value, VolumetricHeatCapacityUnit unit) + public VolumetricHeatCapacity(double value, VolumetricHeatCapacityUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -97,14 +97,14 @@ public VolumetricHeatCapacity(QuantityValue value, VolumetricHeatCapacityUnit un /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public VolumetricHeatCapacity(QuantityValue value, UnitSystem unitSystem) + public VolumetricHeatCapacity(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -145,10 +145,7 @@ public VolumetricHeatCapacity(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -171,49 +168,49 @@ public VolumetricHeatCapacity(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); + public double BtusPerCubicFootDegreeFahrenheit => As(VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); + public double CaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); + public double JoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); + public double JoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); + public double KilocaloriesPerCubicCentimeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); + public double KilojoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); + public double KilojoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); + public double MegajoulesPerCubicMeterDegreeCelsius => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); + public double MegajoulesPerCubicMeterKelvin => As(VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); #endregion @@ -293,7 +290,7 @@ public static string GetAbbreviation(VolumetricHeatCapacityUnit unit, IFormatPro /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(QuantityValue btuspercubicfootdegreefahrenheit) { - QuantityValue value = (QuantityValue) btuspercubicfootdegreefahrenheit; + double value = (double) btuspercubicfootdegreefahrenheit; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.BtuPerCubicFootDegreeFahrenheit); } @@ -303,7 +300,7 @@ public static VolumetricHeatCapacity FromBtusPerCubicFootDegreeFahrenheit(Quanti /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius(QuantityValue caloriespercubiccentimeterdegreecelsius) { - QuantityValue value = (QuantityValue) caloriespercubiccentimeterdegreecelsius; + double value = (double) caloriespercubiccentimeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.CaloriePerCubicCentimeterDegreeCelsius); } @@ -313,7 +310,7 @@ public static VolumetricHeatCapacity FromCaloriesPerCubicCentimeterDegreeCelsius /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(QuantityValue joulespercubicmeterdegreecelsius) { - QuantityValue value = (QuantityValue) joulespercubicmeterdegreecelsius; + double value = (double) joulespercubicmeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterDegreeCelsius); } @@ -323,7 +320,7 @@ public static VolumetricHeatCapacity FromJoulesPerCubicMeterDegreeCelsius(Quanti /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(QuantityValue joulespercubicmeterkelvin) { - QuantityValue value = (QuantityValue) joulespercubicmeterkelvin; + double value = (double) joulespercubicmeterkelvin; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.JoulePerCubicMeterKelvin); } @@ -333,7 +330,7 @@ public static VolumetricHeatCapacity FromJoulesPerCubicMeterKelvin(QuantityValue /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCelsius(QuantityValue kilocaloriespercubiccentimeterdegreecelsius) { - QuantityValue value = (QuantityValue) kilocaloriespercubiccentimeterdegreecelsius; + double value = (double) kilocaloriespercubiccentimeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilocaloriePerCubicCentimeterDegreeCelsius); } @@ -343,7 +340,7 @@ public static VolumetricHeatCapacity FromKilocaloriesPerCubicCentimeterDegreeCel /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(QuantityValue kilojoulespercubicmeterdegreecelsius) { - QuantityValue value = (QuantityValue) kilojoulespercubicmeterdegreecelsius; + double value = (double) kilojoulespercubicmeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterDegreeCelsius); } @@ -353,7 +350,7 @@ public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterDegreeCelsius(Qu /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(QuantityValue kilojoulespercubicmeterkelvin) { - QuantityValue value = (QuantityValue) kilojoulespercubicmeterkelvin; + double value = (double) kilojoulespercubicmeterkelvin; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.KilojoulePerCubicMeterKelvin); } @@ -363,7 +360,7 @@ public static VolumetricHeatCapacity FromKilojoulesPerCubicMeterKelvin(QuantityV /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(QuantityValue megajoulespercubicmeterdegreecelsius) { - QuantityValue value = (QuantityValue) megajoulespercubicmeterdegreecelsius; + double value = (double) megajoulespercubicmeterdegreecelsius; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterDegreeCelsius); } @@ -373,7 +370,7 @@ public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterDegreeCelsius(Qu /// If value is NaN or Infinity. public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(QuantityValue megajoulespercubicmeterkelvin) { - QuantityValue value = (QuantityValue) megajoulespercubicmeterkelvin; + double value = (double) megajoulespercubicmeterkelvin; return new VolumetricHeatCapacity(value, VolumetricHeatCapacityUnit.MegajoulePerCubicMeterKelvin); } @@ -385,7 +382,7 @@ public static VolumetricHeatCapacity FromMegajoulesPerCubicMeterKelvin(QuantityV /// VolumetricHeatCapacity unit value. public static VolumetricHeatCapacity From(QuantityValue value, VolumetricHeatCapacityUnit fromUnit) { - return new VolumetricHeatCapacity((QuantityValue)value, fromUnit); + return new VolumetricHeatCapacity((double)value, fromUnit); } #endregion @@ -555,25 +552,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum } /// Get from multiplying value and . - public static VolumetricHeatCapacity operator *(QuantityValue left, VolumetricHeatCapacity right) + public static VolumetricHeatCapacity operator *(double left, VolumetricHeatCapacity right) { return new VolumetricHeatCapacity(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static VolumetricHeatCapacity operator *(VolumetricHeatCapacity left, QuantityValue right) + public static VolumetricHeatCapacity operator *(VolumetricHeatCapacity left, double right) { return new VolumetricHeatCapacity(left.Value * right, left.Unit); } /// Get from dividing by value. - public static VolumetricHeatCapacity operator /(VolumetricHeatCapacity left, QuantityValue right) + public static VolumetricHeatCapacity operator /(VolumetricHeatCapacity left, double right) { return new VolumetricHeatCapacity(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(VolumetricHeatCapacity left, VolumetricHeatCapacity right) + public static double operator /(VolumetricHeatCapacity left, VolumetricHeatCapacity right) { return left.JoulesPerCubicMeterKelvin / right.JoulesPerCubicMeterKelvin; } @@ -606,19 +603,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Volum return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(VolumetricHeatCapacity left, VolumetricHeatCapacity right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(VolumetricHeatCapacity left, VolumetricHeatCapacity right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -631,29 +615,7 @@ public int CompareTo(object obj) /// public int CompareTo(VolumetricHeatCapacity other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is VolumetricHeatCapacity objVolumetricHeatCapacity)) - return false; - return Equals(objVolumetricHeatCapacity); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(VolumetricHeatCapacity other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -696,13 +658,13 @@ public bool Equals(VolumetricHeatCapacity other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(VolumetricHeatCapacity other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -713,7 +675,7 @@ public bool Equals(VolumetricHeatCapacity other, QuantityValue tolerance, Compar /// A hash code for the current VolumetricHeatCapacity. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -724,16 +686,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(VolumetricHeatCapacityUnit unit) + public double As(VolumetricHeatCapacityUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -748,12 +711,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit typedUnit)) + if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsVolumetricHeatCapacityUnit); } /// @@ -785,7 +748,7 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit, UnitConver var converted = conversionFunction(this); return (VolumetricHeatCapacity)converted; } - else if (Enum.IsDefined(typeof(VolumetricHeatCapacityUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -793,17 +756,17 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit, UnitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit typedUnit)) + if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsVolumetricHeatCapacityUnit, DefaultConversionFunctions); } /// @@ -830,10 +793,10 @@ public VolumetricHeatCapacity ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(VolumetricHeatCapacityUnit unit) + private double GetValueAs(VolumetricHeatCapacityUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 5bc210e52b..2ef276467a 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -35,13 +35,13 @@ namespace UnitsNet /// A geometric property of an area that is used to determine the warping stress. /// [DataContract] - public partial struct WarpingMomentOfInertia : IQuantity, IEquatable, IComparable, IComparable, IConvertible, IFormattable + public partial struct WarpingMomentOfInertia : IQuantity, IComparable, IComparable, IConvertible, IFormattable { /// /// The numeric value this quantity was constructed with. /// [DataMember(Name = "Value", Order = 0)] - private readonly QuantityValue _value; + private readonly double _value; /// /// The unit this quantity was constructed with. @@ -77,9 +77,9 @@ static WarpingMomentOfInertia() /// The numeric value to construct this quantity with. /// The unit representation to construct this quantity with. /// If value is NaN or Infinity. - public WarpingMomentOfInertia(QuantityValue value, WarpingMomentOfInertiaUnit unit) + public WarpingMomentOfInertia(double value, WarpingMomentOfInertiaUnit unit) { - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = unit; } @@ -91,14 +91,14 @@ public WarpingMomentOfInertia(QuantityValue value, WarpingMomentOfInertiaUnit un /// The unit system to create the quantity with. /// The given is null. /// No unit was found for the given . - public WarpingMomentOfInertia(QuantityValue value, UnitSystem unitSystem) + public WarpingMomentOfInertia(double value, UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); var unitInfos = Info.GetUnitInfosFor(unitSystem.BaseUnits); var firstUnitInfo = unitInfos.FirstOrDefault(); - _value = value; + _value = Guard.EnsureValidNumber(value, nameof(value)); _unit = firstUnitInfo?.Value ?? throw new ArgumentException("No units were found for the given UnitSystem.", nameof(unitSystem)); } @@ -139,10 +139,7 @@ public WarpingMomentOfInertia(QuantityValue value, UnitSystem unitSystem) /// /// The numeric value this quantity was constructed with. /// - public QuantityValue Value => _value; - - /// - QuantityValue IQuantity.Value => _value; + public double Value => _value; Enum IQuantity.Unit => Unit; @@ -165,34 +162,34 @@ public WarpingMomentOfInertia(QuantityValue value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); + public double CentimetersToTheSixth => As(WarpingMomentOfInertiaUnit.CentimeterToTheSixth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); + public double DecimetersToTheSixth => As(WarpingMomentOfInertiaUnit.DecimeterToTheSixth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); + public double FeetToTheSixth => As(WarpingMomentOfInertiaUnit.FootToTheSixth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); + public double InchesToTheSixth => As(WarpingMomentOfInertiaUnit.InchToTheSixth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); + public double MetersToTheSixth => As(WarpingMomentOfInertiaUnit.MeterToTheSixth); /// - /// Gets the numeric value of this quantity converted into + /// Gets a value of this quantity converted into /// - public QuantityValue MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); + public double MillimetersToTheSixth => As(WarpingMomentOfInertiaUnit.MillimeterToTheSixth); #endregion @@ -263,7 +260,7 @@ public static string GetAbbreviation(WarpingMomentOfInertiaUnit unit, IFormatPro /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromCentimetersToTheSixth(QuantityValue centimeterstothesixth) { - QuantityValue value = (QuantityValue) centimeterstothesixth; + double value = (double) centimeterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.CentimeterToTheSixth); } @@ -273,7 +270,7 @@ public static WarpingMomentOfInertia FromCentimetersToTheSixth(QuantityValue cen /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromDecimetersToTheSixth(QuantityValue decimeterstothesixth) { - QuantityValue value = (QuantityValue) decimeterstothesixth; + double value = (double) decimeterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.DecimeterToTheSixth); } @@ -283,7 +280,7 @@ public static WarpingMomentOfInertia FromDecimetersToTheSixth(QuantityValue deci /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromFeetToTheSixth(QuantityValue feettothesixth) { - QuantityValue value = (QuantityValue) feettothesixth; + double value = (double) feettothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.FootToTheSixth); } @@ -293,7 +290,7 @@ public static WarpingMomentOfInertia FromFeetToTheSixth(QuantityValue feettothes /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromInchesToTheSixth(QuantityValue inchestothesixth) { - QuantityValue value = (QuantityValue) inchestothesixth; + double value = (double) inchestothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.InchToTheSixth); } @@ -303,7 +300,7 @@ public static WarpingMomentOfInertia FromInchesToTheSixth(QuantityValue inchesto /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromMetersToTheSixth(QuantityValue meterstothesixth) { - QuantityValue value = (QuantityValue) meterstothesixth; + double value = (double) meterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MeterToTheSixth); } @@ -313,7 +310,7 @@ public static WarpingMomentOfInertia FromMetersToTheSixth(QuantityValue metersto /// If value is NaN or Infinity. public static WarpingMomentOfInertia FromMillimetersToTheSixth(QuantityValue millimeterstothesixth) { - QuantityValue value = (QuantityValue) millimeterstothesixth; + double value = (double) millimeterstothesixth; return new WarpingMomentOfInertia(value, WarpingMomentOfInertiaUnit.MillimeterToTheSixth); } @@ -325,7 +322,7 @@ public static WarpingMomentOfInertia FromMillimetersToTheSixth(QuantityValue mil /// WarpingMomentOfInertia unit value. public static WarpingMomentOfInertia From(QuantityValue value, WarpingMomentOfInertiaUnit fromUnit) { - return new WarpingMomentOfInertia((QuantityValue)value, fromUnit); + return new WarpingMomentOfInertia((double)value, fromUnit); } #endregion @@ -495,25 +492,25 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi } /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(QuantityValue left, WarpingMomentOfInertia right) + public static WarpingMomentOfInertia operator *(double left, WarpingMomentOfInertia right) { return new WarpingMomentOfInertia(left * right.Value, right.Unit); } /// Get from multiplying value and . - public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, QuantityValue right) + public static WarpingMomentOfInertia operator *(WarpingMomentOfInertia left, double right) { return new WarpingMomentOfInertia(left.Value * right, left.Unit); } /// Get from dividing by value. - public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, QuantityValue right) + public static WarpingMomentOfInertia operator /(WarpingMomentOfInertia left, double right) { return new WarpingMomentOfInertia(left.Value / right, left.Unit); } /// Get ratio value from dividing by . - public static QuantityValue operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) + public static double operator /(WarpingMomentOfInertia left, WarpingMomentOfInertia right) { return left.MetersToTheSixth / right.MetersToTheSixth; } @@ -546,19 +543,6 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Warpi return left.Value > right.GetValueAs(left.Unit); } - /// Returns true if exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator ==(WarpingMomentOfInertia left, WarpingMomentOfInertia right) - { - return left.Equals(right); - } - /// Returns true if not exactly equal. - /// Consider using for safely comparing floating point values. - public static bool operator !=(WarpingMomentOfInertia left, WarpingMomentOfInertia right) - { - return !(left == right); - } - /// public int CompareTo(object obj) { @@ -571,29 +555,7 @@ public int CompareTo(object obj) /// public int CompareTo(WarpingMomentOfInertia other) { - var asFirstUnit = other.GetValueAs(this.Unit); - var asSecondUnit = GetValueAs(other.Unit); - return (_value.CompareTo(asFirstUnit) - other.Value.CompareTo(asSecondUnit)) / 2; - } - - /// - /// Consider using for safely comparing floating point values. - public override bool Equals(object obj) - { - if (obj is null || !(obj is WarpingMomentOfInertia objWarpingMomentOfInertia)) - return false; - return Equals(objWarpingMomentOfInertia); - } - - /// - /// Consider using for safely comparing floating point values. - public bool Equals(WarpingMomentOfInertia other) - { - if (Value.IsDecimal) - return other.Value.Equals(this.GetValueAs(other.Unit)); - if (other.Value.IsDecimal) - return Value.Equals(other.GetValueAs(this.Unit)); - return this.Unit == other.Unit && this.Value.Equals(other.Value); + return _value.CompareTo(other.GetValueAs(this.Unit)); } /// @@ -636,13 +598,13 @@ public bool Equals(WarpingMomentOfInertia other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(WarpingMomentOfInertia other, QuantityValue tolerance, ComparisonType comparisonType) + public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - QuantityValue thisValue = this.Value; - QuantityValue otherValueInThisUnits = other.As(this.Unit); + double thisValue = (double)this.Value; + double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -653,7 +615,7 @@ public bool Equals(WarpingMomentOfInertia other, QuantityValue tolerance, Compar /// A hash code for the current WarpingMomentOfInertia. public override int GetHashCode() { - return Info.Name.GetHashCode(); + return new { Info.Name, Value, Unit }.GetHashCode(); } #endregion @@ -664,16 +626,17 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public QuantityValue As(WarpingMomentOfInertiaUnit unit) + public double As(WarpingMomentOfInertiaUnit unit) { - if(Unit == unit) - return Value; + if (Unit == unit) + return Convert.ToDouble(Value); - return GetValueAs(unit); + var converted = GetValueAs(unit); + return Convert.ToDouble(converted); } /// - public QuantityValue As(UnitSystem unitSystem) + public double As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -688,12 +651,12 @@ public QuantityValue As(UnitSystem unitSystem) } /// - QuantityValue IQuantity.As(Enum unit) + double IQuantity.As(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) + if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return (QuantityValue)As(typedUnit); + return As(unitAsWarpingMomentOfInertiaUnit); } /// @@ -725,7 +688,7 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit, UnitConver var converted = conversionFunction(this); return (WarpingMomentOfInertia)converted; } - else if (Enum.IsDefined(typeof(WarpingMomentOfInertiaUnit), unit)) + else if (Unit != BaseUnit) { // Direct conversion to requested unit NOT found. Convert to BaseUnit, and then from BaseUnit to requested unit. var inBaseUnits = ToUnit(BaseUnit); @@ -733,17 +696,17 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit, UnitConver } else { - throw new NotSupportedException($"Can not convert {Unit} to {unit}."); + throw new NotImplementedException($"Can not convert {Unit} to {unit}."); } } /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) + if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(typedUnit, DefaultConversionFunctions); + return ToUnit(unitAsWarpingMomentOfInertiaUnit, DefaultConversionFunctions); } /// @@ -770,10 +733,10 @@ public WarpingMomentOfInertia ToUnit(UnitSystem unitSystem) /// IQuantity IQuantity.ToUnit(UnitSystem unitSystem) => ToUnit(unitSystem); - private QuantityValue GetValueAs(WarpingMomentOfInertiaUnit unit) + private double GetValueAs(WarpingMomentOfInertiaUnit unit) { var converted = ToUnit(unit); - return (QuantityValue)converted.Value; + return (double)converted.Value; } #endregion diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index c65a61d0dd..48445422fb 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -28,7 +28,7 @@ public interface IQuantity : IFormattable /// The unit enum value. The unit must be compatible, so for you should provide a value. /// Value converted to the specified unit. /// Wrong unit enum type was given. - QuantityValue As(Enum unit); + double As(Enum unit); /// /// Gets the value in the unit determined by the given . If multiple units were found for the given , @@ -36,7 +36,7 @@ public interface IQuantity : IFormattable /// /// The to convert the quantity value to. /// The converted value. - QuantityValue As(UnitSystem unitSystem); + double As(UnitSystem unitSystem); /// /// The unit this quantity was constructed with -or- BaseUnit if default ctor was used. @@ -46,7 +46,7 @@ public interface IQuantity : IFormattable /// /// The value this quantity was constructed with. See also . /// - QuantityValue Value { get; } + double Value { get; } /// /// Converts this to an in the given . @@ -89,7 +89,7 @@ public interface IQuantity : IQuantity where TUnitType : Enum /// Convert to a unit representation . /// /// Value converted to the specified unit. - QuantityValue As(TUnitType unit); + double As(TUnitType unit); /// new TUnitType Unit { get; } diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index b1f52accff..8c7fdeb613 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -180,9 +180,8 @@ private static string FormatUntrimmed(IQuantity quantity, private static string ToStringWithSignificantDigitsAfterRadix(IQuantity quantity, IFormatProvider formatProvider, int number) where TUnitType : Enum { - // When a fixed number of digits after the dot is expected, double and decimal behave the same - string formatForSignificantDigits = UnitFormatter.GetFormat((double)quantity.Value, number); - object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, (double)quantity.Value, formatProvider, Enumerable.Empty()); + string formatForSignificantDigits = UnitFormatter.GetFormat(quantity.Value, number); + object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, quantity.Value, formatProvider, Enumerable.Empty()); return string.Format(formatProvider, formatForSignificantDigits, formatArgs); } } diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index 0fe4d6169f..d25d184e98 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -5,8 +5,6 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; -using System.Globalization; -using System.Runtime.Serialization; using UnitsNet.InternalHelpers; namespace UnitsNet @@ -29,36 +27,15 @@ namespace UnitsNet /// This allows for adding support for smaller data types without increasing the overall size. /// [StructLayout(LayoutKind.Explicit)] - // [DebuggerDisplay("{GetDebugRepresentation()}")] // TODO replace with a DebuggerTypeProxy? - [DataContract] - public readonly struct QuantityValue : IFormattable, IEquatable, IComparable, IComparable, IConvertible + [DebuggerDisplay("{GetDebugRepresentation()}")] + public readonly struct QuantityValue { - private const decimal MinPrecision = 1E-6m; // min number of decimals reserved: as to avoid values that just barely fit the decimal range - private const double DecimalMin = (double)(decimal.MinValue * MinPrecision); - private const double DecimalMax = (double)(decimal.MaxValue * MinPrecision); - - private static bool InDecimalRange(double value) - { - if (value == 0) - { - return true; - } - - return value is >= DecimalMin and <= DecimalMax && 1 / value is >= DecimalMin and <= DecimalMax; - } - - /// - /// The value 0 - /// - public static readonly QuantityValue Zero = default; - /// /// Value assigned when implicitly casting from all numeric types except , since /// has the greatest range. /// - [FieldOffset(4)] // so that it does not interfere with the Nullable // TODO please review this - [DataMember(Name = "Double", Order = 0, EmitDefaultValue = false)] - private readonly double? _doubleValue; + [FieldOffset(8)] // so that it does not interfere with the Type field + private readonly double _doubleValue; /// /// Value assigned when implicitly casting from type, since it has a greater precision than @@ -67,59 +44,39 @@ private static bool InDecimalRange(double value) /// [FieldOffset(0)] // bytes layout: 0-1 unused, 2 exponent, 3 sign (only highest bit), 4-15 number - [DataMember(Name = "Decimal", Order = 1, EmitDefaultValue = false)] - private readonly decimal? _decimalValue; - + private readonly decimal _decimalValue; /// /// Determines the underlying type of this . /// - public QuantityValueType Type => IsDecimal ? QuantityValueType.Decimal : QuantityValueType.Double; + [FieldOffset(0)] // using unused byte for storing type + public readonly UnderlyingDataType Type; private QuantityValue(double val) : this() { _doubleValue = Guard.EnsureValidNumber(val, nameof(val)); + Type = UnderlyingDataType.Double; } private QuantityValue(decimal val) : this() { _decimalValue = val; + Type = UnderlyingDataType.Decimal; } - /// - /// Returns true if the underlying value is stored as a decimal - /// - /// True for default(QuantityValue) and QuantityValue.Zero - public bool IsDecimal => !_doubleValue.HasValue; - - /// - /// Value assigned when implicitly casting from all numeric types except , since - /// has the greatest range. - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private double DoubleValue => _doubleValue.GetValueOrDefault(); - - /// - /// Value assigned when implicitly casting from type, since it has a greater precision than - /// and we want to preserve that when constructing quantities that use - /// as their value type. - /// - [DebuggerBrowsable(DebuggerBrowsableState.Never)] - private decimal DecimalValue => _decimalValue.GetValueOrDefault(); - - #region Implicit cast to QuantityValue + #region To QuantityValue // Prefer double for integer types, since most quantities use that type as of now and // that avoids unnecessary casts back and forth. // If we later change to use decimal more, we should revisit this. /// Implicit cast from to . - public static implicit operator QuantityValue(byte val) => new QuantityValue((decimal) val); + public static implicit operator QuantityValue(byte val) => new QuantityValue((double) val); /// Implicit cast from to . - public static implicit operator QuantityValue(short val) => new QuantityValue((decimal) val); + public static implicit operator QuantityValue(short val) => new QuantityValue((double) val); /// Implicit cast from to . - public static implicit operator QuantityValue(int val) => new QuantityValue((decimal) val); + public static implicit operator QuantityValue(int val) => new QuantityValue((double) val); /// Implicit cast from to . - public static implicit operator QuantityValue(long val) => new QuantityValue((decimal) val); + public static implicit operator QuantityValue(long val) => new QuantityValue((double) val); /// Implicit cast from to . public static implicit operator QuantityValue(float val) => new QuantityValue(val); // double /// Implicit cast from to . @@ -128,309 +85,42 @@ private QuantityValue(decimal val) : this() public static implicit operator QuantityValue(decimal val) => new QuantityValue(val); // decimal #endregion - #region Explicit cast to double + #region To double - /// Explicit cast from to . + /// Explicit cast from to . public static explicit operator double(QuantityValue number) - { - return number.IsDecimal ? (double)number.DecimalValue : number.DoubleValue; - } + => number.Type switch + { + UnderlyingDataType.Decimal => (double)number._decimalValue, + UnderlyingDataType.Double => number._doubleValue, + _ => throw new NotImplementedException() + }; #endregion - #region Explicit cast to decimal + #region To decimal - /// Explicit cast from to . + /// Explicit cast from to . public static explicit operator decimal(QuantityValue number) - { - return number.IsDecimal ? number.DecimalValue : (decimal)number.DoubleValue; - } - - #endregion - - #region Operators and Comparators - - /// - public int CompareTo(QuantityValue other) - { - if (IsDecimal && other.IsDecimal) - { - return DecimalValue.CompareTo(other.DecimalValue); - } - - if (IsDecimal) - { - var otherValue = other.DoubleValue; - return InDecimalRange(otherValue) ? DecimalValue.CompareTo((decimal)otherValue) : ((double)DecimalValue).CompareTo(otherValue); - } - - if (other.IsDecimal) - { - var thisValue = DoubleValue; - return InDecimalRange(thisValue) ? ((decimal)thisValue).CompareTo(other.DecimalValue) : thisValue.CompareTo((double)other.DecimalValue); - } - - // Both are double - return DoubleValue.CompareTo(other.DoubleValue); - } - - - /// - public int CompareTo(object? obj) - { - return obj is QuantityValue other ? CompareTo(other) : throw new ArgumentException($"Object must be of type {nameof(QuantityValue)}"); - } - - /// - public override bool Equals(object other) - { - if (other is QuantityValue qv) - { - return Equals(qv); - } - - return false; - } - - /// - public override int GetHashCode() - { - if (IsDecimal) - { - return DecimalValue.GetHashCode(); - } - else - { - return DoubleValue.GetHashCode(); - } - } - - /// - /// Performs an equality comparison on two instances of . - /// Note that rounding might occur if the two values don't use the same base type. - /// - /// The value to compare to - /// True on exact equality, false otherwise - public bool Equals(QuantityValue other) - { - if (IsDecimal && other.IsDecimal) - { - return DecimalValue == other.DecimalValue; - } - - if (IsDecimal) - { - var otherValue = other.DoubleValue; - return InDecimalRange(otherValue) && DecimalValue == (decimal)otherValue; - } - - if (other.IsDecimal) - { - var thisValue = DoubleValue; - return InDecimalRange(thisValue) && (decimal)DoubleValue == other.DecimalValue; - } - - return DoubleValue.Equals(other.DoubleValue); - } - - /// Equality comparator - public static bool operator ==(QuantityValue a, QuantityValue b) - { - return a.Equals(b); - } - - /// Inequality comparator - public static bool operator !=(QuantityValue a, QuantityValue b) - { - return !a.Equals(b); - } - - /// - /// Greater-than operator - /// - public static bool operator >(QuantityValue a, QuantityValue b) - { - return a.CompareTo(b) == 1; - } - - /// - /// Less-than operator - /// - public static bool operator <(QuantityValue a, QuantityValue b) - { - - return a.CompareTo(b) == -1; - } - - /// - /// Greater-than-or-equal operator - /// - public static bool operator >=(QuantityValue a, QuantityValue b) - { - - return a.CompareTo(b) >= 0; - } - - /// - /// Less-than-or-equal operator - /// - public static bool operator <=(QuantityValue a, QuantityValue b) - { - - return a.CompareTo(b) <= 0; - } - - /// - /// Returns the negated value of the operand - /// - /// Value to negate - /// -v - public static QuantityValue operator -(QuantityValue v) - { - if (v.IsDecimal) - { - return new QuantityValue(-v.DecimalValue); - } - else - { - return new QuantityValue(-v.DoubleValue); - } - } - - /// - /// Addition operator. - /// - /// - /// This performs an operation on the numeric value of a quantity, clamping the decimal representation as necessary. - /// - public static QuantityValue operator +(QuantityValue a, QuantityValue b) - { - if (a.IsDecimal && b.IsDecimal) - { - var doubleResult = (double)a.DecimalValue + (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue + b.DecimalValue) : new QuantityValue(doubleResult); - } - else if (a.IsDecimal) + => number.Type switch { - var doubleResult = (double)a.DecimalValue + b.DoubleValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue + (decimal)b.DoubleValue): new QuantityValue(doubleResult); - } - else if (b.IsDecimal) - { - var doubleResult = a.DoubleValue + (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue + b.DecimalValue): new QuantityValue(doubleResult); - } - else - { - // Both are double - return new QuantityValue(a.DoubleValue + b.DoubleValue); - } - } - - /// - /// Subtraction operator. - /// - /// - /// This performs an operation on the numeric value of a quantity, there is no unit or conversions involved. - /// - public static QuantityValue operator -(QuantityValue a, QuantityValue b) - { - if (a.IsDecimal && b.IsDecimal) - { - var doubleResult = (double)a.DecimalValue - (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue - b.DecimalValue) : new QuantityValue(doubleResult); - } - else if (a.IsDecimal) - { - var doubleResult = (double)a.DecimalValue - b.DoubleValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue - (decimal)b.DoubleValue): new QuantityValue(doubleResult); - } - else if (b.IsDecimal) - { - var doubleResult = a.DoubleValue - (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue - b.DecimalValue): new QuantityValue(doubleResult); - } - else - { - // Both are double - return new QuantityValue(a.DoubleValue - b.DoubleValue); - } - } - - /// - /// Multiplication operator. - /// - /// - /// This performs an operation on the numeric value of a quantity, there is no unit or conversions involved. - /// - public static QuantityValue operator *(QuantityValue a, QuantityValue b) - { - if (a.IsDecimal && b.IsDecimal) - { - var doubleResult = (double)a.DecimalValue * (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue * b.DecimalValue) : new QuantityValue(doubleResult); - } - else if (a.IsDecimal) - { - var doubleResult = (double)a.DecimalValue * b.DoubleValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue * (decimal)b.DoubleValue): new QuantityValue(doubleResult); - } - else if (b.IsDecimal) - { - var doubleResult = a.DoubleValue * (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue * b.DecimalValue): new QuantityValue(doubleResult); - } - else - { - // Both are double - return new QuantityValue(a.DoubleValue * b.DoubleValue); - } - } - - /// - /// Division operator. - /// - /// - /// This performs an operation on the numeric value of a quantity, there is no unit or conversions involved. - /// - public static QuantityValue operator /(QuantityValue a, QuantityValue b) - { - if (a.IsDecimal && b.IsDecimal) - { - var doubleResult = (double)a.DecimalValue / (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue / b.DecimalValue) : new QuantityValue(doubleResult); - } - else if (a.IsDecimal) - { - var doubleResult = (double)a.DecimalValue / b.DoubleValue; - return InDecimalRange(doubleResult) ? new QuantityValue(a.DecimalValue / (decimal)b.DoubleValue): new QuantityValue(doubleResult); - } - else if (b.IsDecimal) - { - var doubleResult = a.DoubleValue / (double)b.DecimalValue; - return InDecimalRange(doubleResult) ? new QuantityValue((decimal)a.DoubleValue / b.DecimalValue): new QuantityValue(doubleResult); - } - else - { - // Both are double - return new QuantityValue(a.DoubleValue / b.DoubleValue); - } - } + UnderlyingDataType.Decimal => number._decimalValue, + UnderlyingDataType.Double => (decimal)number._doubleValue, + _ => throw new NotImplementedException() + }; #endregion - #region ToString - /// Returns the string representation of the numeric value. public override string ToString() => Type switch { - QuantityValueType.Decimal => DecimalValue.ToString(), - QuantityValueType.Double => DoubleValue.ToString(), + UnderlyingDataType.Decimal => _decimalValue.ToString(), + UnderlyingDataType.Double => _doubleValue.ToString(), _ => throw new NotImplementedException() }; - private string GetDebugRepresentation() // TODO replace by DebuggerTypeProxy? + private string GetDebugRepresentation() { StringBuilder builder = new($"{Type} {ToString()} Hex:"); @@ -443,132 +133,10 @@ private string GetDebugRepresentation() // TODO replace by DebuggerTypeProxy? return builder.ToString(); } - /// - /// Returns the string representation of the numeric value, formatted using the given standard numeric format string - /// - /// A standard numeric format string (must be valid for either double or decimal, depending on the base type) - /// The string representation - public string ToString(string format) - { - return ToString(format, CultureInfo.CurrentCulture); - } - - /// - /// Returns the string representation of the underlying value - /// - /// Standard format specifiers. Because the underlying value can be double or decimal, the meaning can vary - /// Culture specific settings - /// A string representation of the number - public string ToString(string format, IFormatProvider formatProvider) - { - if (IsDecimal) - { - return DecimalValue.ToString(format, formatProvider); - } - else - { - return DoubleValue.ToString(format, formatProvider); - } - } - - #endregion - - #region IConvertiable interface implmentation - - TypeCode IConvertible.GetTypeCode() - { - return IsDecimal ? TypeCode.Decimal : TypeCode.Double; - } - - bool IConvertible.ToBoolean(IFormatProvider provider) - { - throw new InvalidCastException($"Converting {typeof(QuantityValue)} to Boolean is not supported."); - } - - byte IConvertible.ToByte(IFormatProvider provider) - { - return IsDecimal ? Convert.ToByte(DecimalValue) : Convert.ToByte(DoubleValue); - } - - char IConvertible.ToChar(IFormatProvider provider) - { - throw new InvalidCastException($"Converting {typeof(QuantityValue)} to Char is not supported."); - } - - DateTime IConvertible.ToDateTime(IFormatProvider provider) - { - throw new InvalidCastException($"Converting {typeof(QuantityValue)} to DateTime is not supported."); - } - - decimal IConvertible.ToDecimal(IFormatProvider provider) - { - return IsDecimal ? DecimalValue : Convert.ToDecimal(DoubleValue); - } - - double IConvertible.ToDouble(IFormatProvider provider) - { - return IsDecimal ? Convert.ToDouble(DecimalValue) : DoubleValue; - } - - short IConvertible.ToInt16(IFormatProvider provider) - { - return IsDecimal ? Convert.ToInt16(DecimalValue) : Convert.ToInt16(DoubleValue); - } - - int IConvertible.ToInt32(IFormatProvider provider) - { - return IsDecimal ? Convert.ToInt16(DecimalValue) : Convert.ToInt16(DoubleValue); - } - - long IConvertible.ToInt64(IFormatProvider provider) - { - return IsDecimal ? Convert.ToInt16(DecimalValue) : Convert.ToInt16(DoubleValue); - } - - sbyte IConvertible.ToSByte(IFormatProvider provider) - { - return IsDecimal ? Convert.ToSByte(DecimalValue) : Convert.ToSByte(DoubleValue); - } - - float IConvertible.ToSingle(IFormatProvider provider) - { - return IsDecimal ? Convert.ToSingle(DecimalValue) : Convert.ToSingle(DoubleValue); - } - - /// Converts the numeric value of this instance to its equivalent string representation using the specified culture-specific format information. - /// An object that supplies culture-specific formatting information. - /// The string representation of the value of this instance as specified by . - public string ToString(IFormatProvider provider) - { - return IsDecimal ? Convert.ToString(DecimalValue, provider) : Convert.ToString(DoubleValue, provider); - } - - ushort IConvertible.ToUInt16(IFormatProvider provider) - { - return IsDecimal ? Convert.ToUInt16(DecimalValue) : Convert.ToUInt16(DoubleValue); - } - - uint IConvertible.ToUInt32(IFormatProvider provider) - { - return IsDecimal ? Convert.ToUInt32(DecimalValue) : Convert.ToUInt32(DoubleValue); - } - - ulong IConvertible.ToUInt64(IFormatProvider provider) - { - return IsDecimal ? Convert.ToUInt64(DecimalValue) : Convert.ToUInt64(DoubleValue); - } - - object IConvertible.ToType(Type conversionType, IFormatProvider provider) - { - return IsDecimal ? ((IConvertible)DecimalValue).ToType(conversionType, provider) : ((IConvertible)DoubleValue).ToType(conversionType, provider); - } - - #endregion - /// /// Describes the underlying type of a . /// - public enum QuantityValueType : byte + public enum UnderlyingDataType : byte { /// must have the value 0 due to the bit structure of . Decimal = 0, diff --git a/UnitsNet/UnitConverter.cs b/UnitsNet/UnitConverter.cs index b7f639f24d..7b5a93eb0f 100644 --- a/UnitsNet/UnitConverter.cs +++ b/UnitsNet/UnitConverter.cs @@ -270,7 +270,7 @@ public bool TryGetConversionFunction(ConversionFunctionLookupKey lookupKey, out /// From unit enum value. /// To unit enum value, must be compatible with . /// The converted value in the new unit representation. - public static QuantityValue Convert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue) + public static double Convert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue) { return Quantity .From(fromValue, fromUnitValue) @@ -285,7 +285,7 @@ public static QuantityValue Convert(QuantityValue fromValue, Enum fromUnitValue, /// To unit enum value, must be compatible with . /// The converted value, if successful. Otherwise default. /// True if successful. - public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue, out QuantityValue convertedValue) + public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum toUnitValue, out double convertedValue) { convertedValue = 0; if (!Quantity.TryFrom(fromValue, fromUnitValue, out IQuantity? fromQuantity)) @@ -331,7 +331,7 @@ public static bool TryConvert(QuantityValue fromValue, Enum fromUnitValue, Enum /// Output value as the result of converting to . /// No units match the abbreviation. /// More than one unit matches the abbreviation. - public static QuantityValue ConvertByName(QuantityValue fromValue, string quantityName, string fromUnit, string toUnit) + public static double ConvertByName(QuantityValue fromValue, string quantityName, string fromUnit, string toUnit) { if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); @@ -380,7 +380,7 @@ public static QuantityValue ConvertByName(QuantityValue fromValue, string quanti /// Result if conversion was successful, 0 if not. /// bool ok = TryConvertByName(5, "Length", "Meter", "Centimeter", out double centimeters); // 500 /// True if conversion was successful. - public static bool TryConvertByName(QuantityValue inputValue, string quantityName, string fromUnit, string toUnit, out QuantityValue result) + public static bool TryConvertByName(QuantityValue inputValue, string quantityName, string fromUnit, string toUnit, out double result) { result = 0d; @@ -423,7 +423,7 @@ public static bool TryConvertByName(QuantityValue inputValue, string quantityNam /// /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// Output value as the result of converting to . - public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) + public static double ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev) { return ConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, null); } @@ -460,7 +460,7 @@ public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, strin /// are mapped to the abbreviation. /// /// More than one unit matches the abbreviation. - public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string? culture) + public static double ConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, string? culture) { if (!TryGetUnitType(quantityName, out Type? unitType)) throw new UnitNotFoundException($"The unit type for the given quantity was not found: {quantityName}"); @@ -501,7 +501,7 @@ public static QuantityValue ConvertByAbbreviation(QuantityValue fromValue, strin /// Result if conversion was successful, 0 if not. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// True if conversion was successful. - public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out QuantityValue result) + public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result) { return TryConvertByAbbreviation(fromValue, quantityName, fromUnitAbbrev, toUnitAbbrev, out result, null); } @@ -534,7 +534,7 @@ public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quan /// Result if conversion was successful, 0 if not. /// double centimeters = ConvertByName(5, "Length", "m", "cm"); // 500 /// True if conversion was successful. - public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out QuantityValue result, + public static bool TryConvertByAbbreviation(QuantityValue fromValue, string quantityName, string fromUnitAbbrev, string toUnitAbbrev, out double result, string? culture) { result = 0d; diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index b69087b62e..d684c77e66 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -17,7 +17,7 @@ public static class UnitMath /// A quantity with a value, such that 0 ≤ value ≤ . public static TQuantity Abs(this TQuantity value) where TQuantity : IQuantity { - return value.Value >= QuantityValue.Zero ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); + return value.Value >= 0 ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); } /// Computes the sum of a sequence of values. @@ -33,7 +33,7 @@ public static TQuantity Abs(this TQuantity value) where TQuantity : I public static TQuantity Sum(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - return (TQuantity) Quantity.From(source.Aggregate(QuantityValue.Zero, (current, quantity) => current + quantity.As(unitType)), unitType); + return (TQuantity) Quantity.From(source.Sum(x => x.As(unitType)), unitType); } /// @@ -172,20 +172,7 @@ public static TQuantity Max(this IEnumerable source public static TQuantity Average(this IEnumerable source, Enum unitType) where TQuantity : IQuantity { - var count = 0; - var total = QuantityValue.Zero; - foreach (var quantity in source) - { - count++; - total += quantity.As(unitType); - } - - if (count == 0) - { - throw new InvalidOperationException($"{nameof(source)} contains no elements."); - } - - return (TQuantity) Quantity.From(total / count, unitType); + return (TQuantity) Quantity.From(source.Average(x => x.As(unitType)), unitType); } /// @@ -210,25 +197,5 @@ public static TQuantity Average(this IEnumerable so { return source.Select(selector).Average(unitType); } - - /// - /// Explicitly create a instance from a double - /// - /// The input value - /// An instance of - public static QuantityValue ToQuantityValue(this double value) - { - return value; // Implicit cast - } - - /// - /// Explicitly create a instance from a decimal - /// - /// The input value - /// An instance of - public static QuantityValue ToQuantityValue(this decimal value) - { - return value; // Implicit cast - } } } From 142a1fb1c574e13a76c550eb38adaada19b448db Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Fri, 2 Sep 2022 23:12:40 +0200 Subject: [PATCH 63/66] =?UTF-8?q?=F0=9F=94=A5=20Remove=20UnitsNet.Serializ?= =?UTF-8?q?ation.JsonNet.CompatibilityTests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The converter it tested no longer exists. --- ...lization.JsonNet.CompatibilityTests.csproj | 32 -- .../UnitsNetJsonConverterTests.cs | 464 ------------------ UnitsNet.sln | 6 - 3 files changed, 502 deletions(-) delete mode 100644 UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj delete mode 100644 UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj deleted file mode 100644 index 8bcee805f8..0000000000 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - - net6.0 - UnitsNet.Serialization.JsonNet.CompatibilityTests - latest - true - - - - - - - - - - - - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - - - - - - diff --git a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs b/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs deleted file mode 100644 index 6775d8769d..0000000000 --- a/UnitsNet.Serialization.JsonNet.CompatibilityTests/UnitsNetJsonConverterTests.cs +++ /dev/null @@ -1,464 +0,0 @@ -// Licensed under MIT No Attribution, see LICENSE file at the root. -// Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. - -using System; -using Newtonsoft.Json; -using Xunit; - -namespace UnitsNet.Serialization.JsonNet.CompatibilityTests -{ - public class UnitsNetJsonConverterTests - { - private readonly JsonSerializerSettings _jsonSerializerSettings; - - protected UnitsNetJsonConverterTests() - { - _jsonSerializerSettings = new JsonSerializerSettings {Formatting = Formatting.Indented}; - _jsonSerializerSettings.Converters.Add(new UnitsNetJsonConverter()); - } - - private string SerializeObject(object obj) - { - return JsonConvert.SerializeObject(obj, _jsonSerializerSettings).Replace("\r\n", "\n"); - } - - private T DeserializeObject(string json) - { - return JsonConvert.DeserializeObject(json, _jsonSerializerSettings); - } - - public class Serialize : UnitsNetJsonConverterTests - { - [Fact] - public void Information_CanSerializeVeryLargeValues() - { - Information i = Information.FromExabytes(1E+9); - var expectedJson = "{\n \"Unit\": \"InformationUnit.Exabyte\",\n \"Value\": 1000000000.0\n}"; - - string json = SerializeObject(i); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void Mass_ExpectConstructedValueAndUnit() - { - Mass mass = Mass.FromPounds(200); - var expectedJson = "{\n \"Unit\": \"MassUnit.Pound\",\n \"Value\": 200.0\n}"; - - string json = SerializeObject(mass); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void Information_ExpectConstructedValueAndUnit() - { - Information quantity = Information.FromKilobytes(54); - var expectedJson = "{\n \"Unit\": \"InformationUnit.Kilobyte\",\n \"Value\": 54.0\n}"; - - string json = SerializeObject(quantity); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void NonNullNullableValue_ExpectJsonUnaffected() - { - Mass? nullableMass = Mass.FromKilograms(10); - var expectedJson = "{\n \"Unit\": \"MassUnit.Kilogram\",\n \"Value\": 10.0\n}"; - - string json = SerializeObject(nullableMass); - - // There shouldn't be any change in the JSON for the non-null nullable value. - Assert.Equal(expectedJson, json); - } - - [Fact] - public void NonNullNullableValueNestedInObject_ExpectJsonUnaffected() - { - var testObj = new TestObj - { - NullableFrequency = Frequency.FromHertz(10), - NonNullableFrequency = Frequency.FromHertz(10) - }; - // Ugly manually formatted JSON string is used because string literals with newlines are rendered differently - // on the build server (i.e. the build server uses '\r' instead of '\n') - string expectedJson = "{\n" + - " \"NullableFrequency\": {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " \"NonNullableFrequency\": {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - "}"; - - string json = SerializeObject(testObj); - - Assert.Equal(expectedJson, json); - } - - [Fact] - public void NullValue_ExpectJsonContainsNullString() - { - string json = SerializeObject(null); - Assert.Equal("null", json); - } - - [Fact] - public void Ratio_ExpectDecimalFractionsUsedAsBaseValueAndUnit() - { - Ratio ratio = Ratio.FromPartsPerThousand(250); - var expectedJson = "{\n \"Unit\": \"RatioUnit.PartPerThousand\",\n \"Value\": 250.0\n}"; - - string json = SerializeObject(ratio); - - Assert.Equal(expectedJson, json); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void ArrayValue_ExpectJsonArray() - { - Frequency[] testObj = new Frequency[] { Frequency.FromHertz(10), Frequency.FromHertz(10) }; - - string expectedJson = "[\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - "]"; - - string json = SerializeObject(testObj); - - Assert.Equal(expectedJson, json); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void EmptyArrayValue_ExpectJsonArray() - { - Frequency[] testObj = { }; - - string expectedJson = "[]"; - - string json = SerializeObject(testObj); - Assert.Equal(expectedJson, json); - } - } - - public class Deserialize : UnitsNetJsonConverterTests - { - [Fact] - public void Information_CanDeserializeVeryLargeValues() - { - Information original = Information.FromExabytes(1E+9); - string json = SerializeObject(original); - var deserialized = DeserializeObject(json); - - Assert.Equal(original, deserialized); - } - - [Fact] - public void Mass_ExpectJsonCorrectlyDeserialized() - { - Mass originalMass = Mass.FromKilograms(33.33); - string json = SerializeObject(originalMass); - - var deserializedMass = DeserializeObject(json); - - Assert.Equal(originalMass, deserializedMass); - } - - [Fact] - public void NonNullNullableValue_ExpectValueDeserializedCorrectly() - { - Mass? nullableMass = Mass.FromKilograms(10); - string json = SerializeObject(nullableMass); - - Mass? deserializedNullableMass = DeserializeObject(json); - - Assert.Equal(nullableMass.Value, deserializedNullableMass); - } - - [Fact] - public void NonNullNullableValueNestedInObject_ExpectValueDeserializedCorrectly() - { - var testObj = new TestObj - { - NullableFrequency = Frequency.FromHertz(10), - NonNullableFrequency = Frequency.FromHertz(10) - }; - string json = SerializeObject(testObj); - - var deserializedTestObj = DeserializeObject(json); - - Assert.Equal(testObj.NullableFrequency, deserializedTestObj.NullableFrequency); - } - - [Fact] - public void NullValue_ExpectNullReturned() - { - string json = SerializeObject(null); - var deserializedNullMass = DeserializeObject(json); - - Assert.Null(deserializedNullMass); - } - - [Fact] - public void NullValueNestedInObject_ExpectValueDeserializedToNullCorrectly() - { - var testObj = new TestObj - { - NullableFrequency = null, - NonNullableFrequency = Frequency.FromHertz(10) - }; - string json = SerializeObject(testObj); - - var deserializedTestObj = DeserializeObject(json); - - Assert.Null(deserializedTestObj.NullableFrequency); - } - - [Fact] - public void UnitEnumChangedAfterSerialization_ExpectUnitCorrectlyDeserialized() - { - Mass originalMass = Mass.FromKilograms(33.33); - string json = SerializeObject(originalMass); - // Someone manually changed the serialized JSON string to 1000 grams. - json = json.Replace("33.33", "1000"); - json = json.Replace("MassUnit.Kilogram", "MassUnit.Gram"); - - var deserializedMass = DeserializeObject(json); - - // The original value serialized was 33.33 kg, but someone edited the JSON to be 1000 g. We expect the JSON is - // still deserializable, and the correct value of 1000 g is obtained. - Assert.Equal(1000, deserializedMass.Grams); - } - - [Fact] - public void UnitInIComparable_ExpectUnitCorrectlyDeserialized() - { - TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() - { - Value = Power.FromWatts(10) - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - - var deserializedTestObject = JsonConvert.DeserializeObject(json,jsonSerializerSettings); - - Assert.Equal(typeof(Power), deserializedTestObject.Value.GetType()); - Assert.Equal(Power.FromWatts(10), (Power)deserializedTestObject.Value); - } - - [Fact] - public void DoubleInIComparable_ExpectUnitCorrectlyDeserialized() - { - TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() - { - Value = 10.0 - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - - var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(double), deserializedTestObject.Value.GetType()); - Assert.Equal(10d, (double)deserializedTestObject.Value); - } - - [Fact] - public void ClassInIComparable_ExpectUnitCorrectlyDeserialized() - { - TestObjWithIComparable testObjWithIComparable = new TestObjWithIComparable() - { - Value = new ComparableClass() { Value = 10 } - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value.GetType()); - Assert.Equal(10d, ((ComparableClass) deserializedTestObject.Value).Value); - } - - [Fact] - public void OtherObjectWithUnitAndValue_ExpectCorrectResturnValues() - { - TestObjWithValueAndUnit testObjWithValueAndUnit = new TestObjWithValueAndUnit() - { - Value = 5, - Unit = "Test", - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithValueAndUnit, jsonSerializerSettings); - TestObjWithValueAndUnit deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(double), deserializedTestObject.Value.GetType()); - Assert.Equal(5d, deserializedTestObject.Value); - Assert.Equal("Test", deserializedTestObject.Unit); - } - - [Fact] - public void ThreeObjectsInIComparableWithDifferentValues_ExpectAllCorrectlyDeserialized() - { - TestObjWithThreeIComparable testObjWithIComparable = new TestObjWithThreeIComparable() - { - Value1 = 10.0, - Value2 = Power.FromWatts(19), - Value3 = new ComparableClass() { Value = 10 }, - }; - JsonSerializerSettings jsonSerializerSettings = CreateJsonSerializerSettings(); - - string json = JsonConvert.SerializeObject(testObjWithIComparable, jsonSerializerSettings); - var deserializedTestObject = JsonConvert.DeserializeObject(json, jsonSerializerSettings); - - Assert.Equal(typeof(double), deserializedTestObject.Value1.GetType()); - Assert.Equal(10d, deserializedTestObject.Value1); - Assert.Equal(typeof(Power), deserializedTestObject.Value2.GetType()); - Assert.Equal(Power.FromWatts(19), deserializedTestObject.Value2); - Assert.Equal(typeof(ComparableClass), deserializedTestObject.Value3.GetType()); - Assert.Equal(testObjWithIComparable.Value3, deserializedTestObject.Value3); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void ArrayOfUnits_ExpectCorrectlyDeserialized() - { - Frequency[] expected = new Frequency[] { Frequency.FromHertz(10), Frequency.FromHertz(10) }; - - string json = "[\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - "]"; - - Frequency[] result = DeserializeObject(json); - - Assert.Equal(expected, result); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void MultiDimArrayOfUnits_ExpectCorrectlyDeserialized() - { - Frequency[,] expected = { { Frequency.FromHertz(10), Frequency.FromHertz(10) }, { Frequency.FromHertz(10), Frequency.FromHertz(10) } }; - - string json = "[\n" + - " [\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - " ],\n" + - " [\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " },\n" + - " {\n" + - " \"Unit\": \"FrequencyUnit.Hertz\",\n" + - " \"Value\": 10.0\n" + - " }\n" + - " ]\n" + - "]"; - - Frequency[,] result = DeserializeObject(json); - - Assert.Equal(expected, result); - } - - [Fact(Skip = "Not supported in older versions of serialization")] - public void EmptyArray_ExpectCorrectlyDeserialized() - { - string json = "[]"; - - Frequency[] result = DeserializeObject(json); - - Assert.Empty(result); - } - - private static JsonSerializerSettings CreateJsonSerializerSettings() - { - var jsonSerializerSettings = new JsonSerializerSettings() - { - Formatting = Formatting.Indented, - TypeNameHandling = TypeNameHandling.Auto - }; - jsonSerializerSettings.Converters.Add(new UnitsNetJsonConverter()); - return jsonSerializerSettings; - } - } - - private class TestObj - { - public Frequency? NullableFrequency { get; set; } - public Frequency NonNullableFrequency { get; set; } - } - - private class TestObjWithValueAndUnit : IComparable - { - public double Value { get; set; } - public string Unit { get; set; } - - public int CompareTo(object obj) - { - return ((IComparable)Value).CompareTo(obj); - } - } - - private class ComparableClass : IComparable - { - public int Value { get; set; } - public int CompareTo(object obj) - { - return ((IComparable)Value).CompareTo(obj); - } - - // Needed for virfying that the deserialized object is the same, should not affect the serilization code - public override bool Equals(object obj) - { - if (obj == null || GetType() != obj.GetType()) - { - return false; - } - return Value.Equals(((ComparableClass)obj).Value); - } - - public override int GetHashCode() - { - return Value.GetHashCode(); - } - } - - private class TestObjWithIComparable - { - public IComparable Value { get; set; } - } - - private class TestObjWithThreeIComparable - { - public IComparable Value1 { get; set; } - - public IComparable Value2 { get; set; } - - public IComparable Value3 { get; set; } - } - } -} diff --git a/UnitsNet.sln b/UnitsNet.sln index 6ae0d3d8b3..6a9d558b59 100644 --- a/UnitsNet.sln +++ b/UnitsNet.sln @@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.Json EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Tests", "UnitsNet.Tests\UnitsNet.Tests.csproj", "{0E3B7567-5DF2-44BD-88DB-CCF050D3F943}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Serialization.JsonNet.CompatibilityTests", "UnitsNet.Serialization.JsonNet.CompatibilityTests\UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj", "{21F2FFAC-BF39-487F-9ADE-37100162F955}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UnitsNet.Benchmark", "UnitsNet.Benchmark\UnitsNet.Benchmark.csproj", "{76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeGen", "CodeGen\CodeGen.csproj", "{078E3D44-4F60-46B3-9099-91A7CBF0B213}" @@ -66,10 +64,6 @@ Global {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Debug|Any CPU.Build.0 = Debug|Any CPU {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.ActiveCfg = Release|Any CPU {0E3B7567-5DF2-44BD-88DB-CCF050D3F943}.Release|Any CPU.Build.0 = Release|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Debug|Any CPU.Build.0 = Debug|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Release|Any CPU.ActiveCfg = Release|Any CPU - {21F2FFAC-BF39-487F-9ADE-37100162F955}.Release|Any CPU.Build.0 = Release|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Debug|Any CPU.Build.0 = Debug|Any CPU {76B9C7C8-E3D3-4FA7-B782-78E4BA1D0AD8}.Release|Any CPU.ActiveCfg = Release|Any CPU From 9bafef0a45dcb81dfaa46fcf93b2800db4cec202 Mon Sep 17 00:00:00 2001 From: Patrick Grawehr Date: Tue, 29 Nov 2022 22:05:26 +0100 Subject: [PATCH 64/66] Return decimal for decimal-based quantities (#1074) Fixes #1058 Return the correct value type for quantities that use `decimal` internally; `Power, Information, BitRate`. - Quantity properties return `decimal` or `double` based on internal value type. - `IQuantity.Value` returns `QuantityValue`, which supports both double and decimal. - `QuantityValue`: Implement IEquality, IComparable, IComparable. Co-authored-by: Andreas Gullberg Larsen --- .../UnitsNetGen/QuantityGenerator.cs | 64 ++++-- .../UnitsNetGen/UnitTestBaseClassGenerator.cs | 8 +- Common/UnitDefinitions/Power.json | 4 +- .../GeneratedCode/Quantities/Power.g.cs | 12 +- .../UnitsNetBaseJsonConverterTest.cs | 2 +- .../UnitsNetIComparableJsonConverterTest.cs | 2 +- .../UnitsNetIQuantityJsonConverterTest.cs | 2 +- .../AbbreviatedUnitsConverter.cs | 2 +- .../UnitsNetBaseJsonConverter.cs | 5 +- UnitsNet.Tests/AssertEx.cs | 18 ++ UnitsNet.Tests/CustomCode/BitRateTests.cs | 52 ++--- UnitsNet.Tests/CustomCode/InformationTests.cs | 52 ++--- UnitsNet.Tests/CustomCode/MassFlowTests.cs | 2 +- UnitsNet.Tests/CustomCode/PowerRatioTests.cs | 5 +- UnitsNet.Tests/CustomCode/PowerTests.cs | 52 ++--- .../CustomCode/SpecificEnergyTests.cs | 2 +- UnitsNet.Tests/CustomQuantities/HowMuch.cs | 2 +- UnitsNet.Tests/DecimalOverloadTests.cs | 2 +- UnitsNet.Tests/DummyIQuantity.cs | 2 +- .../TestsBase/AccelerationTestsBase.g.cs | 2 +- .../TestsBase/AmountOfSubstanceTestsBase.g.cs | 2 +- .../TestsBase/AmplitudeRatioTestsBase.g.cs | 2 +- .../TestsBase/AngleTestsBase.g.cs | 2 +- .../TestsBase/ApparentEnergyTestsBase.g.cs | 2 +- .../TestsBase/ApparentPowerTestsBase.g.cs | 2 +- .../TestsBase/AreaDensityTestsBase.g.cs | 2 +- .../AreaMomentOfInertiaTestsBase.g.cs | 2 +- .../TestsBase/AreaTestsBase.g.cs | 2 +- .../TestsBase/BitRateTestsBase.g.cs | 108 +++++----- ...BrakeSpecificFuelConsumptionTestsBase.g.cs | 2 +- .../TestsBase/CapacitanceTestsBase.g.cs | 2 +- ...oefficientOfThermalExpansionTestsBase.g.cs | 2 +- .../TestsBase/CompressibilityTestsBase.g.cs | 2 +- .../TestsBase/DensityTestsBase.g.cs | 2 +- .../TestsBase/DurationTestsBase.g.cs | 2 +- .../TestsBase/DynamicViscosityTestsBase.g.cs | 2 +- .../ElectricAdmittanceTestsBase.g.cs | 2 +- .../ElectricChargeDensityTestsBase.g.cs | 2 +- .../TestsBase/ElectricChargeTestsBase.g.cs | 2 +- .../ElectricConductanceTestsBase.g.cs | 2 +- .../ElectricConductivityTestsBase.g.cs | 2 +- .../ElectricCurrentDensityTestsBase.g.cs | 2 +- .../ElectricCurrentGradientTestsBase.g.cs | 2 +- .../TestsBase/ElectricCurrentTestsBase.g.cs | 2 +- .../TestsBase/ElectricFieldTestsBase.g.cs | 2 +- .../ElectricInductanceTestsBase.g.cs | 2 +- .../ElectricPotentialAcTestsBase.g.cs | 2 +- .../ElectricPotentialChangeRateTestsBase.g.cs | 2 +- .../ElectricPotentialDcTestsBase.g.cs | 2 +- .../TestsBase/ElectricPotentialTestsBase.g.cs | 2 +- .../ElectricResistanceTestsBase.g.cs | 2 +- .../ElectricResistivityTestsBase.g.cs | 2 +- ...ElectricSurfaceChargeDensityTestsBase.g.cs | 2 +- .../TestsBase/EnergyTestsBase.g.cs | 2 +- .../TestsBase/EntropyTestsBase.g.cs | 2 +- .../TestsBase/ForceChangeRateTestsBase.g.cs | 2 +- .../TestsBase/ForcePerLengthTestsBase.g.cs | 2 +- .../TestsBase/ForceTestsBase.g.cs | 2 +- .../TestsBase/FrequencyTestsBase.g.cs | 2 +- .../TestsBase/FuelEfficiencyTestsBase.g.cs | 2 +- .../TestsBase/HeatFluxTestsBase.g.cs | 2 +- .../HeatTransferCoefficientTestsBase.g.cs | 2 +- .../TestsBase/IlluminanceTestsBase.g.cs | 2 +- .../TestsBase/InformationTestsBase.g.cs | 108 +++++----- .../TestsBase/IrradianceTestsBase.g.cs | 2 +- .../TestsBase/IrradiationTestsBase.g.cs | 2 +- .../TestsBase/JerkTestsBase.g.cs | 2 +- .../KinematicViscosityTestsBase.g.cs | 2 +- .../TestsBase/LapseRateTestsBase.g.cs | 2 +- .../TestsBase/LengthTestsBase.g.cs | 2 +- .../TestsBase/LevelTestsBase.g.cs | 2 +- .../TestsBase/LinearDensityTestsBase.g.cs | 2 +- .../LinearPowerDensityTestsBase.g.cs | 2 +- .../TestsBase/LuminosityTestsBase.g.cs | 2 +- .../TestsBase/LuminousFluxTestsBase.g.cs | 2 +- .../TestsBase/LuminousIntensityTestsBase.g.cs | 2 +- .../TestsBase/MagneticFieldTestsBase.g.cs | 2 +- .../TestsBase/MagneticFluxTestsBase.g.cs | 2 +- .../TestsBase/MagnetizationTestsBase.g.cs | 2 +- .../TestsBase/MassConcentrationTestsBase.g.cs | 2 +- .../TestsBase/MassFlowTestsBase.g.cs | 2 +- .../TestsBase/MassFluxTestsBase.g.cs | 2 +- .../TestsBase/MassFractionTestsBase.g.cs | 2 +- .../MassMomentOfInertiaTestsBase.g.cs | 2 +- .../TestsBase/MassTestsBase.g.cs | 2 +- .../TestsBase/MolarEnergyTestsBase.g.cs | 2 +- .../TestsBase/MolarEntropyTestsBase.g.cs | 2 +- .../TestsBase/MolarMassTestsBase.g.cs | 2 +- .../TestsBase/MolarityTestsBase.g.cs | 2 +- .../TestsBase/PermeabilityTestsBase.g.cs | 2 +- .../TestsBase/PermittivityTestsBase.g.cs | 2 +- .../PorousMediumPermeabilityTestsBase.g.cs | 2 +- .../TestsBase/PowerDensityTestsBase.g.cs | 2 +- .../TestsBase/PowerRatioTestsBase.g.cs | 2 +- .../TestsBase/PowerTestsBase.g.cs | 108 +++++----- .../PressureChangeRateTestsBase.g.cs | 2 +- .../TestsBase/PressureTestsBase.g.cs | 2 +- .../TestsBase/RatioChangeRateTestsBase.g.cs | 2 +- .../TestsBase/RatioTestsBase.g.cs | 2 +- .../TestsBase/ReactiveEnergyTestsBase.g.cs | 2 +- .../TestsBase/ReactivePowerTestsBase.g.cs | 2 +- .../TestsBase/ReciprocalAreaTestsBase.g.cs | 2 +- .../TestsBase/ReciprocalLengthTestsBase.g.cs | 2 +- .../TestsBase/RelativeHumidityTestsBase.g.cs | 2 +- .../RotationalAccelerationTestsBase.g.cs | 2 +- .../TestsBase/RotationalSpeedTestsBase.g.cs | 2 +- ...RotationalStiffnessPerLengthTestsBase.g.cs | 2 +- .../RotationalStiffnessTestsBase.g.cs | 2 +- .../TestsBase/ScalarTestsBase.g.cs | 2 +- .../TestsBase/SolidAngleTestsBase.g.cs | 2 +- .../TestsBase/SpecificEnergyTestsBase.g.cs | 2 +- .../TestsBase/SpecificEntropyTestsBase.g.cs | 2 +- .../SpecificFuelConsumptionTestsBase.g.cs | 2 +- .../TestsBase/SpecificVolumeTestsBase.g.cs | 2 +- .../TestsBase/SpecificWeightTestsBase.g.cs | 2 +- .../TestsBase/SpeedTestsBase.g.cs | 2 +- .../StandardVolumeFlowTestsBase.g.cs | 2 +- .../TemperatureChangeRateTestsBase.g.cs | 2 +- .../TestsBase/TemperatureDeltaTestsBase.g.cs | 2 +- .../TemperatureGradientTestsBase.g.cs | 2 +- .../TestsBase/TemperatureTestsBase.g.cs | 2 +- .../ThermalConductivityTestsBase.g.cs | 2 +- .../TestsBase/ThermalResistanceTestsBase.g.cs | 2 +- .../TestsBase/TorquePerLengthTestsBase.g.cs | 2 +- .../TestsBase/TorqueTestsBase.g.cs | 2 +- .../TestsBase/TurbidityTestsBase.g.cs | 2 +- .../TestsBase/VitaminATestsBase.g.cs | 2 +- .../VolumeConcentrationTestsBase.g.cs | 2 +- .../TestsBase/VolumeFlowPerAreaTestsBase.g.cs | 2 +- .../TestsBase/VolumeFlowTestsBase.g.cs | 2 +- .../TestsBase/VolumePerLengthTestsBase.g.cs | 2 +- .../TestsBase/VolumeTestsBase.g.cs | 2 +- .../VolumetricHeatCapacityTestsBase.g.cs | 2 +- .../WarpingMomentOfInertiaTestsBase.g.cs | 2 +- UnitsNet.Tests/IntOverloadTests.cs | 2 +- UnitsNet.Tests/LongOverloadTests.cs | 2 +- UnitsNet.Tests/UnitConverterTest.cs | 4 +- UnitsNet/Comparison.cs | 112 ++++++++++ .../BrakeSpecificFuelConsumption.extra.cs | 4 +- .../CustomCode/Quantities/MassFlow.extra.cs | 3 +- UnitsNet/CustomCode/Quantities/Power.extra.cs | 29 +-- .../CustomCode/Quantities/PowerRatio.extra.cs | 2 +- .../Quantities/Acceleration.g.cs | 18 +- .../Quantities/AmountOfSubstance.g.cs | 18 +- .../Quantities/AmplitudeRatio.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Angle.g.cs | 18 +- .../Quantities/ApparentEnergy.g.cs | 18 +- .../Quantities/ApparentPower.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Area.g.cs | 18 +- .../GeneratedCode/Quantities/AreaDensity.g.cs | 18 +- .../Quantities/AreaMomentOfInertia.g.cs | 18 +- .../GeneratedCode/Quantities/BitRate.g.cs | 143 ++++++------ .../BrakeSpecificFuelConsumption.g.cs | 18 +- .../GeneratedCode/Quantities/Capacitance.g.cs | 18 +- .../CoefficientOfThermalExpansion.g.cs | 18 +- .../Quantities/Compressibility.g.cs | 18 +- .../GeneratedCode/Quantities/Density.g.cs | 18 +- .../GeneratedCode/Quantities/Duration.g.cs | 18 +- .../Quantities/DynamicViscosity.g.cs | 18 +- .../Quantities/ElectricAdmittance.g.cs | 18 +- .../Quantities/ElectricCharge.g.cs | 18 +- .../Quantities/ElectricChargeDensity.g.cs | 18 +- .../Quantities/ElectricConductance.g.cs | 18 +- .../Quantities/ElectricConductivity.g.cs | 18 +- .../Quantities/ElectricCurrent.g.cs | 18 +- .../Quantities/ElectricCurrentDensity.g.cs | 18 +- .../Quantities/ElectricCurrentGradient.g.cs | 18 +- .../Quantities/ElectricField.g.cs | 18 +- .../Quantities/ElectricInductance.g.cs | 18 +- .../Quantities/ElectricPotential.g.cs | 18 +- .../Quantities/ElectricPotentialAc.g.cs | 18 +- .../ElectricPotentialChangeRate.g.cs | 18 +- .../Quantities/ElectricPotentialDc.g.cs | 18 +- .../Quantities/ElectricResistance.g.cs | 18 +- .../Quantities/ElectricResistivity.g.cs | 18 +- .../ElectricSurfaceChargeDensity.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Energy.g.cs | 18 +- .../GeneratedCode/Quantities/Entropy.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Force.g.cs | 18 +- .../Quantities/ForceChangeRate.g.cs | 18 +- .../Quantities/ForcePerLength.g.cs | 18 +- .../GeneratedCode/Quantities/Frequency.g.cs | 18 +- .../Quantities/FuelEfficiency.g.cs | 18 +- .../GeneratedCode/Quantities/HeatFlux.g.cs | 18 +- .../Quantities/HeatTransferCoefficient.g.cs | 18 +- .../GeneratedCode/Quantities/Illuminance.g.cs | 18 +- .../GeneratedCode/Quantities/Information.g.cs | 143 ++++++------ .../GeneratedCode/Quantities/Irradiance.g.cs | 18 +- .../GeneratedCode/Quantities/Irradiation.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Jerk.g.cs | 18 +- .../Quantities/KinematicViscosity.g.cs | 18 +- .../GeneratedCode/Quantities/LapseRate.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Length.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Level.g.cs | 18 +- .../Quantities/LinearDensity.g.cs | 18 +- .../Quantities/LinearPowerDensity.g.cs | 18 +- .../GeneratedCode/Quantities/Luminosity.g.cs | 18 +- .../Quantities/LuminousFlux.g.cs | 18 +- .../Quantities/LuminousIntensity.g.cs | 18 +- .../Quantities/MagneticField.g.cs | 18 +- .../Quantities/MagneticFlux.g.cs | 18 +- .../Quantities/Magnetization.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Mass.g.cs | 18 +- .../Quantities/MassConcentration.g.cs | 18 +- .../GeneratedCode/Quantities/MassFlow.g.cs | 18 +- .../GeneratedCode/Quantities/MassFlux.g.cs | 18 +- .../Quantities/MassFraction.g.cs | 18 +- .../Quantities/MassMomentOfInertia.g.cs | 18 +- .../GeneratedCode/Quantities/MolarEnergy.g.cs | 18 +- .../Quantities/MolarEntropy.g.cs | 18 +- .../GeneratedCode/Quantities/MolarMass.g.cs | 18 +- .../GeneratedCode/Quantities/Molarity.g.cs | 18 +- .../Quantities/Permeability.g.cs | 18 +- .../Quantities/Permittivity.g.cs | 18 +- .../Quantities/PorousMediumPermeability.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Power.g.cs | 155 ++++++------- .../Quantities/PowerDensity.g.cs | 18 +- .../GeneratedCode/Quantities/PowerRatio.g.cs | 18 +- .../GeneratedCode/Quantities/Pressure.g.cs | 18 +- .../Quantities/PressureChangeRate.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Ratio.g.cs | 18 +- .../Quantities/RatioChangeRate.g.cs | 18 +- .../Quantities/ReactiveEnergy.g.cs | 18 +- .../Quantities/ReactivePower.g.cs | 18 +- .../Quantities/ReciprocalArea.g.cs | 18 +- .../Quantities/ReciprocalLength.g.cs | 18 +- .../Quantities/RelativeHumidity.g.cs | 18 +- .../Quantities/RotationalAcceleration.g.cs | 18 +- .../Quantities/RotationalSpeed.g.cs | 18 +- .../Quantities/RotationalStiffness.g.cs | 18 +- .../RotationalStiffnessPerLength.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Scalar.g.cs | 18 +- .../GeneratedCode/Quantities/SolidAngle.g.cs | 18 +- .../Quantities/SpecificEnergy.g.cs | 18 +- .../Quantities/SpecificEntropy.g.cs | 18 +- .../Quantities/SpecificFuelConsumption.g.cs | 18 +- .../Quantities/SpecificVolume.g.cs | 18 +- .../Quantities/SpecificWeight.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Speed.g.cs | 18 +- .../Quantities/StandardVolumeFlow.g.cs | 18 +- .../GeneratedCode/Quantities/Temperature.g.cs | 18 +- .../Quantities/TemperatureChangeRate.g.cs | 18 +- .../Quantities/TemperatureDelta.g.cs | 18 +- .../Quantities/TemperatureGradient.g.cs | 18 +- .../Quantities/ThermalConductivity.g.cs | 18 +- .../Quantities/ThermalResistance.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Torque.g.cs | 18 +- .../Quantities/TorquePerLength.g.cs | 18 +- .../GeneratedCode/Quantities/Turbidity.g.cs | 18 +- .../GeneratedCode/Quantities/VitaminA.g.cs | 18 +- UnitsNet/GeneratedCode/Quantities/Volume.g.cs | 18 +- .../Quantities/VolumeConcentration.g.cs | 18 +- .../GeneratedCode/Quantities/VolumeFlow.g.cs | 18 +- .../Quantities/VolumeFlowPerArea.g.cs | 18 +- .../Quantities/VolumePerLength.g.cs | 18 +- .../Quantities/VolumetricHeatCapacity.g.cs | 18 +- .../Quantities/WarpingMomentOfInertia.g.cs | 18 +- UnitsNet/IQuantity.cs | 2 +- UnitsNet/QuantityFormatter.cs | 6 +- UnitsNet/QuantityValue.cs | 203 +++++++++++++++++- UnitsNet/UnitMath.cs | 22 +- 261 files changed, 2160 insertions(+), 1526 deletions(-) diff --git a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs index cf48ef7b4d..9ccc1e97c4 100644 --- a/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/QuantityGenerator.cs @@ -262,11 +262,11 @@ private void GenerateProperties() public {_valueType} Value => _value; "); - // Need to provide explicit interface implementation for decimal quantities like Information - if (_quantity.ValueType != "double") - Writer.WL(@" - double IQuantity.Value => (double) _value; + Writer.WL(@" + /// + QuantityValue IQuantity.Value => _value; "); + // Need to provide explicit interface implementation for decimal quantities like Information if (_quantity.ValueType == "decimal") Writer.WL(@" /// @@ -306,11 +306,11 @@ private void GenerateConversionProperties() Writer.WL($@" /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// "); Writer.WLIfText(2, GetObsoleteAttributeOrNull(unit)); Writer.WL($@" - public double {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); + public {_quantity.ValueType} {unit.PluralName} => As({_unitEnumName}.{unit.SingularName}); "); } @@ -651,7 +651,7 @@ private void GenerateArithmeticOperators() }} /// Get ratio value from dividing by . - public static double operator /({_quantity.Name} left, {_quantity.Name} right) + public static {_quantity.ValueType} operator /({_quantity.Name} left, {_quantity.Name} right) {{ return left.{_baseUnit.PluralName} / right.{_baseUnit.PluralName}; }} @@ -806,13 +806,13 @@ public int CompareTo({_quantity.Name} other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals({_quantity.Name} other, double tolerance, ComparisonType comparisonType) + public bool Equals({_quantity.Name} other, {_quantity.ValueType} tolerance, ComparisonType comparisonType) {{ if (tolerance < 0) throw new ArgumentOutOfRangeException(""tolerance"", ""Tolerance must be greater than or equal to 0.""); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + {_quantity.ValueType} thisValue = this.Value; + {_quantity.ValueType} otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); }} @@ -839,17 +839,30 @@ private void GenerateConversionMethods() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As({_unitEnumName} unit) + public {_quantity.ValueType} As({_unitEnumName} unit) {{ if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + }} +"); - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + if (_quantity.ValueType == "decimal") + { + Writer.WL($@" + + double IQuantity<{_unitEnumName}>.As({_unitEnumName} unit) + {{ + return (double)As(unit); }} +"); + } + + Writer.WL($@" /// - public double As(UnitSystem unitSystem) + public {_quantity.ValueType} As(UnitSystem unitSystem) {{ if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -862,14 +875,27 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); }} +"); + + if (_quantity.ValueType == "decimal") + { + Writer.WL($@" + /// + double IQuantity.As(UnitSystem unitSystem) + {{ + return (double)As(unitSystem); + }} +"); + } + Writer.WL($@" /// double IQuantity.As(Enum unit) {{ - if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) + if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return As(unitAs{_unitEnumName}); + return (double)As(typedUnit); }} /// @@ -916,10 +942,10 @@ double IQuantity.As(Enum unit) /// IQuantity IQuantity.ToUnit(Enum unit) {{ - if (!(unit is {_unitEnumName} unitAs{_unitEnumName})) + if (!(unit is {_unitEnumName} typedUnit)) throw new ArgumentException($""The given unit is of type {{unit.GetType()}}. Only {{typeof({_unitEnumName})}} is supported."", nameof(unit)); - return ToUnit(unitAs{_unitEnumName}, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); }} /// diff --git a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs index b9a4f2db68..ee1518171a 100644 --- a/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs +++ b/CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs @@ -102,7 +102,7 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected abstract double {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); + protected abstract {_quantity.ValueType} {unit.PluralName}InOne{_baseUnit.SingularName} {{ get; }}"); } Writer.WL(""); @@ -114,12 +114,12 @@ public abstract partial class {_quantity.Name}TestsBase : QuantityTestsBase continue; Writer.WL($@" - protected virtual double {unit.PluralName}Tolerance {{ get {{ return 1e-5; }} }}"); + protected virtual {_quantity.ValueType} {unit.PluralName}Tolerance {{ get {{ return { (_quantity.ValueType == "decimal" ? "1e-9m" : "1e-5") }; }} }}"); } Writer.WL($@" // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor({_unitEnumName} unit) + protected ({_quantity.ValueType} UnitsInBaseUnit, {_quantity.ValueType} Tolerence) GetConversionFactor({_unitEnumName} unit) {{ return unit switch {{"); @@ -355,7 +355,7 @@ public void ToUnit({_unitEnumName} unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); }} diff --git a/Common/UnitDefinitions/Power.json b/Common/UnitDefinitions/Power.json index 89f98458eb..ce491fa507 100644 --- a/Common/UnitDefinitions/Power.json +++ b/Common/UnitDefinitions/Power.json @@ -85,8 +85,8 @@ { "SingularName": "BritishThermalUnitPerHour", "PluralName": "BritishThermalUnitsPerHour", - "FromUnitToBaseFunc": "{x} * 0.293071m", - "FromBaseToUnitFunc": "{x} / 0.293071m", + "FromUnitToBaseFunc": "{x} * 0.29307107017m", + "FromBaseToUnitFunc": "{x} / 0.29307107017m", "Prefixes": [ "Kilo", "Mega" ], "Localization": [ { diff --git a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs index 5c25292799..e10cb3d208 100644 --- a/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet.NanoFramework/GeneratedCode/Quantities/Power.g.cs @@ -410,7 +410,7 @@ private double GetValueInBaseUnit() return Unit switch { PowerUnit.BoilerHorsepower => _value * 9812.5d, - PowerUnit.BritishThermalUnitPerHour => _value * 0.293071d, + PowerUnit.BritishThermalUnitPerHour => _value * 0.29307107017d, PowerUnit.Decawatt => (_value) * 1e1d, PowerUnit.Deciwatt => (_value) * 1e-1d, PowerUnit.ElectricalHorsepower => _value * 746d, @@ -419,11 +419,11 @@ private double GetValueInBaseUnit() PowerUnit.Gigawatt => (_value) * 1e9d, PowerUnit.HydraulicHorsepower => _value * 745.69988145d, PowerUnit.JoulePerHour => _value / 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.293071d) * 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e3d, PowerUnit.KilojoulePerHour => (_value / 3600d) * 1e3d, PowerUnit.Kilowatt => (_value) * 1e3d, PowerUnit.MechanicalHorsepower => _value * 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.293071d) * 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (_value * 0.29307107017d) * 1e6d, PowerUnit.MegajoulePerHour => (_value / 3600d) * 1e6d, PowerUnit.Megawatt => (_value) * 1e6d, PowerUnit.MetricHorsepower => _value * 735.49875d, @@ -449,7 +449,7 @@ private double GetValueAs(PowerUnit unit) return unit switch { PowerUnit.BoilerHorsepower => baseUnitValue / 9812.5d, - PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.293071d, + PowerUnit.BritishThermalUnitPerHour => baseUnitValue / 0.29307107017d, PowerUnit.Decawatt => (baseUnitValue) / 1e1d, PowerUnit.Deciwatt => (baseUnitValue) / 1e-1d, PowerUnit.ElectricalHorsepower => baseUnitValue / 746d, @@ -458,11 +458,11 @@ private double GetValueAs(PowerUnit unit) PowerUnit.Gigawatt => (baseUnitValue) / 1e9d, PowerUnit.HydraulicHorsepower => baseUnitValue / 745.69988145d, PowerUnit.JoulePerHour => baseUnitValue * 3600d, - PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e3d, + PowerUnit.KilobritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e3d, PowerUnit.KilojoulePerHour => (baseUnitValue * 3600d) / 1e3d, PowerUnit.Kilowatt => (baseUnitValue) / 1e3d, PowerUnit.MechanicalHorsepower => baseUnitValue / 745.69d, - PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.293071d) / 1e6d, + PowerUnit.MegabritishThermalUnitPerHour => (baseUnitValue / 0.29307107017d) / 1e6d, PowerUnit.MegajoulePerHour => (baseUnitValue * 3600d) / 1e6d, PowerUnit.Megawatt => (baseUnitValue) / 1e6d, PowerUnit.MetricHorsepower => baseUnitValue / 735.49875d, diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs index 9aa3d59239..76e82be109 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetBaseJsonConverterTest.cs @@ -54,7 +54,7 @@ public void UnitsNetBaseJsonConverter_ConvertValueUnit_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5, ComparisonType.Absolute)); + Assert.True(Power.FromWatts(10.2365m).Equals((Power)result, 1E-5m, ComparisonType.Absolute)); } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs index f8053607da..bbe5522852 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIComparableJsonConverterTest.cs @@ -117,7 +117,7 @@ public void UnitsNetIComparableJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(120D, ((Power)result).Watts); + Assert.Equal(120M, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs index ea87af940d..8ed7de7c29 100644 --- a/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs +++ b/UnitsNet.Serialization.JsonNet.Tests/UnitsNetIQuantityJsonConverterTest.cs @@ -135,7 +135,7 @@ public void UnitsNetIQuantityJsonConverter_ReadJson_works_as_expected() Assert.NotNull(result); Assert.IsType(result); - Assert.Equal(10.3654D, ((Power)result).Watts); + Assert.Equal(10.3654M, ((Power)result).Watts); } } } diff --git a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs index b7a150b944..2b89bee8df 100644 --- a/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs +++ b/UnitsNet.Serialization.JsonNet/AbbreviatedUnitsConverter.cs @@ -85,7 +85,7 @@ public override void WriteJson(JsonWriter writer, IQuantity? quantity, JsonSeria } else { - writer.WriteValue(quantity.Value); + writer.WriteValue((double)quantity.Value); } // write the 'Unit' abbreviation diff --git a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs index 2e804182c7..3373b27b26 100644 --- a/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs +++ b/UnitsNet.Serialization.JsonNet/UnitsNetBaseJsonConverter.cs @@ -186,13 +186,14 @@ protected ValueUnit ConvertIQuantity(IQuantity quantity) return new ExtendedValueUnit { Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}", - Value = quantity.Value, + // The type of "Value" is still double + Value = (double)quantity.Value, ValueString = d.Value.ToString(CultureInfo.InvariantCulture), ValueType = "decimal" }; } - return new ValueUnit {Value = quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; + return new ValueUnit {Value = (double)quantity.Value, Unit = $"{quantity.QuantityInfo.UnitType.Name}.{quantity.Unit}"}; } /// diff --git a/UnitsNet.Tests/AssertEx.cs b/UnitsNet.Tests/AssertEx.cs index d052adfeec..229e4324e7 100644 --- a/UnitsNet.Tests/AssertEx.cs +++ b/UnitsNet.Tests/AssertEx.cs @@ -25,5 +25,23 @@ public static void EqualTolerance(double expected, double actual, double toleran Assert.True( areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}" ); } } + + public static void EqualTolerance(decimal expected, decimal actual, decimal tolerance, ComparisonType comparisonType = ComparisonType.Relative) + { + if (comparisonType == ComparisonType.Relative) + { + bool areEqual = Comparison.EqualsRelative(expected, actual, tolerance); + + decimal difference = Math.Abs(expected - actual); + decimal relativeDifference = difference / expected; + + Assert.True(areEqual, $"Values are not equal within relative tolerance: {tolerance:P4}\nExpected: {expected}\nActual: {actual}\nDiff: {relativeDifference:P4}"); + } + else if (comparisonType == ComparisonType.Absolute) + { + bool areEqual = Comparison.EqualsAbsolute(expected, actual, tolerance); + Assert.True(areEqual, $"Values are not equal within absolute tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}"); + } + } } } diff --git a/UnitsNet.Tests/CustomCode/BitRateTests.cs b/UnitsNet.Tests/CustomCode/BitRateTests.cs index 2afe11ae27..5e49dc8ad3 100644 --- a/UnitsNet.Tests/CustomCode/BitRateTests.cs +++ b/UnitsNet.Tests/CustomCode/BitRateTests.cs @@ -29,37 +29,37 @@ public class BitRateTests : BitRateTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double BitsPerSecondInOneBitPerSecond => 1d; - protected override double BytesPerSecondInOneBitPerSecond => 1.25E-1d; + protected override decimal BitsPerSecondInOneBitPerSecond => 1m; + protected override decimal BytesPerSecondInOneBitPerSecond => 1.25E-1m; - protected override double KilobitsPerSecondInOneBitPerSecond => 1E-3d; - protected override double KilobytesPerSecondInOneBitPerSecond => 1.25E-4d; - protected override double KibibitsPerSecondInOneBitPerSecond => 0.0009765625d; - protected override double KibibytesPerSecondInOneBitPerSecond => 0.0001220703125d; + protected override decimal KilobitsPerSecondInOneBitPerSecond => 1E-3m; + protected override decimal KilobytesPerSecondInOneBitPerSecond => 1.25E-4m; + protected override decimal KibibitsPerSecondInOneBitPerSecond => 0.0009765625m; + protected override decimal KibibytesPerSecondInOneBitPerSecond => 0.0001220703125m; - protected override double MegabitsPerSecondInOneBitPerSecond => 1E-6d; - protected override double MegabytesPerSecondInOneBitPerSecond => 1.25E-07d; - protected override double MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07d; - protected override double MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07d; + protected override decimal MegabitsPerSecondInOneBitPerSecond => 1E-6m; + protected override decimal MegabytesPerSecondInOneBitPerSecond => 1.25E-07m; + protected override decimal MebibitsPerSecondInOneBitPerSecond => 9.5367431640625E-07m; + protected override decimal MebibytesPerSecondInOneBitPerSecond => 1.19209289550781E-07m; - protected override double GigabitsPerSecondInOneBitPerSecond => 1E-9d; - protected override double GigabytesPerSecondInOneBitPerSecond => 1.25E-10d; - protected override double GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10d; - protected override double GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10d; + protected override decimal GigabitsPerSecondInOneBitPerSecond => 1E-9m; + protected override decimal GigabytesPerSecondInOneBitPerSecond => 1.25E-10m; + protected override decimal GibibitsPerSecondInOneBitPerSecond => 9.31322574615479E-10m; + protected override decimal GibibytesPerSecondInOneBitPerSecond => 1.16415321826935E-10m; - protected override double TerabitsPerSecondInOneBitPerSecond => 1E-12d; - protected override double TerabytesPerSecondInOneBitPerSecond => 1.25E-13d; - protected override double TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13d; - protected override double TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13d; + protected override decimal TerabitsPerSecondInOneBitPerSecond => 1E-12m; + protected override decimal TerabytesPerSecondInOneBitPerSecond => 1.25E-13m; + protected override decimal TebibitsPerSecondInOneBitPerSecond => 9.09494701772928E-13m; + protected override decimal TebibytesPerSecondInOneBitPerSecond => 1.13686837721616E-13m; - protected override double PetabitsPerSecondInOneBitPerSecond => 1E-15d; - protected override double PetabytesPerSecondInOneBitPerSecond => 1.25E-16d; - protected override double PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16d; - protected override double PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16d; + protected override decimal PetabitsPerSecondInOneBitPerSecond => 1E-15m; + protected override decimal PetabytesPerSecondInOneBitPerSecond => 1.25E-16m; + protected override decimal PebibitsPerSecondInOneBitPerSecond => 8.88178419700125E-16m; + protected override decimal PebibytesPerSecondInOneBitPerSecond => 1.11022302462516E-16m; - protected override double ExabitsPerSecondInOneBitPerSecond => 1E-18d; - protected override double ExabytesPerSecondInOneBitPerSecond => 1.25E-19d; - protected override double ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19d; - protected override double ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19d; + protected override decimal ExabitsPerSecondInOneBitPerSecond => 1E-18m; + protected override decimal ExabytesPerSecondInOneBitPerSecond => 1.25E-19m; + protected override decimal ExbibitsPerSecondInOneBitPerSecond => 8.67361738E-19m; + protected override decimal ExbibytesPerSecondInOneBitPerSecond => 1.0842021724855E-19m; } } diff --git a/UnitsNet.Tests/CustomCode/InformationTests.cs b/UnitsNet.Tests/CustomCode/InformationTests.cs index dc0dbfd879..4e2b1fa474 100644 --- a/UnitsNet.Tests/CustomCode/InformationTests.cs +++ b/UnitsNet.Tests/CustomCode/InformationTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class InformationTests : InformationTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double BitsInOneBit => 1d; + protected override decimal BitsInOneBit => 1m; - protected override double BytesInOneBit => 0.125d; + protected override decimal BytesInOneBit => 0.125m; - protected override double ExabitsInOneBit => 1e-18d; + protected override decimal ExabitsInOneBit => 1e-18m; - protected override double ExabytesInOneBit => 0.125d*1e-18d; + protected override decimal ExabytesInOneBit => 0.125m*1e-18m; - protected override double ExbibitsInOneBit => 1d/Math.Pow(1024, 6); + protected override decimal ExbibitsInOneBit => 1m/(decimal)Math.Pow(1024, 6); - protected override double ExbibytesInOneBit => 1/8d/Math.Pow(1024, 6); + protected override decimal ExbibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 6); - protected override double GibibitsInOneBit => 1d/Math.Pow(1024, 3); + protected override decimal GibibitsInOneBit => 1m/(decimal)Math.Pow(1024, 3); - protected override double GibibytesInOneBit => 1d/8/Math.Pow(1024, 3); + protected override decimal GibibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 3); - protected override double GigabitsInOneBit => 1e-9d; + protected override decimal GigabitsInOneBit => 1e-9m; - protected override double GigabytesInOneBit => 0.125d*1e-9d; + protected override decimal GigabytesInOneBit => 0.125m*1e-9m; - protected override double KibibitsInOneBit => 1d/1024d; + protected override decimal KibibitsInOneBit => 1m/1024m; - protected override double KibibytesInOneBit => 1d/8/1024d; + protected override decimal KibibytesInOneBit => 1m/8/1024m; - protected override double KilobitsInOneBit => 0.001d; + protected override decimal KilobitsInOneBit => 0.001m; - protected override double KilobytesInOneBit => 0.000125d; + protected override decimal KilobytesInOneBit => 0.000125m; - protected override double MebibitsInOneBit => 1d/Math.Pow(1024, 2); + protected override decimal MebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 2); - protected override double MebibytesInOneBit => 1d/8/Math.Pow(1024, 2); + protected override decimal MebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 2); - protected override double MegabitsInOneBit => 1e-6d; + protected override decimal MegabitsInOneBit => 1e-6m; - protected override double MegabytesInOneBit => 0.125d*1e-6d; + protected override decimal MegabytesInOneBit => 0.125m*1e-6m; - protected override double PebibitsInOneBit => 1d/Math.Pow(1024, 5); + protected override decimal PebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 5); - protected override double PebibytesInOneBit => 1d/8/Math.Pow(1024, 5); + protected override decimal PebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 5); - protected override double PetabitsInOneBit => 1e-15d; + protected override decimal PetabitsInOneBit => 1e-15m; - protected override double PetabytesInOneBit => 0.125d*1e-15d; + protected override decimal PetabytesInOneBit => 0.125m*1e-15m; - protected override double TebibitsInOneBit => 1d/Math.Pow(1024, 4); + protected override decimal TebibitsInOneBit => 1m/(decimal)Math.Pow(1024, 4); - protected override double TebibytesInOneBit => 1d/8/Math.Pow(1024, 4); + protected override decimal TebibytesInOneBit => 1m/8m/(decimal)Math.Pow(1024, 4); - protected override double TerabitsInOneBit => 1e-12d; + protected override decimal TerabitsInOneBit => 1e-12m; - protected override double TerabytesInOneBit => 0.125d*1e-12d; + protected override decimal TerabytesInOneBit => 0.125m*1e-12m; [Fact] public void OneKBHas1000Bytes() diff --git a/UnitsNet.Tests/CustomCode/MassFlowTests.cs b/UnitsNet.Tests/CustomCode/MassFlowTests.cs index 9d7cb97f2d..711f82b28d 100644 --- a/UnitsNet.Tests/CustomCode/MassFlowTests.cs +++ b/UnitsNet.Tests/CustomCode/MassFlowTests.cs @@ -108,7 +108,7 @@ public void TimeSpanTimesMassFlowEqualsMass() public void MassFlowDividedByBrakeSpecificFuelConsumptionEqualsPower() { Power power = MassFlow.FromTonnesPerDay(20) / BrakeSpecificFuelConsumption.FromGramsPerKiloWattHour(180.0); - Assert.Equal(20.0 / 24.0 * 1e6 / 180.0, power.Kilowatts); + AssertEx.EqualTolerance(20.0m / 24.0m * 1e6m / 180.0m, power.Kilowatts, 1E-11m); } [Fact] diff --git a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs index e6820ea023..7e149043e6 100644 --- a/UnitsNet.Tests/CustomCode/PowerRatioTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerRatioTests.cs @@ -46,6 +46,7 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) } [Theory] + // Note: Attribute arguments cannot be of type decimal. [InlineData(-20, 0.01)] [InlineData(-10, 0.1)] [InlineData(0, 1)] @@ -54,8 +55,8 @@ public void ExpectPowerConvertedCorrectly(double power, double expected) public void ExpectPowerRatioConvertedCorrectly(double powerRatio, double expected) { PowerRatio pr = PowerRatio.FromDecibelWatts(powerRatio); - double actual = pr.ToPower().Watts; - Assert.Equal(expected, actual); + decimal actual = pr.ToPower().Watts; + Assert.Equal((decimal)expected, actual); } // http://www.maximintegrated.com/en/app-notes/index.mvp/id/808 diff --git a/UnitsNet.Tests/CustomCode/PowerTests.cs b/UnitsNet.Tests/CustomCode/PowerTests.cs index b965e8fa83..8161a50849 100644 --- a/UnitsNet.Tests/CustomCode/PowerTests.cs +++ b/UnitsNet.Tests/CustomCode/PowerTests.cs @@ -9,57 +9,57 @@ namespace UnitsNet.Tests.CustomCode public class PowerTests : PowerTestsBase { protected override bool SupportsSIUnitSystem => false; - protected override double FemtowattsInOneWatt => 1e15; + protected override decimal FemtowattsInOneWatt => 1e15m; - protected override double GigajoulesPerHourInOneWatt => 3600e-9; + protected override decimal GigajoulesPerHourInOneWatt => 3600e-9m; - protected override double PicowattsInOneWatt => 1e12; + protected override decimal PicowattsInOneWatt => 1e12m; - protected override double NanowattsInOneWatt => 1e9; + protected override decimal NanowattsInOneWatt => 1e9m; - protected override double MicrowattsInOneWatt => 1e6; + protected override decimal MicrowattsInOneWatt => 1e6m; - protected override double MillijoulesPerHourInOneWatt => 3600e3; + protected override decimal MillijoulesPerHourInOneWatt => 3600e3m; - protected override double MilliwattsInOneWatt => 1e3; + protected override decimal MilliwattsInOneWatt => 1e3m; - protected override double DeciwattsInOneWatt => 1e1; + protected override decimal DeciwattsInOneWatt => 1e1m; - protected override double WattsInOneWatt => 1; + protected override decimal WattsInOneWatt => 1; - protected override double DecawattsInOneWatt => 1e-1; + protected override decimal DecawattsInOneWatt => 1e-1m; - protected override double KilojoulesPerHourInOneWatt => 3600e-3; + protected override decimal KilojoulesPerHourInOneWatt => 3600e-3m; - protected override double KilowattsInOneWatt => 1e-3; + protected override decimal KilowattsInOneWatt => 1e-3m; - protected override double MegajoulesPerHourInOneWatt => 3600e-6; + protected override decimal MegajoulesPerHourInOneWatt => 3600e-6m; - protected override double MegawattsInOneWatt => 1e-6; + protected override decimal MegawattsInOneWatt => 1e-6m; - protected override double GigawattsInOneWatt => 1e-9; + protected override decimal GigawattsInOneWatt => 1e-9m; - protected override double TerawattsInOneWatt => 1e-12; + protected override decimal TerawattsInOneWatt => 1e-12m; - protected override double PetawattsInOneWatt => 1e-15; + protected override decimal PetawattsInOneWatt => 1e-15m; - protected override double JoulesPerHourInOneWatt => 3600; + protected override decimal JoulesPerHourInOneWatt => 3600; - protected override double KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3; + protected override decimal KilobritishThermalUnitsPerHourInOneWatt => 3.412141633e-3m; - protected override double MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6; + protected override decimal BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4m; - protected override double BoilerHorsepowerInOneWatt => 1.0191082802547770700636942675159e-4; + protected override decimal MegabritishThermalUnitsPerHourInOneWatt => 3.412141633e-6m; - protected override double BritishThermalUnitsPerHourInOneWatt => 3.412141633; + protected override decimal BritishThermalUnitsPerHourInOneWatt => 3.412141633m; - protected override double ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279; + protected override decimal ElectricalHorsepowerInOneWatt => 0.00134048257372654155495978552279m; - protected override double HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719; + protected override decimal HydraulicHorsepowerInOneWatt => 0.00134102207184949258114167291719m; - protected override double MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992; + protected override decimal MechanicalHorsepowerInOneWatt => 0.00134103984229371454625916935992m; - protected override double MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425; + protected override decimal MetricHorsepowerInOneWatt => 0.00135962161730390432342679032425m; [Fact] public void DurationTimesPowerEqualsEnergy() diff --git a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs index 15fb16bb45..ae3ed730c5 100644 --- a/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs +++ b/UnitsNet.Tests/CustomCode/SpecificEnergyTests.cs @@ -70,7 +70,7 @@ public void DoubleDividedBySpecificEnergyEqualsBrakeSpecificFuelConsumption() public void SpecificEnergyTimesMassFlowEqualsPower() { Power power = SpecificEnergy.FromJoulesPerKilogram(10.0) * MassFlow.FromKilogramsPerSecond(20.0); - Assert.Equal(200d, power.Watts); + Assert.Equal(200m, power.Watts); } [Fact] diff --git a/UnitsNet.Tests/CustomQuantities/HowMuch.cs b/UnitsNet.Tests/CustomQuantities/HowMuch.cs index cafdfc75ae..908caecfa9 100644 --- a/UnitsNet.Tests/CustomQuantities/HowMuch.cs +++ b/UnitsNet.Tests/CustomQuantities/HowMuch.cs @@ -17,7 +17,7 @@ public HowMuch(double value, HowMuchUnit unit) Enum IQuantity.Unit => Unit; public HowMuchUnit Unit { get; } - public double Value { get; } + public QuantityValue Value { get; } #region IQuantity diff --git a/UnitsNet.Tests/DecimalOverloadTests.cs b/UnitsNet.Tests/DecimalOverloadTests.cs index 841c9b162b..6b9842d0aa 100644 --- a/UnitsNet.Tests/DecimalOverloadTests.cs +++ b/UnitsNet.Tests/DecimalOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromDecimalReturnsCorre public static void CreatingQuantityWithDecimalBackingFieldFromDecimalReturnsCorrectValue() { Power power = Power.FromWatts(1m); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/DummyIQuantity.cs b/UnitsNet.Tests/DummyIQuantity.cs index cda0f506b1..bd9f57c2e7 100644 --- a/UnitsNet.Tests/DummyIQuantity.cs +++ b/UnitsNet.Tests/DummyIQuantity.cs @@ -11,7 +11,7 @@ internal class DummyIQuantity : IQuantity public Enum Unit => throw new NotImplementedException(); - public double Value => throw new NotImplementedException(); + public QuantityValue Value => throw new NotImplementedException(); public double As(Enum unit ) => throw new NotImplementedException(); diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs index f70180cba6..8eef770a85 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs @@ -997,7 +997,7 @@ public void ToUnit(AccelerationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs index 52cc5fa708..b3d7ce944d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs @@ -673,7 +673,7 @@ public void ToUnit(AmountOfSubstanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs index 53181b282b..cfb79be1be 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(AmplitudeRatioUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs index b6f83dd254..fd9a87d4a0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs @@ -1257,7 +1257,7 @@ public void ToUnit(AngleUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs index e84c7b0aad..ed4d2b7afd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentEnergyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ApparentEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs index b650b9bcd9..809450eef1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ApparentPowerTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ApparentPowerUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs index a9585c99c0..020dba5491 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(AreaDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs index 2321a0aadf..f9518f3a59 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs @@ -533,7 +533,7 @@ public void ToUnit(AreaMomentOfInertiaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs index 39bffa73de..dae06225f0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs @@ -1287,7 +1287,7 @@ public void ToUnit(AreaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs index a26e942ea8..25db4265bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class BitRateTestsBase : QuantityTestsBase { - protected abstract double BitsPerSecondInOneBitPerSecond { get; } - protected abstract double BytesPerSecondInOneBitPerSecond { get; } - protected abstract double ExabitsPerSecondInOneBitPerSecond { get; } - protected abstract double ExabytesPerSecondInOneBitPerSecond { get; } - protected abstract double ExbibitsPerSecondInOneBitPerSecond { get; } - protected abstract double ExbibytesPerSecondInOneBitPerSecond { get; } - protected abstract double GibibitsPerSecondInOneBitPerSecond { get; } - protected abstract double GibibytesPerSecondInOneBitPerSecond { get; } - protected abstract double GigabitsPerSecondInOneBitPerSecond { get; } - protected abstract double GigabytesPerSecondInOneBitPerSecond { get; } - protected abstract double KibibitsPerSecondInOneBitPerSecond { get; } - protected abstract double KibibytesPerSecondInOneBitPerSecond { get; } - protected abstract double KilobitsPerSecondInOneBitPerSecond { get; } - protected abstract double KilobytesPerSecondInOneBitPerSecond { get; } - protected abstract double MebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double MebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double MegabitsPerSecondInOneBitPerSecond { get; } - protected abstract double MegabytesPerSecondInOneBitPerSecond { get; } - protected abstract double PebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double PebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double PetabitsPerSecondInOneBitPerSecond { get; } - protected abstract double PetabytesPerSecondInOneBitPerSecond { get; } - protected abstract double TebibitsPerSecondInOneBitPerSecond { get; } - protected abstract double TebibytesPerSecondInOneBitPerSecond { get; } - protected abstract double TerabitsPerSecondInOneBitPerSecond { get; } - protected abstract double TerabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal BitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal BytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExbibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal ExbibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal GibibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal GibibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal GigabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal GigabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal KibibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal KibibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal KilobitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal KilobytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal MebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal MebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal MegabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal MegabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal PebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal PebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal PetabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal PetabytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal TebibitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal TebibytesPerSecondInOneBitPerSecond { get; } + protected abstract decimal TerabitsPerSecondInOneBitPerSecond { get; } + protected abstract decimal TerabytesPerSecondInOneBitPerSecond { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double BytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExbibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double ExbibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double GibibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GibibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double GigabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double GigabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KibibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KibibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilobitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double KilobytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double MegabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double PebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double PetabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double PetabytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double TebibitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double TebibytesPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerabitsPerSecondTolerance { get { return 1e-5; } } - protected virtual double TerabytesPerSecondTolerance { get { return 1e-5; } } + protected virtual decimal BitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal BytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GibibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GibibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GigabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal GigabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KibibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KibibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KilobitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal KilobytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MebibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MebibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MegabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal MegabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PebibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PebibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PetabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal PetabytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TebibitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TebibytesPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TerabitsPerSecondTolerance { get { return 1e-9m; } } + protected virtual decimal TerabytesPerSecondTolerance { get { return 1e-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(BitRateUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(BitRateUnit unit) { return unit switch { @@ -1356,7 +1356,7 @@ public void ToUnit(BitRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs index 6e1bc6b653..0eee9d0e6b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/BrakeSpecificFuelConsumptionTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(BrakeSpecificFuelConsumptionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs index e6d03a76dc..168173d243 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CapacitanceTestsBase.g.cs @@ -401,7 +401,7 @@ public void ToUnit(CapacitanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs index 01b59f24d5..ee0a57c7d0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CoefficientOfThermalExpansionTestsBase.g.cs @@ -359,7 +359,7 @@ public void ToUnit(CoefficientOfThermalExpansionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs index aaf1331202..be84c575bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/CompressibilityTestsBase.g.cs @@ -591,7 +591,7 @@ public void ToUnit(CompressibilityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs index a37f498d85..3d84283c65 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DensityTestsBase.g.cs @@ -2015,7 +2015,7 @@ public void ToUnit(DensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs index 528fb07f8f..bfbec85a10 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DurationTestsBase.g.cs @@ -1735,7 +1735,7 @@ public void ToUnit(DurationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs index ee6a1a3d95..4297704cce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/DynamicViscosityTestsBase.g.cs @@ -597,7 +597,7 @@ public void ToUnit(DynamicViscosityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs index baf2955386..2f22972766 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricAdmittanceTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ElectricAdmittanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs index e5f237ac25..00774b96c6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeDensityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(ElectricChargeDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs index ffd6b25293..129bb0072d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricChargeTestsBase.g.cs @@ -407,7 +407,7 @@ public void ToUnit(ElectricChargeUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs index d7e199bded..27d6252268 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductanceTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricConductanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs index 1819849908..657dbdb8ea 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricConductivityTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricConductivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs index 8269cdcded..332b351ae0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentDensityTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricCurrentDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs index 415f793b1c..5ebdc99523 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentGradientTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ElectricCurrentGradientUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs index 14be5a3b96..aecbe2fe1b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricCurrentTestsBase.g.cs @@ -435,7 +435,7 @@ public void ToUnit(ElectricCurrentUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs index e75dc3285b..6cf1a78d49 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricFieldTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(ElectricFieldUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs index b436a94c0d..f0e881a9e2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricInductanceTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ElectricInductanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs index 54413cf013..d5cf5e1273 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialAcTestsBase.g.cs @@ -333,7 +333,7 @@ public void ToUnit(ElectricPotentialAcUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs index 11f38843a9..834da37404 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialChangeRateTestsBase.g.cs @@ -777,7 +777,7 @@ public void ToUnit(ElectricPotentialChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs index d7b84a15dc..943eb1600b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialDcTestsBase.g.cs @@ -333,7 +333,7 @@ public void ToUnit(ElectricPotentialDcUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs index 85c888287a..3b3c5e5b77 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricPotentialTestsBase.g.cs @@ -431,7 +431,7 @@ public void ToUnit(ElectricPotentialUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs index 2f5ab2b600..e3e67b0899 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistanceTestsBase.g.cs @@ -367,7 +367,7 @@ public void ToUnit(ElectricResistanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs index 061188ed83..b79c19a2a9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricResistivityTestsBase.g.cs @@ -617,7 +617,7 @@ public void ToUnit(ElectricResistivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs index 50650f67de..ee35f72275 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ElectricSurfaceChargeDensityTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ElectricSurfaceChargeDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs index 22b563d859..b7a30a0293 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EnergyTestsBase.g.cs @@ -1891,7 +1891,7 @@ public void ToUnit(EnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs index 06ae0fd4e5..3ee300f59c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/EntropyTestsBase.g.cs @@ -423,7 +423,7 @@ public void ToUnit(EntropyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs index 6e46e12a28..56a7c50828 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceChangeRateTestsBase.g.cs @@ -791,7 +791,7 @@ public void ToUnit(ForceChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs index c9979db3cf..2ba6c3674b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForcePerLengthTestsBase.g.cs @@ -1651,7 +1651,7 @@ public void ToUnit(ForcePerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs index 28a015c7a7..4fba4daf36 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ForceTestsBase.g.cs @@ -1109,7 +1109,7 @@ public void ToUnit(ForceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs index 6235036d30..dca8772335 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FrequencyTestsBase.g.cs @@ -727,7 +727,7 @@ public void ToUnit(FrequencyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs index 267c73802f..3431afe279 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/FuelEfficiencyTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(FuelEfficiencyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs index d894f51294..9af27ace3e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatFluxTestsBase.g.cs @@ -821,7 +821,7 @@ public void ToUnit(HeatFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs index 0050e1ba0e..b3f9fd93b6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/HeatTransferCoefficientTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(HeatTransferCoefficientUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs index d53ecaf4e4..d0b0c36d4a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IlluminanceTestsBase.g.cs @@ -299,7 +299,7 @@ public void ToUnit(IlluminanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs index f48c5b7434..55b738ffdb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/InformationTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class InformationTestsBase : QuantityTestsBase { - protected abstract double BitsInOneBit { get; } - protected abstract double BytesInOneBit { get; } - protected abstract double ExabitsInOneBit { get; } - protected abstract double ExabytesInOneBit { get; } - protected abstract double ExbibitsInOneBit { get; } - protected abstract double ExbibytesInOneBit { get; } - protected abstract double GibibitsInOneBit { get; } - protected abstract double GibibytesInOneBit { get; } - protected abstract double GigabitsInOneBit { get; } - protected abstract double GigabytesInOneBit { get; } - protected abstract double KibibitsInOneBit { get; } - protected abstract double KibibytesInOneBit { get; } - protected abstract double KilobitsInOneBit { get; } - protected abstract double KilobytesInOneBit { get; } - protected abstract double MebibitsInOneBit { get; } - protected abstract double MebibytesInOneBit { get; } - protected abstract double MegabitsInOneBit { get; } - protected abstract double MegabytesInOneBit { get; } - protected abstract double PebibitsInOneBit { get; } - protected abstract double PebibytesInOneBit { get; } - protected abstract double PetabitsInOneBit { get; } - protected abstract double PetabytesInOneBit { get; } - protected abstract double TebibitsInOneBit { get; } - protected abstract double TebibytesInOneBit { get; } - protected abstract double TerabitsInOneBit { get; } - protected abstract double TerabytesInOneBit { get; } + protected abstract decimal BitsInOneBit { get; } + protected abstract decimal BytesInOneBit { get; } + protected abstract decimal ExabitsInOneBit { get; } + protected abstract decimal ExabytesInOneBit { get; } + protected abstract decimal ExbibitsInOneBit { get; } + protected abstract decimal ExbibytesInOneBit { get; } + protected abstract decimal GibibitsInOneBit { get; } + protected abstract decimal GibibytesInOneBit { get; } + protected abstract decimal GigabitsInOneBit { get; } + protected abstract decimal GigabytesInOneBit { get; } + protected abstract decimal KibibitsInOneBit { get; } + protected abstract decimal KibibytesInOneBit { get; } + protected abstract decimal KilobitsInOneBit { get; } + protected abstract decimal KilobytesInOneBit { get; } + protected abstract decimal MebibitsInOneBit { get; } + protected abstract decimal MebibytesInOneBit { get; } + protected abstract decimal MegabitsInOneBit { get; } + protected abstract decimal MegabytesInOneBit { get; } + protected abstract decimal PebibitsInOneBit { get; } + protected abstract decimal PebibytesInOneBit { get; } + protected abstract decimal PetabitsInOneBit { get; } + protected abstract decimal PetabytesInOneBit { get; } + protected abstract decimal TebibitsInOneBit { get; } + protected abstract decimal TebibytesInOneBit { get; } + protected abstract decimal TerabitsInOneBit { get; } + protected abstract decimal TerabytesInOneBit { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BitsTolerance { get { return 1e-5; } } - protected virtual double BytesTolerance { get { return 1e-5; } } - protected virtual double ExabitsTolerance { get { return 1e-5; } } - protected virtual double ExabytesTolerance { get { return 1e-5; } } - protected virtual double ExbibitsTolerance { get { return 1e-5; } } - protected virtual double ExbibytesTolerance { get { return 1e-5; } } - protected virtual double GibibitsTolerance { get { return 1e-5; } } - protected virtual double GibibytesTolerance { get { return 1e-5; } } - protected virtual double GigabitsTolerance { get { return 1e-5; } } - protected virtual double GigabytesTolerance { get { return 1e-5; } } - protected virtual double KibibitsTolerance { get { return 1e-5; } } - protected virtual double KibibytesTolerance { get { return 1e-5; } } - protected virtual double KilobitsTolerance { get { return 1e-5; } } - protected virtual double KilobytesTolerance { get { return 1e-5; } } - protected virtual double MebibitsTolerance { get { return 1e-5; } } - protected virtual double MebibytesTolerance { get { return 1e-5; } } - protected virtual double MegabitsTolerance { get { return 1e-5; } } - protected virtual double MegabytesTolerance { get { return 1e-5; } } - protected virtual double PebibitsTolerance { get { return 1e-5; } } - protected virtual double PebibytesTolerance { get { return 1e-5; } } - protected virtual double PetabitsTolerance { get { return 1e-5; } } - protected virtual double PetabytesTolerance { get { return 1e-5; } } - protected virtual double TebibitsTolerance { get { return 1e-5; } } - protected virtual double TebibytesTolerance { get { return 1e-5; } } - protected virtual double TerabitsTolerance { get { return 1e-5; } } - protected virtual double TerabytesTolerance { get { return 1e-5; } } + protected virtual decimal BitsTolerance { get { return 1e-9m; } } + protected virtual decimal BytesTolerance { get { return 1e-9m; } } + protected virtual decimal ExabitsTolerance { get { return 1e-9m; } } + protected virtual decimal ExabytesTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibitsTolerance { get { return 1e-9m; } } + protected virtual decimal ExbibytesTolerance { get { return 1e-9m; } } + protected virtual decimal GibibitsTolerance { get { return 1e-9m; } } + protected virtual decimal GibibytesTolerance { get { return 1e-9m; } } + protected virtual decimal GigabitsTolerance { get { return 1e-9m; } } + protected virtual decimal GigabytesTolerance { get { return 1e-9m; } } + protected virtual decimal KibibitsTolerance { get { return 1e-9m; } } + protected virtual decimal KibibytesTolerance { get { return 1e-9m; } } + protected virtual decimal KilobitsTolerance { get { return 1e-9m; } } + protected virtual decimal KilobytesTolerance { get { return 1e-9m; } } + protected virtual decimal MebibitsTolerance { get { return 1e-9m; } } + protected virtual decimal MebibytesTolerance { get { return 1e-9m; } } + protected virtual decimal MegabitsTolerance { get { return 1e-9m; } } + protected virtual decimal MegabytesTolerance { get { return 1e-9m; } } + protected virtual decimal PebibitsTolerance { get { return 1e-9m; } } + protected virtual decimal PebibytesTolerance { get { return 1e-9m; } } + protected virtual decimal PetabitsTolerance { get { return 1e-9m; } } + protected virtual decimal PetabytesTolerance { get { return 1e-9m; } } + protected virtual decimal TebibitsTolerance { get { return 1e-9m; } } + protected virtual decimal TebibytesTolerance { get { return 1e-9m; } } + protected virtual decimal TerabitsTolerance { get { return 1e-9m; } } + protected virtual decimal TerabytesTolerance { get { return 1e-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(InformationUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(InformationUnit unit) { return unit switch { @@ -758,7 +758,7 @@ public void ToUnit(InformationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs index c0d10394f7..2921233abb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradianceTestsBase.g.cs @@ -617,7 +617,7 @@ public void ToUnit(IrradianceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs index db173e10e8..02ee1ab34a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/IrradiationTestsBase.g.cs @@ -423,7 +423,7 @@ public void ToUnit(IrradiationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs index 4b8961c1d7..7daa612be5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/JerkTestsBase.g.cs @@ -823,7 +823,7 @@ public void ToUnit(JerkUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs index aad81609de..7ba8d63569 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/KinematicViscosityTestsBase.g.cs @@ -683,7 +683,7 @@ public void ToUnit(KinematicViscosityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs index 840ff97042..6809b4ae6d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LapseRateTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(LapseRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs index b063af3c1d..4ed2ddcaa6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LengthTestsBase.g.cs @@ -2213,7 +2213,7 @@ public void ToUnit(LengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs index aa977dc3e4..7888edb6e0 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LevelTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(LevelUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs index da6d13e43c..5b2b49380b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearDensityTestsBase.g.cs @@ -661,7 +661,7 @@ public void ToUnit(LinearDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs index 89f251de69..4c89b1be79 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LinearPowerDensityTestsBase.g.cs @@ -925,7 +925,7 @@ public void ToUnit(LinearPowerDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs index 007e99449e..3aaf90c4d9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminosityTestsBase.g.cs @@ -617,7 +617,7 @@ public void ToUnit(LuminosityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs index dcb107c35f..02d89fa3ec 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousFluxTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(LuminousFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs index fcd3954377..780180965e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/LuminousIntensityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(LuminousIntensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs index 174b05b5bc..a3f65674a3 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFieldTestsBase.g.cs @@ -389,7 +389,7 @@ public void ToUnit(MagneticFieldUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs index acee8f296b..60625a68ac 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagneticFluxTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(MagneticFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs index b6e2f93739..5f4acd87eb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MagnetizationTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(MagnetizationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs index 4f1778b29c..16df09d64a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassConcentrationTestsBase.g.cs @@ -1947,7 +1947,7 @@ public void ToUnit(MassConcentrationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs index d4696be3d2..8cad9926bd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFlowTestsBase.g.cs @@ -1549,7 +1549,7 @@ public void ToUnit(MassFlowUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs index 54a6e654cf..3399d668b2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFluxTestsBase.g.cs @@ -593,7 +593,7 @@ public void ToUnit(MassFluxUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs index 1cdfeb11b5..869a440e1c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassFractionTestsBase.g.cs @@ -1025,7 +1025,7 @@ public void ToUnit(MassFractionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs index 12f6d91b6e..6c67b27cce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassMomentOfInertiaTestsBase.g.cs @@ -1137,7 +1137,7 @@ public void ToUnit(MassMomentOfInertiaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs index aee8d32ea4..fdb0825f8b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MassTestsBase.g.cs @@ -2023,7 +2023,7 @@ public void ToUnit(MassUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs index d02524f56e..a8d1e7fc9e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEnergyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(MolarEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs index 78a88ecb39..cb52e3964c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarEntropyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(MolarEntropyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs index ffe0f30f77..3f7389ff63 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarMassTestsBase.g.cs @@ -881,7 +881,7 @@ public void ToUnit(MolarMassUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs index 923b01a6b3..cbe5fe4d20 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/MolarityTestsBase.g.cs @@ -582,7 +582,7 @@ public void ToUnit(MolarityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs index af5bee7872..bb94e4b69b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermeabilityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(PermeabilityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs index 1a1aa929fa..2525d5107b 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PermittivityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(PermittivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs index 88b7bcfa81..66e66d2830 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PorousMediumPermeabilityTestsBase.g.cs @@ -355,7 +355,7 @@ public void ToUnit(PorousMediumPermeabilityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs index 9888200c48..4ad5f27936 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerDensityTestsBase.g.cs @@ -1593,7 +1593,7 @@ public void ToUnit(PowerDensityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs index 3cd613b917..8e70929d4f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerRatioTestsBase.g.cs @@ -277,7 +277,7 @@ public void ToUnit(PowerRatioUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs index 84e4e66f28..131da2b337 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PowerTestsBase.g.cs @@ -38,63 +38,63 @@ namespace UnitsNet.Tests // ReSharper disable once PartialTypeWithSinglePart public abstract partial class PowerTestsBase : QuantityTestsBase { - protected abstract double BoilerHorsepowerInOneWatt { get; } - protected abstract double BritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double DecawattsInOneWatt { get; } - protected abstract double DeciwattsInOneWatt { get; } - protected abstract double ElectricalHorsepowerInOneWatt { get; } - protected abstract double FemtowattsInOneWatt { get; } - protected abstract double GigajoulesPerHourInOneWatt { get; } - protected abstract double GigawattsInOneWatt { get; } - protected abstract double HydraulicHorsepowerInOneWatt { get; } - protected abstract double JoulesPerHourInOneWatt { get; } - protected abstract double KilobritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double KilojoulesPerHourInOneWatt { get; } - protected abstract double KilowattsInOneWatt { get; } - protected abstract double MechanicalHorsepowerInOneWatt { get; } - protected abstract double MegabritishThermalUnitsPerHourInOneWatt { get; } - protected abstract double MegajoulesPerHourInOneWatt { get; } - protected abstract double MegawattsInOneWatt { get; } - protected abstract double MetricHorsepowerInOneWatt { get; } - protected abstract double MicrowattsInOneWatt { get; } - protected abstract double MillijoulesPerHourInOneWatt { get; } - protected abstract double MilliwattsInOneWatt { get; } - protected abstract double NanowattsInOneWatt { get; } - protected abstract double PetawattsInOneWatt { get; } - protected abstract double PicowattsInOneWatt { get; } - protected abstract double TerawattsInOneWatt { get; } - protected abstract double WattsInOneWatt { get; } + protected abstract decimal BoilerHorsepowerInOneWatt { get; } + protected abstract decimal BritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal DecawattsInOneWatt { get; } + protected abstract decimal DeciwattsInOneWatt { get; } + protected abstract decimal ElectricalHorsepowerInOneWatt { get; } + protected abstract decimal FemtowattsInOneWatt { get; } + protected abstract decimal GigajoulesPerHourInOneWatt { get; } + protected abstract decimal GigawattsInOneWatt { get; } + protected abstract decimal HydraulicHorsepowerInOneWatt { get; } + protected abstract decimal JoulesPerHourInOneWatt { get; } + protected abstract decimal KilobritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal KilojoulesPerHourInOneWatt { get; } + protected abstract decimal KilowattsInOneWatt { get; } + protected abstract decimal MechanicalHorsepowerInOneWatt { get; } + protected abstract decimal MegabritishThermalUnitsPerHourInOneWatt { get; } + protected abstract decimal MegajoulesPerHourInOneWatt { get; } + protected abstract decimal MegawattsInOneWatt { get; } + protected abstract decimal MetricHorsepowerInOneWatt { get; } + protected abstract decimal MicrowattsInOneWatt { get; } + protected abstract decimal MillijoulesPerHourInOneWatt { get; } + protected abstract decimal MilliwattsInOneWatt { get; } + protected abstract decimal NanowattsInOneWatt { get; } + protected abstract decimal PetawattsInOneWatt { get; } + protected abstract decimal PicowattsInOneWatt { get; } + protected abstract decimal TerawattsInOneWatt { get; } + protected abstract decimal WattsInOneWatt { get; } // ReSharper disable VirtualMemberNeverOverriden.Global - protected virtual double BoilerHorsepowerTolerance { get { return 1e-5; } } - protected virtual double BritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double DecawattsTolerance { get { return 1e-5; } } - protected virtual double DeciwattsTolerance { get { return 1e-5; } } - protected virtual double ElectricalHorsepowerTolerance { get { return 1e-5; } } - protected virtual double FemtowattsTolerance { get { return 1e-5; } } - protected virtual double GigajoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double GigawattsTolerance { get { return 1e-5; } } - protected virtual double HydraulicHorsepowerTolerance { get { return 1e-5; } } - protected virtual double JoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double KilobritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double KilojoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double KilowattsTolerance { get { return 1e-5; } } - protected virtual double MechanicalHorsepowerTolerance { get { return 1e-5; } } - protected virtual double MegabritishThermalUnitsPerHourTolerance { get { return 1e-5; } } - protected virtual double MegajoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double MegawattsTolerance { get { return 1e-5; } } - protected virtual double MetricHorsepowerTolerance { get { return 1e-5; } } - protected virtual double MicrowattsTolerance { get { return 1e-5; } } - protected virtual double MillijoulesPerHourTolerance { get { return 1e-5; } } - protected virtual double MilliwattsTolerance { get { return 1e-5; } } - protected virtual double NanowattsTolerance { get { return 1e-5; } } - protected virtual double PetawattsTolerance { get { return 1e-5; } } - protected virtual double PicowattsTolerance { get { return 1e-5; } } - protected virtual double TerawattsTolerance { get { return 1e-5; } } - protected virtual double WattsTolerance { get { return 1e-5; } } + protected virtual decimal BoilerHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal BritishThermalUnitsPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal DecawattsTolerance { get { return 1e-9m; } } + protected virtual decimal DeciwattsTolerance { get { return 1e-9m; } } + protected virtual decimal ElectricalHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal FemtowattsTolerance { get { return 1e-9m; } } + protected virtual decimal GigajoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal GigawattsTolerance { get { return 1e-9m; } } + protected virtual decimal HydraulicHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal JoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal KilobritishThermalUnitsPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal KilojoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal KilowattsTolerance { get { return 1e-9m; } } + protected virtual decimal MechanicalHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal MegabritishThermalUnitsPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal MegajoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal MegawattsTolerance { get { return 1e-9m; } } + protected virtual decimal MetricHorsepowerTolerance { get { return 1e-9m; } } + protected virtual decimal MicrowattsTolerance { get { return 1e-9m; } } + protected virtual decimal MillijoulesPerHourTolerance { get { return 1e-9m; } } + protected virtual decimal MilliwattsTolerance { get { return 1e-9m; } } + protected virtual decimal NanowattsTolerance { get { return 1e-9m; } } + protected virtual decimal PetawattsTolerance { get { return 1e-9m; } } + protected virtual decimal PicowattsTolerance { get { return 1e-9m; } } + protected virtual decimal TerawattsTolerance { get { return 1e-9m; } } + protected virtual decimal WattsTolerance { get { return 1e-9m; } } // ReSharper restore VirtualMemberNeverOverriden.Global - protected (double UnitsInBaseUnit, double Tolerence) GetConversionFactor(PowerUnit unit) + protected (decimal UnitsInBaseUnit, decimal Tolerence) GetConversionFactor(PowerUnit unit) { return unit switch { @@ -1050,7 +1050,7 @@ public void ToUnit(PowerUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs index c489b22624..5fe20f091c 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureChangeRateTestsBase.g.cs @@ -1285,7 +1285,7 @@ public void ToUnit(PressureChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs index 3db47ed7e7..cf6967f71a 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/PressureTestsBase.g.cs @@ -2633,7 +2633,7 @@ public void ToUnit(PressureUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs index 989c017044..4ea643a545 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioChangeRateTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(RatioChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs index 8714c6f6a3..861ea209f2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RatioTestsBase.g.cs @@ -389,7 +389,7 @@ public void ToUnit(RatioUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs index 8c4ddb264c..8391a912fe 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactiveEnergyTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(ReactiveEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs index 807b553fda..feed495b61 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReactivePowerTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(ReactivePowerUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs index 93590fd301..777ed892bc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalAreaTestsBase.g.cs @@ -559,7 +559,7 @@ public void ToUnit(ReciprocalAreaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs index 3de7afaf9e..9ea9f3f6dd 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ReciprocalLengthTestsBase.g.cs @@ -765,7 +765,7 @@ public void ToUnit(ReciprocalLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs index 60f67c7468..1f04da75d7 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RelativeHumidityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(RelativeHumidityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs index f0cc297b7e..2a77ca24bb 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalAccelerationTestsBase.g.cs @@ -345,7 +345,7 @@ public void ToUnit(RotationalAccelerationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs index a2df678911..895645ecf5 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalSpeedTestsBase.g.cs @@ -1059,7 +1059,7 @@ public void ToUnit(RotationalSpeedUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs index 7880b8d001..9fa1017fcf 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessPerLengthTestsBase.g.cs @@ -547,7 +547,7 @@ public void ToUnit(RotationalStiffnessPerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs index 8557dab512..77d59aa2d4 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/RotationalStiffnessTestsBase.g.cs @@ -2791,7 +2791,7 @@ public void ToUnit(RotationalStiffnessUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs index 427c4da867..736372bbe1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ScalarTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(ScalarUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs index 6fe1a3602c..25caa612e6 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SolidAngleTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(SolidAngleUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs index 32be1e830a..64160a096f 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEnergyTestsBase.g.cs @@ -1171,7 +1171,7 @@ public void ToUnit(SpecificEnergyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs index b58e37b641..dc46b24d03 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificEntropyTestsBase.g.cs @@ -515,7 +515,7 @@ public void ToUnit(SpecificEntropyUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs index e0e7e9e8cc..d577065a72 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificFuelConsumptionTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(SpecificFuelConsumptionUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs index 44c9025100..4b3b657d2d 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificVolumeTestsBase.g.cs @@ -287,7 +287,7 @@ public void ToUnit(SpecificVolumeUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs index daf5cffeae..4210c1a039 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpecificWeightTestsBase.g.cs @@ -763,7 +763,7 @@ public void ToUnit(SpecificWeightUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs index 9ef94f5cab..fa482d3228 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/SpeedTestsBase.g.cs @@ -1897,7 +1897,7 @@ public void ToUnit(SpeedUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs index 7dfaf4c928..75a3ed37d2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/StandardVolumeFlowTestsBase.g.cs @@ -491,7 +491,7 @@ public void ToUnit(StandardVolumeFlowUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs index 6e8098579d..3d67ad09fc 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureChangeRateTestsBase.g.cs @@ -525,7 +525,7 @@ public void ToUnit(TemperatureChangeRateUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs index 7febab8e92..5d8b5496c2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureDeltaTestsBase.g.cs @@ -491,7 +491,7 @@ public void ToUnit(TemperatureDeltaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs index e0a6f79454..0615daf30e 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureGradientTestsBase.g.cs @@ -321,7 +321,7 @@ public void ToUnit(TemperatureGradientUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs index fe54557914..44de9d28d1 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TemperatureTestsBase.g.cs @@ -525,7 +525,7 @@ public void ToUnit(TemperatureUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs index f9ba3e2d05..3347f067f8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalConductivityTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(ThermalConductivityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs index 00f985ad3e..f81e24bad8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/ThermalResistanceTestsBase.g.cs @@ -389,7 +389,7 @@ public void ToUnit(ThermalResistanceUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs index 4d7495ee03..23cde17010 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorquePerLengthTestsBase.g.cs @@ -971,7 +971,7 @@ public void ToUnit(TorquePerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs index 322306450f..df2ff38bce 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TorqueTestsBase.g.cs @@ -1107,7 +1107,7 @@ public void ToUnit(TorqueUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs index 65fd4b5012..0dd6738ce2 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/TurbidityTestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(TurbidityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs index 36661f561c..a7d6532013 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VitaminATestsBase.g.cs @@ -219,7 +219,7 @@ public void ToUnit(VitaminAUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs index d807ec47aa..5e1a8bf0f9 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeConcentrationTestsBase.g.cs @@ -889,7 +889,7 @@ public void ToUnit(VolumeConcentrationUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs index 722f63a1d7..ac720c72b8 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowPerAreaTestsBase.g.cs @@ -253,7 +253,7 @@ public void ToUnit(VolumeFlowPerAreaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs index caf0e209b2..7df104aa26 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeFlowTestsBase.g.cs @@ -3955,7 +3955,7 @@ public void ToUnit(VolumeFlowUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs index 98f4ce00c7..93fae6f962 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumePerLengthTestsBase.g.cs @@ -423,7 +423,7 @@ public void ToUnit(VolumePerLengthUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs index 4447d491b4..4a05b0d952 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumeTestsBase.g.cs @@ -2949,7 +2949,7 @@ public void ToUnit(VolumeUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs index 030c251bde..7e1c9f3c69 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/VolumetricHeatCapacityTestsBase.g.cs @@ -491,7 +491,7 @@ public void ToUnit(VolumetricHeatCapacityUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs index 683a9313ae..3bf9cafc76 100644 --- a/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs +++ b/UnitsNet.Tests/GeneratedCode/TestsBase/WarpingMomentOfInertiaTestsBase.g.cs @@ -533,7 +533,7 @@ public void ToUnit(WarpingMomentOfInertiaUnit unit) var converted = inBaseUnits.ToUnit(unit); var conversionFactor = GetConversionFactor(unit); - AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, (double)converted.Value, conversionFactor.Tolerence); + AssertEx.EqualTolerance(conversionFactor.UnitsInBaseUnit, converted.Value, conversionFactor.Tolerence); Assert.Equal(unit, converted.Unit); } diff --git a/UnitsNet.Tests/IntOverloadTests.cs b/UnitsNet.Tests/IntOverloadTests.cs index bf63007ba7..9d059dcc46 100644 --- a/UnitsNet.Tests/IntOverloadTests.cs +++ b/UnitsNet.Tests/IntOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromIntReturnsCorrectVa public static void CreatingQuantityWithIntBackingFieldFromIntReturnsCorrectValue() { Power power = Power.FromWatts(1); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/LongOverloadTests.cs b/UnitsNet.Tests/LongOverloadTests.cs index fd54377f08..ba5c00a538 100644 --- a/UnitsNet.Tests/LongOverloadTests.cs +++ b/UnitsNet.Tests/LongOverloadTests.cs @@ -18,7 +18,7 @@ public static void CreatingQuantityWithDoubleBackingFieldFromLongReturnsCorrectV public static void CreatingQuantityWithLongBackingFieldFromLongReturnsCorrectValue() { Power power = Power.FromWatts(1L); - Assert.Equal(1.0, power.Watts); + Assert.Equal(1.0m, power.Watts); } } } diff --git a/UnitsNet.Tests/UnitConverterTest.cs b/UnitsNet.Tests/UnitConverterTest.cs index 421d7fef23..fab0694f48 100644 --- a/UnitsNet.Tests/UnitConverterTest.cs +++ b/UnitsNet.Tests/UnitConverterTest.cs @@ -112,8 +112,8 @@ public void ConversionForUnitsOfCustomQuantity(double fromValue, HowMuchUnit fro { // Intentionally don't map conversion Some->Some, it is not necessary var unitConverter = new UnitConverter(); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch(x.Value * 2, HowMuchUnit.ATon)); - unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch(x.Value * 10, HowMuchUnit.AShitTon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.ATon, x => new HowMuch((double)x.Value * 2, HowMuchUnit.ATon)); + unitConverter.SetConversionFunction(HowMuchUnit.Some, HowMuchUnit.AShitTon, x => new HowMuch((double)x.Value * 10, HowMuchUnit.AShitTon)); var foundConversionFunction = unitConverter.GetConversionFunction(fromUnit, toUnit); var converted = foundConversionFunction(new HowMuch(fromValue, fromUnit)); diff --git a/UnitsNet/Comparison.cs b/UnitsNet/Comparison.cs index 575707e6b5..ac6726c3e2 100644 --- a/UnitsNet/Comparison.cs +++ b/UnitsNet/Comparison.cs @@ -65,6 +65,61 @@ public static bool Equals(double referenceValue, double otherValue, double toler } } + /// + /// + /// Checks if two values are equal with a given relative or absolute tolerance. + /// + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// Equals(a, b, 0.01, ComparisonType.Relative); + /// + /// + /// + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// + /// The reference value. If using relative tolerance, it is the value which the relative + /// tolerance will be calculated against. + /// + /// The value to compare to. + /// The absolute or relative tolerance value. Must be greater than or equal to 0. + /// Whether the tolerance is absolute or relative. + /// + public static bool Equals(decimal referenceValue, decimal otherValue, decimal tolerance, ComparisonType comparisonType) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + switch (comparisonType) + { + case ComparisonType.Relative: + return EqualsRelative(referenceValue, otherValue, tolerance); + case ComparisonType.Absolute: + return EqualsAbsolute(referenceValue, otherValue, tolerance); + default: + throw new InvalidOperationException("The given ComparisonType is not supported."); + } + } + /// /// Checks if two values are equal with a given relative tolerance. /// @@ -95,6 +150,36 @@ public static bool EqualsRelative(double referenceValue, double otherValue, doub return Math.Abs(referenceValue - otherValue) <= maxVariation; } + /// + /// Checks if two values are equal with a given relative tolerance. + /// + /// Relative tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a percentage of . A relative tolerance of + /// 0.01 means the + /// absolute difference of and must be within +/- + /// 1%. + /// + /// In this example, the two values will be equal if the value of b is within +/- 1% of a. + /// + /// EqualsRelative(a, b, 0.01); + /// + /// + /// + /// + /// The reference value which the tolerance will be calculated against. + /// The value to compare to. + /// The relative tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given relative tolerance, otherwise false. + public static bool EqualsRelative(decimal referenceValue, decimal otherValue, decimal tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + var maxVariation = Math.Abs(referenceValue * tolerance); + return Math.Abs(referenceValue - otherValue) <= maxVariation; + } + /// /// Checks if two values are equal with a given absolute tolerance. /// @@ -121,5 +206,32 @@ public static bool EqualsAbsolute(double value1, double value2, double tolerance return Math.Abs(value1 - value2) <= tolerance; } + + /// + /// Checks if two values are equal with a given absolute tolerance. + /// + /// Absolute tolerance is defined as the maximum allowable absolute difference between + /// and + /// as a fixed number. + /// + /// In this example, the two values will be equal if abs( - + /// ) <= 0.01 + /// + /// Equals(a, b, 0.01, ComparisonType.Absolute); + /// + /// + /// + /// + /// The first value. + /// The second value. + /// The absolute tolerance. Must be greater than or equal to 0. + /// True if the two values are equal within the given absolute tolerance, otherwise false. + public static bool EqualsAbsolute(decimal value1, decimal value2, decimal tolerance) + { + if (tolerance < 0) + throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0"); + + return Math.Abs(value1 - value2) <= tolerance; + } } } diff --git a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs index 5bd29a877a..a394b46629 100644 --- a/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs +++ b/UnitsNet/CustomCode/Quantities/BrakeSpecificFuelConsumption.extra.cs @@ -1,6 +1,8 @@ // Licensed under MIT No Attribution, see LICENSE file at the root. // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. +using UnitsNet.Units; + namespace UnitsNet { public partial struct BrakeSpecificFuelConsumption @@ -8,7 +10,7 @@ public partial struct BrakeSpecificFuelConsumption /// Get from times . public static MassFlow operator *(BrakeSpecificFuelConsumption bsfc, Power power) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule*power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * (double)power.Watts); } /// Get from divided by . diff --git a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs index e60c5c75d8..609db1ddef 100644 --- a/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs +++ b/UnitsNet/CustomCode/Quantities/MassFlow.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { @@ -40,7 +41,7 @@ public partial struct MassFlow /// Get from divided by . public static BrakeSpecificFuelConsumption operator /(MassFlow massFlow, Power power) { - return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / power.Watts); + return BrakeSpecificFuelConsumption.FromKilogramsPerJoule(massFlow.KilogramsPerSecond / (double)power.Watts); } /// Get from times . diff --git a/UnitsNet/CustomCode/Quantities/Power.extra.cs b/UnitsNet/CustomCode/Quantities/Power.extra.cs index 187c2740fc..61739b4054 100644 --- a/UnitsNet/CustomCode/Quantities/Power.extra.cs +++ b/UnitsNet/CustomCode/Quantities/Power.extra.cs @@ -2,6 +2,7 @@ // Copyright 2013 Andreas Gullberg Larsen (andreas.larsen84@gmail.com). Maintained at https://github.com/angularsen/UnitsNet. using System; +using UnitsNet.Units; namespace UnitsNet { @@ -24,87 +25,87 @@ public PowerRatio ToPowerRatio() /// Get from times . public static Energy operator *(Power power, TimeSpan time) { - return Energy.FromJoules(power.Watts * time.TotalSeconds); + return Energy.FromJoules((double)power.Watts * time.TotalSeconds); } /// Get from times . public static Energy operator *(TimeSpan time, Power power) { - return Energy.FromJoules(power.Watts * time.TotalSeconds); + return Energy.FromJoules((double)power.Watts * time.TotalSeconds); } /// Get from times . public static Energy operator *(Power power, Duration duration) { - return Energy.FromJoules(power.Watts * duration.Seconds); + return Energy.FromJoules((double)power.Watts * duration.Seconds); } /// Get from times . public static Energy operator *(Duration duration, Power power) { - return Energy.FromJoules(power.Watts * duration.Seconds); + return Energy.FromJoules((double)power.Watts * duration.Seconds); } /// Get from divided by . public static Force operator /(Power power, Speed speed) { - return Force.FromNewtons(power.Watts / speed.MetersPerSecond); + return Force.FromNewtons((double)power.Watts / speed.MetersPerSecond); } /// Get from divided by . public static Torque operator /(Power power, RotationalSpeed rotationalSpeed) { - return Torque.FromNewtonMeters(power.Watts / rotationalSpeed.RadiansPerSecond); + return Torque.FromNewtonMeters((double)power.Watts / rotationalSpeed.RadiansPerSecond); } /// Get from divided by . public static RotationalSpeed operator /(Power power, Torque torque) { - return RotationalSpeed.FromRadiansPerSecond(power.Watts / torque.NewtonMeters); + return RotationalSpeed.FromRadiansPerSecond((double)power.Watts / torque.NewtonMeters); } /// Get from times . public static MassFlow operator *(Power power, BrakeSpecificFuelConsumption bsfc) { - return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * power.Watts); + return MassFlow.FromKilogramsPerSecond(bsfc.KilogramsPerJoule * (double)power.Watts); } /// Get from divided by . public static SpecificEnergy operator /(Power power, MassFlow massFlow) { - return SpecificEnergy.FromJoulesPerKilogram(power.Watts / massFlow.KilogramsPerSecond); + return SpecificEnergy.FromJoulesPerKilogram((double)power.Watts / massFlow.KilogramsPerSecond); } /// Get from divided by . public static MassFlow operator /(Power power, SpecificEnergy specificEnergy) { - return MassFlow.FromKilogramsPerSecond(power.Watts / specificEnergy.JoulesPerKilogram); + return MassFlow.FromKilogramsPerSecond((double)power.Watts / specificEnergy.JoulesPerKilogram); } /// Get from divided by . public static HeatFlux operator /(Power power, Area area) { - return HeatFlux.FromWattsPerSquareMeter(power.Watts / area.SquareMeters); + return HeatFlux.FromWattsPerSquareMeter((double)power.Watts / area.SquareMeters); } /// Get from divided by . public static Area operator /(Power power, HeatFlux heatFlux) { - return Area.FromSquareMeters( power.Watts / heatFlux.WattsPerSquareMeter ); + return Area.FromSquareMeters((double)power.Watts / heatFlux.WattsPerSquareMeter ); } /// Calculate from divided by . /// Electric power is defined as P = U * I, so I = P / U. public static ElectricCurrent operator /(Power power, ElectricPotential potential) { - return ElectricCurrent.FromAmperes(power.Watts / potential.Volts); + return ElectricCurrent.FromAmperes((double)power.Watts / potential.Volts); } /// Calculate from divided by . /// Electric power is defined as P = U * I, so I = P / U. public static ElectricPotential operator /(Power power, ElectricCurrent current) { - return ElectricPotential.FromVolts(power.Watts / current.Amperes); + return ElectricPotential.FromVolts((double)power.Watts / current.Amperes); } } } diff --git a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs index f563f720ae..e4c4f07fe6 100644 --- a/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs +++ b/UnitsNet/CustomCode/Quantities/PowerRatio.extra.cs @@ -21,7 +21,7 @@ public PowerRatio(Power power) nameof(power), "The base-10 logarithm of a number ≤ 0 is undefined. Power must be greater than 0 W."); // P(dBW) = 10*log10(value(W)/reference(W)) - _value = 10 * Math.Log10(power.Watts / 1); + _value = 10 * Math.Log10((double)power.Watts); _unit = PowerRatioUnit.DecibelWatt; } diff --git a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs index 820cb3a395..fbcb6ab303 100644 --- a/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Acceleration.g.cs @@ -149,6 +149,9 @@ public Acceleration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -769,7 +772,7 @@ public bool Equals(Acceleration other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -795,10 +798,9 @@ public override int GetHashCode() public double As(AccelerationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -819,10 +821,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AccelerationUnit unitAsAccelerationUnit)) + if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsAccelerationUnit); + return (double)As(typedUnit); } /// @@ -869,10 +871,10 @@ public Acceleration ToUnit(AccelerationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AccelerationUnit unitAsAccelerationUnit)) + if (!(unit is AccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAccelerationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs index 6b796bdd8a..6575dc99be 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmountOfSubstance.g.cs @@ -150,6 +150,9 @@ public AmountOfSubstance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -774,7 +777,7 @@ public bool Equals(AmountOfSubstance other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -800,10 +803,9 @@ public override int GetHashCode() public double As(AmountOfSubstanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -824,10 +826,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) + if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return As(unitAsAmountOfSubstanceUnit); + return (double)As(typedUnit); } /// @@ -874,10 +876,10 @@ public AmountOfSubstance ToUnit(AmountOfSubstanceUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmountOfSubstanceUnit unitAsAmountOfSubstanceUnit)) + if (!(unit is AmountOfSubstanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmountOfSubstanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAmountOfSubstanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs index 05d7dfc95a..88ec3815eb 100644 --- a/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AmplitudeRatio.g.cs @@ -139,6 +139,9 @@ public AmplitudeRatio(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -573,7 +576,7 @@ public bool Equals(AmplitudeRatio other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -599,10 +602,9 @@ public override int GetHashCode() public double As(AmplitudeRatioUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -623,10 +625,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) + if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return As(unitAsAmplitudeRatioUnit); + return (double)As(typedUnit); } /// @@ -673,10 +675,10 @@ public AmplitudeRatio ToUnit(AmplitudeRatioUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AmplitudeRatioUnit unitAsAmplitudeRatioUnit)) + if (!(unit is AmplitudeRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AmplitudeRatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAmplitudeRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs index 55d9a88517..03cb0fb025 100644 --- a/UnitsNet/GeneratedCode/Quantities/Angle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Angle.g.cs @@ -151,6 +151,9 @@ public Angle(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -805,7 +808,7 @@ public bool Equals(Angle other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -831,10 +834,9 @@ public override int GetHashCode() public double As(AngleUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -855,10 +857,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AngleUnit unitAsAngleUnit)) + if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return As(unitAsAngleUnit); + return (double)As(typedUnit); } /// @@ -905,10 +907,10 @@ public Angle ToUnit(AngleUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AngleUnit unitAsAngleUnit)) + if (!(unit is AngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AngleUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAngleUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs index db89646bfd..5b56ad3a3a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentEnergy.g.cs @@ -138,6 +138,9 @@ public ApparentEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(ApparentEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(ApparentEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) + if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsApparentEnergyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public ApparentEnergy ToUnit(ApparentEnergyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentEnergyUnit unitAsApparentEnergyUnit)) + if (!(unit is ApparentEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsApparentEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs index 403251e02c..0dd50f5778 100644 --- a/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ApparentPower.g.cs @@ -139,6 +139,9 @@ public ApparentPower(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ApparentPower other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ApparentPowerUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) + if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return As(unitAsApparentPowerUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ApparentPower ToUnit(ApparentPowerUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ApparentPowerUnit unitAsApparentPowerUnit)) + if (!(unit is ApparentPowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ApparentPowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsApparentPowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Area.g.cs b/UnitsNet/GeneratedCode/Quantities/Area.g.cs index e7b786a82d..6abacce16a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Area.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Area.g.cs @@ -149,6 +149,9 @@ public Area(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -782,7 +785,7 @@ public bool Equals(Area other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -808,10 +811,9 @@ public override int GetHashCode() public double As(AreaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -832,10 +834,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AreaUnit unitAsAreaUnit)) + if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaUnit); + return (double)As(typedUnit); } /// @@ -882,10 +884,10 @@ public Area ToUnit(AreaUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaUnit unitAsAreaUnit)) + if (!(unit is AreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs index 76e73b46b3..4cb829edfa 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaDensity.g.cs @@ -136,6 +136,9 @@ public AreaDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(AreaDensity other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(AreaDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) + if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return As(unitAsAreaDensityUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public AreaDensity ToUnit(AreaDensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaDensityUnit unitAsAreaDensityUnit)) + if (!(unit is AreaDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs index 26632ad748..f98b4a8891 100644 --- a/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/AreaMomentOfInertia.g.cs @@ -141,6 +141,9 @@ public AreaMomentOfInertia(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(AreaMomentOfInertia other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(AreaMomentOfInertiaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) + if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsAreaMomentOfInertiaUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public AreaMomentOfInertia ToUnit(AreaMomentOfInertiaUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is AreaMomentOfInertiaUnit unitAsAreaMomentOfInertiaUnit)) + if (!(unit is AreaMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(AreaMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsAreaMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs index 1ce28dd1dd..7a60204588 100644 --- a/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BitRate.g.cs @@ -164,7 +164,8 @@ public BitRate(decimal value, UnitSystem unitSystem) /// public decimal Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// decimal IDecimalQuantity.Value => _value; @@ -190,134 +191,134 @@ public BitRate(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BitsPerSecond => As(BitRateUnit.BitPerSecond); + public decimal BitsPerSecond => As(BitRateUnit.BitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BytesPerSecond => As(BitRateUnit.BytePerSecond); + public decimal BytesPerSecond => As(BitRateUnit.BytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); + public decimal ExabitsPerSecond => As(BitRateUnit.ExabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); + public decimal ExabytesPerSecond => As(BitRateUnit.ExabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); + public decimal ExbibitsPerSecond => As(BitRateUnit.ExbibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); + public decimal ExbibytesPerSecond => As(BitRateUnit.ExbibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); + public decimal GibibitsPerSecond => As(BitRateUnit.GibibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); + public decimal GibibytesPerSecond => As(BitRateUnit.GibibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); + public decimal GigabitsPerSecond => As(BitRateUnit.GigabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); + public decimal GigabytesPerSecond => As(BitRateUnit.GigabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); + public decimal KibibitsPerSecond => As(BitRateUnit.KibibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); + public decimal KibibytesPerSecond => As(BitRateUnit.KibibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); + public decimal KilobitsPerSecond => As(BitRateUnit.KilobitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); + public decimal KilobytesPerSecond => As(BitRateUnit.KilobytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); + public decimal MebibitsPerSecond => As(BitRateUnit.MebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); + public decimal MebibytesPerSecond => As(BitRateUnit.MebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); + public decimal MegabitsPerSecond => As(BitRateUnit.MegabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); + public decimal MegabytesPerSecond => As(BitRateUnit.MegabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); + public decimal PebibitsPerSecond => As(BitRateUnit.PebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); + public decimal PebibytesPerSecond => As(BitRateUnit.PebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); + public decimal PetabitsPerSecond => As(BitRateUnit.PetabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); + public decimal PetabytesPerSecond => As(BitRateUnit.PetabytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); + public decimal TebibitsPerSecond => As(BitRateUnit.TebibitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); + public decimal TebibytesPerSecond => As(BitRateUnit.TebibytePerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); + public decimal TerabitsPerSecond => As(BitRateUnit.TerabitPerSecond); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); + public decimal TerabytesPerSecond => As(BitRateUnit.TerabytePerSecond); #endregion @@ -898,7 +899,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out BitRa } /// Get ratio value from dividing by . - public static double operator /(BitRate left, BitRate right) + public static decimal operator /(BitRate left, BitRate right) { return left.BitsPerSecond / right.BitsPerSecond; } @@ -986,13 +987,13 @@ public int CompareTo(BitRate other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(BitRate other, double tolerance, ComparisonType comparisonType) + public bool Equals(BitRate other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1014,17 +1015,21 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(BitRateUnit unit) + public decimal As(BitRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + } - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + double IQuantity.As(BitRateUnit unit) + { + return (double)As(unit); } /// - public double As(UnitSystem unitSystem) + public decimal As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1038,13 +1043,19 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); } + /// + double IQuantity.As(UnitSystem unitSystem) + { + return (double)As(unitSystem); + } + /// double IQuantity.As(Enum unit) { - if (!(unit is BitRateUnit unitAsBitRateUnit)) + if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return As(unitAsBitRateUnit); + return (double)As(typedUnit); } /// @@ -1091,10 +1102,10 @@ public BitRate ToUnit(BitRateUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BitRateUnit unitAsBitRateUnit)) + if (!(unit is BitRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BitRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsBitRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs index 22e36e45c1..1d80a4fae9 100644 --- a/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/BrakeSpecificFuelConsumption.g.cs @@ -138,6 +138,9 @@ public BrakeSpecificFuelConsumption(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(BrakeSpecificFuelConsumption other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(BrakeSpecificFuelConsumptionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsBrakeSpecificFuelConsumptionUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public BrakeSpecificFuelConsumption ToUnit(BrakeSpecificFuelConsumptionUnit unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is BrakeSpecificFuelConsumptionUnit unitAsBrakeSpecificFuelConsumptionUnit)) + if (!(unit is BrakeSpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(BrakeSpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsBrakeSpecificFuelConsumptionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs index c049929b5a..42414c4c15 100644 --- a/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Capacitance.g.cs @@ -145,6 +145,9 @@ public Capacitance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -625,7 +628,7 @@ public bool Equals(Capacitance other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -651,10 +654,9 @@ public override int GetHashCode() public double As(CapacitanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -675,10 +677,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) + if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return As(unitAsCapacitanceUnit); + return (double)As(typedUnit); } /// @@ -725,10 +727,10 @@ public Capacitance ToUnit(CapacitanceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CapacitanceUnit unitAsCapacitanceUnit)) + if (!(unit is CapacitanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CapacitanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCapacitanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs index 1c980e9a81..0825082e41 100644 --- a/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/CoefficientOfThermalExpansion.g.cs @@ -138,6 +138,9 @@ public CoefficientOfThermalExpansion(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(CoefficientOfThermalExpansion other, double tolerance, Compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(CoefficientOfThermalExpansionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return As(unitAsCoefficientOfThermalExpansionUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public CoefficientOfThermalExpansion ToUnit(CoefficientOfThermalExpansionUnit un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CoefficientOfThermalExpansionUnit unitAsCoefficientOfThermalExpansionUnit)) + if (!(unit is CoefficientOfThermalExpansionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CoefficientOfThermalExpansionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCoefficientOfThermalExpansionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs index 24755cc1db..4609bd5ed9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Compressibility.g.cs @@ -142,6 +142,9 @@ public Compressibility(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -622,7 +625,7 @@ public bool Equals(Compressibility other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -648,10 +651,9 @@ public override int GetHashCode() public double As(CompressibilityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -672,10 +674,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) + if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return As(unitAsCompressibilityUnit); + return (double)As(typedUnit); } /// @@ -722,10 +724,10 @@ public Compressibility ToUnit(CompressibilityUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is CompressibilityUnit unitAsCompressibilityUnit)) + if (!(unit is CompressibilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(CompressibilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsCompressibilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Density.g.cs b/UnitsNet/GeneratedCode/Quantities/Density.g.cs index 470717602d..2d5be5c975 100644 --- a/UnitsNet/GeneratedCode/Quantities/Density.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Density.g.cs @@ -189,6 +189,9 @@ public Density(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1465,7 +1468,7 @@ public bool Equals(Density other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1491,10 +1494,9 @@ public override int GetHashCode() public double As(DensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1515,10 +1517,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is DensityUnit unitAsDensityUnit)) + if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return As(unitAsDensityUnit); + return (double)As(typedUnit); } /// @@ -1565,10 +1567,10 @@ public Density ToUnit(DensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DensityUnit unitAsDensityUnit)) + if (!(unit is DensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs index 31dfb5c9b9..09271d58f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Duration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Duration.g.cs @@ -146,6 +146,9 @@ public Duration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -708,7 +711,7 @@ public bool Equals(Duration other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -734,10 +737,9 @@ public override int GetHashCode() public double As(DurationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -758,10 +760,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is DurationUnit unitAsDurationUnit)) + if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return As(unitAsDurationUnit); + return (double)As(typedUnit); } /// @@ -808,10 +810,10 @@ public Duration ToUnit(DurationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DurationUnit unitAsDurationUnit)) + if (!(unit is DurationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DurationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDurationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs index ec17be7043..0f6f562603 100644 --- a/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/DynamicViscosity.g.cs @@ -148,6 +148,9 @@ public DynamicViscosity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -682,7 +685,7 @@ public bool Equals(DynamicViscosity other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -708,10 +711,9 @@ public override int GetHashCode() public double As(DynamicViscosityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -732,10 +734,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) + if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsDynamicViscosityUnit); + return (double)As(typedUnit); } /// @@ -782,10 +784,10 @@ public DynamicViscosity ToUnit(DynamicViscosityUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is DynamicViscosityUnit unitAsDynamicViscosityUnit)) + if (!(unit is DynamicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(DynamicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsDynamicViscosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs index 5f6f688ac8..fea3a3bf60 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricAdmittance.g.cs @@ -139,6 +139,9 @@ public ElectricAdmittance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ElectricAdmittance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ElectricAdmittanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) + if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricAdmittanceUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ElectricAdmittance ToUnit(ElectricAdmittanceUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricAdmittanceUnit unitAsElectricAdmittanceUnit)) + if (!(unit is ElectricAdmittanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricAdmittanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricAdmittanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs index efdcf152cd..01f2c111b2 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCharge.g.cs @@ -143,6 +143,9 @@ public ElectricCharge(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -587,7 +590,7 @@ public bool Equals(ElectricCharge other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -613,10 +616,9 @@ public override int GetHashCode() public double As(ElectricChargeUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -637,10 +639,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) + if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeUnit); + return (double)As(typedUnit); } /// @@ -687,10 +689,10 @@ public ElectricCharge ToUnit(ElectricChargeUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeUnit unitAsElectricChargeUnit)) + if (!(unit is ElectricChargeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricChargeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs index 4538e7e215..c4a55f3a99 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricChargeDensity.g.cs @@ -139,6 +139,9 @@ public ElectricChargeDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(ElectricChargeDensity other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(ElectricChargeDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) + if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricChargeDensityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public ElectricChargeDensity ToUnit(ElectricChargeDensityUnit unit, UnitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricChargeDensityUnit unitAsElectricChargeDensityUnit)) + if (!(unit is ElectricChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricChargeDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs index f9f766a99d..78722c9767 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductance.g.cs @@ -141,6 +141,9 @@ public ElectricConductance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricConductance other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricConductanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) + if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductanceUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricConductance ToUnit(ElectricConductanceUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductanceUnit unitAsElectricConductanceUnit)) + if (!(unit is ElectricConductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricConductanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs index 8b7f49777a..66547aac20 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricConductivity.g.cs @@ -141,6 +141,9 @@ public ElectricConductivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricConductivity other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricConductivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) + if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricConductivityUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricConductivity ToUnit(ElectricConductivityUnit unit, UnitConverter /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricConductivityUnit unitAsElectricConductivityUnit)) + if (!(unit is ElectricConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricConductivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs index 0485881539..fa9b5a42c5 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrent.g.cs @@ -143,6 +143,9 @@ public ElectricCurrent(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -641,7 +644,7 @@ public bool Equals(ElectricCurrent other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -667,10 +670,9 @@ public override int GetHashCode() public double As(ElectricCurrentUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -691,10 +693,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) + if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentUnit); + return (double)As(typedUnit); } /// @@ -741,10 +743,10 @@ public ElectricCurrent ToUnit(ElectricCurrentUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentUnit unitAsElectricCurrentUnit)) + if (!(unit is ElectricCurrentUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs index 8a8989cb79..d1bddfe84c 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentDensity.g.cs @@ -141,6 +141,9 @@ public ElectricCurrentDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricCurrentDensity other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricCurrentDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) + if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentDensityUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricCurrentDensity ToUnit(ElectricCurrentDensityUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentDensityUnit unitAsElectricCurrentDensityUnit)) + if (!(unit is ElectricCurrentDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs index c5b8587e27..069ecdca43 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricCurrentGradient.g.cs @@ -139,6 +139,9 @@ public ElectricCurrentGradient(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ElectricCurrentGradient other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ElectricCurrentGradientUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) + if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return As(unitAsElectricCurrentGradientUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ElectricCurrentGradient ToUnit(ElectricCurrentGradientUnit unit, UnitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricCurrentGradientUnit unitAsElectricCurrentGradientUnit)) + if (!(unit is ElectricCurrentGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricCurrentGradientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricCurrentGradientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs index d49e4be72a..f030a42daa 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricField.g.cs @@ -139,6 +139,9 @@ public ElectricField(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(ElectricField other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(ElectricFieldUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) + if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return As(unitAsElectricFieldUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public ElectricField ToUnit(ElectricFieldUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricFieldUnit unitAsElectricFieldUnit)) + if (!(unit is ElectricFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricFieldUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricFieldUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs index fb2435cdce..a7be636acd 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricInductance.g.cs @@ -142,6 +142,9 @@ public ElectricInductance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(ElectricInductance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(ElectricInductanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) + if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricInductanceUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public ElectricInductance ToUnit(ElectricInductanceUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricInductanceUnit unitAsElectricInductanceUnit)) + if (!(unit is ElectricInductanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricInductanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricInductanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs index 3c413afc86..ffd0f55a45 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotential.g.cs @@ -140,6 +140,9 @@ public ElectricPotential(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -589,7 +592,7 @@ public bool Equals(ElectricPotential other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -615,10 +618,9 @@ public override int GetHashCode() public double As(ElectricPotentialUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -639,10 +641,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) + if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialUnit); + return (double)As(typedUnit); } /// @@ -689,10 +691,10 @@ public ElectricPotential ToUnit(ElectricPotentialUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialUnit unitAsElectricPotentialUnit)) + if (!(unit is ElectricPotentialUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs index fa988ad89a..484f7bdad1 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialAc.g.cs @@ -140,6 +140,9 @@ public ElectricPotentialAc(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -584,7 +587,7 @@ public bool Equals(ElectricPotentialAc other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -610,10 +613,9 @@ public override int GetHashCode() public double As(ElectricPotentialAcUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -634,10 +636,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) + if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialAcUnit); + return (double)As(typedUnit); } /// @@ -684,10 +686,10 @@ public ElectricPotentialAc ToUnit(ElectricPotentialAcUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialAcUnit unitAsElectricPotentialAcUnit)) + if (!(unit is ElectricPotentialAcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialAcUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialAcUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs index 9cc91d8d27..8e26d10e5e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialChangeRate.g.cs @@ -155,6 +155,9 @@ public ElectricPotentialChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -869,7 +872,7 @@ public bool Equals(ElectricPotentialChangeRate other, double tolerance, Comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -895,10 +898,9 @@ public override int GetHashCode() public double As(ElectricPotentialChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -919,10 +921,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) + if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialChangeRateUnit); + return (double)As(typedUnit); } /// @@ -969,10 +971,10 @@ public ElectricPotentialChangeRate ToUnit(ElectricPotentialChangeRateUnit unit, /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialChangeRateUnit unitAsElectricPotentialChangeRateUnit)) + if (!(unit is ElectricPotentialChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs index 787d8e5f5e..b41d363c53 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricPotentialDc.g.cs @@ -140,6 +140,9 @@ public ElectricPotentialDc(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -584,7 +587,7 @@ public bool Equals(ElectricPotentialDc other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -610,10 +613,9 @@ public override int GetHashCode() public double As(ElectricPotentialDcUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -634,10 +636,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) + if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return As(unitAsElectricPotentialDcUnit); + return (double)As(typedUnit); } /// @@ -684,10 +686,10 @@ public ElectricPotentialDc ToUnit(ElectricPotentialDcUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricPotentialDcUnit unitAsElectricPotentialDcUnit)) + if (!(unit is ElectricPotentialDcUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricPotentialDcUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricPotentialDcUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs index 29810c8529..d28df3865a 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistance.g.cs @@ -141,6 +141,9 @@ public ElectricResistance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(ElectricResistance other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(ElectricResistanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) + if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistanceUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public ElectricResistance ToUnit(ElectricResistanceUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistanceUnit unitAsElectricResistanceUnit)) + if (!(unit is ElectricResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricResistanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs index 9fa380d492..40ca57c9e7 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricResistivity.g.cs @@ -152,6 +152,9 @@ public ElectricResistivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -758,7 +761,7 @@ public bool Equals(ElectricResistivity other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -784,10 +787,9 @@ public override int GetHashCode() public double As(ElectricResistivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -808,10 +810,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) + if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricResistivityUnit); + return (double)As(typedUnit); } /// @@ -858,10 +860,10 @@ public ElectricResistivity ToUnit(ElectricResistivityUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricResistivityUnit unitAsElectricResistivityUnit)) + if (!(unit is ElectricResistivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricResistivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricResistivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs index a5e94ca602..6ca9c9f445 100644 --- a/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ElectricSurfaceChargeDensity.g.cs @@ -141,6 +141,9 @@ public ElectricSurfaceChargeDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -549,7 +552,7 @@ public bool Equals(ElectricSurfaceChargeDensity other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -575,10 +578,9 @@ public override int GetHashCode() public double As(ElectricSurfaceChargeDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -599,10 +601,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return As(unitAsElectricSurfaceChargeDensityUnit); + return (double)As(typedUnit); } /// @@ -649,10 +651,10 @@ public ElectricSurfaceChargeDensity ToUnit(ElectricSurfaceChargeDensityUnit unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ElectricSurfaceChargeDensityUnit unitAsElectricSurfaceChargeDensityUnit)) + if (!(unit is ElectricSurfaceChargeDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ElectricSurfaceChargeDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsElectricSurfaceChargeDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs index d8d04ae1af..682dd0b1e9 100644 --- a/UnitsNet/GeneratedCode/Quantities/Energy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Energy.g.cs @@ -171,6 +171,9 @@ public Energy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1194,7 +1197,7 @@ public bool Equals(Energy other, double tolerance, ComparisonType comparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1220,10 +1223,9 @@ public override int GetHashCode() public double As(EnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1244,10 +1246,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is EnergyUnit unitAsEnergyUnit)) + if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return As(unitAsEnergyUnit); + return (double)As(typedUnit); } /// @@ -1294,10 +1296,10 @@ public Energy ToUnit(EnergyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EnergyUnit unitAsEnergyUnit)) + if (!(unit is EnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs index 5a3eed83c2..c8efaf586c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Entropy.g.cs @@ -142,6 +142,9 @@ public Entropy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -622,7 +625,7 @@ public bool Equals(Entropy other, double tolerance, ComparisonType comparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -648,10 +651,9 @@ public override int GetHashCode() public double As(EntropyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -672,10 +674,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is EntropyUnit unitAsEntropyUnit)) + if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return As(unitAsEntropyUnit); + return (double)As(typedUnit); } /// @@ -722,10 +724,10 @@ public Entropy ToUnit(EntropyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is EntropyUnit unitAsEntropyUnit)) + if (!(unit is EntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(EntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Force.g.cs b/UnitsNet/GeneratedCode/Quantities/Force.g.cs index 67478a3e16..b6e6ac5c83 100644 --- a/UnitsNet/GeneratedCode/Quantities/Force.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Force.g.cs @@ -150,6 +150,9 @@ public Force(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -787,7 +790,7 @@ public bool Equals(Force other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -813,10 +816,9 @@ public override int GetHashCode() public double As(ForceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -837,10 +839,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ForceUnit unitAsForceUnit)) + if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return As(unitAsForceUnit); + return (double)As(typedUnit); } /// @@ -887,10 +889,10 @@ public Force ToUnit(ForceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceUnit unitAsForceUnit)) + if (!(unit is ForceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs index 247b741b2a..71fd87e1fa 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForceChangeRate.g.cs @@ -150,6 +150,9 @@ public ForceChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -774,7 +777,7 @@ public bool Equals(ForceChangeRate other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -800,10 +803,9 @@ public override int GetHashCode() public double As(ForceChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -824,10 +826,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) + if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsForceChangeRateUnit); + return (double)As(typedUnit); } /// @@ -874,10 +876,10 @@ public ForceChangeRate ToUnit(ForceChangeRateUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForceChangeRateUnit unitAsForceChangeRateUnit)) + if (!(unit is ForceChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForceChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForceChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs index 820ff9473d..acb10754d3 100644 --- a/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ForcePerLength.g.cs @@ -173,6 +173,9 @@ public ForcePerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1217,7 +1220,7 @@ public bool Equals(ForcePerLength other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1243,10 +1246,9 @@ public override int GetHashCode() public double As(ForcePerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1267,10 +1269,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) + if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsForcePerLengthUnit); + return (double)As(typedUnit); } /// @@ -1317,10 +1319,10 @@ public ForcePerLength ToUnit(ForcePerLengthUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ForcePerLengthUnit unitAsForcePerLengthUnit)) + if (!(unit is ForcePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ForcePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsForcePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs index 695d03630d..b329151779 100644 --- a/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Frequency.g.cs @@ -146,6 +146,9 @@ public Frequency(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -705,7 +708,7 @@ public bool Equals(Frequency other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -731,10 +734,9 @@ public override int GetHashCode() public double As(FrequencyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -755,10 +757,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is FrequencyUnit unitAsFrequencyUnit)) + if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return As(unitAsFrequencyUnit); + return (double)As(typedUnit); } /// @@ -805,10 +807,10 @@ public Frequency ToUnit(FrequencyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FrequencyUnit unitAsFrequencyUnit)) + if (!(unit is FrequencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FrequencyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsFrequencyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs index c2a2cfcf02..865c08adc5 100644 --- a/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/FuelEfficiency.g.cs @@ -142,6 +142,9 @@ public FuelEfficiency(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(FuelEfficiency other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(FuelEfficiencyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) + if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return As(unitAsFuelEfficiencyUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public FuelEfficiency ToUnit(FuelEfficiencyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is FuelEfficiencyUnit unitAsFuelEfficiencyUnit)) + if (!(unit is FuelEfficiencyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(FuelEfficiencyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsFuelEfficiencyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs index 2b0f9a5278..155039b2a2 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatFlux.g.cs @@ -153,6 +153,9 @@ public HeatFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -831,7 +834,7 @@ public bool Equals(HeatFlux other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -857,10 +860,9 @@ public override int GetHashCode() public double As(HeatFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -881,10 +883,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) + if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return As(unitAsHeatFluxUnit); + return (double)As(typedUnit); } /// @@ -931,10 +933,10 @@ public HeatFlux ToUnit(HeatFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatFluxUnit unitAsHeatFluxUnit)) + if (!(unit is HeatFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsHeatFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs index 2e7f448c7b..a9a420b4cc 100644 --- a/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/HeatTransferCoefficient.g.cs @@ -138,6 +138,9 @@ public HeatTransferCoefficient(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(HeatTransferCoefficient other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(HeatTransferCoefficientUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) + if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return As(unitAsHeatTransferCoefficientUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public HeatTransferCoefficient ToUnit(HeatTransferCoefficientUnit unit, UnitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is HeatTransferCoefficientUnit unitAsHeatTransferCoefficientUnit)) + if (!(unit is HeatTransferCoefficientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(HeatTransferCoefficientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsHeatTransferCoefficientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs index 304d11ab4d..6d897055da 100644 --- a/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Illuminance.g.cs @@ -142,6 +142,9 @@ public Illuminance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(Illuminance other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(IlluminanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) + if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return As(unitAsIlluminanceUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public Illuminance ToUnit(IlluminanceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IlluminanceUnit unitAsIlluminanceUnit)) + if (!(unit is IlluminanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IlluminanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIlluminanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Information.g.cs b/UnitsNet/GeneratedCode/Quantities/Information.g.cs index 880f4a52fb..8d5e3250ed 100644 --- a/UnitsNet/GeneratedCode/Quantities/Information.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Information.g.cs @@ -161,7 +161,8 @@ public Information(decimal value, UnitSystem unitSystem) /// public decimal Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// decimal IDecimalQuantity.Value => _value; @@ -187,134 +188,134 @@ public Information(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Bits => As(InformationUnit.Bit); + public decimal Bits => As(InformationUnit.Bit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Bytes => As(InformationUnit.Byte); + public decimal Bytes => As(InformationUnit.Byte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exabits => As(InformationUnit.Exabit); + public decimal Exabits => As(InformationUnit.Exabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exabytes => As(InformationUnit.Exabyte); + public decimal Exabytes => As(InformationUnit.Exabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exbibits => As(InformationUnit.Exbibit); + public decimal Exbibits => As(InformationUnit.Exbibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Exbibytes => As(InformationUnit.Exbibyte); + public decimal Exbibytes => As(InformationUnit.Exbibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gibibits => As(InformationUnit.Gibibit); + public decimal Gibibits => As(InformationUnit.Gibibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gibibytes => As(InformationUnit.Gibibyte); + public decimal Gibibytes => As(InformationUnit.Gibibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gigabits => As(InformationUnit.Gigabit); + public decimal Gigabits => As(InformationUnit.Gigabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gigabytes => As(InformationUnit.Gigabyte); + public decimal Gigabytes => As(InformationUnit.Gigabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kibibits => As(InformationUnit.Kibibit); + public decimal Kibibits => As(InformationUnit.Kibibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kibibytes => As(InformationUnit.Kibibyte); + public decimal Kibibytes => As(InformationUnit.Kibibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kilobits => As(InformationUnit.Kilobit); + public decimal Kilobits => As(InformationUnit.Kilobit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kilobytes => As(InformationUnit.Kilobyte); + public decimal Kilobytes => As(InformationUnit.Kilobyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Mebibits => As(InformationUnit.Mebibit); + public decimal Mebibits => As(InformationUnit.Mebibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Mebibytes => As(InformationUnit.Mebibyte); + public decimal Mebibytes => As(InformationUnit.Mebibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megabits => As(InformationUnit.Megabit); + public decimal Megabits => As(InformationUnit.Megabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megabytes => As(InformationUnit.Megabyte); + public decimal Megabytes => As(InformationUnit.Megabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Pebibits => As(InformationUnit.Pebibit); + public decimal Pebibits => As(InformationUnit.Pebibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Pebibytes => As(InformationUnit.Pebibyte); + public decimal Pebibytes => As(InformationUnit.Pebibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Petabits => As(InformationUnit.Petabit); + public decimal Petabits => As(InformationUnit.Petabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Petabytes => As(InformationUnit.Petabyte); + public decimal Petabytes => As(InformationUnit.Petabyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Tebibits => As(InformationUnit.Tebibit); + public decimal Tebibits => As(InformationUnit.Tebibit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Tebibytes => As(InformationUnit.Tebibyte); + public decimal Tebibytes => As(InformationUnit.Tebibyte); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Terabits => As(InformationUnit.Terabit); + public decimal Terabits => As(InformationUnit.Terabit); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Terabytes => As(InformationUnit.Terabyte); + public decimal Terabytes => As(InformationUnit.Terabyte); #endregion @@ -895,7 +896,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Infor } /// Get ratio value from dividing by . - public static double operator /(Information left, Information right) + public static decimal operator /(Information left, Information right) { return left.Bits / right.Bits; } @@ -983,13 +984,13 @@ public int CompareTo(Information other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Information other, double tolerance, ComparisonType comparisonType) + public bool Equals(Information other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1011,17 +1012,21 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(InformationUnit unit) + public decimal As(InformationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + } - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + double IQuantity.As(InformationUnit unit) + { + return (double)As(unit); } /// - public double As(UnitSystem unitSystem) + public decimal As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1035,13 +1040,19 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); } + /// + double IQuantity.As(UnitSystem unitSystem) + { + return (double)As(unitSystem); + } + /// double IQuantity.As(Enum unit) { - if (!(unit is InformationUnit unitAsInformationUnit)) + if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return As(unitAsInformationUnit); + return (double)As(typedUnit); } /// @@ -1088,10 +1099,10 @@ public Information ToUnit(InformationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is InformationUnit unitAsInformationUnit)) + if (!(unit is InformationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(InformationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsInformationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs index f395d39318..f868a9e832 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiance.g.cs @@ -149,6 +149,9 @@ public Irradiance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -755,7 +758,7 @@ public bool Equals(Irradiance other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -781,10 +784,9 @@ public override int GetHashCode() public double As(IrradianceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -805,10 +807,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is IrradianceUnit unitAsIrradianceUnit)) + if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return As(unitAsIrradianceUnit); + return (double)As(typedUnit); } /// @@ -855,10 +857,10 @@ public Irradiance ToUnit(IrradianceUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradianceUnit unitAsIrradianceUnit)) + if (!(unit is IrradianceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradianceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIrradianceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs index 9ddd5731b6..adbc7282a4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Irradiation.g.cs @@ -145,6 +145,9 @@ public Irradiation(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -625,7 +628,7 @@ public bool Equals(Irradiation other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -651,10 +654,9 @@ public override int GetHashCode() public double As(IrradiationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -675,10 +677,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is IrradiationUnit unitAsIrradiationUnit)) + if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return As(unitAsIrradiationUnit); + return (double)As(typedUnit); } /// @@ -725,10 +727,10 @@ public Irradiation ToUnit(IrradiationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is IrradiationUnit unitAsIrradiationUnit)) + if (!(unit is IrradiationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(IrradiationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsIrradiationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs index 7c5b0cee06..fc85e8048b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Jerk.g.cs @@ -146,6 +146,9 @@ public Jerk(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -709,7 +712,7 @@ public bool Equals(Jerk other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -735,10 +738,9 @@ public override int GetHashCode() public double As(JerkUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -759,10 +761,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is JerkUnit unitAsJerkUnit)) + if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return As(unitAsJerkUnit); + return (double)As(typedUnit); } /// @@ -809,10 +811,10 @@ public Jerk ToUnit(JerkUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is JerkUnit unitAsJerkUnit)) + if (!(unit is JerkUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(JerkUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsJerkUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs index 35282f2c29..d2a91cd9e1 100644 --- a/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/KinematicViscosity.g.cs @@ -147,6 +147,9 @@ public KinematicViscosity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -671,7 +674,7 @@ public bool Equals(KinematicViscosity other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -697,10 +700,9 @@ public override int GetHashCode() public double As(KinematicViscosityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -721,10 +723,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) + if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return As(unitAsKinematicViscosityUnit); + return (double)As(typedUnit); } /// @@ -771,10 +773,10 @@ public KinematicViscosity ToUnit(KinematicViscosityUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is KinematicViscosityUnit unitAsKinematicViscosityUnit)) + if (!(unit is KinematicViscosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(KinematicViscosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsKinematicViscosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs index fa9e8077ee..02e4f6c610 100644 --- a/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LapseRate.g.cs @@ -137,6 +137,9 @@ public LapseRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -509,7 +512,7 @@ public bool Equals(LapseRate other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -535,10 +538,9 @@ public override int GetHashCode() public double As(LapseRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -559,10 +561,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LapseRateUnit unitAsLapseRateUnit)) + if (!(unit is LapseRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return As(unitAsLapseRateUnit); + return (double)As(typedUnit); } /// @@ -609,10 +611,10 @@ public LapseRate ToUnit(LapseRateUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LapseRateUnit unitAsLapseRateUnit)) + if (!(unit is LapseRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LapseRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLapseRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Length.g.cs b/UnitsNet/GeneratedCode/Quantities/Length.g.cs index ab1960b463..c1196e3f9b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Length.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Length.g.cs @@ -171,6 +171,9 @@ public Length(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1205,7 +1208,7 @@ public bool Equals(Length other, double tolerance, ComparisonType comparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1231,10 +1234,9 @@ public override int GetHashCode() public double As(LengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1255,10 +1257,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LengthUnit unitAsLengthUnit)) + if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return As(unitAsLengthUnit); + return (double)As(typedUnit); } /// @@ -1305,10 +1307,10 @@ public Length ToUnit(LengthUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LengthUnit unitAsLengthUnit)) + if (!(unit is LengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Level.g.cs b/UnitsNet/GeneratedCode/Quantities/Level.g.cs index 16b78f3430..b8d63c8ab6 100644 --- a/UnitsNet/GeneratedCode/Quantities/Level.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Level.g.cs @@ -137,6 +137,9 @@ public Level(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -535,7 +538,7 @@ public bool Equals(Level other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -561,10 +564,9 @@ public override int GetHashCode() public double As(LevelUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -585,10 +587,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LevelUnit unitAsLevelUnit)) + if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return As(unitAsLevelUnit); + return (double)As(typedUnit); } /// @@ -635,10 +637,10 @@ public Level ToUnit(LevelUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LevelUnit unitAsLevelUnit)) + if (!(unit is LevelUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LevelUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLevelUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs index 659ad66f37..9007229079 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearDensity.g.cs @@ -152,6 +152,9 @@ public LinearDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -758,7 +761,7 @@ public bool Equals(LinearDensity other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -784,10 +787,9 @@ public override int GetHashCode() public double As(LinearDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -808,10 +810,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) + if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearDensityUnit); + return (double)As(typedUnit); } /// @@ -858,10 +860,10 @@ public LinearDensity ToUnit(LinearDensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearDensityUnit unitAsLinearDensityUnit)) + if (!(unit is LinearDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLinearDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs index 20a484724a..aac661bd04 100644 --- a/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LinearPowerDensity.g.cs @@ -163,6 +163,9 @@ public LinearPowerDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -967,7 +970,7 @@ public bool Equals(LinearPowerDensity other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -993,10 +996,9 @@ public override int GetHashCode() public double As(LinearPowerDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1017,10 +1019,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) + if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsLinearPowerDensityUnit); + return (double)As(typedUnit); } /// @@ -1067,10 +1069,10 @@ public LinearPowerDensity ToUnit(LinearPowerDensityUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LinearPowerDensityUnit unitAsLinearPowerDensityUnit)) + if (!(unit is LinearPowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LinearPowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLinearPowerDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs index d78acbfd8c..b81eeb8563 100644 --- a/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Luminosity.g.cs @@ -152,6 +152,9 @@ public Luminosity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -758,7 +761,7 @@ public bool Equals(Luminosity other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -784,10 +787,9 @@ public override int GetHashCode() public double As(LuminosityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -808,10 +810,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LuminosityUnit unitAsLuminosityUnit)) + if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminosityUnit); + return (double)As(typedUnit); } /// @@ -858,10 +860,10 @@ public Luminosity ToUnit(LuminosityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminosityUnit unitAsLuminosityUnit)) + if (!(unit is LuminosityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminosityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminosityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs index debe7b5dd7..e2f0fd7e70 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousFlux.g.cs @@ -139,6 +139,9 @@ public LuminousFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(LuminousFlux other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(LuminousFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) + if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousFluxUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public LuminousFlux ToUnit(LuminousFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousFluxUnit unitAsLuminousFluxUnit)) + if (!(unit is LuminousFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminousFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs index 82199274f5..b9646d2046 100644 --- a/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/LuminousIntensity.g.cs @@ -139,6 +139,9 @@ public LuminousIntensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(LuminousIntensity other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(LuminousIntensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) + if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return As(unitAsLuminousIntensityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public LuminousIntensity ToUnit(LuminousIntensityUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is LuminousIntensityUnit unitAsLuminousIntensityUnit)) + if (!(unit is LuminousIntensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(LuminousIntensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsLuminousIntensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs index 6103ff0bc9..6455bad9b0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticField.g.cs @@ -144,6 +144,9 @@ public MagneticField(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -606,7 +609,7 @@ public bool Equals(MagneticField other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -632,10 +635,9 @@ public override int GetHashCode() public double As(MagneticFieldUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -656,10 +658,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) + if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFieldUnit); + return (double)As(typedUnit); } /// @@ -706,10 +708,10 @@ public MagneticField ToUnit(MagneticFieldUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFieldUnit unitAsMagneticFieldUnit)) + if (!(unit is MagneticFieldUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFieldUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagneticFieldUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs index 4be6d9f2f7..2b49eab329 100644 --- a/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MagneticFlux.g.cs @@ -139,6 +139,9 @@ public MagneticFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(MagneticFlux other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(MagneticFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) + if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMagneticFluxUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public MagneticFlux ToUnit(MagneticFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagneticFluxUnit unitAsMagneticFluxUnit)) + if (!(unit is MagneticFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagneticFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagneticFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs index f9a7bc0f03..18b3dd108b 100644 --- a/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Magnetization.g.cs @@ -139,6 +139,9 @@ public Magnetization(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Magnetization other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(MagnetizationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) + if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return As(unitAsMagnetizationUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Magnetization ToUnit(MagnetizationUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MagnetizationUnit unitAsMagnetizationUnit)) + if (!(unit is MagnetizationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MagnetizationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMagnetizationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs index 16ecf48781..5e9c02fd49 100644 --- a/UnitsNet/GeneratedCode/Quantities/Mass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Mass.g.cs @@ -160,6 +160,9 @@ public Mass(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -999,7 +1002,7 @@ public bool Equals(Mass other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1025,10 +1028,9 @@ public override int GetHashCode() public double As(MassUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1049,10 +1051,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassUnit unitAsMassUnit)) + if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return As(unitAsMassUnit); + return (double)As(typedUnit); } /// @@ -1099,10 +1101,10 @@ public Mass ToUnit(MassUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassUnit unitAsMassUnit)) + if (!(unit is MassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs index 4e0adad314..a8d33a90bc 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassConcentration.g.cs @@ -187,6 +187,9 @@ public MassConcentration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1427,7 +1430,7 @@ public bool Equals(MassConcentration other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1453,10 +1456,9 @@ public override int GetHashCode() public double As(MassConcentrationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1477,10 +1479,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) + if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsMassConcentrationUnit); + return (double)As(typedUnit); } /// @@ -1527,10 +1529,10 @@ public MassConcentration ToUnit(MassConcentrationUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassConcentrationUnit unitAsMassConcentrationUnit)) + if (!(unit is MassConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassConcentrationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs index 30ce043051..cc6418a0a0 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlow.g.cs @@ -168,6 +168,9 @@ public MassFlow(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1118,7 +1121,7 @@ public bool Equals(MassFlow other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1144,10 +1147,9 @@ public override int GetHashCode() public double As(MassFlowUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1168,10 +1170,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassFlowUnit unitAsMassFlowUnit)) + if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return As(unitAsMassFlowUnit); + return (double)As(typedUnit); } /// @@ -1218,10 +1220,10 @@ public MassFlow ToUnit(MassFlowUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFlowUnit unitAsMassFlowUnit)) + if (!(unit is MassFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs index 48a6bb8a9a..6d64852955 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFlux.g.cs @@ -147,6 +147,9 @@ public MassFlux(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -717,7 +720,7 @@ public bool Equals(MassFlux other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -743,10 +746,9 @@ public override int GetHashCode() public double As(MassFluxUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -767,10 +769,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassFluxUnit unitAsMassFluxUnit)) + if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return As(unitAsMassFluxUnit); + return (double)As(typedUnit); } /// @@ -817,10 +819,10 @@ public MassFlux ToUnit(MassFluxUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFluxUnit unitAsMassFluxUnit)) + if (!(unit is MassFluxUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFluxUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFluxUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs index 2f4b8fe473..5974bbf5bf 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassFraction.g.cs @@ -162,6 +162,9 @@ public MassFraction(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -948,7 +951,7 @@ public bool Equals(MassFraction other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -974,10 +977,9 @@ public override int GetHashCode() public double As(MassFractionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -998,10 +1000,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassFractionUnit unitAsMassFractionUnit)) + if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return As(unitAsMassFractionUnit); + return (double)As(typedUnit); } /// @@ -1048,10 +1050,10 @@ public MassFraction ToUnit(MassFractionUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassFractionUnit unitAsMassFractionUnit)) + if (!(unit is MassFractionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassFractionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassFractionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs index 50edc3fea1..f448596381 100644 --- a/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MassMomentOfInertia.g.cs @@ -163,6 +163,9 @@ public MassMomentOfInertia(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1021,7 +1024,7 @@ public bool Equals(MassMomentOfInertia other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1047,10 +1050,9 @@ public override int GetHashCode() public double As(MassMomentOfInertiaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1071,10 +1073,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) + if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsMassMomentOfInertiaUnit); + return (double)As(typedUnit); } /// @@ -1121,10 +1123,10 @@ public MassMomentOfInertia ToUnit(MassMomentOfInertiaUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MassMomentOfInertiaUnit unitAsMassMomentOfInertiaUnit)) + if (!(unit is MassMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MassMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMassMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs index 3b11d29f12..cb779f6d62 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEnergy.g.cs @@ -138,6 +138,9 @@ public MolarEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(MolarEnergy other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(MolarEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) + if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEnergyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public MolarEnergy ToUnit(MolarEnergyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEnergyUnit unitAsMolarEnergyUnit)) + if (!(unit is MolarEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs index 857fcdaf4a..81ce32d495 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarEntropy.g.cs @@ -138,6 +138,9 @@ public MolarEntropy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(MolarEntropy other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(MolarEntropyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) + if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsMolarEntropyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public MolarEntropy ToUnit(MolarEntropyUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarEntropyUnit unitAsMolarEntropyUnit)) + if (!(unit is MolarEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs index 1bc540caa7..271c5a5113 100644 --- a/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/MolarMass.g.cs @@ -147,6 +147,9 @@ public MolarMass(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -729,7 +732,7 @@ public bool Equals(MolarMass other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -755,10 +758,9 @@ public override int GetHashCode() public double As(MolarMassUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -779,10 +781,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarMassUnit unitAsMolarMassUnit)) + if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return As(unitAsMolarMassUnit); + return (double)As(typedUnit); } /// @@ -829,10 +831,10 @@ public MolarMass ToUnit(MolarMassUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarMassUnit unitAsMolarMassUnit)) + if (!(unit is MolarMassUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarMassUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarMassUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs index 0403f2c28f..8f54f0fffe 100644 --- a/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Molarity.g.cs @@ -155,6 +155,9 @@ public Molarity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -695,7 +698,7 @@ public bool Equals(Molarity other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -721,10 +724,9 @@ public override int GetHashCode() public double As(MolarityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -745,10 +747,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is MolarityUnit unitAsMolarityUnit)) + if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return As(unitAsMolarityUnit); + return (double)As(typedUnit); } /// @@ -795,10 +797,10 @@ public Molarity ToUnit(MolarityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is MolarityUnit unitAsMolarityUnit)) + if (!(unit is MolarityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(MolarityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsMolarityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs index 8f4f597901..59a4be428f 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permeability.g.cs @@ -139,6 +139,9 @@ public Permeability(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Permeability other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(PermeabilityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) + if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPermeabilityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Permeability ToUnit(PermeabilityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermeabilityUnit unitAsPermeabilityUnit)) + if (!(unit is PermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPermeabilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs index a375f49800..b946e54c6c 100644 --- a/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Permittivity.g.cs @@ -139,6 +139,9 @@ public Permittivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Permittivity other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(PermittivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PermittivityUnit unitAsPermittivityUnit)) + if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return As(unitAsPermittivityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Permittivity ToUnit(PermittivityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PermittivityUnit unitAsPermittivityUnit)) + if (!(unit is PermittivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PermittivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPermittivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs index 3bf7765d64..6281deb4e6 100644 --- a/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PorousMediumPermeability.g.cs @@ -143,6 +143,9 @@ public PorousMediumPermeability(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -587,7 +590,7 @@ public bool Equals(PorousMediumPermeability other, double tolerance, ComparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -613,10 +616,9 @@ public override int GetHashCode() public double As(PorousMediumPermeabilityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -637,10 +639,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) + if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return As(unitAsPorousMediumPermeabilityUnit); + return (double)As(typedUnit); } /// @@ -687,10 +689,10 @@ public PorousMediumPermeability ToUnit(PorousMediumPermeabilityUnit unit, UnitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PorousMediumPermeabilityUnit unitAsPorousMediumPermeabilityUnit)) + if (!(unit is PorousMediumPermeabilityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PorousMediumPermeabilityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPorousMediumPermeabilityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Power.g.cs b/UnitsNet/GeneratedCode/Quantities/Power.g.cs index 843092f2dc..20db46edee 100644 --- a/UnitsNet/GeneratedCode/Quantities/Power.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Power.g.cs @@ -161,7 +161,8 @@ public Power(decimal value, UnitSystem unitSystem) /// public decimal Value => _value; - double IQuantity.Value => (double) _value; + /// + QuantityValue IQuantity.Value => _value; /// decimal IDecimalQuantity.Value => _value; @@ -187,134 +188,134 @@ public Power(decimal value, UnitSystem unitSystem) #region Conversion Properties /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BoilerHorsepower => As(PowerUnit.BoilerHorsepower); + public decimal BoilerHorsepower => As(PowerUnit.BoilerHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); + public decimal BritishThermalUnitsPerHour => As(PowerUnit.BritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Decawatts => As(PowerUnit.Decawatt); + public decimal Decawatts => As(PowerUnit.Decawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Deciwatts => As(PowerUnit.Deciwatt); + public decimal Deciwatts => As(PowerUnit.Deciwatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); + public decimal ElectricalHorsepower => As(PowerUnit.ElectricalHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Femtowatts => As(PowerUnit.Femtowatt); + public decimal Femtowatts => As(PowerUnit.Femtowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); + public decimal GigajoulesPerHour => As(PowerUnit.GigajoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Gigawatts => As(PowerUnit.Gigawatt); + public decimal Gigawatts => As(PowerUnit.Gigawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); + public decimal HydraulicHorsepower => As(PowerUnit.HydraulicHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double JoulesPerHour => As(PowerUnit.JoulePerHour); + public decimal JoulesPerHour => As(PowerUnit.JoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); + public decimal KilobritishThermalUnitsPerHour => As(PowerUnit.KilobritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); + public decimal KilojoulesPerHour => As(PowerUnit.KilojoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Kilowatts => As(PowerUnit.Kilowatt); + public decimal Kilowatts => As(PowerUnit.Kilowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); + public decimal MechanicalHorsepower => As(PowerUnit.MechanicalHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); + public decimal MegabritishThermalUnitsPerHour => As(PowerUnit.MegabritishThermalUnitPerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); + public decimal MegajoulesPerHour => As(PowerUnit.MegajoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Megawatts => As(PowerUnit.Megawatt); + public decimal Megawatts => As(PowerUnit.Megawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MetricHorsepower => As(PowerUnit.MetricHorsepower); + public decimal MetricHorsepower => As(PowerUnit.MetricHorsepower); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Microwatts => As(PowerUnit.Microwatt); + public decimal Microwatts => As(PowerUnit.Microwatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); + public decimal MillijoulesPerHour => As(PowerUnit.MillijoulePerHour); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Milliwatts => As(PowerUnit.Milliwatt); + public decimal Milliwatts => As(PowerUnit.Milliwatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Nanowatts => As(PowerUnit.Nanowatt); + public decimal Nanowatts => As(PowerUnit.Nanowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Petawatts => As(PowerUnit.Petawatt); + public decimal Petawatts => As(PowerUnit.Petawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Picowatts => As(PowerUnit.Picowatt); + public decimal Picowatts => As(PowerUnit.Picowatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Terawatts => As(PowerUnit.Terawatt); + public decimal Terawatts => As(PowerUnit.Terawatt); /// - /// Gets a value of this quantity converted into + /// Gets a value of this quantity converted into /// - public double Watts => As(PowerUnit.Watt); + public decimal Watts => As(PowerUnit.Watt); #endregion @@ -328,7 +329,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) { // Register in unit converter: BaseUnit -> PowerUnit unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BoilerHorsepower, quantity => new Power(quantity.Value / 9812.5m, PowerUnit.BoilerHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.293071m, PowerUnit.BritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.BritishThermalUnitPerHour, quantity => new Power(quantity.Value / 0.29307107017m, PowerUnit.BritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Decawatt, quantity => new Power((quantity.Value) / 1e1m, PowerUnit.Decawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Deciwatt, quantity => new Power((quantity.Value) / 1e-1m, PowerUnit.Deciwatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.ElectricalHorsepower, quantity => new Power(quantity.Value / 746m, PowerUnit.ElectricalHorsepower)); @@ -337,11 +338,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Gigawatt, quantity => new Power((quantity.Value) / 1e9m, PowerUnit.Gigawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.HydraulicHorsepower, quantity => new Power(quantity.Value / 745.69988145m, PowerUnit.HydraulicHorsepower)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.JoulePerHour, quantity => new Power(quantity.Value * 3600m, PowerUnit.JoulePerHour)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilobritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e3m, PowerUnit.KilobritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.KilojoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e3m, PowerUnit.KilojoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Kilowatt, quantity => new Power((quantity.Value) / 1e3m, PowerUnit.Kilowatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MechanicalHorsepower, quantity => new Power(quantity.Value / 745.69m, PowerUnit.MechanicalHorsepower)); - unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.293071m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); + unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegabritishThermalUnitPerHour, quantity => new Power((quantity.Value / 0.29307107017m) / 1e6m, PowerUnit.MegabritishThermalUnitPerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MegajoulePerHour, quantity => new Power((quantity.Value * 3600m) / 1e6m, PowerUnit.MegajoulePerHour)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.Megawatt, quantity => new Power((quantity.Value) / 1e6m, PowerUnit.Megawatt)); unitConverter.SetConversionFunction(PowerUnit.Watt, PowerUnit.MetricHorsepower, quantity => new Power(quantity.Value / 735.49875m, PowerUnit.MetricHorsepower)); @@ -358,7 +359,7 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) // Register in unit converter: PowerUnit -> BaseUnit unitConverter.SetConversionFunction(PowerUnit.BoilerHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 9812.5m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.293071m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.BritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power(quantity.Value * 0.29307107017m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Decawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Deciwatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e-1m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.ElectricalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 746m, PowerUnit.Watt)); @@ -367,11 +368,11 @@ internal static void RegisterDefaultConversions(UnitConverter unitConverter) unitConverter.SetConversionFunction(PowerUnit.Gigawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e9m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.HydraulicHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69988145m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.JoulePerHour, PowerUnit.Watt, quantity => new Power(quantity.Value / 3600m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e3m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.KilobritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.KilojoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Kilowatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e3m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MechanicalHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 745.69m, PowerUnit.Watt)); - unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.293071m) * 1e6m, PowerUnit.Watt)); + unitConverter.SetConversionFunction(PowerUnit.MegabritishThermalUnitPerHour, PowerUnit.Watt, quantity => new Power((quantity.Value * 0.29307107017m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MegajoulePerHour, PowerUnit.Watt, quantity => new Power((quantity.Value / 3600m) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.Megawatt, PowerUnit.Watt, quantity => new Power((quantity.Value) * 1e6m, PowerUnit.Watt)); unitConverter.SetConversionFunction(PowerUnit.MetricHorsepower, PowerUnit.Watt, quantity => new Power(quantity.Value * 735.49875m, PowerUnit.Watt)); @@ -895,7 +896,7 @@ public static bool TryParseUnit(string str, IFormatProvider? provider, out Power } /// Get ratio value from dividing by . - public static double operator /(Power left, Power right) + public static decimal operator /(Power left, Power right) { return left.Watts / right.Watts; } @@ -983,13 +984,13 @@ public int CompareTo(Power other) /// The absolute or relative tolerance value. Must be greater than or equal to 0. /// The comparison type: either relative or absolute. /// True if the absolute difference between the two values is not greater than the specified relative or absolute tolerance. - public bool Equals(Power other, double tolerance, ComparisonType comparisonType) + public bool Equals(Power other, decimal tolerance, ComparisonType comparisonType) { if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; - double otherValueInThisUnits = other.As(this.Unit); + decimal thisValue = this.Value; + decimal otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); } @@ -1011,17 +1012,21 @@ public override int GetHashCode() /// Convert to the unit representation . /// /// Value converted to the specified unit. - public double As(PowerUnit unit) + public decimal As(PowerUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; + + return GetValueAs(unit); + } - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + double IQuantity.As(PowerUnit unit) + { + return (double)As(unit); } /// - public double As(UnitSystem unitSystem) + public decimal As(UnitSystem unitSystem) { if (unitSystem is null) throw new ArgumentNullException(nameof(unitSystem)); @@ -1035,13 +1040,19 @@ public double As(UnitSystem unitSystem) return As(firstUnitInfo.Value); } + /// + double IQuantity.As(UnitSystem unitSystem) + { + return (double)As(unitSystem); + } + /// double IQuantity.As(Enum unit) { - if (!(unit is PowerUnit unitAsPowerUnit)) + if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return As(unitAsPowerUnit); + return (double)As(typedUnit); } /// @@ -1088,10 +1099,10 @@ public Power ToUnit(PowerUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerUnit unitAsPowerUnit)) + if (!(unit is PowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs index a13b01eef5..203f70848c 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerDensity.g.cs @@ -179,6 +179,9 @@ public PowerDensity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1325,7 +1328,7 @@ public bool Equals(PowerDensity other, double tolerance, ComparisonType comparis if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1351,10 +1354,9 @@ public override int GetHashCode() public double As(PowerDensityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1375,10 +1377,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) + if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return As(unitAsPowerDensityUnit); + return (double)As(typedUnit); } /// @@ -1425,10 +1427,10 @@ public PowerDensity ToUnit(PowerDensityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerDensityUnit unitAsPowerDensityUnit)) + if (!(unit is PowerDensityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerDensityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerDensityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs index e2297bd8ec..d04c12a898 100644 --- a/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PowerRatio.g.cs @@ -137,6 +137,9 @@ public PowerRatio(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -535,7 +538,7 @@ public bool Equals(PowerRatio other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -561,10 +564,9 @@ public override int GetHashCode() public double As(PowerRatioUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -585,10 +587,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) + if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return As(unitAsPowerRatioUnit); + return (double)As(typedUnit); } /// @@ -635,10 +637,10 @@ public PowerRatio ToUnit(PowerRatioUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PowerRatioUnit unitAsPowerRatioUnit)) + if (!(unit is PowerRatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PowerRatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPowerRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs index 12ab6f58c5..96f98ab024 100644 --- a/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Pressure.g.cs @@ -182,6 +182,9 @@ public Pressure(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1413,7 +1416,7 @@ public bool Equals(Pressure other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1439,10 +1442,9 @@ public override int GetHashCode() public double As(PressureUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1463,10 +1465,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PressureUnit unitAsPressureUnit)) + if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return As(unitAsPressureUnit); + return (double)As(typedUnit); } /// @@ -1513,10 +1515,10 @@ public Pressure ToUnit(PressureUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureUnit unitAsPressureUnit)) + if (!(unit is PressureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPressureUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs index 7ee7d7f344..0f4f5c9cbd 100644 --- a/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/PressureChangeRate.g.cs @@ -149,6 +149,9 @@ public PressureChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -769,7 +772,7 @@ public bool Equals(PressureChangeRate other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -795,10 +798,9 @@ public override int GetHashCode() public double As(PressureChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -819,10 +821,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) + if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsPressureChangeRateUnit); + return (double)As(typedUnit); } /// @@ -869,10 +871,10 @@ public PressureChangeRate ToUnit(PressureChangeRateUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is PressureChangeRateUnit unitAsPressureChangeRateUnit)) + if (!(unit is PressureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(PressureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsPressureChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs index 4477fbdf39..792448e7b3 100644 --- a/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Ratio.g.cs @@ -141,6 +141,9 @@ public Ratio(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(Ratio other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(RatioUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RatioUnit unitAsRatioUnit)) + if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return As(unitAsRatioUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public Ratio ToUnit(RatioUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioUnit unitAsRatioUnit)) + if (!(unit is RatioUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRatioUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs index 9a19832e06..bb1d5c85d5 100644 --- a/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RatioChangeRate.g.cs @@ -137,6 +137,9 @@ public RatioChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -527,7 +530,7 @@ public bool Equals(RatioChangeRate other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -553,10 +556,9 @@ public override int GetHashCode() public double As(RatioChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -577,10 +579,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) + if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsRatioChangeRateUnit); + return (double)As(typedUnit); } /// @@ -627,10 +629,10 @@ public RatioChangeRate ToUnit(RatioChangeRateUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RatioChangeRateUnit unitAsRatioChangeRateUnit)) + if (!(unit is RatioChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RatioChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRatioChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs index b46c2e5303..74233fc07e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactiveEnergy.g.cs @@ -138,6 +138,9 @@ public ReactiveEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(ReactiveEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(ReactiveEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) + if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsReactiveEnergyUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public ReactiveEnergy ToUnit(ReactiveEnergyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactiveEnergyUnit unitAsReactiveEnergyUnit)) + if (!(unit is ReactiveEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactiveEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReactiveEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs index 12ba60dcba..351dbd214e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReactivePower.g.cs @@ -139,6 +139,9 @@ public ReactivePower(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(ReactivePower other, double tolerance, ComparisonType compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(ReactivePowerUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) + if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return As(unitAsReactivePowerUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public ReactivePower ToUnit(ReactivePowerUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReactivePowerUnit unitAsReactivePowerUnit)) + if (!(unit is ReactivePowerUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReactivePowerUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReactivePowerUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs index fa18c54017..80fc416a3f 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalArea.g.cs @@ -149,6 +149,9 @@ public ReciprocalArea(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -701,7 +704,7 @@ public bool Equals(ReciprocalArea other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -727,10 +730,9 @@ public override int GetHashCode() public double As(ReciprocalAreaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -751,10 +753,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) + if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return As(unitAsReciprocalAreaUnit); + return (double)As(typedUnit); } /// @@ -801,10 +803,10 @@ public ReciprocalArea ToUnit(ReciprocalAreaUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalAreaUnit unitAsReciprocalAreaUnit)) + if (!(unit is ReciprocalAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalAreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReciprocalAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs index db5125af45..9293599a58 100644 --- a/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ReciprocalLength.g.cs @@ -148,6 +148,9 @@ public ReciprocalLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -682,7 +685,7 @@ public bool Equals(ReciprocalLength other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -708,10 +711,9 @@ public override int GetHashCode() public double As(ReciprocalLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -732,10 +734,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) + if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return As(unitAsReciprocalLengthUnit); + return (double)As(typedUnit); } /// @@ -782,10 +784,10 @@ public ReciprocalLength ToUnit(ReciprocalLengthUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ReciprocalLengthUnit unitAsReciprocalLengthUnit)) + if (!(unit is ReciprocalLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ReciprocalLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsReciprocalLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs index b91d29a949..cb554e6454 100644 --- a/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RelativeHumidity.g.cs @@ -136,6 +136,9 @@ public RelativeHumidity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(RelativeHumidity other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(RelativeHumidityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) + if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return As(unitAsRelativeHumidityUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public RelativeHumidity ToUnit(RelativeHumidityUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RelativeHumidityUnit unitAsRelativeHumidityUnit)) + if (!(unit is RelativeHumidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RelativeHumidityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRelativeHumidityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs index 82e5e89d70..2004f7795d 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalAcceleration.g.cs @@ -139,6 +139,9 @@ public RotationalAcceleration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(RotationalAcceleration other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(RotationalAccelerationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) + if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalAccelerationUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public RotationalAcceleration ToUnit(RotationalAccelerationUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalAccelerationUnit unitAsRotationalAccelerationUnit)) + if (!(unit is RotationalAccelerationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalAccelerationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalAccelerationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs index 85e4e1cff9..d3785cd75e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalSpeed.g.cs @@ -148,6 +148,9 @@ public RotationalSpeed(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -748,7 +751,7 @@ public bool Equals(RotationalSpeed other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -774,10 +777,9 @@ public override int GetHashCode() public double As(RotationalSpeedUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -798,10 +800,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) + if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalSpeedUnit); + return (double)As(typedUnit); } /// @@ -848,10 +850,10 @@ public RotationalSpeed ToUnit(RotationalSpeedUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalSpeedUnit unitAsRotationalSpeedUnit)) + if (!(unit is RotationalSpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalSpeedUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalSpeedUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs index dd3526719d..ffa39406f7 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffness.g.cs @@ -168,6 +168,9 @@ public RotationalStiffness(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1116,7 +1119,7 @@ public bool Equals(RotationalStiffness other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1142,10 +1145,9 @@ public override int GetHashCode() public double As(RotationalStiffnessUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1166,10 +1168,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) + if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessUnit); + return (double)As(typedUnit); } /// @@ -1216,10 +1218,10 @@ public RotationalStiffness ToUnit(RotationalStiffnessUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessUnit unitAsRotationalStiffnessUnit)) + if (!(unit is RotationalStiffnessUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalStiffnessUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs index 603b45d53a..9b29552a4e 100644 --- a/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/RotationalStiffnessPerLength.g.cs @@ -140,6 +140,9 @@ public RotationalStiffnessPerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -584,7 +587,7 @@ public bool Equals(RotationalStiffnessPerLength other, double tolerance, Compari if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -610,10 +613,9 @@ public override int GetHashCode() public double As(RotationalStiffnessPerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -634,10 +636,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsRotationalStiffnessPerLengthUnit); + return (double)As(typedUnit); } /// @@ -684,10 +686,10 @@ public RotationalStiffnessPerLength ToUnit(RotationalStiffnessPerLengthUnit unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is RotationalStiffnessPerLengthUnit unitAsRotationalStiffnessPerLengthUnit)) + if (!(unit is RotationalStiffnessPerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(RotationalStiffnessPerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsRotationalStiffnessPerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs index 4b70a95229..12bc815bd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Scalar.g.cs @@ -136,6 +136,9 @@ public Scalar(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(Scalar other, double tolerance, ComparisonType comparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(ScalarUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ScalarUnit unitAsScalarUnit)) + if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return As(unitAsScalarUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public Scalar ToUnit(ScalarUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ScalarUnit unitAsScalarUnit)) + if (!(unit is ScalarUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ScalarUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsScalarUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs index 9a4b65cb3d..d5deb55d7a 100644 --- a/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SolidAngle.g.cs @@ -139,6 +139,9 @@ public SolidAngle(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(SolidAngle other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(SolidAngleUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) + if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return As(unitAsSolidAngleUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public SolidAngle ToUnit(SolidAngleUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SolidAngleUnit unitAsSolidAngleUnit)) + if (!(unit is SolidAngleUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SolidAngleUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSolidAngleUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs index 454fa20918..8a9ec48aae 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEnergy.g.cs @@ -167,6 +167,9 @@ public SpecificEnergy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1043,7 +1046,7 @@ public bool Equals(SpecificEnergy other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1069,10 +1072,9 @@ public override int GetHashCode() public double As(SpecificEnergyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1093,10 +1095,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) + if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEnergyUnit); + return (double)As(typedUnit); } /// @@ -1143,10 +1145,10 @@ public SpecificEnergy ToUnit(SpecificEnergyUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEnergyUnit unitAsSpecificEnergyUnit)) + if (!(unit is SpecificEnergyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEnergyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificEnergyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs index 26c1ea1e6f..952769e807 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificEntropy.g.cs @@ -144,6 +144,9 @@ public SpecificEntropy(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -660,7 +663,7 @@ public bool Equals(SpecificEntropy other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -686,10 +689,9 @@ public override int GetHashCode() public double As(SpecificEntropyUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -710,10 +712,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) + if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificEntropyUnit); + return (double)As(typedUnit); } /// @@ -760,10 +762,10 @@ public SpecificEntropy ToUnit(SpecificEntropyUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificEntropyUnit unitAsSpecificEntropyUnit)) + if (!(unit is SpecificEntropyUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificEntropyUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificEntropyUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs index e295f67c8e..1a1e9c4147 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificFuelConsumption.g.cs @@ -142,6 +142,9 @@ public SpecificFuelConsumption(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -568,7 +571,7 @@ public bool Equals(SpecificFuelConsumption other, double tolerance, ComparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -594,10 +597,9 @@ public override int GetHashCode() public double As(SpecificFuelConsumptionUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -618,10 +620,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) + if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificFuelConsumptionUnit); + return (double)As(typedUnit); } /// @@ -668,10 +670,10 @@ public SpecificFuelConsumption ToUnit(SpecificFuelConsumptionUnit unit, UnitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificFuelConsumptionUnit unitAsSpecificFuelConsumptionUnit)) + if (!(unit is SpecificFuelConsumptionUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificFuelConsumptionUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificFuelConsumptionUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs index f15fc45a52..2f564d7bd7 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificVolume.g.cs @@ -138,6 +138,9 @@ public SpecificVolume(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -546,7 +549,7 @@ public bool Equals(SpecificVolume other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -572,10 +575,9 @@ public override int GetHashCode() public double As(SpecificVolumeUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -596,10 +598,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) + if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificVolumeUnit); + return (double)As(typedUnit); } /// @@ -646,10 +648,10 @@ public SpecificVolume ToUnit(SpecificVolumeUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificVolumeUnit unitAsSpecificVolumeUnit)) + if (!(unit is SpecificVolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificVolumeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificVolumeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs index 1698dbf5e8..c70b66490f 100644 --- a/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/SpecificWeight.g.cs @@ -155,6 +155,9 @@ public SpecificWeight(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -815,7 +818,7 @@ public bool Equals(SpecificWeight other, double tolerance, ComparisonType compar if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -841,10 +844,9 @@ public override int GetHashCode() public double As(SpecificWeightUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -865,10 +867,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) + if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return As(unitAsSpecificWeightUnit); + return (double)As(typedUnit); } /// @@ -915,10 +917,10 @@ public SpecificWeight ToUnit(SpecificWeightUnit unit, UnitConverter unitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpecificWeightUnit unitAsSpecificWeightUnit)) + if (!(unit is SpecificWeightUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpecificWeightUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpecificWeightUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs index f064d928b9..fbb92e88d4 100644 --- a/UnitsNet/GeneratedCode/Quantities/Speed.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Speed.g.cs @@ -167,6 +167,9 @@ public Speed(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1120,7 +1123,7 @@ public bool Equals(Speed other, double tolerance, ComparisonType comparisonType) if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1146,10 +1149,9 @@ public override int GetHashCode() public double As(SpeedUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1170,10 +1172,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is SpeedUnit unitAsSpeedUnit)) + if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return As(unitAsSpeedUnit); + return (double)As(typedUnit); } /// @@ -1220,10 +1222,10 @@ public Speed ToUnit(SpeedUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is SpeedUnit unitAsSpeedUnit)) + if (!(unit is SpeedUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(SpeedUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsSpeedUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs index 9267650cd1..5d79ef2ed3 100644 --- a/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/StandardVolumeFlow.g.cs @@ -144,6 +144,9 @@ public StandardVolumeFlow(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -660,7 +663,7 @@ public bool Equals(StandardVolumeFlow other, double tolerance, ComparisonType co if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -686,10 +689,9 @@ public override int GetHashCode() public double As(StandardVolumeFlowUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -710,10 +712,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) + if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsStandardVolumeFlowUnit); + return (double)As(typedUnit); } /// @@ -760,10 +762,10 @@ public StandardVolumeFlow ToUnit(StandardVolumeFlowUnit unit, UnitConverter unit /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is StandardVolumeFlowUnit unitAsStandardVolumeFlowUnit)) + if (!(unit is StandardVolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(StandardVolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsStandardVolumeFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs index 9b314a7349..68033f0271 100644 --- a/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Temperature.g.cs @@ -145,6 +145,9 @@ public Temperature(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -633,7 +636,7 @@ public bool Equals(Temperature other, double tolerance, ComparisonType compariso if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -659,10 +662,9 @@ public override int GetHashCode() public double As(TemperatureUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -683,10 +685,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureUnit unitAsTemperatureUnit)) + if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureUnit); + return (double)As(typedUnit); } /// @@ -733,10 +735,10 @@ public Temperature ToUnit(TemperatureUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureUnit unitAsTemperatureUnit)) + if (!(unit is TemperatureUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs index 0f3704b67e..ab7d76e659 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureChangeRate.g.cs @@ -145,6 +145,9 @@ public TemperatureChangeRate(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -679,7 +682,7 @@ public bool Equals(TemperatureChangeRate other, double tolerance, ComparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -705,10 +708,9 @@ public override int GetHashCode() public double As(TemperatureChangeRateUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -729,10 +731,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) + if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureChangeRateUnit); + return (double)As(typedUnit); } /// @@ -779,10 +781,10 @@ public TemperatureChangeRate ToUnit(TemperatureChangeRateUnit unit, UnitConverte /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureChangeRateUnit unitAsTemperatureChangeRateUnit)) + if (!(unit is TemperatureChangeRateUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureChangeRateUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureChangeRateUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs index 5fb8eaf2ac..2eb92473f1 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureDelta.g.cs @@ -144,6 +144,9 @@ public TemperatureDelta(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -660,7 +663,7 @@ public bool Equals(TemperatureDelta other, double tolerance, ComparisonType comp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -686,10 +689,9 @@ public override int GetHashCode() public double As(TemperatureDeltaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -710,10 +712,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) + if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureDeltaUnit); + return (double)As(typedUnit); } /// @@ -760,10 +762,10 @@ public TemperatureDelta ToUnit(TemperatureDeltaUnit unit, UnitConverter unitConv /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureDeltaUnit unitAsTemperatureDeltaUnit)) + if (!(unit is TemperatureDeltaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureDeltaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureDeltaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs index aaff14abca..78120e21e4 100644 --- a/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TemperatureGradient.g.cs @@ -139,6 +139,9 @@ public TemperatureGradient(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -565,7 +568,7 @@ public bool Equals(TemperatureGradient other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -591,10 +594,9 @@ public override int GetHashCode() public double As(TemperatureGradientUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -615,10 +617,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) + if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return As(unitAsTemperatureGradientUnit); + return (double)As(typedUnit); } /// @@ -665,10 +667,10 @@ public TemperatureGradient ToUnit(TemperatureGradientUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TemperatureGradientUnit unitAsTemperatureGradientUnit)) + if (!(unit is TemperatureGradientUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TemperatureGradientUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTemperatureGradientUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs index 0da7968b47..19b7e51a32 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalConductivity.g.cs @@ -140,6 +140,9 @@ public ThermalConductivity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -530,7 +533,7 @@ public bool Equals(ThermalConductivity other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -556,10 +559,9 @@ public override int GetHashCode() public double As(ThermalConductivityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -580,10 +582,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) + if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return As(unitAsThermalConductivityUnit); + return (double)As(typedUnit); } /// @@ -630,10 +632,10 @@ public ThermalConductivity ToUnit(ThermalConductivityUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalConductivityUnit unitAsThermalConductivityUnit)) + if (!(unit is ThermalConductivityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalConductivityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsThermalConductivityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs index 7ab40b994c..bff304295e 100644 --- a/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/ThermalResistance.g.cs @@ -141,6 +141,9 @@ public ThermalResistance(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(ThermalResistance other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(ThermalResistanceUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) + if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return As(unitAsThermalResistanceUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public ThermalResistance ToUnit(ThermalResistanceUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is ThermalResistanceUnit unitAsThermalResistanceUnit)) + if (!(unit is ThermalResistanceUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(ThermalResistanceUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsThermalResistanceUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs index 2a512729ec..87ab142d53 100644 --- a/UnitsNet/GeneratedCode/Quantities/Torque.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Torque.g.cs @@ -160,6 +160,9 @@ public Torque(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -967,7 +970,7 @@ public bool Equals(Torque other, double tolerance, ComparisonType comparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -993,10 +996,9 @@ public override int GetHashCode() public double As(TorqueUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1017,10 +1019,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TorqueUnit unitAsTorqueUnit)) + if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return As(unitAsTorqueUnit); + return (double)As(typedUnit); } /// @@ -1067,10 +1069,10 @@ public Torque ToUnit(TorqueUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorqueUnit unitAsTorqueUnit)) + if (!(unit is TorqueUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorqueUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTorqueUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs index 4fd2f5f8ef..b714941438 100644 --- a/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/TorquePerLength.g.cs @@ -156,6 +156,9 @@ public TorquePerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -891,7 +894,7 @@ public bool Equals(TorquePerLength other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -917,10 +920,9 @@ public override int GetHashCode() public double As(TorquePerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -941,10 +943,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) + if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsTorquePerLengthUnit); + return (double)As(typedUnit); } /// @@ -991,10 +993,10 @@ public TorquePerLength ToUnit(TorquePerLengthUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TorquePerLengthUnit unitAsTorquePerLengthUnit)) + if (!(unit is TorquePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TorquePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTorquePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs index f94f7592e1..821bbdbeac 100644 --- a/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Turbidity.g.cs @@ -139,6 +139,9 @@ public Turbidity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -511,7 +514,7 @@ public bool Equals(Turbidity other, double tolerance, ComparisonType comparisonT if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -537,10 +540,9 @@ public override int GetHashCode() public double As(TurbidityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -561,10 +563,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is TurbidityUnit unitAsTurbidityUnit)) + if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return As(unitAsTurbidityUnit); + return (double)As(typedUnit); } /// @@ -611,10 +613,10 @@ public Turbidity ToUnit(TurbidityUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is TurbidityUnit unitAsTurbidityUnit)) + if (!(unit is TurbidityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(TurbidityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsTurbidityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs index 454db0c919..e90434cf0a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VitaminA.g.cs @@ -136,6 +136,9 @@ public VitaminA(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -508,7 +511,7 @@ public bool Equals(VitaminA other, double tolerance, ComparisonType comparisonTy if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -534,10 +537,9 @@ public override int GetHashCode() public double As(VitaminAUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -558,10 +560,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VitaminAUnit unitAsVitaminAUnit)) + if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return As(unitAsVitaminAUnit); + return (double)As(typedUnit); } /// @@ -608,10 +610,10 @@ public VitaminA ToUnit(VitaminAUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VitaminAUnit unitAsVitaminAUnit)) + if (!(unit is VitaminAUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VitaminAUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVitaminAUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs index 2d54789723..608929c55a 100644 --- a/UnitsNet/GeneratedCode/Quantities/Volume.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/Volume.g.cs @@ -187,6 +187,9 @@ public Volume(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1524,7 +1527,7 @@ public bool Equals(Volume other, double tolerance, ComparisonType comparisonType if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1550,10 +1553,9 @@ public override int GetHashCode() public double As(VolumeUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1574,10 +1576,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeUnit unitAsVolumeUnit)) + if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeUnit); + return (double)As(typedUnit); } /// @@ -1624,10 +1626,10 @@ public Volume ToUnit(VolumeUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeUnit unitAsVolumeUnit)) + if (!(unit is VolumeUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs index 26d1de1beb..0a8c9d086a 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeConcentration.g.cs @@ -158,6 +158,9 @@ public VolumeConcentration(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -872,7 +875,7 @@ public bool Equals(VolumeConcentration other, double tolerance, ComparisonType c if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -898,10 +901,9 @@ public override int GetHashCode() public double As(VolumeConcentrationUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -922,10 +924,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) + if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeConcentrationUnit); + return (double)As(typedUnit); } /// @@ -972,10 +974,10 @@ public VolumeConcentration ToUnit(VolumeConcentrationUnit unit, UnitConverter un /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeConcentrationUnit unitAsVolumeConcentrationUnit)) + if (!(unit is VolumeConcentrationUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeConcentrationUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeConcentrationUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs index 14cecc5941..3094b62967 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlow.g.cs @@ -197,6 +197,9 @@ public VolumeFlow(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -1694,7 +1697,7 @@ public bool Equals(VolumeFlow other, double tolerance, ComparisonType comparison if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -1720,10 +1723,9 @@ public override int GetHashCode() public double As(VolumeFlowUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -1744,10 +1746,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) + if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowUnit); + return (double)As(typedUnit); } /// @@ -1794,10 +1796,10 @@ public VolumeFlow ToUnit(VolumeFlowUnit unit, UnitConverter unitConverter) /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowUnit unitAsVolumeFlowUnit)) + if (!(unit is VolumeFlowUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeFlowUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs index 93e98d1704..eaf93cc7f5 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumeFlowPerArea.g.cs @@ -137,6 +137,9 @@ public VolumeFlowPerArea(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -527,7 +530,7 @@ public bool Equals(VolumeFlowPerArea other, double tolerance, ComparisonType com if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -553,10 +556,9 @@ public override int GetHashCode() public double As(VolumeFlowPerAreaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -577,10 +579,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) + if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return As(unitAsVolumeFlowPerAreaUnit); + return (double)As(typedUnit); } /// @@ -627,10 +629,10 @@ public VolumeFlowPerArea ToUnit(VolumeFlowPerAreaUnit unit, UnitConverter unitCo /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumeFlowPerAreaUnit unitAsVolumeFlowPerAreaUnit)) + if (!(unit is VolumeFlowPerAreaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumeFlowPerAreaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumeFlowPerAreaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs index d07460ee38..875298e59b 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumePerLength.g.cs @@ -142,6 +142,9 @@ public VolumePerLength(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -622,7 +625,7 @@ public bool Equals(VolumePerLength other, double tolerance, ComparisonType compa if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -648,10 +651,9 @@ public override int GetHashCode() public double As(VolumePerLengthUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -672,10 +674,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) + if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return As(unitAsVolumePerLengthUnit); + return (double)As(typedUnit); } /// @@ -722,10 +724,10 @@ public VolumePerLength ToUnit(VolumePerLengthUnit unit, UnitConverter unitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumePerLengthUnit unitAsVolumePerLengthUnit)) + if (!(unit is VolumePerLengthUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumePerLengthUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumePerLengthUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs index 3ca758cbc0..883c6b5c7f 100644 --- a/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/VolumetricHeatCapacity.g.cs @@ -147,6 +147,9 @@ public VolumetricHeatCapacity(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -663,7 +666,7 @@ public bool Equals(VolumetricHeatCapacity other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -689,10 +692,9 @@ public override int GetHashCode() public double As(VolumetricHeatCapacityUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -713,10 +715,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) + if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return As(unitAsVolumetricHeatCapacityUnit); + return (double)As(typedUnit); } /// @@ -763,10 +765,10 @@ public VolumetricHeatCapacity ToUnit(VolumetricHeatCapacityUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is VolumetricHeatCapacityUnit unitAsVolumetricHeatCapacityUnit)) + if (!(unit is VolumetricHeatCapacityUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(VolumetricHeatCapacityUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsVolumetricHeatCapacityUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs index 2ef276467a..0c4f7e54fc 100644 --- a/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs +++ b/UnitsNet/GeneratedCode/Quantities/WarpingMomentOfInertia.g.cs @@ -141,6 +141,9 @@ public WarpingMomentOfInertia(double value, UnitSystem unitSystem) /// public double Value => _value; + /// + QuantityValue IQuantity.Value => _value; + Enum IQuantity.Unit => Unit; /// @@ -603,7 +606,7 @@ public bool Equals(WarpingMomentOfInertia other, double tolerance, ComparisonTyp if (tolerance < 0) throw new ArgumentOutOfRangeException("tolerance", "Tolerance must be greater than or equal to 0."); - double thisValue = (double)this.Value; + double thisValue = this.Value; double otherValueInThisUnits = other.As(this.Unit); return UnitsNet.Comparison.Equals(thisValue, otherValueInThisUnits, tolerance, comparisonType); @@ -629,10 +632,9 @@ public override int GetHashCode() public double As(WarpingMomentOfInertiaUnit unit) { if (Unit == unit) - return Convert.ToDouble(Value); + return Value; - var converted = GetValueAs(unit); - return Convert.ToDouble(converted); + return GetValueAs(unit); } /// @@ -653,10 +655,10 @@ public double As(UnitSystem unitSystem) /// double IQuantity.As(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) + if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return As(unitAsWarpingMomentOfInertiaUnit); + return (double)As(typedUnit); } /// @@ -703,10 +705,10 @@ public WarpingMomentOfInertia ToUnit(WarpingMomentOfInertiaUnit unit, UnitConver /// IQuantity IQuantity.ToUnit(Enum unit) { - if (!(unit is WarpingMomentOfInertiaUnit unitAsWarpingMomentOfInertiaUnit)) + if (!(unit is WarpingMomentOfInertiaUnit typedUnit)) throw new ArgumentException($"The given unit is of type {unit.GetType()}. Only {typeof(WarpingMomentOfInertiaUnit)} is supported.", nameof(unit)); - return ToUnit(unitAsWarpingMomentOfInertiaUnit, DefaultConversionFunctions); + return ToUnit(typedUnit, DefaultConversionFunctions); } /// diff --git a/UnitsNet/IQuantity.cs b/UnitsNet/IQuantity.cs index 48445422fb..92d974c5bc 100644 --- a/UnitsNet/IQuantity.cs +++ b/UnitsNet/IQuantity.cs @@ -46,7 +46,7 @@ public interface IQuantity : IFormattable /// /// The value this quantity was constructed with. See also . /// - double Value { get; } + QuantityValue Value { get; } /// /// Converts this to an in the given . diff --git a/UnitsNet/QuantityFormatter.cs b/UnitsNet/QuantityFormatter.cs index 8c7fdeb613..6948b14651 100644 --- a/UnitsNet/QuantityFormatter.cs +++ b/UnitsNet/QuantityFormatter.cs @@ -180,8 +180,10 @@ private static string FormatUntrimmed(IQuantity quantity, private static string ToStringWithSignificantDigitsAfterRadix(IQuantity quantity, IFormatProvider formatProvider, int number) where TUnitType : Enum { - string formatForSignificantDigits = UnitFormatter.GetFormat(quantity.Value, number); - object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, quantity.Value, formatProvider, Enumerable.Empty()); + // When a fixed number of digits after the dot is expected, double and decimal behave the same. + var value = (double)quantity.Value; + string formatForSignificantDigits = UnitFormatter.GetFormat(value, number); + object[] formatArgs = UnitFormatter.GetFormatArgs(quantity.Unit, value, formatProvider, Enumerable.Empty()); return string.Format(formatProvider, formatForSignificantDigits, formatArgs); } } diff --git a/UnitsNet/QuantityValue.cs b/UnitsNet/QuantityValue.cs index d25d184e98..862e9133be 100644 --- a/UnitsNet/QuantityValue.cs +++ b/UnitsNet/QuantityValue.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Runtime.InteropServices; using System.Text; +using System.Globalization; using UnitsNet.InternalHelpers; namespace UnitsNet @@ -28,8 +29,13 @@ namespace UnitsNet /// [StructLayout(LayoutKind.Explicit)] [DebuggerDisplay("{GetDebugRepresentation()}")] - public readonly struct QuantityValue + public readonly struct QuantityValue : IFormattable, IEquatable, IComparable, IComparable { + /// + /// The value 0 + /// + public static readonly QuantityValue Zero = new QuantityValue(0, 0); + /// /// Value assigned when implicitly casting from all numeric types except , since /// has the greatest range. @@ -64,6 +70,25 @@ private QuantityValue(decimal val) : this() Type = UnderlyingDataType.Decimal; } + private QuantityValue(double value, decimal valueDecimal) : this() + { + if (valueDecimal != 0) + { + _decimalValue = valueDecimal; + Type = UnderlyingDataType.Decimal; + } + else + { + _doubleValue = value; + Type = UnderlyingDataType.Double; + } + } + + /// + /// Returns true if the underlying value is stored as a decimal + /// + public bool IsDecimal => Type == UnderlyingDataType.Decimal; + #region To QuantityValue // Prefer double for integer types, since most quantities use that type as of now and @@ -103,11 +128,141 @@ public static explicit operator double(QuantityValue number) /// Explicit cast from to . public static explicit operator decimal(QuantityValue number) => number.Type switch + { + UnderlyingDataType.Decimal => number._decimalValue, + UnderlyingDataType.Double => (decimal)number._doubleValue, + _ => throw new NotImplementedException() + }; + + #endregion + + #region Operators and Comparators + + /// + public override bool Equals(object other) + { + if (other is QuantityValue qv) { - UnderlyingDataType.Decimal => number._decimalValue, - UnderlyingDataType.Double => (decimal)number._doubleValue, - _ => throw new NotImplementedException() - }; + return Equals(qv); + } + + return false; + } + + /// + public override int GetHashCode() + { + if (IsDecimal) + { + return _decimalValue.GetHashCode(); + } + else + { + return _doubleValue.GetHashCode(); + } + } + + /// + /// Performs an equality comparison on two instances of . + /// Note that rounding might occur if the two values don't use the same base type. + /// + /// The value to compare to + /// True on exact equality, false otherwise + public bool Equals(QuantityValue other) + { + return CompareTo(other) == 0; + } + + /// Equality comparator + public static bool operator ==(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) == 0; + } + + /// Inequality comparator + public static bool operator !=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) != 0; + } + + /// + /// Greater-than operator + /// + public static bool operator >(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) > 0; + } + + /// + /// Less-than operator + /// + public static bool operator <(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) < 0; + } + + /// + /// Greater-than-or-equal operator + /// + public static bool operator >=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) >= 0; + } + + /// + /// Less-than-or-equal operator + /// + public static bool operator <=(QuantityValue a, QuantityValue b) + { + return a.CompareTo(b) <= 0; + } + + /// + public int CompareTo(QuantityValue other) + { + if (IsDecimal && other.IsDecimal) + { + return _decimalValue.CompareTo(other._decimalValue); + } + else if (IsDecimal) + { + return _decimalValue.CompareTo((decimal)other._doubleValue); + } + else if (other.IsDecimal) + { + return ((decimal)_doubleValue).CompareTo(other._decimalValue); + } + else + { + return _doubleValue.CompareTo(other._doubleValue); + } + } + + /// + public int CompareTo(object obj) + { + if (obj is null) throw new ArgumentNullException(nameof(obj)); + if (!(obj is QuantityValue other)) throw new ArgumentException("Expected type QuantityValue.", nameof(obj)); + + return CompareTo(other); + } + + /// + /// Returns the negated value of the operand + /// + /// Value to negate + /// -v + public static QuantityValue operator -(QuantityValue v) + { + if (v.IsDecimal) + { + return new QuantityValue(-v._decimalValue); + } + else + { + return new QuantityValue(-v._doubleValue); + } + } #endregion @@ -133,6 +288,44 @@ private string GetDebugRepresentation() return builder.ToString(); } + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// A standard numeric format string (must be valid for either double or decimal, depending on the base type) + /// The string representation + public string ToString(string format) + { + return ToString(format, CultureInfo.CurrentCulture); + } + + /// + /// Returns the string representation of the numeric value, formatted using the given standard numeric format string + /// + /// The culture to use + /// The string representation + public string ToString(IFormatProvider formatProvider) + { + return ToString(string.Empty, formatProvider); + } + + /// + /// Returns the string representation of the underlying value + /// + /// Standard format specifiers. Because the underlying value can be double or decimal, the meaning can vary + /// Culture specific settings + /// A string representation of the number + public string ToString(string format, IFormatProvider formatProvider) + { + if (IsDecimal) + { + return _decimalValue.ToString(format, formatProvider); + } + else + { + return _doubleValue.ToString(format, formatProvider); + } + } + /// /// Describes the underlying type of a . /// diff --git a/UnitsNet/UnitMath.cs b/UnitsNet/UnitMath.cs index d684c77e66..79707c0b71 100644 --- a/UnitsNet/UnitMath.cs +++ b/UnitsNet/UnitMath.cs @@ -17,7 +17,7 @@ public static class UnitMath /// A quantity with a value, such that 0 ≤ value ≤ . public static TQuantity Abs(this TQuantity value) where TQuantity : IQuantity { - return value.Value >= 0 ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); + return value.Value >= QuantityValue.Zero ? value : (TQuantity) Quantity.From(-value.Value, value.Unit); } /// Computes the sum of a sequence of values. @@ -197,5 +197,25 @@ public static TQuantity Average(this IEnumerable so { return source.Select(selector).Average(unitType); } + + /// + /// Explicitly create a instance from a double + /// + /// The input value + /// An instance of + public static QuantityValue ToQuantityValue(this double value) + { + return value; // Implicit cast + } + + /// + /// Explicitly create a instance from a decimal + /// + /// The input value + /// An instance of + public static QuantityValue ToQuantityValue(this decimal value) + { + return value; // Implicit cast + } } } From 9ff8142afb60f15d289930b62843fdeb1929676d Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 29 Nov 2022 23:13:55 +0100 Subject: [PATCH 65/66] Remove UnitsNet.Serialization.JsonNet.CompatibilityTests from build script --- Build/build-functions.psm1 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Build/build-functions.psm1 b/Build/build-functions.psm1 index c3f689d348..e5f71964bf 100644 --- a/Build/build-functions.psm1 +++ b/Build/build-functions.psm1 @@ -64,8 +64,7 @@ function Start-Tests { $projectPaths = @( "UnitsNet.Tests\UnitsNet.Tests.csproj", "UnitsNet.NumberExtensions.Tests\UnitsNet.NumberExtensions.Tests.csproj", - "UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.csproj", - "UnitsNet.Serialization.JsonNet.CompatibilityTests\UnitsNet.Serialization.JsonNet.CompatibilityTests.csproj" + "UnitsNet.Serialization.JsonNet.Tests\UnitsNet.Serialization.JsonNet.Tests.csproj" ) # Parent dir must exist before xunit tries to write files to it From 5dc048b8014931c62bb80949711a7e26189d847f Mon Sep 17 00:00:00 2001 From: Andreas Gullberg Larsen Date: Tue, 29 Nov 2022 23:14:35 +0100 Subject: [PATCH 66/66] cleanup --- azure-pipelines.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b9249e97e9..0c22d3de03 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -3,7 +3,7 @@ # Add steps that build, run tests, deploy, and more: # https://aka.ms/yaml -trigger: +trigger: branches: include: - master @@ -28,14 +28,13 @@ steps: fetchTags: false - task: InstallNanoMSBuildComponents@1 - displayName: Install .NET nanoFramework MSBuild components + displayName: Install .NET nanoFramework MSBuild components - task: PowerShell@2 displayName: 'Build, test, pack' inputs: filePath: 'Build/build.ps1' arguments: '-IncludeNanoFramework' -# arguments: '-IncludeWindowsRuntimeComponent -IncludeNanoFramework' failOnStderr: true showWarnings: true pwsh: true @@ -49,21 +48,21 @@ steps: targetType: 'inline' script: | Write-Host -Foreground Green "Downloading codecov binaries..." - - Invoke-WebRequest -Uri https://uploader.codecov.io/verification.gpg -OutFile codecov.asc + + Invoke-WebRequest -Uri https://uploader.codecov.io/verification.gpg -OutFile codecov.asc gpg.exe --import codecov.asc - + Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe -Outfile codecov.exe Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM -Outfile codecov.exe.SHA256SUM Invoke-WebRequest -Uri https://uploader.codecov.io/latest/windows/codecov.exe.SHA256SUM.sig -Outfile codecov.exe.SHA256SUM.sig - + gpg.exe --verify codecov.exe.SHA256SUM.sig codecov.exe.SHA256SUM If ($(Compare-Object -ReferenceObject $(($(certUtil -hashfile codecov.exe SHA256)[1], "codecov.exe") -join " ") -DifferenceObject $(Get-Content codecov.exe.SHA256SUM)).length -eq 0) { echo "SHASUM verified" } Else {exit 1} - + Write-Host -Foreground Green "Uploading to codecov..." - + .\codecov.exe --dir "Artifacts/Coverage" -t "$env:CODECOV_TOKEN" --build "$(Build.BuildNumber)" - + Write-Host -Foreground Green "✅ Uploaded to codecov." pwsh: true @@ -101,4 +100,4 @@ steps: packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/' nuGetFeedType: 'external' publishFeedCredentials: 'nuget.org (UnitsNet)' - allowPackageConflicts: true + allowPackageConflicts: true